|
|
@ -2,23 +2,21 @@ 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.IMesPartService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesTemplateService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesTemplateService;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesConfigService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProduceSnPrintService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProduceSnPrintService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
|
|
|
|
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.MesProduceSnPrintDataModel;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
|
|
|
|
import cn.estsh.i3plus.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.convert.ConvertBean;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.CheckTool;
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
|
|
|
|
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
|
|
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.*;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.*;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.*;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesCustomerPartRepository;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesPackingDefineDetailsRepository;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesPackingDefineRepository;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesProduceSnRepository;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
@ -28,6 +26,7 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
@ -55,9 +54,6 @@ public class MesProduceSnPrintServiceImpl implements IMesProduceSnPrintService {
|
|
|
|
private SnowflakeIdMaker snowflakeIdMaker;
|
|
|
|
private SnowflakeIdMaker snowflakeIdMaker;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private ISyncFuncService syncFuncService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private IMesPartService mesPartService;
|
|
|
|
private IMesPartService mesPartService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
@ -66,6 +62,12 @@ public class MesProduceSnPrintServiceImpl implements IMesProduceSnPrintService {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private MesCustomerPartRepository mesCustomerPartRDao;
|
|
|
|
private MesCustomerPartRepository mesCustomerPartRDao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private IMesConfigService mesConfigService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private MesConfigRepository mesConfigRDao;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public MesProduceSnPrintModel findMesPackingDefine(MesProduceSnPrintModel mesProduceSnPrintModel) {
|
|
|
|
public MesProduceSnPrintModel findMesPackingDefine(MesProduceSnPrintModel mesProduceSnPrintModel) {
|
|
|
|
//查询SAP下发物料信息
|
|
|
|
//查询SAP下发物料信息
|
|
|
@ -77,7 +79,7 @@ public class MesProduceSnPrintServiceImpl implements IMesProduceSnPrintService {
|
|
|
|
DdlPreparedPack.getStringEqualPack(mesProduceSnPrintModel.getPartNo(), "partNo", ddlPackBean);
|
|
|
|
DdlPreparedPack.getStringEqualPack(mesProduceSnPrintModel.getPartNo(), "partNo", ddlPackBean);
|
|
|
|
List<MesPackingDefineDetails> packingDefineDetails = mesPackingDefineDetailsRDao.findByHqlWhere(ddlPackBean);
|
|
|
|
List<MesPackingDefineDetails> packingDefineDetails = mesPackingDefineDetailsRDao.findByHqlWhere(ddlPackBean);
|
|
|
|
if (CollectionUtils.isEmpty(packingDefineDetails)) {
|
|
|
|
if (CollectionUtils.isEmpty(packingDefineDetails)) {
|
|
|
|
MesPcnException.throwFlowException("物料【%s】未维护包装定义信息", mesProduceSnPrintModel.getPartNo());
|
|
|
|
MesPcnException.throwMesBusiException("物料【%s】未维护包装定义信息", mesProduceSnPrintModel.getPartNo());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//查询包装定义主表
|
|
|
|
//查询包装定义主表
|
|
|
|
ddlPackBean = DdlPackBean.getDdlPackBean(mesProduceSnPrintModel.getOrganizeCode());
|
|
|
|
ddlPackBean = DdlPackBean.getDdlPackBean(mesProduceSnPrintModel.getOrganizeCode());
|
|
|
@ -92,7 +94,7 @@ public class MesProduceSnPrintServiceImpl implements IMesProduceSnPrintService {
|
|
|
|
DdlPreparedPack.getStringEqualPack(mesProduceSnPrintModel.getProductSn(), "productSn", ddlPackBean);
|
|
|
|
DdlPreparedPack.getStringEqualPack(mesProduceSnPrintModel.getProductSn(), "productSn", ddlPackBean);
|
|
|
|
MesProduceSn mesProduceSn = mesProduceSnRDao.getByProperty(ddlPackBean);
|
|
|
|
MesProduceSn mesProduceSn = mesProduceSnRDao.getByProperty(ddlPackBean);
|
|
|
|
if (Objects.isNull(mesProduceSn)) {
|
|
|
|
if (Objects.isNull(mesProduceSn)) {
|
|
|
|
MesPcnException.throwFlowException("条码【%s】信息不存在", mesProduceSnPrintModel.getProductSn());
|
|
|
|
MesPcnException.throwMesBusiException("条码【%s】信息不存在", mesProduceSnPrintModel.getProductSn());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return mesProduceSn;
|
|
|
|
return mesProduceSn;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -102,27 +104,27 @@ public class MesProduceSnPrintServiceImpl implements IMesProduceSnPrintService {
|
|
|
|
String organizeName = AuthUtil.getOrganize().getName();
|
|
|
|
String organizeName = AuthUtil.getOrganize().getName();
|
|
|
|
//物料信息
|
|
|
|
//物料信息
|
|
|
|
MesPart mesPart = mesPartService.getMesPartByPartNo(mesProduceSnPrintModel.getPartNo(), mesProduceSnPrintModel.getOrganizeCode());
|
|
|
|
MesPart mesPart = mesPartService.getMesPartByPartNo(mesProduceSnPrintModel.getPartNo(), mesProduceSnPrintModel.getOrganizeCode());
|
|
|
|
|
|
|
|
//打印日期格式
|
|
|
|
|
|
|
|
String format = "yyyy/MM/dd";
|
|
|
|
|
|
|
|
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())) {
|
|
|
|
|
|
|
|
format = DateUtil.BASE_FORMAT;
|
|
|
|
|
|
|
|
}
|
|
|
|
//条码生成
|
|
|
|
//条码生成
|
|
|
|
if (StringUtils.isEmpty(mesProduceSnPrintModel.getProductSn())) {
|
|
|
|
if (StringUtils.isEmpty(mesProduceSnPrintModel.getProductSn())) {
|
|
|
|
ValidatorBean.checkNotNull(mesProduceSnPrintModel.getSnRule(), "条码规则不能为空");
|
|
|
|
ValidatorBean.checkNotNull(mesProduceSnPrintModel.getSnRule(), "条码规则不能为空");
|
|
|
|
ValidatorBean.checkNotNull(mesProduceSnPrintModel.getPrintTemplate(), "打印模板不能为空");
|
|
|
|
ValidatorBean.checkNotNull(mesProduceSnPrintModel.getPrintTemplate(), "打印模板不能为空");
|
|
|
|
//流水码
|
|
|
|
//流水号
|
|
|
|
List<String> resultList = getStringList(mesProduceSnPrintModel);
|
|
|
|
List<String> serialNoList = getSerialNoList(mesProduceSnPrintModel);
|
|
|
|
//条码模板
|
|
|
|
//条码二维码模板
|
|
|
|
StringBuilder template = getTemplate(mesProduceSnPrintModel);
|
|
|
|
String template = getTemplate(mesProduceSnPrintModel, mesPart);
|
|
|
|
|
|
|
|
|
|
|
|
List<MesProduceSn> mesMesProduceSnList = new ArrayList<>();
|
|
|
|
List<MesProduceSn> mesMesProduceSnList = new ArrayList<>();
|
|
|
|
for (String no : resultList) {
|
|
|
|
for (String no : serialNoList) {
|
|
|
|
String reportSn = no;
|
|
|
|
|
|
|
|
if (MesPcnEnumUtil.PRINT_TEMPLATE.GQXNY.getCode().equals(mesProduceSnPrintModel.getPrintTemplate())) {
|
|
|
|
|
|
|
|
no = no.replace(MesPcnEnumUtil.PRINT_TEMPLATE.GQXNY.getValue(), "");
|
|
|
|
|
|
|
|
reportSn = template.toString().replace("serialNo", no);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//保存条码信息
|
|
|
|
//保存条码信息
|
|
|
|
MesProduceSn produceSn = generateMesProduceSn(mesPart, reportSn, mesProduceSnPrintModel.getUserName(), mesProduceSnPrintModel.getQty());
|
|
|
|
MesProduceSn produceSn = generateMesProduceSn(mesPart, template.replace("serialNo", no), mesProduceSnPrintModel.getUserName(), mesProduceSnPrintModel.getQty(), format);
|
|
|
|
mesMesProduceSnList.add(produceSn);
|
|
|
|
mesMesProduceSnList.add(produceSn);
|
|
|
|
//封装打印信息
|
|
|
|
//封装打印信息
|
|
|
|
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(getModel(produceSn, no, mesProduceSnPrintModel.getCustPartNo(),organizeName));
|
|
|
|
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(getModel(produceSn, no, mesProduceSnPrintModel.getCustPartNo(), organizeName));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mesProduceSnRDao.saveAll(mesMesProduceSnList);
|
|
|
|
mesProduceSnRDao.saveAll(mesMesProduceSnList);
|
|
|
|
//条码补打
|
|
|
|
//条码补打
|
|
|
@ -139,27 +141,44 @@ public class MesProduceSnPrintServiceImpl implements IMesProduceSnPrintService {
|
|
|
|
custPartNo = getMesCustomerPart(mesProduceSnPrintModel).getCustPartNo();
|
|
|
|
custPartNo = getMesCustomerPart(mesProduceSnPrintModel).getCustPartNo();
|
|
|
|
no = mesProduceSn.getProductSn().substring(36, 40);
|
|
|
|
no = mesProduceSn.getProductSn().substring(36, 40);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(getModel(mesProduceSn, no,custPartNo ,organizeName));
|
|
|
|
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(getModel(mesProduceSn, no, custPartNo, organizeName));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//获取打印模板信息
|
|
|
|
//获取打印模板信息
|
|
|
|
mesProduceSnPrintModel.setMesLabelTemplate(mesTemplateService.getMesLabelTemplate(mesProduceSnPrintModel.getPrintTemplate()));
|
|
|
|
mesProduceSnPrintModel.setMesLabelTemplate(mesTemplateService.getMesLabelTemplate(mesProduceSnPrintModel.getPrintTemplate()));
|
|
|
|
return mesProduceSnPrintModel;
|
|
|
|
return mesProduceSnPrintModel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private StringBuilder getTemplate(MesProduceSnPrintModel mesProduceSnPrintModel) {
|
|
|
|
private String getTemplate(MesProduceSnPrintModel mesProduceSnPrintModel, MesPart mesPart) {
|
|
|
|
|
|
|
|
Date date = new Date();
|
|
|
|
StringBuilder template = new StringBuilder();
|
|
|
|
StringBuilder template = new StringBuilder();
|
|
|
|
//广乘 GQXNY.btw
|
|
|
|
if (MesPcnEnumUtil.PRINT_TEMPLATE.B2M.getCode().equals(mesProduceSnPrintModel.getPrintTemplate()) || MesPcnEnumUtil.PRINT_TEMPLATE.GQAA.getCode().equals(mesProduceSnPrintModel.getPrintTemplate())) {
|
|
|
|
if (MesPcnEnumUtil.PRINT_TEMPLATE.GQXNY.getCode().equals(mesProduceSnPrintModel.getPrintTemplate())) {
|
|
|
|
//获取客户零件号
|
|
|
|
|
|
|
|
MesCustomerPart mesCustomerPart = getMesCustomerPart(mesProduceSnPrintModel);
|
|
|
|
|
|
|
|
mesProduceSnPrintModel.setCustPartNo(mesCustomerPart.getCustPartNo());
|
|
|
|
|
|
|
|
//"+"(1)+零件简号(4)+ 供应商代码(SE103)+生产线代号(1)+生产日期(4)+供应商生产流水号(4) +软件版本代号(2)
|
|
|
|
|
|
|
|
template.append("+").append(mesPart.getPartSnParam()).append("SE103").append("1").append(getDateTime(date)).append("serialNo").append("01");
|
|
|
|
|
|
|
|
} else if (MesPcnEnumUtil.PRINT_TEMPLATE.GQXNY.getCode().equals(mesProduceSnPrintModel.getPrintTemplate())) {
|
|
|
|
//获取客户零件号
|
|
|
|
//获取客户零件号
|
|
|
|
MesCustomerPart mesCustomerPart = getMesCustomerPart(mesProduceSnPrintModel);
|
|
|
|
MesCustomerPart mesCustomerPart = getMesCustomerPart(mesProduceSnPrintModel);
|
|
|
|
mesProduceSnPrintModel.setCustPartNo(mesCustomerPart.getCustPartNo());
|
|
|
|
mesProduceSnPrintModel.setCustPartNo(mesCustomerPart.getCustPartNo());
|
|
|
|
//零件号(17)+扩展位(2)+供应商代码(7)+扩展位(3)+产线(1)+年月日(6位)+流水号(4)+扩展位(4)+"+"
|
|
|
|
//零件号(17)+扩展位(2)+供应商代码(7)+扩展位(3)+产线(1)+年月日(6位)+流水号(4)+扩展位(4)+"+"
|
|
|
|
template.append(stringFormat(mesCustomerPart.getCustPartNo(), 17)).append("00").append(stringFormat("VD501", 7)).append("000").append("1").append(TimeTool.getNowTime("yyMMdd")).append("serialNo").append("0000").append("+");
|
|
|
|
template.append(stringFormat(mesCustomerPart.getCustPartNo(), 17)).append("00").append(stringFormat("VD501", 7)).append("000").append("1").append(TimeTool.pareDateToString("yyMMdd", date)).append("serialNo").append("0000").append("+");
|
|
|
|
|
|
|
|
} else if (MesPcnEnumUtil.PRINT_TEMPLATE.NO_SORT_BAR_CODE_GZ.getCode().equals(mesProduceSnPrintModel.getPrintTemplate())) {
|
|
|
|
|
|
|
|
//内部条码:M00061102-R619+"10158"
|
|
|
|
|
|
|
|
//条码拼接规则:零件号+年月日+5位流水号
|
|
|
|
|
|
|
|
template.append(mesPart.getPartNo()).append("-").append(getDateTime(date)).append("serialNo");
|
|
|
|
|
|
|
|
} else if (MesPcnEnumUtil.PRINT_TEMPLATE.NO_SORT_BAR_CODE_GZ_NEW.getCode().equals(mesProduceSnPrintModel.getPrintTemplate())) {
|
|
|
|
|
|
|
|
//获取客户零件号
|
|
|
|
|
|
|
|
MesCustomerPart mesCustomerPart = getMesCustomerPart(mesProduceSnPrintModel);
|
|
|
|
|
|
|
|
mesProduceSnPrintModel.setCustPartNo(mesCustomerPart.getCustPartNo());
|
|
|
|
|
|
|
|
//小鹏客户条码:6205100EF3-S5-06-R61910027
|
|
|
|
|
|
|
|
//条码拼接规则:客户零件号+中杠+年月日+5位流水号(按天递增)
|
|
|
|
|
|
|
|
template.append(mesCustomerPart.getCustPartNo()).append("-").append(getDateTime(date)).append("serialNo");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return template;
|
|
|
|
return template.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private MesProduceSnPrintDataModel getModel(MesProduceSn produceSn, String no,String custPartNo, String factoryName) {
|
|
|
|
private MesProduceSnPrintDataModel getModel(MesProduceSn produceSn, String no, String custPartNo, String factoryName) {
|
|
|
|
MesProduceSnPrintDataModel mesProduceSnPrintDataModel = new MesProduceSnPrintDataModel();
|
|
|
|
MesProduceSnPrintDataModel mesProduceSnPrintDataModel = new MesProduceSnPrintDataModel();
|
|
|
|
mesProduceSnPrintDataModel.setFactoryName(factoryName);
|
|
|
|
mesProduceSnPrintDataModel.setFactoryName(factoryName);
|
|
|
|
mesProduceSnPrintDataModel.setPartNo(produceSn.getPartNo());
|
|
|
|
mesProduceSnPrintDataModel.setPartNo(produceSn.getPartNo());
|
|
|
@ -167,14 +186,47 @@ public class MesProduceSnPrintServiceImpl implements IMesProduceSnPrintService {
|
|
|
|
mesProduceSnPrintDataModel.setNo(no);
|
|
|
|
mesProduceSnPrintDataModel.setNo(no);
|
|
|
|
mesProduceSnPrintDataModel.setBarcode(produceSn.getProductSn());
|
|
|
|
mesProduceSnPrintDataModel.setBarcode(produceSn.getProductSn());
|
|
|
|
mesProduceSnPrintDataModel.setCustPartNo(custPartNo);
|
|
|
|
mesProduceSnPrintDataModel.setCustPartNo(custPartNo);
|
|
|
|
mesProduceSnPrintDataModel.setProductDate(TimeTool.getDateTimeShort());
|
|
|
|
mesProduceSnPrintDataModel.setProductDate(produceSn.getLotNo());
|
|
|
|
return mesProduceSnPrintDataModel;
|
|
|
|
return mesProduceSnPrintDataModel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private List<String> getStringList(MesProduceSnPrintModel mesProduceSnPrintModel) {
|
|
|
|
private List<String> getSerialNoList(MesProduceSnPrintModel mesProduceSnPrintModel) {
|
|
|
|
GenSerialNoModel genSerialNoModel = new GenSerialNoModel(mesProduceSnPrintModel.getSnRule());
|
|
|
|
List<String> serialNoList = new ArrayList<>();
|
|
|
|
List<String> resultList = syncFuncService.syncSerialNo(genSerialNoModel, mesProduceSnPrintModel.getUserName(), mesProduceSnPrintModel.getOrganizeCode(), mesProduceSnPrintModel.getPrintQty()).getResultList();
|
|
|
|
//获取系统参数
|
|
|
|
return resultList;
|
|
|
|
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) {
|
|
|
|
private MesCustomerPart getMesCustomerPart(MesProduceSnPrintModel mesProduceSnPrintModel) {
|
|
|
@ -187,7 +239,7 @@ public class MesProduceSnPrintServiceImpl implements IMesProduceSnPrintService {
|
|
|
|
return mesCustomerPart;
|
|
|
|
return mesCustomerPart;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private MesProduceSn generateMesProduceSn(MesPart mesPart, String sn, String userName, Double qty) {
|
|
|
|
private MesProduceSn generateMesProduceSn(MesPart mesPart, String sn, String userName, Double qty, String format) {
|
|
|
|
MesProduceSn mesProduceSn = new MesProduceSn();
|
|
|
|
MesProduceSn mesProduceSn = new MesProduceSn();
|
|
|
|
mesProduceSn.setSerialNumber(snowflakeIdMaker.nextId() + "");
|
|
|
|
mesProduceSn.setSerialNumber(snowflakeIdMaker.nextId() + "");
|
|
|
|
mesProduceSn.setProductSn(sn);
|
|
|
|
mesProduceSn.setProductSn(sn);
|
|
|
@ -200,7 +252,7 @@ public class MesProduceSnPrintServiceImpl implements IMesProduceSnPrintService {
|
|
|
|
mesProduceSn.setQty(qty);
|
|
|
|
mesProduceSn.setQty(qty);
|
|
|
|
mesProduceSn.setSnStatus(10);
|
|
|
|
mesProduceSn.setSnStatus(10);
|
|
|
|
mesProduceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue());
|
|
|
|
mesProduceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue());
|
|
|
|
mesProduceSn.setLotNo(TimeTool.getDateTimeShort());
|
|
|
|
mesProduceSn.setLotNo(TimeTool.getNowTime(format));
|
|
|
|
mesProduceSn.setPrintCount(1);
|
|
|
|
mesProduceSn.setPrintCount(1);
|
|
|
|
mesProduceSn.setPrintStatus(20);
|
|
|
|
mesProduceSn.setPrintStatus(20);
|
|
|
|
mesProduceSn.setOrganizeCode(mesPart.getOrganizeCode());
|
|
|
|
mesProduceSn.setOrganizeCode(mesPart.getOrganizeCode());
|
|
|
@ -208,16 +260,54 @@ public class MesProduceSnPrintServiceImpl implements IMesProduceSnPrintService {
|
|
|
|
return mesProduceSn;
|
|
|
|
return mesProduceSn;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getDateTime(Date date) {
|
|
|
|
|
|
|
|
StringBuilder dateTime = new StringBuilder();
|
|
|
|
|
|
|
|
String yearStr = MesExtEnumUtil.YEAR_SHORT.valueOfDescription(Integer.parseInt(TimeTool.getYear(date)));
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(yearStr)) {
|
|
|
|
|
|
|
|
MesPcnException.throwMesBusiException("【%s】年月简号不存在", TimeTool.getYear(date));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String monthStr = MesExtEnumUtil.MONTH_SHORT.valueOfDescription(Integer.parseInt(TimeTool.getMonth(date)));
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(monthStr)) {
|
|
|
|
|
|
|
|
MesPcnException.throwMesBusiException("【%s】月简号不存在", TimeTool.getMonth(date));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return dateTime.append(yearStr).append(monthStr).append(TimeTool.getDay(date)).toString();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String stringFormat(String data, Integer length) {
|
|
|
|
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) {
|
|
|
|
if (data.length() >= length) {
|
|
|
|
return data;
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StringBuilder dataBuffer = new StringBuilder();
|
|
|
|
StringBuilder dataBuffer = new StringBuilder();
|
|
|
|
dataBuffer.append(data);
|
|
|
|
//左拼接
|
|
|
|
|
|
|
|
if (left) {
|
|
|
|
|
|
|
|
dataBuffer.append(data);
|
|
|
|
|
|
|
|
}
|
|
|
|
for (int i = 0; i < length - data.length(); i++) {
|
|
|
|
for (int i = 0; i < length - data.length(); i++) {
|
|
|
|
dataBuffer.append('*');
|
|
|
|
dataBuffer.append(symbol);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//右拼接
|
|
|
|
|
|
|
|
if (!left) {
|
|
|
|
|
|
|
|
dataBuffer.append(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return dataBuffer.toString();
|
|
|
|
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();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|