diff --git a/epmet-commons/epmet-commons-extapp-auth/pom.xml b/epmet-commons/epmet-commons-extapp-auth/pom.xml index 8ff0d46ada..bf2e9a71c7 100644 --- a/epmet-commons/epmet-commons-extapp-auth/pom.xml +++ b/epmet-commons/epmet-commons-extapp-auth/pom.xml @@ -18,7 +18,7 @@ 1.3.3 2.6 4.6.1 - 4.4.0 + 4.3.0 2.9.9 1.2.79 2.8.6 diff --git a/epmet-commons/epmet-commons-tools/pom.xml b/epmet-commons/epmet-commons-tools/pom.xml index e516c5fba7..867fcf47c7 100644 --- a/epmet-commons/epmet-commons-tools/pom.xml +++ b/epmet-commons/epmet-commons-tools/pom.xml @@ -18,7 +18,7 @@ 1.3.3 2.6 4.6.1 - 4.4.0 + 4.3.0 2.9.9 1.2.79 2.8.6 diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/AsyncConfig.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/AsyncConfig.java index c95c9f8ade..ab8efec85e 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/AsyncConfig.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/AsyncConfig.java @@ -88,7 +88,7 @@ public class AsyncConfig { @Bean public ExecutorService executorService() { ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) executor(); - return TtlExecutors.getTtlExecutorService(executor.getThreadPoolExecutor()); + return executor.getThreadPoolExecutor(); } /** diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerStaffRedis.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerStaffRedis.java index 509b12339f..37904be02b 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerStaffRedis.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerStaffRedis.java @@ -65,6 +65,10 @@ public class CustomerStaffRedis { * @remark 此方法仅用于 获取某个工作人员的信息,不用于获取客户下所有工作人员信息 */ public static CustomerStaffInfoCacheResult getStaffInfo(String customerId, String staffId) { + if (StringUtils.isBlank(customerId) || StringUtils.isBlank(staffId)){ + log.warn("getStaffInfo param is blank,customerId:{},staffId:{}",customerId,staffId); + return null; + } String key = RedisKeys.getCustomerStaffInfoKey(customerId, staffId); Map roleMap = customerStaffRedis.redisUtils.hGetAll(key); if (!CollectionUtils.isEmpty(roleMap)) { diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelUtils.java index 9bc34d0a39..bd5c5597c0 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelUtils.java @@ -11,12 +11,13 @@ package com.epmet.commons.tools.utils; import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; -import com.epmet.commons.tools.utils.excel.ExportMultiView; +import com.epmet.commons.tools.utils.poi.excel.EasyPoiExcelExportStylerImpl; +import com.epmet.commons.tools.utils.poi.excel.ExportMultiView; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.springframework.beans.BeanUtils; -import org.springframework.util.CollectionUtils; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; @@ -30,6 +31,7 @@ import java.util.*; * @author Mark sunlightcs@gmail.com * @since 1.0.0 */ +@Slf4j public class ExcelUtils { /** @@ -47,15 +49,16 @@ public class ExcelUtils { fileName = DateUtils.format(new Date()); } - Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), pojoClass, list); + ExportParams exportParams = new ExportParams(); + //设置导出的样式 + exportParams.setStyle(EasyPoiExcelExportStylerImpl.class); + //设置sheet名称 + exportParams.setSheetName("Sheet1"); + Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, list); Sheet sheet1 = workbook.getSheetAt(0); sheet1.setDefaultColumnWidth(50*256); - sheet1.setDefaultRowHeight((short)(2*256)); - response.setCharacterEncoding("UTF-8"); - response.setHeader("content-Type", "application/vnd.ms-excel"); - response.setHeader("Content-Disposition", - "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xls"); - ServletOutputStream out = response.getOutputStream(); + //sheet1.setDefaultRowHeight((short)(2*256)); + ServletOutputStream out = ExcelUtils.getOutputStreamForExcel(fileName,response); workbook.write(out); out.flush(); out.close(); @@ -81,47 +84,9 @@ public class ExcelUtils { exportExcel(response, fileName, targetList, targetClass); } - public static void exportExcelToTargetDisposeAll(HttpServletResponse response, String fileName, Collection sourceList, - Class targetClass) throws Exception { - if (!CollectionUtils.isEmpty(sourceList)){ - List targetList = new ArrayList<>(sourceList.size()); - for(Object source : sourceList){ - Object target = targetClass.newInstance(); - BeanUtils.copyProperties(source, target); - targetList.add(target); - } - exportExcelDispose(response, fileName, targetList, targetClass); - }else { - exportExcelDispose(response, fileName, new ArrayList<>(), targetClass); - } - - - } - - public static void exportExcelDispose(HttpServletResponse response, String fileName, Collection list, - Class pojoClass) throws IOException { - if(StringUtils.isBlank(fileName)){ - //当前日期 - fileName = DateUtils.format(new Date()); - } - ExportParams params = new ExportParams(fileName,fileName); - Workbook workbook = ExcelExportUtil.exportExcel(params, pojoClass, list); - Sheet sheet1 = workbook.getSheetAt(0); - sheet1.setDefaultColumnWidth(50*256); - sheet1.setDefaultRowHeight((short)(2*256)); - response.setCharacterEncoding("UTF-8"); - response.setHeader("content-Type", "application/vnd.ms-excel"); - fileName = fileName + ".xls"; - response.setHeader("Content-Disposition", - "attachment;filename=" +fileName); - ServletOutputStream out = response.getOutputStream(); - workbook.write(out); - out.flush(); - out.close(); - } - public static ServletOutputStream getOutputStreamForExcel(String fileName, HttpServletResponse response) throws Exception { + public static ServletOutputStream getOutputStreamForExcel(String fileName, HttpServletResponse response) throws IOException { fileName = URLEncoder.encode(fileName, "UTF-8"); - if (!fileName.endsWith(".xls") ||!fileName.endsWith(".xlsx")){ + if (!fileName.endsWith(".xls") && !fileName.endsWith(".xlsx")){ fileName = fileName + ".xlsx"; } response.setContentType("application/vnd.ms-excel"); diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/poi/excel/EasyPoiExcelExportStylerImpl.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/poi/excel/EasyPoiExcelExportStylerImpl.java new file mode 100644 index 0000000000..b1a5606c2e --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/poi/excel/EasyPoiExcelExportStylerImpl.java @@ -0,0 +1,93 @@ +package com.epmet.commons.tools.utils.poi.excel; + + +import cn.afterturn.easypoi.excel.export.styler.AbstractExcelExportStyler; +import cn.afterturn.easypoi.excel.export.styler.IExcelExportStyler; +import org.apache.poi.ss.usermodel.*; + + +/** + * desc:easypoi自定义表头颜色 + * + * @author: LiuJanJun + * @date: 2022/4/8 4:39 下午 + * @version: 1.0 + */ +public class EasyPoiExcelExportStylerImpl extends AbstractExcelExportStyler + implements IExcelExportStyler { + public EasyPoiExcelExportStylerImpl(Workbook workbook) { + super.createStyles(workbook); + } + + @Override + public CellStyle getTitleStyle(short color) { + CellStyle titleStyle = workbook.createCellStyle(); + Font font = this.workbook.createFont(); + // 字体加粗 + font.setBold(true); + font.setFontHeightInPoints((short) 12); + titleStyle.setFont(font); + //居中 + titleStyle.setAlignment(HorizontalAlignment.CENTER); + //垂直居中 + titleStyle.setVerticalAlignment(VerticalAlignment.CENTER); + //设置颜色 + titleStyle.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex()); + titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + titleStyle.setBorderRight(BorderStyle.THIN); + titleStyle.setBorderLeft(BorderStyle.THIN); + titleStyle.setBorderBottom(BorderStyle.THIN); + titleStyle.setBorderTop(BorderStyle.THIN); + titleStyle.setWrapText(true); + return titleStyle; + } + + @Override + public CellStyle getHeaderStyle(short color) { + CellStyle titleStyle = workbook.createCellStyle(); + Font font = workbook.createFont(); + font.setFontHeightInPoints((short) 12); + titleStyle.setFont(font); + titleStyle.setAlignment(HorizontalAlignment.CENTER); + titleStyle.setVerticalAlignment(VerticalAlignment.CENTER); + return null; + } + + /** + * desc:隔行样式 + * @param workbook + * @param isWarp + * @return + */ + @Override + public CellStyle stringNoneStyle(Workbook workbook, boolean isWarp) { + CellStyle style = workbook.createCellStyle(); + //style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + style.setDataFormat(STRING_FORMAT); + if (isWarp) { + style.setWrapText(true); + } + + return style; + } + + /** + * desc:隔行样式 + * @param workbook + * @param isWarp + * @return + */ + @Override + public CellStyle stringSeptailStyle(Workbook workbook, boolean isWarp) { + CellStyle style = workbook.createCellStyle(); + //style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + style.setDataFormat(STRING_FORMAT); + if (isWarp) { + style.setWrapText(true); + } + return style; + } + +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/excel/ExportMultiView.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/poi/excel/ExportMultiView.java similarity index 91% rename from epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/excel/ExportMultiView.java rename to epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/poi/excel/ExportMultiView.java index ff69b2c4b0..6169e83075 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/excel/ExportMultiView.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/poi/excel/ExportMultiView.java @@ -1,4 +1,4 @@ -package com.epmet.commons.tools.utils.excel; +package com.epmet.commons.tools.utils.poi.excel; import cn.afterturn.easypoi.excel.entity.ExportParams; import lombok.AllArgsConstructor; diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/poi/excel/FreezeAndFilter.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/poi/excel/FreezeAndFilter.java new file mode 100644 index 0000000000..6b5d5e55c5 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/poi/excel/FreezeAndFilter.java @@ -0,0 +1,46 @@ +package com.epmet.commons.tools.utils.poi.excel; + +/** + * desc:easyExcel 冻结标题 + * + * @author: LiuJanJun + * @date: 2022/4/11 10:27 上午 + * @version: 1.0 + */ + +import com.alibaba.excel.write.handler.SheetWriteHandler; +import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; +import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.util.CellRangeAddress; + + +public class FreezeAndFilter implements SheetWriteHandler { + + public int colSplit = 0, rowSplit = 1, leftmostColumn = 0, topRow = 1; + public String autoFilterRange = "1:1"; + private boolean isFilter; + + public FreezeAndFilter() { + + } + public FreezeAndFilter(boolean isFilter) { + this.isFilter = isFilter; + } + + @Override + public void beforeSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) { + + } + + @Override + public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) { + Sheet sheet = writeSheetHolder.getSheet(); + sheet.createFreezePane(colSplit, rowSplit, leftmostColumn, topRow); + //不让他筛选 + if (isFilter){ + sheet.setAutoFilter(CellRangeAddress.valueOf(autoFilterRange)); + } + } +} + diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java index e55db49a65..cd77750bee 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java @@ -11,7 +11,7 @@ import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.ExcelUtils; -import com.epmet.commons.tools.utils.excel.ExportMultiView; +import com.epmet.commons.tools.utils.poi.excel.ExportMultiView; import com.epmet.dataaggre.constant.DataSourceConstant; import com.epmet.dataaggre.constant.OrgConstant; import com.epmet.dataaggre.dao.datastats.DataStatsDao; diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/BackDoorController.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/BackDoorController.java index 047ae55ce6..f5f762838b 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/BackDoorController.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/BackDoorController.java @@ -44,7 +44,8 @@ public class BackDoorController { * @param customerId * @return */ - @GetMapping(value = "initpointrule") + //@GetMapping(value = "initpointrule") + @RequestMapping(value = "initpointrule", method = {RequestMethod.POST, RequestMethod.GET}) public Result initPointRule(@RequestParam(required = false) String customerId) { InitPointRuleResultDTO resultDTO = pointRuleService.initPointRule(customerId); return new Result().ok(resultDTO); diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java index edfc0bdcb7..e3ffa35663 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java @@ -524,7 +524,7 @@ public interface GovOrgOpenFeignClient { * @date 2021/11/3 3:30 下午 */ @PostMapping("/gov/org/ichouse/selecthouseinfobyidcard") - Result> selectHouseInfoByIdCard(@RequestParam("idCard")String idCard); + Result> selectHouseInfoByIdCard(@RequestParam("idCard")String idCard,@RequestParam("customerId")String customerId); @GetMapping("/gov/org/ichouse/{id}") Result get(@PathVariable("id") String id); diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java index d66317aa2b..dd29ab6129 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java @@ -311,8 +311,8 @@ public class GovOrgOpenFeignClientFallback implements GovOrgOpenFeignClient { } @Override - public Result> selectHouseInfoByIdCard(String idCard) { - return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "selectHouseInfoByIdCard", idCard); + public Result> selectHouseInfoByIdCard(String idCard,String customerId) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "selectHouseInfoByIdCard", idCard, customerId); } @Override 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 394448e623..fca09fe069 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 @@ -29,7 +29,6 @@ import com.epmet.commons.tools.exception.EpmetException; 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.constant.ImportErrorMsgConstants; import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.IcBuildingUnitDao; import com.epmet.dto.BuildingTreeLevelDTO; @@ -42,8 +41,6 @@ import com.epmet.entity.IcBuildingUnitEntity; import com.epmet.excel.IcBuildingExcel; import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.service.BuildingService; -import com.epmet.service.IcBuildingService; -import com.epmet.service.NeighborHoodService; import com.epmet.util.ExcelPoiUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -118,7 +115,7 @@ public class BuildingController { @PostMapping("treelist") public Result treeList(@LoginUser TokenDto tokenDTO){ - List buildingTreeLevelDTOS =buildingService.treeList(tokenDTO.getUserId()); + List buildingTreeLevelDTOS =buildingService.treeList(tokenDTO.getCustomerId(), tokenDTO.getUserId()); return new Result().ok(buildingTreeLevelDTOS); } /** diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcHouseController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcHouseController.java index 2409edaad0..8473a7ac72 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcHouseController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcHouseController.java @@ -98,8 +98,8 @@ public class IcHouseController { * @date 2021/11/3 3:30 下午 */ @PostMapping("selecthouseinfobyidcard") - public Result> selectHouseInfoByIdCard(@RequestParam("idCard")String idCard){ - return new Result>().ok(icHouseService.selectHouseInfoByIdCard(idCard)); + public Result> selectHouseInfoByIdCard(@RequestParam("idCard")String idCard,@RequestParam("customerId")String customerId){ + return new Result>().ok(icHouseService.selectHouseInfoByIdCard(idCard,customerId)); } /** diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java index f4b4a2c402..c5a392e6ca 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java @@ -52,7 +52,7 @@ public interface IcHouseDao extends BaseDao { * @author zxc * @date 2021/11/3 3:30 下午 */ - List selectHouseInfoByIdCard(@Param("idCard") String idCard); + List selectHouseInfoByIdCard(@Param("idCard") String idCard,@Param("customerId")String customerId); Integer checkDoorNameUq(@Param("neighborHoodId") String neighborHoodId, @Param("buildingId")String buildingId, diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java index 9596a59d1d..c9144ef5ff 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java @@ -163,7 +163,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener treeList(String customerId); + List treeList(String customerId, String staffId); List importExcel(String customerId, List list, String staffId, List numList); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcHouseService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcHouseService.java index e2110550bf..423f218049 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcHouseService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcHouseService.java @@ -96,7 +96,7 @@ public interface IcHouseService extends BaseService { * @author zxc * @date 2021/11/3 3:30 下午 */ - List selectHouseInfoByIdCard(String idCard); + List selectHouseInfoByIdCard(String idCard,String customerId); /** * @Description 楼栋下房屋列表 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 28baadf38f..04670fde28 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 @@ -13,45 +13,37 @@ 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.EpmetException; 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.constant.ImportErrorMsgConstants; import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.*; import com.epmet.dto.BuildingTreeLevelDTO; -import com.epmet.dto.CustomerStaffAgencyDTO; import com.epmet.dto.IcBuildingDTO; import com.epmet.dto.form.IcBulidingFormDTO; import com.epmet.dto.form.ImportInfoFormDTO; import com.epmet.dto.form.ImportTaskCommonFormDTO; import com.epmet.dto.form.ListIcNeighborHoodFormDTO; -import com.epmet.dto.result.*; +import com.epmet.dto.result.BuildingResultDTO; +import com.epmet.dto.result.BuildingResultPagedDTO; +import com.epmet.dto.result.IcNeighborHoodResultDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.entity.*; import com.epmet.enums.BuildingTypeEnums; import com.epmet.excel.IcBuildingExcel; import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.model.BuildingInfoModel; -import com.epmet.model.HouseInfoModel; import com.epmet.model.ImportBuildingInfoListener; import com.epmet.redis.IcHouseRedis; import com.epmet.service.*; -import com.epmet.service.BuildingService; -import com.epmet.service.IcBuildingService; -import com.epmet.service.IcBuildingUnitService; -import com.epmet.service.IcHouseService; import com.epmet.util.ExcelPoiUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Async; -import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; -import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; @@ -128,8 +120,8 @@ public class BuildingServiceImpl implements BuildingService { } @Override - public List treeList(String staffId) { - CustomerStaffAgencyDTO agency = customerStaffAgencyDao.selectLatestCustomerByStaff(staffId); + public List treeList(String customerId, String staffId) { + CustomerStaffInfoCacheResult agency = CustomerStaffRedis.getStaffInfo(customerId, staffId); if(null == agency || StringUtils.isBlank(agency.getAgencyId())){ log.error("com.epmet.service.impl.BuildingServiceImpl.treeList,没有找到工作人员所属的机关信息,用户Id:{}",staffId); return new ArrayList<>(); @@ -163,7 +155,7 @@ public class BuildingServiceImpl implements BuildingService { //2.获取组织所在网格 - List agencyIdList = customerAgencyList.stream().map(a->a.getId()).collect(Collectors.toList()); + List agencyIdList = customerAgencyList.stream().map(BaseEpmetEntity::getId).collect(Collectors.toList()); // agencyIdList.add(customerAgency.getId()); List customerGridList = customerGridDao.selectList(new QueryWrapper().lambda().in(CustomerGridEntity::getPid, agencyIdList)); @@ -222,8 +214,12 @@ public class BuildingServiceImpl implements BuildingService { agencyList.addAll(neighbourHoodList); return covertToTree(customerAgency,agencyList); } + //获取楼里已经有多少个房屋 + LambdaQueryWrapper icHouseEntityWrapper = new QueryWrapper().lambda() + .in(IcHouseEntity::getNeighborHoodId, neighborHoodIdList); + List buildingHouseCount = icHouseDao.selectList(icHouseEntityWrapper); + Map buildingHouseCountMap = buildingHouseCount.stream().collect(Collectors.groupingBy(IcHouseEntity::getBuildingId, Collectors.counting())); //组合封装 - List buildingList = icBuildingList.stream().map(item -> { BuildingTreeLevelDTO buildingTreeLevelDTO = new BuildingTreeLevelDTO(); buildingTreeLevelDTO.setId(item.getId()); @@ -246,9 +242,10 @@ public class BuildingServiceImpl implements BuildingService { //02.11 之前录入的户数概念改为总户数,无需计算直接用就可以了 Integer total = null == item.getTotalHouseNum() ? NumConstant.ZERO : item.getTotalHouseNum(); //已经添加了多少户 - LambdaQueryWrapper icHouseEntityWrapper = new QueryWrapper().lambda() - .in(IcHouseEntity::getBuildingId, item.getId()); - int count= icHouseDao.selectCount(icHouseEntityWrapper); +// LambdaQueryWrapper icHouseEntityWrapper = new QueryWrapper().lambda() +// .in(IcHouseEntity::getBuildingId, item.getId()); +// int count= icHouseDao.selectCount(icHouseEntityWrapper); + int count = buildingHouseCountMap.getOrDefault(item.getId(), NumConstant.ZERO_L).intValue(); if(NumConstant.ZERO==total){ buildingTreeLevelDTO.setShowNum(String.format("%s/%s",count,count)); }else{ diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java index 0e32dbef1e..f0afc84a28 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java @@ -137,8 +137,8 @@ public class IcHouseServiceImpl extends BaseServiceImpl selectHouseInfoByIdCard(String idCard) { - List result = baseDao.selectHouseInfoByIdCard(idCard); + public List selectHouseInfoByIdCard(String idCard,String customerId) { + List result = baseDao.selectHouseInfoByIdCard(idCard,customerId); if (CollectionUtils.isEmpty(result)){ return new ArrayList<>(); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml index f3698b35ed..0db3dfa93e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml @@ -327,7 +327,7 @@ - SELECT CONCAT(inh.NEIGHBOR_HOOD_NAME,ib.BUILDING_NAME,ibu.UNIT_NAME,ih.HOUSE_NAME) FROM ic_house ih @@ -336,6 +336,7 @@ LEFT JOIN ic_building_unit ibu ON (ibu.ID = ih.BUILDING_UNIT_ID AND ibu.DEL_FLAG = '0') WHERE ih.DEL_FLAG = '0' AND ih.OWNER_ID_CARD = #{idCard} + and ih.CUSTOMER_ID = #{customerId}