From 11aa1405fc7cdcdb69064b82054af5d06ac81b87 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Thu, 11 Nov 2021 10:36:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=BC=E5=87=BA=E5=8A=A8?= =?UTF-8?q?=E6=80=81sql=EF=BC=8C=E6=94=B9=E4=B8=BA=E4=B8=8E=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=88=97=E8=A1=A8=E4=B8=80=E4=B8=AAwhere?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/IcResiUserController.java | 34 ++++++++++++++----- .../java/com/epmet/dao/IcResiUserDao.java | 4 ++- .../com/epmet/service/IcResiUserService.java | 7 ++-- .../service/impl/IcResiUserServiceImpl.java | 15 +++++--- ...tatsStaffPatrolRecordDailyServiceImpl.java | 3 ++ .../main/resources/mapper/IcResiUserDao.xml | 2 +- 6 files changed, 49 insertions(+), 16 deletions(-) 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..c92be44a44 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,13 @@ 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.constant.StrConstant; +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,7 +181,14 @@ 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 = StrConstant.EPMETY_STR; + 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()); @@ -229,7 +239,7 @@ public class IcResiUserController { } } - 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"; @@ -246,7 +256,7 @@ public class IcResiUserController { 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> 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,7 +273,14 @@ 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 { + CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(customerId, tokenDto.getUserId()); + String staffOrgPath = StrConstant.EPMETY_STR; + 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()); @@ -314,7 +331,7 @@ public class IcResiUserController { } } - 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"; @@ -334,7 +351,7 @@ public class IcResiUserController { 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> 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(); @@ -397,13 +414,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)); } /** 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/service/IcResiUserService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java index 0f82258bf0..61f0a2c35b 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/impl/IcResiUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java index 27289c392a..8ebec910a8 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) -> { 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