Quellcode durchsuchen

扫码新规则

wangxin vor 1 Jahr
Ursprung
Commit
2b30f578cc

+ 12 - 6
src/main/java/cn/ezhizao/project/business/product/controller/BizCarrierController.java

@@ -268,6 +268,9 @@ public class BizCarrierController extends BaseController {
     public AjaxResult checkCarrier(@RequestBody BizDaywork bizDaywork) {
         // 检测新箱码是否已被使用
         BizCarrier curCarrier = bizCarrierService.getOne(new QueryWrapper<BizCarrier>().eq("code", bizDaywork.getNewCarrierCode()));
+        curCarrier.setCarrierId(curCarrier.getId());
+        curCarrier.setCarrierCode(curCarrier.getCode());
+        bizDaywork.setNewCarrierId(curCarrier.getId());
         BizCarrierCategory carrierCategory = bizCarrierService.getCarrierCategory(curCarrier.getCategoryId());
         List<BizDayworkCarrier> dayworkCarrierList = bizDayworkCarrierService.query().eq("is_changed", 0).eq("carrier_code", bizDaywork.getNewCarrierCode()).list();
 
@@ -277,16 +280,19 @@ public class BizCarrierController extends BaseController {
         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();
+        //在方法开始时已经查询到了箱号信息,所以不需要再查一遍
+//        BizCarrier carrier = new BizCarrier();
+//        carrier.setId(bizDaywork.getNewCarrierId());
+//        BizCarrier bizCarrier = bizCarrierService.getList(carrier).get(0);
+        List<BizCarrierReject> carrierRejects = bizCarrierRejectService.query().eq("carrier_id",bizDaywork.getNewCarrierId()).orderByDesc("create_time").list();
         if (!carrierRejects.isEmpty() && carrierRejects.get(0).getIsAbandoned() == 1) {
             return error("该载具已被废弃");
         }
+        curCarrier.setId(null);
         // 检测新箱和旧箱是否是一个类型
         if (bizDaywork.getDayworkCarriers().isEmpty()) {
-            return success(bizCarrier);
+
+            return success(curCarrier);
         }
         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();
@@ -297,7 +303,7 @@ public class BizCarrierController extends BaseController {
         if (categories.stream().allMatch(v -> v.getIsAllowMore().equals(1))) {
             return error("已有铁箱载具,不需要添加其他载具。");
         }
-        return success(bizCarrier);
+        return success(curCarrier);
     }
 
     // 【checkCarrier 原有代码 备份】

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

@@ -981,7 +981,7 @@ public class BizDayworkController extends BaseController {
     public AjaxResult getDayworkByCarrierId(BizDayworkItem bizDayworkItem) {
         try {
             // 根据箱号,获取箱子
-            BizCarrier bizCarrier = bizCarrierService.query().eq("carrier_code", bizDayworkItem.getCarrierCode()).one();
+            BizCarrier bizCarrier = bizCarrierService.query().eq("code", bizDayworkItem.getCarrierCode()).one();
             if (bizCarrier == null) {
                 return error("该箱号不存在");
             }

+ 68 - 5
src/main/java/cn/ezhizao/project/business/product/controller/BizProcessInspecionController.java

@@ -68,6 +68,9 @@ public class BizProcessInspecionController extends BaseController {
     @Resource
     private IBizLotService bizLotService;
 
+    @Resource
+    private IBizCarrierService bizCarrierService;
+
     @Resource
     private IBizProductService productService;
     @Resource
@@ -409,7 +412,9 @@ public class BizProcessInspecionController extends BaseController {
      */
     @PostMapping("/getLotOutsourcedInfo")
     public AjaxResult getLotOutsourcedInfo(@RequestBody BizDayworkCarrier dayworkCarrier) throws NoSuchFieldException, IllegalAccessException {
-        List<String> processCodes = dayworkCarrier.getProcessCode();
+        List<String> codes=new ArrayList<>();
+        codes.add("27110");
+        List<String> processCodes = dayworkCarrier.getProcessCode()==null?codes:dayworkCarrier.getProcessCode();
         System.out.println("查询工序编码:processCodes" + processCodes);
         //根据箱号查询当前绑定信息
         dayworkCarrier = bizDayworkCarrierService.getByCarrierCode(dayworkCarrier);
@@ -485,18 +490,76 @@ public class BizProcessInspecionController extends BaseController {
      * 根据箱号查询批次信息
      */
 //    @PreAuthorize("@ss.hasPermi('business:inspecion:list')")
+//    @PostMapping("/getLotInfo")
+//    public AjaxResult getLotInfo(@RequestBody BizDayworkCarrier dayworkCarrier) throws NoSuchFieldException, IllegalAccessException {
+//        //根据箱号查询当前绑定信息
+//        dayworkCarrier = bizDayworkCarrierService.getByCarrierCode(dayworkCarrier);
+//        if (dayworkCarrier == null) {
+//            throw new RuntimeException("该箱号未绑定任何批次");
+//        }
+//
+//        //获取报工信息
+//        List<BizDayworkItem> itemList = bizDayworkItemService.getByDayworkId(dayworkCarrier.getDayworkId());
+//        if (itemList.size() == 0) {
+//            throw new RuntimeException("改批次未开始加工");
+//        }
+//        BizDayworkItem item = itemList.get(0);
+//        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) {
+//            throw new RuntimeException("该批次已批废");
+//        }
+//        if (lot.getIsAmend() == 1 || lot.getIsWasteRecycling() == 1) {
+//            BizLotTechnologicalProcessDetail process = bizLotTechnologicalProcessDetailService.getById(item.getTechnologicalProcessDetailId());
+//            lot.setProcessAlias(process.getProcessAlias());
+//        } else {
+//            BizTechnologicalProcessDetail process = bizTechnologicalProcessDetailService.getById(item.getTechnologicalProcessDetailId());
+//            lot.setProcessAlias(process.getProcessAlias());
+//        }
+//        lot.setAllCarrierName(item.getCarrierName());
+//        lot.setDayworkItemId(item.getId());
+//        lot.setCarrierCode(dayworkCarrier.getCarrierCode());
+//        lot.setCarrierId(dayworkCarrier.getCarrierId());
+//        lot.setPudName(item.getProdNum() == 0 ? lot.getProductionQuantity() : item.getProdNum());
+//        return success(lot);
+//    }
+
+    /**
+     * 根据箱号查询批次信息
+     */
     @PostMapping("/getLotInfo")
-    public AjaxResult getLotInfo(@RequestBody BizDayworkCarrier dayworkCarrier) throws NoSuchFieldException, IllegalAccessException {
+    public AjaxResult getLotOrCarrierInfo(@RequestBody BizDayworkCarrier dayworkCarrier) throws NoSuchFieldException, IllegalAccessException {
+
+        /** 因为需要绑定检查载具所以需要先查询出载具信息 **/
+        List<BizCarrier> carriers=bizCarrierService.query().eq("code",dayworkCarrier.getCarrierCode()).list();
+        if(carriers.isEmpty()){
+            return error("箱号信息错误,未找到该载具");
+        }
+        BizCarrier carrier=carriers.get(0);
         //根据箱号查询当前绑定信息
         dayworkCarrier = bizDayworkCarrierService.getByCarrierCode(dayworkCarrier);
+        /** 判断载具类型,是检查载具并且没有 **/
         if (dayworkCarrier == null) {
-            throw new RuntimeException("该箱号未绑定任何批次");
+            return error("该箱号未绑定任何批次");
         }
 
         //获取报工信息
         List<BizDayworkItem> itemList = bizDayworkItemService.getByDayworkId(dayworkCarrier.getDayworkId());
         if (itemList.size() == 0) {
-            throw new RuntimeException("改批次未开始加工");
+            return error("改批次未开始加工");
         }
         BizDayworkItem item = itemList.get(0);
         BizProductionPlanDetail productionPlanDetail = productionPlanDetailService.getById(item.getProductionPlanDetailId());
@@ -515,7 +578,7 @@ public class BizProcessInspecionController extends BaseController {
         lot.setId(item.getLotId());
         lot = bizLotService.getAllList(lot).get(0);
         if (lot.getIsWaste() == 1) {
-            throw new RuntimeException("改批次已批废");
+            return error("改批次已批废");
         }
         if (lot.getIsAmend() == 1 || lot.getIsWasteRecycling() == 1) {
             BizLotTechnologicalProcessDetail process = bizLotTechnologicalProcessDetailService.getById(item.getTechnologicalProcessDetailId());