|
|
@@ -24,6 +24,9 @@ import lombok.AllArgsConstructor;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.los.Util.CurrencyUtils;
|
|
|
+import org.springblade.los.Util.RegularUtils;
|
|
|
+import org.springblade.los.basic.cntr.entity.BCntrTypes;
|
|
|
+import org.springblade.los.basic.cntr.service.IBCntrTypesService;
|
|
|
import org.springblade.los.basic.cur.entity.BCurExrate;
|
|
|
import org.springblade.los.basic.fees.entity.FeesTemplateSonItems;
|
|
|
import org.springblade.los.basic.fees.entity.LosBFeesTemplate;
|
|
|
@@ -32,14 +35,15 @@ import org.springblade.los.basic.fees.service.ILosBFeesTemplateService;
|
|
|
import org.springblade.los.box.entity.PutBox;
|
|
|
import org.springblade.los.box.service.IPutBoxService;
|
|
|
import org.springblade.los.business.sea.entity.Bills;
|
|
|
+import org.springblade.los.business.sea.entity.Containers;
|
|
|
import org.springblade.los.business.sea.entity.PreContainers;
|
|
|
import org.springblade.los.business.sea.entity.SeaContainerNumberItem;
|
|
|
import org.springblade.los.business.sea.mapper.BillsMapper;
|
|
|
import org.springblade.los.business.sea.mapper.SeaContainerNumberItemMapper;
|
|
|
+import org.springblade.los.business.sea.service.IContainersService;
|
|
|
import org.springblade.los.business.sea.service.IPreContainersService;
|
|
|
import org.springblade.los.business.sea.service.ISeaContainerNumberItemService;
|
|
|
import org.springblade.los.business.sea.vo.SeaContainerNumberItemVO;
|
|
|
-import org.springblade.los.excel.UpdatePodStationExcel;
|
|
|
import org.springblade.los.finance.fee.entity.FeeCenter;
|
|
|
import org.springblade.los.finance.fee.service.IFeeCenterService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -65,6 +69,10 @@ public class SeaContainerNumberItemServiceImpl extends ServiceImpl<SeaContainerN
|
|
|
|
|
|
private final IPreContainersService preContainersService;
|
|
|
|
|
|
+ private final IContainersService containersService;
|
|
|
+
|
|
|
+ private final IBCntrTypesService bCntrTypesService;
|
|
|
+
|
|
|
private final BillsMapper billsMapper;
|
|
|
|
|
|
private final ILosBFeesTemplateService losBFeesTemplateService;
|
|
|
@@ -108,9 +116,9 @@ public class SeaContainerNumberItemServiceImpl extends ServiceImpl<SeaContainerN
|
|
|
throw new RuntimeException("数据错误,请联系管理员");
|
|
|
}
|
|
|
item.setOccupyNum(item.getOccupyNum() + containerNumberItem.getOccupyNum());
|
|
|
- item.setRemainingNum(item.getTotalNum() - item.getOccupyNum());
|
|
|
+ item.setRemainingNum(item.getRemainingNum() - item.getOccupyNum());
|
|
|
}
|
|
|
- putBoxService.updateBatchById(putBoxList);
|
|
|
+ putBoxService.updateBatchByIdAndVersion(putBoxList);
|
|
|
PreContainers preContainers = preContainersService.getOne(new LambdaQueryWrapper<PreContainers>()
|
|
|
.eq(PreContainers::getPid, containerNumberItemList.get(0).getPid())
|
|
|
.eq(PreContainers::getCntrTypeCode, containerNumberItemList.get(0).getBoxType()));
|
|
|
@@ -269,10 +277,76 @@ public class SeaContainerNumberItemServiceImpl extends ServiceImpl<SeaContainerN
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ List<Containers> containersList = containersService.list(new LambdaQueryWrapper<Containers>()
|
|
|
+ .eq(Containers::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Containers::getIsDeleted, 0)
|
|
|
+ .eq(Containers::getCntrTypeCode, preContainers.getCntrTypeCode())
|
|
|
+ .eq(Containers::getPid, preContainers.getPid()));
|
|
|
+ List<Containers> containersListNew = new ArrayList<>();
|
|
|
+ if (containersList.isEmpty() || containersList.stream().noneMatch(e -> e.getCntrTypeCode().equals(preContainers.getCntrTypeCode()))) {
|
|
|
+ BCntrTypes bCntrTypes = bCntrTypesService.getOne(new LambdaQueryWrapper<BCntrTypes>()
|
|
|
+ .eq(BCntrTypes::getCnName, preContainers.getCntrTypeCode())
|
|
|
+ .eq(BCntrTypes::getStatus, 0)
|
|
|
+ .eq(BCntrTypes::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BCntrTypes::getIsDeleted, 0)
|
|
|
+ .last("LIMIT 1"));
|
|
|
+ if (bCntrTypes == null) {
|
|
|
+ throw new RuntimeException("未查到对应箱型数据,请先维护箱型信息");
|
|
|
+ }
|
|
|
+ Bills bills = billsMapper.selectById(preContainers.getPid());
|
|
|
+ if (bills == null) {
|
|
|
+ throw new RuntimeException("未找到单据信息");
|
|
|
+ }
|
|
|
+ String ediCode = RegularUtils.getEdiCode(bills.getCyCode(), bCntrTypes.getExtendedData());
|
|
|
+ //生成海运进出口配箱-箱号装箱
|
|
|
+ for (int i = 0; i < preContainers.getQuantity(); i++) {
|
|
|
+ Containers containers = new Containers();
|
|
|
+ containers.setCreateTime(new Date());
|
|
|
+ containers.setCreateUser(AuthUtil.getUserId());
|
|
|
+ containers.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ containers.setCyCntrCode(ediCode);
|
|
|
+ if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
+ containers.setBranchId(preContainers.getBranchId());
|
|
|
+ containers.setCreateDept(preContainers.getCreateDept());
|
|
|
+ containers.setCreateDeptName(preContainers.getCreateDeptName());
|
|
|
+ }
|
|
|
+ containers.setBillNo(bills.getBillNo());
|
|
|
+ containers.setPolId(bills.getPolId());
|
|
|
+ containers.setPolCode(bills.getPolCode());
|
|
|
+ containers.setPolCnName(bills.getPolCnName());
|
|
|
+ containers.setPolEnName(bills.getPolEnName());
|
|
|
+ containers.setPodId(bills.getPodId());
|
|
|
+ containers.setPodCode(bills.getPodCode());
|
|
|
+ containers.setPodCnName(bills.getPodCnName());
|
|
|
+ containers.setPodEnName(bills.getPodEnName());
|
|
|
+ containers.setPodStationId(bills.getPodCyId());
|
|
|
+ containers.setPodStationCode(bills.getPodCyCode());
|
|
|
+ containers.setPodStationCname(bills.getPodCyCnName());
|
|
|
+ containers.setPodStationEname(bills.getPodCyEnName());
|
|
|
+ containers.setMblno(bills.getMblno());
|
|
|
+ containers.setHblno(bills.getHblno());
|
|
|
+ containers.setCommodityDescr(bills.getCommodityDescr());
|
|
|
+ containers.setPackingUnitId(bills.getPackingUnitId());
|
|
|
+ containers.setPackingUnit(bills.getPackingUnit());
|
|
|
+ containers.setPid(preContainers.getPid());
|
|
|
+ containers.setTeu(preContainers.getTeu());
|
|
|
+ containers.setIsSoc(preContainers.getIsSoc());
|
|
|
+ containers.setIsOneway(preContainers.getIsOneway());
|
|
|
+ containers.setCntrTypeCode(preContainers.getCntrTypeCode());
|
|
|
+ containers.setCntrTypeCodeId(preContainers.getCntrTypeCodeId());
|
|
|
+ containers.setLineNo(preContainers.getId());
|
|
|
+ containersListNew.add(containers);
|
|
|
+ }
|
|
|
+ if (!containersListNew.isEmpty()) {
|
|
|
+ containersService.saveOrUpdateBatch(containersListNew);
|
|
|
+ }
|
|
|
+ }
|
|
|
return R.data(containerNumberItemList);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public R revokeSelectedContainerNumber(String boxType, String billId) {
|
|
|
List<SeaContainerNumberItem> containerNumberItemList = baseMapper.selectList(new LambdaQueryWrapper<SeaContainerNumberItem>()
|
|
|
.eq(SeaContainerNumberItem::getTenantId, AuthUtil.getTenantId())
|
|
|
@@ -298,10 +372,13 @@ public class SeaContainerNumberItemServiceImpl extends ServiceImpl<SeaContainerN
|
|
|
if (containerNumberItem == null) {
|
|
|
throw new RuntimeException("数据错误,请联系管理员");
|
|
|
}
|
|
|
+ if (item.getOccupyNum() < containerNumberItem.getOccupyNum()) {
|
|
|
+ throw new RuntimeException("放箱号已出场,撤销失败");
|
|
|
+ }
|
|
|
item.setOccupyNum(item.getOccupyNum() - containerNumberItem.getOccupyNum());
|
|
|
- item.setRemainingNum(item.getTotalNum() - item.getOccupyNum());
|
|
|
+ item.setRemainingNum(item.getRemainingNum() + item.getOccupyNum());
|
|
|
}
|
|
|
- putBoxService.updateBatchById(putBoxList);
|
|
|
+ putBoxService.updateBatchByIdAndVersion(putBoxList);
|
|
|
PreContainers preContainers = preContainersService.getOne(new LambdaQueryWrapper<PreContainers>()
|
|
|
.eq(PreContainers::getPid, billId)
|
|
|
.eq(PreContainers::getCntrTypeCode, boxType));
|
|
|
@@ -332,6 +409,28 @@ public class SeaContainerNumberItemServiceImpl extends ServiceImpl<SeaContainerN
|
|
|
if (!feeIdList.isEmpty()) {
|
|
|
feeCenterService.removeByIds(feeIdList);
|
|
|
}
|
|
|
+ List<Containers> containersList = containersService.list(new LambdaQueryWrapper<Containers>()
|
|
|
+ .eq(Containers::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Containers::getIsDeleted, 0)
|
|
|
+ .eq(Containers::getCntrTypeCode, preContainers.getCntrTypeCode())
|
|
|
+ .eq(Containers::getPid, preContainers.getPid()));
|
|
|
+ if (!containersList.isEmpty()) {
|
|
|
+ List<Containers> containers = containersList.stream().filter(e -> e.getCntrTypeCode().equals(preContainers.getCntrTypeCode()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<Long> containersIdList = new ArrayList<>();
|
|
|
+ for (Containers item : containers){
|
|
|
+ if (new BigDecimal("0.00").compareTo(item.getQuantity()) != 0){
|
|
|
+ throw new RuntimeException("已配箱,请先撤销后再操作!");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(item.getCntrNo())){
|
|
|
+ throw new RuntimeException("存在箱号,请先清空后再操作!");
|
|
|
+ }
|
|
|
+ containersIdList.add(item.getId());
|
|
|
+ }
|
|
|
+ if (!containersIdList.isEmpty()) {
|
|
|
+ containersService.removeByIds(containersIdList);
|
|
|
+ }
|
|
|
+ }
|
|
|
return R.data("操作成功");
|
|
|
}
|
|
|
|