diff --git a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/mapper/AftersalesComplaintNoticeMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/mapper/AftersalesComplaintNoticeMapper.java index 1d82a64f..749d324b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/mapper/AftersalesComplaintNoticeMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/mapper/AftersalesComplaintNoticeMapper.java @@ -2,6 +2,7 @@ package com.ruoyi.aftersales.mapper; import java.util.List; import com.ruoyi.aftersales.domain.AftersalesComplaintNotice; +import io.lettuce.core.dynamic.annotation.Param; /** * 售后客诉通知单Mapper接口 @@ -83,4 +84,12 @@ public interface AftersalesComplaintNoticeMapper * @return 结果 */ public int restoreAftersalesComplaintNoticeById(Long complaintNoticeId); + + + /** + * 获取今天已经生成的最大序号 + * @param dateStr 日期字符串,格式为yyyyMMdd + * @return 最大序号 + */ + int getMaxSequenceForToday(@Param("dateStr") String dateStr); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesComplaintNoticeServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesComplaintNoticeServiceImpl.java index 088d4557..33359ed3 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesComplaintNoticeServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesComplaintNoticeServiceImpl.java @@ -1,5 +1,7 @@ package com.ruoyi.aftersales.service.impl; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.List; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ShiroUtils; @@ -13,6 +15,7 @@ import com.ruoyi.aftersales.mapper.AftersalesComplaintNoticeMapper; import com.ruoyi.aftersales.domain.AftersalesComplaintNotice; import com.ruoyi.aftersales.service.IAftersalesComplaintNoticeService; import com.ruoyi.common.core.text.Convert; +import org.springframework.transaction.annotation.Transactional; /** * 售后客诉通知单Service业务层处理 @@ -60,9 +63,14 @@ public class AftersalesComplaintNoticeServiceImpl implements IAftersalesComplain * @param aftersalesComplaintNotice 售后客诉通知单 * @return 结果 */ + @Transactional @Override public int insertAftersalesComplaintNotice(AftersalesComplaintNotice aftersalesComplaintNotice) { + + // 生成complaintNoticeCode + String complaintNoticeCode = generateComplainNoticeCode(); + aftersalesComplaintNotice.setComplaintNoticeCode(complaintNoticeCode); String loginName = ShiroUtils.getLoginName(); aftersalesComplaintNotice.setCreateBy(loginName); aftersalesComplaintNotice.setCreateTime(DateUtils.getNowDate()); @@ -144,4 +152,17 @@ public class AftersalesComplaintNoticeServiceImpl implements IAftersalesComplain } return sysMakeOrders; } + + /** + * 按照特定编码生成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; + } } diff --git a/ruoyi-admin/src/main/resources/mapper/aftersales/AftersalesComplaintNoticeMapper.xml b/ruoyi-admin/src/main/resources/mapper/aftersales/AftersalesComplaintNoticeMapper.xml index 3183811c..3b31d3c8 100644 --- a/ruoyi-admin/src/main/resources/mapper/aftersales/AftersalesComplaintNoticeMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/aftersales/AftersalesComplaintNoticeMapper.xml @@ -137,4 +137,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update aftersales_complaint_notice set del_flag = '0' where complaint_notice_id = #{complaintNoticeId} + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/aftersales/complaintNotice/add.html b/ruoyi-admin/src/main/resources/templates/aftersales/complaintNotice/add.html index bd79de4a..519bd128 100644 --- a/ruoyi-admin/src/main/resources/templates/aftersales/complaintNotice/add.html +++ b/ruoyi-admin/src/main/resources/templates/aftersales/complaintNotice/add.html @@ -44,24 +44,24 @@ -