Просмотр исходного кода

Merge remote-tracking branch 'origin/dev' into CangKu

zouzhuo 3 лет назад
Родитель
Сommit
f83a1fa622

+ 15 - 0
ruoyi-common/src/main/java/com/ruoyi/common/exception/WarehouseException.java

@@ -0,0 +1,15 @@
+package com.ruoyi.common.exception;
+
+/**
+ * @author caifc
+ * @date 2021-10-18 11:15
+ */
+public class WarehouseException extends RuntimeException {
+
+    /**
+     * @param msg 错误信息
+     */
+    public WarehouseException(String msg) {
+        super(msg);
+    }
+}

+ 59 - 57
ruoyi-warehouse/src/main/java/com/ruoyi/approvalFlow/service/impl/AuditPathsServiceImpl.java

@@ -268,10 +268,11 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
 
     /**
      * 查询审批流配置主信息条数
+     *
      * @return 结果
      */
     @Override
-    public int selectCountAuditItems(){
+    public int selectCountAuditItems() {
         return auditItemsMapper.selectCountAuditItems();
     }
 
@@ -340,9 +341,9 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                             tWarehouseBillsMapper.warehouseFollowUpdate(auditItems.getBillId(), fettle, at.getAuditItem());
                         }
                         tWarehousebillsfeesMapper.warehouseFeesFollowUpdate(auditItems.getBillId(), fettle, at.getAuditItem());
-                        if (Objects.equals(auditItems.getActId(), 150)) {
+                        if (Objects.equals(auditItems.getActId(), 150L)) {
                             List<TWarehousebillsfees> feesList = tWarehousebillsfeesMapper.selectWarehousebillsfeesByPId(auditItems.getBillId());
-                            if (StringUtils.isNull(feesList) || Objects.equals(feesList.size(), 0)) {
+                            if (CollectionUtils.isNotEmpty(feesList)) {
                                 for (TWarehousebillsfees f : feesList) {
                                     if ("KCZZ".equals(f.getfBilltype())) {
                                         TWhgenleg whgenleg = new TWhgenleg();
@@ -396,8 +397,8 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                             return ajaxResult;
                         }
-                    }else if (auditItems.getActId()== 410 ){
-                        if (StringUtils.isEmpty(auditItems.getRefno3())){
+                    } else if (auditItems.getActId() == 410) {
+                        if (StringUtils.isEmpty(auditItems.getRefno3())) {
                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                             return AjaxResult.error("提单号不能为空");
                         }
@@ -422,7 +423,7 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                             return orderMessage;
                         }
-                    }else if (auditItems.getActId()== 420 ){
+                    } else if (auditItems.getActId() == 420) {
                         if ("T".equals(at.getIffinalItem())) {
                             fettle = 11L;
                         } else if ("F".equals(at.getIffinalItem())) {
@@ -456,7 +457,7 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                             return ajaxResult;
                         }
-                    }else if (auditItems.getActId() == 470) {
+                    } else if (auditItems.getActId() == 470) {
                         // 财务模块
                         if ("T".equals(at.getIffinalItem())) {
                             fettle = 6L;
@@ -484,7 +485,7 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                             return invoiceFp;
                         }
-                    }else if (auditItems.getActId()== 460 ){
+                    } else if (auditItems.getActId() == 460) {
                         if ("T".equals(at.getIffinalItem())) {
                             fettle = 6L;
                         } else if ("F".equals(at.getIffinalItem())) {
@@ -492,12 +493,12 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                         }
                         //变更凯和订单状态
                         Integer i = tWarehousebillsfeesMapper.warehouseFeesFollowUpdate(auditItems.getBillId(), fettle, at.getAuditItem());
-                        if (i != null && i>0) {
-                        }else {
+                        if (i != null && i > 0) {
+                        } else {
                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                             return AjaxResult.error("审核失败,更新费用状态失败");
                         }
-                    }else if (auditItems.getActId()== 170 ){
+                    } else if (auditItems.getActId() == 170) {
                         //入库明细审核
                         if ("T".equals(at.getIffinalItem())) {
                             fettle = 6L;
@@ -511,12 +512,12 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                         tWarehouseBills.setfItemstatus(fettle);
                         i = tWarehouseBillsMapper.updateTWarehousebills(tWarehouseBills);
                         i = tWarehousebillsitemsMapper.warehouseItemfItemstatus(auditItems.getBillId(), fettle);
-                        if (i != null && i>0) {
-                        }else {
+                        if (i != null && i > 0) {
+                        } else {
                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                             return AjaxResult.error("审核失败,更新费用状态失败");
                         }
-                    }else if (auditItems.getActId()== 180 ){
+                    } else if (auditItems.getActId() == 180) {
                         //入库明细审核
                         if ("T".equals(at.getIffinalItem())) {
                             fettle = 6L;
@@ -530,8 +531,8 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                         tWarehouseBills.setfItemstatus(fettle);
                         i = tWarehouseBillsMapper.updateTWarehousebills(tWarehouseBills);
                         i = tWarehousebillsitemsMapper.warehouseItemfItemstatus(auditItems.getBillId(), fettle);
-                        if (i != null && i>0) {
-                        }else {
+                        if (i != null && i > 0) {
+                        } else {
                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                             return AjaxResult.error("审核失败,更新费用状态失败");
                         }
@@ -562,7 +563,7 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                         TWarehouseBills tWarehouseBills = new TWarehouseBills();
                         tWarehouseBills.setfId(auditItems.getBillId());
                         tWarehouseBills.setfSubmitUpdate(fettle);
-                        if (fettle == 6L){
+                        if (fettle == 6L) {
                             tWarehouseBills.setfUpdeteStatus(2L);
                             tWarehouseBills.setfSubmitUpdate(2L);
                         }
@@ -583,7 +584,7 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                         tWarehouseBills.setfId(auditItems.getBillId());
                         tWarehouseBills.setfDeleteStatus(fettle);
                         tWarehouseBillsMapper.updateKaHeOrder(tWarehouseBills);
-                    }else if (auditItems.getActId()== 474 ){
+                    } else if (auditItems.getActId() == 474) {
                         if ("F".equals(at.getIffinalItem())) {
                             fettle = 5L;
                         } else if ("T".equals(at.getIffinalItem())) {
@@ -601,7 +602,7 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                         tWarehouseBills.setfId(auditItems.getBillId());
                         tWarehouseBills.setfDismountStatus(fettle);
                         tWarehouseBillsMapper.updateKaHeOrder(tWarehouseBills);
-                    } else if (auditItems.getActId()== 181 ){
+                    } else if (auditItems.getActId() == 181) {
                         if ("T".equals(at.getIffinalItem())) {
                             fettle = 6L;
                         } else if ("F".equals(at.getIffinalItem())) {
@@ -693,23 +694,23 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return ajaxResult;
             }
-        }else if (auditItems.getActId()== 410){
+        } else if (auditItems.getActId() == 410) {
             fettle = 3L;
-            AjaxResult ajaxResult = tWarehouseBillsService.updateKaHeOrder(auditItems.getBillId(), fettle,auditItems.getAuditItem());
+            AjaxResult ajaxResult = tWarehouseBillsService.updateKaHeOrder(auditItems.getBillId(), fettle, auditItems.getAuditItem());
             String code = ajaxResult.get("code").toString();
             if ("500".equals(code)) {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return ajaxResult;
             }
-        }else if (auditItems.getActId()== 420){
+        } else if (auditItems.getActId() == 420) {
             fettle = 8L;
-            AjaxResult ajaxResult = tWarehouseBillsService.updateKaHeOrder(auditItems.getBillId(), fettle,auditItems.getAuditItem());
+            AjaxResult ajaxResult = tWarehouseBillsService.updateKaHeOrder(auditItems.getBillId(), fettle, auditItems.getAuditItem());
             String code = ajaxResult.get("code").toString();
             if ("500".equals(code)) {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return ajaxResult;
             }
-        }else if (auditItems.getActId() >= 430 && auditItems.getActId() <= 450) {
+        } else if (auditItems.getActId() >= 430 && auditItems.getActId() <= 450) {
             fettle = 3L;
             // 财务模块
             AjaxResult ajaxResult = tFeeServiceImpl.tfeeFollow(auditItems.getBillId(), fettle);
@@ -718,15 +719,15 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return ajaxResult;
             }
-        } else if (auditItems.getActId()== 460){
+        } else if (auditItems.getActId() == 460) {
             fettle = 3L;
             Integer i = tWarehousebillsfeesMapper.warehouseFeesFollowUpdate(auditItems.getBillId(), fettle, auditItems.getAuditItem());
-            if (i != null && i>0){
-            }else{
+            if (i != null && i > 0) {
+            } else {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return AjaxResult.error("审批驳回失败,更新费用状态失败");
             }
-        }else if (auditItems.getActId() == 470) {
+        } else if (auditItems.getActId() == 470) {
             fettle = 3L;
             // 财务模块
             AjaxResult ajaxResult = tFeeServiceImpl.tfeeFollow(auditItems.getBillId(), fettle);
@@ -735,7 +736,7 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return ajaxResult;
             }
-        }else if (auditItems.getActId()== 170 ){
+        } else if (auditItems.getActId() == 170) {
             //入库明细审核
             fettle = 3L;
             //变更仓库入库明细审核状态
@@ -745,12 +746,12 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
             tWarehouseBills.setfItemstatus(fettle);
             i = tWarehouseBillsMapper.updateTWarehousebills(tWarehouseBills);
             i = tWarehousebillsitemsMapper.warehouseItemfItemstatus(auditItems.getBillId(), fettle);
-            if (i != null && i>0) {
-            }else {
+            if (i != null && i > 0) {
+            } else {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return AjaxResult.error("审核失败,更新费用状态失败");
             }
-        }else if (auditItems.getActId()== 180 ){
+        } else if (auditItems.getActId() == 180) {
             //入库明细审核
             fettle = 3L;
             //变更仓库入库明细审核状态
@@ -760,8 +761,8 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
             tWarehouseBills.setfItemstatus(fettle);
             i = tWarehouseBillsMapper.updateTWarehousebills(tWarehouseBills);
             i = tWarehousebillsitemsMapper.warehouseItemfItemstatus(auditItems.getBillId(), fettle);
-            if (i != null && i>0) {
-            }else {
+            if (i != null && i > 0) {
+            } else {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return AjaxResult.error("审核失败,更新费用状态失败");
             }
@@ -786,14 +787,14 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
             tWarehouseBills.setfId(auditItems.getBillId());
             tWarehouseBills.setfDeleteStatus(fettle);
             tWarehouseBillsMapper.updateKaHeOrder(tWarehouseBills);
-        }else if (auditItems.getActId()== 474 ){
-             fettle = 3L;
+        } else if (auditItems.getActId() == 474) {
+            fettle = 3L;
             //变更凯和拆单单状态
             TWarehouseBills tWarehouseBills = new TWarehouseBills();
             tWarehouseBills.setfId(auditItems.getBillId());
             tWarehouseBills.setfDismountStatus(fettle);
             tWarehouseBillsMapper.updateKaHeOrder(tWarehouseBills);
-        } else if (auditItems.getActId()== 181 ){
+        } else if (auditItems.getActId() == 181) {
             fettle = 3L;
             //业务处理
         }
@@ -904,33 +905,33 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return AjaxResult.error("审批撤销失败: 更新审批状态失败");
             }
-        }else if (auditItems.getActId()== 410 ){
+        } else if (auditItems.getActId() == 410) {
             fettle = 2L;
             TWarehouseBills tWarehouseBills = tWarehouseBillsService.selectKaHeById(auditItems.getBillId());
-            if (tWarehouseBills.getfBillstatus()!= 4L){
+            if (tWarehouseBills.getfBillstatus() != 4L) {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return AjaxResult.error("审批撤销失败: 已经过审批");
             }
-            AjaxResult ajaxResult = tWarehouseBillsService.updateKaHeOrder(auditItems.getBillId(), fettle,auditItems.getAuditItem());
+            AjaxResult ajaxResult = tWarehouseBillsService.updateKaHeOrder(auditItems.getBillId(), fettle, auditItems.getAuditItem());
             String code = ajaxResult.get("code").toString();
             if ("500".equals(code)) {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return ajaxResult;
             }
-        }else if (auditItems.getActId()== 420 ){
+        } else if (auditItems.getActId() == 420) {
             fettle = 7L;
             TWarehouseBills tWarehouseBills = tWarehouseBillsService.selectKaHeById(auditItems.getBillId());
-            if (tWarehouseBills.getfBillstatus() != 9L){
+            if (tWarehouseBills.getfBillstatus() != 9L) {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return AjaxResult.error("审批撤销失败: 已经过审批");
             }
-            AjaxResult ajaxResult = tWarehouseBillsService.updateKaHeOrder(auditItems.getBillId(), fettle,auditItems.getAuditItem());
+            AjaxResult ajaxResult = tWarehouseBillsService.updateKaHeOrder(auditItems.getBillId(), fettle, auditItems.getAuditItem());
             String code = ajaxResult.get("code").toString();
             if ("500".equals(code)) {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return ajaxResult;
             }
-        }else if (auditItems.getActId() >= 430 && auditItems.getActId() <= 450) {
+        } else if (auditItems.getActId() >= 430 && auditItems.getActId() <= 450) {
             fettle = 2L;
             // 查询财务状态
             TFee tFee = tFeeMapper.selectTFeeById(auditItems.getBillId());
@@ -945,21 +946,22 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return AjaxResult.error("审批撤销失败: 更新审批状态失败");
             }
-        }else if (auditItems.getActId()== 460 ){
+        } else if (auditItems.getActId() == 460) {
             fettle = 2L;
             TWarehousebillsfees warehousebillsfees = new TWarehousebillsfees();
             warehousebillsfees.setfPid(auditItems.getBillId());
             List<TWarehousebillsfees> tWarehousebillsfees = tWarehousebillsfeesMapper.selectTWarehousebillsfeesList(warehousebillsfees);
-            if (CollectionUtils.isNotEmpty(tWarehousebillsfees) && tWarehousebillsfees.get(0).getfBillstatus() != 4L){
+            if (CollectionUtils.isNotEmpty(tWarehousebillsfees) && tWarehousebillsfees.get(0).getfBillstatus() != 4L) {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return AjaxResult.error("审批撤销失败: 已经过审批");
             }
             Integer i = tWarehousebillsfeesMapper.warehouseFeesFollowUpdate(auditItems.getBillId(), fettle, auditItems.getAuditItem());
-            if (i != null && i>0){}else  {
+            if (i != null && i > 0) {
+            } else {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return AjaxResult.error("审核失败,更新费用状态失败");
             }
-        }else if (auditItems.getActId() == 470) {
+        } else if (auditItems.getActId() == 470) {
             fettle = 2L;
             // 查询财务状态
             TFee tFee = tFeeMapper.selectTFeeById(auditItems.getBillId());
@@ -974,7 +976,7 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return AjaxResult.error("审批撤销失败: 更新审批状态失败");
             }
-        }else if (auditItems.getActId()== 170 ){
+        } else if (auditItems.getActId() == 170) {
             //入库明细审核
             fettle = 2L;
             //变更仓库入库明细审核状态
@@ -984,12 +986,12 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
             tWarehouseBills.setfItemstatus(fettle);
             i = tWarehouseBillsMapper.updateTWarehousebills(tWarehouseBills);
             i = tWarehousebillsitemsMapper.warehouseItemfItemstatus(auditItems.getBillId(), fettle);
-            if (i != null && i>0) {
-            }else {
+            if (i != null && i > 0) {
+            } else {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return AjaxResult.error("审核失败,更新费用状态失败");
             }
-        }else if (auditItems.getActId()== 180 ){
+        } else if (auditItems.getActId() == 180) {
             //入库明细审核
             fettle = 2L;
             //变更仓库入库明细审核状态
@@ -999,12 +1001,12 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
             tWarehouseBills.setfItemstatus(fettle);
             i = tWarehouseBillsMapper.updateTWarehousebills(tWarehouseBills);
             i = tWarehousebillsitemsMapper.warehouseItemfItemstatus(auditItems.getBillId(), fettle);
-            if (i != null && i>0) {
-            }else {
+            if (i != null && i > 0) {
+            } else {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return AjaxResult.error("审核失败,更新费用状态失败");
             }
-        }else if (auditItems.getActId() == 471) {
+        } else if (auditItems.getActId() == 471) {
             fettle = 2L;
             // 变更凯和申请修改订单状态
             TWarehouseBills tWarehouseBills = new TWarehouseBills();
@@ -1025,14 +1027,14 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
             tWarehouseBills.setfId(auditItems.getBillId());
             tWarehouseBills.setfDeleteStatus(fettle);
             tWarehouseBillsMapper.updateKaHeOrder(tWarehouseBills);
-        }else if (auditItems.getActId()== 474 ){
+        } else if (auditItems.getActId() == 474) {
             fettle = 2L;
             //变更凯和拆单单状态
             TWarehouseBills tWarehouseBills = new TWarehouseBills();
             tWarehouseBills.setfId(auditItems.getBillId());
             tWarehouseBills.setfDismountStatus(fettle);
             tWarehouseBillsMapper.updateKaHeOrder(tWarehouseBills);
-        }else if (auditItems.getActId()== 181 ){
+        } else if (auditItems.getActId() == 181) {
             fettle = 2L;
             //业务处理
         }

+ 42 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/finance/WarehouseType.java

@@ -0,0 +1,42 @@
+package com.ruoyi.finance;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.Objects;
+
+/**
+ * @author caifc
+ * @date 2021-10-18 14:39
+ */
+@Getter
+@AllArgsConstructor
+public enum WarehouseType {
+
+    // 库存总帐
+    KCZZ("KCZZ"),
+
+    // 出库
+    SJCK("SJCK"),
+
+    // 货转
+    HQZY("HQZY"),
+
+    // 调拨
+    CKDB("CKDB"),
+
+    ;
+
+    private final String type;
+
+
+    public static WarehouseType fromType(Integer tp) {
+        for (WarehouseType type : WarehouseType.values()) {
+            if (Objects.equals(type.getType(), tp)) {
+                return type;
+            }
+        }
+        throw new IllegalArgumentException("warehouse type not exist");
+    }
+
+}

+ 20 - 2
ruoyi-warehouse/src/main/java/com/ruoyi/reportManagement/mapper/TWhgenlegMapper.java

@@ -6,6 +6,7 @@ import com.ruoyi.reportManagement.excel.Whgenleg;
 import com.ruoyi.warehouseBusiness.domain.TWarehouseBills;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -82,21 +83,26 @@ public interface TWhgenlegMapper {
     public int updateTWhgenlegData(@Param("map") Map<String, Object> map);
 
     List<Map<String, Object>> selectInventoryList(TWhgenleg tWhgenleg);
+
     List<Map<String, Object>> selectWhgenlegList(TWhgenleg tWhgenleg);
 
     List<Map<String, Object>> selectGoodsList();
+
     List<Map<String, Object>> selectGoodsListWhouse(Long fId);
 
     List<Map<String, Object>> selectWareHouseList();
+
     List<Map<String, Object>> selectWareHouseListWhouse(Long fId);
 
     List<Map<String, Object>> selectCorpsList();
+
     List<Map<String, Object>> selectCorpsListWhouse(Long fId);
 
     List<Map<String, Object>> selectDateFQtyblcListList(@Param("map") Map<String, Object> map);
 
     /**
-     *  查询库存总账计算仓储费
+     * 查询库存总账计算仓储费
+     *
      * @param tWarehouseBills
      * @return
      */
@@ -104,6 +110,7 @@ public interface TWhgenlegMapper {
 
     /**
      * 查询库存总账列表
+     *
      * @param tWhgenleg 库存总账
      * @return 库存总账集合
      */
@@ -111,15 +118,26 @@ public interface TWhgenlegMapper {
 
     /**
      * 库存总账导出
+     *
      * @param tWhgenleg
      * @return
      */
-    List <Whgenleg> selectWhgenlegMessage(TWhgenleg tWhgenleg);
+    List<Whgenleg> selectWhgenlegMessage(TWhgenleg tWhgenleg);
 
     /**
      * 根据客户id或者提单号查询库存不为0的仓库
+     *
      * @param tWhgenleg
      * @return
      */
     public List<Map<String, Object>> getWarehouse(TWhgenleg tWhgenleg);
+
+    /**
+     * 根据id查询仓储费计费日期是否发生变化
+     *
+     * @param ids        id集合
+     * @param chargedate 校验日期
+     * @return
+     */
+    int queryChangedByFchargedate(@Param("ids") List<Long> ids, @Param("time")Date chargedate);
 }

+ 48 - 16
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/mapper/TWarehousebillsitemsMapper.java

@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ruoyi.warehouseBusiness.domain.TWarehouseBills;
 import com.ruoyi.warehouseBusiness.domain.TWarehousebillsitems;
 import org.apache.ibatis.annotations.Param;
-import org.springframework.security.core.parameters.P;
 
 import java.util.Date;
 import java.util.List;
@@ -72,15 +71,17 @@ public interface TWarehousebillsitemsMapper extends BaseMapper<TWarehousebillsit
 
     /**
      * 新增库存费计算
+     *
      * @param tWarehouseBills 查询条件
-     * @return  结果
+     * @return 结果
      */
     List<Map<String, Object>> selectStorageFeeItemList(@Param("warehouse") TWarehouseBills tWarehouseBills);
 
     /**
-     *  根据库存主表id更新 库存明细表对应状态
+     * 根据库存主表id更新 库存明细表对应状态
+     *
      * @param fettle 状态
-     * @param fPid 主表id
+     * @param fPid   主表id
      * @return 结果
      */
     int warehouseItemFollowUpdate(@Param("fPid") Long fPid, @Param("fettle") Long fettle);
@@ -88,60 +89,66 @@ public interface TWarehousebillsitemsMapper extends BaseMapper<TWarehousebillsit
     int warehousebillsitemsWarehouselocidSize(@Param("fWarehouselocid") Long fPid);
 
     /**
-     *  计算仓储费撤回根据状态判断修改对应字段
+     * 计算仓储费撤回根据状态判断修改对应字段
+     *
      * @param billsItem
      * @return
      */
     int agreementApprovalRejected(TWarehousebillsitems billsItem);
 
     /**
-     *  入库待办数
+     * 入库待办数
      */
     int inStock();
 
     /**
-     *  出库待办数
+     * 出库待办数
      */
     int outStock();
 
     /**
-     *  当月入库待办数
+     * 当月入库待办数
      */
     int monthInStock(@Param("timeInterval") List<String> timeInterval);
 
     /**
-     *  当月出库待办数
+     * 当月出库待办数
      */
     int monthOutStock(@Param("timeInterval") List<String> timeInterval);
 
     public List<Map<String, Object>> selectWarehouseBusinesInList(TWarehousebillsitems billsItem);
+
     public List<Map<String, Object>> selectWarehouseBusinesOutList(TWarehousebillsitems billsItem);
 
     /**
-     *  根据id查询明细详情数据
+     * 根据id查询明细详情数据
+     *
      * @param fId
      * @return
      */
     public Map<String, Object> selectWarehouseItemsByPId(Long fId);
 
     /**
-     *  根据主表id查询明细是否存在已入库、出库、货转、调拨的明细
-     * @param fId    主表id
-     * @return  结果
+     * 根据主表id查询明细是否存在已入库、出库、货转、调拨的明细
+     *
+     * @param fId 主表id
+     * @return 结果
      */
     public int selectItemFStatusByFPid(Long fId);
 
     public TWarehousebillsitems selectItemQtyByFPid(Long fPid);
 
     /**
-     *  根据主表id查询明细状态
+     * 根据主表id查询明细状态
+     *
      * @param fId
      * @return
      */
     public List<TWarehousebillsitems> selectItemsStatusByPid(Long fId);
 
     /**
-     *  根据主表id查询明细最小日期
+     * 根据主表id查询明细最小日期
+     *
      * @param fId
      * @return
      */
@@ -149,6 +156,7 @@ public interface TWarehousebillsitemsMapper extends BaseMapper<TWarehousebillsit
 
     /**
      * 获取最小仓储费计算日期
+     *
      * @param fPid
      * @return
      */
@@ -156,6 +164,7 @@ public interface TWarehousebillsitemsMapper extends BaseMapper<TWarehousebillsit
 
     /**
      * 如果是按最小入库日期计算仓储费更新其他入库明细的仓储费计算日期
+     *
      * @param fPid
      * @param fChargedate
      * @return
@@ -165,6 +174,7 @@ public interface TWarehousebillsitemsMapper extends BaseMapper<TWarehousebillsit
 
     /**
      * 更新入库明细审核状态
+     *
      * @param fPid
      * @param fItemstatus
      * @return
@@ -174,14 +184,17 @@ public interface TWarehousebillsitemsMapper extends BaseMapper<TWarehousebillsit
 
     /**
      * 将出库收费明细里删除的仓储费的来源入库明细的仓储费计算截止日期更新为空
+     *
      * @param fPid
      * @param fId
      * @return
      */
     public int updatefStorageFeeDeadline(@Param("fPid") Long fPid,
                                          @Param("fId") List<Long> fId);
+
     /**
      * 将出库收费明细里删除的仓储费的来源入库明细的仓储费计算截止日期更新为空
+     *
      * @param fPid
      * @return
      */
@@ -189,7 +202,26 @@ public interface TWarehousebillsitemsMapper extends BaseMapper<TWarehousebillsit
 
     /**
      * 查询明细表箱号
+     *
+     * @return
+     */
+    public List<Map<String, Object>> selectStorageFeeItemfTruckNo();
+
+    /**
+     * 根据id查询仓储费计费日期是否发生变化
+     *
+     * @param ids        id集合
+     * @param chargedate 校验日期
+     * @return
+     */
+    int queryChangedByFchargedate(@Param("ids") List<Long> ids, @Param("time") Date chargedate);
+
+    /**
+     * 根据id查询仓储费计费截止日期是否发生变化
+     *
+     * @param ids        id集合
+     * @param chargedate 校验日期
      * @return
      */
-    public List<Map<String,Object>> selectStorageFeeItemfTruckNo();
+    int queryChangedByFstorageFeeDeadline(@Param("ids") List<Long> ids, @Param("time") Date chargedate);
 }

+ 42 - 20
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseBillsServiceImpl.java

@@ -21,11 +21,13 @@ import com.ruoyi.common.core.domain.entity.SysDictData;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.domain.entity.TWarehouse;
 import com.ruoyi.common.core.domain.model.LoginUser;
+import com.ruoyi.common.exception.WarehouseException;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.ip.AddressUtils;
 import com.ruoyi.common.utils.poi.ExcelUtils;
+import com.ruoyi.finance.WarehouseType;
 import com.ruoyi.quotation.domain.TSeaprice;
 import com.ruoyi.quotation.mapper.TSeapriceMapper;
 import com.ruoyi.reportManagement.domain.TWareHouseItemsExcel;
@@ -45,6 +47,7 @@ import com.ruoyi.warehouseBusiness.domain.*;
 import com.ruoyi.warehouseBusiness.excel.*;
 import com.ruoyi.warehouseBusiness.mapper.*;
 import com.ruoyi.warehouseBusiness.service.ITWarehouseBillsService;
+import lombok.AllArgsConstructor;
 import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.CellRangeAddress;
@@ -76,6 +79,7 @@ import static java.util.stream.Collectors.toList;
  * @date 2020-12-11
  */
 @Service
+@AllArgsConstructor
 public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
 
     @Autowired
@@ -1053,9 +1057,9 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         TWarehousebillsCntr tWarehousebillsCntr = tWarehousebillsCntrMapper.selectTWarehousebillsCntrByPId(warehouseBills.getfId());
         int cntritemsfPid = tWarehousebillsCntritemsMapper.deleteTWarehousebillsCntritemsfPid(warehouseBills.getfId());
         if (CollectionUtils.isNotEmpty(tWarehousebillsCntrs)) {
-            if (tWarehousebillsCntrs.size() > tWarehousebillsCntr.getfCntrcount()){
+            if (tWarehousebillsCntrs.size() > tWarehousebillsCntr.getfCntrcount()) {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                return  AjaxResult.error("箱信息中的箱量不能大于货物中的箱量");
+                return AjaxResult.error("箱信息中的箱量不能大于货物中的箱量");
             }
             for (TWarehousebillsCntritems warehousebillsCntritems : tWarehousebillsCntrs) {
                 AjaxResult ajaxResult = this.judgeBoxPile(warehousebillsCntritems, tWarehousebillsCntr.getfCntrid());
@@ -1069,9 +1073,9 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                 warehousebillsCntritems.setCreateBy(SecurityUtils.getUsername());
                 int cntr = tWarehousebillsCntritemsMapper.insertTWarehousebillsCntritems(warehousebillsCntritems);
             }
-        }else {
+        } else {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-            return  AjaxResult.error("箱信息不能为空");
+            return AjaxResult.error("箱信息不能为空");
         }
         map.put("warehouseBills", warehouseBills);
         map.put("tWarehousebillsCntrs", tWarehousebillsCntrs);
@@ -1144,7 +1148,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                 warehousebillsCntritems.setCreateBy(SecurityUtils.getUsername());
                 int cntr = tWarehousebillsCntritemsMapper.insertTWarehousebillsCntritems(warehousebillsCntritems);
             }
-        }else {
+        } else {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             return AjaxResult.error("箱信息不能为空");
         }
@@ -4841,6 +4845,23 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         tWarehousebillsfeesMapper.warehouseFeesFollowUpdate(tWarehousebills.getfId(), 2L, new Date());
         if ("JSCCF".equals(tWarehousebills.getfBilltype())) {
             List<TWarehousebillsfees> feesList = tWarehousebillsfeesMapper.selectWarehousebillsfeesByPId(fId);
+            // 取出本次变更的日期
+            Date chargedate = DateUtils.dateAdd(tWarehousebills.getfBillingDeadline(), 1);
+            // 过滤出总帐信息id集合查询是否存在变更的
+            List<Long> generalLedgerIds = feesList.stream().filter(li -> Objects.nonNull(li.getSrcId()) && Objects.equals(WarehouseType.KCZZ.getType(), li.getfBilltype()))
+                    .map(TWarehousebillsfees::getSrcId).collect(toList());
+            // 判断库存总账是否存在二次计算
+            if (!generalLedgerIds.isEmpty() && tWhgenlegMapper.queryChangedByFchargedate(generalLedgerIds, chargedate) > 0) {
+                throw new WarehouseException("审批撤销失败,库存总账存在二级计算");
+            }
+            // 过滤货转库信息id集合查询是否存在变更的
+            List<Long> forwardingIds = feesList.stream().filter(li -> Objects.nonNull(li.getSrcId()) && Objects.equals(WarehouseType.HQZY.getType(), li.getfBilltype()))
+                    .map(TWarehousebillsfees::getSrcId).collect(toList());
+            // 判断货转是否存在二次计算
+            if (!forwardingIds.isEmpty() && tWarehousebillsitemsMapper.queryChangedByFchargedate(forwardingIds, chargedate) > 0) {
+                throw new WarehouseException("审批撤销失败,货转明细存在二级计算");
+            }
+
             for (TWarehousebillsfees wareItem : feesList) {
                 if (StringUtils.isNull(wareItem.getSrcId())) {
                     continue;
@@ -6099,7 +6120,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
      */
     public AjaxResult judgeBoxPile(TWarehousebillsCntritems tWarehousebillsCntritems, Long fId) {
         //判断箱子是否存在
-        if (StringUtils.isEmpty(tWarehousebillsCntritems.getfCntrno())){
+        if (StringUtils.isEmpty(tWarehousebillsCntritems.getfCntrno())) {
             return AjaxResult.error("箱号不能为空");
         }
         TCntrno tCntrno = tCntrnoMapper.selectTCnTrNoByfNo(tWarehousebillsCntritems.getfCntrno());
@@ -6281,9 +6302,9 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         if ("0".equals(sysConfig.getConfigValue())) {
             isApprove = true;
         }
-        if (isApprove){
+        if (isApprove) {
             billStatus = 4L;
-        }else {
+        } else {
             billStatus = 6L;
         }
         TWarehouseBills warehouseBills = JSONArray.parseObject(tWarehousebills, TWarehouseBills.class); //新单主表信息
@@ -6305,9 +6326,9 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             return AjaxResult.error("分单箱量不能超出原单数量");
         }
-        if (CollectionUtils.isNotEmpty(tWarehousebillsCntrs)){
+        if (CollectionUtils.isNotEmpty(tWarehousebillsCntrs)) {
             TWarehousebillsCntr cnTrWareHouse = tWarehousebillsCntrs.get(0);
-            if(cnTrWareHouse.getfCntrcount() >=Cntr.getfCntrcount() ){
+            if (cnTrWareHouse.getfCntrcount() >= Cntr.getfCntrcount()) {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return AjaxResult.error("分单箱量不能超出原单数量");
             }
@@ -6462,9 +6483,9 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
             // 存储业务类型(业务类型)
             auditItems.setRefno2(warehouseBills.getfBilltype());
             // 存储提单号(提单号)
-            if (StringUtils.isNotEmpty(warehouseBills.getfMblno())){
+            if (StringUtils.isNotEmpty(warehouseBills.getfMblno())) {
                 auditItems.setRefno3(warehouseBills.getfMblno());
-            }else {
+            } else {
                 auditItems.setRefno3(warehouseBills.getfBillno());
             }
             auditItems.setSendUserId(SecurityUtils.getLoginUser().getUser().getUserId());
@@ -6510,18 +6531,19 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
 
     /**
      * 审批通过修改原单信息
+     *
      * @param orderId
      * @return
      */
     @Override
     @Transactional
-    public AjaxResult approveDismount(Long orderId){
+    public AjaxResult approveDismount(Long orderId) {
         TWarehouseBills warehouseBills = tWarehouseBillsMapper.selectTWarehousebillsById(orderId);
         //获取原单信息
         TWarehouseBills bills = new TWarehouseBills();
         bills.setfBillno(warehouseBills.getfOriginalbillno());
         List<TWarehouseBills> tWarehouseBillsList = tWarehouseBillsMapper.webVersionOrderList(bills);
-        if (CollectionUtils.isEmpty(tWarehouseBillsList)){
+        if (CollectionUtils.isEmpty(tWarehouseBillsList)) {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             return AjaxResult.error("未查到原单信息");
         }
@@ -6530,17 +6552,17 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         TWarehousebillsCntr wareHouseBillsCnTr = tWarehousebillsCntrMapper.selectTWarehousebillsCntrByPId(orderId);
         //获取旧单信息 修改货物信息中的箱量
         TWarehousebillsCntr billsCnTr = tWarehousebillsCntrMapper.selectTWarehousebillsCntrByPId(selectOne.getfId());
-        if (wareHouseBillsCnTr.getfCntrcount() >= billsCnTr.getfCntrcount()){
+        if (wareHouseBillsCnTr.getfCntrcount() >= billsCnTr.getfCntrcount()) {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-            return AjaxResult.error("拆单数量不能超过或等于原单数量,现在原单数量为" + billsCnTr.getfCntrcount()+"个。");
+            return AjaxResult.error("拆单数量不能超过或等于原单数量,现在原单数量为" + billsCnTr.getfCntrcount() + "个。");
         }
         billsCnTr.setUpdateBy(SecurityUtils.getUsername());
         billsCnTr.setUpdateTime(new Date());
-        billsCnTr.setfCntrcount(billsCnTr.getfCntrcount()-wareHouseBillsCnTr.getfCntrcount());
+        billsCnTr.setfCntrcount(billsCnTr.getfCntrcount() - wareHouseBillsCnTr.getfCntrcount());
         tWarehousebillsCntrMapper.updateTWarehousebillsCntr(billsCnTr);//修改原单货物信息中的箱量
         //修改原单的费用信息
         List<TWarehousebillsfees> WarehousebillsfeesList = tWarehousebillsfeesMapper.selectWarehousebillsfeesByPId(selectOne.getfId());
-        if (CollectionUtils.isNotEmpty(WarehousebillsfeesList)){
+        if (CollectionUtils.isNotEmpty(WarehousebillsfeesList)) {
             //修改原单费用
             for (TWarehousebillsfees tWarehousebillsfees : WarehousebillsfeesList) {
                 tWarehousebillsfees.setUpdateBy(SecurityUtils.getUsername());
@@ -6552,9 +6574,9 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         }
         //修改原单箱信息
         List<TWarehousebillsCntritems> tWarehousebillsCntritemsList = tWarehousebillsCntritemsMapper.selectTWarehousebillsCntritemsByPId(orderId);
-        if (CollectionUtils.isNotEmpty(tWarehousebillsCntritemsList)){
+        if (CollectionUtils.isNotEmpty(tWarehousebillsCntritemsList)) {
             for (TWarehousebillsCntritems warehousebillsCntritems : tWarehousebillsCntritemsList) {
-                tWarehousebillsCntritemsMapper.deleteTWarehousebillsCntritemOlder(selectOne.getfId(),warehousebillsCntritems.getfCntrno());
+                tWarehousebillsCntritemsMapper.deleteTWarehousebillsCntritemOlder(selectOne.getfId(), warehousebillsCntritems.getfCntrno());
             }
         }
         return AjaxResult.success();

+ 12 - 0
ruoyi-warehouse/src/main/resources/mapper/reportManagement/TWhgenlegMapper.xml

@@ -846,4 +846,16 @@
           AND f_mblno = #{fMblno}
     </select>
 
+    <select id="queryChangedByFchargedate" resultType="java.lang.Integer">
+        SELECT
+            count( f_id )
+        FROM
+            t_whgenleg
+        WHERE
+            f_chargedate != #{time}
+        <foreach collection="ids" item="id" open="and f_id in(" separator="," close=")">
+            #{id}
+        </foreach>
+    </select>
+
 </mapper>

+ 25 - 1
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsitemsMapper.xml

@@ -476,7 +476,7 @@
             and wa.f_charg = 1
             and item.f_billstatus = 40
             and item.f_storage_fee_deadline IS NULL
-            and item.f_chargedate &lt;= #{warehouse.fBillingDeadline}
+            and IF(ware.f_billtype = "SJCK", item.f_bsdate &lt;#{warehouse.fBillingDeadline}, item.f_chargedate &lt;= #{warehouse.fBillingDeadline})
             <if test="warehouse.fGoodsid != null">and item.f_goodsid = #{warehouse.fGoodsid}</if>
             <if test="warehouse.fMblno != null">and ware.f_mblno = #{warehouse.fMblno}</if>
            <!--  <if test="warehouse.fId != null">and item.f_id = #{warehouse.fId}</if> -->
@@ -769,4 +769,28 @@
         ORDER BY CONVERT(f_truckno USING gbk) asc
     </select>
 
+    <select id="queryChangedByFchargedate" resultType="java.lang.Integer">
+        SELECT
+            count( f_id )
+        FROM
+            t_warehousebillsitems
+        WHERE
+        <foreach collection="ids" item="id" open="f_id in(" separator="," close=")">
+            #{id}
+        </foreach>
+            and f_chargedate != #{time}
+    </select>
+
+    <select id="queryChangedByFstorageFeeDeadline" resultType="java.lang.Integer">
+        SELECT
+            count( f_id )
+        FROM
+            t_warehousebillsitems
+        WHERE
+        <foreach collection="ids" item="id" open="f_id in(" separator="," close=")">
+            #{id}
+        </foreach>
+            and f_storage_fee_deadline != #{time}
+    </select>
+
 </mapper>