From d51f64c1f0105d4b18aa8344c11e47827730a40c Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期五, 08 八月 2025 10:42:39 +0800
Subject: [PATCH] Merge branch 'devlop' of http://47.97.1.152:5880/r/wms-master into devlop

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/StockStatisticController.java    |  104 ++++++++
 rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/LocRevise.java                       |    2 
 rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/StockController.java             |    8 
 rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/LocItem.java                         |   10 
 rsf-server/src/main/java/com/vincent/rsf/server/common/CodeBuilder.java                             |    4 
 rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java                |   19 
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/StockStatisticService.java          |    8 
 rsf-server/src/main/java/stockStatistic.sql                                                         |   31 ++
 rsf-server/src/main/java/com/vincent/rsf/server/manager/mapper/StockStatisticMapper.java            |   12 +
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/DeliveryServiceImpl.java       |    5 
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/StockStatisticServiceImpl.java |   12 +
 rsf-server/src/main/resources/mapper/manager/StockStatisticMapper.xml                               |    5 
 rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocItemDeadController.java       |  220 ++++++++++++++++++
 rsf-admin/src/i18n/zh.js                                                                            |   13 +
 rsf-admin/src/i18n/en.js                                                                            |   14 +
 rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/InStockNum.java                      |   38 +++
 rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/StockStatistic.java                  |  117 +++++++++
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/ReviseLogItemServiceImpl.java  |   82 ++++--
 rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/LocItemDead.java                     |   13 +
 19 files changed, 676 insertions(+), 41 deletions(-)

diff --git a/rsf-admin/src/i18n/en.js b/rsf-admin/src/i18n/en.js
index 36d02b0..32dd056 100644
--- a/rsf-admin/src/i18n/en.js
+++ b/rsf-admin/src/i18n/en.js
@@ -214,6 +214,7 @@
         locRevise: 'Loc Revise',
         statisticReport: 'Statistical Report',
         locDeadReport: 'Locs Dead Report',
+        stockStatistic: 'Stock Statistic',
     },
     table: {
         field: {
@@ -825,6 +826,18 @@
                 startTime: "startTime",
                 endTime: "endTime",
             },
+          stockStatistic: {
+            id: "id",
+            dayTime: "dayTime",
+            taskType: "taskType",
+            taskStatus: "taskStatus",
+            maktx: "maktx",
+            matnrCode: "matnrCode",
+            count: "count",
+            batch: "batch",
+            anfme: "anfme",
+            unit: "unit",
+          },
             delivery: {
                 code: "code",
                 platId: "platId",
@@ -1032,7 +1045,6 @@
                 wkType: 'Work Type',
                 orderType: "orderType",
                 orderItemId: "orderItemId",
-                sourceCode: "sourceCode",
                 matnrId: "matnrId",
                 maktx: "maktx",
                 matnrCode: "matnrCode",
diff --git a/rsf-admin/src/i18n/zh.js b/rsf-admin/src/i18n/zh.js
index 7690056..e30ae5a 100644
--- a/rsf-admin/src/i18n/zh.js
+++ b/rsf-admin/src/i18n/zh.js
@@ -221,6 +221,7 @@
         locRevise: '搴撳瓨璋冩暣',
         statisticReport: '鏃ュ織鎶ヨ〃',
         locDeadReport : '搴撳瓨鍋滄粸鎶ヨ〃',
+        stockStatistic: '鏃ュ簱瀛樼粺璁�',
     },
     table: {
         field: {
@@ -479,6 +480,18 @@
                 useStatus: '搴撲綅鐘舵��',
                 locAreaId: '閫昏緫鍒嗗尯'
             },
+          stockStatistic: {
+            id: "id",
+            dayTime: "鏃ユ湡",
+            taskType: "浠诲姟绫诲瀷",
+            taskStatus: "浠诲姟鐘舵��",
+            maktx: "鐗╂枡鍚嶇О",
+            matnrCode: "鐗╂枡缂栫爜",
+            count: "娆℃暟",
+            batch: "鎵规",
+            anfme: "鏁伴噺",
+            unit: "鍗曚綅",
+          },
             locType: {
                 name: "搴撲綅绫诲瀷",
                 code: "缂栧彿",
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
index 971f036..c6bec07 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
@@ -388,23 +388,20 @@
 
         InTaskMsgDto inTaskMsgDto = new InTaskMsgDto();
 
-        int sRow = deviceBind.getStartRow();
-        int eRow = deviceBind.getEndRow();
         int deviceQty = deviceBind.getDeviceQty();
 
 
         // ===============>>>> 寮�濮嬫墽琛�
         curRow = deviceBind.getCurrentRow();
 
-        //姝ょ▼搴忕敤浜庝紭鍖栧爢鍨涙満寮傚父鏃剁殑杩愯鏃堕棿
-        for (int i = times; i <= deviceQty * 2; i++) {
-            int[] locNecessaryParameters = LocUtils.LocNecessaryParameters(deviceBind, curRow, deviceQty);
-            curRow = locNecessaryParameters[1];
-            channel = locNecessaryParameters[2];
-            rowCount = locNecessaryParameters[0];
-            nearRow = locNecessaryParameters[3];
-            break;
-        }
+        //鑾峰彇鎺�
+        int[] locNecessaryParameters = LocUtils.LocNecessaryParameters(deviceBind, curRow, deviceQty);
+        curRow = locNecessaryParameters[1];
+        channel = locNecessaryParameters[2];
+        rowCount = locNecessaryParameters[0];
+        nearRow = locNecessaryParameters[3];
+
+
         if (nearRow == 0) {
             throw new CoolException("鏃犲彲鐢ㄥ爢鍨涙満");
         }
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/common/CodeBuilder.java b/rsf-server/src/main/java/com/vincent/rsf/server/common/CodeBuilder.java
index 574305c..e8bbef4 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/common/CodeBuilder.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/common/CodeBuilder.java
@@ -22,8 +22,8 @@
 //        generator.username="sa";
 //        generator.password="Zoneyung@zy56$";
 
-        generator.table = "man_revise_log_item";
-        generator.tableDesc = "搴撲綅璋冩暣鍘嗗彶";
+        generator.table = "view_stock_statistic";
+        generator.tableDesc = "鏃ュ簱瀛樼粺璁�";
         generator.packagePath = "com.vincent.rsf.server.manager";
 
         generator.build();
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocItemDeadController.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocItemDeadController.java
new file mode 100644
index 0000000..9dae6b5
--- /dev/null
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocItemDeadController.java
@@ -0,0 +1,220 @@
+package com.vincent.rsf.server.manager.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.vincent.rsf.framework.common.Cools;
+import com.vincent.rsf.framework.common.R;
+import com.vincent.rsf.server.common.annotation.OperationLog;
+import com.vincent.rsf.server.common.constant.Constants;
+import com.vincent.rsf.server.common.domain.BaseParam;
+import com.vincent.rsf.server.common.domain.KeyValVo;
+import com.vincent.rsf.server.common.domain.PageParam;
+import com.vincent.rsf.server.common.utils.ExcelUtil;
+import com.vincent.rsf.server.common.utils.FieldsUtils;
+import com.vincent.rsf.server.manager.controller.params.LocToTaskParams;
+import com.vincent.rsf.server.manager.entity.LocItem;
+import com.vincent.rsf.server.manager.enums.LocStsType;
+import com.vincent.rsf.server.manager.enums.TaskResouceType;
+import com.vincent.rsf.server.manager.service.LocItemService;
+import com.vincent.rsf.server.manager.service.LocService;
+import com.vincent.rsf.server.system.controller.BaseController;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.*;
+
+@RestController
+public class LocItemDeadController extends BaseController {
+
+    @Autowired
+    private LocItemService locItemService;
+    @Autowired
+    private LocService locService;
+
+    @PreAuthorize("hasAuthority('manager:statisticReport:list')")
+    @PostMapping("/locDeadReport/page")
+    public R page(@RequestBody Map<String, Object> map) {
+        BaseParam baseParam = buildParam(map, BaseParam.class);
+        PageParam<LocItem, BaseParam> pageParam = new PageParam<>(baseParam, LocItem.class);
+        QueryWrapper<LocItem> wrapper = pageParam.buildWrapper(true);
+        /**鎷兼帴鎵╁睍瀛楁*/
+        PageParam<LocItem, BaseParam> page = locItemService.page(pageParam, wrapper);
+        List<LocItem> records = page.getRecords();
+        for (LocItem record : records) {
+            if (!Objects.isNull(record.getFieldsIndex())) {
+                Map<String, String> fields = FieldsUtils.getFields(record.getFieldsIndex());
+                record.setExtendFields(fields);
+            }
+        }
+        page.setRecords(records);
+
+        return R.ok().add(page);
+    }
+
+    @PreAuthorize("hasAuthority('manager:statisticReport:list')")
+    @PostMapping("/locDeadReport/useO/page")
+    public R locUseOPage(@RequestBody Map<String, Object> map) {
+        BaseParam baseParam = buildParam(map, BaseParam.class);
+        PageParam<LocItem, BaseParam> pageParam = new PageParam<>(baseParam, LocItem.class);
+        QueryWrapper<LocItem> locItemQueryWrapper = pageParam.buildWrapper(true);
+        String applySql = String.format(
+                "EXISTS (SELECT 1 FROM man_loc ml " +
+                        "WHERE ml.use_status = '%s'" +
+                        "AND ml.id = man_loc_item.loc_id " +
+                        ")",
+                LocStsType.LOC_STS_TYPE_F.type
+        );
+        locItemQueryWrapper.apply(applySql);
+        /**鎷兼帴鎵╁睍瀛楁*/
+        PageParam<LocItem, BaseParam> page = locItemService.page(pageParam, locItemQueryWrapper);
+        List<LocItem> records = page.getRecords();
+        for (LocItem record : records) {
+            if (!Objects.isNull(record.getFieldsIndex())) {
+                Map<String, String> fields = FieldsUtils.getFields(record.getFieldsIndex());
+                record.setExtendFields(fields);
+            }
+        }
+        page.setRecords(records);
+
+        return R.ok().add(page);
+    }
+
+    /**
+     * 鐢熸垚搴撳瓨鍑哄簱浠诲姟
+     * @param param
+     * @return
+     */
+    @PreAuthorize("hasAuthority('manager:statisticReport:list')")
+    @ApiOperation("鐢熸垚搴撳瓨鍑哄簱浠诲姟")
+    @PostMapping("/locDeadReport/generate/task")
+    public R generateTask(@RequestBody LocToTaskParams param) {
+        if (Objects.isNull(param)) {
+            return R.error("鍙傛暟涓嶈兘涓虹┖锛侊紒");
+        }
+        param.setType(Constants.TASK_TYPE_OUT_STOCK);
+        try {
+            locItemService.generateTask(TaskResouceType.TASK_RESOUCE_STOCK_TYPE.val, param, getLoginUserId());
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        return R.ok();
+    }
+
+    /**
+     * 鐢熸垚绉诲簱浠诲姟
+     * @param map
+     * @return
+     */
+    @PreAuthorize("hasAuthority('manager:statisticReport:list')")
+    @ApiOperation("鐢熸垚绉诲簱浠诲姟")
+    @PostMapping("/locDeadReport/move/task")
+    public R genMoveTask(@RequestBody LocToTaskParams map) {
+        if (Objects.isNull(map)) {
+            return R.error("鍙傛暟涓嶈兘涓虹┖锛侊紒");
+        }
+        return R.ok("浠诲姟鐢熸垚鎴愬姛").add(locItemService.genMoveTask(map, getLoginUserId()));
+    }
+
+    /**
+     * 鐢熸垚鐩樼偣鍑哄簱浠诲姟
+     * @param map
+     * @return
+     */
+    @PreAuthorize("hasAuthority('manager:statisticReport:list')")
+    @ApiOperation("鐢熸垚鐩樼偣鍑哄簱浠诲姟")
+    @PostMapping("/locDeadReport/check/task")
+    public R genStatisticalTask(@RequestBody LocToTaskParams map) {
+        if (Objects.isNull(map)) {
+            return R.error("鍙傛暟涓嶈兘涓虹┖锛侊紒");
+        }
+        map.setType(Constants.TASK_TYPE_OUT_CHECK);
+
+        try {
+            locItemService.generateTask(TaskResouceType.TASK_RESOUCE_CHECK_TYPE.val, map, getLoginUserId());
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+
+        return R.ok("浠诲姟鐢熸垚鎴愬姛");
+    }
+
+
+    @PreAuthorize("hasAuthority('manager:statisticReport:list')")
+    @PostMapping("/locDeadReport/list")
+    public R list(@RequestBody Map<String, Object> map) {
+        return R.ok().add(locItemService.list());
+    }
+
+    @PreAuthorize("hasAuthority('manager:statisticReport:list')")
+    @PostMapping({"/locDeadReport/many/{ids}", "/locDeadReport/many/{ids}"})
+    public R many(@PathVariable Long[] ids) {
+        return R.ok().add(locItemService.listByIds(Arrays.asList(ids)));
+    }
+
+    @PreAuthorize("hasAuthority('manager:statisticReport:list')")
+    @GetMapping("/locDeadReport/{id}")
+    public R get(@PathVariable("id") Long id) {
+        return R.ok().add(locItemService.getById(id));
+    }
+
+    @PreAuthorize("hasAuthority('manager:statisticReport:save')")
+    @OperationLog("Create 搴撲綅鏄庣粏")
+    @PostMapping("/locDeadReport/save")
+    public R save(@RequestBody LocItem locItem) {
+        locItem.setCreateBy(getLoginUserId());
+        locItem.setCreateTime(new Date());
+        locItem.setUpdateBy(getLoginUserId());
+        locItem.setUpdateTime(new Date());
+        if (!locItemService.save(locItem)) {
+            return R.error("Save Fail");
+        }
+        return R.ok("Save Success").add(locItem);
+    }
+
+    @PreAuthorize("hasAuthority('manager:statisticReport:update')")
+    @OperationLog("Update 搴撲綅鏄庣粏")
+    @PostMapping("/locDeadReport/update")
+    public R update(@RequestBody LocItem locItem) {
+        locItem.setUpdateBy(getLoginUserId());
+        locItem.setUpdateTime(new Date());
+        if (!locItemService.updateById(locItem)) {
+            return R.error("Update Fail");
+        }
+        return R.ok("Update Success").add(locItem);
+    }
+
+    @PreAuthorize("hasAuthority('manager:statisticReport:remove')")
+    @OperationLog("Delete 搴撲綅鏄庣粏")
+    @PostMapping("/locDeadReport/remove/{ids}")
+    public R remove(@PathVariable Long[] ids) {
+        if (!locItemService.removeByIds(Arrays.asList(ids))) {
+            return R.error("Delete Fail");
+        }
+        return R.ok("Delete Success").add(ids);
+    }
+
+    @PreAuthorize("hasAuthority('manager:statisticReport:list')")
+    @PostMapping("/locDeadReport/query")
+    public R query(@RequestParam(required = false) String condition) {
+        List<KeyValVo> vos = new ArrayList<>();
+        LambdaQueryWrapper<LocItem> wrapper = new LambdaQueryWrapper<>();
+        if (!Cools.isEmpty(condition)) {
+            wrapper.like(LocItem::getId, condition);
+        }
+        locItemService.page(new Page<>(1, 30), wrapper).getRecords().forEach(
+                item -> vos.add(new KeyValVo(item.getId(), item.getId()))
+        );
+        return R.ok().add(vos);
+    }
+
+    @PreAuthorize("hasAuthority('manager:statisticReport:list')")
+    @PostMapping("/locDeadReport/export")
+    public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception {
+        ExcelUtil.build(ExcelUtil.create(locItemService.list(), LocItem.class), response);
+    }
+
+}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/StockController.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/StockController.java
index 5d398c3..8f9ad32 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/StockController.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/StockController.java
@@ -36,6 +36,14 @@
     }
 
     @PreAuthorize("hasAuthority('manager:stock:list')")
+    @PostMapping("/inStock/num/page")
+    public R inStockpage(@RequestBody Map<String, Object> map) {
+        BaseParam baseParam = buildParam(map, BaseParam.class);
+        PageParam<Stock, BaseParam> pageParam = new PageParam<>(baseParam, Stock.class);
+        return R.ok().add(stockService.page(pageParam, pageParam.buildWrapper(true)));
+    }
+
+    @PreAuthorize("hasAuthority('manager:stock:list')")
     @PostMapping("/stock/list")
     public R list(@RequestBody Map<String, Object> map) {
         return R.ok().add(stockService.list());
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/StockStatisticController.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/StockStatisticController.java
new file mode 100644
index 0000000..c9058d5
--- /dev/null
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/StockStatisticController.java
@@ -0,0 +1,104 @@
+package com.vincent.rsf.server.manager.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.vincent.rsf.framework.common.Cools;
+import com.vincent.rsf.framework.common.R;
+import com.vincent.rsf.server.common.utils.ExcelUtil;
+import com.vincent.rsf.server.common.annotation.OperationLog;
+import com.vincent.rsf.server.common.domain.BaseParam;
+import com.vincent.rsf.server.common.domain.KeyValVo;
+import com.vincent.rsf.server.common.domain.PageParam;
+import com.vincent.rsf.server.manager.entity.StockStatistic;
+import com.vincent.rsf.server.manager.service.StockStatisticService;
+import com.vincent.rsf.server.system.controller.BaseController;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.*;
+
+@RestController
+public class StockStatisticController extends BaseController {
+
+    @Autowired
+    private StockStatisticService stockStatisticService;
+
+    @PreAuthorize("hasAuthority('manager:stockStatistic:list')")
+    @PostMapping("/stockStatistic/page")
+    public R page(@RequestBody Map<String, Object> map) {
+        BaseParam baseParam = buildParam(map, BaseParam.class);
+        PageParam<StockStatistic, BaseParam> pageParam = new PageParam<>(baseParam, StockStatistic.class);
+        return R.ok().add(stockStatisticService.page(pageParam, pageParam.buildWrapper(true)));
+    }
+
+    @PreAuthorize("hasAuthority('manager:stockStatistic:list')")
+    @PostMapping("/stockStatistic/list")
+    public R list(@RequestBody Map<String, Object> map) {
+        return R.ok().add(stockStatisticService.list());
+    }
+
+    @PreAuthorize("hasAuthority('manager:stockStatistic:list')")
+    @PostMapping({"/stockStatistic/many/{ids}", "/stockStatistics/many/{ids}"})
+    public R many(@PathVariable Long[] ids) {
+        return R.ok().add(stockStatisticService.listByIds(Arrays.asList(ids)));
+    }
+
+    @PreAuthorize("hasAuthority('manager:stockStatistic:list')")
+    @GetMapping("/stockStatistic/{id}")
+    public R get(@PathVariable("id") Long id) {
+        return R.ok().add(stockStatisticService.getById(id));
+    }
+
+    @PreAuthorize("hasAuthority('manager:stockStatistic:save')")
+    @OperationLog("Create 鏃ュ簱瀛樼粺璁�")
+    @PostMapping("/stockStatistic/save")
+    public R save(@RequestBody StockStatistic stockStatistic) {
+        if (!stockStatisticService.save(stockStatistic)) {
+            return R.error("Save Fail");
+        }
+        return R.ok("Save Success").add(stockStatistic);
+    }
+
+    @PreAuthorize("hasAuthority('manager:stockStatistic:update')")
+    @OperationLog("Update 鏃ュ簱瀛樼粺璁�")
+    @PostMapping("/stockStatistic/update")
+    public R update(@RequestBody StockStatistic stockStatistic) {
+        if (!stockStatisticService.updateById(stockStatistic)) {
+            return R.error("Update Fail");
+        }
+        return R.ok("Update Success").add(stockStatistic);
+    }
+
+    @PreAuthorize("hasAuthority('manager:stockStatistic:remove')")
+    @OperationLog("Delete 鏃ュ簱瀛樼粺璁�")
+    @PostMapping("/stockStatistic/remove/{ids}")
+    public R remove(@PathVariable Long[] ids) {
+        if (!stockStatisticService.removeByIds(Arrays.asList(ids))) {
+            return R.error("Delete Fail");
+        }
+        return R.ok("Delete Success").add(ids);
+    }
+
+    @PreAuthorize("hasAuthority('manager:stockStatistic:list')")
+    @PostMapping("/stockStatistic/query")
+    public R query(@RequestParam(required = false) String condition) {
+        List<KeyValVo> vos = new ArrayList<>();
+        LambdaQueryWrapper<StockStatistic> wrapper = new LambdaQueryWrapper<>();
+        if (!Cools.isEmpty(condition)) {
+            wrapper.like(StockStatistic::getId, condition);
+        }
+        stockStatisticService.page(new Page<>(1, 30), wrapper).getRecords().forEach(
+                item -> vos.add(new KeyValVo(item.getId(), item.getId()))
+        );
+        return R.ok().add(vos);
+    }
+
+    @PreAuthorize("hasAuthority('manager:stockStatistic:list')")
+    @PostMapping("/stockStatistic/export")
+    public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception {
+        ExcelUtil.build(ExcelUtil.create(stockStatisticService.list(), StockStatistic.class), response);
+    }
+
+}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/InStockNum.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/InStockNum.java
new file mode 100644
index 0000000..0e7c312
--- /dev/null
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/InStockNum.java
@@ -0,0 +1,38 @@
+package com.vincent.rsf.server.manager.entity;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
+
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "InStockNum", description = "鏃ュ叆搴撶粺璁�")
+public class InStockNum implements Serializable {
+
+    public static final long serialVersionUID = 1L;
+
+    @ApiModelProperty("鐗╂枡鍚嶇О")
+    private String maktx;
+
+    @ApiModelProperty("鐗╂枡缂栫爜")
+    private String matnrCode;
+
+    @ApiModelProperty("鏁伴噺")
+    private Double anfme;
+
+    @ApiModelProperty("鍗曚綅")
+    private String unit;
+
+    @ApiModelProperty("鎵规")
+    private String batch;
+
+    @ApiModelProperty("鏃ユ湡")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    private Date dayTime;
+}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/LocItem.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/LocItem.java
index 5191964..38ae934 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/LocItem.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/LocItem.java
@@ -7,6 +7,7 @@
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.vincent.rsf.framework.common.DateUtils;
 import com.vincent.rsf.server.manager.service.LocService;
 import com.vincent.rsf.server.manager.service.WarehouseAreasService;
 import com.vincent.rsf.server.system.constant.DictTypeCode;
@@ -342,6 +343,10 @@
         return dictData.getLabel();
     }
 
+    public Double getReviseQty() {
+        return this.anfme;
+    }
+
     public String getStatus$(){
         if (null == this.status){ return null; }
         switch (this.status){
@@ -354,6 +359,11 @@
         }
     }
 
+    public Integer getDeadTime() {
+        if (null == this.createTime){ return null; }
+        return DateUtils.diff(createTime, new Date());
+    }
+
     public String getCreateBy$(){
         UserService service = SpringUtils.getBean(UserService.class);
         User user = service.getById(this.createBy);
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/LocItemDead.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/LocItemDead.java
new file mode 100644
index 0000000..9f2979e
--- /dev/null
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/LocItemDead.java
@@ -0,0 +1,13 @@
+package com.vincent.rsf.server.manager.entity;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "LocItemDead", description = "搴撳瓨鍋滄粸")
+public class LocItemDead {
+
+
+}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/LocRevise.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/LocRevise.java
index 0f998cd..fdca335 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/LocRevise.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/LocRevise.java
@@ -158,7 +158,7 @@
     public String getType$(){
         if (null == this.type){ return null; }
         switch (this.type){
-            case 0:
+            case 1:
                 return " 搴撳瓨璋冩暣";
             case  2:
                 return " 鐩樼偣璋冩暣";
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/StockStatistic.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/StockStatistic.java
new file mode 100644
index 0000000..e92e213
--- /dev/null
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/StockStatistic.java
@@ -0,0 +1,117 @@
+package com.vincent.rsf.server.manager.entity;
+
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import com.vincent.rsf.framework.common.Cools;
+import com.vincent.rsf.framework.common.SpringUtils;
+import com.vincent.rsf.server.system.service.UserService;
+import com.vincent.rsf.server.system.entity.User;
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+@TableName("view_stock_statistic")
+public class StockStatistic implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * ID
+     */
+    @ApiModelProperty(value= "ID")
+    private Long id;
+
+    @ApiModelProperty(value= "")
+    private String dayTime;
+
+    /**
+     * 浠诲姟绫诲瀷
+     */
+    @ApiModelProperty(value= "浠诲姟绫诲瀷")
+    private Integer taskType;
+
+    /**
+     * 浠诲姟鐘舵��
+     */
+    @ApiModelProperty(value= "浠诲姟鐘舵��")
+    private Integer taskStatus;
+
+    /**
+     * 鐗╂枡鍚嶇О
+     */
+    @ApiModelProperty(value= "鐗╂枡鍚嶇О")
+    private String maktx;
+
+    /**
+     * 鐗╂枡缂栫爜
+     */
+    @ApiModelProperty(value= "鐗╂枡缂栫爜")
+    private String matnrCode;
+
+    @ApiModelProperty(value= "")
+    private Long count;
+
+    /**
+     * 搴撳瓨鎵规
+     */
+    @ApiModelProperty(value= "搴撳瓨鎵规")
+    private String batch;
+
+    @ApiModelProperty(value= "")
+    private Double anfme;
+
+    /**
+     * 搴撳瓨鍗曚綅
+     */
+    @ApiModelProperty(value= "搴撳瓨鍗曚綅")
+    private String unit;
+
+    public StockStatistic() {}
+
+    public StockStatistic(Long id,String dayTime,Integer taskType,Integer taskStatus,String maktx,String matnrCode,Long count,String batch,Double anfme,String unit) {
+        this.id = id;
+        this.dayTime = dayTime;
+        this.taskType = taskType;
+        this.taskStatus = taskStatus;
+        this.maktx = maktx;
+        this.matnrCode = matnrCode;
+        this.count = count;
+        this.batch = batch;
+        this.anfme = anfme;
+        this.unit = unit;
+    }
+
+//    StockStatistic stockStatistic = new StockStatistic(
+//            null,    // ID[闈炵┖]
+//            null,    // 
+//            null,    // 浠诲姟绫诲瀷
+//            null,    // 浠诲姟鐘舵��
+//            null,    // 鐗╂枡鍚嶇О
+//            null,    // 鐗╂枡缂栫爜
+//            null,    // [闈炵┖]
+//            null,    // 搴撳瓨鎵规
+//            null,    // 
+//            null    // 搴撳瓨鍗曚綅
+//    );
+
+
+
+    public Boolean getStatusBool(){
+        if (null == this.status){ return null; }
+        switch (this.status){
+            case 1:
+                return true;
+            case 0:
+                return false;
+            default:
+                return null;
+        }
+    }
+
+}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/mapper/StockStatisticMapper.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/mapper/StockStatisticMapper.java
new file mode 100644
index 0000000..6b47bc4
--- /dev/null
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/mapper/StockStatisticMapper.java
@@ -0,0 +1,12 @@
+package com.vincent.rsf.server.manager.mapper;
+
+import com.vincent.rsf.server.manager.entity.StockStatistic;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+@Mapper
+@Repository
+public interface StockStatisticMapper extends BaseMapper<StockStatistic> {
+
+}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/StockStatisticService.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/StockStatisticService.java
new file mode 100644
index 0000000..d8cc395
--- /dev/null
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/StockStatisticService.java
@@ -0,0 +1,8 @@
+package com.vincent.rsf.server.manager.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.vincent.rsf.server.manager.entity.StockStatistic;
+
+public interface StockStatisticService extends IService<StockStatistic> {
+
+}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/DeliveryServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/DeliveryServiceImpl.java
index 13530da..702845a 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/DeliveryServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/DeliveryServiceImpl.java
@@ -3,6 +3,7 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.vincent.rsf.framework.exception.CoolException;
 import com.vincent.rsf.server.common.exception.BusinessException;
+import com.vincent.rsf.server.manager.entity.DeliveryItem;
 import com.vincent.rsf.server.manager.enums.AsnExceStatus;
 import com.vincent.rsf.server.manager.mapper.DeliveryMapper;
 import com.vincent.rsf.server.manager.entity.Delivery;
@@ -28,11 +29,11 @@
             throw new BusinessException("鏁版嵁閿欒锛氬崟鎹俊鎭笉瀛樺湪锛侊紒");
         }
         deliveries.forEach(delivery -> {
-            if (delivery.getExceStatus().equals(AsnExceStatus.OUT_STOCK_STATUS_TASK_INIT.val)){
+            if (delivery.getExceStatus().equals(AsnExceStatus.ASN_EXCE_STATUS_UN_EXCE.val)){
                 if (!this.removeById(delivery.getId())) {
                     throw new CoolException("涓诲崟鍒犻櫎澶辫触锛侊紒");
                 }
-                if (!deliveryItemService.removeById(delivery.getId())) {
+                if (!deliveryItemService.remove(new LambdaQueryWrapper<DeliveryItem>().eq(DeliveryItem::getDeliveryId,delivery.getId()))) {
                     throw new CoolException("鍗曟嵁鏄庣粏鍒犻櫎澶辫触锛�1");
                 }
             } else {
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/ReviseLogItemServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/ReviseLogItemServiceImpl.java
index df9136e..cf8c3b1 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/ReviseLogItemServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/ReviseLogItemServiceImpl.java
@@ -1,17 +1,14 @@
 package com.vincent.rsf.server.manager.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.vincent.rsf.framework.exception.CoolException;
 import com.vincent.rsf.server.manager.controller.params.ReviseLogItemParams;
-import com.vincent.rsf.server.manager.entity.Loc;
-import com.vincent.rsf.server.manager.entity.LocItem;
-import com.vincent.rsf.server.manager.entity.ReviseLog;
+import com.vincent.rsf.server.manager.entity.*;
 import com.vincent.rsf.server.manager.mapper.ReviseLogItemMapper;
-import com.vincent.rsf.server.manager.entity.ReviseLogItem;
-import com.vincent.rsf.server.manager.service.LocItemService;
-import com.vincent.rsf.server.manager.service.LocService;
-import com.vincent.rsf.server.manager.service.ReviseLogItemService;
+import com.vincent.rsf.server.manager.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.vincent.rsf.server.manager.service.ReviseLogService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -19,20 +16,26 @@
 
 import java.util.List;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
 @Service("reviseLogItemService")
 public class ReviseLogItemServiceImpl extends ServiceImpl<ReviseLogItemMapper, ReviseLogItem> implements ReviseLogItemService {
 
     @Autowired
-    private  ReviseLogService reviseLogService;
+    private ReviseLogService reviseLogService;
     @Autowired
     private LocItemService locItemService;
     @Autowired
     private LocService locService;
+    @Autowired
+    private ReviseLogItemService reviseLogItemService;
+    @Autowired
+    private LocReviseService locReviseService;
 
 
     /**
      * 淇濆瓨搴撳瓨璋冩暣鍘嗗彶鍗曟槑缁�
+     *
      * @param reviseLogItem
      * @return
      */
@@ -43,42 +46,73 @@
         if (Objects.isNull(reviseLog)) {
             throw new RuntimeException("搴撳瓨鍘嗗彶鍗曟嵁涓嶅瓨鍦紒锛�");
         }
-        Loc locItem = locService.getOne(new LambdaQueryWrapper<Loc>()
+        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>()
                 .eq(Loc::getCode, reviseLog.getLocCode()));
-        if (Objects.isNull(locItem)) {
+        if (Objects.isNull(loc)) {
             throw new RuntimeException("搴撲綅搴撳瓨涓嶅瓨鍦紒锛�");
         }
         List<ReviseLogItem> items = reviseLogItem.getItems();
+
+        this.remove(new LambdaQueryWrapper<ReviseLogItem>()
+                .eq(ReviseLogItem::getLocId, loc.getId()));
+
         items.forEach(item -> {
             ReviseLogItem logItem = new ReviseLogItem();
             BeanUtils.copyProperties(item, logItem);
             logItem.setReviseLogId(reviseLogItem.getReviseLogId())
                     .setUpdateBy(userId)
                     .setCreateBy(userId)
-                    .setLocId(locItem.getId())
-                    .setLocCode(locItem.getCode());
+                    .setLocId(loc.getId())
+                    .setLocCode(loc.getCode());
             if (Objects.isNull(item.getAnfme())) {
-                item.setAnfme(0.0);
+                logItem.setAnfme(0.0);
             }
-            if (!this.save(logItem)) {
+            if (!this.saveOrUpdate(logItem)) {
                 throw new RuntimeException("搴撳瓨鏄庣粏璋冩暣澶辫触");
             }
 
             LocItem one = locItemService.getOne(new LambdaQueryWrapper<LocItem>()
                     .eq(LocItem::getMatnrId, logItem.getMatnrId())
-                    .eq(LocItem::getBatch, logItem.getBatch())
-                    .eq(LocItem::getFieldsIndex, logItem.getFieldsIndex())
+                    .eq(StringUtils.isNotBlank(logItem.getBatch()), LocItem::getBatch, logItem.getBatch())
+                    .eq(StringUtils.isNotBlank(logItem.getFieldsIndex()), LocItem::getFieldsIndex, logItem.getFieldsIndex())
                     .eq(LocItem::getLocCode, logItem.getLocCode()));
             if (Objects.isNull(one)) {
-                throw new RuntimeException("搴撳瓨鏄庣粏涓嶅瓨鍦紒锛�");
-            }
-
-            one.setAnfme(logItem.getReviseQty());
-
-            if (!locItemService.updateById(one)) {
-                throw new RuntimeException("搴撳瓨鏄庣粏淇敼澶辫触锛侊紒");
+                LocItem locDetl = new LocItem();
+                BeanUtils.copyProperties(logItem, locDetl);
+                locDetl.setLocId(loc.getId())
+                        .setLocCode(loc.getCode())
+                        .setAnfme(logItem.getReviseQty())
+                        .setUpdateBy(userId)
+                        .setId(null)
+                        .setCreateBy(userId);
+                if (!locItemService.save(locDetl)) {
+                    throw new CoolException("搴撳瓨鏄庣粏淇濆瓨澶辫触锛侊紒");
+                }
+            } else {
+                one.setAnfme(logItem.getReviseQty());
+                if (!locItemService.updateById(one)) {
+                    throw new RuntimeException("搴撳瓨鏄庣粏淇敼澶辫触锛侊紒");
+                }
             }
         });
+
+        List<ReviseLog> list = reviseLogService.list(new LambdaQueryWrapper<ReviseLog>().eq(ReviseLog::getReviseId, reviseLog.getReviseId()));
+        if (Objects.isNull(list)) {
+            throw new RuntimeException("鏁版嵁閿欒锛氬簱瀛樿皟鏁村崟涓嶅瓨鍦紒锛�");
+        }
+        List<Long> reviseIds = list.stream().map(ReviseLog::getId).collect(Collectors.toList());
+        List<ReviseLogItem> logItems = reviseLogItemService.list(new LambdaQueryWrapper<ReviseLogItem>()
+                .in(ReviseLogItem::getReviseLogId, reviseIds));
+
+        Double anfems = logItems.stream().mapToDouble(ReviseLogItem::getAnfme).sum();
+        Double reviseQty = logItems.stream().mapToDouble(ReviseLogItem::getReviseQty).sum();
+
+        if (!locReviseService.update(new LambdaUpdateWrapper<LocRevise>()
+                .eq(LocRevise::getId, reviseLog.getReviseId())
+                        .set(LocRevise::getAnfme, anfems)
+                        .set(LocRevise::getReviseQty, reviseQty))) {
+            throw new RuntimeException("搴撳瓨璋冩暣鍗曚慨鏀瑰け璐ワ紒锛�");
+        }
         return items;
     }
 }
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/StockStatisticServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/StockStatisticServiceImpl.java
new file mode 100644
index 0000000..280d0ed
--- /dev/null
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/StockStatisticServiceImpl.java
@@ -0,0 +1,12 @@
+package com.vincent.rsf.server.manager.service.impl;
+
+import com.vincent.rsf.server.manager.mapper.StockStatisticMapper;
+import com.vincent.rsf.server.manager.entity.StockStatistic;
+import com.vincent.rsf.server.manager.service.StockStatisticService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+@Service("stockStatisticService")
+public class StockStatisticServiceImpl extends ServiceImpl<StockStatisticMapper, StockStatistic> implements StockStatisticService {
+
+}
diff --git a/rsf-server/src/main/java/stockStatistic.sql b/rsf-server/src/main/java/stockStatistic.sql
new file mode 100644
index 0000000..b82b7b1
--- /dev/null
+++ b/rsf-server/src/main/java/stockStatistic.sql
@@ -0,0 +1,31 @@
+-- save stockStatistic record
+-- mysql
+insert into `sys_menu` ( `name`, `parent_id`, `route`, `component`, `type`, `sort`, `tenant_id`, `status`) values ( 'menu.stockStatistic', '0', '/manager/stockStatistic', 'stockStatistic', '0' , '0', '1' , '1');
+
+insert into `sys_menu` ( `name`, `parent_id`, `type`, `authority`, `sort`, `tenant_id`, `status`) values ( 'Query 鏃ュ簱瀛樼粺璁�', '', '1', 'manager:stockStatistic:list', '0', '1', '1');
+insert into `sys_menu` ( `name`, `parent_id`, `type`, `authority`, `sort`, `tenant_id`, `status`) values ( 'Create 鏃ュ簱瀛樼粺璁�', '', '1', 'manager:stockStatistic:save', '1', '1', '1');
+insert into `sys_menu` ( `name`, `parent_id`, `type`, `authority`, `sort`, `tenant_id`, `status`) values ( 'Update 鏃ュ簱瀛樼粺璁�', '', '1', 'manager:stockStatistic:update', '2', '1', '1');
+insert into `sys_menu` ( `name`, `parent_id`, `type`, `authority`, `sort`, `tenant_id`, `status`) values ( 'Delete 鏃ュ簱瀛樼粺璁�', '', '1', 'manager:stockStatistic:remove', '3', '1', '1');
+
+-- locale menu name
+stockStatistic: 'StockStatistic',
+
+-- locale field
+stockStatistic: {
+    id: "id",
+    dayTime: "dayTime",
+    taskType: "taskType",
+    taskStatus: "taskStatus",
+    maktx: "maktx",
+    matnrCode: "matnrCode",
+    count: "count",
+    batch: "batch",
+    anfme: "anfme",
+    unit: "unit",
+},
+
+-- ResourceContent
+import stockStatistic from './stockStatistic';
+
+case 'stockStatistic':
+    return stockStatistic;
diff --git a/rsf-server/src/main/resources/mapper/manager/StockStatisticMapper.xml b/rsf-server/src/main/resources/mapper/manager/StockStatisticMapper.xml
new file mode 100644
index 0000000..f7a4309
--- /dev/null
+++ b/rsf-server/src/main/resources/mapper/manager/StockStatisticMapper.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.vincent.rsf.server.manager.mapper.StockStatisticMapper">
+
+</mapper>

--
Gitblit v1.9.1