Browse Source

[fix]售后管理:

售后客诉通知
修改客诉通知编号自增的规则
dev
liuxiaoxu 7 months ago
parent
commit
98924b3fca
  1. 4
      ruoyi-admin/src/main/java/com/ruoyi/aftersales/mapper/AftersalesComplaintNoticeMapper.java
  2. 50
      ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesComplaintNoticeServiceImpl.java
  3. 18
      ruoyi-admin/src/main/resources/mapper/aftersales/AftersalesComplaintNoticeMapper.xml

4
ruoyi-admin/src/main/java/com/ruoyi/aftersales/mapper/AftersalesComplaintNoticeMapper.java

@ -85,11 +85,9 @@ public interface AftersalesComplaintNoticeMapper
*/
public int restoreAftersalesComplaintNoticeById(Long complaintNoticeId);
/**
* 获取今天已经生成的最大序号
* @param dateStr 日期字符串格式为yyyyMMdd
* @return 最大序号
*/
int getMaxSequenceForToday(@Param("dateStr") String dateStr);
String maxRoundCode(@Param("code") String code);
}

50
ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesComplaintNoticeServiceImpl.java

@ -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
*自增长:KS20231111001KS20231111002
*
* @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;
}
}

18
ruoyi-admin/src/main/resources/mapper/aftersales/AftersalesComplaintNoticeMapper.xml

@ -137,20 +137,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update aftersales_complaint_notice set del_flag = '0' where complaint_notice_id = #{complaintNoticeId}
</update>
<!-- <select id="getMaxSequenceForToday" resultType="int">-->
<!-- SELECT IFNULL(MAX(SUBSTRING(complaint_notice_code, 10, 3)), 0) AS max_sequence-->
<!-- FROM aftersales_complaint_notice-->
<!-- WHERE DATE_FORMAT(create_time, '%Y%m%d') = #{dateStr}-->
<!-- </select>-->
<select id="getMaxSequenceForToday" resultType="int">
SELECT
IFNULL(MAX(SUBSTRING(complaint_notice_code, 10, 3)), 0) AS max_sequence
FROM
aftersales_complaint_notice
WHERE
DATE_FORMAT(create_time, '%Y%m%d') = DATE_FORMAT(#{dateStr}, '%Y%m%d');
<!--获得最大的编码-->
<select id="maxRoundCode" resultType="String">
SELECT max(complaint_notice_code) from aftersales_complaint_notice where complaint_notice_code like concat(#{code},'%')
</select>
</mapper>
Loading…
Cancel
Save