From 772fa58b459f16dac2524a3ea96b932639288a45 Mon Sep 17 00:00:00 2001 From: philip <244793088@qq.com> Date: Wed, 1 Sep 2021 10:14:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=96=E5=8D=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/PodTemplateServiceImpl.java | 96 ++++++++++--------- 1 file changed, 53 insertions(+), 43 deletions(-) diff --git a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java index 148622d8..29d2d636 100644 --- a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java +++ b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java @@ -31,10 +31,8 @@ import com.foreverwin.mesnac.production.mapper.SfcCrossMapper; import com.foreverwin.mesnac.production.mapper.SfcDataAssembleMapper; import com.foreverwin.mesnac.production.model.LoadInventory; import com.foreverwin.mesnac.production.model.SfcHoldLog; -import com.foreverwin.mesnac.production.service.LoadInventoryService; -import com.foreverwin.mesnac.production.service.PodTemplateService; -import com.foreverwin.mesnac.production.service.SfcCrossService; -import com.foreverwin.mesnac.production.service.SfcHoldLogService; +import com.foreverwin.mesnac.production.model.WorkShopTransfer; +import com.foreverwin.mesnac.production.service.*; import com.foreverwin.modular.core.exception.BaseException; import com.foreverwin.modular.core.meext.MEServices; import com.foreverwin.modular.core.util.CommonMethods; @@ -92,6 +90,8 @@ public class PodTemplateServiceImpl implements PodTemplateService { private LoadInventoryService loadInventoryService; @Autowired private SfcHoldLogService sfcHoldLogService; + @Autowired + private WorkShopTransferService workShopTransferService; @Override public Map resrceEnter(WorkCenterDto workCenterDto) { @@ -208,16 +208,20 @@ public class PodTemplateServiceImpl implements PodTemplateService { String dispatchNo = sfcDto.getDispatchNo(); Sfc sfcServiceById = sfcService.getById(HandleEnum.SFC.getHandle(site, sfc)); BigDecimal qty = new BigDecimal(sfcServiceById.getQty().toString()); - //是否有互检检验项目 - List inspectionItemDetails = inspectionItemService.selectQualityInspection(sfc, operation, stepId, Constants.INSPECTION_TYPE_H); - if (inspectionItemDetails.size() > 0 && inspectionItemDetails.get(0) != null) { - //是否有互检检验任务及已完成 - InspectionTask createTask = inspectionTaskService.isCreateTask(site, Constants.INSPECTION_TYPE_H, sfc, operation, stepId); - if (createTask == null || !createTask.getStatus().equals(Constants.INSPECTION_TASK_STATUS_COMPLETE)) { - throw new BaseException("请完成互检检验任务"); - } - if (!createTask.getResult().equals(Constants.RSESULT_OK)) { - throw new BaseException("互检任务不合格,不能开始请检查"); + WorkShopTransfer transfer = workShopTransferService.sfcEnter(sfc, "OUT"); + String isOutSource = transfer.getIsOutSource(); + if (StringUtil.isBlank(isOutSource)||!isOutSource.equals(Constants.STATUS_Y)){ + //是否有互检检验项目 + List inspectionItemDetails = inspectionItemService.selectQualityInspection(sfc, operation, stepId, Constants.INSPECTION_TYPE_H); + if (inspectionItemDetails.size() > 0 && inspectionItemDetails.get(0) != null) { + //是否有互检检验任务及已完成 + InspectionTask createTask = inspectionTaskService.isCreateTask(site, Constants.INSPECTION_TYPE_H, sfc, operation, stepId); + if (createTask == null || !createTask.getStatus().equals(Constants.INSPECTION_TASK_STATUS_COMPLETE)) { + throw new BaseException("请完成互检检验任务"); + } + if (!createTask.getResult().equals(Constants.RSESULT_OK)) { + throw new BaseException("互检任务不合格,不能开始请检查"); + } } } //是否完成专检 @@ -258,32 +262,35 @@ public class PodTemplateServiceImpl implements PodTemplateService { if (status.equals("404")) { throw new BaseException("产品条码" + sfc + "已暂停"); } + BigDecimal workHour=BigDecimal.ZERO; BigDecimal qty = new BigDecimal(sfcServiceById.getQty().toString()); - //是否有自检检验项目 - List inspectionItemDetails = inspectionItemService.selectQualityInspection(sfc, operation, stepId, Constants.INSPECTION_TYPE_Z); - if (inspectionItemDetails.size() > 0 && inspectionItemDetails.get(0) != null) { - //是否有自检检验任务 - InspectionTask createTask = inspectionTaskService.isCreateTask(site, Constants.INSPECTION_TYPE_Z, sfc, operation, stepId); - if (createTask == null || !createTask.getStatus().equals(Constants.INSPECTION_TASK_STATUS_COMPLETE)) { - throw new BaseException("请完成自检检验任务"); - } - if (!createTask.getResult().equals(Constants.RSESULT_OK)) { - throw new BaseException("自检任务不合格,不能完成请检查"); + WorkShopTransfer transfer = workShopTransferService.sfcEnter(sfc, "OUT"); + String isOutSource = transfer.getIsOutSource(); + if (StringUtil.isBlank(isOutSource)||!isOutSource.equals(Constants.STATUS_Y)) { + //是否有自检检验项目 + List inspectionItemDetails = inspectionItemService.selectQualityInspection(sfc, operation, stepId, Constants.INSPECTION_TYPE_Z); + if (inspectionItemDetails.size() > 0 && inspectionItemDetails.get(0) != null) { + //是否有自检检验任务 + InspectionTask createTask = inspectionTaskService.isCreateTask(site, Constants.INSPECTION_TYPE_Z, sfc, operation, stepId); + if (createTask == null || !createTask.getStatus().equals(Constants.INSPECTION_TASK_STATUS_COMPLETE)) { + throw new BaseException("请完成自检检验任务"); + } + if (!createTask.getResult().equals(Constants.RSESULT_OK)) { + throw new BaseException("自检任务不合格,不能完成请检查"); + } } - } - //是否装配完成 - List> assembleList = sfcDataAssembleMapper.querySfcAssemble(HandleEnum.SFC_DISPATCH.getHandle(site, dispatchNo)); - if (assembleList != null && assembleList.size() > 0) { - for (Map objectMap : assembleList) { - String isAssemble = (String) objectMap.get("IS_ASSEMBLE"); - if (!isAssemble.equals("GREEN")) { - throw new BaseException("未装配完成"); + //是否装配完成 + List> assembleList = sfcDataAssembleMapper.querySfcAssemble(HandleEnum.SFC_DISPATCH.getHandle(site, dispatchNo)); + if (assembleList != null && assembleList.size() > 0) { + for (Map objectMap : assembleList) { + String isAssemble = (String) objectMap.get("IS_ASSEMBLE"); + if (!isAssemble.equals("GREEN")) { + throw new BaseException("未装配完成"); + } } } - } - //物料消耗 - materialConsumption(site, operation, HandleEnum.SFC.getHandle(site, sfc), stepId, resrce); - try { + //物料消耗 + materialConsumption(site, operation, HandleEnum.SFC.getHandle(site, sfc), stepId, resrce); //专检创建 Map paramMap = new HashMap<>(); paramMap.put("SFC", sfc); @@ -312,17 +319,20 @@ public class PodTemplateServiceImpl implements PodTemplateService { //计算工时 LocalDateTime startTime = sfcService.getSfcStartTime(HandleEnum.SFC.getHandle(site, sfc)); long workHourSeconds = Duration.between(startTime, LocalDateTime.now()).getSeconds(); - BigDecimal workHour = new BigDecimal(workHourSeconds).divide(BigDecimal.valueOf(3600), 2, RoundingMode.HALF_UP); + workHour = new BigDecimal(workHourSeconds).divide(BigDecimal.valueOf(3600), 2, RoundingMode.HALF_UP); //减去暂停时间 - QueryWrapper queryWrapper=new QueryWrapper<>(); - queryWrapper.eq(SfcHoldLog.SFC,sfc); - queryWrapper.eq(SfcHoldLog.STEP_ID,stepId); - queryWrapper.eq(SfcHoldLog.TYPE,"CANCEL"); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(SfcHoldLog.SFC, sfc); + queryWrapper.eq(SfcHoldLog.STEP_ID, stepId); + queryWrapper.eq(SfcHoldLog.TYPE, "CANCEL"); List list = sfcHoldLogService.list(queryWrapper); - if (!list.isEmpty()){ + if (!list.isEmpty()) { BigDecimal holdTime = list.stream().map(SfcHoldLog::getHoldDuration).reduce(BigDecimal.ZERO, BigDecimal::add); - workHour=workHour.subtract(holdTime); + workHour = workHour.subtract(holdTime); } + } + try { + sfcCrossService.completeAction(site, currentRevisionRef.getHandle(), resrce, sfcServiceById.getHandle(), qty); //更改派工单状态 sfcDispatchCommonService.updateSfcDispatchStatus(site, CommonMethods.getUser(), dispatchNo, DispatchStatusEnum.COMPLETE.getCode(),workHour);