From 743e5e339ea1f681f0f80cd9f9a80509e0fb5561 Mon Sep 17 00:00:00 2001 From: PigBaoBei <2739175034@qq.com> Date: Tue, 30 Jul 2024 16:46:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E5=AF=BC=E5=85=A5=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E7=BC=96=E7=A0=81=E3=80=81=E5=AE=A2=E6=88=B7=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E8=81=94=E7=B3=BB=E4=BA=BABUG=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E3=80=81=E9=85=8D=E9=80=81=E5=88=97=E8=A1=A8=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=95=B0=E6=8D=AEBUG=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/BasicdataClientController.java | 12 ++ .../BasicdataStoreContactController.java | 3 +- .../excel/BasicDataClienImporter.java | 3 + .../basicdata/excel/BasicdataClientExcel.java | 12 +- .../service/IBasicdataClientService.java | 9 ++ .../IBasicdataStoreContactService.java | 7 ++ .../impl/BasicdataClientServiceImpl.java | 103 ++++++++++++++---- .../BasicdataStoreContactServiceImpl.java | 11 ++ .../mapper/DistributionDeliveryListMapper.xml | 6 +- 9 files changed, 132 insertions(+), 34 deletions(-) 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 0d81120f2..d60d48ee2 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 @@ -245,4 +245,16 @@ public class BasicdataClientController extends BladeController { return R.success("操作成功"); } + + /** + * 校验导入数据 + */ + @PostMapping("/checkImportBasicDataClient") + @ApiOperationSupport(order = 9) + @ApiOperation(value = "导入数据", notes = "传入basicDataClient") + public R checkImportBasicDataClient(MultipartFile file) { + R r = basicdataClientService.checkImportBasicDataClient(file); + return r; + } + } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataStoreContactController.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataStoreContactController.java index 4bcc39117..04fa20224 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataStoreContactController.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataStoreContactController.java @@ -123,7 +123,8 @@ public class BasicdataStoreContactController extends BladeController { @ApiOperationSupport(order = 6) @ApiOperation(value = "新增或修改", notes = "传入basicdataStoreContact") public R submit(@Valid @RequestBody BasicdataStoreContactEntity basicdataStoreContact) { - return R.status(basicdataStoreContactService.saveOrUpdate(basicdataStoreContact)); + + return R.status(basicdataStoreContactService.saveOrUpdateBasicdataStoreContact(basicdataStoreContact)); } /** diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/BasicDataClienImporter.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/BasicDataClienImporter.java index c663173e0..c6c1ce430 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/BasicDataClienImporter.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/BasicDataClienImporter.java @@ -18,4 +18,7 @@ public class BasicDataClienImporter implements ExcelImporter pageList(IPage page, Map basicdataStoreContact); + /** + * 修改客户联系人 + * @param basicdataStoreContact + * @return + */ + boolean saveOrUpdateBasicdataStoreContact(BasicdataStoreContactEntity basicdataStoreContact); + } 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 9d4f442b4..f335eb0b1 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 @@ -56,20 +56,25 @@ import org.springblade.common.constant.RedisKeyConstant; import org.springblade.common.constant.basiccode.BasicCodeShowConstant; import org.springblade.common.constant.basiccode.BasicCodeTypeConstant; import org.springblade.common.model.dto.NameDTO; +import org.springblade.core.excel.util.ExcelUtil; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.redis.cache.BladeRedis; import org.springblade.core.secure.BladeUser; import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.system.cache.DictBizCache; import org.springblade.system.entity.DictBiz; import org.springblade.system.feign.IUserClient; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.Resource; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; +import java.io.File; import java.security.NoSuchAlgorithmException; import java.util.*; import java.util.stream.Collectors; @@ -206,7 +211,7 @@ public class BasicdataClientServiceImpl extends BaseServiceImpl a.equals(i.getClientCode())); - if (b) { - continue; - } - } - if (ObjectUtils.isNull(i.getClientCode()) || ObjectUtils.isNull(i.getClientName())) { +// if (set.isEmpty()) { +// set.add(i.getClientCode()); +// } else { +// boolean b = set.stream().anyMatch(a -> a.equals(i.getClientCode())); +// if (b) { +// continue; +// } +// } +// if (ObjectUtils.isNull(i.getClientCode()) || ObjectUtils.isNull(i.getClientName())) { +// throw new ServiceException("客户编码或客户名称不能为空!"); +// } + 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()); //查询客户编码和客户名称是否存在 @@ -397,15 +408,14 @@ public class BasicdataClientServiceImpl extends BaseServiceImpl>>>>>>>>>>>> 1{}", ii.getClientCode()); log.info(">>>>>>>>>>>>> 2{}", ii.getClientName()); - return ii.getClientCode().equals(basicdataClient.getClientCode()) - || ii.getClientName().equals(basicdataClient.getClientName().trim()); + return ii.getClientCode().equals(basicdataClient.getClientCode()) + || ii.getClientName().equals(basicdataClient.getClientName().trim()); } return false; }); if (b) { - List basicdataClientEntities = basicdataClients.stream().filter(ii -> ii.getClientCode().equals(basicdataClient.getClientCode()) - || ii.getClientName().equals(basicdataClient.getClientName())).collect(Collectors.toList()); + List basicdataClientEntities = basicdataClients.stream().filter(ii -> ii.getClientName().equals(basicdataClient.getClientName())).collect(Collectors.toList()); log.info("###############basicdataClientEntities重复客户:{}", basicdataClientEntities); throw new ServiceException("客户编码或客户名称已存在"); } @@ -413,8 +423,10 @@ public class BasicdataClientServiceImpl extends BaseServiceImpl clientFirst = clientBiz.stream().filter(ii -> ii.getDictValue().equals(i.getClientType())).findFirst(); // i.setTypeService(first.get().getDictValue()); basicdataClient.setClientType(clientFirst.get().getDictKey()); - //查询是不是重复 - List basicdataClientEntities = baseMapper.selectList(Wrappers.query().lambda().eq(BasicdataClientEntity::getClientCode, i.getClientCode())); + //查询客户名称是不是重复 + List basicdataClientEntities = baseMapper.selectList(Wrappers.query().lambda() + .eq(BasicdataClientEntity::getClientName, i.getClientName()) + ); if (basicdataClientEntities.isEmpty()) { BladeUser user = AuthUtil.getUser(); basicdataClient.setPid(0L); @@ -430,6 +442,7 @@ public class BasicdataClientServiceImpl extends BaseServiceImpl str = baseMapper.getFinallyClientCode(tenantCode); - if(!str.isEmpty()){ + if (!str.isEmpty()) { finaClientCode = str.get(0); - }else{ - finaClientCode =tenantCode+"0000000"; + } else { + finaClientCode = tenantCode + "0000000"; } redis.set(RedisKeyConstant.FINAL_CLIENT_CODE + AuthUtil.getTenantId(), finaClientCode); @@ -706,12 +719,54 @@ public class BasicdataClientServiceImpl extends BaseServiceImpl clientExcels = ExcelUtil.read(file, BasicdataClientExcel.class); + if (!clientExcels.isEmpty()) { + log.info("客户导入数据"); + //查询仓库信息 + QueryWrapper queryWrapper = new QueryWrapper<>(); + List basicdataClients = baseMapper.selectList(queryWrapper); + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(BasicdataBrandEntity::getIsDeleted, 0); + List basicdataBrandEntityList = basicdataBrandService.list(lambdaQueryWrapper); + for (BasicdataClientExcel data : clientExcels) { + if (!basicdataClients.isEmpty()) { + //查询客户编码和客户名称是否存在 + boolean b = basicdataClients.stream().anyMatch(ii -> { + if (ii.getClientName() != null && !ii.getClientName().isEmpty()) { + return ii.getClientName().equals(data.getClientName().trim()); + } + return false; + }); + if (b) { + String repeatClientName = basicdataClients.stream().filter(ii -> ii.getClientName().equals(data.getClientName())).map(BasicdataClientEntity::getClientName).collect(Collectors.joining(",")); + return R.fail(repeatClientName+"客户名称已存在"); + } + } + //添加品牌 + if (ObjectUtils.isNotNull(data.getBrandName())) { + + String[] ars = data.getBrandName().split(","); + + for (String ar : ars) { + BasicdataBrandEntity one = matchBasicdataBrandEntityListValue(basicdataBrandEntityList, ar); + if (ObjectUtils.isNull(one)) { + return R.fail(data.getClientName()+"品牌信息不存在"); + } + } + } + } + } + return R.success("校验成功"); + } + } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataStoreContactServiceImpl.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataStoreContactServiceImpl.java index 374b0ad8a..99e5ea474 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataStoreContactServiceImpl.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataStoreContactServiceImpl.java @@ -107,4 +107,15 @@ public class BasicdataStoreContactServiceImpl extends BaseServiceImpl SELECT COALESCE(COUNT(*), 0) FROM logpm_distribution_delivery_list lddl - lddl.type = '1' AND lddl.customers_number > 0 + lddl.type = '1' AND lddl.customers_number > 0 AND lddl.is_deleted = 0 and lddl.train_number like concat('%',#{param.trainNumber},'%') @@ -645,7 +645,7 @@ logpm_distribution_delivery_list lddl join logpm_distribution_signfor lds on lddl.id = lds.delivery_id join logpm_distribution_reservation ldr on lds.reservation_id =ldr.id - lddl.type = '1' + lddl.type = '1' AND lddl.is_deleted = 0 AND lddl.customers_number > 0 and lddl.train_number like concat('%',#{param.trainNumber},'%') @@ -687,7 +687,7 @@