|
|
|
@ -2,9 +2,9 @@ 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.base.IMesTemplateService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesPrintedSnLogService;
|
|
|
|
|
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;
|
|
|
|
@ -12,26 +12,23 @@ 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.platform.common.util.MesPcnConstWords;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
|
|
|
|
|
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.MesCustomerPart;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesNumberRule;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
|
|
|
|
|
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.MesLabelTemplateFieldInfoRepository;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateFieldValueRepository;
|
|
|
|
|
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.*;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description :通用打印方式
|
|
|
|
@ -40,7 +37,7 @@ import java.util.*;
|
|
|
|
|
* @CreateDate 2024/9/26 18:20
|
|
|
|
|
* @Modify:
|
|
|
|
|
**/
|
|
|
|
|
@Component(value = "CustomFieldPrintStrategy")
|
|
|
|
|
@Component
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class CustomFieldPrintStrategy implements IPrintTemplateStrategyService {
|
|
|
|
|
@Autowired
|
|
|
|
@ -59,10 +56,7 @@ public class CustomFieldPrintStrategy implements IPrintTemplateStrategyService {
|
|
|
|
|
private IMesCustomerPartService mesCustomerPartService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesLabelTemplateFieldInfoRepository labelTemplateFieldInfoRDao;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesLabelTemplateFieldValueRepository labelTemplateFieldValueRDao;
|
|
|
|
|
private IMesTemplateService mesTemplateService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep) {
|
|
|
|
@ -70,11 +64,8 @@ public class CustomFieldPrintStrategy implements IPrintTemplateStrategyService {
|
|
|
|
|
//物料信息
|
|
|
|
|
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());
|
|
|
|
|
List<MesLabelTemplateFieldValue> fieldValueList = queryMesLabelTemplateParamPartValue(mesPart.getPartNo(), mesPart.getProductLabelTemplate(), organizeCode);
|
|
|
|
|
Map<String, Object> customParamValue = mesTemplateService.queryMesLabelTemplateParamPartValue(mesPart.getPartNo(), mesPart.getProductLabelTemplate(), organizeCode);
|
|
|
|
|
if (!isStep){
|
|
|
|
|
// if (StringUtils.isEmpty(genSerialNoModel.getShiftCode())) {
|
|
|
|
|
// MesPcnException.throwMesBusiException("班次代码未维护");
|
|
|
|
|
// }
|
|
|
|
|
if (!Objects.isNull(customerPart)) {
|
|
|
|
|
genSerialNoModel.setCustPartNo(customerPart.getCustPartNo());
|
|
|
|
|
}
|
|
|
|
@ -83,15 +74,10 @@ public class CustomFieldPrintStrategy implements IPrintTemplateStrategyService {
|
|
|
|
|
MesProduceSn produceSn = generateMesProduceSn(mesPart, syncFuncService.syncSerialNo(genSerialNoModel.partSnParam(mesPart.getPartSnParam()), mesProduceSnPrintModel.getUserName(), organizeCode, 1).getResultList().get(0).toString(), mesProduceSnPrintModel.getUserName(), mesProduceSnPrintModel.getQty());
|
|
|
|
|
//封装打印信息
|
|
|
|
|
MesProduceSnPrintDataModel printDataModel = getModel(produceSn, customerPart);
|
|
|
|
|
// mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(printDataModel);
|
|
|
|
|
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().clear();
|
|
|
|
|
mesProduceSnPrintModel.getMesProduceSnList().add(produceSn);
|
|
|
|
|
Map<String, Object> printTemplateData = new HashMap<>(getPrintContextMap(produceSn, customerPart));
|
|
|
|
|
if (!CollectionUtils.isEmpty(fieldValueList)) {
|
|
|
|
|
for (MesLabelTemplateFieldValue fieldValue : fieldValueList) {
|
|
|
|
|
printTemplateData.put(fieldValue.getTemplateParam(), fieldValue.getFieldValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printTemplateData.putAll(customParamValue);
|
|
|
|
|
mesProduceSnPrintModel.getPrintContextList().add(printTemplateData);
|
|
|
|
|
//保存打印记录
|
|
|
|
|
mesProduceSnPrintModel.getMesPrintedSnLogList().add(mesPrintedSnLogService.getMesPrintedSnLog(mesProduceSnPrintModel.getUserName(), organizeCode, printDataModel));
|
|
|
|
@ -100,14 +86,9 @@ public class CustomFieldPrintStrategy implements IPrintTemplateStrategyService {
|
|
|
|
|
MesProduceSn mesProduceSn = mesProduceSnPrintModel.getMesProduceSnList().get(0);
|
|
|
|
|
//封装打印信息
|
|
|
|
|
MesProduceSnPrintDataModel printDataModel = getModel(mesProduceSn, customerPart);
|
|
|
|
|
// mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(printDataModel);
|
|
|
|
|
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().clear();
|
|
|
|
|
Map<String, Object> printTemplateData = new HashMap<>(getPrintContextMap(mesProduceSn, customerPart));
|
|
|
|
|
if (!CollectionUtils.isEmpty(fieldValueList)) {
|
|
|
|
|
for (MesLabelTemplateFieldValue fieldValue : fieldValueList) {
|
|
|
|
|
printTemplateData.put(fieldValue.getTemplateParam(), fieldValue.getFieldValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printTemplateData.putAll(customParamValue);
|
|
|
|
|
mesProduceSnPrintModel.getPrintContextList().add(printTemplateData);
|
|
|
|
|
//保存打印记录
|
|
|
|
|
mesProduceSnPrintModel.getMesPrintedSnLogList().add(mesPrintedSnLogService.getMesPrintedSnLog(mesProduceSnPrintModel.getUserName(), organizeCode, printDataModel));
|
|
|
|
@ -162,58 +143,4 @@ public class CustomFieldPrintStrategy implements IPrintTemplateStrategyService {
|
|
|
|
|
result.put(MesPcnExtConstWords.USER_NAME, produceSn.getCreateUser());
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<MesLabelTemplateFieldValue> queryMesLabelTemplateParamPartValue(String partNo, String labelTemplate, String organizeCode) {
|
|
|
|
|
if (StringUtil.isEmpty(labelTemplate)) {
|
|
|
|
|
MesPcnException.throwMesBusiException("零件号【%s】未维护\"零件条码匹配模板\"字段值", partNo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<MesLabelTemplateFieldValue> result = new ArrayList<>();
|
|
|
|
|
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(partNo, "partNo", ddlPackBean);
|
|
|
|
|
|
|
|
|
|
List<MesLabelTemplateFieldInfo> templateFieldInfos = labelTemplateFieldInfoRDao.findByProperty(
|
|
|
|
|
new String[]{"templateCode", "templateFieldType", MesPcnConstWords.IS_VALID, MesPcnConstWords.IS_DELETED, MesPcnConstWords.ORGANIZE_CODE},
|
|
|
|
|
new Object[]{labelTemplate, MesExtEnumUtil.LABEL_TEMPLATE_FIELD_TYPE.CUSTOM.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(),
|
|
|
|
|
CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), organizeCode});
|
|
|
|
|
Map<String, MesLabelTemplateFieldInfo> templateFieldInfoMap = new TreeMap<>();
|
|
|
|
|
for (MesLabelTemplateFieldInfo info : templateFieldInfos) {
|
|
|
|
|
templateFieldInfoMap.putIfAbsent(info.getTemplateParam(), info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<MesLabelTemplateFieldValue> fieldValueList = labelTemplateFieldValueRDao.findByProperty(
|
|
|
|
|
new String[]{"partNo", "templateCode", MesPcnConstWords.IS_VALID, MesPcnConstWords.IS_DELETED, MesPcnConstWords.ORGANIZE_CODE},
|
|
|
|
|
new Object[]{partNo, labelTemplate, CommonEnumUtil.IS_VAILD.VAILD.getValue(),
|
|
|
|
|
CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), organizeCode});
|
|
|
|
|
if (!org.apache.shiro.util.CollectionUtils.isEmpty(fieldValueList)) {
|
|
|
|
|
for (MesLabelTemplateFieldValue fieldValue : fieldValueList) {
|
|
|
|
|
if (StringUtil.isEmpty(fieldValue.getTemplateParam())) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
MesLabelTemplateFieldInfo templateFieldInfo = templateFieldInfoMap.remove(fieldValue.getTemplateParam());
|
|
|
|
|
if (templateFieldInfo != null) {
|
|
|
|
|
MesLabelTemplateFieldValue field = new MesLabelTemplateFieldValue();
|
|
|
|
|
field.setPartNo(partNo);
|
|
|
|
|
field.setTemplateCode(templateFieldInfo.getTemplateCode());
|
|
|
|
|
field.setTemplateParam(templateFieldInfo.getTemplateParam());
|
|
|
|
|
field.setTemplateFieldText(templateFieldInfo.getTemplateFieldText());
|
|
|
|
|
field.setFieldValue(fieldValue.getFieldValue());
|
|
|
|
|
field.setOrganizeCode(organizeCode);
|
|
|
|
|
result.add(field);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (Map.Entry<String, MesLabelTemplateFieldInfo> entry : templateFieldInfoMap.entrySet()) {
|
|
|
|
|
MesLabelTemplateFieldInfo fieldInfo = entry.getValue();
|
|
|
|
|
MesLabelTemplateFieldValue fieldValue = new MesLabelTemplateFieldValue();
|
|
|
|
|
fieldValue.setPartNo(partNo);
|
|
|
|
|
fieldValue.setTemplateCode(fieldInfo.getTemplateCode());
|
|
|
|
|
fieldValue.setTemplateParam(fieldInfo.getTemplateParam());
|
|
|
|
|
fieldValue.setTemplateFieldText(fieldInfo.getTemplateFieldText());
|
|
|
|
|
fieldValue.setOrganizeCode(organizeCode);
|
|
|
|
|
result.add(fieldValue);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|