|
|
@ -1,7 +1,10 @@ |
|
|
|
package com.ruoyi.aftersales.service.impl; |
|
|
|
|
|
|
|
import java.text.DecimalFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import com.ruoyi.common.utils.DateUtils; |
|
|
|
import com.ruoyi.common.utils.ShiroUtils; |
|
|
@ -68,9 +71,21 @@ public class AftersalesComplaintNoticeServiceImpl implements IAftersalesComplain |
|
|
|
public int insertAftersalesComplaintNotice(AftersalesComplaintNotice aftersalesComplaintNotice) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd"); |
|
|
|
String code = "KS"+df.format(new Date()); |
|
|
|
//模糊查询当前最大的编码
|
|
|
|
String maxCode = aftersalesComplaintNoticeMapper.maxRoundCode(code); |
|
|
|
String newCode = null; |
|
|
|
if (StringUtils.isEmpty(maxCode)){ |
|
|
|
newCode= code+"001"; |
|
|
|
}else { |
|
|
|
//切割字符串,取查到编号后三位
|
|
|
|
String getMaxCode = maxCode.substring(11, 13); |
|
|
|
newCode = code+getNum(getMaxCode); |
|
|
|
} |
|
|
|
// 生成complaintNoticeCode
|
|
|
|
String complaintNoticeCode = generateComplainNoticeCode(); |
|
|
|
aftersalesComplaintNotice.setComplaintNoticeCode(complaintNoticeCode); |
|
|
|
aftersalesComplaintNotice.setComplaintNoticeCode(newCode); |
|
|
|
String loginName = ShiroUtils.getLoginName(); |
|
|
|
aftersalesComplaintNotice.setCreateBy(loginName); |
|
|
|
aftersalesComplaintNotice.setCreateTime(DateUtils.getNowDate()); |
|
|
@ -154,15 +169,26 @@ public class AftersalesComplaintNoticeServiceImpl implements IAftersalesComplain |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 按照特定编码生成complaintNoticeCode |
|
|
|
* */ |
|
|
|
private String generateComplainNoticeCode(){ |
|
|
|
LocalDate currentDate = LocalDate.now(); |
|
|
|
String formatDate = currentDate.format(DateTimeFormatter.ofPattern("yyyyMMdd")); |
|
|
|
//查询今天已经生成的最大序号
|
|
|
|
int maxSequenceForToday = aftersalesComplaintNoticeMapper.getMaxSequenceForToday(formatDate); |
|
|
|
//序号自增如果是当天第一条,则序号为001
|
|
|
|
String sequence =String.format("%03d",maxSequenceForToday+1); |
|
|
|
return "KS"+formatDate+sequence; |
|
|
|
*客诉单号生成规则: |
|
|
|
*系统自动生成,按照特定编码,编码暂用【KS+年月日+001】, |
|
|
|
*自增长,如:KS20231111001,KS20231111002 |
|
|
|
* |
|
|
|
* @param code 当前最大编码 |
|
|
|
*/ |
|
|
|
public static String getNum(String code){ |
|
|
|
String roundCode="001"; |
|
|
|
if (code!=null && !code.isEmpty()){ |
|
|
|
int intCode= Integer.parseInt(code)+1; |
|
|
|
if (intCode <999){ |
|
|
|
roundCode =String.format(String.valueOf(intCode)); |
|
|
|
}else { |
|
|
|
throw new RuntimeException("当日编号达到最大"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//编号前面补0
|
|
|
|
DecimalFormat df = new DecimalFormat("000"); |
|
|
|
String newCode = df.format(Integer.parseInt(roundCode)); |
|
|
|
return newCode; |
|
|
|
} |
|
|
|
} |
|
|
|