|  |  |  | @ -13,10 +13,7 @@ import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplate; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplateParam; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.mes.bean.MesPrintedSnLog; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.mes.bean.*; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.mes.model.StationRequestBean; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.mes.model.StationResultBean; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.mes.model.StepResult; | 
		
	
	
		
			
				
					|  |  |  | @ -28,11 +25,9 @@ import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.impp.framework.boot.util.SpringContextsUtil; | 
		
	
		
			
				|  |  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
		
	
		
			
				|  |  |  |  | import org.springframework.stereotype.Service; | 
		
	
		
			
				|  |  |  |  | import org.springframework.util.StringUtils; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | import java.util.ArrayList; | 
		
	
		
			
				|  |  |  |  | import java.util.HashMap; | 
		
	
		
			
				|  |  |  |  | import java.util.List; | 
		
	
		
			
				|  |  |  |  | import java.util.Map; | 
		
	
		
			
				|  |  |  |  | import java.util.*; | 
		
	
		
			
				|  |  |  |  | import java.util.stream.Collectors; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | /** | 
		
	
	
		
			
				
					|  |  |  | @ -46,7 +41,7 @@ import java.util.stream.Collectors; | 
		
	
		
			
				|  |  |  |  | public class MesProductSnPrintStepService extends BaseStepService { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     @Autowired | 
		
	
		
			
				|  |  |  |  |     private IMesProductionDispatchContextStepService mesProductionDispatchContextStepService; | 
		
	
		
			
				|  |  |  |  |     private IMesProductionDispatchContextStepService productionDispatchContextStepService; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     @Autowired | 
		
	
		
			
				|  |  |  |  |     private MesLabelTemplateRepository labelTemplateRao; | 
		
	
	
		
			
				
					|  |  |  | @ -76,8 +71,15 @@ public class MesProductSnPrintStepService extends BaseStepService { | 
		
	
		
			
				|  |  |  |  |         String organizeCode = reqBean.getOrganizeCode(); | 
		
	
		
			
				|  |  |  |  |         StationResultBean resultBean = new StationResultBean(); | 
		
	
		
			
				|  |  |  |  |         StepResult stepResult = StepResult.getSuccessComplete(); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         //获取上下文加工结果
 | 
		
	
		
			
				|  |  |  |  |         String prodResult = productionDispatchContextStepService.getProductResultContext(reqBean); | 
		
	
		
			
				|  |  |  |  |         //验证加工结果是否满足参数条件: 可疑/报废是否打印
 | 
		
	
		
			
				|  |  |  |  |         if (checkIsMatchProdResult(reqBean, prodResult, MesExtEnumUtil.PRODUCT_RESULT_EQUIP_PARAM.PRODUCT_SUSPICIOUS) || checkIsMatchProdResult(reqBean, prodResult, MesExtEnumUtil.PRODUCT_RESULT_EQUIP_PARAM.PRODUCT_SCRAP)) | 
		
	
		
			
				|  |  |  |  |             return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, String.format("打印失败:%s!", MesExtEnumUtil.PRODUCT_RESULT_EQUIP_PARAM.codeOfDescription(prodResult))); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         // 根据foreign找出加工规则对应的上下文,判断是否需要打印
 | 
		
	
		
			
				|  |  |  |  |         List<MesProdRuleContext> prodRuleDataContext = mesProductionDispatchContextStepService.getProdRuleDataContext(reqBean); | 
		
	
		
			
				|  |  |  |  |         List<MesProdRuleContext> prodRuleDataContext = productionDispatchContextStepService.getProdRuleDataContext(reqBean); | 
		
	
		
			
				|  |  |  |  |         Map<Integer, List<MesProdRuleContext>> prodRuleContextMap = prodRuleDataContext.stream().collect(Collectors.groupingBy(MesProdRuleContext::getForeignKey)); | 
		
	
		
			
				|  |  |  |  |         //需要打印的数据 String 是打印模板code
 | 
		
	
		
			
				|  |  |  |  |         Map<String, List<MesProduceSnPrintDataModel>> resultData = new HashMap<>(); | 
		
	
	
		
			
				
					|  |  |  | @ -85,7 +87,7 @@ public class MesProductSnPrintStepService extends BaseStepService { | 
		
	
		
			
				|  |  |  |  |         Map<String, MesLabelTemplate> labelTemplateMap = new HashMap<>(); | 
		
	
		
			
				|  |  |  |  |         //返回打印标识 给前端
 | 
		
	
		
			
				|  |  |  |  |         //1. 获取上下文中生成的主条码
 | 
		
	
		
			
				|  |  |  |  |         List<MesProductionPsOutContext> productionPsOutContextList = mesProductionDispatchContextStepService.getProductionPsOutContext(reqBean); | 
		
	
		
			
				|  |  |  |  |         List<MesProductionPsOutContext> productionPsOutContextList = productionDispatchContextStepService.getProductionPsOutContext(reqBean); | 
		
	
		
			
				|  |  |  |  |         /** | 
		
	
		
			
				|  |  |  |  |          * 重构,返回给前端打印数据 | 
		
	
		
			
				|  |  |  |  |          */ | 
		
	
	
		
			
				
					|  |  |  | @ -149,7 +151,21 @@ public class MesProductSnPrintStepService extends BaseStepService { | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |         //保存打印条码记录
 | 
		
	
		
			
				|  |  |  |  |         snLogRao.saveAll(snLogList); | 
		
	
		
			
				|  |  |  |  |         return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "执行打印成功!"); | 
		
	
		
			
				|  |  |  |  |         return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "打印成功!"); | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     //验证加工结果是否满足参数条件: 可疑/报废是否打印
 | 
		
	
		
			
				|  |  |  |  |     private Boolean checkIsMatchProdResult(StationRequestBean reqBean, String prodResult, MesExtEnumUtil.PRODUCT_RESULT_EQUIP_PARAM prodResultEnum) { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         if (StringUtils.isEmpty(prodResult)) return false; | 
		
	
		
			
				|  |  |  |  |         if (!prodResult.equals(prodResultEnum.getCode())) return false; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         Optional<Map<String, MesProdRouteOptParam>> stepParamMap = getStepParams(reqBean); | 
		
	
		
			
				|  |  |  |  |         String unPrintParam = (null != stepParamMap && stepParamMap.isPresent() && stepParamMap.get().containsKey(prodResultEnum.name())) ? stepParamMap.get().get(prodResultEnum.name()).getParamValue() : null; | 
		
	
		
			
				|  |  |  |  |         if (StringUtils.isEmpty(unPrintParam)) return false; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         return true; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     /** | 
		
	
	
		
			
				
					|  |  |  | 
 |