diff --git a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/BasicdatPriceApiVO.java b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/BasicdatPriceApiVO.java index f59fbd0ac..226557d19 100644 --- a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/BasicdatPriceApiVO.java +++ b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/BasicdatPriceApiVO.java @@ -38,6 +38,8 @@ public class BasicdatPriceApiVO implements Serializable { @NotEmpty(message = "品牌id不能为空") @ApiModelProperty(value = "品牌id") private String brandId; + @ApiModelProperty(value = "日期") + private String time; @ApiModelProperty(value = "发货单位id") private String sendOrgId; @ApiModelProperty(value = "始发地省份id") diff --git a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/BasicdataPriceBasicUpdateVO.java b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/BasicdataPriceBasicUpdateVO.java index 394890b56..0b31c035b 100644 --- a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/BasicdataPriceBasicUpdateVO.java +++ b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/BasicdataPriceBasicUpdateVO.java @@ -33,12 +33,15 @@ import java.util.Date; public class BasicdataPriceBasicUpdateVO implements Serializable { private static final long serialVersionUID = 1L; - @NotNull(message = "修改数据id不能为空") @ApiModelProperty(value = "id") private Long id; @NotNull(message = "模板不能为空") @ApiModelProperty(value = "模板id") private Long templateId; + @ApiModelProperty(value = "客户id") + private Long clientId; + @ApiModelProperty(value = "品牌id") + private Long brandId; @NotNull(message = "生效时间不能为空") @ApiModelProperty(value = "生效时间") private Date effectiveTime; diff --git a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/BasicdataPricePageVO.java b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/BasicdataPricePageVO.java index 3ce265f24..873848787 100644 --- a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/BasicdataPricePageVO.java +++ b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/BasicdataPricePageVO.java @@ -45,6 +45,9 @@ public class BasicdataPricePageVO implements Serializable { @ApiModelProperty(value = "品牌id") private String brandId; + @ApiModelProperty(value = "客户id") + private String clientId; + @ApiModelProperty(value = "价格模板id") private String templateId; diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionReservationPackageEntity.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionReservationPackageEntity.java index 5f2cde2a1..cfa938169 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionReservationPackageEntity.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionReservationPackageEntity.java @@ -96,5 +96,12 @@ public class DistributionReservationPackageEntity extends TenantEntity { private Integer cancelStatus; + /** + * 包件任务取消备注 + */ + @ApiModelProperty(value = "包件任务取消备注") + private String cancelRemark; + + } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataPriceController.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataPriceController.java index 75003dc30..76fd23e51 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataPriceController.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataPriceController.java @@ -101,6 +101,16 @@ public class BasicdataPriceController extends BladeController { IPage pages = basicdataPriceService.selectBasicdataPricePage(Condition.getPage(query), basicdataPrice); return R.data(pages); } + /** + * 基础价格表 历史版本查询 + */ + @GetMapping("hisPage") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "历史版本查询", notes = "历史版本查询") + public R> hisPage(BasicdataPricePageVO basicdataPrice, Query query) { + IPage pages = basicdataPriceService.hisPage(Condition.getPage(query), basicdataPrice); + return R.data(pages); + } /** * 基础价格表 修改 @@ -135,6 +145,18 @@ public class BasicdataPriceController extends BladeController { public R upload(@RequestPart("file") MultipartFile file) { return R.data(basicdataPriceService.upload(file)); } + /** + * 基础价格表 导入 + */ + @PostMapping("upload/v2") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "导入v2", notes = "导入v2") + @ApiImplicitParams({ + @ApiImplicitParam(name = "file", value = "文件", dataType = "MultipartFile") + }) + public R uploadV2(@RequestPart("file") MultipartFile file) { + return R.data(basicdataPriceService.uploadV2(file)); + } /** * 基础价格表 指定查询 diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/pricev2/BasicdataPriceCategoryV2Excel.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/pricev2/BasicdataPriceCategoryV2Excel.java new file mode 100644 index 000000000..1f05060d9 --- /dev/null +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/pricev2/BasicdataPriceCategoryV2Excel.java @@ -0,0 +1,104 @@ +/* + * 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.excel.pricev2; + + +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 lombok.Data; + +import java.io.Serializable; + + +/** + * 价格 Excel实体类 + * + * @author chao + * @since 2024-04-19 + */ +@Data +@ColumnWidth(25) +@HeadRowHeight(20) +@ContentRowHeight(18) +public class BasicdataPriceCategoryV2Excel implements Serializable { + + private static final long serialVersionUID = 1L; + + @ExcelProperty(value = {"商场名称", "商场名称"}, index = 0) + private String client; + @ExcelProperty(value = {"品牌", "品牌"}, index = 1) + private String brand; + @ExcelProperty(value = {"发站", "省"}, index = 2) + private String startProvince; + @ExcelProperty(value = {"发站", "市"}, index = 3) + private String startCity; + @ExcelProperty(value = {"发站", "区"}, index = 4) + private String startArea; + @ExcelProperty(value = {"到站", "省"}, index = 5) + private String endProvince; + @ExcelProperty(value = {"到站", "市"}, index = 6) + private String endCity; + @ExcelProperty(value = {"到站", "区"}, index = 7) + private String endArea; + @ExcelProperty(value = {"发货单位", "发货单位编码"}, index = 8) + private String sendOrgCode; + @ExcelProperty(value = {"发货单位", "发货单位"}, index = 9) + private String sendOrg; + @ExcelProperty(value = {"品类", "品类"}, index = 10) + private String category; + @ExcelProperty(value = {"提货", "单位"}, index = 11) + private String pickupUnit; + @ExcelProperty(value = {"提货", "单价"}, index = 12) + private String pickupPrice; + @ExcelProperty(value = {"干线", "单位"}, index = 13) + private String trunkLineUnit; + @ExcelProperty(value = {"干线", "单价"}, index = 14) + private String trunkLinePrice; + @ExcelProperty(value = {"仓储", "30天内"}, index = 15) + private String withinThirtyPrice; + @ExcelProperty(value = {"仓储", "30-60天"}, index = 16) + private String betweenThirtySixtyPrice; + @ExcelProperty(value = {"仓储", "60-90天"}, index = 17) + private String beyondSixtyPrice; + @ExcelProperty(value = {"仓储", "90天以上"}, index = 18) + private String beyondNinetyPrice; + @ExcelProperty(value = {"仓储附加费", "仓储操作/装卸费"}, index = 19) + private String warehouseOperatePrice; + @ExcelProperty(value = {"仓储附加费", "仓储管理费"}, index = 20) + private String warehouseManagementPrice; + @ExcelProperty(value = {"仓储附加费", "仓储分货费"}, index = 21) + private String warehouseSortPrice; + @ExcelProperty(value = {"配送", "单位"}, index = 22) + private String dispatchUnit; + @ExcelProperty(value = {"配送", "一般单价"}, index = 23) + private String dispatchPrice; + @ExcelProperty(value = {"配送", "遗留单价"}, index = 24) + private String dispatchLeaveBehindPrice; + @ExcelProperty(value = {"配送附加费", "分货费"}, index = 25) + private String dispatchSortPrice; + @ExcelProperty(value = {"配送附加费", "操作/装卸费价格"}, index = 26) + private String dispatchHandlingPrice; + @ExcelProperty(value = {"配送附加费", "平移费价格"}, index = 27) + private String dispatchRelocationPrice; + @ExcelProperty(value = {"配送附加费", "上楼费价格"}, index = 28) + private String dispatchDeliveryPrice; + @ExcelProperty(value = {"配送附加费", "上楼免楼层数"}, index = 29) + private String dispatchStairsCarryingCharge; + +} diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/pricev2/BasicdataPriceFullVehicleV2Excel.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/pricev2/BasicdataPriceFullVehicleV2Excel.java new file mode 100644 index 000000000..a27bd5b0f --- /dev/null +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/pricev2/BasicdataPriceFullVehicleV2Excel.java @@ -0,0 +1,72 @@ +/* + * 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.excel.pricev2; + + +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 lombok.Data; + +import java.io.Serializable; + + +/** + * 价格 Excel实体类 + * + * @author chao + * @since 2024-04-19 + */ +@Data +@ColumnWidth(25) +@HeadRowHeight(20) +@ContentRowHeight(18) +public class BasicdataPriceFullVehicleV2Excel implements Serializable { + + private static final long serialVersionUID = 1L; + + @ExcelProperty(value = {"商场名称", "商场名称"}, index = 0) + private String client; + @ExcelProperty(value = {"品牌", "品牌"}, index = 1) + private String brand; + @ExcelProperty(value = {"发站", "省"}, index = 2) + private String startProvince; + @ExcelProperty(value = {"发站", "市"}, index = 3) + private String startCity; + @ExcelProperty(value = {"发站", "区"}, index = 4) + private String startArea; + @ExcelProperty(value = {"到站", "省"}, index = 5) + private String endProvince; + @ExcelProperty(value = {"到站", "市"}, index = 6) + private String endCity; + @ExcelProperty(value = {"到站", "区"}, index = 7) + private String endArea; + @ExcelProperty(value = {"发货单位", "发货单位ID"}, index = 8) + private String sendOrgCode; + @ExcelProperty(value = {"发货单位", "发货单位"}, index = 9) + private String sendOrg; + @ExcelProperty(value = {"车型", "车型"}, index = 10) + private String vehicleType; + @ExcelProperty(value = {"提货", "单价"}, index = 11) + private String pickupPrice; + @ExcelProperty(value = {"干线", "单价"}, index = 12) + private String trunkLinePrice; + @ExcelProperty(value = {"配送", "单价"}, index = 13) + private String dispatchPrice; + +} diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/pricev2/BasicdataPriceGeneralV2Excel.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/pricev2/BasicdataPriceGeneralV2Excel.java new file mode 100644 index 000000000..2a2879b03 --- /dev/null +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/pricev2/BasicdataPriceGeneralV2Excel.java @@ -0,0 +1,84 @@ +/* + * 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.excel.pricev2; + + +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 lombok.Data; + +import java.io.Serializable; + + +/** + * 价格 Excel实体类 + * + * @author chao + * @since 2024-04-19 + */ +@Data +@ColumnWidth(25) +@HeadRowHeight(20) +@ContentRowHeight(18) +public class BasicdataPriceGeneralV2Excel implements Serializable { + + private static final long serialVersionUID = 1L; + + @ExcelProperty(value = {"商场名称", "商场名称"}, index = 0) + private String client; + @ExcelProperty(value = {"品牌", "品牌"}, index = 1) + private String brand; + @ExcelProperty(value = {"发站", "省"}, index = 2) + private String startProvince; + @ExcelProperty(value = {"发站", "市"}, index = 3) + private String startCity; + @ExcelProperty(value = {"发站", "区"}, index = 4) + private String startArea; + @ExcelProperty(value = {"到站", "省"}, index = 5) + private String endProvince; + @ExcelProperty(value = {"到站", "市"}, index = 6) + private String endCity; + @ExcelProperty(value = {"到站", "区"}, index = 7) + private String endArea; + @ExcelProperty(value = {"发货单位", "发货单位ID"}, index = 8) + private String sendOrgCode; + @ExcelProperty(value = {"发货单位", "发货单位"}, index = 9) + private String sendOrg; + @ExcelProperty(value = {"提货", "最低计费"}, index = 10) + private String pickupMinCost; + @ExcelProperty(value = {"提货", "加算价格"}, index = 11) + private String pickupAddCost; + @ExcelProperty(value = {"干线", "最低计费"}, index = 12) + private String trunkLineMinCost; + @ExcelProperty(value = {"干线", "加算价格"}, index = 13) + private String trunkLineAddCost; + @ExcelProperty(value = {"配送", "最低计费"}, index = 14) + private String dispatchMinCost; + @ExcelProperty(value = {"配送", "加算价格"}, index = 15) + private String dispatchAddCost; + @ExcelProperty(value = {"配送", "向上判断件数"}, index = 16) + private String dispatchUpwardJudgment; + @ExcelProperty(value = {"配送", "向上判断加价"}, index = 17) + private String dispatchUpwardJudgmentCost; + @ExcelProperty(value = {"配送", "遗留最低计费"}, index = 18) + private String dispatchLeaveBehindMinCost; + @ExcelProperty(value = {"配送", "遗留加算价格"}, index = 19) + private String dispatchLeaveBehindAddCost; + +} diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/pricev2/BasicdataPriceV2Excel.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/pricev2/BasicdataPriceV2Excel.java new file mode 100644 index 000000000..d045708fc --- /dev/null +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/pricev2/BasicdataPriceV2Excel.java @@ -0,0 +1,86 @@ +/* + * 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.excel.pricev2; + + +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 lombok.Data; + +import java.io.Serializable; + + +/** + * 价格 Excel实体类 + * + * @author chao + * @since 2024-04-19 + */ +@Data +@ColumnWidth(25) +@HeadRowHeight(20) +@ContentRowHeight(18) +public class BasicdataPriceV2Excel implements Serializable { + + private static final long serialVersionUID = 1L; + + @ExcelProperty(value = "商场编码(工厂)", index = 0) + private String clientCode; + /** + * 客户名称 + */ + @ExcelProperty(value = "商场名称", index = 1) + private String client; + /** + * 品牌 + */ + @ExcelProperty(value = "品牌", index = 2) + private String brand; + /** + * 生效时间 + */ + @ExcelProperty(value = "生效日期", index = 3) + private String effectiveTime; + /** + * 到期时间 + */ + @ExcelProperty(value = "截止日期", index = 4) + private String expiryTime; + /** + * 配送服务类型 + */ + @ExcelProperty(value = "配送服务类型", index = 5) + private String serviceType; + /** + * 结算方式 + */ + @ExcelProperty(value = "结算方式", index = 6) + private String settlementMethod; + /** + * 付款方 + */ + @ExcelProperty(value = "付款方", index = 7) + private String payingParty; + /** + * 模版名称 + */ + @ExcelProperty(value = "模版名称", index = 8) + private String templateName; + +} 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 62aa4ec81..49631d70f 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 @@ -21,6 +21,7 @@ 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.price.BasicdataPriceExcel; +import com.logpm.basicdata.excel.pricev2.BasicdataPriceV2Excel; import com.logpm.basicdata.vo.BasicdataPriceImportVO; import com.logpm.basicdata.vo.BasicdataPricePageVO; import org.apache.ibatis.annotations.Delete; @@ -51,4 +52,8 @@ public interface BasicdataPriceMapper extends BaseMapper { void removeRouteByPriceId(Long id); List findEntityByClientAndBrand(@Param("prices") List prices); + + List findEntityByClientAndBrandV2(@Param("prices") List priceExcels); + + List hisPage(IPage page, BasicdataPricePageVO basicdataPrice); } 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 55bc1204b..efd69243c 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 @@ -11,6 +11,7 @@ select t.id, cli.client_name, t.brand_id, + t.client_id, t.template_id, ldb.brand_name, lbpt.service_type, @@ -22,11 +23,13 @@ t.update_time, t.effective_time, t.expiry_time - from logpm_basicdata_price t - left join logpm_basicdata_price_template lbpt on t.template_id = lbpt.id - left join logpm_basicdata_client cli on cli.id = t.client_id + from logpm_basicdata_store_brand lbsb + left join logpm_basicdata_client cli on cli.id = lbsb.client_id + left join logpm_basicdata_price t on lbsb.client_id = t.client_id + and lbsb.brand_id = t.brand_id and t.effective_time now() and t.expiry_time >= now() left join logpm_basicdata_brand ldb on ldb.id = t.brand_id - where t.is_deleted = 0 + left join logpm_basicdata_price_template lbpt on t.template_id = lbpt.id + where lbsb.is_deleted = 0 and cli.client_name like concat('%',#{basicdataPrice.clientName},'%') @@ -42,6 +45,30 @@ + - + diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataPriceService.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataPriceService.java index 3826bbbb7..f99c5cbb2 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataPriceService.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataPriceService.java @@ -69,4 +69,9 @@ public interface IBasicdataPriceService extends BaseService hisPage(IPage page, BasicdataPricePageVO basicdataPrice); + } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceCategoryBasicServiceImpl.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceCategoryBasicServiceImpl.java index 732bff502..edef25ad1 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceCategoryBasicServiceImpl.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceCategoryBasicServiceImpl.java @@ -41,7 +41,7 @@ public class BasicdataPriceCategoryBasicServiceImpl extends BaseServiceImpl hisPage(IPage page, BasicdataPricePageVO basicdataPrice) { + if (ObjectUtil.hasEmpty(basicdataPrice.getClientId(), basicdataPrice.getBrandId())) { + throw new ServiceException("客户id和品牌id不能为空"); + } + List basicdataPriceVOS = baseMapper.hisPage(page, basicdataPrice); + if (CollUtil.isNotEmpty(basicdataPriceVOS)) { + for (BasicdataPricePageVO basicdataPriceVO : basicdataPriceVOS) { + // 维护状态 + if (ObjectUtil.isNotEmpty(basicdataPriceVO.getExpiryTime())) { + DateTime now = DateUtil.date(); + if (now.isAfter(basicdataPriceVO.getExpiryTime())) { + // 已到期 + basicdataPriceVO.setMaintenanceStatus("已过期"); + } + } + // 服务类型 + String serviceType = basicdataPriceVO.getServiceType(); + if (StrUtil.isNotEmpty(serviceType)) { + List res = new ArrayList<>(); + List split = StrUtil.split(serviceType, ","); + for (String s : split) { + res.add(IDict.getTextByCode(ServiceTypeEnums.class, Convert.toInt(s))); + } + basicdataPriceVO.setServiceType(StrUtil.join("/", res)); + } + } + } + return page.setRecords(basicdataPriceVOS); + } + @Override @Transactional(rollbackFor = Exception.class) public Boolean basicUpdate(BasicdataPriceBasicUpdateVO vo) { if (DateUtil.compare(vo.getEffectiveTime(), vo.getExpiryTime()) > 0) { throw new ServiceException("生效时间大于到期时间,请检查。"); } + Long clientId1 = vo.getClientId(); + Long brandId1 = vo.getBrandId(); + List list1 = this.list(Wrappers.lambdaQuery() + .eq(BasicdataPriceEntity::getClientId, clientId1) + .eq(BasicdataPriceEntity::getBrandId, brandId1) + .eq(BasicdataPriceEntity::getIsDeleted, 0) + ); + // 修改的当前版本时间控制 + Date start1 = vo.getEffectiveTime(); + Date end1 = vo.getExpiryTime(); + int flag = 0; + if (CollUtil.isNotEmpty(list1)) { + for (BasicdataPriceEntity priceEntity : list1) { + Date start2 = priceEntity.getEffectiveTime(); + Date end2 = priceEntity.getExpiryTime(); + if (start1.after(priceEntity.getEffectiveTime())) { + // 交换 interval1 的开始和结束时间 + Date temp = start1; + start1 = start2; + start2 = temp; + temp = end1; + end1 = end2; + end2 = temp; + } + // 计算交集 + if (!end1.before(start2)) { + flag += 1; + } + } + } + if (flag > 1) { + 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 entity = null; + if (ObjectUtil.isNotEmpty(vo.getId())) { + entity = this.getById(vo.getId()); + if (ObjectUtil.isNotEmpty(entity)) { + Long templateId = entity.getTemplateId(); + if (!ObjectUtil.equal(templateId, vo.getTemplateId())) { + // 删除数据 + deleteByPriceId(vo.getId()); + entity.setDispatchStairsCarryingCharge(0); + entity.setDispatchUpwardJudgment(0d); + entity.setDispatchUpwardJudgmentCost(0d); + log.info("价格体系:{} 切换模版删除数据", vo.getId()); + } } - } - - basicdataPriceEntity.setId(vo.getId()); - basicdataPriceEntity.setTemplateId(vo.getTemplateId()); - basicdataPriceEntity.setEffectiveTime(vo.getEffectiveTime()); - basicdataPriceEntity.setExpiryTime(vo.getExpiryTime()); - basicdataPriceEntity.setMaintenanceStatus(2); - int res = this.baseMapper.updateById(basicdataPriceEntity); - return res > 0; + } else { + entity = new BasicdataPriceEntity(); + entity.setClientId(vo.getClientId()); + entity.setBrandId(vo.getBrandId()); + } + entity.setTemplateId(vo.getTemplateId()); + entity.setEffectiveTime(vo.getEffectiveTime()); + entity.setExpiryTime(vo.getExpiryTime()); + entity.setMaintenanceStatus(2); + boolean b = this.saveOrUpdate(entity); + return b; } private void deleteByPriceId(Long id) { @@ -306,11 +380,19 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl priceEntities = this.list(Wrappers.lambdaQuery() + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery() .eq(BasicdataPriceEntity::getClientId, clientId) - .eq(BasicdataPriceEntity::getBrandId, brandId) - .ge(BasicdataPriceEntity::getExpiryTime, new Date()) - ); + .eq(BasicdataPriceEntity::getBrandId, brandId); + if (StrUtil.isNotEmpty(param.getTime())) { + wrapper.ge(BasicdataPriceEntity::getExpiryTime, DateUtil.parse(param.getTime(), "yyyy-MM-dd")) + .le(BasicdataPriceEntity::getEffectiveTime, DateUtil.parse(param.getTime(), "yyyy-MM-dd")) + ; + } else { + wrapper.ge(BasicdataPriceEntity::getExpiryTime, new Date()) + .le(BasicdataPriceEntity::getEffectiveTime, new Date()) + ; + } + List priceEntities = this.list(wrapper); if (CollUtil.isNotEmpty(priceEntities)) { priceEntity = priceEntities.get(0); } @@ -483,11 +565,92 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl priceExcels = EasyExcelUtil.readTrim(file, 0, 2, BasicdataPriceV2Excel.class); + // 校验数据 + String sheet1 = "基础数据"; + String sheet2 = "整车费用"; + String sheet3 = "保底价"; + String sheet4 = "正常计费"; + if (CollUtil.isNotEmpty(priceExcels)) { + + // 模板名称为key + Map templateEntityMap = new HashMap<>(); + // 客户名称 + 品牌名称为key + Map templateMap = new HashMap<>(); + // 客户编码为key + Map clientEntityMap = new HashMap<>(); + // 品牌名称为key + Map brandEntityMap = new HashMap<>(); + // 客户名称 + 品牌名称为key + Map priceEntityMap = new HashMap<>(); + Map> checkPriceEntityMap = new HashMap<>(); + Map clientBrandMap = new HashMap<>(); + List fullVehicleExcels = EasyExcelUtil.readTrim(file, 1, 3, BasicdataPriceFullVehicleV2Excel.class); + List generalExcels = EasyExcelUtil.readTrim(file, 2, 2, BasicdataPriceGeneralV2Excel.class); + List basicExcels = EasyExcelUtil.readTrim(file, 3, 4, BasicdataPriceCategoryV2Excel.class); + // 初始化导入校验数据 + initImportDataV2(priceExcels, basicExcels, generalExcels, fullVehicleExcels, templateEntityMap, clientEntityMap, brandEntityMap, + priceEntityMap, clientBrandMap, checkPriceEntityMap, templateMap); + // 校验数据 + checkPriceDataV2(message, priceExcels, sheet1, templateEntityMap, clientEntityMap, brandEntityMap, priceEntityMap, clientBrandMap, + checkPriceEntityMap); + // 第一个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); + // 路径为key 客户编码&&&品牌&&&发货单位编码 || 客户编码&&&品牌&&&发货单位编码&&&发站省市 || 客户编码&&&品牌&&&发货单位编码&&&发站省市&&&发站省市区 + Map routeMap = new HashMap<>(); + initRouteMapV2(routeMap, basicExcels, generalExcels, fullVehicleExcels); + // 初始化品类 + initCategoryDataV2(basicExcels, categoryEntityMap); + // 提货干线按品类计费 + checkBasicExcelsV2(message, sheet4, clientEntityMap, priceEntityMap, basicExcels, categoryEntityMap, provinceMap, + provinceCityMap, provinceCityAearMap, clientBrandMap, templateMap); + // 一般计费 + checkGeneralExcelsV2(generalExcels, clientEntityMap, priceEntityMap, provinceMap, provinceCityMap, + provinceCityAearMap, message, sheet3, clientBrandMap, templateMap); + // 封装整车车型 车型名称为key + Map vehicleTypeMap = new HashMap<>(); + initVehicleTypeMap(vehicleTypeMap); + //整车 + checkFullExcelV2(fullVehicleExcels, clientEntityMap, priceEntityMap, provinceMap, provinceCityMap, + provinceCityAearMap, vehicleTypeMap, message, sheet2, clientBrandMap, templateMap); + if (StrUtil.isNotEmpty(message.toString())) { + return message.toString(); + } + // 保存数据 + // 先处理 + saveExcelV2(priceExcels, basicExcels, generalExcels, fullVehicleExcels, + templateEntityMap, clientEntityMap, brandEntityMap, priceEntityMap, categoryEntityMap, provinceMap, + provinceCityMap, provinceCityAearMap, vehicleTypeMap, routeMap, clientBrandMap, templateMap); + } 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())) { + if (!ObjectUtil.isAllEmpty(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()); @@ -500,7 +663,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl routeMap, List basicExcels, List generalExcels, List fullVehicleExcels) { + if (CollUtil.isNotEmpty(basicExcels)) { + for (BasicdataPriceCategoryV2Excel basicExcel : basicExcels) { + // 发站省,发站市,到站省,到站市,发货单位不为空则说明是一条路径 + if (!ObjectUtil.isAllEmpty(basicExcel.getClient(), basicExcel.getBrand(), basicExcel.getSendOrg())) { + if (StrUtil.isNotEmpty(basicExcel.getPickupPrice())) { + // 提货路径 + String pickupKey = buildRoutKeyV2(basicExcel.getClient(), basicExcel.getBrand(), basicExcel.getStartProvince(), + basicExcel.getStartCity(), basicExcel.getStartArea(), basicExcel.getEndProvince(), basicExcel.getEndCity(), + basicExcel.getEndArea(), basicExcel.getSendOrg(), "1"); + if (!routeMap.containsKey(pickupKey)) { + routeMap.put(pickupKey, basicExcel.getClient() + "&&&" + basicExcel.getBrand()); + } + } + if (StrUtil.isNotEmpty(basicExcel.getTrunkLinePrice())) { + // 干线路径 + String trunkLineKey = buildRoutKeyV2(basicExcel.getClient(), basicExcel.getBrand(), basicExcel.getStartProvince(), + basicExcel.getStartCity(), basicExcel.getStartArea(), basicExcel.getEndProvince(), basicExcel.getEndCity(), + basicExcel.getEndArea(), basicExcel.getSendOrg(), "2"); + if (!routeMap.containsKey(trunkLineKey)) { + routeMap.put(trunkLineKey, basicExcel.getClient() + "&&&" + basicExcel.getBrand()); + } + } + } + } + } + if (CollUtil.isNotEmpty(generalExcels)) { + for (BasicdataPriceGeneralV2Excel generalExcel : generalExcels) { + if (!ObjectUtil.isAllEmpty(generalExcel.getClient(), generalExcel.getBrand(), generalExcel.getSendOrg())) { + if (StrUtil.isNotEmpty(generalExcel.getPickupMinCost())) { + // 提货路径 + String pickupKey = buildRoutKeyV2(generalExcel.getClient(), generalExcel.getBrand(), generalExcel.getStartProvince(), generalExcel.getStartCity(), generalExcel.getStartArea(), + generalExcel.getEndProvince(), generalExcel.getEndCity(), generalExcel.getEndArea(), generalExcel.getSendOrg(), "1"); + if (!routeMap.containsKey(pickupKey)) { + routeMap.put(pickupKey, generalExcel.getClient() + "&&&" + generalExcel.getBrand()); + } + } + if (StrUtil.isNotEmpty(generalExcel.getTrunkLineMinCost())) { + // 干线路径 + String trunkLineKey = buildRoutKeyV2(generalExcel.getClient(), generalExcel.getBrand(), generalExcel.getStartProvince(), generalExcel.getStartCity(), generalExcel.getStartArea(), + generalExcel.getEndProvince(), generalExcel.getEndCity(), generalExcel.getEndArea(), generalExcel.getSendOrg(), "2"); + if (!routeMap.containsKey(trunkLineKey)) { + routeMap.put(trunkLineKey, generalExcel.getClient() + "&&&" + generalExcel.getBrand()); + } + } + } + } + } + if (CollUtil.isNotEmpty(fullVehicleExcels)) { + for (BasicdataPriceFullVehicleV2Excel fullVehicleExcel : fullVehicleExcels) { + if (!ObjectUtil.isAllEmpty(fullVehicleExcel.getClient(), fullVehicleExcel.getBrand(), fullVehicleExcel.getSendOrg())) { + if (StrUtil.isNotEmpty(fullVehicleExcel.getPickupPrice())) { + // 提货路径 + String pickupKey = buildRoutKeyV2(fullVehicleExcel.getClient(), fullVehicleExcel.getBrand(), fullVehicleExcel.getStartProvince(), fullVehicleExcel.getStartCity(), fullVehicleExcel.getStartArea(), + fullVehicleExcel.getEndProvince(), fullVehicleExcel.getEndCity(), fullVehicleExcel.getEndArea(), fullVehicleExcel.getSendOrg(), "1"); + if (!routeMap.containsKey(pickupKey)) { + routeMap.put(pickupKey, fullVehicleExcel.getClient() + "&&&" + fullVehicleExcel.getBrand()); + } + } + if (StrUtil.isNotEmpty(fullVehicleExcel.getTrunkLinePrice())) { + // 干线路径 + String trunkLineKey = buildRoutKeyV2(fullVehicleExcel.getClient(), fullVehicleExcel.getBrand(), fullVehicleExcel.getStartProvince(), fullVehicleExcel.getStartCity(), fullVehicleExcel.getStartArea(), + fullVehicleExcel.getEndProvince(), fullVehicleExcel.getEndCity(), fullVehicleExcel.getEndArea(), fullVehicleExcel.getSendOrg(), "2"); + if (!routeMap.containsKey(trunkLineKey)) { + routeMap.put(trunkLineKey, fullVehicleExcel.getClient() + "&&&" + fullVehicleExcel.getBrand()); + } + } + } + } + } + } + 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)) { + if (!ObjectUtil.isAllEmpty(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)) { + if (!ObjectUtil.isAllEmpty(endProvince, endCity)) { key.append(split).append(endProvince).append(split).append(endCity); if (StrUtil.isNotEmpty(endArea)) { key.append(split).append(endArea); @@ -542,8 +777,27 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl priceExcels, List basicExcels, @@ -605,6 +859,58 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl priceExcels, List basicExcels, + List generalExcels, List fullVehicleExcels, + Map templateEntityMap, + Map clientEntityMap, Map brandEntityMap, + Map priceEntityMap, Map categoryEntityMap, + Map provinceMap, Map provinceCityMap, + Map provinceCityAearMap, Map vehicleTypeMap, + Map routeMap, Map clientBrandMap, Map templateMap) { + 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<>(); + // 保存基本信息 + buildPriceEntitiesExcelV2(priceExcels, templateEntityMap, priceEntityMap, priceEntities, templateMap, generalExcels, basicExcels, clientBrandMap); + if (CollUtil.isNotEmpty(priceEntities)) { + this.saveOrUpdateBatch(priceEntities); + } + // 封装保存好的路径 + Map routeEntityMap = new HashMap<>(); + // 保存路径 + buildSaveRouteEntitiesExcelV2(clientEntityMap, priceEntityMap, provinceMap, provinceCityMap, + provinceCityAearMap, routeMap, routeEntities, routeEntityMap, templateMap); + if (CollUtil.isNotEmpty(routeEntities)) { + basicdataPriceRouteService.saveBatch(routeEntities); + } + // 处理 提货干线按品类计费 + buildSaveBasicEntitiesExcelV2(basicExcels, priceEntityMap, categoryEntityMap, basicEntities, templateMap, routeEntityMap, warehouseEntities, dispatchEntities); + if (CollUtil.isNotEmpty(basicEntities)) { + categoryBasicService.saveBatch(basicEntities); + } + // 处理整车费用 + buildSaveFullVehicleEntitiesExcelV2(fullVehicleExcels, priceEntityMap, categoryEntityMap, fullVehicleEntities, templateMap, routeEntityMap, vehicleTypeMap); + if (CollUtil.isNotEmpty(fullVehicleEntities)) { + fullVehicleService.saveBatch(fullVehicleEntities); + } + // 处理一般费用 + buildSaveGeneralEntitiesExcelV2(generalExcels, priceEntityMap, categoryEntityMap, generalEntities, templateMap, routeEntityMap); + if (CollUtil.isNotEmpty(generalEntities)) { + generalService.saveBatch(generalEntities); + } + if (CollUtil.isNotEmpty(priceEntities)) { + this.saveOrUpdateBatch(priceEntities); + } + } + } + private void buildSaveWarehouseEntitiesExcel(List warehouseExcels, Map priceEntityMap, Map categoryEntityMap, List warehouseEntities) { if (CollUtil.isNotEmpty(warehouseExcels)) { for (BasicdataPriceCategoryWarehouseExcel warehouseExcel : warehouseExcels) { @@ -716,6 +1022,61 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl priceExcels, Map templateEntityMap, + Map priceEntityMap, List priceEntities, + Map templateMap, List generalExcels, + List basicExcels, Map clientBrandMap) { + for (BasicdataPriceV2Excel priceExcel : priceExcels) { + BasicdataPriceEntity priceEntity = priceEntityMap.get(priceExcel.getClient() + priceExcel.getBrand()); + if (ObjectUtil.isEmpty(priceEntity)) { + priceEntity = new BasicdataPriceEntity(); + priceEntity.setClientId(clientBrandMap.get(priceExcel.getClient() + priceExcel.getBrand()).getClientId()); + priceEntity.setBrandId(clientBrandMap.get(priceExcel.getClient() + priceExcel.getBrand()).getBrandId()); + priceEntityMap.put(priceExcel.getClient() + priceExcel.getBrand(), priceEntity); + } + BasicdataPriceTemplateEntity templateEntity = templateEntityMap.get(priceExcel.getTemplateName()); + templateMap.put(priceExcel.getClient() + priceExcel.getBrand(), templateEntity); + if (ObjectUtil.isNotEmpty(priceEntity)) { + // 删除数据 + if (ObjectUtil.isNotEmpty(priceEntity.getId())) { + deleteByPriceId(priceEntity.getId()); + } + priceEntity.setMaintenanceStatus(2); + // 设置值 +// setPriceExcelV2(templateEntityMap, priceExcel, priceEntity); + priceEntity.setEffectiveTime(DateUtil.parseDate(priceExcel.getEffectiveTime())); + priceEntity.setExpiryTime(DateUtil.parseDate(priceExcel.getExpiryTime())); + priceEntity.setTemplateId(templateEntity.getId()); + // 是否配置向上判断数 + if (ObjectUtil.equal(templateEntity.getDispatchIsUpwardJudgment(), BooleanZeroOneEnums.YES.getCode())) { + for (BasicdataPriceGeneralV2Excel basicExcel : generalExcels) { + if (ObjectUtil.equal(basicExcel.getClient(), priceExcel.getClient()) + && ObjectUtil.equal(basicExcel.getBrand(), priceExcel.getBrand())) { + if (StrUtil.isNotEmpty(basicExcel.getDispatchUpwardJudgment())) { + priceEntity.setDispatchUpwardJudgmentCost(Convert.toDouble(basicExcel.getDispatchUpwardJudgment())); + } + if (StrUtil.isNotEmpty(basicExcel.getDispatchUpwardJudgmentCost())) { + priceEntity.setDispatchUpwardJudgmentCost(Convert.toDouble(basicExcel.getDispatchUpwardJudgmentCost())); + } + } + } + } + // 是否配置免楼层数 + if (ObjectUtil.equal(templateEntity.getDispatchIsFeeFloor(), BooleanZeroOneEnums.YES.getCode())) { + for (BasicdataPriceCategoryV2Excel basicExcel : basicExcels) { + if (ObjectUtil.equal(basicExcel.getClient(), priceExcel.getClient()) + && ObjectUtil.equal(basicExcel.getBrand(), priceExcel.getBrand())) { + if (StrUtil.isNotEmpty(basicExcel.getDispatchStairsCarryingCharge())) { + priceEntity.setDispatchStairsCarryingCharge(Convert.toInt(basicExcel.getDispatchStairsCarryingCharge())); + } + } + } + } + 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()) { @@ -782,6 +1143,78 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl clientEntityMap, Map priceEntityMap, + Map provinceMap, Map provinceCityMap, Map provinceCityAearMap, + Map routeMap, List routeEntities, + Map routeEntityMap, Map templateMap) { + if (CollUtil.isNotEmpty(routeMap)) { + for (Map.Entry entry : routeMap.entrySet()) { + // 客户编码&&&品牌&&&发货单位编码 || 客户编码&&&品牌&&&发货单位编码&&&发站省市 || 客户编码&&&品牌&&&发货单位编码&&&发站省市&&&发站省市区 + // + &&&1/&&&2 + String key = entry.getKey(); + if (StrUtil.isNotEmpty(key)) { + List regions = StrUtil.split(key, "&&&"); + if (CollUtil.isNotEmpty(regions)) { + String s = regions.get(0) + regions.get(1); + BasicdataPriceTemplateEntity templateEntity = templateMap.get(s); + String sendOrg = regions.get(2); + String serviceType = regions.get(3); + BasicdataPriceEntity priceEntity = priceEntityMap.get(s); + BasicdataPriceRouteEntity routeEntity = new BasicdataPriceRouteEntity(); + routeEntity.setPriceId(priceEntity.getId()); + routeEntity.setServiceType(Convert.toInt(serviceType)); + setSendOrgExcel(clientEntityMap, routeEntity, sendOrg); + // 发货单位-省市 6 + if (regions.size() >= 6) { + setStarProvinceExcel(provinceMap, routeEntity, regions.get(4)); + setStartCityExcel(provinceCityMap, routeEntity, regions.get(4), regions.get(5)); + } + // 发货单位-省市区 7 + if (ObjectUtil.equal(regions.size(), 7)) { + setStartCountExcel(provinceCityAearMap, routeEntity, regions.get(4), regions.get(5), regions.get(6)); + } + // 发货单位-省市-省市 8 + if (ObjectUtil.equal(regions.size(), 8)) { + setEndProvinceExcel(provinceMap, routeEntity, regions.get(6)); + setEndCityExcel(provinceCityMap, routeEntity, regions.get(6) + regions.get(7)); + } + // 发货单位-省市区-省市区 10 + if (ObjectUtil.equal(regions.size(), 10)) { + setStartCountExcel(provinceCityAearMap, routeEntity, regions.get(4), regions.get(5), regions.get(6)); + setEndProvinceExcel(provinceMap, routeEntity, regions.get(7)); + setEndCityExcel(provinceCityMap, routeEntity, regions.get(7) + regions.get(8)); + setEndCountExcel(provinceCityAearMap, routeEntity, regions.get(7), regions.get(8), regions.get(9)); + } + // 发货单位-省市区-省市 9 + if (ObjectUtil.equal(regions.size(), 9)) { + // 如果 s3s4s5 是省市区 则说明 s5 是区 + if (provinceCityAearMap.containsKey(regions.get(4) + regions.get(5) + regions.get(6))) { + setStartCountExcel(provinceCityAearMap, routeEntity, regions.get(4), regions.get(5), regions.get(6)); + setEndProvinceExcel(provinceMap, routeEntity, regions.get(7)); + setEndCityExcel(provinceCityMap, routeEntity, regions.get(7) + regions.get(8)); + } else { + // 发货单位-省市-省市区 9 + 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)); + } + } + // 根据模板确定是否创建路径 + if (ObjectUtil.isNotEmpty(templateEntity)) { + if (StrUtil.contains(templateEntity.getServiceType(), "1") && ObjectUtil.equal(templateEntity.getPickupIsUnifyAreaBill(), 0)) { + routeEntityMap.put(key, routeEntity); + routeEntities.add(routeEntity); + } else if (StrUtil.contains(templateEntity.getServiceType(), "2") && ObjectUtil.equal(templateEntity.getTrunklineIsUnifyAreaBill(), 0)) { + routeEntityMap.put(key, routeEntity); + routeEntities.add(routeEntity); + } + } + } + } + } + } + } + private void buildSaveFullVehicleEntitiesExcel(List excels, Map priceEntityMap, Map categoryEntityMap, @@ -809,7 +1242,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl excels, + Map priceEntityMap, + Map categoryEntityMap, + List entities, + Map templateMap, + Map routeEntityMap, + Map vehicleTypeMap) { + if (CollUtil.isNotEmpty(excels)) { + for (BasicdataPriceFullVehicleV2Excel excel : excels) { + BasicdataPriceEntity priceEntity = priceEntityMap.get(excel.getClient() + excel.getBrand()); + if (ObjectUtil.isEmpty(priceEntity)) { + log.error("导入价格体系在系统中不存在:{}_{}", excel.getClient(), excel.getBrand()); + continue; + } + BasicdataPriceTemplateEntity templateEntity = templateMap.get(excel.getClient() + excel.getBrand()); + // 是否按区域计费 + Integer pickupIsUnifyAreaBill = templateEntity.getPickupIsUnifyAreaBill(); + Integer trunklineIsUnifyAreaBill = templateEntity.getTrunklineIsUnifyAreaBill(); + String pickupPrice = excel.getPickupPrice(); + String trunkLinePrice = excel.getTrunkLinePrice(); + String dispatchPrice = excel.getDispatchPrice(); + if (StrUtil.isNotEmpty(pickupPrice)) { + BasicdataPriceFullVehicleEntity entity = new BasicdataPriceFullVehicleEntity(); + if (ObjectUtil.isNotEmpty(pickupIsUnifyAreaBill) && ObjectUtil.equal(pickupIsUnifyAreaBill, BooleanZeroOneEnums.NO.getCode())) { + if (!ObjectUtil.isAllEmpty(excel.getClient(), excel.getBrand(), excel.getSendOrg())) { + String key = buildRoutKeyV2(excel.getClient(), excel.getBrand(), excel.getStartProvince(), excel.getStartCity(), + excel.getStartArea(), excel.getEndProvince(), excel.getEndCity(), excel.getEndArea(), excel.getSendOrg(), "1"); + BasicdataPriceRouteEntity routeEntity = routeEntityMap.get(key); + 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()); + // 类型 + entity.setType(FullVehicleTypeEnums.PICK_UP.getCode()); + // 车型 + if (ObjectUtil.isNotEmpty(excel.getVehicleType())) { + String vehicleType = vehicleTypeMap.get(excel.getVehicleType()); + if (StrUtil.isNotEmpty(vehicleType)) { + entity.setVehicleType(Convert.toInt(vehicleType)); + } + } + // 价格 + entity.setPrice(Convert.toDouble(pickupPrice)); + entities.add(entity); + } + if (StrUtil.isNotEmpty(trunkLinePrice)) { + BasicdataPriceFullVehicleEntity entity = new BasicdataPriceFullVehicleEntity(); + if (ObjectUtil.isNotEmpty(trunklineIsUnifyAreaBill) && ObjectUtil.equal(trunklineIsUnifyAreaBill, BooleanZeroOneEnums.NO.getCode())) { + if (!ObjectUtil.isAllEmpty(excel.getClient(), excel.getBrand(), excel.getSendOrg())) { + String key = buildRoutKeyV2(excel.getClient(), excel.getBrand(), excel.getStartProvince(), excel.getStartCity(), + excel.getStartArea(), excel.getEndProvince(), excel.getEndCity(), excel.getEndArea(), excel.getSendOrg(), "2"); + BasicdataPriceRouteEntity routeEntity = routeEntityMap.get(key); + 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()); + // 类型 + entity.setType(FullVehicleTypeEnums.TRUNK_LINE.getCode()); + // 车型 + if (ObjectUtil.isNotEmpty(excel.getVehicleType())) { + String vehicleType = vehicleTypeMap.get(excel.getVehicleType()); + if (StrUtil.isNotEmpty(vehicleType)) { + entity.setVehicleType(Convert.toInt(vehicleType)); + } + } + // 价格 + entity.setPrice(Convert.toDouble(trunkLinePrice)); + entities.add(entity); + } + if (StrUtil.isNotEmpty(dispatchPrice)) { + BasicdataPriceFullVehicleEntity entity = new BasicdataPriceFullVehicleEntity(); + // 统一计费 + entity.setBoId(priceEntity.getId()); + entity.setPriceId(priceEntity.getId()); + // 类型 + entity.setType(FullVehicleTypeEnums.DISPATCH.getCode()); + // 车型 + if (ObjectUtil.isNotEmpty(excel.getVehicleType())) { + String vehicleType = vehicleTypeMap.get(excel.getVehicleType()); + if (StrUtil.isNotEmpty(vehicleType)) { + entity.setVehicleType(Convert.toInt(vehicleType)); + } + } + // 价格 + entity.setPrice(Convert.toDouble(dispatchPrice)); + 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) { @@ -871,7 +1415,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl 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()); + private void buildSaveGeneralEntitiesExcelV2(List excels, Map priceEntityMap, + Map categoryEntityMap, List entities, + Map templateMap, Map routeEntityMap) { + if (CollUtil.isNotEmpty(excels)) { + for (BasicdataPriceGeneralV2Excel basicExcel : excels) { + BasicdataPriceEntity priceEntity = priceEntityMap.get(basicExcel.getClient() + basicExcel.getBrand()); if (ObjectUtil.isEmpty(priceEntity)) { log.error("导入价格体系在系统中不存在"); continue; } - BasicdataPriceTemplateEntity templateEntity = templateMap.get(basicExcel.getClientCode() + basicExcel.getBrand()); + BasicdataPriceTemplateEntity templateEntity = templateMap.get(basicExcel.getClient() + basicExcel.getBrand()); - Integer unifyAreaBill = null; - String type = basicExcel.getType(); - BasicdataPriceCategoryBasicEntity basicEntity = new BasicdataPriceCategoryBasicEntity(); // 是否按区域计费 - if (ObjectUtil.equal(type, ServiceTypeEnums.PICK_UP.getText())) { + Integer pickupIsUnifyAreaBill = templateEntity.getPickupIsUnifyAreaBill(); + Integer trunklineIsUnifyAreaBill = templateEntity.getTrunklineIsUnifyAreaBill(); + String pickupMinCost = basicExcel.getPickupMinCost(); + String trunkLineMinCost = basicExcel.getTrunkLineMinCost(); + String dispatchMinCost = basicExcel.getDispatchMinCost(); + String dispatchLeaveBehindMinCost = basicExcel.getDispatchLeaveBehindMinCost(); + if (StrUtil.isNotEmpty(pickupMinCost)) { // 服务类型 - basicEntity.setServiceType(ServiceTypeEnums.PICK_UP.getCode()); - unifyAreaBill = templateEntity.getPickupIsUnifyAreaBill(); - } else { + BasicdataPriceGeneralEntity basicEntity = new BasicdataPriceGeneralEntity(); + basicEntity.setServiceType(GeneralServiceTypeEnums.PICK_UP.getCode()); + // 按区域计费 + if (ObjectUtil.isNotEmpty(pickupIsUnifyAreaBill) && ObjectUtil.equal(pickupIsUnifyAreaBill, BooleanZeroOneEnums.NO.getCode())) { + if (!ObjectUtil.isAllEmpty(basicExcel.getClient(), basicExcel.getBrand(), basicExcel.getSendOrg())) { + String key = buildRoutKeyV2(basicExcel.getClient(), basicExcel.getBrand(), basicExcel.getStartProvince(), basicExcel.getStartCity(), + basicExcel.getStartArea(), basicExcel.getEndProvince(), basicExcel.getEndCity(), basicExcel.getEndArea(), basicExcel.getSendOrg(), "1"); + BasicdataPriceRouteEntity routeEntity = routeEntityMap.get(key); + 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()); + // 最低计费 + basicEntity.setMinCost(Convert.toDouble(pickupMinCost)); + // 加算价格 + if (StrUtil.isNotEmpty(basicExcel.getPickupAddCost())) { + basicEntity.setAdditionalCost(Convert.toDouble(basicExcel.getPickupAddCost())); + } + entities.add(basicEntity); + } + if (StrUtil.isNotEmpty(trunkLineMinCost)) { + // 服务类型 + BasicdataPriceGeneralEntity basicEntity = new BasicdataPriceGeneralEntity(); + basicEntity.setServiceType(GeneralServiceTypeEnums.TRUNK_LINE.getCode()); + // 按区域计费 + if (ObjectUtil.isNotEmpty(trunklineIsUnifyAreaBill) && ObjectUtil.equal(trunklineIsUnifyAreaBill, BooleanZeroOneEnums.NO.getCode())) { + if (!ObjectUtil.isAllEmpty(basicExcel.getClient(), basicExcel.getBrand(), basicExcel.getSendOrg())) { + String key = buildRoutKeyV2(basicExcel.getClient(), basicExcel.getBrand(), basicExcel.getStartProvince(), basicExcel.getStartCity(), + basicExcel.getStartArea(), basicExcel.getEndProvince(), basicExcel.getEndCity(), basicExcel.getEndArea(), basicExcel.getSendOrg(), "2"); + BasicdataPriceRouteEntity routeEntity = routeEntityMap.get(key); + 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()); + // 最低计费 + basicEntity.setMinCost(Convert.toDouble(trunkLineMinCost)); + // 加算价格 + if (StrUtil.isNotEmpty(basicExcel.getTrunkLineAddCost())) { + basicEntity.setAdditionalCost(Convert.toDouble(basicExcel.getTrunkLineAddCost())); + } + entities.add(basicEntity); + } + if (StrUtil.isNotEmpty(dispatchMinCost)) { + // 服务类型 + BasicdataPriceGeneralEntity basicEntity = new BasicdataPriceGeneralEntity(); + basicEntity.setServiceType(GeneralServiceTypeEnums.DISPATCH.getCode()); + // 统一计费 + basicEntity.setBoId(priceEntity.getId()); + basicEntity.setPriceId(priceEntity.getId()); + // 最低计费 + basicEntity.setMinCost(Convert.toDouble(dispatchMinCost)); + // 加算价格 + if (StrUtil.isNotEmpty(basicExcel.getDispatchAddCost())) { + basicEntity.setAdditionalCost(Convert.toDouble(basicExcel.getDispatchAddCost())); + } + entities.add(basicEntity); + } + if (StrUtil.isNotEmpty(dispatchLeaveBehindMinCost)) { + // 服务类型 + BasicdataPriceGeneralEntity basicEntity = new BasicdataPriceGeneralEntity(); + basicEntity.setServiceType(GeneralServiceTypeEnums.DISPATCH_LEAVE_BEHIND.getCode()); + // 统一计费 + basicEntity.setBoId(priceEntity.getId()); + basicEntity.setPriceId(priceEntity.getId()); + // 最低计费 + basicEntity.setMinCost(Convert.toDouble(dispatchLeaveBehindMinCost)); + // 加算价格 + if (StrUtil.isNotEmpty(basicExcel.getDispatchLeaveBehindAddCost())) { + basicEntity.setAdditionalCost(Convert.toDouble(basicExcel.getDispatchLeaveBehindAddCost())); + } + entities.add(basicEntity); + } + String dispatchUpwardJudgment = basicExcel.getDispatchUpwardJudgment(); + if (StrUtil.isNotEmpty(dispatchUpwardJudgment)) { + priceEntity.setDispatchUpwardJudgment(Convert.toDouble(dispatchUpwardJudgment)); + } + String dispatchUpwardJudgmentCost = basicExcel.getDispatchUpwardJudgmentCost(); + if (StrUtil.isNotEmpty(dispatchUpwardJudgmentCost)) { + priceEntity.setDispatchUpwardJudgmentCost(Convert.toDouble(dispatchUpwardJudgmentCost)); + } + } + } + } + + 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())) { + if (!ObjectUtil.isAllEmpty(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()); @@ -964,6 +1636,230 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl basicExcels, Map priceEntityMap, + Map categoryEntityMap, List basicEntities, + Map templateMap, Map routeEntityMap, List warehouseEntities, List dispatchEntities) { + if (CollUtil.isNotEmpty(basicExcels)) { + for (BasicdataPriceCategoryV2Excel basicExcel : basicExcels) { + BasicdataPriceEntity priceEntity = priceEntityMap.get(basicExcel.getClient() + basicExcel.getBrand()); + if (ObjectUtil.isEmpty(priceEntity)) { + log.error("导入价格体系在系统中不存在"); + continue; + } + BasicdataPriceTemplateEntity templateEntity = templateMap.get(basicExcel.getClient() + basicExcel.getBrand()); + // 是否按区域计费 + Integer pickupIsUnifyAreaBill = templateEntity.getPickupIsUnifyAreaBill(); + Integer trunklineIsUnifyAreaBill = templateEntity.getTrunklineIsUnifyAreaBill(); + String pickupPrice = basicExcel.getPickupPrice(); + String trunkLinePrice = basicExcel.getTrunkLinePrice(); + if (StrUtil.isNotEmpty(pickupPrice)) { + BasicdataPriceCategoryBasicEntity basicEntity = new BasicdataPriceCategoryBasicEntity(); + // 按区域计费 + if (ObjectUtil.isNotEmpty(pickupIsUnifyAreaBill) && ObjectUtil.equal(pickupIsUnifyAreaBill, BooleanZeroOneEnums.NO.getCode())) { + if (!ObjectUtil.isAllEmpty(basicExcel.getClient(), basicExcel.getBrand(), basicExcel.getSendOrg())) { + String key = buildRoutKeyV2(basicExcel.getClient(), basicExcel.getBrand(), basicExcel.getStartProvince(), + basicExcel.getStartCity(), basicExcel.getStartArea(), basicExcel.getEndProvince(), + basicExcel.getEndCity(), basicExcel.getEndArea(), basicExcel.getSendOrg(), "1"); + BasicdataPriceRouteEntity routeEntity = routeEntityMap.get(key); + 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()); + } + basicEntity.setServiceType(ServiceTypeEnums.PICK_UP.getCode()); + // 计费类型 + if (StrUtil.isNotEmpty(basicExcel.getPickupUnit())) { + basicEntity.setType(IDict.getCodeByText(PickupPricingTypeEnums.class, basicExcel.getPickupUnit())); + } + basicEntity.setPriceId(priceEntity.getId()); + // 品类 + if (StrUtil.isNotEmpty(basicExcel.getCategory())) { + if (ObjectUtil.isNotEmpty(categoryEntityMap.get(basicExcel.getCategory()))) { + basicEntity.setCategoryId(categoryEntityMap.get(basicExcel.getCategory()).getId()); + } + } + // 价格 + basicEntity.setPrice(Convert.toDouble(pickupPrice)); + basicEntities.add(basicEntity); + } + if (StrUtil.isNotEmpty(trunkLinePrice)) { + BasicdataPriceCategoryBasicEntity basicEntity = new BasicdataPriceCategoryBasicEntity(); + // 按区域计费 + if (ObjectUtil.isNotEmpty(trunklineIsUnifyAreaBill) && ObjectUtil.equal(trunklineIsUnifyAreaBill, BooleanZeroOneEnums.NO.getCode())) { + if (!ObjectUtil.isAllEmpty(basicExcel.getClient(), basicExcel.getBrand(), basicExcel.getSendOrg())) { + String key = buildRoutKeyV2(basicExcel.getClient(), basicExcel.getBrand(), basicExcel.getStartProvince(), + basicExcel.getStartCity(), basicExcel.getStartArea(), basicExcel.getEndProvince(), + basicExcel.getEndCity(), basicExcel.getEndArea(), basicExcel.getSendOrg(), "2"); + BasicdataPriceRouteEntity routeEntity = routeEntityMap.get(key); + 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()); + } + basicEntity.setServiceType(ServiceTypeEnums.TRUNK_LINE.getCode()); + // 计费类型 + if (StrUtil.isNotEmpty(basicExcel.getTrunkLineUnit())) { + basicEntity.setType(IDict.getCodeByText(TrunkLinePricingTypeEnums.class, basicExcel.getTrunkLineUnit())); + } + basicEntity.setPriceId(priceEntity.getId()); + // 品类 + if (StrUtil.isNotEmpty(basicExcel.getCategory())) { + if (ObjectUtil.isNotEmpty(categoryEntityMap.get(basicExcel.getCategory()))) { + basicEntity.setCategoryId(categoryEntityMap.get(basicExcel.getCategory()).getId()); + } + } + // 价格 + basicEntity.setPrice(Convert.toDouble(trunkLinePrice)); + basicEntities.add(basicEntity); + } + String withinThirtyPrice = basicExcel.getWithinThirtyPrice(); + String betweenThirtySixtyPrice = basicExcel.getBetweenThirtySixtyPrice(); + String beyondSixtyPrice = basicExcel.getBeyondSixtyPrice(); + String beyondNinetyPrice = basicExcel.getBeyondNinetyPrice(); + if (!ObjectUtil.isAllEmpty(withinThirtyPrice, betweenThirtySixtyPrice, beyondSixtyPrice, beyondNinetyPrice)) { + BasicdataPriceCategoryWarehouseEntity warehouseEntity = new BasicdataPriceCategoryWarehouseEntity(); + if (ObjectUtil.isNotEmpty(priceEntity)) { + warehouseEntity.setPriceId(priceEntity.getId()); + warehouseEntity.setBoId(priceEntity.getId()); + } + if (StrUtil.isNotEmpty(basicExcel.getCategory())) { + BasicdataCategoryEntity basicdataCategoryEntity = categoryEntityMap.get(basicExcel.getCategory()); + if (ObjectUtil.isNotEmpty(basicdataCategoryEntity)) { + warehouseEntity.setCategoryId(basicdataCategoryEntity.getId()); + } + } + warehouseEntity.setCostType(CostTypeEnums.NOMAL.getCode()); + warehouseEntity.setType(Convert.toInt(templateEntity.getDispatchPricingType())); + warehouseEntity.setServiceType(1); + if (StrUtil.isNotEmpty(basicExcel.getWithinThirtyPrice())) { + warehouseEntity.setWithinThirtyPrice(Convert.toDouble(basicExcel.getWithinThirtyPrice())); + } + if (StrUtil.isNotEmpty(basicExcel.getBetweenThirtySixtyPrice())) { + warehouseEntity.setBetweenThirtySixtyPrice(Convert.toDouble(basicExcel.getBetweenThirtySixtyPrice())); + } + if (StrUtil.isNotEmpty(basicExcel.getBeyondSixtyPrice())) { + warehouseEntity.setBeyondSixtyPrice(Convert.toDouble(basicExcel.getBeyondSixtyPrice())); + } + if (StrUtil.isNotEmpty(basicExcel.getBeyondNinetyPrice())) { + warehouseEntity.setBeyondNinetyPrice(Convert.toDouble(basicExcel.getBeyondNinetyPrice())); + } + warehouseEntities.add(warehouseEntity); + } + String warehouseOperatePrice = basicExcel.getWarehouseOperatePrice(); + String warehouseManagementPrice = basicExcel.getWarehouseManagementPrice(); + String warehouseSortPrice = basicExcel.getWarehouseSortPrice(); + if (!ObjectUtil.isAllEmpty(warehouseOperatePrice, warehouseManagementPrice, warehouseSortPrice)) { + BasicdataPriceCategoryWarehouseEntity warehouseEntity = new BasicdataPriceCategoryWarehouseEntity(); + if (ObjectUtil.isNotEmpty(priceEntity)) { + warehouseEntity.setPriceId(priceEntity.getId()); + warehouseEntity.setBoId(priceEntity.getId()); + } + if (StrUtil.isNotEmpty(basicExcel.getCategory())) { + BasicdataCategoryEntity basicdataCategoryEntity = categoryEntityMap.get(basicExcel.getCategory()); + if (ObjectUtil.isNotEmpty(basicdataCategoryEntity)) { + warehouseEntity.setCategoryId(basicdataCategoryEntity.getId()); + } + } + warehouseEntity.setCostType(CostTypeEnums.ADD.getCode()); + warehouseEntity.setType(Convert.toInt(templateEntity.getDispatchPricingType())); + warehouseEntity.setServiceType(1); + if (StrUtil.isNotEmpty(basicExcel.getWarehouseOperatePrice())) { + warehouseEntity.setOperatePrice(Convert.toDouble(basicExcel.getWarehouseOperatePrice())); + } + if (StrUtil.isNotEmpty(basicExcel.getWarehouseManagementPrice())) { + warehouseEntity.setWarehouseManagementPrice(Convert.toDouble(basicExcel.getWarehouseManagementPrice())); + } + if (StrUtil.isNotEmpty(basicExcel.getWarehouseSortPrice())) { + warehouseEntity.setWarehouseSortPrice(Convert.toDouble(basicExcel.getWarehouseSortPrice())); + } + warehouseEntities.add(warehouseEntity); + } + String dispatchPrice = basicExcel.getDispatchPrice(); + if (StrUtil.isNotEmpty(dispatchPrice)) { + BasicdataPriceCategoryDispatchEntity entity = new BasicdataPriceCategoryDispatchEntity(); + if (ObjectUtil.isNotEmpty(priceEntity)) { + entity.setPriceId(priceEntity.getId()); + entity.setBoId(priceEntity.getId()); + } + if (StrUtil.isNotEmpty(basicExcel.getCategory())) { + BasicdataCategoryEntity basicdataCategoryEntity = categoryEntityMap.get(basicExcel.getCategory()); + if (ObjectUtil.isNotEmpty(basicdataCategoryEntity)) { + entity.setCategoryId(basicdataCategoryEntity.getId()); + } + } + entity.setCostType(CostTypeEnums.NOMAL.getCode()); + if (StrUtil.isNotEmpty(basicExcel.getDispatchUnit())) { + entity.setType(IDict.getCodeByText(DispatchPricingTypeEnums.class, basicExcel.getDispatchUnit())); + } + entity.setServiceType(1); + if (StrUtil.isNotEmpty(basicExcel.getDispatchPrice())) { + entity.setPrice(Convert.toDouble(basicExcel.getDispatchPrice())); + } + if (StrUtil.isNotEmpty(basicExcel.getDispatchLeaveBehindPrice())) { + entity.setLeaveBehindPrice(Convert.toDouble(basicExcel.getDispatchLeaveBehindPrice())); + } + dispatchEntities.add(entity); + } + String dispatchSortPrice = basicExcel.getDispatchSortPrice(); + String dispatchHandlingPrice = basicExcel.getDispatchHandlingPrice(); + String dispatchRelocationPrice = basicExcel.getDispatchRelocationPrice(); + String dispatchDeliveryPrice = basicExcel.getDispatchDeliveryPrice(); + if (!ObjectUtil.isAllEmpty(dispatchSortPrice, dispatchHandlingPrice, dispatchRelocationPrice, dispatchDeliveryPrice)) { + BasicdataPriceCategoryDispatchEntity entity = new BasicdataPriceCategoryDispatchEntity(); + if (ObjectUtil.isNotEmpty(priceEntity)) { + entity.setPriceId(priceEntity.getId()); + entity.setBoId(priceEntity.getId()); + } + if (StrUtil.isNotEmpty(basicExcel.getCategory())) { + BasicdataCategoryEntity basicdataCategoryEntity = categoryEntityMap.get(basicExcel.getCategory()); + if (ObjectUtil.isNotEmpty(basicdataCategoryEntity)) { + entity.setCategoryId(basicdataCategoryEntity.getId()); + } + } + entity.setCostType(CostTypeEnums.ADD.getCode()); + if (StrUtil.isNotEmpty(basicExcel.getDispatchUnit())) { + entity.setType(IDict.getCodeByText(DispatchPricingTypeEnums.class, basicExcel.getDispatchUnit())); + } + entity.setServiceType(1); + if (StrUtil.isNotEmpty(basicExcel.getDispatchSortPrice())) { + entity.setSortPrice(Convert.toDouble(basicExcel.getDispatchSortPrice())); + } + if (StrUtil.isNotEmpty(basicExcel.getDispatchHandlingPrice())) { + entity.setHandlingPrice(Convert.toDouble(basicExcel.getDispatchHandlingPrice())); + } + if (StrUtil.isNotEmpty(basicExcel.getDispatchRelocationPrice())) { + entity.setRelocationPrice(Convert.toDouble(basicExcel.getDispatchRelocationPrice())); + } + if (StrUtil.isNotEmpty(basicExcel.getDispatchDeliveryPrice())) { + entity.setUpstairsDeliveryPrice(Convert.toDouble(basicExcel.getDispatchDeliveryPrice())); + } + dispatchEntities.add(entity); + } + String dispatchStairsCarryingCharge = basicExcel.getDispatchStairsCarryingCharge(); + if (StrUtil.isNotEmpty(dispatchStairsCarryingCharge)) { + priceEntity.setDispatchStairsCarryingCharge(Convert.toInt(dispatchStairsCarryingCharge)); + } + + } + } + } + private void setStarProvinceExcel(Map provinceMap, BasicdataPriceRouteEntity routeEntity, String province) { if (StrUtil.isNotEmpty(provinceMap.get(province))) { routeEntity.setStartProvinceId(Convert.toLong(provinceMap.get(province))); @@ -1075,6 +1971,62 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl fullVehicleExcels, Map clientEntityMap, Map priceEntityMap, + Map provinceMap, Map provinceCityMap, + Map provinceCityAearMap, Map vehicleTypeMap, + StringBuilder message, String sheetName, Map clientBrandMap, Map templateMap) { + if (CollUtil.isNotEmpty(fullVehicleExcels)) { + for (int i = 0; i < fullVehicleExcels.size(); i++) { + BasicdataPriceFullVehicleV2Excel excel = fullVehicleExcels.get(i); + StringBuilder rowMessage = new StringBuilder(); + int rowNum = i + 4; + String firstMessage = sheetName + "-第" + rowNum + "行:"; + // 校验客户和品牌 + checkClientAndBrandV2(clientBrandMap, rowMessage, excel.getClient(), 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()); + // 提货干线只要一个是不按区域计费的,就必须要填写路径 + if (ObjectUtil.isAllNotEmpty(excel.getClient(), excel.getBrand())) { + if (templateMap.containsKey(excel.getClient() + excel.getBrand())) { + BasicdataPriceTemplateEntity templateEntity = templateMap.get(excel.getClient() + excel.getBrand()); + if (ObjectUtil.isNotEmpty(templateEntity)) { + Integer pickupIsUnifyAreaBill = templateEntity.getPickupIsUnifyAreaBill(); + Integer trunklineIsUnifyAreaBill = templateEntity.getTrunklineIsUnifyAreaBill(); + if (ObjectUtil.equal(pickupIsUnifyAreaBill, BooleanZeroOneEnums.NO.getCode()) || ObjectUtil.equal(trunklineIsUnifyAreaBill, BooleanZeroOneEnums.NO.getCode())) { + // 路径不能为空 + if (ObjectUtil.isEmpty(excel.getSendOrg())) { + rowMessage.append("模板配置为不按区域计费,路径不能为空,发货单位必填;"); + } + } + } + } + } + // 校验费用 + checkPrice(rowMessage, "【提货-单价】", excel.getPickupPrice()); + checkPrice(rowMessage, "【干线-单价】", excel.getTrunkLinePrice()); + checkPrice(rowMessage, "【配送-单价】", excel.getDispatchPrice()); + // 费用不能都为空 + if (ObjectUtil.isAllEmpty(excel.getPickupPrice(), excel.getTrunkLinePrice(), excel.getDispatchPrice())) { + rowMessage.append("单价不能全部为空,请检查;"); + } + // 校验车型 + 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++) { @@ -1100,6 +2052,56 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl generalExcels, Map clientEntityMap, Map priceEntityMap, Map provinceMap, Map provinceCityMap, Map provinceCityAearMap, StringBuilder message, String sheet5, Map clientBrandMap, Map templateMap) { + if (CollUtil.isNotEmpty(generalExcels)) { + for (int i = 0; i < generalExcels.size(); i++) { + BasicdataPriceGeneralV2Excel excel = generalExcels.get(i); + StringBuilder rowMessage = new StringBuilder(); + int rowNum = i + 3; + String firstMessage = sheet5 + "-第" + rowNum + "行:"; + // 校验客户和品牌 + checkClientAndBrandV2(clientBrandMap, rowMessage, excel.getClient(), 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.getSendOrg()); + if (ObjectUtil.isAllEmpty(excel.getPickupMinCost(), excel.getTrunkLineMinCost(), excel.getDispatchMinCost())) { + rowMessage.append("最低计费不能都为空;"); + } + // 提货干线只要一个是不按区域计费的,就必须要填写路径 + if (ObjectUtil.isAllNotEmpty(excel.getClient(), excel.getBrand())) { + if (templateMap.containsKey(excel.getClient() + excel.getBrand())) { + BasicdataPriceTemplateEntity templateEntity = templateMap.get(excel.getClient() + excel.getBrand()); + if (ObjectUtil.isNotEmpty(templateEntity)) { + Integer pickupIsUnifyAreaBill = templateEntity.getPickupIsUnifyAreaBill(); + Integer trunklineIsUnifyAreaBill = templateEntity.getTrunklineIsUnifyAreaBill(); + if (ObjectUtil.equal(pickupIsUnifyAreaBill, BooleanZeroOneEnums.NO.getCode()) || ObjectUtil.equal(trunklineIsUnifyAreaBill, BooleanZeroOneEnums.NO.getCode())) { + // 路径不能为空 + if (ObjectUtil.isEmpty(excel.getSendOrg())) { + rowMessage.append("模板配置为不按区域计费,路径不能为空,发货单位必填;"); + } + } + } + } + } + // 校验费用 + checkPrice(rowMessage, "【提货-最低计费】", excel.getPickupMinCost()); + checkPrice(rowMessage, "【提货-加算价格】", excel.getPickupAddCost()); + checkPrice(rowMessage, "【干线-最低计费】", excel.getTrunkLineMinCost()); + checkPrice(rowMessage, "【干线-加算价格】", excel.getTrunkLineAddCost()); + checkPrice(rowMessage, "【配送-最低计费】", excel.getDispatchMinCost()); + checkPrice(rowMessage, "【配送-加算价格】", excel.getDispatchAddCost()); + checkPrice(rowMessage, "【配送-向上判断件数】", excel.getDispatchUpwardJudgment()); + checkPrice(rowMessage, "【配送-向上判断加价】", excel.getDispatchUpwardJudgmentCost()); + checkPrice(rowMessage, "【配送-遗留最低计费】", excel.getDispatchLeaveBehindMinCost()); + checkPrice(rowMessage, "【配送-遗留加算价格】", excel.getDispatchLeaveBehindAddCost()); + buildErrorMessageExcel(message, rowMessage, firstMessage); + } + } + } + private void checkDispatchExcels(List excels, Map clientEntityMap, Map priceEntityMap, Map categoryEntityMap, StringBuilder message, String sheetName) { if (CollUtil.isNotEmpty(excels)) { // 校验sheet2的数据 @@ -1229,6 +2231,73 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl clientEntityMap, + Map priceEntityMap, List basicExcels, + Map categoryEntityMap, Map provinceMap, + Map provinceCityMap, Map provinceCityAearMap, + Map clientBrandMap, Map templateMap) { + if (CollUtil.isNotEmpty(basicExcels)) { + // 校验sheet2的数据 + for (int i = 0; i < basicExcels.size(); i++) { + BasicdataPriceCategoryV2Excel basicExcel = basicExcels.get(i); + StringBuilder rowMessage = new StringBuilder(); + int rowNum = i + 5; + String firstMessage = sheetName + "-第" + rowNum + "行:"; + // 校验客户和品牌 + checkClientAndBrandV2(clientBrandMap, rowMessage, basicExcel.getClient(), basicExcel.getBrand()); + // 校验单位 + checkEnumsExcel(rowMessage, basicExcel.getPickupUnit(), "【提货-单位】", PickupPricingTypeEnums.class); + checkEnumsExcel(rowMessage, basicExcel.getTrunkLineUnit(), "【干线-单位】", PickupPricingTypeEnums.class); + checkEnumsExcel(rowMessage, basicExcel.getDispatchUnit(), "【配送-单位】", PickupPricingTypeEnums.class); + + // 发站 + 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.getSendOrg()); + // 品类 + checkCategoryExcel(categoryEntityMap, rowMessage, basicExcel.getCategory()); + // 提货干线只要一个是不按区域计费的,就必须要填写路径 + if (ObjectUtil.isAllNotEmpty(basicExcel.getClient(), basicExcel.getBrand())) { + if (templateMap.containsKey(basicExcel.getClient() + basicExcel.getBrand())) { + BasicdataPriceTemplateEntity templateEntity = templateMap.get(basicExcel.getClient() + basicExcel.getBrand()); + if (ObjectUtil.isNotEmpty(templateEntity)) { + Integer pickupIsUnifyAreaBill = templateEntity.getPickupIsUnifyAreaBill(); + Integer trunklineIsUnifyAreaBill = templateEntity.getTrunklineIsUnifyAreaBill(); + if (ObjectUtil.equal(pickupIsUnifyAreaBill, BooleanZeroOneEnums.NO.getCode()) || ObjectUtil.equal(trunklineIsUnifyAreaBill, BooleanZeroOneEnums.NO.getCode())) { + // 路径不能为空 + if (ObjectUtil.isEmpty(basicExcel.getSendOrg())) { + rowMessage.append("模板配置为不按区域计费,路径不能为空,发货单位必填;"); + } + } + } + } + } + // 校验价格,不能为空,只能是数字 + checkPrice(rowMessage, "【提货-单价】只能为数字", basicExcel.getPickupPrice()); + checkPrice(rowMessage, "【干线-单价】只能为数字", basicExcel.getTrunkLinePrice()); + checkPrice(rowMessage, "【仓储-30天内】只能为数字", basicExcel.getWithinThirtyPrice()); + checkPrice(rowMessage, "【仓储-30-60天】只能为数字", basicExcel.getBetweenThirtySixtyPrice()); + checkPrice(rowMessage, "【仓储-60-90天】只能为数字", basicExcel.getBeyondSixtyPrice()); + checkPrice(rowMessage, "【仓储-90天以上】只能为数字", basicExcel.getBeyondNinetyPrice()); + checkPrice(rowMessage, "【仓储附加费-仓储操作/装卸费】只能为数字", basicExcel.getWarehouseOperatePrice()); + checkPrice(rowMessage, "【仓储附加费-仓储管理费】只能为数字", basicExcel.getWarehouseManagementPrice()); + checkPrice(rowMessage, "【仓储附加费-仓储分货费】只能为数字", basicExcel.getWarehouseSortPrice()); + checkPrice(rowMessage, "【配送-一般单价】只能为数字", basicExcel.getDispatchPrice()); + checkPrice(rowMessage, "【配送-遗留单价】只能为数字", basicExcel.getDispatchLeaveBehindPrice()); + checkPrice(rowMessage, "【配送附加费-分货费】只能为数字", basicExcel.getDispatchSortPrice()); + checkPrice(rowMessage, "【配送附加费-操作/装卸费价格】只能为数字", basicExcel.getDispatchHandlingPrice()); + checkPrice(rowMessage, "【配送附加费-平移费价格】只能为数字", basicExcel.getDispatchRelocationPrice()); + checkPrice(rowMessage, "【配送附加费-上楼费价格】只能为数字", basicExcel.getDispatchDeliveryPrice()); + checkPrice(rowMessage, "【配送附加费-上楼免楼层数】只能为数字", basicExcel.getDispatchStairsCarryingCharge()); + buildErrorMessageExcel(message, rowMessage, firstMessage); + } + } + } + private void buildErrorMessageExcel(StringBuilder message, StringBuilder rowMessage, String firstMessage) { if (StrUtil.isNotEmpty(rowMessage.toString())) { message.append("

"); @@ -1260,7 +2329,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl clientEntityMap, StringBuilder rowMessage, String sendOrg) { if (StrUtil.isNotEmpty(sendOrg)) { if (!clientEntityMap.containsKey(sendOrg)) { - rowMessage.append("发货单位编码不存在;"); + rowMessage.append("发货单位不存在;"); } } } @@ -1287,15 +2356,30 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl priceEntityMap, StringBuilder rowMessage, String client, String brand) { if (StrUtil.isEmpty(client)) { - rowMessage.append("客户编码不能为空;"); + rowMessage.append("客户名称不能为空;"); + } + if (StrUtil.isEmpty(brand)) { + rowMessage.append("品牌不能为空;"); + } + // 客户+品牌必须在sheet1中存在 + if (!ObjectUtil.isAllEmpty(client, brand)) { + if (!priceEntityMap.containsKey(client + brand)) { + rowMessage.append("客户名称+品牌名称不存在;"); + } + } + } + + private void checkClientAndBrandV2(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 (!ObjectUtil.isAllEmpty(client, brand)) { if (!priceEntityMap.containsKey(client + brand)) { - rowMessage.append("客户编码+品牌名称不存在;"); + rowMessage.append("客户名称+品牌名称不存在;"); } } } @@ -1361,6 +2445,27 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl basicExcels, + Map categoryEntityMap) { + Set categorySet = new HashSet<>(); + if (CollUtil.isNotEmpty(basicExcels)) { + for (BasicdataPriceCategoryV2Excel basicExcel : basicExcels) { + if (StrUtil.isNotEmpty(basicExcel.getCategory())) { + categorySet.add(basicExcel.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<>(); @@ -1427,7 +2532,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl priceExcels, List basicExcels, + List generalExcels, List fullVehicleExcels, + Map templateEntityMap, Map clientEntityMap, + Map brandEntityMap, Map priceEntityMap, + Map clientBrandMap, Map> checkPriceMap, + Map templateMap) { + 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.getClient())) { + clientSet.add(priceExcel.getClient()); + } + if (StrUtil.isNotEmpty(priceExcel.getBrand())) { + brandSet.add(priceExcel.getBrand()); + } + }); + if (CollUtil.isNotEmpty(basicExcels)) { + for (BasicdataPriceCategoryV2Excel basicExcel : basicExcels) { + if (StrUtil.isNotEmpty(basicExcel.getSendOrg())) { + clientSet.add(basicExcel.getSendOrg()); + } + } + } + if (CollUtil.isNotEmpty(generalExcels)) { + for (BasicdataPriceGeneralV2Excel generalExcel : generalExcels) { + if (StrUtil.isNotEmpty(generalExcel.getSendOrg())) { + clientSet.add(generalExcel.getSendOrg()); + } + } + } + if (CollUtil.isNotEmpty(fullVehicleExcels)) { + for (BasicdataPriceFullVehicleV2Excel fullVehicleExcel : fullVehicleExcels) { + if (StrUtil.isNotEmpty(fullVehicleExcel.getSendOrg())) { + clientSet.add(fullVehicleExcel.getSendOrg()); + } + } + } + // 先校验数据完整性 + 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); + }); + } + + priceExcels.forEach(priceExcel -> { + if (ObjectUtil.isAllNotEmpty(priceExcel.getClient(), priceExcel.getBrand(), priceExcel.getTemplateName())) { + if (templateEntityMap.containsKey(priceExcel.getTemplateName())) { + templateMap.put(priceExcel.getClient() + priceExcel.getBrand(), templateEntityMap.get(priceExcel.getTemplateName())); + } + } + }); + + Map clientMap = new HashMap<>(); + if (CollUtil.isNotEmpty(clientSet)) { + LambdaQueryWrapper clientWrapper = Wrappers.lambdaQuery().in(BasicdataClientEntity::getClientName, clientSet); + List clientEntities = clientService.list(clientWrapper); + // 将clientEntities中的数据放到map中 + clientEntities.forEach(clientEntity -> { + clientEntityMap.put(clientEntity.getClientName(), clientEntity); + clientMap.put(clientEntity.getId().toString(), clientEntity.getClientName()); + }); + } + Map brandMap = new HashMap<>(); + 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); + brandMap.put(brandEntity.getId().toString(), brandEntity.getBrandName()); + }); + } + + + Boolean flag = Boolean.FALSE; + for (BasicdataPriceV2Excel priceExcel : priceExcels) { + if (!ObjectUtil.isAllEmpty(priceExcel.getClient(), priceExcel.getBrand())) { + flag = Boolean.TRUE; + break; + } + } + if (flag) { + // 封装客户和品牌的关系 + if (!ObjectUtil.isAllEmpty(clientEntityMap, brandEntityMap)) { + List list = storeBrandService.list(Wrappers.lambdaQuery() + .in(BasicdataStoreBrandEntity::getClientId, clientEntityMap.values().stream().map(BasicdataClientEntity::getId).collect(Collectors.toList())) + .in(BasicdataStoreBrandEntity::getBrandId, brandEntityMap.values().stream().map(BasicdataBrandEntity::getId).collect(Collectors.toList())) + .eq(BasicdataStoreBrandEntity::getIsDeleted, 0) + ); + if (CollUtil.isNotEmpty(list)) { + list.forEach(storeBrandEntity -> { + clientBrandMap.put(clientMap.get(storeBrandEntity.getClientId().toString()) + brandMap.get(storeBrandEntity.getBrandId().toString()), storeBrandEntity); + }); + } + List priceEntities = this.list(Wrappers.lambdaQuery() + .in(BasicdataPriceEntity::getClientId, clientEntityMap.values().stream().map(BasicdataClientEntity::getId).collect(Collectors.toList())) + .in(BasicdataPriceEntity::getBrandId, brandEntityMap.values().stream().map(BasicdataBrandEntity::getId).collect(Collectors.toList())) + ); + if (CollUtil.isNotEmpty(priceEntities)) { + // 分组存入map中 + priceEntities.forEach(priceEntity -> { + checkPriceMap.computeIfAbsent(clientMap.get(priceEntity.getClientId().toString()) + brandMap.get(priceEntity.getBrandId().toString()), k -> new ArrayList<>()); + checkPriceMap.get(clientMap.get(priceEntity.getClientId().toString()) + brandMap.get(priceEntity.getBrandId().toString())).add(priceEntity); + }); + } + } +// List priceEntities = this.baseMapper.findEntityByClientAndBrandV2(priceExcels); +// if (CollUtil.isNotEmpty(priceEntities)) { +// priceEntities.forEach(priceEntity -> { +// priceEntityMap.put(priceEntity.getClientName() + priceEntity.getBrandName(), priceEntity); +// }); +// } + } } private void checkPriceData(StringBuilder message, List priceExcels, String sheet1, Map templateEntityMap, Map clientEntityMap, Map brandEntityMap, Map priceEntityMap) { @@ -1483,7 +2711,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl priceExcels, String sheet1, + Map templateEntityMap, Map clientEntityMap, + Map brandEntityMap, Map priceEntityMap, + Map clientBrandMap, Map> checkPriceEntityMap) { + if (CollUtil.isNotEmpty(priceExcels)) { + for (int i = 0; i < priceExcels.size(); i++) { + StringBuilder rowMessage = new StringBuilder(); + int rowNum = i + 2; + String firstMessage = sheet1 + "-第" + rowNum + "行:"; + BasicdataPriceV2Excel priceExcel = priceExcels.get(i); + // 校验必填项 + Boolean clientFlag = Boolean.FALSE; + if (StrUtil.isEmpty(priceExcel.getClient())) { + rowMessage.append("客户名称不能为空;"); + } else { + if (!clientEntityMap.containsKey(priceExcel.getClient())) { + rowMessage.append("客户名称[").append(priceExcel.getClient()).append("]在系统中不存在;"); + } else { + clientFlag = Boolean.TRUE; + } + } + 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.isAllEmpty(priceExcel.getClient(), priceExcel.getBrand())) { + if (!clientBrandMap.containsKey(priceExcel.getClient() + priceExcel.getBrand())) { + rowMessage.append("客户名称[").append(priceExcel.getClient()).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.isAllEmpty(startTime, endTime)) { + // 校验时间大小关系 + if (startTime.isAfter(endTime)) { + rowMessage.append("生效时间不能大于到期时间;"); + } else { + // 校验时间是否合法 + // 1 输入的截至时间不能小于当前时间 + if (endTime.isBefore(DateUtil.beginOfDay(DateUtil.date()))) { + rowMessage.append("到期时间不能小于当前时间;"); + } + // 2 当前输入的时间范围不能跨越2个已有的价格体系 + if (clientFlag && brandFlag) { + int dataFlag = 0; + List priceEntities = checkPriceEntityMap.get(priceExcel.getClient() + priceExcel.getBrand()); + if (CollUtil.isNotEmpty(priceEntities)) { + Date start1 = startTime; + Date end1 = endTime; + for (BasicdataPriceEntity priceEntity : priceEntities) { + Date start2 = priceEntity.getEffectiveTime(); + Date end2 = priceEntity.getExpiryTime(); + if (start1.after(priceEntity.getEffectiveTime())) { + // 交换 interval1 的开始和结束时间 + Date temp = start1; + start1 = start2; + start2 = temp; + temp = end1; + end1 = end2; + end2 = temp; + } + // 计算交集 + if (!end1.before(start2)) { + // 如果有交集 + dataFlag += 1; + // 把存在交集的价格体系放到内存中供后续使用 + if (!ObjectUtil.isAllEmpty(priceExcel.getClient(), priceExcel.getBrand())) { + priceEntityMap.put(priceExcel.getClient() + priceExcel.getBrand(), priceEntity); + } + } + + } + } + if (dataFlag > 1) { + rowMessage.append("生效时间与截至时间范围在系统中存在多个价格体系,请确认;"); + } + } + } + } + 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)) { diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceTemplateServiceImpl.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceTemplateServiceImpl.java index 04c83fe80..ac0a05ab4 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceTemplateServiceImpl.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceTemplateServiceImpl.java @@ -22,6 +22,7 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.logpm.basicdata.entity.BasicdataPriceTemplateEntity; import com.logpm.basicdata.enums.DispatchTypeEnums; import com.logpm.basicdata.enums.MinCostTypeEnums; @@ -203,11 +204,21 @@ public class BasicdataPriceTemplateServiceImpl extends BaseServiceImpllambdaQuery() + .eq(BasicdataPriceTemplateEntity::getName, name) + .last("limit 1") + ); + if (ObjectUtil.isNotEmpty(one)) { + throw new ServiceException("模版名称重复,请检查"); + } + } + @Override public BasicdataPriceTemplateVO detail(Long id) { BasicdataPriceTemplateEntity detail = this.getById(id); @@ -226,9 +237,10 @@ public class BasicdataPriceTemplateServiceImpl extends BaseServiceImpl getDistributionSignforInventoryList(@Param("id")Long id); + + /** + * + * @param reservationId + * @param stockArticleId + * @param parceListId + */ + Integer cancelOld(@Param("reservationId") Long reservationId,@Param("stockArticleId") Long stockArticleId,@Param("packageId") Long parceListId); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionSignforMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionSignforMapper.xml index 425083738..d8d39150e 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionSignforMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionSignforMapper.xml @@ -83,6 +83,17 @@ + + UPDATE logpm_distribution_reservation_package SET packet_bar_status = 2 ,cancel_remark = '异常审核取消原计划' WHERE parce_list_id = #{packageId} ; + + UPDATE logpm_distribution_reservation_stockarticle SET reservation_num = (SELECT count(id) FROM logpm_distribution_reservation_package WHERE packet_bar_status != 2 AND reservation_id = #{reservationId} AND stock_article_id = #{stockArticleId} AND is_deleted = 0) WHERE reservation_id = #{reservationId} AND stock_article_id = #{stockArticleId}; + + UPDATE logpm_distribution_reservation_stockarticle SET stock_article_status = 2 WHERE reservation_num = 0 AND reservation_id = #{reservationId} AND stock_article_id = #{stockArticleId}; + + UPDATE logpm_distribution_reservation SET reservation_num = (SELECT count(id) FROM logpm_distribution_reservation_package WHERE packet_bar_status != 2 AND reservation_id = #{reservationId} AND is_deleted =0 ) WHERE id = #{reservationId}; + + UPDATE logpm_distribution_reservation SET reservation_status = '40',cancel_reason = '异常审核判定判定取消预约计划' WHERE id = #{reservationId} AND (reservation_num + reservation_stock_list_num) = 0; + diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java index 99d77bc5d..2b66f1da6 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java @@ -4274,11 +4274,17 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImplupdate().lambda() + .eq(DistributionStockupInfoEntity::getReservationId,reservationEntity.getId()) + .set(DistributionStockupInfoEntity::getStockStatus,"4") + ); }); //修改备货信息 String kind = deliveryListEntity.getKind(); diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java index 640e01669..9f7bd538a 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java @@ -5454,6 +5454,23 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl packageIds = distributionLoadscanAbnormalEntities.stream().filter(f->LoadingAbnormalAuditingStatusConstant.daishenhe.getValue().equals(f.getAuditingStatus())).map(DistributionLoadscanAbnormalEntity::getPackageId).distinct().collect(Collectors.toList()); + + //查询审核的是否存在计划 + List packageEntityList = distributionReservationPackageService.list(Wrappers.query().lambda() + .in(DistributionReservationPackageEntity::getParceListId, packageIds) + .ne(DistributionReservationPackageEntity::getPacketBarStatus, ReservationPackageStatusConstant.quxiao.getValue()) + ); + if (!packageEntityList.isEmpty()) { + //找出审核的包件中存在计划的包件 + for (DistributionReservationPackageEntity distributionReservationPackageEntity : packageEntityList) { + log.info("异常审核取消原计划包件"); + log.info("异常审核取消原计划包件参数>>>>>>>>>reservationId:{},orderId:{},packageId:{}",distributionReservationPackageEntity.getReservationId(),distributionReservationPackageEntity.getStockArticleId(),distributionReservationPackageEntity.getParceListId()); + Integer a = baseMapper.cancelOld(distributionReservationPackageEntity.getReservationId(),distributionReservationPackageEntity.getStockArticleId(),distributionReservationPackageEntity.getParceListId()); + log.info("异常审核取消原计划包件执行条数row:{}",a); + } + } + List reservationId = distributionLoadscanAbnormalEntities.stream().distinct().map(DistributionLoadscanAbnormalEntity::getReservationId).collect(Collectors.toList()); if (distributionLoadscanAbnormalEntities.size() == 1) { DistributionLoadscanAbnormalEntity distributionLoadscanAbnormalEntity = distributionLoadscanAbnormalEntities.get(0); diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mq/AdvanceOrderListener.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mq/AdvanceOrderListener.java index 61a2b8a7b..234c08ff6 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mq/AdvanceOrderListener.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mq/AdvanceOrderListener.java @@ -89,7 +89,7 @@ public class AdvanceOrderListener { JSONObject jsonObject = JSONUtil.parseObj(detail); TrunklineAdvanceDetailEntity entity = JSONUtil.toBean(jsonObject, TrunklineAdvanceDetailEntity.class); // 检查转换后的实体不为null,且其orderPackageCode非null - if (!ObjectUtil.hasEmpty(entity, entity.getOrderPackageCode())) { + if (!ObjectUtil.isAllEmpty(entity, entity.getOrderPackageCode())) { orderPackageCodes.add(entity.getOrderPackageCode()); } } catch (Exception e) {