diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/LogOperationHelper.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/LogOperationHelper.java index b8c82f6640..ce6502583e 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/LogOperationHelper.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/LogOperationHelper.java @@ -57,7 +57,7 @@ public class LogOperationHelper implements ResultDataResolver { form.setUserId(userId); Result result = userOpenFeignClient.getCustomerStaffInfoByUserId(form); CustomerStaffDTO staffInfo = getResultDataOrThrowsException(result, ServiceConstant.EPMET_ADMIN_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), - "调用epmet-user服务获取staff信息发生异常"); + "调用epmet-user服务获取staff信息发生异常", null); return new OperatorInfo(staffInfo.getCustomerId(), staffInfo.getMobile(), staffInfo.getRealName()); } } diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java index 09b9269063..4ccc4e868f 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java @@ -82,7 +82,7 @@ public class LogOperationServiceImpl implements LogOperationService, ResultDataR CustomerStaffFormDTO form = new CustomerStaffFormDTO(); form.setUserIds(new ArrayList<>(userIds)); Result> result = userOpenFeignClient.list(form); - List staffs = getResultDataOrThrowsException(result, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用user服务发生异常"); + List staffs = getResultDataOrThrowsException(result, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用user服务发生异常", null); HashMap staffMap = new HashMap<>(); staffs.forEach(s -> { @@ -103,7 +103,7 @@ public class LogOperationServiceImpl implements LogOperationService, ResultDataR form.setCustomerId(customerId); form.setMobile(operatorMobile); Result> result = userOpenFeignClient.list(form); - List staffs = getResultDataOrThrowsException(result, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用user服务发生异常"); + List staffs = getResultDataOrThrowsException(result, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用user服务发生异常", null); if (staffs.size() == 0) { return null; @@ -134,7 +134,7 @@ public class LogOperationServiceImpl implements LogOperationService, ResultDataR CustomerStaffFormDTO form = new CustomerStaffFormDTO(); form.setRealName(operatorName); Result> result = userOpenFeignClient.list(form); - List staffs = getResultDataOrThrowsException(result, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用user服务查询工作人员信息发生异常"); + List staffs = getResultDataOrThrowsException(result, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用user服务查询工作人员信息发生异常", null); List userIds = new ArrayList<>(); HashMap staffMap = new HashMap(); diff --git a/epmet-auth/src/main/java/com/epmet/controller/IcLoinController.java b/epmet-auth/src/main/java/com/epmet/controller/IcLoinController.java index cd3c5543e6..659945bddb 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/IcLoinController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/IcLoinController.java @@ -76,7 +76,7 @@ public class IcLoinController implements ResultDataResolver { // 获取用户信息 Result> staffResult = epmetUserFeignClient.checkCustomerStaff(mobile); - List staffList = getResultDataOrThrowsException(staffResult, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【基层治理平台登录】获取用户信息失败"); + List staffList = getResultDataOrThrowsException(staffResult, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【基层治理平台登录】获取用户信息失败", null); if (CollectionUtils.isEmpty(staffList)) { throw new RenException(EpmetErrorCode.ERR10003.getCode()); } @@ -93,7 +93,7 @@ public class IcLoinController implements ResultDataResolver { RootOrgListByStaffIdFormDTO orgListForm = new RootOrgListByStaffIdFormDTO(); orgListForm.setStaffId(staffId); Result> orgListResult = govOrgOpenFeignClient.getStaffOrgListByStaffId(orgListForm); - List orgs = getResultDataOrThrowsException(orgListResult, ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【基层治理平台登录】根据staffId查询所属客户跟组织列表失败"); + List orgs = getResultDataOrThrowsException(orgListResult, ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【基层治理平台登录】根据staffId查询所属客户跟组织列表失败", null); // 生成登录票据 String ticket = UUID.randomUUID().toString().replace("-", ""); diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/IcLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/IcLoginServiceImpl.java index d14db75885..1e1767070e 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/IcLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/IcLoginServiceImpl.java @@ -65,7 +65,7 @@ public class IcLoginServiceImpl implements IcLoginService, ResultDataResolver { String token = this.generateIcToken(staffId, app, client); Result agencyResult = govOrgOpenFeignClient.getAgencyById(orgId); - CustomerAgencyDTO agencyInfo = getResultDataOrThrowsException(agencyResult, ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【IC平台登录】获取组织信息失败"); + CustomerAgencyDTO agencyInfo = getResultDataOrThrowsException(agencyResult, ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【IC平台登录】获取组织信息失败", null); // 2.缓存token cacheToken(app, client, staffId, token, orgId, agencyInfo.getCustomerId()); diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java index 2e1d7d5bea..a18f34f72b 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java @@ -75,6 +75,8 @@ public interface StrConstant { String STAR="*"; String QUESTION_MARK="?"; + String QUESTION_MARK_TRANSFER="\\?"; + String AND_MARK="&"; /** * 空字符串 diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/FormItemTypeEnum.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/FormItemTypeEnum.java new file mode 100644 index 0000000000..753852bfff --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/FormItemTypeEnum.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.commons.tools.enums; + +/** + * form表单 配置item类型 枚举 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +public enum FormItemTypeEnum { + //枚举类型 + INPUT("input", "输入框"), + RADIO("radio", "单选框"), + CHECKBOX("checkbox", "复选框"), + SELECT("select", "下拉框"), + TEXTAREA("textarea", "文本域"), + CASCADER("cascader", "及联"), + DATE_PICKER("datepicker", "组织"), + UN_KNOWN("un_known", "不支持的类型"); + + private String code; + private String desc; + + FormItemTypeEnum(String value,String name) { + this.code = value; + this.desc = name; + } + + public static FormItemTypeEnum getEnum(String code) { + FormItemTypeEnum[] values = FormItemTypeEnum.values(); + for (FormItemTypeEnum value : values) { + if (value.getCode().equals(code)) { + return value; + } + } + return UN_KNOWN; + } + + public String getCode() { + return code; + } + + public String getDesc() { + return desc; + } +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index 37034958e9..a470c0122a 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -229,7 +229,12 @@ public enum EpmetErrorCode { ORG_ADD_FAILED(8919,"添加失败"), ORG_EDIT_FAILED(8920,"编辑失败"), - ORG_DEL_FAILED(8921,"删除失败"); + ORG_DEL_FAILED(8921,"删除失败"), + //通用的 错误消息自己定义返回 + OPERATION_FAILED(9999,"网络开小差。。。"), + ; + + private int code; private String msg; diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java index 5b56e64b1a..1bfa31e96b 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java @@ -34,18 +34,19 @@ public interface ResultDataResolver { * @return * @param targetServiceName 目标service名称 * @param errorCode 错误码,可以为空,为空则使用上游服务抛出的错误码 - * @param errorInternalMsg 错误信息,可以为空,为空则使用上游服务抛出的异常信息 + * @param errorInternalMsg 内部错误信息,可以为空,为空则使用上游服务抛出的异常信息 + * @param showMsg 展示给前端程序的错误信息,可以为空。为空则根据errorCode给定错误msg信息 * @author wxz * @date 2021.06.07 22:45 */ - default R getResultDataOrThrowsException(Result result, String targetServiceName, Integer errorCode, String errorInternalMsg) { + default R getResultDataOrThrowsException(Result result, String targetServiceName, Integer errorCode, String errorInternalMsg, String showMsg) { if (result == null) { throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), "调用{}服务发生错误,返回Result为null", targetServiceName); } if (!result.success()) { Integer finalErrorCode = errorCode == null ? result.getCode() : errorCode; String finalErrorInternalMsg = StringUtils.isBlank(errorInternalMsg) ? result.getInternalMsg() : errorInternalMsg; - throw new RenException(finalErrorCode, finalErrorInternalMsg); + throw new RenException(finalErrorCode, finalErrorInternalMsg, showMsg, RenException.MessageMode.CODE_INTERNAL_EXTERNAL); } return result.getData(); } diff --git a/epmet-gateway/src/main/java/com/epmet/config/CorsConfig.java b/epmet-gateway/src/main/java/com/epmet/config/CorsConfig.java index bb95213c1f..72a2e0a31f 100644 --- a/epmet-gateway/src/main/java/com/epmet/config/CorsConfig.java +++ b/epmet-gateway/src/main/java/com/epmet/config/CorsConfig.java @@ -117,7 +117,7 @@ class EpmetWebFilter implements WebFilter, ResultDataResolver { adminOpenFeignClient.list(), ServiceConstant.EPMET_ADMIN_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), - "调用Admin服务查询Cors配置失败"); + "调用Admin服务查询Cors配置失败", null); } catch (Exception e) { logger.error("调用Admin服务查询Cors配置失败"); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/impl/QuestionnaireServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/impl/QuestionnaireServiceImpl.java index 1c6aab452d..2d69ac0fb3 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/impl/QuestionnaireServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/impl/QuestionnaireServiceImpl.java @@ -73,7 +73,7 @@ public class QuestionnaireServiceImpl implements QuestionnaireService, ResultDat CustomerGridFormDTO form = new CustomerGridFormDTO(); form.setGridId(gridId); Result gridInfoResult = govOrgOpenFeignClient.getGridBaseInfoByGridId(form); - CustomerGridDTO gridInfo = getResultDataOrThrowsException(gridInfoResult, ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【调查问卷】校验访问权限,查询网格信息失败"); + CustomerGridDTO gridInfo = getResultDataOrThrowsException(gridInfoResult, ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【调查问卷】校验访问权限,查询网格信息失败", null); // 网格父级ID列表:网格ID(拼接起来,冒号分割) String gridIdPath = gridInfo.getPids().concat(":").concat(gridInfo.getId()); List publishRangeEntity = prPublishRangeService.getPublishRangeEntity(projectKey); diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/BizPointTotalDetailServiceImpl.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/BizPointTotalDetailServiceImpl.java index 87b7b20a32..2fd521d1d9 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/BizPointTotalDetailServiceImpl.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/BizPointTotalDetailServiceImpl.java @@ -380,7 +380,7 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl> result = resiGroupOpenFeignClient.listGroupDetailsExcludeGroupIds(form); - List groups = getResultDataOrThrowsException(result, ServiceConstant.RESI_GROUP_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【小组排名】查询积分为0的小组列表失败"); + List groups = getResultDataOrThrowsException(result, ServiceConstant.RESI_GROUP_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【小组排名】查询积分为0的小组列表失败", null); if (CollectionUtils.isEmpty(groups)) { return new ArrayList<>(); } @@ -412,7 +412,7 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl> listResult = resiGroupOpenFeignClient.listGroupDetailsByGroupIds(groupIds); - List groupInfos = getResultDataOrThrowsException(listResult, ServiceConstant.RESI_GROUP_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【小组排行】批量查询小组信息出错"); + List groupInfos = getResultDataOrThrowsException(listResult, ServiceConstant.RESI_GROUP_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【小组排行】批量查询小组信息出错", null); // 将小组基本信息转化为map HashMap groupMap = new HashMap<>(); @@ -454,7 +454,7 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl result = govOrgOpenFeignClient.getGridBaseInfoByGridId(form); - return getResultDataOrThrowsException(result, ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【小组排名】查询网格信息失败"); + return getResultDataOrThrowsException(result, ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【小组排名】查询网格信息失败", null); } @Override @@ -464,7 +464,7 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl groupList = getResultDataOrThrowsException(resiGroupOpenFeignClient.listGroupsByMember(form), - ServiceConstant.RESI_GROUP_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【我所在的小组排名】查询组列表失败"); + ServiceConstant.RESI_GROUP_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【我所在的小组排名】查询组列表失败", null); if (CollectionUtils.isEmpty(groupList)) { return new ArrayList(); diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/PingyinPrivateEpmetApiService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/PingyinPrivateEpmetApiService.java index da62386442..9878fe2a3c 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/PingyinPrivateEpmetApiService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/PingyinPrivateEpmetApiService.java @@ -55,7 +55,7 @@ public class PingyinPrivateEpmetApiService extends ApiService implements String urlParams = super.convertQueryParams2String(constructCommonUrlParamsMap(platformKey, authType, uuid, currentTimeMillis, sign)); String requestUrl = baseUrl.concat(apiUrl).concat(urlParams); Result stringResult = HttpClientManager.getInstance().sendPostByHttps(requestUrl, "{}"); - String remoteResultString = getResultDataOrThrowsException(stringResult, "【调用平阴私有化平台获取AccessToken】", EpmetErrorCode.SERVER_ERROR.getCode(), null); + String remoteResultString = getResultDataOrThrowsException(stringResult, "【调用平阴私有化平台获取AccessToken】", EpmetErrorCode.SERVER_ERROR.getCode(), null, null); Result remoteResult = parsePlatformResponseResult(remoteResultString, GetAccessTokenResultDTO.class); log.info("【调用平阴私有化平台获取AccessToken】结果:{}", remoteResultString); accessTokenFromCache = remoteResult.getData().getAccessToken(); @@ -159,7 +159,7 @@ public class PingyinPrivateEpmetApiService extends ApiService implements String jsonString = JSON.toJSONString(form); Result result = super.sendPostRequest(platformId, ThirdPlatformActions.PUSH_COMPONENT_ACCESS_TOKEN, jsonString, null, urlParams); - getResultDataOrThrowsException(result, "【平阴私有化平台】推送ComponentAccessToken", EpmetErrorCode.SERVER_ERROR.getCode(), null); + getResultDataOrThrowsException(result, "【平阴私有化平台】推送ComponentAccessToken", EpmetErrorCode.SERVER_ERROR.getCode(), null, null); } @Override diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java index 14dcda318a..fcd64c4658 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java @@ -45,7 +45,7 @@ import java.util.Map; @RestController @RequestMapping("icneighborhood") public class IcNeighborHoodController { - + @Autowired private IcNeighborHoodService icNeighborHoodService; @@ -109,4 +109,4 @@ public class IcNeighborHoodController { return new Result>().ok(icNeighborHoodService.getListByIds(ids)); } -} \ No newline at end of file +} 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 0dbfa5796a..914bc68a56 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 @@ -219,6 +219,17 @@ public class IcHouseServiceImpl extends BaseServiceImpl + * 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 com.epmet.commons.tools.validator.group.UpdateGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +/** + * 居民类别配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-04 + */ +@Data +public class ResiCategoryStatsConfigListFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 是否预警 + */ + private Integer isWarn; + + /** + * 预警等级 + */ + private Integer level; + +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/ResiCategoryStatsConfigController.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/ResiCategoryStatsConfigController.java index fdec343adf..ef94b7b4ac 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/ResiCategoryStatsConfigController.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/ResiCategoryStatsConfigController.java @@ -19,15 +19,12 @@ package com.epmet.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.commons.tools.annotation.LoginUser; -import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.Result; -import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; -import com.epmet.commons.tools.validator.group.AddGroup; -import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.constant.IcResiCategoryStatsConfigConstant; import com.epmet.dao.IcResiCategoryStatsConfigDao; @@ -36,22 +33,21 @@ import com.epmet.dto.IcResiCategoryStatsConfigDTO; import com.epmet.dto.IcResiCategoryWarnConfigDTO; import com.epmet.dto.form.IcResiCategoryStatsConfigFormDTO; import com.epmet.dto.form.IcResiCategoryStatsConfigSortFormDTO; -import com.epmet.dto.form.UpGovRoleFormDTO; +import com.epmet.dto.form.ResiCategoryStatsConfigListFormDTO; import com.epmet.dto.result.IcResiCategoryStatsConfigResultDTO; import com.epmet.entity.IcResiCategoryStatsConfigEntity; import com.epmet.entity.IcResiCategoryWarnConfigEntity; -import com.epmet.excel.IcResiCategoryStatsConfigExcel; import com.epmet.service.IcResiCategoryStatsConfigService; import com.epmet.service.ResiCategoryStatsConfigService; -import com.github.pagehelper.util.StringUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; import java.util.List; -import java.util.Map; /** @@ -63,7 +59,7 @@ import java.util.Map; @RestController @RequestMapping("resicategorystatsconfig") public class ResiCategoryStatsConfigController { - + @Autowired private IcResiCategoryStatsConfigService icResiCategoryStatsConfigService; @Autowired @@ -79,13 +75,14 @@ public class ResiCategoryStatsConfigController { * @return */ @PostMapping("list") - public Result> list(@LoginUser TokenDto tokenDTO){ + public Result> list(@LoginUser TokenDto tokenDTO,@RequestBody ResiCategoryStatsConfigListFormDTO formDTO){ String customerId = tokenDTO.getCustomerId(); // String customerId = "123123"; - return new Result>().ok(resiCategoryStatsConfigService.list(customerId)); + return new Result>().ok(resiCategoryStatsConfigService.list(customerId,formDTO)); } @PostMapping("update") + @NoRepeatSubmit public Result update(@LoginUser TokenDto tokenDTO,@RequestBody IcResiCategoryStatsConfigFormDTO formDTO){ ValidatorUtils.validateEntity(formDTO, UpdateGroup.class); String customerId = tokenDTO.getCustomerId(); @@ -96,13 +93,13 @@ public class ResiCategoryStatsConfigController { if(IcResiCategoryStatsConfigConstant.WARN_YES.equals(formDTO.getWarn())){ //判断level1 和level2 的值 if(null ==level1 || level1==0){ - return new Result().error(8001,"等级1阈值需大于0"); + return new Result().error(EpmetErrorCode.OPERATION_FAILED.getCode(),"黄色预警阈值需大于0"); } if(null == level2 || level2==0){ - return new Result().error(8001,"等级2阈值需大于0"); + return new Result().error(EpmetErrorCode.OPERATION_FAILED.getCode(),"红色预警阈值需大于0"); } if(level2<=level1){ - return new Result().error(8001,"等级2阈值需大于等级1阈值"); + return new Result().error(EpmetErrorCode.OPERATION_FAILED.getCode(),"黄色预警阈值需大于红色预警阈值"); } } resiCategoryStatsConfigService.update(customerId,formDTO); @@ -170,4 +167,4 @@ public class ResiCategoryStatsConfigController { } -} \ No newline at end of file +} diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/ResiCategoryStatsConfigService.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/ResiCategoryStatsConfigService.java index 9f351d91b4..2494953fcb 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/ResiCategoryStatsConfigService.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/ResiCategoryStatsConfigService.java @@ -22,6 +22,7 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.dto.IcResiCategoryStatsConfigDTO; import com.epmet.dto.form.IcResiCategoryStatsConfigFormDTO; import com.epmet.dto.form.IcResiCategoryStatsConfigSortFormDTO; +import com.epmet.dto.form.ResiCategoryStatsConfigListFormDTO; import com.epmet.dto.result.IcResiCategoryStatsConfigResultDTO; import com.epmet.entity.IcResiCategoryStatsConfigEntity; @@ -36,7 +37,7 @@ import java.util.Map; */ public interface ResiCategoryStatsConfigService { - List list(String customerId); + List list(String customerId, ResiCategoryStatsConfigListFormDTO formDTO); IcResiCategoryStatsConfigResultDTO info(String id); diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/ResiCategoryStatsConfigServiceImpl.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/ResiCategoryStatsConfigServiceImpl.java index bfeeaa0b9d..3cdcd7944f 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/ResiCategoryStatsConfigServiceImpl.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/ResiCategoryStatsConfigServiceImpl.java @@ -9,6 +9,7 @@ import com.epmet.dao.IcResiCategoryWarnConfigDao; import com.epmet.dto.IcResiCategoryStatsConfigDTO; import com.epmet.dto.form.IcResiCategoryStatsConfigFormDTO; import com.epmet.dto.form.IcResiCategoryStatsConfigSortFormDTO; +import com.epmet.dto.form.ResiCategoryStatsConfigListFormDTO; import com.epmet.dto.result.IcResiCategoryStatsConfigResultDTO; import com.epmet.entity.IcFormItemEntity; import com.epmet.entity.IcFormItemGroupEntity; @@ -47,7 +48,7 @@ public class ResiCategoryStatsConfigServiceImpl implements ResiCategoryStatsConf @Override @Transactional(rollbackFor = Exception.class) - public List list(String customerId) { + public List list(String customerId, ResiCategoryStatsConfigListFormDTO formDTO) { //1.获取IC_FORM_ITEM 中 用于数据分析字段的 id 和label List icFormItemEntityList = icFormItemDao.selectList(new QueryWrapper().lambda().eq(IcFormItemEntity::getCustomerId,customerId).eq(IcFormItemEntity::getDataAnalyse, 1)); if(CollectionUtils.isEmpty(icFormItemEntityList)){ @@ -160,7 +161,28 @@ public class ResiCategoryStatsConfigServiceImpl implements ResiCategoryStatsConf result.add(icResiCategoryStatsConfigResultDTO); }); - return result; + if(null == formDTO){ + return result; + } + List collect = new ArrayList<>(); + for (IcResiCategoryStatsConfigResultDTO item:result){ + String isWarn = String.valueOf(formDTO.getIsWarn()); + if(null !=formDTO.getIsWarn() && (!item.getWarn().equals(isWarn))){ + continue; + } + if(null!=formDTO.getLevel()){ + if(1==formDTO.getLevel()&&null==item.getLevel1()){ + continue; + } + if(2==formDTO.getLevel()&&null==item.getLevel2()){ + continue; + } + } + collect.add(item); + + } + + return collect; } @Override @@ -198,13 +220,14 @@ public class ResiCategoryStatsConfigServiceImpl implements ResiCategoryStatsConf @Transactional(rollbackFor = Exception.class) public void update(String customerId,IcResiCategoryStatsConfigFormDTO formDTO) { IcResiCategoryStatsConfigDTO icResiCategoryStatsConfigDTO = icResiCategoryStatsConfigService.get(formDTO.getId()); - if(null == icResiCategoryStatsConfigDTO){ + if(null == icResiCategoryStatsConfigDTO || !customerId.equals(icResiCategoryStatsConfigDTO.getCustomerId())){ return ; } + //更新配置类别 IcResiCategoryStatsConfigEntity icResiCategoryStatsConfigEntity = new IcResiCategoryStatsConfigEntity(); BeanUtils.copyProperties(formDTO,icResiCategoryStatsConfigEntity); - icResiCategoryStatsConfigEntity.setCustomerId(customerId); +// icResiCategoryStatsConfigEntity.setCustomerId(customerId); icResiCategoryStatsConfigDao.updateById(icResiCategoryStatsConfigEntity); //更新配置预警 @@ -226,7 +249,7 @@ public class ResiCategoryStatsConfigServiceImpl implements ResiCategoryStatsConf icResiCategoryWarnConfigEntity.setSort(icResiCategoryStatsConfigDTO.getSort()); icResiCategoryWarnConfigDao.insert(icResiCategoryWarnConfigEntity); }else{ - icResiCategoryWarnConfigEntity.setCustomerId(customerId); +// icResiCategoryWarnConfigEntity.setCustomerId(customerId); icResiCategoryWarnConfigEntity.setLabel(icResiCategoryStatsConfigDTO.getLabel()); icResiCategoryWarnConfigEntity.setTableName(icResiCategoryStatsConfigDTO.getTableName()); icResiCategoryWarnConfigEntity.setColumnName(icResiCategoryStatsConfigDTO.getColumnName()); @@ -253,7 +276,7 @@ public class ResiCategoryStatsConfigServiceImpl implements ResiCategoryStatsConf //更新配置类别 IcResiCategoryStatsConfigEntity icResiCategoryStatsConfigEntity = new IcResiCategoryStatsConfigEntity(); BeanUtils.copyProperties(formDTO,icResiCategoryStatsConfigEntity); - icResiCategoryStatsConfigEntity.setCustomerId(customerId); +// icResiCategoryStatsConfigEntity.setCustomerId(customerId); icResiCategoryStatsConfigDao.updateById(icResiCategoryStatsConfigEntity); } @@ -264,7 +287,7 @@ public class ResiCategoryStatsConfigServiceImpl implements ResiCategoryStatsConf for (IcResiCategoryStatsConfigSortFormDTO formDTO : formDTOs) { IcResiCategoryStatsConfigEntity icResiCategoryStatsConfigEntity = new IcResiCategoryStatsConfigEntity(); icResiCategoryStatsConfigEntity.setId(formDTO.getId()); - icResiCategoryStatsConfigEntity.setCustomerId(customerId); +// icResiCategoryStatsConfigEntity.setCustomerId(customerId); icResiCategoryStatsConfigEntity.setSort(formDTO.getSort()); entityList.add(icResiCategoryStatsConfigEntity); } diff --git a/epmet-module/resi-home/resi-home-server/src/main/java/com/epmet/service/impl/ResiEventServiceImpl.java b/epmet-module/resi-home/resi-home-server/src/main/java/com/epmet/service/impl/ResiEventServiceImpl.java index 36a2a43684..fa19f94f14 100644 --- a/epmet-module/resi-home/resi-home-server/src/main/java/com/epmet/service/impl/ResiEventServiceImpl.java +++ b/epmet-module/resi-home/resi-home-server/src/main/java/com/epmet/service/impl/ResiEventServiceImpl.java @@ -50,7 +50,7 @@ public class ResiEventServiceImpl implements ResiEventService, ResultDataResolve //查询人大代表列表 ListUserByBadgeFormDTO npcForm = new ListUserByBadgeFormDTO(customerId, BadgeConstant.BADGE_KEY_NPC); Result> npcResult = epmetUserOpenFeignClient.listUsersByBadge(npcForm); - List npcData = getResultDataOrThrowsException(npcResult, ServiceConstant.EPMET_USER_SERVER, null, null); + List npcData = getResultDataOrThrowsException(npcResult, ServiceConstant.EPMET_USER_SERVER, null, null, null); if(CollectionUtils.isEmpty(npcData)) { // 没有人大代表,直接返回空列表即可 @@ -61,7 +61,7 @@ public class ResiEventServiceImpl implements ResiEventService, ResultDataResolve List npcGridIds = npcData.stream().map(d -> d.getGridId()).collect(Collectors.toList()); OrgInfoFormDTO form = new OrgInfoFormDTO(OrgInfoConstant.GRID, npcGridIds); Result> npcGridInfoResult = govOrgOpenFeignClient.selectOrgInfo(form); - List npcGridInfos = getResultDataOrThrowsException(npcGridInfoResult, ServiceConstant.GOV_ORG_SERVER, null, null); + List npcGridInfos = getResultDataOrThrowsException(npcGridInfoResult, ServiceConstant.GOV_ORG_SERVER, null, null, null); Map npcGridInfoMap = convertNpcGridInfos2Map(npcGridInfos); @@ -109,7 +109,7 @@ public class ResiEventServiceImpl implements ResiEventService, ResultDataResolve TreeSet targetLevels = new TreeSet<>(); Result gridInfoResult = govOrgOpenFeignClient.queryGridInfo(gridId); - GridInfoResultDTO gridInfoData = getResultDataOrThrowsException(gridInfoResult, ServiceConstant.GOV_ORG_SERVER, null, null); + GridInfoResultDTO gridInfoData = getResultDataOrThrowsException(gridInfoResult, ServiceConstant.GOV_ORG_SERVER, null, null, null); String pidsPath = gridInfoData.getPids(); List parentOrgIds = Arrays.asList(pidsPath.split(":")); // 翻转列表 @@ -118,7 +118,7 @@ public class ResiEventServiceImpl implements ResiEventService, ResultDataResolve // 一.网格信息(只有一条,但是为了适应接口,组装成了列表) List currentGridId = Arrays.asList(gridId); Result> currentGridInfoResult = govOrgOpenFeignClient.selectOrgInfo(new OrgInfoFormDTO(OrgInfoConstant.GRID, currentGridId)); - List currentGridInfos = getResultDataOrThrowsException(currentGridInfoResult, ServiceConstant.GOV_ORG_SERVER, null, null); + List currentGridInfos = getResultDataOrThrowsException(currentGridInfoResult, ServiceConstant.GOV_ORG_SERVER, null, null, null); OrgInfoResultDTO currentGridInfo = currentGridInfos.get(0); // 因为上游接口的值对应问题,这里只好做一个适配,拼接起来,希望上游代码不要再改了... @@ -128,7 +128,7 @@ public class ResiEventServiceImpl implements ResiEventService, ResultDataResolve // 二.父级组织信息 Result> parentOrgInfoResult = govOrgOpenFeignClient.selectOrgInfo(new OrgInfoFormDTO(OrgInfoConstant.AGENCY, parentOrgIds)); - List parentOrgInfos = getResultDataOrThrowsException(parentOrgInfoResult, ServiceConstant.GOV_ORG_SERVER, null, null); + List parentOrgInfos = getResultDataOrThrowsException(parentOrgInfoResult, ServiceConstant.GOV_ORG_SERVER, null, null, null); parentOrgInfos.forEach(porg -> { String levelName = OrgLevelEnums.getLevelName(porg.getLevel()); if (StringUtils.isBlank(levelName)) { diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/IcResiUserConstant.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/IcResiUserConstant.java new file mode 100644 index 0000000000..6b32f663fc --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/IcResiUserConstant.java @@ -0,0 +1,11 @@ +package com.epmet.constant; + +/** + * @author zhaoqifeng + * @dscription + * @date 2021/6/8 15:28 + */ +public interface IcResiUserConstant { + + String IC_RESI_USER = "ic_resi_user"; +} 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 8b571dce85..7f95af3d76 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 @@ -44,10 +44,12 @@ import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.commons.tools.utils.IpUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.constant.IcResiUserConstant; import com.epmet.dto.IcResiUserDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.enums.IcResiUserTableEnum; +import com.epmet.excel.support.ExportResiUserItemDTO; import com.epmet.feign.OperCustomizeOpenFeignClient; import com.epmet.feign.OssFeignClient; import com.epmet.service.IcResiUserImportService; @@ -84,7 +86,7 @@ import java.util.stream.Collectors; @RestController @RequestMapping("icresiuser") public class IcResiUserController { - private static final String BASE_TABLE_NAME = "ic_resi_user"; + //todo 枚举吧 private static final String IC_RESI_FORM_CODE = "resi_base_info"; @@ -227,7 +229,7 @@ public class IcResiUserController { Map> otherSheetItems = buildItemMap(resiFormItems); - Map> resiMainList = icResiUserService.getDataForExport(otherSheetItems.get(BASE_TABLE_NAME), BASE_TABLE_NAME, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath); + Map> resiMainList = null;//icResiUserService.getDataForExport(otherSheetItems.get(IcResiUserConstant.IC_RESI_USER), IcResiUserConstant.IC_RESI_USER, pageFormDTO, 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,13 +243,13 @@ public class IcResiUserController { AtomicInteger n = new AtomicInteger(); for (FormItemResult item : resiFormItems.getItemList()) { //如果 childGroup是空 或者是主表 则跳过 继续下次循环 - if (item.getChildGroup() == null || BASE_TABLE_NAME.equals(item.getChildGroup().getTableName())) { + if (item.getChildGroup() == null || IcResiUserConstant.IC_RESI_USER.equals(item.getChildGroup().getTableName())) { continue; } String tableName = item.getChildGroup().getTableName(); Map itemMap1 = otherSheetItems.get(tableName); - Map> resiChildMap = icResiUserService.getDataForExport(itemMap1, tableName, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath); + Map> resiChildMap = null;//icResiUserService.getDataForExport(itemMap1, tableName, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath); //resiChildMap.forEach((key, value) -> value.putAll(resiMainList.get(key))); Map mapData2 = new HashMap<>(); @@ -286,7 +288,7 @@ public class IcResiUserController { ExcelWriter excelWriter = EasyExcel.write(getOutputStream("居民基本信息.xlsx", response)).withTemplate(file).build(); FillConfig fillConfig = FillConfig.builder().direction(WriteDirectionEnum.VERTICAL).build(); - IcResiUserTableEnum tableEnums = IcResiUserTableEnum.getObjectByTableName(BASE_TABLE_NAME); + IcResiUserTableEnum tableEnums = IcResiUserTableEnum.getObjectByTableName(IcResiUserConstant.IC_RESI_USER); WriteSheet fistSheet = EasyExcel.writerSheet(tableEnums.getSheetNo()).build(); pageFormDTO.setPageSize(NumConstant.FIVE_HUNDRED); @@ -296,24 +298,24 @@ public class IcResiUserController { Map childTableWriteSheetMap = new HashMap<>(); Map> resiMainTableMap = null; do { - resiMainTableMap = icResiUserService.getDataForExport(otherSheetItems.get(BASE_TABLE_NAME), BASE_TABLE_NAME, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath); + resiMainTableMap = null;//icResiUserService.getDataForExport(otherSheetItems.get(IcResiUserConstant.IC_RESI_USER), IcResiUserConstant.IC_RESI_USER, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath); //如果 返回的条数小于每页显示的数 则退出查询 if (resiMainTableMap.keySet().size() < pageFormDTO.getPageSize()) { - stopSearchSet.add(BASE_TABLE_NAME); + stopSearchSet.add(IcResiUserConstant.IC_RESI_USER); } //写入数据 excelWriter.fill(new FillWrapper("t1", resiMainTableMap.values()), fillConfig, fistSheet); pageFormDTO.setPageNo(pageFormDTO.getPageNo() + 1); //重置数据 resiMainTableMap.clear(); - } while (!stopSearchSet.contains(BASE_TABLE_NAME)); + } while (!stopSearchSet.contains(IcResiUserConstant.IC_RESI_USER)); //子表数据写入 AtomicInteger n = new AtomicInteger(); for (FormItemResult item : resiFormItems.getItemList()) { //如果 childGroup是空 或者是主表 则跳过 继续下次循环 - if (item.getChildGroup() == null || BASE_TABLE_NAME.equals(item.getChildGroup().getTableName())) { + if (item.getChildGroup() == null || IcResiUserConstant.IC_RESI_USER.equals(item.getChildGroup().getTableName())) { continue; } String tableName = item.getChildGroup().getTableName(); @@ -326,7 +328,7 @@ public class IcResiUserController { continue; } Map itemMap1 = otherSheetItems.get(tableName); - Map> resiChildMap = icResiUserService.getDataForExport(itemMap1, tableName, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath); + Map> resiChildMap = null;//icResiUserService.getDataForExport(itemMap1, tableName, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath); //如果 返回的条数小于每页显示的数 则退出查询 if (resiChildMap.keySet().size() < pageFormDTO.getPageSize()) { stopSearchSet.add(tableName); @@ -352,6 +354,18 @@ public class IcResiUserController { excelWriter.finish(); } + /** + * desc: 导出居民信息 + * + * @param customerId + * @param tokenDto + * @param pageFormDTO + * @param response + * @return void + * @author LiuJanJun + * @date 2021/11/19 4:24 下午 + * @remark:分页批量导出 + */ @RequestMapping(value = "/exportExcel") public void exportExcelByEasyExcel(@RequestHeader String customerId,@LoginUser TokenDto tokenDto, @RequestBody IcResiUserPageFormDTO pageFormDTO, HttpServletResponse response) throws Exception { //tokenDto.setUserId("9e37adcce6472152e6508a19d3683e02"); @@ -365,50 +379,69 @@ public class IcResiUserController { pageFormDTO.setCustomerId(customerId); pageFormDTO.setPageFlag(false); - - //获取模版文件 File file = getExportTemplateFile(customerId); ExcelWriter excelWriter = null; try { excelWriter = EasyExcel.write(getOutputStream("居民基本信息.xlsx", response)).withTemplate(file).build(); - pageFormDTO.setPageSize(NumConstant.FIVE_HUNDRED); - pageFormDTO.setPageNo(NumConstant.ONE); //子表是否停止查询 Set stopSearchSet = new HashSet<>(); - //获取表单项 List resiFormAllItems = icResiUserService.listFormItems(customerId, IC_RESI_FORM_CODE); + Map allItemMap = resiFormAllItems.stream().collect(Collectors.toMap(FormItemResult::getItemId, o -> o)); + Map map = new HashMap<>(); + allItemMap.values().forEach(item->{ + String tableName = item.getTableName(); + ExportResiUserItemDTO exportItem = map.getOrDefault(tableName, new ExportResiUserItemDTO()); + map.putIfAbsent(tableName,exportItem); + String columnName = item.getColumnName().concat(item.getColumnNum() == NumConstant.ZERO ? StrConstant.EPMETY_STR : item.getColumnNum().toString()); + exportItem.getItemMap().put(columnName,item); + if (item.getOptionSourceType().equals("remote")&&item.getOptionSourceValue().contains(StrConstant.QUESTION_MARK)){ + //多个参数 + String[] paramArr = item.getOptionSourceValue().split(StrConstant.QUESTION_MARK_TRANSFER)[NumConstant.ONE].split(StrConstant.AND_MARK); + Arrays.stream(paramArr).forEach(o->{ + FormItemResult value = allItemMap.get(o); + if (value == null){ + return; + } + Set conditionSet = exportItem.getRemoteItemConditionMap().getOrDefault(item.getItemId(),new HashSet<>()); + conditionSet.add(value); + exportItem.getRemoteItemConditionMap().putIfAbsent(item.getItemId(),conditionSet); + }); + } + }); + //每个表对应的 item ;key:表名,value:<字段名:item对象> - Map> tableItemMap = resiFormAllItems.stream() - .collect(Collectors.groupingBy(FormItemResult::getTableName, - Collectors.toMap(o->o.getColumnName().concat(NumConstant.ZERO == o.getColumnNum()? StrConstant.EPMETY_STR:o.getColumnNum().toString()), o -> o))); Map childTableWriteSheetMap = new HashMap<>(); //表数据写入 //通过枚举获取相关表并按照sheetNo排序 List resiTableList = Arrays.stream(IcResiUserTableEnum.values()) .sorted(Comparator.comparing(IcResiUserTableEnum::getSheetNo)) .collect(Collectors.toList()); + List> resiResultList = null; + + pageFormDTO.setPageSize(NumConstant.FIVE_HUNDRED); for (IcResiUserTableEnum tableEnum : resiTableList) { String tableName = tableEnum.getTableName(); pageFormDTO.setPageNo(NumConstant.ONE); - //循环一次 写入每个sheet + //循环一次 写入一个sheet do { - Map> resiChildMap = icResiUserService.getDataForExport(tableItemMap.get(tableName), tableName, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath); + resiResultList = icResiUserService.getDataForExport(map.get(tableName), tableName, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath); //如果 返回的条数小于每页显示的数 则退出查询 - if (resiChildMap.keySet().size() < pageFormDTO.getPageSize()) { + if (resiResultList.size() < pageFormDTO.getPageSize()) { stopSearchSet.add(tableName); } //如果没有 构建新的writeSheet WriteSheet writeSheet = childTableWriteSheetMap.getOrDefault(tableName,EasyExcel.writerSheet(tableEnum.getSheetNo()).build()); childTableWriteSheetMap.putIfAbsent(tableName, writeSheet); //写入数据 - excelWriter.fill(new FillWrapper("t" + (tableEnum.getSheetNo() + NumConstant.ONE), resiChildMap.values()), writeSheet); + excelWriter.fill(new FillWrapper("t" + (tableEnum.getSheetNo() + NumConstant.ONE), resiResultList), writeSheet); pageFormDTO.setPageNo(pageFormDTO.getPageNo() + NumConstant.ONE); //重置数据 - resiChildMap.clear(); + resiResultList.clear(); + //如果包含则说明子表的数据 已经查询完毕 无需再继续查询了 } while (!stopSearchSet.contains(tableName)); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/enums/IcResiUserTableEnum.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/enums/IcResiUserTableEnum.java index eb4ecd977e..ffd0076429 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/enums/IcResiUserTableEnum.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/enums/IcResiUserTableEnum.java @@ -10,7 +10,9 @@ import lombok.AllArgsConstructor; */ @AllArgsConstructor public enum IcResiUserTableEnum { - + /** + * 注释 + */ IC_RESI_USER("ic_resi_user","社区居民基本信息录入表", 0, 3, null), IC_PARTY_MEMBER("ic_party_member","党员信息录入表", 1, 2, "IS_PARTY"), IC_ENSURE_HOUSE("ic_ensure_house","保障房人员信息录入表", 2, 2, "IS_ENSURE_HOUSE"), diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/support/ExportResiUserItemDTO.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/support/ExportResiUserItemDTO.java new file mode 100644 index 0000000000..8f7cb6de14 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/support/ExportResiUserItemDTO.java @@ -0,0 +1,29 @@ +package com.epmet.excel.support; + +import com.epmet.dto.result.FormItemResult; +import lombok.Data; + +import java.io.Serializable; +import java.util.*; + +/** + * desc: + * + * @author: LiuJanJun + * @date: 2021/11/18 3:31 下午 + * @version: 1.0 + */ +@Data +public class ExportResiUserItemDTO implements Serializable { + + private static final long serialVersionUID = -6581208659638591761L; + + /** + * 该表对应的 字段名:item + */ + private Map itemMap = new HashMap<>(); + /** + * 该表对应的所有远程item的相关条件 key:remote的itemID value:条件中用到的所有的item + */ + private Map> remoteItemConditionMap = new HashMap<>(); +} 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 d18d47d1b3..52e256105c 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 @@ -23,6 +23,7 @@ import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.entity.IcResiUserEntity; +import com.epmet.excel.support.ExportResiUserItemDTO; import java.util.List; import java.util.Map; @@ -105,12 +106,12 @@ public interface IcResiUserService extends BaseService { /** * desc:条件导出 * - * @param itemList + * @param exportResiUserItemDTO * @param baseTableName * @return Map> 用户Id:用户信息所有的字段名及值 */ - Map> getDataForExport(Map itemList, String baseTableName, IcResiUserPageFormDTO pageFormDTO, String currentStaffAgencyId, - String staffOrgPath); + List> getDataForExport(ExportResiUserItemDTO exportResiUserItemDTO, String baseTableName, IcResiUserPageFormDTO pageFormDTO, String currentStaffAgencyId, + String staffOrgPath); /** * @Description 家庭关系 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 909f16b8ad..b2adb20543 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 @@ -7,6 +7,7 @@ import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcelFactory; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.OptionResultDTO; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.ExceptionUtils; @@ -15,7 +16,6 @@ import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.dao.IcResiUserDao; import com.epmet.dto.*; -import com.epmet.dto.form.AgencyIdFormDTO; import com.epmet.dto.form.GridOptionFormDTO; import com.epmet.dto.form.HouseFormDTO; import com.epmet.dto.form.LoginUserDetailsFormDTO; @@ -90,7 +90,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res // 是否必填 private Integer required; - private List colIndexs; + private List colIndex; //private List colContents; // 单元格内容 private String cellContent; @@ -166,11 +166,11 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res userForm.setClient(loginUserClient); userForm.setUserId(loginUserId); - LoginUserDetailsResultDTO loginUserDetails = getResultDataOrThrowsException(epmetUserOpenFeignClient.getLoginUserDetails(userForm), ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); + LoginUserDetailsResultDTO loginUserDetails = getResultDataOrThrowsException(epmetUserOpenFeignClient.getLoginUserDetails(userForm), ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); String currUserAgencyId = loginUserDetails.getAgencyId(); //String excelPathName = "/opt/test/基础信息表/resi_info.xls"; - CustomerAgencyDTO agencyInfo = getResultDataOrThrowsException(govOrgOpenFeignClient.getAgencyById(currUserAgencyId), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); + CustomerAgencyDTO agencyInfo = getResultDataOrThrowsException(govOrgOpenFeignClient.getAgencyById(currUserAgencyId), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); String customerId = agencyInfo.getCustomerId(); try { @@ -544,7 +544,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res || "daterange".equals(columnWrapper.getItemType()) ) { - String cellContent = row.get(columnWrapper.getColIndexs().get(0)); + String cellContent = row.get(columnWrapper.getColIndex().get(0)); columnWrapper.setCellContent(cellContent); columnWrapper.setColValue(cellContent); @@ -553,7 +553,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res String optionSourceType = columnWrapper.getOptionSourceType(); // 取单元格的内容 - String cellContent = row.get(columnWrapper.getColIndexs().get(0)); + String cellContent = row.get(columnWrapper.getColIndex().get(0)); columnWrapper.setCellContent(cellContent); if ("local".equals(optionSourceType)) { @@ -677,7 +677,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res String combinedLabel = StringUtils.isBlank(groupLabel) ? item.getLabel() : groupLabel.concat(":").concat(item.getLabel()); columnWrapper.setCombinedLabel(combinedLabel); columnWrapper.setColumnName(item.getColumnName()); - columnWrapper.setColIndexs(entry.getValue()); + columnWrapper.setColIndex(entry.getValue()); columnWrapper.setRequired(item.getRequired()); columnWrapper.setOptionSourceType(item.getOptionSourceType()); @@ -699,7 +699,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res private String getCheckBoxColValue(ColumnWrapper columnWrapper, Map dataRow, Map checkboxOptions) { Map options = columnWrapper.getOptions(); - List colIndexs = columnWrapper.getColIndexs(); + List colIndexs = columnWrapper.getColIndex(); List optionValues = colIndexs.stream().filter(i -> { String cellContent = dataRow.get(i); @@ -770,8 +770,8 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res String cascadeItemId = null; ColumnWrapper cascadeItemColumnWrapper = null; - if (fullUri.indexOf("?") != -1) { - String[] uriParts = fullUri.split("\\?"); + if (fullUri.indexOf(StrConstant.QUESTION_MARK) != -1) { + String[] uriParts = fullUri.split(StrConstant.QUESTION_MARK_TRANSFER); pureUri = uriParts[0]; cascadeItemId = uriParts[1]; @@ -788,56 +788,61 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res switch (pureUri) { case "/epmetuser/icresidemanddict/demandoption": options = getResultDataOrThrowsException(epmetUserOpenFeignClient.getDemandOptions(), ServiceConstant.EPMET_USER_SERVER, - EpmetErrorCode.SERVER_ERROR.getCode(), null); + EpmetErrorCode.SERVER_ERROR.getCode(), null, null); break; case "/gov/org/customergrid/gridoption": GridOptionFormDTO form = new GridOptionFormDTO(); form.setAgencyId(currUserAgencyId); form.setPurpose(purpose); - options = getResultDataOrThrowsException(govOrgOpenFeignClient.getGridOption(form), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); + options = getResultDataOrThrowsException(govOrgOpenFeignClient.getGridOption(form), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); break; case "/gov/org/customerpartybranch/branchoption": CustomerPartyBranchDTO bform = new CustomerPartyBranchDTO(); bform.setGridId(cascadeItemColumnWrapper.getColValue()); - options = getResultDataOrThrowsException(govOrgOpenFeignClient.getBranchOption(bform), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); + options = getResultDataOrThrowsException(govOrgOpenFeignClient.getBranchOption(bform), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); break; case "/gov/org/icbuilding/buildingoption": IcBuildingDTO buildingform = new IcBuildingDTO(); buildingform.setNeighborHoodId(cascadeItemColumnWrapper.getColValue()); - options = getResultDataOrThrowsException(govOrgOpenFeignClient.getBuildingOptions(buildingform), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); + options = getResultDataOrThrowsException(govOrgOpenFeignClient.getBuildingOptions(buildingform), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); break; case "/gov/org/icbuildingunit/unitoption": IcBuildingUnitDTO buForm = new IcBuildingUnitDTO(); buForm.setBuildingId(cascadeItemColumnWrapper.getColValue()); - options = getResultDataOrThrowsException(govOrgOpenFeignClient.getUnitOptions(buForm), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); + options = getResultDataOrThrowsException(govOrgOpenFeignClient.getUnitOptions(buForm), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); break; case "/gov/org/ichouse/houseoption": HouseFormDTO hform = new HouseFormDTO(); hform.setUnitId(cascadeItemColumnWrapper.getColValue()); - options = getResultDataOrThrowsException(govOrgOpenFeignClient.getHouseOption(hform), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); + options = getResultDataOrThrowsException(govOrgOpenFeignClient.getHouseOption(hform), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); break; case "/gov/org/icneighborhood/neighborhoodoption": IcNeighborHoodDTO nform = new IcNeighborHoodDTO(); - nform.setAgencyId(currUserAgencyId); - nform.setGridId(cascadeItemColumnWrapper.getColValue()); - options = getResultDataOrThrowsException(govOrgOpenFeignClient.getNeighborHoodOptions(nform), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); + String gridId = cascadeItemColumnWrapper.getColValue(); + if (StringUtils.isBlank(gridId)){ + nform.setAgencyId(currUserAgencyId); + } + nform.setGridId(gridId); + options = getResultDataOrThrowsException(govOrgOpenFeignClient.getNeighborHoodOptions(nform), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); break; case "/sys/dict/data/education": - options = getResultDataOrThrowsException(adminOpenFeignClient.getEducationOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); + options = getResultDataOrThrowsException(adminOpenFeignClient.getEducationOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); break; case "/sys/dict/data/house": - options = getResultDataOrThrowsException(adminOpenFeignClient.getHouseOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); + options = getResultDataOrThrowsException(adminOpenFeignClient.getHouseOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); break; case "/sys/dict/data/nation": - options = getResultDataOrThrowsException(adminOpenFeignClient.getNationOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); + options = getResultDataOrThrowsException(adminOpenFeignClient.getNationOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); break; case "/sys/dict/data/ninesmallplaces": - options = getResultDataOrThrowsException(adminOpenFeignClient.getNineSmallPlacesOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); + options = getResultDataOrThrowsException(adminOpenFeignClient.getNineSmallPlacesOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); break; case "/sys/dict/data/relationship": - options = getResultDataOrThrowsException(adminOpenFeignClient.getRelationshipOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); + options = getResultDataOrThrowsException(adminOpenFeignClient.getRelationshipOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); break; + default: + log.warn("listRemoteOptions url is not supported"); } 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 3c021235fd..f82bcf97dc 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 @@ -27,6 +27,7 @@ import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; +import com.epmet.commons.tools.enums.FormItemTypeEnum; import com.epmet.commons.tools.enums.GenderEnum; import com.epmet.commons.tools.enums.HouseTypeEnum; import com.epmet.commons.tools.enums.RelationshipEnum; @@ -44,6 +45,7 @@ import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.IcPlatformConstant; +import com.epmet.constant.IcResiUserConstant; import com.epmet.constant.SystemMessageType; import com.epmet.constant.UserConstant; import com.epmet.dao.IcResiUserDao; @@ -55,6 +57,7 @@ import com.epmet.dto.form.*; import com.epmet.dto.form.demand.UserDemandNameQueryFormDTO; import com.epmet.dto.result.*; import com.epmet.entity.IcResiUserEntity; +import com.epmet.excel.support.ExportResiUserItemDTO; import com.epmet.feign.EpmetHeartOpenFeignClient; import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; @@ -63,6 +66,8 @@ import com.epmet.service.IcResiUserService; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -639,131 +644,132 @@ public class IcResiUserServiceImpl extends BaseServiceImpl> getDataForExport(Map formItemMap, String baseTableName,IcResiUserPageFormDTO pageFormDTO, - String currentStaffAgencyId, - String staffOrgPath) { + public List> getDataForExport(ExportResiUserItemDTO formItemMap, String baseTableName, IcResiUserPageFormDTO pageFormDTO, + String currentStaffAgencyId, + String staffOrgPath) { Page> mapListPage = PageHelper.startPage(pageFormDTO.getPageNo(), pageFormDTO.getPageSize(), pageFormDTO.getPageFlag()).doSelectPage(() -> { this.dynamicQuery(pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), baseTableName, pageFormDTO.getConditions(), currentStaffAgencyId, staffOrgPath); }); - List> mapList = mapListPage.getResult(); - Map> result = new LinkedHashMap<>(); - mapList.stream().filter(Objects::nonNull).forEach(map -> { - //遍历所有字段 格式化时间字段 - map.forEach((k,o) -> { - if (o instanceof java.sql.Date){ - o = DateUtils.format(((Date) o),DateUtils.DATE_PATTERN); - } - if (o instanceof java.sql.Timestamp){ - o = DateUtils.format(new Date(((Timestamp) o).getTime()),DateUtils.DATE_TIME_PATTERN); - } - map.put(k,o); - - //把checkbox radio select的值放入到map里 并添加对应的 - - }); - Object gridId = map.get(UserConstant.GRID_ID); + mapListPage.getResult().stream().filter(Objects::nonNull).forEach(resiUser -> { String resiId = null; - //获取用户Id - if ("ic_resi_user".equals(baseTableName)) { - resiId = (String) map.get("ID"); + if (IcResiUserConstant.IC_RESI_USER.equals(baseTableName)) { + resiId = (String) resiUser.get("ID"); }else { - resiId = (String) map.get(UserConstant.IC_RESI_USER); + resiId = (String) resiUser.get(UserConstant.IC_RESI_USER); } - if (StringUtils.isBlank(resiId)){ - log.error("getDataForExport error,resiId is net exist:{}",map); + log.error("getDataForExport error,resiId is net exist:{}",resiUser); return; } - //把人放进去 - result.put(resiId, map); - - for (Map.Entry e : formItemMap.entrySet()) { - String k = e.getKey(); - FormItemResult v = e.getValue(); - Object temp = map.get(k); - String vauleStr = temp == null ? "" : temp.toString(); - - if (v.getOptionSourceType().equals("remote")) { - try { - Map columnWrappers = new HashMap<>(); - if (v.getItemId().equals("1078")) { - IcResiUserImportServiceImpl.ColumnWrapper value = new IcResiUserImportServiceImpl.ColumnWrapper(); - value.setColValue(gridId.toString()); - columnWrappers.put("1001", value); - }else if (v.getOptionSourceValue().contains(StrConstant.QUESTION_MARK)){ - continue; - } - //todo 获取 options - Map stringMap = icResiUserImportService.listRemoteOptions(columnWrappers, v.getOptionSourceValue(), currentStaffAgencyId, "query"); - if ("checkbox".equals(v.getItemType())) { - stringMap.forEach((label, value) -> map.put(value, vauleStr.contains(value) ? "是" : "否")); - } else if ("select".equals(v.getItemType())) { - stringMap.forEach((label, value) -> { - if (vauleStr.equals(value)) { - map.put(k, label); - } - }); - } - } catch (Exception ex) { - log.warn("listRemoteOptions url:{}", v.getOptionSourceValue()); - } - } else { - if ("checkbox".equals(v.getItemType())) { + //遍历所有字段 格式化时间字段 + resiUser.forEach((k,o) -> { + if (o instanceof java.sql.Date){ + o = DateUtils.format(((Date) o),DateUtils.DATE_PATTERN); + }else if (o instanceof java.sql.Timestamp){ + o = DateUtils.format(new Date(((Timestamp) o).getTime()),DateUtils.DATE_TIME_PATTERN); + } + resiUser.put(k,o); + }); - v.getOptions().forEach(optionDTO -> { - map.put(optionDTO.getValue(), vauleStr.contains(optionDTO.getValue()) ? "是" : "否"); - }); - } else if ("select".equals(v.getItemType())) { - v.getOptions().forEach(optionDTO -> { - if (optionDTO.getValue().equals(vauleStr)) { - map.put(k, optionDTO.getLabel()); - } - }); - } else if ("radio".equals(v.getItemType())) { - v.getOptions().forEach(optionDTO -> { - if (optionDTO.getValue().equals(vauleStr)) { - map.put(k, optionDTO.getLabel()); - } - }); - } + //当前条数据原始的id值 resiUser + Map originalConditionMap = new HashMap<>(); + for (FormItemResult e : formItemMap.getItemMap().values()) { + String columnName = getColumnName(e); + Object temp = resiUser.get(columnName); + String vauleStr = temp == null ? StrConstant.EPMETY_STR : temp.toString(); + originalConditionMap.putIfAbsent(columnName,vauleStr); + if ("remote".equals(e.getOptionSourceType()) && StringUtils.isNotBlank(vauleStr)) { + putRemoteValue(formItemMap.getRemoteItemConditionMap().get(e.getItemId()), currentStaffAgencyId, resiUser,originalConditionMap, e, columnName, vauleStr); + } else { + putOptionValue(resiUser, e, columnName, vauleStr); } } - if (!"ic_resi_user".equals(baseTableName)) { + if (!IcResiUserConstant.IC_RESI_USER.equals(baseTableName)) { Map o = redisUtils.hGetAll(RedisKeys.getExportResiBaseInfoKey(resiId)); if (o != null){ - map.putAll(o); + resiUser.putAll(o); } return; } + //把人放入redis缓存 便于后面的sheet使用基础信息 + redisUtils.hMSet(RedisKeys.getExportResiBaseInfoKey(resiId),resiUser,RedisUtils.MINUTE_THIRTY_EXPIRE); + }); + remoteOptionCacheMap.clear(); + return mapListPage.getResult(); + } - /*if (gridId != null) { - CustomerGridFormDTO formDTO = new CustomerGridFormDTO(); - formDTO.setGridId(gridId.toString()); - Result gridInfoRes = govOrgOpenFeignClient.getGridBaseInfoByGridId(formDTO); - if (gridInfoRes != null && gridInfoRes.success() && gridInfoRes.getData() != null) { - map.put(UserConstant.GRID_NAME, gridInfoRes.getData().getGridName()); + /** + * key:itemId,value: key:columnName,中文 + */ + private static Map> remoteOptionCacheMap = new HashMap<>(); + private void putRemoteValue(Set conditionItemSet, String currentStaffAgencyId, Map map, Map originalConditionMap, FormItemResult e, String columnName, String vauleStr) { + try { + Map columnWrappers = new HashMap<>(); + if (e.getOptionSourceValue().contains(StrConstant.QUESTION_MARK)){ + for (FormItemResult o : conditionItemSet) { + String column = getColumnName(o); + Object conditionValue = originalConditionMap.getOrDefault(column, map.get(column)); + originalConditionMap.putIfAbsent(column,conditionValue.toString()); + IcResiUserImportServiceImpl.ColumnWrapper value = new IcResiUserImportServiceImpl.ColumnWrapper(); + value.setColValue(conditionValue.toString()); + columnWrappers.put(o.getItemId(), value); } + } + /*if (e.getItemId().equals("1078")) { + IcResiUserImportServiceImpl.ColumnWrapper value = new IcResiUserImportServiceImpl.ColumnWrapper(); + value.setColValue(gridId.toString()); + columnWrappers.put("1001", value); + }else if (e.getOptionSourceValue().contains(StrConstant.QUESTION_MARK)){ + continue; }*/ - Object homeId = map.get(UserConstant.HOME_ID); - if (homeId != null) { - HashSet houseIds = new HashSet<>(); - houseIds.add(homeId.toString()); - Result> houseInfoRes = govOrgOpenFeignClient.queryListHouseInfo(houseIds); - if (houseInfoRes != null && houseInfoRes.success() && CollectionUtils.isNotEmpty(houseInfoRes.getData())) { - HouseInfoDTO houseInfoDTO = houseInfoRes.getData().get(NumConstant.ZERO); - map.put("VILLAGE_NAME", houseInfoDTO.getNeighborHoodName()); - map.put("BUILD_NAME", houseInfoDTO.getBuildingName()); - map.put("HOME_ID", houseInfoDTO.getHouseName()); - map.put("UNIT_ID", houseInfoDTO.getUnitName()); + Cache cache = remoteOptionCacheMap.getOrDefault(e.getItemId(), CacheBuilder.newBuilder().maximumSize(NumConstant.FIVE_HUNDRED).build()); + remoteOptionCacheMap.putIfAbsent(e.getItemId(),cache); + String cacheValue = cache.getIfPresent(vauleStr); + if (StringUtils.isNotBlank(cacheValue)){ + map.put(columnName,cacheValue); + } else { + Map remoteOptions = icResiUserImportService.listRemoteOptions(columnWrappers, e.getOptionSourceValue(), currentStaffAgencyId, "query"); + if (FormItemTypeEnum.CHECKBOX.getCode().equals(e.getItemType())) { + remoteOptions.forEach((label, value) -> map.put(value, vauleStr.contains(value) ? "是" : "否")); + } else if (FormItemTypeEnum.SELECT.getCode().equals(e.getItemType())) { + remoteOptions.forEach((label, value) -> { + if (vauleStr.equals(value)) { + map.put(columnName, label); + } + cache.put(value,label); + }); } } - //把人放入缓存 - redisUtils.hMSet(RedisKeys.getExportResiBaseInfoKey(resiId),map,RedisUtils.MINUTE_THIRTY_EXPIRE); - }); - return result; + } catch (Exception ex) { + log.warn("listRemoteOptions url:{}", e.getOptionSourceValue()); + } + } + + private void putOptionValue(Map map, FormItemResult e, String columnName, String vauleStr) { + FormItemTypeEnum itemTypeEnum = FormItemTypeEnum.getEnum(e.getItemType()); + switch (itemTypeEnum) { + case CHECKBOX: + e.getOptions().forEach(optionDTO -> { + map.put(optionDTO.getValue(), vauleStr.contains(optionDTO.getValue()) ? "是" : "否"); + }); + break; + case SELECT: + case RADIO: + e.getOptions().forEach(optionDTO -> { + if (optionDTO.getValue().equals(vauleStr)) { + map.put(columnName, optionDTO.getLabel()); + } + }); + break; + default: + } + } + + private String getColumnName(FormItemResult e) { + return e.getColumnNum() == NumConstant.ZERO? e.getColumnName():e.getColumnName().concat(e.getColumnNum().toString()); } /** @@ -832,6 +838,6 @@ public class IcResiUserServiceImpl extends BaseServiceImpl> result = operCustomizeOpenFeignClient.listItems(form); - return getResultDataOrThrowsException(result, ServiceConstant.OPER_CUSTOMIZE_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "查询表单相关信息失败"); + return getResultDataOrThrowsException(result, ServiceConstant.OPER_CUSTOMIZE_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "查询表单相关信息失败", null); } } diff --git a/epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid_for_easy_excel.xlsx b/epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid_for_easy_excel.xlsx index c427b87ad5..bb88725ee6 100644 Binary files a/epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid_for_easy_excel.xlsx and b/epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid_for_easy_excel.xlsx differ