|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
package com.logpm.basicdata.service.impl; |
|
|
|
|
|
|
|
|
|
import com.logpm.basic.feign.IBasicTenantCodeClient; |
|
|
|
|
import com.logpm.basicdata.entity.BasicdataWarehouseEntity; |
|
|
|
|
import com.logpm.basicdata.feign.IBasicdataWarehouseClient; |
|
|
|
|
import com.logpm.basicdata.service.IBasicdataCodeService; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import lombok.extern.log4j.Log4j2; |
|
|
|
@ -9,9 +11,11 @@ import org.springblade.common.constant.CodeNumConstant;
|
|
|
|
|
import org.springblade.common.utils.CommonUtil; |
|
|
|
|
import org.springblade.core.redis.cache.BladeRedis; |
|
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
|
|
@Service |
|
|
|
|
@AllArgsConstructor |
|
|
|
@ -22,7 +26,7 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
|
|
|
|
|
|
|
|
|
|
private final IBasicTenantCodeClient basicTenantCodeClient; |
|
|
|
|
|
|
|
|
|
// private final IWarehouseClient warehouseClient;
|
|
|
|
|
private final IBasicdataWarehouseClient basicdataWarehouseClient; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 根据类型生成编号 |
|
|
|
@ -30,29 +34,34 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
|
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public String getCodeByType(Integer type,String warehouseCode) { |
|
|
|
|
public String getCodeByType(Integer type,String warehouseCode,String orderCode) { |
|
|
|
|
String code = null; |
|
|
|
|
switch (type){ |
|
|
|
|
// case CodeNumConstant.WAYBILL:
|
|
|
|
|
// break;
|
|
|
|
|
case CodeNumConstant.WAYBILL: |
|
|
|
|
code = getWayBillNo(type,warehouseCode); |
|
|
|
|
break; |
|
|
|
|
// case CodeNumConstant.ORDER:
|
|
|
|
|
// break;
|
|
|
|
|
case CodeNumConstant.PSCC: |
|
|
|
|
code = generateDeliveryTrainNumber(type,warehouseCode); |
|
|
|
|
break; |
|
|
|
|
// case CodeNumConstant.PSCC:
|
|
|
|
|
// code = generateDeliveryTrainNumber(type,warehouseCode);
|
|
|
|
|
// break;
|
|
|
|
|
// case CodeNumConstant.PSJH:
|
|
|
|
|
// break;
|
|
|
|
|
// case CodeNumConstant.LOCATION:
|
|
|
|
|
// break;
|
|
|
|
|
// case CodeNumConstant.TRAYS:
|
|
|
|
|
// break;
|
|
|
|
|
case CodeNumConstant.TRAYS: |
|
|
|
|
code = generateTraysCode(type,warehouseCode); |
|
|
|
|
break; |
|
|
|
|
case CodeNumConstant.PACKAGE: |
|
|
|
|
code = generatePackageCode(type,warehouseCode); |
|
|
|
|
code = generatePackageCode(type,warehouseCode,orderCode); |
|
|
|
|
break; |
|
|
|
|
// case CodeNumConstant.SHELF:
|
|
|
|
|
// break;
|
|
|
|
|
case CodeNumConstant.PSKH: |
|
|
|
|
code = generateDeliveryCustomOrder(type,warehouseCode); |
|
|
|
|
// case CodeNumConstant.PSKH:
|
|
|
|
|
// code = generateDeliveryCustomOrder(type,warehouseCode);
|
|
|
|
|
// break;
|
|
|
|
|
case CodeNumConstant.ABNORMAL_ORDER: |
|
|
|
|
code = generateExOrderCode(type,warehouseCode,orderCode); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
log.info("##################getCodeByType: 暂不支持的编码类型 type={}", CodeDesEnum.getMes(type)); |
|
|
|
@ -60,6 +69,81 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
|
|
|
|
|
return code; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String generateExOrderCode(Integer type, String warehouseCode, String orderCode) { |
|
|
|
|
if(!StringUtil.hasLength(warehouseCode)){ |
|
|
|
|
log.warn("############generateTraysCode: 仓库编码为空warehouseCode={}",warehouseCode); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//HTEX+仓库code+年月日+(仓库当天的数量+1)
|
|
|
|
|
|
|
|
|
|
//获得年月日短字符串
|
|
|
|
|
String dateShort = CommonUtil.dateToStringShort(new Date()); |
|
|
|
|
|
|
|
|
|
String key = "HTEX"+":"+warehouseCode+":"+dateShort; |
|
|
|
|
//获得序号
|
|
|
|
|
Long incr = bladeRedis.incr(key); |
|
|
|
|
if(1 == incr){ |
|
|
|
|
//如果为1就是刚刚才建立,给他一个过期时间
|
|
|
|
|
bladeRedis.expireAt(key,CommonUtil.getMonthDayEnd()); |
|
|
|
|
} |
|
|
|
|
return "HTEX"+warehouseCode+CommonUtil.geFourNumber(incr); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String generateTraysCode(Integer type, String warehouseCode) { |
|
|
|
|
if(!StringUtil.hasLength(warehouseCode)){ |
|
|
|
|
log.warn("############generateTraysCode: 仓库编码为空warehouseCode={}",warehouseCode); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//托盘 HT+仓库拼音+ 年月 +【当前仓库总数+1(五位数 不足补零)】
|
|
|
|
|
//通过仓库编码获取仓库简写
|
|
|
|
|
BasicdataWarehouseEntity entity = basicdataWarehouseClient.getWarehouseEntityByWarehouseCode(warehouseCode); |
|
|
|
|
if(Objects.isNull(entity)){ |
|
|
|
|
log.warn("############generateTraysCode: 未找到对应仓库warehouseCode={}",warehouseCode); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
String abbreviation = entity.getAbbreviation();//简称
|
|
|
|
|
//获得年月日短字符串
|
|
|
|
|
String dateShort = CommonUtil.dateToStringShortYM(new Date()); |
|
|
|
|
|
|
|
|
|
String key = "汇通"+":"+abbreviation+":"+dateShort; |
|
|
|
|
|
|
|
|
|
//获得序号
|
|
|
|
|
Long incr = bladeRedis.incr(key); |
|
|
|
|
if(1 == incr){ |
|
|
|
|
//如果为1就是刚刚才建立,给他一个过期时间
|
|
|
|
|
bladeRedis.expireAt(key,CommonUtil.getMonthDayEnd()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return "汇通"+abbreviation+dateShort+CommonUtil.geFourNumber(incr); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 生成仓库对应的运单号 |
|
|
|
|
* @param type |
|
|
|
|
* @param warehouseCode |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private String getWayBillNo(Integer type, String warehouseCode) { |
|
|
|
|
if(!StringUtil.hasLength(warehouseCode)){ |
|
|
|
|
log.warn("############getWayBillNo: 仓库编码为空warehouseCode={}",warehouseCode); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
//运单 仓库拼音+年月+(仓库当月数量+1)
|
|
|
|
|
//获得年月日短字符串
|
|
|
|
|
String dateShort = CommonUtil.dateToStringShortYM(new Date()); |
|
|
|
|
String key = warehouseCode + ":" +dateShort; |
|
|
|
|
//获得序号
|
|
|
|
|
Long incr = bladeRedis.incr(key); |
|
|
|
|
if(1 == incr){ |
|
|
|
|
//如果为1就是刚刚才建立,给他一个过期时间
|
|
|
|
|
bladeRedis.expireAt(key,CommonUtil.getMonthDayEnd()); |
|
|
|
|
} |
|
|
|
|
return warehouseCode+dateShort+CommonUtil.geFourNumber(incr); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String generateDeliveryCustomOrder(Integer type, String warehouseCode) { |
|
|
|
|
//查询租户编码
|
|
|
|
@ -106,16 +190,23 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String generatePackageCode(Integer type,String warehouseCode) { |
|
|
|
|
String des = CodeDesEnum.getMes(type);//摘要
|
|
|
|
|
String tenantId = AuthUtil.getTenantId();//租户号
|
|
|
|
|
// String tenantId = "627683";//租户号
|
|
|
|
|
private String generatePackageCode(Integer type,String warehouseCode,String orderCode) { |
|
|
|
|
if(!StringUtil.hasLength(warehouseCode)){ |
|
|
|
|
log.warn("############generatePackageCode: 仓库编码为空warehouseCode={}",warehouseCode); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
if(!StringUtil.hasLength(orderCode)){ |
|
|
|
|
log.warn("############generatePackageCode: 订单号为空orderCode={}",orderCode); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//包条 HT+仓库拼音/超管/职能+年月日时分秒+订单索引+包条个数索引
|
|
|
|
|
|
|
|
|
|
//获得年月日短字符串
|
|
|
|
|
String dateShort = CommonUtil.dateToStringShort(new Date()); |
|
|
|
|
String dateShort = CommonUtil.dateToString(new Date()); |
|
|
|
|
|
|
|
|
|
//redis的key
|
|
|
|
|
String key = tenantId + ":" + warehouseCode + ":" + des+":"+dateShort; |
|
|
|
|
String key = warehouseCode + ":" + orderCode+":"+dateShort; |
|
|
|
|
//获得序号
|
|
|
|
|
Long incr = bladeRedis.incr(key); |
|
|
|
|
if(1 == incr){ |
|
|
|
@ -123,6 +214,6 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
|
|
|
|
|
bladeRedis.expireAt(key,CommonUtil.getDayEnd()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return warehouseCode + des + dateShort + CommonUtil.geFourNumber(incr); |
|
|
|
|
return "HT" + warehouseCode + dateShort + CommonUtil.geFourNumber(incr); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|