Browse Source

update bug

caifc 3 years ago
parent
commit
3ecc9caf5a

+ 35 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java

@@ -5,6 +5,10 @@ import org.apache.commons.lang3.time.DateFormatUtils;
 import java.lang.management.ManagementFactory;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.ZoneId;
 import java.util.*;
 
 /**
@@ -330,4 +334,35 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
         return tagDateTime.before(new Date());
     }
 
+    /**
+     *  返货传入时间当天最大值
+     * @param date
+     * @return
+     */
+    public static Date dateConversionMax(Date date) {
+        LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(date.getTime()), ZoneId.systemDefault());
+        LocalDateTime startOfDay = localDateTime.with(LocalTime.MAX);
+        return Date.from(startOfDay.atZone(ZoneId.systemDefault()).toInstant());
+    }
+
+    /**
+     *  返货传入时间当天最小值
+     * @param date
+     * @return
+     */
+    public static Date dateConversionMin(Date date) {
+        LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(date.getTime()), ZoneId.systemDefault());
+        LocalDateTime startOfDay = localDateTime.with(LocalTime.MIN);
+        return Date.from(startOfDay.atZone(ZoneId.systemDefault()).toInstant());
+    }
+
+    /**
+     *  传入时间返回时间戳
+     * @param date
+     * @return
+     */
+    public static String dateToString (Date date){
+        return parseDateToStr(YYYY_MM_DD_HH_MM_SS, date);
+    }
+
 }

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

@@ -2,7 +2,6 @@ package com.ruoyi.approvalFlow.service.impl;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.ruoyi.approvalFlow.domain.*;
 import com.ruoyi.approvalFlow.mapper.*;
@@ -19,7 +18,6 @@ import com.ruoyi.finance.mapper.TFeeMapper;
 import com.ruoyi.finance.service.impl.TFeeServiceImpl;
 import com.ruoyi.reportManagement.domain.TWhgenleg;
 import com.ruoyi.reportManagement.mapper.TWhgenlegMapper;
-import com.ruoyi.system.mapper.SysUserMapper;
 import com.ruoyi.warehouseBusiness.domain.TWarehouseAgreement;
 import com.ruoyi.warehouseBusiness.domain.TWarehouseBills;
 import com.ruoyi.warehouseBusiness.domain.TWarehousebillsfees;
@@ -358,7 +356,7 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                             List<TWarehousebillsfees> feesList = tWarehousebillsfeesMapper.selectWarehousebillsfeesByPId(auditItems.getBillId());
                             // 过滤出明细信息查询是否存在已计算仓储费
                             List<Long> ids = feesList.stream().map(TWarehousebillsfees::getSrcId).distinct().collect(toList());
-                            if (tWarehousebillsitemsMapper.selectIsCalculateStorageFeesByIds(ids) > 0) {
+                            if (CollectionUtils.isNotEmpty(ids) && tWarehousebillsitemsMapper.selectIsCalculateStorageFeesByIds(ids) > 0) {
                                 throw new WarehouseException("计算费用中存在已计算仓储费信息");
                             }
                             // 获取仓储费,并判断费用中是否存在仓储费
@@ -1088,6 +1086,8 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
         } else if (auditItems.getActId() == 181) {
             fettle = 2L;
             //业务处理
+        } else if (Objects.equals(auditItems.getActId(), WarehouseActIdEnum.FEE_CHANGES.getActId().longValue())) {
+            warehousebillsModifyService.withdrawalApprovalById(auditItems.getBillId());
         }
         int deleteNum = auditItemsMapper.deletePurchaseApproval(auditItems);
         if (deleteNum == 0) {

+ 19 - 1
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/domain/TWarehouseBills.java

@@ -1,5 +1,6 @@
 package com.ruoyi.warehouseBusiness.domain;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
@@ -688,18 +689,35 @@ public class TWarehouseBills extends BaseEntity {
     //客户名称
     private String corpName;
     //查询时间区间
+    @TableField(exist = false)
     private List<String> cLoadDate;
     //查询箱使日期时间区间
+    @TableField(exist = false)
     private List<String> freeContainerList;
+    //查询子订单业务日期时间区间
+    @TableField(exist = false)
+    private List<String> itemBsDateList;
     //应收款信息
+    @TableField(exist = false)
     private List<TWarehousebillsfees> tWarehousebillsfeesDr;
     //应付款信息
+    @TableField(exist = false)
     private List<TWarehousebillsfees> warehousebillsfeesCr;
     //费用状态
+    @TableField(exist = false)
     private Long moneyStatus;
     //凯和订单ID
+    @TableField(exist = false)
     private Long[] orderId;
 
+    public List<String> getItemBsDateList() {
+        return itemBsDateList;
+    }
+
+    public void setItemBsDateList(List<String> itemBsDateList) {
+        this.itemBsDateList = itemBsDateList;
+    }
+
     public Long getfCargoPlanning() {
         return fCargoPlanning;
     }
@@ -1008,7 +1026,7 @@ public class TWarehouseBills extends BaseEntity {
     public List<String> gettimeInterval() {
         return timeInterval;
     }
-    
+
     /**
      * 查询计费截止日期区间
      */

+ 19 - 7
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/domain/TWarehousebillsitems.java

@@ -1,5 +1,6 @@
 package com.ruoyi.warehouseBusiness.domain;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
@@ -346,6 +347,17 @@ public class TWarehousebillsitems extends BaseEntity {
     @Excel(name = "是否计算仓储费(应对出库单是否计算过仓储费)")
     private String isCalculateStorageFees;
 
+    @TableField(exist = false)
+    private Long fTocorpid;
+
+    public Long getfTocorpid() {
+        return fTocorpid;
+    }
+
+    public void setfTocorpid(Long fTocorpid) {
+        this.fTocorpid = fTocorpid;
+    }
+
     public String getIsCalculateStorageFees() {
         return isCalculateStorageFees;
     }
@@ -366,16 +378,16 @@ public class TWarehousebillsitems extends BaseEntity {
      * 场地直装,D:入库明细 C 出库明细
      */
     private String fDc;
-    
+
     public String getfDc() {
-		return fDc;
-	}
+        return fDc;
+    }
 
-	public void setfDc(String fDc) {
-		this.fDc = fDc;
-	}
+    public void setfDc(String fDc) {
+        this.fDc = fDc;
+    }
 
-	public Long getfCartypeId() {
+    public Long getfCartypeId() {
         return fCartypeId;
     }
 

+ 12 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/domain/dto/CalculateStorageFeesDto.java

@@ -13,6 +13,9 @@ import java.util.Date;
 public class CalculateStorageFeesDto implements Serializable {
     private static final long serialVersionUID = 1L;
 
+    //提单号
+    private String fMblno;
+
     //出库客户Id
     private Long fCorpid;
 
@@ -47,6 +50,15 @@ public class CalculateStorageFeesDto implements Serializable {
     // 计费其他
     private BigDecimal fVolumn;
 
+
+    public String getfMblno() {
+        return fMblno;
+    }
+
+    public void setfMblno(String fMblno) {
+        this.fMblno = fMblno;
+    }
+
     public Long getfCorpid() {
         return fCorpid;
     }

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

@@ -259,4 +259,12 @@ public interface TWarehousebillsitemsMapper extends BaseMapper<TWarehousebillsit
      * @return
      */
     List<TWarehousebillsitems> selectByBsDateList(@Param("starDate") Date starDate, @Param("endDate") Date endDate);
+
+    /**
+     *  根据客户id、时间区间、状态查询仓储明细
+     * @param tWarehouseBills
+     * @return
+     */
+    List<TWarehousebillsitems> selectListByCorpId(@Param("bills") TWarehouseBills tWarehouseBills);
+
 }

+ 13 - 3
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseAgreementServiceImpl.java

@@ -455,7 +455,7 @@ public class TWarehouseAgreementServiceImpl implements ITWarehouseAgreementServi
                         storageFeesDto.getfGoodsid(),
                         String.valueOf(storageFeesDto.getWarehouseId()), storageFeesDto.getCangKey());
         if (CollUtil.isEmpty(itemList)) {
-            throw new WarehouseException("未找到计费规则");
+            throw new WarehouseException("编号" + storageFeesDto.getfMblno() + "未找到计费规则");
         }
         // 如果仓储费出现两个不同计费单位就进行抛异常
         long count = itemList.stream().map(TWarehouseAgreementitems::getfFeeunitid).distinct().count();
@@ -477,9 +477,13 @@ public class TWarehouseAgreementServiceImpl implements ITWarehouseAgreementServi
         // 计费区间  月日-月日X钱
         String billingInterval = "";
         for (TWarehouseAgreementitems tWarehouseAgreementitems : itemList) {
-            if (storageFeesDto.getDays() < 1) break;
-            if (storageFeesDto.getEarlySumDays() >= tWarehouseAgreementitems.getfEndays())
+            if (storageFeesDto.getDays() < 1) {
+                break;
+            }
+            if (storageFeesDto.getEarlySumDays() >= tWarehouseAgreementitems.getfEndays()) {
+                storageFeesDto.setEarlySumDays(storageFeesDto.getEarlySumDays() - tWarehouseAgreementitems.getfEndays());
                 continue; //将已算账的天数 与 计费规则的 最后一天作比较如果 已算10天 > 规则结束  不算帐
+            }
             // 计算仓储日期
             dayLength = tWarehouseAgreementitems.getfEndays() - tWarehouseAgreementitems.getfFromdays() + 1L; //阶梯中的结束-开始日期
 
@@ -487,6 +491,12 @@ public class TWarehouseAgreementServiceImpl implements ITWarehouseAgreementServi
             String interval;
 
             if (storageFeesDto.getDays() >= dayLength) {
+                if (dayLength < storageFeesDto.getEarlySumDays()) {
+                    storageFeesDto.setEarlySumDays(storageFeesDto.getEarlySumDays() - tWarehouseAgreementitems.getfEndays());
+                } else {
+                    dayLength = dayLength - storageFeesDto.getEarlySumDays();
+                }
+
                 feeId = tWarehouseAgreementitems.getfFeeid();
                 BigDecimal calculate = this.getCalculate(qty, tWarehouseAgreementitems.getfPrice(), dayLength);
                 money = money.add(calculate);

+ 175 - 15
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseBillsServiceImpl.java

@@ -4012,18 +4012,22 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
 
             long fId = Long.valueOf(String.valueOf(item.get("fId")));
             // 累计计费天数
-            storageFeesDto.setEarlySumDays(DateUtils.getDateDay((Date) item.get("fChargedate"), (Date) item.get("fOriginalbilldate")));
+            if (Objects.equals(((Date) item.get("fChargedate")).getTime(), ((Date) item.get("fOriginalbilldate")).getTime())) {
+                storageFeesDto.setEarlySumDays(0L);
+            } else {
+                storageFeesDto.setEarlySumDays(DateUtils.getDateDay((Date) item.get("fChargedate"), (Date) item.get("fOriginalbilldate")));
+            }
             // 库存天数
             long fInventoryDays;
             // 要计费天数
             long fBillingDays;
-            if ("SJCK".equals(fBilltype)) {
+            if (WarehouseTypeEnum.SJCK.getType().equals(fBilltype)) {
                 fInventoryDays = DateUtils.getDateDay(fBsdate, (Date) item.get("fOriginalbilldate"));
                 fBillingDays = fInventoryDays;
                 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("fOriginalbilldate")) ;
                 fBillingDays = fInventoryDays;
                 storageFeesDto.setStartTime(fBsdate);
                 storageFeesDto.setEndTime((Date) item.get("fOriginalbilldate"));
@@ -4034,6 +4038,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                 fBillingDays = DateUtils.getDateDay(warehouseBills.getfBillingDeadline(), (Date) item.get("fChargedate"));
             }
             storageFeesDto.setDays(fBillingDays);
+            storageFeesDto.setfMblno((String) item.get("fMblno"));
             // 赋值要计算的数量单位
             storageFeesDto.setfQty(new BigDecimal(String.valueOf(item.get("fQty"))));
             storageFeesDto.setfVolumn(new BigDecimal(String.valueOf(item.get("fQty"))));
@@ -4043,7 +4048,6 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
             StorageFeeCalculationResultVO feeCalculationResultVO = tWarehouseAgreementService.getCarryingCost(storageFeesDto);
             if (Objects.isNull(feeCalculationResultVO)) {
                 continue;
-//                throw new WarehouseException("单号:" + item.get("fBillno") + ",业务日期:" + item.get("fBsdate") + "未找到仓储费协议,请确认");
             }
             String mblno = "";
             if (StringUtils.isNotNull(item.get("fMblno"))) {
@@ -4080,15 +4084,12 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
             fees.setCreateBy(loginUser.getUser().getUserName());
             fees.setfWarehouseid(storageFeesDto.getWarehouseId());
             fees.setfProductName(item.get("fGoodsids").toString());
-            if (Objects.equals(WarehouseTypeEnum.SJCK.getType(), fBilltype) ||
-                    Objects.equals(WarehouseTypeEnum.HQZY.getType(), fBilltype)) {
+            if (WarehouseTypeEnum.SJCK.getType().equals(fBilltype) ||
+                    WarehouseTypeEnum.HQZY.getType().equals(fBilltype)) {
                 fees.setfChargedate((Date) item.get("fOriginalbilldate"));
-            } else {
-                fees.setfChargedate((Date) item.get("fChargedate"));
-            }
-            if ("SJCK".equals(fBilltype)) {
                 fees.setfBillingDeadline(fBsdate);
             } else {
+                fees.setfChargedate((Date) item.get("fChargedate"));
                 fees.setfBillingDeadline(warehouseBills.getfBillingDeadline());
             }
             fees.setfTaxrate(new BigDecimal(taxRate.get(0).getDictValue()));
@@ -4116,7 +4117,8 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         if (StringUtils.isNull(tWarehouseBills.getfCorpid())) {
             return AjaxResult.error("请选择客户信息");
         }
-        long fPid = 0L;
+        tWarehouseBills.setfBillingDeadline(DateUtils.dateConversionMax(tWarehouseBills.getfBillingDeadline()));
+        long fPid;
         if (StringUtils.isNull(tWarehouseBills.getfId())) {
             // 生成流水号
             Date time = new Date();
@@ -4144,10 +4146,6 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         Map<String, Object> map = new HashMap<>();
         //调一次公共方法,获取字符类型的true或者false传
         String cangKey = sysConfigServiceImpl.selectConfigByKey("agreement.warehouse");
-        // 库存总账id
-        long whgenlegFeeId = 0;
-        // 计费单位
-        long feeUnitid = 1;
         // 查出所有仓库 给后续匹配仓库名字使用
         List<TWarehouse> warehouseList = tWarehouseMapper.selectTWarehouseList(new TWarehouse());
         // 查询 出库 货转的库存明细
@@ -4170,6 +4168,11 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         }
         List<Map<String, Object>> tWhgenlegs = tWhgenlegMapper.selectStorageFeeItemList(tWarehouseBills);
         if (CollectionUtils.isNotEmpty(tWhgenlegs)) {
+            // 如果是计算之前日期的库存总帐则需要使用当时日期的准确数量
+            if (!tWarehouseBills.getfBillingDeadline().after(new Date())) {
+                updateWhgenlegs(tWarehouseBills, tWhgenlegs);
+            }
+
             Map<String, Object> mapItem = getWarehouseItems(tWarehouseBills, tWhgenlegs, loginUser, cangKey);
             if (mapItem.containsKey("error")) {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -4198,6 +4201,162 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
     }
 
     /**
+     * 更新库存总帐当日实际
+     *
+     * @param tWarehouseBills
+     * @param tWhgenlegs
+     * @return
+     */
+    private List<Map<String, Object>> updateWhgenlegs(TWarehouseBills tWarehouseBills, List<Map<String, Object>> tWhgenlegs) {
+        // 获取区间时间
+        tWarehouseBills.setItemBsDateList(timeConversion(tWarehouseBills.getfBillingDeadline(), new Date()));
+        // 查询时间区间内的仓储业务明细信息
+        List<TWarehousebillsitems> warehousebillsitemsList = tWarehousebillsitemsMapper.selectListByCorpId(tWarehouseBills);
+        // 如果没有则直接结束此方法
+        if (CollectionUtils.isEmpty(warehousebillsitemsList)) {
+            return tWhgenlegs;
+        }
+        tWhgenlegs.forEach(whgenleg -> {
+            // 判断是否计算箱号 0为 不计算 1为计算
+            boolean ifCntrno = "1".equals(whgenleg.get("ifCntrno").toString());
+            // 组合一个库存总帐类使用
+            TWhgenleg tWhgenleg = new TWhgenleg();
+            tWhgenleg.setfCorpid(tWarehouseBills.getfCorpid());
+            tWhgenleg.setfQtyblc(Long.parseLong(whgenleg.get("fQty").toString()));
+            tWhgenleg.setfMarks((String) whgenleg.get("fMarks"));
+            tWhgenleg.setfMblno((String) whgenleg.get("fMblno"));
+            tWhgenleg.setfCntrno((String) whgenleg.get("fCntrno"));
+            tWhgenleg.setfGoodsid(Long.parseLong(whgenleg.get("fGoodsid").toString()));
+            tWhgenleg.setfNetweightblc(new BigDecimal(whgenleg.get("fNetweight").toString()));
+            tWhgenleg.setfGrossweightblc(new BigDecimal(whgenleg.get("fGrossweight").toString()));
+            tWhgenleg.setfWarehouseid(Long.parseLong(whgenleg.get("warehouseLocationid").toString()));
+
+            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.put("fQty", tWhgenleg.getfQtyblc());
+            whgenleg.put("fNetweight", tWhgenleg.getfNetweightblc());
+            whgenleg.put("fGrossweight", tWhgenleg.getfGrossweightblc());
+        });
+        return tWhgenlegs;
+    }
+
+    /**
+     * 根据仓储明细更新库存总帐数量、毛重、净重
+     *
+     * @param whgenleg
+     * @param item
+     * @return
+     */
+    private TWhgenleg updateWhgenlegCalculate(TWhgenleg whgenleg, TWarehousebillsitems item) {
+        // 入库
+        if (WarehouseTypeEnum.SJRK.getType().equals(item.getfBilltype())) {
+            // 修改数量
+            whgenleg.setfQtyblc(whgenleg.getfQtyblc() - item.getfQty());
+            // 修改毛重
+            BigDecimal grossweightblc = whgenleg.getfGrossweightblc().subtract(item.getfGrossweight()).setScale(2, RoundingMode.HALF_UP);
+            whgenleg.setfGrossweightblc(grossweightblc);
+            // 修改净重
+            BigDecimal netweightcBlc = whgenleg.getfNetweightblc().subtract(item.getfNetweight()).setScale(2, RoundingMode.HALF_UP);
+            whgenleg.setfNetweightc(netweightcBlc);
+            return whgenleg;
+        } else
+            // 出库
+            if (WarehouseTypeEnum.SJCK.getType().equals(item.getfBilltype())) {
+                // 修改数量
+                whgenleg.setfQtyblc(whgenleg.getfQtyblc() + item.getfQty());
+                // 修改毛重
+                BigDecimal grossweightblc = whgenleg.getfGrossweightblc().add(item.getfGrossweight());
+                whgenleg.setfGrossweightblc(grossweightblc);
+                // 修改净重
+                BigDecimal netweightcBlc = whgenleg.getfNetweightblc().add(item.getfNetweight());
+                whgenleg.setfNetweightc(netweightcBlc);
+                return whgenleg;
+            } else
+                // 调拨
+                if (WarehouseTypeEnum.CKDB.getType().equals(item.getfBilltype())) {
+                    BigDecimal netweightcBlc;
+                    BigDecimal grossweightblc;
+                    if (Objects.equals(item.getfTransferWarehouselocid(), whgenleg.getfWarehouseid())) {
+                        // 修改数量
+                        whgenleg.setfQtyblc(whgenleg.getfQtyblc() - item.getfQty());
+                        // 修改毛重
+                        grossweightblc = whgenleg.getfGrossweightblc().subtract(item.getfGrossweight()).setScale(2, RoundingMode.HALF_UP);
+                        // 修改净重
+                        netweightcBlc = whgenleg.getfNetweightblc().subtract(item.getfNetweight()).setScale(2, RoundingMode.HALF_UP);
+                    } else {
+                        // 修改数量
+                        whgenleg.setfQtyblc(whgenleg.getfQtyblc() + item.getfQty());
+                        // 修改毛重
+                        grossweightblc = whgenleg.getfGrossweightblc().add(item.getfGrossweight());
+                        // 修改净重
+                        netweightcBlc = whgenleg.getfNetweightblc().add(item.getfNetweight());
+                    }
+                    whgenleg.setfGrossweightblc(grossweightblc);
+                    whgenleg.setfNetweightc(netweightcBlc);
+                    return whgenleg;
+                } else
+                    // 货权转移
+                    if (WarehouseTypeEnum.HQZY.getType().equals(item.getfBilltype())) {
+                        BigDecimal netweightcBlc;
+                        BigDecimal grossweightblc;
+
+                        if (Objects.equals(item.getfTocorpid(), whgenleg.getfCorpid())) {
+                            // 修改数量
+                            whgenleg.setfQtyblc(whgenleg.getfQtyblc() - item.getfQty());
+                            // 修改毛重
+                            grossweightblc = whgenleg.getfGrossweightblc().subtract(item.getfGrossweight()).setScale(2, RoundingMode.HALF_UP);
+                            // 修改净重
+                            netweightcBlc = whgenleg.getfNetweightblc().subtract(item.getfNetweight()).setScale(2, RoundingMode.HALF_UP);
+                        } else {
+                            // 修改数量
+                            whgenleg.setfQtyblc(whgenleg.getfQtyblc() + item.getfQty());
+                            // 修改毛重
+                            grossweightblc = whgenleg.getfGrossweightblc().add(item.getfGrossweight());
+                            // 修改净重
+                            netweightcBlc = whgenleg.getfNetweightblc().add(item.getfNetweight());
+                        }
+                        whgenleg.setfGrossweightblc(grossweightblc);
+                        whgenleg.setfNetweightc(netweightcBlc);
+                        return whgenleg;
+                    }
+        return whgenleg;
+    }
+
+    /**
+     * 时间格式转换
+     *
+     * @param start
+     * @param end
+     * @return
+     */
+    private List<String> timeConversion(Date start, Date end) {
+        List<String> timeList = new ArrayList();
+        timeList.add(DateUtils.dateToString(DateUtils.dateConversionMax(start)));
+        timeList.add(DateUtils.dateToString(DateUtils.dateConversionMax(end)));
+        return timeList;
+    }
+
+    /**
      * 批量生成计算仓储费信息
      *
      * @param warehouseBills
@@ -4252,6 +4411,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                 continue;
             }
             storageFeesDto.setDays(fBillingDays);
+            storageFeesDto.setfMblno((String) item.get("fMblno"));
             // 赋值要计算的数量单位
             storageFeesDto.setfQty(new BigDecimal(String.valueOf(item.get("fQty"))));
             storageFeesDto.setfVolumn(new BigDecimal(String.valueOf(item.get("fQty"))));

+ 35 - 2
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehousebillsModifyServiceImpl.java

@@ -5,7 +5,6 @@ import com.ruoyi.approvalFlow.domain.AuditItems;
 import com.ruoyi.approvalFlow.service.impl.AuditItemsServiceImpl;
 import com.ruoyi.basicData.domain.TCorps;
 import com.ruoyi.basicData.domain.TFees;
-import com.ruoyi.basicData.domain.TGoods;
 import com.ruoyi.basicData.mapper.TCorpsMapper;
 import com.ruoyi.basicData.mapper.TFeesMapper;
 import com.ruoyi.basicData.mapper.TGoodsMapper;
@@ -25,7 +24,6 @@ import com.ruoyi.warehouseBusiness.domain.enums.WarehouseTypeEnum;
 import com.ruoyi.warehouseBusiness.domain.vo.WarehousebillsModifyVO;
 import com.ruoyi.warehouseBusiness.mapper.*;
 import com.ruoyi.warehouseBusiness.service.ITWarehousebillsModifyService;
-import org.apache.commons.compress.utils.Lists;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -419,4 +417,39 @@ public class TWarehousebillsModifyServiceImpl implements ITWarehousebillsModifyS
         return AjaxResult.success(modifyVO);
     }
 
+    /**
+     * 撤回已提交的审批
+     *
+     * @param id
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void withdrawalApprovalById(Long id) {
+        TWarehousebillsModify warehousebillsModify = tWarehousebillsModifyMapper.selectTWarehousebillsModifyById(id);
+        if (Objects.isNull(warehousebillsModify)) {
+            throw new WarehouseException("无效id");
+        }
+        List<TWarehousebillsfeesModify> warehousebillsfeesModifies = tWarehousebillsfeesModifyMapper.selectListByPid(id);
+
+        long count = warehousebillsfeesModifies.stream()
+                .filter(item -> !Objects.equals(item.getfStatus(), Long.parseLong(FeesTypeEnum.SUBMIT.getType())))
+                .count();
+        if (count > 0) {
+            throw new WarehouseException("该请核已被操作");
+        }
+        // 获取当前登陆人
+        String username = SecurityUtils.getUsername();
+        // 更新主表
+        warehousebillsModify.setUpdateBy(username);
+        warehousebillsModify.setUpdateTime(new Date());
+        warehousebillsModify.setfStatus(FeesTypeEnum.SAVE.getType());
+        tWarehousebillsModifyMapper.updateTWarehousebillsModify(warehousebillsModify);
+        // 更新明细表
+        warehousebillsfeesModifies.forEach(li -> {
+            li.setUpdateBy(username);
+            li.setUpdateTime(new Date());
+            li.setfStatus(Long.parseLong(FeesTypeEnum.SAVE.getType()));
+            tWarehousebillsfeesModifyMapper.updateTWarehousebillsfeesModify(li);
+        });
+    }
+
 }

+ 4 - 1
ruoyi-warehouse/src/main/resources/mapper/reportManagement/TWhgenlegMapper.xml

@@ -459,12 +459,15 @@
             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
@@ -476,7 +479,7 @@
             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 = #{warehouse.fMblno}</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>

+ 19 - 4
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsitemsMapper.xml

@@ -69,6 +69,7 @@
         <result property="fItemstatus"    column="f_itemstatus"    />
         <result property="fCartypeId"    column="f_cartype_id"    />
         <result property="fDc"    column="f_dc"    />
+        <result property="fTocorpid"    column="f_tocorpid"    />
         <result property="isCalculateStorageFees"    column="is_calculate_storage_fees"    />
     </resultMap>
 
@@ -506,12 +507,12 @@
             and ware.f_billtype in ("HQZY", "SJCK")
             and wa.f_charg = 1
             and item.f_storage_fee_deadline IS NULL
-            and IF(ware.f_billtype = "SJCK", item.f_bsdate &lt;#{warehouse.fBillingDeadline} AND item.f_billstatus = 40,
-                item.f_chargedate &lt;= #{warehouse.fBillingDeadline}  AND item.f_billstatus = 6)
+            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.fMblno != null and warehouse.fMblno != ''">and ware.f_mblno = #{warehouse.fMblno}</if>
             <if test="warehouse.fWarehouseid != null and warehouse.fWarehouseid != ''">and ware.f_warehouseid = #{warehouse.fWarehouseid}</if>
-           <!--  <if test="warehouse.fId != null">and item.f_id = #{warehouse.fId}</if> -->
+            <if test="warehouse.fMblno != null and warehouse.fMblno != ''">and ware.f_mblno like concat('%',#{warehouse.fMblno},'%')</if>
         </where>
     </select>
 
@@ -859,6 +860,20 @@
             f_bsdate between #{starDate}, #{endDate}
     </select>
 
+    <select id="selectListByCorpId" resultMap="TWarehousebillsitemsResult">
+        select t.f_tocorpid, item.f_id, item.f_goodsid, item.f_mblno, item.f_originalbillno, item.f_transfer_warehouselocid,
+            item.f_warehouselocid, item.f_originalbilldate, item.f_bsdate, item.f_billingway, item.f_chargedate, item.f_boxno, item.f_goodsval,
+            item.f_cntqty, item.f_volumn, item.f_qty, item.f_grossweight, item.f_netweight, item.f_cntrno, item.f_marks, item.f_billtype
+        from t_warehousebills t LEFT JOIN t_warehousebillsitems item ON item.f_pid = t.f_id
+        where
+            item.f_id IS NOT NULL
+            and (t.f_corpid = #{bills.fCorpid} or t.f_tocorpid = #{bills.fCorpid})
+            and item.f_bsdate BETWEEN #{bills.itemBsDateList[0]} and #{bills.itemBsDateList[1]}
+            and IF(item.f_billtype = "HQZY",  item.f_billstatus = 6, item.f_billstatus = 40)
+        <if test="bills.fGoodsid != null and bills.fGoodsid != ''">and item.f_goodsid = #{bills.fGoodsid}</if>
+        <if test="bills.fMblno != null and bills.fMblno != ''">and item.f_mblno = #{bills.fMblno}</if>
+    </select>
+
     <update id="updateItemStorageFeeDeadlineByPId">
         UPDATE t_warehousebillsitems
         SET f_storage_fee_deadline = #{time}