From a2599e2fffaf6bb1d781325736f06955fa19511b Mon Sep 17 00:00:00 2001
From: tuqin <tuqin@tuqin.cn>
Date: 星期三, 21 十月 2026 15:24:59 +0800
Subject: [PATCH] fix(芯导): 补回各系统丢失的既有文件修改(分支切换导致)
---
src/main/java/com/ruoyi/procurementrecord/controller/CustomStorageWarningRecordController.java | 66 ++++++++++++++++++++++++++++++++
1 files changed, 65 insertions(+), 1 deletions(-)
diff --git a/src/main/java/com/ruoyi/procurementrecord/controller/CustomStorageWarningRecordController.java b/src/main/java/com/ruoyi/procurementrecord/controller/CustomStorageWarningRecordController.java
index 5dabd7a..063e87e 100644
--- a/src/main/java/com/ruoyi/procurementrecord/controller/CustomStorageWarningRecordController.java
+++ b/src/main/java/com/ruoyi/procurementrecord/controller/CustomStorageWarningRecordController.java
@@ -9,6 +9,15 @@
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import java.util.Map;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import com.ruoyi.procurementrecord.pojo.CustomStorageWarningRecord;
+import com.ruoyi.procurementrecord.pojo.CustomStorage;
+import com.ruoyi.procurementrecord.mapper.CustomStorageWarningRecordMapper;
+import com.ruoyi.procurementrecord.mapper.CustomStorageMapper;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -20,10 +29,65 @@
@Autowired
private CustomStorageWarningRecordService customStorageWarningRecordService;
+ @Autowired
+ private CustomStorageWarningRecordMapper warningRecordMapper;
+
+ @Autowired
+ private CustomStorageMapper customStorageMapper;
+
@GetMapping("/pageList")
@Log(title = "浠撳偍鐗╂祦-搴撳瓨棰勮-鍒嗛〉鏌ヨ", businessType = BusinessType.OTHER)
public AjaxResult pageList(Page page, ProcurementPageDto dto){
return AjaxResult.success(customStorageWarningRecordService.listPage(page,dto));
}
-}
+ /**
+ * 鐢熸垚閲囪喘寤鸿 / 婊為攢澶勭悊鎻愮ず锛堝苟璁板綍鍒伴璀︿簨浠讹級
+ */
+ @PostMapping("/generateSuggestion")
+ @Log(title = "浠撳偍鐗╂祦-搴撳瓨棰勮-鐢熸垚寤鸿", businessType = BusinessType.UPDATE)
+ public AjaxResult generateSuggestion(@RequestBody Map<String, Object> body) {
+ Object idObj = body.get("id");
+ if (idObj == null) return AjaxResult.error("鍙傛暟涓嶈兘涓虹┖");
+ String type = body.get("type") == null ? "閲囪喘寤鸿" : body.get("type").toString();
+ Long targetId = Long.valueOf(idObj.toString());
+ CustomStorageWarningRecord record = warningRecordMapper.selectById(targetId);
+ if (record == null) {
+ com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<CustomStorageWarningRecord> w =
+ new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<>();
+ w.eq(CustomStorageWarningRecord::getCustomStorageId, targetId.intValue()).last("limit 1");
+ record = warningRecordMapper.selectOne(w);
+ }
+ if (record == null) {
+ record = new CustomStorageWarningRecord();
+ record.setCustomStorageId(targetId.intValue());
+ record.setWarningStatus("宸查璀�");
+ record.setWarningTime(LocalDateTime.now());
+ try {
+ record.setTenantId(com.ruoyi.common.utils.SecurityUtils.getLoginUser().getTenantId());
+ } catch (Exception ignored) {
+ }
+ warningRecordMapper.insert(record);
+ }
+ CustomStorage storage = record.getCustomStorageId() == null ? null : customStorageMapper.selectById(record.getCustomStorageId());
+ String product = storage == null ? "鏈煡鍟嗗搧"
+ : (storage.getProductCategory() == null ? "" : storage.getProductCategory())
+ + (storage.getSpecificationModel() == null ? "" : " " + storage.getSpecificationModel());
+ BigDecimal current = (storage == null || storage.getInboundNum() == null) ? BigDecimal.ZERO : storage.getInboundNum();
+ BigDecimal warn = storage == null ? null : storage.getWarnNum();
+ String content;
+ if (type.contains("閲囪喘")) {
+ BigDecimal suggest = (warn == null ? BigDecimal.ZERO : warn).subtract(current);
+ if (suggest.compareTo(BigDecimal.ZERO) <= 0) suggest = BigDecimal.valueOf(10);
+ content = String.format("銆愰噰璐缓璁��%s 褰撳墠搴撳瓨 %s锛屾渶浣庡簱瀛橀槇鍊� %s锛屽缓璁噰璐� %s锛堝缓璁粨鍚堣繎30澶╂秷鑰楅噺琛ヨ揣锛�",
+ product, current.toPlainString(), warn == null ? "-" : warn.toPlainString(), suggest.toPlainString());
+ } else {
+ content = String.format("銆愭粸閿�澶勭悊鎻愮ず銆�%s 褰撳墠搴撳瓨 %s锛屽懆杞紦鎱�/搴撳瓨鍋忛珮锛屽缓璁細鈶犱績閿�鎴栧唴閮ㄩ鐢� 鈶¤浆浣滃叾浠栫敤閫� 鈶笌渚涘簲鍟嗗崗鍟嗛��鎹㈣揣",
+ product, current.toPlainString());
+ }
+ record.setSuggestionType(type);
+ record.setSuggestionContent(content);
+ record.setSuggestionTime(LocalDateTime.now());
+ warningRecordMapper.updateById(record);
+ return AjaxResult.success(content);
+ }}
--
Gitblit v1.9.3