|
|
@@ -26,14 +26,22 @@ import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
|
import org.springblade.los.Util.IDeptUtils;
|
|
|
+import org.springblade.los.basic.fees.entity.BFees;
|
|
|
+import org.springblade.los.basic.fees.service.IBFeesService;
|
|
|
import org.springblade.los.business.sea.entity.Bills;
|
|
|
import org.springblade.los.business.sea.mapper.BillsMapper;
|
|
|
+import org.springblade.los.finance.fee.entity.FeeCenter;
|
|
|
+import org.springblade.los.finance.fee.mapper.FeeCenterMapper;
|
|
|
+import org.springblade.los.finance.fee.service.IFeeCenterService;
|
|
|
import org.springblade.los.trade.entity.AgentItems;
|
|
|
-import org.springblade.los.trade.entity.DispatchVehicles;
|
|
|
import org.springblade.los.trade.entity.InOutStorage;
|
|
|
+import org.springblade.los.trade.entity.StorageFee;
|
|
|
+import org.springblade.los.trade.entity.StorageFeeItems;
|
|
|
import org.springblade.los.trade.mapper.AgentItemsMapper;
|
|
|
import org.springblade.los.trade.mapper.InOutStorageMapper;
|
|
|
import org.springblade.los.trade.service.IInOutStorageService;
|
|
|
+import org.springblade.los.trade.service.IStorageFeeItemsService;
|
|
|
+import org.springblade.los.trade.service.IStorageFeeService;
|
|
|
import org.springblade.los.trade.vo.InOutStorageVO;
|
|
|
import org.springblade.system.entity.Dept;
|
|
|
import org.springblade.system.feign.ISysClient;
|
|
|
@@ -63,15 +71,26 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
|
|
|
|
|
|
private final AgentItemsMapper agentItemsMapper;
|
|
|
|
|
|
+ private final IStorageFeeService storageFeeService;
|
|
|
+
|
|
|
+ private final IStorageFeeItemsService storageFeeItemsService;
|
|
|
+
|
|
|
+ private final IBFeesService bFeesService;
|
|
|
+
|
|
|
+ private final FeeCenterMapper feeCenterMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<InOutStorageVO> selectInOutStoragePage(IPage<InOutStorageVO> page, InOutStorageVO inOutStorage) {
|
|
|
return page.setRecords(baseMapper.selectInOutStoragePage(page, inOutStorage));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
|
|
|
public R confirmWarehouseEntry(InOutStorage inOutStorage) {
|
|
|
inOutStorage.setConfirmDispatchVehicles("1");
|
|
|
inOutStorage.setUpdateTime(new Date());
|
|
|
+ inOutStorage.setOutStorageDate(new Date());
|
|
|
inOutStorage.setUpdateUser(AuthUtil.getUserId());
|
|
|
inOutStorage.setUpdateUserName(AuthUtil.getUserName());
|
|
|
if ("RK".equals(inOutStorage.getBillType())) {
|
|
|
@@ -106,6 +125,106 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
|
|
|
inStorage.setUpdateTime(new Date());
|
|
|
inStorage.setUpdateUser(AuthUtil.getUserId());
|
|
|
inStorage.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+
|
|
|
+ Bills bills = billsMapper.selectById(inOutStorage.getPid());
|
|
|
+ if (bills != null) {
|
|
|
+ StorageFee storageFee = storageFeeService.getOne(new LambdaQueryWrapper<StorageFee>()
|
|
|
+ .eq(StorageFee::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(StorageFee::getIsDeleted, 0)
|
|
|
+ .eq(StorageFee::getStatus, 1)
|
|
|
+ .eq(StorageFee::getWarehouseId, inOutStorage.getWarehouseId())
|
|
|
+ .eq(StorageFee::getGoodsType, inOutStorage.getGoodsType())
|
|
|
+ .eq(StorageFee::getCorpId, bills.getCorpId()));
|
|
|
+ if (storageFee == null) {
|
|
|
+ throw new RuntimeException("未查到可用仓储费规则,请先维护");
|
|
|
+ }
|
|
|
+ List<StorageFeeItems> storageFeeItemsList = storageFeeItemsService.list(new LambdaQueryWrapper<StorageFeeItems>()
|
|
|
+ .eq(StorageFeeItems::getPid, storageFee.getId())
|
|
|
+ .eq(StorageFeeItems::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(StorageFeeItems::getIsDeleted, 0)
|
|
|
+ .orderByAsc(StorageFeeItems::getSort));
|
|
|
+ if (storageFeeItemsList.isEmpty()) {
|
|
|
+ throw new RuntimeException("请先维护仓储费规则明细");
|
|
|
+ }
|
|
|
+ long nd = 1000 * 24 * 60 * 60;
|
|
|
+ long diff = inOutStorage.getOutStorageDate().getTime() - inStorage.getStorageDate().getTime();
|
|
|
+ // 计算差多少天
|
|
|
+ long day = diff / nd + 1L;
|
|
|
+ long dayLength = day;
|
|
|
+ StringBuilder remark = new StringBuilder("仓储费:");
|
|
|
+ BigDecimal amount = new BigDecimal("0.00");
|
|
|
+ for (StorageFeeItems item : storageFeeItemsList) {
|
|
|
+ int days = item.getEnDays() - item.getFromDays();
|
|
|
+ if (dayLength != 0) {
|
|
|
+ if (day >= days) {
|
|
|
+ dayLength = dayLength - days;
|
|
|
+ BigDecimal dayDecimal = new BigDecimal(days);
|
|
|
+ BigDecimal amountSum = dayDecimal.multiply(item.getPrice()).multiply(inOutStorage.getGrossWeight());
|
|
|
+ amount = amount.add(amountSum);
|
|
|
+ remark.append(days).append("天*").append(item.getPrice()).append("元*").append(inOutStorage.getGrossWeight()).append("=").append(amountSum).append("元 ");
|
|
|
+ } else {
|
|
|
+ BigDecimal dayDecimal = new BigDecimal(dayLength);
|
|
|
+ BigDecimal amountSum = dayDecimal.multiply(item.getPrice()).multiply(inOutStorage.getGrossWeight());
|
|
|
+ amount = amount.add(amountSum);
|
|
|
+ remark.append(dayLength).append("天*").append(item.getPrice()).append("元*").append(inOutStorage.getGrossWeight()).append("=").append(amountSum).append("元 ");
|
|
|
+ dayLength = days - dayLength;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ FeeCenter feeCenter = new FeeCenter();
|
|
|
+ feeCenter.setCreateTime(new Date());
|
|
|
+ feeCenter.setCreateUser(AuthUtil.getUserId());
|
|
|
+ feeCenter.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
+ feeCenter.setCreateDept(bills.getCreateDept());
|
|
|
+ feeCenter.setBranchId(bills.getBranchId());
|
|
|
+ feeCenter.setCreateDeptName(bills.getCreateDeptName());
|
|
|
+ }
|
|
|
+ feeCenter.setBusinessType(bills.getBusinessType());
|
|
|
+ feeCenter.setPid(bills.getId());
|
|
|
+ feeCenter.setLineNo(1L);
|
|
|
+ feeCenter.setBillNo(bills.getBillNo());
|
|
|
+ feeCenter.setBillDate(bills.getBillDate());
|
|
|
+ feeCenter.setCorpId(bills.getCorpId());
|
|
|
+ feeCenter.setCorpCnName(bills.getCorpCnName());
|
|
|
+ feeCenter.setBillCorpId(bills.getCorpId());
|
|
|
+ feeCenter.setBillCorpCnName(bills.getCorpCnName());
|
|
|
+ feeCenter.setMblno(bills.getMblno());
|
|
|
+ feeCenter.setPolId(bills.getPolId());
|
|
|
+ feeCenter.setPolCode(bills.getPolCode());
|
|
|
+ feeCenter.setPolCnName(bills.getPolCnName());
|
|
|
+ feeCenter.setPolEnName(bills.getPolEnName());
|
|
|
+ feeCenter.setPodId(bills.getPodId());
|
|
|
+ feeCenter.setPodCode(bills.getPodCode());
|
|
|
+ feeCenter.setPodCnName(bills.getPodCnName());
|
|
|
+ feeCenter.setPodEnName(bills.getPodEnName());
|
|
|
+ BFees fees = bFeesService.getById(storageFeeItemsList.get(0).getFeeId());
|
|
|
+ if (fees == null) {
|
|
|
+ throw new RuntimeException("请先维护" + storageFeeItemsList.get(0).getFeeName() + "费用信息");
|
|
|
+ }
|
|
|
+ feeCenter.setFeeId(fees.getId());
|
|
|
+ feeCenter.setFeeCode(fees.getCode());
|
|
|
+ feeCenter.setFeeCnName(fees.getCnName());
|
|
|
+ feeCenter.setFeeEnName(fees.getEnName());
|
|
|
+ feeCenter.setDc("D");
|
|
|
+ feeCenter.setCurCode(fees.getCurNo());
|
|
|
+ feeCenter.setSort(1);
|
|
|
+ feeCenter.setElementsId(fees.getAccElementId());
|
|
|
+ feeCenter.setElementsCode(fees.getElementsCode());
|
|
|
+ feeCenter.setElementsCnName(fees.getAccElementName());
|
|
|
+ feeCenter.setElementsEnName(fees.getElementsEnName());
|
|
|
+ feeCenter.setUnitNo("JOB");
|
|
|
+ feeCenter.setQuantity(new BigDecimal("1"));
|
|
|
+ feeCenter.setPrice(amount);
|
|
|
+ feeCenter.setAmount(amount);
|
|
|
+ feeCenter.setRemarks(remark.toString());
|
|
|
+ feeCenter.setDays(Integer.parseInt(day+""));
|
|
|
+ feeCenter.setStorageDate(inOutStorage.getOutStorageDate());
|
|
|
+ feeCenter.setOutboundDate(inStorage.getStorageDate());
|
|
|
+ feeCenterMapper.insert(feeCenter);
|
|
|
+ inStorage.setStorageDays(Integer.parseInt(day+""));
|
|
|
+ inStorage.setStorageFeesAmount(amount);
|
|
|
+ }
|
|
|
baseMapper.updateById(inStorage);
|
|
|
}
|
|
|
baseMapper.updateById(inOutStorage);
|
|
|
@@ -113,6 +232,8 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
|
|
|
public R generateOutbound(InOutStorage inOutStorage) {
|
|
|
Long deptId = 0L;
|
|
|
String deptName = "";
|
|
|
@@ -145,7 +266,10 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
|
|
|
outStorage.setSurplusQuantity(inOutStorage.getOutQuantity());
|
|
|
outStorage.setSurplusWeight(inOutStorage.getOutWeight());
|
|
|
outStorage.setSurplusGoodsAmount(inOutStorage.getOutQuantity().multiply(inOutStorage.getPrice()));
|
|
|
+ outStorage.setConfirmDispatchVehicles("0");
|
|
|
baseMapper.insert(outStorage);
|
|
|
+ inOutStorage.setWhetherInOutStorage("1");
|
|
|
+ baseMapper.updateById(inOutStorage);
|
|
|
return R.data(inOutStorage);
|
|
|
}
|
|
|
|