diff --git a/common/src/main/java/com/foreverwin/mesnac/common/service/CommonService.java b/common/src/main/java/com/foreverwin/mesnac/common/service/CommonService.java index 785bd6c3..a66b44bf 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/service/CommonService.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/service/CommonService.java @@ -20,4 +20,12 @@ public interface CommonService { Operation getOperationBySfcBo(String sfcBo); void updateInventory(String site, String inventoryId, BigDecimal measuredQty); + + /** + * 根据工序找资源 + * @param operation + * @return + */ + String getResrceByOperation(String operation); + } diff --git a/common/src/main/java/com/foreverwin/mesnac/common/service/impl/CommonServiceImpl.java b/common/src/main/java/com/foreverwin/mesnac/common/service/impl/CommonServiceImpl.java index 1b73e4da..a43216d4 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/service/impl/CommonServiceImpl.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/service/impl/CommonServiceImpl.java @@ -2,17 +2,20 @@ package com.foreverwin.mesnac.common.service.impl; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.foreverwin.mesnac.common.enums.HandleEnum; import com.foreverwin.mesnac.common.service.CommonService; import com.foreverwin.mesnac.common.util.ExceptionUtil; import com.foreverwin.mesnac.common.util.StringUtil; import com.foreverwin.mesnac.meapi.mapper.OperationMapper; -import com.foreverwin.mesnac.meapi.model.Operation; -import com.foreverwin.mesnac.meapi.model.WorkCenter; -import com.foreverwin.mesnac.meapi.model.WorkCenterMember; +import com.foreverwin.mesnac.meapi.mapper.ResrceMapper; +import com.foreverwin.mesnac.meapi.model.*; +import com.foreverwin.mesnac.meapi.service.ResourceTypeService; import com.foreverwin.mesnac.meapi.service.WorkCenterMemberService; import com.foreverwin.mesnac.meapi.service.WorkCenterService; +import com.foreverwin.modular.core.exception.BaseException; import com.foreverwin.modular.core.exception.BusinessException; import com.foreverwin.modular.core.meext.MEServices; +import com.foreverwin.modular.core.util.CommonMethods; import com.sap.me.inventory.InventoryIdentifier; import com.sap.me.inventory.InventoryServiceInterface; import com.sap.me.inventory.InventoryStatusEnum; @@ -33,7 +36,10 @@ public class CommonServiceImpl implements CommonService { private WorkCenterService workCenterService; @Autowired private OperationMapper operationMapper; - + @Autowired + private ResourceTypeService resourceTypeService; + @Autowired + private ResrceMapper resrceMapper; @Override public String getWorkShopBo(String workCenterBo) { if (StrUtil.isBlank(workCenterBo)) { @@ -96,4 +102,19 @@ public class CommonServiceImpl implements CommonService { ExceptionUtil.throwException(e); } } + + @Override + public String getResrceByOperation(String operation) { + String site = CommonMethods.getSite(); + String resourceTypeHandle = HandleEnum.RESOURCE_TYPE.getHandle(CommonMethods.getSite(), operation); + ResourceType resourceTypeServiceById = resourceTypeService.getById(resourceTypeHandle); + if (resourceTypeServiceById==null){ + throw new BaseException("设备类型"+operation+"不存在"); + } + List resrces = resrceMapper.findResourceListByResourceType(site, resourceTypeServiceById.getHandle()); + if (resrces.isEmpty()){ + throw new BaseException("设备类型"+operation+"下没有资源"); + } + return resrces.get(0).getHandle(); + } } diff --git a/production/src/main/java/com/foreverwin/mesnac/production/dto/SplitSfcDto.java b/production/src/main/java/com/foreverwin/mesnac/production/dto/SplitSfcDto.java index 94c0a090..cae43562 100644 --- a/production/src/main/java/com/foreverwin/mesnac/production/dto/SplitSfcDto.java +++ b/production/src/main/java/com/foreverwin/mesnac/production/dto/SplitSfcDto.java @@ -8,6 +8,15 @@ public class SplitSfcDto extends SplitSfc { private String ncQty; private String abnormalNo; private String abnormalMethod; + private String stepId; + + public String getStepId() { + return stepId; + } + + public void setStepId(String stepId) { + this.stepId = stepId; + } public String getAbnormalMethod() { return abnormalMethod; diff --git a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/SplitSfcServiceImpl.java b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/SplitSfcServiceImpl.java index 53fa66cf..ac8ef787 100644 --- a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/SplitSfcServiceImpl.java +++ b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/SplitSfcServiceImpl.java @@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.foreverwin.mesnac.common.constant.Constants; import com.foreverwin.mesnac.common.dto.SfcDispatchDto; -import com.foreverwin.mesnac.common.enums.DispatchStatusEnum; import com.foreverwin.mesnac.common.enums.HandleEnum; +import com.foreverwin.mesnac.common.service.CommonService; import com.foreverwin.mesnac.common.service.InspectionTaskService; import com.foreverwin.mesnac.common.service.SfcDispatchCommonService; import com.foreverwin.mesnac.common.util.ExceptionUtil; @@ -18,7 +18,6 @@ import com.foreverwin.mesnac.meapi.service.RouterService; import com.foreverwin.mesnac.meapi.service.RouterStepService; import com.foreverwin.mesnac.meapi.service.ShopOrderService; import com.foreverwin.mesnac.production.dto.SplitSfcDto; -import com.foreverwin.mesnac.production.mapper.SfcCrossMapper; import com.foreverwin.mesnac.production.mapper.SplitSfcMapper; import com.foreverwin.mesnac.production.model.SplitSfc; import com.foreverwin.mesnac.production.service.SplitSfcService; @@ -65,7 +64,7 @@ public class SplitSfcServiceImpl extends ServiceImpl i @Autowired private RouterStepService routerStepService; @Autowired - private SfcCrossMapper sfcCrossMapper; + private CommonService commonService; @Override public IPage selectPage(FrontPage frontPage, SplitSfc splitSfc) { QueryWrapper queryWrapper = new QueryWrapper<>(); @@ -186,16 +185,16 @@ public class SplitSfcServiceImpl extends ServiceImpl i if (sfcData==null){ throw new BaseException("未找到产品条码信息"); } + //查询质量异常记录数量 处置工艺路线及不良代码 + SplitSfcDto splitSfcDto=splitSfcMapper.getAbnormalQty(site,sfc,operation, abnormalNo); SfcDispatchDto sfcDispatchDto = new SfcDispatchDto(); sfcDispatchDto.setSite(site); sfcDispatchDto.setSfc(sfc); - sfcDispatchDto.setStepId(sfcData.getStepId()); + sfcDispatchDto.setStepId(splitSfcDto.getStepId()); SfcDispatchDto sfcDispatchBySfc = sfcDispatchCommonService.findSfcDispatchBySfc(sfcDispatchDto); - if (sfcDispatchBySfc.equals(DispatchStatusEnum.CANCEL.getCode())){ - throw new BaseException("产品已取消派工"); + if (sfcDispatchBySfc==null){ + throw new BaseException("未找到派工任务"); } - //查询质量异常记录数量 处置工艺路线及不良代码 - SplitSfcDto splitSfcDto=splitSfcMapper.getAbnormalQty(site,sfc,operation, abnormalNo); String routerBo = splitSfcDto.getRouterBo(); String ncCode = splitSfcDto.getNcCode(); String abnormalMethod = splitSfcDto.getAbnormalMethod(); @@ -236,10 +235,8 @@ public class SplitSfcServiceImpl extends ServiceImpl i stepIdentifier.setStepId(sfcData.getStepId()); stepIdentifier.setOperationId(sfcData.getOperation()); productionContext.setStepIdentifier(stepIdentifier); - if (StringUtil.isBlank(sfcDispatchBySfc.getResrce())){ - throw new BaseException("未派工到设备"); - } - productionContext.setResourceRef(HandleEnum.RESOURCE.getHandle(site,sfcDispatchBySfc.getResrce())); + String resrceBo = commonService.getResrceByOperation(operation); + productionContext.setResourceRef(resrceBo); createNCRequest.setProdCtx(productionContext); createNCRequest.setNcCodeRef(HandleEnum.NC_CODE.getHandle(site,splitNcCode[0])); ncProductionService.createNC(createNCRequest); @@ -266,7 +263,7 @@ public class SplitSfcServiceImpl extends ServiceImpl i paramMap.put("SFC",sfc ); paramMap.put("SHOP_ORDER",sfcDispatchBySfc.getShopOrder()); paramMap.put("OPERATION",sfcDispatchBySfc.getOperation()); - paramMap.put("STEP_ID",sfcDispatchBySfc.getStepId());; + paramMap.put("STEP_ID",sfcDispatchBySfc.getStepId()); paramMap.put("WORK_CENTER",sfcDispatchBySfc.getWorkCenter()); paramMap.put("RESRCE",sfcDispatchBySfc.getResrce()); paramMap.put("SFC_DISPATCH_DETAIL_BO",sfcDispatchBySfc.getHandle()); diff --git a/production/src/main/resources/mapper/SplitSfcMapper.xml b/production/src/main/resources/mapper/SplitSfcMapper.xml index ea2181c0..5321225b 100644 --- a/production/src/main/resources/mapper/SplitSfcMapper.xml +++ b/production/src/main/resources/mapper/SplitSfcMapper.xml @@ -378,7 +378,7 @@ WHERE S.HANDLE=#{handle}