Browse Source

[feat]

修改RedisCache工具类,新增每年序列号从001开始递增生成编号方法;
修改销售订单service接口,更换编号生成绑定方法;
dev
王晓迪 3 months ago
parent
commit
739be8ca2d
  1. 3
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysSalesOrderServiceImpl.java
  2. 24
      ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java

3
ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysSalesOrderServiceImpl.java

@ -183,6 +183,7 @@ public class SysSalesOrderServiceImpl implements ISysSalesOrderService
String loginName = ShiroUtils.getLoginName();
sysSalesOrder.setCreateBy(loginName);
sysSalesOrder.setCreateTime(DateUtils.getNowDate());
sysSalesOrder.setSalesOrderCode(getId());
int result = sysSalesOrderMapper.insertSysSalesOrder(sysSalesOrder);
sysSalesOrder.getSalesOrderId();
int s = sysSalesOrder.getSysSalesOrderChildList().size();
@ -256,7 +257,7 @@ public class SysSalesOrderServiceImpl implements ISysSalesOrderService
@Override
public String getId() {
return redisCache.generateBillNo("XS");
return redisCache.generateBillNoByYear("XS");
}
@Override

24
ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java

@ -314,7 +314,29 @@ public class RedisCache
String serialNum = String.format("%03d",no);
return codeKey+serialNum;
}
/**
* 生成流水号(年为单位)
* @param prefix
* @return
*/
public String generateBillNoByYear(String prefix) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
SimpleDateFormat year_format = new SimpleDateFormat("yyyy");
String yearMonthDay = sdf.format(new Date());
String yearPart = year_format.format(new Date());
String codeKey = prefix+yearPart;
Long no = 0L;
//获取每日流水
if (hasKey(codeKey)) {
no = Long.valueOf(get(codeKey).toString());
}
no = incr(codeKey, 1);
if (no == null) {
throw new RuntimeException("Redis单据编号流水递增失败");
}
String serialNum = String.format("%03d",no);
return prefix + yearMonthDay +serialNum;
}
public String generateNo(String prefix) {
String codeKey = prefix;
Long no = 0L;

Loading…
Cancel
Save