|
|
|
@ -2,10 +2,12 @@ package com.logpm.basicdata.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.logpm.basic.feign.IBasicTenantCodeClient; |
|
|
|
|
import com.logpm.basicdata.entity.BasicdataCodeRecordEntity; |
|
|
|
|
import com.logpm.basicdata.entity.BasicdataTrayEntity; |
|
|
|
|
import com.logpm.basicdata.entity.BasicdataWarehouseEntity; |
|
|
|
|
import com.logpm.basicdata.feign.IBasicdataWarehouseClient; |
|
|
|
|
import com.logpm.basicdata.mapper.BasicdataTrayMapper; |
|
|
|
|
import com.logpm.basicdata.service.IBasicdataCodeRecordService; |
|
|
|
|
import com.logpm.basicdata.service.IBasicdataCodeService; |
|
|
|
|
import com.logpm.basicdata.service.IBasicdataWarehouseService; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
@ -18,6 +20,7 @@ import org.springblade.core.secure.utils.AuthUtil;
|
|
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.util.Calendar; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
|
@ -36,6 +39,8 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
|
|
|
|
|
|
|
|
|
|
private final BasicdataTrayMapper basicdataTrayMapper; |
|
|
|
|
|
|
|
|
|
private final IBasicdataCodeRecordService basicdataCodeRecordService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 根据类型生成编号 |
|
|
|
|
* @param type |
|
|
|
@ -285,17 +290,37 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
|
|
|
|
|
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()); |
|
|
|
|
|
|
|
|
|
BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseService.getWarehouseEntityByWarehouseCode(warehouseCode); |
|
|
|
|
if(Objects.isNull(basicdataWarehouseEntity)){ |
|
|
|
|
log.warn("############getWayBillNo: 仓库信息不存在 warehouseCode={}",warehouseCode); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
//获取年份
|
|
|
|
|
int year = calendar.get(Calendar.YEAR); |
|
|
|
|
|
|
|
|
|
// 获取月份(注意月份从0开始计数)
|
|
|
|
|
int month = calendar.get(Calendar.MONTH) + 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BasicdataCodeRecordEntity basicdataCodeRecordEntity = basicdataCodeRecordService.findEntityByCodeTypeAndWarehouseCodeAndYearAndMonth(type,warehouseCode,year+"",month+""); |
|
|
|
|
|
|
|
|
|
if(Objects.isNull(basicdataCodeRecordEntity)){ |
|
|
|
|
basicdataCodeRecordEntity = new BasicdataCodeRecordEntity(); |
|
|
|
|
basicdataCodeRecordEntity.setCodeType(type); |
|
|
|
|
basicdataCodeRecordEntity.setWarehouseId(basicdataWarehouseEntity.getId()); |
|
|
|
|
basicdataCodeRecordEntity.setWarehouseName(basicdataWarehouseEntity.getName()); |
|
|
|
|
basicdataCodeRecordEntity.setWarehouseCode(warehouseCode); |
|
|
|
|
basicdataCodeRecordEntity.setYear(year+""); |
|
|
|
|
basicdataCodeRecordEntity.setMonth(month+""); |
|
|
|
|
basicdataCodeRecordEntity.setNum(0); |
|
|
|
|
basicdataCodeRecordService.save(basicdataCodeRecordEntity); |
|
|
|
|
} |
|
|
|
|
return warehouseCode+dateShort+CommonUtil.geFourNumber(incr,5); |
|
|
|
|
Integer inrc = basicdataCodeRecordEntity.getNum() + 1; |
|
|
|
|
|
|
|
|
|
return warehouseCode+year+month+CommonUtil.geFourNumber(inrc.longValue(),5); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|