|
|
@@ -14,6 +14,7 @@ import org.springblade.los.basic.corps.entity.BCorps;
|
|
|
import org.springblade.los.basic.corps.service.IBCorpsService;
|
|
|
import org.springblade.los.basic.cur.entity.BCurExrate;
|
|
|
import org.springblade.los.basic.fees.entity.BFees;
|
|
|
+import org.springblade.los.basic.fees.service.IBFeesService;
|
|
|
import org.springblade.los.business.files.entity.FilesCenter;
|
|
|
import org.springblade.los.business.files.service.IFilesCenterService;
|
|
|
import org.springblade.los.business.release.entity.SeaReleaseBillItems;
|
|
|
@@ -31,6 +32,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
@@ -76,6 +78,8 @@ public class BillUtils implements IBillUtils {
|
|
|
|
|
|
private final ISailingScheduleService sailingScheduleService;
|
|
|
|
|
|
+ private final IBFeesService bFeesService;
|
|
|
+
|
|
|
@Override
|
|
|
public void itemCopy(Bills bills, List<Bills> billsList, boolean status) {
|
|
|
List<Containers> containersList = containersService.list(new LambdaQueryWrapper<Containers>()
|
|
|
@@ -617,7 +621,7 @@ public class BillUtils implements IBillUtils {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public R verifyData(Long vesselId, String voyageNo, Long polId,String branchId) {
|
|
|
+ public R verifyData(Long vesselId, String voyageNo, Long polId, String branchId) {
|
|
|
SailingSchedule bills = sailingScheduleService.getOne(new LambdaQueryWrapper<SailingSchedule>()
|
|
|
.eq(SailingSchedule::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(SailingSchedule::getIsDeleted, 0)
|
|
|
@@ -688,4 +692,141 @@ public class BillUtils implements IBillUtils {
|
|
|
}
|
|
|
return R.data(billsList);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R generateAmendmentFee(Long id) {
|
|
|
+ Bills bills = billsMapper.selectById(id);
|
|
|
+ BFees fees = bFeesService.getOne(new LambdaQueryWrapper<BFees>()
|
|
|
+ .eq(BFees::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BFees::getIsDeleted, 0)
|
|
|
+ .eq(BFees::getCode, "GDF"));
|
|
|
+ if (fees == null) {
|
|
|
+ throw new RuntimeException("请先维护“改单费”费用信息");
|
|
|
+ }
|
|
|
+ List<FeeCenter> feeCenterList = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0)
|
|
|
+ .eq(FeeCenter::getFeeCode, fees.getCode())
|
|
|
+ .eq(FeeCenter::getDc, "D"));
|
|
|
+ if (feeCenterList.isEmpty()) {
|
|
|
+ String amendmentFee = sysClient.getParamService("amendment.fee");
|
|
|
+ String deptName = "";
|
|
|
+ String branchId = AuthUtil.getDeptId();
|
|
|
+ if (ObjectUtils.isNotNull(branchId)) {
|
|
|
+ R<String> res = sysClient.getDeptName(Long.parseLong(branchId));
|
|
|
+ if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
|
|
|
+ deptName = res.getData();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Date date;
|
|
|
+ if ("SE".equals(bills.getBusinessType())) {
|
|
|
+ if (ObjectUtils.isNotNull(bills.getActualEtd())) {
|
|
|
+ date = bills.getActualEtd();
|
|
|
+ } else {
|
|
|
+ date = bills.getEtd();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (ObjectUtils.isNotNull(bills.getActualEta())) {
|
|
|
+ date = bills.getActualEta();
|
|
|
+ } else {
|
|
|
+ date = bills.getEta();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String exrateType = currencyUtils.standardCurrency(branchId);
|
|
|
+ List<BCurExrate> curExrateList = currencyUtils.obtainRate(date, "1", branchId);
|
|
|
+ int count = 1;
|
|
|
+ FeeCenter feeCenter = new FeeCenter();
|
|
|
+ feeCenter.setBranchId(branchId);
|
|
|
+ feeCenter.setBranchName(deptName);
|
|
|
+ feeCenter.setBillBranchId(bills.getBranchId());
|
|
|
+ feeCenter.setBillBranchName(bills.getBranchName());
|
|
|
+ feeCenter.setBookingAgentId(bills.getBookingAgentId());
|
|
|
+ feeCenter.setBookingAgentCnName(bills.getBookingAgentCnName());
|
|
|
+ feeCenter.setBookingAgentEnName(bills.getBookingAgentEnName());
|
|
|
+ feeCenter.setQuantityCntrDescr(bills.getQuantityCntrDescr());
|
|
|
+ feeCenter.setTeu(bills.getTeu());
|
|
|
+ feeCenter.setPid(bills.getId());
|
|
|
+ feeCenter.setCntrNo(bills.getQuantityCntrTypesDescr());
|
|
|
+ feeCenter.setBillNo(bills.getBillNo());
|
|
|
+ feeCenter.setBusinessType(bills.getBusinessType());
|
|
|
+ feeCenter.setBillType(bills.getBillType());
|
|
|
+ feeCenter.setBillDate(bills.getBillDate());
|
|
|
+ feeCenter.setBillCorpId(bills.getCorpId());
|
|
|
+ feeCenter.setBillCorpCnName(bills.getCorpCnName());
|
|
|
+ feeCenter.setBillCorpEnName(bills.getCorpEnName());
|
|
|
+ feeCenter.setBillShortName(bills.getCorpCnName());
|
|
|
+ feeCenter.setLineId(bills.getLineId());
|
|
|
+ feeCenter.setLineCnName(bills.getLineCnName());
|
|
|
+ feeCenter.setLineEnName(bills.getLineEnName());
|
|
|
+ feeCenter.setVesselId(bills.getVesselId());
|
|
|
+ feeCenter.setVesselCnName(bills.getVesselCnName());
|
|
|
+ feeCenter.setVesselEnName(bills.getVesselEnName());
|
|
|
+ feeCenter.setVoyageNo(bills.getVoyageNo());
|
|
|
+ feeCenter.setMblno(bills.getMblno());
|
|
|
+ feeCenter.setHblno(bills.getHblno());
|
|
|
+ feeCenter.setEtd(bills.getEtd());
|
|
|
+ feeCenter.setEta(bills.getEta());
|
|
|
+ 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());
|
|
|
+ feeCenter.setDc("D");
|
|
|
+ feeCenter.setPaymode(bills.getMpaymode());
|
|
|
+ feeCenter.setSort(count);
|
|
|
+ feeCenter.setCorpType("国内直接客户");
|
|
|
+ feeCenter.setCorpId(bills.getCorpId());
|
|
|
+ feeCenter.setCorpCnName(bills.getShortName());
|
|
|
+ feeCenter.setCorpEnName(bills.getCorpEnName());
|
|
|
+ feeCenter.setShortName(bills.getShortName());
|
|
|
+ BCorps bCorps = bCorpsService.getById(bills.getCorpId());
|
|
|
+ if (bCorps != null) {
|
|
|
+ feeCenter.setGenerationCorpId(bCorps.getBookingAgentId());
|
|
|
+ feeCenter.setGenerationCorpCnName(bCorps.getBookingAgentCnName());
|
|
|
+ feeCenter.setGenerationCorpEnName(bCorps.getBookingAgentEnName());
|
|
|
+ }
|
|
|
+ feeCenter.setFeeId(fees.getId());
|
|
|
+ feeCenter.setFeeCode(fees.getCode());
|
|
|
+ feeCenter.setFeeCnName(fees.getCnName());
|
|
|
+ feeCenter.setFeeEnName(fees.getEnName());
|
|
|
+ feeCenter.setCurCode(fees.getCurNo());
|
|
|
+ if (ObjectUtils.isNull(amendmentFee) || "获取数据失败".equals(amendmentFee)) {
|
|
|
+ throw new RuntimeException("请先维护改单费参数");
|
|
|
+ }
|
|
|
+ feeCenter.setPrice(new BigDecimal(amendmentFee));
|
|
|
+ if (exrateType.equals(feeCenter.getCurCode())) {
|
|
|
+ feeCenter.setExrate(new BigDecimal("1.00"));
|
|
|
+ } else {
|
|
|
+ feeCenter.setExrate(currencyUtils.obtainExrate(feeCenter.getDc(), curExrateList, feeCenter.getCurCode(), "1"));
|
|
|
+ }
|
|
|
+ feeCenter.setUnitNo(fees.getUnitNo());
|
|
|
+ feeCenter.setQuantity(new BigDecimal("1"));
|
|
|
+ feeCenter.setAmount(feeCenter.getPrice().multiply(new BigDecimal("1")));
|
|
|
+ // 金额
|
|
|
+ BigDecimal amount;
|
|
|
+ amount = feeCenter.getQuantity().multiply(feeCenter.getPrice());
|
|
|
+ feeCenter.setAmount(amount);
|
|
|
+ if (ObjectUtils.isNull(feeCenter.getAmount())) {
|
|
|
+ feeCenter.setAmount(new BigDecimal("0"));
|
|
|
+ }
|
|
|
+ if (exrateType.equals(feeCenter.getCurCode())) {
|
|
|
+ feeCenter.setAmountLoc(feeCenter.getAmount());
|
|
|
+ } else {
|
|
|
+ if (new BigDecimal("0").compareTo(feeCenter.getAmount()) != 0) {
|
|
|
+ feeCenter.setAmountLoc(feeCenter.getAmount().multiply(feeCenter.getExrate()));
|
|
|
+ } else {
|
|
|
+ feeCenter.setAmountLoc(new BigDecimal("0"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ feeCenter.setUnsettledAmount(feeCenter.getAmount());
|
|
|
+ feeCenter.setCreateUser(AuthUtil.getUserId());
|
|
|
+ feeCenter.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ feeCenter.setCreateTime(new Date());
|
|
|
+ feeCenterService.save(feeCenter);
|
|
|
+ }
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
}
|