From 27a32bd0331761fd06ae4dcbbb3141c942429b45 Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期二, 26 五月 2026 09:28:55 +0800
Subject: [PATCH] Merge branch 'dev_New_pro' of http://114.132.189.42:9002/r/product-inventory-management-after into dev_New_pro
---
src/main/java/com/ruoyi/purchase/service/IPurchaseLedgerService.java | 3
src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java | 254 +++++++++++++++++++++++++-------------------------
src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java | 7
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java | 6
src/main/java/com/ruoyi/purchase/controller/PurchaseLedgerController.java | 5
5 files changed, 139 insertions(+), 136 deletions(-)
diff --git a/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java b/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java
index fdb610b..d04239f 100644
--- a/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java
+++ b/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java
@@ -1,14 +1,14 @@
package com.ruoyi.project.system.service.impl;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ruoyi.collaborativeApproval.mapper.EnterpriseNewsMapper;
-import com.ruoyi.collaborativeApproval.pojo.EnterpriseNews;
-import com.ruoyi.common.utils.SecurityUtils;
-import com.ruoyi.project.system.domain.SysDept;
-import com.ruoyi.project.system.domain.SysNotice;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.collaborativeApproval.mapper.EnterpriseNewsMapper;
+import com.ruoyi.collaborativeApproval.pojo.EnterpriseNews;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.project.system.domain.SysDept;
+import com.ruoyi.project.system.domain.SysNotice;
import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.project.system.domain.SysUserDept;
import com.ruoyi.project.system.mapper.SysDeptMapper;
@@ -17,15 +17,15 @@
import com.ruoyi.project.system.mapper.SysUserMapper;
import com.ruoyi.project.system.service.ISysNoticeService;
import lombok.RequiredArgsConstructor;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* 鍏憡 鏈嶅姟灞傚疄鐜�
@@ -34,16 +34,16 @@
*/
@Service
@RequiredArgsConstructor
-public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice> implements ISysNoticeService {
-
- private static final Pattern ENTERPRISE_NEWS_ID_PATTERN = Pattern.compile("[?&]id=(\\d+)");
-
- private final SysNoticeMapper noticeMapper;
- private final SysUserMapper userMapper;
- private final SysDeptMapper deptMapper;
- private final SysUserDeptMapper userDeptMapper;
- private final UnipushService unipushService;
- private final EnterpriseNewsMapper enterpriseNewsMapper;
+public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice> implements ISysNoticeService {
+
+ private static final Pattern ENTERPRISE_NEWS_ID_PATTERN = Pattern.compile("[?&]id=(\\d+)");
+
+ private final SysNoticeMapper noticeMapper;
+ private final SysUserMapper userMapper;
+ private final SysDeptMapper deptMapper;
+ private final SysUserDeptMapper userDeptMapper;
+ private final UnipushService unipushService;
+ private final EnterpriseNewsMapper enterpriseNewsMapper;
/**
* 鏌ヨ鍏憡淇℃伅
@@ -86,26 +86,26 @@
* @param notice 鍏憡淇℃伅
* @return 缁撴灉
*/
- @Override
- @Transactional(rollbackFor = Exception.class)
- public int updateNotice(SysNotice notice)
- {
- if (notice == null || notice.getNoticeId() == null) {
- return 0;
- }
- SysNotice dbNotice = noticeMapper.selectNoticeById(notice.getNoticeId());
- if (dbNotice == null) {
- return 0;
- }
- boolean needSyncNewsReadCount = isEnterpriseNewsNotice(dbNotice)
- && notice.getStatus() != null
- && !notice.getStatus().equals(dbNotice.getStatus());
- int rows = noticeMapper.updateNotice(notice);
- if (rows > 0 && needSyncNewsReadCount) {
- syncEnterpriseNewsReadCount(dbNotice.getJumpPath());
- }
- return rows;
- }
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public int updateNotice(SysNotice notice)
+ {
+ if (notice == null || notice.getNoticeId() == null) {
+ return 0;
+ }
+ SysNotice dbNotice = noticeMapper.selectNoticeById(notice.getNoticeId());
+ if (dbNotice == null) {
+ return 0;
+ }
+ boolean needSyncNewsReadCount = isEnterpriseNewsNotice(dbNotice)
+ && notice.getStatus() != null
+ && !notice.getStatus().equals(dbNotice.getStatus());
+ int rows = noticeMapper.updateNotice(notice);
+ if (rows > 0 && needSyncNewsReadCount) {
+ syncEnterpriseNewsReadCount(dbNotice.getJumpPath());
+ }
+ return rows;
+ }
/**
* 鍒犻櫎鍏憡瀵硅薄
@@ -139,20 +139,20 @@
}
@Override
- public int readAll() {
- Long userId = SecurityUtils.getUserId();
- List<SysNotice> unreadNotices = noticeMapper.selectList(Wrappers.<SysNotice>lambdaQuery()
- .eq(SysNotice::getConsigneeId, userId)
- .eq(SysNotice::getStatus, "0"));
- int rows = noticeMapper.update(null, Wrappers.<SysNotice>lambdaUpdate()
- .eq(SysNotice::getConsigneeId, userId)
- .eq(SysNotice::getStatus, "0")
- .set(SysNotice::getStatus, "1"));
- if (rows > 0) {
- syncEnterpriseNewsReadCount(unreadNotices);
- }
- return rows;
- }
+ public int readAll() {
+ Long userId = SecurityUtils.getUserId();
+ List<SysNotice> unreadNotices = noticeMapper.selectList(Wrappers.<SysNotice>lambdaQuery()
+ .eq(SysNotice::getConsigneeId, userId)
+ .eq(SysNotice::getStatus, "0"));
+ int rows = noticeMapper.update(null, Wrappers.<SysNotice>lambdaUpdate()
+ .eq(SysNotice::getConsigneeId, userId)
+ .eq(SysNotice::getStatus, "0")
+ .set(SysNotice::getStatus, "1"));
+ if (rows > 0) {
+ syncEnterpriseNewsReadCount(unreadNotices);
+ }
+ return rows;
+ }
@Override
public void simpleNoticeByUser(String title, String message, List<Long> consigneeId, String jumpPath) {
@@ -242,72 +242,72 @@
@Override
@Transactional(rollbackFor = Exception.class)
- public boolean appReadNotice(Long noticeId) {
- if (noticeId == null) {
- return false;
+ public boolean appReadNotice(Long noticeId) {
+ if (noticeId == null) {
+ return false;
}
SysNotice sysNotice = noticeMapper.selectNoticeById(noticeId);
if (sysNotice == null) {
return false;
- }
- sysNotice.setStatus("1");
- boolean updated = noticeMapper.update(null, Wrappers.<SysNotice>lambdaUpdate()
- .eq(SysNotice::getNoticeId, noticeId)
- .eq(SysNotice::getStatus, "0")
- .set(SysNotice::getStatus, "1")) > 0;
- if (updated) {
- syncEnterpriseNewsReadCount(sysNotice.getJumpPath());
- }
- return updated;
- }
-
- private boolean isEnterpriseNewsNotice(SysNotice sysNotice) {
- return sysNotice != null
- && sysNotice.getJumpPath() != null
- && sysNotice.getJumpPath().startsWith("/enterpriseNews?id=");
- }
-
- private void syncEnterpriseNewsReadCount(List<SysNotice> notices) {
- if (notices == null || notices.isEmpty()) {
- return;
- }
- Set<String> jumpPaths = new HashSet<>();
- for (SysNotice notice : notices) {
- if (isEnterpriseNewsNotice(notice)) {
- jumpPaths.add(notice.getJumpPath());
- }
- }
- for (String jumpPath : jumpPaths) {
- syncEnterpriseNewsReadCount(jumpPath);
- }
- }
-
- private void syncEnterpriseNewsReadCount(String jumpPath) {
- Long newsId = parseEnterpriseNewsId(jumpPath);
- if (newsId == null) {
- return;
- }
- long readCount = noticeMapper.selectCount(Wrappers.<SysNotice>lambdaQuery()
- .eq(SysNotice::getStatus, "1")
- .eq(SysNotice::getJumpPath, jumpPath));
- EnterpriseNews enterpriseNews = new EnterpriseNews();
- enterpriseNews.setId(newsId);
- enterpriseNews.setReadCount((int) readCount);
- enterpriseNewsMapper.updateById(enterpriseNews);
- }
-
- private Long parseEnterpriseNewsId(String jumpPath) {
- if (jumpPath == null || !jumpPath.startsWith("/enterpriseNews")) {
- return null;
- }
- Matcher matcher = ENTERPRISE_NEWS_ID_PATTERN.matcher(jumpPath);
- if (!matcher.find()) {
- return null;
- }
- try {
- return Long.parseLong(matcher.group(1));
- } catch (NumberFormatException e) {
- return null;
- }
- }
-}
+ }
+ sysNotice.setStatus("1");
+ boolean updated = noticeMapper.update(null, Wrappers.<SysNotice>lambdaUpdate()
+ .eq(SysNotice::getNoticeId, noticeId)
+ .eq(SysNotice::getStatus, "0")
+ .set(SysNotice::getStatus, "1")) > 0;
+ if (updated) {
+ syncEnterpriseNewsReadCount(sysNotice.getJumpPath());
+ }
+ return updated;
+ }
+
+ private boolean isEnterpriseNewsNotice(SysNotice sysNotice) {
+ return sysNotice != null
+ && sysNotice.getJumpPath() != null
+ && sysNotice.getJumpPath().contains("/enterpriseNews?id=");
+ }
+
+ private void syncEnterpriseNewsReadCount(List<SysNotice> notices) {
+ if (notices == null || notices.isEmpty()) {
+ return;
+ }
+ Set<String> jumpPaths = new HashSet<>();
+ for (SysNotice notice : notices) {
+ if (isEnterpriseNewsNotice(notice)) {
+ jumpPaths.add(notice.getJumpPath());
+ }
+ }
+ for (String jumpPath : jumpPaths) {
+ syncEnterpriseNewsReadCount(jumpPath);
+ }
+ }
+
+ private void syncEnterpriseNewsReadCount(String jumpPath) {
+ Long newsId = parseEnterpriseNewsId(jumpPath);
+ if (newsId == null) {
+ return;
+ }
+ long readCount = noticeMapper.selectCount(Wrappers.<SysNotice>lambdaQuery()
+ .eq(SysNotice::getStatus, "1")
+ .eq(SysNotice::getJumpPath, jumpPath));
+ EnterpriseNews enterpriseNews = new EnterpriseNews();
+ enterpriseNews.setId(newsId);
+ enterpriseNews.setReadCount((int) readCount);
+ enterpriseNewsMapper.updateById(enterpriseNews);
+ }
+
+ private Long parseEnterpriseNewsId(String jumpPath) {
+ if (jumpPath == null || !jumpPath.startsWith("/enterpriseNews")) {
+ return null;
+ }
+ Matcher matcher = ENTERPRISE_NEWS_ID_PATTERN.matcher(jumpPath);
+ if (!matcher.find()) {
+ return null;
+ }
+ try {
+ return Long.parseLong(matcher.group(1));
+ } catch (NumberFormatException e) {
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/com/ruoyi/purchase/controller/PurchaseLedgerController.java b/src/main/java/com/ruoyi/purchase/controller/PurchaseLedgerController.java
index 0951d3b..537c903 100644
--- a/src/main/java/com/ruoyi/purchase/controller/PurchaseLedgerController.java
+++ b/src/main/java/com/ruoyi/purchase/controller/PurchaseLedgerController.java
@@ -31,6 +31,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
+import java.util.Date;
import java.util.List;
/**
@@ -246,7 +247,7 @@
@Operation(summary = "鐢熸垚閲囪喘搴忓垪鍙�")
@GetMapping("/createPurchaseNo")
@Log(title = "鐢熸垚閲囪喘搴忓垪鍙�", businessType = BusinessType.OTHER)
- public AjaxResult createPurchaseNo() {
- return AjaxResult.success("鐢熸垚鎴愬姛",purchaseLedgerService.getPurchaseNo());
+ public AjaxResult createPurchaseNo(@RequestParam Date entryDate) {
+ return AjaxResult.success("鐢熸垚鎴愬姛",purchaseLedgerService.getPurchaseNo(entryDate));
}
}
diff --git a/src/main/java/com/ruoyi/purchase/service/IPurchaseLedgerService.java b/src/main/java/com/ruoyi/purchase/service/IPurchaseLedgerService.java
index a0378af..a1f135e 100644
--- a/src/main/java/com/ruoyi/purchase/service/IPurchaseLedgerService.java
+++ b/src/main/java/com/ruoyi/purchase/service/IPurchaseLedgerService.java
@@ -9,6 +9,7 @@
import com.ruoyi.sales.pojo.SalesLedgerProduct;
import org.springframework.web.multipart.MultipartFile;
+import java.util.Date;
import java.util.List;
/**
@@ -39,7 +40,7 @@
IPage<PurchaseLedgerDto> selectPurchaseLedgerListPage(IPage ipage, PurchaseLedgerDto purchaseLedger);
- String getPurchaseNo();
+ String getPurchaseNo(Date entryDate);
AjaxResult importData(MultipartFile file);
diff --git a/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java b/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
index 09d5d20..9cf4d5a 100644
--- a/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
@@ -455,12 +455,13 @@
}
@Override
- public String getPurchaseNo() {
+ public String getPurchaseNo(Date entryDate) {
+ LocalDate localDate = entryDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
// 鐢熸垚鏃ユ湡鍓嶇紑锛堜緥濡傦細CG20250405锛�
- String purchaseNo = "CG" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
+ String purchaseNo = "CG" + localDate.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
// 鏋勫缓 Redis Key锛堟寜澶╁垎闅旓級
- String redisKey = "purchase_no:" + LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE);
+ String redisKey = "purchase_no:" + localDate.format(DateTimeFormatter.ISO_LOCAL_DATE);
// 鑾峰彇褰撳墠搴忓彿骞堕�掑锛堝師瀛愭搷浣滐級
Long sequence = redisTemplate.opsForValue().increment(redisKey);
diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
index 75ee5a6..7b71ef3 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -575,7 +575,7 @@
if (salesLedger.getId() == null) {
String contractNo = salesLedger.getSalesContractNo();
if (StringUtils.isEmpty(contractNo)) {
- contractNo = generateSalesContractNo();
+ contractNo = generateSalesContractNo(salesLedgerDto.getEntryDate());
}
salesLedger.setSalesContractNo(contractNo);
salesLedgerMapper.insert(salesLedger);
@@ -638,8 +638,8 @@
}
@Transactional(readOnly = true)
- public String generateSalesContractNo() {
- LocalDate currentDate = LocalDate.now();
+ public String generateSalesContractNo(Date entryDate) {
+ LocalDate currentDate = entryDate != null ? DateUtils.toLocalDate(entryDate) : LocalDate.now();
String datePart = currentDate.format(DateTimeFormatter.BASIC_ISO_DATE);
String lockKey = LOCK_PREFIX + datePart;
String lockValue = Thread.currentThread().getId() + "-" + System.nanoTime(); // 鍞竴鏍囪瘑閿佹寔鏈夎��
--
Gitblit v1.9.3