dengjun 2024-07-31 09:48:53 +08:00
parent d7daf871ca
commit 2b28b41982
10 changed files with 210 additions and 85 deletions

View File

@ -53,7 +53,7 @@ public class ExportInspectCargoVo implements Serializable {
* 区域( 从基础数据获取区道位信息)
*/
@ApiModelProperty(value = "区域", required = true)
@NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "区域不能为空")
// @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "区域不能为空")
private String area;
/**

View File

@ -126,6 +126,9 @@ public interface NuzarOpenApi {
@PostMapping("/customer/shipment/shipLoad/transitPart")
Map<String, List<TransitPartResp>> getTransitPart(@RequestBody TransitPartRequest request);
@PostMapping("/customer/shipment/shipLoad/transitVinCode")
List<TransitPartResp> getTransitGoods(@RequestBody TransitRequest req);
// 根据ID获取国家
@PostMapping("/miniapp/country/queryByIds")
List<PortAreaCountryDTO> getCountryByIds(@RequestBody List<String> req);

View File

@ -13,4 +13,6 @@ public class TransitPartResp implements Serializable {
private String workStatus;
private String vinCode;
private String model;
}

View File

@ -0,0 +1,18 @@
package com.haitonggauto.rtosc.api.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
@ApiModel("国际中转货物")
public class TransitRequest implements Serializable {
@ApiModelProperty("提单号")
private List<String> mnfBls;
@ApiModelProperty("航次ID")
private List<String> vvyIds;
}

View File

@ -1288,8 +1288,6 @@ public class DepartureHandler implements BaseHandler {
req.setVvyId(form.getVoyageId());
req.setVinCodeList(strings);
List<VinCheckResp> resp = openApi.vinCheckInfo(req);
System.err.println(JSON.toJSONString(req));
System.err.println(JSON.toJSONString(resp));
List<VinCheckResp> checkResps = resp.stream().filter(s -> !s.getHasShutoutScan()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(checkResps)) {

View File

@ -1289,23 +1289,17 @@ public class ExportInHandler implements BaseHandler {
public Result<String> delete(@RequestBody
@NotNull(message = "请传入要删除的出口进场ID")
@Size(min = 1, message = "请传入要删除的出口进场ID") List<Long> ids) {
for (Long id : ids) {
// 货物已开始作业也不能删除
List<CustomerExportInCargo> list = customerExportInCargoService.lambdaQuery().eq(CustomerExportInCargo::getExportInId, id).isNotNull(CustomerExportInCargo::getWorkStatus).list();
if (CollectionUtils.isNotEmpty(list)) {
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "货物已开始作业,也不能删除");
Long w = customerExportInCargoService.lambdaQuery()
.in(CustomerExportInCargo::getExportInId, ids).isNotNull(CustomerExportInCargo::getWorkStatus).count();
if (w > 0) {
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "货物已开始作业,不能删除");
}
// 待提交已驳回的可以删除
CustomerExportIn exportIn = customerExportInService.getById(id);
if (exportIn == null) {
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "要删除的ID不存在");
}
if (exportIn.getCheckStatus() == AuditEnum.SUBMIT || exportIn.getCheckStatus() == AuditEnum.AUDIT_REJECT || exportIn.getCheckStatus() == AuditEnum.AUDIT) {
customerService.delExportIn(id);
} else {
Long a = customerExportInService.lambdaQuery().in(CustomerExportIn::getId, ids).eq(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_PASS).count();
if (a > 0) {
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "已审核通过的不可删除");
}
}
customerService.delExportInBatch(ids);
return ResultUtil.success("success");
}
@ -4095,7 +4089,7 @@ public class ExportInHandler implements BaseHandler {
in.setTermcd(in.getPortAreaId());
in.setVolume(in.getLength().multiply(in.getWidth()).multiply(in.getHeight()).setScale(4, RoundingMode.HALF_UP)); // 计算体积
in.setNatureFlag(goodsNature.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getPtrDesc(), item.getNatureFlagName())).findFirst().get().getPtrCode());
if (!StringUtils.equals(item.getNatureFlagName(), "正常")) {
if (StringUtils.equalsAny(in.getNatureFlagName(), "内进转外出", "外进转内出", "国际中转", "国内中转")) {
in.setTransferShipId(shipList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getTransferShipName())).findFirst().get().getId());
in.setTransferVoyageId(voyageMap.get(in.getTransferShipName()).stream().filter(p -> StringUtils.equalsIgnoreCase(p.getVvyName(), item.getTransferVoyage())).findFirst().get().getVvyId());
}
@ -4115,6 +4109,7 @@ public class ExportInHandler implements BaseHandler {
Map<String, List<CustomerExportIn>> inMap = collect.stream()
.collect(Collectors.groupingBy(item -> StringUtils.joinWith("#$#", item.getShipId(), item.getVoyageId(), item.getBillNum()), Collectors.toList()));
String tip = null;
inMap.entrySet().forEach(item -> {
String[] keys = StringUtils.split(item.getKey(), "#$#");
@ -4189,40 +4184,109 @@ public class ExportInHandler implements BaseHandler {
});
if (CollectionUtils.isNotEmpty(errorDataList)) {
// errorDataList.addAll(successDataList);
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList);
}
inMap.entrySet().forEach(item -> {
String[] keys = StringUtils.split(item.getKey(), "#$#");
String shipId = keys[0]; // 船名
String voyageId = keys[1]; // 航次
String billNo = keys[2]; // 提单号
// 查询出已存在的数据
LambdaQueryWrapper<CustomerExportIn> cQuery = new LambdaQueryWrapper<>();
cQuery.eq(CustomerExportIn::getShipId, shipId);
cQuery.eq(CustomerExportIn::getVoyageId, voyageId);
cQuery.eq(CustomerExportIn::getBillNum, billNo);
List<CustomerExportIn> exportInList = customerExportInService.list(cQuery);
// 单票件件
CustomerExportIn lastE = item.getValue().get(item.getValue().size() - 1); // 以最后一个为标准
// 判断是否为国际中转
if (StringUtils.equals("国际中转", lastE.getNatureFlagName())) {
TransitRequest req = new TransitRequest();
req.setMnfBls(Arrays.asList(lastE.getBillNum()));
req.setVvyIds(Arrays.asList(lastE.getTransferVoyageId()));
List<TransitPartResp> goods = openApi.getTransitGoods(req);
boolean bflag = false;
if (CollectionUtils.isEmpty(goods)) {
JSONObject o = new JSONObject();
o.put("billNum", lastE.getBillNum());
o.put("status", "不存在该提单的卸船清单");
errorDataList.add(o);
} else {
int sum = item.getValue().stream().mapToInt(s -> s.getQuantity()).sum(); // 进场的数量
if (sum != goods.size()) {
JSONObject o = new JSONObject();
o.put("billNum", lastE.getBillNum());
o.put("status", "卸船清单中数量与进港计划中数量不匹配");
errorDataList.add(o);
} else {
bflag = true;
}
}
// 如果数量匹配
if (bflag) {
// 车辆
List<TransitPartResp> cars = goods.stream().filter(s -> !StringUtils.startsWithIgnoreCase(s.getVinCode(), "BJ")).collect(Collectors.toList());
List<TransitPartResp> spares = goods.stream().filter(s -> StringUtils.startsWithIgnoreCase(s.getVinCode(), "BJ")).collect(Collectors.toList());
for (CustomerExportIn ss : item.getValue()) {
List<CustomerExportInTimes> times = new ArrayList<>();
CustomerExportInTimes time = new CustomerExportInTimes();
time.setEnterQuantity(ss.getQuantity());
time.setEnterTime(ss.getTmpEnterDate() == null ? ss.getBeginEnterTime() : ss.getTmpEnterDate());
times.add(time);
ss.setEachVolume(lastE.getEachVolume());
ss.setEachQuantity(lastE.getEachQuantity());
ss.setEachWeight(lastE.getEachWeight());
// 按型号优先匹配
if (StringUtils.equals(ss.getCartType(), "备件")) {
List<CustomerExportInCargo> sList = new ArrayList<>();
for (int k = 0; k < ss.getQuantity(); k++) {
CustomerExportInCargo entity = new CustomerExportInCargo();
entity.setCargoType(1);
entity.setVinStatus(1);
Optional<TransitPartResp> first = spares.stream().filter(t -> StringUtils.equals(t.getModel(), ss.getModels())).findFirst();
if (!first.isPresent()) {
first = spares.stream().findFirst();
}
TransitPartResp resp = first.get();
entity.setVin(resp.getVinCode());
spares.remove(resp);
entity.setTermcd(ss.getPortAreaId());
sList.add(entity);
}
customerService.saveExportIn(ss, null, times, sList);
} else { // 车辆
List<CustomerExportInCargo> sList = new ArrayList<>();
for (int k = 0; k < ss.getQuantity(); k++) {
CustomerExportInCargo entity = new CustomerExportInCargo();
entity.setCargoType(0);
entity.setVinStatus(1);
Optional<TransitPartResp> first = cars.stream().filter(t -> StringUtils.equals(t.getModel(), ss.getModels())).findFirst();
if (!first.isPresent()) {
first = cars.stream().findFirst();
}
TransitPartResp resp = first.get();
entity.setVin(resp.getVinCode());
cars.remove(resp);
entity.setTermcd(ss.getPortAreaId());
sList.add(entity);
}
customerService.saveExportIn(ss, sList, times, null);
}
}
} else {
item.getValue().stream().forEach(ss -> {
List<CustomerExportInTimes> times = new ArrayList<>();
CustomerExportInTimes time = new CustomerExportInTimes();
time.setEnterQuantity(ss.getQuantity());
time.setEnterTime(ss.getTmpEnterDate() == null ? ss.getBeginEnterTime() : ss.getTmpEnterDate());
times.add(time);
ss.setEachVolume(lastE.getEachVolume());
ss.setEachQuantity(lastE.getEachQuantity());
ss.setEachWeight(lastE.getEachWeight());
customerService.saveExportIn(ss, null, times, null);
});
}
} else {
// 如果是备件自动生成条码
// 过滤出是备件
item.getValue().stream().filter(ss -> StringUtils.equals(ss.getCartType(), "备件")).forEach(ss -> {
// 判断是否是国际中转航次ID
String vvyId = ss.getVoyageId();
TransitPartRequest request = new TransitPartRequest();
request.setVvyIds(Arrays.asList(vvyId));
request.setPartAmount(ss.getQuantity());
request.setMnfBl(ss.getBillNum());
// Map<String, List<TransitPartResp>> rst = openApi.getTransitPart(request);
List<String> vins = new ArrayList<>();
if (StringUtils.equals(ss.getNatureFlagName(), "正常")) { // 需要自动生成
// vins.addAll(rst.get(vvyId).stream().map(t -> t.getVinCode()).collect(Collectors.toList()));
// 出口进场计划备件条码生成的规则要变一下BJ+年月日时分+5随机数一共要17位
vins = genBjNo(ss.getQuantity(), null);
}
@ -4262,6 +4326,7 @@ public class ExportInHandler implements BaseHandler {
customerService.saveExportIn(ss, null, times, null);
});
}
});
} catch (ExcelDataConvertException e) {
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入数据错误,请确认导入数据模板是否正确, 行:" + e.getRowIndex() + " 列:" + e.getColumnIndex());

View File

@ -544,9 +544,7 @@ public class ExportLoadHandler implements BaseHandler {
if (count > 0) {
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "只能删除待审核,待提交,已驳回的数据");
}
for (Long id : ids) {
customerService.delExportLoad(id);
}
customerService.delExportLoadBatch(ids);
return ResultUtil.success("success");
}

View File

@ -1088,8 +1088,10 @@ public class ImportInspectHandler implements BaseHandler {
if (StringUtils.isNotEmpty(head.getVoyage())) {
head.setVoyageId(in.getVvyId());
}
// head.setApplyObjId(in.getFreightId());
// head.setApplyObj(in.getFreight());
if (StringUtils.equals("0", type)) {
head.setApplyObjId(userBindFreight.get(0).getCueId());
head.setApplyObj(userBindFreight.get(0).getCueCnname());
}
if (StringUtils.isEmpty(head.getCompany())) {
head.setCompany(head.getApplyObj());
}
@ -1144,7 +1146,9 @@ public class ImportInspectHandler implements BaseHandler {
return o;
}).collect(Collectors.toList()));
} catch (ExcelDataConvertException e) {
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入数据错误,请确认导入数据模板是否正确, 行:"+e.getRowIndex()+" 列:" + e.getColumnIndex());
JSONObject obj = new JSONObject();
obj.put("status", "导入数据错误,请确认导入数据模板是否正确, 行:"+e.getRowIndex()+" 列:" + e.getColumnIndex());
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", Arrays.asList(obj));
} catch (Exception e) {
log.error("上传错误", e);
return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), e.getMessage());

View File

@ -35,6 +35,12 @@ public interface CustomerService {
*/
void delExportIn(Long id);
/**
* 批量删除
* @param id
*/
void delExportInBatch(List<Long> id);
/**
* 修改
* @param exportIn
@ -57,6 +63,8 @@ public interface CustomerService {
*/
void delExportLoad(Long id);
void delExportLoadBatch(List<Long> ids);
/**
* 修改出口装船
* @param imp // 是否是导入, 导入的时候不处理删除

View File

@ -254,6 +254,23 @@ public class CustomerServiceImpl implements CustomerService {
exportInService.removeById(id);
}
@Override
@Transactional(rollbackFor = {Exception.class})
public void delExportInBatch(List<Long> ids) {
// 删除时间表
{
exportInTimesService.lambdaUpdate().in(CustomerExportInTimes::getExportInId, ids).remove();
}
// 删除货物表
{
exportInCargoService.lambdaUpdate().in(CustomerExportInCargo::getExportInId, ids).remove();
}
// 删除表头
exportInService.lambdaUpdate().in(CustomerExportIn::getId, ids).remove();
}
@Override
@Transactional(rollbackFor = {Exception.class})
public void updateExportIn(Boolean imp, CustomerExportIn exportIn, List<CustomerExportInCargo> cargos, List<CustomerExportInTimes> times, List<CustomerExportInCargo> spares) {
@ -382,6 +399,18 @@ public class CustomerServiceImpl implements CustomerService {
exportLoadService.removeById(id);
}
@Override
@Transactional(rollbackFor = {Exception.class})
public void delExportLoadBatch(List<Long> ids) {
// 删除货物表
{
exportLoadCargoService.lambdaUpdate().in(CustomerExportLoadCargo::getExportLoadId, ids).remove();
}
// 删除表头
exportLoadService.lambdaUpdate().in(CustomerExportLoad::getId, ids).remove();
}
@Override
@Transactional(rollbackFor = {Exception.class})
public void updateExportLoad(Boolean imp, CustomerExportLoad exportLoad, List<CustomerExportLoadCargo> cargos) {