forked from I3-YF/i3plus-mes-pcn-yfai
条码生成
parent
f78108c702
commit
3ee38c6e7a
@ -1,22 +0,0 @@
|
|||||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.numberrule;
|
|
||||||
|
|
||||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNumberRuleStrategyModel;
|
|
||||||
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description :
|
|
||||||
* @Reference :
|
|
||||||
* @Author : Castle
|
|
||||||
* @CreateDate : 2024/6/26 9:34
|
|
||||||
* @Modify:
|
|
||||||
**/
|
|
||||||
public interface INumberRulePackAttributeStrategy {
|
|
||||||
/**
|
|
||||||
* 封装封装生成条码模型
|
|
||||||
* @return 生成条码模型
|
|
||||||
*/
|
|
||||||
@ApiOperation(value = "封装封装生成条码模型", notes = "封装封装生成条码模型")
|
|
||||||
GenSerialNoModel execute(MesNumberRuleStrategyModel model);
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,71 @@
|
|||||||
|
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.Service;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description :
|
||||||
|
* @Reference :
|
||||||
|
* @Author : Castle
|
||||||
|
* @CreateDate : 2024/6/26 9:38
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
@Service
|
||||||
|
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());
|
||||||
|
|
||||||
|
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,55 +0,0 @@
|
|||||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.numberrule.strategy;
|
|
||||||
|
|
||||||
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.numberrule.INumberRulePackAttributeStrategy;
|
|
||||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNumberRuleStrategyModel;
|
|
||||||
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description :
|
|
||||||
* @Reference :
|
|
||||||
* @Author : Castle
|
|
||||||
* @CreateDate : 2024/6/26 9:38
|
|
||||||
* @Modify:
|
|
||||||
**/
|
|
||||||
@Component
|
|
||||||
public class XiaoPengNumberRuleStrategy implements INumberRulePackAttributeStrategy {
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public GenSerialNoModel execute(MesNumberRuleStrategyModel model) {
|
|
||||||
Date date = new Date();
|
|
||||||
// XIAO_PENG 原客户条码.小鹏汽车 NoSortBarCodeGZ-new
|
|
||||||
//{custPartNo}{SPILTRULE}{year}{month}{day}{hour}{minute}{second}{serialNo}
|
|
||||||
GenSerialNoModel genSerialNoModel = new GenSerialNoModel();
|
|
||||||
genSerialNoModel.setRuleCode(model.getSnRule());
|
|
||||||
//客户零件号
|
|
||||||
String custPartNo = model.getCustPartNo();
|
|
||||||
genSerialNoModel.setCustPartNo(custPartNo);
|
|
||||||
//日期${dateShort}
|
|
||||||
genSerialNoModel.setYear(getYearShort(date));
|
|
||||||
genSerialNoModel.setMonth(getMonthShort(date));
|
|
||||||
genSerialNoModel.setDay(getDayShort(date));
|
|
||||||
//中杠 -
|
|
||||||
//生产日期 + 时间 yyyyMMddHHmmss
|
|
||||||
//流水号 5位 每天从1开始
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package cn.estsh.i3plus.ext.mes.pcn.pojo.model;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description : 打印数据
|
|
||||||
* @Reference :
|
|
||||||
* @Author : junsheng.li
|
|
||||||
* @CreateDate 2024/6/20 11:40
|
|
||||||
* @Modify:
|
|
||||||
**/
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class MesNumberRuleStrategyModel {
|
|
||||||
|
|
||||||
@ApiParam("物料号")
|
|
||||||
private String partNo;
|
|
||||||
|
|
||||||
@ApiParam("物料名称")
|
|
||||||
private String partName;
|
|
||||||
|
|
||||||
@ApiParam("生产厂家名称")
|
|
||||||
private String factoryName;
|
|
||||||
|
|
||||||
@ApiParam("生产日期")
|
|
||||||
private String productDate;
|
|
||||||
|
|
||||||
@ApiParam("供应商代码")
|
|
||||||
private String supplierCode;
|
|
||||||
|
|
||||||
@ApiParam("客户物料号")
|
|
||||||
private String custPartNo;
|
|
||||||
|
|
||||||
@ApiParam("打印规则")
|
|
||||||
private String snRule;
|
|
||||||
|
|
||||||
@ApiParam("产地")
|
|
||||||
private String prodLocation;
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue