diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/BatchCheckShipVo.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/BatchCheckShipVo.java new file mode 100644 index 0000000..7ab312d --- /dev/null +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/BatchCheckShipVo.java @@ -0,0 +1,31 @@ +package com.haitonggauto.rtosc.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.Date; + +@Data +@ApiModel(value = "多船批量审核") +public class BatchCheckShipVo implements Serializable { + + @ApiModelProperty(value = "船ID") + @NotBlank(message = "船ID不能为空") + private String shipId; + + @ApiModelProperty(value = "航次ID") + @NotBlank(message = "航次ID不能为空") + private String voyageId; + + @ApiModelProperty(value = "港区ID") + @NotBlank(message = "港区ID不能为空") + private String portAreaId; + + @ApiModelProperty(value = "预进港时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date preArrivalTime; +} diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/BillNumValidVo.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/BillNumValidVo.java new file mode 100644 index 0000000..1ae3522 --- /dev/null +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/BillNumValidVo.java @@ -0,0 +1,28 @@ +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.constraints.NotBlank; + +@Data +@ApiModel("提单号验证") +public class BillNumValidVo { + @ApiModelProperty(value = "船ID") + @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "船ID不能为空") + private String shipId; + + @ApiModelProperty(value = "航次ID") + @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "航次ID不能为空") + private String voyageId; + + @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "货代ID不能为空") + @ApiModelProperty(value = "货代ID", required = true) + private String freightId; + + @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "提单号不能为空") + @ApiModelProperty(value = "提单号", required = true) + private String billNum; +} diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/DepartureCargoVo.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/DepartureCargoVo.java index a7916d1..59fe6f0 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/DepartureCargoVo.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/DepartureCargoVo.java @@ -1,5 +1,6 @@ package com.haitonggauto.rtosc.dto; +import com.baomidou.mybatisplus.annotation.TableField; import com.haitonggauto.rtosc.common.utils.ValidationGroup; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -9,6 +10,7 @@ import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import java.io.Serializable; +import java.math.BigDecimal; @Data @ApiModel(value = "提离港区货物表",description = "") @@ -46,14 +48,13 @@ public class DepartureCargoVo implements Serializable { * 货物类型 */ // @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "车型不能为空") - @ApiModelProperty(value = "车型", required = true) - private String cargoType; +// @ApiModelProperty(value = "车型", required = true) +// private String cargoType; /** * 车架号/条码 */ @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "车架号/条码不能为空") - @Size(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, min = 17, max = 17, message = "车架号长度为17位") @ApiModelProperty(value = "车架号/条码", required = true) private String vin; @@ -71,6 +72,53 @@ public class DepartureCargoVo implements Serializable { @ApiModelProperty(value = "是否退关", required = true) private Integer isShutout; + /** + * 车型ID + */ + @ApiModelProperty(value = "车型ID") + private String cartTypeId; + + /** + * 车型 + */ + @ApiModelProperty(value = "车型") + private String cartType; + // 型号 + + @ApiModelProperty(value = "型号") + private String models; + /** + * 长 + */ + @ApiModelProperty(value = "长") + private BigDecimal length; + + /** + * 宽 + */ + @ApiModelProperty(value = "宽") + private BigDecimal width; + + /** + * 高 + */ + @ApiModelProperty(value = "高") + private BigDecimal height; + + /** + * 重量(吨) + */ + @TableField(value = "weight") + @ApiModelProperty(value = "重量") + private BigDecimal weight; + + // 是否报关 + @ApiModelProperty(value = "是否报关") + private Integer isCustoms; + + @ApiModelProperty(value = "是否随车备件") + private Integer isSpare; + @ApiModelProperty(value = "车辆状态") private String vinStatus; diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/DepartureValidVo.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/DepartureValidVo.java new file mode 100644 index 0000000..15398c1 --- /dev/null +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/DepartureValidVo.java @@ -0,0 +1,47 @@ +package com.haitonggauto.rtosc.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.List; + +@Data +@ApiModel("提离港区验证") +public class DepartureValidVo { + @ApiModelProperty(value = "船ID") + @NotBlank(message = "船ID不能为空") + private String shipId; + + @ApiModelProperty(value = "航次ID") + @NotBlank(message = "航次ID不能为空") + private String voyageId; + + @NotBlank(message = "港区ID不能为空") + @ApiModelProperty(value = "港区ID", required = true) + private String portAreaId; + + @ApiModelProperty(value = "品牌ID", required = true) + @NotBlank(message = "品牌ID不能为空") + private String brandId; + + @Valid + @NotNull(message = "车架号不能为空") + @Size(min = 1, message = "车架号不能为空") + private List vins; + + @Data + public static class BillVin { + @ApiModelProperty(value = "提单号", required = true) + @NotBlank(message = "提单号不能为空") + private String billNo; + + @ApiModelProperty(value = "车架号", required = true) + @NotBlank(message = "车架号不能为空") + private String vin; + } +} diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/DepartureVo.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/DepartureVo.java index 6a5ca8e..bb02140 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/DepartureVo.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/DepartureVo.java @@ -56,30 +56,44 @@ public class DepartureVo implements Serializable { * 航次ID */ @ApiModelProperty(value = "航次ID") - @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "航次ID不能为空") +// @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "航次ID不能为空") private String voyageId; /** * 航次 */ @ApiModelProperty(value = "航次", required = true) - @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "航次不能为空") +// @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "航次不能为空") private String voyage; /** * 港区ID */ @ApiModelProperty(value = "港区ID") - @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "港区ID不能为空") +// @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "港区ID不能为空") private String portAreaId; /** * 港区 */ @ApiModelProperty(value = "港区", required = true) - @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "港区不能为空") +// @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "港区不能为空") private String portArea; + /** + * 品牌ID + */ + @ApiModelProperty(value = "品牌ID") + @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "品牌ID不能为空") + private String brandId; + + /** + * 品牌 + */ + @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "品牌不能为空") + @ApiModelProperty(value = "品牌") + private String brand; + /** * 贸易类型 */ diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInAuditVo.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInAuditVo.java new file mode 100644 index 0000000..818730f --- /dev/null +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInAuditVo.java @@ -0,0 +1,51 @@ +package com.haitonggauto.rtosc.dto; + +import com.haitonggauto.rtosc.common.utils.ValidationGroup; +import com.haitonggauto.rtosc.repository.enums.AuditEnum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.io.Serializable; +import java.util.List; + +/** + * 出口进场基本表 + * + * @TableName customer_export_in + */ +@Data +@ApiModel(value = "进港审核", description = "") +public class ExportInAuditVo implements Serializable { + + @ApiModelProperty(value = "船ID") + @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "船ID不能为空") + private String shipId; + + /** + * 航次ID + */ + @ApiModelProperty(value = "航次ID") + @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "航次ID不能为空") + private String voyageId; + + /** + * 审核状态 + */ + @ApiModelProperty(value = "审核状态") + @NotNull(groups = {ValidationGroup.insert.class}, message = "审核状态不能为空") + private AuditEnum checkStatus; + + @ApiModelProperty(value = "提单号列表") + @NotNull(groups = {ValidationGroup.insert.class}, message = "提单号列表不能为空") + @Size(min = 1, message = "提单号列表不能为空") + private List billNums; + /** + * 审核原因 + */ + @ApiModelProperty(value = "审核原因") + private String checkResult; +} \ No newline at end of file diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInBatchCheckVo.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInBatchCheckVo.java new file mode 100644 index 0000000..1091234 --- /dev/null +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInBatchCheckVo.java @@ -0,0 +1,44 @@ +package com.haitonggauto.rtosc.dto; + +import com.haitonggauto.rtosc.common.utils.ValidationGroup; +import com.haitonggauto.rtosc.repository.enums.AuditEnum; +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; + +/** + * 出口进场货物表 + * @TableName customer_export_in_cargo + */ +@Data +@ApiModel(value = "多船审核信息",description = "") +public class ExportInBatchCheckVo implements Serializable { + + @ApiModelProperty(value = "原始审核状态") + @NotNull(message = "原始审核状态不能为空") + private AuditEnum originalCheckStatus; + + @ApiModelProperty(value = "审核状态") + @NotNull(message = "审核状态不能为空") + private AuditEnum checkStatus; + + /** + * 审核原因 + */ + @ApiModelProperty(value = "审核原因") + private String checkResult; + + @ApiModelProperty(value = "审核类型, 0-全部,1-车辆,2-备件") + private String type; + + @Valid + @NotNull(message = "审核船名列表为空") + @Size(min = 1, message = "审核船名列表不能为空") + private List ships; +} \ No newline at end of file diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInCargoVo.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInCargoVo.java index 0408af6..88d8905 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInCargoVo.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInCargoVo.java @@ -32,7 +32,6 @@ public class ExportInCargoVo implements Serializable { * 车架号 */ @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "车架号不能为空") - @Size(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, min = 17, max = 17, message = "车架号长度为17位") @ApiModelProperty(value = "车架号", required = true) private String vin; diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInQueryVo.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInQueryVo.java new file mode 100644 index 0000000..9db249e --- /dev/null +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInQueryVo.java @@ -0,0 +1,30 @@ +package com.haitonggauto.rtosc.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.io.Serializable; +import java.util.List; + +@Data +@ApiModel(value = "进港计划查询",description = "") +public class ExportInQueryVo implements Serializable { + + @ApiModelProperty(value = "船ID") + private String shipId; + + /** + * 受理号 + */ + @ApiModelProperty(value = "航次ID") + private String voyageId; + + @ApiModelProperty(value = "车架号列表") + @NotNull(message = "请传入车架号列表") + @Size(min = 1, message = "车架号列表不能为空") + private List billNums; + +} diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInVo.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInVo.java index 39303f7..9e4bb97 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInVo.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInVo.java @@ -1,6 +1,5 @@ package com.haitonggauto.rtosc.dto; -import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonFormat; import com.haitonggauto.rtosc.common.utils.ValidationGroup; import com.haitonggauto.rtosc.common.validate.DependsOn; @@ -182,6 +181,14 @@ public class ExportInVo implements Serializable { @ApiModelProperty(value = "运输方式", required = true) private String transportWay; + @ApiModelProperty(value = "预进港时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date preArrivalTime; + + @ApiModelProperty(value = "预靠泊时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date planArrivePortTime; + @ApiModelProperty(value = "进场开始时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date beginEnterTime; diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInspectCargoVo.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInspectCargoVo.java index ae06434..e6ca4cc 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInspectCargoVo.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInspectCargoVo.java @@ -47,7 +47,6 @@ public class ExportInspectCargoVo implements Serializable { */ @ApiModelProperty(value = "车架号", required = true) @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "车架号/条码不能为空") - @Size(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, min = 17, max = 17, message = "车架号长度为17位") private String vin; /** diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInspectVo.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInspectVo.java index 015ab76..e6ba1b5 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInspectVo.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInspectVo.java @@ -43,7 +43,7 @@ public class ExportInspectVo 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 voyage; /** @@ -85,7 +85,7 @@ public class ExportInspectVo 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 company; @ApiModelProperty(value = "申请对象ID") @@ -96,7 +96,7 @@ public class ExportInspectVo 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 applyObj; /** @@ -144,7 +144,7 @@ public class ExportInspectVo implements Serializable { * 航次ID */ @ApiModelProperty(value = "航次ID") - @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "航次ID不能为空") +// @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "航次ID不能为空") private String voyageId; @ApiModelProperty(value = "港区ID") diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportLoadCargoVo.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportLoadCargoVo.java index 8deaf1c..e88ec39 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportLoadCargoVo.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportLoadCargoVo.java @@ -39,7 +39,6 @@ public class ExportLoadCargoVo implements Serializable { * 车架号/条码 */ @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "车架号/条码不能为空") - @Size(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, min = 17, max = 17, message = "车架号长度为17位") @ApiModelProperty(value = "车架号/条码", required = true) private String vin; diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportLoadCheckVo.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportLoadCheckVo.java index 28e4b1e..ed1b9e0 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportLoadCheckVo.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportLoadCheckVo.java @@ -48,6 +48,12 @@ public class ExportLoadCheckVo implements Serializable { @NotNull(groups = {ValidationGroup.insert.class}, message = "审核状态不能为空") private AuditEnum checkStatus; + @ApiModelProperty("提单号") + private List billNos; + + @ApiModelProperty(value = "是否为备件") + private Boolean spare; + /** * 审核原因 */ diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/InspectValidVo.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/InspectValidVo.java new file mode 100644 index 0000000..6292b8e --- /dev/null +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/InspectValidVo.java @@ -0,0 +1,25 @@ +package com.haitonggauto.rtosc.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +@ApiModel("出口查验检验") +@Data +public class InspectValidVo implements Serializable { + + @ApiModelProperty("船ID") + @NotBlank(message = "船ID不能为空") + private String shipId; + + @ApiModelProperty("提单号") + @NotBlank(message = "提单号不能为空") + private String billNo; + + @ApiModelProperty("车架号") + private List vins; +} diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/UpdatePlanArrivePortVo.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/UpdatePlanArrivePortVo.java new file mode 100644 index 0000000..2767149 --- /dev/null +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/UpdatePlanArrivePortVo.java @@ -0,0 +1,33 @@ +package com.haitonggauto.rtosc.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.Date; + +/** + * 出口进场货物表 + * @TableName customer_export_in_cargo + */ +@Data +@ApiModel(value = "同步预靠泊时间",description = "") +public class UpdatePlanArrivePortVo implements Serializable { + + @ApiModelProperty(value = "船ID") + @NotBlank(message = "船ID不能为空") + private String shipId; + + @ApiModelProperty(value = "航次ID") + @NotBlank(message = "航次ID不能为空") + private String voyageId; + + @ApiModelProperty(value = "预靠泊时间") + @NotNull(message = "预靠泊时间不能为空") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date planArrivePortTime; +} \ No newline at end of file diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/UpdatePreArrivalTimeVo.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/UpdatePreArrivalTimeVo.java new file mode 100644 index 0000000..caa94c1 --- /dev/null +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/UpdatePreArrivalTimeVo.java @@ -0,0 +1,44 @@ +package com.haitonggauto.rtosc.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.haitonggauto.rtosc.repository.enums.AuditEnum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * 出口进场货物表 + * @TableName customer_export_in_cargo + */ +@Data +@ApiModel(value = "同步预进港时间",description = "") +public class UpdatePreArrivalTimeVo implements Serializable { + + @ApiModelProperty(value = "船ID") + @NotBlank(message = "船ID不能为空") + private String shipId; + + @ApiModelProperty(value = "航次ID") + @NotBlank(message = "航次ID不能为空") + private String voyageId; + + @ApiModelProperty(value = "原预进港时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date oldPreArrivalTime; + + @ApiModelProperty(value = "预进港时间") + @NotNull(message = "预进港时间不能为空") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date preArrivalTime; + + @ApiModelProperty(value = "新航次名称") + private String newVoyage; +} \ No newline at end of file diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/UpdateVoyageVo.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/UpdateVoyageVo.java index 611747d..c050f81 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/UpdateVoyageVo.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/UpdateVoyageVo.java @@ -19,10 +19,10 @@ public class UpdateVoyageVo implements Serializable { /** * 船名 */ - @Valid +// @Valid @ApiModelProperty(value = "计划ID") - @Size(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, min = 1, message = "计划ID不能为空") - @NotNull(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "计划ID不能为空") +// @Size(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, min = 1, message = "计划ID不能为空") +// @NotNull(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "计划ID不能为空") private List ids; /** @@ -39,4 +39,9 @@ public class UpdateVoyageVo implements Serializable { @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "航次不能为空") private String voyage; + @ApiModelProperty(value = "提单号列表") + private List billNums; + + @ApiModelProperty(value = "是否验证") + private Boolean valid; } diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ValidVinActivateVo.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ValidVinActivateVo.java new file mode 100644 index 0000000..e9c8d5e --- /dev/null +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ValidVinActivateVo.java @@ -0,0 +1,31 @@ +package com.haitonggauto.rtosc.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.io.Serializable; +import java.util.List; + +@Data +@ApiModel(value = "验证车架号是否激活",description = "") +public class ValidVinActivateVo implements Serializable { + + @ApiModelProperty(value = "船ID") + private String shipId; + + /** + * 受理号 + */ + @ApiModelProperty(value = "航次ID") + private String voyageId; + + @ApiModelProperty(value = "车架号列表") + @NotNull(message = "请传入车架号列表") + @Size(min = 1, message = "车架号列表不能为空") + private List vins; + +} diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/DepartureImportExcel.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/DepartureImportExcel.java new file mode 100644 index 0000000..c36ff8a --- /dev/null +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/DepartureImportExcel.java @@ -0,0 +1,59 @@ +package com.haitonggauto.rtosc.excel; + +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.math.BigDecimal; + +@Data +@ApiModel("提离港区导入") +public class DepartureImportExcel { + @ApiModelProperty("提单号") + @ExcelProperty(value = "提单号") + @NotBlank(message = "提单号不能为空") + private String billNo; + + @ApiModelProperty("车架号/备件号") + @ExcelProperty(value = "车架号/备件号") + @NotBlank(message = "车架号/备件号不能为空") + private String vin; + + @ApiModelProperty("车型") + @ExcelProperty(value = "车型") + private String cartType; + + @ApiModelProperty(value = "型号") + @ExcelProperty(value = "型号") + private String models; + + @ApiModelProperty(value = "长(米)") + @ExcelProperty(value = "长(米)") + private BigDecimal length; + + @ApiModelProperty(value = "宽(米)") + @ExcelProperty(value = "宽(米)") + private BigDecimal width; + + @ApiModelProperty(value = "高(米)") + @ExcelProperty(value = "高(米)") + private BigDecimal height; + + @ApiModelProperty(value = "重量(kg)") + @ExcelProperty(value = "重量(kg)") + private BigDecimal weight; + + @ApiModelProperty(value = "是否报关") + @ExcelProperty(value = "是否报关") + private String isCustoms; + + @ApiModelProperty(value = "是否退关提离") + @ExcelProperty(value = "是否退关提离") + private String isShutout; + + @ApiModelProperty(value = "是否随车备件") + @ExcelProperty(value = "是否随车备件") + private String isSpare; +} diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInBillSpareExcel.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInBillSpareExcel.java index fb68600..0eb50ff 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInBillSpareExcel.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInBillSpareExcel.java @@ -9,23 +9,23 @@ import javax.validation.constraints.Size; @Data public class ExportInBillSpareExcel { - @ExcelProperty("*船名") + @ExcelProperty(value = "*船名") @NotBlank(message = "船名不能为空") private String shipName; - @ExcelProperty("*航次") + @ExcelProperty(value = "*航次") @NotBlank(message = "航次不能为空") private String voyage; - @ExcelProperty("*提单号") + @ExcelProperty(value = "*提单号") @NotBlank(message = "提单号不能为空") private String billNo; - @ExcelProperty("*品牌") + @ExcelProperty(value = "*品牌") @NotBlank(message = "品牌不能为空") private String brand; - @ExcelProperty("*备件号") + @ExcelProperty(value = "*备件号") @NotBlank(message = "备件号不能为空") @Size(min = 17, max = 17, message = "备件号长度为17位") private String vin; diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInCargoExportExcel.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInCargoExportExcel.java index d35436f..86d7454 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInCargoExportExcel.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInCargoExportExcel.java @@ -12,31 +12,31 @@ import java.math.BigDecimal; @Data public class ExportInCargoExportExcel { - @ExcelProperty("船名") + @ExcelProperty(value = "船名") private String shipName; - @ExcelProperty("航次") + @ExcelProperty(value = "航次") private String voyage; - @ExcelProperty("提单号") + @ExcelProperty(value = "提单号") private String billNum; - @ExcelProperty("品牌") + @ExcelProperty(value = "品牌") private String brand; - @ExcelProperty("型号") + @ExcelProperty(value = "型号") private String models; - @ExcelProperty("车架号") + @ExcelProperty(value = "车架号") private String vin; - @ExcelProperty("实际进港时间") + @ExcelProperty(value = "实际进港时间") private String enterPortTime; - @ExcelProperty("场地") + @ExcelProperty(value = "场地") private String position; - @ExcelProperty("港口") + @ExcelProperty(value = "港口") private String portName; } \ No newline at end of file diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInExcel.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInExcel.java index 9259be1..27514f5 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInExcel.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInExcel.java @@ -9,28 +9,27 @@ import javax.validation.constraints.Size; @Data public class ExportInExcel { - @ExcelProperty("*船名") + @ExcelProperty(value = "*船名") @NotBlank(message = "船名不能为空") private String shipName; - @ExcelProperty("*航次") + @ExcelProperty(value = "*航次") @NotBlank(message = "航次不能为空") private String voyage; - @ExcelProperty("*提单号") + @ExcelProperty(value = "*提单号") @NotBlank(message = "提单号不能为空") private String billNo; - @ExcelProperty("*品牌") + @ExcelProperty(value = "*品牌") @NotBlank(message = "品牌不能为空") private String brand; - @ExcelProperty("*型号") + @ExcelProperty(value = "*型号") @NotBlank(message = "型号不能为空") private String models; - @ExcelProperty("*车架号") + @ExcelProperty(value = "*车架号") @NotBlank(message = "车架号不能为空") - @Size(min = 17, max = 17, message = "车架号长度为17位") private String vin; } diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInPlanExcel.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInPlanExcel.java index cc4564d..304477a 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInPlanExcel.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInPlanExcel.java @@ -43,39 +43,39 @@ public class ExportInPlanExcel { /** * 港区 */ - @ExcelProperty("*港区") + @ExcelProperty(value = "*港区") @NotBlank(message = "港区不能为空") private String portArea; /** * 船名 */ - @ExcelProperty("*船名") + @ExcelProperty(value = "*船名") @NotBlank(message = "船名不能为空") private String shipName; /** * 航次 */ - @ExcelProperty("*航次") + @ExcelProperty(value = "*航次") @NotBlank(message = "航次不能为空") private String voyage; - @ExcelProperty("*货物性质") + @ExcelProperty(value = "*货物性质") @NotBlank(message = "货物性质不能为空") private String natureFlagName; - @ExcelProperty("中转进口船名") + @ExcelProperty(value = "中转进口船名") private String transferShipName; - @ExcelProperty("中转进口航次") + @ExcelProperty(value = "中转进口航次") private String transferVoyage; /** * 货代 */ - @ExcelProperty("*货代") + @ExcelProperty(value = "*货代") @NotBlank(message = "货代不能为空") private String freight; @@ -83,43 +83,43 @@ public class ExportInPlanExcel { /** * 联系人 */ - @ExcelProperty("*联系人") + @ExcelProperty(value = "*联系人") @NotBlank(message = "联系人不能为空") private String contact; /** * 联系方式 */ - @ExcelProperty("*联系方式") + @ExcelProperty(value = "*联系方式") @NotBlank(message = "联系方式不能为空") private String contactPhone; /** * 港口 */ - @ExcelProperty("*国家") + @ExcelProperty(value = "*国家") @NotBlank(message = "国家不能为空") private String country; /** * 港口 */ - @ExcelProperty("*港口") + @ExcelProperty(value = "*港口") @NotBlank(message = "港口不能为空") private String portName; /** * 运输方式 */ - @ExcelProperty("*运输方式") + @ExcelProperty(value = "*运输方式") @NotBlank(message = "运输方式不能为空") private String transportWay; - @ExcelProperty("*进场开始日期") + @ExcelProperty(value = "*进场开始日期") @NotBlank(message = "进场开始日期不能为空") private String beginEnterTime; - @ExcelProperty("*进场结束日期") + @ExcelProperty(value = "*进场结束日期") @NotBlank(message = "进场结束日期不能为空") private String endEnterTime; @@ -127,26 +127,26 @@ public class ExportInPlanExcel { * 进场时间 */ // @DateTimeFormat("yyyy-MM-dd HH:mm") - @ExcelProperty("进场时间") + @ExcelProperty(value = "进场时间") private String enterTime; /** * 进场数量 */ - @ExcelProperty("进场数量") + @ExcelProperty(value = "进场数量") private Integer enterQuantity; /** * 提单号 */ - @ExcelProperty("*提单号") + @ExcelProperty(value = "*提单号") @NotBlank(message = "提单号不能为空") private String billNum; /** * 单票数量 */ - @ExcelProperty("*单票件数") + @ExcelProperty(value = "*单票件数") @NotNull(message = "单票件数不能为空") private Integer eachQuantity; @@ -160,7 +160,7 @@ public class ExportInPlanExcel { /** * 单票体积 */ - @ExcelProperty("*单票体积") + @ExcelProperty(value = "*单票体积") @NotNull(message = "单票体积不能为空") @NumberFormat("#.####") private BigDecimal eachVolume; @@ -168,7 +168,7 @@ public class ExportInPlanExcel { /** * 单票重量 */ - @ExcelProperty("*单票重量(千克)") + @ExcelProperty(value = "*单票重量(千克)") @NotNull(message = "单票重量不能为空") @NumberFormat("#.####") private BigDecimal eachWeight; @@ -176,49 +176,49 @@ public class ExportInPlanExcel { /** * 品牌 */ - @ExcelProperty("*品牌") + @ExcelProperty(value = "*品牌") @NotBlank(message = "品牌不能为空") private String brand; /** * 车型 */ - @ExcelProperty("*车型") + @ExcelProperty(value = "*车型") @NotBlank(message = "车型不能为空") private String cartType; /** * 车型明细 */ - @ExcelProperty("*车型明细") + @ExcelProperty(value = "*车型明细") @NotBlank(message = "车型明细不能为空") private String cartTypeDetail; /** * 型号 */ - @ExcelProperty("*型号") + @ExcelProperty(value = "*型号") @NotBlank(message = "型号不能为空") private String models; /** * 产地 */ - @ExcelProperty("*产地") + @ExcelProperty(value = "*产地") @NotBlank(message = "产地不能为空") private String originPlace; /** * 数量 */ - @ExcelProperty("*数量") + @ExcelProperty(value = "*数量") @NotNull(message = "数量不能为空") private Integer quantity; /** * 长 */ - @ExcelProperty("*长") + @ExcelProperty(value = "*长") @NotNull(message = "长不能为空") @NumberFormat("#.####") private BigDecimal length; @@ -226,7 +226,7 @@ public class ExportInPlanExcel { /** * 宽 */ - @ExcelProperty("*宽") + @ExcelProperty(value = "*宽") @NotNull(message = "宽不能为空") @NumberFormat("#.####") private BigDecimal width; @@ -234,7 +234,7 @@ public class ExportInPlanExcel { /** * 高 */ - @ExcelProperty("*高") + @ExcelProperty(value = "*高") @NotNull(message = "高不能为空") @NumberFormat("#.####") private BigDecimal height; @@ -242,34 +242,37 @@ public class ExportInPlanExcel { /** * 重量(吨) */ - @ExcelProperty("*重量(吨)") + @ExcelProperty(value = "*重量(吨)") @NotNull(message = "重量不能为空") @NumberFormat("#.####") private BigDecimal weight; - @ExcelProperty("*体积") + @ExcelProperty(value = "*体积") @ApiModelProperty(value = "体积") private BigDecimal volume; /** * 操作模式 */ - @ExcelProperty("*操作模式") + @ExcelProperty(value = "*操作模式") @NotBlank(message = "操作模式不能为空") private String operateType; @NotBlank(message = "特殊作业不能为空") - @ExcelProperty("*特殊作业") + @ExcelProperty(value = "*特殊作业") private String specWork; /** * 源类型 */ - @ExcelProperty("*能源类型") + @ExcelProperty(value = "*能源类型") // @NotBlank(message = "*能源类型不能为空") private String energyTypeName; - @ExcelProperty("*是否二手车") + @ExcelProperty(value = "*是否二手车") // @NotBlank(message = "是否是二手车不能为空") private String secondHand; + + @ExcelProperty(value = "备注") + private String remark; } \ No newline at end of file diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInSpareExcel.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInSpareExcel.java index 52ab629..fdf02f7 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInSpareExcel.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInSpareExcel.java @@ -22,7 +22,7 @@ public class ExportInSpareExcel { @NotBlank(message = "备件号不能为空") @Size(min = 17, max = 17, message = "备件号长度为17位") @ApiModelProperty(value = "备件号") - @ExcelProperty("*备件号") + @ExcelProperty(value = "*备件号") private String vin; } \ No newline at end of file diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportLoadExcel.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportLoadExcel.java index 5473ca3..f28f8d1 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportLoadExcel.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportLoadExcel.java @@ -9,28 +9,27 @@ import javax.validation.constraints.Size; @Data public class ExportLoadExcel { - @ExcelProperty("*船名") + @ExcelProperty(value = "*船名") @NotBlank(message = "船名不能为空") private String shipName; - @ExcelProperty("*航次") + @ExcelProperty(value = "*航次") @NotBlank(message = "航次不能为空") private String voyage; - @ExcelProperty("*提单号") + @ExcelProperty(value = "*提单号") @NotBlank(message = "提单号不能为空") private String billNo; - @ExcelProperty("*车架号") + @ExcelProperty(value = "*车架号") @NotBlank(message = "车架号不能为空") - @Size(min = 17, max = 17, message = "车架号长度为17位") private String vin; @ExcelProperty(value = "*目的港") @NotBlank(message = "目的港不能为空") private String destPort; - @ExcelProperty("*品牌") + @ExcelProperty(value = "*品牌") @NotBlank(message = "品牌不能为空") private String brand; diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportLoadExportExcel.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportLoadExportExcel.java new file mode 100644 index 0000000..206d05d --- /dev/null +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportLoadExportExcel.java @@ -0,0 +1,60 @@ +package com.haitonggauto.rtosc.excel; + +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +@ApiModel("出口装船导出") +@Data +public class ExportLoadExportExcel implements Serializable { + @ApiModelProperty(value = "中文船名") + @ExcelProperty("船名") + private String shipName; + + @ApiModelProperty(value = "航次") + @ExcelProperty("船名") + private String voyage; + + @ApiModelProperty(value = "货物性质名称") + @ExcelProperty("货物性质") + private String natureFlagName; + + @ApiModelProperty(value = "中转进口船名") + @ExcelProperty("中转进口船名") + private String transferShipName; + + @ApiModelProperty(value = "中转进口航次") + @ExcelProperty("中转进口航次") + private String transferVoyage; + + @ApiModelProperty(value = "提单号") + @ExcelProperty("提单号") + private String billNo; + + @ApiModelProperty(value = "品牌") + @ExcelProperty("品牌") + private String brand; + + @ApiModelProperty(value = "目的港") + @ExcelProperty("目的港") + private String destPort; + + @ApiModelProperty(value = "车架号") + @ExcelProperty("车架号") + private String vin; + + @ApiModelProperty(value = "结算单位") + @ExcelProperty("结算单位") + private String settleCompName; + + @ApiModelProperty(value = "联系人") + @ExcelProperty("联系人") + private String contact; + + @ApiModelProperty(value = "联系方式") + @ExcelProperty("联系方式") + private String contactPhone; +} diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportLoadInsideExcel.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportLoadInsideExcel.java index d53b5ab..5717d46 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportLoadInsideExcel.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportLoadInsideExcel.java @@ -12,56 +12,55 @@ import javax.validation.constraints.Size; @DependsOn(field1 = "natureFlagName", fields = {"transferShipName", "transferVoyage"}, message = "货物性质为“正常”时,中转船名,中转航次为空, 否则必填") public class ExportLoadInsideExcel { - @ExcelProperty("*船名") + @ExcelProperty(value = "*船名") @NotBlank(message = "船名不能为空") private String shipName; - @ExcelProperty("*航次") + @ExcelProperty(value = "*航次") @NotBlank(message = "航次不能为空") private String voyage; - @ExcelProperty("*货物性质") + @ExcelProperty(value = "*货物性质") @NotBlank(message = "货物性质不能为空") private String natureFlagName; - @ExcelProperty("中转进口船名") + @ExcelProperty(value = "中转进口船名") private String transferShipName; - @ExcelProperty("中转进口航次") + @ExcelProperty(value = "中转进口航次") private String transferVoyage; - @ExcelProperty("*港区") - @NotBlank(message = "港区不能为空") - private String portArea; +// @ExcelProperty("*港区") +// @NotBlank(message = "港区不能为空") +// private String portArea; - @ExcelProperty("*提单号") + @ExcelProperty(value = "*提单号") @NotBlank(message = "提单号不能为空") private String billNo; - @ExcelProperty("*品牌") + @ExcelProperty(value = "*品牌") @NotBlank(message = "品牌不能为空") private String brand; - @ExcelProperty("*目的港") + @ExcelProperty(value = "*目的港") @NotBlank(message = "目的港不能为空") private String destPort; - @ExcelProperty("*车架号") + @ExcelProperty(value = "*车架号") @NotBlank(message = "车架号不能为空") - @Size(min = 17, max = 17, message = "车架号长度为17位") private String vin; - @ExcelProperty("*结算单位") + @ExcelProperty(value = "*结算单位") @ApiModelProperty(value = "结算单位") @NotBlank(message = "结算单位不能为空") private String settleCompName; - @ExcelProperty("*联系人") + @ExcelProperty(value = "*联系人") @ApiModelProperty(value = "联系人") @NotBlank(message = "联系人不能为空") private String contact; - @ExcelProperty("*联系方式") + @ExcelProperty(value = "*联系方式") @ApiModelProperty(value = "联系方式") @NotBlank(message = "联系方式不能为空") private String contactPhone; diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportLoadSpareExcel.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportLoadSpareExcel.java index 73b8866..c596ffb 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportLoadSpareExcel.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportLoadSpareExcel.java @@ -10,15 +10,15 @@ import javax.validation.constraints.Size; @Data public class ExportLoadSpareExcel { - @ExcelProperty("*船名") + @ExcelProperty(value = "*船名") @NotBlank(message = "船名不能为空") private String shipName; - @ExcelProperty("*航次") + @ExcelProperty(value = "*航次") @NotBlank(message = "航次不能为空") private String voyage; - @ExcelProperty("*提单号") + @ExcelProperty(value = "*提单号") @NotBlank(message = "提单号不能为空") private String billNo; @@ -26,11 +26,11 @@ public class ExportLoadSpareExcel { @NotBlank(message = "目的港不能为空") private String destPort; - @ExcelProperty("*品牌") + @ExcelProperty(value = "*品牌") @NotBlank(message = "品牌不能为空") private String brand; - @ExcelProperty("*数量") + @ExcelProperty(value = "*数量") @NotNull(message = "数量不能为空") private Integer num; diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportVinExcel.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportVinExcel.java index 070e7bd..5085dbe 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportVinExcel.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportVinExcel.java @@ -22,16 +22,15 @@ public class ExportVinExcel { */ @ApiModelProperty(value = "提单号") @NotBlank(message = "提单号不能为空") - @ExcelProperty("*提单号") + @ExcelProperty(value = "*提单号") private String billNo; /** * 船名 */ @NotBlank(message = "车架号不能为空") - @Size(min = 17, max = 17, message = "车架号长度为17位") @ApiModelProperty(value = "车架号") - @ExcelProperty("*车架号") + @ExcelProperty(value = "*车架号") private String vin; } \ No newline at end of file diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/FreeTradeExcel.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/FreeTradeExcel.java index 1180e11..a2dd4cb 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/FreeTradeExcel.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/FreeTradeExcel.java @@ -18,104 +18,125 @@ public class FreeTradeExcel { * 港区 */ @NotBlank(message = "港区不能为空") - @ExcelProperty("*港区") + @ExcelProperty(value = "*港区") @ApiModelProperty(value = "港区") private String portArea; + /** + * 船名 + */ + @ExcelProperty(value = "*船名") + @NotBlank(message = "船名不能为空") + private String shipName; + + /** + * 航次 + */ + @ExcelProperty(value = "*航次") + @NotBlank(message = "航次不能为空") + private String voyage; + // 批次号 @ApiModelProperty(value = "批次号") @NotBlank(message = "批次号不能为空") - @ExcelProperty("批次号") + @ExcelProperty(value = "批次号") private String batchNo; // 企业编码 @ApiModelProperty(value = "企业编码") @NotBlank(message = "企业编码不能为空") - @ExcelProperty("*企业编码") + @ExcelProperty(value = "*企业编码") private String companyCode; // 企业社会信用代码 @ApiModelProperty(value = "企业社会信用代码") @NotBlank(message = "企业社会信用代码不能为空") - @ExcelProperty("*企业社会信用代码") + @ExcelProperty(value = "*企业社会信用代码") private String companySocialCode; // 企业名称 @ApiModelProperty(value = "企业名称") @NotBlank(message = "企业名称不能为空") - @ExcelProperty("*企业名称") + @ExcelProperty(value = "*企业名称") private String companyName; // 企业所在国家 @ApiModelProperty(value = "企业所在国家") @NotBlank(message = "企业所在国家不能为空") - @ExcelProperty("*企业所在国家") + @ExcelProperty(value = "*企业所在国家") private String country; // 企业所在城市 @ApiModelProperty(value = "企业所在城市") @NotBlank(message = "企业所在城市不能为空") - @ExcelProperty("*企业所在城市") + @ExcelProperty(value = "*企业所在城市") private String city; - // 商品料号 + /** + * 商品料号 + */ @ApiModelProperty(value = "商品料号") @NotBlank(message = "商品料号不能为空") - @ExcelProperty("*商品料号") + @ExcelProperty(value = "*商品料号") + private String cargoItemNo; + + // 商品料号 + @ApiModelProperty(value = "商品编码") + @NotBlank(message = "商品编码不能为空") + @ExcelProperty(value = "*商品编码") private String cargoCode; // 商品名称 @ApiModelProperty(value = "商品名称") @NotBlank(message = "商品名称不能为空") - @ExcelProperty("*商品名称") + @ExcelProperty(value = "*商品名称") private String cargoName; // 规格型号 @ApiModelProperty(value = "规格型号") @NotBlank(message = "规格型号不能为空") - @ExcelProperty("*规格型号") + @ExcelProperty(value = "*规格型号") private String spec; // 币制 @ApiModelProperty(value = "币制") @NotBlank(message = "币制不能为空") - @ExcelProperty("*币制") + @ExcelProperty(value = "*币制") private String currency; // 总价 @ApiModelProperty(value = "总价") @NotNull(message = "总价不能为空") - @ExcelProperty("*总价") + @ExcelProperty(value = "*总价") private BigDecimal totalPrice; // 净重 @ApiModelProperty(value = "净重") @NotNull(message = "净重不能为空") - @ExcelProperty("*净重") + @ExcelProperty(value = "*净重") private BigDecimal netWeight; // 申报计量单位 @ApiModelProperty(value = "申报计量单位") @NotBlank(message = "申报计量单位不能为空") - @ExcelProperty("*申报计量单位") + @ExcelProperty(value = "*申报计量单位") private String unitMeasure; // 法定单位 @ApiModelProperty(value = "法定单位") @NotBlank(message = "法定单位不能为空") - @ExcelProperty("*法定单位") + @ExcelProperty(value = "*法定单位") private String unitLegal; // 原产国(地区) @ApiModelProperty(value = "原产国") @NotBlank(message = "原产国不能为空") - @ExcelProperty("*原产国(地区)") + @ExcelProperty(value = "*原产国(地区)") private String originArea; // 车架号 @ApiModelProperty(value = "车架号") @NotBlank(message = "车架号不能为空") - @Size(min = 17, max = 17, message = "车架号长度为17位") - @ExcelProperty("*车架号") + @ExcelProperty(value = "*车架号") private String vin; } diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ImportUnloadExcel.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ImportUnloadExcel.java index 23ac159..9864b4d 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ImportUnloadExcel.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ImportUnloadExcel.java @@ -31,6 +31,5 @@ public class ImportUnloadExcel { @ExcelProperty("*车架号") @NotBlank(message = "车架号不能为空") - @Size(min = 17, max = 17, message = "车架号长度为17位") private String vin; } diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/InspectExcel.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/InspectExcel.java new file mode 100644 index 0000000..440459c --- /dev/null +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/InspectExcel.java @@ -0,0 +1,58 @@ +package com.haitonggauto.rtosc.excel; + +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.util.Date; + +@Data +@ApiModel("查验导入") +public class InspectExcel { + /** + * 港区 + */ + @ExcelProperty(value = "*港区") + @NotBlank(message = "港区不能为空") + private String portArea; + + /** + * 船名 + */ + @ExcelProperty(value = "*船名") + @NotBlank(message = "船名不能为空") + private String shipName; + + @ApiModelProperty(value = "航次") + @ExcelProperty(index = 2) + private String voyage; + + @ExcelProperty(value = "*提单号") + @NotBlank(message = "提单号不能为空") + private String billNo; + + @ApiModelProperty(value = "报关单号") + private String passport; + + @ApiModelProperty(value = "*查验日期") + @NotNull(message = "查验日期不能为空") + private Date inspectTime; + + @ApiModelProperty(value = "公司名") + private String company; + + @ApiModelProperty(value = "*联系人") + @NotBlank(message = "联系人不能为空") + private String contact; + + @ApiModelProperty(value = "*联系电话") + @NotBlank(message = "联系电话不能为空") + private String contactPhone; + + @ApiModelProperty(value = "*车架号/备件号") + @NotBlank(message = "车架号/备件号不能为空") + private String vin; +} diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/CargoQuery.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/CargoQuery.java index 04cbbda..328e61c 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/CargoQuery.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/CargoQuery.java @@ -19,4 +19,11 @@ public class CargoQuery extends BaseQuery { @ApiModelProperty(value = "品牌ID") private String brandId; + + @ApiModelProperty(value = "提单号") + @DbQuery(field = "select id from customer_export_load where export_load_id=customer_export_load.id and bill_no like {0}", symbol = SqlSymbol.EXISTS) + private String billNum; + + @ApiModelProperty(value = "是否填充车辆状态") + private Boolean vinStatus; } diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/CargoVinQuery.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/CargoVinQuery.java new file mode 100644 index 0000000..4a049c5 --- /dev/null +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/CargoVinQuery.java @@ -0,0 +1,16 @@ +package com.haitonggauto.rtosc.query; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + + +@Data +@ApiModel(value = "货物明细查询") +public class CargoVinQuery { + @ApiModelProperty(value = "车架号") + private String vin; + + @ApiModelProperty("提单号") + private String billNum; +} diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/DepartureQuery.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/DepartureQuery.java index fd12d82..568e9f0 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/DepartureQuery.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/DepartureQuery.java @@ -74,6 +74,22 @@ public class DepartureQuery extends BaseQuery { @ApiModelProperty(value = "港区ID") private String portAreaId; + @ApiModelProperty(value = "提单号") + @DbQuery(field = "select id from customer_departure_cargo where departure_id=customer_departure.id and bill_no like {0}", symbol = SqlSymbol.EXISTS) + private String billNum; + + @ApiModelProperty(value = "精确提单号") + @DbQuery(field = "select id from customer_departure_cargo where departure_id=customer_departure.id and bill_no={0}", symbol = SqlSymbol.EXISTS) + private String billNumAccurate; + + @ApiModelProperty(value = "品牌ID") +// @DbQuery(field = "select id from customer_departure_cargo where departure_id=customer_departure.id and brand_id={0}", symbol = SqlSymbol.EXISTS) + private String brandId; + + @ApiModelProperty(value = "车架号") + @DbQuery(field = "select id from customer_departure_cargo where departure_id=customer_departure.id and vin like {0}", symbol = SqlSymbol.EXISTS) + private String vin; + @ApiModelProperty(value = "港区ID集合") @DbQuery(field = "portAreaId", symbol = SqlSymbol.IN) private List pamIds; diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInBathCheckQuery.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInBathCheckQuery.java new file mode 100644 index 0000000..b53bf5d --- /dev/null +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInBathCheckQuery.java @@ -0,0 +1,28 @@ +package com.haitonggauto.rtosc.query; + +import com.haitonggauto.rtosc.common.db.query.BaseQuery; +import com.haitonggauto.rtosc.repository.enums.AuditEnum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +@ApiModel(value = "出口进港查询") +public class ExportInBathCheckQuery extends BaseQuery { + + @ApiModelProperty(value = "船ID") + private String shipId; + + @ApiModelProperty(value = "航次ID") + private String voyageId; + + @ApiModelProperty(value = "港区ID") + private String portAreaId; + + @ApiModelProperty(value = "审核状态") + @NotNull(message = "审核状态不能为空") + private AuditEnum checkStatus; + +} diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInCheckQuery.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInCheckQuery.java index dd78093..e0f319e 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInCheckQuery.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInCheckQuery.java @@ -56,12 +56,12 @@ public class ExportInCheckQuery extends BaseQuery { @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @ApiModelProperty(value = "开始进场时间") - @DbQuery(field = "beginEnterTime", symbol = SqlSymbol.GTE) + @DbQuery(field = "beginEnterTime", symbol = SqlSymbol.LTE) private Date beginEnterTime; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @ApiModelProperty(value = "结束进场时间") - @DbQuery(field = "endEnterTime", symbol = SqlSymbol.LTE) + @DbQuery(field = "endEnterTime", symbol = SqlSymbol.GTE) private Date endEnterTime; @ApiModelProperty(value = "贸易类型") @@ -90,6 +90,10 @@ public class ExportInCheckQuery extends BaseQuery { @DbQuery(symbol = SqlSymbol.LIKE) private String billNum; + @ApiModelProperty(value = "精确提单号") + @DbQuery(field = "billNum") + private String billNumAccurate; + @ApiModelProperty(value = "受理号") @DbQuery(symbol = SqlSymbol.LIKE) private String batchNo; @@ -101,6 +105,7 @@ public class ExportInCheckQuery extends BaseQuery { private String freightId; @ApiModelProperty(value = "车架号") + @DbQuery(field = "select id from customer_export_in_cargo where export_in_id=customer_export_in.id and vin like {0}", symbol = SqlSymbol.EXISTS) private String vin; @ApiModelProperty(value = "国家Id") @@ -109,12 +114,18 @@ public class ExportInCheckQuery extends BaseQuery { @ApiModelProperty(value = "港口ID") private String portId; - @ApiModelProperty(hidden = true) - @DbQuery(field = "vin", symbol = SqlSymbol.IN) - private List vins; + @ApiModelProperty(value = "联系人") + @DbQuery(symbol = SqlSymbol.LIKE) + private String contact; // 明细表查询时会用到 @ApiModelProperty(hidden = true) private Long exportInId; + @ApiModelProperty(value = "是否加载车架号列表") + private Boolean vinStatus; + + @ApiModelProperty(value = "是否调用车架号状态接口") + private Boolean vinStatusApi; + } diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInQuery.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInQuery.java index d8b4861..b0d2a1e 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInQuery.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInQuery.java @@ -66,6 +66,10 @@ public class ExportInQuery extends BaseQuery { @DbQuery(symbol = SqlSymbol.LIKE) private String billNum; + @ApiModelProperty(value = "精确提单号") + @DbQuery(field = "billNum") + private String billNumAccurate; + @ApiModelProperty(value = "受理号") @DbQuery(symbol = SqlSymbol.LIKE) private String batchNo; @@ -82,9 +86,13 @@ public class ExportInQuery extends BaseQuery { @ApiModelProperty(value = "货代ID") private String freightId; - @ApiModelProperty(hidden = true) - @DbQuery(field = "vin", symbol = SqlSymbol.IN) - private List vins; + @ApiModelProperty(value = "联系人") + @DbQuery(symbol = SqlSymbol.LIKE) + private String contact; + + @ApiModelProperty(value = "车架号") + @DbQuery(field = "select id from customer_export_in_cargo where export_in_id=customer_export_in.id and vin like {0}", symbol = SqlSymbol.EXISTS) + private String vin; // 明细表查询时会用到 @ApiModelProperty(hidden = true) diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInspectCheckQuery.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInspectCheckQuery.java index 9c68441..941df1c 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInspectCheckQuery.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInspectCheckQuery.java @@ -1,5 +1,6 @@ package com.haitonggauto.rtosc.query; +import com.fasterxml.jackson.annotation.JsonFormat; import com.haitonggauto.rtosc.common.db.anno.DbQuery; import com.haitonggauto.rtosc.common.db.enums.SqlSymbol; import com.haitonggauto.rtosc.common.db.query.BaseQuery; @@ -7,7 +8,9 @@ import com.haitonggauto.rtosc.repository.enums.AuditEnum; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; +import java.util.Date; import java.util.List; @Data @@ -24,6 +27,9 @@ public class ExportInspectCheckQuery extends BaseQuery { @ApiModelProperty(value = "航次ID") private String voyageId; + @ApiModelProperty(value = "申请对象ID") + private String applyObjId; + @ApiModelProperty(value = "航次") private String voyage; @@ -45,6 +51,38 @@ public class ExportInspectCheckQuery extends BaseQuery { @DbQuery(symbol = SqlSymbol.LIKE) private String batchNo; + @ApiModelProperty(value = "报关单号") + @DbQuery(symbol = SqlSymbol.LIKE) + private String passport; + + @ApiModelProperty(value = "提单号") + @DbQuery(field = "billNo", symbol = SqlSymbol.LIKE) + private String billNum; + + @ApiModelProperty(value = "精确提单号") + @DbQuery(field = "billNo") + private String billNumAccurate; + + @ApiModelProperty(value = "品牌ID") + @DbQuery(field = "select id from customer_export_inspect_cargo where export_inspect_id=customer_export_inspect.id and brand_id={0}", symbol = SqlSymbol.EXISTS) + private String brandId; + + @ApiModelProperty(value = "车架号") + @DbQuery(field = "select id from customer_export_inspect_cargo where export_inspect_id=customer_export_inspect.id and vin like {0}", symbol = SqlSymbol.EXISTS) + private String vin; + + @ApiModelProperty(value = "开始查验日期") + @JsonFormat(pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") + @DbQuery(field = "inspectTime", symbol = SqlSymbol.GTE) + private Date beginInspectTime; + + @ApiModelProperty(value = "结束查验日期") + @JsonFormat(pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") + @DbQuery(field = "inspectTime", symbol = SqlSymbol.LTE) + private Date endInspectTime; + @ApiModelProperty(hidden = true) private String tradType; diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInspectQuery.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInspectQuery.java index add28f9..642770d 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInspectQuery.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInspectQuery.java @@ -1,5 +1,6 @@ package com.haitonggauto.rtosc.query; +import com.fasterxml.jackson.annotation.JsonFormat; import com.haitonggauto.rtosc.common.db.anno.DbQuery; import com.haitonggauto.rtosc.common.db.enums.SqlSymbol; import com.haitonggauto.rtosc.common.db.query.BaseQuery; @@ -8,6 +9,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.Date; import java.util.List; @Data @@ -20,6 +22,9 @@ public class ExportInspectQuery extends BaseQuery { @ApiModelProperty(value = "航次ID") private String voyageId; + @ApiModelProperty(value = "申请对象ID") + private String applyObjId; + @ApiModelProperty(value = "船名") @DbQuery(symbol = SqlSymbol.LIKE) private String shipName; @@ -42,6 +47,36 @@ public class ExportInspectQuery extends BaseQuery { @DbQuery(symbol = SqlSymbol.LIKE) private String batchNo; + @ApiModelProperty(value = "报关单号") + @DbQuery(symbol = SqlSymbol.LIKE) + private String passport; + + @ApiModelProperty(value = "提单号") + @DbQuery(field = "billNo", symbol = SqlSymbol.LIKE) + private String billNum; + + @ApiModelProperty(value = "精确提单号") + @DbQuery(field = "billNo") + private String billNumAccurate; + + @ApiModelProperty(value = "品牌ID") + @DbQuery(field = "select id from customer_export_inspect_cargo where export_inspect_id=customer_export_inspect.id and brand_id={0}", symbol = SqlSymbol.EXISTS) + private String brandId; + + @ApiModelProperty(value = "车架号") + @DbQuery(field = "select id from customer_export_inspect_cargo where export_inspect_id=customer_export_inspect.id and vin like {0}", symbol = SqlSymbol.EXISTS) + private String vin; + + @ApiModelProperty(value = "开始查验日期") + @JsonFormat(pattern = "yyyy-MM-dd") + @DbQuery(field = "inspectTime", symbol = SqlSymbol.GTE) + private Date beginInspectTime; + + @ApiModelProperty(value = "结束查验日期") + @JsonFormat(pattern = "yyyy-MM-dd") + @DbQuery(field = "inspectTime", symbol = SqlSymbol.LTE) + private Date endInspectTime; + @ApiModelProperty(hidden = true) private String tradType; diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportLoadCheckQuery.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportLoadCheckQuery.java index ef8f0cf..dff0f96 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportLoadCheckQuery.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportLoadCheckQuery.java @@ -54,6 +54,13 @@ public class ExportLoadCheckQuery extends BaseQuery { @ApiModelProperty(hidden = true) private Long exportLoadId; + @DbQuery(field = "billNo", symbol = SqlSymbol.IN) + private List billNos; + + @ApiModelProperty(value = "车架号") + @DbQuery(field = "select id from customer_export_load_cargo where export_load_id=customer_export_load.id and vin like {0}", symbol = SqlSymbol.EXISTS) + private String vin; + @ApiModelProperty(hidden = true) @DbQuery(field = "vin", symbol = SqlSymbol.IN) private List vins; diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportLoadQuery.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportLoadQuery.java index e15f78d..fa15235 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportLoadQuery.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportLoadQuery.java @@ -51,6 +51,10 @@ public class ExportLoadQuery extends BaseQuery { @ApiModelProperty(hidden = true) private Long exportLoadId; + @ApiModelProperty(value = "车架号") + @DbQuery(field = "select id from customer_export_load_cargo where export_load_id=customer_export_load.id and vin like {0}", symbol = SqlSymbol.EXISTS) + private String vin; + @ApiModelProperty(hidden = true) @DbQuery(field = "vin", symbol = SqlSymbol.IN) private List vins; diff --git a/nuzar-customer-common/src/main/java/com/haitonggauto/rtosc/common/dto/LoginUser.java b/nuzar-customer-common/src/main/java/com/haitonggauto/rtosc/common/dto/LoginUser.java index a749f13..2ec9546 100644 --- a/nuzar-customer-common/src/main/java/com/haitonggauto/rtosc/common/dto/LoginUser.java +++ b/nuzar-customer-common/src/main/java/com/haitonggauto/rtosc/common/dto/LoginUser.java @@ -11,6 +11,9 @@ public class LoginUser implements Serializable { // 用户ID private String userId; + // 用户名 + private String username; + // 角色ID private Long roleId; @@ -57,4 +60,12 @@ public class LoginUser implements Serializable { public void setPermList(Set permList) { this.permList = permList; } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } } diff --git a/nuzar-customer-common/src/main/java/com/haitonggauto/rtosc/common/utils/WrapperKit.java b/nuzar-customer-common/src/main/java/com/haitonggauto/rtosc/common/utils/WrapperKit.java index d74cadc..2afec3c 100644 --- a/nuzar-customer-common/src/main/java/com/haitonggauto/rtosc/common/utils/WrapperKit.java +++ b/nuzar-customer-common/src/main/java/com/haitonggauto/rtosc/common/utils/WrapperKit.java @@ -189,12 +189,18 @@ public interface WrapperKit { return; } - if (!fieldMetadataMap.containsKey(fName)) { + if (symbol != SqlSymbol.EXISTS && symbol != SqlSymbol.NOT_EXISTS && symbol != SqlSymbol.EXPRESSION && !fieldMetadataMap.containsKey(fName)) { throw new FieldNotExistsException(String.format("类:%s, 不存在属性: %s" , classMetadata.getClazz().getName(), fName)); } - String column = fieldMetadataMap.get(fName).getColumn(); - if (StringUtils.isNotEmpty(alias)) { - column = alias + "." + column; + String column = null; + + if (symbol == SqlSymbol.EXISTS || symbol == SqlSymbol.NOT_EXISTS || symbol == SqlSymbol.EXPRESSION) { + column = fName; + } else { + column = fieldMetadataMap.get(fName).getColumn(); + if (StringUtils.isNotEmpty(alias)) { + column = alias + "." + column; + } } if (symbol == SqlSymbol.IN) { @@ -212,9 +218,9 @@ public interface WrapperKit { } else if (symbol.equals(SqlSymbol.RLIKE)) { queryWrapper.likeRight(column, fValue); } else if (symbol.equals(SqlSymbol.EXISTS)) { - queryWrapper.exists(column, fValue); + queryWrapper.exists(column, StringUtils.containsIgnoreCase(column, " like ") ? "%" + fValue + "%" : fValue); } else if (symbol.equals(SqlSymbol.NOT_EXISTS)) { - queryWrapper.notExists(column, fValue); + queryWrapper.notExists(column, StringUtils.containsIgnoreCase(column, " like ") ? "%" + fValue + "%" : fValue); } else if (symbol.equals(SqlSymbol.GTE)) { queryWrapper.ge(column, fValue); } else if (symbol.equals(SqlSymbol.GT)) { diff --git a/nuzar-customer-common/src/main/java/com/haitonggauto/rtosc/common/validate/DependsOnValidator.java b/nuzar-customer-common/src/main/java/com/haitonggauto/rtosc/common/validate/DependsOnValidator.java index 0b45f8b..8e0b6ad 100644 --- a/nuzar-customer-common/src/main/java/com/haitonggauto/rtosc/common/validate/DependsOnValidator.java +++ b/nuzar-customer-common/src/main/java/com/haitonggauto/rtosc/common/validate/DependsOnValidator.java @@ -39,7 +39,7 @@ public class DependsOnValidator implements ConstraintValidator haveShipPlan(@RequestParam("vvyId") String vvyId); + @PostMapping("/customer/shipment/shipLoad/getShipPlans") + Map> haveShipPlans(@RequestBody CheckShipPlanReq req); + // 装船审核获取国际中转备件 @PostMapping("/customer/shipment/shipLoad/transitPart") Map> getTransitPart(@RequestBody TransitPartRequest request); @@ -140,4 +145,23 @@ public interface NuzarOpenApi { // 获取绑定货代 @GetMapping("/rtos/user/getFreightId") List getUserBindFreight(); + + @PostMapping("/customer/shipment/queryTrendShips") + List getTrendShipList(@RequestBody List shipNames); + + @PostMapping("/customer/yard/batchConfirmRevise") + Boolean batchConfirmRevise(UpdateVoyageVo req); + + @PostMapping("/customer/yard/getCarPickTime") + Map getCarPickTime(@RequestBody List vinCodes); + + @GetMapping("/rtos/user/searchUser") + UserInfoDto getUserInfo(); + + // 提离港区车架号验证 + @PostMapping("/customer/pickDeparture/vinCheckInfo") + List vinCheckInfo(@RequestBody VinCheckReq req); + + @PostMapping("/customer/yard/batchConfirmReview") + Boolean batchConfirmReview(@RequestBody BatchConfirmReviewReq req); } diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarShpApi.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarShpApi.java index 19b7001..54b656c 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarShpApi.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarShpApi.java @@ -1,9 +1,6 @@ package com.haitonggauto.rtosc.api; -import com.haitonggauto.rtosc.api.dto.CheckVinReq; -import com.haitonggauto.rtosc.api.dto.VoyageDTO; -import com.haitonggauto.rtosc.api.dto.VoyageReq; -import com.haitonggauto.rtosc.api.dto.VoyageResp; +import com.haitonggauto.rtosc.api.dto.*; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -32,4 +29,15 @@ public interface NuzarShpApi { @PostMapping("/vesselVoyages/shipNameFilter") List checkShipStatus(@RequestBody List req); + + @PostMapping("/shipment/unload/plans/unloadInfoVerify") + List unloadInfoVerify(@RequestBody List req); + + /** + * 离泊状态 + * @param vvyIds + * @return + */ + @PostMapping("/vesselVoyages/queryBerthsStatusByVvyIds") + List queryVoyagesBerthsStatusByVvyIds(@RequestBody List vvyIds); } diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/BatchConfirmReviewReq.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/BatchConfirmReviewReq.java new file mode 100644 index 0000000..91a70ad --- /dev/null +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/BatchConfirmReviewReq.java @@ -0,0 +1,27 @@ +package com.haitonggauto.rtosc.api.dto; + +import io.swagger.annotations.ApiModel; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +@ApiModel("审核后批量修对对应航次") +public class BatchConfirmReviewReq implements Serializable { + private List billNos; + + private List ids; + + private List mnfBls; + + private String shipId; + + private String shipName; + + private String voyage; + + private String voyageId; + + private String vvyId; +} diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/CheckShipPlanReq.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/CheckShipPlanReq.java new file mode 100644 index 0000000..a71fe4a --- /dev/null +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/CheckShipPlanReq.java @@ -0,0 +1,16 @@ +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 CheckShipPlanReq implements Serializable { + @ApiModelProperty("航次ID") + private List vvyIds; +} diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/CheckVinReq.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/CheckVinReq.java index 1f2093b..e54efef 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/CheckVinReq.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/CheckVinReq.java @@ -19,4 +19,7 @@ public class CheckVinReq implements Serializable { @ApiModelProperty("车架号") private String vinCode; + + @ApiModelProperty("航次ID") + private String vvyId; } diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/ImportInspectReq.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/ImportInspectReq.java new file mode 100644 index 0000000..12a9733 --- /dev/null +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/ImportInspectReq.java @@ -0,0 +1,31 @@ +package com.haitonggauto.rtosc.api.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +@Data +@ApiModel("进口查验检验请求") +public class ImportInspectReq implements Serializable { + @ApiModelProperty("提单号") + private String mnfBl; + + @ApiModelProperty("船ID") + private String spmId; + + @ApiModelProperty("船名") + private String spmName; + + @ApiModelProperty("车架号") + private String vinCode; + + @ApiModelProperty("航次ID") + private String vvyId; + + @ApiModelProperty("船次") + private String vvyName; + + +} diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/ImportInspectResp.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/ImportInspectResp.java new file mode 100644 index 0000000..3a76a9c --- /dev/null +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/ImportInspectResp.java @@ -0,0 +1,55 @@ +package com.haitonggauto.rtosc.api.dto; + +import io.swagger.annotations.ApiModel; +import lombok.Data; + +import java.io.Serializable; + +@Data +@ApiModel("进口查验返回") +public class ImportInspectResp implements Serializable { + private String errorMsg; + + private String mnfBl; + + private String spmName; + + private String vinCode; + + private String vvyName; + + private YardGoodsDTO yardGoodsDTO; + + @Data + public static class YardGoodsDTO implements Serializable { + private String brdId; + + private String brdName; + + private String bvmName; + + private String goodsType; + + private String model; + + private String position; + + private String spmId; + + private String storeArea; + + private String vvyId; + + private String yacId; + + private String yalId; + + private String yarId; + + private String yardId; + + private String pamId; + + private String pamName; + } +} diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/ShipmentBerthsStatusRespDTO.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/ShipmentBerthsStatusRespDTO.java new file mode 100644 index 0000000..6dd57d8 --- /dev/null +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/ShipmentBerthsStatusRespDTO.java @@ -0,0 +1,23 @@ +package com.haitonggauto.rtosc.api.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author zhaoyusheng + * @version 1.0.0 + * @classname ShipmentBerthsStatusRespDTO + * @date 2024/7/23 + * @time 13:13 + * @description 航次泊位状态 + */ +@Data +public class ShipmentBerthsStatusRespDTO implements Serializable { + private static final long serialVersionUID = 1566352212034798745L; + @ApiModelProperty(value = "航次id") + private String vvyId; + @ApiModelProperty(value = "是否离泊:0否 1是") + private String unberthedStatus; +} diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/TrendShipResp.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/TrendShipResp.java new file mode 100644 index 0000000..e8c1bf3 --- /dev/null +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/TrendShipResp.java @@ -0,0 +1,26 @@ +package com.haitonggauto.rtosc.api.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +@Data +@ApiModel("旬度计划船名") +public class TrendShipResp { + @ApiModelProperty("船舶id") + private String spmId; + + @ApiModelProperty("船名") + private String spmName; + + @ApiModelProperty("船code") + private String vslCode; + + @ApiModelProperty("预计到港时间") + private Date planArrivePortTime; + + @ApiModelProperty("英文名") + private String spmEname; +} diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/UserInfoDto.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/UserInfoDto.java new file mode 100644 index 0000000..e4e3e16 --- /dev/null +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/UserInfoDto.java @@ -0,0 +1,94 @@ +package com.haitonggauto.rtosc.api.dto; + +import com.fasterxml.jackson.annotation.JsonAlias; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * @author wangzhengyan + * @Date 2023/5/5 0005 13:55 + */ +@Data +public class UserInfoDto implements Serializable { + private static final long serialVersionUID = -2463058823324072492L; + + @ApiModelProperty(value = "用户id") + private String id; + + @ApiModelProperty(value = "客户姓名") + private String name; + + @ApiModelProperty(value = "登录账号") + private String account; + + @ApiModelProperty(value = "联系人") + @JsonAlias("memo") + private String contactPerson; + + @ApiModelProperty(value = "邮箱") + private String email; + + @ApiModelProperty(value = "客户地址") + private String address; + + @ApiModelProperty(value = "创建时间") + protected Date createTime; + + @ApiModelProperty(value = "创建人") + protected String createUser; + + @ApiModelProperty(value = "更新时间") + protected String updateUser; + + @ApiModelProperty(value = "更新人") + protected Date updateTime; + + @ApiModelProperty(value = "登录时间") + private String loginTime; + + @ApiModelProperty(value = "是否启用") + private String enabled; + + + @ApiModelProperty(value = "手机号") + private String phone; + + + @ApiModelProperty(value = "头像地址") + private String uploadUrl; + + @ApiModelProperty(value = "身份证号") + private String idCard; + +// @ApiModelProperty(value = "手机号群组") +// private List phones; + + + /** + * 货代Id + */ + @ApiModelProperty(value = "货代ID") + private String freightId; + + /** + * 货代Id + */ + @ApiModelProperty(value = "货代类型") + private String freightType; + + /** + * 用户角色id + */ + @ApiModelProperty(value = "用户角色id") + private List roleIds; + + @ApiModelProperty(value = "货代类型") + private String med; + + private String mediaType; + +} diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/VinCheckReq.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/VinCheckReq.java new file mode 100644 index 0000000..b6cc2f2 --- /dev/null +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/VinCheckReq.java @@ -0,0 +1,27 @@ +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 VinCheckReq implements Serializable { + @ApiModelProperty("品牌ID") + private String brdId; + + @ApiModelProperty("港区ID") + private String pamId; + + @ApiModelProperty("船舶ID") + private String spmId; + + @ApiModelProperty("航次ID") + private String vvyId; + + @ApiModelProperty("车架号列表") + private List vinCodeList; +} diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/VinCheckResp.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/VinCheckResp.java new file mode 100644 index 0000000..a7061ef --- /dev/null +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/VinCheckResp.java @@ -0,0 +1,20 @@ +package com.haitonggauto.rtosc.api.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +@Data +@ApiModel("提离港区车架号验证") +public class VinCheckResp implements Serializable { + @ApiModelProperty("是否退关扫描") + private Boolean hasShutoutScan; + + @ApiModelProperty("是否无计划收车") + private Boolean noPlanCollect; + + @ApiModelProperty("车架号") + private String vinCode; +} diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/VoyageResp.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/VoyageResp.java index 9479227..eddc57d 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/VoyageResp.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/VoyageResp.java @@ -16,6 +16,9 @@ public class VoyageResp { @ApiModelProperty("船舶id") private String spmId; + @ApiModelProperty("港区ID") + private String pamId; + @ApiModelProperty("内贸/外贸/内外贸") private String tradeType; diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/config/InterceptorConfiguration.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/config/InterceptorConfiguration.java index 5522972..b9b2d8e 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/config/InterceptorConfiguration.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/config/InterceptorConfiguration.java @@ -2,7 +2,11 @@ package com.haitonggauto.rtosc.config; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; +import com.haitonggauto.rtosc.api.NuzarOpenApi; +import com.nuzar.rtops.log.service.SpringApplicationContextHolder; +import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -11,6 +15,7 @@ import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import javax.annotation.PostConstruct; +import javax.annotation.Resource; /** * 拦截器的属性配置 @@ -34,12 +39,15 @@ public class InterceptorConfiguration implements WebMvcConfigurer { * @return */ @Bean - public PermInterceptor permInterceptor() { return new PermInterceptor(); } + public PermInterceptor permInterceptor() { + return new PermInterceptor(); + } @Override + @ConditionalOnBean(PermInterceptor.class) public void addInterceptors(InterceptorRegistry registry) { // 拦截器 - InterceptorRegistration registration = registry.addInterceptor(this.permInterceptor()); + InterceptorRegistration registration = registry.addInterceptor(permInterceptor()); } } \ No newline at end of file diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/config/PermInterceptor.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/config/PermInterceptor.java index dd83361..7332240 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/config/PermInterceptor.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/config/PermInterceptor.java @@ -1,15 +1,13 @@ package com.haitonggauto.rtosc.config; +import com.haitonggauto.rtosc.api.NuzarOpenApi; +import com.haitonggauto.rtosc.api.dto.UserInfoDto; import com.haitonggauto.rtosc.common.context.UserContext; import com.haitonggauto.rtosc.common.dto.LoginUser; -import com.haitonggauto.rtosc.common.exception.NoLoginException; -import com.haitonggauto.rtosc.common.exception.NoPermException; -import com.haitonggauto.rtosc.common.handler.anno.HandlerMethod; -import com.haitonggauto.rtosc.common.service.AuthService; -import com.haitonggauto.rtosc.common.utils.MethodInterceptorUtils; -import com.nuzar.common.security5.common.util.SecurityUtils; import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.BeanFactory; +import org.springframework.util.AntPathMatcher; +import org.springframework.web.context.support.WebApplicationContextUtils; import org.springframework.web.servlet.HandlerInterceptor; import javax.servlet.http.HttpServletRequest; @@ -19,23 +17,51 @@ import javax.servlet.http.HttpServletResponse; * 权限过滤器 */ public class PermInterceptor implements HandlerInterceptor { + public static final String[] SWAGGER_EXCLUDE_PATHS = {"/doc.html", "/swagger-resources/**", "/webjars/**", "/v2/**", "/favicon.ico", "/swagger-ui.htmL/**", "/health/ping"}; @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { - //判断是否登录 - String userId = ""; - try { - userId = SecurityUtils.getUserId(); - } catch (Exception e) { -// e.printStackTrace(); - userId = "0"; + String uri = request.getRequestURI(); + AntPathMatcher antPathMatcher = new AntPathMatcher(); + for (String p : SWAGGER_EXCLUDE_PATHS) { + if (antPathMatcher.match(p, uri)) { + return true; + } } - System.err.println(userId); + //判断是否登录 + String userId = ""; + String username = ""; + try { +// userId = SecurityUtils.getUserId(); + + BeanFactory factory = WebApplicationContextUtils.getRequiredWebApplicationContext(request.getServletContext()); + NuzarOpenApi openApi = factory.getBean(NuzarOpenApi.class); + + UserInfoDto info = openApi.getUserInfo(); + + userId = info.getId(); + username = info.getName(); + + if (StringUtils.equalsIgnoreCase(info.getMediaType(), "MINIAPP") && !StringUtils.equalsAny(request.getRequestURI(), "/dd/ship/all" + , "/ee/plan/ship", "/dd/port", "/ee/plan/port", "/dd/brand", "/ee/voyage/brand", "/it/shipVoyage", "/spz/valid-vins")) { + response.setStatus(HttpServletResponse.SC_FORBIDDEN); + // 可以设置响应体 + response.getWriter().write("Access Forbidden"); + return false; + } + } catch (Exception e) { + throw new RuntimeException(e); +// response.setStatus(HttpServletResponse.SC_FORBIDDEN); +// // 可以设置响应体 +// response.getWriter().write("Access Forbidden"); +// return false; + } LoginUser tmpUser = new LoginUser(); tmpUser.setUserId(userId); tmpUser.setRoleId(0L); + tmpUser.setUsername(username); tmpUser.setAdmin(true); UserContext.setUser(tmpUser); diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/DepartureHandler.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/DepartureHandler.java index d9605f3..ab4466e 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/DepartureHandler.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/DepartureHandler.java @@ -4,9 +4,11 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DateUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.exception.ExcelDataConvertException; import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.excel.write.metadata.fill.FillConfig; import com.alibaba.excel.write.metadata.fill.FillWrapper; +import com.alibaba.fastjson2.JSON; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -22,16 +24,14 @@ import com.haitonggauto.rtosc.common.enums.ErrorType; import com.haitonggauto.rtosc.common.handler.BaseHandler; import com.haitonggauto.rtosc.common.utils.*; import com.haitonggauto.rtosc.dto.*; +import com.haitonggauto.rtosc.excel.DepartureImportExcel; +import com.haitonggauto.rtosc.handler.excel.ReadExcelListener; import com.haitonggauto.rtosc.query.CargoQuery; import com.haitonggauto.rtosc.query.DepartureQuery; -import com.haitonggauto.rtosc.query.ExportInCheckQuery; import com.haitonggauto.rtosc.repository.entity.*; import com.haitonggauto.rtosc.handler.mapper.PoMapper; import com.haitonggauto.rtosc.repository.enums.AuditEnum; -import com.haitonggauto.rtosc.repository.service.CustomerDepartureCargoService; -import com.haitonggauto.rtosc.repository.service.CustomerDepartureDriversService; -import com.haitonggauto.rtosc.repository.service.CustomerDeparturePlanService; -import com.haitonggauto.rtosc.repository.service.CustomerDepartureService; +import com.haitonggauto.rtosc.repository.service.*; import com.haitonggauto.rtosc.service.CustomerService; import com.itextpdf.forms.PdfAcroForm; import com.itextpdf.forms.fields.PdfFormField; @@ -51,11 +51,12 @@ import com.itextpdf.layout.layout.LayoutArea; import com.itextpdf.layout.layout.LayoutResult; import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.layout.renderer.DocumentRenderer; -import com.nuzar.common.security5.common.util.SecurityUtils; import com.nuzar.rtops.log.dto.LogRecordDTO; import com.nuzar.rtops.log.service.EsLogApprovalUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -65,15 +66,18 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; +import java.io.*; import java.net.URLEncoder; import java.util.*; import java.util.stream.Collectors; @@ -82,6 +86,7 @@ import java.util.stream.Collectors; @RestController @RequestMapping("/ep") @Validated +@Slf4j public class DepartureHandler implements BaseHandler { @Resource @@ -99,6 +104,12 @@ public class DepartureHandler implements BaseHandler { @Resource private CustomerDeparturePlanService departurePlanService; + @Resource + private CustomerExportInCargoService exportInCargoService; + + @Resource + private CustomerExportInService exportInService; + @Resource private NuzarOpenApi openApi; @@ -217,6 +228,32 @@ public class DepartureHandler implements BaseHandler { return ResultUtil.success(rst, String.valueOf(page.getTotal())); } + @ApiOperation("提单号模糊匹配") + @PostMapping("/billNo/query") + public Result> getExportInBillNoList( + @ApiParam(name = "操作方式, 0为前端,1为审核端") @RequestParam(required = false, defaultValue = "0") String type, + @RequestParam(required = false, defaultValue = "1") Integer current, + @RequestParam(required = false, defaultValue = "10") Integer size, + @RequestParam(required = false) String shipId, + @RequestParam(required = false) String voyageId, + @RequestParam(required = false) String q) { + QueryWrapper query = new QueryWrapper<>(); + query.select("distinct bill_no"); + query.eq(StringUtils.equals(type, "0"), "create_by", UserContext.getUser().getUserId()); + query.exists(StringUtils.isNotEmpty(shipId), "select id from customer_departure where departure_id=customer_departure.id and ship_id={0}", shipId); + query.exists(StringUtils.isNotEmpty(voyageId), "select id from customer_departure where departure_id=customer_departure.id and voyage_id={0}", shipId); +// query.eq("create_by", UserContext.getUser().getUserId()); + query.like(StringUtils.isNotEmpty(q), "bill_no", q); + + Page page = departureCargoService.page(new Page<>(current, size), query); + List list = page.getRecords(); + + List rst = list.stream().map(tmp -> tmp.getBillNo()).collect(Collectors.toList()); + + + return ResultUtil.success(rst, String.valueOf(page.getTotal())); + } + /** * 分页查询 * @param query @@ -324,6 +361,10 @@ public class DepartureHandler implements BaseHandler { return entity; }).collect(Collectors.toList()); + departure.setQuantity(cargos.size()); + departure.setSpareQuantity((int)cargos.stream().filter(s -> StringUtils.startsWith(s.getVin(), "BJ")).count()); + departure.setCarQuantity(departure.getQuantity() - departure.getSpareQuantity()); + List drivers = form.getDrivers().stream().map(item -> { CustomerDepartureDrivers entity = PoMapper.instance.departureDriverVo2Entity(item); entity.setTermcd(departure.getPortAreaId()); @@ -336,6 +377,11 @@ public class DepartureHandler implements BaseHandler { return entity; }).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(plans)) { + String collect = plans.stream().filter(s -> StringUtils.isNotEmpty(s.getMachine())).map(s -> s.getMachine()).collect(Collectors.joining(",")); + departure.setWorkStatus(collect); + } + Long id = customerService.saveDeparture(departure, cargos, drivers, plans); return ResultUtil.success(String.valueOf(id)); @@ -352,7 +398,7 @@ public class DepartureHandler implements BaseHandler { .in("vin", vo.getVins()) .exists("select id from customer_departure where customer_departure.id=customer_departure_cargo.departure_id and customer_departure.voyage_id={0}", vo.getVoyageId()) .groupBy("vin") - .having("count(quantity) > 1") + .having("count(*) > 1") .list(); rst.put(vo.getVoyageId(), cargos.stream().map(item -> item.getVin()).collect(Collectors.toList())); } @@ -366,7 +412,7 @@ public class DepartureHandler implements BaseHandler { .select("count(*) as quantity, vin") .in("vin", vins) .groupBy("vin") - .having("count(quantity) > 0") + .having("count(*) > 0") .list(); return ResultUtil.success(cargos.stream().map(item -> item.getVin()).collect(Collectors.toList())); } @@ -475,6 +521,10 @@ public class DepartureHandler implements BaseHandler { return entity; }).collect(Collectors.toList()); + departure.setQuantity(cargos.size()); + departure.setSpareQuantity((int)cargos.stream().filter(s -> StringUtils.startsWith(s.getVin(), "BJ")).count()); + departure.setCarQuantity(departure.getQuantity() - departure.getSpareQuantity()); + List drivers = form.getDrivers().stream().map(item -> { CustomerDepartureDrivers entity = PoMapper.instance.departureDriverVo2Entity(item); entity.setTermcd(departure.getPortAreaId()); @@ -487,6 +537,11 @@ public class DepartureHandler implements BaseHandler { return entity; }).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(plans)) { + String collect = plans.stream().filter(s -> StringUtils.isNotEmpty(s.getMachine())).map(s -> s.getMachine()).collect(Collectors.joining(",")); + departure.setWorkStatus(collect); + } + customerService.updateDeparture(false, departure, cargos, drivers, plans); return ResultUtil.success(String.valueOf(departure.getId())); @@ -572,6 +627,16 @@ public class DepartureHandler implements BaseHandler { customerService.wrapperEntity(cargos); + // 获取进港时间 + Map carPickTime = openApi.getCarPickTime(cargos.stream().map(s -> s.getVin()).collect(Collectors.toList())); + if (MapUtils.isNotEmpty(carPickTime)) { + cargos.stream().forEach(s -> { + if (carPickTime.containsKey(s.getVin()) && carPickTime.get(s.getVin()) != null) { + s.setCarPickTime(DateUtils.formatDate(carPickTime.get(s.getVin()))); + } + }); + } + List drivers = departureDriversService.list(new LambdaQueryWrapper().eq(CustomerDepartureDrivers::getDepartureId, id)); customerService.wrapperEntity(drivers); @@ -632,13 +697,23 @@ public class DepartureHandler implements BaseHandler { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); queryWrapper.eq(query.getId() != null, CustomerDepartureCargo::getDepartureId, query.getId()); if (query.getCargoType() != null) { - queryWrapper.eq(query.getCargoType() != null, CustomerDepartureCargo::getCargoType, query.getCargoType()); + queryWrapper.eq(query.getCargoType() != null, CustomerDepartureCargo::getCartType, query.getCargoType()); } Page page = departureCargoService.page(new Page<>(query.getPage(), query.getRows()), queryWrapper); customerService.wrapperEntity(page.getRecords()); if (CollectionUtils.isNotEmpty(page.getRecords())) { + // 获取进港时间 + Map carPickTime = openApi.getCarPickTime(page.getRecords().stream().map(s -> s.getVin()).collect(Collectors.toList())); + if (MapUtils.isNotEmpty(carPickTime)) { + page.getRecords().stream().forEach(s -> { + if (carPickTime.containsKey(s.getVin()) && carPickTime.get(s.getVin()) != null) { + s.setCarPickTime(DateUtils.formatDate(carPickTime.get(s.getVin()))); + } + }); + } + CustomerDeparture departure = departureService.getById(page.getRecords().get(0).getDepartureId()); // 获取作业状态 @@ -699,8 +774,8 @@ public class DepartureHandler implements BaseHandler { log.setOperateData(l); log.setStatus(check.getCheckStatus() == AuditEnum.AUDIT_PASS ? 0 : 1); log.setOperateTime(new Date()); - log.setUserId(SecurityUtils.getUserId()); - log.setUserName(SecurityUtils.getUserName()); + log.setUserId(UserContext.getUser().getUserId()); + log.setUserName(UserContext.getUser().getUsername()); EsLogApprovalUtil.writeLog(log); } } @@ -755,8 +830,8 @@ public class DepartureHandler implements BaseHandler { log.setOperateData(l); log.setStatus(check.getCheckStatus() == AuditEnum.AUDIT_PASS ? 0 : 1); log.setOperateTime(new Date()); - log.setUserId(SecurityUtils.getUserId()); - log.setUserName(SecurityUtils.getUserName()); + log.setUserId(UserContext.getUser().getUserId()); + log.setUserName(UserContext.getUser().getUsername()); EsLogApprovalUtil.writeLog(log); } } @@ -820,6 +895,7 @@ public class DepartureHandler implements BaseHandler { // 查询出要加载的数据 List departures = departureService.list(new LambdaQueryWrapper().in(CustomerDeparture::getBatchNo, nos)); + customerService.wrapperEntity(departures); ExcelWriter excelWriter = null; try(ByteArrayOutputStream bos = new ByteArrayOutputStream()){ @@ -863,18 +939,19 @@ public class DepartureHandler implements BaseHandler { // 简单的说 如果你的模板有list,且list不是最后一行,下面还有数据需要填充 就必须设置 forceNewRow=true 但是这个就会把所有数据放到内存 会很耗内存 // 如果数据量大 list不是最后一行 参照下一个 - FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build(); + FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.FALSE).build(); List before = CollectionUtil.sub(plans, 0, 1); - List after = CollectionUtil.sub(plans, 1, plans.size() - 1); + List after = CollectionUtil.sub(plans, 1, plans.size()); excelWriter.fill(new FillWrapper("plan", before), writeSheet); excelWriter.fill(new FillWrapper("plan", after), fillConfig, writeSheet); Map map = new HashMap<>(); - map.put("batchNo", departures.get(i).getBatchNo()); // {batchNo} +// map.put("batchNo", departures.get(i).getBatchNo()); // {batchNo} map.put("receiveCompany", departures.get(i).getReceiveCompany()); // {receiveCompany} //{applicant} - map.put("applicant", departures.get(i).getApplicant()); + map.put("applicant", departures.get(i).getCheckMan()); + map.put("remark", departures.get(i).getRemark()); //{applyTime} map.put("applyTime", departures.get(i).getApplyTime()); //{shipName} @@ -933,10 +1010,13 @@ public class DepartureHandler implements BaseHandler { List cargos = departureCargoService.list(new LambdaQueryWrapper().eq(CustomerDepartureCargo::getDepartureId, departure.getId())); - Integer num = cargos.stream().mapToInt(CustomerDepartureCargo::getQuantity).sum(); + Integer num = cargos.size(); List drivers = departureDriversService.list(new LambdaQueryWrapper().eq(CustomerDepartureDrivers::getDepartureId, departure.getId())); + // 获取进港时间 + Map carPickTime = openApi.getCarPickTime(cargos.stream().map(s -> s.getVin()).collect(Collectors.toList())); + PdfDocument pdfDoc = new PdfDocument(new PdfReader(inputStream), new PdfWriter(response.getOutputStream())); org.springframework.core.io.Resource resource = new ClassPathResource("templates/SourceHanSansCN-Regular.ttf"); @@ -944,20 +1024,24 @@ public class DepartureHandler implements BaseHandler { byte[] bytes = IOUtils.toByteArray(stream); PdfFont font = PdfFontFactory.createFont(bytes, PdfEncodings.IDENTITY_H, PdfFontFactory.EmbeddingStrategy.PREFER_EMBEDDED); + PdfFont enFont = PdfFontFactory.createFont(); + PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, false); Map fields = form.getFormFields(); fields.get("batchNo").setValue(departure.getBatchNo()).setFont(font).setFontSize(12); fields.get("shipName").setValue(departure.getShipName()).setFont(font).setFontSize(12); - fields.get("voyage").setValue(departure.getVoyage()).setFont(font).setFontSize(12); + fields.get("voyage").setValue(StringUtils.isNotEmpty(departure.getVoyage()) ? departure.getVoyage() : "").setFont(font).setFontSize(12); fields.get("arrivalTime").setValue(DateUtil.format(departure.getArrivalTime(), "yyyy-MM-dd")).setFont(font).setFontSize(12); fields.get("deliveryTime").setValue(DateUtil.format(departure.getDeliveryTime(), "yyyy-MM-dd")).setFont(font).setFontSize(12); - fields.get("returnTime").setValue(DateUtil.format(departure.getReturnTime(), "yyyy-MM-dd")).setFont(font).setFontSize(12); - fields.get("num").setValue(String.valueOf(num)).setFont(font).setFontSize(12); - if (StringUtils.isNotEmpty(departure.getRemark())) { - fields.get("remark").setValue(departure.getRemark()).setFont(font).setFontSize(12); + if (departure.getReturnTime() != null) { + fields.get("returnTime").setValue(DateUtil.format(departure.getReturnTime(), "yyyy-MM-dd")).setFont(font).setFontSize(12); } + fields.get("num").setValue(String.valueOf(num)).setFont(font).setFontSize(12); + fields.get("brand").setValue(StringUtils.isNotEmpty(departure.getBrand()) ? departure.getBrand() : "").setFont(font).setFontSize(12); + fields.get("remark").setValue(StringUtils.isNotEmpty(departure.getRemark()) ? departure.getRemark() : "").setFont(font).setFontSize(12); + fields.get("reason").setValue(StringUtils.isNotEmpty(departure.getReason()) ? departure.getReason() : "").setFont(font).setFontSize(12); Table driverTable = new Table(UnitValue.createPercentArray(new float[] {30f, 50f, 50f})); driverTable.addHeaderCell(new Cell().add(new Paragraph("司机姓名").setFont(font))); @@ -969,18 +1053,30 @@ public class DepartureHandler implements BaseHandler { driverTable.addCell(new Paragraph(driver.getContactPhone()).setFont(font)); }); - Table cargoTable = new Table(UnitValue.createPercentArray(new float[] {30f, 50f, 50f, 50f, 50f})); + Table cargoTable = new Table(UnitValue.createPercentArray(new float[] {30f, 50f, 50f, 50f, 50f, 50f, 50f, 50f, 50f,50f})); + cargoTable.addHeaderCell(new Cell().add(new Paragraph("提单号").setFont(font))); - cargoTable.addHeaderCell(new Cell().add(new Paragraph("品牌").setFont(font))); - cargoTable.addHeaderCell(new Cell().add(new Paragraph("货物类型").setFont(font))); cargoTable.addHeaderCell(new Cell().add(new Paragraph("车架号").setFont(font))); - cargoTable.addHeaderCell(new Cell().add(new Paragraph("数量").setFont(font))); + cargoTable.addHeaderCell(new Cell().add(new Paragraph("车型").setFont(font))); + cargoTable.addHeaderCell(new Cell().add(new Paragraph("型号").setFont(font))); + cargoTable.addHeaderCell(new Cell().add(new Paragraph("通关性质").setFont(font))); + cargoTable.addHeaderCell(new Cell().add(new Paragraph("尺寸(米)").setFont(font))); + cargoTable.addHeaderCell(new Cell().add(new Paragraph("重量(KG)").setFont(font))); + cargoTable.addHeaderCell(new Cell().add(new Paragraph("是否退关提离").setFont(font))); + cargoTable.addHeaderCell(new Cell().add(new Paragraph("是否随车备件").setFont(font))); + cargoTable.addHeaderCell(new Cell().add(new Paragraph("进港时间").setFont(font))); + cargos.stream().forEach(cargo -> { cargoTable.addCell(new Paragraph(cargo.getBillNo()).setFont(font)); - cargoTable.addCell(new Paragraph(cargo.getBrand()).setFont(font)); - cargoTable.addCell(new Paragraph(cargo.getCargoType()).setFont(font)); cargoTable.addCell(cargo.getVin()); - cargoTable.addCell(String.valueOf(cargo.getQuantity())); + cargoTable.addCell(new Paragraph(StringUtils.isNotEmpty(cargo.getCartType()) ? cargo.getCartType() : "").setFont(font)); + cargoTable.addCell(new Paragraph(StringUtils.isNotEmpty(cargo.getModels()) ? cargo.getModels() : "").setFont(font)); + cargoTable.addCell(new Paragraph(cargo.getIsCustoms() != null ? (cargo.getIsCustoms() == 0 ? "未报关" : "已报关") : "").setFont(font)); + cargoTable.addCell(new Paragraph((cargo.getLength() != null && cargo.getWidth() != null && cargo.getHeight() != null) ? StringUtils.join(cargo.getLength(), "*", cargo.getWidth(), "\n*", cargo.getHeight()) : "").setFont(enFont)); + cargoTable.addCell(new Paragraph(cargo.getWeight() != null ? cargo.getWeight().toString() : "").setFont(font)); + cargoTable.addCell(new Paragraph(cargo.getIsShutout() != null ? (cargo.getIsShutout() == 0 ? "否" : "是") : "").setFont(font)); + cargoTable.addCell(new Paragraph(cargo.getIsSpare() != null ? (cargo.getIsSpare() == 0 ? "否" : "是") : "").setFont(font)); + cargoTable.addCell(new Paragraph(carPickTime != null && carPickTime.containsKey(cargo.getVin()) && carPickTime.get(cargo.getVin()) != null ? DateUtils.formatDate(carPickTime.get(cargo.getVin())) : "").setFont(font)); }); final Document doc = new Document(pdfDoc); @@ -1010,4 +1106,223 @@ public class DepartureHandler implements BaseHandler { doc.close(); } + + @ApiOperation("提离港区导入模板下载") + @GetMapping("/temp/down") + public void tempDownPlan(HttpServletResponse response) throws Exception { + // 加载模板 + ClassPathResource classPathResource = new ClassPathResource("templates/departure_temp.xlsx"); + InputStream inputStream = classPathResource.getInputStream(); + + XSSFWorkbook workbook = new XSSFWorkbook(inputStream); + + OutputStream out = response.getOutputStream(); + try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) { + + // 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("utf-8"); + // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 + String fileName = URLEncoder.encode("提离港区导入模板", "UTF-8"); + response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); + + workbook.write(bos); + byte[] bArray = bos.toByteArray(); + InputStream is = new ByteArrayInputStream(bArray); + org.apache.commons.io.IOUtils.copy(is, out); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (out != null) { + try { + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + @ApiOperation("通过车架号获取信息") + @PostMapping("/getInfoByVin") + public Result getInfoByVin(@RequestParam(required = false) @NotBlank(message = "船ID不能为空") @ApiParam("船ID") String shipId, + @RequestParam(required = false) @NotBlank(message = "航次ID不能为空") @ApiParam("航次ID") String voyageId, + @RequestParam(required = false) @NotBlank(message = "港区ID不能为空") @ApiParam("港区ID") String portAreaId, + @RequestParam(required = false) @NotBlank(message = "品牌ID不能为空") @ApiParam("品牌ID") String brandId, + @RequestParam(required = false) @NotBlank(message = "提单号不能为空") @ApiParam("提单号") String billNo, + @RequestParam(required = false) @NotBlank(message = "车架号不能为空") @ApiParam("车架号") String vin) { + DepartureValidVo form = new DepartureValidVo(); + form.setBrandId(brandId); + form.setShipId(shipId); + form.setVoyageId(voyageId); + form.setPortAreaId(portAreaId); + DepartureValidVo.BillVin bvin = new DepartureValidVo.BillVin(); + bvin.setBillNo(billNo); + bvin.setVin(vin); + form.setVins(Arrays.asList(bvin)); + + Result> mapResult = this.validVins(form); + if (mapResult.getCode() != 0) { // 验证失败 + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), mapResult.getMsg()); + } + + return ResultUtil.success(mapResult.getData().get(vin)); + } + + @ApiOperation("提离港区导入") + @PostMapping("/import") + public Result> importExcel(@RequestParam(required = false) @NotBlank(message = "船ID不能为空") @ApiParam("船ID") String shipId, + @RequestParam(required = false) @NotBlank(message = "航次ID不能为空") @ApiParam("航次ID") String voyageId, + @RequestParam(required = false) @NotBlank(message = "港区ID不能为空") @ApiParam("港区ID") String portAreaId, + @RequestParam(required = false) @NotBlank(message = "品牌ID不能为空") @ApiParam("品牌ID") String brandId, + MultipartFile file) { + try { + // 所有读取的数据 + List dataList = new ArrayList<>(); + + EasyExcel.read(file.getInputStream(), DepartureImportExcel.class, new ReadExcelListener() { + @Override + protected void saveData(List list) { // 缓存数据 + dataList.addAll(list); + } + }).sheet().doRead(); + + if (CollectionUtils.isEmpty(dataList)) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "没有读取到数据"); + } + + ValidatorFactory vf = Validation.buildDefaultValidatorFactory(); + Validator validator = vf.getValidator(); + + // 数据验证 + for (DepartureImportExcel item : dataList) { + Set> set = validator.validate(item); + if (CollectionUtils.isNotEmpty(set)) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), set.stream().map(p -> p.getMessage()).collect(Collectors.joining(","))); + } + } + + DepartureValidVo form = new DepartureValidVo(); + form.setBrandId(brandId); + form.setShipId(shipId); + form.setVoyageId(voyageId); + form.setPortAreaId(portAreaId); + + List billVins = dataList.stream().map(item -> { + DepartureValidVo.BillVin vin = new DepartureValidVo.BillVin(); + vin.setBillNo(item.getBillNo()); + vin.setVin(item.getVin()); + return vin; + }).collect(Collectors.toList()); + + form.setVins(billVins); + + Result> mapResult = this.validVins(form); + if (mapResult.getCode() != 0) { // 验证失败 + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), mapResult.getMsg()); + } + + dataList.stream().forEach(item -> { + if (mapResult.getData().containsKey(item.getVin())) { + CustomerExportIn in = mapResult.getData().get(item.getVin()); + item.setCartType(in.getCartType()); + item.setModels(in.getModels()); + item.setHeight(in.getHeight()); + item.setLength(in.getLength()); + item.setWidth(in.getWidth()); + item.setWeight(in.getWeight()); + } + }); + + return ResultUtil.success(dataList); + } catch (ExcelDataConvertException e) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入数据错误,请确认导入数据模板是否正确, 行:" + e.getRowIndex() + " 列:" + e.getColumnIndex()); + } catch (Exception e) { + log.error("错误信息", e); + return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), e.getMessage()); + } + } + + @ApiOperation("车架号验证") + @PostMapping("/vin/valid") + public Result> validVins(@RequestBody @Validated DepartureValidVo form) { + Map rst = new HashMap<>(); + // 所有车架号 + List vins = form.getVins().stream().map(s -> s.getVin()).collect(Collectors.toList()); + // 根据车架号查询进港申请 + List list = exportInCargoService.lambdaQuery() + .in(CustomerExportInCargo::getVin, vins) + .exists("select id from customer_export_in B where B.id=customer_export_in_cargo.export_in_id and B.ship_id={0} and B.voyage_id={1} and port_area_id={2} and brand_id={3} and check_status={4}", + form.getShipId(), form.getVoyageId(), form.getPortAreaId(), form.getBrandId(), AuditEnum.AUDIT_PASS).list(); + // 有进港计划的 + List strings = list.stream().map(s -> s.getVin()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(strings)) { + // 检验提单号是否属于这个账号 + List userBindFreight = openApi.getUserBindFreight(); + List ids = list.stream().map(s -> s.getExportInId()).distinct().collect(Collectors.toList()); + List exportIns = exportInService.lambdaQuery().in(CustomerExportIn::getId, ids).list(); + // 账号不一致的 + List ins = exportIns.stream().filter(item -> CollectionUtils.isEmpty(userBindFreight) || userBindFreight.stream().filter(s -> StringUtils.equalsAny(item.getFreightId(), s.getCueId())).count() == 0).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(ins)) { + // 提示车架号不存在 + List longs = ins.stream().map(s -> s.getId()).collect(Collectors.toList()); + String collect = list.stream().filter(s -> longs.contains(s.getExportInId())).map(s -> s.getVin()).collect(Collectors.joining(",")); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "车架号"+collect+"不存在"); + } + + // 提单号与车架号是否匹配 + Map stringMap = form.getVins().stream().collect(Collectors.toMap(s -> s.getVin(), s -> s.getBillNo())); + Map exportInMap = exportIns.stream().collect(Collectors.toMap(s -> s.getId(), s -> s.getBillNum())); + Map longMap = list.stream().collect(Collectors.toMap(s -> s.getVin(), s -> s.getExportInId())); + List collect = strings.stream().filter(s -> !StringUtils.equals(stringMap.get(s), exportInMap.get(longMap.get(s)))).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(collect)) { + String s1 = collect.stream().map(s -> "车架号" + s + "与提单号" + stringMap.get(s) + "不匹配").collect(Collectors.joining(",")); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), s1); + } + + // 是否做过退关退运扫描 + VinCheckReq req = new VinCheckReq(); + req.setPamId(form.getPortAreaId()); + req.setBrdId(form.getBrandId()); + req.setSpmId(form.getShipId()); + req.setVvyId(form.getVoyageId()); + req.setVinCodeList(strings); + List resp = openApi.vinCheckInfo(req); + System.err.println(JSON.toJSONString(req)); + System.err.println(JSON.toJSONString(resp)); + + List checkResps = resp.stream().filter(s -> !s.getHasShutoutScan()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(checkResps)) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), checkResps.stream().map(s -> s.getVinCode()).collect(Collectors.joining(",")) + "暂无提离车辆信息,请联系码头确认"); + } + + list.stream().forEach(s -> { + rst.put(s.getVin(), exportIns.stream().filter(i -> Long.compare(i.getId(), s.getExportInId()) == 0).findFirst().get()); + }); + } + // 没有进港计划的 + List noVins = vins.stream().filter(s -> !strings.contains(s)).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(noVins)) { + // 是否做过退关退运扫描 + VinCheckReq req = new VinCheckReq(); + req.setPamId(form.getPortAreaId()); + req.setBrdId(form.getBrandId()); + req.setSpmId(form.getShipId()); + req.setVvyId(form.getVoyageId()); + req.setVinCodeList(noVins); + List resp = openApi.vinCheckInfo(req); + + List checkResps = resp.stream().filter(s -> !s.getNoPlanCollect()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(checkResps)) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), checkResps.stream().map(s -> s.getVinCode()).collect(Collectors.joining(",")) + "车架号不正确"); + } + + checkResps = resp.stream().filter(s -> !s.getHasShutoutScan()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(checkResps)) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), checkResps.stream().map(s -> s.getVinCode()).collect(Collectors.joining(",")) + "暂无提离车辆信息,请联系码头确认"); + } + } + + return ResultUtil.success(rst); + } } diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportInHandler.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportInHandler.java index 105c87e..bb14d27 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportInHandler.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportInHandler.java @@ -5,8 +5,12 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.RandomUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.exception.ExcelDataConvertException; import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.fastjson2.JSONObject; +import com.alicp.jetcache.Cache; +import com.alicp.jetcache.anno.CacheType; +import com.alicp.jetcache.anno.CreateCache; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -27,10 +31,7 @@ import com.haitonggauto.rtosc.common.utils.*; import com.haitonggauto.rtosc.dto.*; import com.haitonggauto.rtosc.excel.*; import com.haitonggauto.rtosc.handler.excel.ExcelMergeUtil; -import com.haitonggauto.rtosc.handler.excel.ExcelValidationUtils; -import com.haitonggauto.rtosc.query.CargoQuery; -import com.haitonggauto.rtosc.query.ExportInCheckQuery; -import com.haitonggauto.rtosc.query.ExportInQuery; +import com.haitonggauto.rtosc.query.*; import com.haitonggauto.rtosc.repository.entity.*; import com.haitonggauto.rtosc.handler.excel.ReadExcelListener; import com.haitonggauto.rtosc.handler.mapper.PoMapper; @@ -38,7 +39,6 @@ import com.haitonggauto.rtosc.repository.enums.AuditEnum; import com.haitonggauto.rtosc.repository.query.PrintQuery; import com.haitonggauto.rtosc.repository.service.*; import com.haitonggauto.rtosc.service.CustomerService; -import com.nuzar.common.security5.common.util.SecurityUtils; import com.nuzar.rtops.log.dto.LogRecordDTO; import com.nuzar.rtops.log.service.EsLogApprovalUtil; import io.swagger.annotations.Api; @@ -50,6 +50,8 @@ import org.apache.commons.collections4.MapUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.apache.poi.xssf.usermodel.*; +import org.redisson.api.RLock; +import org.redisson.api.RedissonClient; import org.springframework.core.io.ClassPathResource; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; @@ -70,6 +72,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.net.URLEncoder; import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -80,6 +83,9 @@ import java.util.stream.Collectors; @Slf4j public class ExportInHandler implements BaseHandler { + @Resource + private RedissonClient redissonClient; + @Resource private CustomerService customerService; @@ -107,6 +113,9 @@ public class ExportInHandler implements BaseHandler { @Resource private NuzarPubApi pubApi; + @CreateCache(name="bj_gen:", cacheType = CacheType.REMOTE, expire = 1, timeUnit = TimeUnit.MINUTES) + private Cache> bjNumCache; + @ApiOperation("船名航次模糊匹配") @PostMapping("/shipVoyage") public Result> getExportInShipNameList( @@ -208,16 +217,40 @@ public class ExportInHandler implements BaseHandler { @RequestParam(required = false) String shipName, @RequestParam(required = false) String voyage, @RequestParam(required = false) String q) { - LambdaQueryWrapper query = new LambdaQueryWrapper<>(); - query.eq(CustomerExportIn::getCreateBy, UserContext.getUser().getUserId()); - query.eq(StringUtils.isNotEmpty(shipName), CustomerExportIn::getShipName, shipName); - query.eq(StringUtils.isNotEmpty(voyage), CustomerExportIn::getVoyage, voyage); - query.like(StringUtils.isNotEmpty(q), CustomerExportIn::getBillNum, q); // 提单号 + QueryWrapper query = new QueryWrapper<>(); + query.select("distinct bill_num"); + query.eq("create_by", UserContext.getUser().getUserId()); + query.eq(StringUtils.isNotEmpty(shipName), "ship_name", shipName); + query.eq(StringUtils.isNotEmpty(voyage), "voyage", voyage); + query.like(StringUtils.isNotEmpty(q), "bill_num", q); Page page = customerExportInService.page(new Page<>(current, size), query); List list = page.getRecords(); - List rst = list.stream().map(item -> item.getBillNum()).collect(Collectors.toList()); + List rst = list.stream().map(tmp -> tmp.getBillNum()).collect(Collectors.toList()); + + + return ResultUtil.success(rst, String.valueOf(page.getTotal())); + } + + @ApiOperation("审核端提单号") + @PostMapping("/check/billNo/query") + public Result> getCheckExportInBillNoList( + @RequestParam(required = false, defaultValue = "1") Integer current, + @RequestParam(required = false, defaultValue = "10") Integer size, + @RequestParam(required = false) String shipId, + @RequestParam(required = false) String voyageId, + @RequestParam(required = false) String q) { + QueryWrapper query = new QueryWrapper<>(); + query.select("distinct bill_num"); + query.eq(StringUtils.isNotEmpty(shipId), "ship_id", shipId); + query.eq(StringUtils.isNotEmpty(voyageId), "voyage_id", voyageId); + query.like(StringUtils.isNotEmpty(q), "bill_num", q); + + Page page = customerExportInService.page(new Page<>(current, size), query); + List list = page.getRecords(); + + List rst = list.stream().map(tmp -> tmp.getBillNum()).collect(Collectors.toList()); return ResultUtil.success(rst, String.valueOf(page.getTotal())); } @@ -261,9 +294,9 @@ public class ExportInHandler implements BaseHandler { @ApiOperation("条件分页查询") @PostMapping("/query-list") public Result> query(@RequestBody ExportInQuery query) { - if (query.getEndEnterTime() != null) { - query.setEndEnterTime(DateUtils.getDayEnd(query.getEndEnterTime())); - } +// if (query.getEndEnterTime() != null) { +// query.setEndEnterTime(DateUtils.getDayEnd(query.getEndEnterTime())); +// } query.setCreateBy(UserContext.getUser().getUserId()); Wrapper queryWrapper = new WrapperKit() { }.changeBaseQueryToWrapper(CustomerExportIn.class, query); @@ -277,38 +310,52 @@ public class ExportInHandler implements BaseHandler { @ApiOperation("审核端条件分页查询") @PostMapping("/check/query-list") public Result> checkQuery(@RequestBody ExportInCheckQuery query) { - if (query.getEndEnterTime() != null) { - query.setEndEnterTime(DateUtils.getDayEnd(query.getEndEnterTime())); - } + long b = System.currentTimeMillis(); + Boolean vinStatus = query.getVinStatus(); + query.setVinStatus(null); if (query.getCheckStatus() == null) { query.setCheckStatusList(Arrays.asList(AuditEnum.SUBMIT, AuditEnum.AUDIT, AuditEnum.AUDIT_PASS, AuditEnum.AUDIT_REJECT)); } - Wrapper queryWrapper = new WrapperKit() { + Date beginEnterDate = query.getBeginEnterTime(); + Date endEnterDate = query.getEndEnterTime(); + query.setBeginEnterTime(null); + query.setEndEnterTime(null); + //搜索进场开始日期<=进场开始时间&&搜索进场结束时间>=进场开始时间 || 搜索进场开始日期<=进场结束时间&&搜索进场结束时间>=进场结束时间 + QueryWrapper queryWrapper = (QueryWrapper) new WrapperKit() { }.changeBaseQueryToWrapper(CustomerExportIn.class, query); + queryWrapper.ge(beginEnterDate != null, "begin_enter_time", beginEnterDate) + .le(endEnterDate != null, "end_enter_time", endEnterDate); +// queryWrapper.and(beginEnterDate != null || endEnterDate != null, (q) -> { +// q.and(beginEnterDate != null, (t) -> { +// t.ge("begin_enter_time", beginEnterDate).le("begin_enter_time", endEnterDate); +// }).or(endEnterDate != null, (s) -> { +// s.ge("end_enter_time", beginEnterDate).le("end_enter_time", endEnterDate); +// }); +// }); Page page = customerExportInService.page(new Page<>(query.getPage(), query.getRows()), queryWrapper); customerService.wrapperEntity(page.getRecords()); + log.info("进港计划查询,接口调用前,查询耗时:" + (System.currentTimeMillis() - b)); + long b1 = System.currentTimeMillis(); // 处理是否生成装船计划 - if(CollectionUtils.isNotEmpty(page.getRecords())) { - Map> map = new HashMap<>(); + if (CollectionUtils.isNotEmpty(page.getRecords())) { List collect = page.getRecords().stream().map(item -> item.getVoyageId()).distinct().collect(Collectors.toList()); - for (String v : collect) { - List list = openApi.haveShipPlan(v); - map.put(v, CollectionUtils.isNotEmpty(list) ? list : Collections.emptyList()); - } + CheckShipPlanReq req = new CheckShipPlanReq(); + req.setVvyIds(collect); + Map> list = openApi.haveShipPlans(req); page.getRecords().stream().forEach(item -> { - item.setShipPlan(map.get(item.getVoyageId()).contains(item.getId())); + item.setShipPlan((MapUtils.isNotEmpty(list) && list.containsKey(item.getVoyageId())) ? list.get(item.getVoyageId()).contains(item.getId()) : false); }); } - + log.info("进港计划查询,接口调用耗时:" + (System.currentTimeMillis() - b1)); + log.info("进港计划查询,总耗时:" + (System.currentTimeMillis() - b)); return ResultUtil.success(page); } @ApiOperation("出口进港货物跟踪查询") @PostMapping("/cargo/tracking") public Result> cargoTracking(@RequestBody ExportInCheckQuery query) { - if (query.getEndEnterTime() != null) { - query.setEndEnterTime(DateUtils.getDayEnd(query.getEndEnterTime())); - } + Boolean vinStatus = query.getVinStatus(); + query.setVinStatus(null); // if (query.getCheckStatus() == null) { // query.setCheckStatusList(Arrays.asList(AuditEnum.AUDIT, AuditEnum.AUDIT_PASS, AuditEnum.AUDIT_REJECT)); // } @@ -322,8 +369,21 @@ public class ExportInHandler implements BaseHandler { // 条件过滤查询 + Date beginEnterDate = query.getBeginEnterTime(); + Date endEnterDate = query.getEndEnterTime(); + query.setBeginEnterTime(null); + query.setEndEnterTime(null); QueryWrapper queryWrapper = (QueryWrapper) new WrapperKit() { }.changeBaseQueryToWrapper(CustomerExportIn.class, query); + queryWrapper.ge(beginEnterDate != null, "begin_enter_time", beginEnterDate) + .le(endEnterDate != null, "end_enter_time", endEnterDate); +// queryWrapper.and(beginEnterDate != null || endEnterDate != null, (q) -> { +// q.and(beginEnterDate != null, (t) -> { +// t.ge("begin_enter_time", beginEnterDate).le("begin_enter_time", endEnterDate); +// }).or(endEnterDate != null, (s) -> { +// s.ge("end_enter_time", beginEnterDate).le("end_enter_time", endEnterDate); +// }); +// }); queryWrapper.select("sum(quantity) as quantity, port_area_id, ship_id, voyage_id, max(update_date) as update_date"); queryWrapper.groupBy("port_area_id, ship_id, voyage_id"); @@ -357,17 +417,30 @@ public class ExportInHandler implements BaseHandler { @ApiOperation("审核端统计查询") @PostMapping("/check/query-list/count") public Result> checkCountQuery(@RequestBody ExportInCheckQuery query) { - if (query.getEndEnterTime() != null) { - query.setEndEnterTime(DateUtils.getDayEnd(query.getEndEnterTime())); - } + Boolean vinStatus = query.getVinStatus(); + query.setVinStatus(null); if (query.getCheckStatus() == null) { query.setCheckStatusList(Arrays.asList(AuditEnum.SUBMIT, AuditEnum.AUDIT, AuditEnum.AUDIT_PASS, AuditEnum.AUDIT_REJECT)); } query.setSorts(null); + Date beginEnterDate = query.getBeginEnterTime(); + Date endEnterDate = query.getEndEnterTime(); + query.setBeginEnterTime(null); + query.setEndEnterTime(null); QueryWrapper queryWrapper = (QueryWrapper) new WrapperKit() { }.changeBaseQueryToWrapper(CustomerExportIn.class, query); + //搜索进场开始日期<=进场开始时间&&搜索进场结東时间>=进场结東时间 + queryWrapper.ge(beginEnterDate != null, "begin_enter_time", beginEnterDate) + .le(endEnterDate != null, "end_enter_time", endEnterDate); +// queryWrapper.and(beginEnterDate != null || endEnterDate != null, (q) -> { +// q.and(beginEnterDate != null, (t) -> { +// t.ge("begin_enter_time", beginEnterDate).le("begin_enter_time", endEnterDate); +// }).or(endEnterDate != null, (s) -> { +// s.ge("end_enter_time", beginEnterDate).le("end_enter_time", endEnterDate); +// }); +// }); queryWrapper.select("sum(quantity) as quantity, sum(volume) as volume, sum(weight) as weight, sum(length) as length, sum(width) as width, sum(height) as height"); @@ -376,24 +449,92 @@ public class ExportInHandler implements BaseHandler { return ResultUtil.success(map); } + @ApiOperation("审核通过,且未有装船计划的进港计划列表") + @PostMapping("/auditPassAndNoPlan/list") + public Result> dataList(@RequestBody ExportInQueryVo query) { + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(StringUtils.isNotEmpty(query.getShipId()), CustomerExportIn::getShipId, query.getShipId()) + .eq(StringUtils.isNotEmpty(query.getVoyageId()), CustomerExportIn::getVoyageId, query.getVoyageId()) + .in(CollectionUtils.isNotEmpty(query.getBillNums()), CustomerExportIn::getBillNum, query.getBillNums()) + .eq(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_PASS); + List list = customerExportInService.list(wrapper); + customerService.wrapperEntity(list); + // 处理是否生成装船计划 + if (CollectionUtils.isNotEmpty(list)) { + List collect = list.stream().map(item -> item.getVoyageId()).distinct().collect(Collectors.toList()); + CheckShipPlanReq req = new CheckShipPlanReq(); + req.setVvyIds(collect); + Map> pList = openApi.haveShipPlans(req); + + list.stream().forEach(item -> { + item.setShipPlan((MapUtils.isNotEmpty(pList) && pList.containsKey(item.getVoyageId())) ? pList.get(item.getVoyageId()).contains(item.getId()) : false); + }); + } + + List rst = list.stream().filter(item -> !item.getShipPlan()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(rst)) { + // 港口和国家的英文明称 + Map portMap = new HashMap<>(); + Map countryMap = new HashMap<>(); + List countryIds = rst.stream().map(item -> item.getCountryId()).distinct().collect(Collectors.toList()); + List portIds = rst.stream().map(item -> item.getPortId()).distinct().collect(Collectors.toList()); + + List portByIds = openApi.getPortByIds(portIds); + List countryByIds = openApi.getCountryByIds(countryIds); + portMap.putAll(portByIds.stream().collect(Collectors.toMap(item -> item.getPotId(), item -> item.getPotEnname()))); + countryMap.putAll(countryByIds.stream().collect(Collectors.toMap(item -> item.getCtyId(), item -> item.getCtyEnname()))); + + rst.stream().forEach(item -> { + item.setPortEnName(portMap.get(item.getPortId())); + item.setCountryEnName(countryMap.get(item.getCountryId())); + }); + } + + return ResultUtil.success(rst); + } + @ApiOperation("全量数据查询") @PostMapping("/data/list") public Result> dataList(@RequestBody ExportInCheckQuery query) { + long begin = System.currentTimeMillis(); + Boolean vinStatus = query.getVinStatus(); + Boolean vinStatusApi = query.getVinStatusApi(); + query.setVinStatus(null); + query.setVinStatusApi(null); if (query.getId() != null && Long.compare(0L, query.getId()) == 0) { query.setId(null); } - if (query.getEndEnterTime() != null) { - query.setEndEnterTime(DateUtils.getDayEnd(query.getEndEnterTime())); - } if (query.getCheckStatus() == null) { query.setCheckStatusList(Arrays.asList(AuditEnum.SUBMIT, AuditEnum.AUDIT, AuditEnum.AUDIT_PASS, AuditEnum.AUDIT_REJECT)); } - Wrapper queryWrapper = new WrapperKit() { + Date beginEnterDate = query.getBeginEnterTime(); + Date endEnterDate = query.getEndEnterTime(); + query.setBeginEnterTime(null); + query.setEndEnterTime(null); + QueryWrapper queryWrapper = (QueryWrapper) new WrapperKit() { }.changeBaseQueryToWrapper(CustomerExportIn.class, query); + queryWrapper.ge(beginEnterDate != null, "begin_enter_time", beginEnterDate) + .le(endEnterDate != null, "end_enter_time", endEnterDate); +// queryWrapper.and(beginEnterDate != null || endEnterDate != null, (q) -> { +// q.and(beginEnterDate != null, (t) -> { +// t.ge("begin_enter_time", beginEnterDate).le("begin_enter_time", endEnterDate); +// }).or(endEnterDate != null, (s) -> { +// s.ge("end_enter_time", beginEnterDate).le("end_enter_time", endEnterDate); +// }); +// }); List list = customerExportInService.list(queryWrapper); customerService.wrapperEntity(list); + long end = System.currentTimeMillis(); if (CollectionUtils.isNotEmpty(list)) { + List cargos = new ArrayList<>(); + if (vinStatus == null || vinStatus) { + cargos.addAll(customerExportInCargoService.lambdaQuery() + .in(CustomerExportInCargo::getExportInId, list.stream().map(s -> s.getId()).collect(Collectors.toList())).list()); + } + log.info("全量查询,数据返回耗时:" + (end - begin)); + // 港口和国家的英文明称 Map portMap = new HashMap<>(); Map countryMap = new HashMap<>(); @@ -405,20 +546,13 @@ public class ExportInHandler implements BaseHandler { portMap.putAll(portByIds.stream().collect(Collectors.toMap(item -> item.getPotId(), item -> item.getPotEnname()))); countryMap.putAll(countryByIds.stream().collect(Collectors.toMap(item -> item.getCtyId(), item -> item.getCtyEnname()))); - List cargos = customerExportInCargoService.lambdaQuery() - .in(CustomerExportInCargo::getExportInId, list.stream().map(item -> item.getId()).collect(Collectors.toList())).list(); - - // 按进港ID进行分组 - Map> collect = cargos.stream().collect(Collectors.groupingBy(CustomerExportInCargo::getExportInId)); - - // 数据拼装 - list.stream().forEach(item -> { - List cs = collect.get(item.getId()); - - item.setPortEnName(portMap.get(item.getPortId())); - item.setCountryEnName(countryMap.get(item.getCountryId())); - - if (CollectionUtils.isNotEmpty(cs)) { + // 获取车辆状态 + if (CollectionUtils.isNotEmpty(cargos) && (vinStatusApi == null || vinStatusApi) && (vinStatus == null || vinStatus)) { + // 按航次进行分组 + Map> listMap = list.stream().collect(Collectors.groupingBy(CustomerExportIn::getVoyageId)); + listMap.entrySet().stream().forEach(item -> { + List ids = item.getValue().stream().map(s -> s.getId()).collect(Collectors.toList()); + List cs = cargos.stream().filter(s -> ids.contains(s.getExportInId())).collect(Collectors.toList()); // 获取作业状态 Map statCollect = null; List vins = cs.stream().map(s -> s.getVin()).collect(Collectors.toList()); @@ -427,8 +561,8 @@ public class ExportInHandler implements BaseHandler { req.setBusinessType("IN_PORT"); req.setImportExportType("E"); req.setVinCodeList(vins); - if (!StringUtils.equalsAnyIgnoreCase(item.getVoyageId(), "HT6", "HTLG", "HTTC")) { - req.setVvyId(item.getVoyageId()); + if (!StringUtils.equalsAnyIgnoreCase(item.getKey(), "HT6", "HTLG", "HTTC")) { + req.setVvyId(item.getKey()); } List status = openApi.getVinStatus(req); statCollect = status.stream().collect(Collectors.toMap(WorkStatusDTO::getVinCode, WorkStatusDTO::getWorkStatus)); @@ -439,23 +573,37 @@ public class ExportInHandler implements BaseHandler { cargo.setWorkStatus(statCollect.get(cargo.getVin())); } } - } + }); + } - item.setVins(cs); + // 数据拼装 + list.stream().forEach(item -> { + item.setPortEnName(portMap.get(item.getPortId())); + item.setCountryEnName(countryMap.get(item.getCountryId())); + + if (vinStatus == null || vinStatus) { + List cs = cargos.stream().filter(s -> Long.compare(s.getExportInId(), item.getId()) == 0).collect(Collectors.toList()); + + item.setVins(cs); + } }); } - + long allEnd = System.currentTimeMillis(); + log.info("全量查询,数据拼装耗时:" + (allEnd - end) + " ,共计耗时: " + (allEnd - begin)); return ResultUtil.success(list); } @ApiOperation("根据航次ID查询审核通过进港记录") @PostMapping("/query-list/voyage") - public Result> checkQuery(@RequestParam(required = false) @NotBlank(message = "航次ID不能为空") String voyageId, - @RequestParam(required = false) AuditEnum status) { + public Result> checkQuery( + @RequestParam(required = false) @NotBlank(message = "船ID不能为空") @ApiParam("船ID") String shipId, + @RequestParam(required = false) @NotBlank(message = "航次ID不能为空") @ApiParam("航次ID") String voyageId, + @RequestParam(required = false) @ApiParam("提单号列表") List billNos, + @RequestParam(required = false) AuditEnum status) { if (status == null) { status = AuditEnum.AUDIT_PASS; } - List list = customerExportInService.getListByVoyageId(voyageId, status); + List list = customerExportInService.getListByVoyageId(shipId, voyageId, billNos, status); customerService.wrapperEntity(list); // 判断是否换船,找出车架号重复,且航次不一样的记录 @@ -474,13 +622,25 @@ public class ExportInHandler implements BaseHandler { @ApiOperation("出口条码打印列表查询") @PostMapping("/check/list") public Result> checkList(@RequestBody ExportInCheckQuery query) { - if (query.getEndEnterTime() != null) { - query.setEndEnterTime(DateUtils.getDayEnd(query.getEndEnterTime())); - } + Boolean vinStatus = query.getVinStatus(); + query.setVinStatus(null); query.setCheckStatus(AuditEnum.AUDIT_PASS); - Wrapper queryWrapper = new WrapperKit() { + Date beginEnterDate = query.getBeginEnterTime(); + Date endEnterDate = query.getEndEnterTime(); + query.setBeginEnterTime(null); + query.setEndEnterTime(null); + QueryWrapper queryWrapper = (QueryWrapper) new WrapperKit() { }.changeBaseQueryToWrapper(CustomerExportIn.class, query); - List list = customerExportInService.list(queryWrapper); + queryWrapper.ge(beginEnterDate != null, "begin_enter_time", beginEnterDate) + .le(endEnterDate != null, "end_enter_time", endEnterDate); +// queryWrapper.and(beginEnterDate != null || endEnterDate != null, (q) -> { +// q.and(beginEnterDate != null, (t) -> { +// t.ge("begin_enter_time", beginEnterDate).le("begin_enter_time", endEnterDate); +// }).or(endEnterDate != null, (s) -> { +// s.ge("end_enter_time", beginEnterDate).le("end_enter_time", endEnterDate); +// }); +// }); + List list = customerExportInService.list(queryWrapper); customerService.wrapperEntity(list); return ResultUtil.success(list); } @@ -488,8 +648,45 @@ public class ExportInHandler implements BaseHandler { @ApiOperation("出口条码(航次)打印列表查询") @PostMapping("/print/voyage") public Result> getPrintList(@RequestBody PrintQuery query) { + String s1 = null; + if (CollectionUtils.isNotEmpty(query.getBillNo())) { + s1 = query.getBillNo().stream().map(s -> "'" + s + "'").collect(Collectors.joining(",")); + } - return ResultUtil.success(customerExportInCargoService.getListByVoyageId(query)); +// List rst = customerExportInCargoService.getListByVoyageId(query); + // StringUtils.equalsAnyIgnoreCase(exportIn.getCartType(), "备件" + + List rst = customerExportInCargoService.lambdaQuery() + .in(CollectionUtils.isNotEmpty(query.getId()), CustomerExportInCargo::getId, query.getId()) + .eq(StringUtils.isNotEmpty(query.getFlag()), CustomerExportInCargo::getCargoType, query.getFlag()) + .exists(StringUtils.isNotEmpty(query.getShipId()), "select id from customer_export_in B where export_in_id=B.id and B.ship_id={0}", query.getShipId()) + .exists(StringUtils.isNotEmpty(query.getVoyageId()), "select id from customer_export_in B where export_in_id=B.id and B.voyage_id={0}", query.getVoyageId()) + .exists(StringUtils.isNotEmpty(s1), "select id from customer_export_in B where export_in_id=B.id and B.bill_num in ("+s1+")").list(); + + if (CollectionUtils.isNotEmpty(rst)) { + List list = customerExportInService.lambdaQuery().in(CustomerExportIn::getId, rst.stream().map(s -> s.getExportInId()).collect(Collectors.toList())).list(); + list.stream().forEach(item -> { + rst.stream().filter(s -> Long.compare(s.getExportInId(), item.getId()) == 0).forEach(s -> { + s.setBrandId(item.getBrandId()); + s.setBrand(item.getBrand()); + s.setCartTypeId(item.getCartTypeId()); + s.setCartType(item.getCartType()); + s.setBillNum(item.getBillNum()); + s.setShipEnName(item.getShipEnName()); + s.setVoyage(item.getVoyage()); + s.setShipName(item.getShipName()); + s.setModels(item.getModels()); + s.setPortId(item.getPortId()); + s.setPortName(item.getPortName()); + s.setLength(item.getLength()); + s.setWeight(item.getWeight()); + s.setWidth(item.getWidth()); + s.setHeight(item.getHeight()); + }); + }); + } + + return ResultUtil.success(rst); } @ApiOperation("审核端导出数据") @@ -510,8 +707,8 @@ public class ExportInHandler implements BaseHandler { } rst.stream().forEach(exportIn -> { - exportIn.setSpareNum(exportIn.getVins().stream().filter(item -> item.getCargoType() == 1).count()+""); - exportIn.setCarNum(exportIn.getVins().stream().filter(item -> item.getCargoType() == 0).count()+""); + exportIn.setSpareNum(exportIn.getVins().stream().filter(item -> item.getCargoType() == 1).count() + ""); + exportIn.setCarNum(exportIn.getVins().stream().filter(item -> item.getCargoType() == 0).count() + ""); exportIn.setPortEnName(portMap.get(exportIn.getPortId())); exportIn.setCountryEnName(countryMap.get(exportIn.getCountryId())); // 补足货物缺失的数据 @@ -593,6 +790,8 @@ public class ExportInHandler implements BaseHandler { @ApiOperation("货物明细分页列表") @PostMapping("/cargos/page") public Result> cargoList(@RequestBody @Validated(ValidationGroup.update.class) CargoQuery query) { + Boolean vinStatus = query.getVinStatus(); + query.setVinStatus(null); List ids = new ArrayList<>(); if (query.getId() != null) { ids.add(query.getId()); @@ -600,7 +799,7 @@ public class ExportInHandler implements BaseHandler { ids.addAll(query.getIds()); } List exportInList = customerExportInService.lambdaQuery().in(CustomerExportIn::getId, ids).list(); - Map eMap = exportInList.stream().collect(Collectors.toMap(CustomerExportIn::getId, item->item)); + Map eMap = exportInList.stream().collect(Collectors.toMap(CustomerExportIn::getId, item -> item)); LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); queryWrapper.eq(query.getId() != null, CustomerExportInCargo::getExportInId, query.getId()); @@ -625,38 +824,147 @@ public class ExportInHandler implements BaseHandler { item.setVoyage(exportIn.getVoyage()); item.setShipName(exportIn.getShipName()); item.setModels(exportIn.getModels()); + item.setPortName(exportIn.getPortName()); }); - - Map> collect1 = page.getRecords().stream().collect(Collectors.groupingBy(CustomerExportInCargo::getExportInId)); - - collect1.entrySet().stream().forEach(m->{ - // 获取作业状态 - Map collect = null; - List vins = m.getValue().stream().map(item -> item.getVin()).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(vins)) { - CustomerExportIn exportIn = eMap.get(m.getKey()); - - VinStatusRequest req = new VinStatusRequest(); - req.setBusinessType("IN_PORT"); - req.setImportExportType("E"); - req.setVinCodeList(vins); - if (!StringUtils.equalsAnyIgnoreCase(exportIn.getVoyageId(), "HT6", "HTLG", "HTTC")) { - req.setVvyId(exportIn.getVoyageId()); + + if (CollectionUtils.isNotEmpty(page.getRecords()) && (vinStatus == null || vinStatus)) { + // 按航次进行分组 + Map> listMap = exportInList.stream().collect(Collectors.groupingBy(CustomerExportIn::getVoyageId)); + listMap.entrySet().stream().forEach(item -> { + List cids = item.getValue().stream().map(s -> s.getId()).collect(Collectors.toList()); + List cs = page.getRecords().stream().filter(s -> cids.contains(s.getExportInId())).collect(Collectors.toList()); + // 获取作业状态 + Map statCollect = null; + List vins = cs.stream().map(s -> s.getVin()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(vins)) { + VinStatusRequest req = new VinStatusRequest(); + req.setBusinessType("IN_PORT"); + req.setImportExportType("E"); + req.setVinCodeList(vins); + if (!StringUtils.equalsAnyIgnoreCase(item.getKey(), "HT6", "HTLG", "HTTC")) { + req.setVvyId(item.getKey()); + } + List status = openApi.getVinStatus(req); + statCollect = status.stream().collect(Collectors.toMap(WorkStatusDTO::getVinCode, WorkStatusDTO::getWorkStatus)); } - List status = openApi.getVinStatus(req); - collect = status.stream().collect(Collectors.toMap(WorkStatusDTO::getVinCode, WorkStatusDTO::getWorkStatus)); - } - if (MapUtils.isNotEmpty(collect)) { - for (CustomerExportInCargo cargo : page.getRecords()) { - cargo.setWorkStatus(collect.get(cargo.getVin())); + if (MapUtils.isNotEmpty(statCollect)) { + for (CustomerExportInCargo cargo : cs) { + cargo.setWorkStatus(statCollect.get(cargo.getVin())); + } } - } - }); + }); + } return ResultUtil.success(page); } + @ApiOperation("提单号,车架号查询车辆信息") + @PostMapping("/cargos/list") + public Result> cargoList(@RequestBody CargoVinQuery query) { + + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); + queryWrapper.like(StringUtils.isNotEmpty(query.getVin()), CustomerExportInCargo::getVin, query.getVin()); + queryWrapper.exists("select id from customer_export_in B where B.id=customer_export_in_cargo.export_in_id and B.bill_num={0}", query.getBillNum()); + List list = customerExportInCargoService.list(queryWrapper); + + customerService.wrapperEntity(list); + + if (CollectionUtils.isNotEmpty(list)) { + + List ids = list.stream().map(s -> s.getExportInId()).collect(Collectors.toList()); + + List exportInList = customerExportInService.lambdaQuery().in(CustomerExportIn::getId, ids).list(); + Map eMap = exportInList.stream().collect(Collectors.toMap(CustomerExportIn::getId, item -> item)); + + list.forEach(item -> { + CustomerExportIn exportIn = eMap.get(item.getExportInId()); + item.setBrandId(exportIn.getBrandId()); + item.setBrand(exportIn.getBrand()); + item.setCartTypeId(exportIn.getCartTypeId()); + item.setCartType(exportIn.getCartType()); + item.setBillNum(exportIn.getBillNum()); + item.setShipEnName(exportIn.getShipEnName()); + item.setVoyage(exportIn.getVoyage()); + item.setShipName(exportIn.getShipName()); + item.setModels(exportIn.getModels()); + }); + + } + + return ResultUtil.success(list); + } + + @ApiOperation("验证货代提单号是否可用") + @PostMapping("/billNum/valid") + public Result billNumValid(@RequestBody @Validated(ValidationGroup.insert.class) BillNumValidVo form) { + List repeatBillNum = customerExportInService.lambdaQuery().eq(CustomerExportIn::getShipId, form.getShipId()) + .eq(CustomerExportIn::getVoyageId, form.getVoyageId()) + .eq(CustomerExportIn::getBillNum, form.getBillNum()) + .ne(CustomerExportIn::getFreightId, form.getFreightId()) + .ne(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_REJECT).list(); + if (CollectionUtils.isNotEmpty(repeatBillNum)) { + return ResultUtil.failure(1, "当前已有其他货代" + repeatBillNum.get(0).getFreight() + "使用该提单号,不可重复申请"); + } + + return ResultUtil.success("success"); + } + + /** + * 生成备件号 + * @param size + * @return + */ + private List genBjNo(int size, List tmp) { + if (tmp == null) { + tmp = new ArrayList<>(size); + } + if (size == 0) { + return tmp; + } + String prefix = StringUtils.join("BJ", DateUtil.format(new Date(), "yyMMddHHmm")); + List vins = new ArrayList<>(size); + RLock lock = redissonClient.getLock(prefix); + try { + lock.lock(30, TimeUnit.SECONDS); + do { + String vin = prefix + RandomUtil.randomNumbers(5); + if (!vins.contains(vin)) { + vins.add(vin); + } + } while (vins.size() < size); + + // 验证是否有重复的 + List strings = bjNumCache.get(prefix); + if (CollectionUtils.isNotEmpty(strings)) { + List finalStrings = strings; + List collect = vins.stream().filter(s -> finalStrings.contains(s)).collect(Collectors.toList()); // 重复的 + if (CollectionUtils.isNotEmpty(collect)) { + vins.removeAll(collect); + } + if (CollectionUtils.isNotEmpty(vins)) { + tmp.addAll(vins); + strings.addAll(vins); + bjNumCache.put(prefix, strings); + } + if (CollectionUtils.isNotEmpty(collect)) { + genBjNo(collect.size(), tmp); + } + } else { + strings = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(vins)) { + tmp.addAll(vins); + strings.addAll(vins); + bjNumCache.put(prefix, strings); + } + } + } finally { + lock.unlock(); + } + + return tmp; + } + /** * 新增 * @@ -690,7 +998,14 @@ public class ExportInHandler implements BaseHandler { List repeat = form.getSpares().stream().collect(Collectors.groupingBy(ExportInCargoVo::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, ",") + "车架号重复"); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), StringUtils.join(repeat, ",") + "备件号重复"); + } + // 数据库中是否已经存在 + List list = customerExportInCargoService.lambdaQuery() + .in(CustomerExportInCargo::getVin, form.getSpares().stream().map(s -> s.getVin()).collect(Collectors.toList())) + .notExists("select id from customer_export_in where customer_export_in.id=customer_export_in_cargo.export_in_id and customer_export_in.check_status={0}", AuditEnum.AUDIT_REJECT).list(); + if (CollectionUtils.isNotEmpty(list)) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), list.stream().map(s -> s.getVin()).collect(Collectors.joining(",")) + "备件号重复"); } } String batchNo = customerService.getSequenceNo("export_in_batch_no", "出口进场", "EI"); @@ -736,14 +1051,7 @@ public class ExportInHandler implements BaseHandler { }).collect(Collectors.toList()); if (CollectionUtils.isEmpty(spares) && StringUtils.equalsAnyIgnoreCase(exportIn.getCartType(), "备件", "BJ") && StringUtils.equals("正常", exportIn.getNatureFlagName())) { // 出口进场计划备件条码生成的规则要变一下,BJ+年月日时分+5随机数,一共要17位 - String prefix = StringUtils.join("BJ", DateUtil.format(new Date(), "yyMMddHHmm")); - List vins = new ArrayList<>(exportIn.getQuantity()); - do { - String vin = prefix + RandomUtil.randomNumbers(5); - if (!vins.contains(vin)) { - vins.add(vin); - } - } while (vins.size() < exportIn.getQuantity()); + List vins = genBjNo(exportIn.getQuantity(), null); spares = vins.stream().map(item -> { CustomerExportInCargo entity = new CustomerExportInCargo(); entity.setBrand(exportIn.getBrand()); @@ -771,6 +1079,16 @@ public class ExportInHandler implements BaseHandler { return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), "进场货物的数量,要等于进场货物的所有数量"); } + // 最终逻辑确认了,客户服务平台-出口进港申请,加一个限制,同船名航次提单号只能被一个货代录入,如果A货代已经录入提单号A,B货代再录入提单A的时候弹窗提示“当前已有其他货代#货代名称#使用该提单号,不可重复申请”。 + List repeatBillNum = customerExportInService.lambdaQuery().eq(CustomerExportIn::getShipId, exportIn.getShipId()) + .eq(CustomerExportIn::getVoyageId, exportIn.getVoyageId()) + .eq(CustomerExportIn::getBillNum, exportIn.getBillNum()) + .ne(CustomerExportIn::getFreightId, exportIn.getFreightId()) + .ne(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_REJECT).list(); + if (CollectionUtils.isNotEmpty(repeatBillNum)) { + return ResultUtil.failure(1, "当前已有其他货代" + repeatBillNum.get(0).getFreight() + "使用该提单号,不可重复申请"); + } + // 验证同一提单下,所有进场的数量,体积,重量和提单号的每票的数量进行, 船名,航次 QueryWrapper nQuery = new QueryWrapper<>(); nQuery.select("sum(quantity) as quantity, sum(volume) as volume, sum(weight) as weight") @@ -785,7 +1103,19 @@ public class ExportInHandler implements BaseHandler { map.put("volume", new BigDecimal(0)); } if (new BigDecimal(exportIn.getEachQuantity()).compareTo(((BigDecimal) map.get("quantity")).add(new BigDecimal(exportIn.getQuantity()))) < 0) { - return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), "数量不得超过单票件数"); + QueryWrapper rQuery = new QueryWrapper<>(); + rQuery.eq("bill_num", exportIn.getBillNum()) + .eq("ship_id", exportIn.getShipId()) + .eq("voyage_id", exportIn.getVoyageId()).ne("check_status", AuditEnum.AUDIT_REJECT); + List rList = customerExportInService.list(rQuery); + Optional first = rList.stream().filter(item -> !StringUtils.equals(item.getFreightId(), exportIn.getFreightId())).findFirst(); + if (first.isPresent()) { + String str = first.get().getFreight(); + return ResultUtil.failure(1, "同提单数量之和超过单票数量 注:当前已有其他货代【" + str + "】使用该提单号"); + } else { + return ResultUtil.failure(1, "同提单数量之和超过单票数量"); + } + } if (exportIn.getEachWeight().divide(new BigDecimal(1000)).compareTo(((BigDecimal) map.get("weight")).add(exportIn.getWeight())) < 0) { // return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), "重量不得超过单票重量"); @@ -805,16 +1135,22 @@ public class ExportInHandler implements BaseHandler { // 查询出对应的港区 List list = customerExportInService.lambdaQuery().in(CustomerExportIn::getId, exists.stream().map(item -> item.getExportInId()).collect(Collectors.toList())).list(); Map portAreaMap = list.stream().collect(Collectors.toMap(CustomerExportIn::getId, CustomerExportIn::getPortAreaId)); + Map vvyIdMap = list.stream().collect(Collectors.toMap(CustomerExportIn::getId, CustomerExportIn::getVoyageId)); // 通过接口再次验证 List req = exists.stream().map(item -> { CheckVinReq v = new CheckVinReq(); v.setIsRepetition(true); v.setPamId(portAreaMap.get(item.getExportInId())); v.setVinCode(item.getVin()); + v.setVvyId(vvyIdMap.get(item.getExportInId())); return v; }).collect(Collectors.toList()); List rst = shpApi.checkVinRepeat(req); if (CollectionUtils.isNotEmpty(rst)) { + List strings = rst.stream().filter(ss -> !ss.getIsRepetition()).map(s -> s.getVinCode()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(strings)) { + log.info("接口验证,可以再次导入的车架号:" + strings.stream().collect(Collectors.joining(","))); + } // 再次过滤出重复的 List collect = rst.stream().filter(item -> item.getIsRepetition()).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(collect)) { @@ -998,6 +1334,7 @@ public class ExportInHandler implements BaseHandler { // 使用LambdaUpdateWrapper只在特定需求下做处理(推荐) 将字段修改为空值的处理方法 public Result edit(@RequestParam(required = false, defaultValue = "false") Boolean flag, @RequestBody @Validated(ValidationGroup.update.class) ExportInVo form) { + Long b = System.currentTimeMillis(); // 验证是否有重复的车架号 if (CollectionUtils.isNotEmpty(form.getCargos())) { List repeat = form.getCargos().stream().collect(Collectors.groupingBy(ExportInCargoVo::getVin, Collectors.counting())) @@ -1010,7 +1347,16 @@ public class ExportInHandler implements BaseHandler { List repeat = form.getSpares().stream().collect(Collectors.groupingBy(ExportInCargoVo::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, ",") + "车架号重复"); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), StringUtils.join(repeat, ",") + "备件号重复"); + } + + // 数据库中是否已经存在 + List list = customerExportInCargoService.lambdaQuery() + .ne(CustomerExportInCargo::getExportInId, form.getId()) + .in(CustomerExportInCargo::getVin, form.getSpares().stream().map(s -> s.getVin()).collect(Collectors.toList())) + .notExists("select id from customer_export_in where customer_export_in.id=customer_export_in_cargo.export_in_id and customer_export_in.check_status={0}", AuditEnum.AUDIT_REJECT).list(); + if (CollectionUtils.isNotEmpty(list)) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), list.stream().map(s -> s.getVin()).collect(Collectors.joining(",")) + "备件号重复"); } } @@ -1071,14 +1417,8 @@ public class ExportInHandler implements BaseHandler { return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), "备件列表不能大于备件总数"); } if (exportIn.getQuantity() > spares.size()) { // 自动生成备件号 - String prefix = StringUtils.join("BJ", DateUtil.format(new Date(), "yyMMddHHmm")); - List vins = new ArrayList<>(exportIn.getQuantity() - spares.size()); - do { - String vin = prefix + RandomUtil.randomNumbers(5); - if (!vins.contains(vin)) { - vins.add(vin); - } - } while (vins.size() < exportIn.getQuantity() - spares.size()); + List vins = genBjNo(exportIn.getQuantity() - spares.size(), null); + List addSpares = vins.stream().map(item -> { CustomerExportInCargo entity = new CustomerExportInCargo(); entity.setBrand(exportIn.getBrand()); @@ -1110,7 +1450,16 @@ public class ExportInHandler implements BaseHandler { } // 数量必须≤单票件数,否则不能跳转下一步,并提示“数量不得超过单票件数” if (num > exportIn.getEachQuantity()) { - return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), "数量不得超过单票件数"); + return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), "同提单数量之和超过单票数量"); + } + + List repeatBillNum = customerExportInService.lambdaQuery().eq(CustomerExportIn::getShipId, exportIn.getShipId()) + .eq(CustomerExportIn::getVoyageId, exportIn.getVoyageId()) + .eq(CustomerExportIn::getBillNum, exportIn.getBillNum()) + .ne(CustomerExportIn::getFreightId, exportIn.getFreightId()) + .ne(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_REJECT).list(); + if (CollectionUtils.isNotEmpty(repeatBillNum)) { + return ResultUtil.failure(1, "当前已有其他货代" + repeatBillNum.get(0).getFreight() + "使用该提单号,不可重复申请"); } // 验证同一提单下,所有进场的数量,体积,重量和提单号的每票的数量进行 @@ -1127,7 +1476,18 @@ public class ExportInHandler implements BaseHandler { vmap.put("volume", new BigDecimal(0)); } if (new BigDecimal(exportIn.getEachQuantity()).compareTo(((BigDecimal) vmap.get("quantity")).add(new BigDecimal(exportIn.getQuantity()))) < 0) { - return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), "数量不得超过单票件数"); + QueryWrapper rQuery = new QueryWrapper<>(); + rQuery.eq("bill_num", exportIn.getBillNum()) + .eq("ship_id", exportIn.getShipId()) + .eq("voyage_id", exportIn.getVoyageId()).ne("check_status", AuditEnum.AUDIT_REJECT).ne("id", exportIn.getId()); + List rList = customerExportInService.list(rQuery); + Optional first = rList.stream().filter(item -> !StringUtils.equals(item.getFreightId(), exportIn.getFreightId())).findFirst(); + if (first.isPresent()) { + String str = first.get().getFreight(); + return ResultUtil.failure(1, "同提单数量之和超过单票数量 注:当前已有其他货代【" + str + "】使用该提单号"); + } else { + return ResultUtil.failure(1, "同提单数量之和超过单票数量"); + } } if (exportIn.getEachWeight().divide(new BigDecimal(1000)).compareTo(((BigDecimal) vmap.get("weight")).add(exportIn.getWeight())) < 0) { // return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), "重量不得超过单票重量"); @@ -1137,10 +1497,10 @@ public class ExportInHandler implements BaseHandler { } //* 异常情况有,必填项车架号,车架号必须17位,数据重复,如果重复进行覆盖更新 - count = cargos.stream().filter(item -> item.getVin().length() != 17).count(); - if (count > 0) { - return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), "车架号必须17位"); - } +// count = cargos.stream().filter(item -> item.getVin().length() != 17).count(); +// if (count > 0) { +// return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), "车架号必须17位"); +// } //* 车架号重复不支持导入或新增 if (CollectionUtils.isNotEmpty(cargos)) { // 查询 车架号在系统中是否已经存在, 编辑的和新增的判断方式是不一样的 @@ -1149,19 +1509,26 @@ public class ExportInHandler implements BaseHandler { .notExists("select id from customer_export_in where customer_export_in.id=customer_export_in_cargo.export_in_id and customer_export_in.check_status={0}", AuditEnum.AUDIT_REJECT) .ne(CustomerExportInCargo::getExportInId, exportIn.getId())); if (CollectionUtils.isNotEmpty(exists)) { + Long s = System.currentTimeMillis(); // 查询出对应的港区 List list = customerExportInService.lambdaQuery().in(CustomerExportIn::getId, exists.stream().map(item -> item.getExportInId()).collect(Collectors.toList())).list(); Map portAreaMap = list.stream().collect(Collectors.toMap(CustomerExportIn::getId, CustomerExportIn::getPortAreaId)); + Map vvyIdMap = list.stream().collect(Collectors.toMap(CustomerExportIn::getId, CustomerExportIn::getVoyageId)); // 通过接口再次验证 List req = exists.stream().map(item -> { CheckVinReq v = new CheckVinReq(); v.setIsRepetition(true); v.setPamId(portAreaMap.get(item.getExportInId())); v.setVinCode(item.getVin()); + v.setVvyId(vvyIdMap.get(item.getExportInId())); return v; }).collect(Collectors.toList()); List rst = shpApi.checkVinRepeat(req); if (CollectionUtils.isNotEmpty(rst)) { + List strings = rst.stream().filter(ss -> !ss.getIsRepetition()).map(ss -> ss.getVinCode()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(strings)) { + log.info("接口验证,可以再次导入的车架号:" + strings.stream().collect(Collectors.joining(","))); + } // 再次过滤出重复的 List collect = rst.stream().filter(item -> item.getIsRepetition()).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(collect)) { @@ -1170,6 +1537,7 @@ public class ExportInHandler implements BaseHandler { } else { return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), "车架号已存在:" + exists.stream().map(item -> item.getVin()).collect(Collectors.joining(","))); } + log.info("编辑验证车架号接口耗时:" + (System.currentTimeMillis() - s)); } } @@ -1180,6 +1548,8 @@ public class ExportInHandler implements BaseHandler { customerService.updateExportIn(false, exportIn, cargos, times, spares); + log.info("编辑耗时:" + (System.currentTimeMillis() - b)); + return ResultUtil.success(String.valueOf(exportIn.getId())); } @@ -1256,30 +1626,52 @@ public class ExportInHandler implements BaseHandler { @PostMapping("/check") @Transactional(rollbackFor = {Exception.class}) public Result check(@RequestBody @Validated(ValidationGroup.insert.class) ExportInCheckVo check) throws Exception { - List exportIns = new ArrayList<>(); - for (Long id : check.getIds()) { - CustomerExportIn exportIn = PoMapper.instance.exportInCheckVo2Entity(check); - exportIn.setCheckManId(UserContext.getUser().getUserId()); - exportIn.setCheckTime(new Date()); - exportIn.setId(id); - exportIns.add(exportIn); + // 待审核的数据 + List list = customerExportInService.lambdaQuery() + .in(CustomerExportIn::getId, check.getIds()).list(); + + if (CollectionUtils.isNotEmpty(list)) { + BatchConfirmReviewReq req = new BatchConfirmReviewReq(); + req.setIds(list.stream().map(s -> s.getId() + "").collect(Collectors.toList())); + Boolean rst = openApi.batchConfirmReview(req); + if (!rst) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "审核失败"); + } + + if (check.getCheckStatus() == AuditEnum.AUDIT_PASS) { + // 获取航次的离泊状态 + List collect = list.stream().map(s -> s.getVoyageId()).filter(s -> !StringUtils.equalsAny(s, "HT6", "HTLG", "HTTC")).distinct().collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(collect)) { + List shipmentBerthsStatusRespDTOS = shpApi.queryVoyagesBerthsStatusByVvyIds(collect); + if (CollectionUtils.isNotEmpty(shipmentBerthsStatusRespDTOS)) { + List strings = shipmentBerthsStatusRespDTOS.stream().filter(s -> StringUtils.equalsAny(s.getUnberthedStatus(), "1")).map(s -> s.getVvyId()).distinct().collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(strings)) { + customerExportInService.lambdaUpdate().in(CustomerExportIn::getVoyageId, strings) + .set(CustomerExportIn::getUnberthFlag, "1").update(); + } + } + } + } } - boolean row = customerExportInService.updateBatchById(exportIns); - - // 如果是审核通过,还需要将数据同步到旧系统 + boolean row = customerExportInService.lambdaUpdate() + .set(CustomerExportIn::getCheckManId, UserContext.getUser().getUserId()) + .set(CustomerExportIn::getCheckTime, new Date()) + .set(CustomerExportIn::getCheckStatus, check.getCheckStatus()) + .set(CustomerExportIn::getCheckResult, check.getCheckResult()) + .setSql(check.getCheckStatus() == AuditEnum.AUDIT_REJECT, "voyage_id = case when port_area='外高桥' then 'HT6' when port_area='临港' then 'HTLG' when port_area='太仓' then 'HTTC' else voyage_id end, voyage = case when port_area='外高桥' then 'HT6' when port_area='临港' then 'HTLG' when port_area='太仓' then 'HTTC' else voyage end") + .in(CustomerExportIn::getId, check.getIds()) + .update(); if (row) { - List list = customerExportInService.lambdaQuery().in(CustomerExportIn::getId, check.getIds()).list(); - // 记录日志 for (CustomerExportIn exportIn : list) { LogRecordDTO log = new LogRecordDTO(); log.setOperateData(exportIn); log.setStatus(check.getCheckStatus() == AuditEnum.AUDIT_PASS ? 0 : 1); log.setOperateTime(new Date()); - log.setUserId(SecurityUtils.getUserId()); - log.setUserName(SecurityUtils.getUserName()); + log.setUserId(UserContext.getUser().getUserId()); + log.setUserName(UserContext.getUser().getUsername()); EsLogApprovalUtil.writeLog(log); } @@ -1290,7 +1682,7 @@ public class ExportInHandler implements BaseHandler { return ResultUtil.success("success"); } - return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "修改失败,ID不存在"); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "没有待审核数据"); } @ApiOperation("整船待审核数量查询") @@ -1305,6 +1697,88 @@ public class ExportInHandler implements BaseHandler { return ResultUtil.success(row); } + /** + * 审核 + * + * @param check + * @return + */ + @ApiOperation("新进港审核") + @PostMapping("/check/byShipAndVoyage") + public Result checkByShipAndVoyage(@RequestBody @Validated(ValidationGroup.insert.class) ExportInAuditVo check) throws Exception { + List voyageIds = Arrays.asList("HT6", "HTTC", "HTLG", check.getVoyageId()); + // 待审核的数据 + List list = customerExportInService.lambdaQuery() + .eq(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_PASS) + .eq(CustomerExportIn::getShipId, check.getShipId()) + .in(CustomerExportIn::getVoyageId, voyageIds) + .in(CustomerExportIn::getBillNum, check.getBillNums()).list(); + + List billNums = list.stream().map(item -> item.getBillNum()).collect(Collectors.toList()); + // 系统是否存在,不存在的提单号 + String s = check.getBillNums().stream().filter(item -> !billNums.contains(item)).collect(Collectors.joining(",")); + if (StringUtils.isNotEmpty(s)) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "审核通过的提单号:" + s + "不存在"); + } + + if (CollectionUtils.isNotEmpty(list)) { + BatchConfirmReviewReq req = new BatchConfirmReviewReq(); + req.setIds(list.stream().map(ss -> ss.getId() + "").collect(Collectors.toList())); + Boolean rst = openApi.batchConfirmReview(req); + if (!rst) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "审核失败"); + } + + if (check.getCheckStatus() == AuditEnum.AUDIT_PASS) { + // 获取航次的离泊状态 + List collect = list.stream().map(ss -> ss.getVoyageId()).filter(ss -> !StringUtils.equalsAny(ss, "HT6", "HTLG", "HTTC")).distinct().collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(collect)) { + List shipmentBerthsStatusRespDTOS = shpApi.queryVoyagesBerthsStatusByVvyIds(collect); + if (CollectionUtils.isNotEmpty(shipmentBerthsStatusRespDTOS)) { + List strings = shipmentBerthsStatusRespDTOS.stream().filter(ss -> StringUtils.equalsAny(ss.getUnberthedStatus(), "1")).map(ss -> ss.getVvyId()).distinct().collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(strings)) { + customerExportInService.lambdaUpdate().in(CustomerExportIn::getVoyageId, strings) + .set(CustomerExportIn::getUnberthFlag, "1").update(); + } + } + } + } + } + + boolean row = customerExportInService.lambdaUpdate() + .set(CustomerExportIn::getCheckManId, UserContext.getUser().getUserId()) + .set(CustomerExportIn::getCheckTime, new Date()) + .set(CustomerExportIn::getCheckStatus, check.getCheckStatus()) + .set(CustomerExportIn::getCheckResult, check.getCheckResult()) + .setSql(check.getCheckStatus() == AuditEnum.AUDIT_REJECT, "voyage_id = case when port_area='外高桥' then 'HT6' when port_area='临港' then 'HTLG' when port_area='太仓' then 'HTTC' else voyage_id end, voyage = case when port_area='外高桥' then 'HT6' when port_area='临港' then 'HTLG' when port_area='太仓' then 'HTTC' else voyage end") + .eq(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_PASS) + .eq(CustomerExportIn::getShipId, check.getShipId()) + .in(CustomerExportIn::getVoyageId, voyageIds) + .in(CustomerExportIn::getBillNum, check.getBillNums()) + .update(); + + if (row) { + // 记录日志 + for (CustomerExportIn exportIn : list) { + LogRecordDTO log = new LogRecordDTO(); + log.setOperateData(exportIn); + log.setStatus(check.getCheckStatus() == AuditEnum.AUDIT_PASS ? 0 : 1); + log.setOperateTime(new Date()); + log.setUserId(UserContext.getUser().getUserId()); + log.setUserName(UserContext.getUser().getUsername()); + EsLogApprovalUtil.writeLog(log); + } + + if (check.getCheckStatus() == AuditEnum.AUDIT_PASS) { + customerService.syncAddExportInToOld(list); + } + + return ResultUtil.success("success"); + } + + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "没有可修改的数据"); + } + /** * 审核 * @@ -1320,11 +1794,36 @@ public class ExportInHandler implements BaseHandler { .eq(CustomerExportIn::getShipId, check.getShipId()) .eq(CustomerExportIn::getVoyageId, check.getVoyageId()).list(); + if (CollectionUtils.isNotEmpty(list)) { + BatchConfirmReviewReq req = new BatchConfirmReviewReq(); + req.setIds(list.stream().map(s -> s.getId() + "").collect(Collectors.toList())); + Boolean rst = openApi.batchConfirmReview(req); + if (!rst) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "审核失败"); + } + + if (check.getCheckStatus() == AuditEnum.AUDIT_PASS) { + // 获取航次的离泊状态 + List collect = list.stream().map(s -> s.getVoyageId()).filter(s -> !StringUtils.equalsAny(s, "HT6", "HTLG", "HTTC")).distinct().collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(collect)) { + List shipmentBerthsStatusRespDTOS = shpApi.queryVoyagesBerthsStatusByVvyIds(collect); + if (CollectionUtils.isNotEmpty(shipmentBerthsStatusRespDTOS)) { + List strings = shipmentBerthsStatusRespDTOS.stream().filter(s -> StringUtils.equalsAny(s.getUnberthedStatus(), "1")).map(s -> s.getVvyId()).distinct().collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(strings)) { + customerExportInService.lambdaUpdate().in(CustomerExportIn::getVoyageId, strings) + .set(CustomerExportIn::getUnberthFlag, "1").update(); + } + } + } + } + } + boolean row = customerExportInService.lambdaUpdate() .set(CustomerExportIn::getCheckManId, UserContext.getUser().getUserId()) .set(CustomerExportIn::getCheckTime, new Date()) .set(CustomerExportIn::getCheckStatus, check.getCheckStatus()) .set(CustomerExportIn::getCheckResult, check.getCheckResult()) + .setSql(check.getCheckStatus() == AuditEnum.AUDIT_REJECT, "voyage_id = case when port_area='外高桥' then 'HT6' when port_area='临港' then 'HTLG' when port_area='太仓' then 'HTTC' else voyage_id end, voyage = case when port_area='外高桥' then 'HT6' when port_area='临港' then 'HTLG' when port_area='太仓' then 'HTTC' else voyage end") .eq(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT) .eq(CustomerExportIn::getShipId, check.getShipId()) .eq(CustomerExportIn::getVoyageId, check.getVoyageId()) @@ -1337,8 +1836,8 @@ public class ExportInHandler implements BaseHandler { log.setOperateData(exportIn); log.setStatus(check.getCheckStatus() == AuditEnum.AUDIT_PASS ? 0 : 1); log.setOperateTime(new Date()); - log.setUserId(SecurityUtils.getUserId()); - log.setUserName(SecurityUtils.getUserName()); + log.setUserId(UserContext.getUser().getUserId()); + log.setUserName(UserContext.getUser().getUsername()); EsLogApprovalUtil.writeLog(log); } @@ -1361,6 +1860,8 @@ public class ExportInHandler implements BaseHandler { @Transactional(rollbackFor = {Exception.class}) public Result cancelCheck(@RequestBody @Validated(ValidationGroup.update.class) ExportInCheckVo check) throws Exception { List exportIns = new ArrayList<>(); + Map> cMap = new HashMap<>(); + for (Long id : check.getIds()) { // 需要判断,是否有出口装船审核通过的数据 @@ -1369,7 +1870,15 @@ public class ExportInHandler implements BaseHandler { return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), "id:" + id + "不存在"); } - List havePlans = openApi.haveShipPlan(ei.getVoyageId()); + List havePlans = null; + if (!cMap.containsKey(ei.getVoyageId())) { + List c = openApi.haveShipPlan(ei.getVoyageId()); // 这个接口做个缓存处理 + cMap.put(ei.getVoyageId(), c); + } + if (cMap.containsKey(ei.getVoyageId())) { + havePlans = cMap.get(ei.getVoyageId()); + } + if (CollectionUtils.isNotEmpty(havePlans)) { Boolean c = havePlans.contains(ei.getId()); if (c) { @@ -1382,6 +1891,7 @@ public class ExportInHandler implements BaseHandler { exportIn.setId(id); exportIn.setCheckManId(UserContext.getUser().getUserId()); exportIn.setCheckStatus(AuditEnum.AUDIT); + exportIn.setCheckResult(""); exportIns.add(exportIn); } @@ -1467,28 +1977,70 @@ public class ExportInHandler implements BaseHandler { @Transactional(rollbackFor = {Exception.class}) @PostMapping("/update/shipVoyage/new") public Result shipVoyageUpdate(@RequestBody @Validated(ValidationGroup.insert.class) UpdateVoyageVo form) { + long b = System.currentTimeMillis(); + if (CollectionUtils.isEmpty(form.getIds()) && CollectionUtils.isEmpty(form.getBillNums())) { + return ResultUtil.failure(ErrorType.ERROR_PASS.id(), "ID列表或提单号列表不能都为空"); + } + String idsStr = StringUtils.join(form.getIds(), ","); List exportIns = customerExportInService.query() - .select("distinct voyage_id, ship_id") - .in("id", form.getIds()) + .eq("check_status", AuditEnum.AUDIT_PASS) + .exists("select id from customer_export_in B where B.ship_id=customer_export_in.ship_id and B.voyage_id = customer_export_in.voyage_id and B.bill_num=customer_export_in.bill_num and B.id in ("+idsStr+")") .list(); - if (exportIns.size() > 1) { + if (CollectionUtils.isEmpty(exportIns)) { + return ResultUtil.failure(ErrorType.ERROR_PASS.id(), "没有可修改的记录"); + } + + if (StringUtils.equalsIgnoreCase(form.getVoyage(), "HT6")) { + if (exportIns.stream().filter(s -> !StringUtils.equals(s.getPortArea(), "外高桥")).count() > 0) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "虚拟航次名错误"); + } + } else if (StringUtils.equalsIgnoreCase(form.getVoyage(), "HTTC")) { + if (exportIns.stream().filter(s -> !StringUtils.equals(s.getPortArea(), "太仓")).count() > 0) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "虚拟航次名错误"); + } + } else if (StringUtils.equalsIgnoreCase(form.getVoyage(), "HTLG")) { + if (exportIns.stream().filter(s -> !StringUtils.equals(s.getPortArea(), "临港")).count() > 0) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "虚拟航次名错误"); + } + } + + // 首先按对船名,般次,提单进行分组 + Map> collect = exportIns.stream() + .collect(Collectors.groupingBy(item -> StringUtils.joinWith("#$#", item.getShipId(), item.getVoyageId()), Collectors.toList())); + + if (collect.keySet().size() > 1) { return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "所选船名航次不同,不支持批量修改航次"); } // 判断是不是备件,如果是备件,则需要重新生成 - List exportInList = customerExportInService.lambdaQuery() - .in(CustomerExportIn::getId, form.getIds()).list(); - List havePlans = openApi.haveShipPlan(exportIns.get(0).getVoyageId()); - if (CollectionUtils.isNotEmpty(exportInList) && CollectionUtils.isNotEmpty(havePlans)) { - long c = exportInList.stream().filter(item -> havePlans.contains(item.getId())).count(); - if (c > 0) { - return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "已生成装船计划,不支持批量修改航次"); +// List havePlans = openApi.haveShipPlan(exportIns.get(0).getVoyageId()); +// if (CollectionUtils.isNotEmpty(exportIns) && CollectionUtils.isNotEmpty(havePlans)) { +// long c = exportIns.stream().filter(item -> havePlans.contains(item.getId())).count(); +// if (c > 0) { +// return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "已生成装船计划,不支持批量修改航次"); +// } +// } + + List ids = exportIns.stream().map(s -> s.getId()).collect(Collectors.toList()); + + log.info("批量修改航次,查询耗时:" + (System.currentTimeMillis() - b)); + + long b1 = System.currentTimeMillis(); + if (form.getValid() != null && form.getValid()) { + form.setIds(ids); + if (!openApi.batchConfirmRevise(form)) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "修改舱单失败"); } + log.info("批量修改航次,调用[/customer/yard/batchConfirmRevise]耗时:" + (System.currentTimeMillis() - b1)); } - exportInList.stream().filter(item -> StringUtils.equals("备件", item.getCartType()) && StringUtils.equalsAnyIgnoreCase(item.getVoyage(), "HT6", "HTTC", "HTLG")) + long b2 = System.currentTimeMillis(); + // 按提单号进行分组 + /* + Map> listMap = exportIns.stream().filter(item -> StringUtils.equals("备件", item.getCartType()) && StringUtils.equalsAnyIgnoreCase(item.getVoyage(), "HT6", "HTTC", "HTLG")).collect(Collectors.groupingBy(CustomerExportIn::getBillNum)); + exportIns.stream().filter(item -> StringUtils.equals("备件", item.getCartType()) && StringUtils.equalsAnyIgnoreCase(item.getVoyage(), "HT6", "HTTC", "HTLG")) .forEach(item -> { String vvyId = item.getVoyageId(); TransitPartRequest request = new TransitPartRequest(); @@ -1516,12 +2068,16 @@ public class ExportInHandler implements BaseHandler { customerExportInCargoService.saveBatch(spares); } }); + log.info("批量修改航次,调用[/customer/shipment/shipLoad/transitPart, 同步虚拟航次备件]耗时:" + (System.currentTimeMillis() - b2)); + */ + long b3 = System.currentTimeMillis(); customerExportInService.lambdaUpdate() .set(CustomerExportIn::getVoyageId, form.getVoyageId()) .set(CustomerExportIn::getVoyage, form.getVoyage()) - .in(CustomerExportIn::getId, form.getIds()) + .in(CustomerExportIn::getId, ids) .update(); + log.info("批量修改航次,修改耗时:" + (System.currentTimeMillis() - b3)); return ResultUtil.success("success"); } @@ -1593,17 +2149,23 @@ public class ExportInHandler implements BaseHandler { if (CollectionUtils.isNotEmpty(exists)) { List list = customerExportInService.lambdaQuery().in(CustomerExportIn::getId, exists.stream().map(item -> item.getExportInId()).collect(Collectors.toList())).list(); Map portAreaMap = list.stream().collect(Collectors.toMap(CustomerExportIn::getId, CustomerExportIn::getPortAreaId)); + Map vvyIdMap = list.stream().collect(Collectors.toMap(CustomerExportIn::getId, CustomerExportIn::getVoyageId)); // 通过接口再次验证 List req = exists.stream().map(item -> { CheckVinReq v = new CheckVinReq(); v.setIsRepetition(true); v.setPamId(portAreaMap.get(item.getExportInId())); v.setVinCode(item.getVin()); + v.setVvyId(vvyIdMap.get(item.getExportInId())); return v; }).collect(Collectors.toList()); List rst = shpApi.checkVinRepeat(req); existVins.clear(); if (CollectionUtils.isNotEmpty(rst)) { + List strings = rst.stream().filter(ss -> !ss.getIsRepetition()).map(s -> s.getVinCode()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(strings)) { + log.info("接口验证,可以再次导入的车架号:" + strings.stream().collect(Collectors.joining(","))); + } // 再次过滤出重复的 List collect = rst.stream().filter(item -> item.getIsRepetition()).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(collect)) { @@ -1696,17 +2258,23 @@ public class ExportInHandler implements BaseHandler { // 查询出对应的港区 List sList = customerExportInService.lambdaQuery().in(CustomerExportIn::getId, existCargos.stream().map(ss -> ss.getExportInId()).collect(Collectors.toList())).list(); Map portAreaMap = sList.stream().collect(Collectors.toMap(CustomerExportIn::getId, CustomerExportIn::getPortAreaId)); + Map vvyIdMap = sList.stream().collect(Collectors.toMap(CustomerExportIn::getId, CustomerExportIn::getVoyageId)); // 通过接口再次验证 List req = existCargos.stream().map(ss -> { CheckVinReq v = new CheckVinReq(); v.setIsRepetition(true); v.setPamId(portAreaMap.get(ss.getExportInId())); v.setVinCode(ss.getVin()); + v.setVvyId(vvyIdMap.get(ss.getExportInId())); return v; }).collect(Collectors.toList()); List rst = shpApi.checkVinRepeat(req); existVins.clear(); if (CollectionUtils.isNotEmpty(rst)) { + List strings = rst.stream().filter(ss -> !ss.getIsRepetition()).map(s -> s.getVinCode()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(strings)) { + log.info("接口验证,可以再次导入的车架号:" + strings.stream().collect(Collectors.joining(","))); + } // 再次过滤出重复的 List sCollect = rst.stream().filter(ss -> ss.getIsRepetition()).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(sCollect)) { @@ -1762,6 +2330,8 @@ public class ExportInHandler implements BaseHandler { } return ResultUtil.success(rst); + } catch (ExcelDataConvertException e) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入数据错误,请确认导入数据模板是否正确, 行:" + e.getRowIndex() + " 列:" + e.getColumnIndex()); } catch (Exception e) { log.error("错误信息", e); return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage()); @@ -1859,6 +2429,11 @@ public class ExportInHandler implements BaseHandler { }); if (CollectionUtils.isEmpty(validData)) { + if (CollectionUtils.isEmpty(errorDataList)) { // 代表没有读取到数据 + JSONObject o = new JSONObject(); + o.put("status", "未读取到数据"); + errorDataList.add(o); + } return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); } @@ -1922,17 +2497,23 @@ public class ExportInHandler implements BaseHandler { // 查询出对应的港区 List sList = customerExportInService.lambdaQuery().in(CustomerExportIn::getId, existCargos.stream().map(ss -> ss.getExportInId()).collect(Collectors.toList())).list(); Map portAreaMap = sList.stream().collect(Collectors.toMap(CustomerExportIn::getId, CustomerExportIn::getPortAreaId)); + Map vvyIdMap = sList.stream().collect(Collectors.toMap(CustomerExportIn::getId, CustomerExportIn::getVoyageId)); // 通过接口再次验证 List req = existCargos.stream().map(ss -> { CheckVinReq v = new CheckVinReq(); v.setIsRepetition(true); v.setPamId(portAreaMap.get(ss.getExportInId())); v.setVinCode(ss.getVin()); + v.setVvyId(vvyIdMap.get(ss.getExportInId())); return v; }).collect(Collectors.toList()); List rst = shpApi.checkVinRepeat(req); existVins.clear(); if (CollectionUtils.isNotEmpty(rst)) { + List strings = rst.stream().filter(ss -> !ss.getIsRepetition()).map(s -> s.getVinCode()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(strings)) { + log.info("接口验证,可以再次导入的车架号:" + strings.stream().collect(Collectors.joining(","))); + } // 再次过滤出重复的 List sCollect = rst.stream().filter(ss -> ss.getIsRepetition()).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(sCollect)) { @@ -1961,7 +2542,7 @@ public class ExportInHandler implements BaseHandler { }); if (CollectionUtils.isNotEmpty(errorDataList)) { - errorDataList.addAll(successDataList); +// errorDataList.addAll(successDataList); return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); } @@ -1972,6 +2553,8 @@ public class ExportInHandler implements BaseHandler { } return ResultUtil.success(errorDataList); + } catch (ExcelDataConvertException e) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入数据错误,请确认导入数据模板是否正确, 行:" + e.getRowIndex() + " 列:" + e.getColumnIndex()); } catch (Exception e) { log.error("错误信息", e); return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), e.getMessage()); @@ -2068,6 +2651,11 @@ public class ExportInHandler implements BaseHandler { }); if (CollectionUtils.isEmpty(validData)) { + if (CollectionUtils.isEmpty(errorDataList)) { // 代表没有读取到数据 + JSONObject o = new JSONObject(); + o.put("status", "未读取到数据"); + errorDataList.add(o); + } return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); } @@ -2077,7 +2665,7 @@ public class ExportInHandler implements BaseHandler { if (CollectionUtils.isNotEmpty(repeat)) { errorDataList.addAll(validData.stream().filter(p -> repeat.contains(p.getVin())).map(p -> { JSONObject o = JSONObject.from(p); - o.put("status", "车架号重复"); + o.put("status", "备件号重复"); return o; }).collect(Collectors.toList())); return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); @@ -2116,17 +2704,23 @@ public class ExportInHandler implements BaseHandler { // 查询出对应的港区 List sList = customerExportInService.lambdaQuery().in(CustomerExportIn::getId, existCargos.stream().map(ss -> ss.getExportInId()).collect(Collectors.toList())).list(); Map portAreaMap = sList.stream().collect(Collectors.toMap(CustomerExportIn::getId, CustomerExportIn::getPortAreaId)); + Map vvyIdMap = sList.stream().collect(Collectors.toMap(CustomerExportIn::getId, CustomerExportIn::getVoyageId)); // 通过接口再次验证 List req = existCargos.stream().map(ss -> { CheckVinReq v = new CheckVinReq(); v.setIsRepetition(true); v.setPamId(portAreaMap.get(ss.getExportInId())); v.setVinCode(ss.getVin()); + v.setVvyId(vvyIdMap.get(ss.getExportInId())); return v; }).collect(Collectors.toList()); List rst = shpApi.checkVinRepeat(req); existVins.clear(); if (CollectionUtils.isNotEmpty(rst)) { + List strings = rst.stream().filter(ss -> !ss.getIsRepetition()).map(s -> s.getVinCode()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(strings)) { + log.info("接口验证,可以再次导入的车架号:" + strings.stream().collect(Collectors.joining(","))); + } // 再次过滤出重复的 List sCollect = rst.stream().filter(ss -> ss.getIsRepetition()).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(sCollect)) { @@ -2154,7 +2748,7 @@ public class ExportInHandler implements BaseHandler { saveCargos.addAll(cargos.stream().filter(p -> !existVins.contains(p.getVin())).collect(Collectors.toList())); if (CollectionUtils.isNotEmpty(errorDataList)) { - errorDataList.addAll(successDataList); +// errorDataList.addAll(successDataList); return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); } @@ -2165,6 +2759,8 @@ public class ExportInHandler implements BaseHandler { } return ResultUtil.success(errorDataList); + } catch (ExcelDataConvertException e) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入数据错误,请确认导入数据模板是否正确, 行:" + e.getRowIndex() + " 列:" + e.getColumnIndex()); } catch (Exception e) { log.error("错误信息", e); return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage()); @@ -2258,12 +2854,29 @@ public class ExportInHandler implements BaseHandler { // 所有数据验证都不通过 if (CollectionUtils.isEmpty(validData)) { + if (CollectionUtils.isEmpty(errorDataList)) { // 代表没有读取到数据 + JSONObject o = new JSONObject(); + o.put("status", "未读取到数据"); + errorDataList.add(o); + } return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); } // 模型去空格处理 validData.stream().forEach(item -> item.setModels(StringUtils.trim(item.getModels()))); + // 是否有重复的车架号 + List repeat = validData.stream().collect(Collectors.groupingBy(ExportInExcel::getVin, Collectors.counting())) + .entrySet().stream().filter(entry -> entry.getValue() > 1).map(entry -> entry.getKey()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(repeat)) { + errorDataList.addAll(validData.stream().filter(p -> repeat.contains(p.getVin())).map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "车架号重复"); + return o; + }).collect(Collectors.toList())); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + // 首先按对船名,般次,提单进行分组 Map> collect = validData.stream() .collect(Collectors.groupingBy(item -> StringUtils.joinWith("#$#", item.getShipName(), item.getVoyage(), item.getBillNo(), item.getBrand(), item.getModels()), Collectors.toList())); @@ -2285,19 +2898,6 @@ public class ExportInHandler implements BaseHandler { .eq(CustomerExportIn::getModels, models) .ne(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_REJECT) .ne(CustomerExportIn::getCartType, "备件"); // 备件的不允许整船导入 -// if (StringUtils.equals(type, "0")) { -// cQuery.and((wrapper) -> { -// wrapper.eq(CustomerExportIn::getCheckStatus, AuditEnum.SUBMIT) -// .or() -// .eq(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_REJECT); -// }); -// } else { -// cQuery.and((wrapper) -> { -// wrapper.eq(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT) -// .or() -// .eq(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_REJECT); -// }); -// } // 同一个型号可能存在多个进港计划 @@ -2315,9 +2915,6 @@ public class ExportInHandler implements BaseHandler { // 计划总数量 int planQuantity = exportInList.stream().mapToInt(p -> p.getQuantity()).sum(); - // 找到和本次数量一致的 -// Optional first = exportInList.stream().filter(p -> p.getQuantity() == item.getValue().size()).findFirst(); - CustomerExportIn exportIn = exportInList.get(0); if (planQuantity != item.getValue().size()) { @@ -2330,7 +2927,6 @@ public class ExportInHandler implements BaseHandler { } ids.addAll(exportInList.stream().map(p -> p.getId()).collect(Collectors.toList())); -// ids.add(exportIn.getId()); // 已生成装船计划,不能导入 List havePlans = openApi.haveShipPlan(exportIn.getVoyageId()); @@ -2346,23 +2942,6 @@ public class ExportInHandler implements BaseHandler { } } -// if (exportIn.getCheckStatus() == AuditEnum.AUDIT_PASS) { // 审核 -// errorDataList.addAll(item.getValue().stream().map(p -> { -// JSONObject o = JSONObject.from(p); -// o.put("status", "审核通过状态的不可导入"); -// return o; -// }).collect(Collectors.toList())); -// return; -// } - -// if (exportIn.getEnterQuantity() != item.getValue().size()) { -// errorDataList.addAll(item.getValue().stream().map(p -> { -// JSONObject o = JSONObject.from(p); -// o.put("status", "车架号数量和实际货物数量不符合,无法导入"); -// return o; -// }).collect(Collectors.toList())); -// return; -// } // 按计划中的件数进行VIN的分配 int j = 0; List cargos = new ArrayList<>(); @@ -2382,42 +2961,36 @@ public class ExportInHandler implements BaseHandler { } } -// List cargos = item.getValue().stream().map(p -> { -// CustomerExportInCargo cargo = new CustomerExportInCargo(); -// cargo.setBrandId(exportIn.getBrandId()); -// cargo.setBrand(exportIn.getBrand()); -// cargo.setExportInId(exportIn.getId()); -// cargo.setCargoType(0); -// cargo.setVin(p.getVin()); -// cargo.setTermcd(exportIn.getPortAreaId()); -// cargo.setVinStatus(1); -// return cargo; -// }).collect(Collectors.toList()); - List vins = cargos.stream().map(p -> p.getVin()).collect(Collectors.toList()); // 验证哪些车架号已经存在了 List existCargos = customerExportInCargoService .list(new LambdaQueryWrapper().in(CustomerExportInCargo::getVin, vins) .notExists("select id from customer_export_in where customer_export_in.id=customer_export_in_cargo.export_in_id and customer_export_in.check_status={0}", AuditEnum.AUDIT_REJECT) - .ne(CustomerExportInCargo::getExportInId, exportIn.getId())); + .notIn(CustomerExportInCargo::getExportInId, exportInList.stream().map(s -> s.getId()).collect(Collectors.toList()))); List existVins = existCargos.stream().map(p -> p.getVin()).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(existCargos)) { // 查询出对应的港区 List sList = customerExportInService.lambdaQuery().in(CustomerExportIn::getId, existCargos.stream().map(ss -> ss.getExportInId()).collect(Collectors.toList())).list(); Map portAreaMap = sList.stream().collect(Collectors.toMap(CustomerExportIn::getId, CustomerExportIn::getPortAreaId)); + Map vvyIdMap = sList.stream().collect(Collectors.toMap(CustomerExportIn::getId, CustomerExportIn::getVoyageId)); // 通过接口再次验证 List req = existCargos.stream().map(ss -> { CheckVinReq v = new CheckVinReq(); v.setIsRepetition(true); v.setPamId(portAreaMap.get(ss.getExportInId())); v.setVinCode(ss.getVin()); + v.setVvyId(vvyIdMap.get(ss.getExportInId())); return v; }).collect(Collectors.toList()); List rst = shpApi.checkVinRepeat(req); existVins.clear(); // 先清空 if (CollectionUtils.isNotEmpty(rst)) { + List strings = rst.stream().filter(ss -> !ss.getIsRepetition()).map(s -> s.getVinCode()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(strings)) { + log.info("接口验证,可以再次导入的车架号:" + strings.stream().collect(Collectors.joining(","))); + } // 再次过滤出重复的 List sCollect = rst.stream().filter(ss -> ss.getIsRepetition()).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(sCollect)) { @@ -2428,9 +3001,13 @@ public class ExportInHandler implements BaseHandler { List existData = item.getValue().stream().filter(p -> existVins.contains(p.getVin())).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(existData)) { + // 获取使用货代 + List ts = existCargos.stream().map(s -> s.getExportInId()).distinct().collect(Collectors.toList()); + Map inMap = customerExportInService.lambdaQuery().in(CustomerExportIn::getId, ts).list().stream().collect(Collectors.toMap(CustomerExportIn::getId, s -> s)); errorDataList.addAll(existData.stream().map(p -> { + CustomerExportInCargo inCargo = existCargos.stream().filter(s -> StringUtils.equals(s.getVin(), p.getVin())).findFirst().get(); JSONObject o = JSONObject.from(p); - o.put("status", "数据已存在, 未导入"); + o.put("status", "车架号被" + inMap.get(inCargo.getExportInId()).getFreight() + "货代已使用,未导入"); return o; }).collect(Collectors.toList())); successDataList.addAll(item.getValue().stream().filter(p -> !existVins.contains(p.getVin())) @@ -2454,7 +3031,7 @@ public class ExportInHandler implements BaseHandler { }); if (CollectionUtils.isNotEmpty(errorDataList)) { - errorDataList.addAll(successDataList); +// errorDataList.addAll(successDataList); return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); } @@ -2465,6 +3042,8 @@ public class ExportInHandler implements BaseHandler { } return ResultUtil.success(errorDataList); + } catch (ExcelDataConvertException e) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入数据错误,请确认导入数据模板是否正确, 行:" + e.getRowIndex() + " 列:" + e.getColumnIndex()); } catch (Exception e) { log.error("错误信息", e); return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage()); @@ -2532,7 +3111,7 @@ public class ExportInHandler implements BaseHandler { try { - EasyExcel.read(file.getInputStream(), ExportLoadExcel.class, new ReadExcelListener() { + EasyExcel.read(file.getInputStream(), ExportInBillSpareExcel.class, new ReadExcelListener() { @Override protected void saveData(List list) { // 保存数据 dataList.addAll(list); @@ -2558,6 +3137,23 @@ public class ExportInHandler implements BaseHandler { // 所有数据验证都不通过 if (CollectionUtils.isEmpty(validData)) { + if (CollectionUtils.isEmpty(errorDataList)) { // 代表没有读取到数据 + JSONObject o = new JSONObject(); + o.put("status", "未读取到数据"); + errorDataList.add(o); + } + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + + // 是否有重复的车架号 + List repeat = validData.stream().collect(Collectors.groupingBy(ExportInBillSpareExcel::getVin, Collectors.counting())) + .entrySet().stream().filter(entry -> entry.getValue() > 1).map(entry -> entry.getKey()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(repeat)) { + errorDataList.addAll(validData.stream().filter(p -> repeat.contains(p.getVin())).map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "备件号重复"); + return o; + }).collect(Collectors.toList())); return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); } @@ -2676,17 +3272,23 @@ public class ExportInHandler implements BaseHandler { // 查询出对应的港区 List sList = customerExportInService.lambdaQuery().in(CustomerExportIn::getId, existCargos.stream().map(ss -> ss.getExportInId()).collect(Collectors.toList())).list(); Map portAreaMap = sList.stream().collect(Collectors.toMap(CustomerExportIn::getId, CustomerExportIn::getPortAreaId)); + Map vvyIdMap = sList.stream().collect(Collectors.toMap(CustomerExportIn::getId, CustomerExportIn::getVoyageId)); // 通过接口再次验证 List req = existCargos.stream().map(ss -> { CheckVinReq v = new CheckVinReq(); v.setIsRepetition(true); v.setPamId(portAreaMap.get(ss.getExportInId())); v.setVinCode(ss.getVin()); + v.setVvyId(vvyIdMap.get(ss.getExportInId())); return v; }).collect(Collectors.toList()); List rst = shpApi.checkVinRepeat(req); existVins.clear(); // 先清空 if (CollectionUtils.isNotEmpty(rst)) { + List strings = rst.stream().filter(ss -> !ss.getIsRepetition()).map(s -> s.getVinCode()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(strings)) { + log.info("接口验证,可以再次导入的车架号:" + strings.stream().collect(Collectors.joining(","))); + } // 再次过滤出重复的 List sCollect = rst.stream().filter(ss -> ss.getIsRepetition()).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(sCollect)) { @@ -2723,7 +3325,7 @@ public class ExportInHandler implements BaseHandler { }); if (CollectionUtils.isNotEmpty(errorDataList)) { - errorDataList.addAll(successDataList); +// errorDataList.addAll(successDataList); return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); } @@ -2734,6 +3336,8 @@ public class ExportInHandler implements BaseHandler { } return ResultUtil.success(errorDataList); + } catch (ExcelDataConvertException e) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入数据错误,请确认导入数据模板是否正确, 行:" + e.getRowIndex() + " 列:" + e.getColumnIndex()); } catch (Exception e) { log.error("错误信息", e); return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage()); @@ -2788,9 +3392,13 @@ public class ExportInHandler implements BaseHandler { } query.setPage(1); query.setRows(500); - Wrapper queryWrapper = new WrapperKit() { + query.setSorts(null); +// query.setSorts(Arrays.asList(new BaseQuery.SortField("shipId", "asc"), new BaseQuery.SortField("voyageId", "asc"), new BaseQuery.SortField("billNum", "asc"))); + QueryWrapper queryWrapper = (QueryWrapper) new WrapperKit() { }.changeBaseQueryToWrapper(CustomerExportIn.class, query); + queryWrapper.orderByAsc(Arrays.asList("voyage_id", "bill_num")); + ExcelWriter excelWriter = null; OutputStream out = null; try { @@ -2804,7 +3412,7 @@ public class ExportInHandler implements BaseHandler { response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); //合并坐标 - int[] mergeColumeIndex = {22,23,24}; + int[] mergeColumeIndex = {22, 23, 24}; //从第二行后开始合并 int mergeRowIndex = 1; @@ -2853,6 +3461,7 @@ public class ExportInHandler implements BaseHandler { List rows = headers.stream().map(item -> { ExportInExportExcel e = PoMapper.instance.entity2Excel(item); e.setSerialNo(index.getAndIncrement()); + e.setCheckStatus(item.getCheckStatus().text()); return e; }).collect(Collectors.toList()); @@ -2861,34 +3470,31 @@ public class ExportInHandler implements BaseHandler { // 头映射 Map collect = headers.stream().collect(Collectors.toMap(item -> item.getId(), item -> item)); // 处理明细数据 - List list = customerExportInCargoService.lambdaQuery().in(CustomerExportInCargo::getExportInId, headers.stream().map(item -> item.getId()).collect(Collectors.toList())).list(); + List cargos = customerExportInCargoService.lambdaQuery().in(CustomerExportInCargo::getExportInId, headers.stream().map(item -> item.getId()).collect(Collectors.toList())).list(); - // 通过接口获取进场时间和位置 - headers.stream().forEach(item -> { - List cargos = list.stream().filter(p -> Long.compare(p.getExportInId(), item.getId()) == 0).collect(Collectors.toList()); - if (CollectionUtils.isEmpty(cargos)) return; + if (CollectionUtils.isNotEmpty(cargos)) { - GoodsStatusReq req = new GoodsStatusReq(); - req.setBusinessType("IN_PORT"); - req.setImportExportType("E"); - req.setVvyId(StringUtils.equalsAnyIgnoreCase(item.getVoyageId(), "HT6", "HTLG", "HTTC") ? "" : item.getVoyageId()); - req.setVinCodeList(cargos.stream().map(p -> p.getVin()).collect(Collectors.toList())); + GoodsStatusReq req = new GoodsStatusReq(); + req.setBusinessType("IN_PORT"); + req.setImportExportType("E"); +// req.setVvyId(StringUtils.equalsAnyIgnoreCase(item.getKey(), "HT6", "HTLG", "HTTC") ? "" : item.getKey()); + req.setVinCodeList(cargos.stream().map(p -> p.getVin()).collect(Collectors.toList())); - List resp = openApi.getGoodsStatus(req); + List resp = openApi.getGoodsStatus(req); - Map respMap = resp.stream().collect(Collectors.toMap(p -> p.getVinCode(), p -> p)); + Map respMap = resp.stream().collect(Collectors.toMap(p -> p.getVinCode(), p -> p)); - cargos.stream().forEach(p -> { - GoodsStatusResp r = respMap.get(p.getVin()); - if (r != null) { - p.setEnterPortTime(r.getInTime()); - p.setPosition(r.getPosition()); - } - }); + cargos.stream().forEach(p -> { + GoodsStatusResp r = respMap.get(p.getVin()); + if (r != null) { + p.setEnterPortTime(r.getInTime()); + p.setPosition(r.getPosition()); + } + }); + } - }); - List details = list.stream().map(item -> { + List details = cargos.stream().map(item -> { ExportInCargoExportExcel e = PoMapper.instance.entity2Excel(collect.get(item.getExportInId()), item); return e; }).collect(Collectors.toList()); @@ -3164,44 +3770,6 @@ public class ExportInHandler implements BaseHandler { try { - // 获取用户绑定的货代 - List userBindFreight = openApi.getUserBindFreight(); - - PubMappingMapDto pubMapping = pubApi.getPubMapping(); - - // 国家数据 - List countryList = openApi.getCountryList(); - // 港口基础数据 - List portList = dictHandler.getPortList(null).getData(); - // 船名基础数据 - List shipList = dictHandler.getAllShip(null).getData(); - // 港区基础数据 - List portAreaList = dictHandler.getPortAreaList(null).getData(); - // 品牌基础数据 - List brandList = dictHandler.getBrandList(null).getData(); - // 车型基础数据 - List carTypeList = dictHandler.getCartTypeList(null).getData(); - // 产地基础数据 - List originPlaceList = dictHandler.getAllCountryList(null).getData(); - // 运输模式 - List transportWayList = dictHandler.getTransportWayList(null).getData(); - // 操作模式 - List operateTypeList = dictHandler.getOperateTypeList(null).getData(); - // 特殊作业 - List specWorkList = dictHandler.getSpecWorkList().getData(); - // 新能源类型 - List energyTypeList = dictHandler.getEnergyTypeList().getData(); - // 根据港口ID 获取国家 - // Map portCountryList = new HashMap<>(); - // 货代列表 - Map companyMap = new HashMap<>(); - // 货物性质 - List goodsNature = dictHandler.getGoodsNature().getData(); - // 车型明细缓存 - Map> carDetailTypeList = new HashMap<>(); - // 航次缴存 - Map> voyageMap = new HashMap<>(); - EasyExcel.read(file.getInputStream(), ExportInPlanExcel.class, new ReadExcelListener() { @Override protected void saveData(List list) { // 保存数据 @@ -3230,9 +3798,55 @@ public class ExportInHandler implements BaseHandler { }); if (CollectionUtils.isEmpty(validData)) { // 数据完整性检验 + if (CollectionUtils.isEmpty(errorDataList)) { // 代表没有读取到数据 + JSONObject o = new JSONObject(); + o.put("status", "未读取到数据"); + errorDataList.add(o); + } return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); } + // 获取用户绑定的货代 + List userBindFreight = openApi.getUserBindFreight(); + + PubMappingMapDto pubMapping = pubApi.getPubMapping(); + + // 国家数据 + List countryList = openApi.getCountryList(); + // 港口基础数据 + List portList = dictHandler.getPortList(null).getData(); +// // 船名基础数据 + List shipList = dictHandler.getAllShip(null).getData(); + // 旬度计划船名 +// Map> trendShipMap = new HashMap<>(); + List trendShipList = openApi.getTrendShipList(validData.stream().map(s -> s.getShipName()).distinct().collect(Collectors.toList())); + // 港区基础数据 + List portAreaList = dictHandler.getPortAreaList(null).getData(); + // 品牌基础数据 + List brandList = dictHandler.getBrandList(null).getData(); + // 车型基础数据 + List carTypeList = dictHandler.getCartTypeList(null).getData(); + // 产地基础数据 + List originPlaceList = dictHandler.getAllCountryList(null).getData(); + // 运输模式 + List transportWayList = dictHandler.getTransportWayList(null).getData(); + // 操作模式 + List operateTypeList = dictHandler.getOperateTypeList(null).getData(); + // 特殊作业 + List specWorkList = dictHandler.getSpecWorkList().getData(); + // 新能源类型 + List energyTypeList = dictHandler.getEnergyTypeList().getData(); + // 根据港口ID 获取国家 + // Map portCountryList = new HashMap<>(); + // 货代列表 + Map companyMap = new HashMap<>(); + // 货物性质 + List goodsNature = dictHandler.getGoodsNature().getData(); + // 车型明细缓存 + Map> carDetailTypeList = new HashMap<>(); + // 航次缴存 + Map> voyageMap = new HashMap<>(); + // 港区、船名、港口、品牌、车型 validData.stream().forEach(item -> { if (countryList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getCtyCnname(), item.getCountry())).count() == 0) { @@ -3254,7 +3868,7 @@ public class ExportInHandler implements BaseHandler { errorDataList.add(o); return; } - if (shipList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getShipName())).count() == 0) { + if (trendShipList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getSpmName(), item.getShipName())).count() == 0) { JSONObject o = JSONObject.from(item); o.put("status", "船名不存在"); errorDataList.add(o); @@ -3387,7 +4001,7 @@ public class ExportInHandler implements BaseHandler { errorDataList.add(o); return; } - if (!StringUtils.equals(item.getNatureFlagName(), "正常")) { + if (StringUtils.equalsAny(item.getNatureFlagName(), "内进转外出", "外进转内出", "国际中转", "国内中转")) { if (shipList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getTransferShipName())).count() == 0) { JSONObject o = JSONObject.from(item); o.put("status", "中转进口船名不存在"); @@ -3441,7 +4055,7 @@ public class ExportInHandler implements BaseHandler { }); if (CollectionUtils.isNotEmpty(errorDataList)) { - errorDataList.addAll(successDataList); +// errorDataList.addAll(successDataList); return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); } @@ -3461,8 +4075,9 @@ public class ExportInHandler implements BaseHandler { in.setTmpEnterDate(d); } - in.setShipId(shipList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getShipName())).findFirst().get().getId()); - in.setShipEnName(shipList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getShipName())).findFirst().get().getExtra1()); + in.setShipId(trendShipList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getSpmName(), item.getShipName())).findFirst().get().getSpmId()); + in.setShipEnName(trendShipList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getSpmName(), item.getShipName())).findFirst().get().getSpmEname()); + in.setPreArrivalTime(trendShipList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getSpmName(), item.getShipName())).findFirst().get().getPlanArrivePortTime()); in.setPortAreaId(portAreaList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getPortArea())).findFirst().get().getId()); in.setBrandId(brandList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getBrand())).findFirst().get().getId()); in.setCartTypeId(carTypeList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getCartType())).findFirst().get().getId()); @@ -3521,10 +4136,26 @@ public class ExportInHandler implements BaseHandler { // 验证件,毛,体 // 件数 int totalQuantity = exportInList.stream().mapToInt(CustomerExportIn::getQuantity).sum() + item.getValue().stream().mapToInt(CustomerExportIn::getQuantity).sum(); + // 是否有其它的货代用了些提单号 + List repeatBillNum = exportInList.stream().filter(s -> !StringUtils.equals(s.getFreightId(), lastE.getFreightId())).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(repeatBillNum)) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "当前已有其他货代" + repeatBillNum.get(0).getFreight() + "使用该提单号,不可重复申请"); + return o; + }).collect(Collectors.toList())); + return; + } if (totalQuantity > lastE.getEachQuantity()) { errorDataList.addAll(item.getValue().stream().map(p -> { JSONObject o = JSONObject.from(p); - o.put("status", "数量不得超过单票件数"); + Optional first = exportInList.stream().filter(s -> !StringUtils.equals(s.getFreightId(), lastE.getFreightId())).findFirst(); + if (first.isPresent()) { + String str = first.get().getFreight(); + o.put("status", "同提单数量之和超过单票数量 注:当前已有其他货代【" + str + "】使用该提单号"); + } else { + o.put("status", "同提单数量之和超过单票数量"); + } return o; }).collect(Collectors.toList())); return; @@ -3558,7 +4189,7 @@ public class ExportInHandler implements BaseHandler { }); if (CollectionUtils.isNotEmpty(errorDataList)) { - errorDataList.addAll(successDataList); +// errorDataList.addAll(successDataList); return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); } @@ -3593,13 +4224,7 @@ public class ExportInHandler implements BaseHandler { if (StringUtils.equals(ss.getNatureFlagName(), "正常")) { // 需要自动生成 // vins.addAll(rst.get(vvyId).stream().map(t -> t.getVinCode()).collect(Collectors.toList())); // 出口进场计划备件条码生成的规则要变一下,BJ+年月日时分+5随机数,一共要17位 - String prefix = StringUtils.join("BJ", DateUtil.format(new Date(), "yyMMddHHmm")); - do { - String vin = prefix + RandomUtil.randomNumbers(5); - if (!vins.contains(vin)) { - vins.add(vin); - } - } while (vins.size() < ss.getQuantity()); + vins = genBjNo(ss.getQuantity(), null); } List spares = vins.stream().map(p -> { CustomerExportInCargo entity = new CustomerExportInCargo(); @@ -3638,6 +4263,8 @@ 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()); } catch (Exception e) { log.error("上传错误", e); return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), e.getMessage()); @@ -3689,15 +4316,17 @@ public class ExportInHandler implements BaseHandler { @ApiOperation("出口进场计划船名航次") @PostMapping("/plan/ship") public Result> getExportInPlanShipList( - @RequestParam(required = false) @NotBlank(message = "港区ID不能为空") String portAreaId, + @RequestParam(required = false) String portAreaId, @RequestParam(required = false, defaultValue = "1") Integer current, @RequestParam(required = false, defaultValue = "10") Integer size, @RequestParam(required = false) String q) { QueryWrapper query = new QueryWrapper<>(); query.select("distinct ship_id, ship_name, ship_en_name"); query.eq("check_status", AuditEnum.AUDIT_PASS); - query.eq("port_area_id", portAreaId); + query.eq(StringUtils.isNotEmpty(portAreaId), "port_area_id", portAreaId); query.eq("load_ship_flag", 0); + query.eq("unberth_flag", 0); + query.gt("end_enter_time", DateUtils.getDayStart(DateUtils.addDay(new Date(), -15))); if (StringUtils.isNotEmpty(q)) { query.and((wrapper) -> { wrapper.like("ship_name", q); @@ -3730,6 +4359,16 @@ public class ExportInHandler implements BaseHandler { return ResultUtil.success("success"); } + @ApiOperation("离泊确认状态通知") + @PostMapping("/unberth/confirm") + public Result unberthConfirm(@RequestBody @Validated ShipStatusVo vo) { + customerExportInService.lambdaUpdate().eq(CustomerExportIn::getShipId, vo.getShipId()) + .eq(CustomerExportIn::getVoyageId, vo.getVoyageId()) + .set(CustomerExportIn::getUnberthFlag, StringUtils.equals("0", vo.getStatus()) ? 0 : 1) + .update(); + return ResultUtil.success("success"); + } + @ApiOperation("出口进场计划航次") @PostMapping("/plan/voyage") public Result> getPlanVoyageList( @@ -3816,4 +4455,209 @@ public class ExportInHandler implements BaseHandler { return ResultUtil.success(rst, String.valueOf(page.getTotal())); } + + @ApiOperation("同步预进港时间") + @PostMapping("/update/preArrivalTime") + public Result getCheckShipList(@RequestBody @Validated UpdatePreArrivalTimeVo form) { + if (StringUtils.equalsAny(form.getNewVoyage(), "HT6", "HTTC", "HTLG")) { + // 查找出港区 + Page page = customerExportInService.lambdaQuery() + .eq(CustomerExportIn::getShipId, form.getShipId()) + .eq(CustomerExportIn::getVoyageId, form.getVoyageId()) + .page(new Page<>(1, 1)); + + if (CollectionUtils.isEmpty(page.getRecords())) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "没有可修改的记录"); + } + + String portArea = page.getRecords().get(0).getPortArea(); + + if (StringUtils.equalsIgnoreCase(form.getNewVoyage(), "HT6") && StringUtils.equals(portArea, "外高桥")) { + + } else if (StringUtils.equalsIgnoreCase(form.getNewVoyage(), "HTTC") && StringUtils.equals(portArea, "太仓")) { + + } else if (StringUtils.equalsIgnoreCase(form.getNewVoyage(), "HTLG") && StringUtils.equals(portArea, "临港")) { + + } else { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "虚拟航次名错误"); + } + } + customerExportInService.lambdaUpdate() + .eq(CustomerExportIn::getShipId, form.getShipId()) + .eq(CustomerExportIn::getVoyageId, form.getVoyageId()) + .eq(form.getOldPreArrivalTime() != null, CustomerExportIn::getPreArrivalTime, form.getOldPreArrivalTime()) + .set(CustomerExportIn::getPreArrivalTime, form.getPreArrivalTime()) + .set(StringUtils.equalsAny(form.getNewVoyage(), "HT6", "HTTC", "HTLG"), CustomerExportIn::getVoyageId, form.getNewVoyage()) + .set(StringUtils.isNotEmpty(form.getNewVoyage()), CustomerExportIn::getVoyage, form.getNewVoyage()) + .update(); + if (StringUtils.isNotEmpty(form.getNewVoyage())) { + customerExportLoadService.lambdaUpdate() + .eq(CustomerExportLoad::getShipId, form.getShipId()) + .eq(CustomerExportLoad::getVoyageId, form.getVoyageId()) + .set(StringUtils.isNotEmpty(form.getNewVoyage()), CustomerExportLoad::getVoyage, form.getNewVoyage()) + .set(StringUtils.equalsAny(form.getNewVoyage(), "HT6", "HTTC", "HTLG"), CustomerExportLoad::getVoyageId, form.getNewVoyage()) + .update(); + } + + return ResultUtil.success("success"); + } + + @ApiOperation("同步预靠泊时间时间") + @PostMapping("/update/planArrivePortTime") + public Result getCheckShipList(@RequestBody @Validated UpdatePlanArrivePortVo form) { + customerExportInService.lambdaUpdate() + .eq(CustomerExportIn::getShipId, form.getShipId()) + .eq(CustomerExportIn::getVoyageId, form.getVoyageId()) + .set(CustomerExportIn::getPlanArrivePortTime, form.getPlanArrivePortTime()) + .update(); + + return ResultUtil.success("success"); + } + + @ApiOperation("审核端批量获取进港信息") + @PostMapping("/check/batchCheckShip/list") + public Result> getCheckShipList(@RequestBody @Validated ExportInBathCheckQuery query) { + QueryWrapper cQuery = new QueryWrapper<>(); + cQuery.select("distinct port_area_id, port_area, ship_id, ship_name, ship_en_name, voyage_id, voyage, pre_arrival_time, check_status"); + cQuery.eq(StringUtils.isNotEmpty(query.getPortAreaId()), "port_area_id", query.getPortAreaId()); + cQuery.eq(StringUtils.isNotEmpty(query.getShipId()), "ship_id", query.getShipId()); + cQuery.eq(StringUtils.isNotEmpty(query.getVoyageId()), "voyage_id", query.getVoyageId()); + cQuery.eq("check_status", query.getCheckStatus()); + cQuery.orderByDesc("pre_arrival_time"); + + Page page = customerExportInService.page(new Page<>(query.getPage(), query.getRows()), cQuery); + + return ResultUtil.success(page); + } + + + /** + * 审核 + * + * @param check + * @return + */ + @ApiOperation("多船审核") + @PostMapping("/check/more/ship") + public Result checkMoreVoyage(@RequestBody @Validated ExportInBatchCheckVo check) throws Exception { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(CustomerExportIn::getCheckStatus, check.getOriginalCheckStatus()); + if (!StringUtils.equals("0", check.getType())) { + // exportIn.getCartType(), "备件", "BJ" + query.ne(StringUtils.equals("1", check.getType()), CustomerExportIn::getCartType, "备件"); + query.eq(StringUtils.equals("2", check.getType()), CustomerExportIn::getCartType, "备件"); + } + query.and((wrapper) -> { + for (BatchCheckShipVo ship : check.getShips()) { + wrapper.or(i -> i.eq(CustomerExportIn::getPortAreaId, ship.getPortAreaId()) + .eq(CustomerExportIn::getShipId, ship.getShipId()) + .eq(CustomerExportIn::getVoyageId, ship.getVoyageId()) + .eq(ship.getPreArrivalTime() != null, CustomerExportIn::getPreArrivalTime, ship.getPreArrivalTime())); + } + }); + + + // 待审核的数据 + List list = customerExportInService.list(query); + + CustomerExportIn update = new CustomerExportIn(); + update.setCheckTime(new Date()); + update.setCheckStatus(check.getCheckStatus()); + update.setCheckResult(check.getCheckResult()); + update.setCheckManId(UserContext.getUser().getUserId()); + + if (CollectionUtils.isNotEmpty(list)) { + BatchConfirmReviewReq req = new BatchConfirmReviewReq(); + req.setIds(list.stream().map(s -> s.getId() + "").collect(Collectors.toList())); + Boolean rst = openApi.batchConfirmReview(req); + if (!rst) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "审核失败"); + } + + if (check.getCheckStatus() == AuditEnum.AUDIT_PASS) { + // 获取航次的离泊状态 + List collect = list.stream().map(s -> s.getVoyageId()).filter(s -> !StringUtils.equalsAny(s, "HT6", "HTLG", "HTTC")).distinct().collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(collect)) { + List shipmentBerthsStatusRespDTOS = shpApi.queryVoyagesBerthsStatusByVvyIds(collect); + if (CollectionUtils.isNotEmpty(shipmentBerthsStatusRespDTOS)) { + List strings = shipmentBerthsStatusRespDTOS.stream().filter(s -> StringUtils.equalsAny(s.getUnberthedStatus(), "1")).map(s -> s.getVvyId()).distinct().collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(strings)) { + customerExportInService.lambdaUpdate().in(CustomerExportIn::getVoyageId, strings) + .set(CustomerExportIn::getUnberthFlag, "1").update(); + } + } + } + } + } + + boolean row = customerExportInService.update(update, query); + + if (row) { + // 记录日志 + for (CustomerExportIn exportIn : list) { + LogRecordDTO log = new LogRecordDTO(); + log.setOperateData(exportIn); + log.setStatus(check.getCheckStatus() == AuditEnum.AUDIT_PASS ? 0 : 1); + log.setOperateTime(new Date()); + log.setUserId(UserContext.getUser().getUserId()); + log.setUserName(UserContext.getUser().getUsername()); + EsLogApprovalUtil.writeLog(log); + } + + if (check.getCheckStatus() == AuditEnum.AUDIT_PASS) { + customerService.syncAddExportInToOld(list); + } + + return ResultUtil.success("success"); + } + + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "没有待审核数据"); + } + + @ApiOperation("多船批量删除") + @PostMapping("/delete/more/ship") + @Transactional(rollbackFor = {Exception.class}) + public Result deleteMoreVoyage(@RequestBody @Validated @NotNull(message = "请传入船名,航次信息") @Size(min = 1, message = "请传入船名,航次信息") ValidList form) throws Exception { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.and((wrapper) -> { + for (BatchCheckShipVo ship : form) { + wrapper.or(i -> i.eq(CustomerExportIn::getPortAreaId, ship.getPortAreaId()) + .eq(CustomerExportIn::getShipId, ship.getShipId()) + .eq(CustomerExportIn::getVoyageId, ship.getVoyageId()) + .eq(ship.getPreArrivalTime() != null, CustomerExportIn::getPreArrivalTime, ship.getPreArrivalTime())); + } + }); + + // 待审核的数据 + List list = customerExportInService.list(query); + + if (CollectionUtils.isNotEmpty(list)) { + // 删除明细 + List ids = list.stream().map(item -> item.getId()).collect(Collectors.toList()); + + customerExportInCargoService.lambdaUpdate().in(CustomerExportInCargo::getExportInId, ids).remove(); + + customerExportInService.removeByIds(ids); + } + + return ResultUtil.success("success"); + } + + + @PostMapping("/bj/gen") + public Result> genBjNos(@RequestParam Integer num) { + List rst = new ArrayList<>(); + for (int i =0 ; i < 10; i++) { + ((Runnable) () -> { + List vins = genBjNo(num, null); + rst.addAll(vins); + }).run(); + + } + Map collect = rst.stream().collect(Collectors.groupingBy(s -> s, Collectors.counting())); + List strings = collect.entrySet().stream().filter(s -> s.getValue() > 1).map(s -> s.getKey()).collect(Collectors.toList()); + System.err.println(strings); + System.err.println(rst.size()); + return ResultUtil.success(rst); + } } diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportInspectHandler.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportInspectHandler.java index e84f7a4..6be67e9 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportInspectHandler.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportInspectHandler.java @@ -1,10 +1,14 @@ package com.haitonggauto.rtosc.handler; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.RandomUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.exception.ExcelDataConvertException; import com.alibaba.excel.write.metadata.WriteSheet; +import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -19,11 +23,15 @@ import com.haitonggauto.rtosc.common.dto.DictDTO; import com.haitonggauto.rtosc.common.dto.Result; import com.haitonggauto.rtosc.common.enums.ErrorType; import com.haitonggauto.rtosc.common.handler.BaseHandler; +import com.haitonggauto.rtosc.common.utils.DateUtils; import com.haitonggauto.rtosc.common.utils.ResultUtil; import com.haitonggauto.rtosc.common.utils.ValidationGroup; import com.haitonggauto.rtosc.common.utils.WrapperKit; import com.haitonggauto.rtosc.dto.*; +import com.haitonggauto.rtosc.excel.ExportInPlanExcel; import com.haitonggauto.rtosc.excel.ExportInspectExportExcel; +import com.haitonggauto.rtosc.excel.InspectExcel; +import com.haitonggauto.rtosc.handler.excel.ReadExcelListener; import com.haitonggauto.rtosc.query.CargoQuery; import com.haitonggauto.rtosc.query.ExportInspectCheckQuery; import com.haitonggauto.rtosc.query.ExportInspectQuery; @@ -31,6 +39,8 @@ import com.haitonggauto.rtosc.repository.entity.*; import com.haitonggauto.rtosc.handler.mapper.PoMapper; import com.haitonggauto.rtosc.repository.enums.AuditEnum; import com.haitonggauto.rtosc.repository.enums.InspectStatusEnum; +import com.haitonggauto.rtosc.repository.service.CustomerExportInCargoService; +import com.haitonggauto.rtosc.repository.service.CustomerExportInService; import com.haitonggauto.rtosc.repository.service.CustomerExportInspectCargoService; import com.haitonggauto.rtosc.repository.service.CustomerExportInspectService; import com.haitonggauto.rtosc.service.CustomerService; @@ -40,22 +50,34 @@ import com.nuzar.rtops.log.service.EsLogApprovalUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.core.io.ClassPathResource; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import java.io.*; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.net.URLEncoder; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; +@Slf4j @RestController @RequestMapping("/ci") @Api(tags = "出口海关查验") @@ -77,6 +99,15 @@ public class ExportInspectHandler implements BaseHandler { @Resource private NuzarYardApi yardApi; + @Resource + private CustomerExportInService exportInService; + + @Resource + private CustomerExportInCargoService exportInCargoService; + + @Resource + private DictHandler dictHandler; + @ApiOperation("船名航次模糊匹配") @PostMapping("/shipVoyage") public Result> getExportInShipNameList( @@ -176,16 +207,19 @@ public class ExportInspectHandler implements BaseHandler { @ApiOperation("提单号模糊匹配") @PostMapping("/billNo/query") public Result> getExportInBillNoList( + @ApiParam(name = "操作方式, 0为前端,1为审核端") @RequestParam(required = false, defaultValue = "0") String type, @RequestParam(required = false, defaultValue = "1") Integer current, @RequestParam(required = false, defaultValue = "10") Integer size, @RequestParam(required = false) String shipName, @RequestParam(required = false) String voyage, @RequestParam(required = false) String q) { - LambdaQueryWrapper query = new LambdaQueryWrapper<>(); - query.eq(CustomerExportInspect::getTradType, "E"); - query.eq(StringUtils.isNotEmpty(shipName), CustomerExportInspect::getShipName, shipName); - query.eq(StringUtils.isNotEmpty(voyage), CustomerExportInspect::getVoyage, voyage); - query.like(StringUtils.isNotEmpty(q), CustomerExportInspect::getBillNo, q); // 提单号 + QueryWrapper query = new QueryWrapper<>(); + query.select("distinct bill_no"); + query.eq("trad_type", "E"); + query.eq(StringUtils.equals(type, "0"), "create_by", UserContext.getUser().getUserId()); + query.eq(StringUtils.isNotEmpty(shipName), "ship_name", shipName); + query.eq(StringUtils.isNotEmpty(voyage), "voyage", voyage); + query.like(StringUtils.isNotEmpty(q), "bill_no", q); // 提单号 Page page = customerExportInspectService.page(new Page<>(current, size), query); List list = page.getRecords(); @@ -506,6 +540,28 @@ public class ExportInspectHandler implements BaseHandler { List cargos = customerExportInspectCargoService.list(new LambdaQueryWrapper().eq(CustomerExportInspectCargo::getExportInspectId, id)); + // 获取实时 + if (CollectionUtils.isNotEmpty(cargos)) { + GoodsStatusReq req = new GoodsStatusReq(); + req.setBusinessType("INSPECT"); + req.setImportExportType("E"); + req.setVvyId(StringUtils.equalsAnyIgnoreCase(exportInspect.getVoyageId(), "HT6", "HTLG", "HTTC") ? "" : exportInspect.getVoyageId()); + req.setVinCodeList(cargos.stream().map(p -> p.getVin()).collect(Collectors.toList())); + + List resp = openApi.getGoodsStatus(req); + + Map respMap = resp.stream().collect(Collectors.toMap(p -> p.getVinCode(), p -> p)); + + cargos.stream().forEach(p -> { + GoodsStatusResp r = respMap.get(p.getVin()); + if (r != null) { + p.setArea(r.getPosition()); + } else { + p.setArea(""); + } + }); + } + customerService.wrapperEntity(cargos); exportInspect.setCargos(cargos); @@ -549,6 +605,34 @@ public class ExportInspectHandler implements BaseHandler { } Page page = customerExportInspectCargoService.page(new Page<>(query.getPage(), query.getRows()), queryWrapper); + // 获取实时 + if (CollectionUtils.isNotEmpty(page.getRecords())) { + // 需要按InspectId 进行分组 + Map> collect = page.getRecords().stream().collect(Collectors.groupingBy(CustomerExportInspectCargo::getExportInspectId)); + collect.entrySet().forEach(item -> { + CustomerExportInspect inspect = customerExportInspectService.getById(item.getKey()); + + GoodsStatusReq req = new GoodsStatusReq(); + req.setBusinessType("INSPECT"); + req.setImportExportType("E"); + req.setVvyId(StringUtils.equalsAnyIgnoreCase(inspect.getVoyageId(), "HT6", "HTLG", "HTTC") ? "" : inspect.getVoyageId()); + req.setVinCodeList(item.getValue().stream().map(p -> p.getVin()).collect(Collectors.toList())); + + List resp = openApi.getGoodsStatus(req); + + Map respMap = resp.stream().collect(Collectors.toMap(p -> p.getVinCode(), p -> p)); + + page.getRecords().stream().filter(p -> p.getExportInspectId() == item.getKey()).forEach(p -> { + GoodsStatusResp r = respMap.get(p.getVin()); + if (r != null) { + p.setArea(r.getPosition()); + } else { + p.setArea(""); + } + }); + }); + } + customerService.wrapperEntity(page.getRecords()); return ResultUtil.success(page); @@ -599,10 +683,11 @@ public class ExportInspectHandler implements BaseHandler { // 判断车辆是否在场 List vinStatus = yardApi.getVinStatus(vins); + List exists = vinStatus.stream().map(item -> item.getVinCode()).collect(Collectors.toList()); page.getRecords().stream().forEach(item -> { item.setInspect(collect.get(item.getExportInspectId())); - item.setInArea(vinStatus.contains(item.getVin())); + item.setInArea(exists.contains(item.getVin())); }); } @@ -638,8 +723,8 @@ public class ExportInspectHandler implements BaseHandler { log.setOperateData(record); log.setStatus(check.getCheckStatus() == AuditEnum.AUDIT_PASS ? 0 : 1); log.setOperateTime(new Date()); - log.setUserId(SecurityUtils.getUserId()); - log.setUserName(SecurityUtils.getUserName()); + log.setUserId(UserContext.getUser().getUserId()); + log.setUserName(UserContext.getUser().getUsername()); EsLogApprovalUtil.writeLog(log); } @@ -685,8 +770,8 @@ public class ExportInspectHandler implements BaseHandler { log.setOperateData(record); log.setStatus(check.getCheckStatus() == AuditEnum.AUDIT_PASS ? 0 : 1); log.setOperateTime(new Date()); - log.setUserId(SecurityUtils.getUserId()); - log.setUserName(SecurityUtils.getUserName()); + log.setUserId(UserContext.getUser().getUserId()); + log.setUserName(UserContext.getUser().getUsername()); EsLogApprovalUtil.writeLog(log); } @@ -787,6 +872,7 @@ public class ExportInspectHandler implements BaseHandler { private void write(AtomicInteger index, List headers, ExcelWriter excelWriter, WriteSheet writeSheet) { if (CollectionUtils.isEmpty(headers)) { + excelWriter.write(new ArrayList<>(), writeSheet); return; } @@ -810,6 +896,10 @@ public class ExportInspectHandler implements BaseHandler { // 备件号排序 List details = list.stream().filter(p -> ids.contains(p.getExportInspectId())) + .map(s -> { + s.setCartType(StringUtils.isBlank(s.getCartType()) ? "":s.getCartType()); + return s; + }) .sorted(Comparator.comparing(CustomerExportInspectCargo::getCartType).reversed()) .map(p -> { CustomerExportInspect head = collect.get(p.getExportInspectId()); @@ -823,4 +913,337 @@ public class ExportInspectHandler implements BaseHandler { }); } + + @ApiOperation("出口查验导入模板下载") + @GetMapping("/temp/down") + public void tempDownPlan(HttpServletResponse response) throws Exception { + // 加载模板 + ClassPathResource classPathResource = new ClassPathResource("templates/export_inspect_temp.xlsx"); + InputStream inputStream = classPathResource.getInputStream(); + + XSSFWorkbook workbook = new XSSFWorkbook(inputStream); + + OutputStream out = response.getOutputStream(); + try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) { + + // 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("utf-8"); + // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 + String fileName = URLEncoder.encode("出口查验导入模板", "UTF-8"); + response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); + + workbook.write(bos); + byte[] bArray = bos.toByteArray(); + InputStream is = new ByteArrayInputStream(bArray); + IOUtils.copy(is, out); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (out != null) { + try { + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + @ApiOperation("出口查验导入") + @PostMapping("/inspect/import-to-add") + public Result> exportInPlanUpload( + @ApiParam(name = "操作方式, 0为前端,1为审核端") @RequestParam(required = false, defaultValue = "0") String type, + MultipartFile file) { + // 所有读取的数据 + List dataList = new ArrayList<>(); + + // 有错误的数据 + List errorDataList = new ArrayList<>(); + + // 验证通过的数据 + List successDataList = new ArrayList<>(); + + Map headMap = new HashMap<>(); + Map> detailMap = new HashMap<>(); + + try { + + EasyExcel.read(file.getInputStream(), InspectExcel.class, new ReadExcelListener() { + @Override + protected void saveData(List list) { // 保存数据 + dataList.addAll(list); + } + }).sheet().doRead(); + + ValidatorFactory vf = Validation.buildDefaultValidatorFactory(); + Validator validator = vf.getValidator(); + + List validData = new ArrayList<>(); + + // 需要保存的数据 + List saveData = new ArrayList<>(); + + // 数据验证 + dataList.stream().forEach(item -> { + Set> set = validator.validate(item); + if (CollectionUtils.isEmpty(set)) { // 验证通过的 + validData.add(item); + } else { // 验证失败的 + JSONObject o = JSONObject.from(item); + o.put("status", set.stream().map(p -> p.getMessage()).collect(Collectors.joining(","))); + errorDataList.add(o); + } + }); + + if (CollectionUtils.isEmpty(validData)) { // 数据完整性检验 + if (CollectionUtils.isEmpty(errorDataList)) { // 代表没有读取到数据 + JSONObject o = new JSONObject(); + o.put("status", "未读取到数据"); + errorDataList.add(o); + } + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + + // 获取用户绑定的货代 + List userBindFreight = openApi.getUserBindFreight(); + + // 港区基础数据 + List portAreaList = dictHandler.getPortAreaList(null).getData(); + + // 航次不能为空 + validData.stream().forEach(item -> { + if (portAreaList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getPortArea())).count() == 0) { + JSONObject o = JSONObject.from(item); + o.put("status", "港区不存在"); + errorDataList.add(o); + return; + } + saveData.add(item); + }); + + // 首先按对船名,般次,提单进行分组 + Map> inMap = saveData.stream() + .collect(Collectors.groupingBy(item -> StringUtils.joinWith("#$#", item.getShipName(), StringUtils.isEmpty(item.getVoyage()) ? " " : item.getVoyage(), item.getBillNo()), Collectors.toList())); + + inMap.entrySet().forEach(item -> { + String[] keys = StringUtils.split(item.getKey(), "#$#"); + String shipName = keys[0]; // 船名 + String voyageName = keys[1]; // 航次 + String billNo = keys[2]; // 提单号 + + // 判断船名是否在进港计划中 + List list = exportInService.lambdaQuery().eq(CustomerExportIn::getShipName, shipName) + .ne(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_REJECT) + .last("limit 1").list(); + + if (CollectionUtils.isEmpty(list)) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "查验申请中的船名不存在"); + return o; + }).collect(Collectors.toList())); + return; + } + // 如果航次不为空 + if (StringUtils.isNotBlank(voyageName)) { + list = exportInService.lambdaQuery().eq(CustomerExportIn::getShipName, shipName) + .eq(CustomerExportIn::getVoyage, voyageName) + .ne(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_REJECT) + .last("limit 1").list(); + + if (CollectionUtils.isEmpty(list)) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "查验申请中的航次不存在"); + return o; + }).collect(Collectors.toList())); + return; + } + } + + // 判断提单号 + list = exportInService.lambdaQuery().eq(CustomerExportIn::getShipName, shipName) + .eq(StringUtils.isNotEmpty(voyageName), CustomerExportIn::getVoyage, voyageName) + .eq(CustomerExportIn::getBillNum, billNo) + .ne(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_REJECT) + .last("limit 1").list(); + + if (CollectionUtils.isEmpty(list)) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", StringUtils.isNotEmpty(voyageName) ? "该船名航次下的提单号不存在" : "该船名下的提单号不存在"); + return o; + }).collect(Collectors.toList())); + return; + } + + CustomerExportIn in = list.get(0); + + // 提单对应的货代与登录账号是否一致 + Long id = in.getId(); + String freightId = in.getFreightId(); + if (CollectionUtils.isEmpty(userBindFreight) || userBindFreight.stream().filter(s -> StringUtils.equals(freightId, s.getCueId())).count() == 0) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "提单号的货代与登录账号不一致"); + return o; + }).collect(Collectors.toList())); + return; + } + + // 车架号是否在该提单下 + Map vins = item.getValue().stream().collect(Collectors.toMap(InspectExcel::getVin, s -> s)); + List exists = exportInCargoService.lambdaQuery().eq(CustomerExportInCargo::getExportInId, id) + .in(CustomerExportInCargo::getVin, vins.keySet()).list(); + List existsVins = exists.stream().map(s -> s.getVin()).collect(Collectors.toList()); + List collect = vins.keySet().stream().filter(s -> !existsVins.contains(s)).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(collect)) { + collect.stream().forEach(s -> { + JSONObject o = JSONObject.from(vins.get(s)); + o.put("status", "提单号不存在此车架号"); + errorDataList.add(o); + }); + return; + } + + // 港区是否一致 + long count = item.getValue().stream().map(s -> s.getPortArea()).collect(Collectors.toList()) + .stream().filter(s -> !StringUtils.equals(s, in.getPortArea())).count(); + if (count > 0) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "港区不一致"); + return o; + }).collect(Collectors.toList())); + return; + } + + CustomerExportInspect head = PoMapper.instance.excel2Entity(item.getValue().get(0)); + + String batchNo = customerService.getSequenceNo("inspect_in_batch_no", "出口查验", "CI"); + head.setInspectStatus(InspectStatusEnum.NO_INSPECT); + head.setBatchNo(batchNo); + head.setApplicantId(UserContext.getUser().getUserId()); + head.setTradType("E"); + head.setPortAreaId(in.getPortAreaId()); + head.setCheckStatus(StringUtils.equals(type, "1") ? AuditEnum.AUDIT : AuditEnum.SUBMIT); + head.setTermcd(head.getPortAreaId()); + head.setApplyTime(new Date()); + head.setShipId(in.getShipId()); + head.setShipEnName(in.getShipEnName()); + if (StringUtils.isNotEmpty(head.getVoyage())) { + head.setVoyageId(in.getVoyageId()); + } + head.setApplyObjId(in.getFreightId()); + head.setApplyObj(in.getFreight()); + if (StringUtils.isEmpty(head.getCompany())) { + head.setCompany(head.getApplyObj()); + } + + List detail = item.getValue().stream().map(s -> { + CustomerExportInspectCargo c = new CustomerExportInspectCargo(); + c.setCargoType(StringUtils.startsWith(s.getVin(), "BJ") ? 1 : 0); + c.setBrand(in.getBrand()); + c.setBrandId(in.getBrandId()); + c.setCartTypeId(in.getCartTypeId()); + c.setCartType(in.getCartType()); + c.setModels(in.getModels()); + c.setVin(s.getVin()); + return c; + }).collect(Collectors.toList()); + + head.setPlannedCargoQuantity((int)detail.stream().filter( s -> s.getCargoType() == 0).count()); + head.setPlannedSpareQuantity(detail.size() - head.getPlannedCargoQuantity()); + + headMap.put(item.getKey(), head); + detailMap.put(item.getKey(), detail); + + }); + + if (CollectionUtils.isNotEmpty(errorDataList)) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + + // 判断车辆是否在场 + List vinStatus = yardApi.getVinStatus(dataList.stream().map(s -> s.getVin()).collect(Collectors.toList())); + if (CollectionUtils.isEmpty(vinStatus)) { + errorDataList.addAll(dataList.stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "所有查验的车架号均不在场"); + return o; + }).collect(Collectors.toList())); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + + Map vinStatusMap = vinStatus.stream().collect(Collectors.toMap(VinStatus::getVinCode, s -> s)); + + // 保存对象 + headMap.keySet().stream().forEach(s -> customerService.saveExportInspect(headMap.get(s), detailMap.get(s))); + + successDataList.addAll(dataList.stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "成攻"); + o.put("yardPos", vinStatusMap.containsKey(p.getVin()) ? vinStatusMap.get(p.getVin()).getYardPos() : "未进港"); + return o; + }).collect(Collectors.toList())); + + } catch (ExcelDataConvertException e) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入数据错误,请确认导入数据模板是否正确, 行:"+e.getRowIndex()+" 列:" + e.getColumnIndex()); + } catch (Exception e) { + log.error("上传错误", e); + return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), e.getMessage()); + } + + List rst = new ArrayList<>(); + rst.addAll(successDataList.stream().filter(s -> StringUtils.isNotBlank(s.getString("yardPos"))).collect(Collectors.toList())); + rst.addAll(successDataList.stream().filter(s -> StringUtils.isBlank(s.getString("yardPos"))).collect(Collectors.toList())); + + return ResultUtil.success(rst); + } + + @ApiOperation("验证航次是否在进港计划中") + @PostMapping("/valid/voyage") + public Result validVoyage(@RequestParam @NotBlank(message = "船ID不能为空") String shipId, @RequestParam @NotBlank(message = "航次ID不能为空") String voyageId) { + Long count = exportInService.lambdaQuery().eq(CustomerExportIn::getVoyageId, voyageId) + .eq(CustomerExportIn::getShipId, shipId).count(); + + return ResultUtil.success(count > 0); + } + + @ApiOperation("提单号,货代,车架号验证") + @PostMapping("/valid/billno") + public Result validBillno(@RequestBody InspectValidVo form) { + List list = exportInService.lambdaQuery().eq(CustomerExportIn::getShipId, form.getShipId()) + .eq(CustomerExportIn::getBillNum, form.getBillNo()) + .ne(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_REJECT) + .list(); + + if(CollectionUtil.isEmpty(list)) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(),"该船名下提单号不存在"); + } + + // 获取用户绑定的货代 + List userBindFreight = openApi.getUserBindFreight(); + if (CollectionUtils.isEmpty(userBindFreight) || userBindFreight.stream().filter(s -> StringUtils.equals(list.get(0).getFreightId(), s.getCueId())).count() == 0) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(),"提单号的货代与登录账号不一致"); + } + + if (CollectionUtils.isNotEmpty(form.getVins())) { + List cargos = exportInCargoService.lambdaQuery().in(CustomerExportInCargo::getExportInId, list.stream().map(s -> s.getId()).collect(Collectors.toList())) + .in(CustomerExportInCargo::getVin, form.getVins()).list(); + List collect = cargos.stream().map(s -> s.getVin()).collect(Collectors.toList()); + List strings = form.getVins().stream().filter(s -> !collect.contains(s)).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(strings)) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(),"提单号不存在此车架号," + StringUtils.join(strings, ",")); + } + } + + JSONObject rst = new JSONObject(); + rst.put("portAreaId", list.get(0).getPortAreaId()); + rst.put("portArea", list.get(0).getPortArea()); + + + return ResultUtil.success(rst); + } } diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportLoadHandler.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportLoadHandler.java index c05b985..f271be8 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportLoadHandler.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportLoadHandler.java @@ -1,7 +1,10 @@ package com.haitonggauto.rtosc.handler; +import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.DateUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.exception.ExcelDataConvertException; import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.Wrapper; @@ -19,13 +22,16 @@ import com.haitonggauto.rtosc.common.dto.DictDTO; import com.haitonggauto.rtosc.common.dto.Result; import com.haitonggauto.rtosc.common.enums.ErrorType; import com.haitonggauto.rtosc.common.handler.BaseHandler; +import com.haitonggauto.rtosc.common.utils.DateUtils; import com.haitonggauto.rtosc.common.utils.ResultUtil; import com.haitonggauto.rtosc.common.utils.ValidationGroup; import com.haitonggauto.rtosc.common.utils.WrapperKit; import com.haitonggauto.rtosc.dto.*; import com.haitonggauto.rtosc.excel.*; import com.haitonggauto.rtosc.handler.excel.CustomCellWriteHandler; +import com.haitonggauto.rtosc.handler.excel.ExcelMergeUtil; import com.haitonggauto.rtosc.query.CargoQuery; +import com.haitonggauto.rtosc.query.ExportInQuery; import com.haitonggauto.rtosc.query.ExportLoadCheckQuery; import com.haitonggauto.rtosc.query.ExportLoadQuery; import com.haitonggauto.rtosc.repository.entity.*; @@ -34,11 +40,11 @@ import com.haitonggauto.rtosc.handler.mapper.PoMapper; import com.haitonggauto.rtosc.repository.enums.AuditEnum; import com.haitonggauto.rtosc.repository.service.*; import com.haitonggauto.rtosc.service.CustomerService; -import com.nuzar.common.security5.common.util.SecurityUtils; import com.nuzar.rtops.log.dto.LogRecordDTO; import com.nuzar.rtops.log.service.EsLogApprovalUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; @@ -61,6 +67,7 @@ import java.io.IOException; import java.io.OutputStream; import java.net.URLEncoder; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @RestController @@ -230,18 +237,20 @@ public class ExportLoadHandler implements BaseHandler { @ApiOperation("提单号模糊匹配") @PostMapping("/billNo/query") public Result> getExportInBillNoList( + @ApiParam(name = "操作方式, 0为前端,1为审核端") @RequestParam(required = false, defaultValue = "0") String type, @RequestParam(required = false, defaultValue = "W") String tradType, @RequestParam(required = false, defaultValue = "1") Integer current, @RequestParam(required = false, defaultValue = "10") Integer size, @RequestParam(required = false) String shipName, @RequestParam(required = false) String voyage, @RequestParam(required = false) String q) { - LambdaQueryWrapper query = new LambdaQueryWrapper<>(); - query.eq(CustomerExportLoad::getCreateBy, UserContext.getUser().getUserId()); - query.eq(StringUtils.isNotEmpty(shipName), CustomerExportLoad::getShipName, shipName); - query.eq(StringUtils.isNotEmpty(voyage), CustomerExportLoad::getVoyage, voyage); - query.like(StringUtils.isNotEmpty(q), CustomerExportLoad::getBillNo, q); // 提单号 - query.like(CustomerExportLoad::getTradType, tradType); + QueryWrapper query = new QueryWrapper<>(); + query.select("distinct bill_no"); + query.eq(StringUtils.equals(type, "0"), "create_by", UserContext.getUser().getUserId()); + query.eq(StringUtils.isNotEmpty(shipName), "ship_name", shipName); + query.eq(StringUtils.isNotEmpty(voyage), "voyage", voyage); + query.like(StringUtils.isNotEmpty(q), "bill_no", q); // 提单号 + query.eq("trad_type", tradType); Page page = customerExportLoadService.page(new Page<>(current, size), query); List list = page.getRecords(); @@ -327,7 +336,7 @@ public class ExportLoadHandler implements BaseHandler { // 数据拼装 list.stream().forEach(item -> { - List cs = collect.get(item.getId()); + List cs = collect.get(item.getId()); item.setVins(cs); }); } @@ -356,13 +365,36 @@ public class ExportLoadHandler implements BaseHandler { @ApiOperation("根据航次ID查询审核通过出口装船记录") @PostMapping("/query-list/voyage") - public Result> checkQuery(@RequestParam(required = false) @NotBlank(message = "航次ID不能为空") String voyageId, - @RequestParam(required = false) AuditEnum status) { + public Result> checkQuery( + @RequestParam(required = false) @NotBlank(message = "航次ID不能为空") String voyageId, + @RequestParam(required = false) @ApiParam("提单号列表") List billNos, + @RequestParam(required = false) AuditEnum status) { + ExportLoadCheckQuery query = new ExportLoadCheckQuery(); if (status == null) { status = AuditEnum.AUDIT_PASS; } + query.setCheckStatus(status); + query.setVoyageId(voyageId); + query.setBillNos(billNos); - List list = customerExportLoadService.getListByVoyageId(voyageId, status); + Wrapper queryWrapper = new WrapperKit() { + }.changeBaseQueryToWrapper(CustomerExportLoad.class, query); + List list = customerExportLoadService.list(queryWrapper); + customerService.wrapperEntity(list); + + if (CollectionUtils.isNotEmpty(list)) { + List cargos = customerExportLoadCargoService.lambdaQuery() + .in(CustomerExportLoadCargo::getExportLoadId, list.stream().map(item -> item.getId()).collect(Collectors.toList())).list(); + + // 按进港ID进行分组 + Map> collect = cargos.stream().collect(Collectors.groupingBy(CustomerExportLoadCargo::getExportLoadId)); + + // 数据拼装 + list.stream().forEach(item -> { + List cs = collect.get(item.getId()); + item.setVins(cs); + }); + } // 判断是否换船,找出车架号重复,且航次不一样的记录 List vins = customerExportLoadCargoService.getChangeShipVin(voyageId); @@ -436,7 +468,7 @@ public class ExportLoadHandler implements BaseHandler { } } - Long id = customerService.saveExportLoad(exportLoad, cargos); + Long id = customerService.saveExportLoad(exportLoad, null, cargos); return ResultUtil.success(String.valueOf(id)); } @@ -482,8 +514,8 @@ public class ExportLoadHandler implements BaseHandler { @ApiOperation("撤销提交审核") @PostMapping("/submit-check/reverse") public Result submitCheckReverse(@RequestBody - @NotNull(message = "请传入要审核的出口装船ID") - @Size(min = 1, message = "ID列表不能为空") List ids) { + @NotNull(message = "请传入要审核的出口装船ID") + @Size(min = 1, message = "ID列表不能为空") List ids) { // 是否除提交审核的其它状态 Long count = customerExportLoadService.lambdaQuery().in(CustomerExportLoad::getId, ids).ne(CustomerExportLoad::getCheckStatus, AuditEnum.AUDIT).count(); if (count > 0) { @@ -504,8 +536,14 @@ public class ExportLoadHandler implements BaseHandler { @ApiOperation("删除") @PostMapping("/del") public Result delete(@RequestBody - @NotNull(message = "请传入要删除的ID") - @Size(min = 1, message = "请传入要删除的ID") List ids) { + @NotNull(message = "请传入要删除的ID") + @Size(min = 1, message = "请传入要删除的ID") List ids) { + // 只能删除待审核,待提交,已驳回的数据 + Long count = customerExportLoadService.lambdaQuery().in(CustomerExportLoad::getId, ids) + .notIn(CustomerExportLoad::getCheckStatus, AuditEnum.AUDIT, AuditEnum.SUBMIT, AuditEnum.AUDIT_REJECT).count(); + if (count > 0) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "只能删除待审核,待提交,已驳回的数据"); + } for (Long id : ids) { customerService.delExportLoad(id); } @@ -601,6 +639,7 @@ public class ExportLoadHandler implements BaseHandler { public Result edit(@RequestBody @Validated(ValidationGroup.update.class) ExportLoadVo form) { return this.edit(true, form); } + /** * 编辑 * @@ -610,7 +649,7 @@ public class ExportLoadHandler implements BaseHandler { @ApiOperation("编辑") @PostMapping("/edit") // 使用LambdaUpdateWrapper只在特定需求下做处理(推荐) 将字段修改为空值的处理方法 - public Result edit(@RequestParam(required = false, defaultValue = "false")Boolean flag, + public Result edit(@RequestParam(required = false, defaultValue = "false") Boolean flag, @RequestBody @Validated(ValidationGroup.update.class) ExportLoadVo form) { if (CollectionUtils.isNotEmpty(form.getCargos())) { List repeat = form.getCargos().stream().collect(Collectors.groupingBy(ExportLoadCargoVo::getVin, Collectors.counting())) @@ -707,43 +746,53 @@ public class ExportLoadHandler implements BaseHandler { @PostMapping("/cargos/page") public Result> cargoList(@RequestBody @Validated(ValidationGroup.update.class) CargoQuery query) { // 查询内外贸 - CustomerExportLoad exportLoad = customerExportLoadService.getById(query.getId()); +// CustomerExportLoad exportLoad = customerExportLoadService.getById(query.getId()); LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); queryWrapper.eq(query.getId() != null, CustomerExportLoadCargo::getExportLoadId, query.getId()); if (query.getCargoType() != null) { queryWrapper.eq(query.getCargoType() != null, CustomerExportLoadCargo::getCargoType, query.getCargoType()); } + queryWrapper.eq(StringUtils.isNotEmpty(query.getBrandId()), CustomerExportLoadCargo::getBrandId, query.getBrandId()); + queryWrapper.like(StringUtils.isNotEmpty(query.getVin()), CustomerExportLoadCargo::getVin, query.getVin()); + queryWrapper.exists(StringUtils.isNotEmpty(query.getBillNum()), "select id from customer_export_load where export_load_id=customer_export_load.id and bill_no like {0}", query.getBillNum()); Page page = customerExportLoadCargoService.page(new Page<>(query.getPage(), query.getRows()), queryWrapper); customerService.wrapperEntity(page.getRecords()); - // 获取作业状态 - Map collect = null; - List vins = page.getRecords().stream().map(item -> item.getVin()).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(vins)) { - VinStatusRequest req = new VinStatusRequest(); - req.setBusinessType("LOAD"); - req.setImportExportType("E"); - req.setVinCodeList(vins); - req.setVvyId(exportLoad.getVoyageId()); - List status = openApi.getVinStatus(req); - collect = status.stream().collect(Collectors.toMap(WorkStatusDTO::getVinCode, WorkStatusDTO::getWorkStatus)); - } - for (CustomerExportLoadCargo cargo : page.getRecords()) { - cargo.setDestPortId(exportLoad.getDestPortId()); - cargo.setDestPort(exportLoad.getDestPort()); - cargo.setNatureFlag(exportLoad.getNatureFlag()); - cargo.setNatureFlagName(exportLoad.getNatureFlagName()); - cargo.setTransferShipId(exportLoad.getTransferShipId()); - cargo.setTransferShipName(exportLoad.getTransferShipName()); - cargo.setTransferVoyageId(exportLoad.getTransferVoyageId()); - cargo.setTransferVoyage(exportLoad.getTransferVoyage()); - } - if (MapUtils.isNotEmpty(collect)) { - for (CustomerExportLoadCargo cargo : page.getRecords()) { - cargo.setWorkStatus(collect.get(cargo.getVin())); + Map> listMap = page.getRecords().stream().collect(Collectors.groupingBy(CustomerExportLoadCargo::getExportLoadId)); + listMap.entrySet().stream().forEach(s -> { + CustomerExportLoad exportLoad = customerExportLoadService.getById(s.getKey()); + + // 获取作业状态 + Map collect = null; + List vins = s.getValue().stream().map(item -> item.getVin()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(vins)) { + VinStatusRequest req = new VinStatusRequest(); + req.setBusinessType("LOAD"); + req.setImportExportType("E"); + req.setVinCodeList(vins); + req.setVvyId(exportLoad.getVoyageId()); + List status = openApi.getVinStatus(req); + collect = status.stream().collect(Collectors.toMap(WorkStatusDTO::getVinCode, WorkStatusDTO::getWorkStatus)); } - } + for (CustomerExportLoadCargo cargo : page.getRecords()) { + cargo.setDestPortId(exportLoad.getDestPortId()); + cargo.setDestPort(exportLoad.getDestPort()); + cargo.setNatureFlag(exportLoad.getNatureFlag()); + cargo.setNatureFlagName(exportLoad.getNatureFlagName()); + cargo.setTransferShipId(exportLoad.getTransferShipId()); + cargo.setTransferShipName(exportLoad.getTransferShipName()); + cargo.setTransferVoyageId(exportLoad.getTransferVoyageId()); + cargo.setTransferVoyage(exportLoad.getTransferVoyage()); + } + if (MapUtils.isNotEmpty(collect)) { + for (CustomerExportLoadCargo cargo : page.getRecords()) { + cargo.setWorkStatus(collect.get(cargo.getVin())); + } + } + }); + + /* if (CollectionUtils.isNotEmpty(page.getRecords()) && StringUtils.equalsIgnoreCase("N", exportLoad.getTradType())) { @@ -766,12 +815,23 @@ public class ExportLoadHandler implements BaseHandler { public Result check(@RequestBody @Validated(ValidationGroup.insert.class) ExportLoadCheckVo check) throws Exception { List spares = null; - if (check.getCheckStatus() == AuditEnum.AUDIT_PASS) { // 先找到需要同步的备件 + // 记录日志 + List logList = customerExportLoadService.lambdaQuery() + .eq(CustomerExportLoad::getShipId, check.getShipId()) + .eq(CustomerExportLoad::getVoyageId, check.getVoyageId()) + .gt(check.getSpare(), CustomerExportLoad::getSpareQuantity, 0) + .eq(!check.getSpare(), CustomerExportLoad::getSpareQuantity, 0) + .in(CollectionUtils.isNotEmpty(check.getBillNos()), CustomerExportLoad::getBillNo, check.getBillNos()) + .eq(CustomerExportLoad::getCheckStatus, AuditEnum.AUDIT) + .list(); + + if (check.getCheckStatus() == AuditEnum.AUDIT_PASS && check.getSpare()) { // 先找到需要同步的备件 // 如果审核通过,且是备件,则需要从出口进港计划中匹配到相同的数量,添加到装船申请中 LambdaQueryWrapper lQuery = new LambdaQueryWrapper<>(); lQuery.eq(CustomerExportLoad::getShipId, check.getShipId()); lQuery.eq(CustomerExportLoad::getVoyageId, check.getVoyageId()); lQuery.gt(CustomerExportLoad::getSpareQuantity, 0); + lQuery.in(CollectionUtils.isNotEmpty(check.getBillNos()), CustomerExportLoad::getBillNo, check.getBillNos()); lQuery.eq(CustomerExportLoad::getCheckStatus, AuditEnum.AUDIT); spares = customerExportLoadService.list(lQuery); @@ -786,6 +846,9 @@ public class ExportLoadHandler implements BaseHandler { update.set(CustomerExportLoad::getCheckTime, new Date()); update.eq(CustomerExportLoad::getShipId, check.getShipId()); update.eq(CustomerExportLoad::getVoyageId, check.getVoyageId()); + update.gt(check.getSpare(), CustomerExportLoad::getSpareQuantity, 0); + update.eq(!check.getSpare(), CustomerExportLoad::getSpareQuantity, 0); + update.in(CollectionUtils.isNotEmpty(check.getBillNos()), CustomerExportLoad::getBillNo, check.getBillNos()); update.eq(CustomerExportLoad::getCheckStatus, AuditEnum.AUDIT); boolean flag = customerExportLoadService.update(update); @@ -810,6 +873,9 @@ public class ExportLoadHandler implements BaseHandler { update.set(CustomerExportLoad::getCheckTime, new Date()); update.eq(CustomerExportLoad::getShipId, check.getShipId()); update.eq(CustomerExportLoad::getVoyageId, check.getVoyageId()); + update.gt(check.getSpare(), CustomerExportLoad::getSpareQuantity, 0); + update.eq(!check.getSpare(), CustomerExportLoad::getSpareQuantity, 0); + update.in(CollectionUtils.isNotEmpty(check.getBillNos()), CustomerExportLoad::getBillNo, check.getBillNos()); update.eq(CustomerExportLoad::getCheckStatus, AuditEnum.AUDIT); // update.in(CustomerExportLoad::getCreateBy, userIds); @@ -849,26 +915,61 @@ public class ExportLoadHandler implements BaseHandler { } // 记录日志 - List list = customerExportLoadService.lambdaQuery() - .eq(CustomerExportLoad::getShipId, check.getShipId()) - .eq(CustomerExportLoad::getVoyageId, check.getVoyageId()) - .eq(CustomerExportLoad::getCheckStatus, AuditEnum.AUDIT) - .list(); - - // 记录日志 - for (CustomerExportLoad record : list) { + for (CustomerExportLoad record : logList) { LogRecordDTO log = new LogRecordDTO(); log.setOperateData(record); log.setStatus(check.getCheckStatus() == AuditEnum.AUDIT_PASS ? 0 : 1); log.setOperateTime(new Date()); - log.setUserId(SecurityUtils.getUserId()); - log.setUserName(SecurityUtils.getUserName()); + log.setUserId(UserContext.getUser().getUserId()); + log.setUserName(UserContext.getUser().getUsername()); EsLogApprovalUtil.writeLog(log); } return ResultUtil.success("success"); } + @ApiOperation("其它取消审核") + @PostMapping("/cancel-check/other") + @Transactional(rollbackFor = {Exception.class}) + public Result cancelCheckOther(@RequestBody @Validated(ValidationGroup.update.class) ExportLoadCheckVo check) { + LambdaUpdateWrapper update = new LambdaUpdateWrapper<>(); + update.set(CustomerExportLoad::getCheckManId, UserContext.getUser().getUserId()); + update.set(CustomerExportLoad::getCheckMan, check.getCheckMan()); + update.set(CustomerExportLoad::getCheckStatus, AuditEnum.AUDIT); + update.set(CustomerExportLoad::getCheckResult, ""); + update.set(CustomerExportLoad::getCheckTime, new Date()); + update.eq(CustomerExportLoad::getShipId, check.getShipId()); + update.eq(CustomerExportLoad::getVoyageId, check.getVoyageId()); + update.gt(check.getSpare() != null && check.getSpare(), CustomerExportLoad::getSpareQuantity, 0); + update.eq(check.getSpare() != null && !check.getSpare(), CustomerExportLoad::getSpareQuantity, 0); + update.in(CollectionUtils.isNotEmpty(check.getBillNos()), CustomerExportLoad::getBillNo, check.getBillNos()); + update.and((wrapper) -> { + wrapper.eq(CustomerExportLoad::getCheckStatus, AuditEnum.AUDIT_PASS) + .or() + .eq(CustomerExportLoad::getCheckStatus, AuditEnum.AUDIT_REJECT); + }); + boolean flag = customerExportLoadService.update(update); + + if (!flag) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "船名,航次不存在"); + } + + // 如果审核通过,且是备件,则需要从出口进港计划中匹配到相同的数量,添加到装船申请中 + LambdaQueryWrapper lQuery = new LambdaQueryWrapper<>(); + lQuery.eq(CustomerExportLoad::getShipId, check.getShipId()); + lQuery.eq(CustomerExportLoad::getVoyageId, check.getVoyageId()); + lQuery.in(CollectionUtils.isNotEmpty(check.getBillNos()), CustomerExportLoad::getBillNo, check.getBillNos()); + lQuery.gt(CustomerExportLoad::getSpareQuantity, 0); + + List spares = customerExportLoadService.list(lQuery); + for (CustomerExportLoad load : spares) { // 找到审核通过的进港计划 + //删除 + customerExportLoadCargoService.lambdaUpdate().eq(CustomerExportLoadCargo::getExportLoadId, load.getId()).remove(); + } + + return ResultUtil.success("success"); + } + /** * 取消审核 * @@ -887,6 +988,9 @@ public class ExportLoadHandler implements BaseHandler { update.set(CustomerExportLoad::getCheckTime, new Date()); update.eq(CustomerExportLoad::getShipId, check.getShipId()); update.eq(CustomerExportLoad::getVoyageId, check.getVoyageId()); + update.gt(check.getSpare(), CustomerExportLoad::getSpareQuantity, 0); + update.eq(!check.getSpare(), CustomerExportLoad::getSpareQuantity, 0); + update.in(CollectionUtils.isNotEmpty(check.getBillNos()), CustomerExportLoad::getBillNo, check.getBillNos()); update.and((wrapper) -> { wrapper.eq(CustomerExportLoad::getCheckStatus, AuditEnum.AUDIT_PASS) .or() @@ -902,6 +1006,7 @@ public class ExportLoadHandler implements BaseHandler { LambdaQueryWrapper lQuery = new LambdaQueryWrapper<>(); lQuery.eq(CustomerExportLoad::getShipId, check.getShipId()); lQuery.eq(CustomerExportLoad::getVoyageId, check.getVoyageId()); + lQuery.in(CollectionUtils.isNotEmpty(check.getBillNos()), CustomerExportLoad::getBillNo, check.getBillNos()); lQuery.gt(CustomerExportLoad::getSpareQuantity, 0); List spares = customerExportLoadService.list(lQuery); @@ -1025,6 +1130,557 @@ public class ExportLoadHandler implements BaseHandler { } } + @ApiOperation("外贸整船车辆导入(按提单)") + @PostMapping("/outside/import-to-add/billno") + public Result> outsideUploadBillno(@RequestParam(required = false) String type, MultipartFile file) { + // 所有读取的数据 + List dataList = new ArrayList<>(); + + // 有错误的数据 + List errorDataList = new ArrayList<>(); + + // 验证通过的数据 + List successDataList = new ArrayList<>(); + + // 要保存的表头 + Map heads = new LinkedHashMap<>(); + + // 要保存的明细 + Map> details = new HashMap<>(); + + // 要删除的清单 + Map> removeIds = new HashMap<>(); + + try { + + // 港口基础数据 + List portList = dictHandler.getPortList(null).getData(); + + // 品牌基础数据 + List brandList = dictHandler.getBrandList(null).getData(); + + EasyExcel.read(file.getInputStream(), ExportLoadExcel.class, new ReadExcelListener() { + @Override + protected void saveData(List list) { // 保存数据 + dataList.addAll(list); + } + }).sheet().doRead(); + + ValidatorFactory vf = Validation.buildDefaultValidatorFactory(); + Validator validator = vf.getValidator(); + + List validData = new ArrayList<>(); + + // 数据验证 + dataList.stream().forEach(item -> { + Set> set = validator.validate(item); + if (CollectionUtils.isEmpty(set)) { // 验证通过的 + validData.add(item); + } else { // 验证失败的 + JSONObject o = JSONObject.from(item); + o.put("status", set.stream().map(p -> p.getMessage()).collect(Collectors.joining(","))); + errorDataList.add(o); + } + }); + + if (CollectionUtils.isEmpty(validData)) { + if (CollectionUtils.isEmpty(errorDataList)) { // 代表没有读取到数据 + JSONObject o = new JSONObject(); + o.put("status", "未读取到数据"); + errorDataList.add(o); + } + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + + // 是否有重复的车架号 + List repeat = validData.stream().collect(Collectors.groupingBy(ExportLoadExcel::getVin, Collectors.counting())) + .entrySet().stream().filter(entry -> entry.getValue() > 1).map(entry -> entry.getKey()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(repeat)) { + errorDataList.addAll(validData.stream().filter(p -> repeat.contains(p.getVin())).map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "车架号重复"); + return o; + }).collect(Collectors.toList())); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + + // 首先按对船名,般次,提单进行分组 + Map> collect = validData.stream() + .collect(Collectors.groupingBy(item -> StringUtils.joinWith("#$#", item.getShipName(), item.getVoyage(), item.getBillNo(), item.getBrand(), item.getDestPort()), Collectors.toList())); + collect.entrySet().forEach(item -> { + String[] keys = StringUtils.split(item.getKey(), "#$#"); + // 首先判断,船名,航次,提单号在出口进港申请中是否已经通过 + LambdaQueryWrapper iQuery = new LambdaQueryWrapper<>(); + iQuery.eq(CustomerExportIn::getShipName, keys[0]); + iQuery.eq(CustomerExportIn::getVoyage, keys[1]); + iQuery.eq(CustomerExportIn::getBillNum, keys[2]); + iQuery.eq(CustomerExportIn::getBrand, keys[3]); + iQuery.ne(CustomerExportIn::getCartType, "备件"); + iQuery.isNotNull(CustomerExportIn::getVoyageId); + iQuery.eq(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_PASS); + + List exportInList = customerExportInService.list(iQuery); + if (CollectionUtils.isEmpty(exportInList)) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "本船名航次下未找到审核通过的出口进港申请"); + return o; + }).collect(Collectors.toList())); + return; + } + + CustomerExportIn exportIn = exportInList.get(0); + + if (portList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), keys[4])).count() == 0) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "目的港信息错误"); + return o; + }).collect(Collectors.toList())); + return; + } + + if (brandList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), keys[3])).count() == 0) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "品牌不存在"); + return o; + }).collect(Collectors.toList())); + return; + } + + List cargos = item.getValue().stream().map(p -> { + CustomerExportLoadCargo cargo = new CustomerExportLoadCargo(); + cargo.setCargoType(0); + cargo.setVinStatus(1); + cargo.setBrandId(brandList.stream().filter(s -> StringUtils.equalsIgnoreCase(s.getText(), keys[3])).findFirst().get().getId()); + cargo.setBrand(keys[3]); + cargo.setVin(p.getVin()); + cargo.setTermcd(exportIn.getPortAreaId()); + return cargo; + }).collect(Collectors.toList()); + + List vins = cargos.stream().map(p -> p.getVin()).collect(Collectors.toList()); + + // 查询出是否已经有了装船导入记录 + List list = customerExportLoadService.lambdaQuery() + .eq(CustomerExportLoad::getShipName, keys[0]) + .eq(CustomerExportLoad::getVoyage, keys[1]) + .eq(CustomerExportLoad::getBillNo, keys[2]) + .eq(CustomerExportLoad::getBrand, keys[3]) + .gt(CustomerExportLoad::getQuantity, 0).list(); + + Optional first = list.stream().filter(s -> s.getCheckStatus() == AuditEnum.AUDIT_PASS).findFirst(); + if (first.isPresent()) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "提单号"+first.get().getBillNo()+"已审核通过,请先取消后再次导入装船清单"); + return o; + }).collect(Collectors.toList())); + } + + // 导入时校验待提交、待审核、已通过状态中是否有重复的车架号,重复导入失败,提示”车架号已存在,请勿重复申请“ + List existCargos = customerExportLoadCargoService.list(new LambdaQueryWrapper() + .in(CustomerExportLoadCargo::getVin, vins) + .notIn(CollectionUtils.isNotEmpty(list), CustomerExportLoadCargo::getExportLoadId, list.stream().map(s -> s.getId()).collect(Collectors.toList())) + .exists("select id from customer_export_load where customer_export_load.id = customer_export_load_cargo.export_load_id and customer_export_load.check_status <> 3")); + List existVins = existCargos.stream().map(p -> p.getVin()).collect(Collectors.toList()); + Map id2bill = new HashMap<>(); + Map vin2id = new HashMap<>(); + + // 查询出对应的港区 + if (CollectionUtils.isNotEmpty(existCargos)) { + List els = customerExportLoadService.lambdaQuery().in(CustomerExportLoad::getId, existCargos.stream().map(s -> s.getExportLoadId()).distinct().collect(Collectors.toList())).list(); + // 转成MAP + id2bill.putAll(els.stream().collect(Collectors.toMap(CustomerExportLoad::getId, CustomerExportLoad::getBillNo))); + vin2id.putAll(existCargos.stream().collect(Collectors.toMap(CustomerExportLoadCargo::getVin, CustomerExportLoadCargo::getExportLoadId))); + + List sList = customerExportLoadService.lambdaQuery().in(CustomerExportLoad::getId, existCargos.stream().map(ss -> ss.getExportLoadId()).collect(Collectors.toList())).list(); + Map portAreaMap = sList.stream().collect(Collectors.toMap(CustomerExportLoad::getId, CustomerExportLoad::getPortAreaId)); + // 通过接口再次验证 + List req = existCargos.stream().map(ss -> { + CheckVinReq v = new CheckVinReq(); + v.setIsRepetition(true); + v.setPamId(portAreaMap.get(ss.getExportLoadId())); + v.setVinCode(ss.getVin()); + return v; + }).collect(Collectors.toList()); + List rst = shpApi.checkVinRepeat(req); + existVins.clear(); + if (CollectionUtils.isNotEmpty(rst)) { + // 再次过滤出重复的 + List sCollect = rst.stream().filter(ss -> ss.getIsRepetition()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(sCollect)) { + existVins.addAll(sCollect.stream().map(ss -> ss.getVinCode()).collect(Collectors.toList())); + } + } + } + + List existData = item.getValue().stream().filter(p -> existVins.contains(p.getVin())).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(existData)) { + errorDataList.addAll(existData.stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "当前车架号已存在,关联提单号为:" + id2bill.get(vin2id.get(p.getVin()))); + return o; + }).collect(Collectors.toList())); + successDataList.addAll(item.getValue().stream().filter(p -> !existVins.contains(p.getVin())) + .map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "数据验证成功"); + return o; + }).collect(Collectors.toList())); + return; + } else { + successDataList.addAll(item.getValue().stream().filter(p -> !existVins.contains(p.getVin())) + .map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "数据验证成功"); + return o; + }).collect(Collectors.toList())); + } + + // 生成新的装船记录 + List saveCargos = cargos.stream().filter(s -> !existVins.contains(s.getVin())).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(saveCargos)) { + + if (CollectionUtils.isNotEmpty(list)) { + removeIds.put(item.getKey(), list.stream().map(s -> s.getId()).collect(Collectors.toList())); + } + + CustomerExportLoad exportLoad = new CustomerExportLoad(); + exportLoad.setTradType("W"); + exportLoad.setShipName(keys[0]); + exportLoad.setVoyage(keys[1]); + exportLoad.setBillNo(keys[2]); + exportLoad.setShipId(exportIn.getShipId()); + exportLoad.setShipEnName(exportIn.getShipEnName()); + exportLoad.setVoyageId(exportIn.getVoyageId()); + exportLoad.setBrandId(brandList.stream().filter(s -> StringUtils.equalsIgnoreCase(s.getText(), keys[3])).findFirst().get().getId()); + exportLoad.setBrand(keys[3]); + exportLoad.setDestPortId(portList.stream().filter(s -> StringUtils.equalsIgnoreCase(s.getText(), keys[4])).findFirst().get().getId()); + exportLoad.setDestPort(keys[4]); + exportLoad.setQuantity(saveCargos.size()); + exportLoad.setSpareQuantity(0); + exportLoad.setPortArea(exportIn.getPortArea()); + exportLoad.setPortAreaId(exportIn.getPortAreaId()); + exportLoad.setTermcd(exportIn.getPortAreaId()); + if (StringUtils.equals("1", type)) { + exportLoad.setCheckStatus(AuditEnum.AUDIT); + } else { + exportLoad.setCheckStatus(AuditEnum.SUBMIT); + } + exportLoad.setApplyTime(new Date()); + exportLoad.setApplicantId(UserContext.getUser().getUserId()); + + heads.put(item.getKey(), exportLoad); + details.put(item.getKey(), saveCargos); + } + + }); + + if (CollectionUtils.isNotEmpty(errorDataList)) { +// errorDataList.addAll(successDataList); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + + if (MapUtils.isNotEmpty(heads)) { + heads.entrySet().forEach(item -> { + CustomerExportLoad exportLoad = item.getValue(); + String batchNo = customerService.getSequenceNo("export_load_batch_no", "出口装船", "EL"); + exportLoad.setBatchNo(batchNo); + + customerService.saveExportLoad(exportLoad, removeIds.get(item.getKey()), details.get(item.getKey())); + }); + } + + return ResultUtil.success(errorDataList); + } catch (ExcelDataConvertException e) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入数据错误,请确认导入数据模板是否正确, 行:" + e.getRowIndex() + " 列:" + e.getColumnIndex()); + } catch (Exception e) { + log.error("错误信息", e); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage()); + } + } + + @ApiOperation("外贸整船车辆导入(按船)") + @PostMapping("/outside/import-to-add/ship") + public Result> outsideUploadShip(@RequestParam(required = false) String type, MultipartFile file) { + // 所有读取的数据 + List dataList = new ArrayList<>(); + + // 有错误的数据 + List errorDataList = new ArrayList<>(); + + // 验证通过的数据 + List successDataList = new ArrayList<>(); + + // 要保存的表头 + Map heads = new LinkedHashMap<>(); + + // 要保存的明细 + Map> details = new HashMap<>(); + + // 要删除的清单 + Map> removeIds = new HashMap<>(); + + try { + + // 港口基础数据 + List portList = dictHandler.getPortList(null).getData(); + + // 品牌基础数据 + List brandList = dictHandler.getBrandList(null).getData(); + + EasyExcel.read(file.getInputStream(), ExportLoadExcel.class, new ReadExcelListener() { + @Override + protected void saveData(List list) { // 保存数据 + dataList.addAll(list); + } + }).sheet().doRead(); + + ValidatorFactory vf = Validation.buildDefaultValidatorFactory(); + Validator validator = vf.getValidator(); + + List validData = new ArrayList<>(); + + // 数据验证 + dataList.stream().forEach(item -> { + Set> set = validator.validate(item); + if (CollectionUtils.isEmpty(set)) { // 验证通过的 + validData.add(item); + } else { // 验证失败的 + JSONObject o = JSONObject.from(item); + o.put("status", set.stream().map(p -> p.getMessage()).collect(Collectors.joining(","))); + errorDataList.add(o); + } + }); + + if (CollectionUtils.isEmpty(validData)) { + if (CollectionUtils.isEmpty(errorDataList)) { // 代表没有读取到数据 + JSONObject o = new JSONObject(); + o.put("status", "未读取到数据"); + errorDataList.add(o); + } + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + + // 是否有重复的车架号 + List repeat = validData.stream().collect(Collectors.groupingBy(ExportLoadExcel::getVin, Collectors.counting())) + .entrySet().stream().filter(entry -> entry.getValue() > 1).map(entry -> entry.getKey()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(repeat)) { + errorDataList.addAll(validData.stream().filter(p -> repeat.contains(p.getVin())).map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "车架号重复"); + return o; + }).collect(Collectors.toList())); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + + // 首先按对船名,般次,判断是否有审核通过的装船计划 + Map> collect = validData.stream() + .collect(Collectors.groupingBy(item -> StringUtils.joinWith("#$#", item.getShipName(), item.getVoyage()), Collectors.toList())); + collect.entrySet().forEach(item -> { + String[] keys = StringUtils.split(item.getKey(), "#$#"); + List list = customerExportLoadService.lambdaQuery() + .eq(CustomerExportLoad::getShipName, keys[0]) + .eq(CustomerExportLoad::getVoyage, keys[1]) + .eq(CustomerExportLoad::getSpareQuantity, 0) + .eq(CustomerExportLoad::getCheckStatus, AuditEnum.AUDIT_PASS).list(); + if (CollectionUtils.isNotEmpty(list)) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "当前航次有审核通过的装船清单"); + return o; + }).collect(Collectors.toList())); + return; + } + }); + + if (CollectionUtils.isNotEmpty(errorDataList)) { +// errorDataList.addAll(successDataList); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + + // 首先按对船名,般次,提单进行分组 + collect = validData.stream() + .collect(Collectors.groupingBy(item -> StringUtils.joinWith("#$#", item.getShipName(), item.getVoyage(), item.getBillNo(), item.getBrand(), item.getDestPort()), Collectors.toList())); + collect.entrySet().forEach(item -> { + String[] keys = StringUtils.split(item.getKey(), "#$#"); + // 首先判断,船名,航次,提单号在出口进港申请中是否已经通过 + LambdaQueryWrapper iQuery = new LambdaQueryWrapper<>(); + iQuery.eq(CustomerExportIn::getShipName, keys[0]); + iQuery.eq(CustomerExportIn::getVoyage, keys[1]); + iQuery.eq(CustomerExportIn::getBillNum, keys[2]); + iQuery.eq(CustomerExportIn::getBrand, keys[3]); + iQuery.ne(CustomerExportIn::getCartType, "备件"); + iQuery.isNotNull(CustomerExportIn::getVoyageId); + iQuery.eq(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_PASS); + + List exportInList = customerExportInService.list(iQuery); + if (CollectionUtils.isEmpty(exportInList)) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "本船名航次下未找到审核通过的出口进港申请"); + return o; + }).collect(Collectors.toList())); + return; + } + + CustomerExportIn exportIn = exportInList.get(0); + + if (portList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), keys[4])).count() == 0) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "目的港信息错误"); + return o; + }).collect(Collectors.toList())); + return; + } + + if (brandList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), keys[3])).count() == 0) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "品牌不存在"); + return o; + }).collect(Collectors.toList())); + return; + } + + List cargos = item.getValue().stream().map(p -> { + CustomerExportLoadCargo cargo = new CustomerExportLoadCargo(); + cargo.setCargoType(0); + cargo.setVinStatus(1); + cargo.setBrandId(brandList.stream().filter(s -> StringUtils.equalsIgnoreCase(s.getText(), keys[3])).findFirst().get().getId()); + cargo.setBrand(keys[3]); + cargo.setVin(p.getVin()); + cargo.setTermcd(exportIn.getPortAreaId()); + return cargo; + }).collect(Collectors.toList()); + + List vins = cargos.stream().map(p -> p.getVin()).collect(Collectors.toList()); + + // 查询出是否已经有了装船导入记录 + List list = customerExportLoadService.lambdaQuery() + .eq(CustomerExportLoad::getShipName, keys[0]) + .eq(CustomerExportLoad::getVoyage, keys[1]) + .eq(CustomerExportLoad::getBillNo, keys[2]) + .eq(CustomerExportLoad::getBrand, keys[3]) + .gt(CustomerExportLoad::getQuantity, 0).list(); + + // 导入时校验待提交、待审核、已通过状态中是否有重复的车架号,重复导入失败,提示”车架号已存在,请勿重复申请“ + List existCargos = customerExportLoadCargoService.list(new LambdaQueryWrapper() + .in(CustomerExportLoadCargo::getVin, vins) + .notIn(CollectionUtils.isNotEmpty(list), CustomerExportLoadCargo::getExportLoadId, list.stream().map(s -> s.getId()).collect(Collectors.toList())) + .exists("select id from customer_export_load where customer_export_load.id = customer_export_load_cargo.export_load_id and customer_export_load.check_status <> 3")); + List existVins = existCargos.stream().map(p -> p.getVin()).collect(Collectors.toList()); + + // 查询出对应的港区 + if (CollectionUtils.isNotEmpty(existCargos)) { + List sList = customerExportLoadService.lambdaQuery().in(CustomerExportLoad::getId, existCargos.stream().map(ss -> ss.getExportLoadId()).collect(Collectors.toList())).list(); + Map portAreaMap = sList.stream().collect(Collectors.toMap(CustomerExportLoad::getId, CustomerExportLoad::getPortAreaId)); + // 通过接口再次验证 + List req = existCargos.stream().map(ss -> { + CheckVinReq v = new CheckVinReq(); + v.setIsRepetition(true); + v.setPamId(portAreaMap.get(ss.getExportLoadId())); + v.setVinCode(ss.getVin()); + return v; + }).collect(Collectors.toList()); + List rst = shpApi.checkVinRepeat(req); + existVins.clear(); + if (CollectionUtils.isNotEmpty(rst)) { + // 再次过滤出重复的 + List sCollect = rst.stream().filter(ss -> ss.getIsRepetition()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(sCollect)) { + existVins.addAll(sCollect.stream().map(ss -> ss.getVinCode()).collect(Collectors.toList())); + } + } + } + + List existData = item.getValue().stream().filter(p -> existVins.contains(p.getVin())).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(existData)) { + errorDataList.addAll(existData.stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "车架号已存在,请勿重复申请"); + return o; + }).collect(Collectors.toList())); + successDataList.addAll(item.getValue().stream().filter(p -> !existVins.contains(p.getVin())) + .map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "数据验证成功"); + return o; + }).collect(Collectors.toList())); + return; + } else { + successDataList.addAll(item.getValue().stream().filter(p -> !existVins.contains(p.getVin())) + .map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "数据验证成功"); + return o; + }).collect(Collectors.toList())); + } + + // 生成新的装船记录 + List saveCargos = cargos.stream().filter(s -> !existVins.contains(s.getVin())).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(saveCargos)) { + if (CollectionUtils.isNotEmpty(list)) { + removeIds.put(item.getKey(), list.stream().map(s -> s.getId()).collect(Collectors.toList())); + } + CustomerExportLoad exportLoad = new CustomerExportLoad(); + exportLoad.setTradType("W"); + exportLoad.setShipName(keys[0]); + exportLoad.setVoyage(keys[1]); + exportLoad.setBillNo(keys[2]); + exportLoad.setShipId(exportIn.getShipId()); + exportLoad.setShipEnName(exportIn.getShipEnName()); + exportLoad.setVoyageId(exportIn.getVoyageId()); + exportLoad.setBrandId(brandList.stream().filter(s -> StringUtils.equalsIgnoreCase(s.getText(), keys[3])).findFirst().get().getId()); + exportLoad.setBrand(keys[3]); + exportLoad.setDestPortId(portList.stream().filter(s -> StringUtils.equalsIgnoreCase(s.getText(), keys[4])).findFirst().get().getId()); + exportLoad.setDestPort(keys[4]); + exportLoad.setQuantity(saveCargos.size()); + exportLoad.setSpareQuantity(0); + exportLoad.setPortArea(exportIn.getPortArea()); + exportLoad.setPortAreaId(exportIn.getPortAreaId()); + exportLoad.setTermcd(exportIn.getPortAreaId()); + if (StringUtils.equals("1", type)) { + exportLoad.setCheckStatus(AuditEnum.AUDIT); + } else { + exportLoad.setCheckStatus(AuditEnum.SUBMIT); + } + exportLoad.setApplyTime(new Date()); + exportLoad.setApplicantId(UserContext.getUser().getUserId()); + + heads.put(item.getKey(), exportLoad); + details.put(item.getKey(), saveCargos); + } + + }); + + if (CollectionUtils.isNotEmpty(errorDataList)) { +// errorDataList.addAll(successDataList); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + + if (MapUtils.isNotEmpty(heads)) { + heads.entrySet().forEach(item -> { + CustomerExportLoad exportLoad = item.getValue(); + String batchNo = customerService.getSequenceNo("export_load_batch_no", "出口装船", "EL"); + exportLoad.setBatchNo(batchNo); + + customerService.saveExportLoad(exportLoad, removeIds.get(item.getKey()), details.get(item.getKey())); + }); + } + + return ResultUtil.success(errorDataList); + } catch (ExcelDataConvertException e) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入数据错误,请确认导入数据模板是否正确, 行:" + e.getRowIndex() + " 列:" + e.getColumnIndex()); + } catch (Exception e) { + log.error("错误信息", e); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage()); + } + } + @ApiOperation("外贸整船车辆导入") @PostMapping("/outside/import-to-add") public Result> outsideUpload(@RequestParam(required = false) String type, MultipartFile file) { @@ -1076,6 +1732,11 @@ public class ExportLoadHandler implements BaseHandler { }); if (CollectionUtils.isEmpty(validData)) { + if (CollectionUtils.isEmpty(errorDataList)) { // 代表没有读取到数据 + JSONObject o = new JSONObject(); + o.put("status", "未读取到数据"); + errorDataList.add(o); + } return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); } @@ -1102,11 +1763,12 @@ public class ExportLoadHandler implements BaseHandler { iQuery.eq(CustomerExportIn::getVoyage, keys[1]); iQuery.eq(CustomerExportIn::getBillNum, keys[2]); iQuery.eq(CustomerExportIn::getBrand, keys[3]); + iQuery.ne(CustomerExportIn::getCartType, "备件"); iQuery.isNotNull(CustomerExportIn::getVoyageId); iQuery.eq(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_PASS); - CustomerExportIn exportIn = customerExportInService.getOne(iQuery, false); - if (exportIn == null || exportIn.getCheckStatus() != AuditEnum.AUDIT_PASS) { + List exportInList = customerExportInService.list(iQuery); + if (CollectionUtils.isEmpty(exportInList)) { errorDataList.addAll(item.getValue().stream().map(p -> { JSONObject o = JSONObject.from(p); o.put("status", "本船名航次下未找到审核通过的出口进港申请"); @@ -1115,17 +1777,23 @@ public class ExportLoadHandler implements BaseHandler { return; } + CustomerExportIn exportIn = exportInList.get(0); + if (portList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), keys[4])).count() == 0) { - JSONObject o = JSONObject.from(item); - o.put("status", "目的港信息错误"); - errorDataList.add(o); + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "目的港信息错误"); + return o; + }).collect(Collectors.toList())); return; } if (brandList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), keys[3])).count() == 0) { - JSONObject o = JSONObject.from(item); - o.put("status", "品牌不存在"); - errorDataList.add(o); + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "品牌不存在"); + return o; + }).collect(Collectors.toList())); return; } @@ -1226,13 +1894,12 @@ public class ExportLoadHandler implements BaseHandler { heads.put(item.getKey(), exportLoad); details.put(item.getKey(), saveCargos); - } }); if (CollectionUtils.isNotEmpty(errorDataList)) { - errorDataList.addAll(successDataList); +// errorDataList.addAll(successDataList); return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); } @@ -1241,11 +1908,214 @@ public class ExportLoadHandler implements BaseHandler { CustomerExportLoad exportLoad = item.getValue(); String batchNo = customerService.getSequenceNo("export_load_batch_no", "出口装船", "EL"); exportLoad.setBatchNo(batchNo); - customerService.saveExportLoad(exportLoad, details.get(item.getKey())); + customerService.saveExportLoad(exportLoad, null, details.get(item.getKey())); }); } return ResultUtil.success(errorDataList); + } catch (ExcelDataConvertException e) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入数据错误,请确认导入数据模板是否正确, 行:" + e.getRowIndex() + " 列:" + e.getColumnIndex()); + } catch (Exception e) { + log.error("错误信息", e); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage()); + } + } + + @ApiOperation("外贸整船车辆导入覆盖") + @PostMapping("/outside/import-to-over") + public Result> outsideUploadOver(MultipartFile file) { + // 所有读取的数据 + List dataList = new ArrayList<>(); + + // 有错误的数据 + List errorDataList = new ArrayList<>(); + + // 验证通过的数据 + List successDataList = new ArrayList<>(); + + List inUpdate = new ArrayList<>(); + + try { + EasyExcel.read(file.getInputStream(), ExportLoadExcel.class, new ReadExcelListener() { + @Override + protected void saveData(List list) { // 保存数据 + dataList.addAll(list); + } + }).sheet().doRead(); + + ValidatorFactory vf = Validation.buildDefaultValidatorFactory(); + Validator validator = vf.getValidator(); + + List validData = new ArrayList<>(); + + // 数据验证 + dataList.stream().forEach(item -> { + Set> set = validator.validate(item); + if (CollectionUtils.isEmpty(set)) { // 验证通过的 + validData.add(item); + } else { // 验证失败的 + JSONObject o = JSONObject.from(item); + o.put("status", set.stream().map(p -> p.getMessage()).collect(Collectors.joining(","))); + errorDataList.add(o); + } + }); + + if (CollectionUtils.isEmpty(validData)) { + if (CollectionUtils.isEmpty(errorDataList)) { // 代表没有读取到数据 + JSONObject o = new JSONObject(); + o.put("status", "未读取到数据"); + errorDataList.add(o); + } + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + + // 是否有重复的车架号 + List repeat = validData.stream().collect(Collectors.groupingBy(ExportLoadExcel::getVin, Collectors.counting())) + .entrySet().stream().filter(entry -> entry.getValue() > 1).map(entry -> entry.getKey()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(repeat)) { + errorDataList.addAll(validData.stream().filter(p -> repeat.contains(p.getVin())).map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "车架号重复"); + return o; + }).collect(Collectors.toList())); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + + // 首先按对船名,般次,提单进行分组 + Map> collect = validData.stream() + .collect(Collectors.groupingBy(item -> StringUtils.joinWith("#$#", item.getShipName(), item.getVoyage(), item.getBillNo(), item.getBrand(), item.getDestPort()), Collectors.toList())); + collect.entrySet().forEach(item -> { + String[] keys = StringUtils.split(item.getKey(), "#$#"); + // 首先判断,船名,航次,提单号在出口进港申请中是否已经通过 + LambdaQueryWrapper iQuery = new LambdaQueryWrapper<>(); + iQuery.eq(CustomerExportIn::getShipName, keys[0]); + iQuery.eq(CustomerExportIn::getVoyage, keys[1]); + iQuery.eq(CustomerExportIn::getBillNum, keys[2]); + iQuery.eq(CustomerExportIn::getBrand, keys[3]); + iQuery.ne(CustomerExportIn::getCartType, "备件"); + iQuery.isNotNull(CustomerExportIn::getVoyageId); + iQuery.eq(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_PASS); + + List exportInList = customerExportInService.list(iQuery); + if (CollectionUtils.isEmpty(exportInList)) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "本船名航次下未找到审核通过的出口进港申请"); + return o; + }).collect(Collectors.toList())); + return; + } + + // 这个品牌的总数 + int sum = exportInList.stream().mapToInt(s -> s.getQuantity()).sum(); + if (item.getValue().size() != sum) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "此品牌的车架号数量与进港计划的数量不一致"); + return o; + }).collect(Collectors.toList())); + return; + } + + CustomerExportIn exportIn = exportInList.get(0); + // 是否已经导入了装船计划 + List exportLoadList = customerExportLoadService.lambdaQuery() + .eq(CustomerExportLoad::getShipId, exportIn.getShipId()) + .eq(CustomerExportLoad::getVoyageId, exportIn.getVoyageId()) + .eq(CustomerExportLoad::getBillNo, exportIn.getBillNum()) + .eq(CustomerExportLoad::getBrandId, exportIn.getBrandId()) + .ne(CustomerExportLoad::getCheckStatus, AuditEnum.AUDIT_REJECT) + .list(); + if (CollectionUtils.isEmpty(exportLoadList)) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "本船名航次下未找到装船计划申请"); + return o; + }).collect(Collectors.toList())); + return; + } + sum = exportLoadList.stream().mapToInt(s -> s.getQuantity()).sum(); + if (item.getValue().size() != sum) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "此品牌的车架号数量与装船计划已导入的数量不一致"); + return o; + }).collect(Collectors.toList())); + return; + } + + List cargos = item.getValue().stream().map(p -> { + CustomerExportLoadCargo cargo = new CustomerExportLoadCargo(); + cargo.setCargoType(0); + cargo.setVinStatus(1); + cargo.setBrand(keys[3]); + cargo.setVin(p.getVin()); + cargo.setTermcd(exportIn.getPortAreaId()); + return cargo; + }).collect(Collectors.toList()); + + // 需要与装船计划的车架号一致 + List loadCargos = customerExportLoadCargoService.lambdaQuery().in(CustomerExportLoadCargo::getExportLoadId, exportLoadList.stream().map(s -> s.getId()).collect(Collectors.toList())).list(); + List vins = loadCargos.stream().map(p -> p.getVin()).collect(Collectors.toList()); + + // 找到不存在的 + List noExists = item.getValue().stream().filter(s -> !vins.contains(s.getVin())).map(s -> s.getVin()).collect(Collectors.toList()); + + if (CollectionUtils.isNotEmpty(noExists)) { + errorDataList.addAll(item.getValue().stream().filter(s -> noExists.contains(s.getVin())).map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "此提单号不存在此车架号"); + return o; + }).collect(Collectors.toList())); + successDataList.addAll(item.getValue().stream().filter(p -> !noExists.contains(p.getVin())) + .map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "数据验证成功"); + return o; + }).collect(Collectors.toList())); + return; + } else { + successDataList.addAll(item.getValue().stream().filter(p -> !noExists.contains(p.getVin())) + .map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "数据验证成功"); + return o; + }).collect(Collectors.toList())); + } + + + // 生成新的装船记录 + if (CollectionUtils.isNotEmpty(cargos)) { + // 进港计划需要覆盖的 + List nVins = cargos.stream().map(s -> s.getVin()).collect(Collectors.toList()); + // 进港计划,需要调整的车架号 + List list = customerExportInCargoService.lambdaQuery().in(CustomerExportInCargo::getExportInId, exportInList.stream().map(s -> s.getId()).collect(Collectors.toList())).list(); + List oVins = list.stream().map(s -> s.getVin()).collect(Collectors.toList()); + // 找到不存在的 + List update = list.stream().filter(s -> !nVins.contains(s.getVin())).collect(Collectors.toList()); + List uVins = nVins.stream().filter(s -> !oVins.contains(s)).collect(Collectors.toList()); + + for (int i = 0; i < update.size(); i++) { + update.get(i).setVin(uVins.get(i)); + } + + inUpdate.addAll(update); + } + + }); + + if (CollectionUtils.isNotEmpty(errorDataList)) { +// errorDataList.addAll(successDataList); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + + if (CollectionUtils.isNotEmpty(inUpdate)) { + customerExportInCargoService.updateBatchById(inUpdate); + } + + return ResultUtil.success(errorDataList); + } catch (ExcelDataConvertException e) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入数据错误,请确认导入数据模板是否正确, 行:" + e.getRowIndex() + " 列:" + e.getColumnIndex()); } catch (Exception e) { log.error("错误信息", e); return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage()); @@ -1340,6 +2210,11 @@ public class ExportLoadHandler implements BaseHandler { }); if (CollectionUtils.isEmpty(validData)) { + if (CollectionUtils.isEmpty(errorDataList)) { // 代表没有读取到数据 + JSONObject o = new JSONObject(); + o.put("status", "未读取到数据"); + errorDataList.add(o); + } return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); } @@ -1368,16 +2243,20 @@ public class ExportLoadHandler implements BaseHandler { } if (portList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), keys[4])).count() == 0) { - JSONObject o = JSONObject.from(item); - o.put("status", "目的港信息错误"); - errorDataList.add(o); + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "目的港信息错误"); + return o; + }).collect(Collectors.toList())); return; } if (brandList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), keys[3])).count() == 0) { - JSONObject o = JSONObject.from(item); - o.put("status", "品牌不存在"); - errorDataList.add(o); + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "品牌不存在"); + return o; + }).collect(Collectors.toList())); return; } @@ -1421,7 +2300,7 @@ public class ExportLoadHandler implements BaseHandler { }); if (CollectionUtils.isNotEmpty(errorDataList)) { - errorDataList.addAll(successDataList); +// errorDataList.addAll(successDataList); return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); } @@ -1434,6 +2313,390 @@ public class ExportLoadHandler implements BaseHandler { } return ResultUtil.success(errorDataList); + } catch (ExcelDataConvertException e) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入数据错误,请确认导入数据模板是否正确, 行:" + e.getRowIndex() + " 列:" + e.getColumnIndex()); + } catch (Exception e) { + log.error("错误信息", e); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage()); + } + } + + @ApiOperation("外贸整船备件导入(按船)") + @PostMapping("/outside/spare/import-to-add/ship") + public Result> outsideSpareUploadShip(@RequestParam(required = false) String type, MultipartFile file) { + // 所有读取的数据 + List dataList = new ArrayList<>(); + + // 有错误的数据 + List errorDataList = new ArrayList<>(); + + // 验证成功的数据 + List successDataList = new ArrayList<>(); + + // 要保存的数据 + Map heads = new LinkedHashMap<>(); + Map> removeIds = new HashMap<>(); + + try { + + // 港口基础数据 + List portList = dictHandler.getPortList(null).getData(); + + // 品牌基础数据 + List brandList = dictHandler.getBrandList(null).getData(); + + EasyExcel.read(file.getInputStream(), ExportLoadSpareExcel.class, new ReadExcelListener() { + @Override + protected void saveData(List list) { // 保存数据 + dataList.addAll(list); + } + }).sheet().doRead(); + + ValidatorFactory vf = Validation.buildDefaultValidatorFactory(); + Validator validator = vf.getValidator(); + + List validData = new ArrayList<>(); + + // 数据验证 + dataList.stream().forEach(item -> { + Set> set = validator.validate(item); + if (CollectionUtils.isEmpty(set)) { // 验证通过的 + validData.add(item); + } else { // 验证失败的 + JSONObject o = JSONObject.from(item); + o.put("status", set.stream().map(p -> p.getMessage()).collect(Collectors.joining(","))); + errorDataList.add(o); + } + }); + + if (CollectionUtils.isEmpty(validData)) { + if (CollectionUtils.isEmpty(errorDataList)) { // 代表没有读取到数据 + JSONObject o = new JSONObject(); + o.put("status", "未读取到数据"); + errorDataList.add(o); + } + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + + // 首先按对船名,般次,判断是否有审核通过的装船计划 + Map> collect = validData.stream() + .collect(Collectors.groupingBy(item -> StringUtils.joinWith("#$#", item.getShipName(), item.getVoyage()), Collectors.toList())); + collect.entrySet().forEach(item -> { + String[] keys = StringUtils.split(item.getKey(), "#$#"); + List list = customerExportLoadService.lambdaQuery() + .eq(CustomerExportLoad::getShipName, keys[0]) + .eq(CustomerExportLoad::getVoyage, keys[1]) + .gt(CustomerExportLoad::getSpareQuantity, 0) + .eq(CustomerExportLoad::getCheckStatus, AuditEnum.AUDIT_PASS).list(); + if (CollectionUtils.isNotEmpty(list)) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "当前航次有审核通过的装船清单"); + return o; + }).collect(Collectors.toList())); + return; + } + }); + + if (CollectionUtils.isNotEmpty(errorDataList)) { +// errorDataList.addAll(successDataList); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + + // 首先按对船名,般次,提单进行分组 + collect = validData.stream().collect(Collectors.groupingBy(item -> StringUtils.joinWith("#$#", item.getShipName(), item.getVoyage(), item.getBillNo(), item.getBrand(), item.getDestPort()), Collectors.toList())); + collect.entrySet().forEach(item -> { + String[] keys = StringUtils.split(item.getKey(), "#$#"); + + // 首先判断,船名,航次,提单号在出口进港申请中是否已经通过 + LambdaQueryWrapper iQuery = new LambdaQueryWrapper<>(); + iQuery.eq(CustomerExportIn::getShipName, keys[0]); + iQuery.eq(CustomerExportIn::getVoyage, keys[1]); + iQuery.eq(CustomerExportIn::getBillNum, keys[2]); + iQuery.eq(CustomerExportIn::getBrand, keys[3]); + iQuery.isNotNull(CustomerExportIn::getVoyageId); + iQuery.eq(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_PASS); + + CustomerExportIn exportIn = customerExportInService.getOne(iQuery, false); + if (exportIn == null || exportIn.getCheckStatus() != AuditEnum.AUDIT_PASS) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "本船名航次下未找到审核通过的出口进港申请"); + return o; + }).collect(Collectors.toList())); + return; + } + + if (portList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), keys[4])).count() == 0) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "目的港信息错误"); + return o; + }).collect(Collectors.toList())); + return; + } + + if (brandList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), keys[3])).count() == 0) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "品牌不存在"); + return o; + }).collect(Collectors.toList())); + return; + } + + int num = item.getValue().stream().mapToInt(ExportLoadSpareExcel::getNum).sum(); + + // 查询出是否已经有了装船导入记录 + List list = customerExportLoadService.lambdaQuery() + .eq(CustomerExportLoad::getShipName, keys[0]) + .eq(CustomerExportLoad::getVoyage, keys[1]) + .eq(CustomerExportLoad::getBillNo, keys[2]) + .eq(CustomerExportLoad::getBrand, keys[3]) + .gt(CustomerExportLoad::getSpareQuantity, 0).list(); + + successDataList.addAll(item.getValue().stream() + .map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "数据验证成功"); + return o; + }).collect(Collectors.toList())); + + if (CollectionUtils.isNotEmpty(list)) { + removeIds.put(item.getKey(), list.stream().map(s -> s.getId()).collect(Collectors.toList())); + } + + CustomerExportLoad exportLoad = new CustomerExportLoad(); + + exportLoad.setTradType("W"); + exportLoad.setShipId(exportIn.getShipId()); + exportLoad.setShipName(keys[0]); + exportLoad.setShipEnName(exportIn.getShipEnName()); + exportLoad.setVoyage(keys[1]); + exportLoad.setVoyageId(exportIn.getVoyageId()); + exportLoad.setBillNo(keys[2]); + exportLoad.setBrandId(brandList.stream().filter(s -> StringUtils.equalsIgnoreCase(s.getText(), keys[3])).findFirst().get().getId()); + exportLoad.setBrand(keys[3]); + exportLoad.setDestPortId(portList.stream().filter(s -> StringUtils.equalsIgnoreCase(s.getText(), keys[4])).findFirst().get().getId()); + exportLoad.setDestPort(keys[4]); + exportLoad.setQuantity(0); + exportLoad.setSpareQuantity(num); + exportLoad.setPortArea(exportIn.getPortArea()); + exportLoad.setPortAreaId(exportIn.getPortAreaId()); + exportLoad.setTermcd(exportIn.getTermcd()); + if (StringUtils.equals("1", type)) { + exportLoad.setCheckStatus(AuditEnum.AUDIT); + } else { + exportLoad.setCheckStatus(AuditEnum.SUBMIT); + } + exportLoad.setApplyTime(new Date()); + exportLoad.setApplicantId(UserContext.getUser().getUserId()); + + heads.put(item.getKey(), exportLoad); + + }); + + if (CollectionUtils.isNotEmpty(errorDataList)) { +// errorDataList.addAll(successDataList); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + + if (MapUtils.isNotEmpty(heads)) { + heads.entrySet().forEach(item -> { + CustomerExportLoad exportLoad = item.getValue(); + String batchNo = customerService.getSequenceNo("export_load_batch_no", "出口装船", "EL"); + exportLoad.setBatchNo(batchNo); + + customerService.saveExportLoad(exportLoad, removeIds.get(item.getKey()), null); + }); + } + + return ResultUtil.success(errorDataList); + } catch (ExcelDataConvertException e) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入数据错误,请确认导入数据模板是否正确, 行:" + e.getRowIndex() + " 列:" + e.getColumnIndex()); + } catch (Exception e) { + log.error("错误信息", e); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage()); + } + } + + @ApiOperation("外贸整船备件导入(按提单)") + @PostMapping("/outside/spare/import-to-add/billno") + public Result> outsideSpareUploadBill(@RequestParam(required = false) String type, MultipartFile file) { + // 所有读取的数据 + List dataList = new ArrayList<>(); + + // 有错误的数据 + List errorDataList = new ArrayList<>(); + + // 验证成功的数据 + List successDataList = new ArrayList<>(); + + // 要保存的数据 + Map heads = new LinkedHashMap<>(); + Map> removeIds = new HashMap<>(); + + try { + + // 港口基础数据 + List portList = dictHandler.getPortList(null).getData(); + + // 品牌基础数据 + List brandList = dictHandler.getBrandList(null).getData(); + + EasyExcel.read(file.getInputStream(), ExportLoadSpareExcel.class, new ReadExcelListener() { + @Override + protected void saveData(List list) { // 保存数据 + dataList.addAll(list); + } + }).sheet().doRead(); + + ValidatorFactory vf = Validation.buildDefaultValidatorFactory(); + Validator validator = vf.getValidator(); + + List validData = new ArrayList<>(); + + // 数据验证 + dataList.stream().forEach(item -> { + Set> set = validator.validate(item); + if (CollectionUtils.isEmpty(set)) { // 验证通过的 + validData.add(item); + } else { // 验证失败的 + JSONObject o = JSONObject.from(item); + o.put("status", set.stream().map(p -> p.getMessage()).collect(Collectors.joining(","))); + errorDataList.add(o); + } + }); + + if (CollectionUtils.isEmpty(validData)) { + if (CollectionUtils.isEmpty(errorDataList)) { // 代表没有读取到数据 + JSONObject o = new JSONObject(); + o.put("status", "未读取到数据"); + errorDataList.add(o); + } + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + + // 首先按对船名,般次,提单进行分组 + Map> collect = validData.stream().collect(Collectors.groupingBy(item -> StringUtils.joinWith("#$#", item.getShipName(), item.getVoyage(), item.getBillNo(), item.getBrand(), item.getDestPort()), Collectors.toList())); + collect.entrySet().forEach(item -> { + String[] keys = StringUtils.split(item.getKey(), "#$#"); + + // 首先判断,船名,航次,提单号在出口进港申请中是否已经通过 + LambdaQueryWrapper iQuery = new LambdaQueryWrapper<>(); + iQuery.eq(CustomerExportIn::getShipName, keys[0]); + iQuery.eq(CustomerExportIn::getVoyage, keys[1]); + iQuery.eq(CustomerExportIn::getBillNum, keys[2]); + iQuery.eq(CustomerExportIn::getBrand, keys[3]); + iQuery.isNotNull(CustomerExportIn::getVoyageId); + iQuery.eq(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_PASS); + + CustomerExportIn exportIn = customerExportInService.getOne(iQuery, false); + if (exportIn == null || exportIn.getCheckStatus() != AuditEnum.AUDIT_PASS) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "本船名航次下未找到审核通过的出口进港申请"); + return o; + }).collect(Collectors.toList())); + return; + } + + if (portList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), keys[4])).count() == 0) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "目的港信息错误"); + return o; + }).collect(Collectors.toList())); + return; + } + + if (brandList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), keys[3])).count() == 0) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "品牌不存在"); + return o; + }).collect(Collectors.toList())); + return; + } + + int num = item.getValue().stream().mapToInt(ExportLoadSpareExcel::getNum).sum(); + + // 查询出是否已经有了装船导入记录 + List list = customerExportLoadService.lambdaQuery() + .eq(CustomerExportLoad::getShipName, keys[0]) + .eq(CustomerExportLoad::getVoyage, keys[1]) + .eq(CustomerExportLoad::getBillNo, keys[2]) + .eq(CustomerExportLoad::getBrand, keys[3]) + .gt(CustomerExportLoad::getSpareQuantity, 0).list(); + + Optional first = list.stream().filter(s -> s.getCheckStatus() == AuditEnum.AUDIT_PASS).findFirst(); + if (first.isPresent()) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "提单号"+first.get().getBillNo()+"已审核通过,请先取消后再次导入装船清单"); + return o; + }).collect(Collectors.toList())); + } + + successDataList.addAll(item.getValue().stream() + .map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "数据验证成功"); + return o; + }).collect(Collectors.toList())); + + if (CollectionUtils.isNotEmpty(list)) { + removeIds.put(item.getKey(), list.stream().map(s -> s.getId()).collect(Collectors.toList())); + } + + CustomerExportLoad exportLoad = new CustomerExportLoad(); + + exportLoad.setTradType("W"); + exportLoad.setShipId(exportIn.getShipId()); + exportLoad.setShipName(keys[0]); + exportLoad.setShipEnName(exportIn.getShipEnName()); + exportLoad.setVoyage(keys[1]); + exportLoad.setVoyageId(exportIn.getVoyageId()); + exportLoad.setBillNo(keys[2]); + exportLoad.setBrandId(brandList.stream().filter(s -> StringUtils.equalsIgnoreCase(s.getText(), keys[3])).findFirst().get().getId()); + exportLoad.setBrand(keys[3]); + exportLoad.setDestPortId(portList.stream().filter(s -> StringUtils.equalsIgnoreCase(s.getText(), keys[4])).findFirst().get().getId()); + exportLoad.setDestPort(keys[4]); + exportLoad.setQuantity(0); + exportLoad.setSpareQuantity(num); + exportLoad.setPortArea(exportIn.getPortArea()); + exportLoad.setPortAreaId(exportIn.getPortAreaId()); + exportLoad.setTermcd(exportIn.getTermcd()); + if (StringUtils.equals("1", type)) { + exportLoad.setCheckStatus(AuditEnum.AUDIT); + } else { + exportLoad.setCheckStatus(AuditEnum.SUBMIT); + } + exportLoad.setApplyTime(new Date()); + exportLoad.setApplicantId(UserContext.getUser().getUserId()); + + heads.put(item.getKey(), exportLoad); + + }); + + if (CollectionUtils.isNotEmpty(errorDataList)) { +// errorDataList.addAll(successDataList); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + + if (MapUtils.isNotEmpty(heads)) { + heads.entrySet().forEach(item -> { + CustomerExportLoad exportLoad = item.getValue(); + String batchNo = customerService.getSequenceNo("export_load_batch_no", "出口装船", "EL"); + exportLoad.setBatchNo(batchNo); + + customerService.saveExportLoad(exportLoad, removeIds.get(item.getKey()), null); + }); + } + + return ResultUtil.success(errorDataList); + } catch (ExcelDataConvertException e) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入数据错误,请确认导入数据模板是否正确, 行:" + e.getRowIndex() + " 列:" + e.getColumnIndex()); } catch (Exception e) { log.error("错误信息", e); return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage()); @@ -1465,7 +2728,7 @@ public class ExportLoadHandler implements BaseHandler { //普通下拉数据 Map map = new HashMap<>(); - String[] isZgArray = {"正常", "国内中转", "外进转内出", "长江","沿海"}; + String[] isZgArray = {"正常", "国内中转", "外进转内出", "长江", "沿海"}; map.put(2, isZgArray); //检查类型-子类 Map> inspNameMap = new HashMap<>(); @@ -1520,7 +2783,6 @@ public class ExportLoadHandler implements BaseHandler { // 结算单位 Map companyMap = new HashMap<>(); -// List companyList = pubApi.getCompanyList(Arrays.asList("7")); // 品牌基础数据 List brandList = dictHandler.getBrandList(null).getData(); // 港口基础数据 @@ -1529,10 +2791,12 @@ public class ExportLoadHandler implements BaseHandler { List shipList = dictHandler.getAllShip(null).getData(); // 港区基础数据 List portAreaList = dictHandler.getPortAreaList(null).getData(); + Map portMap = portAreaList.stream().collect(Collectors.toMap(DictDTO::getId, DictDTO::getText)); // 货物性质 List goodsNature = dictHandler.getGoodsNature().getData(); // 缓存航次信息 Map voyageMap = new HashMap<>(); + Map voyageToPortMap = new HashMap<>(); // 缓存中转航次信息 Map> transferVoyageMap = new HashMap<>(); @@ -1562,6 +2826,11 @@ public class ExportLoadHandler implements BaseHandler { }); if (CollectionUtils.isEmpty(validData)) { + if (CollectionUtils.isEmpty(errorDataList)) { // 代表没有读取到数据 + JSONObject o = new JSONObject(); + o.put("status", "未读取到数据"); + errorDataList.add(o); + } return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); } @@ -1588,12 +2857,6 @@ public class ExportLoadHandler implements BaseHandler { errorDataList.add(o); return; } - if (portAreaList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getPortArea())).count() == 0) { - JSONObject o = JSONObject.from(item); - o.put("status", "港区不存在"); - errorDataList.add(o); - return; - } if (shipList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getShipName())).count() == 0) { JSONObject o = JSONObject.from(item); o.put("status", "船名不存在"); @@ -1605,11 +2868,12 @@ public class ExportLoadHandler implements BaseHandler { req.setSpmName(item.getShipName()); req.setVvyName(item.getVoyage()); List resp = shpApi.queryVvyListByVvNameAndSpmName(Arrays.asList(req)); -// VoyageDTO v = shpApi.getVoyageNameByVvyName(item.getVoyage()); if (CollectionUtils.isEmpty(resp)) { voyageMap.put(StringUtils.join(item.getShipName(), item.getVoyage()), ""); + voyageToPortMap.put(StringUtils.join(item.getShipName(), item.getVoyage()), ""); } else { voyageMap.put(StringUtils.join(item.getShipName(), item.getVoyage()), StringUtils.trim(resp.get(0).getVvyId())); + voyageToPortMap.put(StringUtils.join(item.getShipName(), item.getVoyage()), StringUtils.trim(resp.get(0).getPamId())); } } if (StringUtils.isEmpty(voyageMap.get(StringUtils.join(item.getShipName(), item.getVoyage())))) { @@ -1618,13 +2882,26 @@ public class ExportLoadHandler implements BaseHandler { errorDataList.add(o); return; } + if (StringUtils.isEmpty(voyageToPortMap.get(StringUtils.join(item.getShipName(), item.getVoyage())))) { + JSONObject o = JSONObject.from(item); + o.put("status", "港区不存在"); + errorDataList.add(o); + return; + } + // 匹配港区字典 + if (!portMap.containsKey(voyageToPortMap.get(StringUtils.join(item.getShipName(), item.getVoyage())))) { + JSONObject o = JSONObject.from(item); + o.put("status", "港区不存在"); + errorDataList.add(o); + return; + } if (goodsNature.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getPtrDesc(), item.getNatureFlagName())).count() == 0) { JSONObject o = JSONObject.from(item); o.put("status", "货物性质不存在"); errorDataList.add(o); return; } - if (!StringUtils.equals(item.getNatureFlagName(), "正常")) { + if (StringUtils.equalsAny(item.getNatureFlagName(), "内进转外出", "外进转内出", "国际中转", "国内中转")) { if (shipList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getTransferShipName())).count() == 0) { JSONObject o = JSONObject.from(item); o.put("status", "中转进口船名不存在"); @@ -1682,6 +2959,8 @@ public class ExportLoadHandler implements BaseHandler { // 相同的提单号,必须是相同的结算单位 LambdaQueryWrapper lQuery = new LambdaQueryWrapper<>(); + lQuery.eq(CustomerExportLoad::getShipName, keys[0]); + lQuery.eq(CustomerExportLoad::getVoyage, keys[1]); lQuery.eq(CustomerExportLoad::getBillNo, keys[2]); lQuery.ne(CustomerExportLoad::getSettleCompId, companyMap.get(item.getValue().get(0).getSettleCompName())); @@ -1738,7 +3017,7 @@ public class ExportLoadHandler implements BaseHandler { List existData = item.getValue().stream().filter(p -> existVins.contains(p.getVin())).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(existData)) { - errorDataList.addAll(item.getValue().stream().map(p -> { + errorDataList.addAll(existData.stream().map(p -> { JSONObject o = JSONObject.from(p); o.put("status", "车架号已存在,请勿重复申请"); return o; @@ -1782,15 +3061,15 @@ public class ExportLoadHandler implements BaseHandler { exportLoad.setSpareQuantity(0); exportLoad.setSettleCompId(companyMap.get(item.getValue().get(0).getSettleCompName())); exportLoad.setSettleCompName(item.getValue().get(0).getSettleCompName()); - exportLoad.setPortAreaId(portAreaList.stream().filter(s -> StringUtils.equals(s.getText(), item.getValue().get(0).getPortArea())).findFirst().get().getId()); - exportLoad.setPortArea(item.getValue().get(0).getPortArea()); + exportLoad.setPortAreaId(voyageToPortMap.get(StringUtils.join(keys[0], keys[1]))); + exportLoad.setPortArea(portMap.get(exportLoad.getPortAreaId())); exportLoad.setContact(item.getValue().get(0).getContact()); exportLoad.setContactPhone(item.getValue().get(0).getContactPhone()); exportLoad.setNatureFlagName(item.getValue().get(0).getNatureFlagName()); exportLoad.setNatureFlag(goodsNature.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getPtrDesc(), item.getValue().get(0).getNatureFlagName())).findFirst().get().getPtrCode()); exportLoad.setTransferVoyage(item.getValue().get(0).getTransferVoyage()); exportLoad.setTransferShipName(item.getValue().get(0).getTransferShipName()); - if (!StringUtils.equals(item.getValue().get(0).getNatureFlagName(), "正常")) { + if (StringUtils.equalsAny(item.getValue().get(0).getNatureFlagName(), "内进转外出", "外进转内出", "国际中转", "国内中转")) { exportLoad.setTransferShipId(shipList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getValue().get(0).getTransferShipName())).findFirst().get().getId()); exportLoad.setTransferVoyageId(transferVoyageMap.get(exportLoad.getTransferShipName()).stream().filter(p -> StringUtils.equalsIgnoreCase(p.getVvyName(), item.getValue().get(0).getTransferVoyage())).findFirst().get().getVvyId()); } @@ -1813,7 +3092,7 @@ public class ExportLoadHandler implements BaseHandler { }); if (CollectionUtils.isNotEmpty(errorDataList)) { - errorDataList.addAll(successDataList); +// errorDataList.addAll(successDataList); return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); } @@ -1822,129 +3101,105 @@ public class ExportLoadHandler implements BaseHandler { CustomerExportLoad exportLoad = item.getValue(); String batchNo = customerService.getSequenceNo("export_load_batch_no", "出口装船", "EL"); exportLoad.setBatchNo(batchNo); - customerService.saveExportLoad(exportLoad, details.get(item.getKey())); + customerService.saveExportLoad(exportLoad, null, details.get(item.getKey())); }); } return ResultUtil.success(errorDataList); + } catch (ExcelDataConvertException e) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入数据错误,请确认导入数据模板是否正确, 行:" + e.getRowIndex() + " 列:" + e.getColumnIndex()); } catch (Exception e) { log.error("错误信息", e); return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage()); } } - /* - @ApiOperation("内贸整船备件导入") - @PostMapping("/inside/spare/import-to-add") - public Result> insideSpareUpload(@RequestParam(required = false) String type, MultipartFile file) throws IOException { - // 所有读取的数据 - List dataList = new ArrayList<>(); + @ApiOperation("出口装船导出") + @GetMapping("/exportExecl") + public void exportExecl( + @ApiParam(name = "操作方式, 0为前端,1为审核端") @RequestParam(required = false, defaultValue = "0") String type, + ExportLoadCheckQuery query, HttpServletResponse response) { + if (StringUtils.equals(type, "0")) { + query.setCreateBy(UserContext.getUser().getUserId()); + } + query.setPage(1); + query.setRows(100); + query.setSorts(null); +// query.setSorts(Arrays.asList(new BaseQuery.SortField("shipId", "asc"), new BaseQuery.SortField("voyageId", "asc"), new BaseQuery.SortField("billNum", "asc"))); + QueryWrapper queryWrapper = (QueryWrapper) new WrapperKit() { + }.changeBaseQueryToWrapper(CustomerExportLoad.class, query); - // 有错误的数据 - List errorDataList = new ArrayList<>(); + queryWrapper.orderByAsc(Arrays.asList("voyage_id", "bill_no")); - // 公司信息 - List companyList = pubApi.getCompanyList(Arrays.asList("7")); + ExcelWriter excelWriter = null; + OutputStream out = null; + try { + out = response.getOutputStream(); - EasyExcel.read(file.getInputStream(), ExportLoadInsideSpareExcel.class, new ReadExcelListener() { - @Override - protected void saveData(List list) { // 保存数据 - dataList.addAll(list); + // 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("utf-8"); + // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 + String fileName = URLEncoder.encode(DateUtil.format(new Date(), DatePattern.PURE_DATE_PATTERN) + "出口装船清单", "UTF-8"); + response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); + + + excelWriter = EasyExcel.write(out).build(); + + WriteSheet writeSheet = EasyExcel.writerSheet(0, "出口装船计划").head(ExportLoadExportExcel.class).build(); + + // 查询数据 + Page page = customerExportLoadService.page(new Page<>(query.getPage(), query.getRows()), queryWrapper); + + AtomicInteger index = new AtomicInteger(1); + + write(index, page.getRecords(), excelWriter, writeSheet); + + for (int i = 2; i <= page.getPages(); i++) { + query.setPage(i); + page = customerExportLoadService.page(new Page<>(query.getPage(), query.getRows()), queryWrapper); + + write(index, page.getRecords(), excelWriter, writeSheet); } - }).sheet().doRead(); - - ValidatorFactory vf = Validation.buildDefaultValidatorFactory(); - Validator validator = vf.getValidator(); - - List validData = new ArrayList<>(); - - // 数据验证 - dataList.stream().forEach(item -> { - Set> set = validator.validate(item); - if (CollectionUtils.isEmpty(set)) { // 验证通过的 - validData.add(item); - } else { // 验证失败的 - JSONObject o = JSONObject.from(item); - o.put("status", set.stream().map(p -> p.getMessage()).collect(Collectors.joining(","))); - errorDataList.add(o); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (excelWriter != null) { + excelWriter.finish(); + } + if (out != null) { + try { + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } } - }); - - if (CollectionUtils.isEmpty(validData)) { - return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); } - validData.stream().forEach(item -> { - if (companyList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getCueCnname(), item.getSettleCompName())).count() == 0) { - JSONObject o = JSONObject.from(item); - o.put("status", "结算单位不存在"); - errorDataList.add(o); - return; - } - }); + } - // 首先按对船名,般次,提单进行分组 - Map> collect = validData.stream().collect(Collectors.groupingBy(item -> StringUtils.joinWith("#$#", item.getShipName(), item.getVoyage(), item.getBillNo(), item.getBrand()), Collectors.toList())); - collect.entrySet().forEach(item -> { - String[] keys = StringUtils.split(item.getKey(), "#$#"); + private void write(AtomicInteger index, List headers, ExcelWriter excelWriter, WriteSheet writeSheet) { + if (CollectionUtils.isEmpty(headers)) { + excelWriter.write(Collections.emptyList(), writeSheet); + return; + } - // 首先判断,船名,航次,提单号在出口进港申请中是否已经通过 - LambdaQueryWrapper iQuery = new LambdaQueryWrapper<>(); - iQuery.eq(CustomerExportIn::getShipName, keys[0]); - iQuery.eq(CustomerExportIn::getVoyage, keys[1]); - iQuery.eq(CustomerExportIn::getBillNum, keys[2]); - iQuery.eq(CustomerExportIn::getBrand, keys[3]); - iQuery.isNotNull(CustomerExportIn::getVoyageId); - iQuery.eq(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_PASS); + Map loadMap = headers.stream().collect(Collectors.toMap(CustomerExportLoad::getId, s -> s)); - CustomerExportIn exportIn = customerExportInService.getOne(iQuery); - if (exportIn == null || exportIn.getCheckStatus() != AuditEnum.AUDIT_PASS) { - errorDataList.addAll(item.getValue().stream().map(p -> { - JSONObject o = JSONObject.from(p); - o.put("status", "本船名航次下未找到审核通过的出口进港申请"); - return o; - }).collect(Collectors.toList())); - return; - } + List cargos = customerExportLoadCargoService.lambdaQuery() + .in(CustomerExportLoadCargo::getExportLoadId, headers.stream().map(s -> s.getId()).collect(Collectors.toList())).list(); - int num = item.getValue().stream().mapToInt(ExportLoadInsideSpareExcel::getNum).sum(); + if (CollectionUtils.isEmpty(cargos)) { + excelWriter.write(Collections.emptyList(), writeSheet); + return; + } - errorDataList.addAll(item.getValue().stream() - .map(p -> { - JSONObject o = JSONObject.from(p); - o.put("status", "导入成功"); - return o; - }).collect(Collectors.toList())); + List rows = cargos.stream().map(item -> { + ExportLoadExportExcel e = PoMapper.instance.entity2Excel(loadMap.get(item.getExportLoadId())); + e.setVin(item.getVin()); + return e; + }).collect(Collectors.toList()); - String batchNo = customerService.getSequenceNo("export_load_batch_no", "出口装船", "EL"); - - CustomerExportLoad exportLoad = new CustomerExportLoad(); - - exportLoad.setTradType("N"); - exportLoad.setShipId(exportIn.getShipId()); - exportLoad.setShipName(keys[0]); - exportLoad.setShipEnName(exportIn.getShipEnName()); - exportLoad.setVoyageId(exportIn.getVoyageId()); - exportLoad.setVoyage(keys[1]); - exportLoad.setBillNo(keys[2]); - exportLoad.setBrandId(exportIn.getBrandId()); - exportLoad.setBrand(exportIn.getBrand()); - exportLoad.setBatchNo(batchNo); - exportLoad.setQuantity(0); - exportLoad.setSpareQuantity(num); - if (StringUtils.equals("1", type)) { - exportLoad.setCheckStatus(AuditEnum.AUDIT); - } else { - exportLoad.setCheckStatus(AuditEnum.SUBMIT); - } - exportLoad.setApplyTime(new Date()); - -// exportLoad.setQuantity(exportLoad.getQuantity() + saveCargos.size()); - - customerService.saveExportLoad(exportLoad, Collections.emptyList()); - - }); - - return ResultUtil.success(errorDataList); - }*/ + excelWriter.write(rows, writeSheet); + } } diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/FreeTradeHandler.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/FreeTradeHandler.java index a80390c..ef1fa00 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/FreeTradeHandler.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/FreeTradeHandler.java @@ -4,6 +4,7 @@ import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.exception.ExcelDataConvertException; import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.Wrapper; @@ -12,13 +13,18 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.haitonggauto.rtosc.api.NuzarMiniApi; +import com.haitonggauto.rtosc.api.NuzarShpApi; +import com.haitonggauto.rtosc.api.dto.VoyageReq; +import com.haitonggauto.rtosc.api.dto.VoyageResp; import com.haitonggauto.rtosc.common.context.UserContext; +import com.haitonggauto.rtosc.common.dto.DictDTO; import com.haitonggauto.rtosc.common.dto.Result; import com.haitonggauto.rtosc.common.enums.ErrorType; import com.haitonggauto.rtosc.common.handler.BaseHandler; import com.haitonggauto.rtosc.common.utils.*; import com.haitonggauto.rtosc.dto.FreeTradeCheckVo; import com.haitonggauto.rtosc.dto.FreeTradeVo; +import com.haitonggauto.rtosc.dto.ValidVinActivateVo; import com.haitonggauto.rtosc.dto.VoyageSubmitVo; import com.haitonggauto.rtosc.excel.*; import com.haitonggauto.rtosc.handler.excel.ReadExcelListener; @@ -74,6 +80,12 @@ public class FreeTradeHandler implements BaseHandler { @Resource private NuzarMiniApi miniApi; + @Resource + private NuzarShpApi shpApi; + + @Resource + private DictHandler dictHandler; + /** * 分页查询 * @@ -267,19 +279,37 @@ public class FreeTradeHandler implements BaseHandler { return ResultUtil.success("success"); } + @ApiOperation("返回车架号详情, IsActivate 为 1 代表已激活") + @PostMapping("/valid-vins-all") + public Result> validAllVins(@RequestBody @Validated ValidVinActivateVo vo) { + List list = customerFreeTradeService.lambdaQuery() + .eq(StringUtils.isNotEmpty(vo.getShipId()), CustomerFreeTrade::getShipId, vo.getShipId()) + .eq(StringUtils.isNotEmpty(vo.getVoyageId()), CustomerFreeTrade::getVoyageId, vo.getVoyageId()) + .in(CustomerFreeTrade::getVin, vo.getVins()).list(); + // 返回的车架号信息 +// List collect = list.stream().map(item -> item.getVin()).collect(Collectors.toList()); + // 待激活的车架号信息 +// List noActivate = list.stream().filter(item -> item.getIsActivate() == ActiveEnum.NO).map(item -> item.getVin()).collect(Collectors.toList()); +// List noValid = vins.stream().filter(item -> !collect.contains(item) || noActivate.contains(item)).collect(Collectors.toList()); +// if (CollectionUtils.isNotEmpty(noValid)) { +// return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), StringUtils.join(noValid, ",")); +// } + return ResultUtil.success(list); + } + /** * 验证车架号状态是否激活 - * @param vins + * @param vo * @return */ @ApiOperation("验证车架号激活状态, 返回已激活车架号详情") @PostMapping("/valid-vins") - public Result> validVins(@RequestBody - @NotNull(message = "请传入车架号列表") - @Size(min = 1, message = "车架号列表不能为空") List vins) { + public Result> validVins(@RequestBody @Validated ValidVinActivateVo vo) { List list = customerFreeTradeService.lambdaQuery() + .eq(StringUtils.isNotEmpty(vo.getShipId()), CustomerFreeTrade::getShipId, vo.getShipId()) + .eq(StringUtils.isNotEmpty(vo.getVoyageId()), CustomerFreeTrade::getVoyageId, vo.getVoyageId()) .eq(CustomerFreeTrade::getIsActivate, ActiveEnum.YES) - .in(CustomerFreeTrade::getVin, vins).list(); + .in(CustomerFreeTrade::getVin, vo.getVins()).list(); // 返回的车架号信息 // List collect = list.stream().map(item -> item.getVin()).collect(Collectors.toList()); // 待激活的车架号信息 @@ -333,8 +363,8 @@ public class FreeTradeHandler implements BaseHandler { log.setOperateData(record); log.setStatus(check.getCheckStatus() == AuditEnum.AUDIT_PASS ? 0 : 1); log.setOperateTime(new Date()); - log.setUserId(SecurityUtils.getUserId()); - log.setUserName(SecurityUtils.getUserName()); + log.setUserId(UserContext.getUser().getUserId()); + log.setUserName(UserContext.getUser().getUsername()); EsLogApprovalUtil.writeLog(log); } @@ -422,6 +452,12 @@ public class FreeTradeHandler implements BaseHandler { // 验证成功的数据 List successDataList = new ArrayList<>(); + // 船名基础数据 + List shipList = dictHandler.getAllShip(null).getData(); + + // 航次缴存 + Map voyageMap = new HashMap<>(); + try { EasyExcel.read(file.getInputStream(), FreeTradeExcel.class, new ReadExcelListener() { @@ -450,6 +486,41 @@ public class FreeTradeHandler implements BaseHandler { // 所有数据验证都不通过 if (CollectionUtils.isEmpty(validData)) { + if (CollectionUtils.isEmpty(errorDataList)) { // 代表没有读取到数据 + JSONObject o = new JSONObject(); + o.put("status", "未读取到数据"); + errorDataList.add(o); + } + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + + validData.stream().forEach(item -> { + if (shipList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getShipName())).count() == 0) { + JSONObject o = JSONObject.from(item); + o.put("status", "船名不存在"); + errorDataList.add(o); + return; + } + if (!voyageMap.containsKey(StringUtils.join(item.getShipName(), item.getVoyage()))) { + VoyageReq req = new VoyageReq(); + req.setSpmName(item.getShipName()); + req.setVvyName(item.getVoyage()); + List resp = shpApi.queryVvyListByVvNameAndSpmName(Arrays.asList(req)); + if (CollectionUtils.isEmpty(resp)) { + voyageMap.put(StringUtils.join(item.getShipName(), item.getVoyage()), ""); + } else { + voyageMap.put(StringUtils.join(item.getShipName(), item.getVoyage()), StringUtils.trim(resp.get(0).getVvyId())); + } + } + if (StringUtils.isEmpty(voyageMap.get(StringUtils.join(item.getShipName(), item.getVoyage())))) { + JSONObject o = JSONObject.from(item); + o.put("status", "航次不存在"); + errorDataList.add(o); + return; + } + }); + + if (CollectionUtils.isNotEmpty(errorDataList)) { return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); } @@ -467,6 +538,11 @@ public class FreeTradeHandler implements BaseHandler { List collect = validData.stream().map(item -> { CustomerFreeTrade freeTrade = PoMapper.instance.excel2Entity(item); + + freeTrade.setShipId(shipList.stream().filter(s -> StringUtils.equalsIgnoreCase(s.getText(), item.getShipName())).findFirst().get().getId()); + freeTrade.setShipEnName(shipList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getShipName())).findFirst().get().getExtra1()); + freeTrade.setVoyageId(voyageMap.get(StringUtils.join(item.getShipName(), item.getVoyage()))); + freeTrade.setApplicantId(UserContext.getUser().getUserId()); freeTrade.setIsActivate(ActiveEnum.NO); freeTrade.setApplyTime(new Date()); @@ -514,6 +590,8 @@ public class FreeTradeHandler implements BaseHandler { customerFreeTradeService.saveBatch(save); return ResultUtil.success(errorDataList); + } catch (ExcelDataConvertException e) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入数据错误,请确认导入数据模板是否正确, 行:"+e.getRowIndex()+" 列:" + e.getColumnIndex()); } catch (Exception e) { log.error("错误信息", e); return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage()); diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/HeathCheckHandler.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/HeathCheckHandler.java new file mode 100644 index 0000000..70362bf --- /dev/null +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/HeathCheckHandler.java @@ -0,0 +1,14 @@ +package com.haitonggauto.rtosc.handler; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/health") +public class HeathCheckHandler { + @GetMapping("/ping") + public String ping() { + return "pong"; + } +} diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ImportInspectHandler.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ImportInspectHandler.java index 9ca898c..c55519a 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ImportInspectHandler.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ImportInspectHandler.java @@ -2,15 +2,20 @@ package com.haitonggauto.rtosc.handler; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.RandomUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.exception.ExcelDataConvertException; import com.alibaba.excel.write.metadata.WriteSheet; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.haitonggauto.rtosc.api.NuzarOpenApi; +import com.haitonggauto.rtosc.api.NuzarShpApi; import com.haitonggauto.rtosc.api.NuzarYardApi; import com.haitonggauto.rtosc.api.dto.*; import com.haitonggauto.rtosc.api.dto.log.ImportInspectLog; @@ -19,12 +24,16 @@ import com.haitonggauto.rtosc.common.dto.DictDTO; import com.haitonggauto.rtosc.common.dto.Result; import com.haitonggauto.rtosc.common.enums.ErrorType; import com.haitonggauto.rtosc.common.handler.BaseHandler; +import com.haitonggauto.rtosc.common.utils.DateUtils; import com.haitonggauto.rtosc.common.utils.ResultUtil; import com.haitonggauto.rtosc.common.utils.ValidationGroup; import com.haitonggauto.rtosc.common.utils.WrapperKit; import com.haitonggauto.rtosc.dto.*; +import com.haitonggauto.rtosc.excel.ExportInPlanExcel; import com.haitonggauto.rtosc.excel.ExportInspectExportExcel; import com.haitonggauto.rtosc.excel.ImportInspectExportExcel; +import com.haitonggauto.rtosc.excel.InspectExcel; +import com.haitonggauto.rtosc.handler.excel.ReadExcelListener; import com.haitonggauto.rtosc.handler.mapper.PoMapper; import com.haitonggauto.rtosc.query.CargoQuery; import com.haitonggauto.rtosc.query.ExportInspectCheckQuery; @@ -41,18 +50,32 @@ import com.nuzar.rtops.log.service.EsLogApprovalUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.core.io.ClassPathResource; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; -import java.io.IOException; -import java.io.OutputStream; +import java.io.*; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.net.URLEncoder; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; @@ -62,6 +85,7 @@ import java.util.stream.Collectors; @RequestMapping("/iis") @Api(tags = "进口海关查验") @Validated +@Slf4j public class ImportInspectHandler implements BaseHandler { @Resource @@ -79,6 +103,12 @@ public class ImportInspectHandler implements BaseHandler { @Resource private NuzarYardApi yardApi; + @Resource + private NuzarShpApi shpApi; + + @Resource + private DictHandler dictHandler; + @ApiOperation("船名航次模糊匹配") @PostMapping("/shipVoyage") public Result> getExportInShipNameList( @@ -178,17 +208,19 @@ public class ImportInspectHandler implements BaseHandler { @ApiOperation("提单号模糊匹配") @PostMapping("/billNo/query") public Result> getExportInBillNoList( + @ApiParam(name = "操作方式, 0为前端,1为审核端") @RequestParam(required = false, defaultValue = "0") String type, @RequestParam(required = false, defaultValue = "1") Integer current, @RequestParam(required = false, defaultValue = "10") Integer size, @RequestParam(required = false) String shipName, @RequestParam(required = false) String voyage, @RequestParam(required = false) String q) { - LambdaQueryWrapper query = new LambdaQueryWrapper<>(); - query.eq(CustomerExportInspect::getTradType, "I"); - query.eq(StringUtils.isNotEmpty(shipName), CustomerExportInspect::getShipName, shipName); - query.eq(StringUtils.isNotEmpty(voyage), CustomerExportInspect::getVoyage, voyage); - query.like(StringUtils.isNotEmpty(q), CustomerExportInspect::getBillNo, q); // 提单号 - + QueryWrapper query = new QueryWrapper<>(); + query.select("distinct bill_no"); + query.eq("trad_type", "I"); + query.eq(StringUtils.equals(type, "0"), "create_by", UserContext.getUser().getUserId()); + query.eq(StringUtils.isNotEmpty(shipName), "ship_name", shipName); + query.eq(StringUtils.isNotEmpty(voyage), "voyage", voyage); + query.like(StringUtils.isNotEmpty(q), "bill_no", q); // 提单号 Page page = customerExportInspectService.page(new Page<>(current, size), query); List list = page.getRecords(); @@ -346,6 +378,9 @@ public class ImportInspectHandler implements BaseHandler { exportInspect.setCheckStatus(form.getFlag() ? AuditEnum.AUDIT : AuditEnum.SUBMIT); exportInspect.setTermcd(exportInspect.getPortAreaId()); exportInspect.setApplyTime(new Date()); + if (StringUtils.isEmpty(exportInspect.getCompany())) { // 公司为空,则填充申请对象 + exportInspect.setCompany(exportInspect.getApplyObj()); + } List cargos = form.getCargos().stream().map(item -> { CustomerExportInspectCargo entity = PoMapper.instance.exportInspectCargoVo2Entity(item); @@ -474,6 +509,28 @@ public class ImportInspectHandler implements BaseHandler { customerService.wrapperEntity(exportInspect); List cargos = customerExportInspectCargoService.list(new LambdaQueryWrapper().eq(CustomerExportInspectCargo::getExportInspectId, id)); + // 获取实时 + if (CollectionUtils.isNotEmpty(cargos)) { + GoodsStatusReq req = new GoodsStatusReq(); + req.setBusinessType("INSPECT"); + req.setImportExportType("I"); + req.setVvyId(StringUtils.equalsAnyIgnoreCase(exportInspect.getVoyageId(), "HT6", "HTLG", "HTTC") ? "" : exportInspect.getVoyageId()); + req.setVinCodeList(cargos.stream().map(p -> p.getVin()).collect(Collectors.toList())); + + List resp = openApi.getGoodsStatus(req); + + Map respMap = resp.stream().collect(Collectors.toMap(p -> p.getVinCode(), p -> p)); + + cargos.stream().forEach(p -> { + GoodsStatusResp r = respMap.get(p.getVin()); + if (r != null) { + p.setArea(r.getPosition()); + } else { + p.setArea(""); + } + }); + } + customerService.wrapperEntity(cargos); exportInspect.setCargos(cargos); @@ -516,6 +573,35 @@ public class ImportInspectHandler implements BaseHandler { queryWrapper.eq(query.getCargoType() != null, CustomerExportInspectCargo::getCargoType, query.getCargoType()); } Page page = customerExportInspectCargoService.page(new Page<>(query.getPage(), query.getRows()), queryWrapper); + + // 获取实时 + if (CollectionUtils.isNotEmpty(page.getRecords())) { + // 需要按InspectId 进行分组 + Map> collect = page.getRecords().stream().collect(Collectors.groupingBy(CustomerExportInspectCargo::getExportInspectId)); + collect.entrySet().forEach(item -> { + CustomerExportInspect inspect = customerExportInspectService.getById(item.getKey()); + + GoodsStatusReq req = new GoodsStatusReq(); + req.setBusinessType("INSPECT"); + req.setImportExportType("I"); + req.setVvyId(StringUtils.equalsAnyIgnoreCase(inspect.getVoyageId(), "HT6", "HTLG", "HTTC") ? "" : inspect.getVoyageId()); + req.setVinCodeList(item.getValue().stream().map(p -> p.getVin()).collect(Collectors.toList())); + + List resp = openApi.getGoodsStatus(req); + + Map respMap = resp.stream().collect(Collectors.toMap(p -> p.getVinCode(), p -> p)); + + page.getRecords().stream().filter(p -> p.getExportInspectId() == item.getKey()).forEach(p -> { + GoodsStatusResp r = respMap.get(p.getVin()); + if (r != null) { + p.setArea(r.getPosition()); + } else { + p.setArea(""); + } + }); + }); + } + customerService.wrapperEntity(page.getRecords()); return ResultUtil.success(page); } @@ -565,10 +651,11 @@ public class ImportInspectHandler implements BaseHandler { // 判断车辆是否在场 List vinStatus = yardApi.getVinStatus(vins); + List exists = vinStatus.stream().map(item -> item.getVinCode()).collect(Collectors.toList()); page.getRecords().stream().forEach(item -> { item.setInspect(collect.get(item.getExportInspectId())); - item.setInArea(vinStatus.contains(item.getVin())); + item.setInArea(exists.contains(item.getVin())); }); } @@ -607,8 +694,8 @@ public class ImportInspectHandler implements BaseHandler { log.setOperateData(importInspectLog); log.setStatus(check.getCheckStatus() == AuditEnum.AUDIT_PASS ? 0 : 1); log.setOperateTime(new Date()); - log.setUserId(SecurityUtils.getUserId()); - log.setUserName(SecurityUtils.getUserName()); + log.setUserId(UserContext.getUser().getUserId()); + log.setUserName(UserContext.getUser().getUsername()); EsLogApprovalUtil.writeLog(log); } @@ -655,8 +742,8 @@ public class ImportInspectHandler implements BaseHandler { log.setOperateData(record); log.setStatus(check.getCheckStatus() == AuditEnum.AUDIT_PASS ? 0 : 1); log.setOperateTime(new Date()); - log.setUserId(SecurityUtils.getUserId()); - log.setUserName(SecurityUtils.getUserName()); + log.setUserId(UserContext.getUser().getUserId()); + log.setUserName(UserContext.getUser().getUsername()); EsLogApprovalUtil.writeLog(log); } @@ -756,6 +843,7 @@ public class ImportInspectHandler implements BaseHandler { private void write(AtomicInteger index, List headers, ExcelWriter excelWriter, WriteSheet writeSheet) { if (CollectionUtils.isEmpty(headers)) { + excelWriter.write(new ArrayList<>(), writeSheet); return; } @@ -779,6 +867,10 @@ public class ImportInspectHandler implements BaseHandler { // 备件号排序 List details = list.stream().filter(p -> ids.contains(p.getExportInspectId())) + .map(s -> { + s.setCartType(StringUtils.isBlank(s.getCartType()) ? "":s.getCartType()); + return s; + }) .sorted(Comparator.comparing(CustomerExportInspectCargo::getCartType).reversed()) .map(p -> { CustomerExportInspect head = collect.get(p.getExportInspectId()); @@ -791,4 +883,279 @@ public class ImportInspectHandler implements BaseHandler { excelWriter.write(details, writeSheet); }); } + + @ApiOperation("进口查验导入模板下载") + @GetMapping("/temp/down") + public void tempDownPlan(HttpServletResponse response) throws Exception { + // 加载模板 + ClassPathResource classPathResource = new ClassPathResource("templates/import_inspect_temp.xlsx"); + InputStream inputStream = classPathResource.getInputStream(); + + XSSFWorkbook workbook = new XSSFWorkbook(inputStream); + + OutputStream out = response.getOutputStream(); + try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) { + + // 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("utf-8"); + // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 + String fileName = URLEncoder.encode("进口查验导入模板", "UTF-8"); + response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); + + workbook.write(bos); + byte[] bArray = bos.toByteArray(); + InputStream is = new ByteArrayInputStream(bArray); + IOUtils.copy(is, out); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (out != null) { + try { + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + @ApiOperation("进口查验导入") + @PostMapping("/inspect/import-to-add") + public Result> exportInPlanUpload( + @ApiParam(name = "操作方式, 0为前端,1为审核端") @RequestParam(required = false, defaultValue = "0") String type, + MultipartFile file) { + // 所有读取的数据 + List dataList = new ArrayList<>(); + + // 有错误的数据 + List errorDataList = new ArrayList<>(); + + // 验证通过的数据 + List successDataList = new ArrayList<>(); + + Map headMap = new HashMap<>(); + Map> detailMap = new HashMap<>(); + + try { + + EasyExcel.read(file.getInputStream(), InspectExcel.class, new ReadExcelListener() { + @Override + protected void saveData(List list) { // 保存数据 + dataList.addAll(list); + } + }).sheet().doRead(); + + ValidatorFactory vf = Validation.buildDefaultValidatorFactory(); + Validator validator = vf.getValidator(); + + List validData = new ArrayList<>(); + + // 需要保存的数据 + List saveData = new ArrayList<>(); + + // 数据验证 + dataList.stream().forEach(item -> { + Set> set = validator.validate(item); + if (CollectionUtils.isEmpty(set)) { // 验证通过的 + validData.add(item); + } else { // 验证失败的 + JSONObject o = JSONObject.from(item); + o.put("status", set.stream().map(p -> p.getMessage()).collect(Collectors.joining(","))); + errorDataList.add(o); + } + }); + + if (CollectionUtils.isEmpty(validData)) { // 数据完整性检验 + if (CollectionUtils.isEmpty(errorDataList)) { // 代表没有读取到数据 + JSONObject o = new JSONObject(); + o.put("status", "未读取到数据"); + errorDataList.add(o); + } + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + + // 获取用户绑定的货代 + List userBindFreight = openApi.getUserBindFreight(); + + // 港区基础数据 + List portAreaList = dictHandler.getPortAreaList(null).getData(); + + // 航次不能为空 + validData.stream().forEach(item -> { + if (StringUtils.isEmpty(item.getVoyage())) { + JSONObject o = JSONObject.from(item); + o.put("status", "般次不能为空"); + errorDataList.add(o); + return; + } + if (portAreaList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getPortArea())).count() == 0) { + JSONObject o = JSONObject.from(item); + o.put("status", "港区不存在"); + errorDataList.add(o); + return; + } + saveData.add(item); + }); + + // 首先按对船名,般次,提单进行分组 + Map> inMap = saveData.stream() + .collect(Collectors.groupingBy(item -> StringUtils.joinWith("#$#", item.getShipName(), item.getVoyage(), item.getBillNo()), Collectors.toList())); + + inMap.entrySet().forEach(item -> { + String[] keys = StringUtils.split(item.getKey(), "#$#"); + String shipName = keys[0]; // 船名 + String voyageName = keys[1]; // 航次 + String billNo = keys[2]; // 提单号 + + List req = item.getValue().stream().map(s -> { + ImportInspectReq r = new ImportInspectReq(); + r.setSpmName(shipName); + r.setMnfBl(billNo); + r.setVinCode(s.getVin()); + r.setVvyName(voyageName); + return r; + }).collect(Collectors.toList()); + + System.err.println(JSON.toJSONString(req)); + + // 调用接口进行验证 + List resp = shpApi.unloadInfoVerify(req); + + Map stringMap = resp.stream().filter(s -> StringUtils.isNotBlank(s.getErrorMsg())).collect(Collectors.toMap(s -> s.getVinCode(), s -> s.getErrorMsg())); + if (MapUtils.isNotEmpty(stringMap)) { + errorDataList.addAll(item.getValue().stream().filter(p -> stringMap.keySet().contains(p.getVin())).map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", stringMap.get(p.getVin())); + return o; + }).collect(Collectors.toList())); + return; + } + + long count1 = resp.stream().filter(s -> s.getYardGoodsDTO() == null).count(); + if (count1 > 0) { + errorDataList.addAll(item.getValue().stream().filter(p -> stringMap.keySet().contains(p.getVin())).map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "接口未返回货物详细信息,参数为:" + JSONObject.toJSONString(req)); + return o; + }).collect(Collectors.toList())); + return; + } + + ImportInspectResp.YardGoodsDTO in = resp.get(0).getYardGoodsDTO(); + + // 港区是否一致 + long count = item.getValue().stream().map(s -> s.getPortArea()).collect(Collectors.toList()) + .stream().filter(s -> !StringUtils.equals(s, in.getPamName())).count(); + if (count > 0) { + errorDataList.addAll(item.getValue().stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "港区不一致"); + return o; + }).collect(Collectors.toList())); + return; + } + + Map respMap = resp.stream().collect(Collectors.toMap(ImportInspectResp::getVinCode, s -> s)); + List tList = new ArrayList<>(); + item.getValue().forEach(s -> { + String errorMsg = respMap.get(s.getVin()).getErrorMsg(); + if (StringUtils.isNotEmpty(errorMsg)) { + JSONObject o = JSONObject.from(item); + o.put("status", errorMsg); + tList.add(o); + } + }); + + if (CollectionUtils.isNotEmpty(tList)) { + errorDataList.addAll(tList); + return; + } + + CustomerExportInspect head = PoMapper.instance.excel2Entity(item.getValue().get(0)); + + String batchNo = customerService.getSequenceNo("inspect_in_batch_no", "出口查验", "CI"); + head.setInspectStatus(InspectStatusEnum.NO_INSPECT); + head.setBatchNo(batchNo); + head.setApplicantId(UserContext.getUser().getUserId()); + head.setTradType("I"); + head.setPortAreaId(portAreaList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), head.getPortArea())).findFirst().get().getId()); + head.setCheckStatus(StringUtils.equals(type, "1") ? AuditEnum.AUDIT : AuditEnum.SUBMIT); + head.setTermcd(head.getPortAreaId()); + head.setApplyTime(new Date()); + head.setShipId(in.getSpmId()); +// head.setShipEnName(in.getShipEnName()); + if (StringUtils.isNotEmpty(head.getVoyage())) { + head.setVoyageId(in.getVvyId()); + } +// head.setApplyObjId(in.getFreightId()); +// head.setApplyObj(in.getFreight()); + if (StringUtils.isEmpty(head.getCompany())) { + head.setCompany(head.getApplyObj()); + } + + List detail = item.getValue().stream().map(s -> { + CustomerExportInspectCargo c = new CustomerExportInspectCargo(); + c.setCargoType(StringUtils.startsWith(s.getVin(), "BJ") ? 1 : 0); + + ImportInspectResp.YardGoodsDTO ss = respMap.get(s.getVin()).getYardGoodsDTO(); + + c.setBrand(ss.getBrdName()); + c.setBrandId(ss.getBrdId()); + c.setCartTypeId(ss.getGoodsType()); + c.setCartType(ss.getBvmName()); + c.setModels(in.getModel()); + c.setVin(s.getVin()); + return c; + }).collect(Collectors.toList()); + + head.setPlannedCargoQuantity((int)detail.stream().filter( s -> s.getCargoType() == 0).count()); + head.setPlannedSpareQuantity(detail.size() - head.getPlannedCargoQuantity()); + + headMap.put(item.getKey(), head); + detailMap.put(item.getKey(), detail); + + }); + + if (CollectionUtils.isNotEmpty(errorDataList)) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); + } + + // 判断车辆是否在场 + List vinStatus = yardApi.getVinStatus(dataList.stream().map(s -> s.getVin()).collect(Collectors.toList())); +// if (CollectionUtils.isEmpty(vinStatus)) { +// errorDataList.addAll(dataList.stream().map(p -> { +// JSONObject o = JSONObject.from(p); +// o.put("status", "所有查验的车架号均不在场"); +// return o; +// }).collect(Collectors.toList())); +// return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); +// } + + Map vinStatusMap = vinStatus.stream().collect(Collectors.toMap(VinStatus::getVinCode, s -> s)); + + // 保存对象 + headMap.keySet().stream().forEach(s -> customerService.saveExportInspect(headMap.get(s), detailMap.get(s))); + + successDataList.addAll(dataList.stream().map(p -> { + JSONObject o = JSONObject.from(p); + o.put("status", "成功"); + o.put("yardPos", vinStatusMap.containsKey(p.getVin()) ? vinStatusMap.get(p.getVin()).getYardPos() : "未进港"); + return o; + }).collect(Collectors.toList())); + } catch (ExcelDataConvertException e) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入数据错误,请确认导入数据模板是否正确, 行:"+e.getRowIndex()+" 列:" + e.getColumnIndex()); + } catch (Exception e) { + log.error("上传错误", e); + return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), e.getMessage()); + } + + List rst = new ArrayList<>(); + rst.addAll(successDataList.stream().filter(s -> StringUtils.isNotBlank(s.getString("yardPos"))).collect(Collectors.toList())); + rst.addAll(successDataList.stream().filter(s -> StringUtils.isBlank(s.getString("yardPos"))).collect(Collectors.toList())); + + return ResultUtil.success(rst); + } } + + diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ImportUnloadHandler.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ImportUnloadHandler.java index c0b1141..a15bb08 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ImportUnloadHandler.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ImportUnloadHandler.java @@ -441,6 +441,11 @@ public class ImportUnloadHandler implements BaseHandler { }); if (CollectionUtils.isEmpty(validData)) { + if (CollectionUtils.isEmpty(errorDataList)) { // 代表没有读取到数据 + JSONObject o = new JSONObject(); + o.put("status", "未读取到数据"); + errorDataList.add(o); + } return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); } @@ -632,6 +637,11 @@ public class ImportUnloadHandler implements BaseHandler { }); if (CollectionUtils.isEmpty(validData)) { + if (CollectionUtils.isEmpty(errorDataList)) { // 代表没有读取到数据 + JSONObject o = new JSONObject(); + o.put("status", "未读取到数据"); + errorDataList.add(o); + } return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); } diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/excel/ExcelMergeUtil.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/excel/ExcelMergeUtil.java index ff2e9b0..373a7b4 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/excel/ExcelMergeUtil.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/excel/ExcelMergeUtil.java @@ -74,7 +74,7 @@ public class ExcelMergeUtil implements CellWriteHandler { // 将当前单元格数据与上一个单元格数据比较 Boolean dataBool = preData.equals(curData); //此处需要注意,获取每一行第二列数据和上一行第一列数据进行比较,如果相等合并,getCell里面的值,是名称所在列的下标 - System.err.println(cell.getRow().getCell(baseColIndex).getStringCellValue()); +// System.err.println(cell.getRow().getCell(baseColIndex).getStringCellValue()); Boolean bool = cell.getRow().getCell(baseColIndex).getStringCellValue().equals(cell.getSheet().getRow(curRowIndex - 1).getCell(baseColIndex).getStringCellValue()); if (dataBool && bool) { Sheet sheet = writeSheetHolder.getSheet(); diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/excel/ReadExcelListener.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/excel/ReadExcelListener.java index 35071f9..e2460de 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/excel/ReadExcelListener.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/excel/ReadExcelListener.java @@ -5,6 +5,8 @@ import com.alibaba.excel.read.listener.ReadListener; import com.alibaba.excel.util.ListUtils; import com.alibaba.fastjson2.JSON; import lombok.extern.slf4j.Slf4j; +import org.springframework.util.ReflectionUtils; +import org.thymeleaf.util.StringUtils; import java.util.List; @@ -37,10 +39,23 @@ public abstract class ReadExcelListener implements ReadListener { @Override public void invoke(T data, AnalysisContext context) { log.info("解析到一条数据:{}", JSON.toJSONString(data)); + // 去除空格的处理 + ReflectionUtils.doWithFields(data.getClass(), (field) -> { + field.setAccessible(true); + // 只处理字符串类型 + if (String.class.isAssignableFrom(field.getType())) { + // 属性值 + String str = (String)field.get(data); + + field.set(data, StringUtils.trim(str)); + } + + }); cachedDataList.add(data); // 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM if (cachedDataList.size() >= BATCH_COUNT) { + saveData(cachedDataList); // 存储完成清理 list cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT); diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/mapper/PoMapper.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/mapper/PoMapper.java index e70c1de..ba32f9a 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/mapper/PoMapper.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/mapper/PoMapper.java @@ -116,4 +116,8 @@ public interface PoMapper { @Mapping(source = "endEnterTime", target = "inEndTm", dateFormat = "yyyy-MM-dd") @Mapping(source = "contactPhone", target = "personTel") OldExportInAddReq exportIn2OldExportInAddReq(CustomerExportIn exportIn); + + CustomerExportInspect excel2Entity(InspectExcel excel); + + ExportLoadExportExcel entity2Excel(CustomerExportLoad entity); } diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/job/SyncToOldHandler.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/job/SyncToOldHandler.java index a9786d0..52baf09 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/job/SyncToOldHandler.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/job/SyncToOldHandler.java @@ -40,13 +40,6 @@ public class SyncToOldHandler { XxlJobHelper.log("需要同步的数据:" + JSONObject.toJSONString(collect)); - // 异步时,变量会丢失 -// LoginUser tmpUser = new LoginUser(); -// tmpUser.setUserId(SecurityUtils.getUserId()); -// tmpUser.setRoleId(0L); -// tmpUser.setAdmin(true); -// -// UserContext.setUser(tmpUser); for (CustomerExportInSyncLog item : page.getRecords()) { try { diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/service/CustomerService.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/service/CustomerService.java index 5dde021..64dde4a 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/service/CustomerService.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/service/CustomerService.java @@ -49,7 +49,7 @@ public interface CustomerService { * @param cargos * @return */ - Long saveExportLoad(CustomerExportLoad exportLoad, List cargos); + Long saveExportLoad(CustomerExportLoad exportLoad, List removeIds, List cargos); /** * 删除出口装船 diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/service/impl/CustomerServiceImpl.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/service/impl/CustomerServiceImpl.java index 263eab9..307cd1b 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/service/impl/CustomerServiceImpl.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/service/impl/CustomerServiceImpl.java @@ -3,6 +3,8 @@ package com.haitonggauto.rtosc.service.impl; import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.haitonggauto.rtosc.api.NuzarOpenApi; +import com.haitonggauto.rtosc.api.dto.UserInfoDto; import com.haitonggauto.rtosc.common.context.UserContext; import com.haitonggauto.rtosc.common.dto.LoginUser; import com.haitonggauto.rtosc.common.utils.OkHttpUtils; @@ -20,10 +22,12 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.http.client.utils.DateUtils; +import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.context.support.WebApplicationContextUtils; import javax.annotation.Resource; import java.math.RoundingMode; @@ -94,6 +98,9 @@ public class CustomerServiceImpl implements CustomerService { @Resource private SyncConfig syncConfig; + @Resource + private NuzarOpenApi openApi; + @Override @EchoResult public T wrapperEntity(T entity) { @@ -190,6 +197,8 @@ public class CustomerServiceImpl implements CustomerService { @Override @Transactional(rollbackFor = {Exception.class}) public Long saveExportIn(CustomerExportIn exportIn, List cargos, List times, List spares) { + // 去除空格 + exportIn.setBillNum(StringUtils.trim(exportIn.getBillNum())); // 保存表头 exportInService.save(exportIn); @@ -341,7 +350,12 @@ public class CustomerServiceImpl implements CustomerService { @Override @Transactional(rollbackFor = {Exception.class}) - public Long saveExportLoad(CustomerExportLoad exportLoad, List cargos) { + public Long saveExportLoad(CustomerExportLoad exportLoad, List removeIds, List cargos) { + + if (CollectionUtils.isNotEmpty(removeIds)) { + exportLoadCargoService.lambdaUpdate().in(CustomerExportLoadCargo::getExportLoadId, removeIds).remove(); + exportLoadService.lambdaUpdate().in(CustomerExportLoad::getId, removeIds).remove(); + } // 保存表头 exportLoadService.save(exportLoad); @@ -794,9 +808,12 @@ public class CustomerServiceImpl implements CustomerService { if (!syncConfig.getSync() || CollectionUtils.isEmpty(list)) { // 没有打开同步或,列表为空真直接返回 return; } + + UserInfoDto info = openApi.getUserInfo(); // 异步时,变量会丢失 LoginUser tmpUser = new LoginUser(); - tmpUser.setUserId(SecurityUtils.getUserId()); + tmpUser.setUserId(info.getId()); + tmpUser.setUsername(info.getName()); tmpUser.setRoleId(0L); tmpUser.setAdmin(true); @@ -861,9 +878,13 @@ public class CustomerServiceImpl implements CustomerService { if (!syncConfig.getSync() || CollectionUtils.isEmpty(list)) { // 没有打开同步或,列表为空真直接返回 return; } + + UserInfoDto info = openApi.getUserInfo(); + // 异步时,变量会丢失 LoginUser tmpUser = new LoginUser(); - tmpUser.setUserId(SecurityUtils.getUserId()); + tmpUser.setUserId(info.getId()); + tmpUser.setUsername(info.getName()); tmpUser.setRoleId(0L); tmpUser.setAdmin(true); diff --git a/nuzar-customer-controller/src/main/resources/application-pre.yml b/nuzar-customer-controller/src/main/resources/application-pre.yml index 3be0c01..44b93b7 100644 --- a/nuzar-customer-controller/src/main/resources/application-pre.yml +++ b/nuzar-customer-controller/src/main/resources/application-pre.yml @@ -16,7 +16,7 @@ # import: # - optional:nacos:${spring.application.name}-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} -server: - port: 18086 +#server: +# port: 18086 # servlet: # context-path: /move diff --git a/nuzar-customer-controller/src/main/resources/logback-spring.xml b/nuzar-customer-controller/src/main/resources/logback-spring.xml index 06beff5..8e93a79 100644 --- a/nuzar-customer-controller/src/main/resources/logback-spring.xml +++ b/nuzar-customer-controller/src/main/resources/logback-spring.xml @@ -43,8 +43,8 @@ 100MB - 1 - true + 7 + diff --git a/nuzar-customer-controller/src/main/resources/templates/departure_temp.xlsx b/nuzar-customer-controller/src/main/resources/templates/departure_temp.xlsx new file mode 100644 index 0000000..2e55d83 Binary files /dev/null and b/nuzar-customer-controller/src/main/resources/templates/departure_temp.xlsx differ diff --git a/nuzar-customer-controller/src/main/resources/templates/export_inspect_temp.xlsx b/nuzar-customer-controller/src/main/resources/templates/export_inspect_temp.xlsx new file mode 100644 index 0000000..5809018 Binary files /dev/null and b/nuzar-customer-controller/src/main/resources/templates/export_inspect_temp.xlsx differ diff --git a/nuzar-customer-controller/src/main/resources/templates/import_inspect_temp.xlsx b/nuzar-customer-controller/src/main/resources/templates/import_inspect_temp.xlsx new file mode 100644 index 0000000..459a87f Binary files /dev/null and b/nuzar-customer-controller/src/main/resources/templates/import_inspect_temp.xlsx differ diff --git a/nuzar-customer-controller/src/main/resources/templates/in_temp.xlsx b/nuzar-customer-controller/src/main/resources/templates/in_temp.xlsx index fb98092..15acead 100644 Binary files a/nuzar-customer-controller/src/main/resources/templates/in_temp.xlsx and b/nuzar-customer-controller/src/main/resources/templates/in_temp.xlsx differ diff --git a/nuzar-customer-controller/src/main/resources/templates/template.pdf b/nuzar-customer-controller/src/main/resources/templates/template.pdf index 215a7b5..ae06efa 100644 --- a/nuzar-customer-controller/src/main/resources/templates/template.pdf +++ b/nuzar-customer-controller/src/main/resources/templates/template.pdf @@ -2,14 +2,15 @@ 上海海通国际汽车码头有限公司: -基本信息 航次: -受理号: 提货日期: -船名: +基本信息 船名: +受理号: 品牌: +航次: 提货日期: 进港日期: 返回日期: 数量: 事由: +备注: 司机信息 diff --git a/nuzar-customer-controller/src/main/resources/templates/template.xlsx b/nuzar-customer-controller/src/main/resources/templates/template.xlsx index fd2f59e..69d636d 100644 Binary files a/nuzar-customer-controller/src/main/resources/templates/template.xlsx and b/nuzar-customer-controller/src/main/resources/templates/template.xlsx differ diff --git a/nuzar-customer-controller/src/test/java/com/haitonggauto/rtosc/BJNumTest.java b/nuzar-customer-controller/src/test/java/com/haitonggauto/rtosc/BJNumTest.java index 5829377..a5a496c 100644 --- a/nuzar-customer-controller/src/test/java/com/haitonggauto/rtosc/BJNumTest.java +++ b/nuzar-customer-controller/src/test/java/com/haitonggauto/rtosc/BJNumTest.java @@ -1,6 +1,7 @@ package com.haitonggauto.rtosc; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.lang.generator.SnowflakeGenerator; import cn.hutool.core.util.RandomUtil; import com.alibaba.fastjson2.JSONObject; import com.haitonggauto.rtosc.common.utils.OkHttpUtils; @@ -11,42 +12,65 @@ import org.asynchttpclient.RequestBuilder; import org.asynchttpclient.Response; import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.concurrent.ExecutionException; public class BJNumTest { public static void main(String[] args) { - JSONObject page = new JSONObject(); - page.put("current", 1); - page.put("size", 50); +// JSONObject page = new JSONObject(); +// page.put(current, 1); +// page.put(size, 50); +// +// JSONObject params = new JSONObject(); +// params.put(queryPage, page); +// +// DefaultAsyncHttpClient asyncHttpClient = new DefaultAsyncHttpClient(); +// try { +// String str = http://192.168.61.133/tos/yard/shutout/list; +// +// org.asynchttpclient.Request r = new RequestBuilder() +// .setUrl(str) +// .setBody(JSONObject.toJSONString(params)) +// .addHeader(Content-Type, application/json) +// .build(); +// +// ListenableFuture future = asyncHttpClient.executeRequest(r); +// +// org.asynchttpclient.Response resp = future.get(); +// +// System.err.println(responseASYN=============+resp.getResponseBody()); +// +// } catch (ExecutionException e) { +// e.printStackTrace(); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } finally { +// asyncHttpClient.close(); +// } - JSONObject params = new JSONObject(); - params.put("queryPage", page); +// Map map = new HashMap<>(); +// +// map.put(MV.ETERNAL LIGHT, ceshi); +// +// System.err.println(map.get(MV.ETERNAL LIGHT)); - DefaultAsyncHttpClient asyncHttpClient = new DefaultAsyncHttpClient(); - try { - String str = "http://192.168.61.133/tos/yard/shutout/list"; + SnowflakeGenerator generator = new SnowflakeGenerator(); - org.asynchttpclient.Request r = new RequestBuilder() - .setUrl(str) - .setBody(JSONObject.toJSONString(params)) - .addHeader("Content-Type", "application/json") - .build(); +// for (int j = 0; j < 5; j++) { +// new Runnable() { +// @Override +// public void run() { +// for (int i = 0; i < 500; i++) { +// System.err.println(generator.next()); +// } +// } +// }.run(); +// } - ListenableFuture future = asyncHttpClient.executeRequest(r); + List vins = new ArrayList<>(5); + System.err.println(vins.size()); - org.asynchttpclient.Response resp = future.get(); + System.err.println(StringUtils.isNotBlank(" ")); - System.err.println("responseASYN============="+resp.getResponseBody()); - - } catch (ExecutionException e) { - e.printStackTrace(); - } catch (InterruptedException e) { - e.printStackTrace(); - } finally { - asyncHttpClient.close(); - } } } diff --git a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerDeparture.java b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerDeparture.java index 97a5840..37a692a 100644 --- a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerDeparture.java +++ b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerDeparture.java @@ -2,6 +2,7 @@ package com.haitonggauto.rtosc.repository.entity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import com.haitonggauto.rtosc.common.db.entity.BaseEntity; import com.haitonggauto.rtosc.repository.enums.AuditEnum; import com.nuzar.cloud.annotation.echo.Echo; @@ -131,13 +132,29 @@ public class CustomerDeparture extends BaseEntity implements Serializable { /** * 进港日期 */ + @JsonFormat(pattern = "yyyy-MM-dd") @TableField(value = "arrival_time") @ApiModelProperty(value = "进港日期") private Date arrivalTime; + /** + * 品牌ID + */ + @TableField(value = "brand_id") + @ApiModelProperty(value = "品牌ID") + private String brandId; + + /** + * 品牌 + */ + @TableField(value = "brand") + @ApiModelProperty(value = "品牌") + private String brand; + /** * 提货日期 */ + @JsonFormat(pattern = "yyyy-MM-dd") @TableField(value = "delivery_time") @ApiModelProperty(value = "提货日期") private Date deliveryTime; @@ -145,6 +162,7 @@ public class CustomerDeparture extends BaseEntity implements Serializable { /** * 返回日期 */ + @JsonFormat(pattern = "yyyy-MM-dd") @TableField(value = "return_time") @ApiModelProperty(value = "返回日期") private Date returnTime; @@ -214,10 +232,22 @@ public class CustomerDeparture extends BaseEntity implements Serializable { @ApiModelProperty(value = "备注") private String remark; - @TableField(exist = false) - @ApiModelProperty(value = "数量(计划中,备件数和车辆数之后)") + @TableField(value = "quantity") + @ApiModelProperty(value = "数量(计划中,备件数和车辆数之和)") private Integer quantity; + @TableField(value = "car_quantity") + @ApiModelProperty(value = "车辆数") + private Integer carQuantity; + + @TableField(value = "spare_quantity") + @ApiModelProperty(value = "备件数") + private Integer spareQuantity; + + @TableField(value = "work_status") + @ApiModelProperty(value = "工作过程") + private String workStatus; + /** * 事由 */ diff --git a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerDepartureCargo.java b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerDepartureCargo.java index 6fb6f80..d37d28f 100644 --- a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerDepartureCargo.java +++ b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerDepartureCargo.java @@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; +import java.math.BigDecimal; /** * 提离港区货物表 @@ -24,13 +25,6 @@ public class CustomerDepartureCargo extends BaseEntity implements Serializable { @ApiModelProperty(hidden = true) private Long departureId; - /** - * 货物类型ID,0代表车辆,1代表备件 - */ - @TableField(value = "cargo_type") - @ApiModelProperty(hidden = true) - private String cargoType; - /** * 提单号 */ @@ -38,20 +32,6 @@ public class CustomerDepartureCargo extends BaseEntity implements Serializable { @ApiModelProperty(value = "提单号") private String billNo; - /** - * 品牌ID - */ - @TableField(value = "brand_id") - @ApiModelProperty(value = "品牌ID") - private String brandId; - - /** - * 品牌 - */ - @TableField(value = "brand") - @ApiModelProperty(value = "品牌") - private String brand; - /** * 车架号/条码 */ @@ -59,12 +39,10 @@ public class CustomerDepartureCargo extends BaseEntity implements Serializable { @TableField(value = "vin") private String vin; - /** - * 数量 - */ - @ApiModelProperty(value = "数量") - @TableField(value = "quantity") - private Integer quantity; + // 是否报关 + @ApiModelProperty(value = "是否报关") + @TableField(value = "is_customs") + private Integer isCustoms; /** * 是否退关 @@ -73,6 +51,11 @@ public class CustomerDepartureCargo extends BaseEntity implements Serializable { @TableField(value = "is_shutout") private Integer isShutout; + // 是否随车备件 + @ApiModelProperty(value = "是否随车备件") + @TableField(value = "is_spare") + private Integer isSpare; + /** * 车辆状态 */ @@ -80,6 +63,57 @@ public class CustomerDepartureCargo extends BaseEntity implements Serializable { @ApiModelProperty(value = "车辆状态") private String vinStatus; + /** + * 车型ID + */ + @TableField(value = "cart_type_id") + @ApiModelProperty(value = "车型ID") + private String cartTypeId; + + /** + * 车型 + */ + @TableField(value = "cart_type") + @ApiModelProperty(value = "车型") + private String cartType; + // 型号 + + @TableField(value = "models") + @ApiModelProperty(value = "型号") + private String models; + /** + * 长 + */ + @TableField(value = "length") + @ApiModelProperty(value = "长") + private BigDecimal length; + + /** + * 宽 + */ + @TableField(value = "width") + @ApiModelProperty(value = "宽") + private BigDecimal width; + + /** + * 高 + */ + @TableField(value = "height") + @ApiModelProperty(value = "高") + private BigDecimal height; + + /** + * 重量(吨) + */ + @TableField(value = "weight") + @ApiModelProperty(value = "重量") + private BigDecimal weight; + + @TableField(exist = false) + @ApiModelProperty(value = "进港时间") + private String carPickTime; + + @TableField(exist = false) @ApiModelProperty(hidden = true) private static final long serialVersionUID = 1L; diff --git a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerExportIn.java b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerExportIn.java index c69c371..5dec2d1 100644 --- a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerExportIn.java +++ b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerExportIn.java @@ -192,6 +192,14 @@ public class CustomerExportIn extends BaseEntity implements Serializable { @ApiModelProperty(value = "运输方式") private String transportWay; + @TableField(value = "pre_arrival_time") + @ApiModelProperty(value = "预进港时间") + private Date preArrivalTime; + + @TableField(value = "plan_arrive_port_time") + @ApiModelProperty(value = "预靠泊时间") + private Date planArrivePortTime; + /** * 进场开始时间 */ @@ -451,6 +459,10 @@ public class CustomerExportIn extends BaseEntity implements Serializable { @ApiModelProperty(value = "是否装船确认") private Integer loadShipFlag = 0; + @TableField(value = "unberth_flag") + @ApiModelProperty(value = "是否离泊确认") + private Integer unberthFlag = 0; + @TableField(exist = false) @ApiModelProperty(value = "进场日期", hidden = true) private Date tmpEnterDate; diff --git a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerExportInCargo.java b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerExportInCargo.java index c0f7662..fc6b5e2 100644 --- a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerExportInCargo.java +++ b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerExportInCargo.java @@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; +import java.math.BigDecimal; /** * 出口进场货物表 @@ -82,6 +83,14 @@ public class CustomerExportInCargo extends BaseEntity implements Serializable { @ApiModelProperty(value = "航次") private String voyage; + @TableField(exist = false) + @ApiModelProperty(value = "港口ID") + private String portId; + + @TableField(exist = false) + @ApiModelProperty(value = "港口名称") + private String portName; + @TableField(exist = false) @ApiModelProperty(value = "型号") private String models; @@ -112,6 +121,34 @@ public class CustomerExportInCargo extends BaseEntity implements Serializable { @ApiModelProperty(value = "车架号") private String vin; + /** + * 长 + */ + @TableField(exist = false) + @ApiModelProperty(value = "长") + private BigDecimal length; + + /** + * 宽 + */ + @TableField(exist = false) + @ApiModelProperty(value = "宽") + private BigDecimal width; + + /** + * 高 + */ + @TableField(exist = false) + @ApiModelProperty(value = "高") + private BigDecimal height; + + /** + * 重量(吨) + */ + @TableField(exist = false) + @ApiModelProperty(value = "重量") + private BigDecimal weight; + @TableField(exist = false) @ApiModelProperty(value = "进港记录") private CustomerExportIn exportIn; diff --git a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerExportInspect.java b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerExportInspect.java index c749369..477d856 100644 --- a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerExportInspect.java +++ b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerExportInspect.java @@ -3,7 +3,6 @@ package com.haitonggauto.rtosc.repository.entity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.haitonggauto.rtosc.common.db.entity.BaseEntity; -import com.haitonggauto.rtosc.common.dto.DictDTO; import com.haitonggauto.rtosc.repository.enums.AuditEnum; import com.haitonggauto.rtosc.repository.enums.InspectStatusEnum; import com.nuzar.cloud.annotation.echo.Echo; diff --git a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerFreeTrade.java b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerFreeTrade.java index 652abec..58c36a8 100644 --- a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerFreeTrade.java +++ b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerFreeTrade.java @@ -47,6 +47,43 @@ public class CustomerFreeTrade extends BaseEntity implements Serializable { @ApiModelProperty(value = "港区") private String portArea; + /** + * 船名 + */ + @TableField(value = "ship_id") + @ApiModelProperty(value = "船ID") + private String shipId; + + /** + * 中文船名 + */ + @TableField(value = "ship_name") + @ApiModelProperty(value = "中文船名") + @EsLogMean(name = "船名", title = true) + private String shipName; + + /** + * 英文船名 + */ + @TableField(value = "ship_en_name") + @ApiModelProperty(value = "英文船名") + private String shipEnName; + + /** + * 航次ID + */ + @TableField(value = "voyage_id") + @ApiModelProperty(value = "航次ID") + private String voyageId; + + /** + * 航次 + */ + @TableField(value = "voyage") + @ApiModelProperty(value = "航次") + @EsLogMean(name = "航次", title = true) + private String voyage; + /** * 企业编码 */ diff --git a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/mapper/CustomerExportInMapper.java b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/mapper/CustomerExportInMapper.java index a14222e..135f362 100644 --- a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/mapper/CustomerExportInMapper.java +++ b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/mapper/CustomerExportInMapper.java @@ -19,7 +19,7 @@ public interface CustomerExportInMapper extends BaseMapper { * @param voyageId * @return */ - List getListByVoyageId(@Param("voyageId") String voyageId, @Param("status") AuditEnum status); + List getListByVoyageId(@Param("shipId") String shipId, @Param("voyageId") String voyageId, @Param("billNos") List billNos, @Param("status") AuditEnum status); List getExportList(@Param("ids")List ids, @Param("voyageId") String voyageId); } diff --git a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/mapper/CustomerExportLoadMapper.java b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/mapper/CustomerExportLoadMapper.java index f443839..d6d6464 100644 --- a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/mapper/CustomerExportLoadMapper.java +++ b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/mapper/CustomerExportLoadMapper.java @@ -17,7 +17,7 @@ import java.util.List; */ public interface CustomerExportLoadMapper extends BaseMapper { - List getListByVoyageId(@Param("voyageId") String voyageId, @Param("status") AuditEnum status); + List getListByVoyageId(@Param("voyageId") String voyageId, @Param("billNos") List billNos, @Param("status") AuditEnum status); Page getReceiveCarShipList(@Param("page") Page page, @Param("q") String q); } diff --git a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/query/PrintQuery.java b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/query/PrintQuery.java index da86a42..3c47d71 100644 --- a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/query/PrintQuery.java +++ b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/query/PrintQuery.java @@ -10,6 +10,9 @@ import java.util.List; @Data @ApiModel("打印查询") public class PrintQuery implements Serializable { + @ApiModelProperty("船ID") + private String shipId; + @ApiModelProperty("航次ID") private String voyageId; @@ -18,4 +21,7 @@ public class PrintQuery implements Serializable { @ApiModelProperty("货物ID列表") private List id; + + @ApiModelProperty("0代表车辆,1代表备件,空代表所有") + private String flag; } diff --git a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/service/CustomerExportInService.java b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/service/CustomerExportInService.java index 4fe9733..7bed576 100644 --- a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/service/CustomerExportInService.java +++ b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/service/CustomerExportInService.java @@ -18,7 +18,7 @@ public interface CustomerExportInService extends IService { * @param voyageId * @return */ - List getListByVoyageId(String voyageId, AuditEnum status); + List getListByVoyageId(String shipId, String voyageId, List billNos, AuditEnum status); /** * 数据导出 diff --git a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/service/CustomerExportLoadService.java b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/service/CustomerExportLoadService.java index d3ceda7..c9a86e4 100644 --- a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/service/CustomerExportLoadService.java +++ b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/service/CustomerExportLoadService.java @@ -18,7 +18,7 @@ public interface CustomerExportLoadService extends IService * @param voyageId * @return */ - List getListByVoyageId(String voyageId, AuditEnum status); + List getListByVoyageId(String voyageId, List billNos, AuditEnum status); /** * 收车凭证: 进港申请(审核通过)、装船申请(审核通过 diff --git a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/service/impl/CustomerExportInServiceImpl.java b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/service/impl/CustomerExportInServiceImpl.java index 0bde05b..79b4424 100644 --- a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/service/impl/CustomerExportInServiceImpl.java +++ b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/service/impl/CustomerExportInServiceImpl.java @@ -20,8 +20,8 @@ public class CustomerExportInServiceImpl extends ServiceImpl getListByVoyageId(String voyageId, AuditEnum status) { - return getBaseMapper().getListByVoyageId(voyageId, status); + public List getListByVoyageId(String shipId, String voyageId, List billNos, AuditEnum status) { + return getBaseMapper().getListByVoyageId(shipId, voyageId, billNos, status); } @Override diff --git a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/service/impl/CustomerExportLoadServiceImpl.java b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/service/impl/CustomerExportLoadServiceImpl.java index 74fef13..79988fd 100644 --- a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/service/impl/CustomerExportLoadServiceImpl.java +++ b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/service/impl/CustomerExportLoadServiceImpl.java @@ -20,8 +20,8 @@ public class CustomerExportLoadServiceImpl extends ServiceImpl getListByVoyageId(String voyageId, AuditEnum status) { - return getBaseMapper().getListByVoyageId(voyageId, status); + public List getListByVoyageId(String voyageId, List billNos, AuditEnum status) { + return getBaseMapper().getListByVoyageId(voyageId, billNos, status); } @Override diff --git a/nuzar-customer-repository/src/main/resources/mapper/CustomerDepartureCargoMapper.xml b/nuzar-customer-repository/src/main/resources/mapper/CustomerDepartureCargoMapper.xml index d0c7adc..23454c4 100644 --- a/nuzar-customer-repository/src/main/resources/mapper/CustomerDepartureCargoMapper.xml +++ b/nuzar-customer-repository/src/main/resources/mapper/CustomerDepartureCargoMapper.xml @@ -4,31 +4,31 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - id,departure_id,bill_no, - brand,cargo_type,vin, - quantity,is_shutout,is_del, - create_by,create_date,update_by, - update_date,version,termcd, - brand_id - + + + + + + + + diff --git a/nuzar-customer-repository/src/main/resources/mapper/CustomerExportInCargoMapper.xml b/nuzar-customer-repository/src/main/resources/mapper/CustomerExportInCargoMapper.xml index 14dd5ee..c75fee7 100644 --- a/nuzar-customer-repository/src/main/resources/mapper/CustomerExportInCargoMapper.xml +++ b/nuzar-customer-repository/src/main/resources/mapper/CustomerExportInCargoMapper.xml @@ -104,6 +104,9 @@ select customer_export_in.*, customer_export_in.id as m_id, customer_export_in_cargo.id as vin_id, export_in_id, - vin,cargo_type, work_status from customer_export_in left join customer_export_in_cargo on customer_export_in.id=customer_export_in_cargo.export_in_id where customer_export_in.is_del = 0 and (customer_export_in_cargo.is_del = 0 and customer_export_in_cargo.vin_status=1 or customer_export_in_cargo.is_del is null) and customer_export_in.voyage_id=#{voyageId} and customer_export_in.check_status=#{status} + vin,cargo_type, work_status from customer_export_in left join customer_export_in_cargo on customer_export_in.id=customer_export_in_cargo.export_in_id where customer_export_in.is_del = 0 and (customer_export_in_cargo.is_del = 0 and customer_export_in_cargo.vin_status=1 or customer_export_in_cargo.is_del is null) + and customer_export_in.ship_id=#{shipId} and customer_export_in.voyage_id=#{voyageId} and customer_export_in.check_status=#{status} + + and customer_export_in.bill_num in + #{billNo} + select customer_export_load.*, customer_export_load.id as m_id, - customer_export_load_cargo.id as vin_id, export_load_id, customer_export_load_cargo.brand as v_brand, customer_export_load_cargo.models as v_models, vin, work_status,cargo_type,customer_export_load_cargo.brand_id as v_brand_id,settle_comp_id,settle_comp_name,contact,contact_phone from customer_export_load left join customer_export_load_cargo on customer_export_load.id=customer_export_load_cargo.export_load_id where customer_export_load.is_del = 0 and (customer_export_load_cargo.is_del = 0 and customer_export_load_cargo.vin_status=1 or customer_export_load_cargo.is_del is null) and customer_export_load.voyage_id=#{voyageId} and check_status=#{status} + customer_export_load_cargo.id as vin_id, export_load_id, customer_export_load_cargo.brand as v_brand, customer_export_load_cargo.models as v_models, vin, work_status,cargo_type,customer_export_load_cargo.brand_id as v_brand_id,settle_comp_id,settle_comp_name,contact,contact_phone from customer_export_load left join customer_export_load_cargo on customer_export_load.id=customer_export_load_cargo.export_load_id where customer_export_load.is_del = 0 + and customer_export_load.voyage_id=#{voyageId} and check_status=#{status} + + and customer_export_load.bill_no in + #{billNo} +