Browse Source

入库单批量删除bug修改

dfsfs 1 year ago
parent
commit
3d61fdb6ed

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/wms/asn/WmsDocAsnHeaderController.java

@@ -116,7 +116,7 @@ public class WmsDocAsnHeaderController extends BaseController {
     @Log(title = "入库单", businessType = BusinessType.DELETE)
     @DeleteMapping("/{asnNos}")
     public AjaxResult remove(@PathVariable String[] asnNos) {
-        return toAjax(wmsDocAsnHeaderService.deleteWmsDocAsnHeaderByAsnNos(asnNos));
+        return wmsDocAsnHeaderService.deleteWmsDocAsnHeaderByAsnNos(asnNos);
     }
 
     /**

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

@@ -8,7 +8,7 @@ spring:
             master:
                 url: jdbc:mysql://localhost:3306/warewms-xuankuang_cy?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
                 username: root
-                password: 123455
+                password: 123456
                 driverClassName: com.mysql.cj.jdbc.Driver
             # 从库数据源
             slave:

+ 1 - 1
warewms-ams/src/main/java/com/ruoyi/ams/asn/service/IWmsDocAsnHeaderService.java

@@ -74,7 +74,7 @@ public interface IWmsDocAsnHeaderService {
      * @param asnNos 需要删除的入库单主键集合
      * @return 结果
      */
-    int deleteWmsDocAsnHeaderByAsnNos(String[] asnNos);
+    AjaxResult deleteWmsDocAsnHeaderByAsnNos(String[] asnNos);
 
     /**
      * 删除入库单信息

+ 25 - 2
warewms-ams/src/main/java/com/ruoyi/ams/asn/service/impl/WmsDocAsnHeaderServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ruoyi.ams.asn.service.impl;
 
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.lang.Assert;
 import com.ruoyi.ams.asn.domain.WmsDocAsnDetails;
 import com.ruoyi.ams.asn.domain.WmsDocAsnExportTime;
 import com.ruoyi.ams.asn.domain.WmsDocAsnHeader;
@@ -212,9 +213,31 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
      */
     @Transactional
     @Override
-    public int deleteWmsDocAsnHeaderByAsnNos(String[] asnNos) {
+    public AjaxResult deleteWmsDocAsnHeaderByAsnNos(String[] asnNos) {
+
+        List<String> asnNosList = Arrays.asList(asnNos);
+        ArrayList<WmsDocAsnHeader> WmsDocAsnHeaders = new ArrayList<>();
+        ArrayList<String> asnNoWrongStatus = new ArrayList<>();
+        // 判断入库单状态为00新建状态才进行删除
+        asnNosList.stream().forEach(asnNo->{
+            WmsDocAsnHeader wmsDocAsnHeader = wmsDocAsnHeaderMapper.selectWmsDocAsnHeaderByAsnNo(asnNo);
+            String asnStatus = wmsDocAsnHeader.getAsnStatus();
+            if (asnStatus.equals(Constant.ASN_STS.STS00.getValue())){
+                WmsDocAsnHeaders.add(wmsDocAsnHeader);
+            } else asnNoWrongStatus.add(wmsDocAsnHeader.getAsnNo());//获取状态不符合的单号
+        });
+        // 获取到符合条件的入库单号
+        asnNos = WmsDocAsnHeaders.stream().map(w -> w.getAsnNo()).toArray(String[]::new);
+        //判断是否有符合条件的入库单
+        Assert.isTrue(asnNos.length>0,"所选入库单状态异常不能删除");
         wmsDocAsnHeaderMapper.deleteWmsDocAsnDetailsByAsnNos(asnNos);
-        return wmsDocAsnHeaderMapper.deleteWmsDocAsnHeaderByAsnNos(asnNos);
+        wmsDocAsnHeaderMapper.deleteWmsDocAsnHeaderByAsnNos(asnNos);
+
+        if (asnNoWrongStatus.size()>0){
+            return AjaxResult.success("入库单"+Arrays.deepToString(asnNos)+"已删除;"+"入库单"+asnNoWrongStatus.toString()+"状态异常未删除");
+        }
+
+        return AjaxResult.success();
     }
 
     /**