|  |  |  | @ -5,6 +5,7 @@ import cn.estsh.i3plus.ext.mes.api.base.IMesShippingOrderManagementDetailService | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.ext.mes.apiservice.dao.IMesShippingOrderManagementDetailDao; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.ext.mes.apiservice.utils.MesException; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.ext.mes.pojo.model.MesShippingOrderManagementDetailModel; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.platform.common.convert.ConvertBean; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.platform.common.tool.TimeTool; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; | 
		
	
	
		
			
				
					|  |  |  | @ -13,6 +14,7 @@ import cn.estsh.i3plus.pojo.base.common.Pager; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.base.common.PagerHelper; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.base.util.StringUtil; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.mes.bean.*; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagementDetail; | 
		
	
	
		
			
				
					|  |  |  | @ -59,10 +61,18 @@ public class MesShippingOrderManagementDetailService extends BaseMesService<MesS | 
		
	
		
			
				|  |  |  |  |     private MesCimGmCbrRuleRepository mesCimGmCbrRuleRepository; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     @Autowired | 
		
	
		
			
				|  |  |  |  |     private MesWorkOrderRepository mesWorkOrderRDao; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     @Autowired | 
		
	
		
			
				|  |  |  |  |     private MesWorkOrderPartRepository mesWorkOrderPartRepository; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     @Autowired | 
		
	
		
			
				|  |  |  |  |     private MesPartShippingGroupRepository mesPartShippingGroupRDao; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     @Autowired | 
		
	
		
			
				|  |  |  |  |     private MesJisShippingRepository jisShippingRepository; | 
		
	
		
			
				|  |  |  |  |     @Autowired | 
		
	
		
			
				|  |  |  |  |     private MesPartService mesPartService; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     protected void setPackQueryBean(MesShippingOrderManagementDetail bean, DdlPackBean packBean) { | 
		
	
		
			
				|  |  |  |  |         DdlPreparedPack.getNumEqualPack(bean.getPid(), "pid", packBean); | 
		
	
	
		
			
				
					|  |  |  | @ -230,8 +240,8 @@ public class MesShippingOrderManagementDetailService extends BaseMesService<MesS | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     public MesJisShipping getMesJisShipping(MesShippingOrderManagement orderManagement,MesShippingOrderManagementDetail detail, String srcLocateNo, MesWorkOrderPart orderPart, String userName) { | 
		
	
		
			
				|  |  |  |  |         MesJisShipping jisShipping = new MesJisShipping(); | 
		
	
		
			
				|  |  |  |  |         BeanUtils.copyProperties(orderManagement, jisShipping); | 
		
	
		
			
				|  |  |  |  |         BeanUtils.copyProperties(detail, jisShipping); | 
		
	
		
			
				|  |  |  |  |         BeanUtils.copyProperties(orderManagement, jisShipping, MesExtConstWords.ID); | 
		
	
		
			
				|  |  |  |  |         BeanUtils.copyProperties(detail, jisShipping, MesExtConstWords.ID); | 
		
	
		
			
				|  |  |  |  |         jisShipping.setFactoryCode(orderManagement.getCustOrganizeCode()); | 
		
	
		
			
				|  |  |  |  |         jisShipping.setShippingTime(TimeTool.getNowTime(true)); | 
		
	
		
			
				|  |  |  |  |         jisShipping.setErpWarerhouse(srcLocateNo); | 
		
	
	
		
			
				
					|  |  |  | @ -250,6 +260,8 @@ public class MesShippingOrderManagementDetailService extends BaseMesService<MesS | 
		
	
		
			
				|  |  |  |  |         jisShipping.setOffTime(TimeTool.getNowTime(true)); | 
		
	
		
			
				|  |  |  |  |         jisShipping.setShippingOrderCode(orderManagement.getShippingCode()); | 
		
	
		
			
				|  |  |  |  |         jisShipping.setFid(UUID.randomUUID().toString()); | 
		
	
		
			
				|  |  |  |  |         jisShipping.setRemark(null); | 
		
	
		
			
				|  |  |  |  |         jisShipping.setDescription(null); | 
		
	
		
			
				|  |  |  |  |         jisShipping.setSystemSyncStatus(CommonEnumUtil.FALSE); | 
		
	
		
			
				|  |  |  |  |         ConvertBean.serviceModelInitialize(jisShipping, userName); | 
		
	
		
			
				|  |  |  |  |         return jisShipping; | 
		
	
	
		
			
				
					|  |  |  | @ -298,6 +310,7 @@ public class MesShippingOrderManagementDetailService extends BaseMesService<MesS | 
		
	
		
			
				|  |  |  |  |         return detailList; | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     @Override | 
		
	
		
			
				|  |  |  |  |     public ListPager<MesWorkOrderPart> queryDetailMesWorkOrderPart(MesWorkOrderPart bean, Pager pager) { | 
		
	
		
			
				|  |  |  |  |         List<MesWorkOrderPart> modelList=new ArrayList<>(); | 
		
	
		
			
				|  |  |  |  |         List<MesShippingOrderManagementDetail> shippingDetails = shippingOrderManagementDetailDao.queryMesShippingOrderManagementDetail(bean); | 
		
	
	
		
			
				
					|  |  |  | @ -325,4 +338,80 @@ public class MesShippingOrderManagementDetailService extends BaseMesService<MesS | 
		
	
		
			
				|  |  |  |  |         return new ListPager<>(modelList, pager); | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     @Override | 
		
	
		
			
				|  |  |  |  |     public void doHandleCockpitShippingError(MesShippingOrderManagementDetail detail, MesWorkOrder workOrder) { | 
		
	
		
			
				|  |  |  |  |         if (StringUtils.isEmpty(detail.getPartNo())) { | 
		
	
		
			
				|  |  |  |  |             MesException.throwFlowException("发运单明细对应零件号为空"); | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |         if (StringUtils.isEmpty(workOrder.getCustSn())) { | 
		
	
		
			
				|  |  |  |  |             MesException.throwMesBusiException("工单【%s】不存在客户条码", workOrder.getWorkOrderNo()); | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |         String organizeCode = AuthUtil.getOrganizeCode(); | 
		
	
		
			
				|  |  |  |  |         String userName = AuthUtil.getSessionUser().getUserName(); | 
		
	
		
			
				|  |  |  |  |         DdlPackBean orderPackBean = DdlPackBean.getDdlPackBean(organizeCode); | 
		
	
		
			
				|  |  |  |  |         DdlPreparedPack.getNumEqualPack(detail.getPid(), "id", orderPackBean); | 
		
	
		
			
				|  |  |  |  |         MesShippingOrderManagement orderManagement = shippingOrderRepository.getByProperty(orderPackBean); | 
		
	
		
			
				|  |  |  |  |         if (orderManagement == null || StringUtils.isEmpty(orderManagement.getShippingGroupCode())) { | 
		
	
		
			
				|  |  |  |  |             MesException.throwFlowException("发运单主表不存在"); | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         DdlPackBean partShippingGroupPackBean = DdlPackBean.getDdlPackBean(organizeCode); | 
		
	
		
			
				|  |  |  |  |         DdlPreparedPack.getStringLikerPack(orderManagement.getShippingGroupCode(), "shippingGroupCode", partShippingGroupPackBean); | 
		
	
		
			
				|  |  |  |  |         MesPartShippingGroup mesPartShippingGroup = mesPartShippingGroupRDao.getByProperty(partShippingGroupPackBean); | 
		
	
		
			
				|  |  |  |  |         if (mesPartShippingGroup == null || StringUtils.isEmpty(mesPartShippingGroup.getConfirmPartType()) || Integer.parseInt(mesPartShippingGroup.getConfirmPartType()) != MesExtEnumUtil.SHIPPING_GROUP_CONFIRM_PART_TYPE.SHIPPING_GROUP_CONFIRM_PART_TYPE_30.getValue()) { | 
		
	
		
			
				|  |  |  |  |             MesException.throwFlowException("零件发运组【%s】,扫描确认零件方式应为【装配目视单和客户零件条码】", orderManagement.getShippingGroupCode()); | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         DdlPackBean workOrderPartPackBean = DdlPackBean.getDdlPackBean(organizeCode); | 
		
	
		
			
				|  |  |  |  |         DdlPreparedPack.getStringEqualPack(workOrder.getWorkOrderNo(), "workOrderNo", workOrderPartPackBean); | 
		
	
		
			
				|  |  |  |  |         List<MesWorkOrderPart> workOrderParts = mesWorkOrderPartRepository.findByHqlWhere(workOrderPartPackBean); | 
		
	
		
			
				|  |  |  |  |         if (!CollectionUtils.isEmpty(workOrderParts)) { | 
		
	
		
			
				|  |  |  |  |             List<MesJisShipping> shippingList = new ArrayList<>(); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |             DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode); | 
		
	
		
			
				|  |  |  |  |             DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.MOVE_RULE_GROUP_TYPE.MOVE_RULE_GROUP_TYPE_10.getValue(), "groupType", ddlPackBean); | 
		
	
		
			
				|  |  |  |  |             DdlPreparedPack.getStringEqualPack(orderManagement.getShippingGroupCode(), "code", ddlPackBean); | 
		
	
		
			
				|  |  |  |  |             List<MesMoveRule> mesMoveRuleList = mesMoveRuleRepository.findByHqlWhere(ddlPackBean); | 
		
	
		
			
				|  |  |  |  |             if (CollectionUtils.isEmpty(mesMoveRuleList)) { | 
		
	
		
			
				|  |  |  |  |                 MesException.throwFlowException(String.format("移库规则不存在:发运单编号:%s,发运组代码:%s,", orderManagement.getShippingCode(), orderManagement.getShippingGroupCode())); | 
		
	
		
			
				|  |  |  |  |             } | 
		
	
		
			
				|  |  |  |  |             Map<String, MesMoveRule> mesMoveRuleMap = mesMoveRuleList.stream().filter(t -> Objects.nonNull(t.getSrcType())).collect(Collectors.toMap(MesMoveRule::getSrcType, Function.identity(), (x, y) -> y)); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |             for (MesWorkOrderPart orderPart : workOrderParts) { | 
		
	
		
			
				|  |  |  |  |                 MesPart itemPart = mesPartService.getPartByPartNo(orderPart.getPartNo(), organizeCode); | 
		
	
		
			
				|  |  |  |  |                 if (itemPart == null) { | 
		
	
		
			
				|  |  |  |  |                     continue; | 
		
	
		
			
				|  |  |  |  |                 } | 
		
	
		
			
				|  |  |  |  |                 MesMoveRule moveRule = mesMoveRuleMap.get(itemPart.getEsd()); | 
		
	
		
			
				|  |  |  |  |                 if (moveRule != null && Objects.equals(moveRule.getMoveNum(), MesExtEnumUtil.MOVE_RULE_MOVE_NUM.MOVE_RULE_MOVE_NUM_20.getValue()) && MesExtEnumUtil.MOVE_TYPE_REPORT_TYPE.SHIPPING.getValue() == moveRule.getReportType()) { | 
		
	
		
			
				|  |  |  |  |                     shippingList.add(getMesJisShipping(orderManagement, detail, moveRule.getErpSrcLocateNo(), orderPart, userName)); | 
		
	
		
			
				|  |  |  |  |                 } else { | 
		
	
		
			
				|  |  |  |  |                     log.info("客供品移库零件【{}】在零件发运组【{}】的移库规则中,汇报类型未维护或不为发运", orderPart.getPartNo(), workOrder.getPartProdGroupCode()); | 
		
	
		
			
				|  |  |  |  |                 } | 
		
	
		
			
				|  |  |  |  |             } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |             jisShippingRepository.saveAll(shippingList); | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         MesProduceSn mesProduceSn = mesProduceSnService.getMesProduceSnByCustSn(organizeCode, workOrder.getCustSn()); | 
		
	
		
			
				|  |  |  |  |         if (mesProduceSn != null) { | 
		
	
		
			
				|  |  |  |  |             //更新条码状态为完成
 | 
		
	
		
			
				|  |  |  |  |             mesProduceSn.setSnStatus(MesExtEnumUtil.PRODUCE_SN_STATUS.SHIPPED.getValue()); | 
		
	
		
			
				|  |  |  |  |             mesProduceSn.setSystemSyncStatus(CommonEnumUtil.FALSE); | 
		
	
		
			
				|  |  |  |  |             ConvertBean.serviceModelUpdate(mesProduceSn, userName); | 
		
	
		
			
				|  |  |  |  |             mesProduceSnRepository.update(mesProduceSn); | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         workOrder.setWorkOrderStatus(MesExtEnumUtil.ORDER_STATUS.SHIPPING.getValue()); | 
		
	
		
			
				|  |  |  |  |         workOrder.setSystemSyncStatus(CommonEnumUtil.FALSE); | 
		
	
		
			
				|  |  |  |  |         ConvertBean.serviceModelUpdate(workOrder, userName); | 
		
	
		
			
				|  |  |  |  |         mesWorkOrderRDao.update(workOrder); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         detail.setBarcode(workOrder.getWorkOrderNo() + "," + workOrder.getCustSn()); | 
		
	
		
			
				|  |  |  |  |         detail.setStatus(MesExtEnumUtil.SHIPPING_ORDER_DETAIL_SHIPPING_STATUS.SHIPPINGED.getValue()); | 
		
	
		
			
				|  |  |  |  |         detail.setSystemSyncStatus(CommonEnumUtil.FALSE); | 
		
	
		
			
				|  |  |  |  |         detail.setRemark("cockpit发运处理"); | 
		
	
		
			
				|  |  |  |  |         ConvertBean.serviceModelUpdate(detail, userName); | 
		
	
		
			
				|  |  |  |  |         shippingOrderDetailRepository.update(detail); | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | } | 
		
	
	
		
			
				
					|  |  |  | 
 |