diff --git a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/BasicdataPriceImportVO.java b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/BasicdataPriceImportVO.java new file mode 100644 index 000000000..7cb2a5949 --- /dev/null +++ b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/BasicdataPriceImportVO.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package com.logpm.basicdata.vo; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.logpm.basicdata.entity.BasicdataPriceEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + +import java.util.Date; + +/** + * 基础价格表 实体类 + * + * @author zqb + * @since 2024-04-02 + */ +@Data +@ApiModel(value = "BasicdataPrice对象", description = "基础价格表") +@EqualsAndHashCode(callSuper = true) +public class BasicdataPriceImportVO extends BasicdataPriceEntity { + + @ApiModelProperty(value = "客户名称") + private String clientName; + @ApiModelProperty(value = "客户编码") + private String clientCode; + @ApiModelProperty(value = "品牌名称") + private String brandName; + +} diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/constant/BasicdataConstants.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/constant/BasicdataConstants.java new file mode 100644 index 000000000..824ee2f73 --- /dev/null +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/constant/BasicdataConstants.java @@ -0,0 +1,13 @@ +package com.logpm.basicdata.constant; + +/** + * @author zhaoqiaobo + * @create 2024-04-24 + */ +public abstract class BasicdataConstants { + + public interface Price { + String VEHICLE_TYPE = "price_vehicle_type"; + } + +} diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/dto/BasicdataPriceRouteImportDTO.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/dto/BasicdataPriceRouteImportDTO.java new file mode 100644 index 000000000..9d707993b --- /dev/null +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/dto/BasicdataPriceRouteImportDTO.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package com.logpm.basicdata.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 基础价格路径 数据传输对象实体类 + * + * @author zqb + * @since 2024-04-08 + */ +@Data +public class BasicdataPriceRouteImportDTO implements Serializable { + + /** + * 客户编码 + */ + private String clientCode; + /** + * 品牌 + */ + private String brand; + /** + * 发货单位 + */ + private String sendOrgCode; + /** + * 发站省 + */ + private String startProvince; + /** + * 发站市 + */ + private String startCity; + /** + * 发站区 + */ + private String startArea; + /** + * 到站省 + */ + private String endProvince; + /** + * 到站市 + */ + private String endCity; + /** + * 到站区 + */ + private String endArea; + /** + * 类型 提货,干线 + */ + private String type; + +} diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/enums/DispatchPricingTypeEnums.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/enums/DispatchPricingTypeEnums.java index 3af7fba8c..2ed67c096 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/enums/DispatchPricingTypeEnums.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/enums/DispatchPricingTypeEnums.java @@ -10,14 +10,14 @@ import org.springblade.common.model.IDict; */ public enum DispatchPricingTypeEnums implements IDict { - PIECE(1, "按件计费"), - WEIGHT(2, "按重量计费"), - CUBE(3, "按方计费"), - COMPLETE_VEHICLE(4, "按整车计费"), - DESTINATIONS_NUMBER(5, "按点位计费"), - TON_PER_KILOMETER(6, "按吨公里计费"), - KILOMETER(7, "按公里计费"), - TON(8, "按吨计费"), + PIECE(1, "按件"), + WEIGHT(2, "按重量"), + CUBE(3, "按方"), + COMPLETE_VEHICLE(4, "按整车"), + DESTINATIONS_NUMBER(5, "按点位"), + TON_PER_KILOMETER(6, "按吨公里"), + KILOMETER(7, "按公里"), + TON(8, "按吨"), ; DispatchPricingTypeEnums(Integer code, String text) { diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/enums/FullVehicleTypeEnums.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/enums/FullVehicleTypeEnums.java index 2ad5f0f67..f523c686b 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/enums/FullVehicleTypeEnums.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/enums/FullVehicleTypeEnums.java @@ -10,9 +10,9 @@ import org.springblade.common.model.IDict; */ public enum FullVehicleTypeEnums implements IDict { - PICK_UP(1, "提货整车"), - TRUNK_LINE(2, "干线整车"), - DISPATCH(4, "配送整车"), + PICK_UP(1, "提货"), + TRUNK_LINE(2, "干线"), + DISPATCH(4, "配送"), ; FullVehicleTypeEnums(Integer code, String text) { diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/enums/WarehousePricingTypeEnums.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/enums/WarehousePricingTypeEnums.java index 430f075ac..f572bda2e 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/enums/WarehousePricingTypeEnums.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/enums/WarehousePricingTypeEnums.java @@ -12,8 +12,8 @@ public enum WarehousePricingTypeEnums implements IDict { PIECE(1, "按件"), CUBE(2, "按方"), - WEIGHT(3, "按重量(Kg)"), - TONNE(4, "按吨(t)"), + WEIGHT(3, "按重量"), + TONNE(4, "按吨"), ; WarehousePricingTypeEnums(Integer code, String text) { diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceCategoryBasicExcel.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceCategoryBasicExcel.java index 7001e55de..05cb55f59 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceCategoryBasicExcel.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceCategoryBasicExcel.java @@ -40,23 +40,35 @@ public class BasicdataPriceCategoryBasicExcel implements Serializable { private static final long serialVersionUID = 1L; - @ExcelProperty(value = "客户名称", index = 0) + @ExcelProperty(value = {"客户名称", "客户名称"}, index = 0) private String client; - @ExcelProperty(value = "品牌", index = 1) + @ExcelProperty(value = {"客户编码", "客户编码"}, index = 1) + private String clientCode; + @ExcelProperty(value = {"品牌", "品牌"}, index = 2) private String brand; - @ExcelProperty(value = "发站", index = 2) - private String startName; - @ExcelProperty(value = "到站", index = 3) - private String endName; - @ExcelProperty(value = "发货单位", index = 4) + @ExcelProperty(value = {"发站", "省"}, index = 3) + private String startProvince; + @ExcelProperty(value = {"发站", "市"}, index = 4) + private String startCity; + @ExcelProperty(value = {"发站", "区"}, index = 5) + private String startArea; + @ExcelProperty(value = {"到站", "省"}, index = 6) + private String endProvince; + @ExcelProperty(value = {"到站", "市"}, index = 7) + private String endCity; + @ExcelProperty(value = {"到站", "区"}, index = 8) + private String endArea; + @ExcelProperty(value = {"发货单位", "发货单位"}, index = 9) private String sendOrg; - @ExcelProperty(value = "服务类型", index = 5) + @ExcelProperty(value = {"发货单位", "发货单位编码"}, index = 10) + private String sendOrgCode; + @ExcelProperty(value = {"类型", "类型"}, index = 11) private String type; - @ExcelProperty(value = "计费类型", index = 6) + @ExcelProperty(value = {"计价方式", "计价方式"}, index = 12) private String costType; - @ExcelProperty(value = "品类", index = 7) + @ExcelProperty(value = {"品类", "品类"}, index = 13) private String category; - @ExcelProperty(value = "单价", index = 8) + @ExcelProperty(value = {"单价", "单价"}, index = 14) private String price; } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceCategoryDispatchExcel.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceCategoryDispatchExcel.java index 9c8a6c51b..bd96cb769 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceCategoryDispatchExcel.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceCategoryDispatchExcel.java @@ -40,27 +40,29 @@ public class BasicdataPriceCategoryDispatchExcel implements Serializable { private static final long serialVersionUID = 1L; - @ExcelProperty(value = "客户名称", index = 0) + @ExcelProperty(value = {"客户名称", "客户名称"}, index = 0) private String client; - @ExcelProperty(value = "品牌", index = 1) + @ExcelProperty(value = {"客户编码", "客户编码"}, index = 1) + private String clientCode; + @ExcelProperty(value = {"品牌", "品牌"}, index = 2) private String brand; - @ExcelProperty(value = "费用类型", index = 2) + @ExcelProperty(value = {"费用类型", "费用类型"}, index = 3) private String type; - @ExcelProperty(value = "计价方式", index = 3) - private String costType; - @ExcelProperty(value = "品类", index = 4) + @ExcelProperty(value = {"品类", "品类"}, index = 4) private String category; - @ExcelProperty(value = "单价", index = 5) - private Double price; - @ExcelProperty(value = "遗留单价", index = 6) - private Double leaveBehindPrice; - @ExcelProperty(value = "分货费", index = 7) - private Double sortPrice; - @ExcelProperty(value = "操作/装卸费", index = 8) - private Double handlingPrice; - @ExcelProperty(value = "平移费", index = 9) - private Double relocationPrice; - @ExcelProperty(value = "上楼费", index = 10) - private Double upstairsDeliveryPrice; + @ExcelProperty(value = {"一般计费", "计价方式"}, index = 5) + private String costType; + @ExcelProperty(value = {"一般计费", "单价"}, index = 6) + private String price; + @ExcelProperty(value = {"一般计费", "单价"}, index = 7) + private String leaveBehindPrice; + @ExcelProperty(value = {"附加费", "分货费"}, index = 8) + private String sortPrice; + @ExcelProperty(value = {"附加费", "操作/装卸费"}, index = 9) + private String handlingPrice; + @ExcelProperty(value = {"附加费", "平移费"}, index = 10) + private String relocationPrice; + @ExcelProperty(value = {"附加费", "上楼费"}, index = 11) + private String upstairsDeliveryPrice; } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceCategoryWarehouseExcel.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceCategoryWarehouseExcel.java index 310c986d8..c46b93af6 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceCategoryWarehouseExcel.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceCategoryWarehouseExcel.java @@ -21,7 +21,6 @@ import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.write.style.ColumnWidth; import com.alibaba.excel.annotation.write.style.ContentRowHeight; import com.alibaba.excel.annotation.write.style.HeadRowHeight; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; @@ -41,27 +40,31 @@ public class BasicdataPriceCategoryWarehouseExcel implements Serializable { private static final long serialVersionUID = 1L; - @ExcelProperty(value = "客户名称", index = 0) + @ExcelProperty(value = {"客户名称", "客户名称"}, index = 0) private String client; - @ExcelProperty(value = "品牌", index = 1) + @ExcelProperty(value = {"客户编码", "客户编码"}, index = 1) + private String clientCode; + @ExcelProperty(value = {"品牌", "品牌"}, index = 2) private String brand; - @ExcelProperty(value = "计价方式", index = 2) + @ExcelProperty(value = {"费用类型", "费用类型"}, index = 3) + private String type; + @ExcelProperty(value = {"计价方式", "计价方式"}, index = 4) private String costType; - @ExcelProperty(value = "品类", index = 3) + @ExcelProperty(value = {"品类", "品类"}, index = 5) private String category; - @ExcelProperty(value = "30天内", index = 4) + @ExcelProperty(value = {"一般计费", "30天内"}, index = 6) private String withinThirtyPrice; - @ExcelProperty(value = "30-60天", index = 5) + @ExcelProperty(value = {"一般计费", "30-60天"}, index = 7) private String betweenThirtySixtyPrice; - @ExcelProperty(value = "60天外", index = 6) + @ExcelProperty(value = {"一般计费", "60天外"}, index = 8) private String beyondSixtyPrice; - @ExcelProperty(value = "上限价格", index = 7) + @ExcelProperty(value = {"一般计费", "上限价格"}, index = 9) private String maximumPrice; - @ExcelProperty(value = "操作/装卸费", index = 8) + @ExcelProperty(value = {"附加费", "操作/装卸费"}, index = 10) private String operatePrice; - @ExcelProperty(value = "仓储管理费", index = 9) + @ExcelProperty(value = {"附加费", "仓储管理费"}, index = 11) private String warehouseManagementPrice; - @ExcelProperty(value = "仓储分货费", index = 10) + @ExcelProperty(value = {"附加费", "仓储分货费"}, index = 12) private String warehouseSortPrice; } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceExcel.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceExcel.java index a7eb045e4..9ce97cc41 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceExcel.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceExcel.java @@ -21,6 +21,7 @@ import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.write.style.ColumnWidth; import com.alibaba.excel.annotation.write.style.ContentRowHeight; import com.alibaba.excel.annotation.write.style.HeadRowHeight; +import com.logpm.basicdata.util.TrimConverter; import lombok.Data; import java.io.Serializable; @@ -45,42 +46,44 @@ public class BasicdataPriceExcel implements Serializable { */ @ExcelProperty(value = "客户名称", index = 0) private String client; + @ExcelProperty(value = "客户编码", index = 1) + private String clientCode; /** * 品牌 */ - @ExcelProperty(value = "品牌", index = 1) + @ExcelProperty(value = "品牌", index = 2) private String brand; /** * 生效时间 */ - @ExcelProperty(value = "生效时间", index = 2) + @ExcelProperty(value = "生效时间", index = 3) private String effectiveTime; /** * 到期时间 */ - @ExcelProperty(value = "到期时间", index = 3) + @ExcelProperty(value = "到期时间", index = 4) private String expiryTime; /** * 模版名称 */ - @ExcelProperty(value = "模版名称", index = 4) + @ExcelProperty(value = "模版名称", index = 5) private String templateName; /** * 向上判断件数 */ - @ExcelProperty(value = "向上判断件数", index = 5) + @ExcelProperty(value = "向上判断件数", index = 6) private String dispatchUpwardJudgment; /** - * 向上判断件数 + * 向上判断加价 */ - @ExcelProperty(value = "向上判断件数", index = 6) + @ExcelProperty(value = "向上判断加价", index = 7) private String dispatchUpwardJudgmentCost; /** * 上楼费免费楼层 */ - @ExcelProperty(value = "上楼费免费楼层", index = 7) + @ExcelProperty(value = "上楼费免费楼层", index = 8) private String dispatchStairsCarryingCharge; } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceFullVehicleExcel.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceFullVehicleExcel.java index 262959caf..f68ac2a9c 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceFullVehicleExcel.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceFullVehicleExcel.java @@ -40,21 +40,33 @@ public class BasicdataPriceFullVehicleExcel implements Serializable { private static final long serialVersionUID = 1L; - @ExcelProperty(value = "客户名称", index = 0) + @ExcelProperty(value = {"客户名称", "客户名称"}, index = 0) private String client; - @ExcelProperty(value = "品牌", index = 1) + @ExcelProperty(value = "客户编码", index = 1) + private String clientCode; + @ExcelProperty(value = {"品牌", "品牌"}, index = 2) private String brand; - @ExcelProperty(value = "发站", index = 2) - private String startName; - @ExcelProperty(value = "到站", index = 3) - private String endName; - @ExcelProperty(value = "发货单位", index = 4) + @ExcelProperty(value = {"发站", "省"}, index = 3) + private String startProvince; + @ExcelProperty(value = {"发站", "市"}, index = 4) + private String startCity; + @ExcelProperty(value = {"发站", "区"}, index = 5) + private String startArea; + @ExcelProperty(value = {"到站", "省"}, index = 6) + private String endProvince; + @ExcelProperty(value = {"到站", "市"}, index = 7) + private String endCity; + @ExcelProperty(value = {"到站", "区"}, index = 8) + private String endArea; + @ExcelProperty(value = {"发货单位", "发货单位"}, index = 9) private String sendOrg; - @ExcelProperty(value = "类型", index = 5) + @ExcelProperty(value = {"发货单位", "发货单位编码"}, index = 10) + private String sendOrgCode; + @ExcelProperty(value = {"类型", "类型"}, index = 11) private String type; - @ExcelProperty(value = "车型", index = 6) + @ExcelProperty(value = {"车型", "车型"}, index = 12) private String vehicleType; - @ExcelProperty(value = "整车计费(元/车)", index = 7) + @ExcelProperty(value = {"价格", "价格"}, index = 13) private String price; } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceGeneralExcel.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceGeneralExcel.java index 1cb171c38..6db988da5 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceGeneralExcel.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/price/BasicdataPriceGeneralExcel.java @@ -40,45 +40,33 @@ public class BasicdataPriceGeneralExcel implements Serializable { private static final long serialVersionUID = 1L; - /** - * 客户名称 - */ - @ExcelProperty(value = "客户名称", index = 0) + @ExcelProperty(value = {"客户名称", "客户名称"}, index = 0) private String client; - /** - * 品牌 - */ - @ExcelProperty(value = "品牌", index = 1) + @ExcelProperty(value = "客户编码", index = 1) + private String clientCode; + @ExcelProperty(value = {"品牌", "品牌"}, index = 2) private String brand; - /** - * 发站 - */ - @ExcelProperty(value = "发站", index = 2) - private String startName; - /** - * 到站 - */ - @ExcelProperty(value = "到站", index = 3) - private String endName; - /** - * 发货单位 - */ - @ExcelProperty(value = "发货单位", index = 4) + @ExcelProperty(value = {"发站", "省"}, index = 3) + private String startProvince; + @ExcelProperty(value = {"发站", "市"}, index = 4) + private String startCity; + @ExcelProperty(value = {"发站", "区"}, index = 5) + private String startArea; + @ExcelProperty(value = {"到站", "省"}, index = 6) + private String endProvince; + @ExcelProperty(value = {"到站", "市"}, index = 7) + private String endCity; + @ExcelProperty(value = {"到站", "区"}, index = 8) + private String endArea; + @ExcelProperty(value = {"发货单位", "发货单位"}, index = 9) private String sendOrg; - /** - * 类型 - */ - @ExcelProperty(value = "类型", index = 5) + @ExcelProperty(value = {"发货单位", "发货单位编码"}, index = 10) + private String sendOrgCode; + @ExcelProperty(value = {"类型", "类型"}, index = 11) private String type; - /** - * 最低计费值 - */ - @ExcelProperty(value = "最低计费值", index = 6) + @ExcelProperty(value = {"最低计费值", "最低计费值"}, index = 12) private String minCost; - /** - * 加算价格 - */ - @ExcelProperty(value = "加算价格", index = 7) + @ExcelProperty(value = {"加算价格", "加算价格"}, index = 13) private String addCost; } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataPriceMapper.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataPriceMapper.java index 3e792e99f..62aa4ec81 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataPriceMapper.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataPriceMapper.java @@ -20,12 +20,14 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.logpm.basicdata.entity.BasicdataPriceEntity; -import com.logpm.basicdata.excel.BasicdataPriceExcel; +import com.logpm.basicdata.excel.price.BasicdataPriceExcel; +import com.logpm.basicdata.vo.BasicdataPriceImportVO; import com.logpm.basicdata.vo.BasicdataPricePageVO; import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Param; import java.util.List; +import java.util.Set; /** * 基础价格表 Mapper 接口 @@ -45,14 +47,8 @@ public interface BasicdataPriceMapper extends BaseMapper { List selectBasicdataPricePage(IPage page, BasicdataPricePageVO basicdataPrice); - /** - * 获取导出数据 - * - * @param queryWrapper - * @return - */ - List exportBasicdataPrice(@Param("ew") Wrapper queryWrapper); - @Delete("delete from logpm_basicdata_price_route where price_id = #{id}") void removeRouteByPriceId(Long id); + + List findEntityByClientAndBrand(@Param("prices") List prices); } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataPriceMapper.xml b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataPriceMapper.xml index fd6f171f3..55bc1204b 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataPriceMapper.xml +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataPriceMapper.xml @@ -43,10 +43,20 @@ - - + select t.*,lbc.client_name,lbb.brand_name,lbc.client_code + from logpm_basicdata_price t + left join logpm_basicdata_client lbc on t.client_id = lbc.id + left join logpm_basicdata_brand lbb on t.brand_id = lbb.id + where t.is_deleted = 0 + + and + + + (lbc.client_code = #{item.clientCode} and lbb.brand_name = #{item.brand}) + + + diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java index 17e927962..42235b22f 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java @@ -21,10 +21,18 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; +import com.alibaba.excel.EasyExcel; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.logpm.basicdata.constant.BasicdataConstants; +import com.logpm.basicdata.entity.BasicdataBrandEntity; +import com.logpm.basicdata.entity.BasicdataCategoryEntity; +import com.logpm.basicdata.entity.BasicdataClientEntity; import com.logpm.basicdata.entity.BasicdataPriceCategoryBasicEntity; import com.logpm.basicdata.entity.BasicdataPriceCategoryDispatchEntity; import com.logpm.basicdata.entity.BasicdataPriceCategoryWarehouseEntity; @@ -48,6 +56,9 @@ import com.logpm.basicdata.excel.price.BasicdataPriceExcel; import com.logpm.basicdata.excel.price.BasicdataPriceFullVehicleExcel; import com.logpm.basicdata.excel.price.BasicdataPriceGeneralExcel; import com.logpm.basicdata.mapper.BasicdataPriceMapper; +import com.logpm.basicdata.service.IBasicdataBrandService; +import com.logpm.basicdata.service.IBasicdataCategoryService; +import com.logpm.basicdata.service.IBasicdataClientService; import com.logpm.basicdata.service.IBasicdataPriceCategoryBasicService; import com.logpm.basicdata.service.IBasicdataPriceCategoryDispatchService; import com.logpm.basicdata.service.IBasicdataPriceCategoryWarehouseService; @@ -56,9 +67,11 @@ import com.logpm.basicdata.service.IBasicdataPriceGeneralService; import com.logpm.basicdata.service.IBasicdataPriceRouteService; import com.logpm.basicdata.service.IBasicdataPriceService; import com.logpm.basicdata.service.IBasicdataPriceTemplateService; +import com.logpm.basicdata.util.EasyExcelUtil; import com.logpm.basicdata.vo.BasicdatPriceApiVO; import com.logpm.basicdata.vo.BasicdataPriceBasicUpdateVO; import com.logpm.basicdata.vo.BasicdataPriceFullVehicleVO; +import com.logpm.basicdata.vo.BasicdataPriceImportVO; import com.logpm.basicdata.vo.BasicdataPricePageVO; import com.logpm.basicdata.vo.PriceBasicVO; import com.logpm.basicdata.vo.PriceClientVO; @@ -76,10 +89,13 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.common.enums.BooleanZeroOneEnums; import org.springblade.common.model.IDict; -//import org.springblade.core.excel.util.ExcelUtil; -import org.springblade.core.excel.util.ExcelUtil; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.api.R; +import org.springblade.system.entity.DictBiz; +import org.springblade.system.feign.IDictBizClient; +import org.springblade.system.feign.ISysClient; +import org.springblade.system.vo.RegionAllVO; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; @@ -87,8 +103,10 @@ import org.springframework.web.multipart.MultipartFile; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; /** @@ -103,6 +121,9 @@ import java.util.stream.Collectors; public class BasicdataPriceServiceImpl extends BaseServiceImpl implements IBasicdataPriceService { private final IBasicdataPriceTemplateService templateService; + private final IBasicdataClientService clientService; + private final IBasicdataBrandService brandService; + private final IBasicdataCategoryService categoryService; private final IBasicdataPriceFullVehicleService fullVehicleService; private final IBasicdataPriceCategoryDispatchService categoryDispatchService; @@ -112,6 +133,9 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl selectBasicdataPricePage(IPage page, BasicdataPricePageVO basicdataPrice) { List basicdataPriceVOS = baseMapper.selectBasicdataPricePage(page, basicdataPrice); @@ -141,21 +165,26 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl 0) { throw new ServiceException("生效时间大于到期时间,请检查。"); } // 如果是切换模版,则删除所有本价格相关的数据 BasicdataPriceEntity entity = this.getById(vo.getId()); + BasicdataPriceEntity basicdataPriceEntity = new BasicdataPriceEntity(); if (ObjectUtil.isNotEmpty(entity)) { Long templateId = entity.getTemplateId(); if (!ObjectUtil.equal(templateId, vo.getTemplateId())) { // 删除数据 deleteByPriceId(vo.getId()); + basicdataPriceEntity.setDispatchStairsCarryingCharge(0); + basicdataPriceEntity.setDispatchUpwardJudgment(0d); + basicdataPriceEntity.setDispatchUpwardJudgmentCost(0d); log.info("价格体系:{} 切换模版删除数据", vo.getId()); } } - BasicdataPriceEntity basicdataPriceEntity = new BasicdataPriceEntity(); + basicdataPriceEntity.setId(vo.getId()); basicdataPriceEntity.setTemplateId(vo.getTemplateId()); basicdataPriceEntity.setEffectiveTime(vo.getEffectiveTime()); @@ -335,7 +364,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl priceExcels = ExcelUtil.read(file, 0, BasicdataPriceExcel.class); - List basicExcels = ExcelUtil.read(file, 1, BasicdataPriceCategoryBasicExcel.class); - List dispatchExcels = ExcelUtil.read(file, 2, BasicdataPriceCategoryDispatchExcel.class); - List warehouseExcels = ExcelUtil.read(file, 3, BasicdataPriceCategoryWarehouseExcel.class); - List generalExcels = ExcelUtil.read(file, 4, BasicdataPriceGeneralExcel.class); - List fullVehicleExcels = ExcelUtil.read(file, 5, BasicdataPriceFullVehicleExcel.class); + List priceExcels = EasyExcelUtil.readTrim(file, 0, BasicdataPriceExcel.class); // 校验数据 + String sheet1 = "客户信息"; + String sheet2 = "提货干线按品类计费"; + String sheet3 = "仓储按品类计费"; + String sheet4 = "配送按品类计费"; + String sheet5 = "最低计费"; + String sheet6 = "整车计费"; if (CollUtil.isNotEmpty(priceExcels)) { + // 模板名称为key + Map templateEntityMap = new HashMap<>(); + // 客户编码为key + Map clientEntityMap = new HashMap<>(); + // 品牌名称为key + Map brandEntityMap = new HashMap<>(); + // 客户编码 + 品牌名称为key + Map priceEntityMap = new HashMap<>(); + List basicExcels = EasyExcelUtil.readTrim(file, 1, 2, BasicdataPriceCategoryBasicExcel.class); + List generalExcels = EasyExcelUtil.readTrim(file, 4, 2, BasicdataPriceGeneralExcel.class); + List fullVehicleExcels = EasyExcelUtil.readTrim(file, 5, 2, BasicdataPriceFullVehicleExcel.class); + // 初始化导入校验数据 + initImportData(priceExcels, basicExcels, generalExcels, fullVehicleExcels, templateEntityMap, clientEntityMap, brandEntityMap, priceEntityMap); + // 校验数据 + checkPriceData(message, priceExcels, sheet1, templateEntityMap, clientEntityMap, brandEntityMap, priceEntityMap); + // 第一个sheet数据不合格直接返回 + if (StrUtil.isNotEmpty(message.toString())) { + return message.toString(); + } + // 品类名称为key + Map categoryEntityMap = new HashMap<>(); + // 省市区 + Map provinceMap = new HashMap<>(); + Map provinceCityMap = new HashMap<>(); + Map provinceCityAearMap = new HashMap<>(); + // 初始化行政区划 + initRegion(provinceMap, provinceCityMap, provinceCityAearMap); + List dispatchExcels = EasyExcelUtil.readTrim(file, 3, 2, BasicdataPriceCategoryDispatchExcel.class); + List warehouseExcels = EasyExcelUtil.readTrim(file, 2, 2, BasicdataPriceCategoryWarehouseExcel.class); + // 路径为key 客户编码&&&品牌&&&发货单位编码 || 客户编码&&&品牌&&&发货单位编码&&&发站省市 || 客户编码&&&品牌&&&发货单位编码&&&发站省市&&&发站省市区 + Map routeMap = new HashMap<>(); + initRouteMap(routeMap, basicExcels, generalExcels, fullVehicleExcels); + // 初始化品类 + initCategoryData(basicExcels, dispatchExcels, warehouseExcels, categoryEntityMap); + // 提货干线按品类计费 + checkBasicExcels(message, sheet2, clientEntityMap, priceEntityMap, basicExcels, categoryEntityMap, provinceMap, provinceCityMap, provinceCityAearMap); + // 仓储按品类 + checkWarehouseExcels(warehouseExcels, clientEntityMap, priceEntityMap, categoryEntityMap, message, sheet3); + // 配送按品类 + checkDispatchExcels(dispatchExcels, clientEntityMap, priceEntityMap, categoryEntityMap, message, sheet4); + // 一般计费 + checkGeneralExcels(generalExcels, clientEntityMap, priceEntityMap, provinceMap, provinceCityMap, provinceCityAearMap, message, sheet5); + // 封装整车车型 车型名称为key + Map vehicleTypeMap = new HashMap<>(); + initVehicleTypeMap(vehicleTypeMap); + //整车 + checkFullExcel(fullVehicleExcels, clientEntityMap, priceEntityMap, provinceMap, provinceCityMap, provinceCityAearMap, vehicleTypeMap, message, sheet6); + if (StrUtil.isNotEmpty(message.toString())) { + return message.toString(); + } + // 保存数据 + // 先处理 + saveExcel(priceExcels, basicExcels, warehouseExcels, dispatchExcels, generalExcels, fullVehicleExcels, + templateEntityMap, clientEntityMap, brandEntityMap, priceEntityMap, categoryEntityMap, provinceMap, + provinceCityMap, provinceCityAearMap, vehicleTypeMap, routeMap); + } else { + message.append("请维护").append(sheet1).append("中的基础数据"); + } + } catch (Exception e) { + log.error("价格导入失败", e); + throw new ServiceException("导入失败"); + } + return message.toString(); + } + + private void initRouteMap(Map routeMap, List basicExcels, List generalExcels, List fullVehicleExcels) { + if (CollUtil.isNotEmpty(basicExcels)) { + for (BasicdataPriceCategoryBasicExcel basicExcel : basicExcels) { + // 发站省,发站市,到站省,到站市,发货单位不为空则说明是一条路径 + if (!ObjectUtil.hasEmpty(basicExcel.getClientCode(), basicExcel.getBrand(), basicExcel.getSendOrgCode())) { + String key = buildRoutKey(basicExcel.getClientCode(), basicExcel.getBrand(), basicExcel.getStartProvince(), + basicExcel.getStartCity(), basicExcel.getStartArea(), basicExcel.getEndProvince(), basicExcel.getEndCity(), + basicExcel.getEndArea(), basicExcel.getSendOrgCode()); + if (!routeMap.containsKey(key)) { + routeMap.put(key, basicExcel.getClientCode() + "&&&" + basicExcel.getBrand() + "&&&" + basicExcel.getType()); + } + } + + } + } + if (CollUtil.isNotEmpty(generalExcels)) { + for (BasicdataPriceGeneralExcel generalExcel : generalExcels) { + if (!ObjectUtil.hasEmpty(generalExcel.getStartProvince(), generalExcel.getStartCity(), generalExcel.getEndProvince(), + generalExcel.getEndCity(), generalExcel.getSendOrgCode())) { + String key = buildRoutKey(generalExcel.getClientCode(), generalExcel.getBrand(), generalExcel.getStartProvince(), generalExcel.getStartCity(), generalExcel.getStartArea(), + generalExcel.getEndProvince(), generalExcel.getEndCity(), generalExcel.getEndArea(), generalExcel.getSendOrgCode()); + if (!routeMap.containsKey(key)) { + routeMap.put(key, generalExcel.getClientCode() + "&&&" + generalExcel.getBrand() + "&&&" + generalExcel.getType()); + } + } + } + } + if (CollUtil.isNotEmpty(fullVehicleExcels)) { + for (BasicdataPriceFullVehicleExcel fullVehicleExcel : fullVehicleExcels) { + if (!ObjectUtil.hasEmpty(fullVehicleExcel.getStartProvince(), fullVehicleExcel.getStartCity(), + fullVehicleExcel.getEndProvince(), fullVehicleExcel.getEndCity(), fullVehicleExcel.getSendOrgCode())) { + String key = buildRoutKey(fullVehicleExcel.getClientCode(), fullVehicleExcel.getBrand(), fullVehicleExcel.getStartProvince(), fullVehicleExcel.getStartCity(), fullVehicleExcel.getStartArea(), + fullVehicleExcel.getEndProvince(), fullVehicleExcel.getEndCity(), fullVehicleExcel.getEndArea(), fullVehicleExcel.getSendOrgCode()); + if (!routeMap.containsKey(key)) { + routeMap.put(key, fullVehicleExcel.getClientCode() + "&&&" + fullVehicleExcel.getBrand() + "&&&" + fullVehicleExcel.getType()); + } + } + } + } + } + private String buildRoutKey(String clientCode, String brand, String startProvince, String startCity, String startArea, String endProvince, String endCity, String endArea, String sendOrg) { + StringBuilder key = new StringBuilder(); + String split = "&&&"; + key.append(clientCode).append(split).append(brand); + key.append(split).append(sendOrg); + if (!ObjectUtil.hasEmpty(startProvince, startCity)) { + key.append(split).append(startProvince).append(split).append(startCity); + if (StrUtil.isNotEmpty(startArea)) { + key.append(split).append(startArea); } - // 保存数据 + if (!ObjectUtil.hasEmpty(endProvince, endCity)) { + key.append(split).append(endProvince).append(split).append(endCity); + if (StrUtil.isNotEmpty(endArea)) { + key.append(split).append(endArea); + } + } + } + return key.toString(); - } catch (Exception e) { + } + + private void saveExcel(List priceExcels, List basicExcels, + List warehouseExcels, + List dispatchExcels, + List generalExcels, List fullVehicleExcels, + Map templateEntityMap, + Map clientEntityMap, Map brandEntityMap, + Map priceEntityMap, Map categoryEntityMap, + Map provinceMap, Map provinceCityMap, + Map provinceCityAearMap, Map vehicleTypeMap, + Map routeMap) { + if (CollUtil.isNotEmpty(priceExcels)) { + List priceEntities = new ArrayList<>(); + List basicEntities = new ArrayList<>(); + List warehouseEntities = new ArrayList<>(); + List dispatchEntities = new ArrayList<>(); + List fullVehicleEntities = new ArrayList<>(); + List generalEntities = new ArrayList<>(); + List routeEntities = new ArrayList<>(); + Map templateMap = new HashMap<>(); + // 保存基本信息 + buildPriceEntitiesExcel(priceExcels, templateEntityMap, priceEntityMap, priceEntities, templateMap); + if (CollUtil.isNotEmpty(priceEntities)) { + this.updateBatchById(priceEntities); + } + // 封装保存好的路径 + Map routeEntityMap = new HashMap<>(); + // 保存路径 + buildSaveRouteEntitiesExcel(clientEntityMap, priceEntityMap, provinceMap, provinceCityMap, provinceCityAearMap, routeMap, routeEntities, routeEntityMap); + if (CollUtil.isNotEmpty(routeEntities)) { + basicdataPriceRouteService.saveBatch(routeEntities); + } + // 处理 提货干线按品类计费 + buildSaveBasicEntitiesExcel(basicExcels, priceEntityMap, categoryEntityMap, basicEntities, templateMap, routeEntityMap); + if (CollUtil.isNotEmpty(basicEntities)) { + categoryBasicService.saveBatch(basicEntities); + } + // 处理仓储费 + buildSaveWarehouseEntitiesExcel(warehouseExcels, priceEntityMap, categoryEntityMap, warehouseEntities); + if (CollUtil.isNotEmpty(warehouseEntities)) { + categoryWarehouseService.saveBatch(warehouseEntities); + } + // 处理配送费 + buildSaveDispatchEntitiesExcel(dispatchExcels, priceEntityMap, categoryEntityMap, dispatchEntities); + if (CollUtil.isNotEmpty(dispatchEntities)) { + categoryDispatchService.saveBatch(dispatchEntities); + } + // 处理整车费用 + buildSaveFullVehicleEntitiesExcel(fullVehicleExcels, priceEntityMap, categoryEntityMap, fullVehicleEntities, templateMap, routeEntityMap, vehicleTypeMap); + if (CollUtil.isNotEmpty(fullVehicleEntities)) { + fullVehicleService.saveBatch(fullVehicleEntities); + } + // 处理一般费用 + buildSaveGeneralEntitiesExcel(generalExcels, priceEntityMap, categoryEntityMap, generalEntities, templateMap, routeEntityMap); + if (CollUtil.isNotEmpty(generalEntities)) { + generalService.saveBatch(generalEntities); + } + } + } + + private void buildSaveWarehouseEntitiesExcel(List warehouseExcels, Map priceEntityMap, Map categoryEntityMap, List warehouseEntities) { + if (CollUtil.isNotEmpty(warehouseExcels)) { + for (BasicdataPriceCategoryWarehouseExcel warehouseExcel : warehouseExcels) { + BasicdataPriceCategoryWarehouseEntity warehouseEntity = new BasicdataPriceCategoryWarehouseEntity(); + BasicdataPriceEntity priceEntity = priceEntityMap.get(warehouseExcel.getClientCode() + warehouseExcel.getBrand()); + if (ObjectUtil.isNotEmpty(priceEntity)) { + warehouseEntity.setPriceId(priceEntity.getId()); + warehouseEntity.setBoId(priceEntity.getId()); + } + if (StrUtil.isNotEmpty(warehouseExcel.getCategory())) { + BasicdataCategoryEntity basicdataCategoryEntity = categoryEntityMap.get(warehouseExcel.getCategory()); + if (ObjectUtil.isNotEmpty(basicdataCategoryEntity)) { + warehouseEntity.setCategoryId(basicdataCategoryEntity.getId()); + } + } + if (StrUtil.isNotEmpty(warehouseExcel.getType())) { + warehouseEntity.setCostType(IDict.getCodeByText(CostTypeEnums.class, warehouseExcel.getType())); + } + if (StrUtil.isNotEmpty(warehouseExcel.getCostType())) { + warehouseEntity.setType(IDict.getCodeByText(WarehousePricingTypeEnums.class, warehouseExcel.getCostType())); + } + warehouseEntity.setServiceType(1); + if (StrUtil.isNotEmpty(warehouseExcel.getWithinThirtyPrice())) { + warehouseEntity.setWithinThirtyPrice(Convert.toDouble(warehouseExcel.getWithinThirtyPrice())); + } + if (StrUtil.isNotEmpty(warehouseExcel.getBetweenThirtySixtyPrice())) { + warehouseEntity.setBetweenThirtySixtyPrice(Convert.toDouble(warehouseExcel.getBetweenThirtySixtyPrice())); + } + if (StrUtil.isNotEmpty(warehouseExcel.getBeyondSixtyPrice())) { + warehouseEntity.setBeyondSixtyPrice(Convert.toDouble(warehouseExcel.getBeyondSixtyPrice())); + } + if (StrUtil.isNotEmpty(warehouseExcel.getMaximumPrice())) { + warehouseEntity.setMaximumPrice(Convert.toDouble(warehouseExcel.getMaximumPrice())); + } + if (StrUtil.isNotEmpty(warehouseExcel.getOperatePrice())) { + warehouseEntity.setOperatePrice(Convert.toDouble(warehouseExcel.getOperatePrice())); + } + if (StrUtil.isNotEmpty(warehouseExcel.getWarehouseManagementPrice())) { + warehouseEntity.setWarehouseManagementPrice(Convert.toDouble(warehouseExcel.getWarehouseManagementPrice())); + } + if (StrUtil.isNotEmpty(warehouseExcel.getWarehouseSortPrice())) { + warehouseEntity.setWarehouseSortPrice(Convert.toDouble(warehouseExcel.getWarehouseSortPrice())); + } + warehouseEntities.add(warehouseEntity); + } + } + } + + private void buildSaveDispatchEntitiesExcel(List warehouseExcels, + Map priceEntityMap, + Map categoryEntityMap, + List entities) { + if (CollUtil.isNotEmpty(warehouseExcels)) { + for (BasicdataPriceCategoryDispatchExcel excel : warehouseExcels) { + BasicdataPriceCategoryDispatchEntity entity = new BasicdataPriceCategoryDispatchEntity(); + BasicdataPriceEntity priceEntity = priceEntityMap.get(excel.getClientCode() + excel.getBrand()); + if (ObjectUtil.isNotEmpty(priceEntity)) { + entity.setPriceId(priceEntity.getId()); + entity.setBoId(priceEntity.getId()); + } + if (StrUtil.isNotEmpty(excel.getCategory())) { + BasicdataCategoryEntity basicdataCategoryEntity = categoryEntityMap.get(excel.getCategory()); + if (ObjectUtil.isNotEmpty(basicdataCategoryEntity)) { + entity.setCategoryId(basicdataCategoryEntity.getId()); + } + } + if (StrUtil.isNotEmpty(excel.getType())) { + entity.setCostType(IDict.getCodeByText(CostTypeEnums.class, excel.getType())); + } + if (StrUtil.isNotEmpty(excel.getCostType())) { + entity.setType(IDict.getCodeByText(WarehousePricingTypeEnums.class, excel.getCostType())); + } + entity.setServiceType(1); + if (StrUtil.isNotEmpty(excel.getPrice())) { + entity.setPrice(Convert.toDouble(excel.getPrice())); + } + if (StrUtil.isNotEmpty(excel.getLeaveBehindPrice())) { + entity.setLeaveBehindPrice(Convert.toDouble(excel.getLeaveBehindPrice())); + } + if (StrUtil.isNotEmpty(excel.getSortPrice())) { + entity.setSortPrice(Convert.toDouble(excel.getSortPrice())); + } + if (StrUtil.isNotEmpty(excel.getHandlingPrice())) { + entity.setHandlingPrice(Convert.toDouble(excel.getHandlingPrice())); + } + if (StrUtil.isNotEmpty(excel.getRelocationPrice())) { + entity.setRelocationPrice(Convert.toDouble(excel.getRelocationPrice())); + } + if (StrUtil.isNotEmpty(excel.getUpstairsDeliveryPrice())) { + entity.setUpstairsDeliveryPrice(Convert.toDouble(excel.getUpstairsDeliveryPrice())); + } + entities.add(entity); + } + } + } + + private void buildPriceEntitiesExcel(List priceExcels, Map templateEntityMap, Map priceEntityMap, List priceEntities, Map templateMap) { + for (BasicdataPriceExcel priceExcel : priceExcels) { + BasicdataPriceEntity priceEntity = priceEntityMap.get(priceExcel.getClientCode() + priceExcel.getBrand()); + templateMap.put(priceExcel.getClientCode() + priceExcel.getBrand(), templateEntityMap.get(priceExcel.getTemplateName())); + if (ObjectUtil.isNotEmpty(priceEntity)) { + // 删除数据 + deleteByPriceId(priceEntity.getId()); + priceEntity.setMaintenanceStatus(2); + // 设置值 + setPriceExcel(templateEntityMap, priceExcel, priceEntity); + priceEntities.add(priceEntity); + } + } + } + + private void buildSaveRouteEntitiesExcel(Map clientEntityMap, Map priceEntityMap, Map provinceMap, Map provinceCityMap, Map provinceCityAearMap, Map routeMap, List routeEntities, Map routeEntityMap) { + if (CollUtil.isNotEmpty(routeMap)) { + for (Map.Entry entry : routeMap.entrySet()) { + String value = entry.getValue(); + // 客户编码&&&品牌&&&发货单位编码 || 客户编码&&&品牌&&&发货单位编码&&&发站省市 || 客户编码&&&品牌&&&发货单位编码&&&发站省市&&&发站省市区 + String key = entry.getKey(); + if (StrUtil.isNotEmpty(value)) { + List split = StrUtil.split(value, "&&&"); + if (split.size() == 3) { + String s = split.get(0) + split.get(1); + String s1 = split.get(2); + if (StrUtil.isNotEmpty(s)) { + BasicdataPriceEntity priceEntity = priceEntityMap.get(s); + BasicdataPriceRouteEntity routeEntity = new BasicdataPriceRouteEntity(); + routeEntity.setPriceId(priceEntity.getId()); + routeEntity.setServiceType(IDict.getCodeByText(ServiceTypeEnums.class, s1)); + if (StrUtil.isNotEmpty(key)) { + List regions = StrUtil.split(key, "&&&"); + if (CollUtil.isNotEmpty(regions)) { + setSendOrgExcel(clientEntityMap, routeEntity, regions.get(2)); + // 发货单位-省市 5 + if (regions.size() >= 5) { + setStarProvinceExcel(provinceMap, routeEntity, regions.get(3)); + setStartCityExcel(provinceCityMap, routeEntity, regions.get(3), regions.get(4)); + } + // 发货单位-省市区 6 + if (ObjectUtil.equal(regions.size(), 6)) { + setStartCountExcel(provinceCityAearMap, routeEntity, regions.get(3), regions.get(4), regions.get(5)); + } + // 发货单位-省市-省市 7 + if (ObjectUtil.equal(regions.size(), 7)) { + setEndProvinceExcel(provinceMap, routeEntity, regions.get(5)); + setEndCityExcel(provinceCityMap, routeEntity, regions.get(5) + regions.get(6)); + } + // 发货单位-省市区-省市区 9 + if (ObjectUtil.equal(regions.size(), 9)) { + setStartCountExcel(provinceCityAearMap, routeEntity, regions.get(3), regions.get(4), regions.get(5)); + setEndProvinceExcel(provinceMap, routeEntity, regions.get(6)); + setEndCityExcel(provinceCityMap, routeEntity, regions.get(6) + regions.get(7)); + setEndCountExcel(provinceCityAearMap, routeEntity, regions.get(6), regions.get(7), regions.get(8)); + } + // 发货单位-省市区-省市 8 + if (ObjectUtil.equal(regions.size(), 8)) { + // 如果 s3s4s5 是省市区 则说明 s5 是区 + if (provinceCityAearMap.containsKey(regions.get(3) + regions.get(4) + regions.get(5))) { + setStartCountExcel(provinceCityAearMap, routeEntity, regions.get(3), regions.get(4), regions.get(5)); + setEndProvinceExcel(provinceMap, routeEntity, regions.get(6)); + setEndCityExcel(provinceCityMap, routeEntity, regions.get(6) + regions.get(7)); + } else { + // 发货单位-省市-省市区 8 + setEndProvinceExcel(provinceMap, routeEntity, regions.get(5)); + setEndCityExcel(provinceCityMap, routeEntity, regions.get(5) + regions.get(6)); + setEndCountExcel(provinceCityAearMap, routeEntity, regions.get(5), regions.get(6), regions.get(7)); + } + } + } + } + routeEntityMap.put(key + "&&&" + s1, routeEntity); + routeEntities.add(routeEntity); + } + } + } + } + } + } + + private void buildSaveFullVehicleEntitiesExcel(List excels, + Map priceEntityMap, + Map categoryEntityMap, + List entities, + Map templateMap, + Map routeEntityMap, + Map vehicleTypeMap) { + if (CollUtil.isNotEmpty(excels)) { + for (BasicdataPriceFullVehicleExcel excel : excels) { + BasicdataPriceEntity priceEntity = priceEntityMap.get(excel.getClientCode() + excel.getBrand()); + if (ObjectUtil.isEmpty(priceEntity)) { + log.error("导入价格体系在系统中不存在:{}_{}", excel.getClientCode(), excel.getBrand()); + continue; + } + BasicdataPriceTemplateEntity templateEntity = templateMap.get(excel.getClientCode() + excel.getBrand()); + Integer unifyAreaBill = null; + String type = excel.getType(); + BasicdataPriceFullVehicleEntity entity = new BasicdataPriceFullVehicleEntity(); + // 是否按区域计费 + if (ObjectUtil.equal(type, ServiceTypeEnums.PICK_UP.getText())) { + unifyAreaBill = templateEntity.getPickupIsUnifyAreaBill(); + } else if (ObjectUtil.equal(type, ServiceTypeEnums.TRUNK_LINE.getText())) { + // 服务类型 + unifyAreaBill = templateEntity.getTrunklineIsUnifyAreaBill(); + } + // 按区域计费 + if (ObjectUtil.isNotEmpty(unifyAreaBill) && ObjectUtil.equal(unifyAreaBill, BooleanZeroOneEnums.NO.getCode())) { + if (!ObjectUtil.hasEmpty(excel.getClientCode(), excel.getBrand(), excel.getSendOrgCode())) { + String key = buildRoutKey(excel.getClientCode(), excel.getBrand(), excel.getStartProvince(), excel.getStartCity(), excel.getStartArea(), excel.getEndProvince(), excel.getEndCity(), excel.getEndArea(), excel.getSendOrgCode()); + BasicdataPriceRouteEntity routeEntity = routeEntityMap.get(key + "&&&" + excel.getType()); + if (ObjectUtil.isNotEmpty(routeEntity)) { + entity.setBoId(routeEntity.getId()); + } + } else { + // TODO 这个放到校验的时候处理 + entity.setBoId(priceEntity.getId()); + log.error("价格体系导入FullVehicle数据无法处理,模板配置的按区域计费,数据不满足路径条件:{}", JSONUtil.toJsonStr(excel)); + continue; + } + } else { + // 统一计费 + entity.setBoId(priceEntity.getId()); + } + entity.setPriceId(priceEntity.getId()); + // 类型 + if (ObjectUtil.isNotEmpty(excel.getType())) { + entity.setType(IDict.getCodeByText(FullVehicleTypeEnums.class, excel.getType())); + } + // 车型 + if (ObjectUtil.isNotEmpty(excel.getVehicleType())) { + String vehicleType = vehicleTypeMap.get(excel.getVehicleType()); + if (StrUtil.isNotEmpty(vehicleType)) { + entity.setVehicleType(Convert.toInt(vehicleType)); + } + } + // 价格 + if (StrUtil.isNotEmpty(excel.getPrice())) { + entity.setPrice(Convert.toDouble(excel.getPrice())); + } + entities.add(entity); + } + } + } + + private void buildSaveGeneralEntitiesExcel(List excels, Map priceEntityMap, Map categoryEntityMap, List entities, Map templateMap, Map routeEntityMap) { + if (CollUtil.isNotEmpty(excels)) { + for (BasicdataPriceGeneralExcel basicExcel : excels) { + BasicdataPriceEntity priceEntity = priceEntityMap.get(basicExcel.getClientCode() + basicExcel.getBrand()); + if (ObjectUtil.isEmpty(priceEntity)) { + log.error("导入价格体系在系统中不存在"); + continue; + } + BasicdataPriceTemplateEntity templateEntity = templateMap.get(basicExcel.getClientCode() + basicExcel.getBrand()); + + Integer unifyAreaBill = null; + String type = basicExcel.getType(); + BasicdataPriceGeneralEntity basicEntity = new BasicdataPriceGeneralEntity(); + // 是否按区域计费 + if (ObjectUtil.equal(type, ServiceTypeEnums.PICK_UP.getText())) { + unifyAreaBill = templateEntity.getPickupIsUnifyAreaBill(); + } else if (ObjectUtil.equal(type, ServiceTypeEnums.TRUNK_LINE.getText())) { + unifyAreaBill = templateEntity.getTrunklineIsUnifyAreaBill(); + } + // 服务类型 + if (StrUtil.isNotEmpty(type)) { + basicEntity.setServiceType(IDict.getCodeByText(GeneralServiceTypeEnums.class, type)); + } + // 按区域计费 + if (ObjectUtil.isNotEmpty(unifyAreaBill) && ObjectUtil.equal(unifyAreaBill, BooleanZeroOneEnums.NO.getCode())) { + if (!ObjectUtil.hasEmpty(basicExcel.getClientCode(), basicExcel.getBrand(), basicExcel.getSendOrgCode())) { + String key = buildRoutKey(basicExcel.getClientCode(), basicExcel.getBrand(), basicExcel.getStartProvince(), basicExcel.getStartCity(), basicExcel.getStartArea(), basicExcel.getEndProvince(), basicExcel.getEndCity(), basicExcel.getEndArea(), basicExcel.getSendOrgCode()); + BasicdataPriceRouteEntity routeEntity = routeEntityMap.get(key + "&&&" + basicExcel.getType()); + if (ObjectUtil.isNotEmpty(routeEntity)) { + basicEntity.setBoId(routeEntity.getId()); + } + } else { + basicEntity.setBoId(priceEntity.getId()); + // TODO 这个放到校验的时候处理 + log.error("价格体系导入General数据无法处理,模板配置的按区域计费,数据不满足路径条件:{}", JSONUtil.toJsonStr(basicExcel)); + continue; + } + } else { + // 统一计费 + basicEntity.setBoId(priceEntity.getId()); + } + basicEntity.setPriceId(priceEntity.getId()); + // 最低计费 + if (StrUtil.isNotEmpty(basicExcel.getMinCost())) { + basicEntity.setMinCost(Convert.toDouble(basicExcel.getMinCost())); + } + // 加算价格 + if (StrUtil.isNotEmpty(basicExcel.getAddCost())) { + basicEntity.setAdditionalCost(Convert.toDouble(basicExcel.getAddCost())); + } + entities.add(basicEntity); + } + } + } + + private void buildSaveBasicEntitiesExcel(List basicExcels, Map priceEntityMap, Map categoryEntityMap, List basicEntities, Map templateMap, Map routeEntityMap) { + if (CollUtil.isNotEmpty(basicExcels)) { + for (BasicdataPriceCategoryBasicExcel basicExcel : basicExcels) { + BasicdataPriceEntity priceEntity = priceEntityMap.get(basicExcel.getClientCode() + basicExcel.getBrand()); + if (ObjectUtil.isEmpty(priceEntity)) { + log.error("导入价格体系在系统中不存在"); + continue; + } + BasicdataPriceTemplateEntity templateEntity = templateMap.get(basicExcel.getClientCode() + basicExcel.getBrand()); + + Integer unifyAreaBill = null; + String type = basicExcel.getType(); + BasicdataPriceCategoryBasicEntity basicEntity = new BasicdataPriceCategoryBasicEntity(); + // 是否按区域计费 + if (ObjectUtil.equal(type, ServiceTypeEnums.PICK_UP.getText())) { + // 服务类型 + basicEntity.setServiceType(ServiceTypeEnums.PICK_UP.getCode()); + unifyAreaBill = templateEntity.getPickupIsUnifyAreaBill(); + } else { + // 服务类型 + basicEntity.setServiceType(ServiceTypeEnums.TRUNK_LINE.getCode()); + unifyAreaBill = templateEntity.getTrunklineIsUnifyAreaBill(); + } + // 按区域计费 + if (ObjectUtil.isNotEmpty(unifyAreaBill) && ObjectUtil.equal(unifyAreaBill, BooleanZeroOneEnums.NO.getCode())) { + if (!ObjectUtil.hasEmpty(basicExcel.getClientCode(), basicExcel.getBrand(), basicExcel.getSendOrgCode())) { + String key = buildRoutKey(basicExcel.getClientCode(), basicExcel.getBrand(), basicExcel.getStartProvince(), + basicExcel.getStartCity(), basicExcel.getStartArea(), basicExcel.getEndProvince(), + basicExcel.getEndCity(), basicExcel.getEndArea(), basicExcel.getSendOrgCode()); + BasicdataPriceRouteEntity routeEntity = routeEntityMap.get(key + "&&&" + basicExcel.getType()); + if (ObjectUtil.isNotEmpty(routeEntity)) { + basicEntity.setBoId(routeEntity.getId()); + } + } else { + // TODO 这个放到校验的时候处理 + basicEntity.setBoId(priceEntity.getId()); + log.error("价格体系导入CategoryBasic数据无法处理,模板配置的按区域计费,数据不满足路径条件:{}", JSONUtil.toJsonStr(basicExcel)); + continue; + } + } else { + // 统一计费 + basicEntity.setBoId(priceEntity.getId()); + } + // 计费类型 + if (StrUtil.isNotEmpty(basicExcel.getCostType())) { + basicEntity.setType(IDict.getCodeByText(PickupPricingTypeEnums.class, basicExcel.getCostType())); + } + basicEntity.setPriceId(priceEntity.getId()); + // 品类 + if (StrUtil.isNotEmpty(basicExcel.getCategory())) { + if (ObjectUtil.isNotEmpty(categoryEntityMap.get(basicExcel.getCategory()))) { + basicEntity.setCategoryId(categoryEntityMap.get(basicExcel.getCategory()).getId()); + } + } + // 价格 + if (StrUtil.isNotEmpty(basicExcel.getPrice())) { + basicEntity.setPrice(Convert.toDouble(basicExcel.getPrice())); + } + basicEntities.add(basicEntity); + } + } + } + + private void setStarProvinceExcel(Map provinceMap, BasicdataPriceRouteEntity routeEntity, String province) { + if (StrUtil.isNotEmpty(provinceMap.get(province))) { + routeEntity.setStartProvinceId(Convert.toLong(provinceMap.get(province))); + } + } + + private void setStartCityExcel(Map provinceCityMap, BasicdataPriceRouteEntity routeEntity, String province, String city) { + if (StrUtil.isNotEmpty(provinceCityMap.get(province + city))) { + routeEntity.setStartCityId(Convert.toLong(provinceCityMap.get(province + city))); + } + } + + private void setStartCountExcel(Map provinceCityAearMap, BasicdataPriceRouteEntity routeEntity, String province, String city, String s2) { + if (StrUtil.isNotEmpty(provinceCityAearMap.get(province + city + s2))) { + routeEntity.setStartCountyId(Convert.toLong(provinceCityAearMap.get(province + city + s2))); + } + } + + private void setEndCountExcel(Map provinceCityAearMap, BasicdataPriceRouteEntity routeEntity, String province, String city, String s2) { + if (StrUtil.isNotEmpty(provinceCityAearMap.get(province + city + s2))) { + routeEntity.setEndCountyId(Convert.toLong(provinceCityAearMap.get(province + city + s2))); + } + } + + private void setSendOrgExcel(Map clientEntityMap, BasicdataPriceRouteEntity routeEntity, String s2) { + if (ObjectUtil.isNotEmpty(clientEntityMap.get(s2))) { + routeEntity.setSendOrgId(clientEntityMap.get(s2).getId()); + } + } + + private void setEndCityExcel(Map provinceCityMap, BasicdataPriceRouteEntity routeEntity, String s3) { + if (StrUtil.isNotEmpty(provinceCityMap.get(s3))) { + routeEntity.setEndCityId(Convert.toLong(provinceCityMap.get(s3))); + } + } + + private void setEndProvinceExcel(Map provinceMap, BasicdataPriceRouteEntity routeEntity, String s2) { + if (StrUtil.isNotEmpty(provinceMap.get(s2))) { + routeEntity.setEndProvinceId(Convert.toLong(provinceMap.get(s2))); + } + } + + private void setPriceExcel(Map templateEntityMap, BasicdataPriceExcel priceExcel, BasicdataPriceEntity priceEntity) { + priceEntity.setEffectiveTime(DateUtil.parseDate(priceExcel.getEffectiveTime())); + priceEntity.setExpiryTime(DateUtil.parseDate(priceExcel.getExpiryTime())); + priceEntity.setTemplateId(templateEntityMap.get(priceExcel.getTemplateName()).getId()); + if (StrUtil.isNotEmpty(priceExcel.getDispatchUpwardJudgment())) { + priceEntity.setDispatchUpwardJudgment(Convert.toDouble(priceExcel.getDispatchUpwardJudgment())); + } else { + priceEntity.setDispatchUpwardJudgment(0d); + } + if (StrUtil.isNotEmpty(priceExcel.getDispatchUpwardJudgmentCost())) { + priceEntity.setDispatchUpwardJudgmentCost(Convert.toDouble(priceExcel.getDispatchUpwardJudgmentCost())); + } else { + priceEntity.setDispatchUpwardJudgmentCost(0d); + } + if (StrUtil.isNotEmpty(priceExcel.getDispatchStairsCarryingCharge())) { + priceEntity.setDispatchStairsCarryingCharge(Convert.toInt(priceExcel.getDispatchStairsCarryingCharge())); + } else { + priceEntity.setDispatchStairsCarryingCharge(0); + } + } + + private void initVehicleTypeMap(Map vehicleTypeMap) { + R> r = dictBizClient.getList(BasicdataConstants.Price.VEHICLE_TYPE); + if (r.isSuccess()) { + List dictBizList = r.getData(); + if (CollUtil.isNotEmpty(dictBizList)) { + for (DictBiz dictBiz : dictBizList) { + vehicleTypeMap.put(dictBiz.getDictValue(), dictBiz.getDictKey()); + } + } + } + } + + private void checkFullExcel(List fullVehicleExcels, Map clientEntityMap, Map priceEntityMap, + Map provinceMap, Map provinceCityMap, + Map provinceCityAearMap, Map vehicleTypeMap, + StringBuilder message, String sheetName) { + if (CollUtil.isNotEmpty(fullVehicleExcels)) { + for (int i = 0; i < fullVehicleExcels.size(); i++) { + BasicdataPriceFullVehicleExcel excel = fullVehicleExcels.get(i); + StringBuilder rowMessage = new StringBuilder(); + int rowNum = i + 3; + String firstMessage = sheetName + "-第" + rowNum + "行:"; + // 校验客户和品牌 + checkClientAndBrand(priceEntityMap, rowMessage, excel.getClientCode(), excel.getBrand()); + // 校验发站 + checkReign(provinceMap, provinceCityMap, provinceCityAearMap, rowMessage, excel.getStartProvince(), excel.getStartCity(), excel.getStartArea(), "发站"); + // 校验到站 + checkReign(provinceMap, provinceCityMap, provinceCityAearMap, rowMessage, excel.getEndProvince(), excel.getEndCity(), excel.getEndArea(), "到站"); + // 发货单位 + checkSendOrgExcel(clientEntityMap, rowMessage, excel.getSendOrgCode()); + // 校验一般费用类型 + checkEnumsExcelNotEmpty(rowMessage, excel.getType(), "类型", FullVehicleTypeEnums.class); + // 校验费用 + checkPriceNotEmpty(rowMessage, "价格", excel.getPrice()); + // 校验车型 + if (StrUtil.isNotEmpty(excel.getVehicleType())) { + if (!vehicleTypeMap.containsKey(excel.getVehicleType())) { + rowMessage.append("车型[").append(excel.getVehicleType()).append("]不存在;"); + } + } else { + rowMessage.append("车型不能为空;"); + } + buildErrorMessageExcel(message, rowMessage, firstMessage); + } + } + } + + private void checkGeneralExcels(List generalExcels, Map clientEntityMap, Map priceEntityMap, Map provinceMap, Map provinceCityMap, Map provinceCityAearMap, StringBuilder message, String sheet5) { + if (CollUtil.isNotEmpty(generalExcels)) { + for (int i = 0; i < generalExcels.size(); i++) { + BasicdataPriceGeneralExcel excel = generalExcels.get(i); + StringBuilder rowMessage = new StringBuilder(); + int rowNum = i + 3; + String firstMessage = sheet5 + "-第" + rowNum + "行:"; + // 校验客户和品牌 + checkClientAndBrand(priceEntityMap, rowMessage, excel.getClientCode(), excel.getBrand()); + // 校验发站 + checkReign(provinceMap, provinceCityMap, provinceCityAearMap, rowMessage, excel.getStartProvince(), excel.getStartCity(), excel.getStartArea(), "发站"); + // 校验到站 + checkReign(provinceMap, provinceCityMap, provinceCityAearMap, rowMessage, excel.getEndProvince(), excel.getEndCity(), excel.getEndArea(), "到站"); + // 发货单位 + checkSendOrgExcel(clientEntityMap, rowMessage, excel.getSendOrgCode()); + // 校验一般费用类型 + checkEnumsExcelNotEmpty(rowMessage, excel.getType(), "类型", GeneralServiceTypeEnums.class); + // 校验费用 + checkPrice(rowMessage, "加算价格", excel.getAddCost()); + checkPrice(rowMessage, "最低计费值", excel.getMinCost()); + buildErrorMessageExcel(message, rowMessage, firstMessage); + } + } + } + + private void checkDispatchExcels(List excels, Map clientEntityMap, Map priceEntityMap, Map categoryEntityMap, StringBuilder message, String sheetName) { + if (CollUtil.isNotEmpty(excels)) { + // 校验sheet2的数据 + for (int i = 0; i < excels.size(); i++) { + BasicdataPriceCategoryDispatchExcel excel = excels.get(i); + StringBuilder rowMessage = new StringBuilder(); + int rowNum = i + 3; + String firstMessage = sheetName + "-第" + rowNum + "行:"; + // 校验客户和品牌 + checkClientAndBrand(priceEntityMap, rowMessage, excel.getClientCode(), excel.getBrand()); + // 校验计费类型 + checkEnumsExcelNotEmpty(rowMessage, excel.getType(), "费用类型", CostTypeEnums.class); + // 校验计价方式 + checkEnumsExcel(rowMessage, excel.getCostType(), "计价方式", DispatchPricingTypeEnums.class); + // 品类 + checkCategoryExcel(categoryEntityMap, rowMessage, excel.getCategory()); + // 校验价格,只能是数字 + checkPrice(rowMessage, "单价", excel.getPrice()); + checkPrice(rowMessage, "遗留单价", excel.getLeaveBehindPrice()); + checkPrice(rowMessage, "分货费", excel.getSortPrice()); + checkPrice(rowMessage, "操作/装卸费", excel.getHandlingPrice()); + checkPrice(rowMessage, "平移费", excel.getRelocationPrice()); + checkPrice(rowMessage, "上楼费", excel.getUpstairsDeliveryPrice()); + buildErrorMessageExcel(message, rowMessage, firstMessage); + } + } + } + + private void checkEnumsExcelNotEmpty(StringBuilder rowMessage, String type, String columnName, Class classz) { + if (StrUtil.isEmpty(type)) { + rowMessage.append(columnName).append("不能为空;"); + } else { + buildEnumsMessage(rowMessage, type, columnName, classz); + } + } + + private void buildEnumsMessage(StringBuilder rowMessage, String type, String columnName, Class classz) { + if (ObjectUtil.isEmpty(IDict.getCodeByText(classz, type))) { + Set textSrt = new HashSet<>(); + IDict.getAll(classz).forEach(item -> { + IDict dict = (IDict) item; + textSrt.add(dict.getText()); + }); + rowMessage.append(columnName).append("只能为:") + .append(CollUtil.join(textSrt, "/")) + .append(";"); + } + } + + private void checkEnumsExcel(StringBuilder rowMessage, String type, String columnName, Class classz) { + if (StrUtil.isNotEmpty(type)) { + buildEnumsMessage(rowMessage, type, columnName, classz); + } + } + + private void checkWarehouseExcels(List excels, Map clientEntityMap, Map priceEntityMap, Map categoryEntityMap, StringBuilder message, String sheetName) { + if (CollUtil.isNotEmpty(excels)) { + // 校验sheet2的数据 + for (int i = 0; i < excels.size(); i++) { + BasicdataPriceCategoryWarehouseExcel excel = excels.get(i); + StringBuilder rowMessage = new StringBuilder(); + int rowNum = i + 3; + String firstMessage = sheetName + "-第" + rowNum + "行:"; + // 校验客户和品牌 + checkClientAndBrand(priceEntityMap, rowMessage, excel.getClientCode(), excel.getBrand()); + // 费用类型 + checkEnumsExcelNotEmpty(rowMessage, excel.getType(), "费用类型", CostTypeEnums.class); + // 校验计价方式 + checkEnumsExcel(rowMessage, excel.getCostType(), "计价方式", WarehousePricingTypeEnums.class); + // 品类 + checkCategoryExcel(categoryEntityMap, rowMessage, excel.getCategory()); + + // 校验价格,只能是数字 + checkPrice(rowMessage, "30天内", excel.getWithinThirtyPrice()); + checkPrice(rowMessage, "30-60天", excel.getBetweenThirtySixtyPrice()); + checkPrice(rowMessage, "60天外", excel.getBeyondSixtyPrice()); + checkPrice(rowMessage, "上限价格", excel.getMaximumPrice()); + checkPrice(rowMessage, "操作/装卸费", excel.getOperatePrice()); + checkPrice(rowMessage, "仓储管理费", excel.getWarehouseManagementPrice()); + checkPrice(rowMessage, "仓储分货费", excel.getWarehouseSortPrice()); + buildErrorMessageExcel(message, rowMessage, firstMessage); + } + } + } + + private void checkBasicExcels(StringBuilder message, String sheetName, Map clientEntityMap, Map priceEntityMap, List basicExcels, Map categoryEntityMap, Map provinceMap, Map provinceCityMap, Map provinceCityAearMap) { + if (CollUtil.isNotEmpty(basicExcels)) { + // 校验sheet2的数据 + for (int i = 0; i < basicExcels.size(); i++) { + BasicdataPriceCategoryBasicExcel basicExcel = basicExcels.get(i); + StringBuilder rowMessage = new StringBuilder(); + int rowNum = i + 3; + String firstMessage = sheetName + "-第" + rowNum + "行:"; + // 校验客户和品牌 + checkClientAndBrand(priceEntityMap, rowMessage, basicExcel.getClientCode(), basicExcel.getBrand()); + if (StrUtil.isEmpty(basicExcel.getType())) { + rowMessage.append("服务类型不能为空;"); + } else { + if (!(ObjectUtil.equal(ServiceTypeEnums.PICK_UP.getText(), basicExcel.getType()) + || ObjectUtil.equal(ServiceTypeEnums.TRUNK_LINE.getText(), basicExcel.getType()))) { + rowMessage.append("服务类型只能为提货或干线;"); + } + } + if (StrUtil.isNotEmpty(basicExcel.getCostType())) { + if (!(ObjectUtil.equal(PickupPricingTypeEnums.PIECE.getText(), basicExcel.getCostType()) + || ObjectUtil.equal(PickupPricingTypeEnums.CUBE.getText(), basicExcel.getCostType()) + || ObjectUtil.equal(PickupPricingTypeEnums.WEIGHT.getText(), basicExcel.getCostType())) + ) { + rowMessage.append("服务类型只能为按件或按方或按重量;"); + } + } + + // 发站 + checkReign(provinceMap, provinceCityMap, provinceCityAearMap, rowMessage, basicExcel.getStartProvince(), + basicExcel.getStartCity(), basicExcel.getStartArea(), "发站"); + // 到站 + checkReign(provinceMap, provinceCityMap, provinceCityAearMap, rowMessage, basicExcel.getEndProvince(), + basicExcel.getEndCity(), basicExcel.getEndArea(), "到站"); + // 发货单位 + checkSendOrgExcel(clientEntityMap, rowMessage, basicExcel.getSendOrgCode()); + // 品类 + checkCategoryExcel(categoryEntityMap, rowMessage, basicExcel.getCategory()); + // 校验价格,不能为空,只能是数字 + checkPriceNotEmpty(rowMessage, "价格", basicExcel.getPrice()); + buildErrorMessageExcel(message, rowMessage, firstMessage); + } + } + } + + private void buildErrorMessageExcel(StringBuilder message, StringBuilder rowMessage, String firstMessage) { + if (StrUtil.isNotEmpty(rowMessage.toString())) { + message.append("

"); + message.append(firstMessage); + message.append(rowMessage.toString()); + message.append("

"); + message.append("
"); + } + } + + private void checkPriceNotEmpty(StringBuilder rowMessage, String columnName, String price) { + if (StrUtil.isNotEmpty(price)) { + if (!NumberUtil.isNumber(price)) { + rowMessage.append(columnName).append("只能是数字;"); + } + } else { + rowMessage.append(columnName).append("不能为空;"); + } + } + + private void checkCategoryExcel(Map categoryEntityMap, StringBuilder rowMessage, String category) { + if (StrUtil.isNotEmpty(category)) { + if (!categoryEntityMap.containsKey(category)) { + rowMessage.append("品类不存在;"); + } + } + } + + private void checkSendOrgExcel(Map clientEntityMap, StringBuilder rowMessage, String sendOrg) { + if (StrUtil.isNotEmpty(sendOrg)) { + if (!clientEntityMap.containsKey(sendOrg)) { + rowMessage.append("发货单位编码不存在;"); + } + } + } + + private void checkReign(Map provinceMap, Map provinceCityMap, Map provinceCityAearMap, StringBuilder rowMessage, String startProvince, String startCity, String startArea, String type) { + if (StrUtil.isNotEmpty(startProvince)) { + if (!provinceMap.containsKey(startProvince)) { + rowMessage.append(type).append("(省)不存在;"); + } else { + if (StrUtil.isNotEmpty(startCity)) { + if (!provinceCityMap.containsKey(startProvince + startCity)) { + rowMessage.append(type).append("(市)不存在;"); + } else { + if (StrUtil.isNotEmpty(startArea)) { + if (!provinceCityAearMap.containsKey(startProvince + startCity + startArea)) { + rowMessage.append(type).append("(区)不存在;"); + } + } + } + } + } + } + } + + private void checkClientAndBrand(Map priceEntityMap, StringBuilder rowMessage, String client, String brand) { + if (StrUtil.isEmpty(client)) { + rowMessage.append("客户编码不能为空;"); + } + if (StrUtil.isEmpty(brand)) { + rowMessage.append("品牌不能为空;"); + } + // 客户+品牌必须在sheet1中存在 + if (!ObjectUtil.hasEmpty(client, brand)) { + if (!priceEntityMap.containsKey(client + brand)) { + rowMessage.append("客户编码+品牌名称不存在;"); + } + } + } + + private void initRegion(Map provinceMap, Map provinceCityMap, Map provinceCityAearMap) { + R> regionALL = sysClient.getRegionALL(); + if (regionALL.isSuccess()) { + List data = regionALL.getData(); + if (CollUtil.isNotEmpty(data)) { + for (RegionAllVO datum : data) { + provinceMap.put(datum.getLabel(), datum.getValue()); + List children = datum.getChildren(); + if (CollUtil.isNotEmpty(children)) { + for (RegionAllVO child : children) { + provinceCityMap.put(datum.getLabel() + child.getLabel(), child.getValue()); + List children1 = child.getChildren(); + if (CollUtil.isNotEmpty(children1)) { + for (RegionAllVO regionAllVO : children1) { + provinceCityAearMap.put(datum.getLabel() + child.getLabel() + regionAllVO.getLabel(), regionAllVO.getValue()); + } + } + } + } + } + } + } + } + + private void initCategoryData(List basicExcels, + List dispatchExcels, + List warehouseExcels, + Map categoryEntityMap) { + Set categorySet = new HashSet<>(); + if (CollUtil.isNotEmpty(basicExcels)) { + for (BasicdataPriceCategoryBasicExcel basicExcel : basicExcels) { + if (StrUtil.isNotEmpty(basicExcel.getCategory())) { + categorySet.add(basicExcel.getCategory()); + } + } + } + if (CollUtil.isNotEmpty(dispatchExcels)) { + for (BasicdataPriceCategoryDispatchExcel dispatchExcel : dispatchExcels) { + if (StrUtil.isNotEmpty(dispatchExcel.getCategory())) { + categorySet.add(dispatchExcel.getCategory()); + } + } + } + if (CollUtil.isNotEmpty(warehouseExcels)) { + for (BasicdataPriceCategoryWarehouseExcel warehouseExcel : warehouseExcels) { + if (StrUtil.isNotEmpty(warehouseExcel.getCategory())) { + categorySet.add(warehouseExcel.getCategory()); + } + } + } + if (CollUtil.isNotEmpty(categorySet)) { + List list = categoryService.list(Wrappers.lambdaQuery().in(BasicdataCategoryEntity::getName, categorySet)); + if (CollUtil.isNotEmpty(list)) { + // 将List中的数据方到categoryEntityMap中 + list.forEach(basicdataCategoryEntity -> { + categoryEntityMap.put(basicdataCategoryEntity.getName(), basicdataCategoryEntity); + }); + } + } + } + + private void initImportData(List priceExcels, List basicExcels, List generalExcels, List fullVehicleExcels, Map templateEntityMap, Map clientEntityMap, Map brandEntityMap, Map priceEntityMap) { + Set templateNameSet = new HashSet<>(); + Set clientSet = new HashSet<>(); + Set brandSet = new HashSet<>(); + // 将数据封装到set中 + priceExcels.forEach(priceExcel -> { + if (StrUtil.isNotEmpty(priceExcel.getTemplateName())) { + templateNameSet.add(priceExcel.getTemplateName()); + } + if (StrUtil.isNotEmpty(priceExcel.getClientCode())) { + clientSet.add(priceExcel.getClientCode()); + } + if (StrUtil.isNotEmpty(priceExcel.getBrand())) { + brandSet.add(priceExcel.getBrand()); + } + }); + if (CollUtil.isNotEmpty(basicExcels)) { + for (BasicdataPriceCategoryBasicExcel basicExcel : basicExcels) { + if (StrUtil.isNotEmpty(basicExcel.getSendOrgCode())) { + clientSet.add(basicExcel.getSendOrgCode()); + } + } + } + if (CollUtil.isNotEmpty(generalExcels)) { + for (BasicdataPriceGeneralExcel generalExcel : generalExcels) { + if (StrUtil.isNotEmpty(generalExcel.getSendOrgCode())) { + clientSet.add(generalExcel.getSendOrgCode()); + } + } + } + if (CollUtil.isNotEmpty(fullVehicleExcels)) { + for (BasicdataPriceFullVehicleExcel fullVehicleExcel : fullVehicleExcels) { + if (StrUtil.isNotEmpty(fullVehicleExcel.getSendOrgCode())) { + clientSet.add(fullVehicleExcel.getSendOrgCode()); + } + } + } + // 先校验数据完整性 + if (CollUtil.isNotEmpty(templateNameSet)) { + LambdaQueryWrapper templateWrapper = Wrappers.lambdaQuery().in(BasicdataPriceTemplateEntity::getName, templateNameSet); + List templateEntities = templateService.list(templateWrapper); + // 将templateEntities中的数据放到map中 + templateEntities.forEach(templateEntity -> { + templateEntityMap.put(templateEntity.getName(), templateEntity); + }); + } + + if (CollUtil.isNotEmpty(clientSet)) { + LambdaQueryWrapper clientWrapper = Wrappers.lambdaQuery().in(BasicdataClientEntity::getClientCode, clientSet); + List clientEntities = clientService.list(clientWrapper); + // 将clientEntities中的数据放到map中 + clientEntities.forEach(clientEntity -> { + clientEntityMap.put(clientEntity.getClientCode(), clientEntity); + }); + } + + if (CollUtil.isNotEmpty(brandSet)) { + LambdaQueryWrapper brandWrapper = Wrappers.lambdaQuery().in(BasicdataBrandEntity::getBrandName, brandSet); + List brandEntities = brandService.list(brandWrapper); + // 将brandEntities中的数据放到map中 + brandEntities.forEach(brandEntity -> { + brandEntityMap.put(brandEntity.getBrandName(), brandEntity); + }); + } + Boolean flag = Boolean.FALSE; + for (BasicdataPriceExcel priceExcel : priceExcels) { + if (!ObjectUtil.hasEmpty(priceExcel.getClientCode(), priceExcel.getBrand())) { + flag = Boolean.TRUE; + break; + } + } + if (flag) { + List priceEntities = this.baseMapper.findEntityByClientAndBrand(priceExcels); + if (CollUtil.isNotEmpty(priceEntities)) { + priceEntities.forEach(priceEntity -> { + priceEntityMap.put(priceEntity.getClientCode() + priceEntity.getBrandName(), priceEntity); + }); + } + } + + } + + private void checkPriceData(StringBuilder message, List priceExcels, String sheet1, Map templateEntityMap, Map clientEntityMap, Map brandEntityMap, Map priceEntityMap) { + if (CollUtil.isNotEmpty(priceExcels)) { + for (int i = 0; i < priceExcels.size(); i++) { + StringBuilder rowMessage = new StringBuilder(); + int rowNum = i + 2; + String firstMessage = sheet1 + "-第" + rowNum + "行:"; + BasicdataPriceExcel priceExcel = priceExcels.get(i); + // 校验必填项 + if (StrUtil.isEmpty(priceExcel.getClientCode())) { + rowMessage.append("客户编码不能为空;"); + } else { + if (!clientEntityMap.containsKey(priceExcel.getClientCode())) { + rowMessage.append("客户编码[").append(priceExcel.getClientCode()).append("]在系统中不存在;"); + } + } + Boolean brandFlag = Boolean.FALSE; + if (StrUtil.isEmpty(priceExcel.getBrand())) { + rowMessage.append("品牌名称名称不能为空;"); + } else { + if (!brandEntityMap.containsKey(priceExcel.getBrand())) { + rowMessage.append("品牌名称[").append(priceExcel.getBrand()).append("]在系统中不存在;"); + } else { + brandFlag = Boolean.TRUE; + } + } + Boolean templateFlag = Boolean.FALSE; + if (StrUtil.isEmpty(priceExcel.getTemplateName())) { + rowMessage.append("模板名称不能为空;"); + } else { + if (!templateEntityMap.containsKey(priceExcel.getTemplateName())) { + rowMessage.append("模板名称[").append(priceExcel.getTemplateName()).append("]在系统中不存在;"); + } else { + templateFlag = Boolean.TRUE; + } + } + if (brandFlag && templateFlag) { + if (!ObjectUtil.equal(brandEntityMap.get(priceExcel.getBrand()).getId(), templateEntityMap.get(priceExcel.getTemplateName()).getBrandId())) { + rowMessage.append("品牌名称[").append(priceExcel.getBrand()).append("]与模板对应的品牌").append("不相同,请填写对应品牌的模板;"); + } + } + if (!ObjectUtil.hasEmpty(priceExcel.getClientCode(), priceExcel.getClientCode())) { + if (!priceEntityMap.containsKey(priceExcel.getClientCode() + priceExcel.getBrand())) { + rowMessage.append("客户编码[").append(priceExcel.getClientCode()).append("]品牌名称[").append(priceExcel.getBrand()).append("]在系统价格体系中不存在,请维护客户和品牌的关系;"); + } + } + DateTime startTime = null; + DateTime endTime = null; + if (StrUtil.isNotEmpty(priceExcel.getEffectiveTime())) { + // 校验是否为日期格式 + try { + startTime = DateUtil.parseDate(priceExcel.getEffectiveTime()); + } catch (Exception e) { + rowMessage.append("生效时间格式错误,例:2020-01-01;"); + } + } + if (StrUtil.isNotEmpty(priceExcel.getExpiryTime())) { + // 校验是否为日期格式 + try { + endTime = DateUtil.parseDate(priceExcel.getExpiryTime()); + } catch (Exception e) { + rowMessage.append("到期时间格式错误,例:2020-01-01;"); + } + } + if (!ObjectUtil.hasEmpty(startTime, endTime)) { + // 校验时间大小关系 + if (startTime.isAfter(endTime)) { + rowMessage.append("生效时间不能大于到期时间;"); + } + } + checkPrice(rowMessage, "向上判断件数", priceExcel.getDispatchUpwardJudgment()); + checkPrice(rowMessage, "向上判断加价", priceExcel.getDispatchUpwardJudgmentCost()); + checkPrice(rowMessage, "上楼费免费楼层", priceExcel.getDispatchStairsCarryingCharge()); + buildErrorMessageExcel(message, rowMessage, firstMessage); + } + if (StrUtil.isEmpty(message.toString())) { + if (CollUtil.isNotEmpty(priceEntityMap) && !ObjectUtil.equal(priceExcels.size(), priceEntityMap.size())) { + message.append(sheet1).append("中存在重复数据,请检查;"); + } + } + } + + } + + private void checkPrice(StringBuilder rowMessage, String cloumName, String price) { + if (StrUtil.isNotEmpty(price)) { + if (!NumberUtil.isNumber(price)) { + rowMessage.append(cloumName).append("只能为数字;"); + } } - return null; } private void buildDetailMap(BasicdataPriceEntity priceEntity, Map> fullMap, Map> basicMap, Map> warehouseMap, Map> dispatchMap, Map> generalMap) { @@ -598,13 +1735,17 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl List read(MultipartFile excel, Class clazz) { + DataListener dataListener = new DataListener(); + ExcelReaderBuilder builder = getReaderBuilder(excel, dataListener, clazz); + if (builder == null) { + return null; + } else { + builder.doReadAll(); + return dataListener.getDataList(); + } + } + + public static List read(MultipartFile excel, int sheetNo, Class clazz) { + return read(excel, sheetNo, 1, clazz); + } + + public static List readTrim(MultipartFile excel, int sheetNo, Class clazz) { + return readTrim(excel, sheetNo, 1, clazz); + } + + public static List read(MultipartFile excel, int sheetNo, int headRowNumber, Class clazz) { + DataListener dataListener = new DataListener(); + ExcelReaderBuilder builder = getReaderBuilder(excel, dataListener, clazz); + if (builder == null) { + return null; + } else { + ((ExcelReaderSheetBuilder) builder.sheet(sheetNo).headRowNumber(headRowNumber)).doRead(); + return dataListener.getDataList(); + } + } + public static List readTrim(MultipartFile excel, int sheetNo, int headRowNumber, Class clazz) { + DataListener dataListener = new DataListener(); + ExcelReaderBuilder builder = getReaderBuilder(excel, dataListener, clazz); + if (builder == null) { + return null; + } else { + ((ExcelReaderSheetBuilder) builder.sheet(sheetNo).headRowNumber(headRowNumber)).registerConverter(new TrimConverter()).doRead(); + return dataListener.getDataList(); + } + } + + public static ExcelReaderBuilder getReaderBuilder(MultipartFile excel, ReadListener readListener, Class clazz) { + String filename = excel.getOriginalFilename(); + if (StrUtil.isEmpty(filename)) { + throw new ExcelException("请上传文件!"); + } else if (!StringUtils.endsWithIgnoreCase(filename, ".xls") && !StringUtils.endsWithIgnoreCase(filename, ".xlsx")) { + throw new ExcelException("请上传正确的excel文件!"); + } else { + try { + InputStream inputStream = new BufferedInputStream(excel.getInputStream()); + return EasyExcel.read(inputStream, clazz, readListener); + } catch (IOException var6) { + var6.printStackTrace(); + return null; + } + } + } +} diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/util/TrimConverter.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/util/TrimConverter.java new file mode 100644 index 000000000..3e25d0ddf --- /dev/null +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/util/TrimConverter.java @@ -0,0 +1,43 @@ +package com.logpm.basicdata.util; + +import cn.hutool.core.util.StrUtil; +import com.alibaba.excel.converters.Converter; +import com.alibaba.excel.enums.CellDataTypeEnum; +import com.alibaba.excel.metadata.CellData; +import com.alibaba.excel.metadata.GlobalConfiguration; +import com.alibaba.excel.metadata.property.ExcelContentProperty; + +/** + * 自定义去除cell前后空格转换器 + * + * @author zhaoqiaobo + * @create 2024-04-24 + */ +public class TrimConverter implements Converter { + @Override + public Class supportJavaTypeKey() { + return String.class; + } + + @Override + public CellDataTypeEnum supportExcelTypeKey() { + return CellDataTypeEnum.STRING; + } + + @Override + public String convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { + String value = cellData.getStringValue(); + if (StrUtil.isNotEmpty(value)) { + return value.trim(); + } + return value; + } + + @Override + public CellData convertToExcelData(String value, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { + if (StrUtil.isEmpty(value)) { + return new CellData(value); + } + return new CellData(value.trim()); + } +}