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/dao/CustomerGridDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java index 34534391c3..bec972b9d7 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java @@ -336,4 +336,10 @@ public interface CustomerGridDao extends BaseDao { * @Date 2021/10/25 16:04 */ List selectUnitList(@Param("buildingId") String buildingId); + + /** + * @Author sun + * @Description 查询组织下直属网格列表 + **/ + List selectByPid(@Param("pid") String pid); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java index e0fce5c740..b0cb1d46b6 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java @@ -56,7 +56,8 @@ public interface IcBuildingDao extends BaseDao { List selectAgencyChildrenList(@Param("agencyId") String agencyId); - List> selectListByName(@Param("neighborNameList")ArrayList strings, + List> selectListByName(@Param("customerId") String customerId, + @Param("neighborNameList")ArrayList strings, @Param("buildingNameList") ArrayList strings1, @Param("buildingUnitList") ArrayList integers); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java index 19e30210ae..6e5d0487eb 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java @@ -43,7 +43,8 @@ public interface IcNeighborHoodDao extends BaseDao { // List searchAllNeighborhood(@Param(Constants.WRAPPER) QueryWrapper neighborHoodEntityQueryWrapper); List searchAllNeighborhood(@Param("neighbor") IcNeighborHoodEntity neighbor, @Param("house")IcHouseEntity house); - List selectListByName(@Param("neighborNameList")List neighborNameList, + List selectListByName(@Param("customerId") String customerId, + @Param("neighborNameList")List neighborNameList, @Param("agencyNameList") List agencyNameList, @Param("gridNameList") List gridNameList); 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..d00fade930 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; } //查询所有组织和网格根据名字 @@ -236,7 +236,7 @@ public class BuildingServiceImpl implements BuildingService { Set neighborNameList = list.stream().map(item -> item.getNeighborHoodName()).collect(Collectors.toSet()); Set agencyNameList = list.stream().map(item -> item.getAgencyName()).collect(Collectors.toSet()); Set gridNameList = list.stream().map(item -> item.getGridName()).collect(Collectors.toSet()); - List neighborHoodList = icNeighborHoodDao.selectListByName(new ArrayList(neighborNameList),new ArrayList(agencyNameList),new ArrayList(gridNameList)); + List neighborHoodList = icNeighborHoodDao.selectListByName(customerId, new ArrayList(neighborNameList),new ArrayList(agencyNameList),new ArrayList(gridNameList)); // List neighborHoodList = icNeighborHoodDao.selectList(new QueryWrapper().lambda().in(IcNeighborHoodEntity::getNeighborHoodName, neighborNameList)); Map neighborHoodMap = neighborHoodList.stream().collect(Collectors.toMap(IcNeighborHoodEntity::getNeighborHoodName, Function.identity(),(key1, key2)->key1)); @@ -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..d6bbe4dc86 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()); @@ -153,7 +153,7 @@ public class HouseServiceImpl implements HouseService { Set neighborNameList = list.stream().map(item -> item.getNeighborHoodName()).collect(Collectors.toSet()); Set buildingNameList = list.stream().map(item -> item.getBuildingName()).collect(Collectors.toSet()); Set buildingUnitList = list.stream().map(item -> item.getBuildingUnit()).collect(Collectors.toSet()); - List> buildMapList = icBuildingDao.selectListByName(new ArrayList(neighborNameList),new ArrayList(buildingNameList),new ArrayList(buildingUnitList)); + List> buildMapList = icBuildingDao.selectListByName(customerId, new ArrayList(neighborNameList),new ArrayList(buildingNameList),new ArrayList(buildingUnitList)); //转Map Map> buildMap = new HashMap<>(); buildMapList.forEach(item->{ @@ -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..d7558cd110 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 @@ -36,6 +36,7 @@ import org.springframework.util.StringUtils; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.util.*; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Function; import java.util.stream.Collectors; @@ -240,32 +241,49 @@ 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); + //查询当前组织下网格列表 + List customerGridList = customerGridDao.selectByPid(staffInfoCache.getAgencyId()); //组织名称不一样的数据舍弃 Iterator iterator = list.iterator(); while (iterator.hasNext()) { IcNeighborHoodExcel obj = iterator.next(); if (!obj.getAgencyName().trim().equals(staffInfoCache.getAgencyName())) { + numList.add(obj.getRowNum()); iterator.remove(); } + //当前组织下网格名不存在的也不允许导入 + AtomicBoolean br = new AtomicBoolean(true); + customerGridList.forEach(g->{ + if(obj.getGridName().trim().equals(g.getGridName())){ + br.set(false); + } + }); + if(br.get()){ + numList.add(obj.getRowNum()); + iterator.remove(); + } + } //end sun //导入 if(CollectionUtils.isEmpty(list)){ - return ; + return numList; } //获取所有组织 list List agencyNameList = list.stream().map(item -> item.getAgencyName()).collect(Collectors.toList()); + agencyNameList = agencyNameList.stream().distinct().collect(Collectors.toList()); //获取所有网格 list - List gridNameList = list.stream().map(item->item.getGridName()).collect(Collectors.toList()); + //List gridNameList = list.stream().map(item->item.getGridName()).collect(Collectors.toList()); //获取所有物业 list List propertyNameList = list.stream().map(item->item.getPropertyName()).collect(Collectors.toList()); + propertyNameList = propertyNameList.stream().distinct().collect(Collectors.toList()); //查询对应的id List customerAgencyList = customerAgencyDao.selectList(new QueryWrapper().lambda().in(CustomerAgencyEntity::getOrganizationName, agencyNameList)); - List customerGridList = customerGridDao.selectList(new QueryWrapper().lambda().in(CustomerGridEntity::getGridName, gridNameList)); + //List customerGridList = customerGridDao.selectList(new QueryWrapper().lambda().in(CustomerGridEntity::getGridName, gridNameList)); List icPropertyManagementList = icPropertyManagementDao.selectList(new QueryWrapper().lambda().in(IcPropertyManagementEntity::getName, propertyNameList)); Map agencyMap = customerAgencyList.stream().collect(Collectors.toMap(CustomerAgencyEntity::getOrganizationName, Function.identity(),(key1, key2)->key1)); @@ -294,6 +312,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 +331,7 @@ public class NeighborHoodServiceImpl implements NeighborHoodService { icNeighborHoodService.insertBatch(neighborHoodEntityList); icNeighborHoodPropertyService.insertBatch(icNeighborHoodPropertyEntityList); + return numList; } diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml index a3aba7122e..8b90fc9e74 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml @@ -680,5 +680,13 @@ DEL_FLAG = '0' AND BUILDING_ID = #{buildingId} + diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml index 3c4022ea6f..2091daeba8 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml @@ -283,7 +283,9 @@ #{val} - WHERE a.DEL_FLAG = '0' and a.NEIGHBOR_HOOD_NAME in + WHERE a.DEL_FLAG = '0' + AND a.CUSTOMER_ID = #{customerId} + and a.NEIGHBOR_HOOD_NAME in #{val} diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml index dba659f38c..ea950eb90b 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml @@ -193,7 +193,9 @@ #{val} - where a.DEL_FLAG= '0'and a.NEIGHBOR_HOOD_NAME in + where a.DEL_FLAG= '0' + AND a.CUSTOMER_ID = #{customerId} + and a.NEIGHBOR_HOOD_NAME in #{val} diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/CustomerFormResultDTO.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/CustomerFormResultDTO.java index e5afdeddc2..45cd1dd0ea 100644 --- a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/CustomerFormResultDTO.java +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/CustomerFormResultDTO.java @@ -27,7 +27,7 @@ public class CustomerFormResultDTO implements Serializable { /** * 表单项 */ - private List itemList; + private List itemList; /** * 表单分组 diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormGroupDTO.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormGroupDTO.java index dbb3f60e70..1b2a6c8964 100644 --- a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormGroupDTO.java +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormGroupDTO.java @@ -42,6 +42,6 @@ public class FormGroupDTO implements Serializable { /** * 分组里面的组件 */ - private List itemList; + private List itemList; } diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormItem.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormItemResult.java similarity index 97% rename from epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormItem.java rename to epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormItemResult.java index 7e3abbaa0e..dfe0b85ffa 100644 --- a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormItem.java +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormItemResult.java @@ -12,7 +12,7 @@ import java.util.List; * @Date 2021/10/26 2:15 下午 */ @Data -public class FormItem implements Serializable { +public class FormItemResult implements Serializable { private static final long serialVersionUID = 7443085469505238040L; /** diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormItem2.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormItemResult2.java similarity index 97% rename from epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormItem2.java rename to epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormItemResult2.java index 99114fe830..3372b55a37 100644 --- a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormItem2.java +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormItemResult2.java @@ -12,7 +12,7 @@ import java.util.List; * @Date 2021/10/26 4:29 下午 */ @Data -public class FormItem2 implements Serializable { +public class FormItemResult2 implements Serializable { private static final long serialVersionUID = -7571266621687396261L; /** * 父项ID diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java index ecfe051d35..9205d5bedb 100644 --- a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java @@ -91,7 +91,7 @@ public interface OperCustomizeOpenFeignClient { * @date 2021.10.28 15:19:59 */ @PostMapping("/oper/customize/icform/items") - Result> listItems(@RequestBody CustomerFormQueryDTO formDto); + Result> listItems(@RequestBody CustomerFormQueryDTO formDto); /** * @Author sun diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java index b1cc198c20..7835c21b5b 100644 --- a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java @@ -73,7 +73,7 @@ public class OperCustomizeOpenFeignClientFallback implements OperCustomizeOpenFe } @Override - public Result> listItems(CustomerFormQueryDTO formDto) { + public Result> listItems(CustomerFormQueryDTO formDto) { return ModuleUtils.feignConError(ServiceConstant.OPER_CUSTOMIZE_SERVER, "listItems", formDto); } diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcFormController.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcFormController.java index 8c506cfe74..f6f52d00c2 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcFormController.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcFormController.java @@ -187,9 +187,9 @@ public class IcFormController { * @date 2021.10.28 15:19:59 */ @PostMapping("items") - public Result> listItems(@LoginUser TokenDto tokenDto, @RequestBody CustomerFormQueryDTO formDto) { + public Result> listItems(@LoginUser TokenDto tokenDto, @RequestBody CustomerFormQueryDTO formDto) { ValidatorUtils.validateEntity(formDto, CustomerFormQueryDTO.GetFormInfoGroup.class); - List rst = icFormService.listItems(tokenDto.getCustomerId(), formDto.getFormCode()); - return new Result>().ok(rst); + List rst = icFormService.listItems(tokenDto.getCustomerId(), formDto.getFormCode()); + return new Result>().ok(rst); } } diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcFormDao.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcFormDao.java index 6cd4fa7188..7cd489b2bb 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcFormDao.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcFormDao.java @@ -20,7 +20,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.result.CustomerFormResultDTO; import com.epmet.dto.result.FormGroupDTO; -import com.epmet.dto.result.FormItem; +import com.epmet.dto.result.FormItemResult; import com.epmet.dto.result.OptionDTO; import com.epmet.entity.IcFormEntity; import org.apache.ibatis.annotations.Mapper; @@ -47,9 +47,9 @@ public interface IcFormDao extends BaseDao { */ CustomerFormResultDTO selectByCode(@Param("customerId") String customerId, @Param("formCode") String formCode); - List selectItemList(String formId, Boolean dynamic); + List selectItemList(String formId, Boolean dynamic); - List selectItemListByGroupId(String groupId); + List selectItemListByGroupId(String groupId); List selectListOption(String itemId); List selectListGroup(String formId); @@ -64,5 +64,5 @@ public interface IcFormDao extends BaseDao { * @author wxz * @date 2021.10.28 16:43:00 */ - List listItems(@Param("formId") String formId); + List listItems(@Param("formId") String formId); } diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/IcFormService.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/IcFormService.java index b1d0dddaf1..c90e6227dc 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/IcFormService.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/IcFormService.java @@ -22,7 +22,7 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.dto.IcFormDTO; import com.epmet.dto.form.CustomerFormQueryDTO; import com.epmet.dto.result.CustomerFormResultDTO; -import com.epmet.dto.result.FormItem; +import com.epmet.dto.result.FormItemResult; import com.epmet.entity.IcFormEntity; import java.util.List; @@ -115,5 +115,5 @@ public interface IcFormService extends BaseService { * @author wxz * @date 2021.10.27 17:41:59 */ - List listItems(String customerId, String formCode); -} \ No newline at end of file + List listItems(String customerId, String formCode); +} diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormServiceImpl.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormServiceImpl.java index 1170a08309..7d50e6091b 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormServiceImpl.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormServiceImpl.java @@ -17,9 +17,7 @@ package com.epmet.service.impl; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; @@ -35,21 +33,18 @@ import com.epmet.dto.IcFormDTO; import com.epmet.dto.form.CustomerFormQueryDTO; import com.epmet.dto.result.CustomerFormResultDTO; import com.epmet.dto.result.FormGroupDTO; -import com.epmet.dto.result.FormItem; +import com.epmet.dto.result.FormItemResult; import com.epmet.entity.IcFormEntity; import com.epmet.redis.CustomerFootBarRedis; import com.epmet.service.IcFormService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.core.ValueOperations; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; import java.util.List; import java.util.Map; -import java.util.Optional; /** * 配置表单 @@ -61,7 +56,7 @@ import java.util.Optional; public class IcFormServiceImpl extends BaseServiceImpl implements IcFormService { @Autowired private CustomerFootBarRedis customerFootBarRedis; - + @Autowired private RedisUtils redisUtils; @@ -135,7 +130,7 @@ public class IcFormServiceImpl extends BaseServiceImpl if (null == resultDTO) { throw new RenException(EpmetErrorCode.CUSTOMER_FORM_NOT_EXITS.getCode(),EpmetErrorCode.CUSTOMER_FORM_NOT_EXITS.getMsg()); } - List itemList=baseDao.selectItemList(resultDTO.getFormId(),formDto.getDynamic()); + List itemList=baseDao.selectItemList(resultDTO.getFormId(),formDto.getDynamic()); List groupList=baseDao.selectListGroup(resultDTO.getFormId()); resultDTO.setItemList(itemList); resultDTO.setGroupList(groupList); @@ -144,13 +139,13 @@ public class IcFormServiceImpl extends BaseServiceImpl } @Override - public List listItems(String customerId, String formCode) { + public List listItems(String customerId, String formCode) { // 从redis取 String icFormItemsKey = RedisKeys.getIcFormItemsKey(customerId, formCode); - + Object objValue = redisUtils.get(icFormItemsKey); if (objValue != null) { - return ((JSONArray) objValue).toJavaList(FormItem.class); + return ((JSONArray) objValue).toJavaList(FormItemResult.class); //return JSON.parseObject((String) objValue, type); } @@ -160,14 +155,14 @@ public class IcFormServiceImpl extends BaseServiceImpl throw new RenException(EpmetErrorCode.CUSTOMER_FORM_NOT_EXITS.getCode(),EpmetErrorCode.CUSTOMER_FORM_NOT_EXITS.getMsg()); } - List formItems = baseDao.listItems(formResultDto.getFormId()); - formItems.forEach(i -> { + List formItemResults = baseDao.listItems(formResultDto.getFormId()); + formItemResults.forEach(i -> { i.setOptions(baseDao.selectListOption(i.getItemId())); }); - + // 缓存 - redisUtils.set(icFormItemsKey, formItems); + redisUtils.set(icFormItemsKey, formItemResults); - return formItems; + return formItemResults; } } diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcFormDao.xml b/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcFormDao.xml index 44d23cda3f..d93d611f7c 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcFormDao.xml +++ b/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcFormDao.xml @@ -17,7 +17,7 @@ - + @@ -123,13 +123,13 @@ - - + @@ -210,7 +210,7 @@ g.SORT ASC - SELECT fi.ID AS item_id, case when g.TABLE_NAME is null or g.TABLE_NAME = '' then 'ic_resi_user' 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/IcResiUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java index 52f4ea9adf..0bc25d5ccd 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java @@ -29,10 +29,12 @@ import com.alibaba.fastjson.JSON; 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.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; @@ -178,58 +180,21 @@ public class IcResiUserController { * @throws Exception */ @RequestMapping(value = "/exportExcel2") - public void exportExcel(@RequestHeader String customerId, @RequestBody IcResiUserPageFormDTO pageFormDTO, HttpServletResponse response) throws Exception { + public void exportExcel(@RequestHeader String customerId,@LoginUser TokenDto tokenDto, @RequestBody IcResiUserPageFormDTO pageFormDTO, HttpServletResponse response) throws Exception { + CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(customerId, tokenDto.getUserId()); + String staffOrgPath = null; + if (StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds()) && !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())) { + staffOrgPath = staffInfoCacheResult.getAgencyPIds().concat(":").concat(staffInfoCacheResult.getAgencyId()); + }else{ + staffOrgPath=staffInfoCacheResult.getAgencyId(); + } pageFormDTO.setCustomerId(customerId); pageFormDTO.setPageFlag(false); - CustomerFormResultDTO resiFormItems = getResiFormItems(pageFormDTO.getCustomerId()); - - Map> otherSheetItems = new HashMap<>(); + CustomerFormResultDTO resiFormItems = getResiFormAddItems(pageFormDTO.getCustomerId()); - //主表的 - for (FormItem formItem : resiFormItems.getItemList()) { - if (StringUtils.isBlank(formItem.getColumnName())) { - continue; - } - - Map itemMap = otherSheetItems.getOrDefault(formItem.getTableName(), new HashMap<>()); - otherSheetItems.putIfAbsent(formItem.getTableName(), itemMap); - if (formItem.getItemType().equals("checkbox") || formItem.getItemType().equals("select") || formItem.getItemType().equals("radio")) { - itemMap.put(formItem.getColumnName().concat(formItem.getColumnNum() == 0 ? "" : formItem.getColumnNum().toString()), formItem); - } - if (formItem.getChildGroup() != null) { - itemMap = otherSheetItems.getOrDefault(formItem.getChildGroup().getTableName(), new HashMap<>()); - otherSheetItems.putIfAbsent(formItem.getChildGroup().getTableName(), itemMap); - for (FormItem2 item2 : formItem.getChildGroup().getItemList()) { - if (StringUtils.isBlank(item2.getColumnName())) { - continue; - } - - if ("checkbox".equals(item2.getItemType()) || "select".equals(item2.getItemType()) || "radio".equals(item2.getItemType())) { - itemMap.put(item2.getColumnName().concat(item2.getColumnNum() == 0 ? "" : item2.getColumnNum().toString()), ConvertUtils.sourceToTarget(item2, FormItem.class)); - } - } - - } - } - //其他sheet - - for (FormGroupDTO groupItem : resiFormItems.getGroupList()) { - if (groupItem.getItemList() == null) { - continue; - } - Map itemMap = otherSheetItems.getOrDefault(groupItem.getTableName(), new HashMap<>()); - otherSheetItems.putIfAbsent(groupItem.getTableName(), itemMap); - for (FormItem2 formItem2 : groupItem.getItemList()) { - if (StringUtils.isBlank(formItem2.getColumnName())) { - continue; - } - if ("checkbox".equals(formItem2.getItemType()) || "select".equals(formItem2.getItemType()) || "radio".equals(formItem2.getItemType())) { - itemMap.put(formItem2.getColumnName().concat(formItem2.getColumnNum() == 0 ? "" : formItem2.getColumnNum().toString()), ConvertUtils.sourceToTarget(formItem2, FormItem.class)); - } - } - } + Map> otherSheetItems = buildItemMap(resiFormItems); - Map> resiMainList = icResiUserService.getDataForExport(otherSheetItems.get(BASE_TABLE_NAME),new HashMap<>(), pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), BASE_TABLE_NAME, pageFormDTO.getConditions()); + Map> resiMainList = icResiUserService.getDataForExport(otherSheetItems.get(BASE_TABLE_NAME),new HashMap<>(), pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), BASE_TABLE_NAME, pageFormDTO.getConditions(),staffInfoCacheResult.getAgencyId(),staffOrgPath); //resiMainList = (List>)JSON.parse("[{\"IS_BDHJ\":\"1\",\"IS_SPECIAL\":\"1\",\"IS_XFRY\":\"0\",\"REMARKS\":\"beizhu\",\"IS_PARTY\":\"1\",\"icResiUserId\":\"yzmtest2\",\"HOME_ID\":\"中海国际社区一里城1号楼1单元101\",\"HOUSE_TYPE\":\"平房\",\"UNIT_NAME\":\"1单元\",\"GRID_ID\":\"市北区-市北区第三网格3\",\"IS_DB\":\"0\",\"GENDER\":\"男\",\"BIRTHDAY\":\"2021-10-04\",\"IS_VETERANS\":\"0\",\"IS_MB\":\"0\",\"IS_UNEMPLOYED\":\"0\",\"DEMAND_NAME\":null,\"IS_KC\":\"0\",\"IS_ENSURE_HOUSE\":\"0\",\"IS_SD\":\"0\",\"NAME\":\"尹作梅\",\"RDSJ\":null,\"IS_VOLUNTEER\":\"1\",\"GRID_ID_VALUE\":\"e74829ffc43d5470eba6b5e060c11e63\",\"IS_SZ\":\"0\",\"IS_CJ\":\"0\",\"HOME_ID_VALUE\":\"200\",\"DEMAND_CATEGORY_IDS\":null,\"VILLAGE_NAME\":\"中海国际社区一里城\",\"IS_DBH\":\"0\",\"IS_SN\":\"0\",\"BUILD_NAME\":\"1号楼\",\"IS_YLFN\":\"0\",\"IS_UNITED_FRONT\":\"0\",\"ID_CARD\":\"371325199310260529\",\"MOBILE\":\"15764229697\",\"IS_OLD_PEOPLE\":\"0\",\"DOOR_NAME\":\"101\"},{\"IS_SPECIAL\":\"1\",\"IS_XFRY\":\"0\",\"REMARKS\":\"beizhu\",\"IS_PARTY\":\"1\",\"icResiUserId\":\"yzmtest\",\"HOME_ID\":\"中海国际社区一里城1号楼1单元101\",\"HOUSE_TYPE\":\"平房\",\"UNIT_NAME\":\"1单元\",\"GRID_ID\":\"市北区-市北区第三网格3\",\"IS_DB\":\"0\",\"GENDER\":\"男\",\"BIRTHDAY\":\"2021-10-04\",\"IS_VETERANS\":\"0\",\"IS_MB\":\"0\",\"IS_UNEMPLOYED\":\"0\",\"DEMAND_NAME\":\"心理咨询\",\"IS_KC\":\"0\",\"IS_ENSURE_HOUSE\":\"0\",\"IS_SD\":\"0\",\"NAME\":\"尹作梅\",\"RDSJ\":\"2021-10-28 00:00:00\",\"IS_VOLUNTEER\":\"1\",\"GRID_ID_VALUE\":\"e74829ffc43d5470eba6b5e060c11e63\",\"IS_SZ\":\"0\",\"IS_CJ\":\"0\",\"HOME_ID_VALUE\":\"200\",\"DEMAND_CATEGORY_IDS\":\"10180002\",\"VILLAGE_NAME\":\"中海国际社区一里城\",\"IS_DBH\":\"0\",\"IS_SN\":\"0\",\"BUILD_NAME\":\"1号楼\",\"IS_YLFN\":\"0\",\"IS_UNITED_FRONT\":\"0\",\"ID_CARD\":\"371325199310260529\",\"MOBILE\":\"15764229697\",\"IS_OLD_PEOPLE\":\"0\",\"DOOR_NAME\":\"101\"}]"); log.info("resiMainList:{}", JSON.toJSONString(resiMainList)); String templatePath = "excel/ic_resi_info_cid.xls"; @@ -241,12 +206,12 @@ public class IcResiUserController { System.out.println("===resiMainList==="+" "+JSON.toJSONString(resiMainList.values())); sheetMap.put(0, mapData); AtomicInteger n = new AtomicInteger(); - for (FormItem item : resiFormItems.getItemList()) { + for (FormItemResult item : resiFormItems.getItemList()) { if (item.getChildGroup() != null) { if (!item.getChildGroup().getTableName().equals(BASE_TABLE_NAME)) { - Map itemMap1 = otherSheetItems.get(item.getChildGroup().getTableName()); - Map> resiChildMap = icResiUserService.getDataForExport(itemMap1,resiMainList, pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), item.getChildGroup().getTableName(), pageFormDTO.getConditions()); + Map itemMap1 = otherSheetItems.get(item.getChildGroup().getTableName()); + Map> resiChildMap = icResiUserService.getDataForExport(itemMap1,resiMainList, pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), item.getChildGroup().getTableName(), pageFormDTO.getConditions(),staffInfoCacheResult.getAgencyId(),staffOrgPath); //resiChildMap.forEach((key, value) -> value.putAll(resiMainList.get(key))); Map mapData2 = new HashMap<>(); @@ -263,58 +228,25 @@ public class IcResiUserController { } @RequestMapping(value = "/exportExcel") - public void exportExcelByEasyExcel(@RequestHeader String customerId, @RequestBody IcResiUserPageFormDTO pageFormDTO, HttpServletResponse response) throws Exception { + public void exportExcelByEasyExcel(@RequestHeader String customerId,@LoginUser TokenDto tokenDto, @RequestBody IcResiUserPageFormDTO pageFormDTO, HttpServletResponse response) throws Exception { + //tokenDto.setUserId("9e37adcce6472152e6508a19d3683e02"); + CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(customerId, tokenDto.getUserId()); + String staffOrgPath = null; + if (StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds()) && !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())) { + staffOrgPath = staffInfoCacheResult.getAgencyPIds().concat(":").concat(staffInfoCacheResult.getAgencyId()); + }else{ + staffOrgPath=staffInfoCacheResult.getAgencyId(); + } pageFormDTO.setCustomerId(customerId); pageFormDTO.setPageFlag(false); - CustomerFormResultDTO resiFormItems = getResiFormItems(pageFormDTO.getCustomerId()); + CustomerFormResultDTO resiFormItems = getResiFormAddItems(pageFormDTO.getCustomerId()); + Map> otherSheetItems = buildItemMap(resiFormItems); - Map> otherSheetItems = new HashMap<>(); + /*List resiFormAllItems = getResiFormAllItems(pageFormDTO.getCustomerId()); + resiFormAllItems.stream().collect(Collectors.groupingBy(e ->e.get));*/ - //主表的 - for (FormItem formItem : resiFormItems.getItemList()) { - if (StringUtils.isBlank(formItem.getColumnName())) { - continue; - } - - Map itemMap = otherSheetItems.getOrDefault(formItem.getTableName(), new HashMap<>()); - otherSheetItems.putIfAbsent(formItem.getTableName(), itemMap); - if (formItem.getItemType().equals("checkbox") || formItem.getItemType().equals("select") || formItem.getItemType().equals("radio")) { - itemMap.put(formItem.getColumnName().concat(formItem.getColumnNum() == 0 ? "" : formItem.getColumnNum().toString()), formItem); - } - if (formItem.getChildGroup() != null) { - itemMap = otherSheetItems.getOrDefault(formItem.getChildGroup().getTableName(), new HashMap<>()); - otherSheetItems.putIfAbsent(formItem.getChildGroup().getTableName(), itemMap); - for (FormItem2 item2 : formItem.getChildGroup().getItemList()) { - if (StringUtils.isBlank(item2.getColumnName())) { - continue; - } - - if ("checkbox".equals(item2.getItemType()) || "select".equals(item2.getItemType()) || "radio".equals(item2.getItemType())) { - itemMap.put(item2.getColumnName().concat(item2.getColumnNum() == 0 ? "" : item2.getColumnNum().toString()), ConvertUtils.sourceToTarget(item2, FormItem.class)); - } - } - - } - } - //其他sheet - - for (FormGroupDTO groupItem : resiFormItems.getGroupList()) { - if (groupItem.getItemList() == null) { - continue; - } - Map itemMap = otherSheetItems.getOrDefault(groupItem.getTableName(), new HashMap<>()); - otherSheetItems.putIfAbsent(groupItem.getTableName(), itemMap); - for (FormItem2 formItem2 : groupItem.getItemList()) { - if (StringUtils.isBlank(formItem2.getColumnName())) { - continue; - } - if ("checkbox".equals(formItem2.getItemType()) || "select".equals(formItem2.getItemType()) || "radio".equals(formItem2.getItemType())) { - itemMap.put(formItem2.getColumnName().concat(formItem2.getColumnNum() == 0 ? "" : formItem2.getColumnNum().toString()), ConvertUtils.sourceToTarget(formItem2, FormItem.class)); - } - } - } - Map> resiMainList = icResiUserService.getDataForExport(otherSheetItems.get(BASE_TABLE_NAME),new HashMap<>(), pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), BASE_TABLE_NAME, pageFormDTO.getConditions()); + Map> resiMainList = icResiUserService.getDataForExport(otherSheetItems.get(BASE_TABLE_NAME),new HashMap<>(), pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), BASE_TABLE_NAME, pageFormDTO.getConditions(),staffInfoCacheResult.getAgencyId(),staffOrgPath); //========================================= String templatePath = "excel/ic_resi_info_cid_for_easy_excel.xlsx"; @@ -329,12 +261,12 @@ public class IcResiUserController { //======================================= AtomicInteger n = new AtomicInteger(); - for (FormItem item : resiFormItems.getItemList()) { + for (FormItemResult item : resiFormItems.getItemList()) { if (item.getChildGroup() != null) { if (!item.getChildGroup().getTableName().equals(BASE_TABLE_NAME)) { - Map itemMap1 = otherSheetItems.get(item.getChildGroup().getTableName()); - Map> resiChildMap = icResiUserService.getDataForExport(itemMap1,resiMainList, pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), item.getChildGroup().getTableName(), pageFormDTO.getConditions()); + Map itemMap1 = otherSheetItems.get(item.getChildGroup().getTableName()); + Map> resiChildMap = icResiUserService.getDataForExport(itemMap1,resiMainList, pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), item.getChildGroup().getTableName(), pageFormDTO.getConditions(),staffInfoCacheResult.getAgencyId(),staffOrgPath); //resiChildMap.forEach((key, value) -> value.putAll(resiMainList.get(key))); int sheetNo = n.incrementAndGet(); @@ -348,6 +280,57 @@ public class IcResiUserController { excelWriter.finish(); } + + @NotNull + private Map> buildItemMap(CustomerFormResultDTO resiFormItems) { + Map> otherSheetItems = new HashMap<>(); + + //主表的 + for (FormItemResult formItemResult : resiFormItems.getItemList()) { + if (StringUtils.isBlank(formItemResult.getColumnName())) { + continue; + } + + Map itemMap = otherSheetItems.getOrDefault(formItemResult.getTableName(), new HashMap<>()); + otherSheetItems.putIfAbsent(formItemResult.getTableName(), itemMap); + if (formItemResult.getItemType().equals("checkbox") || formItemResult.getItemType().equals("select") || formItemResult.getItemType().equals("radio")) { + itemMap.put(formItemResult.getColumnName().concat(formItemResult.getColumnNum() == 0 ? "" : formItemResult.getColumnNum().toString()), formItemResult); + } + if (formItemResult.getChildGroup() != null) { + itemMap = otherSheetItems.getOrDefault(formItemResult.getChildGroup().getTableName(), new HashMap<>()); + otherSheetItems.putIfAbsent(formItemResult.getChildGroup().getTableName(), itemMap); + for (FormItemResult2 item2 : formItemResult.getChildGroup().getItemList()) { + if (StringUtils.isBlank(item2.getColumnName())) { + continue; + } + + if ("checkbox".equals(item2.getItemType()) || "select".equals(item2.getItemType()) || "radio".equals(item2.getItemType())) { + itemMap.put(item2.getColumnName().concat(item2.getColumnNum() == 0 ? "" : item2.getColumnNum().toString()), ConvertUtils.sourceToTarget(item2, FormItemResult.class)); + } + } + + } + } + //其他sheet + + for (FormGroupDTO groupItem : resiFormItems.getGroupList()) { + if (groupItem.getItemList() == null) { + continue; + } + Map itemMap = otherSheetItems.getOrDefault(groupItem.getTableName(), new HashMap<>()); + otherSheetItems.putIfAbsent(groupItem.getTableName(), itemMap); + for (FormItemResult2 formItemResult2 : groupItem.getItemList()) { + if (StringUtils.isBlank(formItemResult2.getColumnName())) { + continue; + } + if ("checkbox".equals(formItemResult2.getItemType()) || "select".equals(formItemResult2.getItemType()) || "radio".equals(formItemResult2.getItemType())) { + itemMap.put(formItemResult2.getColumnName().concat(formItemResult2.getColumnNum() == 0 ? "" : formItemResult2.getColumnNum().toString()), ConvertUtils.sourceToTarget(formItemResult2, FormItemResult.class)); + } + } + } + return otherSheetItems; + } + private static OutputStream getOutputStream(String fileName, HttpServletResponse response) throws Exception { fileName = URLEncoder.encode(fileName, "UTF-8"); response.setContentType("application/vnd.ms-excel"); @@ -397,13 +380,14 @@ public class IcResiUserController { } @PostMapping("test") - public Result>> test(@RequestBody DynamicQueryFormDTO formDTO) { + public Result>> test(@LoginUser TokenDto tokenDto,@RequestBody DynamicQueryFormDTO formDTO) { formDTO.setCustomerId("45687aa479955f9d06204d415238f7cc"); //formDTO.setCustomerId(tokenDto.getCustomerId()); return new Result>>().ok(icResiUserService.dynamicQuery(formDTO.getCustomerId(), formDTO.getFormCode(), formDTO.getResultTableName(), - formDTO.getConditions())); + formDTO.getConditions(), + tokenDto.getUserId(),null)); } /** @@ -431,7 +415,7 @@ public class IcResiUserController { } @NotNull - private CustomerFormResultDTO getResiFormItems(String customerId) { + private CustomerFormResultDTO getResiFormAddItems(String customerId) { CustomerFormQueryDTO queryDTO = new CustomerFormQueryDTO(); queryDTO.setFormCode("resi_base_info"); queryDTO.setCustomerId(customerId); @@ -443,6 +427,19 @@ public class IcResiUserController { return resultForm.getData(); } + @NotNull + private List getResiFormAllItems(String customerId) { + CustomerFormQueryDTO queryDTO = new CustomerFormQueryDTO(); + queryDTO.setFormCode("resi_base_info"); + queryDTO.setCustomerId(customerId); + Result> resultForm = operCustomizeOpenFeignClient.listItems(queryDTO); + if (resultForm == null || !resultForm.success() || resultForm.getData() == null) { + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } + System.out.println(JSON.toJSONString(resultForm.getData())); + return resultForm.getData(); + } + /** * @Description 个人信息-家庭关系 * @Param formDTO 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/IcResiUserDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java index db7344b6ea..fbd753f8fb 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java @@ -100,7 +100,9 @@ public interface IcResiUserDao extends BaseDao { List> dynamicQuery(@Param("customerId")String customerId, @Param("resultTableName")String resultTableName, @Param("conditions") List conditions, - @Param("subTables") List subTables); + @Param("subTables") List subTables, + @Param("currentStaffAgencyId")String currentStaffAgencyId, + @Param("staffOrgPath")String staffOrgPath); /** * @Description 查询个人信息 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/IcResiUserService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java index 0f82258bf0..478ab8f65f 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java @@ -80,7 +80,9 @@ public interface IcResiUserService extends BaseService { List> dynamicQuery(String customerId, String formCode, String resultTableName, - List conditions); + List conditions, + String currentStaffAgencyId, + String staffOrgPath); /** * @Description 查询个人数据 @@ -111,7 +113,8 @@ public interface IcResiUserService extends BaseService { * @param conditions * @return */ - Map> getDataForExport(Map itemList, Map> resiMainList, String customerId, String formCode, String baseTableName, List conditions); + Map> getDataForExport(Map itemList, Map> resiMainList, String customerId, String formCode, String baseTableName, List conditions,String currentStaffAgencyId, + String staffOrgPath); /** * @Description 家庭关系 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/IcResiUserImportServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java index 076a880ff0..eeaa8c03e7 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java @@ -5,7 +5,6 @@ import cn.afterturn.easypoi.excel.annotation.Excel; import cn.afterturn.easypoi.excel.entity.ExportParams; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcelFactory; -import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.dto.result.OptionResultDTO; @@ -21,7 +20,7 @@ import com.epmet.dto.form.AgencyIdFormDTO; import com.epmet.dto.form.CustomerFormQueryDTO; import com.epmet.dto.form.HouseFormDTO; import com.epmet.dto.form.LoginUserDetailsFormDTO; -import com.epmet.dto.result.FormItem; +import com.epmet.dto.result.FormItemResult; import com.epmet.dto.result.LoginUserDetailsResultDTO; import com.epmet.dto.result.OptionDTO; import com.epmet.entity.IcResiUserEntity; @@ -262,7 +261,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res Map> headers = mergeHead(headList); // 查询form相关信息 - List customerItems = listFormItems(IMPORT_IC_RESI_FORM_CODE); + List customerItems = listFormItems(IMPORT_IC_RESI_FORM_CODE); // 清洗表头数据 Map abandonedHeaders = washHeaders(headers, customerItems); @@ -271,7 +270,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res HashMap> combinedHeaders = combineHeaders(headers); // 得到客户配置item数据 - Map formItemMap = customerItems.stream().collect( + Map formItemMap = customerItems.stream().collect( Collectors.toMap(formItem -> { String groupLabel = formItem.getGroupLabel(); String label = formItem.getLabel(); @@ -311,7 +310,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res Map> headers = mergeHead(headList); // 查询form相关信息 - List customerItems = listFormItems(IMPORT_IC_RESI_FORM_CODE); + List customerItems = listFormItems(IMPORT_IC_RESI_FORM_CODE); // 清洗表头数据 Map abandonedHeaders = washHeaders(headers, customerItems); @@ -320,7 +319,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res HashMap> combinedHeaders = combineHeaders(headers); // 得到客户配置item数据 - Map formItemMap = customerItems.stream().collect( + Map formItemMap = customerItems.stream().collect( Collectors.toMap(formItem -> { String groupLabel = formItem.getGroupLabel(); String label = formItem.getLabel(); @@ -461,7 +460,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res // skipedRow.setInfo("信息已存在,跳过导入"); // skipedRow.setTableName(targetTableName); // skipedRows.get().get(targetTableName).add(skipedRow); - // + // // continue; //} @@ -603,10 +602,10 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res * @param formCode * @return */ - private List listFormItems(String formCode) { + private List listFormItems(String formCode) { CustomerFormQueryDTO form = new CustomerFormQueryDTO(); form.setFormCode(formCode); - Result> result = operCustomizeOpenFeignClient.listItems(form); + Result> result = operCustomizeOpenFeignClient.listItems(form); return getResultDataOrThrowsException(result, ServiceConstant.OPER_CUSTOMIZE_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【居民信息excel导入】查询表单相关信息失败"); } @@ -643,7 +642,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res * @author wxz * @date 2021.10.28 21:07:12 */ - private Map washHeaders(Map> headers, List items) { + private Map washHeaders(Map> headers, List items) { List itemLabels = items.stream().map(i -> i.getLabel()).collect(Collectors.toList()); Map abandonedHeaders = new HashMap<>(); for (Map.Entry> entry:headers.entrySet()) { @@ -675,7 +674,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res * @param abandonedHeaders * @return */ - private Map convertExcelHeaders2DBColumnWrappers(Map formItemMap, Map> combinedHeaders, + private Map convertExcelHeaders2DBColumnWrappers(Map formItemMap, Map> combinedHeaders, List> datas, Map abandonedHeaders) { // HashMap> tables = new HashMap<>(); @@ -684,7 +683,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res for (Map.Entry> entry : combinedHeaders.entrySet()) { String combinedHeader = entry.getKey(); - FormItem item = formItemMap.get(combinedHeader); + FormItemResult item = formItemMap.get(combinedHeader); if (item == null) { // 如果数据库中没有该项,可能是用户自己定义的项,忽略 diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java index 27289c392a..351c5058b3 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java @@ -290,6 +290,8 @@ public class IcResiUserServiceImpl extends BaseServiceImpl> dynamicQuery(String customerId, String formCode, String resultTableName, - List conditions){ + List conditions, + String currentStaffAgencyId, + String staffOrgPath){ CustomerFormQueryDTO queryDTO=new CustomerFormQueryDTO(); queryDTO.setCustomerId(customerId); queryDTO.setFormCode(formCode); + //所有的子表 Result> subTablesRes=operCustomizeOpenFeignClient.querySubTables(queryDTO); List subTables=new ArrayList<>(); if(subTablesRes.success()&&CollectionUtils.isNotEmpty(subTablesRes.getData())){ subTables =subTablesRes.getData(); } - return baseDao.dynamicQuery(customerId,resultTableName,conditions,subTables); + return baseDao.dynamicQuery(customerId,resultTableName,conditions,subTables,currentStaffAgencyId,staffOrgPath); } /** @@ -616,8 +621,10 @@ public class IcResiUserServiceImpl extends BaseServiceImpl> getDataForExport(Map formItemMap, Map> resiMainList, String customerId, String formCode, String baseTableName, List conditions) { - List> mapList = this.dynamicQuery(customerId, formCode, baseTableName, conditions); + public Map> getDataForExport(Map formItemMap, Map> resiMainList, String customerId, String formCode, String baseTableName, List conditions, + String currentStaffAgencyId, + String staffOrgPath) { + List> mapList = this.dynamicQuery(customerId, formCode, baseTableName, conditions,currentStaffAgencyId,staffOrgPath); Map> result = new LinkedHashMap<>(); mapList.stream().filter(Objects::nonNull).forEach(map -> { map.forEach((k,o) -> { @@ -640,9 +647,9 @@ public class IcResiUserServiceImpl extends BaseServiceImpl e : formItemMap.entrySet()) { + for (Map.Entry e : formItemMap.entrySet()) { String k = e.getKey(); - FormItem v = e.getValue(); + FormItemResult v = e.getValue(); Object temp = map.get(k); String vauleStr = temp == null ? "" : temp.toString(); 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/java/com/epmet/service/impl/StatsStaffPatrolRecordDailyServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsStaffPatrolRecordDailyServiceImpl.java index 4d2913cd43..03467b2c30 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsStaffPatrolRecordDailyServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsStaffPatrolRecordDailyServiceImpl.java @@ -47,6 +47,9 @@ public class StatsStaffPatrolRecordDailyServiceImpl extends BaseServiceImpl - + group by IC_RESI_USER.id order by ic_resi_user.CREATED_TIME desc 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 diff --git a/epmet-user/epmet-user-server/src/test/java/com/epmet/epmetuser/test/IcResiUserControllerTest.java b/epmet-user/epmet-user-server/src/test/java/com/epmet/epmetuser/test/IcResiUserControllerTest.java index 4e08497a8e..4bf7b1c16c 100644 --- a/epmet-user/epmet-user-server/src/test/java/com/epmet/epmetuser/test/IcResiUserControllerTest.java +++ b/epmet-user/epmet-user-server/src/test/java/com/epmet/epmetuser/test/IcResiUserControllerTest.java @@ -11,7 +11,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.CustomerFormQueryDTO; import com.epmet.dto.result.CustomerFormResultDTO; import com.epmet.dto.result.FormGroupDTO; -import com.epmet.dto.result.FormItem; +import com.epmet.dto.result.FormItemResult; import com.epmet.feign.OperCustomizeOpenFeignClient; import org.apache.commons.lang3.StringUtils; import org.apache.poi.xssf.usermodel.XSSFWorkbook; @@ -75,7 +75,7 @@ public class IcResiUserControllerTest { private Map> buildHeaderByItem(CustomerFormResultDTO resultForm) { //form中的itemlist 为一级表头 但是要排除每个item中含有childGroup的 - List itemList = resultForm.getItemList(); + List itemList = resultForm.getItemList(); List groupList = resultForm.getGroupList(); Map> everySheetHeaderMap = new LinkedHashMap<>(); @@ -155,7 +155,7 @@ public class IcResiUserControllerTest { return everySheetHeaderMap; } - private void buildHeader(Map> everySheetHeaderMap, FormItem item, ExcelExportEntity header) { + private void buildHeader(Map> everySheetHeaderMap, FormItemResult item, ExcelExportEntity header) { List firstSheetHeaderList = new ArrayList<>(); List secondHeaderList = new ArrayList<>(); item.getChildGroup().getItemList().forEach(item2->{