From 8eb67efed5c8c8cd6139157579d9359a2f173d0d Mon Sep 17 00:00:00 2001 From: liuxiaoxu <1793812695@qq.com> Date: Tue, 30 Apr 2024 10:44:59 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=E5=94=AE=E5=90=8E=E7=AE=A1=E7=90=86:=20?= =?UTF-8?q?=E5=94=AE=E5=90=8E=E5=AE=A2=E8=AF=89=E9=80=9A=E7=9F=A5=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AE=A2=E8=AF=89=E9=80=9A=E7=9F=A5=E5=8D=95?= =?UTF-8?q?=E5=8F=B7=E6=A0=B9=E6=8D=AE=E7=BC=96=E7=A0=81=E8=A7=84=E5=88=99?= =?UTF-8?q?=E8=87=AA=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AftersalesComplaintNoticeMapper.java | 9 +++++ .../AftersalesComplaintNoticeServiceImpl.java | 21 +++++++++++ .../AftersalesComplaintNoticeMapper.xml | 16 +++++++++ .../aftersales/complaintNotice/add.html | 36 +++++++++---------- 4 files changed, 64 insertions(+), 18 deletions(-) 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 @@ -
-
- -
-
-
-
-
-
-
+ + + + + + + + + + + + + + + + + +