预约单改造;
This commit is contained in:
+51
@@ -1,6 +1,8 @@
|
|||||||
package com.mhd.oms.domain.businessDocumentOrder.repository.persistence;
|
package com.mhd.oms.domain.businessDocumentOrder.repository.persistence;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
@@ -43,6 +45,7 @@ import org.springframework.beans.BeanUtils;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.rmi.ServerException;
|
import java.rmi.ServerException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -169,6 +172,29 @@ public class BusinessDocumentOrderImpl extends ServiceImpl<BusinessDocumentOrder
|
|||||||
return businessDocumentOrderPO;
|
return businessDocumentOrderPO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static String getOrderCodeByDate(Date date){
|
||||||
|
return new StringBuffer()
|
||||||
|
.append(getSecondPartByDate(date))
|
||||||
|
.append(getThreePart())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
private static String getSecondPartByDate(Date date) {
|
||||||
|
if (date == null) {
|
||||||
|
date = new Date();
|
||||||
|
}
|
||||||
|
String temp_current_time = DateUtil.format(date, datePattern());
|
||||||
|
return temp_current_time.substring(2, temp_current_time.length());
|
||||||
|
}
|
||||||
|
private static String datePattern() {
|
||||||
|
return "yyyyMMddHHmmss";
|
||||||
|
}
|
||||||
|
private static String getThreePart() {
|
||||||
|
return RandomUtil.randomNumbers(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean audit(List<Long> ids, Long reviewStatus, String SalesManager,String reviewOpinion ) {
|
public Boolean audit(List<Long> ids, Long reviewStatus, String SalesManager,String reviewOpinion ) {
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();//获取登录人
|
LoginUser loginUser = SecurityUtils.getLoginUser();//获取登录人
|
||||||
@@ -229,6 +255,31 @@ public class BusinessDocumentOrderImpl extends ServiceImpl<BusinessDocumentOrder
|
|||||||
subOrder.setRecipientName(user.getUserName());
|
subOrder.setRecipientName(user.getUserName());
|
||||||
|
|
||||||
|
|
||||||
|
String orderCode = null;
|
||||||
|
int maxRetryCount = 100;
|
||||||
|
int retryCount = 0;
|
||||||
|
|
||||||
|
while (retryCount < maxRetryCount) {
|
||||||
|
orderCode = getOrderCodeByDate(subOrder.getDocumentDate());
|
||||||
|
retryCount++;
|
||||||
|
|
||||||
|
List<BusinessDocumentOrder> checkOrderCodes = businessDocumentOrderMapper.selectList(
|
||||||
|
new QueryWrapper<BusinessDocumentOrder>().eq("goods_number", orderCode)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (CollectionUtils.isEmpty(checkOrderCodes)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (retryCount >= maxRetryCount) {
|
||||||
|
throw new com.aliyun.oss.ServiceException("生成唯一订单编号失败,已达到最大重试次数:" + maxRetryCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//生成货源单号
|
||||||
|
subOrder.setGoodsNumber(orderCode);
|
||||||
|
|
||||||
|
|
||||||
businessDocumentOrderMapper.insert(subOrder);
|
businessDocumentOrderMapper.insert(subOrder);
|
||||||
subOrderCount++; // 增加子单计数
|
subOrderCount++; // 增加子单计数
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user