|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.management.platform.entity.*;
|
|
import com.management.platform.entity.*;
|
|
@@ -210,6 +211,12 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
queryWrapper.in(Plan::getId,planIds);
|
|
queryWrapper.in(Plan::getId,planIds);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if (user.getDepartmentId()!=null) {
|
|
|
|
+ List<Integer> planIds = planProcedureTotalService.selectPlanIdsWithTransfer(user.getDepartmentId());
|
|
|
|
+ if(!planIds.isEmpty()){
|
|
|
|
+ queryWrapper.or().in(Plan::getId,planIds);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
queryWrapper.orderByDesc(Plan::getCreateTime).orderByDesc(Plan::getStartDate);
|
|
queryWrapper.orderByDesc(Plan::getCreateTime).orderByDesc(Plan::getStartDate);
|
|
IPage<Plan> planIPage = planMapper.selectPage(new Page<>(pageIndex, pageSize), queryWrapper);
|
|
IPage<Plan> planIPage = planMapper.selectPage(new Page<>(pageIndex, pageSize), queryWrapper);
|
|
List<Plan> records = planIPage.getRecords();
|
|
List<Plan> records = planIPage.getRecords();
|
|
@@ -1209,6 +1216,124 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg planDetailWithStation(Integer id, Integer type, Integer stationType,HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg msg=new HttpRespMsg();
|
|
|
|
+ Plan plan = planMapper.selectOne(new QueryWrapper<Plan>().eq("id", id));
|
|
|
|
+ User userSelect = userMapper.selectById(request.getHeader("token"));
|
|
|
|
+ Integer companyId = userSelect.getCompanyId();
|
|
|
|
+ String userId = request.getHeader("token");
|
|
|
|
+ if(plan!=null){
|
|
|
|
+ switch (type){
|
|
|
|
+ case 0:
|
|
|
|
+ List<PlanProcedureTotal> procedureTotals=new ArrayList<>();
|
|
|
|
+ //看自己工位的
|
|
|
|
+ if (stationType==0){
|
|
|
|
+ procedureTotals = planProcedureTotalService.list(
|
|
|
|
+ new LambdaQueryWrapper<PlanProcedureTotal>()
|
|
|
|
+ .eq(PlanProcedureTotal::getPlanId, plan.getId())
|
|
|
|
+ .and(wrapper -> wrapper.eq(PlanProcedureTotal::getIsTransfer, 0)
|
|
|
|
+ .or()
|
|
|
|
+ .eq(PlanProcedureTotal::getIsTransfer, 1)
|
|
|
|
+ .eq(PlanProcedureTotal::getStationId, userSelect.getDepartmentId())
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ //看其他工位的
|
|
|
|
+ else if (stationType==1){
|
|
|
|
+ procedureTotals = planProcedureTotalService.list(new QueryWrapper<PlanProcedureTotal>().eq("plan_id", plan.getId()).eq("is_transfer", 1)
|
|
|
|
+ .ne("station_id", userSelect.getDepartmentId()));
|
|
|
|
+ }
|
|
|
|
+ //全部
|
|
|
|
+ else {
|
|
|
|
+ procedureTotals = planProcedureTotalService.list(new QueryWrapper<PlanProcedureTotal>().eq("plan_id", plan.getId()));
|
|
|
|
+ }
|
|
|
|
+ List<Integer> procedureIds = procedureTotals.stream().map(PlanProcedureTotal::getProdProcedureId).distinct().collect(Collectors.toList());
|
|
|
|
+ procedureIds.add(-1);
|
|
|
|
+ List<ProdProcedure> prodProcedureList = prodProcedureMapper.selectList(new QueryWrapper<ProdProcedure>().in("id",procedureIds));
|
|
|
|
+ List<Integer> ids = procedureTotals.stream().map(PlanProcedureTotal::getId).collect(Collectors.toList());
|
|
|
|
+ ids.add(-1);
|
|
|
|
+ List<ProdProcedureTeam> procedureTeams = prodProcedureTeamService.list(new QueryWrapper<ProdProcedureTeam>().in("plan_procedure_id", ids));
|
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
|
|
|
|
+ procedureTotals.forEach(ps->{
|
|
|
|
+ Optional<ProdProcedure> first = prodProcedureList.stream().filter(pl -> pl.getId().equals(ps.getProdProcedureId())).findFirst();
|
|
|
|
+ if(first.isPresent()){
|
|
|
|
+ ps.setProdProcedure(first.get());
|
|
|
|
+ }
|
|
|
|
+ if(procedureTeams.size()>0){
|
|
|
|
+ List<ProdProcedureTeam> procedureTeamList = procedureTeams.stream().filter(pt -> pt.getPlanProcedureId().equals(ps.getId())).collect(Collectors.toList());
|
|
|
|
+ ps.setTeamIds(procedureTeamList.stream().map(ProdProcedureTeam::getUserId).distinct().collect(Collectors.joining(",")));
|
|
|
|
+ procedureTeamList.forEach(pt->{
|
|
|
|
+ Optional<User> user = userList.stream().filter(ul -> ul.getId().equals(pt.getUserId())).findFirst();
|
|
|
|
+ if(user.isPresent()){
|
|
|
|
+ pt.setUser(user.get());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ ps.setProdProcedureTeamList(procedureTeamList);
|
|
|
|
+ if(procedureTeamList.stream().anyMatch(pl->pl.getUserId()!=null&&pl.getStatus()==0&&pl.getUserId().equals(userId))){
|
|
|
|
+ ps.setCanReceive(true);
|
|
|
|
+ }
|
|
|
|
+ if(!StringUtils.isEmpty(ps.getTeamIds())){
|
|
|
|
+ String userNames = userList.stream().filter(ul -> Arrays.asList(ps.getTeamIds().split(",")).contains(ul.getId())).collect(Collectors.toList())
|
|
|
|
+ .stream().map(User::getName).collect(Collectors.joining(","));
|
|
|
|
+ ps.setTeamNames(userNames);
|
|
|
|
+ }
|
|
|
|
+ if(procedureTeamList.stream().anyMatch(pl->pl.getProgress()>0&&pl.getStatus()==4)){
|
|
|
|
+ ps.setNeedAddCircle(true);
|
|
|
|
+ }
|
|
|
|
+ if(procedureTeamList.stream().anyMatch(pl->pl.getUserId()!=null&&pl.getUserId().equals(userId)&&pl.getStatus()==1)){
|
|
|
|
+ ps.setCancellationReceive(true);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ msg.setData(procedureTotals);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg planDetailTransStation(String ids, Integer stationId, HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ if (StringUtils.isEmpty(ids)) {
|
|
|
|
+ msg.setError("请传递关键信息");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ String[] strings = ids.split(",");
|
|
|
|
+ List<String> collect = Arrays.stream(strings).collect(Collectors.toList());
|
|
|
|
+ List<PlanProcedureTotal> totalList = planProcedureTotalService.list(new QueryWrapper<PlanProcedureTotal>().in("id", collect));
|
|
|
|
+ boolean b = totalList.stream().anyMatch(a -> a.getIsTransfer() == 1);
|
|
|
|
+ if (b){
|
|
|
|
+ msg.setError("存在工序已被转派,不能再次转派");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ boolean update = planProcedureTotalService.update(new UpdateWrapper<PlanProcedureTotal>().set("station_id", stationId).set("isTransfer", 1).in("id", collect));
|
|
|
|
+ //todo 发送改派通知
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg planDetailCancelTransfer(String ids, HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ if (StringUtils.isEmpty(ids)) {
|
|
|
|
+ msg.setError("请传递关键信息");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ String[] strings = ids.split(",");
|
|
|
|
+ List<String> collect = Arrays.stream(strings).collect(Collectors.toList());
|
|
|
|
+ List<PlanProcedureTotal> totalList = planProcedureTotalService.list(new QueryWrapper<PlanProcedureTotal>().in("id", collect));
|
|
|
|
+ boolean b = totalList.stream().anyMatch(a -> a.getIsTransfer() == 1);
|
|
|
|
+ if (b){
|
|
|
|
+ msg.setError("存在工序未被转派,不能取消转派");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ boolean update = planProcedureTotalService.update(new UpdateWrapper<PlanProcedureTotal>().set("station_id",null).set("isTransfer", 0).in("id", collect));
|
|
|
|
+ //todo 发送改派通知
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public HttpRespMsg deletePeople(Integer id) {
|
|
public HttpRespMsg deletePeople(Integer id) {
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
HttpRespMsg msg=new HttpRespMsg();
|