进港导出格式

This commit is contained in:
dengjun 2023-12-29 14:45:34 +08:00
parent 3250f6b570
commit 1dfb2a1279
5 changed files with 118 additions and 16 deletions

View File

@ -0,0 +1,27 @@
package com.haitonggauto.rtosc.dto;
import com.haitonggauto.rtosc.common.utils.ValidationGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.List;
@Data
@ApiModel(value = "提离明细编辑",description = "")
public class DepartureDetailVo implements Serializable {
@NotNull(groups = {ValidationGroup.update.class}, message = "提离港区ID不能为空")
@ApiModelProperty(value = "id")
private Long id;
@Valid
@NotNull(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "货物必须填!" )
@Size(min = 1 , message = "提离港区验货物至少要有一个")
private List<DepartureCargoVo> cargos;
}

View File

@ -72,8 +72,14 @@ public class ExportInExcel {
/** /**
* 进场时间 * 进场时间
*/ */
@ExcelProperty("进场时间") @ExcelProperty("进场开始时间")
private String enterTime; private String beginEnterTime;
/**
* 进场时间
*/
@ExcelProperty("进场结束时间")
private String endEnterTime;
/** /**
* 品牌 * 品牌
@ -136,25 +142,25 @@ public class ExportInExcel {
* *
*/ */
@ExcelProperty("") @ExcelProperty("")
private Integer length; private BigDecimal length;
/** /**
* *
*/ */
@ExcelProperty("") @ExcelProperty("")
private Integer width; private BigDecimal width;
/** /**
* *
*/ */
@ExcelProperty("") @ExcelProperty("")
private Integer height; private BigDecimal height;
/** /**
* 重量() * 重量()
*/ */
@ExcelProperty("重量(吨)") @ExcelProperty("重量(吨)")
private Integer weight; private BigDecimal weight;
/** /**
* 操作模式 * 操作模式

View File

@ -19,10 +19,7 @@ import com.haitonggauto.rtosc.common.dto.Result;
import com.haitonggauto.rtosc.common.enums.ErrorType; import com.haitonggauto.rtosc.common.enums.ErrorType;
import com.haitonggauto.rtosc.common.handler.BaseHandler; import com.haitonggauto.rtosc.common.handler.BaseHandler;
import com.haitonggauto.rtosc.common.utils.*; import com.haitonggauto.rtosc.common.utils.*;
import com.haitonggauto.rtosc.dto.CheckVinRepeatVo; import com.haitonggauto.rtosc.dto.*;
import com.haitonggauto.rtosc.dto.DepartureCargoVo;
import com.haitonggauto.rtosc.dto.DepartureCheckVo;
import com.haitonggauto.rtosc.dto.DepartureVo;
import com.haitonggauto.rtosc.query.CargoQuery; import com.haitonggauto.rtosc.query.CargoQuery;
import com.haitonggauto.rtosc.query.DepartureQuery; import com.haitonggauto.rtosc.query.DepartureQuery;
import com.haitonggauto.rtosc.repository.entity.*; import com.haitonggauto.rtosc.repository.entity.*;
@ -62,6 +59,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -384,6 +382,66 @@ public class DepartureHandler implements BaseHandler {
return ResultUtil.success(String.valueOf(departure.getId())); return ResultUtil.success(String.valueOf(departure.getId()));
} }
@ApiOperation("审核端明细编辑")
@PostMapping("/cargo/edit")
@Transactional(rollbackFor = {Exception.class})
// 使用LambdaUpdateWrapper只在特定需求下做处理推荐 将字段修改为空值的处理方法
public Result<String> cargoEdit(@RequestBody @Validated(ValidationGroup.update.class) DepartureDetailVo form) {
// 验证是否有重复的车架号
if (CollectionUtils.isNotEmpty(form.getCargos())) {
List<String> repeat = form.getCargos().stream().collect(Collectors.groupingBy(DepartureCargoVo::getVin, Collectors.counting()))
.entrySet().stream().filter(entry -> entry.getValue() > 1).map(entry -> entry.getKey()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(repeat)) {
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), StringUtils.join(repeat, ",") + "车架号重复");
}
}
CustomerDeparture dep = departureService.getById(form.getId());
if (dep.getCheckStatus() == AuditEnum.AUDIT_PASS) {
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "审核通过之后不能进行编辑");
}
// 验证是否重复申请
List<String> vins = form.getCargos().stream().map(item -> item.getVin()).collect(Collectors.toList());
List<CustomerDepartureCargo> exists = departureCargoService.lambdaQuery().in(CustomerDepartureCargo::getVin, vins).ne(CustomerDepartureCargo::getDepartureId, form.getId()).list();
List<String> repeat = exists.stream().map(item -> item.getVin()).collect(Collectors.toList());;
if (CollectionUtils.isNotEmpty(exists)) {
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), StringUtils.join(repeat, ",") + "车架号不能重复申请");
}
List<CustomerDepartureCargo> cargos = form.getCargos().stream().map(item -> {
CustomerDepartureCargo entity = PoMapper.instance.departureCargoVo2Entity(item);
entity.setDepartureId(dep.getId());
entity.setTermcd(dep.getPortAreaId());
return entity;
}).collect(Collectors.toList());
{
List<CustomerDepartureCargo> insert = cargos.stream().filter(item -> item.getId() == null).collect(Collectors.toList());
List<CustomerDepartureCargo> update = cargos.stream().filter(item -> item.getId() != null).collect(Collectors.toList());
// 需要更新的
departureCargoService.updateBatchById(update);
// 需要删除的
List<Long> collect = update.stream().map(item -> item.getId()).collect(Collectors.toList());
LambdaQueryWrapper<CustomerDepartureCargo> query = new LambdaQueryWrapper<>();
query.eq(CustomerDepartureCargo::getDepartureId, dep.getId());
List<Long> delete = departureCargoService.list(query).stream()
.map(item -> item.getId())
.filter(item -> !collect.contains(item))
.collect(Collectors.toList());
departureCargoService.removeByIds(delete);
// 需要删除的
departureCargoService.saveBatch(insert);
}
return ResultUtil.success(String.valueOf(dep.getId()));
}
/** /**
* 详情 * 详情
* @param id * @param id

View File

@ -1367,6 +1367,15 @@ public class ExportInHandler implements BaseHandler {
} }
@ApiOperation("验证是否是出口条码打印中的货物")
@PostMapping("/valid/print/vin")
public Result<List<String>> validPrintVin(@RequestBody @NotNull(message = "验证列表不能为空") @Size(min = 1, message = "验证列表不能为空") ValidList<String> vins) {
List<CustomerExportInCargo> exists = customerExportInCargoService.list(new LambdaQueryWrapper<CustomerExportInCargo>().in(CustomerExportInCargo::getVin, vins));
List<String> existVins = exists.stream().map(p -> p.getVin()).collect(Collectors.toList());
return ResultUtil.success(existVins);
}
@ApiOperation("车架号导入(数组形式)") @ApiOperation("车架号导入(数组形式)")
@PostMapping("/import-vin-data") @PostMapping("/import-vin-data")
public Result<List<JSONObject>> importVinData(@RequestBody @Validated ImportVinVo vinList) throws IOException { public Result<List<JSONObject>> importVinData(@RequestBody @Validated ImportVinVo vinList) throws IOException {
@ -2010,12 +2019,12 @@ public class ExportInHandler implements BaseHandler {
List<ExportInExcel> rows = page.getRecords().stream().map(item -> { List<ExportInExcel> rows = page.getRecords().stream().map(item -> {
// item.setEnergyTypeName(item.getEnergyType().text()); // item.setEnergyTypeName(item.getEnergyType().text());
ExportInExcel e = PoMapper.instance.entity2Excel(item); ExportInExcel e = PoMapper.instance.entity2Excel(item);
e.setEnterTime( // e.setEnterTime(
StringUtils.join( // StringUtils.join(
item.getBeginEnterTime() != null ? DateUtils.formatDate(item.getBeginEnterTime(), "yyyy-MM-dd HH:mm") : "", // item.getBeginEnterTime() != null ? DateUtils.formatDate(item.getBeginEnterTime(), "yyyy-MM-dd HH:mm") : "",
",", // ",",
item.getEndEnterTime() != null ? DateUtils.formatDate(item.getEndEnterTime(), "yyyy-MM-dd HH:mm") : "" // item.getEndEnterTime() != null ? DateUtils.formatDate(item.getEndEnterTime(), "yyyy-MM-dd HH:mm") : ""
)); // ));
// 处理一下时间问题 // 处理一下时间问题
return e; return e;
}).collect(Collectors.toList()); }).collect(Collectors.toList());

View File

@ -51,6 +51,8 @@ public interface PoMapper {
CustomerFreeTrade freeTradeCheckVo2Entity(FreeTradeCheckVo vo); CustomerFreeTrade freeTradeCheckVo2Entity(FreeTradeCheckVo vo);
@Mapping(source = "beginEnterTime", target = "beginEnterTime", dateFormat="yyyy/MM/dd")
@Mapping(source = "endEnterTime", target = "endEnterTime", dateFormat="yyyy/MM/dd")
ExportInExcel entity2Excel(CustomerExportIn entity); ExportInExcel entity2Excel(CustomerExportIn entity);
CustomerFreeTrade excel2Entity(FreeTradeExcel excel); CustomerFreeTrade excel2Entity(FreeTradeExcel excel);