|
@@ -4,7 +4,9 @@ package com.ruoyi.warehouseBusiness.service.impl;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.ruoyi.approvalFlow.domain.AuditItems;
|
|
|
import com.ruoyi.approvalFlow.mapper.AuditItemsMapper;
|
|
|
import com.ruoyi.approvalFlow.service.impl.AuditItemsServiceImpl;
|
|
@@ -28,6 +30,8 @@ import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.common.utils.ip.AddressUtils;
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtils;
|
|
|
import com.ruoyi.finance.WarehouseType;
|
|
|
+import com.ruoyi.finance.domain.TFee;
|
|
|
+import com.ruoyi.finance.mapper.TFeeMapper;
|
|
|
import com.ruoyi.quotation.domain.TSeaprice;
|
|
|
import com.ruoyi.quotation.mapper.TSeapriceMapper;
|
|
|
import com.ruoyi.reportManagement.domain.TWareHouseItemsExcel;
|
|
@@ -44,6 +48,7 @@ import com.ruoyi.system.mapper.*;
|
|
|
import com.ruoyi.system.service.ISysConfigService;
|
|
|
import com.ruoyi.system.service.impl.SysConfigServiceImpl;
|
|
|
import com.ruoyi.warehouseBusiness.domain.*;
|
|
|
+import com.ruoyi.warehouseBusiness.dto.CalculateStorageFeesDto;
|
|
|
import com.ruoyi.warehouseBusiness.excel.*;
|
|
|
import com.ruoyi.warehouseBusiness.mapper.*;
|
|
|
import com.ruoyi.warehouseBusiness.service.ITWarehouseBillsService;
|
|
@@ -64,6 +69,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.*;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
@@ -83,6 +89,9 @@ import static java.util.stream.Collectors.toList;
|
|
|
public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
|
|
|
|
|
|
@Autowired
|
|
|
+ private TFeeMapper tFeeMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private TFeesMapper tFeesMapper;
|
|
|
|
|
|
@Autowired
|
|
@@ -3982,20 +3991,24 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
|
|
|
List<SysDictData> taxRate = sysDictDataMapper.selectDictDataByType("tax_rate");
|
|
|
for (Map<String, Object> item : mapItem) {
|
|
|
if (StringUtils.isNull(item.get("fBillingway"))) {
|
|
|
- map.put("error", "单号:" + item.get("fBillno") + ",业务日期:" + item.get("fBsdate") + "未找到库存总账的计费单位,请确认");
|
|
|
- return map;
|
|
|
+ throw new WarehouseException("单号:" + item.get("fBillno") + ",业务日期:" + item.get("fBsdate") + "未找到库存总账的计费单位,请确认");
|
|
|
}
|
|
|
+ CalculateStorageFeesDto storageFeesDto = new CalculateStorageFeesDto();
|
|
|
+ storageFeesDto.setFCorpid(warehouseBills.getfCorpid());
|
|
|
+ storageFeesDto.setCangKey(cangKey);
|
|
|
+ storageFeesDto.setWarehouseId(Long.parseLong(String.valueOf(item.get("warehouse"))));
|
|
|
+
|
|
|
Date fBsdate = (Date) item.get("fBsdate");
|
|
|
- long fCorpid = warehouseBills.getfCorpid();
|
|
|
String fBilltype = (String) item.get("fBilltype");
|
|
|
- Long warehouseId = Long.parseLong(String.valueOf(item.get("warehouse")));
|
|
|
String fGoodsid = (String) item.get("fTypeid");
|
|
|
if (StringUtils.isNotEmpty(fGoodsid)) {
|
|
|
fGoodsid = "\"" + fGoodsid + "\"";
|
|
|
}
|
|
|
- long fId = Long.valueOf(String.valueOf(item.get("fId"))).longValue();
|
|
|
+ storageFeesDto.setFGoodsid(fGoodsid);
|
|
|
+
|
|
|
+ long fId = Long.valueOf(String.valueOf(item.get("fId")));
|
|
|
// 累计计费天数
|
|
|
- long accumulatedDays = DateUtils.getDateDay((Date) item.get("fChargedate"), (Date) item.get("fOriginalbilldate"));
|
|
|
+ storageFeesDto.setEarlySumDays(DateUtils.getDateDay((Date) item.get("fChargedate"), (Date) item.get("fOriginalbilldate")));
|
|
|
// 库存天数
|
|
|
long fInventoryDays = 0L;
|
|
|
// 要计费天数
|
|
@@ -4003,38 +4016,45 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
|
|
|
if ("SJCK".equals(fBilltype)) {
|
|
|
fInventoryDays = DateUtils.getDateDay(fBsdate, (Date) item.get("fOriginalbilldate"));
|
|
|
fBillingDays = fInventoryDays;
|
|
|
+ storageFeesDto.setStartTime((Date) item.get("fOriginalbilldate"));
|
|
|
+ storageFeesDto.setEndTime(fBsdate);
|
|
|
} else if ("HQZY".equals(fBilltype)) {
|
|
|
fInventoryDays = DateUtils.getDateDay(warehouseBills.getfBillingDeadline(), fBsdate);
|
|
|
+ storageFeesDto.setStartTime(fBsdate);
|
|
|
+ storageFeesDto.setEndTime(warehouseBills.getfBillingDeadline());
|
|
|
} else {
|
|
|
- fBillingDays = DateUtils.getDateDay(warehouseBills.getfBillingDeadline(), (Date) item.get("fChargedate"));
|
|
|
+ storageFeesDto.setStartTime((Date) item.get("fOriginalbilldate"));
|
|
|
+ storageFeesDto.setEndTime(warehouseBills.getfBillingDeadline());
|
|
|
fInventoryDays = DateUtils.getDateDay(warehouseBills.getfBillingDeadline(), (Date) item.get("fOriginalbilldate"));
|
|
|
+ fBillingDays = DateUtils.getDateDay(warehouseBills.getfBillingDeadline(), (Date) item.get("fChargedate"));
|
|
|
}
|
|
|
+ storageFeesDto.setDays(fBillingDays);
|
|
|
/*if ("KCZZ".equals(fBilltype)) {
|
|
|
} else {
|
|
|
fInventoryDays = Long.valueOf(String.valueOf(item.get("fBillingDays")));
|
|
|
}*/
|
|
|
- Long dictLabel = Long.valueOf(String.valueOf(item.get("fBillingway")));
|
|
|
- BigDecimal fQty = acquiredQuantity(item, dictLabel);
|
|
|
- if (fQty.equals(BigDecimal.ZERO)) {
|
|
|
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
- return AjaxResult.error("单号:" + item.get("fBillno") + ",业务日期:" + item.get("fBsdate") + "未找到计费单位,请确认");
|
|
|
+ storageFeesDto.setFeeUnitid(Long.valueOf(String.valueOf(item.get("fBillingway"))));
|
|
|
+ BigDecimal fQty = acquiredQuantity(item, storageFeesDto.getFeeUnitid());
|
|
|
+ if (fQty.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ continue;
|
|
|
}
|
|
|
+ storageFeesDto.setItemNums(fQty);
|
|
|
// 仓储费协议计算
|
|
|
- Map<String, Object> objectMap = tWarehouseAgreementService.getCarryingCost(fCorpid, fGoodsid, fBillingDays, dictLabel, fQty, accumulatedDays, cangKey, warehouseId);
|
|
|
+ Map<String, Object> objectMap = tWarehouseAgreementService.getCarryingCost(storageFeesDto);
|
|
|
if (StringUtils.isNull(objectMap)) {
|
|
|
- map.put("error", "单号:" + item.get("fBillno") + ",业务日期:" + item.get("fBsdate") + "未找到仓储费协议,请确认");
|
|
|
- return map;
|
|
|
+ throw new WarehouseException("单号:" + item.get("fBillno") + ",业务日期:" + item.get("fBsdate") + "未找到仓储费协议,请确认");
|
|
|
}
|
|
|
String mblno = "";
|
|
|
if (StringUtils.isNotNull(item.get("fMblno"))) {
|
|
|
mblno = item.get("fMblno").toString();
|
|
|
}
|
|
|
String remark = objectMap.get("remark").toString();
|
|
|
+ String billingInterval = objectMap.get("billingInterval").toString();
|
|
|
feeId = Long.parseLong(String.valueOf(objectMap.get("feeId")));
|
|
|
BigDecimal amt = (BigDecimal) objectMap.get("amt");
|
|
|
map.put("feeId", feeId);
|
|
|
map.put("itemFeeId", objectMap.get("feeId"));
|
|
|
- sumAmt = sumAmt.add(amt).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ sumAmt = sumAmt.add(amt).setScale(2, RoundingMode.HALF_UP);
|
|
|
TWarehousebillsfees fees = new TWarehousebillsfees();
|
|
|
fees.setfFeeid(feeId);
|
|
|
fees.setfDc("D");
|
|
@@ -4051,13 +4071,14 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
|
|
|
fees.setfUnitprice(sumAmt);
|
|
|
fees.setfBilltype(fBilltype);
|
|
|
fees.setCreateTime(new Date());
|
|
|
- fees.setfWarehouseid(warehouseId);
|
|
|
+ fees.setfWarehouseid(storageFeesDto.getWarehouseId());
|
|
|
fees.setfBillingDays(fBillingDays);
|
|
|
fees.setfQty(new BigDecimal(1));
|
|
|
fees.setfPid(warehouseBills.getfId());
|
|
|
fees.setfInventoryDays(fInventoryDays);
|
|
|
fees.setfExrate(new BigDecimal(1));
|
|
|
fees.setfCorpid(warehouseBills.getfCorpid());
|
|
|
+ fees.setPriceDateRemarks(billingInterval);
|
|
|
fees.setfMarks(item.get("fMarks").toString());
|
|
|
fees.setSrcBillNo((String) item.get("fBillno"));
|
|
|
fees.setfChargedate((Date) item.get("fChargedate"));
|
|
@@ -4080,6 +4101,99 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 新增库存费计算
|
|
|
+ *
|
|
|
+ * @param tWarehouseBills 主表的查询条件
|
|
|
+ * @param loginUser 登录用户
|
|
|
+ * @param billsType 状态
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public AjaxResult calculateStorageFees(TWarehouseBills tWarehouseBills, LoginUser loginUser, String billsType) {
|
|
|
+ if (StringUtils.isNull(tWarehouseBills.getfCorpid())) {
|
|
|
+ return AjaxResult.error("请选择客户信息");
|
|
|
+ }
|
|
|
+ long fPid = 0L;
|
|
|
+ if (StringUtils.isNull(tWarehouseBills.getfId())) {
|
|
|
+ // 生成流水号
|
|
|
+ Date time = new Date();
|
|
|
+ String billNo = billnoSerialServiceImpl.getSerialNumber("JSCCF", 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");
|
|
|
+ // 库存总账id
|
|
|
+ long whgenlegFeeId = 0;
|
|
|
+ // 计费单位
|
|
|
+ long feeUnitid = 1;
|
|
|
+ // 查出所有仓库 给后续匹配仓库名字使用
|
|
|
+ List<TWarehouse> warehouseList = tWarehouseMapper.selectTWarehouseList(new TWarehouse());
|
|
|
+ // 查询 出库 货转的库存明细
|
|
|
+ List<Map<String, Object>> warehousebillsitemsList = tWarehousebillsitemsMapper.selectStorageFeeItemList(tWarehouseBills);
|
|
|
+ if (warehousebillsitemsList.size() != 0) {
|
|
|
+ Map<String, Object> mapItem = getWarehouseItems(tWarehouseBills, warehousebillsitemsList, 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<Map<String, Object>> tWhgenlegs = tWhgenlegMapper.selectStorageFeeItemList(tWarehouseBills);
|
|
|
+ if (CollectionUtils.isNotEmpty(tWhgenlegs)) {
|
|
|
+ Map<String, Object> mapItem = getWarehouseItems(tWarehouseBills, tWhgenlegs, 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 批量生成计算仓储费信息
|
|
|
*
|
|
|
* @param warehouseBills
|
|
@@ -4098,17 +4212,20 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
|
|
|
map.put("error", "单号:" + item.get("fBillno") + ",业务日期:" + item.get("fBsdate") + "未找到库存总账的计费单位,请确认");
|
|
|
return map;
|
|
|
}
|
|
|
+ CalculateStorageFeesDto storageFeesDto = new CalculateStorageFeesDto();
|
|
|
+ storageFeesDto.setFCorpid(warehouseBills.getfCorpid());
|
|
|
+ storageFeesDto.setCangKey(warehouse);
|
|
|
+ storageFeesDto.setWarehouseId(Long.parseLong(String.valueOf(item.get("warehouse"))));
|
|
|
Date fBsdate = (Date) item.get("fBsdate");
|
|
|
- long fCorpid = warehouseBills.getfCorpid();
|
|
|
String fBilltype = (String) item.get("fBilltype");
|
|
|
String fGoodsid = (String) item.get("fTypeid");
|
|
|
- Long warehouseId = Long.parseLong(String.valueOf(item.get("warehouse")));
|
|
|
if (StringUtils.isNotEmpty(fGoodsid)) {
|
|
|
fGoodsid = "\"" + fGoodsid + "\"";
|
|
|
}
|
|
|
- long fId = Long.valueOf(String.valueOf(item.get("fId"))).longValue();
|
|
|
+ storageFeesDto.setFGoodsid(fGoodsid);
|
|
|
+ long fId = Long.valueOf(String.valueOf(item.get("fId")));
|
|
|
// 累计计费天数
|
|
|
- long accumulatedDays = DateUtils.getDateDay((Date) item.get("fChargedate"), (Date) item.get("fOriginalbilldate"));
|
|
|
+ storageFeesDto.setEarlySumDays(DateUtils.getDateDay((Date) item.get("fChargedate"), (Date) item.get("fOriginalbilldate")));
|
|
|
// 库存天数
|
|
|
long fInventoryDays = 0L;
|
|
|
// 要计费天数
|
|
@@ -4116,24 +4233,32 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
|
|
|
if ("SJCK".equals(fBilltype)) {
|
|
|
fInventoryDays = DateUtils.getDateDay(fBsdate, (Date) item.get("fChargedate"));
|
|
|
fBillingDays = fInventoryDays;
|
|
|
+ storageFeesDto.setStartTime((Date) item.get("fChargedate"));
|
|
|
+ storageFeesDto.setEndTime(fBsdate);
|
|
|
} else if ("HQZY".equals(fBilltype)) {
|
|
|
fInventoryDays = DateUtils.getDateDay(warehouseBills.getfBillingDeadline(), fBsdate);
|
|
|
+ storageFeesDto.setStartTime(fBsdate);
|
|
|
+ storageFeesDto.setEndTime(warehouseBills.getfBillingDeadline());
|
|
|
} else {
|
|
|
+ storageFeesDto.setStartTime((Date) item.get("fOriginalbilldate"));
|
|
|
+ storageFeesDto.setEndTime(warehouseBills.getfBillingDeadline());
|
|
|
fBillingDays = DateUtils.getDateDay(warehouseBills.getfBillingDeadline(), (Date) item.get("fChargedate"));
|
|
|
fInventoryDays = DateUtils.getDateDay(warehouseBills.getfBillingDeadline(), (Date) item.get("fOriginalbilldate"));
|
|
|
}
|
|
|
+ storageFeesDto.setDays(fBillingDays);
|
|
|
/*if ("KCZZ".equals(fBilltype)) {
|
|
|
} else {
|
|
|
fInventoryDays = Long.valueOf(String.valueOf(item.get("fBillingDays")));
|
|
|
}*/
|
|
|
- Long dictLabel = Long.valueOf(String.valueOf(item.get("fBillingway")));
|
|
|
- BigDecimal fQty = acquiredQuantity(item, dictLabel);
|
|
|
+ storageFeesDto.setFeeUnitid(Long.valueOf(String.valueOf(item.get("fBillingway"))));
|
|
|
+ BigDecimal fQty = acquiredQuantity(item, storageFeesDto.getFeeUnitid());
|
|
|
if (fQty.equals(BigDecimal.ZERO)) {
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
return AjaxResult.error("单号:" + item.get("fBillno") + ",业务日期:" + item.get("fBsdate") + "未找到计费单位,请确认");
|
|
|
}
|
|
|
+ storageFeesDto.setItemNums(fQty);
|
|
|
// 计算仓储费明细
|
|
|
- Map<String, Object> objectMap = tWarehouseAgreementService.getCarryingCost(fCorpid, fGoodsid, fBillingDays, dictLabel, fQty, accumulatedDays, warehouse, warehouseId);
|
|
|
+ Map<String, Object> objectMap = tWarehouseAgreementService.getCarryingCost(storageFeesDto);
|
|
|
if (StringUtils.isNull(objectMap)) {
|
|
|
map.put("error", "单号:" + item.get("fBillno") + ",业务日期:" + item.get("fBsdate") + "未找到仓储费协议,请确认");
|
|
|
return map;
|
|
@@ -4165,7 +4290,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
|
|
|
fees.setfBilltype(fBilltype);
|
|
|
fees.setfBillingDays(fBillingDays);
|
|
|
fees.setCreateTime(new Date());
|
|
|
- fees.setfWarehouseid(warehouseId);
|
|
|
+ fees.setfWarehouseid(storageFeesDto.getWarehouseId());
|
|
|
fees.setfQty(new BigDecimal(1));
|
|
|
fees.setfPid(warehouseBills.getfId());
|
|
|
fees.setfInventoryDays(fInventoryDays);
|
|
@@ -4196,99 +4321,6 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 新增库存费计算
|
|
|
- *
|
|
|
- * @param tWarehouseBills 主表的查询条件
|
|
|
- * @param loginUser 登录用户
|
|
|
- * @param billsType 状态
|
|
|
- * @return 结果
|
|
|
- */
|
|
|
- @Override
|
|
|
- @Transactional
|
|
|
- public AjaxResult calculateStorageFees(TWarehouseBills tWarehouseBills, LoginUser loginUser, String billsType) {
|
|
|
- if (StringUtils.isNull(tWarehouseBills.getfCorpid())) {
|
|
|
- return AjaxResult.error("请选择客户信息");
|
|
|
- }
|
|
|
- long fPid = 0L;
|
|
|
- if (StringUtils.isNull(tWarehouseBills.getfId())) {
|
|
|
- // 生成流水号
|
|
|
- Date time = new Date();
|
|
|
- String billNo = billnoSerialServiceImpl.getSerialNumber("JSCCF", 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");
|
|
|
- // 库存总账id
|
|
|
- long whgenlegFeeId = 0;
|
|
|
- // 计费单位
|
|
|
- long feeUnitid = 1;
|
|
|
- // 查出所有仓库 给后续匹配仓库名字使用
|
|
|
- List<TWarehouse> warehouseList = tWarehouseMapper.selectTWarehouseList(new TWarehouse());
|
|
|
- // 查询 出库 货转的库存明细
|
|
|
- List<Map<String, Object>> warehousebillsitemsList = tWarehousebillsitemsMapper.selectStorageFeeItemList(tWarehouseBills);
|
|
|
- if (warehousebillsitemsList.size() != 0) {
|
|
|
- Map<String, Object> mapItem = getWarehouseItems(tWarehouseBills, warehousebillsitemsList, 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<Map<String, Object>> tWhgenlegs = tWhgenlegMapper.selectStorageFeeItemList(tWarehouseBills);
|
|
|
- if (tWhgenlegs.size() != 0) {
|
|
|
- Map<String, Object> mapItem = getWarehouseItems(tWarehouseBills, tWhgenlegs, 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 (itemsList.size() <= 0) {
|
|
|
- return AjaxResult.error("未找到合适的库存明细");
|
|
|
- }
|
|
|
- map.put("feesList", feesList);
|
|
|
- map.put("warehouseBills", tWarehouseBills);
|
|
|
- map.put("warehouseItemList", itemsList);
|
|
|
- return AjaxResult.success(map);
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public AjaxResult calculateStorageFeesList(List<TWarehouseBills> tWarehouseBillsList, LoginUser loginUser, String billsType) {
|
|
@@ -4858,7 +4890,10 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
|
|
|
tWarehousebills.setfNetweight(itemInFo.getfNetweight());
|
|
|
tWarehousebills.setfGrossweight(itemInFo.getfGrossweight());
|
|
|
tWarehousebillsfeesMapper.warehouseFeesFollowUpdate(tWarehousebills.getfId(), 2L, new Date());
|
|
|
- if ("JSCCF".equals(tWarehousebills.getfBilltype())) {
|
|
|
+ // 判断是否出库
|
|
|
+ if (tWarehousebills.getfBilltype().equals(WarehouseType.SJCK.getType())) {
|
|
|
+ cancellationInStockFee(tWarehousebills);
|
|
|
+ } else if ("JSCCF".equals(tWarehousebills.getfBilltype())) {
|
|
|
List<TWarehousebillsfees> feesList = tWarehousebillsfeesMapper.selectWarehousebillsfeesByPId(fId);
|
|
|
// 取出本次变更的日期
|
|
|
Date chargedate = DateUtils.dateAdd(tWarehousebills.getfBillingDeadline(), 1);
|
|
@@ -4876,7 +4911,6 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
|
|
|
if (!forwardingIds.isEmpty() && tWarehousebillsitemsMapper.queryChangedByFchargedate(forwardingIds, chargedate) > 0) {
|
|
|
throw new WarehouseException("审批撤销失败,货转明细存在二级计算");
|
|
|
}
|
|
|
-
|
|
|
for (TWarehousebillsfees wareItem : feesList) {
|
|
|
if (StringUtils.isNull(wareItem.getSrcId())) {
|
|
|
continue;
|
|
@@ -4909,6 +4943,30 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 撤销入库费用信息,并更新子订单
|
|
|
+ *
|
|
|
+ * @param tWarehousebills 订单信息
|
|
|
+ */
|
|
|
+ private void cancellationInStockFee(TWarehouseBills tWarehousebills) {
|
|
|
+ LambdaUpdateWrapper<TWarehousebillsitems> updateWrapper = Wrappers.<TWarehousebillsitems>lambdaUpdate();
|
|
|
+ // 查询出库费用信息
|
|
|
+ List<TWarehousebillsfees> feesList = tWarehousebillsfeesMapper.selectWarehousebillsfeesByPId(tWarehousebills.getfId());
|
|
|
+ // 获取仓储费,并判断费用中是否存在仓储费
|
|
|
+ TFee ccf = tFeeMapper.seletFeeByCode("CCF");
|
|
|
+ if (Objects.isNull(ccf)) {
|
|
|
+ throw new WarehouseException("未找到仓储费费用信息");
|
|
|
+ }
|
|
|
+ // 过滤出费用类型等于仓储费并且有商机id,并取出来进行更新仓储费计费日期
|
|
|
+ List<Long> itemIds = feesList.stream().filter(li -> Objects.equals(li.getfFeeid(), ccf.getfId()) && Objects.nonNull(li.getSrcId()))
|
|
|
+ .map(TWarehousebillsfees::getSrcId).distinct().collect(toList());
|
|
|
+
|
|
|
+ updateWrapper = updateWrapper.in(TWarehousebillsitems::getfPid, itemIds)
|
|
|
+ .isNull(TWarehousebillsitems::getfStorageFeeDeadline);
|
|
|
+
|
|
|
+ tWarehousebillsitemsMapper.update(new TWarehousebillsitems(), updateWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 撤销已审核通过的接单入库信息
|
|
|
*
|
|
|
* @param fId
|