Quellcode durchsuchen

优化位置二维码修改刷新

LinWuTai vor 1 Jahr
Ursprung
Commit
9ff3658ce2

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/asset/controller/TbLocationController.java

@@ -127,7 +127,7 @@ public class TbLocationController extends BaseController
      * 查看位置二维码
      */
     @GetMapping(value = "/code/{number}", produces = MediaType.IMAGE_PNG_VALUE)
-    public byte[] selectQrCode(@PathVariable("number") String locationNumber) {
+    public byte[] selectQrCode(@PathVariable("number") String locationNumber, @RequestParam("v") String v) {
         return tbLocationService.selectQrCodeByLocationNumber(locationNumber);
     }
 

+ 19 - 3
ruoyi-admin/src/main/java/com/ruoyi/asset/service/impl/TbLocationServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ruoyi.asset.service.impl;
 
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -13,6 +14,7 @@ import com.ruoyi.common.code.QrDTO;
 import com.ruoyi.common.core.domain.TreeSelect;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.FileUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -29,6 +31,7 @@ import javax.annotation.Resource;
  * @author 原动力
  * @date 2023-05-15
  */
+@Slf4j
 @Service
 public class TbLocationServiceImpl implements ITbLocationService 
 {
@@ -201,7 +204,10 @@ public class TbLocationServiceImpl implements ITbLocationService
             String fileUrl = getFileUrl(tbLocation.getNumber());
             File file = new File(fileUrl);
             if (file.isFile() && file.exists()) {
-                file.delete();
+                boolean delete = file.delete();
+                if (!delete) {
+                    System.out.println(tbLocation.getNumber()+"位置二维码删除失败,目标路径:\n"+fileUrl);
+                }
             }
         }
         return result;
@@ -295,14 +301,24 @@ public class TbLocationServiceImpl implements ITbLocationService
             createQrCodeDataByLocation(location);
         }
         byte[] bytes = new byte[0];
+        FileInputStream fileInputStream = null;
         try {
-            FileInputStream fileInputStream = new FileInputStream(file);
+            fileInputStream = new FileInputStream(file);
             bytes = new byte[fileInputStream.available()];
             fileInputStream.read(bytes, 0, fileInputStream.available());
         } catch (Exception e) {
             e.printStackTrace();
+        } finally {
+            if (fileInputStream != null) {
+                try {
+                    fileInputStream.close(); // 关闭文件输入流
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
         }
-        return bytes;
+
+         return bytes;
     }
 
     @Override

+ 1 - 1
ruoyi-admin/src/main/resources/application-druid.yml

@@ -7,7 +7,7 @@ spring:
             # 主库数据源
             master:
                 #url: jdbc:mysql://139.9.50.163:3306/rfid-hotel-manager?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
-                url: jdbc:mysql://192.168.1.250:3306/rfid-hotel-manager?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                url: jdbc:mysql://127.0.0.1:3306/rfid-hotel-manager?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
                 password: mysql@123456
                 username: root
             # 从库数据源

+ 2 - 2
ruoyi-ui/src/api/asset/location.js

@@ -66,6 +66,6 @@ export function delLocation(id) {
   })
 }
 
-export function selectQrCode(number) {
-  return '/asset/location/code/' + number
+export function selectQrCode(number, v) {
+  return `/asset/location/code/${number}?v=${v}`
 }

+ 56 - 56
ruoyi-ui/src/views/asset/information/index.vue

@@ -1,12 +1,12 @@
 <template>
   <div class="app-container">
-    <el-form :model="queryParams" ref="queryForm" class="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
-      <el-form-item label="资产条码" prop="code">
-        <el-input v-model="queryParams.code" placeholder="请输入资产条码" clearable @keyup.enter.native="handleQuery" />
-      </el-form-item>
+    <el-form :model="queryParams" ref="queryForm" class="queryForm" size="small" :inline="true" v-show="showSearch" label-width="110px">
       <el-form-item label="资产名称" prop="name">
         <el-input v-model="queryParams.name" placeholder="请输入资产名称" clearable @keyup.enter.native="handleQuery" />
       </el-form-item>
+      <el-form-item label="资产条码" prop="code">
+        <el-input v-model="queryParams.code" placeholder="请输入资产条码" clearable @keyup.enter.native="handleQuery" />
+      </el-form-item>
       <el-form-item label="资产编号" prop="number">
         <el-input v-model="queryParams.number" placeholder="请输入资产编号" clearable @keyup.enter.native="handleQuery" />
       </el-form-item>
@@ -15,45 +15,61 @@
           <el-option v-for="item in categoryList" :key="item.number" :label="item.name" :value="item.number"></el-option>
         </el-select>
       </el-form-item>
+      <el-form-item label="所在位置" prop="locationNumber">
+        <treeselect v-model="queryParams.locationNumber" :options="locationList" :normalizer="tenantIdnormalizer" placeholder="选择位置" />
+      </el-form-item> 
       <el-form-item label="使用部门" prop="userDepartment">
         <div style="display: inline-block; width: 183px">
           <treeselect v-model="queryParams.userDepartment" :options="deptOptions" :normalizer="normalizer" placeholder="选择使用部门" />
         </div>
       </el-form-item>
-      <el-form-item v-if="isExist('管理部门')"  label="管理部门" prop="department">
-        <div style="display: inline-block; width: 183px">
-          <treeselect v-model="queryParams.department" :options="deptOptions" :normalizer="normalizer" placeholder="选择管理部门" />
-        </div>
+      <el-form-item label="EPC" prop="epc" v-if="isExist('epc')">
+        <el-input
+          v-model="queryParams.epc"
+          placeholder="请输入EPC"
+          clearable
+          @keyup.enter.native="handleQuery"
+        />
       </el-form-item>
-      <el-form-item label="所在位置" prop="locationNumber">
-        <treeselect v-model="queryParams.locationNumber" :options="locationList" :normalizer="tenantIdnormalizer" placeholder="选择位置" />
+      <el-form-item label="开始使用日期" prop="startDate" v-if="isExist('开始使用日期')">
+        <el-input
+          v-model="queryParams.startDate"
+          placeholder="请输入开始使用日期"
+          clearable
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item> 
+      <el-form-item v-if="isExist('责任人')" label="责任人" prop="responsiblePerson">
+        <el-input v-model="queryParams.responsiblePerson" placeholder="请输入责任人" clearable @keyup.enter.native="handleQuery" />
       </el-form-item>
       <el-form-item v-if="isExist('所属公司')"  label="所属公司" prop="corporation">
         <div style="display: inline-block; width: 183px">
           <treeselect v-model="queryParams.corporation" :options="deptOptions" :normalizer="normalizer" placeholder="选择所属公司" />
         </div>
       </el-form-item>
-      <el-form-item v-if="isExist('入账时间')" label="入账时间" prop="paymentReceivingTime">
-        <el-date-picker clearable v-model="queryParams.paymentReceivingTime" type="date" value-format="yyyy-MM-dd" placeholder="请选择入账时间"> </el-date-picker>
+      <el-form-item v-if="isExist('管理部门')"  label="管理部门" prop="department">
+        <div style="display: inline-block; width: 183px">
+          <treeselect v-model="queryParams.department" :options="deptOptions" :normalizer="normalizer" placeholder="选择管理部门" />
+        </div>
       </el-form-item>
-      <el-form-item v-if="isExist('管理状态')" label="管理状态" prop="manageStatus">
-        <el-select v-model="queryParams.manageStatus" placeholder="请选择管理状态" clearable>
-          <el-option v-for="dict in dict.type.sys_manger_status" :key="dict.value" :label="dict.label" :value="dict.value" />
-        </el-select>
+      <el-form-item v-if="isExist('规格型号')" label="规格型号" prop="specificationsModel">
+        <el-input v-model="queryParams.specificationsModel" placeholder="请输入规格型号" clearable @keyup.enter.native="handleQuery" />
+      </el-form-item>
+      <el-form-item v-if="isExist('ABC分类')" label="ABC分类" prop="abcCategory">
+        <el-input v-model="queryParams.abcCategory" placeholder="请输入ABC分类" clearable @keyup.enter.native="handleQuery" />
       </el-form-item>
       <el-form-item v-if="isExist('资产性质')" label="资产性质" prop="property">
         <el-select v-model="queryParams.property" placeholder="请选择资产性质" clearable>
           <el-option v-for="dict in dict.type.sys_asset_property" :key="dict.value" :label="dict.label" :value="dict.value" />
         </el-select>
       </el-form-item>
-      <el-form-item v-if="isExist('规格型号')" label="规格型号" prop="specificationsModel">
-        <el-input v-model="queryParams.specificationsModel" placeholder="请输入规格型号" clearable @keyup.enter.native="handleQuery" />
-      </el-form-item>
-      <el-form-item v-if="isExist('ABC分类')" label="ABC分类" prop="abcCategory">
-        <el-input v-model="queryParams.abcCategory" placeholder="请输入ABC分类" clearable @keyup.enter.native="handleQuery" />
+      <el-form-item v-if="isExist('管理状态')" label="管理状态" prop="manageStatus">
+        <el-select v-model="queryParams.manageStatus" placeholder="请选择管理状态" clearable>
+          <el-option v-for="dict in dict.type.sys_manger_status" :key="dict.value" :label="dict.label" :value="dict.value" />
+        </el-select>
       </el-form-item>
-      <el-form-item v-if="isExist('责任人')" label="责任人" prop="responsiblePerson">
-        <el-input v-model="queryParams.responsiblePerson" placeholder="请输入责任人" clearable @keyup.enter.native="handleQuery" />
+      <el-form-item v-if="isExist('入账时间')" label="入账时间" prop="paymentReceivingTime">
+        <el-date-picker clearable v-model="queryParams.paymentReceivingTime" type="date" value-format="yyyy-MM-dd" placeholder="请选择入账时间"> </el-date-picker>
       </el-form-item>
       <el-form-item v-if="isExist('购置日期')" label="购置日期" prop="purchaseDate">
         <el-date-picker clearable v-model="queryParams.purchaseDate" type="date" value-format="yyyy-MM-dd" placeholder="请选择购置日期"> </el-date-picker>
@@ -61,27 +77,27 @@
       <el-form-item v-if="isExist('启用日期')" label="启用日期" prop="commissioningDate">
         <el-date-picker clearable v-model="queryParams.commissioningDate" type="date" value-format="yyyy-MM-dd" placeholder="请选择启用日期"> </el-date-picker>
       </el-form-item>
-      <el-form-item v-if="isExist('原值')" label="原值" prop="originalValue">
-        <el-input v-model="queryParams.originalValue" placeholder="请输入原值" clearable @keyup.enter.native="handleQuery" />
-      </el-form-item>
       <el-form-item v-if="isExist('使用年限')" label="使用年限" prop="durableYears">
         <el-input v-model="queryParams.durableYears" placeholder="请输入使用年限" clearable @keyup.enter.native="handleQuery" />
       </el-form-item>
+      <el-form-item v-if="isExist('原值')" label="原值" prop="originalValue">
+        <el-input v-model="queryParams.originalValue" placeholder="请输入原值" clearable @keyup.enter.native="handleQuery" />
+      </el-form-item>
       <el-form-item v-if="isExist('净值')" label="净值" prop="netValue">
         <el-input v-model="queryParams.netValue" placeholder="请输入净值" clearable @keyup.enter.native="handleQuery" />
       </el-form-item>
       <el-form-item v-if="isExist('残值')" label="残值" prop="residualValue">
         <el-input v-model="queryParams.residualValue" placeholder="请输入残值" clearable @keyup.enter.native="handleQuery" />
       </el-form-item>
+      <el-form-item v-if="isExist('折旧方式')" label="折旧方式" prop="depreciationMethod">
+        <el-input v-model="queryParams.depreciationMethod" placeholder="请输入折旧方式" clearable @keyup.enter.native="handleQuery" />
+      </el-form-item>
       <el-form-item v-if="isExist('累计折旧')" label="累计折旧" prop="accumulatedDepreciation">
         <el-input v-model="queryParams.accumulatedDepreciation" placeholder="请输入累计折旧" clearable @keyup.enter.native="handleQuery" />
       </el-form-item>
       <el-form-item v-if="isExist('最近折旧日期')" label="最近折旧日期" prop="lastDepreciationDate">
         <el-date-picker clearable v-model="queryParams.lastDepreciationDate" type="date" value-format="yyyy-MM-dd" placeholder="请选择最近折旧日期"> </el-date-picker>
       </el-form-item>
-      <el-form-item v-if="isExist('折旧方式')" label="折旧方式" prop="depreciationMethod">
-        <el-input v-model="queryParams.depreciationMethod" placeholder="请输入折旧方式" clearable @keyup.enter.native="handleQuery" />
-      </el-form-item>
       <el-form-item v-if="isExist('合同编号')" label="合同编号" prop="contractNumber">
         <el-input v-model="queryParams.contractNumber" placeholder="请输入合同编号" clearable @keyup.enter.native="handleQuery" />
       </el-form-item>
@@ -129,30 +145,14 @@
           @keyup.enter.native="handleQuery"
         />
       </el-form-item> -->
-      <el-form-item label="EPC" prop="epc" v-if="isExist('epc')">
-        <el-input
-          v-model="queryParams.epc"
-          placeholder="请输入epc"
-          clearable
-          @keyup.enter.native="handleQuery"
-        />
-      </el-form-item>
       <!-- <el-form-item label="epc补充长度" prop="epcReplenishLength">
         <el-input
           v-model="queryParams.epcReplenishLength"
-          placeholder="请输入epc补充长度"
+          placeholder="请输入EPC补充长度"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item> -->
-      <el-form-item label="开始使用日期" prop="startDate">
-        <el-input
-          v-model="queryParams.startDate"
-          placeholder="请输入开始使用日期"
-          clearable
-          @keyup.enter.native="handleQuery"
-        />
-      </el-form-item>
       <!-- <el-form-item label="预计使用期限" prop="lifeExpectancy">
         <el-input
           v-model="queryParams.lifeExpectancy"
@@ -565,10 +565,10 @@
           <el-input v-model="form.code" placeholder="请输入资产条码" />
         </el-form-item> -->
         <!-- <el-form-item label="epc" prop="epc">
-          <el-input v-model="form.epc" placeholder="请输入epc" />
+          <el-input v-model="form.epc" placeholder="请输入EPC" />
         </el-form-item>
         <el-form-item label="epc补充长度" prop="epcReplenishLength">
-          <el-input v-model="form.epcReplenishLength" placeholder="请输入epc补充长度" />
+          <el-input v-model="form.epcReplenishLength" placeholder="请输入EPC补充长度" />
         </el-form-item> -->
         <!-- <el-form-item label="预留字段j" prop="reservedColumnJ">
           <el-input v-model="form.reservedColumnJ" placeholder="请输入预留字段j" />
@@ -583,7 +583,8 @@
       <template>
         <div>
           <el-checkbox-group v-model="checkList" mini>
-            <el-checkbox label="管理状态" border></el-checkbox>
+            <el-checkbox label="epc" border></el-checkbox>
+            <el-checkbox label="资产条码" border></el-checkbox>
             <el-checkbox label="资产性质" border></el-checkbox>
             <el-checkbox label="规格型号" border></el-checkbox>
             <el-checkbox label="ABC分类" border></el-checkbox>
@@ -594,9 +595,9 @@
             <el-checkbox label="原值" border></el-checkbox>
             <el-checkbox label="净值" border></el-checkbox>
             <el-checkbox label="残值" border></el-checkbox>
+            <el-checkbox label="折旧方式" border></el-checkbox>
             <el-checkbox label="累计折旧" border></el-checkbox>
             <el-checkbox label="最近折旧日期" border></el-checkbox>
-            <el-checkbox label="折旧方式" border></el-checkbox>
             <el-checkbox label="合同编号" border></el-checkbox>
             <el-checkbox label="出厂编号" border></el-checkbox>
             <el-checkbox label="制造商" border></el-checkbox>
@@ -604,17 +605,16 @@
             <el-checkbox label="维保到期日期" border></el-checkbox>
             <el-checkbox label="维修电话" border></el-checkbox>
             <el-checkbox label="维修人员" border></el-checkbox>
-            <el-checkbox label="记录状态" border></el-checkbox>
-            <el-checkbox label="是否白名单" border></el-checkbox>
-            <el-checkbox label="资产条码" border></el-checkbox>
-            <el-checkbox label="备注" border></el-checkbox>
-            <el-checkbox label="epc" border></el-checkbox>
             <el-checkbox label="入账时间" border></el-checkbox>
             <el-checkbox label="开始使用日期" border></el-checkbox>
             <el-checkbox label="预计使用期限" border></el-checkbox>
             <el-checkbox label="预计使用期限单位" border></el-checkbox>
-            <el-checkbox label="管理部门" border></el-checkbox>
             <el-checkbox label="所属公司" border></el-checkbox>
+            <el-checkbox label="管理部门" border></el-checkbox>
+            <el-checkbox label="记录状态" border></el-checkbox>
+            <el-checkbox label="是否白名单" border></el-checkbox>
+            <el-checkbox label="管理状态" border></el-checkbox>
+            <el-checkbox label="备注" border></el-checkbox>
           </el-checkbox-group>
         </div>
       </template>

+ 1 - 1
ruoyi-ui/src/views/asset/location/index.vue

@@ -179,7 +179,7 @@ export default {
       return sequence.split(',').length
     },
     getCode(number) {
-      return selectQrCode(number)
+      return selectQrCode(number, Math.random())
     },
     // 取消按钮
     cancel() {