|
|
|
@ -4,15 +4,18 @@ 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.base.bean.DdlPackBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
|
|
|
|
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.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.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -24,8 +27,13 @@ import java.util.Map;
|
|
|
|
|
**/
|
|
|
|
|
@Component
|
|
|
|
|
public class GqxnyNumberRuleStrategyService implements INumberRulePackAttributeStrategyService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IConfigService configService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesCustomerPartRepository customerPartRepository;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public GenSerialNoModel execute(GenSerialNoModel genSerialNoModel) {
|
|
|
|
|
Date date = new Date();
|
|
|
|
@ -35,20 +43,27 @@ public class GqxnyNumberRuleStrategyService implements INumberRulePackAttributeS
|
|
|
|
|
//零件长号---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);
|
|
|
|
|
MesCustomerPart customerPart = (!CollectionUtils.isEmpty(dataMap) && dataMap.containsKey(MesCustomerPart.class.getSimpleName())) ?
|
|
|
|
|
(MesCustomerPart)dataMap.get(MesCustomerPart.class.getSimpleName()) : getMesCustomerPart(genSerialNoModel.getOrganizeCode(), genSerialNoModel.getPartNo());
|
|
|
|
|
if (null != customerPart) {
|
|
|
|
|
String custPartNo = customerPart.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);
|
|
|
|
|
if (null != supplierConfig) {
|
|
|
|
|
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);
|
|
|
|
|
String year = TimeTool.pareDateToString(MesPcnExtConstWords.DATE_FORMAT_SHORT, date);
|
|
|
|
|
genSerialNoModel.setYear(year);
|
|
|
|
|
//流水号 4位 采用34进制 0001~ZZZZ (I、O除外)顺位进行标注 (同广汽 & 广新) {serialNo}
|
|
|
|
|
//扩展位 4位 预留扩展位信息,包含0~9和字母A~Z,不使用时,补“0” 填充; {SPILTRULE}
|
|
|
|
@ -58,7 +73,7 @@ public class GqxnyNumberRuleStrategyService implements INumberRulePackAttributeS
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String stringFormat(String data, Integer length) {
|
|
|
|
|
return stringFormat(data, length, true, "*");
|
|
|
|
|
return stringFormat(data, length, true, MesPcnExtConstWords.ASTERISK);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String stringFormat(String data, Integer length, boolean left, String symbol) {
|
|
|
|
@ -85,4 +100,11 @@ public class GqxnyNumberRuleStrategyService implements INumberRulePackAttributeS
|
|
|
|
|
return dataBuffer.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MesCustomerPart getMesCustomerPart(String orgaizeCode, String partNo) {
|
|
|
|
|
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(orgaizeCode);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(partNo, MesPcnExtConstWords.ERP_PART_NO, ddlPackBean);
|
|
|
|
|
MesCustomerPart customerPart = customerPartRepository.getByProperty(ddlPackBean);
|
|
|
|
|
return customerPart;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|