Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master'

ezhizao_zx 9 mēneši atpakaļ
vecāks
revīzija
84f309f815

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

@@ -1178,30 +1178,30 @@ public TableDataInfo examineList(@RequestBody BizProcessInspecion bizProcessInsp
                 inspection.setStartTime(new Date());
             }
             bizProcessInspecionService.save(inspection);
-            //保存检查明细
-            List<BizInspectionStandardsCheck> inspectionStandardsCheckList = bizInspectionStandardsCheckService.query()
-                    .eq("inspection_code", "instrumentRoomInspection")
-                    .eq("product_id", inspection.getProductId())
-                    .eq("process_id", processInspecion.getLot().getProcessId()).list();
-            List<BizProcessInspectionDetail> detailList = new ArrayList<>();
-            inspectionStandardsCheckList.forEach(inspectionStandardsCheck -> {
-                BizProcessInspectionDetail detail = new BizProcessInspectionDetail();
-                detail.setId(null);
-                detail.setUserId(processInspecion.getLot().getUserId());
-                detail.setProcessInspectionId(inspection.getId());
-                detail.setDayworkId(0L);
-                detail.setProductionPlanId(daywork.getProductionPlanId());
-                detail.setProductionPlanDetailId(daywork.getProductionPlanDetailId());
-                detail.setProductionPlanDetailSubDetailId(daywork.getProductionPlanDetailSubDetailId());
-                detail.setLotId(processInspecion.getLot().getId());
-                detail.setDayworkItemId(dayworkItem.getId());
-                detail.setCheckStandard(inspectionStandardsCheck.getStandard());
-                detail.setInspectionStandardsId(inspectionStandardsCheck.getId());
-                detailList.add(detail);
-            });
-            if(!detailList.isEmpty()) {
-                processInspectionDetailService.saveBatch(detailList);
-            }
+//            //保存检查明细
+//            List<BizInspectionStandardsCheck> inspectionStandardsCheckList = bizInspectionStandardsCheckService.query()
+//                    .eq("inspection_code", "instrumentRoomInspection")
+//                    .eq("product_id", inspection.getProductId())
+//                    .eq("process_id", processInspecion.getLot().getProcessId()).list();
+//            List<BizProcessInspectionDetail> detailList = new ArrayList<>();
+//            inspectionStandardsCheckList.forEach(inspectionStandardsCheck -> {
+//                BizProcessInspectionDetail detail = new BizProcessInspectionDetail();
+//                detail.setId(null);
+//                detail.setUserId(processInspecion.getLot().getUserId());
+//                detail.setProcessInspectionId(inspection.getId());
+//                detail.setDayworkId(0L);
+//                detail.setProductionPlanId(daywork.getProductionPlanId());
+//                detail.setProductionPlanDetailId(daywork.getProductionPlanDetailId());
+//                detail.setProductionPlanDetailSubDetailId(daywork.getProductionPlanDetailSubDetailId());
+//                detail.setLotId(processInspecion.getLot().getId());
+//                detail.setDayworkItemId(dayworkItem.getId());
+//                detail.setCheckStandard(inspectionStandardsCheck.getStandard());
+//                detail.setInspectionStandardsId(inspectionStandardsCheck.getId());
+//                detailList.add(detail);
+//            });
+//            if(!detailList.isEmpty()) {
+//                processInspectionDetailService.saveBatch(detailList);
+//            }
             //绑定检测载具
             BizDayworkCarrier newDayworkCarrier = new BizDayworkCarrier();
             newDayworkCarrier.setDayworkId(inspection.getDayworkId());
@@ -1475,30 +1475,30 @@ public TableDataInfo examineList(@RequestBody BizProcessInspecion bizProcessInsp
                 inspection.setStartTime(new Date());
             }
             bizProcessInspecionService.save(inspection);
-            //保存检查明细
-            List<BizInspectionStandardsCheck> inspectionStandardsCheckList = bizInspectionStandardsCheckService.query()
-                    .eq("inspection_code", "instrumentRoomInspection")
-                    .eq("product_id", inspection.getProductId())
-                    .eq("process_id", processInspecion.getLot().getProcessId()).list();
-            List<BizProcessInspectionDetail> detailList = new ArrayList<>();
-            inspectionStandardsCheckList.forEach(inspectionStandardsCheck -> {
-                BizProcessInspectionDetail detail = new BizProcessInspectionDetail();
-                detail.setId(null);
-                detail.setUserId(processInspecion.getLot().getUserId());
-                detail.setProcessInspectionId(inspection.getId());
-                detail.setDayworkId(0L);
-                detail.setProductionPlanId(daywork.getProductionPlanId());
-                detail.setProductionPlanDetailId(daywork.getProductionPlanDetailId());
-                detail.setProductionPlanDetailSubDetailId(daywork.getProductionPlanDetailSubDetailId());
-                detail.setLotId(processInspecion.getLot().getId());
-                detail.setDayworkItemId(dayworkItem.getId());
-                detail.setCheckStandard(inspectionStandardsCheck.getStandard());
-                detail.setInspectionStandardsId(inspectionStandardsCheck.getId());
-                detailList.add(detail);
-            });
-            if(!detailList.isEmpty()) {
-                processInspectionDetailService.saveBatch(detailList);
-            }
+//            //保存检查明细
+//            List<BizInspectionStandardsCheck> inspectionStandardsCheckList = bizInspectionStandardsCheckService.query()
+//                    .eq("inspection_code", "instrumentRoomInspection")
+//                    .eq("product_id", inspection.getProductId())
+//                    .eq("process_id", processInspecion.getLot().getProcessId()).list();
+//            List<BizProcessInspectionDetail> detailList = new ArrayList<>();
+//            inspectionStandardsCheckList.forEach(inspectionStandardsCheck -> {
+//                BizProcessInspectionDetail detail = new BizProcessInspectionDetail();
+//                detail.setId(null);
+//                detail.setUserId(processInspecion.getLot().getUserId());
+//                detail.setProcessInspectionId(inspection.getId());
+//                detail.setDayworkId(0L);
+//                detail.setProductionPlanId(daywork.getProductionPlanId());
+//                detail.setProductionPlanDetailId(daywork.getProductionPlanDetailId());
+//                detail.setProductionPlanDetailSubDetailId(daywork.getProductionPlanDetailSubDetailId());
+//                detail.setLotId(processInspecion.getLot().getId());
+//                detail.setDayworkItemId(dayworkItem.getId());
+//                detail.setCheckStandard(inspectionStandardsCheck.getStandard());
+//                detail.setInspectionStandardsId(inspectionStandardsCheck.getId());
+//                detailList.add(detail);
+//            });
+//            if(!detailList.isEmpty()) {
+//                processInspectionDetailService.saveBatch(detailList);
+//            }
             //绑定检测载具
             BizDayworkCarrier newDayworkCarrier = new BizDayworkCarrier();
             newDayworkCarrier.setDayworkId(inspection.getDayworkId());
@@ -1985,20 +1985,49 @@ public TableDataInfo examineList(@RequestBody BizProcessInspecion bizProcessInsp
     @PostMapping("/unbindInspectionCarrier")
     public AjaxResult unbindInspectionCarrier(@RequestBody BizDayworkCarrier dayworkCarrier) throws NoSuchFieldException, IllegalAccessException {
         List<BizDayworkCarrier> carrierList = bizDayworkCarrierService.query().eq("carrier_code", dayworkCarrier.getCarrierCode()).list();
-        //判断领取的人是否是当前工序的操作者
-        Long dayworkId = carrierList.get(0).getDayworkId();
-        List<BizDayworkItem> dayworkItemList = bizDayworkItemService.query().eq("daywork_id", dayworkId).orderByDesc("create_time").list();
-        String lastProcessStepNumber = dayworkItemList.get(0).getProcessStepNumber();
-        List<BizDayworkItem> lastDayworkItemList = dayworkItemList.stream().filter(item -> item.getProcessStepNumber().equals(lastProcessStepNumber)).collect(Collectors.toList());
-        List<Long> lastUserIds = lastDayworkItemList.stream().map(BizDayworkItem::getUserId).distinct().collect(Collectors.toList());
-        Long loginUserId = SecurityUtils.getLoginUser().getUserId();
-        if(!lastUserIds.contains(loginUserId)) {
-            carrierList.forEach(item -> {
-                item.setIsChanged(1);
-            });
-            return success(bizDayworkCarrierService.updateBatchById(carrierList));
+        //操作检查表
+        List<BizProcessInspecion> list = bizProcessInspecionService.query()
+                .eq("inspection_carrier_code", dayworkCarrier.getCarrierCode())
+                .eq("is_inspection_carrier_changed", 0)
+                .list();
+        //判断如果是出厂检查创建者和最新那道序所有报工人员能领取
+        if(list.stream().anyMatch(v->v.getType().equals("factoryInspection"))) {
+            Long dayworkId = carrierList.get(0).getDayworkId();
+            List<BizDayworkItem> dayworkItemList = bizDayworkItemService.query().eq("daywork_id", dayworkId).orderByDesc("create_time").list();
+            String lastProcessStepNumber = dayworkItemList.get(0).getProcessStepNumber();
+            List<BizDayworkItem> lastDayworkItemList = dayworkItemList.stream().filter(item -> item.getProcessStepNumber().equals(lastProcessStepNumber)).collect(Collectors.toList());
+            List<Long> lastUserIds = lastDayworkItemList.stream().map(BizDayworkItem::getUserId).distinct().collect(Collectors.toList());
+            lastUserIds.add(list.get(0).getCreatorId());
+            //当前登陆者
+            Long loginUserId = SecurityUtils.getLoginUser().getUserId();
+            if(lastUserIds.contains(loginUserId)) {
+                carrierList.forEach(item -> {
+                    item.setIsChanged(1);
+                });
+                list.forEach(item ->{
+                    item.setIsInspectionCarrierChanged(1);
+                    bizProcessInspecionService.updateBatchById(list);
+                });
+                return success(bizDayworkCarrierService.updateBatchById(carrierList));
+            }
+            return error("您未参与当前批次的加工,无法领取");
+        }else {
+            //检查选择的操作者能领取
+            List<Long> lastUserIds = list.stream().map(BizProcessInspecion::getUserId).distinct().collect(Collectors.toList());
+            //当前登陆者
+            Long loginUserId = SecurityUtils.getLoginUser().getUserId();
+            if(lastUserIds.contains(loginUserId)) {
+                carrierList.forEach(item -> {
+                    item.setIsChanged(1);
+                });
+                list.forEach(item ->{
+                    item.setIsInspectionCarrierChanged(1);
+                    bizProcessInspecionService.updateBatchById(list);
+                });
+                return success(bizDayworkCarrierService.updateBatchById(carrierList));
+            }
+            return error("您不是当前检查的操作者,无法领取");
         }
-        return error("您未参与当前批次的加工,无法领取");
     }
 
 
@@ -2015,9 +2044,10 @@ public TableDataInfo examineList(@RequestBody BizProcessInspecion bizProcessInsp
         }
 
         //获取报工信息
-        List<BizDayworkItem> itemList = bizDayworkItemService.getByDayworkId(dayworkCarrier.getDayworkId()).stream().filter(item ->!item.getStatus().equals("0")).collect(Collectors.toList());
+        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("该批次未开始加工");
+            return error("该批次当前工段没有报工");
         }
         BizDayworkItem item = itemList.get(0);
         List<BizDayworkItem> latestList = itemList.stream().filter(v -> v.getProcessStepNumber().equals(item.getProcessStepNumber())).collect(Collectors.toList());

+ 2 - 0
src/main/java/cn/ezhizao/project/business/product/domain/BizDayworkCarrier.java

@@ -90,5 +90,7 @@ public class BizDayworkCarrier extends BaseEntity
     private Long value;
     @TableField(exist = false)
     private String label;
+    @TableField(exist = false)
+    private Long deptId;
 
 }

+ 4 - 0
src/main/resources/mybatis/business/product/BizDayworkCarrierMapper.xml

@@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <resultMap type="cn.ezhizao.project.business.product.domain.BizDayworkCarrier" id="BizDayworkCarrierResult">
         <id column="id" property="id"/>
         <result column="daywork_id" property="dayworkId"/>
+        <association property="deptId" column="daywork_id" select="getDeptId"/>
         <association property="lotCode" javaType="java.lang.String" column="daywork_id" select="getLotCode"/>
     </resultMap>
 
@@ -22,6 +23,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
         </trim>
     </select>
+    <select id="getDeptId" resultType="Long">
+        select dept_id from biz_daywork where id = #{daywork_id}
+    </select>
     <select id="getDayworkCarrierByCarrierCode" resultType="cn.ezhizao.project.business.product.domain.BizDayworkCarrier">
         select t1.daywork_id as value,t2.lot_code as label from biz_daywork_carrier t1 left join biz_daywork t2 on t1.daywork_id = t2.id
         where t1.deleted = 0 and t1.is_changed = 0 and t1.carrier_code = #{carrierCode} and t2.deleted = 0