|
|
|
@ -1,19 +1,18 @@
|
|
|
|
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.strategy;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesCustomerPartService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPartService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesPrintedSnLogService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintDataModel;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.api.iservice.base.IPartService;
|
|
|
|
|
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.codemaker.SnowflakeIdMaker;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesCustomerPart;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesNumberRule;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
|
|
|
|
@ -27,7 +26,9 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.StringJoiner;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description :门板及cnsl总成条码(单件)
|
|
|
|
@ -47,7 +48,7 @@ public class MesDPBarcodeWhPrintStrategy implements IPrintTemplateStrategyServic
|
|
|
|
|
private SnowflakeIdMaker snowflakeIdMaker;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesPartService mesPartService;
|
|
|
|
|
private IPartService partService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesPrintedSnLogService mesPrintedSnLogService;
|
|
|
|
@ -57,32 +58,43 @@ public class MesDPBarcodeWhPrintStrategy implements IPrintTemplateStrategyServic
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep) {
|
|
|
|
|
String organizeCode = mesProduceSnPrintModel.getOrganizeCode();
|
|
|
|
|
//物料信息
|
|
|
|
|
MesPart mesPart = mesPartService.getMesPartByPartNo(mesProduceSnPrintModel.getPartNo(), organizeCode);
|
|
|
|
|
MesCustomerPart customerPart = (!Objects.isNull(genSerialNoModel) && !CollectionUtils.isEmpty(genSerialNoModel.getDataMap()) && genSerialNoModel.getDataMap().containsKey(MesCustomerPart.class.getSimpleName())) ? (MesCustomerPart) genSerialNoModel.getDataMap().get(MesCustomerPart.class.getSimpleName()) : mesCustomerPartService.getMesCustomerPart(organizeCode,mesProduceSnPrintModel.getPartNo());
|
|
|
|
|
|
|
|
|
|
MesPart part = partService.getPartByNo(mesProduceSnPrintModel.getOrganizeCode(), mesProduceSnPrintModel.getPartNo());
|
|
|
|
|
|
|
|
|
|
if (!isStep){
|
|
|
|
|
if (StringUtils.isEmpty(genSerialNoModel.getShiftCode()) || Objects.isNull(customerPart)) {
|
|
|
|
|
MesPcnException.throwMesBusiException("班次代码或客户零件号未维护");
|
|
|
|
|
}
|
|
|
|
|
genSerialNoModel.partSnParam(mesPart.getPartSnParam()).setCustPartNo(customerPart.getCustPartNo());
|
|
|
|
|
for (int i = 0; i < mesProduceSnPrintModel.getPrintQty(); i++) {
|
|
|
|
|
|
|
|
|
|
if (null == part) MesPcnException.throwBusiException("请检查零件信息,零件[%s]信息不存在", genSerialNoModel.getPartNo());
|
|
|
|
|
if (StringUtils.isEmpty(part.getPartSnParam())) MesPcnException.throwBusiException("请检查零件信息,零件[%s]未维护零件条码参数", part.getPartNo());
|
|
|
|
|
if (part.getPartSnParam().length() < 4) MesPcnException.throwBusiException("请检查零件信息,零件[%s]维护零件条码参数[%s]长度小于4", part.getPartNo(), part.getPartSnParam());
|
|
|
|
|
if (StringUtils.isEmpty(genSerialNoModel.getShiftCode())) MesPcnException.throwBusiException("入参缺少班次代码");
|
|
|
|
|
|
|
|
|
|
genSerialNoModel.partSnParam(part.getPartSnParam())
|
|
|
|
|
.dynamicRule(new StringJoiner(MesPcnExtConstWords.COMMA).add(part.getPartSnParam().substring(part.getPartSnParam().length() - 4)).add(genSerialNoModel.getShiftCode()).toString());
|
|
|
|
|
//年月日缩写
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
genSerialNoModel.setYear(getYearShort(date));
|
|
|
|
|
genSerialNoModel.setMonth(getMonthShort(date));
|
|
|
|
|
genSerialNoModel.setDay(getDayShort(date));
|
|
|
|
|
|
|
|
|
|
List<Object> productSnList = syncFuncService.syncSerialNo(genSerialNoModel, mesProduceSnPrintModel.getUserName(), mesProduceSnPrintModel.getOrganizeCode(), mesProduceSnPrintModel.getPrintQty()).getResultList();
|
|
|
|
|
if (CollectionUtils.isEmpty(productSnList)) MesPcnException.throwBusiException("根据编码规则[%s]生成零件条码失败!", genSerialNoModel.getRuleCode());
|
|
|
|
|
for (Object productSn : productSnList) {
|
|
|
|
|
//保存条码信息
|
|
|
|
|
MesProduceSn produceSn = generateMesProduceSn(mesPart, syncFuncService.syncSerialNo(genSerialNoModel, mesProduceSnPrintModel.getUserName(), organizeCode, 1).getResultList().get(0).toString(), mesProduceSnPrintModel.getUserName(), mesProduceSnPrintModel.getQty());
|
|
|
|
|
MesProduceSn produceSn = generateMesProduceSn(part, productSn.toString(), mesProduceSnPrintModel.getUserName(), mesProduceSnPrintModel.getQty());
|
|
|
|
|
//封装打印信息
|
|
|
|
|
MesProduceSnPrintDataModel printDataModel = getModel(produceSn, customerPart);
|
|
|
|
|
MesProduceSnPrintDataModel printDataModel = getModel(produceSn, part);
|
|
|
|
|
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(printDataModel);
|
|
|
|
|
mesProduceSnPrintModel.getMesProduceSnList().add(produceSn);
|
|
|
|
|
//保存打印记录
|
|
|
|
|
mesProduceSnPrintModel.getMesPrintedSnLogList().add(mesPrintedSnLogService.getMesPrintedSnLog(mesProduceSnPrintModel.getUserName(),organizeCode,printDataModel));
|
|
|
|
|
mesProduceSnPrintModel.getMesPrintedSnLogList().add(mesPrintedSnLogService.getMesPrintedSnLog(mesProduceSnPrintModel.getUserName(), mesProduceSnPrintModel.getOrganizeCode(), printDataModel));
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
MesProduceSn mesProduceSn = mesProduceSnPrintModel.getMesProduceSnList().get(0);
|
|
|
|
|
//封装打印信息
|
|
|
|
|
MesProduceSnPrintDataModel printDataModel = getModel(mesProduceSn, customerPart);
|
|
|
|
|
MesProduceSnPrintDataModel printDataModel = getModel(mesProduceSn, part);
|
|
|
|
|
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(printDataModel);
|
|
|
|
|
//保存打印记录
|
|
|
|
|
mesProduceSnPrintModel.getMesPrintedSnLogList().add(mesPrintedSnLogService.getMesPrintedSnLog(mesProduceSnPrintModel.getUserName(),organizeCode,printDataModel));
|
|
|
|
|
mesProduceSnPrintModel.getMesPrintedSnLogList().add(mesPrintedSnLogService.getMesPrintedSnLog(mesProduceSnPrintModel.getUserName(), mesProduceSnPrintModel.getOrganizeCode(), printDataModel));
|
|
|
|
|
}
|
|
|
|
|
return mesProduceSnPrintModel;
|
|
|
|
|
}
|
|
|
|
@ -108,13 +120,13 @@ public class MesDPBarcodeWhPrintStrategy implements IPrintTemplateStrategyServic
|
|
|
|
|
return mesProduceSn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MesProduceSnPrintDataModel getModel(MesProduceSn produceSn, MesCustomerPart customerPart) {
|
|
|
|
|
private MesProduceSnPrintDataModel getModel(MesProduceSn produceSn, MesPart part) {
|
|
|
|
|
MesProduceSnPrintDataModel mesProduceSnPrintDataModel = new MesProduceSnPrintDataModel();
|
|
|
|
|
mesProduceSnPrintDataModel.setPartNo(produceSn.getPartNo());
|
|
|
|
|
mesProduceSnPrintDataModel.setPartName(produceSn.getPartName());
|
|
|
|
|
if (!Objects.isNull(customerPart)) {
|
|
|
|
|
mesProduceSnPrintDataModel.setCustPartNo(customerPart.getCustPartNo().substring(0,customerPart.getCustPartNo().length()-4));
|
|
|
|
|
mesProduceSnPrintDataModel.setCustPartNo1(customerPart.getCustPartNo().substring(customerPart.getCustPartNo().length()-4));
|
|
|
|
|
if (null != part && !StringUtils.isEmpty(part.getPartSnParam()) && part.getPartSnParam().length() >= 4) {
|
|
|
|
|
mesProduceSnPrintDataModel.setCustPartNo(part.getPartSnParam().substring(0, 4));
|
|
|
|
|
mesProduceSnPrintDataModel.setCustPartNo1(part.getPartSnParam().substring(part.getPartSnParam().length() - 4));
|
|
|
|
|
}
|
|
|
|
|
mesProduceSnPrintDataModel.setBarcode(produceSn.getProductSn());
|
|
|
|
|
mesProduceSnPrintDataModel.setPrintDate(TimeTool.getNowTime(true));
|
|
|
|
@ -122,4 +134,17 @@ public class MesDPBarcodeWhPrintStrategy implements IPrintTemplateStrategyServic
|
|
|
|
|
mesProduceSnPrintDataModel.setProductDate(TimeTool.parseStringFormat(produceSn.getLotNo(), DateUtil.SHORT_FORMAT, "yyyy/MM/dd"));
|
|
|
|
|
return mesProduceSnPrintDataModel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|