From 6233c215047bd2c15512f1f32e42b7a858306882 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期四, 11 九月 2025 15:19:38 +0800
Subject: [PATCH] 权限接口

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java |   61 ++++++++++++++++++++++++------
 1 files changed, 48 insertions(+), 13 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java
index 4ecd195..d81f78a 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java
@@ -8,7 +8,6 @@
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.ruoyi.common.basic.PageInfo;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.R;
@@ -20,21 +19,15 @@
 import com.ruoyi.system.dto.TErpGoodsInfoSaveDto;
 import com.ruoyi.system.dto.TErpGoodsUpdateStatusDto;
 import com.ruoyi.system.importExcel.TErpGoodsExcel;
-import com.ruoyi.system.model.TErpGoods;
-import com.ruoyi.system.model.TErpGoodsType;
-import com.ruoyi.system.model.TErpGoodsUnit;
+import com.ruoyi.system.model.*;
 import com.ruoyi.system.query.TErpGoodsQuery;
-import com.ruoyi.system.service.TErpGoodsService;
-import com.ruoyi.system.service.TErpGoodsTypeService;
-import com.ruoyi.system.service.TErpGoodsUnitService;
+import com.ruoyi.system.service.*;
 import com.ruoyi.system.vo.TErpGoodsVO;
-import com.ruoyi.web.controller.tool.ImportExcelUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.util.StringUtils;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -47,9 +40,10 @@
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.net.URLEncoder;
-import java.text.SimpleDateFormat;
-import java.time.LocalDate;
-import java.util.*;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -70,13 +64,23 @@
     private final TokenService tokenService;
     private final TErpGoodsTypeService erpGoodsTypeService;
     private final TErpGoodsUnitService erpGoodsUnitService;
+    private final TErpSupplierWarehousingBatchService erpSupplierWarehousingBatchService;
+    private final TErpSupplierWarehousingService erpSupplierWarehousingService;
+    private final TErpSupplierOutboundGoodsService erpSupplierOutboundGoodsService;
+    private final TErpMaintenanceReminderService erpMaintenanceReminderService;
 
     @Autowired
-    public TErpGoodsController(TErpGoodsService erpGoodsService, TokenService tokenService, TErpGoodsTypeService erpGoodsTypeService, TErpGoodsUnitService erpGoodsUnitService) {
+    public TErpGoodsController(TErpGoodsService erpGoodsService, TokenService tokenService, TErpGoodsTypeService erpGoodsTypeService, TErpGoodsUnitService erpGoodsUnitService,
+                               TErpSupplierWarehousingBatchService erpSupplierWarehousingBatchService, TErpSupplierWarehousingService erpSupplierWarehousingService,
+                               TErpSupplierOutboundGoodsService erpSupplierOutboundGoodsService, TErpMaintenanceReminderService erpMaintenanceReminderService) {
         this.erpGoodsService = erpGoodsService;
         this.tokenService = tokenService;
         this.erpGoodsTypeService = erpGoodsTypeService;
         this.erpGoodsUnitService = erpGoodsUnitService;
+        this.erpSupplierWarehousingBatchService = erpSupplierWarehousingBatchService;
+        this.erpSupplierWarehousingService = erpSupplierWarehousingService;
+        this.erpSupplierOutboundGoodsService = erpSupplierOutboundGoodsService;
+        this.erpMaintenanceReminderService = erpMaintenanceReminderService;
     }
 
 
@@ -140,8 +144,39 @@
     @ApiOperation(value = "供应商完善商品")
     @PostMapping(value = "/saveDataInfo")
     public R<Boolean> saveDataInfo(@RequestBody @Valid TErpGoodsInfoSaveDto dto) {
+        SysUser user = tokenService.getLoginUser().getUser();
         TErpGoods goods = erpGoodsService.getById(dto.getId());
         BeanUtils.copyProperties(dto,goods);
+        if(goods.getMaintenanceInterval()!=null){
+
+            List<TErpSupplierWarehousing> list = erpSupplierWarehousingService.list(new LambdaQueryWrapper<TErpSupplierWarehousing>().eq(TErpSupplierWarehousing::getGoodsId, dto.getId()));
+            if(!list.isEmpty()){
+                List<TErpSupplierWarehousingBatch> tErpSupplierWarehousingBatches = erpSupplierWarehousingBatchService.list(new LambdaQueryWrapper<TErpSupplierWarehousingBatch>().in(TErpSupplierWarehousingBatch::getWarehousingId, list.stream().map(TErpSupplierWarehousing::getId).collect(Collectors.toList())));
+                for (TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch : tErpSupplierWarehousingBatches) {
+                    List<TErpSupplierOutboundGoods> list1 = erpSupplierOutboundGoodsService.list(new LambdaQueryWrapper<TErpSupplierOutboundGoods>().eq(TErpSupplierOutboundGoods::getWarehousingBatchId, tErpSupplierWarehousingBatch.getId()));
+                    if(!list1.isEmpty()){
+                        int sum = list1.stream().mapToInt(TErpSupplierOutboundGoods::getOutboundCount).sum();
+                        if (tErpSupplierWarehousingBatch.getWarehousingNumber()-sum>0) {
+                            // 生成保养单
+                            TErpMaintenanceReminder tErpMaintenanceReminder = new TErpMaintenanceReminder();
+                            tErpMaintenanceReminder.setClinicSupplierId(user.getUserId().toString());
+                            tErpMaintenanceReminder.setMaintenanceType(1);
+                            tErpMaintenanceReminder.setWarehousingBatchId(tErpSupplierWarehousingBatch.getId());
+                            Integer day = Integer.valueOf(goods.getMaintenanceInterval());
+                            // 当前时间+day天
+                            LocalDateTime time1 = LocalDateTime.now().plusDays(day);
+                            tErpMaintenanceReminder.setMaintenanceTime(time1);
+                            erpMaintenanceReminderService.save(tErpMaintenanceReminder);
+                        }
+                    }
+
+                }
+
+            }
+
+        }
+
+
         return R.ok(erpGoodsService.updateById(goods));
     }
 

--
Gitblit v1.7.1