|
|
@@ -41,8 +41,6 @@ import org.springblade.los.trade.entity.Storage;
|
|
|
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.service.IStorageService;
|
|
|
import org.springblade.los.trade.vo.InOutStorageVO;
|
|
|
import org.springblade.system.entity.Dept;
|
|
|
@@ -77,10 +75,6 @@ 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;
|
|
|
@@ -99,6 +93,14 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public R confirmWarehouseEntry(InOutStorage inOutStorage) {
|
|
|
+ Storage storage = storageService.getById(inOutStorage.getWarehouseId());
|
|
|
+ if (storage == null) {
|
|
|
+ throw new RuntimeException("未查到仓库信息");
|
|
|
+ }
|
|
|
+ boolean billingRules = true;
|
|
|
+ if ("1".equals(storage.getBillingRules())) {
|
|
|
+ billingRules = false;
|
|
|
+ }
|
|
|
inOutStorage.setConfirmDispatchVehicles("1");
|
|
|
inOutStorage.setUpdateTime(new Date());
|
|
|
inOutStorage.setUpdateUser(AuthUtil.getUserId());
|
|
|
@@ -107,6 +109,7 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
|
|
|
if (ObjectUtils.isNull(inOutStorage.getStorageDate())) {
|
|
|
inOutStorage.setStorageDate(new Date());
|
|
|
}
|
|
|
+ inOutStorage.setChargingDate(inOutStorage.getStorageDate());
|
|
|
Bills bills = billsMapper.selectById(inOutStorage.getPid());
|
|
|
if (ObjectUtils.isNotNull(bills.getMconsigneeCntyName())) {
|
|
|
List<FeeCenter> feeCenterList = feeCenterMapper.selectList(new LambdaQueryWrapper<FeeCenter>()
|
|
|
@@ -134,17 +137,6 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
|
|
|
if (feeCenterTradeList.isEmpty()) {
|
|
|
throw new RuntimeException("未查到提单号:" + bills.getMblno() + "对应贸易代理费用信息");
|
|
|
}
|
|
|
- /*List<Long> ids = feeCenterTradeList.stream().map(FeeCenter::getPid).filter(Objects::nonNull)
|
|
|
- .distinct().collect(Collectors.toList());
|
|
|
- List<FeeCenter> feeCenterTradeList1 = feeCenterMapper.selectList(new LambdaQueryWrapper<FeeCenter>()
|
|
|
- .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(FeeCenter::getIsDeleted, 0)
|
|
|
- .in(FeeCenter::getPid, ids)
|
|
|
- .eq(FeeCenter::getDc, "C")
|
|
|
- .apply("find_in_set(fee_code,'SXF,YDF') and (mblno IS NULL or mblno = '')"));
|
|
|
- if (!feeCenterTradeList1.isEmpty()) {
|
|
|
- feeCenterTradeList.addAll(feeCenterTradeList1);
|
|
|
- }*/
|
|
|
List<AgentItems> agentItemsList = agentItemsMapper.selectList(new LambdaQueryWrapper<AgentItems>()
|
|
|
.eq(AgentItems::getPid, feeCenterTradeList.get(0).getPid())
|
|
|
.eq(AgentItems::getTenantId, AuthUtil.getTenantId())
|
|
|
@@ -235,6 +227,11 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
|
|
|
} else {
|
|
|
inOutStorage.setWarehouseUnitPrice(inOutStorage.getPrice());
|
|
|
}
|
|
|
+ if (billingRules) {
|
|
|
+ inOutStorage.setSurplusGoodsAmount(inOutStorage.getSurplusNetWeight().multiply(inOutStorage.getPrice()));
|
|
|
+ } else {
|
|
|
+ inOutStorage.setSurplusGoodsAmount(inOutStorage.getSurplusWeight().multiply(inOutStorage.getPrice()));
|
|
|
+ }
|
|
|
} else {
|
|
|
if (ObjectUtils.isNull(inOutStorage.getOutStorageDate())) {
|
|
|
inOutStorage.setOutStorageDate(new Date());
|
|
|
@@ -246,13 +243,23 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
|
|
|
}
|
|
|
BigDecimal grossWeight = inStorage.getSurplusWeight();
|
|
|
if (grossWeight.compareTo(inOutStorage.getOutWeight()) < 0) {
|
|
|
- throw new RuntimeException("剩余重量:" + grossWeight + "小于出库重量:" + inOutStorage.getOutWeight());
|
|
|
+ throw new RuntimeException("剩余毛重:" + grossWeight + "小于出库毛重:" + inOutStorage.getOutWeight());
|
|
|
+ }
|
|
|
+ BigDecimal netWeight = inStorage.getSurplusNetWeight();
|
|
|
+ if (netWeight.compareTo(inOutStorage.getOutNetWeight()) < 0) {
|
|
|
+ throw new RuntimeException("剩余净重:" + netWeight + "小于出库净重:" + inOutStorage.getOutWeight());
|
|
|
}
|
|
|
inStorage.setOutQuantity(inStorage.getOutQuantity().add(inOutStorage.getOutQuantity()));
|
|
|
inStorage.setOutWeight(inStorage.getOutWeight().add(inOutStorage.getOutWeight()));
|
|
|
+ inStorage.setOutNetWeight(inStorage.getOutNetWeight().add(inOutStorage.getOutNetWeight()));
|
|
|
inStorage.setSurplusQuantity(quantity.subtract(inOutStorage.getOutQuantity()));
|
|
|
inStorage.setSurplusWeight(grossWeight.subtract(inOutStorage.getOutWeight()));
|
|
|
- inStorage.setSurplusGoodsAmount(inStorage.getSurplusWeight().multiply(inOutStorage.getPrice()));
|
|
|
+ inStorage.setSurplusNetWeight(netWeight.subtract(inOutStorage.getOutNetWeight()));
|
|
|
+ if (billingRules) {
|
|
|
+ inStorage.setSurplusGoodsAmount(inStorage.getSurplusWeight().multiply(inOutStorage.getPrice()));
|
|
|
+ } else {
|
|
|
+ inStorage.setSurplusGoodsAmount(inStorage.getSurplusNetWeight().multiply(inOutStorage.getPrice()));
|
|
|
+ }
|
|
|
inStorage.setUpdateTime(new Date());
|
|
|
inStorage.setUpdateUser(AuthUtil.getUserId());
|
|
|
inStorage.setUpdateUserName(AuthUtil.getUserName());
|
|
|
@@ -260,7 +267,12 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
|
|
|
|
|
|
inOutStorage.setSurplusQuantity(quantity.subtract(inOutStorage.getOutQuantity()));
|
|
|
inOutStorage.setSurplusWeight(grossWeight.subtract(inOutStorage.getOutWeight()));
|
|
|
- inOutStorage.setSurplusGoodsAmount(inStorage.getSurplusWeight().multiply(inOutStorage.getPrice()));
|
|
|
+ inOutStorage.setSurplusNetWeight(netWeight.subtract(inOutStorage.getOutNetWeight()));
|
|
|
+ if (billingRules) {
|
|
|
+ inOutStorage.setSurplusGoodsAmount(inStorage.getSurplusWeight().multiply(inOutStorage.getPrice()));
|
|
|
+ } else {
|
|
|
+ inOutStorage.setSurplusGoodsAmount(inStorage.getSurplusNetWeight().multiply(inOutStorage.getPrice()));
|
|
|
+ }
|
|
|
Bills bills = billsMapper.selectById(inOutStorage.getPid());
|
|
|
if (bills != null) {
|
|
|
BFees fees = bFeesService.getOne(new LambdaQueryWrapper<BFees>()
|
|
|
@@ -275,10 +287,16 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
|
|
|
// 计算差多少天
|
|
|
long day = diff / nd + 1L;
|
|
|
StringBuilder remark = new StringBuilder("仓储费:");
|
|
|
- BigDecimal outWeight = inOutStorage.getOutWeight().divide(new BigDecimal("1000"), 4, RoundingMode.HALF_UP);
|
|
|
+ BigDecimal weight;
|
|
|
+ BigDecimal amountSum;
|
|
|
+ if (billingRules) {
|
|
|
+ weight = inOutStorage.getOutNetWeight().divide(new BigDecimal("1000"), 4, RoundingMode.HALF_UP);
|
|
|
+ } else {
|
|
|
+ weight = inOutStorage.getOutWeight().divide(new BigDecimal("1000"), 4, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
BigDecimal dayDecimal = new BigDecimal(day);
|
|
|
- BigDecimal amountSum = dayDecimal.multiply(inOutStorage.getStorageFeePriceD()).multiply(outWeight);
|
|
|
- remark.append(day).append("天*").append(inOutStorage.getStorageFeePriceD()).append("元*").append(outWeight).append("吨=").append(amountSum).append("元 ");
|
|
|
+ amountSum = dayDecimal.multiply(inOutStorage.getStorageFeePriceD()).multiply(weight);
|
|
|
+ remark.append(day).append("天*").append(inOutStorage.getStorageFeePriceD()).append("元*").append(weight).append("吨=").append(amountSum).append("元 ");
|
|
|
FeeCenter feeCenter = new FeeCenter();
|
|
|
feeCenter.setCreateTime(new Date());
|
|
|
feeCenter.setCreateUser(AuthUtil.getUserId());
|
|
|
@@ -318,7 +336,7 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
|
|
|
feeCenter.setElementsCnName(fees.getAccElementName());
|
|
|
feeCenter.setElementsEnName(fees.getElementsEnName());
|
|
|
feeCenter.setUnitNo("JOB");
|
|
|
- feeCenter.setQuantity(outWeight);
|
|
|
+ feeCenter.setQuantity(weight);
|
|
|
feeCenter.setPrice(inOutStorage.getStorageFeePriceD());
|
|
|
feeCenter.setAmount(amountSum);
|
|
|
feeCenter.setRemarks(remark.toString());
|
|
|
@@ -327,9 +345,9 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
|
|
|
feeCenter.setOutboundDate(inOutStorage.getOutStorageDate());
|
|
|
feeCenter.setSrcItemId(inOutStorage.getId());
|
|
|
feeCenterMapper.insert(feeCenter);
|
|
|
- StringBuilder remarkC = new StringBuilder("仓储费:");
|
|
|
- BigDecimal amountSumC = dayDecimal.multiply(inOutStorage.getStorageFeePriceC()).multiply(outWeight);
|
|
|
- remarkC.append(day).append("天*").append(inOutStorage.getStorageFeePriceC()).append("元*").append(outWeight).append("吨=").append(amountSumC).append("元 ");
|
|
|
+// StringBuilder remarkC = new StringBuilder("仓储费:");
|
|
|
+ BigDecimal amountSumC = dayDecimal.multiply(inOutStorage.getStorageFeePriceC()).multiply(weight);
|
|
|
+ /*remarkC.append(day).append("天*").append(inOutStorage.getStorageFeePriceC()).append("元*").append(outWeight).append("吨=").append(amountSumC).append("元 ");
|
|
|
FeeCenter feeCenterC = new FeeCenter();
|
|
|
feeCenterC.setCreateTime(new Date());
|
|
|
feeCenterC.setCreateUser(AuthUtil.getUserId());
|
|
|
@@ -375,7 +393,7 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
|
|
|
feeCenterC.setStorageDate(inStorage.getStorageDate());
|
|
|
feeCenterC.setOutboundDate(inOutStorage.getOutStorageDate());
|
|
|
feeCenterC.setSrcItemId(inOutStorage.getId());
|
|
|
- feeCenterMapper.insert(feeCenterC);
|
|
|
+ feeCenterMapper.insert(feeCenterC);*/
|
|
|
inOutStorage.setStorageDays(Integer.parseInt(day + ""));
|
|
|
inOutStorage.setStorageFeesAmount(amountSumC);
|
|
|
}
|
|
|
@@ -413,14 +431,25 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
|
|
|
outStorage.setUpdateUserName(null);
|
|
|
outStorage.setBillType("CK");
|
|
|
outStorage.setOutQuantity(inOutStorage.getQuantity().subtract(inOutStorage.getOutQuantity()));
|
|
|
- outStorage.setOutWeight(inOutStorage.getNetWeight().subtract(inOutStorage.getOutWeight()));
|
|
|
+ outStorage.setOutWeight(inOutStorage.getGrossWeight().subtract(inOutStorage.getOutWeight()));
|
|
|
+ outStorage.setOutNetWeight(inOutStorage.getNetWeight().subtract(inOutStorage.getOutNetWeight()));
|
|
|
outStorage.setSurplusQuantity(inOutStorage.getQuantity().subtract(inOutStorage.getOutQuantity()));
|
|
|
- outStorage.setSurplusWeight(inOutStorage.getNetWeight().subtract(inOutStorage.getOutWeight()));
|
|
|
- outStorage.setSurplusGoodsAmount(inOutStorage.getSurplusWeight().multiply(inOutStorage.getPrice()));
|
|
|
+ outStorage.setSurplusNetWeight(inOutStorage.getNetWeight().subtract(inOutStorage.getOutNetWeight()));
|
|
|
+ outStorage.setSurplusWeight(inOutStorage.getGrossWeight().subtract(inOutStorage.getOutWeight()));
|
|
|
+ Storage storage = storageService.getById(inOutStorage.getWarehouseId());
|
|
|
+ if (storage == null) {
|
|
|
+ throw new RuntimeException("未查到仓库信息");
|
|
|
+ }
|
|
|
+ if ("1".equals(storage.getBillingRules())) {
|
|
|
+ outStorage.setSurplusGoodsAmount(inOutStorage.getSurplusWeight().multiply(inOutStorage.getPrice()));
|
|
|
+ } else {
|
|
|
+ outStorage.setSurplusGoodsAmount(inOutStorage.getSurplusNetWeight().multiply(inOutStorage.getPrice()));
|
|
|
+ }
|
|
|
outStorage.setConfirmDispatchVehicles("0");
|
|
|
baseMapper.insert(outStorage);
|
|
|
if (new BigDecimal("0.00").compareTo(inOutStorage.getSurplusQuantity()) == 0 &&
|
|
|
- new BigDecimal("0.00").compareTo(inOutStorage.getSurplusWeight()) == 0) {
|
|
|
+ new BigDecimal("0.00").compareTo(inOutStorage.getSurplusWeight()) == 0 &&
|
|
|
+ new BigDecimal("0.00").compareTo(inOutStorage.getSurplusNetWeight()) == 0) {
|
|
|
throw new RuntimeException("库存余额为零,生成失败");
|
|
|
}
|
|
|
|
|
|
@@ -495,17 +524,6 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
|
|
|
if (feeCenterTradeList.isEmpty()) {
|
|
|
throw new RuntimeException("未查到提单号:" + bills.getMblno() + "对应贸易代理费用信息");
|
|
|
}
|
|
|
- /*List<Long> ids = feeCenterTradeList.stream().map(FeeCenter::getPid).filter(Objects::nonNull)
|
|
|
- .distinct().collect(Collectors.toList());
|
|
|
- List<FeeCenter> feeCenterTradeList1 = feeCenterMapper.selectList(new LambdaQueryWrapper<FeeCenter>()
|
|
|
- .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(FeeCenter::getIsDeleted, 0)
|
|
|
- .in(FeeCenter::getPid, ids)
|
|
|
- .eq(FeeCenter::getDc, "C")
|
|
|
- .apply("find_in_set(fee_code,'SXF,YDF') and (mblno IS NULL or mblno = '')"));
|
|
|
- if (!feeCenterTradeList1.isEmpty()) {
|
|
|
- feeCenterTradeList.addAll(feeCenterTradeList1);
|
|
|
- }*/
|
|
|
List<AgentItems> agentItemsList = agentItemsMapper.selectList(new LambdaQueryWrapper<AgentItems>()
|
|
|
.eq(AgentItems::getPid, feeCenterTradeList.get(0).getPid())
|
|
|
.eq(AgentItems::getTenantId, AuthUtil.getTenantId())
|
|
|
@@ -614,6 +632,7 @@ 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>()
|
|
|
@@ -644,15 +663,30 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
+ Storage storage = storageService.getById(inOutStorage.getWarehouseId());
|
|
|
+ if (storage == null) {
|
|
|
+ throw new RuntimeException("未查到仓库信息");
|
|
|
+ }
|
|
|
+ boolean billingRules = true;
|
|
|
+ if ("1".equals(storage.getBillingRules())) {
|
|
|
+ billingRules = false;
|
|
|
+ }
|
|
|
inOutStorage.setOutStorageDate(null);
|
|
|
InOutStorage inStorage = baseMapper.selectById(inOutStorage.getSrcId());
|
|
|
BigDecimal quantity = inStorage.getSurplusQuantity();
|
|
|
BigDecimal grossWeight = inStorage.getSurplusWeight();
|
|
|
+ BigDecimal netWeight = inStorage.getSurplusNetWeight();
|
|
|
inStorage.setOutQuantity(inStorage.getOutQuantity().subtract(inOutStorage.getOutQuantity()));
|
|
|
inStorage.setOutWeight(inStorage.getOutWeight().subtract(inOutStorage.getOutWeight()));
|
|
|
+ inStorage.setOutNetWeight(inStorage.getOutNetWeight().subtract(inOutStorage.getOutNetWeight()));
|
|
|
inStorage.setSurplusQuantity(quantity.add(inOutStorage.getOutQuantity()));
|
|
|
inStorage.setSurplusWeight(grossWeight.add(inOutStorage.getOutWeight()));
|
|
|
- inStorage.setSurplusGoodsAmount(inStorage.getSurplusGoodsAmount().add(inStorage.getSurplusWeight().multiply(inOutStorage.getPrice())));
|
|
|
+ inStorage.setSurplusNetWeight(netWeight.add(inOutStorage.getOutNetWeight()));
|
|
|
+ if (billingRules){
|
|
|
+ inStorage.setSurplusGoodsAmount(inStorage.getSurplusGoodsAmount().add(inStorage.getSurplusNetWeight().multiply(inOutStorage.getPrice())));
|
|
|
+ }else{
|
|
|
+ inStorage.setSurplusGoodsAmount(inStorage.getSurplusGoodsAmount().add(inStorage.getSurplusWeight().multiply(inOutStorage.getPrice())));
|
|
|
+ }
|
|
|
inStorage.setUpdateTime(new Date());
|
|
|
inStorage.setUpdateUser(AuthUtil.getUserId());
|
|
|
inStorage.setUpdateUserName(AuthUtil.getUserName());
|
|
|
@@ -664,7 +698,7 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
|
|
|
.eq(FeeCenter::getPid, inOutStorage.getPid())
|
|
|
.eq(FeeCenter::getSrcItemId, inOutStorage.getId()));
|
|
|
if (!feeCenter.isEmpty()) {
|
|
|
- for (FeeCenter item :feeCenter){
|
|
|
+ for (FeeCenter item : feeCenter) {
|
|
|
if (1 == item.getAccStatus()) {
|
|
|
throw new RuntimeException("仓储费已生成账单,撤销失败");
|
|
|
}
|