parent
820b978ee3
commit
e6c4ee735f
|
|
@ -4,6 +4,7 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.as.common.exception.base.BaseException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -73,27 +74,29 @@ public class WorkFlowServiceImpl implements WorkFlowService {
|
|||
QueryWrapper<WorkFlowEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc("sid");
|
||||
Page<WorkFlowEntity> page = new Page<>(1, 1);
|
||||
workFlowMapper.selectPage(page, queryWrapper);
|
||||
List<WorkFlowEntity> list = page.getRecords();
|
||||
String str = "";
|
||||
for (WorkFlowEntity workFlowEntity : list) {
|
||||
str = workFlowEntity.getWorkOrderNo();
|
||||
}
|
||||
Page workFlow = workFlowMapper.selectPage(page, queryWrapper);
|
||||
List<WorkFlowEntity> list = workFlow.getRecords();
|
||||
if(list.size()>0) {
|
||||
String str = list.get(0).getWorkOrderNo();
|
||||
// 截取最后四位
|
||||
// 然后返回AS + 当前YYYYmmdd + 刚才的数字
|
||||
|
||||
String lastFourDigits = str.substring(str.length() - 4);
|
||||
|
||||
// 转换为整数并加1
|
||||
int number = Integer.parseInt(lastFourDigits) + 1;
|
||||
String formattedNumber = String.format("%04d", number);
|
||||
System.out.println(formattedNumber);
|
||||
|
||||
if (formattedNumber.equals("10000")) {
|
||||
formattedNumber = "0001";
|
||||
}
|
||||
// 获取当前日期并格式化为YYYYmmdd
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
||||
String currentDate = sdf.format(new Date());
|
||||
|
||||
// 生成最终的字符串
|
||||
String finalString = "AS" + currentDate + number;
|
||||
|
||||
|
||||
String finalString = "AS" + currentDate + formattedNumber;
|
||||
return finalString;
|
||||
}else {
|
||||
throw new BaseException("WorkFlowOrderId_FAILED", "未查询到订单号");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue