Prechádzať zdrojové kódy

优化资产资产信息新增epc逻辑

LinWuTai 1 rok pred
rodič
commit
6506777364

+ 22 - 0
ruoyi-admin/src/main/java/com/ruoyi/asset/domain/TbAssetInformation.java

@@ -6,6 +6,7 @@ import cn.hutool.core.util.CharsetUtil;
 import cn.hutool.core.util.HexUtil;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ruoyi.asset.domain.dto.AssetEpcInfo;
+import com.ruoyi.common.utils.MyUtils;
 import lombok.*;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
@@ -49,6 +50,9 @@ public class TbAssetInformation extends BaseEntity
     /** epc补充长度 */
     private Integer epcReplenishLength;
 
+    /** ecp前置补充 */
+    private String epcPreSupplement;
+
     /** 图片路径 */
 //    @Excel(name = "图片路径")
     private String imageUrl;
@@ -265,8 +269,17 @@ public class TbAssetInformation extends BaseEntity
         // 将epc大写
         epc = epc.toUpperCase();
 
+        int epcLength = epc.length();
+        String epcPre = "";
+        // 判断epc长度是否超过24位
+        if (epcLength > 24) {
+            epcPre = epc.substring(0, epcLength - 24);
+            epc = epc.substring(epcLength - 24);
+        }
+
         setEpc(epc);
         setEpcReplenishLength(epcReplenishLength);
+        setEpcPreSupplement(epcPre);
     }
 
     /**
@@ -308,6 +321,7 @@ public class TbAssetInformation extends BaseEntity
             assetEpcInfo.setNumber(number);
             assetEpcInfo.setEpc(epc);
             assetEpcInfo.setEpcReplenishLength(epcReplenishLength);
+            assetEpcInfo.setEpcPreSupplement(epcPreSupplement);
 
             assetEpcInfos.add(assetEpcInfo);
 
@@ -333,9 +347,17 @@ public class TbAssetInformation extends BaseEntity
 
             // 将epc大写
             epc = epc.toUpperCase();
+            int epcLength = epc.length();
+            String epcPre = "";
+            // 判断epc长度是否超过24位
+            if (epcLength > 24) {
+                epcPre = epc.substring(0, epcLength - 24);
+                epc = epc.substring(epcLength - 24);
+            }
 
             assetEpcInfo.setEpc(epc);
             assetEpcInfo.setEpcReplenishLength(epcReplenishLength);
+            assetEpcInfo.setEpcPreSupplement(epcPre);
 
             assetEpcInfos.add(assetEpcInfo);
         }

+ 2 - 0
ruoyi-admin/src/main/java/com/ruoyi/asset/domain/dto/AssetEpcInfo.java

@@ -10,4 +10,6 @@ public class AssetEpcInfo {
     private String epc;
 
     private Integer epcReplenishLength;
+
+    private String epcPreSupplement;
 }

+ 1 - 0
ruoyi-admin/src/main/java/com/ruoyi/asset/service/impl/TbAssetInformationServiceImpl.java

@@ -167,6 +167,7 @@ public class TbAssetInformationServiceImpl implements ITbAssetInformationService
             tbAssetInformation.setLocationNumber(null);
         }
         tbAssetInformation.setEpcInfo();
+        tbAssetInformation.setChildNumberInfo();
 
         tbAssetInformation.setUpdateTime(DateUtils.getNowDate());
         return tbAssetInformationMapper.updateTbAssetInformation(tbAssetInformation);

+ 4 - 5
ruoyi-admin/src/main/java/com/ruoyi/inventory/controller/TbAssetInventoryController.java

@@ -178,11 +178,11 @@ public class TbAssetInventoryController extends BaseController
      * @return
      */
     @GetMapping("/getDepAssetLossTb")
-    public AjaxResult getDepAssetLossTb(String depId){
+    public AjaxResult getDepAssetLossTb(String deptId){
 
         List<DepAssetLossResultDto> result = null;
         try {
-            result = tbAssetInventoryService.inventoryDepAssetById(depId);
+            result = tbAssetInventoryService.inventoryDepAssetById(deptId);
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -190,11 +190,10 @@ public class TbAssetInventoryController extends BaseController
     }
 
     @PostMapping("/exportDepAssetLossTb/{deptId}")
-    public void exportDepAssetLossTb(HttpServletResponse response, @RequestParam String deptId){
-
+    public void exportDepAssetLossTb(HttpServletResponse response, @PathVariable String deptId){
         List<DepAssetLossResultDto> result = null;
         try {
-            result = tbAssetInventoryService.inventoryDepAssetById(depId);
+            result = tbAssetInventoryService.inventoryDepAssetById(deptId);
         } catch (Exception e) {
             e.printStackTrace();
         }

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/inventory/service/impl/TbAssetInventoryServiceImpl.java

@@ -485,7 +485,7 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
 
         List<String> childDeptIdList = tbAssetInventoryMapper.getChildDeptId(depId);
         if(childDeptIdList == null || childDeptIdList.size()==0){
-            throw new Exception("不存在该部门id");
+            throw new RuntimeException("不存在该部门id");
         }
         List<DepAssetLossResultDto> resultDtoList = new ArrayList<>();
         //历史盘点计划编码和日期

+ 8 - 1
ruoyi-admin/src/main/resources/mapper/asset/TbAssetInformationMapper.xml

@@ -49,13 +49,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="paymentReceivingTime"    column="payment_receiving_time"    />
         <result property="epc"    column="epc"    />
         <result property="epcReplenishLength"    column="epc_replenish_length"    />
+        <result property="epcPreSupplement" column="epc_pre_supplement" />
         <result property="lifeExpectancy"    column="life_expectancy"    />
         <result property="lifeUnits"    column="life_units"    />
         <result property="startDate"    column="start_date"    />
     </resultMap>
 
     <sql id="selectTbAssetInformationVo">
-        select id, code, name, number, image_url, category_number, specifications_model, abc_category, manage_status, user_department, department, responsible_person, location_number, property, purchase_date, commissioning_date, original_value, durable_years, net_value, residual_value, accumulated_depreciation, last_depreciation_date, depreciation_method, contract_number, factory_number, manufacturer, supplier, purpose, maintenance_date, maintenance_tel, maintenance_user, corporation, record_status, remark, create_by, create_time, update_by, update_time, is_whitelist, quantity, units, payment_receiving_time, epc, epc_replenish_length, life_expectancy, life_units, start_date from tb_asset_information
+        select id, code, name, number, image_url, category_number, specifications_model, abc_category, manage_status, user_department, department, responsible_person, location_number, property, purchase_date, commissioning_date, original_value, durable_years, net_value, residual_value, accumulated_depreciation, last_depreciation_date, depreciation_method, contract_number, factory_number, manufacturer, supplier, purpose, maintenance_date, maintenance_tel, maintenance_user, corporation, record_status, remark, create_by, create_time, update_by, update_time, is_whitelist, quantity, units, payment_receiving_time, epc, epc_replenish_length, epc_pre_supplement, life_expectancy, life_units, start_date from tb_asset_information
     </sql>
 
     <sql id="selectTbAssetInformation">
@@ -101,6 +102,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             a.payment_receiving_time paymentReceivingTime,
             a.epc,
             a.epc_replenish_length epcReplenishLength,
+            a.epc_pre_supplement epcPreSupplement,
             a.life_expectancy lifeExpectancy,
             a.life_units lifeUnits,
             a.start_date startDate,
@@ -171,6 +173,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             a.payment_receiving_time paymentReceivingTime,
             a.epc,
             a.epc_replenish_length epcReplenishLength,
+            a.epc_pre_supplement epcPreSupplement,
             a.life_expectancy lifeExpectancy,
             a.life_units lifeUnits,
             a.start_date startDate,
@@ -291,6 +294,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="paymentReceivingTime != null"> and a.payment_receiving_time = #{paymentReceivingTime}</if>
             <if test="epc != null  and epc != ''"> and a.epc = #{epc}</if>
             <if test="epcReplenishLength != null"> and a.epc_replenish_length = #{epcReplenishLength}</if>
+            <if test="epcPreSupplement != null">and a.epc_pre_supplement = #{epcPreSupplement}</if>
             <if test="lifeExpectancy != null"> and a.life_expectancy = #{lifeExpectancy}</if>
             <if test="lifeUnits != null  and lifeUnits != ''"> and a.life_units = #{lifeUnits}</if>
             <if test="startDate != null"> and a.start_date = #{startDate}</if>
@@ -408,6 +412,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="paymentReceivingTime != null">payment_receiving_time,</if>
             <if test="epc != null">epc,</if>
             <if test="epcReplenishLength != null">epc_replenish_length,</if>
+            <if test="epcPreSupplement != null">epc_pre_supplement,</if>
             <if test="lifeExpectancy != null">life_expectancy,</if>
             <if test="lifeUnits != null">life_units,</if>
             <if test="startDate != null">start_date,</if>
@@ -456,6 +461,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="paymentReceivingTime != null">#{paymentReceivingTime},</if>
             <if test="epc != null">#{epc},</if>
             <if test="epcReplenishLength != null">#{epcReplenishLength},</if>
+            <if test="epcPreSupplement != null">#{epcPreSupplement},</if>
             <if test="lifeExpectancy != null">#{lifeExpectancy},</if>
             <if test="lifeUnits != null">#{lifeUnits},</if>
             <if test="startDate != null">#{startDate},</if>
@@ -508,6 +514,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="paymentReceivingTime != null">payment_receiving_time = #{paymentReceivingTime},</if>
             <if test="epc != null">epc= #{epc},</if>
             <if test="epcReplenishLength != null">epc_replenish_length = #{epcReplenishLength},</if>
+            <if test="epcPreSupplement != null">epc_pre_supplement = #{epcPreSupplement},</if>
             <if test="lifeExpectancy != null">life_expectancy = #{lifeExpectancy},</if>
             <if test="lifeUnits != null">life_units = #{lifeUnits},</if>
             <if test="startDate != null">start_date = #{startDate},</if>

+ 15 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/MyUtils.java

@@ -46,4 +46,19 @@ public class MyUtils {
         }
         return StrUtil.subBetweenAll(str, "${", "}");
     }
+
+    /**
+     * 判断是否可转为Int类型
+     *
+     * @param str 字符串
+     * @return 布尔值
+     */
+    public static boolean isConvertibleToInt(String str) {
+        try {
+            Integer.parseInt(str);
+            return true;
+        } catch (NumberFormatException e) {
+            return false;
+        }
+    }
 }

+ 1 - 1
ruoyi-ui/src/api/inventory/detail.js

@@ -47,7 +47,7 @@ export function delDetail(id) {
 // 查询全单位或者部门的资产对比分析报表
 export function getDepAssetLossTb(query) {
   return request({
-    url: '/inventory/detail/getDepAssetLossTb',
+    url: '/inventory/inventory/getDepAssetLossTb',
     method: 'get',
     params: query
   })

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

@@ -18,7 +18,7 @@
       <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">
+      <el-form-item v-if="isExist('使用部门')" label="使用部门" prop="userDepartment">
         <div style="display: inline-block; width: 183px">
           <treeselect v-model="queryParams.userDepartment" :options="deptOptions" :normalizer="normalizer" placeholder="选择使用部门" />
         </div>
@@ -227,36 +227,38 @@
       <el-table-column type="selection" width="55" align="center" />
       <!-- <el-table-column label="编号" align="center" prop="id" /> -->
       <el-table-column label="资产编号" align="center" prop="number" />
-      <el-table-column label="资产名称" align="center" prop="name" />
-      <el-table-column label="EPC" align="center" prop="epc" v-if="isExist('epc')" width="180">
-        <template slot-scope="scope">
-          <div>{{scope.row.epc}}<br/>&lceil;补位:{{scope.row.epcReplenishLength}}&rfloor;</div>
-        </template>
-      </el-table-column>
-      <el-table-column label="资产条码" v-if="isExist('资产条码')" align="center" prop="code" />
       <el-table-column label="照片" align="center" prop="imageUrl" width="100">
         <template slot-scope="scope">
           <image-preview :src="scope.row.imageUrl" :width="50" :height="50" v-show="scope.row.imageUrl === '' || scope.row.imageUrl == null ? false : true" />
         </template>
       </el-table-column>
+      <el-table-column label="资产名称" align="center" prop="name" />
+      <el-table-column label="数量" align="center" prop="quantity" />
+      <el-table-column label="计量" align="center" prop="units" />
       <el-table-column label="资产分类" align="center" prop="categoryName">
         <!-- <template slot-scope="scope">
           <span>{{ scope.row.categoryNumber != null ? categoryName(scope.row.categoryNumber) : '' }}</span>
         </template> -->
       </el-table-column>
-      <el-table-column label="使用部门" align="center" prop="userDepartmentName">
+      <el-table-column label="所在位置" align="center" prop="locationName" width="120">
+        <template slot-scope="scope">
+          <span>{{ (scope.row.ancestorLocationName ? scope.row.ancestorLocationName + "-" : "") +  (scope.row.parentLocationName ?  scope.row.parentLocationName + "-" : "") + scope.row.locationName }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column v-if="isExist('使用部门')" label="使用部门" align="center" prop="userDepartmentName">
         <!-- <template slot-scope="scope">
           <span>{{ scope.row.userDepartment != null ? companyName(scope.row.userDepartment) : '' }}</span>
         </template> -->
       </el-table-column>
-      <el-table-column v-if="isExist('管理部门')" label="管理部门" align="center">
+      <el-table-column label="资产条码" v-if="isExist('资产条码')" align="center" prop="code" />
+      <el-table-column label="EPC" align="center" prop="epc" v-if="isExist('epc')" width="180">
         <template slot-scope="scope">
-          <span>{{ scope.row.departmentName }}</span>
+          <div>{{scope.row.epc}}<br/>&lceil;补位:{{scope.row.epcReplenishLength}}&rfloor;</div>
         </template>
       </el-table-column>
-      <el-table-column label="所在位置" align="center" prop="locationName" width="120">
+      <el-table-column v-if="isExist('管理部门')" label="管理部门" align="center">
         <template slot-scope="scope">
-          <span>{{ (scope.row.ancestorLocationName ? scope.row.ancestorLocationName + "-" : "") +  (scope.row.parentLocationName ?  scope.row.parentLocationName + "-" : "") + scope.row.locationName }}</span>
+          <span>{{ scope.row.departmentName }}</span>
         </template>
       </el-table-column>
       <el-table-column v-if="isExist('所属公司')" label="所属公司" align="center" prop="corporationName">
@@ -264,8 +266,6 @@
           <span>{{ scope.row.corporation != null ? companyName(scope.row.corporation) : '' }}</span>
         </template> -->
       </el-table-column>
-      <el-table-column label="数量" align="center" prop="quantity" />
-      <el-table-column label="计量" align="center" prop="units" />
       <el-table-column v-if="isExist('入账时间')" label="入账时间" align="center" prop="paymentReceivingTime" />
       <el-table-column v-if="isExist('备注')" label="备注" align="center" prop="remark" />
       <el-table-column v-if="isExist('管理状态')" label="管理状态" align="center" prop="manageStatus">
@@ -333,7 +333,7 @@
       <el-table-column label="预计使用期限" v-if="isExist('预计使用期限')" align="center" prop="lifeExpectancy" />
       <el-table-column label="预计使用期限单位" v-if="isExist('预计使用期限单位')" align="center" prop="lifeUnits" />
       <!-- <el-table-column label="预留字段j" align="center" prop="reservedColumnJ" /> -->
-      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button size="mini" type="text" icon="el-icon-printer" @click="handPrinter(scope.row)" v-hasPermi="['asset:information:query']">打印</el-button>
           <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['asset:information:edit']">修改</el-button>
@@ -598,6 +598,7 @@
         <div>
           <el-checkbox-group v-model="checkList" mini>
             <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>

+ 26 - 23
ruoyi-ui/src/views/inventory/statement/index.vue

@@ -28,26 +28,30 @@
     <el-table :data="lossList">
       <el-table-column type="expand">
         <template v-slot="slot">
-          <el-table :data="slot.row.assetResultList" ref="table" :header-cell-style="{ background: '#dcdfe6' }" >
+          <el-table :data="slot.row.compareResultList" ref="table" :header-cell-style="{ background: '#dcdfe6' }" >
             <el-table-column
-              prop="inventoryName"
+              prop="assetName"
               label="资产名称">
             </el-table-column>
             <el-table-column
-              prop="inventoryLocationName"
+              prop="location"
               label="资产位置">
             </el-table-column>
             <el-table-column
-              prop="expectInventoryNumber"
-              label="账面数量">
+              prop="category"
+              label="类别">
             </el-table-column>
             <el-table-column
-              prop="realityInventoryNumber"
-              label="实点数量">
+              prop="nowQuantity"
+              label="账面数量变化">
             </el-table-column>
             <el-table-column
-              prop="lossNumber"
-              label="损耗数量">
+              prop="invQuantity"
+              label="实点数量变化">
+            </el-table-column>
+            <el-table-column
+              prop="lossQuantity"
+              label="损耗数量变化">
             </el-table-column>
             <el-table-column
               prop="units"
@@ -55,32 +59,32 @@
             </el-table-column>
             <el-table-column
               prop="lossVal"
-              label="资产损耗金额">
+              label="损耗值变化">
             </el-table-column>
           </el-table>
         </template>
       </el-table-column>
       <el-table-column
-        prop="inventoryDepartment"
+        prop="deptName"
         label="盘点部门">
       </el-table-column>
       <el-table-column
-        prop="lossTotal"
-        label="损耗总额">
+        prop="lastSecondDate"
+        label="最后第二次盘点日期">
       </el-table-column>
       <el-table-column
-        prop="date"
-        label="盘点时间">
+        prop="lastFirstDate"
+        label="最后盘点日期">
       </el-table-column>
     </el-table>
 
-    <pagination
+    <!-- <pagination
       v-show="total>0"
       :total="total"
       :page.sync="queryParams.pageNum"
       :limit.sync="queryParams.pageSize"
       @pagination="onQueryLoss"
-    />
+    /> -->
   </div>
 
 </template>
@@ -102,8 +106,8 @@ export default {
       deptOptions: [],
       // 查询参数
       queryParams: {
-        pageNum: 1,
-        pageSize: 10,
+        // pageNum: 1,
+        // pageSize: 10,
         deptId: null
       }
     }
@@ -126,8 +130,8 @@ export default {
         return
       }
       getDepAssetLossTb(this.queryParams).then(response => {
-        this.lossList = response.rows
-        this.total = response.total;
+        this.lossList = response.data
+        // this.total = response.total;
         console.log('资产报表', this.lossData)
       })
     },
@@ -137,8 +141,7 @@ export default {
         return
       }
       const deptId = this.queryParams.deptId
-      this.download('inventory/detail/exportDepAssetLossTb', {
-        deptId
+      this.download('inventory/inventory/exportDepAssetLossTb/' + deptId, {
       }, `资产报表_${new Date().getTime()}.xlsx`)
       this.openExport = false
     }