条码补打二维码生成

tags/yfai-pcn-ext-v1.0
jun 1 year ago
parent 24c251de15
commit c0ad75b6ff

@ -15,5 +15,8 @@ public interface IMesConfigService {
@ApiOperation(value = "获取配置表模板代码") @ApiOperation(value = "获取配置表模板代码")
MesConfig getCfgValueByCode(String key); MesConfig getCfgValueByCode(String key);
@ApiOperation(value = "获取配置表模板代码")
MesConfig getMesConfig(String org, String key);
} }

@ -19,14 +19,14 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.Objects; import java.util.Objects;
/** /**
* @Description : * @Description :
* @Reference : * @Reference :
* @Author : junsheng.li * @Author : junsheng.li
* @CreateDate 2024/6/13 15:13 * @CreateDate 2024/6/13 15:13
* @Modify: * @Modify:
**/ **/
@RestController @RestController
@Api(tags = "物料信息") @Api(tags = "条码补打")
@RequestMapping(MesCommonConstant.MES_YANFEN + "/mes-produce-sn-print") @RequestMapping(MesCommonConstant.MES_YANFEN + "/mes-produce-sn-print")
public class MesProduceSnPrintController { public class MesProduceSnPrintController {
@ -68,7 +68,7 @@ public class MesProduceSnPrintController {
ValidatorBean.checkNotNull(mesProduceSnPrintModel.getPartNo(), "ERP零件号不能为空"); ValidatorBean.checkNotNull(mesProduceSnPrintModel.getPartNo(), "ERP零件号不能为空");
ValidatorBean.checkNotNull(mesProduceSnPrintModel.getOrganizeCode(), "工厂代码不能为空"); ValidatorBean.checkNotNull(mesProduceSnPrintModel.getOrganizeCode(), "工厂代码不能为空");
if (Objects.isNull(mesProduceSnPrintModel.getPrintQty()) || mesProduceSnPrintModel.getPrintQty() <= 0) { if (Objects.isNull(mesProduceSnPrintModel.getPrintQty()) || mesProduceSnPrintModel.getPrintQty() <= 0) {
MesPcnException.throwFlowException("打印数量不能小于等于零"); MesPcnException.throwMesBusiException("打印数量不能小于等于零");
} }
mesProduceSnPrintModel.setUserName(AuthUtil.getSessionUser().getUserName()); mesProduceSnPrintModel.setUserName(AuthUtil.getSessionUser().getUserName());
return ResultBean.success("查询成功").setResultObject(mesProduceSnPrintService.doPrint(mesProduceSnPrintModel)); return ResultBean.success("查询成功").setResultObject(mesProduceSnPrintService.doPrint(mesProduceSnPrintModel));

@ -49,7 +49,7 @@ public class MesPartServiceImpl implements IMesPartService {
DdlPreparedPack.getStringEqualPack(partNo, "partNo", packBean); DdlPreparedPack.getStringEqualPack(partNo, "partNo", packBean);
MesPart mesPart = mesPartRDao.getByProperty(packBean); MesPart mesPart = mesPartRDao.getByProperty(packBean);
if(Objects.isNull(mesPart)){ if(Objects.isNull(mesPart)){
MesPcnException.throwFlowException("物料【%s】信息不存在",partNo); MesPcnException.throwMesBusiException("物料【%s】信息不存在",partNo);
} }
return mesPart; return mesPart;
} }
@ -60,7 +60,7 @@ public class MesPartServiceImpl implements IMesPartService {
DdlPreparedPack.getStringEqualPack(partNo, "partNo", packBean); DdlPreparedPack.getStringEqualPack(partNo, "partNo", packBean);
MesPartSap mesPartSap = mesPartSapRDao.getByProperty(packBean); MesPartSap mesPartSap = mesPartSapRDao.getByProperty(packBean);
if(Objects.isNull(mesPartSap)){ if(Objects.isNull(mesPartSap)){
MesPcnException.throwFlowException("SAP物料【%s】信息不存在",partNo); MesPcnException.throwMesBusiException("SAP物料【%s】信息不存在",partNo);
} }
return mesPartSap; return mesPartSap;
} }

@ -143,7 +143,7 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
List<MesReworkTaskDetail> mesReworkTaskDetailList = mesReworkTaskDetailRepository.findByHqlWhere(packBean); List<MesReworkTaskDetail> mesReworkTaskDetailList = mesReworkTaskDetailRepository.findByHqlWhere(packBean);
if (CollectionUtils.isEmpty(mesReworkTaskDetailList)) { if (CollectionUtils.isEmpty(mesReworkTaskDetailList)) {
MesPcnException.throwFlowException("返工单详情不存在"); MesPcnException.throwMesBusiException("返工单详情不存在");
} }
mesReworkTaskDetailList.forEach(mesReworkTaskDetail->{ mesReworkTaskDetailList.forEach(mesReworkTaskDetail->{
mesReworkTaskDetail.setStatus(MesExtEnumUtil.REWORK_TASK_DETAIL_STATUS.REWORK_TASK_DETAIL_STATUS_20.getValue()); mesReworkTaskDetail.setStatus(MesExtEnumUtil.REWORK_TASK_DETAIL_STATUS.REWORK_TASK_DETAIL_STATUS_20.getValue());

@ -38,7 +38,7 @@ public class MesTemplateServiceImpl implements IMesTemplateService {
new Object[]{CommonEnumUtil.IS_VAILD.VAILD.getValue(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), templateCode}); new Object[]{CommonEnumUtil.IS_VAILD.VAILD.getValue(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), templateCode});
if (labelTemplate == null) { if (labelTemplate == null) {
MesPcnException.throwFlowException("标签模板代码【%s】在标签模板表不存在", templateCode); MesPcnException.throwMesBusiException("标签模板代码【%s】在标签模板表不存在", templateCode);
} }
// 根据模板代码查询模板参数信息 // 根据模板代码查询模板参数信息
@ -48,7 +48,7 @@ public class MesTemplateServiceImpl implements IMesTemplateService {
CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()}); CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()});
if (CollectionUtils.isEmpty(templateParamList)) { if (CollectionUtils.isEmpty(templateParamList)) {
MesPcnException.throwFlowException("标签模板代码【%s】在标签模板明细表不存在", templateCode); MesPcnException.throwMesBusiException("标签模板代码【%s】在标签模板明细表不存在", templateCode);
} }
labelTemplate.setLabelTemplateParamList(templateParamList); labelTemplate.setLabelTemplateParamList(templateParamList);

@ -40,4 +40,19 @@ public class MesConfigService implements IMesConfigService {
return this.configRepository.getByProperty(new String[]{"isDeleted", "isValid", "cfgCode"}, return this.configRepository.getByProperty(new String[]{"isDeleted", "isValid", "cfgCode"},
new Object[]{CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), cfgCode}); new Object[]{CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), cfgCode});
} }
@Override
public MesConfig getMesConfig(String org, String key) {
MesConfig config = configRepository.getByProperty(
new String[]{"cfgKey", "organizeCode", "isValid", "isDeleted"},
new Object[]{key, org, CommonEnumUtil.IS_VAILD.VAILD.getValue(), CommonEnumUtil.IS_DEAL.NO.getValue()});
if (config == null) {
throw ImppExceptionBuilder.newInstance().setErrorCode(cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode())
.setErrorDetail(String.format("配置表数据不存在请维护key【%s】", key))
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode())
.build();
}
return config;
}
} }

@ -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();
}
} }

@ -392,7 +392,7 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean); DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean);
MesProduceSn produceSn = produceSnRepository.getByProperty(packBean); MesProduceSn produceSn = produceSnRepository.getByProperty(packBean);
if(Objects.isNull(produceSn)){ if(Objects.isNull(produceSn)){
MesPcnException.throwFlowException("【%s】此产品条码不存在请检查数据", detail.getBarcode()); MesPcnException.throwMesBusiException("【%s】此产品条码不存在请检查数据", detail.getBarcode());
} }
produceSn.setSnStatus(MesExtEnumUtil.PRODUCE_SN_STATUS.SHIPPED.getValue()); produceSn.setSnStatus(MesExtEnumUtil.PRODUCE_SN_STATUS.SHIPPED.getValue());

Loading…
Cancel
Save