diff --git a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/entity/BasicdataClientEntity.java b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/entity/BasicdataClientEntity.java index 6f13a1fc2..ec021bc91 100644 --- a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/entity/BasicdataClientEntity.java +++ b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/entity/BasicdataClientEntity.java @@ -164,16 +164,34 @@ public class BasicdataClientEntity extends TenantEntity { */ @ApiModelProperty(value = "省份") private String bladeRegionProvinceId; + + /** + * 省份 + */ + @ApiModelProperty(value = "省份") + private String bladeRegionProvinceName; /** * 市 */ @ApiModelProperty(value = "市") private String bladeRegionCityId; + + /** + * 市 + */ + @ApiModelProperty(value = "市") + private String bladeRegionCityName; /** * 区/县 */ @ApiModelProperty(value = "区/县") private String bladeRegionAreaId; + + /** + * 区/县 + */ + @ApiModelProperty(value = "区/县") + private String bladeRegionAreaName; /** * 合同附件 */ diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataClientController.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataClientController.java index 7ef3464e2..ee25e414a 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataClientController.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataClientController.java @@ -257,6 +257,30 @@ public class BasicdataClientController extends BladeController { return R.success("操作成功"); } + /** + * 导入数据 + */ + @PostMapping("/newImportBasicDataClient") + @ApiOperationSupport(order = 9) + @ApiOperation(value = "导入数据", notes = "传入basicDataClient") + public R newImportBasicDataClient(MultipartFile file, Integer isCovered) { + isCovered = 1; + BasicDataClienImporter clientImporter = new BasicDataClienImporter(basicdataClientService, isCovered == 1); + ExcelUtil.save(file, clientImporter, BasicdataClientExcel.class); + return R.success("操作成功"); + } + + /** + * 导入模板 + */ + @PostMapping("/exportclientTemplate") + @ApiOperationSupport(order = 9) + @ApiOperation(value = "导入数据", notes = "传入basicDataClient") + public void exportclientTemplate(HttpServletResponse response) { + List list = basicdataClientService.exportclientTemplate(); + ExcelUtil.export(response, "基础客户导入模板" + DateUtil.time(), "基础客户导入模板", list, BasicdataClientExcel.class); + } + /** * 校验导入数据 diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataTripartiteMallController.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataTripartiteMallController.java index d26bd7339..27edd19f2 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataTripartiteMallController.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataTripartiteMallController.java @@ -21,7 +21,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.logpm.basicdata.entity.BasicdataTripartiteMallEntity; +import com.logpm.basicdata.excel.BasicDataClienImporter; +import com.logpm.basicdata.excel.BasicdataClientExcel; import com.logpm.basicdata.excel.BasicdataTripartiteMallExcel; +import com.logpm.basicdata.excel.BasicdataTripartiteMallImporter; import com.logpm.basicdata.service.IBasicdataTripartiteMallService; import com.logpm.basicdata.vo.BasicdataTripartiteMallVO; import io.swagger.annotations.Api; @@ -37,6 +40,7 @@ import org.springblade.core.tool.api.R; import org.springblade.core.tool.constant.BladeConstant; import org.springblade.core.tool.utils.DateUtil; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import springfox.documentation.annotations.ApiIgnore; import javax.servlet.http.HttpServletResponse; @@ -152,6 +156,32 @@ public class BasicdataTripartiteMallController extends BladeController { } + /** + * 导出数据 + */ + @PostMapping("/exportTripartiteMallTemplate") + @ApiOperationSupport(order = 9) + @ApiOperation(value = "导出数据", notes = "传入basicdataTripartiteMall") + public void exportTripartiteMallTemplate(HttpServletResponse response) { + List list = basicdataTripartiteMallService.exportTripartiteMallTemplate(); + ExcelUtil.export(response, "客户三方商城导入模板" + DateUtil.time(), "客户三方商城数据表", list, BasicdataTripartiteMallExcel.class); + } + + + /** + * 导出数据 + */ + @PostMapping("/importTripartiteMall") + @ApiOperationSupport(order = 9) + @ApiOperation(value = "导出数据", notes = "传入basicdataTripartiteMall") + public R importTripartiteMall(MultipartFile file) { + BasicdataTripartiteMallImporter tripartiteMallImporter = new BasicdataTripartiteMallImporter(basicdataTripartiteMallService ); + ExcelUtil.save(file, tripartiteMallImporter, BasicdataTripartiteMallExcel.class); + return R.success("操作成功"); + } + + + /** * 导出数据 */ diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/BasicdataClientExcel.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/BasicdataClientExcel.java index e8f6e87c6..003b77e2d 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/BasicdataClientExcel.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/BasicdataClientExcel.java @@ -78,19 +78,19 @@ public class BasicdataClientExcel implements Serializable { */ @ColumnWidth(20) @ExcelProperty("省") - private String bladeRegionProvinceId; + private String bladeRegionProvinceName; /** * 市 */ @ColumnWidth(20) @ExcelProperty("市") - private String bladeRegionCityId; + private String bladeRegionCityName; /** * 区/县 */ @ColumnWidth(20) @ExcelProperty("区/县") - private String bladeRegionAreaId; + private String bladeRegionAreaName; /** * 是否控货 */ @@ -128,26 +128,26 @@ public class BasicdataClientExcel implements Serializable { @ColumnWidth(20) @ExcelProperty("品牌") private String brandName; - /** - * 三方商场 - */ - @ColumnWidth(20) - @ExcelProperty("三方商场编码") - private String tripartiteCoding; - - /** - * 三方商场品牌 - */ - @ColumnWidth(20) - @ExcelProperty("三方商场品牌") - private String tripartiteMallBrand; +// /** +// * 三方商场 +// */ +// @ColumnWidth(20) +// @ExcelProperty("三方商场编码") +// private String tripartiteCoding; - /** - * 三方商场 - */ - @ColumnWidth(20) - @ExcelProperty("三方商场名称") - private String tripartiteMall; +// /** +// * 三方商场品牌 +// */ +// @ColumnWidth(20) +// @ExcelProperty("三方商场品牌") +// private String tripartiteMallBrand; +// +// /** +// * 三方商场 +// */ +// @ColumnWidth(20) +// @ExcelProperty("三方商场名称") +// private String tripartiteMall; /** * 配送类型 diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/BasicdataTripartiteMallExcel.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/BasicdataTripartiteMallExcel.java index 8b0d25769..21c818282 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/BasicdataTripartiteMallExcel.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/BasicdataTripartiteMallExcel.java @@ -40,55 +40,15 @@ public class BasicdataTripartiteMallExcel implements Serializable { private static final long serialVersionUID = 1L; + + /** - * 租户号 - */ - @ColumnWidth(20) - @ExcelProperty("租户号") - private String tenantId; - /** - * 是否已删除 - */ - @ColumnWidth(20) - @ExcelProperty("是否已删除") - private Integer isDeleted; - /** - * 预留1 - */ - @ColumnWidth(20) - @ExcelProperty("预留1") - private String reserve1; - /** - * 预留2 - */ - @ColumnWidth(20) - @ExcelProperty("预留2") - private String reserve2; - /** - * 预留3 - */ - @ColumnWidth(20) - @ExcelProperty("预留3") - private String reserve3; - /** - * 预留4 - */ - @ColumnWidth(20) - @ExcelProperty("预留4") - private String reserve4; - /** - * 预留5 - */ - @ColumnWidth(20) - @ExcelProperty("预留5") - private String reserve5; - /** - * 客户ID + * 三方编码 */ @ColumnWidth(20) - @ExcelProperty("客户ID") - private String client; - /** + @ExcelProperty("客户名称") + private String clientName; + /* * 三方商城 */ @ColumnWidth(20) @@ -101,4 +61,13 @@ public class BasicdataTripartiteMallExcel implements Serializable { @ExcelProperty("三方编码") private String tripartiteCoding; + /** + * 三方编码 + */ + @ColumnWidth(20) + @ExcelProperty("品牌") + private String brandName; + + + } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/BasicdataTripartiteMallImporter.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/BasicdataTripartiteMallImporter.java new file mode 100644 index 000000000..07f5f49c3 --- /dev/null +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/BasicdataTripartiteMallImporter.java @@ -0,0 +1,20 @@ +package com.logpm.basicdata.excel; + +import com.logpm.basicdata.service.IBasicdataTripartiteMallService; +import lombok.RequiredArgsConstructor; +import org.springblade.core.excel.support.ExcelImporter; + +import java.util.List; + +@RequiredArgsConstructor +public class BasicdataTripartiteMallImporter implements ExcelImporter { + + private final IBasicdataTripartiteMallService service; + + + + @Override + public void save(List data) { + service.importTripartiteMall(data); + } +} diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataClientService.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataClientService.java index 4d25f445e..3e292a88a 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataClientService.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataClientService.java @@ -134,4 +134,11 @@ public interface IBasicdataClientService extends BaseService listNameLike(String name); + + /** + * 获取客户导入模板 + * @return + */ + List exportclientTemplate(); + } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataTripartiteMallService.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataTripartiteMallService.java index 62c43e7f3..5e5826cb2 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataTripartiteMallService.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataTripartiteMallService.java @@ -86,4 +86,16 @@ public interface IBasicdataTripartiteMallService extends BaseService exportTripartiteMallTemplate(); + + /** + * 三方商城导入 + * @param data + */ + void importTripartiteMall(List data); } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataClientServiceImpl.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataClientServiceImpl.java index 05573fa64..a4931507f 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataClientServiceImpl.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataClientServiceImpl.java @@ -74,6 +74,7 @@ import org.springblade.system.cache.DictBizCache; import org.springblade.system.entity.DictBiz; import org.springblade.system.feign.IRegionFeign; import org.springblade.system.feign.IUserClient; +import org.springblade.system.vo.RegionAllVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -409,14 +410,22 @@ public class BasicdataClientServiceImpl extends BaseServiceImpl[").append(sdf.format(oldClientEntity.getContractStartTime())).append("],"); + if (!Objects.isNull(oldClientEntity.getContractStartTime())){ + content.append("合同开始时间由[").append(sdf.format(oldClientEntity.getContractStartTime())).append("]变更为-->[").append(sdf.format(oldClientEntity.getContractStartTime())).append("],"); + }else { + content.append("添加合同开始时间[").append(sdf.format(newClientEntity.getContractStartTime())).append("],"); + } } } //对于合同结束时间比对 Predicate predicateContractEntTime = Predicate.isEqual(oldClientEntity.getContractEntTime()); boolean contractEndTime = predicateContractEntTime.test(newClientEntity.getContractEntTime()); if (!contractEndTime) { - content.append("合同开始时间由[").append(sdf.format(oldClientEntity.getContractEntTime())).append("]变更为-->[").append(sdf.format(newClientEntity.getContractEntTime())).append("],"); + if (!Objects.isNull(oldClientEntity.getContractEntTime())){ + content.append("合同结束时间由[").append(sdf.format(oldClientEntity.getContractStartTime())).append("]变更为-->[").append(sdf.format(oldClientEntity.getContractStartTime())).append("],"); + }else { + content.append("添加合同结束时间[").append(sdf.format(newClientEntity.getContractStartTime())).append("],"); + } } BasicdataClientLogEntity basicdataClientLogEntity = new BasicdataClientLogEntity(); basicdataClientLogEntity.setClientName(newClientEntity.getClientName()); @@ -444,6 +453,35 @@ public class BasicdataClientServiceImpl extends BaseServiceImpl exportclientTemplate() { + List list = new ArrayList<>(); + BasicdataClientExcel basicdataClientExcel = new BasicdataClientExcel(); + basicdataClientExcel.setClientName("示例:商场A"); + basicdataClientExcel.setTypeService("示例:干线,仓库,配送"); + basicdataClientExcel.setClientType("示例:商配"); + basicdataClientExcel.setDetailedly("示例:XXX省XX市XX区/县"); + basicdataClientExcel.setBladeRegionProvinceName("示例:XX省"); + basicdataClientExcel.setBladeRegionCityName("示例:XX市"); + basicdataClientExcel.setBladeRegionAreaName("示例:XX区/县"); + basicdataClientExcel.setCargoControl("示例:是"); + basicdataClientExcel.setSendWarehouseName("示例:XX仓"); + basicdataClientExcel.setServeWarehouseName("示例:XX仓"); + basicdataClientExcel.setLinkman("示例:张三"); + basicdataClientExcel.setPhone("示例:120********"); + basicdataClientExcel.setBrandName("示例:品牌"); +// basicdataClientExcel.setTripartiteCoding("示例:张三"); +// basicdataClientExcel.setTripartiteMallBrand("示例:张三"); +// basicdataClientExcel.setTripartiteMall("示例:张三"); + basicdataClientExcel.setMold("示例:商配"); + basicdataClientExcel.setContractStartTime(new Date()); + basicdataClientExcel.setContractEntTime(new Date()); + basicdataClientExcel.setDefaultPaymentMethods("示例:月结"); + basicdataClientExcel.setCleanObjType("示例:工厂"); + list.add(basicdataClientExcel); + return list; + } + @Override @Transactional(rollbackFor = Exception.class) public Boolean ownDeleteLogic(List toLongList) { @@ -497,6 +535,308 @@ public class BasicdataClientServiceImpl extends BaseServiceImpl data, Boolean isCovered) { +// log.info("客户导入数据"); +// +// QueryWrapper queryWrapper = new QueryWrapper<>(); +// List basicdataClients = baseMapper.selectList(queryWrapper); +// // 验证数据 +// checkImportBasicDataClient(data,basicdataClients); +// +// +// List storeContactEntities = new ArrayList<>(); // 联系人 +// List tripartiteMallEntities = new ArrayList<>(); // 三方商场 +// List storeBrandEntities = new ArrayList<>(); // 品牌 +// List storageServicesEntities = new ArrayList<>(); // 服务仓 +// List storeBusinessEntities = new ArrayList<>(); // 服务类型 +// //查询仓库信息 +// List list1 = warehouseService.warehouseListqx(); +// List dictBizs = DictBizCache.getList(DictBizConstant.DISTRIBUTION_TYPE);//商 市 自 +// List clientBiz = DictBizCache.getList(DictBizConstant.CLIENT_TYPE); //客 工 +// List freightBiz = DictBizCache.getList(BASIC_FREIGHT_TYPE); //客 工 +// Set set = new HashSet<>(); +// +// +// +// LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); +// lambdaQueryWrapper.eq(BasicdataBrandEntity::getIsDeleted, 0); +// List basicdataBrandEntityList = basicdataBrandService.list(lambdaQueryWrapper); +// +// +// +// for (BasicdataClientExcel i : data) { +// +// // 处理下空格 换行 +// i.setClientName(i.getClientName().trim()); +// +// log.info("导入数据《》《》{}", i); +// +// if (ObjectUtils.isNull(i.getClientName())) { +// throw new ServiceException("客户编码或客户名称不能为空!"); +// } +// BasicdataClientEntity basicdataClient = new BasicdataClientEntity(); +// BeanUtil.copyProperties(i, basicdataClient); +// //系统生成码值 +// String finallyClientCode = this.getFinallyClientCode(); +// basicdataClient.setClientCode(finallyClientCode); +// //将这个最新的防止缓存中 +// +// log.info(">>>>>> basicdataClient.getClientCode() {}", basicdataClient.getClientCode()); +// +// if(!basicdataClients.isEmpty()){ +// List basicdataClientEntities = basicdataClients.stream().filter(ii -> ii.getClientName().equals(basicdataClient.getClientName()) && ii.getClientCode().equals(basicdataClient.getClientCode())).collect(Collectors.toList()); +// if(!basicdataClientEntities.isEmpty()){ +// // 获取全部重复的数据 +// List clientNames = basicdataClientEntities.stream().map(BasicdataClientEntity::getClientName).collect(Collectors.toList()); +// List clientCodes = basicdataClientEntities.stream().map(BasicdataClientEntity::getClientCode).collect(Collectors.toList()); +// String clientNameStr = String.join(",", clientNames); +// String clientCodeStr = String.join(",", clientCodes); +// throw new ServiceException("客户编码 "+clientCodeStr+" 或客户名称 "+clientNameStr+" 已存在"); +// } +// +// } +// +// Optional clientFirst = clientBiz.stream().filter(ii -> ii.getDictValue().equals(i.getClientType())).findFirst(); +// basicdataClient.setClientType(clientFirst.get().getDictKey()); +// //查询客户名称是不是重复 +// List basicdataClientEntities = baseMapper.selectList(Wrappers.query().lambda() +// .eq(BasicdataClientEntity::getClientName, i.getClientName()) +// ); +// if (basicdataClientEntities.isEmpty()) { +// BladeUser user = AuthUtil.getUser(); +// basicdataClient.setPid(0L); +// basicdataClient.setCreateUser(user.getUserId()); +// basicdataClient.setCargoControl(false); +// basicdataClient.setStatus(1); +// basicdataClient.setIsDeleted(0); +// basicdataClient.setCreateTime(new Date()); +// basicdataClient.setUpdateTime(new Date()); +// +// // 默认付款方式 +// String keyValue = matchDictValue(DictBizCache.getList(OPEN_ORDER_PAY_WAY), i.getDefaultPaymentMethods().trim()); +// +// basicdataClient.setDefaultPaymentMethods(keyValue); +// +// String s = matchDictValue(DictBizCache.getList(CLEAN_OBJ_TYPE), i.getCleanObjType()); +// +// basicdataClient.setCleanObjType(s); +// +// +// String typeValue= matchDictValue(DictBizCache.getList(DISTRIBUTION_TYPE), i.getMold()); +// +// basicdataClient.setTypeService(StringUtil.isNoneBlank(typeValue)?Integer.parseInt(typeValue):null); +// +// baseMapper.insert(basicdataClient); +// redis.set(RedisKeyConstant.FINAL_CLIENT_CODE + AuthUtil.getTenantId(), basicdataClient.getClientCode()); +// if (ObjectUtils.isNull(basicdataClient.getId())) { +// throw new ServiceException("客户ID不存在"); +// } +// +// //添加服务类型 +// if (ObjectUtils.isNotNull(i.getTypeService())) { +// BasicdataStoreBusinessEntity storeBusinessEntity = new BasicdataStoreBusinessEntity(); +// storeBusinessEntity.setClientId(basicdataClient.getId().toString()); +// storeBusinessEntity.setTypeService(i.getTypeService()); +// storeBusinessEntity.setMold(i.getMold()); +// storeBusinessEntities.add(storeBusinessEntity); +// } +// //添加服务仓 +// if (ObjectUtils.isNotNull(i.getServeWarehouseName())) { +// BasicdataStorageServicesEntity servicesEntity = new BasicdataStorageServicesEntity(); +// servicesEntity.setClientId(basicdataClient.getId()); +// servicesEntity.setDistinguish(2); +// if (ObjectUtils.isNotNull(i.getSendWarehouseName())) { +//// Long id = list1.stream().filter(q -> q.getName().equals(i.getSendWarehouseName())).findFirst().get().getId(); +//// servicesEntity.setSendWarehouseId(String.valueOf(id)); +// servicesEntity.setSendWarehouseName(i.getSendWarehouseName()); +// } +// Long id = list1.stream().filter(q -> q.getName().equals(i.getServeWarehouseName())).findFirst().get().getId(); +// servicesEntity.setServeWarehouseId(id); +// servicesEntity.setServeWarehouseName(i.getServeWarehouseName()); +// storageServicesEntities.add(servicesEntity); +// }else { +// BasicdataStorageServicesEntity servicesEntity = new BasicdataStorageServicesEntity(); +// servicesEntity.setClientId(basicdataClient.getId()); +// servicesEntity.setDistinguish(2); +// servicesEntity.setSendWarehouseName("全部"); +// storageServicesEntities.add(servicesEntity); +// } +// //添加品牌 +// if (ObjectUtils.isNotNull(i.getBrandName())) { +// +// String[] ars = i.getBrandName().split(","); +// +// for (String ar : ars) { +// BasicdataStoreBrandEntity storeBrandEntity = new BasicdataStoreBrandEntity(); +// storeBrandEntity.setClientId(basicdataClient.getId()); +// storeBrandEntity.setShopId(basicdataClient.getId().toString()); +// BasicdataBrandEntity one = matchBasicdataBrandEntityListValue(basicdataBrandEntityList, ar); +// +// +// if (ObjectUtils.isNull(one)) { +// throw new ServiceException("品牌不存在"); +// } +// assert one != null; +// storeBrandEntity.setBrandId(one.getId()); +// storeBrandEntity.setBrandName(one.getBrandName()); +// storeBrandEntities.add(storeBrandEntity); +// } +// +// +// } +// //添加联系人 +// if (ObjectUtils.isNotNull(i.getLinkman())) { +// BasicdataStoreContactEntity storeContactEntity = new BasicdataStoreContactEntity(); +// storeContactEntity.setShopId(basicdataClient.getId()); +// storeContactEntity.setPhone(i.getPhone()); +// storeContactEntity.setLinkman(i.getLinkman()); +// storeContactEntity.setDefaultType(true); +// storeContactEntities.add(storeContactEntity); +// +// } +// //添加三方商场 +//// if (ObjectUtils.isNotNull(i.getTripartiteMall())) { +//// BasicdataTripartiteMallEntity tripartiteMallEntity = new BasicdataTripartiteMallEntity(); +//// tripartiteMallEntity.setClientId(basicdataClient.getId()); +//// tripartiteMallEntity.setTripartiteMall(i.getTripartiteMall()); +//// tripartiteMallEntity.setTripartiteCoding(i.getTripartiteCoding()); +//// +//// BasicdataBrandEntity one = matchBasicdataBrandEntityListValue(basicdataBrandEntityList, i.getTripartiteMallBrand()); +//// +//// if (ObjectUtil.isNotEmpty(one)) { +//// //三方名称 +//// assert one != null; +//// tripartiteMallEntity.setBrandId(one.getId()); +//// tripartiteMallEntity.setBrandName(one.getBrandName()); +//// } +//// tripartiteMallEntities.add(tripartiteMallEntity); +//// } +// +// } +// } +// +// //品牌 +// if (!storeBrandEntities.isEmpty()) { +// basicdataStoreBrandService.saveBatch(storeBrandEntities); +// } +// //服务类型 +// if (!storeBusinessEntities.isEmpty()) { +// List list = new ArrayList<>(); +// storeBusinessEntities.stream().forEach(i -> { +// if (i.getTypeService().contains(",")) { +// String[] split = i.getTypeService().split(","); +// for (int j = 0; j < split.length; j++) { +// BasicdataStoreBusinessEntity business = new BasicdataStoreBusinessEntity(); +// BeanUtil.copyProperties(i, business); +// int finalJ = j; +// if ("配送".equals(split[j])) { +// switch (business.getMold()) { +// case "商配": +// business.setMold("1"); +// break; +// case "市配": +// business.setMold("2"); +// break; +// case "自提": +// business.setMold("3"); +// break; +// case "三方中转": +// business.setMold("4"); +// break; +// default: +// throw new CustomerException("未知的服务类型"); +// } +// +// } else { +// business.setMold(null); +// } +// log.info("#################split[finalJ]>>>>>>>>>>>>>>:{}", split[finalJ]); +// String dictValue = freightBiz.stream().filter(q -> q.getDictValue().equals(split[finalJ])).findFirst().get().getDictKey(); +// business.setTypeService(dictValue); +// list.add(business); +// } +// } else { +// String dictValue = freightBiz.stream().filter(q -> q.getDictValue().equals(i.getTypeService())).findFirst().get().getDictKey(); +// i.setTypeService(dictValue); +// if ("配送".equals(i.getTypeService())) { +// String mold = i.getMold(); +// switch (mold) { +// case "商配": +// i.setMold("1"); +// break; +// case "市配": +// i.setMold("2"); +// break; +// case "自提": +// i.setMold("3"); +// break; +// case "三方中转": +// i.setMold("4"); +// break; +// default: +// throw new CustomerException("未知的服务类型"); +// } +// +// } else { +// i.setMold(null); +// } +// list.add(i); +// } +// }); +// basicdataStoreBusinessService.saveBatch(list); +// } +// //服务仓 +// if (!storageServicesEntities.isEmpty()) { +// List servicesEntityList = new ArrayList<>(); +// storageServicesEntities.forEach(i -> { +// if (ObjectUtils.isNotNull(i.getSendWarehouseName())) { +// if (i.getSendWarehouseName().contains(",")) { +// String[] split = i.getSendWarehouseName().split(","); +// for (int j = 0; j < split.length; j++) { +// BasicdataStorageServicesEntity servicesEntity = new BasicdataStorageServicesEntity(); +// Long id = list1.stream().filter(q -> q.getName().equals(i.getSendWarehouseName())).findFirst().get().getId(); +// BeanUtil.copyProperties(i, servicesEntity); +// servicesEntity.setSendWarehouseId(id.toString()); +// servicesEntity.setSendWarehouseName(split[j]); +// servicesEntityList.add(servicesEntity); +// } +// } else { +// Long id = list1.stream().filter(q -> q.getName().equals(i.getSendWarehouseName())).findFirst().get().getId(); +// i.setSendWarehouseId(id.toString()); +// servicesEntityList.add(i); +// } +// } else { +// BasicdataStorageServicesEntity servicesEntity = new BasicdataStorageServicesEntity(); +// BeanUtil.copyProperties(i, servicesEntity); +// servicesEntityList.add(servicesEntity); +// } +// +// }); +// basicdataStorageServicesService.saveBatch(servicesEntityList); +// } +// //联系人 +// if (!storeContactEntities.isEmpty()) { +// basicdataStoreContactService.saveBatch(storeContactEntities); +// } +// //三方 +// if (!tripartiteMallEntities.isEmpty()) { +// basicdataTripartiteMallService.saveBatch(tripartiteMallEntities); +// } +// } + + + + + + /** * 导入数据 * @@ -506,7 +846,6 @@ public class BasicdataClientServiceImpl extends BaseServiceImpl data, Boolean isCovered) { - log.info("客户导入数据"); QueryWrapper queryWrapper = new QueryWrapper<>(); List basicdataClients = baseMapper.selectList(queryWrapper); @@ -533,7 +872,6 @@ public class BasicdataClientServiceImpl extends BaseServiceImpl basicdataBrandEntityList = basicdataBrandService.list(lambdaQueryWrapper); - for (BasicdataClientExcel i : data) { // 处理下空格 换行 @@ -554,7 +892,7 @@ public class BasicdataClientServiceImpl extends BaseServiceImpl>>>>> basicdataClient.getClientCode() {}", basicdataClient.getClientCode()); if(!basicdataClients.isEmpty()){ - List basicdataClientEntities = basicdataClients.stream().filter(ii -> ii.getClientName().equals(basicdataClient.getClientName()) && ii.getClientCode().equals(basicdataClient.getClientCode())).collect(Collectors.toList()); + List basicdataClientEntities = basicdataClients.stream().filter(ii -> ii.getClientName().equals(basicdataClient.getClientName())).collect(Collectors.toList()); if(!basicdataClientEntities.isEmpty()){ // 获取全部重复的数据 List clientNames = basicdataClientEntities.stream().map(BasicdataClientEntity::getClientName).collect(Collectors.toList()); @@ -567,7 +905,9 @@ public class BasicdataClientServiceImpl extends BaseServiceImpl clientFirst = clientBiz.stream().filter(ii -> ii.getDictValue().equals(i.getClientType())).findFirst(); - basicdataClient.setClientType(clientFirst.get().getDictKey()); + if (!Objects.isNull(clientFirst.get())){ + basicdataClient.setClientType(clientFirst.get().getDictKey()); + } //查询客户名称是不是重复 List basicdataClientEntities = baseMapper.selectList(Wrappers.query().lambda() .eq(BasicdataClientEntity::getClientName, i.getClientName()) @@ -579,8 +919,6 @@ public class BasicdataClientServiceImpl extends BaseServiceImpl regionAllVOList= redis.get("blade:sys:regions::SimpleKey []"); + if (!Objects.isNull(i.getBladeRegionProvinceName())){ + List collect = regionAllVOList.stream().filter(f -> i.getBladeRegionProvinceName().equals(f.getLabel())).collect(Collectors.toList()); + if (!collect.isEmpty()) { + RegionAllVO regionAllVO = collect.get(0); + basicdataClient.setBladeRegionProvinceId(regionAllVO.getValue()); + basicdataClient.setBladeRegionProvinceName(regionAllVO.getLabel()); + if (!Objects.isNull(i.getBladeRegionCityName())){ + List children1 = regionAllVO.getChildren(); + if (!children1.isEmpty()) { + List collect1 = children1.stream().filter(f -> i.getBladeRegionCityName().equals(f.getLabel())).collect(Collectors.toList()); + if (!collect1.isEmpty()) { + RegionAllVO regionAllVO1 = collect1.get(0); + basicdataClient.setBladeRegionCityId(regionAllVO1.getValue()); + basicdataClient.setBladeRegionCityName(regionAllVO1.getLabel()); + if (!Objects.isNull(i.getBladeRegionAreaName())){ + List children2 = regionAllVO1.getChildren(); + if (!children2.isEmpty()) { + List collect2 = children2.stream().filter(f -> i.getBladeRegionAreaName().equals(f.getLabel())).collect(Collectors.toList()); + if (!collect2.isEmpty()) { + RegionAllVO regionAllVO2= collect2.get(0); + basicdataClient.setBladeRegionAreaId(regionAllVO2.getValue()); + basicdataClient.setBladeRegionAreaName(regionAllVO2.getLabel()); + } + } + } + } + } + } + } + } + + + this.save(basicdataClient); redis.set(RedisKeyConstant.FINAL_CLIENT_CODE + AuthUtil.getTenantId(), basicdataClient.getClientCode()); + if (ObjectUtils.isNull(basicdataClient.getId())) { throw new ServiceException("客户ID不存在"); } @@ -621,9 +993,12 @@ public class BasicdataClientServiceImpl extends BaseServiceImpl q.getName().equals(i.getServeWarehouseName())).findFirst().get().getId(); - servicesEntity.setServeWarehouseId(id); - servicesEntity.setServeWarehouseName(i.getServeWarehouseName()); - storageServicesEntities.add(servicesEntity); + if (!Objects.isNull(id)){ + servicesEntity.setServeWarehouseId(id); + servicesEntity.setServeWarehouseName(i.getServeWarehouseName()); + storageServicesEntities.add(servicesEntity); + } + }else { BasicdataStorageServicesEntity servicesEntity = new BasicdataStorageServicesEntity(); servicesEntity.setClientId(basicdataClient.getId()); @@ -651,8 +1026,6 @@ public class BasicdataClientServiceImpl extends BaseServiceImpl selectBasicdataTripartiteMallPage(IPage page, BasicdataTripartiteMallVO basicdataTripartiteMall) { @@ -236,6 +244,85 @@ public class BasicdataTripartiteMallServiceImpl extends BaseServiceImpl exportTripartiteMallTemplate() { + List list = new ArrayList<>(); + BasicdataTripartiteMallExcel tripartiteMallExcel = new BasicdataTripartiteMallExcel(); + tripartiteMallExcel.setTripartiteMall("示例:XXX商城"); + tripartiteMallExcel.setTripartiteCoding("示例:ASDFG0000"); + tripartiteMallExcel.setBrandName("示例:欧派"); + list.add(tripartiteMallExcel); + return list; + } + + @Override + @Transactional + public void importTripartiteMall(List data) { + List clientIds = new ArrayList<>(); + boolean b = data.stream().anyMatch(a -> Objects.isNull(a.getClientName())); + String string =""; + if (b) { + string = data.stream().filter(a -> Objects.isNull(a.getClientName())).map(BasicdataTripartiteMallExcel::getTripartiteMall).collect(Collectors.joining(",")); + throw new ServiceException(string+"未填写客户信息"); + } + boolean c = data.stream().anyMatch(a -> Objects.isNull(a.getBrandName())); + if (c) { + string = data.stream().filter(a -> Objects.isNull(a.getBrandName())).map(BasicdataTripartiteMallExcel::getTripartiteMall).collect(Collectors.joining(",")); + throw new ServiceException(string+"未填写品牌信息"); + } + String clientNames = data.stream().map(BasicdataTripartiteMallExcel::getClientName).collect(Collectors.joining(",")); + + //查询客户信息是否合法 + List basicdataClientEntityList = basicdataClientService.list(Wrappers.query().lambda() + .in(BasicdataClientEntity::getClientName, clientNames) + ); + if (basicdataClientEntityList.isEmpty()) { + throw new ServiceException(clientNames+"查询客户信息错误"); + } + Map> listMap = basicdataClientEntityList.stream().collect(Collectors.groupingBy(BasicdataClientEntity::getClientName)); + List tripartiteMallEntityList = new ArrayList<>(); + for (BasicdataTripartiteMallExcel datum : data) { + List entities = this.list(Wrappers.query().lambda() + .eq(BasicdataTripartiteMallEntity::getTripartiteMall, datum.getTripartiteMall()) + .eq(BasicdataTripartiteMallEntity::getTripartiteCoding, datum.getTripartiteCoding()) + .eq(BasicdataTripartiteMallEntity::getBrandName, datum.getBrandName()) + ); + if (!entities.isEmpty()) { + clientIds.addAll(entities.stream().map(BasicdataTripartiteMallEntity::getClientId).collect(Collectors.toList())); + }else { + List basicdataClientEntities = listMap.get(datum.getClientName()); + if (basicdataClientEntities.size() > 1) { + throw new ServiceException(datum.getClientName()+"客户信息错误"); + } + BasicdataClientEntity basicdataClientEntity = basicdataClientEntities.get(0); + BasicdataTripartiteMallEntity basicdataTripartiteMall = BeanUtil.copyProperties(datum, BasicdataTripartiteMallEntity.class); + basicdataTripartiteMall.setClientId(basicdataClientEntity.getId()); + List list = basicdataBrandService.list(Wrappers.query().lambda() + .eq(BasicdataBrandEntity::getBrandName, datum.getBrandName()) + ); + if (!list.isEmpty()) { + basicdataTripartiteMall.setBrandId(list.get(0).getId()); + }else { + throw new ServiceException(datum.getClientName()+"客户信息错误"); + + } + tripartiteMallEntityList.add(basicdataTripartiteMall); + } + + } + if (!clientIds.isEmpty()) { + List basicdataClientEntityList1 = basicdataClientService.listByIds(clientIds); + if (!basicdataClientEntityList1.isEmpty()) { + String errorClient = basicdataClientEntityList1.stream().map(BasicdataClientEntity::getClientName).collect(Collectors.joining(",")); + throw new ServiceException(errorClient+"已存在相关配置"); + } + } + if (!tripartiteMallEntityList.isEmpty()) { + this.saveBatch(tripartiteMallEntityList); + } + + } + private String comparisonBasicdataTripartiteMall(BasicdataTripartiteMallEntity entity, BasicdataTripartiteMallEntity basicdataTripartiteMall) { StringBuilder builder = new StringBuilder(); String str1 = entity.getTripartiteCoding().isEmpty() ? "空" : entity.getTripartiteCoding();