From 0100359605ba05638c1f683d68a2948cc273b0d2 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期一, 08 十二月 2025 11:21:29 +0800
Subject: [PATCH] yys  修改设备模块

---
 src/main/java/com/ruoyi/device/controller/DeviceLedgerController.java    |   13 ++++
 src/main/java/com/ruoyi/device/pojo/DeviceLedger.java                    |    4 +
 src/main/java/com/ruoyi/device/service/impl/DeviceLedgerServiceImpl.java |   20 ++++--
 src/main/java/com/ruoyi/device/execl/DeviceLedgerExeclDto.java           |   52 ++++++++++------
 src/main/java/com/ruoyi/device/dto/DeviceLedgerDto.java                  |    4 +
 src/main/resources/application-jyhjCopy.yml                              |    6 +-
 src/main/resources/mapper/device/DeviceLedgerMapper.xml                  |   22 ------
 7 files changed, 70 insertions(+), 51 deletions(-)

diff --git a/src/main/java/com/ruoyi/device/controller/DeviceLedgerController.java b/src/main/java/com/ruoyi/device/controller/DeviceLedgerController.java
index f00595f..66e5e7f 100644
--- a/src/main/java/com/ruoyi/device/controller/DeviceLedgerController.java
+++ b/src/main/java/com/ruoyi/device/controller/DeviceLedgerController.java
@@ -4,7 +4,9 @@
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.device.dto.DeviceLedgerDto;
+import com.ruoyi.device.execl.DeviceLedgerExeclDto;
 import com.ruoyi.device.mapper.DeviceLedgerMapper;
 import com.ruoyi.device.mapper.DeviceMaintenanceMapper;
 import com.ruoyi.device.pojo.DeviceLedger;
@@ -12,6 +14,8 @@
 import com.ruoyi.device.service.IDeviceLedgerService;
 import com.ruoyi.device.service.IDeviceMaintenanceService;
 import com.ruoyi.framework.aspectj.lang.annotation.Anonymous;
+import com.ruoyi.framework.aspectj.lang.annotation.Log;
+import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
 import com.ruoyi.framework.web.domain.AjaxResult;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiModelProperty;
@@ -87,6 +91,7 @@
 
     @PostMapping("import")
     @ApiModelProperty("瀵煎叆璁惧鍙拌处")
+    @Log(title = "璁惧鍙拌处瀵煎叆", businessType = BusinessType.IMPORT)
     public AjaxResult importData(MultipartFile file) throws IOException {
         Boolean b = deviceLedgerService.importData(file);
         if (b) {
@@ -95,6 +100,14 @@
         return AjaxResult.error("瀵煎叆澶辫触");
     }
 
+    @PostMapping("/downloadTemplate")
+    @ApiModelProperty("涓嬭浇瀵煎叆妯℃澘")
+    @Log(title = "璁惧鍙拌处瀵煎叆", businessType = BusinessType.IMPORT)
+    public void downloadTemplate(HttpServletResponse response) {
+        ExcelUtil<DeviceLedgerExeclDto> util = new ExcelUtil<DeviceLedgerExeclDto>(DeviceLedgerExeclDto.class);
+        util.importTemplateExcel(response, "璁惧鍙拌处妯℃澘");
+    }
+
 
     @GetMapping("getDeviceLedger")
     @ApiModelProperty("鑾峰彇璁惧鍙拌处")
diff --git a/src/main/java/com/ruoyi/device/dto/DeviceLedgerDto.java b/src/main/java/com/ruoyi/device/dto/DeviceLedgerDto.java
index 26bdc91..bdc1fcd 100644
--- a/src/main/java/com/ruoyi/device/dto/DeviceLedgerDto.java
+++ b/src/main/java/com/ruoyi/device/dto/DeviceLedgerDto.java
@@ -71,6 +71,10 @@
      */
     private BigDecimal unTaxIncludingPriceTotal;
 
+    private String deviceBrand;
+
+    private String storageLocation;
+
     /**
      * 褰曞叆鏃堕棿
      */
diff --git a/src/main/java/com/ruoyi/device/execl/DeviceLedgerExeclDto.java b/src/main/java/com/ruoyi/device/execl/DeviceLedgerExeclDto.java
index 09c5f40..1335284 100644
--- a/src/main/java/com/ruoyi/device/execl/DeviceLedgerExeclDto.java
+++ b/src/main/java/com/ruoyi/device/execl/DeviceLedgerExeclDto.java
@@ -41,31 +41,31 @@
      * 鏁伴噺
      */
     @Excel(name = "鏁伴噺",sort = 5)
-    private BigDecimal number;
+    private Integer number;
 
     /**
-     * 鍚◣鍗曚环
+     * 璧勪骇鍘熷��
      */
-    @Excel(name = "鍚◣鍗曚环",sort = 6)
+    @Excel(name = "璧勪骇鍘熷��",sort = 6)
     private BigDecimal taxIncludingPriceUnit;
+//
+//    /**
+//     * 鍚◣鎬讳环
+//     */
+//    @Excel(name = "鍚◣鎬讳环",sort = 7)
+//    private BigDecimal taxIncludingPriceTotal;
+//
+//    /**
+//     * 绋庣巼
+//     */
+//    @Excel(name = "绋庣巼",sort = 8)
+//    private BigDecimal taxRate;
 
-    /**
-     * 鍚◣鎬讳环
-     */
-    @Excel(name = "鍚◣鎬讳环",sort = 7)
-    private BigDecimal taxIncludingPriceTotal;
-
-    /**
-     * 绋庣巼
-     */
-    @Excel(name = "绋庣巼",sort = 8)
-    private BigDecimal taxRate;
-
-    /**
-     * 涓嶅惈绋庢�讳环
-     */
-    @Excel(name = "涓嶅惈绋庢�讳环",sort = 9)
-    private BigDecimal unTaxIncludingPriceTotal;
+//    /**
+//     * 涓嶅惈绋庢�讳环
+//     */
+//    @Excel(name = "涓嶅惈绋庢�讳环",sort = 9)
+//    private BigDecimal unTaxIncludingPriceTotal;
 //
 //    /**
 //     * 褰曞叆鏃堕棿
@@ -75,6 +75,18 @@
 //    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
 //    private LocalDateTime createTime;
 
+    /**
+     * 鍗曚綅
+     */
+    @Excel(name = "瀛樻斁鍦扮偣",sort = 7)
+    private String storageLocation;
+
+    /**
+     * 鍗曚綅
+     */
+    @Excel(name = "璁惧鍝佺墝",sort = 8)
+    private String deviceBrand;
+
 
 
     /**
diff --git a/src/main/java/com/ruoyi/device/pojo/DeviceLedger.java b/src/main/java/com/ruoyi/device/pojo/DeviceLedger.java
index caa8f32..6101426 100644
--- a/src/main/java/com/ruoyi/device/pojo/DeviceLedger.java
+++ b/src/main/java/com/ruoyi/device/pojo/DeviceLedger.java
@@ -75,6 +75,10 @@
      */
     private BigDecimal unTaxIncludingPriceTotal;
 
+    private String deviceBrand;
+
+    private String storageLocation;
+
     /**
      * 褰曞叆鏃堕棿
      */
diff --git a/src/main/java/com/ruoyi/device/service/impl/DeviceLedgerServiceImpl.java b/src/main/java/com/ruoyi/device/service/impl/DeviceLedgerServiceImpl.java
index de85cad..10683f8 100644
--- a/src/main/java/com/ruoyi/device/service/impl/DeviceLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/device/service/impl/DeviceLedgerServiceImpl.java
@@ -24,6 +24,7 @@
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.time.ZoneOffset;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -106,15 +107,18 @@
         ExcelUtil<DeviceLedgerExeclDto> util = new ExcelUtil<DeviceLedgerExeclDto>(DeviceLedgerExeclDto.class);
         List<DeviceLedgerExeclDto> userList = util.importExcel(file.getInputStream());
         userList.forEach(c -> {
-            DeviceLedger deviceLedger = new DeviceLedger();
-            SysUser sysUser = sysUserMapper.selectUserByUserName(c.getCreateUser());
-            if (sysUser!=null) {
-                deviceLedger.setCreateUser(sysUser.getUserId().intValue());
-            }else {
-                deviceLedger.setCreateUser(SecurityUtils.getUserId().intValue());
+            for (Integer i = 0; i < c.getNumber(); i++) {
+                DeviceLedger deviceLedger = new DeviceLedger();
+                SysUser sysUser = sysUserMapper.selectUserByUserName(c.getCreateUser());
+                if (sysUser!=null) {
+                    deviceLedger.setCreateUser(sysUser.getUserId().intValue());
+                }else {
+                    deviceLedger.setCreateUser(SecurityUtils.getUserId().intValue());
+                }
+                BeanUtils.copyProperties(c,deviceLedger);
+                deviceLedger.setNumber(new BigDecimal(1));
+                deviceLedgerMapper.insert(deviceLedger);
             }
-            BeanUtils.copyProperties(c,deviceLedger);
-            deviceLedgerMapper.insert(deviceLedger);
         });
 
         return true;
diff --git a/src/main/resources/application-jyhjCopy.yml b/src/main/resources/application-jyhjCopy.yml
index fa3da4b..a288a2f 100644
--- a/src/main/resources/application-jyhjCopy.yml
+++ b/src/main/resources/application-jyhjCopy.yml
@@ -134,10 +134,10 @@
   # redis 閰嶇疆
   redis:
     # 鍦板潃
-#    host: 127.0.0.1
-    host: 192.168.1.185
+    host: 127.0.0.1
+#    host: 192.168.1.185
     # 绔彛锛岄粯璁や负6379
-    port: 6380
+    port: 6379
     # 鏁版嵁搴撶储寮�
     database: 15
     # 瀵嗙爜
diff --git a/src/main/resources/mapper/device/DeviceLedgerMapper.xml b/src/main/resources/mapper/device/DeviceLedgerMapper.xml
index 9cee459..bb5206e 100644
--- a/src/main/resources/mapper/device/DeviceLedgerMapper.xml
+++ b/src/main/resources/mapper/device/DeviceLedgerMapper.xml
@@ -7,26 +7,8 @@
 
     <select id="queryPage" resultType="com.ruoyi.device.dto.DeviceLedgerDto">
         SELECT
-        dl.id,
-        dl.device_name,
-        dl.device_model,
-        dl.supplier_name,
-        dl.unit,
-        dl.number,
-        dl.status,
-        dl.plan_runtime_time,
-        dl.start_runtime_time,
-        dl.end_runtime_time,
-        dl.runtime_duration,
-        dl.tax_including_price_unit,
-        dl.tax_including_price_total,
-        dl.tax_rate,
-        dl.un_tax_including_price_total,
-        dl.create_time,
-        dl.update_time ,
-        su.user_name AS createUser,
-        dl.update_user,
-        dl.tenant_id
+        dl.* ,
+        su.user_name AS createUser
         FROM device_ledger dl
         left join sys_user su on dl.create_user = su.user_id
         <where>

--
Gitblit v1.9.3