Explorar el Código

优化盘点详细修改

LinWuTai hace 10 meses
padre
commit
19432d3126

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

@@ -7,10 +7,15 @@ import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import com.ruoyi.asset.domain.TbAssetInformation;
+import com.ruoyi.asset.domain.TbLocation;
 import com.ruoyi.asset.mapper.TbAssetInformationMapper;
 import com.ruoyi.asset.mapper.TbLocationMapper;
 import com.ruoyi.inventory.domain.TbAssetInventory;
 import com.ruoyi.inventory.domain.TbInventoryCompare;
+import com.ruoyi.inventory.domain.enums.InventoryPlanResult;
+import com.ruoyi.inventory.domain.enums.InventoryPlanStatus;
+import com.ruoyi.inventory.domain.enums.InventoryResult;
+import com.ruoyi.inventory.domain.enums.InventoryStatus;
 import com.ruoyi.inventory.mapper.TbAssetInventoryMapper;
 import com.ruoyi.utils.RecursionUtil;
 import org.apache.commons.collections.map.HashedMap;
@@ -96,7 +101,86 @@ public class TbInventoryDetailServiceImpl implements ITbInventoryDetailService
     @Override
     public int updateTbInventoryDetail(TbInventoryDetail tbInventoryDetail)
     {
-        return tbInventoryDetailMapper.updateTbInventoryDetail(tbInventoryDetail);
+        // 获取盘点计划单号
+        String orderNumber = tbInventoryDetail.getOrderNumber();
+        // 根据单号获取盘点计划
+        TbAssetInventory tbAssetInventory = tbAssetInventoryMapper.selectTbAssetInventoryByNumber(orderNumber);
+
+        TbAssetInformation assetInformation = JSONUtil.toBean(tbInventoryDetail.getInventoryMetadata(), TbAssetInformation.class);
+        // 获取账面数量
+        Integer quantity = assetInformation.getQuantity();
+        // 获取盘点数量
+        Integer inventoryQuantity = tbInventoryDetail.getInventoryQuantity();
+
+        // 盘点数量为null
+        if (inventoryQuantity == null) {
+            tbInventoryDetail.setInventoryResult(null);
+        } else {
+            if (quantity > inventoryQuantity) { // 账面大于盘点 盘亏
+                tbInventoryDetail.setInventoryResult(InventoryResult.INVENTORY_SHORTAGES.getCode());
+            }
+            if (quantity.equals(inventoryQuantity)) { // 账面等于盘点 正常
+                tbInventoryDetail.setInventoryResult(InventoryResult.INVENTORY_NORMAL.getCode());
+            }
+            if (inventoryQuantity > quantity ) { // 盘点大于账面 盘盈
+                tbInventoryDetail.setInventoryResult(InventoryResult.INVENTORY_PROFIT.getCode());
+            }
+        }
+
+        int updated = tbInventoryDetailMapper.updateTbInventoryDetail(tbInventoryDetail);
+        if (updated < 1) {
+            throw new RuntimeException("操作失败");
+        }
+
+        // 查看盘点计划是否已执行
+        Integer inventoryStatus = tbAssetInventory.getInventoryStatus();
+        if (inventoryStatus.equals(InventoryPlanStatus.PLAN_FINISH.getCode())) {
+            // 根据计划单号获取盘点详细
+            List<TbInventoryDetail> tbInventoryDetails = tbInventoryDetailMapper.selectTbInventoryDetailByOrderNumber(orderNumber);
+
+            // 获取盘点计划中的盘点详细
+            List<TbInventoryDetail> inventoryDetailList = tbInventoryDetails.stream()
+                    .filter(item -> !InventoryStatus.ERROR.getCode().equals(item.getInventoryStatus()))
+                    .collect(Collectors.toList());
+
+            // 获取盘点详细中未盘
+            List<TbInventoryDetail> uncountedInventoryDetailList = inventoryDetailList.stream()
+                    .filter(item -> InventoryStatus.UNCOUNTED.getCode().equals(item.getInventoryStatus()))
+                    .collect(Collectors.toList());
+
+            // 获取盘点详细中盘亏
+            List<TbInventoryDetail> shortagesInventoryDetailList = inventoryDetailList.stream()
+                    .filter(item -> InventoryResult.INVENTORY_SHORTAGES.getCode().equals(item.getInventoryResult()))
+                    .collect(Collectors.toList());
+
+            // 获取盘点详细中盘盈
+            List<TbInventoryDetail> normalInventoryDetailList = inventoryDetailList.stream()
+                    .filter(item -> InventoryResult.INVENTORY_PROFIT.getCode().equals(item.getInventoryResult()))
+                    .collect(Collectors.toList());
+
+            // 未盘数量
+            int uncounted = uncountedInventoryDetailList.size();
+            // 盘亏数量
+            int shortages = shortagesInventoryDetailList.size();
+            // 盘盈数量
+            int normal = normalInventoryDetailList.size();
+            if (uncounted > 0 || shortages > 0) { // 存在盘亏 或者 存在未盘
+                tbAssetInventory.setInventoryResult(InventoryPlanResult.PLAN_INVENTORY_SHORTAGES.getCode());
+            } else {
+                if (normal > 0) { // 不存在盘亏,存在盘盈
+                    tbAssetInventory.setInventoryResult(InventoryPlanResult.PLAN_INVENTORY_PROFIT.getCode());
+                } else { // 不存在盘亏盘盈
+                    tbAssetInventory.setInventoryResult(InventoryPlanResult.PLAN_INVENTORY_NORMAL.getCode());
+                }
+            }
+
+            int flag = tbAssetInventoryMapper.updateTbAssetInventory(tbAssetInventory);
+            if (flag < 1) {
+                throw new RuntimeException("操作失败");
+            }
+        }
+
+        return 1;
     }
 
     /**

+ 2 - 2
ruoyi-ui/src/views/inventory/detail/index.vue

@@ -171,10 +171,10 @@
             ></el-option>
           </el-select>
         </el-form-item>
-        <!-- <el-form-item label="盘点数量" prop="orderNumber">
+        <el-form-item label="盘点数量" prop="orderNumber">
           <el-input-number size="small" v-model="form.inventoryQuantity" :min="0"></el-input-number>
         </el-form-item>
-        <el-form-item label="盘点结果" prop="inventoryResult">
+        <!-- <el-form-item label="盘点结果" prop="inventoryResult">
           <el-select v-model="form.inventoryResult" placeholder="请选择盘点结果">
             <el-option
               v-for="dict in dict.type.inventory_detail_inventory_result"

+ 1 - 5
ruoyi-ui/src/views/inventory/statement/index.vue

@@ -84,11 +84,7 @@ export default {
         return
       }
       getDepAssetLossTb(this.queryParams).then((response) => {
-        this.lossList = response.data(
-          // this.total = response.total;
-          '资产报表',
-          this.lossData
-        )
+        this.lossList = response.data
       })
     },
     onLossExport() {

+ 4 - 4
ruoyi-ui/src/views/label/labelModel/index.vue

@@ -51,9 +51,9 @@
     <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
 
     <!-- 添加或修改标签模板信息对话框 -->
-    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
-      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
-        <el-row>
+    <el-dialog :title="title" :visible.sync="open" width="850px" append-to-body>
+      <el-form ref="form" :model="form" :rules="rules" label-width="130px">
+        <el-row :gutter="10">
           <el-col :span="12">
             <el-form-item label="标签名称" prop="name">
               <el-input v-model="form.name" placeholder="请输入标签名称" />
@@ -72,7 +72,7 @@
           </el-col>
           <el-col :span="12">
             <el-form-item label="备注" prop="remark">
-              <el-input v-model="form.remark" placeholder="请输入备注" />
+              <el-input type="textarea" v-model="form.remark" placeholder="请输入备注" />
             </el-form-item>
           </el-col>
         </el-row>

+ 1 - 1
ruoyi-ui/src/views/order/order/index.vue

@@ -576,7 +576,7 @@ export default {
       this.reset()('修改表单信息:', row)
       const id = row.id || this.ids
       getOrder(id).then((response) => {
-        this.form = response.data('修改表单信息:', this.form)
+        this.form = response.data
         if (response.data.recordStatus > 0) {
           this.$modal.msgWarning('已提交单据不可修改')
           return

+ 1 - 1
ruoyi-ui/vue.config.js

@@ -20,7 +20,7 @@ module.exports = {
   // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
   publicPath: process.env.NODE_ENV === "production" ? "/" : "/",
   // 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist)
-  outputDir: 'dist',
+  outputDir: 'rfid',
   // 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下)
   assetsDir: 'static',
   // 是否开启eslint保存检测,有效值:ture | false | 'error'