|
|
@@ -631,6 +631,12 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
BigDecimal grossWeight = new BigDecimal("0.00");
|
|
|
BigDecimal measurement = new BigDecimal("0.00");
|
|
|
if (ObjectUtils.isNotNull(bills.getContainersList())) {
|
|
|
+ List<Long> idList = bills.getContainersList().stream().map(Containers::getId).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ List<Containers> containersList = new ArrayList<>();
|
|
|
+ if (!idList.isEmpty()) {
|
|
|
+ containersList = containersService.list(new LambdaQueryWrapper<Containers>()
|
|
|
+ .in(Containers::getId, idList));
|
|
|
+ }
|
|
|
for (Containers item : bills.getContainersList()) {
|
|
|
if (ObjectUtils.isNotNull(item.getQuantity())) {
|
|
|
quantity = quantity.add(item.getQuantity());
|
|
|
@@ -665,7 +671,19 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
item.setCreateDeptName(deptName);
|
|
|
}
|
|
|
+ int version = StringUtil.isBlank(item.getVersion()) ? 1 : Integer.parseInt(item.getVersion());
|
|
|
+ item.setVersion(String.valueOf(version + 1));
|
|
|
} else {
|
|
|
+ if (!containersList.isEmpty()) {
|
|
|
+ Containers containers = containersList.stream().filter(e -> e.getId().equals(item.getId())).findFirst().orElse(null);
|
|
|
+ if (containers != null) {
|
|
|
+ if (!Objects.equals(containers.getVersion(), item.getVersion())) {
|
|
|
+ throw new RuntimeException("数据已被其他用户更新,请刷新后重试");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int version = StringUtil.isBlank(item.getVersion()) ? 1 : Integer.parseInt(item.getVersion());
|
|
|
+ item.setVersion(String.valueOf(version + 1));
|
|
|
item.setUpdateUser(AuthUtil.getUserId());
|
|
|
item.setUpdateTime(new Date());
|
|
|
item.setUpdateUserName(AuthUtil.getUserName());
|
|
|
@@ -1757,6 +1775,24 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
if (!preContainersList.isEmpty()){
|
|
|
throw new RuntimeException("已占用放箱号,请先撤销后再退舱");
|
|
|
}
|
|
|
+ List<Long> idList = billsList.stream().map(Bills::getTemporaryId).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ if (!idList.isEmpty()){
|
|
|
+ List<Bills> bills = baseMapper.selectList(new LambdaQueryWrapper<Bills>()
|
|
|
+ .eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Bills::getIsDeleted, 0)
|
|
|
+ .in(Bills::getId, idList));
|
|
|
+ if (!bills.isEmpty()){
|
|
|
+ for (Bills item : bills){
|
|
|
+ item.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ item.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ item.setUpdateTime(new Date());
|
|
|
+ item.setBillStatus(1);
|
|
|
+ int version = StringUtil.isBlank(item.getVersion()) ? 1 : Integer.parseInt(item.getVersion());
|
|
|
+ item.setVersion(String.valueOf(version + 1));
|
|
|
+ }
|
|
|
+ this.updateBatchById(bills);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
for (Bills item : billsList) {
|
|
|
int version = StringUtil.isBlank(item.getVersion()) ? 1 : Integer.parseInt(item.getVersion());
|
|
|
@@ -6084,6 +6120,14 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
.eq(Bills::getIsDeleted, 0)
|
|
|
.eq(Bills::getTemporaryId, bills.getId()));
|
|
|
if (detail != null) {
|
|
|
+ List<PreContainers> preContainersList = preContainersService.list(new LambdaQueryWrapper<PreContainers>()
|
|
|
+ .eq(PreContainers::getIsDeleted,0)
|
|
|
+ .eq(PreContainers::getContainerNumberStatus,"已选择")
|
|
|
+ .eq(PreContainers::getTenantId,AuthUtil.getTenantId())
|
|
|
+ .eq(PreContainers::getPid,detail.getId()));
|
|
|
+ if (!preContainersList.isEmpty()){
|
|
|
+ throw new RuntimeException("海运出口已占用放箱号,请先联系客服撤销放箱号");
|
|
|
+ }
|
|
|
detail.setUpdateUserName(AuthUtil.getUserName());
|
|
|
detail.setUpdateUser(AuthUtil.getUserId());
|
|
|
detail.setUpdateTime(new Date());
|
|
|
@@ -6529,217 +6573,6 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public R sendVerificationPrompt(String ids) {
|
|
|
- if (ObjectUtils.isNull(ids)) {
|
|
|
- throw new RuntimeException("缺少必要参数,发送失败!");
|
|
|
- }
|
|
|
- Bills bills = baseMapper.selectById(ids);
|
|
|
- if (bills == null) {
|
|
|
- throw new RuntimeException("未查到海运出口单据,发送失败!");
|
|
|
- }
|
|
|
- StringBuilder text = new StringBuilder();
|
|
|
- StringBuilder messageBody = new StringBuilder();
|
|
|
- if ("SOC".equals(bills.getBoxBelongsTo()) && "DD,MH".contains(bills.getBillType())) {
|
|
|
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- List<RouteCost> costList = routeCostService.list(new LambdaQueryWrapper<RouteCost>()
|
|
|
- .eq(RouteCost::getPodId, bills.getPolId())
|
|
|
- .eq(RouteCost::getDestinationId, bills.getPodId())
|
|
|
- .eq(RouteCost::getShippingCompanyId, bills.getCarrierId())
|
|
|
- .eq(RouteCost::getBusinessType, bills.getBoxBelongsTo())
|
|
|
- .apply("DATE_FORMAT(effective_start_date,'%Y-%m-%d') <= '" + formatter.format(bills.getEtd()) + "'")
|
|
|
- .apply("DATE_FORMAT(effective_end_date,'%Y-%m-%d') >= '" + formatter.format(bills.getEtd()) + "'")
|
|
|
- );
|
|
|
- if (costList.isEmpty()) {
|
|
|
- throw new RuntimeException("请先维护成本!");
|
|
|
- }
|
|
|
- List<RouteCostItem> costItemList = routeCostItemService.list(new LambdaQueryWrapper<RouteCostItem>()
|
|
|
- .eq(RouteCostItem::getIsDeleted, 0)
|
|
|
- .eq(RouteCostItem::getTenantId, AuthUtil.getTenantId())
|
|
|
- .in(RouteCostItem::getPid, costList.stream().map(RouteCost::getId).collect(Collectors.toList())));
|
|
|
- if (costItemList.isEmpty()) {
|
|
|
- throw new RuntimeException("请先维护成本!");
|
|
|
- }
|
|
|
- List<PreContainers> preContainersList = preContainersService.list(new LambdaQueryWrapper<PreContainers>()
|
|
|
- .eq(PreContainers::getIsDeleted, 0)
|
|
|
- .eq(PreContainers::getPid, ids));
|
|
|
- if (preContainersList.isEmpty()) {
|
|
|
- throw new RuntimeException("未查到预配箱型信息,发送失败!");
|
|
|
- }
|
|
|
- List<SeaContainerNumberItem> containerNumberItemList = seaContainerNumberItemService.list(new LambdaQueryWrapper<SeaContainerNumberItem>()
|
|
|
- .eq(SeaContainerNumberItem::getIsDeleted, 0)
|
|
|
- .eq(SeaContainerNumberItem::getPid, ids)
|
|
|
- .in(SeaContainerNumberItem::getBoxType, preContainersList.stream().map(PreContainers::getCntrTypeCode)
|
|
|
- .distinct().collect(Collectors.toList())));
|
|
|
- if (containerNumberItemList.isEmpty()) {
|
|
|
- throw new RuntimeException("未选择放箱号,发送失败!");
|
|
|
- }
|
|
|
- List<FeeCenter> feeCenterList = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
- .eq(FeeCenter::getIsDeleted, 0)
|
|
|
- .eq(FeeCenter::getDc, "D")
|
|
|
- .eq(FeeCenter::getFeeCode, "HYF")
|
|
|
- .eq(FeeCenter::getPid, ids));
|
|
|
- if (feeCenterList.isEmpty()) {
|
|
|
- throw new RuntimeException("未查到应收海运费,发送失败!");
|
|
|
- }
|
|
|
- String boxBusinessConnectionTime = sysClient.getParamService("box.business.connection.time");
|
|
|
- Date date = null;
|
|
|
- DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- if (ObjectUtils.isNotNull(boxBusinessConnectionTime)) {
|
|
|
- try {
|
|
|
- date = dateFormat.parse(boxBusinessConnectionTime);
|
|
|
- } catch (ParseException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- }
|
|
|
- }
|
|
|
- boolean status = bills.getEtd().compareTo(date) >= 0;
|
|
|
- if (status) {
|
|
|
- for (PreContainers containers : preContainersList) {
|
|
|
- BigDecimal price = feeCenterList.stream().filter(e -> containers.getCntrTypeCode().equals(e.getUnitNo()))
|
|
|
- .map(FeeCenter::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- List<RouteCostItem> minCostItem = costItemList.stream().filter(e -> containers.getCntrTypeCode().equals(e.getBoxType()))
|
|
|
- .sorted(Comparator.comparing(RouteCostItem::getSalesPrice))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (price.compareTo(minCostItem.get(0).getSalesPrice()) < 0) {
|
|
|
- text.append("提单号:").append(bills.getMblno()).append("箱型:").append(containers.getCntrTypeCode()).append("应收海运费:" + price + "小于成本中心海运费:" + minCostItem.get(0).getSalesPrice() + "!");
|
|
|
- messageBody.append("提单号:").append(bills.getMblno()).append("应收海运费:" + price + "小于成本中心海运费:" + minCostItem.get(0).getSalesPrice() + "!");
|
|
|
- }
|
|
|
- if (containerNumberItemList.stream().filter(e -> e.getBoxType().equals(containers.getCntrTypeCode()))
|
|
|
- .mapToInt(SeaContainerNumberItem::getOccupyNum).sum() != containers.getQuantity()) {
|
|
|
- text.append("提单号:").append(bills.getMblno()).append("箱型:").append(containers.getCntrTypeCode()).append("箱量与所选放箱号数量不等!");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (ObjectUtils.isNotNull(text.toString())) {
|
|
|
- String url = "/iosBasicData/OceanFreightImport/bills/index";
|
|
|
- String pageLabel = "海运出口";
|
|
|
- String pageStatus = "this.$store.getters.domSaleStatus";
|
|
|
- messageBody.append("发送人:").append(AuthUtil.getUserName());
|
|
|
- billUtils.sendMessage(bills, url, pageLabel, pageStatus, messageBody.toString(), "2", bills.getOperatorId(), "成本中心");
|
|
|
-// return R.success(text.toString());
|
|
|
- throw new RuntimeException(text.toString());
|
|
|
- } else {
|
|
|
- return R.success("操作成功");
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public R sendDeliveryPaper(String ids) {
|
|
|
- if (ObjectUtils.isNull(ids)) {
|
|
|
- throw new RuntimeException("缺少必要参数");
|
|
|
- }
|
|
|
- List<Long> idList = Func.toLongList(ids);
|
|
|
- List<Bills> billsList = baseMapper.selectList(new LambdaQueryWrapper<Bills>()
|
|
|
- .eq(Bills::getIsDeleted, 0)
|
|
|
- .in(Bills::getId, idList));
|
|
|
- if (billsList.isEmpty()) {
|
|
|
- throw new RuntimeException("未查到海运出口单据,发送失败!");
|
|
|
- }
|
|
|
- List<PreContainers> preContainersList = preContainersService.list(new LambdaQueryWrapper<PreContainers>()
|
|
|
- .eq(PreContainers::getIsDeleted, 0)
|
|
|
- .in(PreContainers::getPid, idList));
|
|
|
- if (preContainersList.isEmpty()) {
|
|
|
- throw new RuntimeException("未查到预配箱型信息,发送失败!");
|
|
|
- }
|
|
|
- List<SeaContainerNumberItem> containerNumberItemList = seaContainerNumberItemService.list(new LambdaQueryWrapper<SeaContainerNumberItem>()
|
|
|
- .eq(SeaContainerNumberItem::getIsDeleted, 0)
|
|
|
- .in(SeaContainerNumberItem::getPid, idList)
|
|
|
- .in(SeaContainerNumberItem::getBoxType, preContainersList.stream().map(PreContainers::getCntrTypeCode)
|
|
|
- .distinct().collect(Collectors.toList())));
|
|
|
- if (containerNumberItemList.isEmpty()) {
|
|
|
- throw new RuntimeException("未选择放箱号,发送失败!");
|
|
|
- }
|
|
|
- List<DeliveryPaperExcel> excelList = new ArrayList<>();
|
|
|
- for (Bills item : billsList) {
|
|
|
- DeliveryPaperExcel excel = new DeliveryPaperExcel();
|
|
|
- excel.setEtd(item.getEtd());
|
|
|
- excel.setPodEnName(item.getPodEnName());
|
|
|
- excel.setVesselCnName(item.getVesselEnName());
|
|
|
- excel.setVoyageNo(item.getVoyageNo());
|
|
|
- excel.setBoxOwner("WFL");
|
|
|
- excel.setInboundContainerOwner(item.getCarrierEnName());
|
|
|
- excel.setPotEnName(item.getPotEnName());
|
|
|
- excel.setMblno(item.getMblno());
|
|
|
- excel.setHblno(item.getHblno());
|
|
|
- excel.setQuantityCntrDescr(item.getQuantityCntrDescr());
|
|
|
- excel.setGrossWeight(item.getGrossWeight());
|
|
|
- String containerNumber = "";
|
|
|
- List<PreContainers> preContainers = preContainersList.stream().filter(e -> e.getPid().equals(item.getId()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- for (PreContainers containers : preContainers) {
|
|
|
- List<SeaContainerNumberItem> containerNumberItems = containerNumberItemList.stream().filter(e ->
|
|
|
- containers.getCntrTypeCode().equals(e.getBoxType()) && 0 != e.getOccupyNum()).collect(Collectors.toList());
|
|
|
- for (SeaContainerNumberItem numberItem : containerNumberItems) {
|
|
|
- containerNumber = containerNumber + numberItem.getContainerNumber() + " " + numberItem.getOccupyNum() + "*" +
|
|
|
- containers.getCntrTypeCode() + "\n";
|
|
|
- }
|
|
|
- }
|
|
|
- excel.setContainerNumber(containerNumber);
|
|
|
- excelList.add(excel);
|
|
|
- }
|
|
|
- return R.data(excelList);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<DeliveryPaperExcel> sendDeliveryPaperExport(String ids) {
|
|
|
- if (ObjectUtils.isNull(ids)) {
|
|
|
- throw new RuntimeException("缺少必要参数");
|
|
|
- }
|
|
|
- List<Long> idList = Func.toLongList(ids);
|
|
|
- List<Bills> billsList = baseMapper.selectList(new LambdaQueryWrapper<Bills>()
|
|
|
- .eq(Bills::getIsDeleted, 0)
|
|
|
- .in(Bills::getId, idList));
|
|
|
- if (billsList.isEmpty()) {
|
|
|
- throw new RuntimeException("未查到海运出口单据,发送失败!");
|
|
|
- }
|
|
|
- List<PreContainers> preContainersList = preContainersService.list(new LambdaQueryWrapper<PreContainers>()
|
|
|
- .eq(PreContainers::getIsDeleted, 0)
|
|
|
- .in(PreContainers::getPid, idList));
|
|
|
- if (preContainersList.isEmpty()) {
|
|
|
- throw new RuntimeException("未查到预配箱型信息,发送失败!");
|
|
|
- }
|
|
|
- List<SeaContainerNumberItem> containerNumberItemList = seaContainerNumberItemService.list(new LambdaQueryWrapper<SeaContainerNumberItem>()
|
|
|
- .eq(SeaContainerNumberItem::getIsDeleted, 0)
|
|
|
- .in(SeaContainerNumberItem::getPid, idList)
|
|
|
- .in(SeaContainerNumberItem::getBoxType, preContainersList.stream().map(PreContainers::getCntrTypeCode)
|
|
|
- .distinct().collect(Collectors.toList())));
|
|
|
- if (containerNumberItemList.isEmpty()) {
|
|
|
- throw new RuntimeException("未选择放箱号,发送失败!");
|
|
|
- }
|
|
|
- List<DeliveryPaperExcel> excelList = new ArrayList<>();
|
|
|
- for (Bills item : billsList) {
|
|
|
- DeliveryPaperExcel excel = new DeliveryPaperExcel();
|
|
|
- excel.setEtd(item.getEtd());
|
|
|
- excel.setPodEnName(item.getPodEnName());
|
|
|
- excel.setVesselCnName(item.getVesselEnName());
|
|
|
- excel.setVoyageNo(item.getVoyageNo());
|
|
|
- excel.setBoxOwner("WFL");
|
|
|
- excel.setInboundContainerOwner(item.getCarrierEnName());
|
|
|
- excel.setPotEnName(item.getPotEnName());
|
|
|
- excel.setMblno(item.getMblno());
|
|
|
- excel.setHblno(item.getHblno());
|
|
|
- excel.setQuantityCntrDescr(item.getQuantityCntrDescr());
|
|
|
- excel.setGrossWeight(item.getGrossWeight());
|
|
|
- String containerNumber = "";
|
|
|
- List<PreContainers> preContainers = preContainersList.stream().filter(e -> e.getPid().equals(item.getId()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- for (PreContainers containers : preContainers) {
|
|
|
- List<SeaContainerNumberItem> containerNumberItems = containerNumberItemList.stream().filter(e ->
|
|
|
- containers.getCntrTypeCode().equals(e.getBoxType()) && 0 != e.getOccupyNum()).collect(Collectors.toList());
|
|
|
- for (SeaContainerNumberItem numberItem : containerNumberItems) {
|
|
|
- containerNumber = containerNumber + numberItem.getContainerNumber() + " " + numberItem.getOccupyNum() + "*" +
|
|
|
- containers.getCntrTypeCode() + "\n";
|
|
|
- }
|
|
|
- }
|
|
|
- excel.setContainerNumber(containerNumber);
|
|
|
- excelList.add(excel);
|
|
|
- }
|
|
|
- return excelList;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
public R synchronizeCustoms(Bills bills) {
|
|
|
|
|
|
if (bills.getId() == null) {
|