oyq28 преди 3 години
родител
ревизия
159ec0927f

+ 15 - 6
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/operationManagementCenter/InspectionController.java

@@ -18,6 +18,7 @@ import com.github.zuihou.business.operationManagementCenter.service.WorkpieceSer
 import com.github.zuihou.business.productionReadyCenter.entity.BomProcedure;
 import com.github.zuihou.business.productionReadyCenter.service.BBomService;
 import com.github.zuihou.business.productionReadyCenter.service.BomProcedureService;
+import com.github.zuihou.business.productionResourceCenter.entity.ZZone;
 import com.github.zuihou.business.productionResourceCenter.service.ZZoneService;
 import com.github.zuihou.common.util.StringUtil;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
@@ -26,10 +27,12 @@ import com.github.zuihou.log.annotation.SysLog;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.compress.utils.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -78,6 +81,13 @@ public class InspectionController extends SuperController<InspectionService, Lon
     @ApiOperation(value = "获取可抽检工序", notes = "获取可抽检工序")
     @PostMapping("/procedure")
     public R<List<TTask>> procedure(@RequestBody Map map) {
+
+        ZZone zZone = zZoneService.getById(map.get("zoneId").toString());
+        if(null==zZone || zZone.getNo().equals("safeguard")){
+            //排除保障中心设备序
+            return success(Lists.newArrayList());
+        }
+
         LbqWrapper<BomProcedure> wrapper = new LbqWrapper<BomProcedure>();
         //满足当前零件、属于设备序、工艺允许配置抽检、按照优先级降序排列
         wrapper.eq(BomProcedure::getBomId, map.get("bomId")).eq(BomProcedure::getType, "设备序").eq(BomProcedure::getRandomCheckConf, "1").orderByDesc(BomProcedure::getSort);
@@ -95,21 +105,20 @@ public class InspectionController extends SuperController<InspectionService, Lon
             //在当前零件加工工序之后
             wrapper.le(BomProcedure::getSort, sort);
         }
+        List<Long> procedureIds = bomProcedureService.list(wrapper).stream().map(item->item.getId()).collect(Collectors.toList());
 
-        List<Long> idList = bomProcedureService.list(wrapper).stream().filter(data -> {
-            //排除保障中心设备序
-            Long zone_id = bBomService.getById(data.getBomId()).getZoneId();
-            return zZoneService.getById(zone_id).getNo() != "safeguard";
-        }).map(BomProcedure::getId).collect(Collectors.toList());
         //获取已存在的工序的任务节点
         LbqWrapper<TTask> taskLbqWrapper = new LbqWrapper<TTask>();
-        taskLbqWrapper.eq(TTask::getCompleteBatchNo, workPiece.getCompleteBatchNo()).eq(TTask::getPlanId, map.get("planId").toString()).in(TTask::getProcedureId, idList.toArray());
+        taskLbqWrapper.eq(TTask::getCompleteBatchNo, workPiece.getCompleteBatchNo()).eq(TTask::getPlanId, map.get("planId").toString());
 
         List<Long> taskIds = baseService.list(new LbqWrapper<Inspection>().eq(Inspection::getWorkpieceId, workPiece.getId())).stream().map(item->item.getTaskId()).collect(Collectors.toList());
         //排除已经提交抽检的工序
         if (null != taskIds && taskIds.size()>0) {
             taskLbqWrapper.notIn(TTask::getId, taskIds.toArray());
         }
+        if(null!=procedureIds && procedureIds.size()>0){
+            taskLbqWrapper.in(TTask::getProcedureId, procedureIds.toArray());
+        }
         List<TTask> dataList = taskService.list(taskLbqWrapper);
         return success(dataList);
     }