纪新园 пре 9 месеци
родитељ
комит
270e49afea
14 измењених фајлова са 361 додато и 27 уклоњено
  1. 5 0
      blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/LandOrder.java
  2. 3 0
      blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/OrderFee.java
  3. 5 0
      blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/OrderItem.java
  4. 6 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/trade/entity/PayableStorageFees.java
  5. 2 1
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/trade/entity/Storage.java
  6. 1 1
      blade-service/blade-los/src/main/java/org/springblade/los/business/sea/service/impl/ContainersServiceImpl.java
  7. 87 0
      blade-service/blade-los/src/main/java/org/springblade/los/excel/InventoryAlertExcel.java
  8. 25 0
      blade-service/blade-los/src/main/java/org/springblade/los/trade/controller/InOutStorageController.java
  9. 13 0
      blade-service/blade-los/src/main/java/org/springblade/los/trade/controller/PayableStorageFeesController.java
  10. 8 9
      blade-service/blade-los/src/main/java/org/springblade/los/trade/mapper/InOutStorageMapper.xml
  11. 5 0
      blade-service/blade-los/src/main/java/org/springblade/los/trade/service/IInOutStorageService.java
  12. 159 2
      blade-service/blade-los/src/main/java/org/springblade/los/trade/service/impl/InOutStorageServiceImpl.java
  13. 2 1
      blade-service/blade-los/src/main/java/org/springblade/los/trade/service/impl/PayableStorageFeesServiceImpl.java
  14. 40 13
      blade-service/trade-finance/src/main/java/org/springblade/finance/service/impl/SettlementServiceImpl.java

+ 5 - 0
blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/LandOrder.java

@@ -16,6 +16,7 @@
  */
 package org.springblade.land.entity;
 
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -467,6 +468,7 @@ public class LandOrder implements Serializable {
 	 * 结算时间-收
 	 */
 	@ApiModelProperty(value = "结算时间-收")
+	@TableField(updateStrategy = FieldStrategy.IGNORED)
 	private Date settlementDateD;
 
 	/**
@@ -478,6 +480,7 @@ public class LandOrder implements Serializable {
 	 * 结算时间-付
 	 */
 	@ApiModelProperty(value = "结算时间-付")
+	@TableField(updateStrategy = FieldStrategy.IGNORED)
 	private Date settlementDateC;
 
 	/**
@@ -489,6 +492,7 @@ public class LandOrder implements Serializable {
 	 * 对账时间-收
 	 */
 	@ApiModelProperty(value = "对账时间-收")
+	@TableField(updateStrategy = FieldStrategy.IGNORED)
 	private Date reconciliationDateD;
 
 	/**
@@ -500,6 +504,7 @@ public class LandOrder implements Serializable {
 	 * 对账时间-付
 	 */
 	@ApiModelProperty(value = "对账时间-付")
+	@TableField(updateStrategy = FieldStrategy.IGNORED)
 	private Date reconciliationDateC;
 
 

+ 3 - 0
blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/OrderFee.java

@@ -16,6 +16,7 @@
  */
 package org.springblade.land.entity;
 
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -211,6 +212,7 @@ public class OrderFee implements Serializable {
 	 * 结算时间
 	 */
 	@ApiModelProperty(value = "结算时间")
+	@TableField(updateStrategy = FieldStrategy.IGNORED)
 	private Date settlementDate;
 	/**
 	 * 对账金额
@@ -221,5 +223,6 @@ public class OrderFee implements Serializable {
 	 * 对账时间
 	 */
 	@ApiModelProperty(value = "对账时间")
+	@TableField(updateStrategy = FieldStrategy.IGNORED)
 	private Date reconciliationDate;
 }

+ 5 - 0
blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/OrderItem.java

@@ -16,6 +16,7 @@
  */
 package org.springblade.land.entity;
 
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -473,6 +474,7 @@ public class OrderItem implements Serializable {
 	 * 结算时间-收
 	 */
 	@ApiModelProperty(value = "结算时间-收")
+	@TableField(updateStrategy = FieldStrategy.IGNORED)
 	private Date settlementDateD;
 
 	/**
@@ -484,6 +486,7 @@ public class OrderItem implements Serializable {
 	 * 结算时间-付
 	 */
 	@ApiModelProperty(value = "结算时间-付")
+	@TableField(updateStrategy = FieldStrategy.IGNORED)
 	private Date settlementDateC;
 
 	/**
@@ -495,6 +498,7 @@ public class OrderItem implements Serializable {
 	 * 对账时间-收
 	 */
 	@ApiModelProperty(value = "对账时间-收")
+	@TableField(updateStrategy = FieldStrategy.IGNORED)
 	private Date reconciliationDateD;
 
 	/**
@@ -506,6 +510,7 @@ public class OrderItem implements Serializable {
 	 * 对账时间-付
 	 */
 	@ApiModelProperty(value = "对账时间-付")
+	@TableField(updateStrategy = FieldStrategy.IGNORED)
 	private Date reconciliationDateC;
 
 }

+ 6 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/trade/entity/PayableStorageFees.java

@@ -107,5 +107,11 @@ public class PayableStorageFees implements Serializable {
 	@TableField(exist = false)
 	private List<PayableStorageFeesItems> storageFeesItemsList;
 
+	/**
+	 * 创建人
+	 */
+	@TableField(exist = false)
+	private String createUserName;
+
 
 }

+ 2 - 1
blade-service-api/blade-los-api/src/main/java/org/springblade/los/trade/entity/Storage.java

@@ -24,6 +24,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 
@@ -103,7 +104,7 @@ public class Storage implements Serializable {
 	 * 库存预警(吨)
 	 */
 	@ApiModelProperty(value = "库存预警(吨)")
-	private String inventoryAlert;
+	private BigDecimal inventoryAlert;
 
 	@TableField(exist = false)
 	private List<StorageFeeItems> storageFeeItemsList;

+ 1 - 1
blade-service/blade-los/src/main/java/org/springblade/los/business/sea/service/impl/ContainersServiceImpl.java

@@ -641,7 +641,7 @@ public class ContainersServiceImpl extends ServiceImpl<ContainersMapper, Contain
 			map.put("grossWeight", item.getGrossWeight());
 			map.put("netWeight", item.getNetWeight());
 			map.put("measurement", item.getMeasurement());
-			List<ContainersCommodity> containersCommodityList = commodityList.stream().filter(e -> e.getPpId().equals(item.getId()))
+			List<ContainersCommodity> containersCommodityList = commodityList.stream().filter(e -> e.getPid().equals(item.getId()))
 				.collect(Collectors.toList());
 			BigDecimal quantityTotal = new BigDecimal("0.00");
 			BigDecimal grossWeightTotal = new BigDecimal("0.00");

+ 87 - 0
blade-service/blade-los/src/main/java/org/springblade/los/excel/InventoryAlertExcel.java

@@ -0,0 +1,87 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.los.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 库存预警
+ *
+ * @author BladeX
+ * @since 2023-10-07
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class InventoryAlertExcel implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+
+	/**
+	 * 业务类型
+	 */
+	@ExcelProperty(value = "业务类型")
+	private String businessType;
+	/**
+	 * 合同号
+	 */
+	@ExcelProperty(value = "合同号")
+	private String bookingNo;
+	/**
+	 * 提单号
+	 */
+	@ExcelProperty(value = "提单号")
+	private String mblno;
+	/**
+	 * 往来单位
+	 */
+	@ExcelProperty(value = "往来单位")
+	private String corpCnName;
+	/**
+	 * 费用名称
+	 */
+	@ExcelProperty(value = "费用名称")
+	private String feeCnName;
+
+	/**
+	 * 未收金额
+	 */
+	@ExcelProperty(value = "未收金额")
+	private BigDecimal unsettledAmount;
+
+	/**
+	 * 业务时间
+	 */
+	@ExcelProperty(value = "业务时间")
+	private Date billDate;
+	/**
+	 * 是否生成账单
+	 */
+	@ExcelProperty(value = "是否生成账单")
+	private String accStatus;
+
+}

+ 25 - 0
blade-service/blade-los/src/main/java/org/springblade/los/trade/controller/InOutStorageController.java

@@ -21,14 +21,19 @@ import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import lombok.AllArgsConstructor;
+
+import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 
 import org.springblade.common.annotation.RepeatSubmit;
+import org.springblade.core.excel.util.ExcelUtil;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.los.business.sea.entity.PreContainers;
+import org.springblade.los.excel.BPortsExcel;
+import org.springblade.los.excel.InventoryAlertExcel;
 import org.springframework.web.bind.annotation.*;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springblade.los.trade.entity.InOutStorage;
@@ -36,6 +41,7 @@ import org.springblade.los.trade.vo.InOutStorageVO;
 import org.springblade.los.trade.service.IInOutStorageService;
 import org.springblade.core.boot.ctrl.BladeController;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -181,5 +187,24 @@ public class InOutStorageController extends BladeController {
 		return inOutStorageService.revokeOutbound(inOutStorage);
 	}
 
+	/**
+	 * 库存预警
+	 */
+	@PostMapping("/inventoryAlert")
+	@RepeatSubmit
+	public R inventoryAlert(@Valid @RequestBody InOutStorage inOutStorage){
+		return inOutStorageService.inventoryAlert(inOutStorage);
+	}
+
+	/**
+	 * 库存预警导出
+	 */
+	@GetMapping("/inventoryAlertExport")
+	@RepeatSubmit
+	public void inventoryAlertExport(HttpServletResponse response, InOutStorage inOutStorage){
+		List<InventoryAlertExcel> list = inOutStorageService.inventoryAlertExport(inOutStorage);
+		ExcelUtil.export(response, "库存预警", "库存预警", list, InventoryAlertExcel.class);
+	}
+
 
 }

+ 13 - 0
blade-service/blade-los/src/main/java/org/springblade/los/trade/controller/PayableStorageFeesController.java

@@ -34,10 +34,13 @@ import org.springblade.los.trade.entity.PayableStorageFees;
 import org.springblade.los.trade.entity.PayableStorageFeesItems;
 import org.springblade.los.trade.service.IPayableStorageFeesService;
 import org.springblade.los.trade.vo.PayableStorageFeesVO;
+import org.springblade.system.user.entity.User;
+import org.springblade.system.user.feign.IUserClient;
 import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 应付仓储费表 控制器
@@ -53,6 +56,8 @@ public class PayableStorageFeesController extends BladeController {
 
 	private final IPayableStorageFeesService payableStorageFeesService;
 
+	private final IUserClient userClient;
+
 	/**
 	 * 详情
 	 */
@@ -79,6 +84,14 @@ public class PayableStorageFeesController extends BladeController {
 			.like(ObjectUtils.isNotNull(payableStorageFees.getStatus()), PayableStorageFees::getStatus, payableStorageFees.getStatus())
 			.orderByDesc(PayableStorageFees::getChargingEndDate);
 		IPage<PayableStorageFees> pages = payableStorageFeesService.page(Condition.getPage(query), Condition.getQueryWrapper(payableStorageFees));
+		if (!pages.getRecords().isEmpty()) {
+			List<User> userList = userClient.userListGetByIds(pages.getRecords().stream().map(PayableStorageFees::getCreateUser).collect(Collectors.toList()));
+			for (PayableStorageFees item : pages.getRecords()) {
+				if (!userList.isEmpty()) {
+                    userList.stream().filter(e -> e.getId().equals(item.getCreateUser())).findFirst().ifPresent(user -> item.setCreateUserName(user.getRealName()));
+                }
+			}
+		}
 		return R.data(pages);
 	}
 

+ 8 - 9
blade-service/blade-los/src/main/java/org/springblade/los/trade/mapper/InOutStorageMapper.xml

@@ -19,7 +19,6 @@
         <result column="sort" property="sort"/>
         <result column="warehouse_id" property="warehouseId"/>
         <result column="warehouse_name" property="warehouseName"/>
-        <result column="goods_id" property="goodsId"/>
         <result column="goods_name" property="goodsName"/>
         <result column="box_no" property="boxNo"/>
         <result column="storage_unit" property="storageUnit"/>
@@ -84,13 +83,13 @@
             and tio.goods_name=#{data.goodsName}
         </if>
         <if test="data.warehouseId !=null">
-            and tio.goods_name=#{data.warehouseId}
+            and tio.warehouse_id=#{data.warehouseId}
         </if>
-        <if test="data.warehouseId ==null or data.warehouseId ==''">
+        <if test="data.inventory ==null or data.inventory ==''">
             and tio.surplus_quantity != 0
         </if>
-        <if test="data.mblno !=null and data.mblno != ''">
-            and lsb.mblno like concat('%', #{data.mblno}, '%')
+        <if test="data.mblNo !=null and data.mblNo != ''">
+            and lsb.mblno like concat('%', #{data.mblNo}, '%')
         </if>
         <if test="data.contractNo !=null and data.contractNo != ''">
             and lsb.booking_no like concat('%', #{data.contractNo}, '%')
@@ -142,13 +141,13 @@
             and tio.goods_name=#{data.goodsName}
         </if>
         <if test="data.warehouseId !=null">
-            and tio.goods_name=#{data.warehouseId}
+            and tio.warehouse_id=#{data.warehouseId}
         </if>
-        <if test="data.warehouseId ==null or data.warehouseId ==''">
+        <if test="data.inventory ==null or data.inventory ==''">
             and tio.surplus_quantity != 0
         </if>
-        <if test="data.mblno !=null and data.mblno != ''">
-            and lsb.mblno like concat('%', #{data.mblno}, '%')
+        <if test="data.mblNo !=null and data.mblNo != ''">
+            and lsb.mblno like concat('%', #{data.mblNo}, '%')
         </if>
         <if test="data.contractNo !=null and data.contractNo != ''">
             and lsb.booking_no like concat('%', #{data.contractNo}, '%')

+ 5 - 0
blade-service/blade-los/src/main/java/org/springblade/los/trade/service/IInOutStorageService.java

@@ -18,6 +18,7 @@ package org.springblade.los.trade.service;
 
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
+import org.springblade.los.excel.InventoryAlertExcel;
 import org.springblade.los.trade.entity.InOutStorage;
 import org.springblade.los.trade.entity.InOutStorageStatistics;
 import org.springblade.los.trade.vo.InOutStorageVO;
@@ -60,4 +61,8 @@ public interface IInOutStorageService extends IService<InOutStorage> {
 	R<IPage<InOutStorageStatistics>> inventoryAccountStatisticsPage(InOutStorageStatistics outStorageStatistics, IPage<InOutStorageStatistics> page);
 
 	List<InOutStorageStatistics> export(InOutStorageStatistics outStorageStatistics);
+
+	R inventoryAlert(InOutStorage inOutStorage);
+
+	List<InventoryAlertExcel> inventoryAlertExport(InOutStorage inOutStorage);
 }

+ 159 - 2
blade-service/blade-los/src/main/java/org/springblade/los/trade/service/impl/InOutStorageServiceImpl.java

@@ -33,6 +33,7 @@ import org.springblade.los.business.sea.entity.Bills;
 import org.springblade.los.business.sea.entity.PreContainers;
 import org.springblade.los.business.sea.mapper.BillsMapper;
 import org.springblade.los.business.sea.mapper.PreContainersMapper;
+import org.springblade.los.excel.InventoryAlertExcel;
 import org.springblade.los.finance.fee.entity.FeeCenter;
 import org.springblade.los.finance.fee.mapper.FeeCenterMapper;
 import org.springblade.los.trade.entity.*;
@@ -40,6 +41,7 @@ import org.springblade.los.trade.mapper.AgentItemsMapper;
 import org.springblade.los.trade.mapper.DispatchVehiclesMapper;
 import org.springblade.los.trade.mapper.InOutStorageMapper;
 import org.springblade.los.trade.service.IInOutStorageService;
+import org.springblade.los.trade.service.IPayableStorageFeesItemsService;
 import org.springblade.los.trade.service.IStorageService;
 import org.springblade.los.trade.vo.InOutStorageVO;
 import org.springblade.system.entity.Dept;
@@ -84,6 +86,8 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
 
 	private final DispatchVehiclesMapper dispatchVehiclesMapper;
 
+	private final IPayableStorageFeesItemsService payableStorageFeesItemsService;
+
 	@Override
 	public IPage<InOutStorageVO> selectInOutStoragePage(IPage<InOutStorageVO> page, InOutStorageVO inOutStorage) {
 		return page.setRecords(baseMapper.selectInOutStoragePage(page, inOutStorage));
@@ -667,7 +671,6 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
 			if ("1".equals(inOutStorage.getWhetherInOutStorage())) {
 				throw new RuntimeException("已生成出库信息,撤销失败");
 			}
-			inOutStorage.setChargingDate(null);
 			Bills bills = billsMapper.selectById(inOutStorage.getPid());
 			if (ObjectUtils.isNotNull(bills.getMconsigneeCntyName())) {
 				List<FeeCenter> feeCenterTradeList = feeCenterMapper.selectList(new LambdaQueryWrapper<FeeCenter>()
@@ -706,7 +709,13 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
 			if ("1".equals(storage.getBillingRules())) {
 				billingRules = false;
 			}
-			inOutStorage.setOutStorageDate(null);
+			List<PayableStorageFeesItems> payableStorageFees = payableStorageFeesItemsService.list(new LambdaQueryWrapper<PayableStorageFeesItems>()
+				.eq(PayableStorageFeesItems::getTenantId, AuthUtil.getTenantId())
+				.eq(PayableStorageFeesItems::getIsDeleted, 0)
+				.eq(PayableStorageFeesItems::getItemId, inOutStorage.getId()));
+			if (!payableStorageFees.isEmpty()) {
+				throw new RuntimeException("改出库记录已计算过仓储费,撤销失败");
+			}
 			InOutStorage inStorage = baseMapper.selectById(inOutStorage.getSrcId());
 			BigDecimal quantity = inStorage.getSurplusQuantity();
 			BigDecimal grossWeight = inStorage.getSurplusWeight();
@@ -811,4 +820,152 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
 		return baseMapper.inventoryAccountStatisticsList(outStorageStatistics);
 	}
 
+	@Override
+	public R inventoryAlert(InOutStorage inOutStorage) {
+		Map<String, Object> map = new HashMap<>();
+		Storage storage = storageService.getById(inOutStorage.getWarehouseId());
+		if (storage == null) {
+			throw new RuntimeException("未查到仓库信息");
+		}
+		boolean billingRules = true;
+		if ("1".equals(storage.getBillingRules())) {
+			billingRules = false;
+		}
+		InOutStorage inStorage = baseMapper.selectById(inOutStorage.getSrcId());
+		BigDecimal quantity = inStorage.getSurplusQuantity();
+		if (quantity.compareTo(inOutStorage.getOutQuantity()) < 0) {
+			throw new RuntimeException("剩余数量:" + quantity + "小于出库数量:" + inOutStorage.getOutQuantity());
+		}
+		BigDecimal grossWeight = inStorage.getSurplusWeight();
+		if (grossWeight.compareTo(inOutStorage.getOutWeight()) < 0) {
+			throw new RuntimeException("剩余毛重:" + grossWeight + "小于出库毛重:" + inOutStorage.getOutWeight());
+		}
+		BigDecimal netWeight = inStorage.getSurplusNetWeight();
+		if (netWeight.compareTo(inOutStorage.getOutNetWeight()) < 0) {
+			throw new RuntimeException("剩余净重:" + netWeight + "小于出库净重:" + inOutStorage.getOutWeight());
+		}
+		BigDecimal outGoodsAmount;
+		if (billingRules) {
+			outGoodsAmount = inOutStorage.getOutWeight().multiply(inOutStorage.getPrice());
+		} else {
+			outGoodsAmount = inOutStorage.getOutNetWeight().multiply(inOutStorage.getPrice());
+		}
+		Bills bills = billsMapper.selectById(inStorage.getPid());
+		if (bills == null) {
+			throw new RuntimeException("未查到该条出库对应总单据信息");
+		}
+		List<Bills> billsList = billsMapper.selectList(new LambdaQueryWrapper<Bills>()
+			.eq(Bills::getTenantId, AuthUtil.getTenantId())
+			.eq(Bills::getIsDeleted, 0)
+			.eq(Bills::getCorpId, bills.getCorpId()));
+		if (billsList.isEmpty()) {
+			throw new RuntimeException("未查到客户:" + bills.getCorpCnName() + "单据信息");
+		}
+		List<Long> pidList = billsList.stream().map(Bills::getId).distinct().collect(Collectors.toList());
+		List<InOutStorage> inOutStorageList = baseMapper.selectList(new LambdaQueryWrapper<InOutStorage>()
+			.eq(InOutStorage::getTenantId, AuthUtil.getTenantId())
+			.eq(InOutStorage::getIsDeleted, 0)
+			.eq(InOutStorage::getBillType, "RK")
+			.eq(InOutStorage::getPid, pidList));
+		List<FeeCenter> feeCenterList = feeCenterMapper.selectList(new LambdaQueryWrapper<FeeCenter>()
+			.in(FeeCenter::getPid, pidList)
+			.eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
+			.eq(FeeCenter::getIsDeleted, 0)
+			.eq(FeeCenter::getDc, "D")
+			.orderByDesc(FeeCenter::getCorpId)
+			.orderByAsc(FeeCenter::getBillNo));
+		BigDecimal amount = new BigDecimal("0.00");
+		BigDecimal surplusGoodsAmount = new BigDecimal("0.00");
+		if (!feeCenterList.isEmpty()) {
+			amount = feeCenterList.stream().map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+		}
+		if (!feeCenterList.isEmpty()) {
+			surplusGoodsAmount = inOutStorageList.stream().map(InOutStorage::getSurplusGoodsAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+		}
+		BigDecimal thisGoodsAmount = outGoodsAmount.multiply(inStorage.getPrice());
+		if (amount.compareTo(surplusGoodsAmount.subtract(thisGoodsAmount)) >= 0) {
+			map.put("status", true);
+			map.put("content", "客户未收金额:" + amount + "大于剩余货值:" + surplusGoodsAmount.subtract(thisGoodsAmount) + "(" +
+				(surplusGoodsAmount.subtract(thisGoodsAmount)).divide(surplusGoodsAmount, 2, RoundingMode.HALF_UP) + "%)" +
+				",本次出库货值:" + thisGoodsAmount + "(" + thisGoodsAmount.divide(surplusGoodsAmount, 2, RoundingMode.HALF_UP) + ")");
+			map.put("feeCenterList", feeCenterList);
+		} else {
+			map.put("status", false);
+		}
+		return R.data(map);
+	}
+
+	@Override
+	public List<InventoryAlertExcel> inventoryAlertExport(InOutStorage detail) {
+		InOutStorage inOutStorage = baseMapper.selectById(detail.getId());
+		Storage storage = storageService.getById(inOutStorage.getWarehouseId());
+		if (storage == null) {
+			throw new RuntimeException("未查到仓库信息");
+		}
+		boolean billingRules = true;
+		if ("1".equals(storage.getBillingRules())) {
+			billingRules = false;
+		}
+		InOutStorage inStorage = baseMapper.selectById(inOutStorage.getSrcId());
+		BigDecimal outGoodsAmount;
+		if (billingRules) {
+			outGoodsAmount = inOutStorage.getOutWeight().multiply(inOutStorage.getPrice());
+		} else {
+			outGoodsAmount = inOutStorage.getOutNetWeight().multiply(inOutStorage.getPrice());
+		}
+		Bills bills = billsMapper.selectById(inStorage.getPid());
+		if (bills == null) {
+			throw new RuntimeException("未查到该条出库对应总单据信息");
+		}
+		List<Bills> billsList = billsMapper.selectList(new LambdaQueryWrapper<Bills>()
+			.eq(Bills::getTenantId, AuthUtil.getTenantId())
+			.eq(Bills::getIsDeleted, 0)
+			.eq(Bills::getCorpId, bills.getCorpId()));
+		if (billsList.isEmpty()) {
+			throw new RuntimeException("未查到客户:" + bills.getCorpCnName() + "单据信息");
+		}
+		List<Long> pidList = billsList.stream().map(Bills::getId).distinct().collect(Collectors.toList());
+		List<InOutStorage> inOutStorageList = baseMapper.selectList(new LambdaQueryWrapper<InOutStorage>()
+			.eq(InOutStorage::getTenantId, AuthUtil.getTenantId())
+			.eq(InOutStorage::getIsDeleted, 0)
+			.eq(InOutStorage::getBillType, "RK")
+			.eq(InOutStorage::getPid, pidList));
+		List<FeeCenter> feeCenterList = feeCenterMapper.selectList(new LambdaQueryWrapper<FeeCenter>()
+			.in(FeeCenter::getPid, pidList)
+			.eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
+			.eq(FeeCenter::getIsDeleted, 0)
+			.eq(FeeCenter::getDc, "D")
+			.orderByDesc(FeeCenter::getCorpId)
+			.orderByAsc(FeeCenter::getBillNo));
+		BigDecimal amount = new BigDecimal("0.00");
+		BigDecimal surplusGoodsAmount = new BigDecimal("0.00");
+		if (!feeCenterList.isEmpty()) {
+			amount = feeCenterList.stream().map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+		}
+		if (!feeCenterList.isEmpty()) {
+			surplusGoodsAmount = inOutStorageList.stream().map(InOutStorage::getSurplusGoodsAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+		}
+		BigDecimal thisGoodsAmount = outGoodsAmount.multiply(inStorage.getPrice());
+		List<InventoryAlertExcel> inventoryAlertExcelList = new ArrayList<>();
+		if (amount.compareTo(surplusGoodsAmount.subtract(thisGoodsAmount)) >= 0) {
+			for (FeeCenter item : feeCenterList) {
+				InventoryAlertExcel excel = new InventoryAlertExcel();
+				excel.setBusinessType(item.getBusinessType());
+				excel.setBookingNo(item.getBookingNo());
+				excel.setMblno(item.getMblno());
+				excel.setCorpCnName(item.getCorpCnName());
+				excel.setFeeCnName(item.getFeeCnName());
+				excel.setUnsettledAmount(item.getUnsettledAmount());
+				excel.setBillDate(item.getBillDate());
+				if (0 == item.getAccStatus()) {
+					excel.setAccStatus("否");
+				} else {
+					excel.setAccStatus("是");
+				}
+				inventoryAlertExcelList.add(excel);
+			}
+		}
+		return inventoryAlertExcelList;
+	}
+
 }

+ 2 - 1
blade-service/blade-los/src/main/java/org/springblade/los/trade/service/impl/PayableStorageFeesServiceImpl.java

@@ -154,6 +154,7 @@ public class PayableStorageFeesServiceImpl extends ServiceImpl<PayableStorageFee
 		LambdaQueryWrapper<InOutStorage> lambdaQueryWrapper = new LambdaQueryWrapper<InOutStorage>()
 			.eq(InOutStorage::getTenantId, AuthUtil.getTenantId())
 			.eq(InOutStorage::getIsDeleted, 0)
+			.eq(InOutStorage::getConfirmDispatchVehicles, "1")
 			.eq(InOutStorage::getWarehouseId, payableStorageFees.getWarehouseId())
 			.le(InOutStorage::getChargingDate, payableStorageFees.getChargingEndDate());
 		List<InOutStorage> inOutStorageList = inOutStorageService.list(lambdaQueryWrapper);
@@ -216,7 +217,7 @@ public class PayableStorageFeesServiceImpl extends ServiceImpl<PayableStorageFee
 				// 计算差多少天
 				long day = diff / nd + 1L;
 				storageFeesItems.setChargingDay((int) day);
-				storageFeesItems.setChargingStartDate(inOutStorage.getChargingDate());
+				storageFeesItems.setChargingStartDate(calendar.getTime());
 				storageFeesItems.setChargingEndDate(dateEnd);
 				StorageFeeItems storageFeeItems = storageFeeItemsList.stream().filter(e -> e.getGoodsType().equals(inOutStorage.getGoodsType())).findFirst().orElse(null);
 				if (storageFeeItems == null) {

+ 40 - 13
blade-service/trade-finance/src/main/java/org/springblade/finance/service/impl/SettlementServiceImpl.java

@@ -3780,16 +3780,19 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, Settlem
 			type = false;
 		}
 		for (Items item : itemsList) {
-			if ((item.getAmount().subtract(item.getSettlementAmount())).compareTo(item.getThisAmount()) < 0) {
-				throw new RuntimeException("单号:" + item.getSrcBillNo() + "本次结算金额大于剩余结算金额");
-			}
 			if (2 == item.getSrcType() && "1".equals(item.getDc()) && !orderItemsList.isEmpty()) {
 				OrderItem orderItem = orderItemsList.stream().filter(e -> e.getId().equals(item.getSrcFeesId())).findFirst().orElse(null);
 				if (orderItem != null) {
 					if (type) {
+						if ((orderItem.getLandAmountD().subtract(orderItem.getSettlementAmountD())).compareTo(item.getThisAmount()) < 0) {
+							throw new RuntimeException("单号:" + item.getSrcBillNo() + "本次结算金额大于剩余结算金额");
+						}
 						orderItem.setSettlementAmountD(orderItem.getSettlementAmountD().add(item.getThisAmount()));
 						orderItem.setSettlementDateD(new Date());
 					} else {
+						if ((orderItem.getLandAmountD().subtract(orderItem.getReconciliationAmountD())).compareTo(item.getThisAmount()) < 0) {
+							throw new RuntimeException("单号:" + item.getSrcBillNo() + "本次对账金额大于剩余已对账金额");
+						}
 						orderItem.setReconciliationAmountD(orderItem.getReconciliationAmountD().add(item.getThisAmount()));
 						orderItem.setReconciliationDateD(new Date());
 					}
@@ -3802,9 +3805,15 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, Settlem
 				OrderItem orderItem = orderItemsList.stream().filter(e -> e.getId().equals(item.getSrcFeesId())).findFirst().orElse(null);
 				if (orderItem != null) {
 					if (type) {
+						if ((orderItem.getLandAmountC().subtract(orderItem.getSettlementAmountC())).compareTo(item.getThisAmount()) < 0) {
+							throw new RuntimeException("单号:" + item.getSrcBillNo() + "本次结算金额大于剩余结算金额");
+						}
 						orderItem.setSettlementAmountC(orderItem.getSettlementAmountC().add(item.getThisAmount()));
 						orderItem.setSettlementDateC(new Date());
 					} else {
+						if ((orderItem.getLandAmountC().subtract(orderItem.getReconciliationAmountC())).compareTo(item.getThisAmount()) < 0) {
+							throw new RuntimeException("单号:" + item.getSrcBillNo() + "本次对账金额大于剩余已对账金额");
+						}
 						orderItem.setReconciliationAmountC(orderItem.getReconciliationAmountC().add(item.getThisAmount()));
 						orderItem.setReconciliationDateC(new Date());
 					}
@@ -3817,9 +3826,15 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, Settlem
 				OrderFee orderFee = orderFeeList.stream().filter(e -> e.getId().equals(item.getSrcFeesId())).findFirst().orElse(null);
 				if (orderFee != null) {
 					if (type) {
+						if ((orderFee.getAmount().subtract(orderFee.getSettlementAmount())).compareTo(item.getThisAmount()) < 0) {
+							throw new RuntimeException("单号:" + item.getSrcBillNo() + "本次结算金额大于剩余结算金额");
+						}
 						orderFee.setSettlementAmount(orderFee.getSettlementAmount().add(item.getThisAmount()));
 						orderFee.setSettlementDate(new Date());
 					} else {
+						if ((orderFee.getAmount().subtract(orderFee.getReconciliationAmount())).compareTo(item.getThisAmount()) < 0) {
+							throw new RuntimeException("单号:" + item.getSrcBillNo() + "本次对账金额大于剩余已对账金额");
+						}
 						orderFee.setReconciliationAmount(orderFee.getReconciliationAmount().add(item.getThisAmount()));
 						orderFee.setReconciliationDate(new Date());
 					}
@@ -3832,9 +3847,15 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, Settlem
 				LandOrder order = orderList.stream().filter(e -> e.getId().equals(item.getSrcFeesId())).findFirst().orElse(null);
 				if (order != null) {
 					if (type) {
+						if ((order.getFreightCollect().subtract(order.getSettlementAmountD())).compareTo(item.getThisAmount()) < 0) {
+							throw new RuntimeException("单号:" + item.getSrcBillNo() + "本次结算金额大于剩余结算金额");
+						}
 						order.setSettlementAmountD(order.getSettlementAmountD().add(item.getThisAmount()));
 						order.setSettlementDateD(new Date());
 					} else {
+						if ((order.getFreightPay().subtract(order.getReconciliationAmountD())).compareTo(item.getThisAmount()) < 0) {
+							throw new RuntimeException("单号:" + item.getSrcBillNo() + "本次对账金额大于剩余已对账金额");
+						}
 						order.setReconciliationAmountD(order.getReconciliationAmountD().add(item.getThisAmount()));
 						order.setReconciliationDateD(new Date());
 					}
@@ -3847,9 +3868,15 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, Settlem
 				LandOrder order = orderList.stream().filter(e -> e.getId().equals(item.getSrcFeesId())).findFirst().orElse(null);
 				if (order != null) {
 					if (type) {
+						if ((order.getFreightCollect().subtract(order.getSettlementAmountC())).compareTo(item.getThisAmount()) < 0) {
+							throw new RuntimeException("单号:" + item.getSrcBillNo() + "本次结算金额大于剩余结算金额");
+						}
 						order.setSettlementAmountC(order.getSettlementAmountC().add(item.getThisAmount()));
 						order.setSettlementDateC(new Date());
 					} else {
+						if ((order.getFreightPay().subtract(order.getReconciliationAmountC())).compareTo(item.getThisAmount()) < 0) {
+							throw new RuntimeException("单号:" + item.getSrcBillNo() + "本次对账金额大于剩余已对账金额");
+						}
 						order.setReconciliationAmountC(order.getReconciliationAmountC().add(item.getThisAmount()));
 						order.setReconciliationDateC(new Date());
 					}
@@ -3924,10 +3951,10 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, Settlem
 				if (orderItem != null) {
 					if (type) {
 						orderItem.setSettlementAmountD(orderItem.getSettlementAmountD().subtract(item.getThisAmount()));
-						orderItem.setSettlementDateD(new Date());
+						orderItem.setSettlementDateD(null);
 					} else {
 						orderItem.setReconciliationAmountD(orderItem.getReconciliationAmountD().subtract(item.getThisAmount()));
-						orderItem.setReconciliationDateD(new Date());
+						orderItem.setReconciliationDateD(null);
 					}
 					orderItemsNew.add(orderItem);
 				} else {
@@ -3939,10 +3966,10 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, Settlem
 				if (orderItem != null) {
 					if (type) {
 						orderItem.setSettlementAmountC(orderItem.getSettlementAmountC().subtract(item.getThisAmount()));
-						orderItem.setSettlementDateC(new Date());
+						orderItem.setSettlementDateC(null);
 					} else {
 						orderItem.setReconciliationAmountC(orderItem.getReconciliationAmountC().subtract(item.getThisAmount()));
-						orderItem.setReconciliationDateC(new Date());
+						orderItem.setReconciliationDateC(null);
 					}
 					orderItemsNew.add(orderItem);
 				} else {
@@ -3954,10 +3981,10 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, Settlem
 				if (orderFee != null) {
 					if (type) {
 						orderFee.setSettlementAmount(orderFee.getSettlementAmount().subtract(item.getThisAmount()));
-						orderFee.setSettlementDate(new Date());
+						orderFee.setSettlementDate(null);
 					} else {
 						orderFee.setReconciliationAmount(orderFee.getReconciliationAmount().subtract(item.getThisAmount()));
-						orderFee.setReconciliationDate(new Date());
+						orderFee.setReconciliationDate(null);
 					}
 					orderFeeNew.add(orderFee);
 				} else {
@@ -3969,10 +3996,10 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, Settlem
 				if (order != null) {
 					if (type) {
 						order.setSettlementAmountD(order.getSettlementAmountD().subtract(item.getThisAmount()));
-						order.setSettlementDateD(new Date());
+						order.setSettlementDateD(null);
 					} else {
 						order.setReconciliationAmountD(order.getReconciliationAmountD().subtract(item.getThisAmount()));
-						order.setReconciliationDateD(new Date());
+						order.setReconciliationDateD(null);
 					}
 					orderListNew.add(order);
 				} else {
@@ -3984,10 +4011,10 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, Settlem
 				if (order != null) {
 					if (type) {
 						order.setSettlementAmountC(order.getSettlementAmountC().subtract(item.getThisAmount()));
-						order.setSettlementDateC(new Date());
+						order.setSettlementDateC(null);
 					} else {
 						order.setReconciliationAmountC(order.getReconciliationAmountC().subtract(item.getThisAmount()));
-						order.setReconciliationDateC(new Date());
+						order.setReconciliationDateC(null);
 					}
 					orderListNew.add(order);
 				} else {