guoyujia 9 mesi fa
parent
commit
6122e3ba0d

+ 93 - 9
src/main/java/cn/ezhizao/project/business/product/controller/BizProcessInspecionController.java

@@ -2700,6 +2700,90 @@ public TableDataInfo examineList(@RequestBody BizProcessInspecion bizProcessInsp
         lot.setPudName(item.getProdNum() == 0 ? lot.getProductionQuantity() : item.getProdNum());
         return success(lot);
     }
+    //巡检专用
+    @PostMapping("/getPatrolLotInfo")
+    public AjaxResult getPatrolLotInfo(@RequestBody BizDayworkCarrier dayworkCarrier) throws NoSuchFieldException, IllegalAccessException {
+        //根据箱号查询当前绑定信息
+        dayworkCarrier = bizDayworkCarrierService.getByCarrierCode(dayworkCarrier);
+        if (dayworkCarrier == null) {
+            return error("该箱号未绑定任何批次");
+        }
+
+        //获取报工信息
+        BizDayworkCarrier finalDayworkCarrier = dayworkCarrier;
+        List<BizDayworkItem> itemList = bizDayworkItemService.getByDayworkId(dayworkCarrier.getDayworkId()).stream().filter(item ->!item.getStatus().equals("0") && item.getDeptId().equals(finalDayworkCarrier.getDeptId())).collect(Collectors.toList());
+        if (itemList.size() == 0) {
+            return error("该批次当前工段没有报工");
+        }
+        BizDayworkItem item = itemList.get(0);
+        List<BizDayworkItem> latestList = itemList.stream().filter(v -> v.getProcessStepNumber().equals(item.getProcessStepNumber())).collect(Collectors.toList());
+
+        BizProductionPlanDetail productionPlanDetail = productionPlanDetailService.getById(item.getProductionPlanDetailId());
+        BizProduct product = productService.getById(productionPlanDetail.getProductId());
+        SysUser user = sysUserService.selectUserById(product.getTechnicianId());
+        if (user != null) {
+            item.setTechnicianName(user.getNickName());
+            item.setTechnicianId(user.getUserId());
+        } else {
+            item.setTechnicianName("");
+            item.setTechnicianId(0L);
+        }
+
+        //查询是否为正常批次
+        BizLot lot = new BizLot();
+        lot.setId(item.getLotId());
+        lot = bizLotService.getAllList(lot).get(0);
+        if (lot.getIsWaste() == 1) {
+            return error("该批次已批废");
+        }
+        if (lot.getIsAmend() == 1 || lot.getIsWasteRecycling() == 1) {
+            BizLotTechnologicalProcessDetail process = bizLotTechnologicalProcessDetailService.getById(item.getTechnologicalProcessDetailId());
+            lot.setProcessAlias(process.getProcessAlias());
+            lot.setProcessCode(process.getProcessCode());
+            lot.setProcessId(process.getProcessId());
+        } else {
+            BizTechnologicalProcessDetail process = bizTechnologicalProcessDetailService.getById(item.getTechnologicalProcessDetailId());
+            lot.setProcessAlias(process.getProcessAlias());
+            lot.setProcessCode(process.getProcessCode());
+            lot.setProcessId(process.getProcessId());
+        }
+        lot.setAllCarrierName(item.getCarrierName());
+        if(latestList.stream().map(BizDayworkItem::getStatus).collect(Collectors.toList()).contains("0")){
+            if(!latestList.stream().map(BizDayworkItem::getStatus).collect(Collectors.toList()).contains("1")&&!latestList.stream().map(BizDayworkItem::getStatus).collect(Collectors.toList()).contains("2")){
+                return error("该批次未开始加工");
+            }
+        }
+        if(latestList.stream().map(BizDayworkItem::getStatus).collect(Collectors.toList()).contains("3")) {
+            return error("当前批次,工序已完成");
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Date date = new Date();
+        String startTime = simpleDateFormat.format(date) + " 00:00:00";
+        String endTime = simpleDateFormat.format(date) + " 23:59:59";
+        List<BizDayworkItem> collect = latestList.stream().filter(v -> v.getStatus().equals("1") || v.getStatus().equals("2")).collect(Collectors.toList());
+        lot.setDayworkItemList(collect.stream().filter(info -> {
+            try {
+//                if (info.getEndTime() == null) {
+//                    // 如果为 null,可以选择返回 false(排除该项),或者根据需要处理
+//                    return true;
+//                }
+                // 确保 info 的状态为 "1" 或 "2",且结束时间不晚于当天结束时间
+                // 并且结束时间不早于当天开始时间
+                return info.getStartTime().before(sdf.parse(endTime))
+                        && info.getStartTime().after(sdf.parse(startTime));
+            } catch (ParseException e) {
+                throw new RuntimeException(e);
+            }
+        }).collect(Collectors.toList()));
+        lot.setDeptName(item.getDeptName());
+        lot.setDayworkItemId(item.getId());
+        lot.setProcessStepNumber(item.getProcessStepNumber());
+        lot.setCarrierCode(dayworkCarrier.getCarrierCode());
+        lot.setCarrierId(dayworkCarrier.getCarrierId());
+        lot.setPudName(item.getProdNum() == 0 ? lot.getProductionQuantity() : item.getProdNum());
+        return success(lot);
+    }
     //交检专用
     @PostMapping("/getDeliveryLotInfo")
     public AjaxResult getDeliveryLotInfo(@RequestBody BizDayworkCarrier dayworkCarrier) throws NoSuchFieldException, IllegalAccessException {
@@ -2769,7 +2853,7 @@ public TableDataInfo examineList(@RequestBody BizProcessInspecion bizProcessInsp
         lot.setPudName(item.getProdNum() == 0 ? lot.getProductionQuantity() : item.getProdNum());
         return success(lot);
     }
-
+    //首件检专用
     @PostMapping("/getLotInfoByFirstInspection")
     public AjaxResult getLotInfoByFirstInspection(@RequestBody BizDayworkCarrier dayworkCarrier) throws NoSuchFieldException, IllegalAccessException {
         //获取报工信息
@@ -2827,14 +2911,14 @@ public TableDataInfo examineList(@RequestBody BizProcessInspecion bizProcessInsp
         List<BizDayworkItem> collect = latestList.stream().filter(v -> v.getStatus().equals("1") || v.getStatus().equals("2")).collect(Collectors.toList());
         lot.setDayworkItemList(collect.stream().filter(info -> {
             try {
-                if (info.getEndTime() == null) {
-                    // 如果为 null,可以选择返回 false(排除该项),或者根据需要处理
-                    return true;
-                }
-                // 确保 info 的状态为 "1" 或 "2",且结束时间不晚于当天结束时间
-                // 并且结束时间不早于当天开始时间
-                return info.getEndTime().before(sdf.parse(endTime))
-                        && info.getEndTime().after(sdf.parse(startTime));
+//                if (info.getEndTime() == null) {
+//                    // 如果为 null,可以选择返回 false(排除该项),或者根据需要处理
+//                    return true;
+//                }
+                // 确保 info 的状态为 "1" 或 "2",且开始时间不晚于当天结束时间
+                // 并且开始时间不早于当天开始时间
+                return info.getStartTime().before(sdf.parse(endTime))
+                        && info.getStartTime().after(sdf.parse(startTime));
             } catch (ParseException e) {
                 throw new RuntimeException(e);
             }