|
|
|
|
@ -2,7 +2,6 @@ package org.springblade.wms.service.impl; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
import cn.hutool.core.util.NumberUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
@ -18,6 +17,7 @@ import org.springblade.wms.pojo.vo.StStockInoutRecordVO; |
|
|
|
|
import org.springblade.wms.service.IStStockInoutRecordService; |
|
|
|
|
import org.springblade.wms.service.IStStorehouseService; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.List; |
|
|
|
|
@ -77,41 +77,56 @@ public class StStockInoutRecordServiceImpl extends BaseServiceImpl<StStockInoutR |
|
|
|
|
return voPage; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
// @Override
|
|
|
|
|
// public String generateCode1() {
|
|
|
|
|
// // 1. 日期前缀
|
|
|
|
|
// String datePrefix = DateUtil.format(new Date(), "yyyyMMdd");
|
|
|
|
|
// // 2. 当天最大序号
|
|
|
|
|
// String maxCode = baseMapper.getMaxCheckCode(datePrefix);
|
|
|
|
|
// int lastNum = 0;
|
|
|
|
|
// if (StrUtil.isNotBlank(maxCode)) {
|
|
|
|
|
// String number = maxCode.substring(datePrefix.length());
|
|
|
|
|
// String[] arr = number.split("-");
|
|
|
|
|
// // 防止没有"-"导致数组空
|
|
|
|
|
// if(arr.length >= 1){
|
|
|
|
|
// String realNum = arr[0];
|
|
|
|
|
// // 只有全数字才转整型
|
|
|
|
|
// if(StrUtil.isNumeric(realNum)){
|
|
|
|
|
// lastNum = Integer.parseInt(realNum);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// // 3. 补零拼接
|
|
|
|
|
// return datePrefix + StrUtil.padPre(String.valueOf(++lastNum), 4, '0');
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public String generateCode() { |
|
|
|
|
// 1. 日期前缀
|
|
|
|
|
String datePrefix = DateUtil.format(new Date(), "yyyyMMdd"); |
|
|
|
|
// 2. 当天最大序号
|
|
|
|
|
String maxCode = baseMapper.getMaxCheckCode(datePrefix); |
|
|
|
|
int lastNum = 0; |
|
|
|
|
if (StrUtil.isNotBlank(maxCode)) { |
|
|
|
|
String number = maxCode.substring(datePrefix.length()); |
|
|
|
|
String[] arr = number.split("-"); |
|
|
|
|
// 防止没有"-"导致数组空
|
|
|
|
|
if(arr.length >= 1){ |
|
|
|
|
String realNum = arr[0]; |
|
|
|
|
// 只有全数字才转整型
|
|
|
|
|
if(StrUtil.isNumeric(realNum)){ |
|
|
|
|
lastNum = Integer.parseInt(realNum); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 3. 补零拼接
|
|
|
|
|
return datePrefix + StrUtil.padPre(String.valueOf(++lastNum), 4, '0'); |
|
|
|
|
// 1. 获取日期
|
|
|
|
|
String today = DateUtil.format(new Date(), "yyMMdd"); |
|
|
|
|
// 初始化当天序号(不存在则插入0)
|
|
|
|
|
baseMapper.insertTodaySeq(today); |
|
|
|
|
// 3. 原子 +1
|
|
|
|
|
baseMapper.incrementSeq(today); |
|
|
|
|
// 4. 加行锁,查询当前值
|
|
|
|
|
Integer currentNum = baseMapper.getCurrentSeqForUpdate(today); |
|
|
|
|
String seqNo = String.format("%05d", currentNum); |
|
|
|
|
return "RK" + today + seqNo; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
// @Transactional
|
|
|
|
|
// public String makeCode() {
|
|
|
|
|
// // 时间格式:yyMMddHHmmss(2位年+月+日+时+分+秒)
|
|
|
|
|
// String dateTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMddHHmmss"));
|
|
|
|
|
// // 获取下一个流水号
|
|
|
|
|
// int serialNo = baseMapper.getMaxSerialNoByDate(dateTime);
|
|
|
|
|
// // 拼接最终单号:CK + 时间 + 4位流水号(前面补0)
|
|
|
|
|
// String sirCode = "CK" + dateTime + String.format("%04d", serialNo);
|
|
|
|
|
//
|
|
|
|
|
// return sirCode;
|
|
|
|
|
// }
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public String generateOutStockNo() { |
|
|
|
|
// 1. 获取日期
|
|
|
|
|
String today = DateUtil.format(new Date(), "yyMMdd"); |
|
|
|
|
// 初始化当天序号(不存在则插入0)
|
|
|
|
|
baseMapper.insertTodaySeq(today); |
|
|
|
|
// 3. 原子 +1
|
|
|
|
|
baseMapper.incrementSeq(today); |
|
|
|
|
// 4. 加行锁,查询当前值
|
|
|
|
|
Integer currentNum = baseMapper.getCurrentSeqForUpdate(today); |
|
|
|
|
String seqNo = String.format("%05d", currentNum); |
|
|
|
|
return "CK" + today + seqNo; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String getMaxPiNo(String typeCode) { |
|
|
|
|
|