|
|
@@ -63,10 +63,7 @@ import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.ZoneId;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -2517,6 +2514,260 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
|
|
|
return R.data(this.removeByIds(longList));
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R synchronizationPrompt(Long billId, String dc) {
|
|
|
+ if (ObjectUtils.isNull(billId) || ObjectUtils.isNull(dc)) {
|
|
|
+ throw new RuntimeException("缺少必要参数");
|
|
|
+ }
|
|
|
+ List<Map<String, String>> mapList = new ArrayList<>();
|
|
|
+ Bills bills = billsMapper.selectById(billId);
|
|
|
+ if (bills == null) {
|
|
|
+ throw new RuntimeException("未查到单据明细");
|
|
|
+ }
|
|
|
+ List<Long> idList = new ArrayList<>();
|
|
|
+ idList.add(bills.getCorpId());
|
|
|
+ idList.add(bills.getCyId());
|
|
|
+ idList.add(bills.getCarrierId());
|
|
|
+ idList.add(bills.getBookingAgentId());
|
|
|
+ idList.add(bills.getMconsigneeId());
|
|
|
+ idList.add(bills.getMnotifyId());
|
|
|
+ idList.add(bills.getForeignAgencyId());
|
|
|
+ idList.add(bills.getShippingAgencyId());
|
|
|
+ List<BCorps> corpsList = corpsMapper.selectList(new LambdaQueryWrapper<BCorps>()
|
|
|
+ .eq(BCorps::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BCorps::getIsDeleted, 0)
|
|
|
+ .in(BCorps::getId, idList));
|
|
|
+ List<FeeCenter> feeCenterList = baseMapper.selectList(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0)
|
|
|
+ .eq(FeeCenter::getPid, billId)
|
|
|
+ .eq(FeeCenter::getDc, dc)
|
|
|
+ .isNotNull(FeeCenter::getCorpType));
|
|
|
+ if (feeCenterList.isEmpty()) {
|
|
|
+ throw new RuntimeException("未查到可同步数据");
|
|
|
+ }
|
|
|
+ for (FeeCenter feeCenter : feeCenterList) {
|
|
|
+ if (1 == feeCenter.getAccStatus()) {
|
|
|
+ throw new RuntimeException("费用:" + feeCenter.getFeeCnName() + "已生成账单");
|
|
|
+ }
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("feeCnName", feeCenter.getFeeCnName());
|
|
|
+ map.put("corpCnName", feeCenter.getCorpCnName());
|
|
|
+ if ("国内直接客户,国外直接客户,国内同行及代理".contains(feeCenter.getCorpType())) {
|
|
|
+ if (!feeCenter.getCorpId().equals(bills.getCorpId())) {
|
|
|
+ feeCenter.setCorpId(bills.getCorpId());
|
|
|
+ feeCenter.setCorpCnName(bills.getCorpCnName());
|
|
|
+ feeCenter.setCorpEnName(bills.getCorpEnName());
|
|
|
+ feeCenter.setShortName(bills.getShortName());
|
|
|
+ BCorps bCorps = null;
|
|
|
+ if (!corpsList.isEmpty()) {
|
|
|
+ bCorps = corpsList.stream().filter(e -> e.getId().equals(bills.getCorpId())).findFirst().orElse(null);
|
|
|
+ }
|
|
|
+ if (bCorps != null) {
|
|
|
+ feeCenter.setGenerationCorpId(bCorps.getBookingAgentId());
|
|
|
+ feeCenter.setGenerationCorpCnName(bCorps.getBookingAgentCnName());
|
|
|
+ feeCenter.setGenerationCorpEnName(bCorps.getBookingAgentEnName());
|
|
|
+ }
|
|
|
+ map.put("corpCnNameNew", feeCenter.getCorpCnName());
|
|
|
+ mapList.add(map);
|
|
|
+ }
|
|
|
+ } else if ("国外同行及代理".contains(feeCenter.getCorpType())) {
|
|
|
+ if (!feeCenter.getCorpId().equals(bills.getForeignAgencyId())) {
|
|
|
+ feeCenter.setCorpId(bills.getForeignAgencyId());
|
|
|
+ feeCenter.setCorpCnName(bills.getForeignAgencyCnName());
|
|
|
+ feeCenter.setCorpEnName(bills.getForeignAgencyEnName());
|
|
|
+ feeCenter.setShortName(bills.getForeignAgencyCnName());
|
|
|
+ if (!corpsList.isEmpty()) {
|
|
|
+ BCorps foreignAgency = corpsList.stream().filter(e -> e.getId().equals(bills.getForeignAgencyId())).findFirst().orElse(null);
|
|
|
+ if (foreignAgency != null) {
|
|
|
+ feeCenter.setGenerationCorpId(foreignAgency.getBookingAgentId());
|
|
|
+ feeCenter.setGenerationCorpCnName(foreignAgency.getBookingAgentCnName());
|
|
|
+ feeCenter.setGenerationCorpEnName(foreignAgency.getBookingAgentEnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("corpCnNameNew", feeCenter.getCorpCnName());
|
|
|
+ mapList.add(map);
|
|
|
+ }
|
|
|
+ } else if ("船公司".contains(feeCenter.getCorpType())) {
|
|
|
+ if (!feeCenter.getCorpId().equals(bills.getCarrierId())) {
|
|
|
+ feeCenter.setCorpId(bills.getCarrierId());
|
|
|
+ feeCenter.setCorpCnName(bills.getCarrierCnName());
|
|
|
+ feeCenter.setCorpEnName(bills.getCarrierEnName());
|
|
|
+ feeCenter.setShortName(bills.getCarrierShortName());
|
|
|
+ if (!corpsList.isEmpty()) {
|
|
|
+ BCorps carrier = corpsList.stream().filter(e -> e.getId().equals(bills.getCarrierId())).findFirst().orElse(null);
|
|
|
+ if (carrier != null) {
|
|
|
+ feeCenter.setGenerationCorpId(carrier.getBookingAgentId());
|
|
|
+ feeCenter.setGenerationCorpCnName(carrier.getBookingAgentCnName());
|
|
|
+ feeCenter.setGenerationCorpEnName(carrier.getBookingAgentEnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("corpCnNameNew", feeCenter.getCorpCnName());
|
|
|
+ mapList.add(map);
|
|
|
+ }
|
|
|
+ } else if ("场站".contains(feeCenter.getCorpType())) {
|
|
|
+ if (!feeCenter.getCorpId().equals(bills.getCyId())) {
|
|
|
+ feeCenter.setCorpId(bills.getCyId());
|
|
|
+ feeCenter.setCorpCnName(bills.getCyCnName());
|
|
|
+ feeCenter.setCorpEnName(bills.getCyEnName());
|
|
|
+ feeCenter.setShortName(bills.getCyCnName());
|
|
|
+ BCorps bCorps = null;
|
|
|
+ if (!corpsList.isEmpty()) {
|
|
|
+ bCorps = corpsList.stream().filter(e -> e.getId().equals(bills.getCyId())).findFirst().orElse(null);
|
|
|
+ }
|
|
|
+ if (bCorps != null) {
|
|
|
+ feeCenter.setGenerationCorpId(bCorps.getBookingAgentId());
|
|
|
+ feeCenter.setGenerationCorpCnName(bCorps.getBookingAgentCnName());
|
|
|
+ feeCenter.setGenerationCorpEnName(bCorps.getBookingAgentEnName());
|
|
|
+ }
|
|
|
+ map.put("corpCnNameNew", feeCenter.getCorpCnName());
|
|
|
+ mapList.add(map);
|
|
|
+ }
|
|
|
+ } else if ("船代".contains(feeCenter.getCorpType())) {
|
|
|
+ if (!feeCenter.getCorpId().equals(bills.getCyId())) {
|
|
|
+ feeCenter.setCorpId(bills.getShippingAgencyId());
|
|
|
+ feeCenter.setCorpCnName(bills.getShippingAgencyCname());
|
|
|
+ feeCenter.setCorpEnName(bills.getShippingAgencyEname());
|
|
|
+ feeCenter.setShortName(bills.getShippingAgencyCname());
|
|
|
+ if (!corpsList.isEmpty()) {
|
|
|
+ BCorps shippingAgency = corpsList.stream().filter(e -> e.getId().equals(bills.getShippingAgencyId())).findFirst().orElse(null);
|
|
|
+ if (shippingAgency != null) {
|
|
|
+ feeCenter.setGenerationCorpId(shippingAgency.getBookingAgentId());
|
|
|
+ feeCenter.setGenerationCorpCnName(shippingAgency.getBookingAgentCnName());
|
|
|
+ feeCenter.setGenerationCorpEnName(shippingAgency.getBookingAgentEnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("corpCnNameNew", feeCenter.getCorpCnName());
|
|
|
+ mapList.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(mapList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R synchronizationSettlementObject(Long billId, String dc) {
|
|
|
+ if (ObjectUtils.isNull(billId) || ObjectUtils.isNull(dc)) {
|
|
|
+ throw new RuntimeException("缺少必要参数");
|
|
|
+ }
|
|
|
+ List<FeeCenter> feeCenters = new ArrayList<>();
|
|
|
+ Bills bills = billsMapper.selectById(billId);
|
|
|
+ if (bills == null) {
|
|
|
+ throw new RuntimeException("未查到单据明细");
|
|
|
+ }
|
|
|
+ List<Long> idList = new ArrayList<>();
|
|
|
+ idList.add(bills.getCorpId());
|
|
|
+ idList.add(bills.getCyId());
|
|
|
+ idList.add(bills.getCarrierId());
|
|
|
+ idList.add(bills.getBookingAgentId());
|
|
|
+ idList.add(bills.getMconsigneeId());
|
|
|
+ idList.add(bills.getMnotifyId());
|
|
|
+ idList.add(bills.getForeignAgencyId());
|
|
|
+ idList.add(bills.getShippingAgencyId());
|
|
|
+ List<BCorps> corpsList = corpsMapper.selectList(new LambdaQueryWrapper<BCorps>()
|
|
|
+ .eq(BCorps::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BCorps::getIsDeleted, 0)
|
|
|
+ .in(BCorps::getId, idList));
|
|
|
+ List<FeeCenter> feeCenterList = baseMapper.selectList(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0)
|
|
|
+ .eq(FeeCenter::getPid, billId)
|
|
|
+ .eq(FeeCenter::getDc, dc)
|
|
|
+ .isNotNull(FeeCenter::getCorpType));
|
|
|
+ if (feeCenterList.isEmpty()) {
|
|
|
+ throw new RuntimeException("未查到可同步数据");
|
|
|
+ }
|
|
|
+ for (FeeCenter feeCenter : feeCenterList) {
|
|
|
+ if ("国内直接客户,国外直接客户,国内同行及代理".contains(feeCenter.getCorpType())) {
|
|
|
+ if (!feeCenter.getCorpId().equals(bills.getCorpId())) {
|
|
|
+ feeCenter.setCorpId(bills.getCorpId());
|
|
|
+ feeCenter.setCorpCnName(bills.getCorpCnName());
|
|
|
+ feeCenter.setCorpEnName(bills.getCorpEnName());
|
|
|
+ feeCenter.setShortName(bills.getShortName());
|
|
|
+ BCorps bCorps = null;
|
|
|
+ if (!corpsList.isEmpty()) {
|
|
|
+ bCorps = corpsList.stream().filter(e -> e.getId().equals(bills.getCorpId())).findFirst().orElse(null);
|
|
|
+ }
|
|
|
+ if (bCorps != null) {
|
|
|
+ feeCenter.setGenerationCorpId(bCorps.getBookingAgentId());
|
|
|
+ feeCenter.setGenerationCorpCnName(bCorps.getBookingAgentCnName());
|
|
|
+ feeCenter.setGenerationCorpEnName(bCorps.getBookingAgentEnName());
|
|
|
+ }
|
|
|
+ feeCenters.add(feeCenter);
|
|
|
+ }
|
|
|
+ } else if ("国外同行及代理".contains(feeCenter.getCorpType())) {
|
|
|
+ if (!feeCenter.getCorpId().equals(bills.getForeignAgencyId())) {
|
|
|
+ feeCenter.setCorpId(bills.getForeignAgencyId());
|
|
|
+ feeCenter.setCorpCnName(bills.getForeignAgencyCnName());
|
|
|
+ feeCenter.setCorpEnName(bills.getForeignAgencyEnName());
|
|
|
+ feeCenter.setShortName(bills.getForeignAgencyCnName());
|
|
|
+ if (!corpsList.isEmpty()) {
|
|
|
+ BCorps foreignAgency = corpsList.stream().filter(e -> e.getId().equals(bills.getForeignAgencyId())).findFirst().orElse(null);
|
|
|
+ if (foreignAgency != null) {
|
|
|
+ feeCenter.setGenerationCorpId(foreignAgency.getBookingAgentId());
|
|
|
+ feeCenter.setGenerationCorpCnName(foreignAgency.getBookingAgentCnName());
|
|
|
+ feeCenter.setGenerationCorpEnName(foreignAgency.getBookingAgentEnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ feeCenters.add(feeCenter);
|
|
|
+ }
|
|
|
+ } else if ("船公司".contains(feeCenter.getCorpType())) {
|
|
|
+ if (!feeCenter.getCorpId().equals(bills.getCarrierId())) {
|
|
|
+ feeCenter.setCorpId(bills.getCarrierId());
|
|
|
+ feeCenter.setCorpCnName(bills.getCarrierCnName());
|
|
|
+ feeCenter.setCorpEnName(bills.getCarrierEnName());
|
|
|
+ feeCenter.setShortName(bills.getCarrierShortName());
|
|
|
+ if (!corpsList.isEmpty()) {
|
|
|
+ BCorps carrier = corpsList.stream().filter(e -> e.getId().equals(bills.getCarrierId())).findFirst().orElse(null);
|
|
|
+ if (carrier != null) {
|
|
|
+ feeCenter.setGenerationCorpId(carrier.getBookingAgentId());
|
|
|
+ feeCenter.setGenerationCorpCnName(carrier.getBookingAgentCnName());
|
|
|
+ feeCenter.setGenerationCorpEnName(carrier.getBookingAgentEnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ feeCenters.add(feeCenter);
|
|
|
+ }
|
|
|
+ } else if ("场站".contains(feeCenter.getCorpType())) {
|
|
|
+ if (!feeCenter.getCorpId().equals(bills.getCyId())) {
|
|
|
+ feeCenter.setCorpId(bills.getCyId());
|
|
|
+ feeCenter.setCorpCnName(bills.getCyCnName());
|
|
|
+ feeCenter.setCorpEnName(bills.getCyEnName());
|
|
|
+ feeCenter.setShortName(bills.getCyCnName());
|
|
|
+ BCorps bCorps = null;
|
|
|
+ if (!corpsList.isEmpty()) {
|
|
|
+ bCorps = corpsList.stream().filter(e -> e.getId().equals(bills.getCyId())).findFirst().orElse(null);
|
|
|
+ }
|
|
|
+ if (bCorps != null) {
|
|
|
+ feeCenter.setGenerationCorpId(bCorps.getBookingAgentId());
|
|
|
+ feeCenter.setGenerationCorpCnName(bCorps.getBookingAgentCnName());
|
|
|
+ feeCenter.setGenerationCorpEnName(bCorps.getBookingAgentEnName());
|
|
|
+ }
|
|
|
+ feeCenters.add(feeCenter);
|
|
|
+ }
|
|
|
+ } else if ("船代".contains(feeCenter.getCorpType())) {
|
|
|
+ if (!feeCenter.getCorpId().equals(bills.getCyId())) {
|
|
|
+ feeCenter.setCorpId(bills.getShippingAgencyId());
|
|
|
+ feeCenter.setCorpCnName(bills.getShippingAgencyCname());
|
|
|
+ feeCenter.setCorpEnName(bills.getShippingAgencyEname());
|
|
|
+ feeCenter.setShortName(bills.getShippingAgencyCname());
|
|
|
+ if (!corpsList.isEmpty()) {
|
|
|
+ BCorps shippingAgency = corpsList.stream().filter(e -> e.getId().equals(bills.getShippingAgencyId())).findFirst().orElse(null);
|
|
|
+ if (shippingAgency != null) {
|
|
|
+ feeCenter.setGenerationCorpId(shippingAgency.getBookingAgentId());
|
|
|
+ feeCenter.setGenerationCorpCnName(shippingAgency.getBookingAgentCnName());
|
|
|
+ feeCenter.setGenerationCorpEnName(shippingAgency.getBookingAgentEnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ feeCenters.add(feeCenter);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!feeCenters.isEmpty()) {
|
|
|
+ this.updateBatchById(feeCenters);
|
|
|
+ }
|
|
|
+ return R.data(feeCenters);
|
|
|
+ }
|
|
|
+
|
|
|
private FeeCenter addFeeCenterQuotation(Bills bills, String dc, int count, BFees fees, String corpType,
|
|
|
PreContainers items, List<BCurExrate> curExrateList,
|
|
|
MktSlotQuotation mktSlotQuotations, String exrateType, String type) {
|