Merge remote-tracking branch 'origin/dev' into dev

tags/yfai-pcn-ext-v1.0
jun 10 months ago
commit fb6c3843fc

@ -33,4 +33,7 @@ public interface IMesAssemblyExtService {
@ApiOperation(value = "获取设备的装配件规则清单")
List<MesProductionAssemblyNosortContext> getProductionAssemblyNosortContextList(String organizeCode, String equipmentCode);
@ApiOperation(value = "【排序线】获取生产工单装配件清单")
List<MesWorkOrderAssembly> getWorkOrderAssemblyList(String organizeCode, String workOrderNo, String productSn, String craftCode);
}

@ -156,6 +156,14 @@ public class MesAssemblyExtService implements IMesAssemblyExtService {
return productionAssemblyNosortContextList;
}
@Override
public List<MesWorkOrderAssembly> getWorkOrderAssemblyList(String organizeCode, String workOrderNo, String productSn, String craftCode) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(workOrderNo) || StringUtils.isEmpty(productSn) || StringUtils.isEmpty(craftCode)) return null;
return workOrderAssemblyRepository.findByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.WORK_ORDER_NO, MesPcnExtConstWords.PRODUCT_SN, MesPcnExtConstWords.CRAFT_CODE},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), workOrderNo, productSn, craftCode});
}
//剔除解绑的数据
private List<MesProductionAssembly> filterProductionAssemblyList(List<MesProductionAssembly> productionAssemblyList) {
return CollectionUtils.isEmpty(productionAssemblyList) ? null : productionAssemblyList.stream().filter(o -> (null != o && MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_20.getValue() != o.getAssemblyStatus())).collect(Collectors.toList());

@ -3,13 +3,14 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi;
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.IMesProduceSnPrintService;
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;
import cn.estsh.i3plus.mes.pcn.api.iservice.base.IConfigService;
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.INumberRulePackAttributeStrategyService;
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.exception.ImppExceptionEnum;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
@ -23,7 +24,7 @@ import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
import cn.estsh.i3plus.pojo.mes.repository.*;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ResultBean;
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
import cn.hutool.core.bean.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -79,6 +80,9 @@ public class MesProduceSnPrintService implements IMesProduceSnPrintService {
@Autowired
private IMesPrintedSnLogRepository mesPrintedSnRao;
@Autowired
private MesLabelTemplateRepository templateRao;
@Override
public MesProduceSnPrintModel findMesPackingDefine(MesProduceSnPrintModel mesProduceSnPrintModel) {
//查询SAP下发物料信息
@ -113,13 +117,7 @@ public class MesProduceSnPrintService implements IMesProduceSnPrintService {
@Override
public MesProduceSnPrintModel doPrint(MesProduceSnPrintModel mesProduceSnPrintModel) {
String organizeCode = mesProduceSnPrintModel.getOrganizeCode();
// 获取工厂名称
MesConfig mesConfig = configService.getMesConfigByCfgCode(MesPcnExtConstWords.ORGANIZE_NAME, organizeCode);
if (null == mesConfig || StringUtils.isEmpty(mesConfig.getCfgValue())) {
throw ImppExceptionBuilder.newInstance().setSystemID(CommonEnumUtil.SOFT_TYPE.MES_PCN.getCode()).setErrorCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode()).setErrorDetail("没有维护当前工厂的系统参数!").build();
}
//获取工厂名称
String organizeName = mesConfig.getCfgValue();
//物料信息
MesPart mesPart = mesPartService.getMesPartByPartNo(mesProduceSnPrintModel.getPartNo(), organizeCode);
//条码生成
@ -136,205 +134,52 @@ public class MesProduceSnPrintService implements IMesProduceSnPrintService {
MesPcnException.throwMesBusiException("零件号【】打印规则查询不到!", mesPart.getPartNo());
}
MesNumberRule numberRule = ruleList.get(0);
String methodNameExt = numberRule.getMethodNameExt();
if (StringUtils.isEmpty(methodNameExt)) {
throw ImppExceptionBuilder.newInstance().setSystemID(CommonEnumUtil.SOFT_TYPE.MES_PCN.getCode())
.setErrorCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode())
.setErrorDetail(String.format("当前编码规则【%s】未维护构造入参方法名", snRule)).build();
//打印日期格式
String format = "yyyy/MM/dd";
if (MesExtEnumUtil.MES_PRINT_TEMPLATE.NO_SORT_BAR_CODE_GZ.getCode().equals(printTemplate) || MesExtEnumUtil.MES_PRINT_TEMPLATE.XIAO_PENG.getCode().equals(printTemplate) || MesExtEnumUtil.MES_PRINT_TEMPLATE.XIAO_PENG_NEW.getCode().equals(printTemplate)) {
format = DateUtil.BASE_FORMAT;
}
int printQty = mesProduceSnPrintModel.getPrintQty();
Date date = new Date();
//if 1B2M || GQAA_BARCODE
if (MesExtEnumUtil.MES_PRINT_TEMPLATE.B2M.getCode().equals(printTemplate) || MesExtEnumUtil.MES_PRINT_TEMPLATE.GQAA.getCode().equals(printTemplate)) {
GenSerialNoModel genSerialNoModel = new GenSerialNoModel();
genSerialNoModel.setRuleCode(numberRule.getRuleCode());
//${SPILTRULE}${partNo}${SPILTRULE}${SPILTRULE}${year}${month}${day}${serialNo}${SPILTRULE}
//规格号,零件号,供应商,生产线代码,年,月,日,序列号,软件版本号
// ----广汽 1B2M & 广新 GQAA_BARCODE 21位
//规格号 ${SPILTRULE} +
//零件简号 {partNo} - mesPart.getPartSnParam()
genSerialNoModel.setPartNo(mesPart.getPartSnParam());
//供应商号 supplierNo ---固定VD501 ${SPILTRULE}拼接
//生产线代码 workCenterCode 或者 fixWorkCenterCode (取配置值) ${SPILTRULE}
//日期${dateShort}
genSerialNoModel.setYear(getYearShort(date));
genSerialNoModel.setMonth(getMonthShort(date));
genSerialNoModel.setDay(getDayShort(date));
//获取客户零件号
String custPartNo = getMesCustomerPart(mesProduceSnPrintModel).getCustPartNo();
//供应商生产流水号 ${serialNo} 采用34进制 获取条码是十进制,需要截取转换成34位
//软件版本号${versionNo} ${SPILTRULE}
for (int i = 0; i < printQty; i++) {
ResultBean resultBean = syncFuncService.syncSerialNo(genSerialNoModel, mesProduceSnPrintModel.getUserName(), organizeCode, 1);
String sn = resultBean.getResultList().get(0).toString();
int versionNoLength = numberRule.getSpiltRule().substring(numberRule.getSpiltRule().lastIndexOf(",") + 1).length();
Integer serialNoLength = numberRule.getSerialnoLength();
String snPrefix = sn.substring(0, sn.length() - versionNoLength - serialNoLength);
String snSuffix = sn.substring(sn.length() - versionNoLength);
String serialNo = sn.substring(sn.length() - versionNoLength - serialNoLength, sn.length() - versionNoLength);
String serialNo34 = toBase34(Integer.parseInt(serialNo));
serialNo34 = stringFormat(serialNo34, 4, false, "0");
sn = snPrefix + serialNo34 + snSuffix;
//保存条码信息
MesProduceSn produceSn = generateMesProduceSn(mesPart, sn, mesProduceSnPrintModel.getUserName(), mesProduceSnPrintModel.getQty(), format);
//封装打印信息
MesProduceSnPrintDataModel model = getModel(produceSn, serialNo, custPartNo, organizeName);
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(model);
mesProduceSnRDao.insert(produceSn);
//保存打印记录
MesPrintedSnLog snLog = new MesPrintedSnLog();
ConvertBean.serviceModelInitialize(snLog, mesProduceSnPrintModel.getUserName());
BeanUtil.copyProperties(model,snLog);
mesPrintedSnRao.insert(snLog);
// 获取打印模板
MesLabelTemplate mesLabelTemplate = mesTemplateService.getMesLabelTemplate(printTemplate);
String methodCode = mesLabelTemplate.getMethodCode();
if (StringUtils.isEmpty(methodCode)) {
throw ImppExceptionBuilder.newInstance().setSystemID(CommonEnumUtil.SOFT_TYPE.MES_PCN.getCode())
.setErrorCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode())
.setErrorDetail(String.format("当前打印模板【%s】未维护方法名", printTemplate)).build();
}
} else if (MesExtEnumUtil.MES_PRINT_TEMPLATE.GQXNY.getCode().equals(printTemplate)) {
// else if GQXNY
//----广乘 45位 GQXNY
//{custPartNo}{SPILTURE}{custCode}{spiltrure}{spiltrule}{year}{serialNo}{spilture}{spiltrule}
//客户零件号-扩展位-客户代码-预留位000-产线1-年月日-条码-扩展0000-追溯位+
//零件长号---17位,不足17位 右边补*
GenSerialNoModel genSerialNoModel = new GenSerialNoModel();
genSerialNoModel.setRuleCode(numberRule.getRuleCode());
//获取客户零件号
String custPartNo = getMesCustomerPart(mesProduceSnPrintModel).getCustPartNo();
String custPartNoFormat = stringFormat(custPartNo, 17);
genSerialNoModel.setCustPartNo(custPartNoFormat);
//拓展位 2位 00 包含0~9,A~Z 不使用时补“0”填充 {SPILTRULE}
//供应商代码 7位 供应商代码 0~9,A~Z;不足7位 右测补*
MesConfig supplierConfig = configService.getMesConfigByCfgCodeKeyOrg(MesPcnExtConstWords.SUPPLIER_CODE, MesExtEnumUtil.MES_PRINT_TEMPLATE.GQXNY.getValue(), organizeCode);
String supplierCode = supplierConfig.getCfgValue();
String supplierCodeFormat = stringFormat(supplierCode, 7);
genSerialNoModel.setCustCode(supplierCodeFormat);
//扩展位 3位 预留扩展位0~9 A~Z 不使用时,补 0 {SPILTRULE}
//产线 1位 供应商产线号表示由数字1~9 和字母A~Z(I/O除外)组成; {SPILTRULE}
//年月日 6位 yyMMdd 零部件生产日期年月日各2位
String year = TimeTool.pareDateToString("yyMMdd", date);
genSerialNoModel.setYear(year);
//流水号 4位 采用34进制 0001~ZZZZ (I、O除外)顺位进行标注 (同广汽 & 广新) {serialNo}
//扩展位 4位 预留扩展位信息包含0~9和字母A~Z,不使用时补“0” 填充; {SPILTRULE}
//追溯标识 1位 + 代表精确按件追溯,$标识按批追溯, % 代表按生产方式追溯 {SPILTRULE}
for (int i = 0; i < printQty; i++) {
ResultBean resultBean = syncFuncService.syncSerialNo(genSerialNoModel, mesProduceSnPrintModel.getUserName(), organizeCode, 1);
String sn = resultBean.getResultList().get(0).toString();
String snPrefix = sn.substring(0, sn.length() - 12);
String snSuffix = sn.substring(sn.length() - 5);
String serialNo = sn.substring(sn.length() - 12, sn.length() - 5);
String serialNo34 = toBase34(Integer.parseInt(serialNo));
serialNo34 = stringFormat(serialNo34, 4, false, "0");
sn = snPrefix + serialNo34 + snSuffix;
//保存条码信息
MesProduceSn produceSn = generateMesProduceSn(mesPart, sn, mesProduceSnPrintModel.getUserName(), mesProduceSnPrintModel.getQty(), format);
//封装打印信息
MesProduceSnPrintDataModel model = getModel(produceSn, serialNo, custPartNo, organizeName);
model.setSupplierCode(supplierCode);
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(model);
mesProduceSnRDao.insert(produceSn);
//保存打印记录
MesPrintedSnLog snLog = new MesPrintedSnLog();
ConvertBean.serviceModelInitialize(snLog, mesProduceSnPrintModel.getUserName());
BeanUtil.copyProperties(model,snLog);
mesPrintedSnRao.insert(snLog);
}
} else if (MesExtEnumUtil.MES_PRINT_TEMPLATE.NO_SORT_BAR_CODE_GZ.getCode().equals(printTemplate)) {
// noSortBarCodeGz
//{partNo}{year}{month}{day}{serialNo}
//内部条码, 批量打印 NoSortBarCodeGZ
//零件号 partNo
String partNo = mesPart.getPartNo();
GenSerialNoModel genSerialNoModel = new GenSerialNoModel();
genSerialNoModel.setRuleCode(numberRule.getRuleCode());
genSerialNoModel.setPartNo(partNo);
//年月日 yyyyMMdd
//流水号 4位 每天从1开始
for (int i = 0; i < printQty; 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(), format);
//封装打印信息
MesProduceSnPrintDataModel model = getModel(produceSn, serialNo, mesProduceSnPrintModel.getCustPartNo(), organizeName);
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(model);
mesProduceSnRDao.insert(produceSn);
//保存打印记录
MesPrintedSnLog snLog = new MesPrintedSnLog();
ConvertBean.serviceModelInitialize(snLog, mesProduceSnPrintModel.getUserName());
BeanUtil.copyProperties(model,snLog);
mesPrintedSnRao.insert(snLog);
}
} else if (MesExtEnumUtil.MES_PRINT_TEMPLATE.XIAO_PENG.getCode().equals(printTemplate)) {
format = DateUtil.BASE_FORMAT;
// XIAO_PENG 原客户条码.小鹏汽车 NoSortBarCodeGZ-new
//{custPartNo}{SPILTRULE}{year}{month}{day}{hour}{minute}{second}{serialNo}
INumberRulePackAttributeStrategyService packStrategy = (INumberRulePackAttributeStrategyService) SpringContextsUtil.getBean(methodNameExt);
MesCustomerPart mesCustomerPart = getMesCustomerPart(mesProduceSnPrintModel);
GenSerialNoModel genSerialNoModel = new GenSerialNoModel();
genSerialNoModel.setRuleCode(numberRule.getRuleCode());
//客户零件号
String custPartNo = getMesCustomerPart(mesProduceSnPrintModel).getCustPartNo();
genSerialNoModel.setCustPartNo(custPartNo);
//日期${dateShort}
genSerialNoModel.setYear(getYearShort(date));
genSerialNoModel.setMonth(getMonthShort(date));
genSerialNoModel.setDay(getDayShort(date));
//中杠 -
//生产日期 + 时间 yyyyMMddHHmmss
//流水号 5位 每天从1开始
for (int i = 0; i < printQty; 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(), format);
//封装打印信息
MesProduceSnPrintDataModel model = getModel(produceSn, serialNo, mesProduceSnPrintModel.getCustPartNo(), organizeName);
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(model);
mesProduceSnRDao.insert(produceSn);
genSerialNoModel.setPartNo(mesPart.getPartNo());
genSerialNoModel.putDataMap("mesPart",mesPart);
genSerialNoModel.putDataMap("mesCustomerPart",mesCustomerPart);
genSerialNoModel.setOrganizeCode(organizeCode);
genSerialNoModel = packStrategy.execute(genSerialNoModel);
genSerialNoModel.setCustPartNo(mesCustomerPart.getCustPartNo());
IPrintTemplateStrategyService templateStrategy = (IPrintTemplateStrategyService) SpringContextsUtil.getBean(methodCode);
MesProduceSnPrintModel resultModel = templateStrategy.execute(genSerialNoModel, mesProduceSnPrintModel, numberRule,null,null,false);
resultModel.getMesProduceSnList().forEach(mesProduceSn -> {
//保存条码
mesProduceSnRDao.insert(mesProduceSn);
});
resultModel.getMesPrintedSnLogList().forEach(model -> {
//保存打印记录
MesPrintedSnLog snLog = new MesPrintedSnLog();
ConvertBean.serviceModelInitialize(snLog, mesProduceSnPrintModel.getUserName());
BeanUtil.copyProperties(model, snLog);
mesPrintedSnRao.insert(snLog);
}
});
} else if (MesExtEnumUtil.MES_PRINT_TEMPLATE.XIAO_PENG_NEW.getCode().equals(printTemplate)) {
format = "yyyy-MM-dd";
//gz-xiaopeng
//客户条码-小鹏汽车 gz-xiaopeng
//{custPartNo}{year}{month}{day}{serialNo}
GenSerialNoModel genSerialNoModel = new GenSerialNoModel();
//客户零件号
String custPartNo = getMesCustomerPart(mesProduceSnPrintModel).getCustPartNo();
genSerialNoModel.setCustPartNo(custPartNo);
//年月日缩写
genSerialNoModel.setYear(getYearShort(date));
genSerialNoModel.setMonth(getMonthShort(date));
genSerialNoModel.setDay(getDayShort(date));
genSerialNoModel.setRuleCode(numberRule.getRuleCode());
//流水号 5位 每天从1开始
for (int i = 0; i < printQty; 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(), format);
produceSn.setCustPartNo(custPartNo);
//封装打印信息
MesProduceSnPrintDataModel model = getModel(produceSn, serialNo, custPartNo, organizeName);
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(model);
mesProduceSnRDao.insert(produceSn);
//保存打印记录
MesPrintedSnLog snLog = new MesPrintedSnLog();
ConvertBean.serviceModelInitialize(snLog, mesProduceSnPrintModel.getUserName());
BeanUtil.copyProperties(model,snLog);
mesPrintedSnRao.insert(snLog);
}
}
resultModel.setMesLabelTemplate(mesLabelTemplate);
resultModel.setMesPrintedSnLogList(null);
resultModel.setMesProduceSnList(null);
return resultModel;
//条码补打
} else {
//查找打印记录
@ -396,44 +241,6 @@ public class MesProduceSnPrintService implements IMesProduceSnPrintService {
return mesProduceSnPrintDataModel;
}
// private List<String> getSerialNoList(MesProduceSnPrintModel mesProduceSnPrintModel) {
// List<String> serialNoList = new ArrayList<>();
// //获取系统参数
// String configKey = MesPcnEnumUtil.PRINT_TEMPLATE.codeOfValue(mesProduceSnPrintModel.getPrintTemplate());
// if (StringUtils.isEmpty(configKey)) {
// MesPcnException.throwMesBusiException("打印模板未匹配到流水码规则");
// }
// MesConfig mesConfig = mesConfigService.getMesConfig(mesProduceSnPrintModel.getOrganizeCode(), configKey);
// int cfgValue = StringUtils.isEmpty(mesConfig.getCfgValue()) || !CheckTool.isInteger(mesConfig.getCfgValue()) ? 1 : Integer.parseInt(mesConfig.getCfgValue());
// if (MesPcnEnumUtil.PRINT_TEMPLATE.B2M.getCode().equals(mesProduceSnPrintModel.getPrintTemplate()) || MesPcnEnumUtil.PRINT_TEMPLATE.GQAA.getCode().equals(mesProduceSnPrintModel.getPrintTemplate())) {
// if (StringUtils.isEmpty(mesConfig.getCfgValueDesc()) || !TimeTool.getYear().equals(mesConfig.getCfgValueDesc())) {
// cfgValue = 1;
// mesConfig.setCfgValueDesc(TimeTool.getYear());
// }
// for (int i = 0; i < mesProduceSnPrintModel.getPrintQty(); i++) {
// serialNoList.add(stringFormat(toBase34(cfgValue), 4, false, "0"));
// cfgValue++;
// }
// } else if (MesPcnEnumUtil.PRINT_TEMPLATE.GQXNY.getCode().equals(mesProduceSnPrintModel.getPrintTemplate())) {
// for (int i = 0; i < mesProduceSnPrintModel.getPrintQty(); i++) {
// serialNoList.add(String.format("%04d", cfgValue));
// cfgValue++;
// }
// } else if (MesPcnEnumUtil.PRINT_TEMPLATE.NO_SORT_BAR_CODE_GZ.getCode().equals(mesProduceSnPrintModel.getPrintTemplate()) || MesPcnEnumUtil.PRINT_TEMPLATE.NO_SORT_BAR_CODE_GZ_NEW.getCode().equals(mesProduceSnPrintModel.getPrintTemplate())) {
// if (StringUtils.isEmpty(mesConfig.getCfgValueDesc()) || !TimeTool.getToday().equals(mesConfig.getCfgValueDesc())) {
// cfgValue = 1;
// mesConfig.setCfgValueDesc(TimeTool.getToday());
// }
// for (int i = 0; i < mesProduceSnPrintModel.getPrintQty(); i++) {
// serialNoList.add(String.format("%05d", cfgValue));
// cfgValue++;
// }
// }
// mesConfig.setCfgValue(String.valueOf(cfgValue));
// ConvertBean.serviceModelUpdate(mesConfig, mesProduceSnPrintModel.getUserName());
// mesConfigRDao.update(mesConfig);
// return serialNoList;
// }
private MesCustomerPart getMesCustomerPart(MesProduceSnPrintModel mesProduceSnPrintModel) {
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(mesProduceSnPrintModel.getOrganizeCode());

@ -166,7 +166,7 @@ public class MesProductionRecordService implements IMesProductionRecordService {
public List<MesProductionRecord> findProductionRecordList(String organizeCode, String productSn) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(productSn)) return null;
return productionRecordRepository.findByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.PRODUCT_SN},
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.PRODUCT_SN},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), productSn});
}
@ -174,7 +174,7 @@ public class MesProductionRecordService implements IMesProductionRecordService {
public List<MesProductionRecord> findProductionRecordList(String organizeCode, String productSn, String partNo, String processCode, String craftCode) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(productSn) || StringUtils.isEmpty(partNo) || StringUtils.isEmpty(processCode) || StringUtils.isEmpty(craftCode)) return null;
return productionRecordRepository.findByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.PRODUCT_SN, MesPcnExtConstWords.PART_NO, MesPcnExtConstWords.PROCESS_CODE, MesPcnExtConstWords.CRAFT_CODE},
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.PRODUCT_SN, MesPcnExtConstWords.PART_NO, MesPcnExtConstWords.PROCESS_CODE, MesPcnExtConstWords.CRAFT_CODE},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), productSn, partNo, processCode, craftCode});
}
@ -182,7 +182,7 @@ public class MesProductionRecordService implements IMesProductionRecordService {
public List<MesProductionRecord> findProductionRecordList(String organizeCode, String productSn, String partNo, String craftCode) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(productSn) || StringUtils.isEmpty(partNo) || StringUtils.isEmpty(craftCode)) return null;
return productionRecordRepository.findByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.PRODUCT_SN, MesPcnExtConstWords.PART_NO, MesPcnExtConstWords.CRAFT_CODE},
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.PRODUCT_SN, MesPcnExtConstWords.PART_NO, MesPcnExtConstWords.CRAFT_CODE},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), productSn, partNo, craftCode});
}

@ -0,0 +1,60 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.numberrule;
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.INumberRulePackAttributeStrategyService;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.HashMap;
/**
* @Description :
* @Reference :
* @Author : Castle
* @CreateDate : 2024/7/6 13:51
* @Modify:
**/
@Component
public class B2mAndGqaaNumberRuleStrategyService implements INumberRulePackAttributeStrategyService {
@Override
public GenSerialNoModel execute(GenSerialNoModel genSerialNoModel) {
MesPart mesPart = (MesPart) genSerialNoModel.getDataMap().get("mesPart");
Date date = new Date();
// genSerialNoModel.setRuleCode(numberRule.getRuleCode());
//${SPILTRULE}${partNo}${SPILTRULE}${SPILTRULE}${year}${month}${day}${serialNo}${SPILTRULE}
//规格号,零件号,供应商,生产线代码,年,月,日,序列号,软件版本号
// ----广汽 1B2M & 广新 GQAA_BARCODE 21位
//规格号 ${SPILTRULE} +
//零件简号 {partNo} - mesPart.getPartSnParam()
genSerialNoModel.setPartNo(mesPart.getPartSnParam());
//供应商号 supplierNo ---固定VD501 ${SPILTRULE}拼接
//生产线代码 workCenterCode 或者 fixWorkCenterCode (取配置值) ${SPILTRULE}
//日期${dateShort}
genSerialNoModel.setYear(getYearShort(date));
genSerialNoModel.setMonth(getMonthShort(date));
genSerialNoModel.setDay(getDayShort(date));
//获取客户零件号
// String custPartNo = custPart.getCustPartNo();
//供应商生产流水号 ${serialNo} 采用34进制 获取条码是十进制,需要截取转换成34位
//软件版本号${versionNo} ${SPILTRULE}
return genSerialNoModel;
}
private String getYearShort(Date date) {
return MesExtEnumUtil.YEAR_SHORT.valueOfDescription(Integer.parseInt(TimeTool.getYear(date)));
}
private String getMonthShort(Date date) {
return MesExtEnumUtil.MONTH_SHORT.valueOfDescription(Integer.parseInt(TimeTool.getMonth(date)));
}
private String getDayShort(Date date) {
return TimeTool.getDay(date);
}
}

@ -0,0 +1,88 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.numberrule;
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.INumberRulePackAttributeStrategyService;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.mes.bean.MesConfig;
import cn.estsh.i3plus.pojo.mes.bean.MesCustomerPart;
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @Description :
* @Reference :
* @Author : Castle
* @CreateDate : 2024/7/6 14:01
* @Modify:
**/
@Component
public class GqxnyNumberRuleStrategyService implements INumberRulePackAttributeStrategyService {
@Autowired
private IConfigService configService;
@Override
public GenSerialNoModel execute(GenSerialNoModel genSerialNoModel) {
Date date = new Date();
//----广乘 45位 GQXNY
//{custPartNo}{SPILTURE}{custCode}{spiltrure}{spiltrule}{year}{serialNo}{spilture}{spiltrule}
//客户零件号-扩展位-客户代码-预留位000-产线1-年月日-条码-扩展0000-追溯位+
//零件长号---17位,不足17位 右边补*
//获取客户零件号
Map<String, Object> dataMap = genSerialNoModel.getDataMap();
MesCustomerPart mesCustomerPart = (MesCustomerPart)dataMap.get("mesCustomerPart");
String custPartNo = mesCustomerPart.getCustPartNo();
String custPartNoFormat = stringFormat(custPartNo, 17);
genSerialNoModel.setCustPartNo(custPartNoFormat);
//拓展位 2位 00 包含0~9,A~Z 不使用时补“0”填充 {SPILTRULE}
//供应商代码 7位 供应商代码 0~9,A~Z;不足7位 右测补*
MesConfig supplierConfig = configService.getMesConfigByCfgCodeKeyOrg(MesPcnExtConstWords.SUPPLIER_CODE, MesExtEnumUtil.MES_PRINT_TEMPLATE.GQXNY.getValue(), genSerialNoModel.getOrganizeCode());
String supplierCode = supplierConfig.getCfgValue();
String supplierCodeFormat = stringFormat(supplierCode, 7);
genSerialNoModel.setCustCode(supplierCodeFormat);
//扩展位 3位 预留扩展位0~9 A~Z 不使用时,补 0 {SPILTRULE}
//产线 1位 供应商产线号表示由数字1~9 和字母A~Z(I/O除外)组成; {SPILTRULE}
//年月日 6位 yyMMdd 零部件生产日期年月日各2位
String year = TimeTool.pareDateToString("yyMMdd", date);
genSerialNoModel.setYear(year);
//流水号 4位 采用34进制 0001~ZZZZ (I、O除外)顺位进行标注 (同广汽 & 广新) {serialNo}
//扩展位 4位 预留扩展位信息包含0~9和字母A~Z,不使用时补“0” 填充; {SPILTRULE}
//追溯标识 1位 + 代表精确按件追溯,$标识按批追溯, % 代表按生产方式追溯 {SPILTRULE}
return genSerialNoModel;
}
private String stringFormat(String data, Integer length) {
return stringFormat(data, length, true, "*");
}
private String stringFormat(String data, Integer length, boolean left, String symbol) {
//数据长途大于填充位数直接返回
if (data.length() >= length) {
return data;
}
StringBuilder dataBuffer = new StringBuilder();
//右拼接
if (left) {
dataBuffer.append(data);
for (int i = 0; i < length - data.length(); i++) {
dataBuffer.append(symbol);
}
}
//左拼接
if (!left) {
for (int i = 0; i < length - data.length(); i++) {
dataBuffer.append(symbol);
}
dataBuffer.append(data);
}
return dataBuffer.toString();
}
}

@ -0,0 +1,27 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.numberrule;
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.INumberRulePackAttributeStrategyService;
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
import org.springframework.stereotype.Component;
/**
* @Description :
* @Reference :
* @Author : Castle
* @CreateDate : 2024/7/6 14:09
* @Modify:
**/
@Component
public class NoSortBarcodeGzNumberRuleStrategyService implements INumberRulePackAttributeStrategyService {
@Override
public GenSerialNoModel execute(GenSerialNoModel genSerialNoModel) {
//{partNo}{year}{month}{day}{serialNo}
//内部条码, 批量打印 NoSortBarCodeGZ
//零件号 partNo
// GenSerialNoModel genSerialNoModel = new GenSerialNoModel();
// genSerialNoModel.setRuleCode(numberRule.getRuleCode());
// genSerialNoModel.setPartNo(partNo);
return genSerialNoModel;
}
}

@ -0,0 +1,74 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.numberrule;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.INumberRulePackAttributeStrategyService;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesCustomerPart;
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
import cn.estsh.i3plus.pojo.mes.repository.MesCustomerPartRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.Date;
/**
* @Description :
* @Reference :
* @Author : Castle
* @CreateDate : 2024/6/26 9:38
* @Modify:
**/
@Component
public class XiaoPengNewNumberRuleStrategyService implements INumberRulePackAttributeStrategyService {
@Autowired
private MesCustomerPartRepository customerPartRepository;
@Override
public GenSerialNoModel execute(GenSerialNoModel model) {
if (StringUtils.isEmpty(model.getOrganizeCode()))
MesPcnException.throwMesBusiException("XiaoPengNumberRuleStrategyService执行异常:缺失组织代码参数");
if (StringUtils.isEmpty(model.getPartNo()))
MesPcnException.throwMesBusiException("XiaoPengNumberRuleStrategyService执行异常:缺失零件编码参数");
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(model.getPartNo(), "erpPartNo", ddlPackBean);
MesCustomerPart customerPart = customerPartRepository.getByProperty(ddlPackBean);
if (null == customerPart)
MesPcnException.throwMesBusiException("请检查客户零件信息,零件[%s]客户零件关系未维护", model.getPartNo());
model.setCustPartNo(customerPart.getCustPartNo());
Date date = new Date();
// XIAO_PENG 原客户条码.小鹏汽车 NoSortBarCodeGZ-new
//{custPartNo}{SPILTRULE}{year}{month}{day}{hour}{minute}{second}{serialNo}
//客户零件号
//String custPartNo = model.getCustPartNo();
//日期${dateShort}
model.setYear(getYearShort(date));
model.setMonth(getMonthShort(date));
model.setDay(getDayShort(date));
//中杠 -
//生产日期 + 时间 yyyyMMddHHmmss
//流水号 5位 每天从1开始
return model;
}
private String getYearShort(Date date) {
return MesExtEnumUtil.YEAR_SHORT.valueOfDescription(Integer.parseInt(TimeTool.getYear(date)));
}
private String getMonthShort(Date date) {
return MesExtEnumUtil.MONTH_SHORT.valueOfDescription(Integer.parseInt(TimeTool.getMonth(date)));
}
private String getDayShort(Date date) {
return TimeTool.getDay(date);
}
}

@ -1,19 +1,18 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.numberrule;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.INumberRulePackAttributeStrategyService;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesCustomerPart;
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
import cn.estsh.i3plus.pojo.mes.repository.MesCustomerPartRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @Description :
@ -22,38 +21,25 @@ import java.util.Date;
* @CreateDate : 2024/6/26 9:38
* @Modify:
**/
@Service
@Component
public class XiaoPengNumberRuleStrategyService implements INumberRulePackAttributeStrategyService {
@Autowired
private MesCustomerPartRepository customerPartRepository;
@Override
public GenSerialNoModel execute(GenSerialNoModel model) {
if (StringUtils.isEmpty(model.getOrganizeCode())) MesPcnException.throwMesBusiException("XiaoPengNumberRuleStrategyService执行异常:缺失组织代码参数");
if (StringUtils.isEmpty(model.getPartNo())) MesPcnException.throwMesBusiException("XiaoPengNumberRuleStrategyService执行异常:缺失零件编码参数");
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(model.getPartNo(), "erpPartNo", ddlPackBean);
MesCustomerPart customerPart = customerPartRepository.getByProperty(ddlPackBean);
if (null == customerPart) MesPcnException.throwMesBusiException("请检查客户零件信息,零件[%s]客户零件关系未维护", model.getPartNo());
model.setCustPartNo(customerPart.getCustPartNo());
public GenSerialNoModel execute(GenSerialNoModel genSerialNoModel) {
Date date = new Date();
// XIAO_PENG 原客户条码.小鹏汽车 NoSortBarCodeGZ-new
//{custPartNo}{SPILTRULE}{year}{month}{day}{hour}{minute}{second}{serialNo}
Map<String, Object> dataMap =genSerialNoModel.getDataMap();
MesCustomerPart customerPart = (MesCustomerPart) dataMap.get("mesCustomerPart");
//客户零件号
String custPartNo = model.getCustPartNo();
//日期${dateShort}
model.setYear(getYearShort(date));
model.setMonth(getMonthShort(date));
model.setDay(getDayShort(date));
//中杠 -
//生产日期 + 时间 yyyyMMddHHmmss
//流水号 5位 每天从1开始
return model;
String custPartNo = customerPart.getCustPartNo();
genSerialNoModel.setCustPartNo(custPartNo);
//年月日缩写
genSerialNoModel.setYear(getYearShort(date));
genSerialNoModel.setMonth(getMonthShort(date));
genSerialNoModel.setDay(getDayShort(date));
return genSerialNoModel;
}
private String getYearShort(Date date) {

@ -1,13 +1,11 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintDataModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
import cn.estsh.i3plus.pojo.mes.bean.MesNumberRule;
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 java.util.List;
import java.util.Map;
/**
* @Description : , content dataList
* @Reference :
@ -22,5 +20,14 @@ public interface IPrintTemplateStrategyService {
* @param sn
* @return
*/
MesProduceSnPrintDataModel execute(StepResult stepResult, StationRequestBean reqBean, MesProductionPsOutContext sn , String organizeCode);
// MesProduceSnPrintDataModel execute(StepResult stepResult, StationRequestBean reqBean, MesProductionPsOutContext sn , String organizeCode);
/**
* GenSerialNoModel
* mesProduceSnPrintModel
* @param model
* @param mesProduceSnPrintModel
* @return
*/
MesProduceSnPrintModel execute(GenSerialNoModel model , MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep);
}

@ -1,29 +1,35 @@
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.pojo.context.MesProductionPsOutContext;
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;
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.exception.ImppExceptionEnum;
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.MesCustomerOriganze;
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
import cn.estsh.i3plus.pojo.mes.bean.*;
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.MesCustomerOriganizeRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesPartRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesCustomerPartRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ResultBean;
import cn.hutool.core.bean.BeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.Objects;
/**
* @Description : 广使
@ -32,71 +38,169 @@ import java.util.*;
* @CreateDate : 2024/6/6 17:03
* @Modify:
**/
@Service
@Component
@Slf4j
public class AionPrintStrategy implements IPrintTemplateStrategyService {
@Autowired
private ISyncFuncService syncFuncService;
@Autowired
private SnowflakeIdMaker snowflakeIdMaker;
@Autowired
private IMesPartService mesPartService;
@Autowired
private MesPartRepository mesPartRao;
private IConfigService configService;
@Autowired
private MesCustomerPartRepository mesCustomerPartRDao;
@Override
public MesProduceSnPrintDataModel execute(StepResult stepResult, StationRequestBean reqBean, MesProductionPsOutContext sn, String organizeCode) {
//partNo零件号
String partNo = sn.getPartNo();
//零件条码中获取 serialNo
String productSn = sn.getProductSn();
//构造标签
Map<String,Object> map = new HashMap<>();
String partName = sn.getPartName();
String factoryName = reqBean.getOrganizeName();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
LocalDateTime now = LocalDateTime.now();
String productDate = now.format(formatter);
int no = 1;
String noStr = String.format("%07d", no);
//构造二维码
// StringBuilder barcode = new StringBuilder();
// barcode.append("+");
//第二位 是零件简号 零件扩展信息中的 零件条码参数 字段
DdlPackBean partPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(partNo,"partNo",partPackBean);
// List<MesPart> parts = mesPartRao.findByHqlWhere(partPackBean);
// if (!parts.isEmpty()){
// MesPart mesPart = parts.get(0);
// String partSnParam = mesPart.getPartSnParam();
// if (partSnParam!=null && !partSnParam.isEmpty()){
// barcode.append(partSnParam);
// }else {
// log.error("零件号:{},缺少配置零件扩展属性的 零件条码参数",partNo);
// }
// }
//第三位 供应商代码 // 配置表
// String supplierCode = "VD501";
// barcode.append(supplierCode);
//第四位 生产线代号 // 配置表
// String workCenterCode = "1";
// barcode.append(workCenterCode);
//第五位 生产年月日
// int year = now.getYear();
// int month = now.getMonth().getValue();
// int day = now.getDayOfMonth();
// String yearStr = MesExtEnumUtil.YEAR_SHORT.valueOfDescription(year);
// String monthStr = MesExtEnumUtil.MONTH_SHORT.valueOfDescription(month);
// String dayStr = MesExtEnumUtil.NUM_SCALE_34.valueOfDescription(day);
// barcode.append(yearStr);
// barcode.append(monthStr);
// barcode.append(dayStr);
//第六位 供应商生产流水号
//第七位 软件版本代号
map.put("partNo",partNo);
map.put("partName",partName);
map.put("factoryName",factoryName);
map.put("productDate",productDate);
map.put("no",noStr);
map.put("barcode",productSn);
// return map;
return null;
public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule , StepResult stepResult, StationRequestBean reqBean, Boolean isStep) {
// 获取工厂名称
String organizeCode = mesProduceSnPrintModel.getOrganizeCode();
MesConfig mesConfig = configService.getMesConfigByCfgCode(MesPcnExtConstWords.ORGANIZE_NAME, organizeCode);
if (null == mesConfig || StringUtils.isEmpty(mesConfig.getCfgValue())) {
throw ImppExceptionBuilder.newInstance().setSystemID(CommonEnumUtil.SOFT_TYPE.MES_PCN.getCode()).setErrorCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode()).setErrorDetail("没有维护当前工厂的系统参数!").build();
}
//获取工厂名称
String organizeName = mesConfig.getCfgValue();
String format ="yyyy/MM/dd";
MesCustomerPart mesCustomerPart = getMesCustomerPart(mesProduceSnPrintModel);
//物料信息
MesPart mesPart = mesPartService.getMesPartByPartNo(mesProduceSnPrintModel.getPartNo(), organizeCode);
if (!isStep){
for (int i = 0; i < mesProduceSnPrintModel.getPrintQty(); i++) {
ResultBean resultBean = syncFuncService.syncSerialNo(genSerialNoModel, mesProduceSnPrintModel.getUserName(), organizeCode, 1);
String sn = resultBean.getResultList().get(0).toString();
int versionNoLength = numberRule.getSpiltRule().substring(numberRule.getSpiltRule().lastIndexOf(",") + 1).length();
Integer serialNoLength = numberRule.getSerialnoLength();
String snPrefix = sn.substring(0, sn.length() - versionNoLength - serialNoLength);
String snSuffix = sn.substring(sn.length() - versionNoLength);
String serialNo = sn.substring(sn.length() - versionNoLength - serialNoLength, sn.length() - versionNoLength);
String serialNo34 = toBase34(Integer.parseInt(serialNo));
serialNo34 = stringFormat(serialNo34, 4, false, "0");
sn = snPrefix + serialNo34 + snSuffix;
//保存条码信息
MesProduceSn produceSn = generateMesProduceSn(mesPart, sn, mesProduceSnPrintModel.getUserName(), mesProduceSnPrintModel.getQty(), format);
//封装打印信息
MesProduceSnPrintDataModel printDataModel = getModel(produceSn, serialNo, mesCustomerPart.getCustPartNo(), organizeName);
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(printDataModel);
mesProduceSnPrintModel.getMesProduceSnList().add(produceSn);
//保存打印记录
MesPrintedSnLog snLog = new MesPrintedSnLog();
ConvertBean.serviceModelInitialize(snLog, mesProduceSnPrintModel.getUserName());
BeanUtil.copyProperties(printDataModel,snLog);
mesProduceSnPrintModel.getMesPrintedSnLogList().add(snLog);
}
}else {
String sn = mesProduceSnPrintModel.getProductSn();
MesProduceSn mesProduceSn = mesProduceSnPrintModel.getMesProduceSnList().get(0);
int versionNoLength = numberRule.getSpiltRule().substring(numberRule.getSpiltRule().lastIndexOf(",") + 1).length();
Integer serialNoLength = numberRule.getSerialnoLength();
String snPrefix = sn.substring(0, sn.length() - versionNoLength - serialNoLength);
String snSuffix = sn.substring(sn.length() - versionNoLength);
String serialNo = sn.substring(sn.length() - versionNoLength - serialNoLength, sn.length() - versionNoLength);
String serialNo34 = toBase34(Integer.parseInt(serialNo));
serialNo34 = stringFormat(serialNo34, 4, false, "0");
sn = snPrefix + serialNo34 + snSuffix;
//封装打印信息
MesProduceSnPrintDataModel printDataModel = getModel(mesProduceSn, serialNo, mesCustomerPart.getCustPartNo(), organizeName);
printDataModel.setBarcode(sn);
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(printDataModel);
//保存打印记录
MesPrintedSnLog snLog = new MesPrintedSnLog();
ConvertBean.serviceModelInitialize(snLog, mesProduceSnPrintModel.getUserName());
BeanUtil.copyProperties(printDataModel,snLog);
mesProduceSnPrintModel.getMesPrintedSnLogList().add(snLog);
}
return mesProduceSnPrintModel;
}
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.setProductDate(produceSn.getLotNo());
return mesProduceSnPrintDataModel;
}
// 34进制字符集
private String toBase34(int number) {
String base34Chars = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ";
StringBuilder sb = new StringBuilder();
while (number > 0) {
int remainder = number % 34;
sb.append(base34Chars.charAt(remainder));
number /= 34;
}
return sb.reverse().toString();
}
private String stringFormat(String data, Integer length) {
return stringFormat(data, length, true, "*");
}
private String stringFormat(String data, Integer length, boolean left, String symbol) {
//数据长途大于填充位数直接返回
if (data.length() >= length) {
return data;
}
StringBuilder dataBuffer = new StringBuilder();
//右拼接
if (left) {
dataBuffer.append(data);
for (int i = 0; i < length - data.length(); i++) {
dataBuffer.append(symbol);
}
}
//左拼接
if (!left) {
for (int i = 0; i < length - data.length(); i++) {
dataBuffer.append(symbol);
}
dataBuffer.append(data);
}
return dataBuffer.toString();
}
private MesProduceSn generateMesProduceSn(MesPart mesPart, String sn, String userName, Double qty, String format) {
MesProduceSn mesProduceSn = new MesProduceSn();
mesProduceSn.setSerialNumber(snowflakeIdMaker.nextId() + "");
mesProduceSn.setProductSn(sn);
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.getNowTime(format));
mesProduceSn.setPrintCount(MesPcnExtConstWords.ONE);
mesProduceSn.setPrintStatus(MesExtEnumUtil.PRINT_STATUS.PRINTED.getValue());
mesProduceSn.setOrganizeCode(mesPart.getOrganizeCode());
ConvertBean.serviceModelInitialize(mesProduceSn, userName);
return mesProduceSn;
}
private MesCustomerPart getMesCustomerPart(MesProduceSnPrintModel mesProduceSnPrintModel) {
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(mesProduceSnPrintModel.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(mesProduceSnPrintModel.getPartNo(), "erpPartNo", ddlPackBean);
MesCustomerPart mesCustomerPart = mesCustomerPartRDao.getByProperty(ddlPackBean);
if (Objects.isNull(mesCustomerPart)) {
MesPcnException.throwMesBusiException("物料【%s】客户零件关系未维护", mesProduceSnPrintModel.getPartNo());
}
return mesCustomerPart;
}
}

@ -1,18 +1,35 @@
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.pojo.context.MesProductionPsOutContext;
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;
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.exception.ImppExceptionEnum;
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.model.GenSerialNoModel;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StepResult;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.i3plus.pojo.mes.repository.MesCustomerPartRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ResultBean;
import cn.hutool.core.bean.BeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* @Description :
@ -21,38 +38,169 @@ import java.util.Map;
* @CreateDate : 2024/6/17 16:10
* @Modify:
**/
@Service
@Component
@Slf4j
public class GqaaPrintStrategy implements IPrintTemplateStrategyService {
@Autowired
private ISyncFuncService syncFuncService;
@Autowired
private SnowflakeIdMaker snowflakeIdMaker;
@Autowired
private IMesPartService mesPartService;
@Autowired
private IConfigService configService;
@Autowired
private MesCustomerPartRepository mesCustomerPartRDao;
@Override
public MesProduceSnPrintDataModel execute(StepResult stepResult, StationRequestBean reqBean, MesProductionPsOutContext sn, String organizeCode) {
Map<String,Object> map = new HashMap<>();
String partNo = sn.getPartNo();
String partName = sn.getPartName();
String factoryName = reqBean.getOrganizeName();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yy/MM/dd");
LocalDateTime now = LocalDateTime.now();
String productDate = now.format(formatter);
//构造二维码
StringBuilder barcode = new StringBuilder();
//第三位 供应商代码 // 配置表
String supplierCode = "VD501";
barcode.append(supplierCode);
//第四位 生产线代号 // 配置表
String workCenterCode = "1";
barcode.append(workCenterCode);
int no = 1;
String noStr = String.format("%07d", no);
map.put("no",noStr);
map.put("partNo", partNo);
map.put("partName", partName);
map.put("factoryName", factoryName);
map.put("productDate", productDate);
map.put("barcode", barcode.toString());
return null;
public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep) {
// 获取工厂名称
String organizeCode = mesProduceSnPrintModel.getOrganizeCode();
MesConfig mesConfig = configService.getMesConfigByCfgCode(MesPcnExtConstWords.ORGANIZE_NAME, organizeCode);
if (null == mesConfig || StringUtils.isEmpty(mesConfig.getCfgValue())) {
throw ImppExceptionBuilder.newInstance().setSystemID(CommonEnumUtil.SOFT_TYPE.MES_PCN.getCode()).setErrorCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode()).setErrorDetail("没有维护当前工厂的系统参数!").build();
}
//获取工厂名称
String organizeName = mesConfig.getCfgValue();
String format ="yyyy/MM/dd";
MesCustomerPart mesCustomerPart = getMesCustomerPart(mesProduceSnPrintModel);
//物料信息
MesPart mesPart = mesPartService.getMesPartByPartNo(mesProduceSnPrintModel.getPartNo(), organizeCode);
if (!isStep){
for (int i = 0; i < mesProduceSnPrintModel.getPrintQty(); i++) {
ResultBean resultBean = syncFuncService.syncSerialNo(genSerialNoModel, mesProduceSnPrintModel.getUserName(), organizeCode, 1);
String sn = resultBean.getResultList().get(0).toString();
int versionNoLength = numberRule.getSpiltRule().substring(numberRule.getSpiltRule().lastIndexOf(",") + 1).length();
Integer serialNoLength = numberRule.getSerialnoLength();
String snPrefix = sn.substring(0, sn.length() - versionNoLength - serialNoLength);
String snSuffix = sn.substring(sn.length() - versionNoLength);
String serialNo = sn.substring(sn.length() - versionNoLength - serialNoLength, sn.length() - versionNoLength);
String serialNo34 = toBase34(Integer.parseInt(serialNo));
serialNo34 = stringFormat(serialNo34, 4, false, "0");
sn = snPrefix + serialNo34 + snSuffix;
//保存条码信息
MesProduceSn produceSn = generateMesProduceSn(mesPart, sn, mesProduceSnPrintModel.getUserName(), mesProduceSnPrintModel.getQty(), format);
//封装打印信息
MesProduceSnPrintDataModel printDataModel = getModel(produceSn, serialNo, mesCustomerPart.getCustPartNo(), organizeName);
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(printDataModel);
mesProduceSnPrintModel.getMesProduceSnList().add(produceSn);
//保存打印记录
MesPrintedSnLog snLog = new MesPrintedSnLog();
ConvertBean.serviceModelInitialize(snLog, mesProduceSnPrintModel.getUserName());
BeanUtil.copyProperties(printDataModel,snLog);
mesProduceSnPrintModel.getMesPrintedSnLogList().add(snLog);
}
}else {
String sn = mesProduceSnPrintModel.getProductSn();
MesProduceSn mesProduceSn = mesProduceSnPrintModel.getMesProduceSnList().get(0);
int versionNoLength = numberRule.getSpiltRule().substring(numberRule.getSpiltRule().lastIndexOf(",") + 1).length();
Integer serialNoLength = numberRule.getSerialnoLength();
String snPrefix = sn.substring(0, sn.length() - versionNoLength - serialNoLength);
String snSuffix = sn.substring(sn.length() - versionNoLength);
String serialNo = sn.substring(sn.length() - versionNoLength - serialNoLength, sn.length() - versionNoLength);
String serialNo34 = toBase34(Integer.parseInt(serialNo));
serialNo34 = stringFormat(serialNo34, 4, false, "0");
sn = snPrefix + serialNo34 + snSuffix;
//封装打印信息
MesProduceSnPrintDataModel printDataModel = getModel(mesProduceSn, serialNo, mesCustomerPart.getCustPartNo(), organizeName);
printDataModel.setBarcode(sn);
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(printDataModel);
//保存打印记录
MesPrintedSnLog snLog = new MesPrintedSnLog();
ConvertBean.serviceModelInitialize(snLog, mesProduceSnPrintModel.getUserName());
BeanUtil.copyProperties(printDataModel,snLog);
mesProduceSnPrintModel.getMesPrintedSnLogList().add(snLog);
}
return mesProduceSnPrintModel;
}
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.setProductDate(produceSn.getLotNo());
return mesProduceSnPrintDataModel;
}
// 34进制字符集
private String toBase34(int number) {
String base34Chars = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ";
StringBuilder sb = new StringBuilder();
while (number > 0) {
int remainder = number % 34;
sb.append(base34Chars.charAt(remainder));
number /= 34;
}
return sb.reverse().toString();
}
private String stringFormat(String data, Integer length) {
return stringFormat(data, length, true, "*");
}
private String stringFormat(String data, Integer length, boolean left, String symbol) {
//数据长途大于填充位数直接返回
if (data.length() >= length) {
return data;
}
StringBuilder dataBuffer = new StringBuilder();
//右拼接
if (left) {
dataBuffer.append(data);
for (int i = 0; i < length - data.length(); i++) {
dataBuffer.append(symbol);
}
}
//左拼接
if (!left) {
for (int i = 0; i < length - data.length(); i++) {
dataBuffer.append(symbol);
}
dataBuffer.append(data);
}
return dataBuffer.toString();
}
private MesProduceSn generateMesProduceSn(MesPart mesPart, String sn, String userName, Double qty, String format) {
MesProduceSn mesProduceSn = new MesProduceSn();
mesProduceSn.setSerialNumber(snowflakeIdMaker.nextId() + "");
mesProduceSn.setProductSn(sn);
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.getNowTime(format));
mesProduceSn.setPrintCount(MesPcnExtConstWords.ONE);
mesProduceSn.setPrintStatus(MesExtEnumUtil.PRINT_STATUS.PRINTED.getValue());
mesProduceSn.setOrganizeCode(mesPart.getOrganizeCode());
ConvertBean.serviceModelInitialize(mesProduceSn, userName);
return mesProduceSn;
}
private MesCustomerPart getMesCustomerPart(MesProduceSnPrintModel mesProduceSnPrintModel) {
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(mesProduceSnPrintModel.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(mesProduceSnPrintModel.getPartNo(), "erpPartNo", ddlPackBean);
MesCustomerPart mesCustomerPart = mesCustomerPartRDao.getByProperty(ddlPackBean);
if (Objects.isNull(mesCustomerPart)) {
MesPcnException.throwMesBusiException("物料【%s】客户零件关系未维护", mesProduceSnPrintModel.getPartNo());
}
return mesCustomerPart;
}
}

@ -1,18 +1,37 @@
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.pojo.context.MesProductionPsOutContext;
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;
import cn.estsh.i3plus.mes.pcn.api.iservice.base.IConfigService;
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.exception.ImppExceptionEnum;
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.model.GenSerialNoModel;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StepResult;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.i3plus.pojo.mes.repository.MesCustomerPartRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ResultBean;
import cn.hutool.core.bean.BeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
import java.util.Date;
import java.util.Objects;
/**
* @Description :
@ -21,38 +40,190 @@ import java.util.Map;
* @CreateDate : 2024/6/17 16:10
* @Modify:
**/
@Service
@Component
@Slf4j
public class GqxnyPrintStrategy implements IPrintTemplateStrategyService {
@Autowired
private ISyncFuncService syncFuncService;
@Autowired
private SnowflakeIdMaker snowflakeIdMaker;
@Autowired
private IMesPartService mesPartService;
@Autowired
private IConfigService configService;
@Autowired
private MesCustomerPartRepository mesCustomerPartRDao;
@Override
public MesProduceSnPrintDataModel execute(StepResult stepResult, StationRequestBean reqBean, MesProductionPsOutContext sn, String organizeCode) {
Map<String,Object> map = new HashMap<>();
String partNo = sn.getPartNo();
String partName = sn.getPartName();
String factoryName = reqBean.getOrganizeName();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yy/MM/dd");
LocalDateTime now = LocalDateTime.now();
String productDate = now.format(formatter);
//构造二维码
StringBuilder barcode = new StringBuilder();
//第三位 供应商代码 // 配置表
String supplierCode = "VD501";
barcode.append(supplierCode);
//第四位 生产线代号 // 配置表
String workCenterCode = "1";
barcode.append(workCenterCode);
int no = 1;
String noStr = String.format("%07d", no);
map.put("no",noStr);
map.put("partNo", partNo);
map.put("partName", partName);
map.put("factoryName", factoryName);
map.put("productDate", productDate);
map.put("barcode", barcode.toString());
return null;
public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule,StepResult stepResult, StationRequestBean reqBean,Boolean isStep) {
//获取客户零件号
String custPartNo = getMesCustomerPart(mesProduceSnPrintModel).getCustPartNo();
String format = DateUtil.BASE_FORMAT;
// 获取工厂名称
String organizeCode = mesProduceSnPrintModel.getOrganizeCode();
MesConfig mesConfig = configService.getMesConfigByCfgCode(MesPcnExtConstWords.ORGANIZE_NAME, organizeCode);
if (null == mesConfig || StringUtils.isEmpty(mesConfig.getCfgValue())) {
throw ImppExceptionBuilder.newInstance().setSystemID(CommonEnumUtil.SOFT_TYPE.MES_PCN.getCode()).setErrorCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode()).setErrorDetail("没有维护当前工厂的系统参数!").build();
}
//获取工厂名称
String organizeName = mesConfig.getCfgValue();
if (!isStep){
//物料信息
MesPart mesPart = mesPartService.getMesPartByPartNo(mesProduceSnPrintModel.getPartNo(), organizeCode);
Date date = new Date();
//----广乘 45位 GQXNY
//{custPartNo}{SPILTURE}{custCode}{spiltrure}{spiltrule}{year}{serialNo}{spilture}{spiltrule}
//客户零件号-扩展位-客户代码-预留位000-产线1-年月日-条码-扩展0000-追溯位+
//零件长号---17位,不足17位 右边补*
genSerialNoModel.setRuleCode(numberRule.getRuleCode());
String custPartNoFormat = stringFormat(custPartNo, 17);
genSerialNoModel.setCustPartNo(custPartNoFormat);
//拓展位 2位 00 包含0~9,A~Z 不使用时补“0”填充 {SPILTRULE}
//供应商代码 7位 供应商代码 0~9,A~Z;不足7位 右测补*
MesConfig supplierConfig = configService.getMesConfigByCfgCodeKeyOrg(MesPcnExtConstWords.SUPPLIER_CODE, MesExtEnumUtil.MES_PRINT_TEMPLATE.GQXNY.getValue(), organizeCode);
String supplierCode = supplierConfig.getCfgValue();
String supplierCodeFormat = stringFormat(supplierCode, 7);
genSerialNoModel.setCustCode(supplierCodeFormat);
//扩展位 3位 预留扩展位0~9 A~Z 不使用时,补 0 {SPILTRULE}
//产线 1位 供应商产线号表示由数字1~9 和字母A~Z(I/O除外)组成; {SPILTRULE}
//年月日 6位 yyMMdd 零部件生产日期年月日各2位
String year = TimeTool.pareDateToString("yyMMdd", date);
genSerialNoModel.setYear(year);
//流水号 4位 采用34进制 0001~ZZZZ (I、O除外)顺位进行标注 (同广汽 & 广新) {serialNo}
//扩展位 4位 预留扩展位信息包含0~9和字母A~Z,不使用时补“0” 填充; {SPILTRULE}
//追溯标识 1位 + 代表精确按件追溯,$标识按批追溯, % 代表按生产方式追溯 {SPILTRULE}
for (int i = 0; i < mesProduceSnPrintModel.getPrintQty(); i++) {
ResultBean resultBean = syncFuncService.syncSerialNo(genSerialNoModel, mesProduceSnPrintModel.getUserName(), organizeCode, 1);
String sn = resultBean.getResultList().get(0).toString();
String snPrefix = sn.substring(0, sn.length() - 12);
String snSuffix = sn.substring(sn.length() - 5);
String serialNo = sn.substring(sn.length() - 12, sn.length() - 5);
String serialNo34 = toBase34(Integer.parseInt(serialNo));
serialNo34 = stringFormat(serialNo34, 4, false, "0");
sn = snPrefix + serialNo34 + snSuffix;
//保存条码信息
MesProduceSn produceSn = generateMesProduceSn(mesPart, sn, mesProduceSnPrintModel.getUserName(), mesProduceSnPrintModel.getQty(), format);
//封装打印信息
MesProduceSnPrintDataModel printDataModel = getModel(produceSn, serialNo, custPartNo, organizeName);
printDataModel.setSupplierCode(supplierCode);
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(printDataModel);
//保存打印记录
MesPrintedSnLog snLog = new MesPrintedSnLog();
ConvertBean.serviceModelInitialize(snLog, mesProduceSnPrintModel.getUserName());
BeanUtil.copyProperties(printDataModel, snLog);
mesProduceSnPrintModel.getMesProduceSnList().add(produceSn);
}
}else {
String sn = mesProduceSnPrintModel.getProductSn();
MesProduceSn mesProduceSn = mesProduceSnPrintModel.getMesProduceSnList().get(0);
int versionNoLength = numberRule.getSpiltRule().substring(numberRule.getSpiltRule().lastIndexOf(",") + 1).length();
Integer serialNoLength = numberRule.getSerialnoLength();
String snPrefix = sn.substring(0, sn.length() - versionNoLength - serialNoLength);
String snSuffix = sn.substring(sn.length() - versionNoLength);
String serialNo = sn.substring(sn.length() - versionNoLength - serialNoLength, sn.length() - versionNoLength);
String serialNo34 = toBase34(Integer.parseInt(serialNo));
serialNo34 = stringFormat(serialNo34, 4, false, "0");
sn = snPrefix + serialNo34 + snSuffix;
//封装打印信息
MesProduceSnPrintDataModel printDataModel = getModel(mesProduceSn, serialNo, custPartNo, organizeName);
printDataModel.setBarcode(sn);
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(printDataModel);
//保存打印记录
MesPrintedSnLog snLog = new MesPrintedSnLog();
ConvertBean.serviceModelInitialize(snLog, mesProduceSnPrintModel.getUserName());
BeanUtil.copyProperties(printDataModel,snLog);
mesProduceSnPrintModel.getMesPrintedSnLogList().add(snLog);
}
return mesProduceSnPrintModel;
}
private MesCustomerPart getMesCustomerPart(MesProduceSnPrintModel mesProduceSnPrintModel) {
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(mesProduceSnPrintModel.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(mesProduceSnPrintModel.getPartNo(), "erpPartNo", ddlPackBean);
MesCustomerPart mesCustomerPart = mesCustomerPartRDao.getByProperty(ddlPackBean);
if (Objects.isNull(mesCustomerPart)) {
MesPcnException.throwMesBusiException("物料【%s】客户零件关系未维护", mesProduceSnPrintModel.getPartNo());
}
return mesCustomerPart;
}
private String stringFormat(String data, Integer length) {
return stringFormat(data, length, true, "*");
}
private String stringFormat(String data, Integer length, boolean left, String symbol) {
//数据长途大于填充位数直接返回
if (data.length() >= length) {
return data;
}
StringBuilder dataBuffer = new StringBuilder();
//右拼接
if (left) {
dataBuffer.append(data);
for (int i = 0; i < length - data.length(); i++) {
dataBuffer.append(symbol);
}
}
//左拼接
if (!left) {
for (int i = 0; i < length - data.length(); i++) {
dataBuffer.append(symbol);
}
dataBuffer.append(data);
}
return dataBuffer.toString();
}
// 34进制字符集
private String toBase34(int number) {
String base34Chars = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ";
StringBuilder sb = new StringBuilder();
while (number > 0) {
int remainder = number % 34;
sb.append(base34Chars.charAt(remainder));
number /= 34;
}
return sb.reverse().toString();
}
private MesProduceSn generateMesProduceSn(MesPart mesPart, String sn, String userName, Double qty, String format) {
MesProduceSn mesProduceSn = new MesProduceSn();
mesProduceSn.setSerialNumber(snowflakeIdMaker.nextId() + "");
mesProduceSn.setProductSn(sn);
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.getNowTime(format));
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.setProductDate(produceSn.getLotNo());
return mesProduceSnPrintDataModel;
}
}

@ -1,21 +1,35 @@
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.pojo.context.MesProductionPsOutContext;
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;
import cn.estsh.i3plus.mes.pcn.api.iservice.base.IConfigService;
import cn.estsh.i3plus.pojo.mes.bean.MesConfig;
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.exception.ImppExceptionEnum;
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.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.MesNumberRuleRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ResultBean;
import cn.hutool.core.bean.BeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
/**
* @Description :
@ -24,39 +38,110 @@ import java.util.Map;
* @CreateDate : 2024/6/17 16:31
* @Modify:
**/
@Service
@Component
@Slf4j
public class NoSortBarCodeGzStrategy implements IPrintTemplateStrategyService {
@Autowired
private IConfigService configService;
@Autowired
private IMesPartService mesPartService;
@Autowired
private ISyncFuncService syncFuncService;
@Autowired
private SnowflakeIdMaker snowflakeIdMaker;
@Autowired
private MesNumberRuleRepository mesNumberRuleRDao;
@Override
public MesProduceSnPrintDataModel execute(StepResult stepResult,StationRequestBean reqBean, MesProductionPsOutContext sn, String organizeCode) {
//获取供应商编码
MesConfig mesConfig = configService.getMesConfigByCfgCodeKeyOrg(MesPcnExtConstWords.SUPPLIER_CODE, MesPcnExtConstWords.SUPPLIER_CODE_NO_SORT_GZ, reqBean.getOrganizeCode());
if (null == mesConfig) {
stepResult.setCompleted(false);
stepResult.setMsg(String.format("缺少供应商编码配置,请配置系统参数,配置代码【%s】,配置key为【%s】", MesPcnExtConstWords.SUPPLIER_CODE,MesPcnExtConstWords.SUPPLIER_CODE_NO_SORT_GZ));
return null;
public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule,StepResult stepResult, StationRequestBean reqBean,Boolean isStep) {
// noSortBarCodeGz
String format = DateUtil.BASE_FORMAT;
//{partNo}{year}{month}{day}{serialNo}
String organizeCode = mesProduceSnPrintModel.getOrganizeCode();
MesPart mesPart = mesPartService.getMesPartByPartNo(mesProduceSnPrintModel.getPartNo(), organizeCode);
String partNo = mesPart.getPartNo();
MesConfig mesConfig = configService.getMesConfigByCfgCode(MesPcnExtConstWords.ORGANIZE_NAME, organizeCode);
if (!isStep){
if (null == mesConfig || StringUtils.isEmpty(mesConfig.getCfgValue())) {
throw ImppExceptionBuilder.newInstance().setSystemID(CommonEnumUtil.SOFT_TYPE.MES_PCN.getCode()).setErrorCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode()).setErrorDetail("没有维护当前工厂的系统参数!").build();
}
String organizeName = mesConfig.getCfgValue();
genSerialNoModel.setRuleCode(numberRule.getRuleCode());
genSerialNoModel.setPartNo(partNo);
//年月日 yyyyMMdd
//流水号 4位 每天从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(), format);
//封装打印信息
MesProduceSnPrintDataModel printDataModel = getModel(produceSn, serialNo, mesProduceSnPrintModel.getCustPartNo(), organizeName);
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(printDataModel);
mesProduceSnPrintModel.getMesProduceSnList().add(produceSn);
//保存打印记录
MesPrintedSnLog snLog = new MesPrintedSnLog();
ConvertBean.serviceModelInitialize(snLog, mesProduceSnPrintModel.getUserName());
BeanUtil.copyProperties(printDataModel,snLog);
mesProduceSnPrintModel.getMesPrintedSnLogList().add(snLog);
}
}else {
//获取条码规则,根据条码规则中的序列号长度截取序列号
DdlPackBean mesRulePackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(mesPart.getProductMatchRule(), "ruleCode", mesRulePackBean);
List<MesNumberRule> ruleList = mesNumberRuleRDao.findByHqlWhere(mesRulePackBean);
MesNumberRule mesNumberRule = ruleList.get(0);
String organizeName = mesConfig.getCfgValue();
String sn = mesProduceSnPrintModel.getProductSn();
MesProduceSn mesProduceSn = mesProduceSnPrintModel.getMesProduceSnList().get(0);
Integer serialNoLength = mesNumberRule.getSerialnoLength();
String serialNo = sn.substring(sn.length() - serialNoLength);
//封装打印信息
MesProduceSnPrintDataModel printDataModel = getModel(mesProduceSn, serialNo, mesProduceSnPrintModel.getCustPartNo(), organizeName);
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(printDataModel);
//保存打印记录
MesPrintedSnLog snLog = new MesPrintedSnLog();
ConvertBean.serviceModelInitialize(snLog, mesProduceSnPrintModel.getUserName());
BeanUtil.copyProperties(printDataModel,snLog);
mesProduceSnPrintModel.getMesPrintedSnLogList().add(snLog);
}
return mesProduceSnPrintModel;
}
private MesProduceSn generateMesProduceSn(MesPart mesPart, String sn, String userName, Double qty, String format) {
MesProduceSn mesProduceSn = new MesProduceSn();
mesProduceSn.setSerialNumber(snowflakeIdMaker.nextId() + "");
mesProduceSn.setProductSn(sn);
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.getNowTime(format));
mesProduceSn.setPrintCount(MesPcnExtConstWords.ONE);
mesProduceSn.setPrintStatus(MesExtEnumUtil.PRINT_STATUS.PRINTED.getValue());
mesProduceSn.setOrganizeCode(mesPart.getOrganizeCode());
ConvertBean.serviceModelInitialize(mesProduceSn, userName);
return mesProduceSn;
}
String supplierCode = mesConfig.getCfgValue();
//1.根据零件号获取 零件扩展信息
Map<String,Object> map = new HashMap<>();
String partNo = sn.getPartNo();
String partName = sn.getPartName();
String factoryName = reqBean.getOrganizeName();
String productSn = sn.getProductSn();
LocalDateTime now = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String productDateTime = now.format(formatter);
MesProduceSnPrintDataModel model = new MesProduceSnPrintDataModel();
model.setPartNo(partNo);
model.setPartName(partName);
model.setFactoryName(factoryName);
model.setSupplierCode(supplierCode);
model.setProductDate(productDateTime);
model.setNo( productSn.substring(productSn.length()-4));
model.setBarcode(productSn);
return model;
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.setProductDate(produceSn.getLotNo());
return mesProduceSnPrintDataModel;
}
}

@ -0,0 +1,178 @@
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.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;
import cn.estsh.i3plus.mes.pcn.api.iservice.base.IConfigService;
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.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.*;
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.MesCustomerPartRepository;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.Date;
import java.util.Objects;
/**
* @Description :
* @Reference :
* @Author : Castle
* @CreateDate : 2024/6/17 16:43
* @Modify:
**/
@Component
@Slf4j
public class XiaoPengNewPrintStrategy implements IPrintTemplateStrategyService {
@Autowired
private MesCustomerPartRepository mesCustomerPartRDao;
@Autowired
private ISyncFuncService syncFuncService;
@Autowired
private SnowflakeIdMaker snowflakeIdMaker;
@Autowired
private IMesPartService mesPartService;
@Autowired
private IConfigService configService;
@Override
public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep) {
String format = DateUtil.BASE_FORMAT;
Date date = new Date();
String organizeCode = mesProduceSnPrintModel.getOrganizeCode();
//gz-xiaopeng
//客户条码-小鹏汽车 gz-xiaopeng
//{custPartNo}{year}{month}{day}{serialNo}
//客户零件号
String custPartNo = getMesCustomerPart(mesProduceSnPrintModel).getCustPartNo();
MesPart mesPart = mesPartService.getMesPartByPartNo(mesProduceSnPrintModel.getPartNo(), organizeCode);
MesConfig mesConfig = configService.getMesConfigByCfgCode(MesPcnExtConstWords.ORGANIZE_NAME, organizeCode);
String organizeName = mesConfig.getCfgValue();
if (!isStep){
genSerialNoModel.setCustPartNo(custPartNo);
//年月日缩写
genSerialNoModel.setYear(getYearShort(date));
genSerialNoModel.setMonth(getMonthShort(date));
genSerialNoModel.setDay(getDayShort(date));
genSerialNoModel.setRuleCode(numberRule.getRuleCode());
//流水号 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(), format);
produceSn.setCustPartNo(custPartNo);
//封装打印信息
MesProduceSnPrintDataModel printDataModel = getModel(produceSn, serialNo, custPartNo, organizeName);
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(printDataModel);
mesProduceSnPrintModel.getMesProduceSnList().add(produceSn);
//保存打印记录
MesPrintedSnLog snLog = new MesPrintedSnLog();
ConvertBean.serviceModelInitialize(snLog, mesProduceSnPrintModel.getUserName());
BeanUtil.copyProperties(printDataModel,snLog);
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();
ConvertBean.serviceModelInitialize(snLog, mesProduceSnPrintModel.getUserName());
BeanUtil.copyProperties(printDataModel,snLog);
mesProduceSnPrintModel.getMesPrintedSnLogList().add(snLog);
}
return mesProduceSnPrintModel;
}
private MesCustomerPart getMesCustomerPart(MesProduceSnPrintModel mesProduceSnPrintModel) {
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(mesProduceSnPrintModel.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(mesProduceSnPrintModel.getPartNo(), "erpPartNo", ddlPackBean);
MesCustomerPart mesCustomerPart = mesCustomerPartRDao.getByProperty(ddlPackBean);
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) {
String day = TimeTool.getDay(date);
return day;
}
private MesProduceSn generateMesProduceSn(MesPart mesPart, String sn, String userName, Double qty, String format) {
MesProduceSn mesProduceSn = new MesProduceSn();
mesProduceSn.setSerialNumber(snowflakeIdMaker.nextId() + "");
mesProduceSn.setProductSn(sn);
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.getNowTime(format));
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.setProductDate(produceSn.getLotNo());
return mesProduceSnPrintDataModel;
}
}

@ -1,17 +1,34 @@
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.pojo.context.MesProductionPsOutContext;
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;
import cn.estsh.i3plus.mes.pcn.api.iservice.base.IConfigService;
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.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.*;
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.MesCustomerPartRepository;
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 org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
import java.util.Date;
import java.util.Objects;
/**
* @Description :
@ -20,23 +37,143 @@ import java.util.Map;
* @CreateDate : 2024/6/17 16:43
* @Modify:
**/
@Service
@Component
@Slf4j
public class XiaoPengPrintStrategy implements IPrintTemplateStrategyService {
@Autowired
private MesCustomerPartRepository mesCustomerPartRDao;
@Autowired
private ISyncFuncService syncFuncService;
@Autowired
private SnowflakeIdMaker snowflakeIdMaker;
@Autowired
private IMesPartService mesPartService;
@Autowired
private IConfigService configService;
@Override
public MesProduceSnPrintDataModel execute(StepResult stepResult, StationRequestBean reqBean, MesProductionPsOutContext sn, String organizeCode) {
//从条码中截取流水号,流水号 后四位
String productSn = sn.getProductSn();
String partNo = sn.getPartNo();
String partName = sn.getPartName();
LocalDateTime now = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
String productDateTime = now.format(formatter);
MesProduceSnPrintDataModel model = new MesProduceSnPrintDataModel();
model.setPartNo(partNo);
model.setBarcode(productSn);
model.setPartName(partName);
model.setProductDate(productDateTime);
return model;
public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep) {
String format = DateUtil.BASE_FORMAT;
Date date = new Date();
String organizeCode = mesProduceSnPrintModel.getOrganizeCode();
//gz-xiaopeng
//客户条码-小鹏汽车 gz-xiaopeng
//{custPartNo}{year}{month}{day}{serialNo}
//客户零件号
String custPartNo = getMesCustomerPart(mesProduceSnPrintModel).getCustPartNo();
MesPart mesPart = mesPartService.getMesPartByPartNo(mesProduceSnPrintModel.getPartNo(), organizeCode);
MesConfig mesConfig = configService.getMesConfigByCfgCode(MesPcnExtConstWords.ORGANIZE_NAME, organizeCode);
String organizeName = mesConfig.getCfgValue();
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(), format);
produceSn.setCustPartNo(custPartNo);
//封装打印信息
MesProduceSnPrintDataModel printDataModel = getModel(produceSn, serialNo, custPartNo, organizeName);
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(printDataModel);
mesProduceSnPrintModel.getMesProduceSnList().add(produceSn);
//保存打印记录
MesPrintedSnLog snLog = new MesPrintedSnLog();
ConvertBean.serviceModelInitialize(snLog, mesProduceSnPrintModel.getUserName());
BeanUtil.copyProperties(printDataModel,snLog);
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();
ConvertBean.serviceModelInitialize(snLog, mesProduceSnPrintModel.getUserName());
BeanUtil.copyProperties(printDataModel,snLog);
mesProduceSnPrintModel.getMesPrintedSnLogList().add(snLog);
}
return mesProduceSnPrintModel;
}
private MesCustomerPart getMesCustomerPart(MesProduceSnPrintModel mesProduceSnPrintModel) {
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(mesProduceSnPrintModel.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(mesProduceSnPrintModel.getPartNo(), "erpPartNo", ddlPackBean);
MesCustomerPart mesCustomerPart = mesCustomerPartRDao.getByProperty(ddlPackBean);
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) {
String day = TimeTool.getDay(date);
return day;
}
private MesProduceSn generateMesProduceSn(MesPart mesPart, String sn, String userName, Double qty, String format) {
MesProduceSn mesProduceSn = new MesProduceSn();
mesProduceSn.setSerialNumber(snowflakeIdMaker.nextId() + "");
mesProduceSn.setProductSn(sn);
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.getNowTime(format));
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.setProductDate(produceSn.getLotNo());
return mesProduceSnPrintDataModel;
}
}

@ -21,7 +21,7 @@ public class MesFunctionSwitchCellService extends BaseSwsService implements IFsm
private IShippingDispatchService shippingDispatchService;
@Override
public Boolean doFunction(StationRequestBean reqBean, StationResultBean resultBean, ButtonDynamicModel buttonDynamicModel) {
public Object doCustomApiDispatch(StationRequestBean reqBean, StationResultBean resultBean, ButtonDynamicModel buttonDynamicModel) {
this.sendMessage(reqBean, resultBean.writeDbLog(MesExtEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PICK.getValue()).scanInfo(buttonDynamicModel.getFunctionValue()),
String.format("生产线[%s]工位[%s]%s,客户端已下线!", reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), buttonDynamicModel.getButtonName()), MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);

@ -1,5 +1,6 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesAssemblyExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionRecordService;
@ -46,6 +47,9 @@ public class MesProdCraftRouteCheckStepService extends BaseStepService {
@Autowired
private IFsmRouteDataService fsmRouteDataService;
@Autowired
private IMesAssemblyExtService assemblyExtService;
@Override
public StepResult execute(StationRequestBean reqBean) {
@ -235,8 +239,8 @@ public class MesProdCraftRouteCheckStepService extends BaseStepService {
//执行首道工艺 当前主条码验证通过
if (CollectionUtils.isEmpty(beforeCellCraftList)) return true;
//当前主条码的工艺字段为空
if (StringUtils.isEmpty(productionPsInContext.getCraftCode()) && craftRouteDetailList.get(0).getIsChoose().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)
//当前主条码的工艺字段为空 验证首工艺是否存在工单装配件信息
if (StringUtils.isEmpty(productionPsInContext.getCraftCode()) && craftRouteDetailList.get(0).getIsChoose().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0 && checkIsExistWorkOrderAssembly(productionPsInContext, craftRouteDetailList.get(0).getCraftCode()))
return stepResult.isCompleted(false).msg(String.format("%s主条码[%s]未经过首道工艺[%s]", message, productionPsInContext.getProductSn(), craftRouteDetailList.get(0).getCraftCode())).isCompleted();
//搜集主条码当前工艺于当前工位对应工艺之间的未完成的工艺集合
@ -255,14 +259,20 @@ public class MesProdCraftRouteCheckStepService extends BaseStepService {
//未完成工艺倒序
unCompleteCraftList = unCompleteCraftList.stream().filter(o -> null != o).sorted(Comparator.comparing(MesCraftRouteDetail::getSeq).reversed()).collect(Collectors.toList());
//验证未完成工艺是否存在工单装配件信息
Optional<MesCraftRouteDetail> optional = unCompleteCraftList.stream().filter(o -> (null != o && o.getIsChoose() == CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue())).findFirst();
if (unCompleteCraftList.get(0).getIsChoose().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)
if (unCompleteCraftList.get(0).getIsChoose().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0 && checkIsExistWorkOrderAssembly(productionPsInContext, unCompleteCraftList.get(0).getCraftCode()))
return stepResult.isCompleted(false).msg(String.format("%s主条码[%s]未经过必过工艺[%s]", message, productionPsInContext.getProductSn(), unCompleteCraftList.get(0).getCraftCode())).isCompleted();
return true;
}
//验证工艺是否存在工单装配件信息
private Boolean checkIsExistWorkOrderAssembly(MesProductionPsInContext productionPsInContext, String craftCode) {
return !CollectionUtils.isEmpty(assemblyExtService.getWorkOrderAssemblyList(productionPsInContext.getOrganizeCode(), productionPsInContext.getWorkOrderNo(), productionPsInContext.getProductSn(), craftCode)) ? true : false;
}
//前道工艺防错验证 【非排序】
private Boolean doProdCraftRouteCheckNosort(StationRequestBean reqBean, StepResult stepResult, MesProductionProcessContext productionProcessContext, MesProductionPsInContext productionPsInContext, List<MesCraftRouteDetail> craftRouteDetailList) {

@ -1,77 +1,182 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPartContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
import cn.estsh.i3plus.pojo.mes.model.StepResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.List;
import java.util.Optional;
/**
* @Description :
* @Author : wangjie
**/
@Slf4j
@Service("mesProduceSeqCheckStepService")
public class MesProduceSeqCheckStepService extends BaseStepService {
@Autowired
private IMesProductionProcessContextStepService productionProcessContextStepService;
@Autowired
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
@Override
public StepResult execute(StationRequestBean reqBean) {
StationResultBean resultBean = new StationResultBean();
StepResult stepResult = StepResult.getSuccessComplete();
//获取上下文信息
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.doHandleCurCellEquipment(reqBean);
//获取生产过程上下文对象有异常信息 抛出异常
if (!productionProcessContext.getSuccess()) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), productionProcessContext.getMessage());
//存储生产过程上下文对象
productionProcessContextStepService.saveProductionProcessContext(reqBean, productionProcessContext);
//获取上下文产出零件信息
List<MesProductionPartContext> productionPartContextList = productionDispatchContextStepService.getProductionPartContext(reqBean);
//验证是否存在加工单
if (!checkIsExistWorkOrder(productionPartContextList)) return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "当前无加工单信息,无需进行顺序防错验证!");
return stepResult;
}
//验证是否存在加工单
private Boolean checkIsExistWorkOrder(List<MesProductionPartContext> productionPartContextList) {
if (CollectionUtils.isEmpty(productionPartContextList)) return false;
Optional<MesProductionPartContext> optional = productionPartContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getWorkOrderNo()))).findFirst();
if (null == optional || !optional.isPresent()) return false;
return true;
}
}
//package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
//
//import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService;
//import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
//import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPartContext;
//import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
//import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
//import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
//import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
//import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
//import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter;
//import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
//import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
//import cn.estsh.i3plus.pojo.mes.model.StepResult;
//import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.util.CollectionUtils;
//import org.springframework.util.StringUtils;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Optional;
//
///**
// * @Description : 生产工单顺序防错
// * @Author : wangjie
// **/
//@Slf4j
//@Service("mesProduceSeqCheckStepService")
//public class MesProduceSeqCheckStepService extends BaseStepService {
//
// @Autowired
// private IMesProductionProcessContextStepService productionProcessContextStepService;
//
// @Autowired
// private IMesProductionDispatchContextStepService productionDispatchContextStepService;
//
// @Override
// public StepResult execute(StationRequestBean reqBean) {
//
// StationResultBean resultBean = new StationResultBean();
//
// StepResult stepResult = StepResult.getSuccessComplete();
//
// //获取上下文信息
// MesProductionProcessContext productionProcessContext = productionProcessContextStepService.doHandleCurCellEquipment(reqBean);
//
// //获取生产过程上下文对象有异常信息 抛出异常
// if (!productionProcessContext.getSuccess()) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), productionProcessContext.getMessage());
//
// //存储生产过程上下文对象
// productionProcessContextStepService.saveProductionProcessContext(reqBean, productionProcessContext);
//
// //获取上下文产出零件信息
// List<MesProductionPartContext> productionPartContextList = productionDispatchContextStepService.getProductionPartContext(reqBean);
//
// //验证是否存在加工单
// if (!checkIsExistWorkOrder(productionPartContextList)) return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "当前无加工单信息,无需进行顺序防错验证!");
//
// //验证工位是否设置需要顺序防错
// if (!isNeedCheckProduceSeq(productionPartContextList))
// return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format("生产线[%s]工位[%s]未设置顺序防错,无需进行顺序防错验证!", reqBean.getWorkCenterCode(), reqBean.getWorkCellCode()));
//
// //验证是否存在工艺强过码, 存在则保存 并返回强过的加工单
// List<String> workOrderNoList2Jump = doHandleCraftJumpCode(reqBean, productionPartContextList);
// if (!CollectionUtils.isEmpty(workOrderNoList2Jump))
// return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().scanInfo(workOrderNoList2Jump.toString()), stepResult, String.format("加工单%s跳过顺序防错验证成功!", workOrderNoList2Jump.toString()));
//
// //验证是否已经全部通过
// if (!isExistNeedCheckProduceSeq(productionPartContextList)) return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean, stepResult, "加工单均已通过顺序防错验证!");
//
// //顺序防错验证处理
// doHandleProduceSeqCheck(reqBean, resultBean, stepResult, productionProcessContext, productionProcessContext.getWorkCenter(), productionPartContextList);
//
// return stepResult;
//
// }
//
// //验证是否存在加工单
// private Boolean checkIsExistWorkOrder(List<MesProductionPartContext> productionPartContextList) {
//
// if (CollectionUtils.isEmpty(productionPartContextList)) return false;
//
// Optional<MesProductionPartContext> optional = productionPartContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getWorkOrderNo()))).findFirst();
//
// return (null == optional || !optional.isPresent()) ? false : true;
//
// }
//
// //验证工位是否设置需要前道防错
// private Boolean isNeedCheckProduceSeq(List<MesProductionPartContext> productionPartContextList) {
// Optional<MesProductionPartContext> optional = productionPartContextList.stream().filter(o -> (null != o &&
// o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0 && o.getIsCheckSeq().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0)).findFirst();
// return (null == optional || !optional.isPresent()) ? false : true;
// }
//
// //验证是否已经全部通过
// private Boolean isExistNeedCheckProduceSeq(List<MesProductionPartContext> productionPartContextList) {
// Optional<MesProductionPartContext> optional = productionPartContextList.stream().filter(o -> (null != o &&
// o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0 && o.getCheckSeqResult().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) != 0)).findFirst();
// return (null == optional || !optional.isPresent()) ? false : true;
// }
//
// //验证是否存在工艺强过码, 存在则保存 并返回强过的加工单
// private List<String> doHandleCraftJumpCode(StationRequestBean reqBean, List<MesProductionPartContext> productionPartContextList) {
//
// List<String> workOrderNoList2Jump = null;
//
// for (MesProductionPartContext productionPartContext : productionPartContextList) {
//
// if (null == productionPartContext || productionPartContext.getCheckSeqResult().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) != 0 || StringUtils.isEmpty(productionPartContext.getCraftJumpCode())) continue;
//
// if (CollectionUtils.isEmpty(workOrderNoList2Jump)) workOrderNoList2Jump = new ArrayList<>();
//
// workOrderNoList2Jump.add(productionPartContext.getWorkOrderNo());
//
// productionPartContext.checkSeqResult(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
//
// }
//
// //保存上下文产出零件信息
// if (!CollectionUtils.isEmpty(workOrderNoList2Jump)) productionDispatchContextStepService.saveProductionPartContext(reqBean, productionPartContextList);
//
// return workOrderNoList2Jump;
//
// }
//
// //顺序防错验证处理
// private void doHandleProduceSeqCheck(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesProductionProcessContext productionProcessContext, MesWorkCenter workCenter, List<MesProductionPartContext> productionPartContextList) {
//
// List<String> workOrderNoList = new ArrayList<>();
//
// for (MesProductionPartContext productionPartContext : productionPartContextList) {
//
// if (null == productionPartContext || StringUtils.isEmpty(productionPartContext.getWorkOrderNo()) || productionPartContext.getCheckSeqResult().compareTo(MesPcnExtConstWords.ZERO) != 0) continue;
//
// //顺序防错验证
// Boolean result = doProduceSeqCheck(reqBean, stepResult, productionProcessContext, workCenter, productionPartContextList);
//
// if (!result) productionPartContext.setCheckSeqResult(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
// else productionPartContext.setCheckSeqResult(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
//
// workOrderNoList.add(productionPartContext.getWorkOrderNo());
//
// }
//
// //保存上下文产出零件信息
// productionDispatchContextStepService.saveProductionPartContext(reqBean, productionPartContextList);
//
// if (stepResult.isCompleted()) this.sendMessage(reqBean, resultBean.writeDbLog().scanInfo(workOrderNoList.toString()), String.format("加工单%s顺序防错验证成功!", workOrderNoList.toString()), MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
// else this.sendMessage(reqBean, resultBean.writeDbLog().scanInfo(workOrderNoList.toString()), stepResult.getMsg(), MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT);
//
// }
//
// //顺序防错验证
// private Boolean doProduceSeqCheck(StationRequestBean reqBean, StepResult stepResult, MesProductionProcessContext productionProcessContext, MesWorkCenter workCenter, List<MesProductionPartContext> productionPartContextList) {
//
// //排序
// if (workCenter.getCenterType().compareTo(MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue()) == 0) return doProduceSeqCheckSort(reqBean, stepResult, productionProcessContext, productionPartContextList);
//
// //非排序
// return doProduceSeqCheckNosort(reqBean, stepResult, productionProcessContext, productionPartContextList);
//
// }
//
// //前道工艺防错验证 【排序】
// private Boolean doProduceSeqCheckSort(StationRequestBean reqBean, StepResult stepResult, MesProductionProcessContext productionProcessContext, List<MesProductionPartContext> productionPartContextList) {
//
//
//
// }
//
// //前道工艺防错验证 【非排序】
// private Boolean doProduceSeqCheckNosort(StationRequestBean reqBean, StepResult stepResult, MesProductionProcessContext productionProcessContext, List<MesProductionPartContext> productionPartContextList) {
//
//
//
// }
//
//}

@ -211,7 +211,7 @@ public class MesProductSnGenerateStepService extends BaseStepService {
} catch (ImppBusiException e) {
execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), e.getErrorDetail());
} catch (Exception e) {
execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), e.toString());
execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), e.toString() + "[doGererateSerialNo]");
}
return null;
}

@ -1,13 +1,12 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
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.MesProductionPsOutContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintDataModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
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.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
@ -15,19 +14,23 @@ 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.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
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.MesLabelTemplateRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesProduceSnRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
import cn.hutool.core.bean.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
@ -52,19 +55,22 @@ public class MesProductSnPrintStepService extends BaseStepService {
@Autowired
private IMesPrintedSnLogRepository snLogRao;
@Autowired
private MesProduceSnRepository mesProduceSnRao;
@Override
public StepResult execute(StationRequestBean reqBean) {
/**
* Map<String,Object>
* valueList:List<Map<String,Object>>
* paramInfo:{
* templateContent:xxxx,
* labelTemplateParamList: List<Map<String,Object>>
* }
*
* foreign
*
*/
// /**
// * Map<String,Object>
// * valueList:List<Map<String,Object>>
// * paramInfo:{
// * templateContent:xxxx,
// * labelTemplateParamList: List<Map<String,Object>>
// * }
// *
// * 根据foreign找出加工规则对应的上下文判断是否需要打印
// *
// */
String organizeCode = reqBean.getOrganizeCode();
StationResultBean resultBean = new StationResultBean();
StepResult stepResult = StepResult.getSuccessComplete();
@ -78,6 +84,10 @@ public class MesProductSnPrintStepService extends BaseStepService {
//返回打印标识 给前端
//1. 获取上下文中生成的主条码
List<MesProductionPsOutContext> productionPsOutContextList = mesProductionDispatchContextStepService.getProductionPsOutContext(reqBean);
/**
*
*/
List<MesProduceSnPrintModel> printModelList = new ArrayList<>();
//2. 获取条码需要模板、模板代码、打印机 --- 循环遍历条码 封装数据
for (MesProductionPsOutContext sn : productionPsOutContextList) {
List<MesProdRuleContext> mesProdRuleContexts = prodRuleContextMap.get(sn.getForeignKey());
@ -93,18 +103,20 @@ public class MesProductSnPrintStepService extends BaseStepService {
if (prodLabelTemplate == null) {
execExpSendMsgAndThrowEx(reqBean, resultBean, String.format("零件号[%s]的模板代码[%s]的模板信息丢失,请配置!", sn.getPartNo(), prodLabelTemplate));
}
MesLabelTemplate labelTemplate;
MesProduceSnPrintModel mesProduceSnPrintModel = new MesProduceSnPrintModel();
// 查模板代码
if (!labelTemplateMap.containsKey(prodLabelTemplate)) {
labelTemplate = getLabelTemplate(prodLabelTemplate, organizeCode);
MesLabelTemplate labelTemplate = getLabelTemplate(prodLabelTemplate, organizeCode);
mesProduceSnPrintModel.setMesLabelTemplate(labelTemplate);
mesProduceSnPrintModel.setProductSn(sn.getProductSn());
mesProduceSnPrintModel.setOrganizeCode(organizeCode);
List<MesProduceSn> snList = new ArrayList<>();
snList.add(sn);
mesProduceSnPrintModel.getMesProduceSnList().addAll(snList);
//模板信息丢失抛出异常
if (labelTemplate == null) {
execExpSendMsgAndThrowEx(reqBean, resultBean, String.format("零件号[%s]的模板代码[%s]的模板信息丢失,请配置!", sn.getPartNo(), prodLabelTemplate));
}
labelTemplateMap.put(prodLabelTemplate, labelTemplate);
} else {
labelTemplate = labelTemplateMap.get(prodLabelTemplate);
}
//根据反射获取策略类--封装打印数据
String methodCode = labelTemplate.getMethodCode();
//模板信息丢失抛出异常
@ -112,60 +124,25 @@ public class MesProductSnPrintStepService extends BaseStepService {
execExpSendMsgAndThrowEx(reqBean, resultBean, String.format("零件号[%s]的模板代码[%s]的反射类丢失,请配置!", sn.getPartNo(), prodLabelTemplate));
}
IPrintTemplateStrategyService strategyService = (IPrintTemplateStrategyService) SpringContextsUtil.getBean(methodCode);
MesProduceSnPrintDataModel model = strategyService.execute(stepResult, reqBean, sn, organizeCode);
if (!stepResult.isCompleted()){
execExpSendMsgAndThrowEx(reqBean, resultBean, stepResult.getMsg());
}
List<MesProduceSnPrintDataModel> printData;
if (resultData.containsKey(labelTemplate.getTemplateCode())) {
printData = resultData.get(labelTemplate.getTemplateCode());
printData.add(model);
} else {
printData = new ArrayList<>();
printData.add(model);
resultData.put(labelTemplate.getTemplateCode(), printData);
}
}
/** Map<String,Object>
* valueList:List<Map<String,Object>>
* paramInfo:{
* templateContent:xxxx,
* labelTemplateParamList: List<Map<String,Object>>
* }
*
*/
List<Map<String, Object>> printData = new ArrayList<>();
Set<String> labelKeys = labelTemplateMap.keySet();
List<MesPrintedSnLog> snLogList = new ArrayList<>();
for (String labelKey : labelKeys) {
Map<String,Object> paramInfo = new HashMap<>();
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);
String templateContent = mesLabelTemplate.getTemplateContent();
paramInfo.put("templateContent",templateContent);
paramInfo.put("labelTemplateParamList",mesLabelTemplate.getLabelTemplateParamList());
Map<String, Object> data = new HashMap<>();
data.put("paramInfo", paramInfo);
data.put("valueList", dataMaps);
printData.add(data);
// GenSerialNoModel model , MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep
MesProduceSnPrintModel printModel = strategyService.execute(null, mesProduceSnPrintModel, null, stepResult, reqBean, true);
printModelList.add(printModel);
}
//前端接收到busiTyep是customComponent并且 dataType是file类型的消息就需要打印后续消息里的数据一个模板对应多个打印数据
resultBean.setBusiType(MesPcnEnumUtil.STATION_BUSI_TYPE.CUSTOM_COMPONENT.getValue());
resultBean.setDataType(MesPcnEnumUtil.STATION_DATA_TYPE.FILE.getValue());
resultBean.setResultObj(printData);
resultBean.setResultObj(printModelList);
//3. 发送数据给到前端
this.sendMessage(reqBean, resultBean);
//todo 更新打印状态
List<MesPrintedSnLog> snLogList = printModelList.stream().map(MesProduceSnPrintModel::getMesPrintedSnLogList).flatMap(List::stream).collect(Collectors.toList());
//更新打印状态
for (MesProductionPsOutContext outSn : productionPsOutContextList) {
Long id = outSn.getId();
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(outSn.getOrganizeCode());
DdlPreparedPack.getNumberSmallerEqualPack(id,"id",ddlPackBean);
mesProduceSnRao.updateByProperties("printStatus",MesExtEnumUtil.PRINT_STATUS.PRINTED.getValue(),ddlPackBean);
}
//保存打印条码记录
snLogRao.saveAll(snLogList);
return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesExtEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "执行打印成功!");

@ -2,6 +2,8 @@ package cn.estsh.i3plus.ext.mes.pcn.pojo.model;
import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplate;
import cn.estsh.i3plus.pojo.mes.bean.MesPackingDefine;
import cn.estsh.i3plus.pojo.mes.bean.MesPrintedSnLog;
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
import io.swagger.annotations.ApiParam;
import lombok.Data;
@ -63,6 +65,10 @@ public class MesProduceSnPrintModel {
@ApiParam(name = "产品条码信息")
private List<MesProduceSnPrintDataModel> mesProduceSnPrintDataModelList = new ArrayList<>();
private List<MesProduceSn> mesProduceSnList = new ArrayList<>();
private List<MesPrintedSnLog> mesPrintedSnLogList = new ArrayList<>();
public Double getQty() {
return qty == null || qty <= 0d ? 1d : qty;
}

Loading…
Cancel
Save