From 88e40e7069bab21b7c44a516447a509d408705cf Mon Sep 17 00:00:00 2001 From: lzh Date: Wed, 10 Nov 2021 22:06:03 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=B1=85=E6=B0=91?= =?UTF-8?q?=E9=A2=84=E8=AD=A6=E7=B1=BB=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/form/StatsResiWarnCountFormDTO.java | 46 ++++++++++++++ .../controller/StatsResiWarnController.java | 9 ++- .../com/epmet/dao/IcStatsResiWarnDao.java | 2 + .../epmet/service/StatsResiWarnService.java | 2 + .../impl/StatsResiWarnServiceImpl.java | 60 +++++++++++++++++++ .../resources/mapper/IcStatsResiWarnDao.xml | 22 +++++++ 6 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StatsResiWarnCountFormDTO.java diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StatsResiWarnCountFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StatsResiWarnCountFormDTO.java new file mode 100644 index 0000000000..7fba162e27 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StatsResiWarnCountFormDTO.java @@ -0,0 +1,46 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; + + +/** + * 预警统计表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-04 + */ +@Data +public class StatsResiWarnCountFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 组织id + */ + @NotBlank(message = "用户id不能为空") + private String userId; + + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StatsResiWarnController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StatsResiWarnController.java index 6a872d078d..510c434264 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StatsResiWarnController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StatsResiWarnController.java @@ -23,6 +23,7 @@ import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.StatsResiListFormDTO; +import com.epmet.dto.form.StatsResiWarnCountFormDTO; import com.epmet.dto.form.StatsResiWarnFormDTO; import com.epmet.dto.result.IcStatsResiResultDTO; import com.epmet.dto.result.IcStatsResiWarnBuildingResultDTO; @@ -83,7 +84,7 @@ public class StatsResiWarnController { } /** - * 统计 + * 统计所有 * @return */ @PostMapping("resiwarn") @@ -91,5 +92,11 @@ public class StatsResiWarnController { statsResiWarnService.resiWarn(tokenDto.getCustomerId()); return new Result(); } + @PostMapping("resiWarnByOne") + public Result resiWarnByOne(@LoginUser TokenDto tokenDto,@RequestBody StatsResiWarnCountFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO); + statsResiWarnService.resiWarnByOne(tokenDto.getCustomerId(),formDTO.getUserId()); + return new Result(); + } } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcStatsResiWarnDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcStatsResiWarnDao.java index 0cd26050a0..5eea1c2c44 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcStatsResiWarnDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcStatsResiWarnDao.java @@ -46,4 +46,6 @@ public interface IcStatsResiWarnDao extends BaseDao { @Param("level")String level); List resiWarn(@Param("tableName") String tableName,@Param("columnName") String columnName); + IcStatsResiWarnEntity resiWarnById(@Param("tableName") String tableName,@Param("columnName") String columnName,@Param("icStatsResiWarn") IcStatsResiWarnEntity icStatsResiWarn); + } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StatsResiWarnService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StatsResiWarnService.java index 5192e27981..4ef4b6722a 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StatsResiWarnService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StatsResiWarnService.java @@ -38,4 +38,6 @@ public interface StatsResiWarnService{ List list(String id, String level); void resiWarn(String customerId); + + void resiWarnByOne(String customerId,String userId); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java index 33d30a3212..8a8af94e2b 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.dao.IcResiUserDao; import com.epmet.dao.IcStatsResiWarnDao; import com.epmet.dto.IcResiCategoryStatsConfigDTO; import com.epmet.dto.IcResiCategoryWarnConfigDTO; @@ -12,6 +13,7 @@ import com.epmet.dto.result.BuildingResultDTO; import com.epmet.dto.result.IcStatsResiResultDTO; import com.epmet.dto.result.IcStatsResiWarnBuildingResultDTO; import com.epmet.dto.result.IcStatsResiWarnUserResultDTO; +import com.epmet.entity.IcResiUserEntity; import com.epmet.entity.IcStatsResiWarnEntity; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.feign.OperCustomizeOpenFeignClient; @@ -46,6 +48,9 @@ public class StatsResiWarnServiceImpl implements StatsResiWarnService { @Autowired private OperCustomizeOpenFeignClient operCustomizeOpenFeignClient; + @Resource + private IcResiUserDao icResiUserDao; + @Override public List buildingwWarnList(String agencyID) { List result = new ArrayList<>(); @@ -207,4 +212,59 @@ public class StatsResiWarnServiceImpl implements StatsResiWarnService { icStatsResiWarnService.insertBatch(icStatsResiWarnEntities,500); } + + @Override + public void resiWarnByOne(String customerId, String userId) { + // 获取预警配置项 + Result> warnResult = operCustomizeOpenFeignClient.resiCategoryWarnList(); + if (!warnResult.success() || null == warnResult.getData()) { + throw new RenException("预警配置查询失败:"+ warnResult.getMsg()); + } + List icResiCategoryWarnConfigDTOList = warnResult.getData(); + + IcResiUserEntity icResiUserEntity = icResiUserDao.selectById(userId); + if(null == icResiUserEntity){ + return ; + } + + //保存数据 + for (IcResiCategoryWarnConfigDTO item : icResiCategoryWarnConfigDTOList) { + //查询这个用户信息 + + IcStatsResiWarnEntity icStatsResiWarn = icStatsResiWarnDao.selectOne(new QueryWrapper().lambda() + .eq(IcStatsResiWarnEntity::getConfigId,item.getId()) + .eq(IcStatsResiWarnEntity::getAgencyId, icResiUserEntity.getAgencyId()) + .eq(IcStatsResiWarnEntity::getGridId, icResiUserEntity.getGridId()) + .eq(IcStatsResiWarnEntity::getNeighborHoodId, icResiUserEntity.getVillageId()) + .eq(IcStatsResiWarnEntity::getBuildingId, icResiUserEntity.getBuildId())); + + if(null == icStatsResiWarn){ + //如果不存在,新增统计数量 + icStatsResiWarn = new IcStatsResiWarnEntity(); + icStatsResiWarn.setAgencyId(icResiUserEntity.getAgencyId()); + icStatsResiWarn.setAgencyPids(icResiUserEntity.getPids()); + icStatsResiWarn.setGridId(icResiUserEntity.getGridId()); + icStatsResiWarn.setNeighborHoodId(icResiUserEntity.getVillageId()); + icStatsResiWarn.setBuildingId(icResiUserEntity.getBuildId()); + icStatsResiWarn.setConfigId(item.getId()); + icStatsResiWarn.setCustomerId(customerId); + IcStatsResiWarnEntity resiWarnEntity = icStatsResiWarnDao.resiWarnById(item.getTableName(), item.getColumnName(),icStatsResiWarn); + if(null == resiWarnEntity){ + continue; + } + icStatsResiWarn.setCount(resiWarnEntity.getCount()); + icStatsResiWarnDao.insert(icStatsResiWarn); + }else{ + //如果存在,更新统计数量 + IcStatsResiWarnEntity resiWarnEntity = icStatsResiWarnDao.resiWarnById(item.getTableName(), item.getColumnName(),icStatsResiWarn); + icStatsResiWarn.setCount(resiWarnEntity.getCount()); + icStatsResiWarn.setCustomerId(customerId); + icStatsResiWarnDao.updateById(icStatsResiWarn); + } + + + } + } + + } diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcStatsResiWarnDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcStatsResiWarnDao.xml index 4416ac2f2e..79a5f7499b 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcStatsResiWarnDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcStatsResiWarnDao.xml @@ -103,4 +103,26 @@ and DEL_FLAG = '0' group by AGENCY_ID,GRID_ID,VILLAGE_ID,BUILD_ID + \ No newline at end of file From 71ad799c19276f900d1638dd3db5874eee93ba6b Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Thu, 11 Nov 2021 09:15:13 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E3=80=81=E6=A5=BC?= =?UTF-8?q?=E5=AE=87=E3=80=81=E6=88=BF=E5=B1=8B=E5=AF=BC=E5=85=A5=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/controller/BuildingController.java | 22 +++++++++++++------ .../com/epmet/controller/HouseController.java | 16 ++++++++++++-- .../controller/NeighborHoodController.java | 22 +++++++++++++------ .../com/epmet/service/BuildingService.java | 3 +-- .../java/com/epmet/service/HouseService.java | 3 +-- .../epmet/service/NeighborHoodService.java | 2 +- .../service/impl/BuildingServiceImpl.java | 17 +++++++------- .../epmet/service/impl/HouseServiceImpl.java | 19 ++++++++-------- .../service/impl/NeighborHoodServiceImpl.java | 7 ++++-- 9 files changed, 71 insertions(+), 40 deletions(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java index 5b408d1367..f1aac1a9c0 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java @@ -23,6 +23,7 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; @@ -47,10 +48,8 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; /** @@ -180,15 +179,24 @@ public class BuildingController { List failList = importResult.getFailList(); + //存放错误数据行号 + List numList = new ArrayList<>(); if(!CollectionUtils.isEmpty(failList)){ for ( IcBuildingExcel entity : failList) { log.error("第{}行,{}",entity.getRowNum(),entity.getErrorMsg());//打印失败的行 和失败的信息 + numList.add(entity.getRowNum()); } - return new Result().error(8001,failList.get(0).getErrorMsg()); + //return new Result().error(8001,failList.get(0).getErrorMsg()); } List result =importResult.getList(); - - return new Result().ok(buildingService.importExcel(customerId,result,tokenDTO.getUserId())); + List resultList = buildingService.importExcel(customerId,result,tokenDTO.getUserId(),numList); + String str = String.format("共%s条,成功导入%s条。",numList.size()+result.size(),numList.size()+result.size()-resultList.size()); + if(resultList.size()> NumConstant.ZERO){ + Collections.sort(resultList); + String subList = resultList.stream().map(String::valueOf).collect(Collectors.joining("、")); + return new Result().error(9999, str+"第"+subList+"行未成功!"); + } + return new Result().ok(str); } /** diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java index 1807565cee..a2bb68f09f 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java @@ -21,6 +21,7 @@ import cn.afterturn.easypoi.excel.entity.TemplateExportParams; import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; @@ -42,6 +43,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.*; +import java.util.stream.Collectors; /** @@ -145,15 +147,25 @@ public class HouseController { List failList = importResult.getFailList(); + //存放错误数据行号 + List numList = new ArrayList<>(); if(!CollectionUtils.isEmpty(failList)){ for ( IcHouseExcel entity : failList) { log.error("第{}行,{}",entity.getRowNum(),entity.getErrorMsg());//打印失败的行 和失败的信息 + numList.add(entity.getRowNum()); } - return new Result().error(8001,failList.get(0).getErrorMsg()); + //return new Result().error(8001,failList.get(0).getErrorMsg()); } List result =importResult.getList(); - return new Result().ok(houseService.importExcel(customerId,result,tokenDTO.getUserId())); + List resultList = houseService.importExcel(customerId,result,tokenDTO.getUserId(),numList); + String str = String.format("共%s条,成功导入%s条。",numList.size()+result.size(),numList.size()+result.size()-resultList.size()); + if(resultList.size()> NumConstant.ZERO){ + Collections.sort(resultList); + String subList = resultList.stream().map(String::valueOf).collect(Collectors.joining("、")); + return new Result().error(9999, str+"第"+subList+"行未成功!"); + } + return new Result().ok(str); } @PostMapping( "queryListHouseInfo") diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java index 11e1f65d6b..cb22dd00f2 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java @@ -22,6 +22,7 @@ import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; @@ -45,10 +46,8 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; /** @@ -207,16 +206,25 @@ public class NeighborHoodController { // List result = ExcelPoiUtils.importExcel(file, 0, 1, IcNeighborHoodExcel.class); List failList = importResult.getFailList(); + //存放错误数据行号 + List numList = new ArrayList<>(); if(!CollectionUtils.isEmpty(failList)){ for ( IcNeighborHoodExcel entity : failList) { log.error("第{}行,{}",entity.getRowNum(),entity.getErrorMsg());//打印失败的行 和失败的信息 + numList.add(entity.getRowNum()); } - return new Result().error(8001,failList.get(0).getErrorMsg()); + //return new Result().error(8001,failList.get(0).getErrorMsg()); } List result =importResult.getList(); // log.info(JSON.toJSONString(result)); - neighborHoodService.importExcel(customerId,result,tokenDTO.getUserId()); - return new Result(); + List resultList = neighborHoodService.importExcel(customerId,result,tokenDTO.getUserId(),numList); + String str = String.format("共%s条,成功导入%s条。",numList.size()+result.size(),numList.size()+result.size()-resultList.size()); + if(resultList.size()> NumConstant.ZERO){ + Collections.sort(resultList); + String subList = resultList.stream().map(String::valueOf).collect(Collectors.joining("、")); + return new Result().error(9999, str+"第"+subList+"行未成功!"); + } + return new Result().ok(str); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java index 1a8c8c04e9..405887d709 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java @@ -17,7 +17,6 @@ package com.epmet.service; -import com.epmet.commons.tools.utils.Result; import com.epmet.dto.BuildingTreeLevelDTO; import com.epmet.dto.form.IcBulidingFormDTO; import com.epmet.dto.form.ListIcNeighborHoodFormDTO; @@ -53,7 +52,7 @@ public interface BuildingService { List treeList(String customerId); - Result importExcel(String customerId, List list, String staffId); + List importExcel(String customerId, List list, String staffId, List numList); IcNeighborHoodResultDTO listBuilding(ListIcNeighborHoodFormDTO formDTO); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java index 0fd98dc3df..48ab8c7d1b 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java @@ -17,7 +17,6 @@ package com.epmet.service; -import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.IcHouseFormDTO; import com.epmet.dto.form.ListIcNeighborHoodFormDTO; import com.epmet.dto.result.HouseInfoDTO; @@ -48,7 +47,7 @@ public interface HouseService { void delHouse(String houseId); - Result importExcel(String customerId, List list, String staffId); + List importExcel(String customerId, List list, String staffId, List numList); IcNeighborHoodResultDTO listNeighborhood(ListIcNeighborHoodFormDTO formDTO); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/NeighborHoodService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/NeighborHoodService.java index 266c3b912d..ff1a35f45a 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/NeighborHoodService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/NeighborHoodService.java @@ -52,5 +52,5 @@ public interface NeighborHoodService{ */ void exportNeighborhoodinfo(ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception ; - void importExcel(String customerId,List list,String staffId); + List importExcel(String customerId, List list, String staffId, List numList); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java index 40659b958f..6925d238aa 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java @@ -9,7 +9,6 @@ import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.utils.Result; import com.epmet.dao.*; import com.epmet.dto.BuildingTreeLevelDTO; import com.epmet.dto.CustomerStaffAgencyDTO; @@ -210,7 +209,7 @@ public class BuildingServiceImpl implements BuildingService { @Override @Transactional(rollbackFor = Exception.class) - public Result importExcel(String customerId, List list, String staffId) { + public List importExcel(String customerId, List list, String staffId, List numList) { //2021.11.9 需求变更 当前工作人员只能导致自己所属组织下数据,网格名对应不上的数据舍弃【注:需求就这样】 sun CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(customerId, staffId); //组织名称不一样的数据舍弃 @@ -218,15 +217,16 @@ public class BuildingServiceImpl implements BuildingService { while (iterator.hasNext()) { IcBuildingExcel obj = iterator.next(); if (!obj.getAgencyName().trim().equals(staffInfoCache.getAgencyName())) { + numList.add(obj.getRowNum()); iterator.remove(); } } //用于存储匹配不上的数据给前端的提示 如南宁社区不存在 - StringBuffer str = new StringBuffer(""); + //StringBuffer str = new StringBuffer(""); //end sun //导入 if(CollectionUtils.isEmpty(list)){ - return new Result(); + return numList; } //查询所有组织和网格根据名字 @@ -252,7 +252,8 @@ public class BuildingServiceImpl implements BuildingService { entity.setCustomerId(customerId); entity.setNeighborHoodId(Optional.ofNullable(neighborHoodMap.get(icBuildingExcel.getNeighborHoodName())).map(u->u.getId()).orElse(""));//neighborHoodMap.get(icBuildingExcel.getNeighborHoodName()).getId() if ("".equals(entity.getNeighborHoodId())) { - str.append("".equals(str) ? icBuildingExcel.getNeighborHoodName() : str.append("、").append(icBuildingExcel.getNeighborHoodName())); + //str.append("".equals(str) ? icBuildingExcel.getNeighborHoodName() : str.append("、").append(icBuildingExcel.getNeighborHoodName())); + numList.add(icBuildingExcel.getRowNum()); continue; } entity.setBuildingName(icBuildingExcel.getBuildingName()); @@ -286,10 +287,10 @@ public class BuildingServiceImpl implements BuildingService { icBuildingService.insertBatch(buildingEntityList); icBuildingUnitService.insertBatch(icBuildingUnitEntityList); - if(!"".equals(str)){ + /* if(!"".equals(str)){ return new Result().error(9999, str.append("不存在").toString()); - } - return new Result(); + }*/ + return numList; } @Override diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java index 2a0ce1465d..ff5dd90ef8 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java @@ -8,7 +8,6 @@ import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.utils.Result; import com.epmet.dao.IcBuildingDao; import com.epmet.dao.IcBuildingUnitDao; import com.epmet.dao.IcHouseDao; @@ -24,7 +23,6 @@ import com.epmet.entity.IcHouseEntity; import com.epmet.enums.HousePurposeEnums; import com.epmet.enums.HouseRentFlagEnums; import com.epmet.enums.HouseTypeEnums; -import com.epmet.excel.IcBuildingExcel; import com.epmet.excel.IcHouseExcel; import com.epmet.service.HouseService; import com.epmet.service.IcBuildingService; @@ -123,7 +121,8 @@ public class HouseServiceImpl implements HouseService { } @Override - public Result importExcel(String customerId, List list, String staffId) { + @Transactional(rollbackFor = Exception.class) + public List importExcel(String customerId, List list, String staffId, List numList) { //2021.11.10 需求变更 当前工作人员只能导致自己所属组织下数据,对应不上的数据舍弃【注:需求就这样】 sun CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(customerId, staffId); //组织名称不一样的数据舍弃 @@ -131,15 +130,16 @@ public class HouseServiceImpl implements HouseService { while (iterator.hasNext()) { IcHouseExcel obj = iterator.next(); if (!obj.getAgencyName().trim().equals(staffInfoCache.getAgencyName())) { + numList.add(obj.getRowNum()); iterator.remove(); } } //用于存储匹配不上的数据给前端的提示 如南宁社区不存在 - StringBuffer str = new StringBuffer(""); + //StringBuffer str = new StringBuffer(""); //end sun //导入 if(CollectionUtils.isEmpty(list)){ - return new Result(); + return numList; } //获取所有小区 list // List neighborNameList = list.stream().map(item -> item.getNeighborHoodName()).collect(Collectors.toList()); @@ -173,7 +173,8 @@ public class HouseServiceImpl implements HouseService { entity.setBuildingUnitId(String.valueOf(Optional.ofNullable(item).map(u->u.get("buildingUnitId")).orElse(""))); entity.setHouseName(icHouseExcel.getBuildingName()+"-"+icHouseExcel.getBuildingUnit()+"-"+icHouseExcel.getDoorName()); if ("".equals(entity.getNeighborHoodId()) || "".equals(entity.getBuildingId()) || "".equals(entity.getBuildingUnitId())) { - str.append("".equals(str) ? icHouseExcel.getBuildingName() + icHouseExcel.getBuildingUnit() : str.append("、").append(icHouseExcel.getBuildingName() + icHouseExcel.getBuildingUnit())); + //str.append("".equals(str) ? icHouseExcel.getBuildingName() + icHouseExcel.getBuildingUnit() : str.append("、").append(icHouseExcel.getBuildingName() + icHouseExcel.getBuildingUnit())); + numList.add(icHouseExcel.getRowNum()); continue; } entity.setDoorName(icHouseExcel.getDoorName()); @@ -193,10 +194,10 @@ public class HouseServiceImpl implements HouseService { //3.保存 icHouseService.insertBatch(houseEntityList); - if(!"".equals(str)){ + /*if(!"".equals(str)){ return new Result().error(9999, str.append("不存在").toString()); - } - return new Result(); + }*/ + return numList; } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java index 4e36375890..2e72f0341c 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java @@ -240,7 +240,7 @@ public class NeighborHoodServiceImpl implements NeighborHoodService { @Override @Transactional(rollbackFor = Exception.class) - public void importExcel(String customerId,List list,String staffId) { + public List importExcel(String customerId,List list,String staffId, List numList) { //2021.11.9 需求变更 当前工作人员只能导致自己所属组织下数据,网格名对应不上的数据舍弃【注:需求就这样】 sun CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(customerId, staffId); //组织名称不一样的数据舍弃 @@ -248,6 +248,7 @@ public class NeighborHoodServiceImpl implements NeighborHoodService { while (iterator.hasNext()) { IcNeighborHoodExcel obj = iterator.next(); if (!obj.getAgencyName().trim().equals(staffInfoCache.getAgencyName())) { + numList.add(obj.getRowNum()); iterator.remove(); } } @@ -255,7 +256,7 @@ public class NeighborHoodServiceImpl implements NeighborHoodService { //导入 if(CollectionUtils.isEmpty(list)){ - return ; + return numList; } //获取所有组织 list List agencyNameList = list.stream().map(item -> item.getAgencyName()).collect(Collectors.toList()); @@ -294,6 +295,7 @@ public class NeighborHoodServiceImpl implements NeighborHoodService { entity.setGridId(Optional.ofNullable(gridMap.get(icNeighborHoodExcel.getGridName().trim())).map(u->u.getId()).orElse(""));//gridMap.get(icNeighborHoodExcel.getGridName()).getId() //网格名对应不上的数据舍弃 if ("".equals(entity.getGridId())) { + numList.add(icNeighborHoodExcel.getRowNum()); continue; } entity.setAddress(icNeighborHoodExcel.getAddress()); @@ -312,6 +314,7 @@ public class NeighborHoodServiceImpl implements NeighborHoodService { icNeighborHoodService.insertBatch(neighborHoodEntityList); icNeighborHoodPropertyService.insertBatch(icNeighborHoodPropertyEntityList); + return numList; }