|
|
@ -1,36 +1,18 @@
|
|
|
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.strategy;
|
|
|
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.strategy;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPartService;
|
|
|
|
|
|
|
|
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.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.model.MesProduceSnPrintModel;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesWorkOrderCutDetailModel;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesWorkOrderCutDetailModel;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
|
|
|
import cn.estsh.i3plus.mes.pcn.api.iservice.base.IConfigService;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
|
|
|
|
|
|
|
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.mes.bean.*;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.*;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StepResult;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StepResult;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesCustomerPartRepository;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesNumberRuleRepository;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ResultBean;
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @Description : 裁片工单包装标签打印
|
|
|
|
* @Description : 裁片工单包装标签打印
|
|
|
@ -42,161 +24,49 @@ import java.util.List;
|
|
|
|
@Component
|
|
|
|
@Component
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
|
public class CutWorkOrderPackageSnPrintStrategy implements IPrintTemplateStrategyService {
|
|
|
|
public class CutWorkOrderPackageSnPrintStrategy implements IPrintTemplateStrategyService {
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private MesCustomerPartRepository mesCustomerPartRDao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private ISyncFuncService syncFuncService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private SnowflakeIdMaker snowflakeIdMaker;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private IMesPartService mesPartService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private IConfigService configService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private MesNumberRuleRepository numberRuleRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep) {
|
|
|
|
public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep) {
|
|
|
|
Date date = new Date();
|
|
|
|
|
|
|
|
String organizeCode = mesProduceSnPrintModel.getOrganizeCode();
|
|
|
|
|
|
|
|
//gz-xiaopeng
|
|
|
|
|
|
|
|
//客户零件号
|
|
|
|
|
|
|
|
MesCustomerPart mesCustomerPart = getMesCustomerPart(mesProduceSnPrintModel);
|
|
|
|
|
|
|
|
String custPartNo = mesCustomerPart == null ? "" : mesCustomerPart.getCustPartNo();
|
|
|
|
|
|
|
|
MesPart mesPart = mesPartService.getMesPartByPartNo(mesProduceSnPrintModel.getPartNo(), organizeCode);
|
|
|
|
|
|
|
|
MesConfig mesConfig = configService.getMesConfigByCfgCode(MesPcnExtConstWords.ORGANIZE_NAME, organizeCode);
|
|
|
|
|
|
|
|
String organizeName = mesConfig.getCfgValue();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<MesWorkOrderCutDetailModel> workOrderCutDetailModelList = (List<MesWorkOrderCutDetailModel>) mesProduceSnPrintModel.getSourceData();
|
|
|
|
List<MesWorkOrderCutDetailModel> workOrderCutDetailModelList = (List<MesWorkOrderCutDetailModel>) mesProduceSnPrintModel.getSourceData();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> printDataMapList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (MesWorkOrderCutDetailModel model : workOrderCutDetailModelList) {
|
|
|
|
|
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
|
|
|
resultMap.put(MesPcnExtConstWords.PART_NO, model.getPartNo());
|
|
|
|
|
|
|
|
resultMap.put(MesPcnExtConstWords.PART_NAME, model.getPartName());
|
|
|
|
|
|
|
|
resultMap.put(MesPcnExtConstWords.CUST_PART_NO, model.getCustPartNo());
|
|
|
|
|
|
|
|
String lotNo = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(model.getLotNo())) {
|
|
|
|
|
|
|
|
String[] split = model.getLotNo().split("-");
|
|
|
|
|
|
|
|
lotNo = new StringJoiner(MesPcnExtConstWords.SLANT_R).add(split[0]).add(split[1]).add(split[2]).toString();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resultMap.put(MesPcnExtConstWords.LOT_NO, lotNo);
|
|
|
|
|
|
|
|
resultMap.put(MesPcnExtConstWords.PACKAGE_QTY, model.getPackageQty());
|
|
|
|
|
|
|
|
resultMap.put(MesPcnExtConstWords.QTY, model.getQty());
|
|
|
|
|
|
|
|
resultMap.put(MesPcnExtConstWords.CUT_WORK_ORDER_NO, model.getCutWorkOrderNo());
|
|
|
|
|
|
|
|
resultMap.put(MesPcnExtConstWords.PACKAGE_SN, model.getPackageNo());
|
|
|
|
|
|
|
|
printDataMapList.add(resultMap);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mesProduceSnPrintModel.setPrintContextList(packResultMapList(mesProduceSnPrintModel, printDataMapList));
|
|
|
|
if (!isStep){
|
|
|
|
|
|
|
|
//年月日缩写
|
|
|
|
|
|
|
|
genSerialNoModel.setYear(getYearShort(date));
|
|
|
|
|
|
|
|
genSerialNoModel.setMonth(getMonthShort(date));
|
|
|
|
|
|
|
|
genSerialNoModel.setDay(getDayShort(date));
|
|
|
|
|
|
|
|
genSerialNoModel.setRuleCode(numberRule.getRuleCode());
|
|
|
|
|
|
|
|
genSerialNoModel.setCustPartNo(custPartNo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//流水号 5位 每天从1开始
|
|
|
|
|
|
|
|
for (int i = 0; i < mesProduceSnPrintModel.getPrintQty(); i++) {
|
|
|
|
|
|
|
|
ResultBean resultBean = syncFuncService.syncSerialNo(genSerialNoModel, mesProduceSnPrintModel.getUserName(), organizeCode, 1);
|
|
|
|
|
|
|
|
String sn = resultBean.getResultList().get(0).toString();
|
|
|
|
|
|
|
|
Integer serialNoLength = numberRule.getSerialnoLength();
|
|
|
|
|
|
|
|
String serialNo = sn.substring(sn.length() - serialNoLength);
|
|
|
|
|
|
|
|
//保存条码信息
|
|
|
|
|
|
|
|
MesProduceSn produceSn = generateMesProduceSn(mesPart, sn, mesProduceSnPrintModel.getUserName(), mesProduceSnPrintModel.getQty());
|
|
|
|
|
|
|
|
produceSn.setCustPartNo(custPartNo);
|
|
|
|
|
|
|
|
//封装打印信息
|
|
|
|
|
|
|
|
MesProduceSnPrintDataModel printDataModel = getModel(produceSn, serialNo, custPartNo, organizeName);
|
|
|
|
|
|
|
|
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(printDataModel);
|
|
|
|
|
|
|
|
mesProduceSnPrintModel.getMesProduceSnList().add(produceSn);
|
|
|
|
|
|
|
|
//保存打印记录
|
|
|
|
|
|
|
|
MesPrintedSnLog snLog = new MesPrintedSnLog();
|
|
|
|
|
|
|
|
BeanUtil.copyProperties(printDataModel,snLog);
|
|
|
|
|
|
|
|
snLog.setOrganizeCode(organizeCode);
|
|
|
|
|
|
|
|
ConvertBean.serviceModelInitialize(snLog, mesProduceSnPrintModel.getUserName());
|
|
|
|
|
|
|
|
mesProduceSnPrintModel.getMesPrintedSnLogList().add(snLog);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
String sn = mesProduceSnPrintModel.getProductSn();
|
|
|
|
|
|
|
|
MesProduceSn mesProduceSn = mesProduceSnPrintModel.getMesProduceSnList().get(0);
|
|
|
|
|
|
|
|
Integer serialNoLength = numberRule.getSerialnoLength();
|
|
|
|
|
|
|
|
String serialNo = sn.substring(sn.length() - serialNoLength);
|
|
|
|
|
|
|
|
//封装打印信息
|
|
|
|
|
|
|
|
MesProduceSnPrintDataModel printDataModel = getModel(mesProduceSn, serialNo, custPartNo, organizeName);
|
|
|
|
|
|
|
|
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(printDataModel);
|
|
|
|
|
|
|
|
//保存打印记录
|
|
|
|
|
|
|
|
MesPrintedSnLog snLog = new MesPrintedSnLog();
|
|
|
|
|
|
|
|
BeanUtil.copyProperties(printDataModel,snLog);
|
|
|
|
|
|
|
|
snLog.setOrganizeCode(organizeCode);
|
|
|
|
|
|
|
|
ConvertBean.serviceModelInitialize(snLog, mesProduceSnPrintModel.getUserName());
|
|
|
|
|
|
|
|
mesProduceSnPrintModel.getMesPrintedSnLogList().add(snLog);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return mesProduceSnPrintModel;
|
|
|
|
return mesProduceSnPrintModel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private MesNumberRule getNumberRule(String organizeCode, MesPart part) {
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(part.getProductMatchRule())) MesPcnException.throwMesBusiException("物料[%s]未维护零件条码匹配规则", part.getPartNo());
|
|
|
|
|
|
|
|
MesNumberRule numberRule = numberRuleRepository.getByProperty(
|
|
|
|
|
|
|
|
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.RULE_CODE},
|
|
|
|
|
|
|
|
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), part.getProcessMatchRule()});
|
|
|
|
|
|
|
|
if (null == numberRule) MesPcnException.throwMesBusiException("物料[%s]维护的零件条码匹配规则[%s]信息不存在", part.getPartNo(), part.getProcessMatchRule());
|
|
|
|
|
|
|
|
return numberRule;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private MesCustomerPart getMesCustomerPart(MesProduceSnPrintModel mesProduceSnPrintModel) {
|
|
|
|
|
|
|
|
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(mesProduceSnPrintModel.getOrganizeCode());
|
|
|
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(mesProduceSnPrintModel.getPartNo(), "erpPartNo", ddlPackBean);
|
|
|
|
|
|
|
|
MesCustomerPart mesCustomerPart = mesCustomerPartRDao.getByProperty(ddlPackBean);
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 2024/07/25 打印模板不校验 客户零件号,校验客户零件号移动到条码规则中 numberRule的策略中
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
// if (Objects.isNull(mesCustomerPart)) {
|
|
|
|
|
|
|
|
// MesPcnException.throwMesBusiException("物料【%s】客户零件关系未维护", mesProduceSnPrintModel.getPartNo());
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
return mesCustomerPart;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getYearShort(Date date) {
|
|
|
|
|
|
|
|
String yearStr = MesExtEnumUtil.YEAR_SHORT.valueOfDescription(Integer.parseInt(TimeTool.getYear(date)));
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(yearStr)) {
|
|
|
|
|
|
|
|
MesPcnException.throwMesBusiException("【%s】年月简号不存在", TimeTool.getYear(date));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return yearStr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getMonthShort(Date date) {
|
|
|
|
|
|
|
|
String monthStr = MesExtEnumUtil.MONTH_SHORT.valueOfDescription(Integer.parseInt(TimeTool.getMonth(date)));
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(monthStr)) {
|
|
|
|
|
|
|
|
MesPcnException.throwMesBusiException("【%s】月简号不存在", TimeTool.getMonth(date));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return monthStr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getDayShort(Date date) {
|
|
|
|
private List<Map<String, Object>> packResultMapList(MesProduceSnPrintModel printModel, List<Map<String, Object>> printTemplateDateList) {
|
|
|
|
String day = TimeTool.getDay(date);
|
|
|
|
List<Map<String, Object>> resultMapList = new ArrayList<>();
|
|
|
|
return day;
|
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
}
|
|
|
|
resultMap.put(MesPcnExtConstWords.LABEL_TEMPLATE, printModel.getMesLabelTemplate());
|
|
|
|
|
|
|
|
resultMap.put(MesPcnExtConstWords.TEMPLATE_DATA, printTemplateDateList);
|
|
|
|
private MesProduceSn generateMesProduceSn(MesPart mesPart, String sn, String userName, Double qty) {
|
|
|
|
resultMap.put(MesPcnExtConstWords.TEMPLATE_CODE, printModel.getMesLabelTemplate().getTemplateCode());
|
|
|
|
MesProduceSn mesProduceSn = new MesProduceSn();
|
|
|
|
resultMap.put(MesPcnExtConstWords.PRINTERE, printModel.getPrinter());
|
|
|
|
mesProduceSn.setSerialNumber(snowflakeIdMaker.nextId() + "");
|
|
|
|
resultMapList.add(resultMap);
|
|
|
|
mesProduceSn.setProductSn(sn);
|
|
|
|
return resultMapList;
|
|
|
|
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, String no, String custPartNo, String factoryName) {
|
|
|
|
|
|
|
|
MesProduceSnPrintDataModel mesProduceSnPrintDataModel = new MesProduceSnPrintDataModel();
|
|
|
|
|
|
|
|
mesProduceSnPrintDataModel.setFactoryName(factoryName);
|
|
|
|
|
|
|
|
mesProduceSnPrintDataModel.setPartNo(produceSn.getPartNo());
|
|
|
|
|
|
|
|
mesProduceSnPrintDataModel.setPartName(produceSn.getPartName());
|
|
|
|
|
|
|
|
mesProduceSnPrintDataModel.setNo(no);
|
|
|
|
|
|
|
|
mesProduceSnPrintDataModel.setBarcode(produceSn.getProductSn());
|
|
|
|
|
|
|
|
mesProduceSnPrintDataModel.setCustPartNo(custPartNo);
|
|
|
|
|
|
|
|
mesProduceSnPrintDataModel.setPrintDate(TimeTool.getNowTime(true));
|
|
|
|
|
|
|
|
mesProduceSnPrintDataModel.setProductDate(produceSn.getCreateDatetime());
|
|
|
|
|
|
|
|
return mesProduceSnPrintDataModel;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|