guoyujia 9 mēneši atpakaļ
vecāks
revīzija
a3c03b6745

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

@@ -1846,6 +1846,44 @@ public TableDataInfo examineList(@RequestBody BizProcessInspecion bizProcessInsp
         }
         return success();
     }
+    //首件扫码专用
+    @PostMapping("/getFirstCarrierInfo")
+    public AjaxResult getFirstCarrierInfo(@RequestBody BizDayworkCarrier dayworkCarrier) throws NoSuchFieldException, IllegalAccessException {
+        // 判断是哪种箱
+        String carrierCode = dayworkCarrier.getCarrierCode();
+        BizCarrier carrier = bizCarrierService.query().eq("code", carrierCode).one();
+        if (carrier == null) {
+            return error("未找到该箱号");
+        }
+        //查询箱号是否废弃
+        BizCarrierReject carrierReject = bizCarrierRejectService.query().eq("carrier_id", carrier.getId()).eq("deleted", 0).eq("is_abandoned", 1).last("limit 1").one();
+        if (carrierReject != null) {
+            return error("该载具已废弃");
+        }
+
+        Map<String, Object> map = new HashMap<>();
+        dayworkCarrier.setIsChanged(0);
+//        List<BizDayworkCarrier> list = bizDayworkCarrierService.getList(dayworkCarrier);
+        List<BizDayworkCarrier> list = bizDayworkCarrierService.query().eq("carrier_code", dayworkCarrier.getCarrierCode()).eq("is_changed",0).list();
+        List<BizDaywork> dayworks = bizDayworkService.query().in("id", list.isEmpty() ? Collections.singletonList(0L) : list.stream().map(BizDayworkCarrier::getDayworkId).collect(Collectors.toList())).list();
+        if (carrier.getIsInspection().equals(1)) {
+            // 为检查载具返回检查载具信息
+            if (carrier.getIsInspection().equals(1) && list.size() == 0) {
+                map.put("inspectionCarrier", carrier);
+                return success(map);
+            } else if (carrier.getIsInspection().equals(1) && list.size() > 0) {
+                // 需要显示已经绑定的批次。
+                return error("检查载具:" + carrier.getCode() + "已经绑定其他批次" + dayworks.stream().map(BizDaywork::getLotCode).collect(Collectors.joining()));
+            }
+        } else {
+            if (list.size() == 0) {
+                throw new RuntimeException("请扫检测载具。");
+            }
+            map.put("dayworkCarriers", list);
+            return success(map);
+        }
+        return success();
+    }
     //交检
     @Transactional
     @PostMapping("/saveDeliveryInspection")
@@ -2662,6 +2700,75 @@ public TableDataInfo examineList(@RequestBody BizProcessInspecion bizProcessInsp
         lot.setPudName(item.getProdNum() == 0 ? lot.getProductionQuantity() : item.getProdNum());
         return success(lot);
     }
+    //交检专用
+    @PostMapping("/getDeliveryLotInfo")
+    public AjaxResult getDeliveryLotInfo(@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("4") ||latestList.stream().map(BizDayworkItem::getStatus).collect(Collectors.toList()).contains("5")||latestList.stream().map(BizDayworkItem::getStatus).collect(Collectors.toList()).contains("7")) {
+            return error("当前批次已经周转");
+        }
+        if(!latestList.stream().map(BizDayworkItem::getStatus).collect(Collectors.toList()).contains("3")) {
+            return error("当前工序未完成,不能交检");
+        }
+        List<BizDayworkItem> collect = latestList.stream().filter(v -> v.getStatus().equals("1") || v.getStatus().equals("2")|| v.getStatus().equals("3")).collect(Collectors.toList());
+        lot.setDayworkItemList(collect);
+        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("/getLotInfoByFirstInspection")
     public AjaxResult getLotInfoByFirstInspection(@RequestBody BizDayworkCarrier dayworkCarrier) throws NoSuchFieldException, IllegalAccessException {