caifc 3 éve
szülő
commit
2033d90239

+ 3 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/approvalFlow/domain/dto/AppAuditItemDTO.java

@@ -27,6 +27,9 @@ public class AppAuditItemDTO extends AuditItems {
     // 业务类型
     private String billType;
 
+    // 活动号集合
+    private List<Integer> actIdList;
+
     // 业务类型区间
     private List<String> billTypeList;
 

+ 1 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/approvalFlow/service/impl/AuditPathsServiceImpl.java

@@ -1159,6 +1159,7 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
             list.add(split[1] + " 23:59:59");
             auditItems.setSendList(list);
         }
+        auditItems.setActIdList(WarehouseActIdEnum.isWarehousingActList());
         // 查询
         List<AppAuditItemVO> appAuditItemVOList = auditItemsMapper.selectOrderAuditItems(auditItems);
         // 贸易方式

+ 9 - 1
ruoyi-warehouse/src/main/java/com/ruoyi/finance/service/impl/TFeeServiceImpl.java

@@ -181,7 +181,15 @@ public class TFeeServiceImpl implements ITFeeService {
                     sysDictData.setStatus("0");
                     sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
                 }
-                FeesTypeEnum feesTypeEnum = FeesTypeEnum.fromType(fees.getfSrcdc());
+                // 之前遗留汉字特别处理
+                FeesTypeEnum feesTypeEnum;
+                if (fees.getfSrcdc().equals("收")) {
+                    feesTypeEnum = FeesTypeEnum.D;
+                } else if (fees.getfSrcdc().equals("付")) {
+                    feesTypeEnum = FeesTypeEnum.C;
+                } else {
+                    feesTypeEnum = FeesTypeEnum.fromType(fees.getfSrcdc());
+                }
                 map1.put("fSrcdcName", feesTypeEnum.getName());
                 map1.put("fId", fees.getfId());
                 map1.put("fSrcid", fees.getfSrcid());

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

@@ -4,6 +4,7 @@ package com.ruoyi.reportManagement.mapper;
 import com.ruoyi.reportManagement.domain.TWhgenleg;
 import com.ruoyi.reportManagement.excel.Whgenleg;
 import com.ruoyi.warehouseBusiness.domain.TWarehouseBills;
+import com.ruoyi.warehouseBusiness.domain.vo.CalculateStorageFeesInfoVO;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.Date;
@@ -107,6 +108,7 @@ public interface TWhgenlegMapper {
      * @return
      */
     public List<Map<String, Object>> selectStorageFeeItemList(@Param("warehouse") TWarehouseBills tWarehouseBills);
+    public List<CalculateStorageFeesInfoVO> selectStorageFeeItemList1(@Param("warehouse") TWarehouseBills tWarehouseBills);
 
     /**
      * 查询库存总账列表

+ 14 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/domain/enums/WarehouseActIdEnum.java

@@ -89,4 +89,18 @@ public enum WarehouseActIdEnum {
         return integers;
     }
 
+    /**
+     * 获取仓储业务入库、出库、货转、调拨活动号集合
+     *
+     * @return
+     */
+    public static List<Integer> isWarehousingActList() {
+        ArrayList<Integer> integers = Lists.newArrayList();
+        integers.add(INSTOCK.actId);
+        integers.add(OUTSTOCK.actId);
+        integers.add(TRANSFER.actId);
+        integers.add(FORWARDING.actId);
+        return integers;
+    }
+
 }

+ 86 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/domain/vo/CalculateStorageFeesInfoVO.java

@@ -0,0 +1,86 @@
+package com.ruoyi.warehouseBusiness.domain.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author caifc
+ * @date 2021-10-22 9:43
+ */
+@Data
+public class CalculateStorageFeesInfoVO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    //id
+    private Long fId;
+
+    //业务编号
+    private String fBillno;
+
+    //物资Id
+    private Long fGoodsid;
+
+    //业务日期
+    private Date fBsdate;
+
+    //计费方式
+    private Long fBillingway;
+
+    //提单号
+    private String fMblno;
+
+    //计费开始日期
+    private Date fChargedate;
+
+    //原始入库日期
+    private Date fOriginalbilldate;
+
+    //唛头
+    private String fMarks;
+
+    //箱号
+    private String fCntrno;
+
+    //结余尺码
+    private BigDecimal fVolumn;
+
+    //结余数量
+    private Long fQty;
+
+    //结余毛重
+    private BigDecimal fGrossweight;
+
+    //结余净重
+    private BigDecimal fNetweight;
+
+    //仓库id
+    private Long warehouse;
+
+    //库区id
+    private Long warehouseLocationid;
+
+    //类型名称
+    private String fBilltype;
+
+    //是否按箱号统计
+    private String ifCntrno;
+
+    //商品类型
+    private String fTypeid;
+
+    //商品名
+    private String fGoodsids;
+
+    //计费天数
+    private Long fBillingDays;
+
+    //是否入库
+    private Long fIsInventory;
+
+    //原仓库
+    private String fOrgwarehouseInformation;
+
+}

+ 0 - 302
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/domain/vo/CalculateStorageFeesVO.java

@@ -1,302 +0,0 @@
-package com.ruoyi.warehouseBusiness.domain.vo;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.util.Date;
-
-/**
- * @author caifc
- * @date 2021-10-22 9:43
- */
-public class CalculateStorageFeesVO implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * 仓库id
-     */
-    private Long warehouse;
-
-    /**
-     * 明细id
-     */
-    private Long fId;
-
-    /**
-     * 明细编号
-     */
-    private String fBillno;
-
-    /**
-     * 明细商品id
-     */
-    private Long fGoodsid;
-
-    /**
-     * 明细入(出)库日期
-     */
-    private Date fBsdate;
-
-    /**
-     * 明细计费方式
-     */
-    private Long fBillingway;
-
-    /**
-     * 仓储计费日期
-     */
-    private Date fChargedate;
-
-    /**
-     * 原始入库日期
-     */
-    private Date fOriginalbilldate;
-
-    /**
-     * 提单号
-     */
-    private String fMblno;
-
-    /**
-     * 尺码
-     */
-    private BigDecimal fVolumn;
-
-    /**
-     * 唛头
-     */
-    private String fMarks;
-
-    /**
-     * 计费天数
-     */
-    private Long fBillingDays;
-
-    /**
-     * 是否入库0入总帐;1不计入总账(用于入库时候选择场地直装)
-     */
-    private Long fIsInventory;
-
-    /**
-     * 件数
-     */
-    private BigDecimal fQty;
-
-    /**
-     * 原仓库/库区/库位
-     */
-    private String fOrgwarehouseInformation;
-
-    /**
-     * 毛重
-     */
-    private BigDecimal fGrossweight;
-
-    /**
-     * 净重
-     */
-    private BigDecimal fNetweight;
-
-    /**
-     * 业务类型
-     */
-    private String fBilltype;
-
-    /**
-     * 商品类型
-     */
-    private Long fTypeid;
-
-    /**
-     * 商品名称
-     */
-    private String fGoodsids;
-
-    public Long getWarehouse() {
-        return warehouse;
-    }
-
-    public void setWarehouse(Long warehouse) {
-        this.warehouse = warehouse;
-    }
-
-    public Long getfId() {
-        return fId;
-    }
-
-    public void setfId(Long fId) {
-        this.fId = fId;
-    }
-
-    public String getfBillno() {
-        return fBillno;
-    }
-
-    public void setfBillno(String fBillno) {
-        this.fBillno = fBillno;
-    }
-
-    public Long getfGoodsid() {
-        return fGoodsid;
-    }
-
-    public void setfGoodsid(Long fGoodsid) {
-        this.fGoodsid = fGoodsid;
-    }
-
-    public Date getfBsdate() {
-        return fBsdate;
-    }
-
-    public void setfBsdate(Date fBsdate) {
-        this.fBsdate = fBsdate;
-    }
-
-    public Long getfBillingway() {
-        return fBillingway;
-    }
-
-    public void setfBillingway(Long fBillingway) {
-        this.fBillingway = fBillingway;
-    }
-
-    public Date getfChargedate() {
-        return fChargedate;
-    }
-
-    public void setfChargedate(Date fChargedate) {
-        this.fChargedate = fChargedate;
-    }
-
-    public Date getfOriginalbilldate() {
-        return fOriginalbilldate;
-    }
-
-    public void setfOriginalbilldate(Date fOriginalbilldate) {
-        this.fOriginalbilldate = fOriginalbilldate;
-    }
-
-    public String getfMblno() {
-        return fMblno;
-    }
-
-    public void setfMblno(String fMblno) {
-        this.fMblno = fMblno;
-    }
-
-    public BigDecimal getfVolumn() {
-        return fVolumn;
-    }
-
-    public void setfVolumn(BigDecimal fVolumn) {
-        this.fVolumn = fVolumn;
-    }
-
-    public String getfMarks() {
-        return fMarks;
-    }
-
-    public void setfMarks(String fMarks) {
-        this.fMarks = fMarks;
-    }
-
-    public Long getfBillingDays() {
-        return fBillingDays;
-    }
-
-    public void setfBillingDays(Long fBillingDays) {
-        this.fBillingDays = fBillingDays;
-    }
-
-    public Long getfIsInventory() {
-        return fIsInventory;
-    }
-
-    public void setfIsInventory(Long fIsInventory) {
-        this.fIsInventory = fIsInventory;
-    }
-
-    public BigDecimal getfQty() {
-        return fQty;
-    }
-
-    public void setfQty(BigDecimal fQty) {
-        this.fQty = fQty;
-    }
-
-    public String getfOrgwarehouseInformation() {
-        return fOrgwarehouseInformation;
-    }
-
-    public void setfOrgwarehouseInformation(String fOrgwarehouseInformation) {
-        this.fOrgwarehouseInformation = fOrgwarehouseInformation;
-    }
-
-    public BigDecimal getfGrossweight() {
-        return fGrossweight;
-    }
-
-    public void setfGrossweight(BigDecimal fGrossweight) {
-        this.fGrossweight = fGrossweight;
-    }
-
-    public BigDecimal getfNetweight() {
-        return fNetweight;
-    }
-
-    public void setfNetweight(BigDecimal fNetweight) {
-        this.fNetweight = fNetweight;
-    }
-
-    public String getfBilltype() {
-        return fBilltype;
-    }
-
-    public void setfBilltype(String fBilltype) {
-        this.fBilltype = fBilltype;
-    }
-
-    public Long getfTypeid() {
-        return fTypeid;
-    }
-
-    public void setfTypeid(Long fTypeid) {
-        this.fTypeid = fTypeid;
-    }
-
-    public String getfGoodsids() {
-        return fGoodsids;
-    }
-
-    public void setfGoodsids(String fGoodsids) {
-        this.fGoodsids = fGoodsids;
-    }
-
-    @Override
-    public String toString() {
-        return "CalculateStorageFeesVO{" +
-                "warehouse=" + warehouse +
-                ", fId=" + fId +
-                ", fBillno='" + fBillno + '\'' +
-                ", fGoodsid=" + fGoodsid +
-                ", fBsdate=" + fBsdate +
-                ", fBillingway=" + fBillingway +
-                ", fChargedate=" + fChargedate +
-                ", fOriginalbilldate=" + fOriginalbilldate +
-                ", fMblno='" + fMblno + '\'' +
-                ", fVolumn=" + fVolumn +
-                ", fMarks='" + fMarks + '\'' +
-                ", fBillingDays=" + fBillingDays +
-                ", fIsInventory=" + fIsInventory +
-                ", fQty=" + fQty +
-                ", fOrgwarehouseInformation='" + fOrgwarehouseInformation + '\'' +
-                ", fGrossweight=" + fGrossweight +
-                ", fNetweight=" + fNetweight +
-                ", fBilltype='" + fBilltype + '\'' +
-                ", fTypeid=" + fTypeid +
-                ", fGoodsids='" + fGoodsids + '\'' +
-                '}';
-    }
-}

+ 9 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/mapper/TWarehousebillsitemsMapper.java

@@ -4,6 +4,7 @@ package com.ruoyi.warehouseBusiness.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ruoyi.warehouseBusiness.domain.TWarehouseBills;
 import com.ruoyi.warehouseBusiness.domain.TWarehousebillsitems;
+import com.ruoyi.warehouseBusiness.domain.vo.CalculateStorageFeesInfoVO;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.Date;
@@ -78,6 +79,14 @@ public interface TWarehousebillsitemsMapper extends BaseMapper<TWarehousebillsit
     List<Map<String, Object>> selectStorageFeeItemList(@Param("warehouse") TWarehouseBills tWarehouseBills);
 
     /**
+     * 新增库存费计算
+     *
+     * @param tWarehouseBills 查询条件
+     * @return 结果
+     */
+    List<CalculateStorageFeesInfoVO> selectStorageFeeItemList1(@Param("warehouse") TWarehouseBills tWarehouseBills);
+
+    /**
      * 根据库存主表id更新 库存明细表对应状态
      *
      * @param fettle 状态

+ 270 - 1
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseBillsServiceImpl.java

@@ -50,6 +50,7 @@ import com.ruoyi.warehouseBusiness.domain.enums.FeesTypeEnum;
 import com.ruoyi.warehouseBusiness.domain.enums.WarehouseActIdEnum;
 import com.ruoyi.warehouseBusiness.domain.enums.WarehouseTypeEnum;
 import com.ruoyi.warehouseBusiness.domain.vo.AppWarehouseInfoVO;
+import com.ruoyi.warehouseBusiness.domain.vo.CalculateStorageFeesInfoVO;
 import com.ruoyi.warehouseBusiness.domain.vo.StorageFeeCalculationResultVO;
 import com.ruoyi.warehouseBusiness.excel.*;
 import com.ruoyi.warehouseBusiness.mapper.*;
@@ -3628,6 +3629,10 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
             }
             // 查询总账是否存在
             TWhgenleg tWhgenle = queryTWhgenleg(tWarehouseBills, wbItem, goods.getIfCntrno());
+
+            if (Objects.nonNull(tWhgenle) && wbItem.getfBsdate().before(tWarehouseBills.getfChargedate())) {
+                throw new WarehouseException("业务日期不得超出库存总帐日期");
+            }
             //  入库数特殊不判断入账
             if ("SJCK".equals(billsType)) { // 出库 查询
                 if (StringUtils.isNull(tWhgenle)) { // 为空 提示没有库存
@@ -4022,7 +4027,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                 storageFeesDto.setStartTime((Date) item.get("fOriginalbilldate"));
                 storageFeesDto.setEndTime(fBsdate);
             } else if (WarehouseTypeEnum.HQZY.getType().equals(fBilltype)) {
-                fInventoryDays = DateUtils.getDateDay(fBsdate, (Date) item.get("fOriginalbilldate"));
+                fInventoryDays = DateUtils.getDateDay(fBsdate, (Date) item.get("fChargedate"));
                 fBillingDays = fInventoryDays;
                 storageFeesDto.setStartTime(fBsdate);
                 storageFeesDto.setEndTime((Date) item.get("fOriginalbilldate"));
@@ -4033,6 +4038,9 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                 fInventoryDays = DateUtils.getDateDay(warehouseBills.getfBillingDeadline(), (Date) item.get("fOriginalbilldate"));
                 fBillingDays = DateUtils.getDateDay(warehouseBills.getfBillingDeadline(), (Date) item.get("fChargedate"));
             }
+            if (fBillingDays <= 0) {
+                continue;
+            }
             storageFeesDto.setDays(fBillingDays);
             storageFeesDto.setfMblno((String) item.get("fMblno"));
             // 赋值要计算的数量单位
@@ -4100,6 +4108,124 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         return map;
     }
 
+    public Map<String, Object> getWarehouseItems1(TWarehouseBills warehouseBills, List<CalculateStorageFeesInfoVO> feesInfoVOList, LoginUser loginUser, String cangKey) {
+        Map<String, Object> map = new HashMap<>();
+        BigDecimal sumAmt = new BigDecimal(0);
+        List<TWarehousebillsfees> itemsList = new ArrayList<>();
+        List<SysDictData> taxRate = sysDictDataMapper.selectDictDataByType("tax_rate");
+
+        for (CalculateStorageFeesInfoVO item : feesInfoVOList) {
+            if (StringUtils.isNull(item.getFBillingway())) {
+                throw new WarehouseException("单号:" + item.getFBillno() + ",业务日期:" + item.getFBsdate() + "未找到库存总账的计费单位,请确认");
+            }
+            CalculateStorageFeesDTO storageFeesDto = new CalculateStorageFeesDTO();
+            storageFeesDto.setfCorpid(warehouseBills.getfCorpid());
+            storageFeesDto.setCangKey(cangKey);
+            storageFeesDto.setWarehouseId(Long.parseLong(String.valueOf(item.getWarehouse())));
+
+            String fGoodsid = item.getFTypeid();
+            if (StringUtils.isNotEmpty(fGoodsid)) {
+                fGoodsid = "\"" + fGoodsid + "\"";
+            }
+            storageFeesDto.setfGoodsid(fGoodsid);
+
+            long fId = item.getFId();
+            // 累计计费天数
+            if (Objects.equals(item.getFChargedate().getTime(), item.getFOriginalbilldate().getTime())) {
+                storageFeesDto.setEarlySumDays(0L);
+            } else {
+                storageFeesDto.setEarlySumDays(DateUtils.getDateDay(item.getFChargedate(), item.getFOriginalbilldate()));
+            }
+            // 库存天数
+            long fInventoryDays;
+            // 要计费天数
+            long fBillingDays;
+            if (WarehouseTypeEnum.SJCK.getType().equals(item.getFBilltype())) {
+                fInventoryDays = DateUtils.getDateDay(item.getFBsdate(), item.getFChargedate());
+                fBillingDays = fInventoryDays;
+                storageFeesDto.setStartTime(item.getFOriginalbilldate());
+                storageFeesDto.setEndTime(item.getFBsdate());
+            } else if (WarehouseTypeEnum.HQZY.getType().equals(item.getFBilltype())) {
+                fInventoryDays = DateUtils.getDateDay(item.getFBsdate(), item.getFChargedate());
+                fBillingDays = fInventoryDays;
+                storageFeesDto.setStartTime(item.getFBsdate());
+                storageFeesDto.setEndTime(item.getFOriginalbilldate());
+            } else {
+                storageFeesDto.setStartTime(item.getFChargedate());
+                storageFeesDto.setEndTime(warehouseBills.getfBillingDeadline());
+                fInventoryDays = DateUtils.getDateDay(warehouseBills.getfBillingDeadline(), item.getFOriginalbilldate());
+                fBillingDays = DateUtils.getDateDay(warehouseBills.getfBillingDeadline(), item.getFChargedate());
+            }
+            if (fBillingDays <= 0) {
+                continue;
+            }
+            storageFeesDto.setDays(fBillingDays);
+            storageFeesDto.setfMblno(item.getFMblno());
+            // 赋值要计算的数量单位
+            storageFeesDto.setfQty(new BigDecimal(item.getFQty()));
+            storageFeesDto.setfVolumn(item.getFVolumn());
+            storageFeesDto.setfNetweight(item.getFNetweight());
+            storageFeesDto.setfGrossweight(item.getFGrossweight());
+            // 仓储费协议计算
+            StorageFeeCalculationResultVO feeCalculationResultVO = tWarehouseAgreementService.getCarryingCost(storageFeesDto);
+            if (Objects.isNull(feeCalculationResultVO)) {
+                continue;
+            }
+            String mblno = "";
+            if (StringUtils.isNotNull(item.getFMblno())) {
+                mblno = item.getFMblno();
+            }
+            map.put("feeId", feeCalculationResultVO.getFeeId());
+            map.put("itemFeeId", feeCalculationResultVO.getFeeId());
+            sumAmt = sumAmt.add(feeCalculationResultVO.getAmt());
+            TWarehousebillsfees fees = new TWarehousebillsfees();
+            fees.setfFeeid(feeCalculationResultVO.getFeeId());
+            fees.setfDc("D");
+            fees.setfAmt(feeCalculationResultVO.getAmt());
+            fees.setSrcId(fId);
+            fees.setfMblno(mblno);
+            fees.setRemark(feeCalculationResultVO.getRemark());
+            fees.setfFeeunitid(2L);
+            fees.setfAmount(feeCalculationResultVO.getAmt());
+            fees.setfBillstatus(2L);
+            fees.setfCurrency("RMB");
+            fees.setfBsdate(item.getFBsdate());
+            fees.setfBillingQty(feeCalculationResultVO.getQty());
+            fees.setfUnitprice(feeCalculationResultVO.getAmt());
+            fees.setfBilltype(item.getFBilltype());
+            fees.setCreateTime(new Date());
+            fees.setfBillingDays(fBillingDays);
+            fees.setfQty(new BigDecimal(1));
+            fees.setfPid(warehouseBills.getfId());
+            fees.setfInventoryDays(fInventoryDays);
+            fees.setfExrate(new BigDecimal(1));
+            fees.setPriceDateRemarks(feeCalculationResultVO.getBillingInterval());
+            fees.setfCorpid(warehouseBills.getfCorpid());
+            fees.setfMarks(item.getFMarks());
+            fees.setSrcBillNo(item.getFBillno());
+            fees.setCreateBy(loginUser.getUser().getUserName());
+            fees.setfWarehouseid(storageFeesDto.getWarehouseId());
+            fees.setfProductName(item.getFGoodsids());
+            if (WarehouseTypeEnum.SJCK.getType().equals(item.getFBilltype()) ||
+                    WarehouseTypeEnum.HQZY.getType().equals(item.getFBilltype())) {
+                fees.setfBillingDeadline(item.getFBsdate());
+            } else {
+                fees.setfBillingDeadline(warehouseBills.getfBillingDeadline());
+            }
+            fees.setfChargedate(item.getFChargedate());
+            fees.setfTaxrate(new BigDecimal(taxRate.get(0).getDictValue()));
+            fees.setfOriginalbilldate(item.getFOriginalbilldate());
+
+            fees.setfBillingway(feeCalculationResultVO.getUnit());
+
+            tWarehousebillsfeesMapper.insertTWarehousebillsfees(fees);
+            itemsList.add(fees);
+        }
+        map.put("sumAmt", sumAmt);
+        map.put("itemsList", itemsList);
+        return map;
+    }
+
     /**
      * 新增库存费计算
      *
@@ -4197,6 +4323,93 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         return AjaxResult.success(map);
     }
 
+    public AjaxResult calculateStorageFees1(TWarehouseBills tWarehouseBills, LoginUser loginUser, String billsType) {
+        if (StringUtils.isNull(tWarehouseBills.getfCorpid())) {
+            return AjaxResult.error("请选择客户信息");
+        }
+        tWarehouseBills.setfBillingDeadline(DateUtils.dateConversionMax(tWarehouseBills.getfBillingDeadline()));
+        long fPid;
+        if (StringUtils.isNull(tWarehouseBills.getfId())) {
+            // 生成流水号
+            Date time = new Date();
+            String billNo = billnoSerialServiceImpl.getSerialNumber(WarehouseTypeEnum.JSCCF.getType(), time);
+            tWarehouseBills.setfBillno(billNo);
+            if (StringUtils.isNull(tWarehouseBills.getfBillstatus())) {
+                tWarehouseBills.setfBillstatus(2L);
+            }
+            tWarehouseBills.setfBilltype(billsType);
+            tWarehouseBills.setfBsdeptid(loginUser.getUser().getDeptId());
+            tWarehouseBills.setCreateBy(loginUser.getUser().getUserName());
+            tWarehouseBills.setCreateTime(new Date());
+            tWarehouseBillsMapper.insertTWarehousebills(tWarehouseBills);
+            fPid = tWarehouseBills.getfId();
+        } else {
+            tWarehousebillsfeesMapper.deleteByFPid(tWarehouseBills.getfId());
+            tWarehousebillsitemsMapper.deleteByFPid(tWarehouseBills.getfId());
+            tWarehouseBills.setUpdateBy(loginUser.getUser().getUserName());
+            tWarehouseBills.setUpdateTime(new Date());
+            tWarehouseBillsMapper.updateTWarehousebills(tWarehouseBills);
+            fPid = tWarehouseBills.getfId();
+        }
+        // 计划物资明细
+        List<TWarehousebillsfees> itemsList = new ArrayList<>();
+        Map<String, Object> map = new HashMap<>();
+        //调一次公共方法,获取字符类型的true或者false传
+        String cangKey = sysConfigServiceImpl.selectConfigByKey("agreement.warehouse");
+        // 查出所有仓库 给后续匹配仓库名字使用
+        List<TWarehouse> warehouseList = tWarehouseMapper.selectTWarehouseList(new TWarehouse());
+        // 查询 出库 货转的库存明细
+        tWarehouseBills.setfId(null);
+        List<CalculateStorageFeesInfoVO> feesInfoVOList = tWarehousebillsitemsMapper.selectStorageFeeItemList1(tWarehouseBills);
+        tWarehouseBills.setfId(fPid);
+        if (CollectionUtils.isNotEmpty(feesInfoVOList)) {
+            Map<String, Object> mapItem = getWarehouseItems1(tWarehouseBills, feesInfoVOList, loginUser, cangKey);
+            if (mapItem.containsKey("error")) {
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return AjaxResult.error((String) mapItem.get("error"));
+            }
+            itemsList = (List<TWarehousebillsfees>) mapItem.get("itemsList");
+            // 给仓库信息赋值
+            itemsList.forEach(li -> {
+                TWarehouse tWarehouse = warehouseList.stream().filter(warehouse -> Objects.equals(warehouse.getfId(), li.getfWarehouseid()))
+                        .findFirst().orElseThrow(() -> new WarehouseException("找不到仓库信息"));
+                li.setWarehouseName(tWarehouse.getfName());
+            });
+        }
+        List<CalculateStorageFeesInfoVO> whgenlegfeesInfoVOList = tWhgenlegMapper.selectStorageFeeItemList1(tWarehouseBills);
+        if (CollectionUtils.isNotEmpty(whgenlegfeesInfoVOList)) {
+            // 如果是计算之前日期的库存总帐则需要使用当时日期的准确数量
+            if (!tWarehouseBills.getfBillingDeadline().after(new Date())) {
+                updateWhgenlegs1(tWarehouseBills, whgenlegfeesInfoVOList);
+            }
+
+            Map<String, Object> mapItem = getWarehouseItems1(tWarehouseBills, whgenlegfeesInfoVOList, loginUser, cangKey);
+            if (mapItem.containsKey("error")) {
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return AjaxResult.error((String) mapItem.get("error"));
+            }
+            List<TWarehousebillsfees> itemList = (List<TWarehousebillsfees>) mapItem.get("itemsList");
+            // 给仓库信息赋值
+            for (TWarehousebillsfees li : itemList) {
+                TWarehouse tWarehouse = warehouseList.stream().filter(warehouse -> Objects.equals(warehouse.getfId(), li.getfWarehouseid()))
+                        .findFirst().orElseThrow(() -> new WarehouseException("找不到仓库信息"));
+                li.setWarehouseName(tWarehouse.getfName());
+                itemsList.add(li);
+            }
+        }
+        TFees tFees = new TFees();
+        tFees.setfStatus("2");
+        tFees.setDelFlag("0");
+        List<TFees> feesList = tFeesMapper.selectTFeesList(tFees);
+        if (CollectionUtils.isEmpty(itemsList)) {
+            throw new WarehouseException("未找到合适的库存明细");
+        }
+        map.put("feesList", feesList);
+        map.put("warehouseBills", tWarehouseBills);
+        map.put("warehouseItemList", itemsList);
+        return AjaxResult.success(map);
+    }
+
     /**
      * 更新库存总帐当日实际
      *
@@ -4257,6 +4470,58 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         return tWhgenlegs;
     }
 
+    private void updateWhgenlegs1(TWarehouseBills tWarehouseBills, List<CalculateStorageFeesInfoVO> infoVOList) {
+        // 获取区间时间
+        tWarehouseBills.setItemBsDateList(timeConversion(tWarehouseBills.getfBillingDeadline(), new Date()));
+        // 查询时间区间内的仓储业务明细信息
+        List<TWarehousebillsitems> warehousebillsitemsList = tWarehousebillsitemsMapper.selectListByCorpId(tWarehouseBills);
+        // 如果没有则直接结束此方法
+        if (CollectionUtils.isEmpty(warehousebillsitemsList)) {
+            return;
+        }
+        infoVOList.forEach(whgenleg -> {
+            // 判断是否计算箱号 0为 不计算 1为计算
+            boolean ifCntrno = "1".equals(whgenleg.getIfCntrno());
+            // 组合一个库存总帐类使用
+            TWhgenleg tWhgenleg = new TWhgenleg();
+            tWhgenleg.setfCorpid(tWarehouseBills.getfCorpid());
+            tWhgenleg.setfQtyblc(whgenleg.getFQty());
+            tWhgenleg.setfMarks(whgenleg.getFMarks());
+            tWhgenleg.setfMblno(whgenleg.getFMblno());
+            tWhgenleg.setfCntrno(whgenleg.getFCntrno());
+            tWhgenleg.setfGoodsid(whgenleg.getFGoodsid());
+            tWhgenleg.setfNetweightblc(whgenleg.getFNetweight());
+            tWhgenleg.setfGrossweightblc(whgenleg.getFGrossweight());
+            tWhgenleg.setfWarehouseid(whgenleg.getWarehouseLocationid());
+
+            log.info("每次yuan件数、毛重、净重、:{}, {}, {}, {}", tWhgenleg.getfQtyblc(), tWhgenleg.getfVolumnblc(), tWhgenleg.getfNetweightblc(),
+                    tWhgenleg.getfGrossweightblc());
+
+            List<TWarehousebillsitems> itemList = new ArrayList<>();
+            for (TWarehousebillsitems li : warehousebillsitemsList) {
+                if ((!Objects.equals(li.getfGoodsid(), tWhgenleg.getfGoodsid())) ||
+                        (!Objects.equals(li.getfWarehouselocid(), tWhgenleg.getfWarehouseid()) || Objects.equals(li.getfTransferWarehouselocid(), tWhgenleg.getfWarehouseid())) ||
+                        !li.getfMblno().equals(tWhgenleg.getfMblno()) ||
+                        (!li.getfMarks().equals(tWhgenleg.getfMarks())) ||
+                        (ifCntrno && !li.getfCntrno().equals(tWhgenleg.getfCntrno()))
+                ) {
+                    continue;
+                }
+                itemList.add(li);
+            }
+            // 如果找不到符合条件的明细信息 直接结束此方法
+            if (CollectionUtils.isNotEmpty(itemList)) {
+                itemList.forEach(li -> updateWhgenlegCalculate(tWhgenleg, li));
+            }
+            log.info("每次的件数、毛重、净重、:{}, {}, {}, {}", tWhgenleg.getfQtyblc(), tWhgenleg.getfVolumnblc(), tWhgenleg.getfNetweightblc(),
+                    tWhgenleg.getfGrossweightblc());
+            // 覆盖数量、毛重、净重
+            whgenleg.setFQty(tWhgenleg.getfQtyblc());
+            whgenleg.setFNetweight(tWhgenleg.getfNetweightblc());
+            whgenleg.setFGrossweight(tWhgenleg.getfGrossweightblc());
+        });
+    }
+
     /**
      * 根据仓储明细更新库存总帐数量、毛重、净重
      *
@@ -6770,6 +7035,10 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
     @Override
     public AjaxResult feeReviewSubmit(Long id) {
         TWarehousebillsfees warehousebillsfees = tWarehousebillsfeesMapper.selectTWarehousebillsfeesById(id);
+        if (StringUtils.isNull(warehousebillsfees.getfCorpid()) || StringUtils.isNull(warehousebillsfees.getfFeeid()) ||
+                StringUtils.isNull(warehousebillsfees.getfFeeunitid())) {
+            throw new WarehouseException("请确认是否维护客户、费用信息、计价单位");
+        }
         if (Objects.isNull(warehousebillsfees) || Objects.nonNull(warehousebillsfees.getfReviewDate())) {
             throw new WarehouseException("未找到费用信息或费用已被审核");
         }

+ 4 - 0
ruoyi-warehouse/src/main/resources/mapper/approvalFlow/AuditItemsMapper.xml

@@ -388,6 +388,10 @@
             <foreach collection="audit.billTypeList" item="type" index="index" open="(" close=")" separator=",">
                 #{type}
             </foreach>
+            and a.act_id in
+            <foreach collection="audit.actIdList" item="actId" index="index" open="(" close=")" separator=",">
+                #{actId}
+            </foreach>
             and a.audit_user_id = #{audit.auditUserId}
             <if test='audit.auditStatus != null and audit.auditStatus!= ""'>
                 and a.audit_status = #{audit.auditStatus}

+ 2 - 2
ruoyi-warehouse/src/main/resources/mapper/finance/TFeeMapper.xml

@@ -757,7 +757,7 @@
             <if test="map.tWareHouseFees.fBillstatus != null">and w.f_billstatus = #{map.tWareHouseFees.fBillstatus}
             </if>
             and w.f_review_date IS NOT NULL
-            and abs(w.f_amount - w.f_stlamount) &gt; 0
+            and abs(IFNULL(w.f_amount, 0) - IFNULL(w.f_stlamount, 0)) &gt; 0
             GROUP BY w.f_id
         </where>
     </select>
@@ -1292,7 +1292,7 @@
                 and w.create_by = #{map.tWareHouseFees.createBy}
             </if>
             and w.f_review_date IS NOT NULL
-            and abs(w.f_amount - w.f_accamount) &gt; 0
+            and abs(IFNULL(w.f_amount, 0) - IFNULL(w.f_accamount, 0)) &gt; 0
             GROUP BY w.f_id
         </where>
     </select>

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

@@ -46,6 +46,30 @@
         <result property="fCustomno" column="f_customno"/>
     </resultMap>
 
+    <resultMap type="com.ruoyi.warehouseBusiness.domain.vo.CalculateStorageFeesInfoVO" id="StorageFeesInfoResult">
+        <result property="warehouse" column="f_warehouseid"/>
+        <result property="fId" column="f_id"/>
+        <result property="warehouse" column="f_warehouseid"/>
+        <result property="fBillno" column="f_billno"/>
+        <result property="fGoodsid" column="f_goodsid"/>
+        <result property="fBsdate" column="f_bsdate"/>
+        <result property="fBillingway" column="f_billingway"/>
+        <result property="fChargedate" column="f_chargedate"/>
+        <result property="fOriginalbilldate" column="f_originalbilldate"/>
+        <result property="fMblno" column="f_mblno"/>
+        <result property="fVolumn" column="f_volumn"/>
+        <result property="fMarks" column="f_marks"/>
+        <result property="fBillingDays" column="f_billing_days"/>
+        <result property="fIsInventory" column="f_is_inventory"/>
+        <result property="fQty" column="f_qty"/>
+        <result property="fOrgwarehouseInformation" column="f_orgwarehouse_information"/>
+        <result property="fGrossweight" column="f_grossweight"/>
+        <result property="fNetweight" column="f_netweight"/>
+        <result property="fBilltype" column="f_billtype"/>
+        <result property="fTypeid" column="f_typeid"/>
+        <result property="fGoodsids" column="f_name"/>
+    </resultMap>
+
     <sql id="selectTWhgenlegVo">
         select f_id, f_accyear, f_accmonth, f_corpid, f_mblno, f_originalbillno, f_warehouse_locationid, f_goodsid, f_trademodeid, f_preqty,
          f_pregrossweight, f_warehouseid, f_prenetweight, f_chargedate, f_volumnD, f_qtyD, f_billingway, f_grossweightD, f_netweightD, f_volumnC,
@@ -484,6 +508,42 @@
         </where>
     </select>
 
+    <select id="selectStorageFeeItemList1" resultType="java.util.Map" resultMap="StorageFeesInfoResult">
+        SELECT
+            wh.f_id AS fId,
+            wh.f_originalbillno AS fBillno,
+            wh.f_goodsid AS fGoodsid,
+            wh.f_originalbilldate AS fBsdate,
+            wh.f_billingway AS fBillingway,
+            wh.f_mblno AS fMblno,
+            wh.f_chargedate AS fChargedate,
+            wh.f_originalbilldate AS fOriginalbilldate,
+            wh.f_marks AS fMarks,
+            wh.f_cntrno AS fCntrno,
+            wh.f_volumnblc AS fVolumn,
+            wh.f_qtyblc AS fQty,
+            wh.f_grossweightblc AS fGrossweight,
+            wh.f_netweightblc AS fNetweight,
+            wh.f_warehouseid AS warehouse,
+            wh.f_warehouse_locationid AS warehouseLocationid,
+            "KCZZ" AS fBilltype,
+            goods.if_cntrno AS ifCntrno,
+            goods.f_typeid AS fTypeid,
+            goods.f_name AS fGoodsids
+        FROM
+            t_whgenleg wh
+            LEFT JOIN t_goods goods ON goods.f_id = wh.f_goodsid
+            LEFT JOIN t_warehouse ware ON ware.f_id = wh.f_warehouseid
+        <where>
+            wh.f_corpid = #{warehouse.fCorpid}
+            and ware.f_charg = 1
+            and wh.f_chargedate &lt; #{warehouse.fBillingDeadline}
+            <if test="warehouse.fGoodsid != null and warehouse.fGoodsid != ''">and wh.f_goodsid = #{warehouse.fGoodsid}</if>
+            <if test="warehouse.fMblno != null and warehouse.fMblno != ''">and wh.f_mblno like concat('%',#{warehouse.fMblno},'%')</if>
+            <if test="warehouse.fWarehouseid != null and warehouse.fWarehouseid != ''">and wh.f_warehouseid = #{warehouse.fWarehouseid}</if>
+        </where>
+    </select>
+
     <select id="selectInventoryList" parameterType="TWhgenleg" resultType="Map">
         select
             DISTINCT
@@ -867,4 +927,5 @@
         </foreach>
     </select>
 
+
 </mapper>

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

@@ -73,9 +73,10 @@
         <result property="isCalculateStorageFees"    column="is_calculate_storage_fees"    />
     </resultMap>
 
-    <resultMap type="CalculateStorageFeesVO" id="StorageFeesResult">
+    <resultMap type="com.ruoyi.warehouseBusiness.domain.vo.CalculateStorageFeesInfoVO" id="StorageFeesInfoResult">
         <result property="warehouse" column="f_warehouseid"/>
         <result property="fId" column="f_id"/>
+        <result property="warehouse" column="f_warehouseid"/>
         <result property="fBillno" column="f_billno"/>
         <result property="fGoodsid" column="f_goodsid"/>
         <result property="fBsdate" column="f_bsdate"/>
@@ -516,6 +517,48 @@
         </where>
     </select>
 
+    <select id="selectStorageFeeItemList1" resultMap="StorageFeesInfoResult">
+        SELECT
+            ware.f_warehouseid,
+            item.f_id,
+            item.f_billno,
+            item.f_goodsid,
+            item.f_bsdate,
+            item.f_billingway,
+            item.f_chargedate,
+            item.f_originalbilldate,
+            item.f_mblno,
+            item.f_volumn,
+            item.f_marks,
+            item.f_billing_days,
+            item.f_is_inventory,
+            item.f_qty,
+            item.f_orgwarehouse_information,
+            item.f_grossweight,
+            item.f_netweight,
+            item.f_billtype,
+            goods.f_typeid,
+            goods.f_name
+        FROM
+            t_warehousebills ware
+            LEFT JOIN t_warehousebillsitems item ON item.f_pid = ware.f_id
+            LEFT JOIN t_goods goods ON goods.f_id = item.f_goodsid
+            LEFT JOIN t_warehouse wa ON wa.f_id = ware.f_warehouseid
+        <where>
+            ware.f_corpid = #{warehouse.fCorpid}
+            <if test="warehouse.fId != null">and item.f_id = #{warehouse.fId}</if>
+            and ware.f_billtype in ("HQZY", "SJCK")
+            and wa.f_charg = 1
+            and item.f_storage_fee_deadline IS NULL
+            and item.f_bsdate &lt;= #{warehouse.fBillingDeadline}
+            and IF(ware.f_billtype = "SJCK", item.f_billstatus = 40,
+                item.f_billstatus = 6)
+            <if test="warehouse.fGoodsid != null and warehouse.fGoodsid != ''">and item.f_goodsid = #{warehouse.fGoodsid}</if>
+            <if test="warehouse.fWarehouseid != null and warehouse.fWarehouseid != ''">and ware.f_warehouseid = #{warehouse.fWarehouseid}</if>
+            <if test="warehouse.fMblno != null and warehouse.fMblno != ''">and ware.f_mblno like concat('%',#{warehouse.fMblno},'%')</if>
+        </where>
+    </select>
+
     <select id="warehousebillsitemsWarehouselocidSize" resultType="java.lang.Integer">
         SELECT
             COUNT( 1 )