Browse Source

1.运单号 包条码 托盘码 异常单 的码值生成逻辑优化

dev-warehouse
zhenghaoyu 2 years ago
parent
commit
0f8366ddc9
  1. 4
      blade-biz-common/src/main/java/org/springblade/common/utils/CommonUtil.java
  2. 18
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataCodeServiceImpl.java
  3. 25
      blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryCommonController.java

4
blade-biz-common/src/main/java/org/springblade/common/utils/CommonUtil.java

@ -162,9 +162,9 @@ public class CommonUtil {
* @param number 数字
* @return
*/
public static String geFourNumber(Long number){
public static String geFourNumber(Long number,int num){
NumberFormat formatter = NumberFormat.getNumberInstance();
formatter.setMinimumIntegerDigits(4);
formatter.setMinimumIntegerDigits(num);
formatter.setGroupingUsed(false);
return formatter.format(number);
}

18
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataCodeServiceImpl.java

@ -87,7 +87,7 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
//如果为1就是刚刚才建立,给他一个过期时间
bladeRedis.expireAt(key,CommonUtil.getMonthDayEnd());
}
return "HTEX"+warehouseCode+CommonUtil.geFourNumber(incr);
return "HTEX"+warehouseCode+CommonUtil.geFourNumber(incr,5);
}
private String generateTraysCode(Integer type, String warehouseCode) {
@ -116,7 +116,7 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
bladeRedis.expireAt(key,CommonUtil.getMonthDayEnd());
}
return "汇通"+abbreviation+dateShort+CommonUtil.geFourNumber(incr);
return "汇通"+abbreviation+dateShort+CommonUtil.geFourNumber(incr,5);
}
@ -141,7 +141,7 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
//如果为1就是刚刚才建立,给他一个过期时间
bladeRedis.expireAt(key,CommonUtil.getMonthDayEnd());
}
return warehouseCode+dateShort+CommonUtil.geFourNumber(incr);
return warehouseCode+dateShort+CommonUtil.geFourNumber(incr,5);
}
@ -162,7 +162,7 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
bladeRedis.expireAt(key,CommonUtil.getDayEnd());
}
return tenantCode+warehouseCode+dateShort+CommonUtil.geFourNumber(incr);
return tenantCode+warehouseCode+dateShort+CommonUtil.geFourNumber(incr,5);
}
/**
@ -186,7 +186,7 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
bladeRedis.expireAt(key,CommonUtil.getDayEnd());
}
return warehouseCode + des + dateShort + CommonUtil.geFourNumber(incr);
return warehouseCode + des + dateShort + CommonUtil.geFourNumber(incr,5);
}
@ -203,10 +203,12 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
//包条 HT+仓库拼音/超管/职能+年月日时分秒+订单索引+包条个数索引
//获得年月日短字符串
String dateShort = CommonUtil.dateToString(new Date());
Date date = new Date();
String s = CommonUtil.dateToStringShort(date);
String dateShort = CommonUtil.dateToString(date);
//redis的key
String key = warehouseCode + ":" + orderCode+":"+dateShort;
String key = warehouseCode + ":" + orderCode+":"+s;
//获得序号
Long incr = bladeRedis.incr(key);
if(1 == incr){
@ -214,6 +216,6 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
bladeRedis.expireAt(key,CommonUtil.getDayEnd());
}
return "HT" + warehouseCode + dateShort + CommonUtil.geFourNumber(incr);
return "HT" + warehouseCode + dateShort + CommonUtil.geFourNumber(incr,5);
}
}

25
blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryCommonController.java

@ -2,6 +2,7 @@ package com.logpm.factory.comfac.controller;
import com.alibaba.fastjson.JSONObject;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.logpm.basicdata.feign.IBasicdataCodeClient;
import com.logpm.factory.comfac.dto.OrderInfoDTO;
import com.logpm.factory.comfac.dto.OrderStatusDTO;
import com.logpm.factory.comfac.dto.ReceiveInfoDTO;
@ -13,6 +14,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springblade.common.constant.CodeNumConstant;
import org.springblade.common.constant.RabbitConstant;
import org.springblade.common.exception.CustomerException;
import org.springblade.common.utils.CommonUtil;
@ -24,7 +26,6 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@ -39,6 +40,7 @@ public class FactoryCommonController {
private final RabbitTemplate rabbitTemplate;
private final IOrderStatusLogService orderStatusLogService;
private final IFactoryCommonService factoryCommonService;
private final IBasicdataCodeClient codeClient;
@ResponseBody
@PostMapping("/sendOrders")
@ -191,4 +193,25 @@ public class FactoryCommonController {
}
@ResponseBody
@PostMapping("/testCode")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "卸车完成推送", notes = "传入receiveInfoDTO")
public R testCode(@RequestBody OrderInfoDTO orderInfoDTO) {
String lq = codeClient.getCodeByType(CodeNumConstant.WAYBILL, "LQ", orderInfoDTO.getOrderNo());
String lq1 = codeClient.getCodeByType(CodeNumConstant.PACKAGE, "LQ", orderInfoDTO.getOrderNo());
String lq2 = codeClient.getCodeByType(CodeNumConstant.TRAYS, "LQ", orderInfoDTO.getOrderNo());
String lq3 = codeClient.getCodeByType(CodeNumConstant.ABNORMAL_ORDER, "LQ", orderInfoDTO.getOrderNo());
log.info("##############testCode: code={}",lq);
Map<String,String> map = new HashMap<>();
map.put("运单号",lq);
map.put("包件码",lq1);
map.put("托盘码",lq2);
map.put("异常工单码",lq3);
return R.data(map);
}
}

Loading…
Cancel
Save