|
@@ -1,6 +1,7 @@
|
|
|
package com.ruoyi.warehouseBusiness.service.impl;
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
@@ -18,6 +19,7 @@ import com.ruoyi.warehouseBusiness.service.ITWarehouseAgreementService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -160,4 +162,90 @@ public class TWarehouseAgreementServiceImpl implements ITWarehouseAgreementServi
|
|
|
public int deleteTWarehouseAgreementById(Long fId) {
|
|
|
return tWarehouseAgreementMapper.deleteTWarehouseAgreementById(fId);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算存储费用
|
|
|
+ * @author shanxin
|
|
|
+ * @param fCorpid 出库客户Id
|
|
|
+ * @param fGoodsid 物资类型Id
|
|
|
+ * @param days 时长天数
|
|
|
+ * @param feeUnitid 计价单位
|
|
|
+ * @param itemNums 数量
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public BigDecimal getCarryingCost(Long fCorpid,
|
|
|
+ Long fGoodsid,
|
|
|
+ Long days,
|
|
|
+ Long feeUnitid,
|
|
|
+ Long itemNums) {
|
|
|
+
|
|
|
+ if (null == fCorpid ||
|
|
|
+ null == fGoodsid ||
|
|
|
+ null == days ||
|
|
|
+ null == feeUnitid ||
|
|
|
+ null == itemNums) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<TWarehouseAgreementitems> itemList =
|
|
|
+ this.tWarehouseAgreementitemsMapper.getItemsBytWarehouseAgreementMsg(fCorpid,fGoodsid,feeUnitid);
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(itemList)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ BigDecimal money = new BigDecimal(0);
|
|
|
+ Long dayLength = 0L;
|
|
|
+ for (TWarehouseAgreementitems tWarehouseAgreementitems : itemList) {
|
|
|
+ if (days < 1) break;
|
|
|
+ dayLength = tWarehouseAgreementitems.getfEndays() - tWarehouseAgreementitems.getfFromdays() + 1L;
|
|
|
+ if (days >= dayLength) {
|
|
|
+ money = money.add(this.getCalculate(itemNums,tWarehouseAgreementitems.getfPrice(),dayLength));
|
|
|
+ days -= dayLength;
|
|
|
+ } else {
|
|
|
+ money = money.add(this.getCalculate(itemNums,feeUnitid,days));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return money;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数量 * 单价 * 天数
|
|
|
+ * @param itemNums 数量
|
|
|
+ * @param unitPrice 单价
|
|
|
+ * @param dateLength 天数
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public BigDecimal getCalculate (Long itemNums,Long unitPrice,Long dateLength) {
|
|
|
+ BigDecimal money = new BigDecimal(0);
|
|
|
+ BigDecimal itemNumsBig = new BigDecimal(itemNums);
|
|
|
+ BigDecimal unitPriceBig = new BigDecimal(unitPrice);
|
|
|
+ BigDecimal bigDaysBig = new BigDecimal(dateLength);
|
|
|
+ money = itemNumsBig.multiply(unitPriceBig).multiply(bigDaysBig);
|
|
|
+ return money;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|