|
|
@@ -31,11 +31,12 @@ import org.springblade.los.basic.cntr.service.IBCntrTypesService;
|
|
|
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.cur.service.IBCurrencyService;
|
|
|
import org.springblade.los.basic.ports.entity.BPorts;
|
|
|
import org.springblade.los.basic.ports.service.IBPortsService;
|
|
|
import org.springblade.los.box.entity.TradingBox;
|
|
|
import org.springblade.los.box.entity.TradingBoxItem;
|
|
|
+import org.springblade.los.box.excel.AgentBoxItemExcel;
|
|
|
+import org.springblade.los.box.excel.RentalBoxItemExcel;
|
|
|
import org.springblade.los.box.excel.TradingBoxItemExcel;
|
|
|
import org.springblade.los.box.mapper.TradingBoxItemMapper;
|
|
|
import org.springblade.los.box.mapper.TradingBoxMapper;
|
|
|
@@ -79,52 +80,158 @@ public class TradingBoxItemServiceImpl extends ServiceImpl<TradingBoxItemMapper,
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public R importBoxItem(MultipartFile file, Long id) {
|
|
|
+ public R importBoxItem(MultipartFile file, Long id, String type) {
|
|
|
if (id == null) {
|
|
|
throw new RuntimeException("缺少必要参数");
|
|
|
}
|
|
|
- //导入数据
|
|
|
- List<TradingBoxItemExcel> excelList = ExcelUtil.read(file, TradingBoxItemExcel.class);
|
|
|
- if (CollectionUtils.isEmpty(excelList)) {
|
|
|
- throw new SecurityException("数据不能为空");
|
|
|
- }
|
|
|
TradingBox tradingBox = tradingBoxMapper.selectById(id);
|
|
|
if (tradingBox == null) {
|
|
|
throw new RuntimeException("未查到单据信息");
|
|
|
}
|
|
|
- //箱号拼接字符串
|
|
|
- List<String> codes = excelList.stream().map(TradingBoxItemExcel::getCode).distinct().collect(Collectors.toList());
|
|
|
- if (excelList.size() != codes.size()) {
|
|
|
- throw new RuntimeException("本单据明细存在重复箱号,操作失败!");
|
|
|
+ Date date;
|
|
|
+ if ("DL,ZR".contains(tradingBox.getType())) {
|
|
|
+ date = tradingBox.getEffectiveDate();
|
|
|
+ } else if ("BUY".contains(tradingBox.getType())) {
|
|
|
+ date = tradingBox.getPurchaseDate();
|
|
|
+ } else {
|
|
|
+ date = new Date();
|
|
|
}
|
|
|
- List<TradingBoxItem> itemList = baseMapper.selectList(new LambdaQueryWrapper<TradingBoxItem>()
|
|
|
- .eq(TradingBoxItem::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(TradingBoxItem::getIsDeleted, 0)
|
|
|
- .eq(TradingBoxItem::getPid, id)
|
|
|
- .in(TradingBoxItem::getCode, codes));
|
|
|
- for (TradingBoxItemExcel item : excelList) {
|
|
|
- if (ObjectUtils.isNull(item.getCode())) {
|
|
|
- throw new RuntimeException("箱号不能为空");
|
|
|
+ String exrateType = currencyUtils.standardCurrency(AuthUtil.getDeptId());
|
|
|
+ List<BCurExrate> curExrateList = currencyUtils.obtainRate(date, "1", AuthUtil.getDeptId());
|
|
|
+ BigDecimal exrateC = currencyUtils.obtainExrate("C", curExrateList, "USD", "1");
|
|
|
+ List<String> codes=new ArrayList<>();
|
|
|
+ List<String> boxType=new ArrayList<>();
|
|
|
+ String portName = "";
|
|
|
+ String stationName = "";
|
|
|
+ String cyCname = "";
|
|
|
+ List<TradingBoxItem> tradingBoxItemList = new ArrayList<>();
|
|
|
+ if ("1".equals(type)) {
|
|
|
+ //导入数据
|
|
|
+ List<TradingBoxItemExcel> excelList = ExcelUtil.read(file, TradingBoxItemExcel.class);
|
|
|
+ if (CollectionUtils.isEmpty(excelList)) {
|
|
|
+ throw new SecurityException("数据不能为空");
|
|
|
+ }
|
|
|
+ //箱号拼接字符串
|
|
|
+ codes = excelList.stream().map(TradingBoxItemExcel::getCode).distinct().collect(Collectors.toList());
|
|
|
+ if (excelList.size() != codes.size()) {
|
|
|
+ throw new RuntimeException("本单据明细存在重复箱号,操作失败!");
|
|
|
+ }
|
|
|
+ for (TradingBoxItemExcel item : excelList) {
|
|
|
+ if (ObjectUtils.isNull(item.getCode())) {
|
|
|
+ throw new RuntimeException("箱号不能为空");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNull(item.getBoxType())) {
|
|
|
+ throw new RuntimeException("箱型不能为空");
|
|
|
+ }
|
|
|
+ item.setBoxType(item.getBoxType().toUpperCase());
|
|
|
+ if (ObjectUtils.isNull(item.getBoxStatus())) {
|
|
|
+ throw new RuntimeException("箱好坏不能为空");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNull(item.getBoxCondition())) {
|
|
|
+ throw new RuntimeException("箱况不能为空");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNull(item.getCurrency())) {
|
|
|
+ throw new RuntimeException("币别不能为空");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNull(item.getAmount())) {
|
|
|
+ throw new RuntimeException("金额不能为空");
|
|
|
+ }
|
|
|
}
|
|
|
- if (ObjectUtils.isNull(item.getBoxType())) {
|
|
|
- throw new RuntimeException("箱型不能为空");
|
|
|
+ boxType = excelList.stream().map(TradingBoxItemExcel::getBoxType).filter(Objects::nonNull)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ portName = excelList.stream().map(TradingBoxItemExcel::getRestrictedPortsName).filter(Objects::nonNull)
|
|
|
+ .distinct().collect(Collectors.joining(","));
|
|
|
+ stationName = excelList.stream().map(TradingBoxItemExcel::getRestrictingShippingCompaniesName).filter(Objects::nonNull)
|
|
|
+ .distinct().collect(Collectors.joining(","));
|
|
|
+ } else if("2".equals(type)) {
|
|
|
+ //导入数据
|
|
|
+ List<RentalBoxItemExcel> excelList = ExcelUtil.read(file, RentalBoxItemExcel.class);
|
|
|
+ if (CollectionUtils.isEmpty(excelList)) {
|
|
|
+ throw new SecurityException("数据不能为空");
|
|
|
}
|
|
|
- item.setBoxType(item.getBoxType().toUpperCase());
|
|
|
- if (ObjectUtils.isNull(item.getBoxStatus())) {
|
|
|
- throw new RuntimeException("箱好坏不能为空");
|
|
|
+ //箱号拼接字符串
|
|
|
+ codes = excelList.stream().map(RentalBoxItemExcel::getCode).distinct().collect(Collectors.toList());
|
|
|
+ if (excelList.size() != codes.size()) {
|
|
|
+ throw new RuntimeException("本单据明细存在重复箱号,操作失败!");
|
|
|
+ }
|
|
|
+ for (RentalBoxItemExcel item : excelList) {
|
|
|
+ if (ObjectUtils.isNull(item.getCode())) {
|
|
|
+ throw new RuntimeException("箱号不能为空");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNull(item.getBoxType())) {
|
|
|
+ throw new RuntimeException("箱型不能为空");
|
|
|
+ }
|
|
|
+ item.setBoxType(item.getBoxType().toUpperCase());
|
|
|
+ if (ObjectUtils.isNull(item.getBoxStatus())) {
|
|
|
+ throw new RuntimeException("箱好坏不能为空");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNull(item.getBoxCondition())) {
|
|
|
+ throw new RuntimeException("箱况不能为空");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNull(item.getCurrency())) {
|
|
|
+ throw new RuntimeException("币别不能为空");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNull(item.getStationCname())) {
|
|
|
+ throw new RuntimeException("场站不能为空");
|
|
|
+ }
|
|
|
}
|
|
|
- if (ObjectUtils.isNull(item.getBoxCondition())) {
|
|
|
- throw new RuntimeException("箱况不能为空");
|
|
|
+ boxType = excelList.stream().map(RentalBoxItemExcel::getBoxType).filter(Objects::nonNull)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ portName = excelList.stream().map(RentalBoxItemExcel::getRestrictedPortsName).filter(Objects::nonNull)
|
|
|
+ .distinct().collect(Collectors.joining(","));
|
|
|
+ stationName = excelList.stream().map(RentalBoxItemExcel::getRestrictingShippingCompaniesName).filter(Objects::nonNull)
|
|
|
+ .distinct().collect(Collectors.joining(","));
|
|
|
+ cyCname = excelList.stream().map(RentalBoxItemExcel::getStationCname).filter(Objects::nonNull)
|
|
|
+ .distinct().collect(Collectors.joining(","));
|
|
|
+ }else if("3".equals(type)) {
|
|
|
+ //导入数据
|
|
|
+ List<AgentBoxItemExcel> excelList = ExcelUtil.read(file, AgentBoxItemExcel.class);
|
|
|
+ if (CollectionUtils.isEmpty(excelList)) {
|
|
|
+ throw new SecurityException("数据不能为空");
|
|
|
}
|
|
|
- if (ObjectUtils.isNull(item.getCurrency())) {
|
|
|
- throw new RuntimeException("币别不能为空");
|
|
|
+ //箱号拼接字符串
|
|
|
+ codes = excelList.stream().map(AgentBoxItemExcel::getCode).distinct().collect(Collectors.toList());
|
|
|
+ if (excelList.size() != codes.size()) {
|
|
|
+ throw new RuntimeException("本单据明细存在重复箱号,操作失败!");
|
|
|
}
|
|
|
- if (ObjectUtils.isNull(item.getAmount())) {
|
|
|
- throw new RuntimeException("金额不能为空");
|
|
|
+ for (AgentBoxItemExcel item : excelList) {
|
|
|
+ if (ObjectUtils.isNull(item.getCode())) {
|
|
|
+ throw new RuntimeException("箱号不能为空");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNull(item.getBoxType())) {
|
|
|
+ throw new RuntimeException("箱型不能为空");
|
|
|
+ }
|
|
|
+ item.setBoxType(item.getBoxType().toUpperCase());
|
|
|
+ if (ObjectUtils.isNull(item.getBoxStatus())) {
|
|
|
+ throw new RuntimeException("箱好坏不能为空");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNull(item.getBoxCondition())) {
|
|
|
+ throw new RuntimeException("箱况不能为空");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNull(item.getCurrency())) {
|
|
|
+ throw new RuntimeException("币别不能为空");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNull(item.getStationCname())) {
|
|
|
+ throw new RuntimeException("场站不能为空");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNull(item.getAmount())) {
|
|
|
+ throw new RuntimeException("金额不能为空");
|
|
|
+ }
|
|
|
}
|
|
|
+ boxType = excelList.stream().map(AgentBoxItemExcel::getBoxType).filter(Objects::nonNull)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ portName = excelList.stream().map(AgentBoxItemExcel::getRestrictedPortsName).filter(Objects::nonNull)
|
|
|
+ .distinct().collect(Collectors.joining(","));
|
|
|
+ stationName = excelList.stream().map(AgentBoxItemExcel::getRestrictingShippingCompaniesName).filter(Objects::nonNull)
|
|
|
+ .distinct().collect(Collectors.joining(","));
|
|
|
+ cyCname = excelList.stream().map(AgentBoxItemExcel::getStationCname).filter(Objects::nonNull)
|
|
|
+ .distinct().collect(Collectors.joining(","));
|
|
|
}
|
|
|
- List<String> boxType = excelList.stream().map(TradingBoxItemExcel::getBoxType).filter(Objects::nonNull)
|
|
|
- .distinct().collect(Collectors.toList());
|
|
|
+ List<TradingBoxItem> itemList = baseMapper.selectList(new LambdaQueryWrapper<TradingBoxItem>()
|
|
|
+ .eq(TradingBoxItem::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(TradingBoxItem::getIsDeleted, 0)
|
|
|
+ .eq(TradingBoxItem::getPid, id)
|
|
|
+ .in(TradingBoxItem::getCode, codes));
|
|
|
List<BCntrTypes> cntrTypesList = bCntrTypesService.list(new LambdaQueryWrapper<BCntrTypes>()
|
|
|
.eq(BCntrTypes::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(BCntrTypes::getIsDeleted, 0)
|
|
|
@@ -132,8 +239,6 @@ public class TradingBoxItemServiceImpl extends ServiceImpl<TradingBoxItemMapper,
|
|
|
if (cntrTypesList.isEmpty()) {
|
|
|
throw new RuntimeException("未查到箱型数据");
|
|
|
}
|
|
|
- String portName = excelList.stream().map(TradingBoxItemExcel::getRestrictedPortsName).filter(Objects::nonNull)
|
|
|
- .distinct().collect(Collectors.joining(","));
|
|
|
List<BPorts> portsList = new ArrayList<>();
|
|
|
if (ObjectUtils.isNotNull(portName)) {
|
|
|
portsList = bPortsService.list(new LambdaQueryWrapper<BPorts>()
|
|
|
@@ -141,129 +246,343 @@ public class TradingBoxItemServiceImpl extends ServiceImpl<TradingBoxItemMapper,
|
|
|
.eq(BPorts::getIsDeleted, 0)
|
|
|
.apply("find_in_set(cn_name,'" + portName + "')"));
|
|
|
}
|
|
|
- String stationName = excelList.stream().map(TradingBoxItemExcel::getRestrictingShippingCompaniesName).filter(Objects::nonNull)
|
|
|
- .distinct().collect(Collectors.joining(","));
|
|
|
if (ObjectUtils.isNotNull(stationName)) {
|
|
|
stationName = stationName + ",WFL";
|
|
|
+ if (ObjectUtils.isNotNull(cyCname)) {
|
|
|
+ stationName = stationName + "," + cyCname;
|
|
|
+ }
|
|
|
} else {
|
|
|
stationName = "WFL";
|
|
|
+ if (ObjectUtils.isNotNull(cyCname)) {
|
|
|
+ stationName = stationName + "," + cyCname;
|
|
|
+ }
|
|
|
}
|
|
|
List<BCorps> corpsList = bCorpsService.list(new LambdaQueryWrapper<BCorps>()
|
|
|
.eq(BCorps::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(BCorps::getIsDeleted, 0)
|
|
|
.apply("find_in_set(cn_name,'" + stationName + "')"));
|
|
|
- Date date;
|
|
|
- if ("DL,ZR".contains(tradingBox.getType())) {
|
|
|
- date = tradingBox.getEffectiveDate();
|
|
|
- } else if ("BUY".contains(tradingBox.getType())) {
|
|
|
- date = tradingBox.getPurchaseDate();
|
|
|
- } else {
|
|
|
- date = new Date();
|
|
|
- }
|
|
|
- String exrateType = currencyUtils.standardCurrency(AuthUtil.getDeptId());
|
|
|
- List<BCurExrate> curExrateList = currencyUtils.obtainRate(date, "1", AuthUtil.getDeptId());
|
|
|
- BigDecimal exrateC = currencyUtils.obtainExrate("C", curExrateList, "USD", "1");
|
|
|
- List<TradingBoxItem> tradingBoxItemList = new ArrayList<>();
|
|
|
- for (TradingBoxItemExcel item : excelList) {
|
|
|
- TradingBoxItem tradingBoxItem;
|
|
|
- if (!itemList.isEmpty()) {
|
|
|
- tradingBoxItem = itemList.stream().filter(e -> e.getCode().equals(item.getCode())).findFirst().orElse(null);
|
|
|
- if (tradingBoxItem == null) {
|
|
|
+ if ("1".equals(type)) {
|
|
|
+ List<TradingBoxItemExcel> excelList = ExcelUtil.read(file, TradingBoxItemExcel.class);
|
|
|
+ for (TradingBoxItemExcel item : excelList) {
|
|
|
+ TradingBoxItem tradingBoxItem;
|
|
|
+ if (!itemList.isEmpty()) {
|
|
|
+ tradingBoxItem = itemList.stream().filter(e -> e.getCode().equals(item.getCode())).findFirst().orElse(null);
|
|
|
+ if (tradingBoxItem == null) {
|
|
|
+ tradingBoxItem = new TradingBoxItem();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
tradingBoxItem = new TradingBoxItem();
|
|
|
}
|
|
|
- } else {
|
|
|
- tradingBoxItem = new TradingBoxItem();
|
|
|
- }
|
|
|
- if (ObjectUtils.isNotNull(item.getCode())) {
|
|
|
- tradingBoxItem.setCode(item.getCode().trim());
|
|
|
- tradingBoxItem.setCode(item.getCode().toUpperCase());
|
|
|
- }
|
|
|
- if (!exrateType.equals(item.getCurrency())) {
|
|
|
- tradingBoxItem.setCurrency(item.getCurrency());
|
|
|
- tradingBoxItem.setExrate(exrateC);
|
|
|
- } else {
|
|
|
- tradingBoxItem.setCurrency(exrateType);
|
|
|
- tradingBoxItem.setExrate(new BigDecimal("1"));
|
|
|
- }
|
|
|
- tradingBoxItem.setAmount(item.getAmount());
|
|
|
- tradingBoxItem.setBoxCondition(item.getBoxCondition());
|
|
|
- tradingBoxItem.setBoxStatus(item.getBoxStatus());
|
|
|
- BCntrTypes bCntrTypes = cntrTypesList.stream().filter(e -> e.getCnName().equals(item.getBoxType())).findFirst().orElse(null);
|
|
|
- if (bCntrTypes == null) {
|
|
|
- throw new RuntimeException("箱型:" + item.getBoxType() + "不存在,请先维护基础资料");
|
|
|
- }
|
|
|
- tradingBoxItem.setBoxType(bCntrTypes.getCnName());
|
|
|
- tradingBoxItem.setBoxTypeId(bCntrTypes.getId());
|
|
|
- if (!portsList.isEmpty() && ObjectUtils.isNotNull(item.getRestrictedPortsName())) {
|
|
|
- String[] arr = item.getRestrictedPortsName().split(",");
|
|
|
- StringBuilder portsIds = new StringBuilder();
|
|
|
- for (String name : arr) {
|
|
|
- BPorts bPorts = portsList.stream().filter(e -> name.equals(e.getCnName())).findFirst().orElse(null);
|
|
|
- if (bPorts == null) {
|
|
|
- throw new RuntimeException("港口:" + name + "不存在,请先维护基础资料");
|
|
|
+ if (ObjectUtils.isNotNull(item.getCode())) {
|
|
|
+ tradingBoxItem.setCode(item.getCode().trim());
|
|
|
+ tradingBoxItem.setCode(item.getCode().toUpperCase());
|
|
|
+ }
|
|
|
+ if (!exrateType.equals(item.getCurrency())) {
|
|
|
+ tradingBoxItem.setCurrency(item.getCurrency());
|
|
|
+ tradingBoxItem.setExrate(exrateC);
|
|
|
+ } else {
|
|
|
+ tradingBoxItem.setCurrency(exrateType);
|
|
|
+ tradingBoxItem.setExrate(new BigDecimal("1"));
|
|
|
+ }
|
|
|
+ tradingBoxItem.setAmount(item.getAmount());
|
|
|
+ tradingBoxItem.setBoxCondition(item.getBoxCondition());
|
|
|
+ tradingBoxItem.setBoxStatus(item.getBoxStatus());
|
|
|
+ BCntrTypes bCntrTypes = cntrTypesList.stream().filter(e -> e.getCnName().equals(item.getBoxType())).findFirst().orElse(null);
|
|
|
+ if (bCntrTypes == null) {
|
|
|
+ throw new RuntimeException("箱型:" + item.getBoxType() + "不存在,请先维护基础资料");
|
|
|
+ }
|
|
|
+ tradingBoxItem.setBoxType(bCntrTypes.getCnName());
|
|
|
+ tradingBoxItem.setBoxTypeId(bCntrTypes.getId());
|
|
|
+ if (!portsList.isEmpty() && ObjectUtils.isNotNull(item.getRestrictedPortsName())) {
|
|
|
+ String[] arr = item.getRestrictedPortsName().split(",");
|
|
|
+ StringBuilder portsIds = new StringBuilder();
|
|
|
+ for (String name : arr) {
|
|
|
+ BPorts bPorts = portsList.stream().filter(e -> name.equals(e.getCnName())).findFirst().orElse(null);
|
|
|
+ if (bPorts == null) {
|
|
|
+ throw new RuntimeException("港口:" + name + "不存在,请先维护基础资料");
|
|
|
+ }
|
|
|
+ portsIds.append(bPorts.getId()).append(",");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(portsIds.toString())) {
|
|
|
+ tradingBoxItem.setRestrictedPortsIds(portsIds.substring(0, portsIds.length() - 1));
|
|
|
+ tradingBoxItem.setRestrictedPortsName(item.getRestrictedPortsName());
|
|
|
}
|
|
|
- portsIds.append(bPorts.getId()).append(",");
|
|
|
}
|
|
|
- if (ObjectUtils.isNotNull(portsIds.toString())) {
|
|
|
- tradingBoxItem.setRestrictedPortsIds(portsIds.substring(0, portsIds.length() - 1));
|
|
|
- tradingBoxItem.setRestrictedPortsName(item.getRestrictedPortsName());
|
|
|
+ if (!corpsList.isEmpty()) {
|
|
|
+ if (ObjectUtils.isNotNull(item.getRestrictingShippingCompaniesName())) {
|
|
|
+ String[] arr = item.getRestrictingShippingCompaniesName().split(",");
|
|
|
+ StringBuilder corpIds = new StringBuilder();
|
|
|
+ for (String name : arr) {
|
|
|
+ BCorps bCorps = corpsList.stream().filter(e -> name.equals(e.getCnName())).findFirst().orElse(null);
|
|
|
+ if (bCorps == null) {
|
|
|
+ throw new RuntimeException("船公司:" + name + "不存在,请先维护基础资料");
|
|
|
+ }
|
|
|
+ corpIds.append(bCorps.getId()).append(",");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(corpIds.toString())) {
|
|
|
+ tradingBoxItem.setRestrictingShippingCompaniesIds(corpIds.substring(0, corpIds.length() - 1));
|
|
|
+ tradingBoxItem.setRestrictingShippingCompaniesName(item.getRestrictingShippingCompaniesName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BCorps bCorps = corpsList.stream().filter(e -> "WFL".equals(e.getCode())).findFirst().orElse(null);
|
|
|
+ if (bCorps == null) {
|
|
|
+ throw new RuntimeException("箱东:WFL不存在,请先维护基础资料");
|
|
|
+ }
|
|
|
+ if ("BUY".equals(tradingBox.getType())) {
|
|
|
+ tradingBoxItem.setBoxEastId(bCorps.getId());
|
|
|
+ tradingBoxItem.setBoxEastName(bCorps.getCnName());
|
|
|
+ tradingBoxItem.setOriginalBoxEastId(tradingBox.getPurchaseCompanyId());
|
|
|
+ tradingBoxItem.setOriginalBoxEastName(tradingBox.getPurchaseCompanyName());
|
|
|
+ } else if ("DL".equals(tradingBox.getType())) {
|
|
|
+ tradingBoxItem.setBoxEastId(tradingBox.getPurchaseCompanyId());
|
|
|
+ tradingBoxItem.setBoxEastName(tradingBox.getPurchaseCompanyName());
|
|
|
+ } else if ("ZR".equals(tradingBox.getType())) {
|
|
|
+ tradingBoxItem.setBoxEastId(bCorps.getId());
|
|
|
+ tradingBoxItem.setBoxEastName(bCorps.getCnName());
|
|
|
+ tradingBoxItem.setOriginalBoxEastId(tradingBox.getPurchaseCompanyId());
|
|
|
+ tradingBoxItem.setOriginalBoxEastName(tradingBox.getPurchaseCompanyName());
|
|
|
+ }
|
|
|
}
|
|
|
+ if ("BUY".equals(tradingBox.getType())) {
|
|
|
+ tradingBoxItem.setBoxCategory("自有箱");
|
|
|
+ } else if ("DL".equals(tradingBox.getType())) {
|
|
|
+ tradingBoxItem.setBoxCategory("代理箱");
|
|
|
+ } else if ("ZR".equals(tradingBox.getType())) {
|
|
|
+ tradingBoxItem.setBoxCategory("自有箱");
|
|
|
+ } else {
|
|
|
+ tradingBoxItem.setBoxCategory("自有箱");
|
|
|
+ }
|
|
|
+ tradingBoxItem.setBoxBelongsTo("SOC");
|
|
|
+ tradingBoxItem.setStatus("待使用");
|
|
|
+ tradingBoxItem.setStationId(tradingBox.getStationId());
|
|
|
+ tradingBoxItem.setStationCname(tradingBox.getStationCname());
|
|
|
+ tradingBoxItem.setStationEname(tradingBox.getStationEname());
|
|
|
+ tradingBoxItem.setStationCode(tradingBox.getStationCode());
|
|
|
+ tradingBoxItem.setCreateUser(AuthUtil.getUserId());
|
|
|
+ tradingBoxItem.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ tradingBoxItem.setCreateTime(new Date());
|
|
|
+ tradingBoxItem.setPid(tradingBox.getId());
|
|
|
+ tradingBoxItemList.add(tradingBoxItem);
|
|
|
}
|
|
|
- if (!corpsList.isEmpty()) {
|
|
|
- if (ObjectUtils.isNotNull(item.getRestrictingShippingCompaniesName())) {
|
|
|
- String[] arr = item.getRestrictingShippingCompaniesName().split(",");
|
|
|
- StringBuilder corpIds = new StringBuilder();
|
|
|
+ } else if("2".equals(type)){
|
|
|
+ //导入数据
|
|
|
+ List<RentalBoxItemExcel> excelList = ExcelUtil.read(file, RentalBoxItemExcel.class);
|
|
|
+ for (RentalBoxItemExcel item : excelList) {
|
|
|
+ TradingBoxItem tradingBoxItem;
|
|
|
+ if (!itemList.isEmpty()) {
|
|
|
+ tradingBoxItem = itemList.stream().filter(e -> e.getCode().equals(item.getCode())).findFirst().orElse(null);
|
|
|
+ if (tradingBoxItem == null) {
|
|
|
+ tradingBoxItem = new TradingBoxItem();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tradingBoxItem = new TradingBoxItem();
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(item.getCode())) {
|
|
|
+ tradingBoxItem.setCode(item.getCode().trim());
|
|
|
+ tradingBoxItem.setCode(item.getCode().toUpperCase());
|
|
|
+ }
|
|
|
+ if (!exrateType.equals(item.getCurrency())) {
|
|
|
+ tradingBoxItem.setCurrency(item.getCurrency());
|
|
|
+ tradingBoxItem.setExrate(exrateC);
|
|
|
+ } else {
|
|
|
+ tradingBoxItem.setCurrency(exrateType);
|
|
|
+ tradingBoxItem.setExrate(new BigDecimal("1"));
|
|
|
+ }
|
|
|
+ tradingBoxItem.setBoxCondition(item.getBoxCondition());
|
|
|
+ tradingBoxItem.setBoxStatus(item.getBoxStatus());
|
|
|
+ BCntrTypes bCntrTypes = cntrTypesList.stream().filter(e -> e.getCnName().equals(item.getBoxType())).findFirst().orElse(null);
|
|
|
+ if (bCntrTypes == null) {
|
|
|
+ throw new RuntimeException("箱型:" + item.getBoxType() + "不存在,请先维护基础资料");
|
|
|
+ }
|
|
|
+ tradingBoxItem.setBoxType(bCntrTypes.getCnName());
|
|
|
+ tradingBoxItem.setBoxTypeId(bCntrTypes.getId());
|
|
|
+ if (!portsList.isEmpty() && ObjectUtils.isNotNull(item.getRestrictedPortsName())) {
|
|
|
+ String[] arr = item.getRestrictedPortsName().split(",");
|
|
|
+ StringBuilder portsIds = new StringBuilder();
|
|
|
for (String name : arr) {
|
|
|
- BCorps bCorps = corpsList.stream().filter(e -> name.equals(e.getCnName())).findFirst().orElse(null);
|
|
|
- if (bCorps == null) {
|
|
|
- throw new RuntimeException("船公司:" + name + "不存在,请先维护基础资料");
|
|
|
+ BPorts bPorts = portsList.stream().filter(e -> name.equals(e.getCnName())).findFirst().orElse(null);
|
|
|
+ if (bPorts == null) {
|
|
|
+ throw new RuntimeException("港口:" + name + "不存在,请先维护基础资料");
|
|
|
}
|
|
|
- corpIds.append(bCorps.getId()).append(",");
|
|
|
+ portsIds.append(bPorts.getId()).append(",");
|
|
|
}
|
|
|
- if (ObjectUtils.isNotNull(corpIds.toString())) {
|
|
|
- tradingBoxItem.setRestrictingShippingCompaniesIds(corpIds.substring(0, corpIds.length() - 1));
|
|
|
- tradingBoxItem.setRestrictingShippingCompaniesName(item.getRestrictingShippingCompaniesName());
|
|
|
+ if (ObjectUtils.isNotNull(portsIds.toString())) {
|
|
|
+ tradingBoxItem.setRestrictedPortsIds(portsIds.substring(0, portsIds.length() - 1));
|
|
|
+ tradingBoxItem.setRestrictedPortsName(item.getRestrictedPortsName());
|
|
|
}
|
|
|
}
|
|
|
- BCorps bCorps = corpsList.stream().filter(e -> "WFL".equals(e.getCode())).findFirst().orElse(null);
|
|
|
- if (bCorps == null) {
|
|
|
- throw new RuntimeException("箱东:WFL不存在,请先维护基础资料");
|
|
|
+ if (!corpsList.isEmpty()) {
|
|
|
+ if (ObjectUtils.isNotNull(item.getStationCname())) {
|
|
|
+ BCorps bCorps = corpsList.stream().filter(e -> item.getStationCname().equals(e.getCnName())).findFirst().orElse(null);
|
|
|
+ if (bCorps == null) {
|
|
|
+ throw new RuntimeException("场站:" + item.getStationCname() + "不存在,请先维护基础资料");
|
|
|
+ }
|
|
|
+ tradingBoxItem.setStationId(bCorps.getId());
|
|
|
+ tradingBoxItem.setStationCname(bCorps.getCnName());
|
|
|
+ tradingBoxItem.setStationCode(bCorps.getCode());
|
|
|
+ tradingBoxItem.setStationEname(bCorps.getEnName());
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(item.getRestrictingShippingCompaniesName())) {
|
|
|
+ String[] arr = item.getRestrictingShippingCompaniesName().split(",");
|
|
|
+ StringBuilder corpIds = new StringBuilder();
|
|
|
+ for (String name : arr) {
|
|
|
+ BCorps bCorps = corpsList.stream().filter(e -> name.equals(e.getCnName())).findFirst().orElse(null);
|
|
|
+ if (bCorps == null) {
|
|
|
+ throw new RuntimeException("船公司:" + name + "不存在,请先维护基础资料");
|
|
|
+ }
|
|
|
+ corpIds.append(bCorps.getId()).append(",");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(corpIds.toString())) {
|
|
|
+ tradingBoxItem.setRestrictingShippingCompaniesIds(corpIds.substring(0, corpIds.length() - 1));
|
|
|
+ tradingBoxItem.setRestrictingShippingCompaniesName(item.getRestrictingShippingCompaniesName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BCorps bCorps = corpsList.stream().filter(e -> "WFL".equals(e.getCode())).findFirst().orElse(null);
|
|
|
+ if (bCorps == null) {
|
|
|
+ throw new RuntimeException("箱东:WFL不存在,请先维护基础资料");
|
|
|
+ }
|
|
|
+ if ("BUY".equals(tradingBox.getType())) {
|
|
|
+ tradingBoxItem.setBoxEastId(bCorps.getId());
|
|
|
+ tradingBoxItem.setBoxEastName(bCorps.getCnName());
|
|
|
+ tradingBoxItem.setOriginalBoxEastId(tradingBox.getPurchaseCompanyId());
|
|
|
+ tradingBoxItem.setOriginalBoxEastName(tradingBox.getPurchaseCompanyName());
|
|
|
+ } else if ("DL".equals(tradingBox.getType())) {
|
|
|
+ tradingBoxItem.setBoxEastId(tradingBox.getPurchaseCompanyId());
|
|
|
+ tradingBoxItem.setBoxEastName(tradingBox.getPurchaseCompanyName());
|
|
|
+ } else if ("ZR".equals(tradingBox.getType())) {
|
|
|
+ tradingBoxItem.setBoxEastId(bCorps.getId());
|
|
|
+ tradingBoxItem.setBoxEastName(bCorps.getCnName());
|
|
|
+ tradingBoxItem.setOriginalBoxEastId(tradingBox.getPurchaseCompanyId());
|
|
|
+ tradingBoxItem.setOriginalBoxEastName(tradingBox.getPurchaseCompanyName());
|
|
|
+ }
|
|
|
}
|
|
|
if ("BUY".equals(tradingBox.getType())) {
|
|
|
- tradingBoxItem.setBoxEastId(bCorps.getId());
|
|
|
- tradingBoxItem.setBoxEastName(bCorps.getCnName());
|
|
|
- tradingBoxItem.setOriginalBoxEastId(tradingBox.getPurchaseCompanyId());
|
|
|
- tradingBoxItem.setOriginalBoxEastName(tradingBox.getPurchaseCompanyName());
|
|
|
+ tradingBoxItem.setBoxCategory("自有箱");
|
|
|
} else if ("DL".equals(tradingBox.getType())) {
|
|
|
- tradingBoxItem.setBoxEastId(tradingBox.getPurchaseCompanyId());
|
|
|
- tradingBoxItem.setBoxEastName(tradingBox.getPurchaseCompanyName());
|
|
|
+ tradingBoxItem.setBoxCategory("代理箱");
|
|
|
} else if ("ZR".equals(tradingBox.getType())) {
|
|
|
- tradingBoxItem.setBoxEastId(bCorps.getId());
|
|
|
- tradingBoxItem.setBoxEastName(bCorps.getCnName());
|
|
|
- tradingBoxItem.setOriginalBoxEastId(tradingBox.getPurchaseCompanyId());
|
|
|
- tradingBoxItem.setOriginalBoxEastName(tradingBox.getPurchaseCompanyName());
|
|
|
+ tradingBoxItem.setBoxCategory("自有箱");
|
|
|
+ } else {
|
|
|
+ tradingBoxItem.setBoxCategory("自有箱");
|
|
|
}
|
|
|
+ tradingBoxItem.setBoxBelongsTo("SOC");
|
|
|
+ tradingBoxItem.setStatus("待使用");
|
|
|
+ tradingBoxItem.setCreateUser(AuthUtil.getUserId());
|
|
|
+ tradingBoxItem.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ tradingBoxItem.setCreateTime(new Date());
|
|
|
+ tradingBoxItem.setPid(tradingBox.getId());
|
|
|
+ tradingBoxItemList.add(tradingBoxItem);
|
|
|
}
|
|
|
- if ("BUY".equals(tradingBox.getType())) {
|
|
|
- tradingBoxItem.setBoxCategory("自有箱");
|
|
|
- } else if ("DL".equals(tradingBox.getType())) {
|
|
|
- tradingBoxItem.setBoxCategory("代理箱");
|
|
|
- } else if ("ZR".equals(tradingBox.getType())) {
|
|
|
- tradingBoxItem.setBoxCategory("自有箱");
|
|
|
- } else {
|
|
|
- tradingBoxItem.setBoxCategory("自有箱");
|
|
|
+ }else if("3".equals(type)){
|
|
|
+ //导入数据
|
|
|
+ List<AgentBoxItemExcel> excelList = ExcelUtil.read(file, AgentBoxItemExcel.class);
|
|
|
+ for (AgentBoxItemExcel item : excelList) {
|
|
|
+ TradingBoxItem tradingBoxItem;
|
|
|
+ if (!itemList.isEmpty()) {
|
|
|
+ tradingBoxItem = itemList.stream().filter(e -> e.getCode().equals(item.getCode())).findFirst().orElse(null);
|
|
|
+ if (tradingBoxItem == null) {
|
|
|
+ tradingBoxItem = new TradingBoxItem();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tradingBoxItem = new TradingBoxItem();
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(item.getCode())) {
|
|
|
+ tradingBoxItem.setCode(item.getCode().trim());
|
|
|
+ tradingBoxItem.setCode(item.getCode().toUpperCase());
|
|
|
+ }
|
|
|
+ if (!exrateType.equals(item.getCurrency())) {
|
|
|
+ tradingBoxItem.setCurrency(item.getCurrency());
|
|
|
+ tradingBoxItem.setExrate(exrateC);
|
|
|
+ } else {
|
|
|
+ tradingBoxItem.setCurrency(exrateType);
|
|
|
+ tradingBoxItem.setExrate(new BigDecimal("1"));
|
|
|
+ }
|
|
|
+ tradingBoxItem.setBoxCondition(item.getBoxCondition());
|
|
|
+ tradingBoxItem.setBoxStatus(item.getBoxStatus());
|
|
|
+ tradingBoxItem.setAmount(item.getAmount());
|
|
|
+ BCntrTypes bCntrTypes = cntrTypesList.stream().filter(e -> e.getCnName().equals(item.getBoxType())).findFirst().orElse(null);
|
|
|
+ if (bCntrTypes == null) {
|
|
|
+ throw new RuntimeException("箱型:" + item.getBoxType() + "不存在,请先维护基础资料");
|
|
|
+ }
|
|
|
+ tradingBoxItem.setBoxType(bCntrTypes.getCnName());
|
|
|
+ tradingBoxItem.setBoxTypeId(bCntrTypes.getId());
|
|
|
+ if (!portsList.isEmpty() && ObjectUtils.isNotNull(item.getRestrictedPortsName())) {
|
|
|
+ String[] arr = item.getRestrictedPortsName().split(",");
|
|
|
+ StringBuilder portsIds = new StringBuilder();
|
|
|
+ for (String name : arr) {
|
|
|
+ BPorts bPorts = portsList.stream().filter(e -> name.equals(e.getCnName())).findFirst().orElse(null);
|
|
|
+ if (bPorts == null) {
|
|
|
+ throw new RuntimeException("港口:" + name + "不存在,请先维护基础资料");
|
|
|
+ }
|
|
|
+ portsIds.append(bPorts.getId()).append(",");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(portsIds.toString())) {
|
|
|
+ tradingBoxItem.setRestrictedPortsIds(portsIds.substring(0, portsIds.length() - 1));
|
|
|
+ tradingBoxItem.setRestrictedPortsName(item.getRestrictedPortsName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!corpsList.isEmpty()) {
|
|
|
+ if (ObjectUtils.isNotNull(item.getStationCname())) {
|
|
|
+ BCorps bCorps = corpsList.stream().filter(e -> item.getStationCname().equals(e.getCnName())).findFirst().orElse(null);
|
|
|
+ if (bCorps == null) {
|
|
|
+ throw new RuntimeException("场站:" + item.getStationCname() + "不存在,请先维护基础资料");
|
|
|
+ }
|
|
|
+ tradingBoxItem.setStationId(bCorps.getId());
|
|
|
+ tradingBoxItem.setStationCname(bCorps.getCnName());
|
|
|
+ tradingBoxItem.setStationCode(bCorps.getCode());
|
|
|
+ tradingBoxItem.setStationEname(bCorps.getEnName());
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(item.getRestrictingShippingCompaniesName())) {
|
|
|
+ String[] arr = item.getRestrictingShippingCompaniesName().split(",");
|
|
|
+ StringBuilder corpIds = new StringBuilder();
|
|
|
+ for (String name : arr) {
|
|
|
+ BCorps bCorps = corpsList.stream().filter(e -> name.equals(e.getCnName())).findFirst().orElse(null);
|
|
|
+ if (bCorps == null) {
|
|
|
+ throw new RuntimeException("船公司:" + name + "不存在,请先维护基础资料");
|
|
|
+ }
|
|
|
+ corpIds.append(bCorps.getId()).append(",");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(corpIds.toString())) {
|
|
|
+ tradingBoxItem.setRestrictingShippingCompaniesIds(corpIds.substring(0, corpIds.length() - 1));
|
|
|
+ tradingBoxItem.setRestrictingShippingCompaniesName(item.getRestrictingShippingCompaniesName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BCorps bCorps = corpsList.stream().filter(e -> "WFL".equals(e.getCode())).findFirst().orElse(null);
|
|
|
+ if (bCorps == null) {
|
|
|
+ throw new RuntimeException("箱东:WFL不存在,请先维护基础资料");
|
|
|
+ }
|
|
|
+ if ("BUY".equals(tradingBox.getType())) {
|
|
|
+ tradingBoxItem.setBoxEastId(bCorps.getId());
|
|
|
+ tradingBoxItem.setBoxEastName(bCorps.getCnName());
|
|
|
+ tradingBoxItem.setOriginalBoxEastId(tradingBox.getPurchaseCompanyId());
|
|
|
+ tradingBoxItem.setOriginalBoxEastName(tradingBox.getPurchaseCompanyName());
|
|
|
+ } else if ("DL".equals(tradingBox.getType())) {
|
|
|
+ tradingBoxItem.setBoxEastId(tradingBox.getPurchaseCompanyId());
|
|
|
+ tradingBoxItem.setBoxEastName(tradingBox.getPurchaseCompanyName());
|
|
|
+ } else if ("ZR".equals(tradingBox.getType())) {
|
|
|
+ tradingBoxItem.setBoxEastId(bCorps.getId());
|
|
|
+ tradingBoxItem.setBoxEastName(bCorps.getCnName());
|
|
|
+ tradingBoxItem.setOriginalBoxEastId(tradingBox.getPurchaseCompanyId());
|
|
|
+ tradingBoxItem.setOriginalBoxEastName(tradingBox.getPurchaseCompanyName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("BUY".equals(tradingBox.getType())) {
|
|
|
+ tradingBoxItem.setBoxCategory("自有箱");
|
|
|
+ } else if ("DL".equals(tradingBox.getType())) {
|
|
|
+ tradingBoxItem.setBoxCategory("代理箱");
|
|
|
+ } else if ("ZR".equals(tradingBox.getType())) {
|
|
|
+ tradingBoxItem.setBoxCategory("自有箱");
|
|
|
+ } else {
|
|
|
+ tradingBoxItem.setBoxCategory("自有箱");
|
|
|
+ }
|
|
|
+ tradingBoxItem.setBoxBelongsTo("SOC");
|
|
|
+ tradingBoxItem.setStatus("待使用");
|
|
|
+ tradingBoxItem.setCreateUser(AuthUtil.getUserId());
|
|
|
+ tradingBoxItem.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ tradingBoxItem.setCreateTime(new Date());
|
|
|
+ tradingBoxItem.setPid(tradingBox.getId());
|
|
|
+ tradingBoxItemList.add(tradingBoxItem);
|
|
|
}
|
|
|
- tradingBoxItem.setBoxBelongsTo("SOC");
|
|
|
- tradingBoxItem.setStatus("待使用");
|
|
|
- tradingBoxItem.setStationId(tradingBox.getStationId());
|
|
|
- tradingBoxItem.setStationCname(tradingBox.getStationCname());
|
|
|
- tradingBoxItem.setStationEname(tradingBox.getStationEname());
|
|
|
- tradingBoxItem.setStationCode(tradingBox.getStationCode());
|
|
|
- tradingBoxItem.setCreateUser(AuthUtil.getUserId());
|
|
|
- tradingBoxItem.setCreateUserName(AuthUtil.getUserName());
|
|
|
- tradingBoxItem.setCreateTime(new Date());
|
|
|
- tradingBoxItem.setPid(tradingBox.getId());
|
|
|
- tradingBoxItemList.add(tradingBoxItem);
|
|
|
}
|
|
|
if (!tradingBoxItemList.isEmpty()) {
|
|
|
this.saveOrUpdateBatch(tradingBoxItemList);
|