|
|
@ -5,19 +5,24 @@ import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepServ
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdRuleContext;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdRuleContext;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintDataModel;
|
|
|
|
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
|
|
|
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
|
|
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplate;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplate;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplateParam;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplateParam;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesPrintedSnLog;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StepResult;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StepResult;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.IMesPrintedSnLogRepository;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateParamRepository;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateParamRepository;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateRepository;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateRepository;
|
|
|
|
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
|
|
|
|
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
@ -33,8 +38,6 @@ import java.util.stream.Collectors;
|
|
|
|
**/
|
|
|
|
**/
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
public class MesProductSnPrintStepService extends BaseStepService {
|
|
|
|
public class MesProductSnPrintStepService extends BaseStepService {
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private IMesProductionProcessContextStepService productionProcessContextStepService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private IMesProductionDispatchContextStepService mesProductionDispatchContextStepService;
|
|
|
|
private IMesProductionDispatchContextStepService mesProductionDispatchContextStepService;
|
|
|
@ -45,6 +48,9 @@ public class MesProductSnPrintStepService extends BaseStepService {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private MesLabelTemplateParamRepository labelTemplateParamRao;
|
|
|
|
private MesLabelTemplateParamRepository labelTemplateParamRao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private IMesPrintedSnLogRepository snLogRao;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public StepResult execute(StationRequestBean reqBean) {
|
|
|
|
public StepResult execute(StationRequestBean reqBean) {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -65,7 +71,7 @@ public class MesProductSnPrintStepService extends BaseStepService {
|
|
|
|
List<MesProdRuleContext> prodRuleDataContext = mesProductionDispatchContextStepService.getProdRuleDataContext(reqBean);
|
|
|
|
List<MesProdRuleContext> prodRuleDataContext = mesProductionDispatchContextStepService.getProdRuleDataContext(reqBean);
|
|
|
|
Map<Integer, List<MesProdRuleContext>> prodRuleContextMap = prodRuleDataContext.stream().collect(Collectors.groupingBy(MesProdRuleContext::getForeignKey));
|
|
|
|
Map<Integer, List<MesProdRuleContext>> prodRuleContextMap = prodRuleDataContext.stream().collect(Collectors.groupingBy(MesProdRuleContext::getForeignKey));
|
|
|
|
//需要打印的数据 String 是打印模板code
|
|
|
|
//需要打印的数据 String 是打印模板code
|
|
|
|
Map<String, List<Map<String, Object>>> resultData = new HashMap<>();
|
|
|
|
Map<String, List<MesProduceSnPrintDataModel>> resultData = new HashMap<>();
|
|
|
|
//用于保存客户模板代码 和 模板信息关系
|
|
|
|
//用于保存客户模板代码 和 模板信息关系
|
|
|
|
Map<String, MesLabelTemplate> labelTemplateMap = new HashMap<>();
|
|
|
|
Map<String, MesLabelTemplate> labelTemplateMap = new HashMap<>();
|
|
|
|
//返回打印标识 给前端
|
|
|
|
//返回打印标识 给前端
|
|
|
@ -105,14 +111,17 @@ public class MesProductSnPrintStepService extends BaseStepService {
|
|
|
|
execExpSendMsgAndThrowEx(reqBean, resultBean, String.format("零件号[%s]的模板代码[%s]的反射类丢失,请配置!", sn.getPartNo(), prodLabelTemplate));
|
|
|
|
execExpSendMsgAndThrowEx(reqBean, resultBean, String.format("零件号[%s]的模板代码[%s]的反射类丢失,请配置!", sn.getPartNo(), prodLabelTemplate));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IPrintTemplateStrategyService strategyService = (IPrintTemplateStrategyService) SpringContextsUtil.getBean(methodCode);
|
|
|
|
IPrintTemplateStrategyService strategyService = (IPrintTemplateStrategyService) SpringContextsUtil.getBean(methodCode);
|
|
|
|
Map<String, Object> snData = strategyService.execute(reqBean,sn, organizeCode);
|
|
|
|
MesProduceSnPrintDataModel model = strategyService.execute(stepResult, reqBean, sn, organizeCode);
|
|
|
|
List<Map<String, Object>> printData;
|
|
|
|
if (!stepResult.isCompleted()){
|
|
|
|
|
|
|
|
execExpSendMsgAndThrowEx(reqBean, resultBean, stepResult.getMsg());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
List<MesProduceSnPrintDataModel> printData;
|
|
|
|
if (resultData.containsKey(labelTemplate.getTemplateCode())) {
|
|
|
|
if (resultData.containsKey(labelTemplate.getTemplateCode())) {
|
|
|
|
printData = resultData.get(labelTemplate.getTemplateCode());
|
|
|
|
printData = resultData.get(labelTemplate.getTemplateCode());
|
|
|
|
printData.add(snData);
|
|
|
|
printData.add(model);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
printData = new ArrayList<>();
|
|
|
|
printData = new ArrayList<>();
|
|
|
|
printData.add(snData);
|
|
|
|
printData.add(model);
|
|
|
|
resultData.put(labelTemplate.getTemplateCode(), printData);
|
|
|
|
resultData.put(labelTemplate.getTemplateCode(), printData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -127,9 +136,17 @@ public class MesProductSnPrintStepService extends BaseStepService {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
List<Map<String, Object>> printData = new ArrayList<>();
|
|
|
|
List<Map<String, Object>> printData = new ArrayList<>();
|
|
|
|
Set<String> labelKeys = labelTemplateMap.keySet();
|
|
|
|
Set<String> labelKeys = labelTemplateMap.keySet();
|
|
|
|
|
|
|
|
List<MesPrintedSnLog> snLogList = new ArrayList<>();
|
|
|
|
for (String labelKey : labelKeys) {
|
|
|
|
for (String labelKey : labelKeys) {
|
|
|
|
Map<String,Object> paramInfo = new HashMap<>();
|
|
|
|
Map<String,Object> paramInfo = new HashMap<>();
|
|
|
|
List<Map<String, Object>> dataMaps = resultData.get(labelKey);
|
|
|
|
List<MesProduceSnPrintDataModel> dataMaps = resultData.get(labelKey);
|
|
|
|
|
|
|
|
for (MesProduceSnPrintDataModel dataModel : dataMaps) {
|
|
|
|
|
|
|
|
MesPrintedSnLog snLog = new MesPrintedSnLog();
|
|
|
|
|
|
|
|
BeanUtil.copyProperties(dataModel,snLog);
|
|
|
|
|
|
|
|
snLog.setOrganizeCode(reqBean.getOrganizeCode());
|
|
|
|
|
|
|
|
ConvertBean.saveOrUpdate(snLog,reqBean.getUserInfo());
|
|
|
|
|
|
|
|
snLogList.add(snLog);
|
|
|
|
|
|
|
|
}
|
|
|
|
MesLabelTemplate mesLabelTemplate = labelTemplateMap.get(labelKey);
|
|
|
|
MesLabelTemplate mesLabelTemplate = labelTemplateMap.get(labelKey);
|
|
|
|
String templateContent = mesLabelTemplate.getTemplateContent();
|
|
|
|
String templateContent = mesLabelTemplate.getTemplateContent();
|
|
|
|
paramInfo.put("templateContent",templateContent);
|
|
|
|
paramInfo.put("templateContent",templateContent);
|
|
|
@ -148,7 +165,8 @@ public class MesProductSnPrintStepService extends BaseStepService {
|
|
|
|
this.sendMessage(reqBean, resultBean);
|
|
|
|
this.sendMessage(reqBean, resultBean);
|
|
|
|
|
|
|
|
|
|
|
|
//todo 更新打印状态
|
|
|
|
//todo 更新打印状态
|
|
|
|
//todo 保存打印条码
|
|
|
|
//保存打印条码记录
|
|
|
|
|
|
|
|
snLogRao.saveAll(snLogList);
|
|
|
|
return stepResult;
|
|
|
|
return stepResult;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|