Sfoglia il codice sorgente

二维码内容规则调整后的修改

zhuangdezheng 1 anno fa
parent
commit
58f9296a6c

+ 40 - 2
src/main/java/cn/ezhizao/project/business/product/controller/BizCarrierController.java

@@ -265,6 +265,43 @@ public class BizCarrierController extends BaseController {
 
     @Log(title = "检测箱号", businessType = BusinessType.SELECT)
     @PostMapping("/checkCarrier")
+    public AjaxResult checkCarrier(@RequestBody BizDaywork bizDaywork) {
+        // 检测新箱码是否已被使用
+        BizCarrier curCarrier = bizCarrierService.getOne(new QueryWrapper<BizCarrier>().eq("code", bizDaywork.getNewCarrierCode()));
+        BizCarrierCategory carrierCategory = bizCarrierService.getCarrierCategory(curCarrier.getCategoryId());
+        List<BizDayworkCarrier> dayworkCarrierList = bizDayworkCarrierService.query().eq("is_changed", 0).eq("carrier_code", bizDaywork.getNewCarrierCode()).list();
+
+        if (!dayworkCarrierList.isEmpty() && carrierCategory.getIsAllowMore() == 0) { // 通过类别判断
+            return error("该载具已被使用,未解绑无法使用");
+        }
+        if (bizDaywork.getDayworkCarriers().stream().anyMatch(v -> v.getCarrierCode().equals(bizDaywork.getNewCarrierCode()))) {
+            return error("已使用该载具");
+        }
+        BizCarrier carrier = new BizCarrier();
+        carrier.setId(bizDaywork.getNewCarrierId());
+        BizCarrier bizCarrier = bizCarrierService.getList(carrier).get(0);
+        List<BizCarrierReject> carrierRejects = bizCarrierRejectService.query().eq("carrier_code",bizDaywork.getNewCarrierCode()).orderByDesc("create_time").list();
+        if (!carrierRejects.isEmpty() && carrierRejects.get(0).getIsAbandoned() == 1) {
+            return error("该载具已被废弃");
+        }
+        // 检测新箱和旧箱是否是一个类型
+        if (bizDaywork.getDayworkCarriers().isEmpty()) {
+            return success(bizCarrier);
+        }
+        List<BizCarrier> oldCarriers = bizCarrierService.query().in("code", bizDaywork.getDayworkCarriers().isEmpty() ? Collections.singletonList(0L) : bizDaywork.getDayworkCarriers().stream().map(BizDayworkCarrier::getCarrierCode).collect(Collectors.toList())).list();
+        List<BizCarrierCategory> categories = bizCarrierCategoryService.query().in("id", oldCarriers.isEmpty() ? Collections.singletonList(0L) : oldCarriers.stream().map(BizCarrier::getCategoryId).collect(Collectors.toList())).list();
+        if (categories.stream().anyMatch(v -> !v.getIsAllowMore().equals(carrierCategory.getIsAllowMore()))) {
+            return error("该载具与已有载具类型不同。");
+        }
+        // 检测是否有一个铁箱不该扫一个新箱号
+        if (categories.stream().allMatch(v -> v.getIsAllowMore().equals(1))) {
+            return error("已有铁箱载具,不需要添加其他载具。");
+        }
+        return success(bizCarrier);
+    }
+
+    // 【checkCarrier 原有代码 备份】
+    /*
     public AjaxResult checkCarrier(@RequestBody BizDaywork bizDaywork) {
         // 检测新箱码是否已被使用
         BizCarrier curCarrier = bizCarrierService.getOne(new QueryWrapper<BizCarrier>().eq("id", bizDaywork.getNewCarrierId()));
@@ -273,7 +310,7 @@ public class BizCarrierController extends BaseController {
 //        if (dayworkCarrierList.size() > 0 && curCarrier.getIsAllowMore() == 0) { // 单独通过箱子的字段判断
 //            return error("该载具已被使用,未解绑无法使用");
 //        }
-        if (dayworkCarrierList.size() > 0 && carrierCategory.getIsAllowMore() == 0) { // 通过类别判断
+        if (!dayworkCarrierList.isEmpty() && carrierCategory.getIsAllowMore() == 0) { // 通过类别判断
             return error("该载具已被使用,未解绑无法使用");
         }
         if (bizDaywork.getDayworkCarriers().stream().anyMatch(v -> v.getCarrierId().equals(bizDaywork.getNewCarrierId()))) {
@@ -287,7 +324,7 @@ public class BizCarrierController extends BaseController {
             return error("该载具已被废弃");
         }
         // 检测新箱和旧箱是否是一个类型
-        if (bizDaywork.getDayworkCarriers().size() == 0) {
+        if (bizDaywork.getDayworkCarriers().isEmpty()) {
             return success(bizCarrier);
         }
         List<BizCarrier> oldCarriers = bizCarrierService.query().in("id", bizDaywork.getDayworkCarriers().isEmpty() ? Collections.singletonList(0L) : bizDaywork.getDayworkCarriers().stream().map(BizDayworkCarrier::getCarrierId).collect(Collectors.toList())).list();
@@ -301,4 +338,5 @@ public class BizCarrierController extends BaseController {
         }
         return success(bizCarrier);
     }
+     */
 }

+ 63 - 54
src/main/java/cn/ezhizao/project/business/product/controller/BizDayworkController.java

@@ -979,65 +979,74 @@ public class BizDayworkController extends BaseController {
     @GetMapping(value = "/showDaywork")
     @Log(title = "报工", businessType = BusinessType.SELECT)
     public AjaxResult getDayworkByCarrierId(BizDayworkItem bizDayworkItem) {
-        // 判断该批次是否已被领取
-        // 获取该批次最后一条的状态
-        List<BizDayworkCarrier> bizDayworkCarriers = bizDayworkCarrierService.query().eq("carrier_id", bizDayworkItem.getCarrierId()).eq("is_changed", 0).list();
-        if (bizDayworkCarriers.isEmpty()) {
-            throw new RuntimeException("该载具未绑定任何批次!");
-        }
+        try {
+            // 根据箱号,获取箱子
+            BizCarrier bizCarrier = bizCarrierService.query().eq("carrier_code", bizDayworkItem.getCarrierCode()).one();
+            if (bizCarrier == null) {
+                return error("该箱号不存在");
+            }
+            // 判断该批次是否已被领取
+            // 获取该批次最后一条的状态
+            List<BizDayworkCarrier> bizDayworkCarriers = bizDayworkCarrierService.query().eq("carrier_id", bizCarrier.getId()).eq("is_changed", 0).list();
+            if (bizDayworkCarriers.isEmpty()) {
+                throw new RuntimeException("该载具未绑定任何批次!");
+            }
 
-        List<BizDaywork> bizDayworks = bizDayworkService.query().in("id", bizDayworkCarriers.isEmpty()
-                        ?
-                        Collections.singletonList(0L)
-                        :
-                        bizDayworkCarriers.stream()
-                                .map(BizDayworkCarrier::getDayworkId)
-                                .collect(Collectors.toList())
-                )
-                .list();
+            List<BizDaywork> bizDayworks = bizDayworkService.query().in("id", bizDayworkCarriers.isEmpty()
+                            ?
+                            Collections.singletonList(0L)
+                            :
+                            bizDayworkCarriers.stream()
+                                    .map(BizDayworkCarrier::getDayworkId)
+                                    .collect(Collectors.toList())
+                    )
+                    .list();
 
-        List<BizDayworkItem> allBizDayworkItem = bizDayworkItemService.query().in("daywork_id", bizDayworks.isEmpty() ? Collections.singletonList(0L) : bizDayworks.stream().map(BizDaywork::getId).collect(Collectors.toList())).orderByDesc("create_time").list();
-        bizDayworks.forEach(l -> l.setDayworkItemList(allBizDayworkItem.stream().filter(v -> v.getDayworkId().equals(l.getId())).collect(Collectors.toList())));
-        List<BizDayworkItem> turnoverItems = new ArrayList<>();
-        for (BizDaywork bizDaywork : bizDayworks) {
-            if (bizDaywork.getDayworkItemList().get(0).getStatus().equals("4")
-                    || bizDaywork.getDayworkItemList().get(0).getStatus().equals("5")
-                    || bizDaywork.getDayworkItemList().get(0).getStatus().equals("7")) {
-                turnoverItems.add(bizDaywork.getDayworkItemList().get(0));
+            List<BizDayworkItem> allBizDayworkItem = bizDayworkItemService.query().in("daywork_id", bizDayworks.isEmpty() ? Collections.singletonList(0L) : bizDayworks.stream().map(BizDaywork::getId).collect(Collectors.toList())).orderByDesc("create_time").list();
+            bizDayworks.forEach(l -> l.setDayworkItemList(allBizDayworkItem.stream().filter(v -> v.getDayworkId().equals(l.getId())).collect(Collectors.toList())));
+            List<BizDayworkItem> turnoverItems = new ArrayList<>();
+            for (BizDaywork bizDaywork : bizDayworks) {
+                if (bizDaywork.getDayworkItemList().get(0).getStatus().equals("4")
+                        || bizDaywork.getDayworkItemList().get(0).getStatus().equals("5")
+                        || bizDaywork.getDayworkItemList().get(0).getStatus().equals("7")) {
+                    turnoverItems.add(bizDaywork.getDayworkItemList().get(0));
+                }
             }
-        }
-        if (!turnoverItems.isEmpty()) {
-            BizDayworkItem conditions = new BizDayworkItem();
-            conditions.setIds(turnoverItems.stream().map(BizDayworkItem::getId).collect(Collectors.toList()));
-            List<BizDayworkItem> items = bizDayworkItemService.getList(conditions);
-            //拿到生产计划id
-            List<Long> productionPlanDetailIds = items.stream().map(BizDayworkItem::getProductionPlanDetailId).collect(Collectors.toList());
-            List<BizProductionPlanDetail> bizProductionPlanDetails = bizProductionPlanDetailService.query().in("id", productionPlanDetailIds.isEmpty() ? Collections.singletonList(0L) : productionPlanDetailIds).list();
-            //查找批次id
-            List<Long> bizLotIds = bizDayworks.stream()
-                    .filter(v -> v.getIsWasteRecycling() == 1 || v.getIsAmend() == 1)
-                    .map(BizDaywork::getLotId).collect(Collectors.toList());
-            List<BizLotTechnologicalProcess> bizLotTechnologicalProcesses = bizLotTechnologicalProcessService.query().eq("is_stop", 0).in("lot_id", bizLotIds.isEmpty() ? Collections.singletonList(0L) : bizLotIds).list();
-            List<Long> LotTechnologicalProcessesIds = bizLotTechnologicalProcesses.stream().map(BizLotTechnologicalProcess::getId).collect(Collectors.toList());
-            List<BizLotTechnologicalProcessDetail> bizLotTechnologicalProcessDetails = bizLotTechnologicalProcessDetailService.query().in("lot_technological_process_id", LotTechnologicalProcessesIds.isEmpty() ? Collections.singletonList(0L) : LotTechnologicalProcessesIds).list();
-            for (BizDayworkItem item : items) {
-                //添加产品描述
-                item.setProductDescription(bizProductionPlanDetails.stream().filter(v -> v.getId().equals(item.getProductionPlanDetailId())).collect(Collectors.toList()).get(0).getProductDescription());
-                //如果不是正常批次,则工艺重新取
-                if (bizLotIds.contains(item.getLotId())) {
-                    List<BizLotTechnologicalProcessDetail> processDetail = bizLotTechnologicalProcessDetails.stream().filter(v -> v.getLotId().equals(item.getLotId())).collect(Collectors.toList());
-                    BizLotTechnologicalProcessDetail process = processDetail.stream().filter(v -> v.getProcessStepNumber().equals(item.getProcessStepNumber())).findFirst().orElse(null);
-                    BizTechnologicalProcessDetail technologicalProcessDetail = new BizTechnologicalProcessDetail();
-                    technologicalProcessDetail.setProcessAlias(process.getProcessAlias());
-                    technologicalProcessDetail.setProcessCode(process.getProcessCode());
-                    technologicalProcessDetail.setProductDescription(process.getProductDescription());
-                    technologicalProcessDetail.setProcessStepNumber(process.getProcessStepNumber());
-                    item.setTechnologicalProcessDetail(technologicalProcessDetail);
+            if (!turnoverItems.isEmpty()) {
+                BizDayworkItem conditions = new BizDayworkItem();
+                conditions.setIds(turnoverItems.stream().map(BizDayworkItem::getId).collect(Collectors.toList()));
+                List<BizDayworkItem> items = bizDayworkItemService.getList(conditions);
+                //拿到生产计划id
+                List<Long> productionPlanDetailIds = items.stream().map(BizDayworkItem::getProductionPlanDetailId).collect(Collectors.toList());
+                List<BizProductionPlanDetail> bizProductionPlanDetails = bizProductionPlanDetailService.query().in("id", productionPlanDetailIds.isEmpty() ? Collections.singletonList(0L) : productionPlanDetailIds).list();
+                //查找批次id
+                List<Long> bizLotIds = bizDayworks.stream()
+                        .filter(v -> v.getIsWasteRecycling() == 1 || v.getIsAmend() == 1)
+                        .map(BizDaywork::getLotId).collect(Collectors.toList());
+                List<BizLotTechnologicalProcess> bizLotTechnologicalProcesses = bizLotTechnologicalProcessService.query().eq("is_stop", 0).in("lot_id", bizLotIds.isEmpty() ? Collections.singletonList(0L) : bizLotIds).list();
+                List<Long> LotTechnologicalProcessesIds = bizLotTechnologicalProcesses.stream().map(BizLotTechnologicalProcess::getId).collect(Collectors.toList());
+                List<BizLotTechnologicalProcessDetail> bizLotTechnologicalProcessDetails = bizLotTechnologicalProcessDetailService.query().in("lot_technological_process_id", LotTechnologicalProcessesIds.isEmpty() ? Collections.singletonList(0L) : LotTechnologicalProcessesIds).list();
+                for (BizDayworkItem item : items) {
+                    //添加产品描述
+                    item.setProductDescription(bizProductionPlanDetails.stream().filter(v -> v.getId().equals(item.getProductionPlanDetailId())).collect(Collectors.toList()).get(0).getProductDescription());
+                    //如果不是正常批次,则工艺重新取
+                    if (bizLotIds.contains(item.getLotId())) {
+                        List<BizLotTechnologicalProcessDetail> processDetail = bizLotTechnologicalProcessDetails.stream().filter(v -> v.getLotId().equals(item.getLotId())).collect(Collectors.toList());
+                        BizLotTechnologicalProcessDetail process = processDetail.stream().filter(v -> v.getProcessStepNumber().equals(item.getProcessStepNumber())).findFirst().orElse(null);
+                        BizTechnologicalProcessDetail technologicalProcessDetail = new BizTechnologicalProcessDetail();
+                        technologicalProcessDetail.setProcessAlias(process.getProcessAlias());
+                        technologicalProcessDetail.setProcessCode(process.getProcessCode());
+                        technologicalProcessDetail.setProductDescription(process.getProductDescription());
+                        technologicalProcessDetail.setProcessStepNumber(process.getProcessStepNumber());
+                        item.setTechnologicalProcessDetail(technologicalProcessDetail);
+                    }
                 }
+                return success(items);
+            } else {
+                return success(turnoverItems);
             }
-            return success(items);
-        } else {
-            return success(turnoverItems);
+        } catch (Exception e) {
+            return error("箱子数据有误");
         }
     }
 

+ 21 - 0
src/main/java/cn/ezhizao/project/business/product/controller/BizDayworkItemController.java

@@ -380,6 +380,27 @@ public class BizDayworkItemController extends BaseController {
         return success(dayworkItemByCarriers);
     }
 
+    // 箱码规则修改后,二维码中存的是箱码。所以增加了这个方法
+    @GetMapping(value = "/getDayworkItemByCarrierCode")
+    public AjaxResult getDayworkItemByCarrierCode(BizDayworkItem bizDayworkItem) {
+        List<BizDayworkItem> dayworkItemByCarriers = bizDayworkItemService.getDayworkItemByCarrierCode(bizDayworkItem);
+
+        for (BizDayworkItem dayworkItemByCarrier : dayworkItemByCarriers) {
+            BizProcess byId = processService.getById(dayworkItemByCarrier.getProcessId());
+            dayworkItemByCarrier.setNextProcess(byId);
+
+            // 设置上一工段,周转用
+            List<BizDayworkItem> dayworkItemList = bizDayworkItemService.query().lt("status", 4).eq("lot_id", dayworkItemByCarrier.getLotId()).eq("process_id", dayworkItemByCarrier.getProcessId()).list();
+            for (int i = 0; i < dayworkItemList.size(); i++) {
+                if (dayworkItemList.get(i).getDeptName() != null && !"".equals(dayworkItemList.get(i).getDeptName())) {
+                    dayworkItemByCarrier.setPreDeptName(dayworkItemList.get(i).getDeptName());
+                    break;
+                }
+            }
+        }
+        return success(dayworkItemByCarriers);
+    }
+
     /**
      * 新增报工记录
      */

+ 0 - 2
src/main/java/cn/ezhizao/project/business/product/controller/BizProcessInspecionController.java

@@ -407,7 +407,6 @@ public class BizProcessInspecionController extends BaseController {
     /**
      * 根据箱号查询批次信息
      */
-//    @PreAuthorize("@ss.hasPermi('business:inspecion:list')")
     @PostMapping("/getLotOutsourcedInfo")
     public AjaxResult getLotOutsourcedInfo(@RequestBody BizDayworkCarrier dayworkCarrier) throws NoSuchFieldException, IllegalAccessException {
         List<String> processCodes = dayworkCarrier.getProcessCode();
@@ -482,7 +481,6 @@ public class BizProcessInspecionController extends BaseController {
         return success(lot);
     }
 
-
     /**
      * 根据箱号查询批次信息
      */

+ 120 - 0
src/main/java/cn/ezhizao/project/business/product/controller/BizQuickDayworkController.java

@@ -346,6 +346,126 @@ public class BizQuickDayworkController extends BaseController {
         }
     }
 
+    // 通过周转箱获取所有批次 和对应工序
+    @PostMapping("/getDayworkByCarrierCode")
+    @Log(title = "快速报工扫码载具", businessType = BusinessType.SELECT)
+    public AjaxResult getDayworkByCarrierCode(@RequestBody BizDayworkItem bizDayworkItem) throws NoSuchFieldException, IllegalAccessException {
+        // 获取快速报工的所有工段
+        SysDept dept = deptService.selectDeptById(bizDayworkItem.getDeptId());
+        List<BizDeptProcess> processes = deptProcessService.query().eq("dept_id", dept.getDeptId()).list();
+
+        List<BizDeptProcess> allProcesses = deptProcessService.query().list();
+        // 根据id获取资源组明细
+        List<BizProductionResourceGroupDetail> detailsList = bizProductionResourceGroupDetailService.query().eq("common_type", "person").eq("common_id", SecurityUtils.getLoginUser().getUser().getUserId()).list();
+
+        List<BizProductionResourceGroupSubPlan> groupSubPlans = bizProductionResourceGroupSubPlanService.query().in("resource_group_id", detailsList.isEmpty() ? Collections.singletonList("0") : detailsList.stream().map(BizProductionResourceGroupDetail::getProductionResourceGroupId).collect(Collectors.toList())).list();
+        if (groupSubPlans.isEmpty()) {
+            return success(new ArrayList<>());
+        }
+        BizProductionPlanDetail bizProductionPlanDetail = new BizProductionPlanDetail();
+        bizProductionPlanDetail.setPlanIds(groupSubPlans.stream().map(BizProductionResourceGroupSubPlan::getProductionPlanDetailId).collect(Collectors.toList()));
+        List<BizProductionPlanDetail> list = productionPlanDetailService.getInfo(bizProductionPlanDetail);
+        // 判断该批次是否已被领取
+        // 获取该批次最后一条的状态
+        List<BizDayworkCarrier> bizDayworkCarriers = bizDayworkCarrierService.query().eq("carrier_code", bizDayworkItem.getCarrierCode()).eq("is_changed", 0).list();
+        List<BizDaywork> bizDayworks = bizDayworkService.query()
+                .eq("dept_id", dept.getDeptId())
+                .in("id", bizDayworkCarriers.isEmpty() ? Collections.singletonList("0") : bizDayworkCarriers.stream().map(BizDayworkCarrier::getDayworkId).collect(Collectors.toList())).list();
+
+        List<BizDayworkItem> allBizDayworkItem = bizDayworkItemService.query().in("production_plan_detail_id", list.isEmpty() ? Collections.singletonList("0") : list.stream().map(BizProductionPlanDetail::getId).collect(Collectors.toList())).in("daywork_id", bizDayworks.isEmpty() ? Collections.singletonList("0") : bizDayworks.stream().map(BizDaywork::getId).collect(Collectors.toList())).orderByDesc("create_time").list();
+        bizDayworks.forEach(l -> l.setDayworkItemList(allBizDayworkItem.stream().filter(v -> v.getDayworkId().equals(l.getId())).collect(Collectors.toList())));
+
+        List<BizDayworkItem> turnoverItems = new ArrayList<>();
+        List<BizLotTechnologicalProcess> ltp = bizLotTechnologicalProcessService.query().eq("is_stop", 0).in("lot_id", bizDayworks.isEmpty() ? Collections.singletonList(0L) : bizDayworks.stream().map(BizDaywork::getLotId).collect(Collectors.toList())).list();
+        List<BizLotTechnologicalProcessDetail> ltpd = bizLotTechnologicalProcessDetailService.query().in("lot_technological_process_id", ltp.isEmpty() ? Collections.singletonList(0L) : ltp.stream().map(BizLotTechnologicalProcess::getId).collect(Collectors.toList())).list();
+        for (BizDaywork bizDaywork : bizDayworks) {
+            if (!bizDaywork.getDayworkItemList().isEmpty() && (bizDaywork.getDayworkItemList().get(0).getStatus().equals("4") || bizDaywork.getDayworkItemList().get(0).getStatus().equals("7") || bizDaywork.getDayworkItemList().get(0).getStatus().equals("5"))) {
+                turnoverItems.add(bizDaywork.getDayworkItemList().get(0));
+            }
+        }
+        Map<String, Object> result = new HashMap<>();
+        if (turnoverItems.isEmpty()) {
+            result.put("items", turnoverItems);
+            return success(result);
+        } else {
+            BizDayworkItem conditions = new BizDayworkItem();
+            conditions.setIds(turnoverItems.stream().map(BizDayworkItem::getId).collect(Collectors.toList()));
+            List<BizDayworkItem> items = bizDayworkItemService.getList(conditions);
+            // 对应产品的工段
+            SysDept deptConditions = new SysDept();
+            setTenantId(deptConditions);
+            deptConditions.setIsWorkSection(1);
+            List<SysDept> depts = deptService.selectDeptList(deptConditions);
+            // 对应工段的车间
+            List<BizWorkshop> workshops = workshopService.query().list();
+            AtomicBoolean hasNoProcess = new AtomicBoolean(false);
+            items.forEach(l -> {
+                BizProductionPlanDetail productionPlanDetail = list.stream().filter(v -> v.getId().equals(l.getProductionPlanDetailId())).findFirst().orElse(null);
+                l.setProductionPlanNo(productionPlanDetail != null ? productionPlanDetail.getProductionPlanNo() : null);
+                if (l.getDaywork().getIsAmend().equals(1) || l.getDaywork().getIsWasteRecycling().equals(1)) {
+                    BizLotTechnologicalProcess p = ltp.stream().filter(v -> v.getLotId().equals(l.getDaywork().getLotId())).findFirst().orElse(new BizLotTechnologicalProcess());
+                    List<BizLotTechnologicalProcessDetail> processDetails = ltpd.stream().filter(t -> t.getLotTechnologicalProcessId().equals(p.getId())).collect(Collectors.toList());
+                    if (processDetails.stream().filter(v -> v.getProcessStepNumber().compareTo(l.getProcessStepNumber()) > 0).noneMatch(v -> processes.stream().anyMatch(e -> e.getProcessId().equals(v.getProcessId())))) {
+                        hasNoProcess.set(true);
+                    } else {
+                        l.setProcess(processDetails.stream().filter(v -> v.getProcessStepNumber().compareTo(l.getProcessStepNumber()) > 0).filter(v -> processes.stream().anyMatch(e -> e.getProcessId().equals(v.getProcessId()))).map(BizProcess::new).findFirst().orElse(new BizProcess()));
+                        l.setProcessSequence(processDetails.stream().map(BizProcess::new).collect(Collectors.toList()));
+                        l.setNextProcess(l.getProcessSequence().stream().filter(e -> e.getProcessStepNumber().compareTo(l.getProcess().getProcessStepNumber()) > 0).min(Comparator.comparing(BizProcess::getProcessStepNumber)).orElse(null));
+                        l.setNextProcesses(l.getProcess() != null ? processDetails.stream().sorted(Comparator.comparing(BizLotTechnologicalProcessDetail::getProcessStepNumber)).filter(v -> v.getProcessStepNumber().compareTo(l.getProcess().getProcessStepNumber()) > 0).map(BizProcess::new).collect(Collectors.toList()) : new ArrayList<>());
+                        l.setWorkshopId(workshops.stream().filter(v -> v.getId().equals(l.getWorkshopId())).findFirst().orElse(new BizWorkshop()).getId());
+                        List<SysDept> nextDept = depts.stream().filter(
+                                e -> allProcesses.stream().filter(
+                                        v -> l.getNextProcesses().stream().anyMatch(
+                                                n -> v.getProcessId().equals(n.getId()))).anyMatch(
+                                        v -> e.getDeptId().equals(v.getDeptId()))
+                        ).collect(Collectors.toList());
+
+                        workshops.forEach(e -> {
+                            if (e.getDepts() == null) {
+                                e.setDepts(new ArrayList<>());
+                            }
+                            nextDept.forEach(v -> {
+                                if (v.getWorkshopId().equals(e.getId()) && e.getDepts().stream().noneMatch(n -> v.getDeptId().equals(n.getDeptId()))) {
+                                    e.getDepts().add(v);
+                                }
+                            });
+                        });
+                    }
+
+                } else {
+                    BizProcess process = l.getProcessSequence().stream().filter(v -> v.getTechnologicalProcessDetailId().equals(l.getTechnologicalProcessDetailId())).findFirst().orElse(new BizProcess());
+                    if (l.getProcessSequence().stream().filter(v -> v.getProcessStepNumber().compareTo(l.getProcessStepNumber()) > 0).noneMatch(v -> processes.stream().anyMatch(e -> e.getProcessId().equals(v.getId())))) {
+                        hasNoProcess.set(true);
+                    } else {
+                        l.setProcess(l.getProcessSequence().stream().sorted(Comparator.comparing(BizProcess::getProcessStepNumber)).filter(v -> v.getProcessStepNumber().compareTo(process.getProcessStepNumber()) > 0).filter(v -> processes.stream().anyMatch(e -> e.getProcessId().equals(v.getId()))).findFirst().orElse(null));
+                        l.setNextProcesses(l.getProcess() != null ? l.getProcessSequence().stream().sorted(Comparator.comparing(BizProcess::getProcessStepNumber)).filter(v -> v.getProcessStepNumber().compareTo(l.getProcess().getProcessStepNumber()) > 0).collect(Collectors.toList()) : new ArrayList<>());
+                        l.setNextProcess(l.getNextProcesses().isEmpty() ? null : l.getNextProcesses().get(0));
+
+                        l.setWorkshopId(workshops.stream().filter(v -> v.getId().equals(l.getWorkshopId())).findFirst().orElse(new BizWorkshop()).getId());
+                        List<SysDept> nextDept = depts.stream().filter(e -> allProcesses.stream().filter(v -> l.getNextProcesses().stream().anyMatch(n -> v.getProcessId().equals(n.getId()))).anyMatch(v -> e.getDeptId().equals(v.getDeptId()))
+                        ).collect(Collectors.toList());
+                        workshops.forEach(e -> {
+                            if (e.getDepts() == null) {
+                                e.setDepts(new ArrayList<>());
+                            }
+                            nextDept.forEach(v -> {
+                                if (v.getWorkshopId().equals(e.getId()) && e.getDepts().stream().noneMatch(n -> v.getDeptId().equals(n.getDeptId()))) {
+                                    e.getDepts().add(v);
+                                }
+                            });
+                        });
+                    }
+                }
+            });
+            if (hasNoProcess.get()) {
+                return error("该工段没有可报工工序");
+            }
+            result.put("items", items);
+            result.put("workShops", workshops.stream().filter(v -> !v.getDepts().isEmpty()).collect(Collectors.toList()));
+            return success(result);
+        }
+    }
+
     // 批量开始报工
     @PostMapping("/reportDaywork")
     @Log(title = "报工", businessType = BusinessType.INSERT)

+ 3 - 0
src/main/java/cn/ezhizao/project/business/product/domain/BizDaywork.java

@@ -176,6 +176,9 @@ public class BizDaywork extends BaseEntity
     @TableField(exist = false)
     private Long newCarrierId;
 
+    @TableField(exist = false)
+    private String newCarrierCode;
+
     @TableField(exist = false)
     private String processStepNumber;
 

+ 3 - 4
src/main/java/cn/ezhizao/project/business/product/domain/BizDayworkItem.java

@@ -106,6 +106,9 @@ public class BizDayworkItem extends BaseEntity
 
     @TableField(exist = false)
     private Long carrierId;
+
+    @TableField(exist = false)
+    private String carrierCode;
     /** 员工编码 */
     @Excel(name = "员工编码")
     @ApiModelProperty(value = "员工编码")
@@ -210,10 +213,6 @@ public class BizDayworkItem extends BaseEntity
     @TableField(exist = false)
     private List<BizDayworkItemCollaboration>  collaborationList;
 
-    @TableField(exist = false)
-    private String carrierCode;
-
-
     @TableField(exist = false)
     private String nextDeptProcess;
 

+ 6 - 0
src/main/java/cn/ezhizao/project/business/product/mapper/BizDayworkItemMapper.java

@@ -30,6 +30,12 @@ public interface BizDayworkItemMapper extends BaseMapper<BizDayworkItem>
      */
     public List<BizDayworkItem> getDayworkItemByCarrier(BizDayworkItem bizDayworkItem);
 
+    /**
+     * 根据载具code查询待周转列表
+     * @param bizDayworkItem
+     * @return
+     */
+    public List<BizDayworkItem> getDayworkItemByCarrierCode(BizDayworkItem bizDayworkItem);
 
 
     /**

+ 5 - 0
src/main/java/cn/ezhizao/project/business/product/service/IBizDayworkItemService.java

@@ -34,6 +34,11 @@ public interface IBizDayworkItemService extends IService<BizDayworkItem>
      */
     public List<BizDayworkItem> getDayworkItemByCarrier(BizDayworkItem bizDayworkItem);
 
+    /**
+     * 根据载具code查询待周转列表
+     */
+    public List<BizDayworkItem> getDayworkItemByCarrierCode(BizDayworkItem bizDayworkItem);
+
     /**
      * 查询未周转的item
      * @param bizDayworkItem

+ 5 - 0
src/main/java/cn/ezhizao/project/business/product/service/impl/BizDayworkItemServiceImpl.java

@@ -47,6 +47,11 @@ public class BizDayworkItemServiceImpl  extends ServiceImpl<BizDayworkItemMapper
         return bizDayworkItemMapper.getDayworkItemByCarrier(bizDayworkItem);
     }
 
+    @Override
+    public List<BizDayworkItem> getDayworkItemByCarrierCode(BizDayworkItem bizDayworkItem) {
+        return bizDayworkItemMapper.getDayworkItemByCarrierCode(bizDayworkItem);
+    }
+
     @Override
     public List<BizDayworkItem> getUndoneItem(BizDayworkItem bizDayworkItem) {
         return bizDayworkItemMapper.getUndoneItem(bizDayworkItem);

+ 62 - 0
src/main/java/cn/ezhizao/project/business/switchDept/controller/SwitchController.java

@@ -54,6 +54,7 @@ public class SwitchController extends BaseController {
     @Resource
     IBizProductionResourceGroupService bizProductionResourceGroupService;
 
+    /*
     @PostMapping("/getDayworkByCarrierCode")
     public AjaxResult getDayworkByCarrierCode(@RequestBody BizDayworkItem bizDayworkItem) {
         List<BizDayworkCarrier> bizDayworkCarriers = dayworkCarrierService.query().eq("carrier_id", bizDayworkItem.getCarrierId()).eq("is_changed", 0).list();
@@ -112,6 +113,67 @@ public class SwitchController extends BaseController {
             return success(items);
         }
     }
+    */
+
+    @PostMapping("/getDayworkByCarrierCode")
+    public AjaxResult getDayworkByCarrierCode(@RequestBody BizDayworkItem bizDayworkItem) {
+        List<BizDayworkCarrier> bizDayworkCarriers = dayworkCarrierService.query().eq("carrier_code", bizDayworkItem.getCarrierCode()).eq("is_changed", 0).list();
+        if (bizDayworkCarriers.isEmpty()) {
+            throw new RuntimeException("该载具未绑定任何批次!");
+        }
+        List<BizDaywork> bizDayworks = dayworkService.query().in("id", bizDayworkCarriers.isEmpty()
+                        ?
+                        Collections.singletonList(0L)
+                        :
+                        bizDayworkCarriers.stream()
+                                .map(BizDayworkCarrier::getDayworkId)
+                                .collect(Collectors.toList())
+                )
+                .list();
+        // 判断是否是在当前工段
+        bizDayworks = bizDayworks.stream().filter(v -> v.getDeptId().equals(bizDayworkItem.getDeptId())).collect(Collectors.toList());
+        List<BizDayworkItem> allBizDayworkItem = dayworkItemService.query().in("daywork_id", bizDayworks.isEmpty() ? Collections.singletonList(0L) : bizDayworks.stream().map(BizDaywork::getId).collect(Collectors.toList())).orderByDesc("create_time").list();
+        bizDayworks.forEach(l -> l.setDayworkItemList(allBizDayworkItem.stream().filter(v -> v.getDayworkId().equals(l.getId())).collect(Collectors.toList())));
+        bizDayworks.forEach(l -> l.setDayworkItemList(allBizDayworkItem.stream().filter(v -> v.getDayworkId().equals(l.getId())).collect(Collectors.toList())));
+        List<BizDayworkItem> turnoverItems = new ArrayList<>();
+        for (BizDaywork bizDaywork : bizDayworks) {
+            if (bizDaywork.getDayworkItemList().get(0).getStatus().equals("4")
+                    || bizDaywork.getDayworkItemList().get(0).getStatus().equals("5")
+                    || bizDaywork.getDayworkItemList().get(0).getStatus().equals("7")) {
+                turnoverItems.add(bizDaywork.getDayworkItemList().get(0));
+            }
+        }
+        if (turnoverItems.isEmpty()) {
+            return success(turnoverItems);
+        } else {
+            BizDayworkItem conditions = new BizDayworkItem();
+            conditions.setIds(turnoverItems.stream().map(BizDayworkItem::getId).collect(Collectors.toList()));
+            List<BizDayworkItem> items = dayworkItemService.getList(conditions);
+            //拿到生产计划id
+            List<Long> productionPlanDetailIds = items.stream().map(BizDayworkItem::getProductionPlanDetailId).collect(Collectors.toList());
+            List<BizProductionPlanDetail> bizProductionPlanDetails = productionPlanDetailService.query().in("id", productionPlanDetailIds.isEmpty() ? Collections.singletonList(0L) : productionPlanDetailIds).list();
+            //查找批次id
+            List<Long> LotTechnologicalProcessesIds = items.stream().filter(v -> v.getDaywork().getIsAmend().equals(1) || v.getDaywork().getIsWasteRecycling().equals(1)).map(BizDayworkItem::getTechnologicalProcessId).collect(Collectors.toList());
+            List<BizLotTechnologicalProcessDetail> bizLotTechnologicalProcessDetails = lotTechnologicalProcessDetailService.query().in("lot_technological_process_id", LotTechnologicalProcessesIds.isEmpty() ? Collections.singletonList(0L) : LotTechnologicalProcessesIds).list();
+            for (BizDayworkItem item : items) {
+                //添加产品描述
+                item.setProductDescription(bizProductionPlanDetails.stream().filter(v -> v.getId().equals(item.getProductionPlanDetailId())).collect(Collectors.toList()).get(0).getProductDescription());
+                //如果不是正常批次,则工艺重新取
+                if (item.getDaywork().getIsAmend().equals(1) || item.getDaywork().getIsWasteRecycling().equals(1)) {
+                    List<BizLotTechnologicalProcessDetail> processDetail = bizLotTechnologicalProcessDetails.stream().filter(v -> v.getLotId().equals(item.getLotId())).collect(Collectors.toList());
+                    BizLotTechnologicalProcessDetail process = processDetail.stream().filter(v -> v.getProcessStepNumber().equals(item.getProcessStepNumber())).findFirst().orElse(null);
+                    BizTechnologicalProcessDetail technologicalProcessDetail = new BizTechnologicalProcessDetail();
+                    technologicalProcessDetail.setProcessAlias(process.getProcessAlias());
+                    technologicalProcessDetail.setProcessCode(process.getProcessCode());
+                    technologicalProcessDetail.setProductDescription(process.getProductDescription());
+                    technologicalProcessDetail.setProcessStepNumber(process.getProcessStepNumber());
+                    item.setTechnologicalProcessDetail(technologicalProcessDetail);
+                }
+            }
+            return success(items);
+        }
+    }
+
 
     @GetMapping("/listAllDepts")
     public AjaxResult listAllDepts() {

+ 11 - 0
src/main/resources/mybatis/business/product/BizDayworkItemMapper.xml

@@ -145,6 +145,17 @@
         order by create_time desc
     </select>
 
+    <select id="getDayworkItemByCarrierCode" resultMap="BizDayworkItemResult">
+        select *
+        from biz_daywork_item
+        where deleted = 0
+          and status = #{status}
+          and daywork_id in (select daywork_id
+                             from biz_daywork_carrier
+                             where deleted = 0 and is_changed = 0 and carrier_code = #{carrierCode})
+        order by create_time desc
+    </select>
+
     <select id="getUnfinishedDayworkItemByUser" resultMap="BizDayworkItemResult">
         select t1.* from biz_daywork_item t1
         where t1.deleted = 0 and t1.status = '1' and t1.is_quick = 1 and t1.user_id = #{userId}