diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesOrgService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesOrgService.java index 04ae68c..a0432ae 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesOrgService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesOrgService.java @@ -14,4 +14,7 @@ import java.util.List; public interface IMesOrgService { List queryMesOrg(MesOrg mesOrg); + + List queryMesOrgSplit(MesOrg mesOrg); + } diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesPartPackageTypeService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesPartPackageTypeService.java new file mode 100644 index 0000000..c13ebf4 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesPartPackageTypeService.java @@ -0,0 +1,7 @@ +package cn.estsh.i3plus.ext.mes.pcn.api.base; + +import cn.estsh.i3plus.pojo.mes.bean.MesPartPackageType; + +public interface IMesPartPackageTypeService { + MesPartPackageType getMesPartPackageType(String organizeCode, String packageTypeCode); +} diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesShippingKanbanCfgService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesShippingKanbanCfgService.java index 4864b29..61687bb 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesShippingKanbanCfgService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesShippingKanbanCfgService.java @@ -4,7 +4,7 @@ import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesShippingKanbanCfgModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesShippingKanbanModel; public interface IMesShippingKanbanCfgService { - MesShippingKanbanCfgModel queryShippingKanbanCfg(String organizeCode); + MesShippingKanbanCfgModel queryShippingKanbanCfg(String organizeCode, String shippingGroupCode); void doSaveShippingKanbanCfg(MesShippingKanbanCfgModel request, String organizeCode, String username); - MesShippingKanbanModel queryShippingKanbanContext(String organizeCode); + MesShippingKanbanModel queryShippingKanbanContext(String organizeCode, String shippingGroupCode); } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesOrgController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesOrgController.java index f3fc87b..d1c09fc 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesOrgController.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesOrgController.java @@ -39,4 +39,19 @@ public class MesOrgController { return ResultBean.fail(e); } } + + @GetMapping(value = "/query-split") + @ApiOperation(value = "查询责任人区域关系(拆分责任人)") + public ResultBean queryMesOrgSplit(MesOrg mesOrg) { + try { + List mesOrgList= mesOrgService.queryMesOrgSplit(mesOrg); + return ResultBean.success("查询成功") + .setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(mesOrgList); + } catch (ImppBusiException e) { + return ResultBean.fail(e).build(); + } catch (Exception e) { + return ResultBean.fail(e); + } + } + } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesShippingKanbanCfgController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesShippingKanbanCfgController.java index c687281..c367bc8 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesShippingKanbanCfgController.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesShippingKanbanCfgController.java @@ -26,10 +26,10 @@ public class MesShippingKanbanCfgController { @GetMapping("/query") @ApiOperation(value = "查询发运看板配置项") - public ResultBean queryShippingKanbanCfg(String organizeCode) { + public ResultBean queryShippingKanbanCfg(String organizeCode, String shippingGroupCode) { try { organizeCode = !StringUtils.isEmpty(organizeCode) ? organizeCode : AuthUtil.getOrganize().getOrganizeCode(); - return ResultBean.success("查询成功").setResultObject(shippingKanbanCfgService.queryShippingKanbanCfg(organizeCode)); + return ResultBean.success("查询成功").setResultObject(shippingKanbanCfgService.queryShippingKanbanCfg(organizeCode, shippingGroupCode)); } catch (ImppBusiException imppException) { return ResultBean.fail(imppException); } catch (Exception e) { @@ -53,10 +53,10 @@ public class MesShippingKanbanCfgController { @GetMapping("/queryContext") @ApiOperation(value = "查询发运看板内容") - public ResultBean queryShippingKanbanContext(String organizeCode) { + public ResultBean queryShippingKanbanContext(String organizeCode, String shippingGroupCode) { try { organizeCode = !StringUtils.isEmpty(organizeCode) ? organizeCode : AuthUtil.getOrganize().getOrganizeCode(); - return ResultBean.success("查询成功").setResultObject(shippingKanbanCfgService.queryShippingKanbanContext(organizeCode)); + return ResultBean.success("查询成功").setResultObject(shippingKanbanCfgService.queryShippingKanbanContext(organizeCode, shippingGroupCode)); } catch (ImppBusiException imppException) { return ResultBean.fail(imppException); } catch (Exception e) { diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesOrgServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesOrgServiceImpl.java index b43c8d9..1e9141d 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesOrgServiceImpl.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesOrgServiceImpl.java @@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; @@ -39,4 +40,36 @@ public class MesOrgServiceImpl implements IMesOrgService { return mesOrgRDao.findByHqlWhere(packBean); } + + @Override + public List queryMesOrgSplit(MesOrg mesOrg) { + DdlPackBean packBean = DdlPackBean.getDdlPackBean(mesOrg.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(mesOrg.getInventoryLocationCode(), "inventoryLocationCode", packBean); + if(StringUtil.isEmpty(mesOrg.getResponsibleParty())){ + DdlPreparedPack.getIsNotNull( "responsibleParty", packBean); + }else { + DdlPreparedPack.getStringEqualPack(mesOrg.getResponsibleParty(), "responsibleParty", packBean); + } + packBean.setOrderByStr(mesOrg.orderBy()); + List mesOrgList = mesOrgRDao.findByHqlWhere(packBean); + List resultList = new ArrayList<>(); + for (MesOrg org : mesOrgList) { + String responsibleParty = org.getResponsibleParty(); + if (StringUtil.isEmpty(responsibleParty)) { + resultList.add(org); + }else { + if (responsibleParty.contains(",")) { + String[] split = responsibleParty.split(","); + for (int i = 0; i < split.length; i++) { + org.setResponsibleParty(split[i]); + resultList.add(org); + } + }else { + resultList.add(org); + } + } + } + return resultList; + } + } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesPartPackageTypeServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesPartPackageTypeServiceImpl.java new file mode 100644 index 0000000..d043263 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesPartPackageTypeServiceImpl.java @@ -0,0 +1,27 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.base; + +import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPartPackageTypeService; +import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; +import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; +import cn.estsh.i3plus.pojo.mes.bean.MesPartPackageType; +import cn.estsh.i3plus.pojo.mes.repository.IMesPartPackageTypeRepository; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @author jason + */ +@Service +@Slf4j +public class MesPartPackageTypeServiceImpl implements IMesPartPackageTypeService { + @Autowired + private IMesPartPackageTypeRepository partPackageTypeRDao; + + @Override + public MesPartPackageType getMesPartPackageType(String organizeCode, String packageTypeCode) { + DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getStringEqualPack(packageTypeCode, "packageTypeCode", packBean); + return partPackageTypeRDao.getByProperty(packBean); + } +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java index 44c3142..e6e40e8 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java @@ -573,11 +573,11 @@ public class MesNcProcessingService implements IMesNcProcessingService { } //更新检验单 - DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); - DdlPreparedPack.getStringEqualPack(areaCode, "inventoryLocationCode", packBean); - MesOrg mesOrg = mesOrgRDao.getByProperty(packBean); +// DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); +// DdlPreparedPack.getStringEqualPack(areaCode, "inventoryLocationCode", packBean); +// MesOrg mesOrg = mesOrgRDao.getByProperty(packBean); //报废时设置责任人 - model.getPartInspection().setResponsibleParty(StringUtil.isEmpty(mesOrg)?areaCode:mesOrg.getResponsibleParty()); + model.getPartInspection().setResponsibleParty(model.getOnlyPerson()); model.getPartInspection().setDefectTypeId(person.getId()); model.getPartInspection().setNcStatus(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.SCRAP.getValue()); model.getPartInspection().setRejectQty(model.getPartInspection().getQty()); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesShippingKanbanCfgServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesShippingKanbanCfgServiceImpl.java index c189975..7e699dc 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesShippingKanbanCfgServiceImpl.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesShippingKanbanCfgServiceImpl.java @@ -54,17 +54,19 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer private EntityManager entityManager; @Override - public MesShippingKanbanCfgModel queryShippingKanbanCfg(String organizeCode) { + public MesShippingKanbanCfgModel queryShippingKanbanCfg(String organizeCode, String shippingGroupCode) { MesShippingKanbanCfgModel model = new MesShippingKanbanCfgModel(); DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getStringEqualPack(shippingGroupCode, "shippingGroupCode", packBean); MesShippingKanbanCfg kanbanCfg = shippingKanbanCfgRDao.getByProperty(packBean); if (kanbanCfg != null) { DdlPackBean detailPackBean = DdlPackBean.getDdlPackBean(organizeCode); - DdlPreparedPack.getNumEqualPack(kanbanCfg.getId(), "configID", packBean); + DdlPreparedPack.getNumEqualPack(kanbanCfg.getId(), "configID", detailPackBean); List details = shippingKanbanCfgDetailRDao.findByHqlWhere(detailPackBean); model.setDetails(details); } else { kanbanCfg = new MesShippingKanbanCfg(); + kanbanCfg.setShippingGroupCode(shippingGroupCode); } model.setConfig(kanbanCfg); @@ -95,13 +97,13 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer MesShippingKanbanCfg cfg = request.getConfig(); DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getStringEqualPack(cfg.getShippingGroupCode(), "shippingGroupCode", packBean); MesShippingKanbanCfg oldCfg = shippingKanbanCfgRDao.getByProperty(packBean); if (oldCfg == null) { cfg.setOrganizeCode(organizeCode); ConvertBean.serviceModelInitialize(cfg, username); oldCfg = shippingKanbanCfgRDao.insert(cfg); } else { - oldCfg.setShippingGroupCode(cfg.getShippingGroupCode()); oldCfg.setRefreshFrequency(cfg.getRefreshFrequency()); oldCfg.setKanbanName(cfg.getKanbanName()); oldCfg.setOnlinePoint(cfg.getOnlinePoint()); @@ -130,11 +132,11 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer } @Override - public MesShippingKanbanModel queryShippingKanbanContext(String organizeCode) { + public MesShippingKanbanModel queryShippingKanbanContext(String organizeCode, String shippingGroupCode) { MesShippingKanbanModel model = new MesShippingKanbanModel(); Map cfgDetailMap = null; - MesShippingKanbanCfgModel cfgModel = queryShippingKanbanCfg(organizeCode); + MesShippingKanbanCfgModel cfgModel = queryShippingKanbanCfg(organizeCode, shippingGroupCode); MesShippingKanbanCfg cfg = cfgModel != null ? cfgModel.getConfig() : null; if (cfg == null) { return model; @@ -1086,10 +1088,17 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer .getSingleResult(); if (vpCount == null || Objects.equals(vpCount, 0L)) { - values.add(cfg.getCustJph()); + if (!StringUtils.isEmpty(cfg.getCustJph())) { + values.add(cfg.getCustJph()); + } + } else { values.add(vpCount.toString()); } + + if (values.isEmpty()) { + values.add("1"); + } return values; } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesShippingLoadingCheckService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesShippingLoadingCheckService.java index 72e07cb..00aad84 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesShippingLoadingCheckService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesShippingLoadingCheckService.java @@ -228,9 +228,9 @@ public class MesShippingLoadingCheckService implements IMesShippingLoadingCheckS //装车单明细 List vehiclesOrderDetailList = model.getDetailList(); vehiclesOrderDetailList.forEach(k -> { - if(MesExtEnumUtil.LOADING_ORDER_DETAIL_SHIPPING_STATUS.SHIPPINGED.getValue() == k.getStatus()){ - k.setStatus(MesExtEnumUtil.LOADING_ORDER_DETAIL_SHIPPING_STATUS.PUBLISHED.getValue()); // todo 不改变为发运状态 - } +// if(MesExtEnumUtil.LOADING_ORDER_DETAIL_SHIPPING_STATUS.SHIPPINGED.getValue() == k.getStatus()){ +// k.setStatus(MesExtEnumUtil.LOADING_ORDER_DETAIL_SHIPPING_STATUS.PUBLISHED.getValue()); // todo 不改变为发运状态 +// } k.setSystemSyncStatus(CommonEnumUtil.FALSE); ConvertBean.serviceModelUpdate(k, userInfo); }); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesSortShippingCheckService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesSortShippingCheckService.java index 21809f9..94771c8 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesSortShippingCheckService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesSortShippingCheckService.java @@ -150,6 +150,7 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService if (!StringUtils.isEmpty(orderManagement.getCheckSeqCode())) { model.setIsScanLocationCode(true); } + model.setVolvoRackNo(orderManagement.getRackNo()); //发运单号 model.setShippingCode(orderManagement.getShippingCode()); //零件发运组 @@ -329,8 +330,6 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService shippingOrderManagementDetailRepository.update(detail); break; } - - final String confirmPartType = getConfirmPartType(orderManagement); } if (!scanFlg) { @@ -617,7 +616,7 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService DdlPreparedPack.getStringEqualPack(model.getVolvoRackNo(), "barCode", rackPackBean); MesVolvoRack volvoRack = mesVolvoRackRDao.getByProperty(rackPackBean); if (volvoRack == null) { - throw new ImppBusiException(String.format("无效料架条码【%s】,请重新扫描!", model.getVolvoRackNo())); + throw new ImppBusiException(String.format("无效料架条码【%s】,请检查数据!", model.getVolvoRackNo())); } } @@ -638,24 +637,28 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService orderManagement.getStatus() == MesExtEnumUtil.SHIPPING_ORDER_STATUS.PUBLISHED.getValue()) { orderManagement.setStartScanTime(TimeTool.getNowTime(true)); } - //根据发运单查询装车单明细信息 - DdlPackBean packBean = DdlPackBean.getDdlPackBean(orderManagement.getOrganizeCode()); - DdlPreparedPack.getStringEqualPack(orderManagement.getShippingCode(),"shippingCode",packBean); - MesLoadingListDetail listDetail = listDetailRepository.getByProperty(packBean); MesLoadingList loadingList = null; - if(!Objects.isNull(listDetail)){ - packBean = DdlPackBean.getDdlPackBean(orderManagement.getOrganizeCode()); - DdlPreparedPack.getNumEqualPack(listDetail.getPid(), "id", packBean); - loadingList = listRepository.getByProperty(packBean); - //反填装车单信息到发运单 - if(!Objects.isNull(loadingList)){ - orderManagement.setOrderCode(loadingList.getOrderCode()); - orderManagement.setLoadingListId(loadingList.getId()); + //零件发运组 + MesPartShippingGroup shippingGroup = Objects.isNull(model.getMesPartShippingGroup()) ? getMesPartShippingGroup(orderManagement.getOrganizeCode(), orderManagement.getShippingGroupCode()) : model.getMesPartShippingGroup(); + //根据发运单查询装车单明细信息 + if (Objects.equals(shippingGroup.getIsFirstInstall(), CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue())) { + DdlPackBean packBean = DdlPackBean.getDdlPackBean(orderManagement.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(orderManagement.getShippingCode(),"shippingCode",packBean); + MesLoadingListDetail listDetail = listDetailRepository.getByProperty(packBean); + if(!Objects.isNull(listDetail)){ + packBean = DdlPackBean.getDdlPackBean(orderManagement.getOrganizeCode()); + DdlPreparedPack.getNumEqualPack(listDetail.getPid(), "id", packBean); + loadingList = listRepository.getByProperty(packBean); + //反填装车单信息到发运单 + if(!Objects.isNull(loadingList)){ + orderManagement.setOrderCode(loadingList.getOrderCode()); + orderManagement.setLoadingListId(loadingList.getId()); + } + //更新装车单明细对应的发运单状态=发运 + listDetail.setStatus(MesExtEnumUtil.LOADING_ORDER_DETAIL_SHIPPING_STATUS.SHIPPINGED.getValue()); + ConvertBean.serviceModelUpdate(listDetail, userInfo); + listDetailRepository.update(listDetail); } - //更新装车单明细对应的发运单状态=发运 - listDetail.setStatus(MesExtEnumUtil.LOADING_ORDER_DETAIL_SHIPPING_STATUS.SHIPPINGED.getValue()); - ConvertBean.serviceModelUpdate(listDetail, userInfo); - listDetailRepository.update(listDetail); } //发运单状态修改为校验完成 orderManagement.setSystemSyncStatus(CommonEnumUtil.FALSE); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/shippingscan/strategy/mesShippingCheckVolvoRackNoAndPartNoStrategyServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/shippingscan/strategy/mesShippingCheckVolvoRackNoAndPartNoStrategyServiceImpl.java index 628a676..c3a839d 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/shippingscan/strategy/mesShippingCheckVolvoRackNoAndPartNoStrategyServiceImpl.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/shippingscan/strategy/mesShippingCheckVolvoRackNoAndPartNoStrategyServiceImpl.java @@ -89,6 +89,7 @@ public class mesShippingCheckVolvoRackNoAndPartNoStrategyServiceImpl implements if (Objects.equals(detail.getVin(), workOrder.getVinCode())) { throw new ImppBusiException(String.format("产品条码明细【%s】与发运单明细不匹配,请重新扫描!", model.getSn())); } + checkDetailScanSeq(orderManagement, detail, workOrder); //校验发运明细 checkShippingDetails(model, orderManagement, shippingGroup, produceSn, detail); scanFlg = true; @@ -104,6 +105,16 @@ public class mesShippingCheckVolvoRackNoAndPartNoStrategyServiceImpl implements return model; } + private void checkDetailScanSeq(MesShippingOrderManagement orderManagement, MesShippingOrderManagementDetail detail, MesWorkOrder workOrder) { + if (StringUtils.isEmpty(workOrder.getWorkOrderSource())) { + throw new ImppBusiException(String.format("工单【%s】缺少来源!", workOrder.getWorkOrderNo())); + } + MesCustSortInfo custSoftInfo = custSoftInfoRDao.getById(Long.parseLong(workOrder.getWorkOrderSource())); + if (custSoftInfo == null || !Objects.equals(detail.getCustInfoSeq(), custSoftInfo.getCustInfoSeq())) { + throw new ImppBusiException(String.format("发运单【%s】启用明细顺序防错,序号【%s】前还有未扫描的发运单明细,请检查数据!", orderManagement.getShippingCode(), custSoftInfo.getCustInfoSeq())); + } + } + private void checkShippingDetails(MesSortShippingCheckModel model, MesShippingOrderManagement orderManagement, MesPartShippingGroup shippingGroup, MesProduceSn produceSn, MesShippingOrderManagementDetail detail) { @@ -124,14 +135,14 @@ public class mesShippingCheckVolvoRackNoAndPartNoStrategyServiceImpl implements } //校验客户零件信息是否存在 (默认需要验证, 值可能是[空/0/20]) -// if (StringUtils.isEmpty(shippingGroup.getScanMethodJudgment()) || !shippingGroup.getScanMethodJudgment().equals(MesExtEnumUtil.SHIPPING_GROUP_SCAN_METHOD_JUDGMENT.PART_NO.getValueStr())) { -// DdlPackBean packBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode()); -// DdlPreparedPack.getStringEqualPack(detail.getPartNo(), "erpPartNo", packBean); -// DdlPreparedPack.getStringEqualPack(detail.getCustPartNo(), "custPartNo", packBean); -// if (!mesCustomerPartRepository.isExitByHql(packBean)) { -// throw new ImppBusiException(String.format("零件号【%s】客户零件号【%s】关系不存在,请检查数据!", detail.getPartNo(), detail.getCustPartNo())); -// } -// } + if (StringUtils.isEmpty(shippingGroup.getScanMethodJudgment()) || !shippingGroup.getScanMethodJudgment().equals(MesExtEnumUtil.SHIPPING_GROUP_SCAN_METHOD_JUDGMENT.PART_NO.getValueStr())) { + DdlPackBean packBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(detail.getPartNo(), "erpPartNo", packBean); + DdlPreparedPack.getStringEqualPack(detail.getCustPartNo(), "custPartNo", packBean); + if (!mesCustomerPartRepository.isExitByHql(packBean)) { + throw new ImppBusiException(String.format("零件号【%s】客户零件号【%s】关系不存在,请检查数据!", detail.getPartNo(), detail.getCustPartNo())); + } + } } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/XiaoPengNumberRule2StrategyService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/XiaoPengNumberRule2StrategyService.java new file mode 100644 index 0000000..ebe7328 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/XiaoPengNumberRule2StrategyService.java @@ -0,0 +1,67 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.numberrule; + +import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException; +import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; +import cn.estsh.i3plus.mes.pcn.api.iservice.busi.INumberRulePackAttributeStrategyService; +import cn.estsh.i3plus.platform.common.tool.TimeTool; +import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; +import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; +import cn.estsh.i3plus.pojo.mes.bean.MesCustomerPart; +import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel; +import cn.estsh.i3plus.pojo.mes.repository.MesCustomerPartRepository; +import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; + +import java.util.Date; +import java.util.Map; + +@Component +public class XiaoPengNumberRule2StrategyService implements INumberRulePackAttributeStrategyService { + + @Autowired + private MesCustomerPartRepository customerPartRepository; + + @Override + public GenSerialNoModel execute(GenSerialNoModel genSerialNoModel) { + + Map dataMap = genSerialNoModel.getDataMap(); + MesCustomerPart customerPart = (!CollectionUtils.isEmpty(dataMap) && dataMap.containsKey(MesCustomerPart.class.getSimpleName())) ? + (MesCustomerPart)dataMap.get(MesCustomerPart.class.getSimpleName()) : getMesCustomerPart(genSerialNoModel.getOrganizeCode(), genSerialNoModel.getPartNo()); + if (null != customerPart) { + genSerialNoModel.setCustPartNo(customerPart.getCustPartNo()); + }else { + MesPcnException.throwMesBusiException("请检查客户零件信息,零件[%s]客户零件关系未维护", genSerialNoModel.getPartNo()); + } + + //年月日缩写 + Date date = new Date(); + genSerialNoModel.setYear(getYearShort(date)); + genSerialNoModel.setMonth(getMonthShort(date)); + genSerialNoModel.setDay(getDayShort(date)); + return genSerialNoModel; + } + + private String getYearShort(Date date) { + return MesExtEnumUtil.YEAR_SHORT2.valueOfDescription(Integer.parseInt(TimeTool.getYear(date))); + } + + private String getMonthShort(Date date) { + return MesExtEnumUtil.MONTH_SHORT2.valueOfDescription(Integer.parseInt(TimeTool.getMonth(date))); + } + + private String getDayShort(Date date) { + return MesExtEnumUtil.DAY_SHORT2.valueOfDescription(Integer.parseInt(TimeTool.getDay(date))); + } + + private MesCustomerPart getMesCustomerPart(String orgaizeCode, String partNo) { + if (StringUtils.isEmpty(orgaizeCode) || StringUtils.isEmpty(partNo)) return null; + DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(orgaizeCode); + DdlPreparedPack.getStringEqualPack(partNo, MesPcnExtConstWords.ERP_PART_NO, ddlPackBean); + MesCustomerPart customerPart = customerPartRepository.getByProperty(ddlPackBean); + return customerPart; + } + +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/sortshipping/strategy/ChengDuVolvoShippingPrintStrategyService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/sortshipping/strategy/ChengDuVolvoShippingPrintStrategyService.java new file mode 100644 index 0000000..449860f --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/sortshipping/strategy/ChengDuVolvoShippingPrintStrategyService.java @@ -0,0 +1,164 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.sortshipping.strategy; + +import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPartPackageTypeService; +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesPartShippingGroupService; +import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService; +import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; +import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil; +import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; +import cn.estsh.i3plus.pojo.mes.bean.MesPart; +import cn.estsh.i3plus.pojo.mes.bean.MesPartPackageType; +import cn.estsh.i3plus.pojo.mes.bean.MesPartShippingGroup; +import cn.estsh.i3plus.pojo.mes.bean.edi.cd.MesCimVolvoJisRackId; +import cn.estsh.i3plus.pojo.mes.bean.edi.cd.MesCimVolvoJisRackIdDetail; +import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement; +import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagementDetail; +import cn.estsh.i3plus.pojo.mes.model.ChengDuVolvoShippingPrintModel; +import cn.estsh.i3plus.pojo.mes.repository.MesPartRepository; +import cn.estsh.i3plus.pojo.mes.repository.MesShippingOrderManagementDetailRepository; +import cn.estsh.i3plus.pojo.mes.repository.edi.cd.MesCimVolvoJisRackIdDetailRepository; +import cn.estsh.i3plus.pojo.mes.repository.edi.cd.MesCimVolvoJisRackIdRepository; +import cn.estsh.impp.framework.boot.auth.AuthUtil; +import cn.estsh.impp.framework.boot.util.ResultBean; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * @Description : 成都volvo发运单打印策略 + * @Reference : + * @Author : jason.niu + * @CreateDate : 2025/03/20 16:43 + * @Modify: + **/ +@Component +@Slf4j +public class ChengDuVolvoShippingPrintStrategyService implements IPrintTemplateStrategyService { + @Autowired + private MesShippingOrderManagementDetailRepository shippingOrderDetailRDao; + @Autowired + private MesCimVolvoJisRackIdRepository rackIdRDao; + @Autowired + private MesCimVolvoJisRackIdDetailRepository rackIdDetailRDao; + @Autowired + private MesPartRepository partRDao; + @Autowired + private IMesPartShippingGroupService shippingGroupService; + @Autowired + private IMesPartPackageTypeService partPackageTypeService; + + @Override + public ResultBean execute(MesShippingOrderManagement bean, List shippingOrderManagementList) { + List modelList = new ArrayList<>(); + for (MesShippingOrderManagement loadingList : shippingOrderManagementList) { + ChengDuVolvoShippingPrintModel model = getPrintData(loadingList); + if (model != null) { + modelList.add(model); + } + } + return ResultBean.success("装车单打印成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(modelList); + } + + private ChengDuVolvoShippingPrintModel getPrintData(MesShippingOrderManagement shippingOrder) { + final String organizeCode = AuthUtil.getOrganize().getOrganizeCode(); + final String userName = AuthUtil.getSessionUser().getUserName(); + + ChengDuVolvoShippingPrintModel model = new ChengDuVolvoShippingPrintModel(); + DdlPackBean shippingDetailPackBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getNumEqualPack(shippingOrder.getId(), "pid", shippingDetailPackBean); + List shippingDetails = shippingOrderDetailRDao.findByHqlWhere(shippingDetailPackBean); + if (CollectionUtils.isEmpty(shippingDetails)) { + return null; + } + + List partNos = new ArrayList<>(); + List rackDetailIdList = new ArrayList<>(); + for (MesShippingOrderManagementDetail shippingDetail : shippingDetails) { + if (shippingDetail.getSourceId() != null) { + rackDetailIdList.add(shippingDetail.getSourceId()); + } + if (!partNos.contains(shippingDetail.getPartNo())) { + partNos.add(shippingDetail.getPartNo()); + } + } + DdlPackBean rackDetailPackBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getInPackList(rackDetailIdList, "id", rackDetailPackBean); + List rackIdDetails = rackIdDetailRDao.findByHqlWhere(rackDetailPackBean); + if (CollectionUtils.isEmpty(rackIdDetails)) { + return null; + } + + List rackIdList = new ArrayList<>(); + for (MesCimVolvoJisRackIdDetail rackIdDetail : rackIdDetails) { + if (rackIdDetail.getJisRackIdFid() != null && !rackIdList.contains(rackIdDetail.getJisRackIdFid())) { + rackIdList.add(rackIdDetail.getJisRackIdFid()); + } + } + DdlPackBean rackPackBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getInPackList(rackIdList, "id", rackPackBean); + List rackIds = rackIdRDao.findByHqlWhere(rackPackBean); + if (CollectionUtils.isEmpty(rackIds)) { + return null; + } + + // 净重 + double totalNetWeight = 0.0; + // 净重单位 + String netWom = ""; + // 包装重量 + double packageWeight = 0.0; + // 包装重量单位 + String tmpGwUom = ""; + DdlPackBean partPackBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getInPackList(partNos, "partNo", rackPackBean); + List parts = partRDao.findByHqlWhere(partPackBean); + if (!CollectionUtils.isEmpty(parts)) { + for (MesPart mesPart : parts) { + if (mesPart.getNetWeight() != null) { + totalNetWeight += mesPart.getNetWeight(); + } + netWom = mesPart.getWeightUom(); + } + } + MesPartShippingGroup shippingGroup = shippingGroupService.getMesPartShippingGroup(organizeCode, shippingOrder.getShippingGroupCode()); + if (shippingGroup != null && !StringUtils.isEmpty(shippingGroup.getPackageTypeCode()) && (shippingGroup.getPackageTypeCode().startsWith("P") || shippingGroup.getPackageTypeCode().startsWith("p"))) { + MesPartPackageType partPackageType = partPackageTypeService.getMesPartPackageType(organizeCode, shippingGroup.getPackageTypeCode()); + if (partPackageType != null) { + packageWeight = partPackageType.getNetWeight() != null ? partPackageType.getNetWeight() : 0; + tmpGwUom = partPackageType.getWeightUom(); + } + } + + MesCimVolvoJisRackId rackId = rackIds.get(0); + model.setRecelver(rackId.getShipToId()); + model.setDock(rackId.getIdForPlaceOfDischarge()); + model.setAdviceNoteNo(rackId.getAsnNo()); + model.setAdviceNoteBarCode(rackId.getAsnNo()); + model.setSupplierAddress(StringUtils.isEmpty(rackId.getShipFrom()) ? rackId.getShipFromId() : rackId.getShipFrom()); + model.setNetWeight(String.format("%.2f", totalNetWeight)); + model.setNWUom(netWom); + model.setGrossWeight(String.format("%.2f", totalNetWeight + packageWeight)); + model.setGWUom(tmpGwUom); + model.setRackId(rackId.getJisRackId()); + model.setRackBarCode(rackId.getJisRackId()); + model.setFirstPreNo(rackId.getFirstSequenceNumber()); + model.setFirstPreBarCode(rackId.getFirstSequenceNumber()); + model.setLastPreNo(rackId.getLastSequenceNumber()); + model.setLastPreBarCode(rackId.getLastSequenceNumber()); + model.setSupplierID(rackId.getSellerId()); + model.setSupplierBarCode(rackId.getSellerId()); + model.setCountryOfOrigin("CN"); + model.setNoofCars(rackDetailIdList.size()); + model.setDescription(rackId.getRackReference()); + model.setPackageId(rackId.getJisRackId()); + model.setPackageBarCode(rackId.getJisRackId()); + model.setProcess("LDJIS"); + + return model; + } +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/ChengDuVolvoPartPrintStrategy.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/ChengDuVolvoPartPrintStrategy.java new file mode 100644 index 0000000..816af80 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/ChengDuVolvoPartPrintStrategy.java @@ -0,0 +1,169 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.strategy; + +import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesCustomerPartService; +import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPartService; +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesPrintedSnLogService; +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesWorkOrderService; +import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService; +import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintDataModel; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel; +import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; +import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService; +import cn.estsh.i3plus.mes.pcn.util.DateUtil; +import cn.estsh.i3plus.platform.common.convert.ConvertBean; +import cn.estsh.i3plus.platform.common.tool.TimeTool; +import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker; +import cn.estsh.i3plus.pojo.mes.bean.*; +import cn.estsh.i3plus.pojo.mes.bean.edi.cd.MesCimVolvoJisRackId; +import cn.estsh.i3plus.pojo.mes.bean.edi.cd.MesCimVolvoJisRackIdDetail; +import cn.estsh.i3plus.pojo.mes.bean.shipping.MesCustSortInfo; +import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel; +import cn.estsh.i3plus.pojo.mes.model.StationRequestBean; +import cn.estsh.i3plus.pojo.mes.model.StepResult; +import cn.estsh.i3plus.pojo.mes.repository.MesCustSoftInfoRepository; +import cn.estsh.i3plus.pojo.mes.repository.edi.cd.MesCimVolvoJisRackIdDetailRepository; +import cn.estsh.i3plus.pojo.mes.repository.edi.cd.MesCimVolvoJisRackIdRepository; +import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; + +import java.util.*; + +/** + * @Description : 成都volvo零件标签打印 + * @Reference : + * @Author : jason.niu + * @CreateDate : 2025/03/20 16:43 + * @Modify: + **/ +@Component +@Slf4j +public class ChengDuVolvoPartPrintStrategy implements IPrintTemplateStrategyService { + @Autowired + private ISyncFuncService syncFuncService; + + @Autowired + private SnowflakeIdMaker snowflakeIdMaker; + + @Autowired + private IMesPartService mesPartService; + + @Autowired + private IMesPrintedSnLogService mesPrintedSnLogService; + + @Autowired + private IMesCustomerPartService mesCustomerPartService; + @Autowired + private IMesWorkOrderService mesWorkOrderService; + @Autowired + private MesCustSoftInfoRepository custSoftInfoRDao; + @Autowired + private MesCimVolvoJisRackIdDetailRepository rackIdDetailRDao; + @Autowired + private MesCimVolvoJisRackIdRepository volvoJisRackIdRDao; + + @Override + public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep) { + String organizeCode = mesProduceSnPrintModel.getOrganizeCode(); + //物料信息 + MesPart mesPart = mesPartService.getMesPartByPartNo(mesProduceSnPrintModel.getPartNo(), organizeCode); + MesCustomerPart customerPart = (!Objects.isNull(genSerialNoModel) && !CollectionUtils.isEmpty(genSerialNoModel.getDataMap()) && genSerialNoModel.getDataMap().containsKey(MesCustomerPart.class.getSimpleName())) ? (MesCustomerPart) genSerialNoModel.getDataMap().get(MesCustomerPart.class.getSimpleName()) : mesCustomerPartService.getMesCustomerPart(organizeCode,mesProduceSnPrintModel.getPartNo()); + if (!isStep){ + MesPcnException.throwBusiException("成都volvo零件标签打印只支持工位端打印!"); + } + + MesProduceSn mesProduceSn = mesProduceSnPrintModel.getMesProduceSnList().get(0); + //封装打印信息 + MesProduceSnPrintDataModel printDataModel = getModel(mesProduceSn, customerPart); + mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().clear(); + Map printTemplateData = new HashMap<>(getPrintContextMap(mesProduceSn, customerPart)); + List> printDataMapList = new ArrayList<>(); + printDataMapList.add(printTemplateData); + mesProduceSnPrintModel.getPrintContextList().add(packResultMap(mesProduceSnPrintModel, printDataMapList)); + + //保存打印记录 + mesProduceSnPrintModel.getMesPrintedSnLogList().add(mesPrintedSnLogService.getMesCustomPrintedSnLog(mesProduceSnPrintModel.getUserName(), organizeCode, printDataModel, printTemplateData)); + return mesProduceSnPrintModel; + } + + private MesProduceSn generateMesProduceSn(MesPart mesPart, String sn, String userName, Double qty) { + MesProduceSn mesProduceSn = new MesProduceSn(); + mesProduceSn.setSerialNumber(snowflakeIdMaker.nextId() + ""); + mesProduceSn.setProductSn(sn); + mesProduceSn.setCustSn(sn); + mesProduceSn.setPartNo(mesPart.getPartNo()); + mesProduceSn.setPartName(mesPart.getPartName()); + mesProduceSn.setProcessLabelTemplate(mesPart.getProcessLabelTemplate()); + mesProduceSn.setCustLabelTemplate(mesPart.getCustLabelTemplate()); + mesProduceSn.setProdLabelTemplate(mesPart.getProductLabelTemplate()); + mesProduceSn.setQty(qty); + mesProduceSn.setSnStatus(MesExtEnumUtil.PRODUCE_SN_STATUS.CREATE.getValue()); + mesProduceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue()); + mesProduceSn.setLotNo(TimeTool.getToday()); + mesProduceSn.setPrintCount(MesPcnExtConstWords.ONE); + mesProduceSn.setPrintStatus(MesExtEnumUtil.PRINT_STATUS.PRINTED.getValue()); + mesProduceSn.setOrganizeCode(mesPart.getOrganizeCode()); + ConvertBean.serviceModelInitialize(mesProduceSn, userName); + return mesProduceSn; + } + + private MesProduceSnPrintDataModel getModel(MesProduceSn produceSn, MesCustomerPart customerPart) { + MesProduceSnPrintDataModel mesProduceSnPrintDataModel = new MesProduceSnPrintDataModel(); + mesProduceSnPrintDataModel.setPartNo(produceSn.getPartNo()); + mesProduceSnPrintDataModel.setPartName(produceSn.getPartName()); + if (!Objects.isNull(customerPart)) { + mesProduceSnPrintDataModel.setCustPartNo(customerPart.getCustPartNo()); + } + mesProduceSnPrintDataModel.setBarcode(produceSn.getProductSn()); + mesProduceSnPrintDataModel.setPrintDate(TimeTool.getNowTime(true)); + mesProduceSnPrintDataModel.setUserName(produceSn.getCreateUser()); + mesProduceSnPrintDataModel.setProductDate(TimeTool.parseStringFormat(produceSn.getLotNo(), DateUtil.SHORT_FORMAT, "yyyy/MM/dd")); + return mesProduceSnPrintDataModel; + } + + private Map getPrintContextMap(MesProduceSn produceSn, MesCustomerPart customerPart) { + MesWorkOrder workOrder = mesWorkOrderService.getWorkOrderNoByCustSn(produceSn.getOrganizeCode(), produceSn.getProductSn()); + if (workOrder == null || StringUtils.isEmpty(workOrder.getWorkOrderSource())) { + MesPcnException.throwBusiException("客户条码[%s]对应的工单信息不存在!", produceSn.getProductSn()); + } + + MesCustSortInfo custSoftInfo = custSoftInfoRDao.getById(Long.parseLong(workOrder.getWorkOrderSource())); + if (custSoftInfo == null) { + MesPcnException.throwBusiException("工单[%s]无法匹配客户排序信息!", workOrder.getWorkOrderNo()); + } + MesCimVolvoJisRackIdDetail rackIdDetail = rackIdDetailRDao.getById(custSoftInfo.getSourceId()); + if (rackIdDetail == null) { + MesPcnException.throwBusiException("工单[%s]客户排序信息无法匹配RackIdDetail!", workOrder.getWorkOrderNo()); + } + MesCimVolvoJisRackId rackId = volvoJisRackIdRDao.getById(rackIdDetail.getJisRackIdFid()); + if (rackId == null) { + MesPcnException.throwBusiException("工单[%s]客户排序信息无法匹配RackId!", workOrder.getWorkOrderNo()); + } + + Map result = new HashMap<>(); + result.put(MesPcnExtConstWords.VOLVO_CONSIGNMENT_REFERENCE, rackId.getConsignmentReference()); + result.put(MesPcnExtConstWords.PRODUCT_DATE, TimeTool.getNowTime("yyyyMMdd HH:mm")); + result.put(MesPcnExtConstWords.VOLVO_FYON, rackIdDetail.getFyon()); + result.put(MesPcnExtConstWords.VOLVO_SEQUENCENUMBER, rackIdDetail.getSequenceNumber()); + result.put(MesPcnExtConstWords.VOLVO_RACKID, rackId.getJisRackId()); + result.put(MesPcnExtConstWords.VOLVO_POSITION, rackIdDetail.getPosition()); + result.put(MesPcnExtConstWords.CUST_PART_NO, custSoftInfo.getCustPartNo()); + result.put(MesPcnExtConstWords.PRINT_BAR_CODE, produceSn.getProductSn()); + result.put(MesPcnExtConstWords.PRINT_DATE, TimeTool.getNowTime(true)); + result.put(MesPcnExtConstWords.USER_NAME, produceSn.getCreateUser()); + return result; + } + + private Map packResultMap(MesProduceSnPrintModel printModel, List> printTemplateDateList) { + Map resultMap = new HashMap<>(); + resultMap.put(MesPcnExtConstWords.LABEL_TEMPLATE, printModel.getMesLabelTemplate()); + resultMap.put(MesPcnExtConstWords.TEMPLATE_DATA, printTemplateDateList); + resultMap.put(MesPcnExtConstWords.TEMPLATE_CODE, printModel.getMesLabelTemplate().getTemplateCode()); + resultMap.put(MesPcnExtConstWords.PRINTER, printModel.getPrinter()); + return resultMap; + } +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyShowNosortStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyShowNosortStepService.java index 7ebe1a1..45a37ec 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyShowNosortStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyShowNosortStepService.java @@ -332,7 +332,6 @@ public class MesAssemblyShowNosortStepService extends BaseStepService { return stepNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().scanInfo(productionPsInContext.getProductSn()), stepResult, String.format("主条码[%s]零件号[%s]关联的加工单[%s]与产出零件[%s]关联的加工单[%s]不一致!", productionPsInContext.getProductSn(), productionPsInContext.getPartNo(), productionPsInContext.getWorkOrderNo(), productionPartContext.getPartNo(), productionPartContext.getWorkOrderNo())); } - //进料存在工单且已经过某工序生产, 不能匹配无工单的产出零件 if (StringUtils.isEmpty(productionPartContext.getWorkOrderNo()) && !StringUtils.isEmpty(productionPsInContext.getWorkOrderNo()) && !StringUtils.isEmpty(productionPsInContext.getProcessCode())) { if (productionPsInContext.getMessageSource().compareTo(MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN.getValue()) == 0) productionPsInContext.busiCheckToDelete(); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesRecyclablePackageScanStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesRecyclablePackageScanStepService.java new file mode 100644 index 0000000..82cf667 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesRecyclablePackageScanStepService.java @@ -0,0 +1,84 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step; + +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService; +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService; +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService; +import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesEquipVariableCollectContext; +import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext; +import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService; +import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil; +import cn.estsh.i3plus.pojo.mes.model.StationRequestBean; +import cn.estsh.i3plus.pojo.mes.model.StationResultBean; +import cn.estsh.i3plus.pojo.mes.model.StepResult; +import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * @Description : 扫描可回用包装条码工步 + * @Reference : + * @Author : wangjie + * @CreateDate 2024/9/11 13:53 + * @Modify: + **/ +@Slf4j +@Service("mesRecyclablePackageScanStepService") +public class MesRecyclablePackageScanStepService extends BaseStepService { + + @Autowired + private IMesProductionProcessContextStepService productionProcessContextStepService; + + @Autowired + private IMesProductionDispatchContextStepService productionDispatchContextStepService; + + @Autowired + private IMesProductionCustomContextStepService productionCustomContextStepService; + + @Override + public StepResult execute(StationRequestBean reqBean) { + + StationResultBean resultBean = new StationResultBean(); + + StepResult stepResult = StepResult.getSuccessComplete(); + + //获取上下文信息 + MesProductionProcessContext productionProcessContext = productionProcessContextStepService.dispatchCurCellEquipment(reqBean); + + //当前工序已存在读取待验证的可回用包装条码信息 + if (productionDispatchContextStepService.checkScanRecyclablePackageIsExistContext(reqBean)) return stepResult; + + //存储生产过程上下文对象 + productionProcessContextStepService.dispatchProductionProcessContext(reqBean, productionProcessContext); + + if (StringUtils.isEmpty(reqBean.getScanInfo())) stepSendGuideAndThrowEx(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), "请扫描可回用包装条码!"); + + doHandleScanRecyclablePackageContext(reqBean, stepResult, reqBean.getScanInfo()); + + return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.SCAN.getValue()).scanInfo(reqBean.getScanInfo()), stepResult, stepResult.getMsg()); + } + + //封装可回用包装条码信息 (扫描) + private List doHandleScanRecyclablePackageContext(StationRequestBean reqBean, StepResult stepResult, String scanInfo) { + + List equipVariableCollectContextList = new ArrayList<>(); + + equipVariableCollectContextList.add(new MesEquipVariableCollectContext(reqBean.getOrganizeCode(), scanInfo, MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN.getValue())); + + //保存设备当前一轮工序的待验证的可回用包装条码信息 + productionDispatchContextStepService.dispatchScanRecyclablePackageContext(reqBean, equipVariableCollectContextList); + + //发送工步内容 + productionCustomContextStepService.sendStepContextMessage(reqBean, scanInfo, MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN); + + stepResult.msg(String.format("当前扫描信息可回用包装条码[%s]!", scanInfo)); + + return equipVariableCollectContextList; + + } + +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderQueueAcceptStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderQueueAcceptStepService.java index f3a8399..e5e4e0e 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderQueueAcceptStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderQueueAcceptStepService.java @@ -153,42 +153,36 @@ public class MesWorkOrderQueueAcceptStepService extends BaseStepService { } //验证是否满足腔数 - if (CollectionUtils.isEmpty(curPushList) || curPushList.size() < cellEquipContext.getCavity()) { - return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().checkRepeat(), stepResult, - false, MesPcnEnumUtil.STATION_BUSI_TYPE.GUIDE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, - CollectionUtils.isEmpty(curPushList) ? "当前未接收到工位工单队列,持续监听中..." : String.format("当前接收到到工位工单队列个数[%s]不满足腔数[%s],持续监听中...", curPushList.size(), cellEquipContext.getCavity()), - getStepParams(reqBean), MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME); - } + if (!CollectionUtils.isEmpty(curPushList) && curPushList.size() == cellEquipContext.getCavity()) { - //搜集工单号 - List workOrderNoList = curPushList.stream().filter(o -> null != o).map(MesQueueOrderPush::getWorkOrderNo).collect(Collectors.toList()); + //搜集工单号 + List workOrderNoList = curPushList.stream().filter(o -> null != o).map(MesQueueOrderPush::getWorkOrderNo).collect(Collectors.toList()); - //发送工步内容 - productionCustomContextStepService.sendStepContextMessage(reqBean, workOrderNoList.toString(), MesExtEnumUtil.CELL_MESSAGE_SOURCE.READ); + //发送工步内容 + productionCustomContextStepService.sendStepContextMessage(reqBean, workOrderNoList.toString(), MesExtEnumUtil.CELL_MESSAGE_SOURCE.READ); - List equipVariableCollectContextList = new ArrayList<>(); - workOrderNoList.stream().filter(o -> !StringUtils.isEmpty(o)).forEach(o -> - equipVariableCollectContextList.add(new MesEquipVariableCollectContext(reqBean.getOrganizeCode(), o, MesExtEnumUtil.CELL_MESSAGE_SOURCE.READ.getValue()))); - //保存上下文扫/读信息:加工单 - productionDispatchContextStepService.dispatchScanWorkOrderNoContext(reqBean, equipVariableCollectContextList); + List equipVariableCollectContextList = new ArrayList<>(); + workOrderNoList.stream().filter(o -> !StringUtils.isEmpty(o)).forEach(o -> + equipVariableCollectContextList.add(new MesEquipVariableCollectContext(reqBean.getOrganizeCode(), o, MesExtEnumUtil.CELL_MESSAGE_SOURCE.READ.getValue()))); + //保存上下文扫/读信息:加工单 + productionDispatchContextStepService.dispatchScanWorkOrderNoContext(reqBean, equipVariableCollectContextList); - this.sendMessage(reqBean, new StationResultBean().writeDbLog().checkRepeat(), String.format("获取到工位工单推送队列%s!", workOrderNoList.toString()), MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT); + this.sendMessage(reqBean, new StationResultBean().writeDbLog().checkRepeat(), String.format("获取到工位工单推送队列%s!", workOrderNoList.toString()), MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT); - //加工单验证工步 【排序】 - stepResult = ((IStepService) SpringContextsUtil.getBean("mesWorkOrderCheckSortStepService")).executeInState(reqBean); + //加工单验证工步 【排序】 + stepResult = ((IStepService) SpringContextsUtil.getBean("mesWorkOrderCheckSortStepService")).executeInState(reqBean); - if (!stepResult.isCompleted()) { - stepThreadSleepAndSendTaskCompleteAndThrowEx(reqBean, stepResult, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT, - getStepParams(reqBean), MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME); - } + if (stepResult.isCompleted()) { - //保存上下文推单信息 - productionDispatchContextStepService.dispatchSortQueuePushContext(reqBean, curPushList); + //保存上下文推单信息 + productionDispatchContextStepService.dispatchSortQueuePushContext(reqBean, curPushList); - log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- QUEUE_ORDER_PUSH:{}", - reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), JSONObject.toJSONString(curPushList)); + log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- QUEUE_ORDER_PUSH:{}", + reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), JSONObject.toJSONString(curPushList)); - return stepResult; + return stepResult; + } + } } finally { //当需要加锁且满足腔数的情况下, 保存排序线工单队列推送锁数据 @@ -202,6 +196,16 @@ public class MesWorkOrderQueueAcceptStepService extends BaseStepService { if (!CollectionUtils.isEmpty(queuePushMap2Locked)) queuePushMap2Locked.values().forEach(o -> unLock(reqBean, o)); } + if (!stepResult.isCompleted()) { + stepThreadSleepAndSendTaskCompleteAndThrowEx(reqBean, stepResult, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT, + getStepParams(reqBean), MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME); + } + + return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().checkRepeat(), stepResult, + false, MesPcnEnumUtil.STATION_BUSI_TYPE.GUIDE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, + CollectionUtils.isEmpty(curPushList) ? "当前未接收到工位工单队列,持续监听中..." : String.format("当前接收到到工位工单队列个数[%s]不满足腔数[%s],持续监听中...", curPushList.size(), cellEquipContext.getCavity()), + getStepParams(reqBean), MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME); + } //加锁 diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java index a3aa13b..9472f47 100644 --- a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java @@ -915,4 +915,10 @@ public class MesPcnExtConstWords { //生产过程控制非排序打印机配置【物料级别=1, 默认打印机=2】 public static final String PRODUCTION_CONTROL_NOSORT_PRINTER_CFG = "PRODUCTION_CONTROL_NOSORT_PRINTER_CFG"; + // volvo零件打印 + public static final String VOLVO_CONSIGNMENT_REFERENCE = "consignmentReference"; + public static final String VOLVO_FYON = "fyon"; + public static final String VOLVO_SEQUENCENUMBER = "sequenceNumber"; + public static final String VOLVO_RACKID = "rackId"; + public static final String VOLVO_POSITION = "position"; }