Browse Source

Merge branches 'dev_ic_platform' and 'dev_ic_v2' of http://121.42.41.42:7070/r/epmet-cloud into dev_ic_v2

master
yinzuomei 4 years ago
parent
commit
3bf202d4b1
  1. 2
      epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/LogOperationHelper.java
  2. 6
      epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java
  3. 4
      epmet-auth/src/main/java/com/epmet/controller/IcLoinController.java
  4. 2
      epmet-auth/src/main/java/com/epmet/service/impl/IcLoginServiceImpl.java
  5. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java
  6. 53
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/FormItemTypeEnum.java
  7. 7
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  8. 7
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java
  9. 2
      epmet-gateway/src/main/java/com/epmet/config/CorsConfig.java
  10. 2
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/impl/QuestionnaireServiceImpl.java
  11. 8
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/BizPointTotalDetailServiceImpl.java
  12. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/PingyinPrivateEpmetApiService.java
  13. 4
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java
  14. 11
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java
  15. 48
      epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/ResiCategoryStatsConfigListFormDTO.java
  16. 33
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/ResiCategoryStatsConfigController.java
  17. 3
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/ResiCategoryStatsConfigService.java
  18. 37
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/ResiCategoryStatsConfigServiceImpl.java
  19. 10
      epmet-module/resi-home/resi-home-server/src/main/java/com/epmet/service/impl/ResiEventServiceImpl.java
  20. 11
      epmet-user/epmet-user-client/src/main/java/com/epmet/constant/IcResiUserConstant.java
  21. 79
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java
  22. 4
      epmet-user/epmet-user-server/src/main/java/com/epmet/enums/IcResiUserTableEnum.java
  23. 29
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/support/ExportResiUserItemDTO.java
  24. 7
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java
  25. 53
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java
  26. 208
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java
  27. BIN
      epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid_for_easy_excel.xlsx

2
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<CustomerStaffDTO> 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());
}
}

6
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<List<CustomerStaffDTO>> result = userOpenFeignClient.list(form);
List<CustomerStaffDTO> staffs = getResultDataOrThrowsException(result, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用user服务发生异常");
List<CustomerStaffDTO> staffs = getResultDataOrThrowsException(result, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用user服务发生异常", null);
HashMap<String, CustomerStaffDTO> staffMap = new HashMap<>();
staffs.forEach(s -> {
@ -103,7 +103,7 @@ public class LogOperationServiceImpl implements LogOperationService, ResultDataR
form.setCustomerId(customerId);
form.setMobile(operatorMobile);
Result<List<CustomerStaffDTO>> result = userOpenFeignClient.list(form);
List<CustomerStaffDTO> staffs = getResultDataOrThrowsException(result, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用user服务发生异常");
List<CustomerStaffDTO> 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<List<CustomerStaffDTO>> result = userOpenFeignClient.list(form);
List<CustomerStaffDTO> staffs = getResultDataOrThrowsException(result, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用user服务查询工作人员信息发生异常");
List<CustomerStaffDTO> staffs = getResultDataOrThrowsException(result, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用user服务查询工作人员信息发生异常", null);
List<String> userIds = new ArrayList<>();
HashMap<String, CustomerStaffDTO> staffMap = new HashMap<String, CustomerStaffDTO>();

4
epmet-auth/src/main/java/com/epmet/controller/IcLoinController.java

@ -76,7 +76,7 @@ public class IcLoinController implements ResultDataResolver {
// 获取用户信息
Result<List<CustomerStaffDTO>> staffResult = epmetUserFeignClient.checkCustomerStaff(mobile);
List<CustomerStaffDTO> staffList = getResultDataOrThrowsException(staffResult, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【基层治理平台登录】获取用户信息失败");
List<CustomerStaffDTO> 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<List<StaffOrgsResultDTO>> orgListResult = govOrgOpenFeignClient.getStaffOrgListByStaffId(orgListForm);
List<StaffOrgsResultDTO> orgs = getResultDataOrThrowsException(orgListResult, ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【基层治理平台登录】根据staffId查询所属客户跟组织列表失败");
List<StaffOrgsResultDTO> orgs = getResultDataOrThrowsException(orgListResult, ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【基层治理平台登录】根据staffId查询所属客户跟组织列表失败", null);
// 生成登录票据
String ticket = UUID.randomUUID().toString().replace("-", "");

2
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<CustomerAgencyDTO> 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());

2
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="&";
/**
* 空字符串

53
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;
}
}

7
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;

7
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> R getResultDataOrThrowsException(Result<R> result, String targetServiceName, Integer errorCode, String errorInternalMsg) {
default <R> R getResultDataOrThrowsException(Result<R> 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();
}

2
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配置失败");
}

2
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<CustomerGridDTO> 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<PrPublishRangeEntity> publishRangeEntity = prPublishRangeService.getPublishRangeEntity(projectKey);

8
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<BizPointTota
form.setSearchScopeObjectId(searchScopeObjectId);
Result<List<GroupDetailResultDTO>> result = resiGroupOpenFeignClient.listGroupDetailsExcludeGroupIds(form);
List<GroupDetailResultDTO> groups = getResultDataOrThrowsException(result, ServiceConstant.RESI_GROUP_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【小组排名】查询积分为0的小组列表失败");
List<GroupDetailResultDTO> 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<BizPointTota
// 查询这些小组的基本信息
Result<List<GroupDetailResultDTO>> listResult = resiGroupOpenFeignClient.listGroupDetailsByGroupIds(groupIds);
List<GroupDetailResultDTO> groupInfos = getResultDataOrThrowsException(listResult, ServiceConstant.RESI_GROUP_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【小组排行】批量查询小组信息出错");
List<GroupDetailResultDTO> groupInfos = getResultDataOrThrowsException(listResult, ServiceConstant.RESI_GROUP_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【小组排行】批量查询小组信息出错", null);
// 将小组基本信息转化为map
HashMap<String, GroupDetailResultDTO> groupMap = new HashMap<>();
@ -454,7 +454,7 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl<BizPointTota
CustomerGridFormDTO form = new CustomerGridFormDTO();
form.setGridId(gridId);
Result<CustomerGridDTO> 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<BizPointTota
form.setGridId(gridId);
form.setUserId(userId);
List<GroupDetailResultDTO> 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();

4
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<Result> implements
String urlParams = super.convertQueryParams2String(constructCommonUrlParamsMap(platformKey, authType, uuid, currentTimeMillis, sign));
String requestUrl = baseUrl.concat(apiUrl).concat(urlParams);
Result<String> 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<GetAccessTokenResultDTO> remoteResult = parsePlatformResponseResult(remoteResultString, GetAccessTokenResultDTO.class);
log.info("【调用平阴私有化平台获取AccessToken】结果:{}", remoteResultString);
accessTokenFromCache = remoteResult.getData().getAccessToken();
@ -159,7 +159,7 @@ public class PingyinPrivateEpmetApiService extends ApiService<Result> 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

4
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<List<IcNeighborHoodDTO>>().ok(icNeighborHoodService.getListByIds(ids));
}
}
}

11
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<IcHouseDao, IcHouseEntit
categories.add(bean);
}
}
//将党员放在最前面
if(CollectionUtils.isNotEmpty(categories)) {
int a = 0;
for (int i = 0; i < categories.size(); i++) {
if ("党员".equals(categories.get(i).getName())) {
a = i;
break;
}
}
categories.add(NumConstant.ZERO, categories.remove(a));
}
dto.setCategoryList(categories);
return dto;
}).collect(Collectors.toList());

48
epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/ResiCategoryStatsConfigListFormDTO.java

@ -0,0 +1,48 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

33
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<IcResiCategoryStatsConfigResultDTO>> list(@LoginUser TokenDto tokenDTO){
public Result<List<IcResiCategoryStatsConfigResultDTO>> list(@LoginUser TokenDto tokenDTO,@RequestBody ResiCategoryStatsConfigListFormDTO formDTO){
String customerId = tokenDTO.getCustomerId();
// String customerId = "123123";
return new Result<List<IcResiCategoryStatsConfigResultDTO>>().ok(resiCategoryStatsConfigService.list(customerId));
return new Result<List<IcResiCategoryStatsConfigResultDTO>>().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 {
}
}
}

3
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<IcResiCategoryStatsConfigResultDTO> list(String customerId);
List<IcResiCategoryStatsConfigResultDTO> list(String customerId, ResiCategoryStatsConfigListFormDTO formDTO);
IcResiCategoryStatsConfigResultDTO info(String id);

37
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<IcResiCategoryStatsConfigResultDTO> list(String customerId) {
public List<IcResiCategoryStatsConfigResultDTO> list(String customerId, ResiCategoryStatsConfigListFormDTO formDTO) {
//1.获取IC_FORM_ITEM 中 用于数据分析字段的 id 和label
List<IcFormItemEntity> icFormItemEntityList = icFormItemDao.selectList(new QueryWrapper<IcFormItemEntity>().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<IcResiCategoryStatsConfigResultDTO> 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);
}

10
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<List<ListUserByBadgeResultDTO>> npcResult = epmetUserOpenFeignClient.listUsersByBadge(npcForm);
List<ListUserByBadgeResultDTO> npcData = getResultDataOrThrowsException(npcResult, ServiceConstant.EPMET_USER_SERVER, null, null);
List<ListUserByBadgeResultDTO> 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<String> npcGridIds = npcData.stream().map(d -> d.getGridId()).collect(Collectors.toList());
OrgInfoFormDTO form = new OrgInfoFormDTO(OrgInfoConstant.GRID, npcGridIds);
Result<List<OrgInfoResultDTO>> npcGridInfoResult = govOrgOpenFeignClient.selectOrgInfo(form);
List<OrgInfoResultDTO> npcGridInfos = getResultDataOrThrowsException(npcGridInfoResult, ServiceConstant.GOV_ORG_SERVER, null, null);
List<OrgInfoResultDTO> npcGridInfos = getResultDataOrThrowsException(npcGridInfoResult, ServiceConstant.GOV_ORG_SERVER, null, null, null);
Map<String, OrgInfoResultDTO> npcGridInfoMap = convertNpcGridInfos2Map(npcGridInfos);
@ -109,7 +109,7 @@ public class ResiEventServiceImpl implements ResiEventService, ResultDataResolve
TreeSet<ResiEventTargetLevelResultDTO> targetLevels = new TreeSet<>();
Result<GridInfoResultDTO> 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<String> parentOrgIds = Arrays.asList(pidsPath.split(":"));
// 翻转列表
@ -118,7 +118,7 @@ public class ResiEventServiceImpl implements ResiEventService, ResultDataResolve
// 一.网格信息(只有一条,但是为了适应接口,组装成了列表)
List<String> currentGridId = Arrays.asList(gridId);
Result<List<OrgInfoResultDTO>> currentGridInfoResult = govOrgOpenFeignClient.selectOrgInfo(new OrgInfoFormDTO(OrgInfoConstant.GRID, currentGridId));
List<OrgInfoResultDTO> currentGridInfos = getResultDataOrThrowsException(currentGridInfoResult, ServiceConstant.GOV_ORG_SERVER, null, null);
List<OrgInfoResultDTO> 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<List<OrgInfoResultDTO>> parentOrgInfoResult = govOrgOpenFeignClient.selectOrgInfo(new OrgInfoFormDTO(OrgInfoConstant.AGENCY, parentOrgIds));
List<OrgInfoResultDTO> parentOrgInfos = getResultDataOrThrowsException(parentOrgInfoResult, ServiceConstant.GOV_ORG_SERVER, null, null);
List<OrgInfoResultDTO> parentOrgInfos = getResultDataOrThrowsException(parentOrgInfoResult, ServiceConstant.GOV_ORG_SERVER, null, null, null);
parentOrgInfos.forEach(porg -> {
String levelName = OrgLevelEnums.getLevelName(porg.getLevel());
if (StringUtils.isBlank(levelName)) {

11
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";
}

79
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<String, Map<String, FormItemResult>> otherSheetItems = buildItemMap(resiFormItems);
Map<String, Map<String, Object>> resiMainList = icResiUserService.getDataForExport(otherSheetItems.get(BASE_TABLE_NAME), BASE_TABLE_NAME, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath);
Map<String, Map<String, Object>> resiMainList = null;//icResiUserService.getDataForExport(otherSheetItems.get(IcResiUserConstant.IC_RESI_USER), IcResiUserConstant.IC_RESI_USER, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath);
//resiMainList = (List<Map<String, Object>>)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<String, FormItemResult> itemMap1 = otherSheetItems.get(tableName);
Map<String, Map<String, Object>> resiChildMap = icResiUserService.getDataForExport(itemMap1, tableName, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath);
Map<String, Map<String, Object>> resiChildMap = null;//icResiUserService.getDataForExport(itemMap1, tableName, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath);
//resiChildMap.forEach((key, value) -> value.putAll(resiMainList.get(key)));
Map<String, Object> 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<String, WriteSheet> childTableWriteSheetMap = new HashMap<>();
Map<String, Map<String, Object>> 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<String, FormItemResult> itemMap1 = otherSheetItems.get(tableName);
Map<String, Map<String, Object>> resiChildMap = icResiUserService.getDataForExport(itemMap1, tableName, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath);
Map<String, Map<String, Object>> 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<String> stopSearchSet = new HashSet<>();
//获取表单项
List<FormItemResult> resiFormAllItems = icResiUserService.listFormItems(customerId, IC_RESI_FORM_CODE);
Map<String, FormItemResult> allItemMap = resiFormAllItems.stream().collect(Collectors.toMap(FormItemResult::getItemId, o -> o));
Map<String, ExportResiUserItemDTO> 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<FormItemResult> conditionSet = exportItem.getRemoteItemConditionMap().getOrDefault(item.getItemId(),new HashSet<>());
conditionSet.add(value);
exportItem.getRemoteItemConditionMap().putIfAbsent(item.getItemId(),conditionSet);
});
}
});
//每个表对应的 item ;key:表名,value:<字段名:item对象>
Map<String, Map<String, FormItemResult>> 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<String, WriteSheet> childTableWriteSheetMap = new HashMap<>();
//表数据写入
//通过枚举获取相关表并按照sheetNo排序
List<IcResiUserTableEnum> resiTableList = Arrays.stream(IcResiUserTableEnum.values())
.sorted(Comparator.comparing(IcResiUserTableEnum::getSheetNo))
.collect(Collectors.toList());
List<Map<String, Object>> resiResultList = null;
pageFormDTO.setPageSize(NumConstant.FIVE_HUNDRED);
for (IcResiUserTableEnum tableEnum : resiTableList) {
String tableName = tableEnum.getTableName();
pageFormDTO.setPageNo(NumConstant.ONE);
//循环一次 写入每个sheet
//循环一次 写入个sheet
do {
Map<String, Map<String, Object>> 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));
}

4
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"),

29
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<String,FormItemResult> itemMap = new HashMap<>();
/**
* 该表对应的所有远程item的相关条件 key:remote的itemID value条件中用到的所有的item
*/
private Map<String,Set<FormItemResult>> remoteItemConditionMap = new HashMap<>();
}

7
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<IcResiUserEntity> {
/**
* desc:条件导出
*
* @param itemList
* @param exportResiUserItemDTO
* @param baseTableName
* @return Map<String,Map<String,Object>> 用户Id用户信息所有的字段名及值
*/
Map<String, Map<String, Object>> getDataForExport(Map<String, FormItemResult> itemList, String baseTableName, IcResiUserPageFormDTO pageFormDTO, String currentStaffAgencyId,
String staffOrgPath);
List<Map<String, Object>> getDataForExport(ExportResiUserItemDTO exportResiUserItemDTO, String baseTableName, IcResiUserPageFormDTO pageFormDTO, String currentStaffAgencyId,
String staffOrgPath);
/**
* @Description 家庭关系

53
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<Integer> colIndexs;
private List<Integer> colIndex;
//private List<String> 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<Integer, String> dataRow, Map<Integer, String> checkboxOptions) {
Map<String, String> options = columnWrapper.getOptions();
List<Integer> colIndexs = columnWrapper.getColIndexs();
List<Integer> colIndexs = columnWrapper.getColIndex();
List<String> 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");
}

208
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<IcResiUserDao, IcResi
* @return
*/
@Override
public Map<String, Map<String, Object>> getDataForExport(Map<String, FormItemResult> formItemMap, String baseTableName,IcResiUserPageFormDTO pageFormDTO,
String currentStaffAgencyId,
String staffOrgPath) {
public List<Map<String, Object>> getDataForExport(ExportResiUserItemDTO formItemMap, String baseTableName, IcResiUserPageFormDTO pageFormDTO,
String currentStaffAgencyId,
String staffOrgPath) {
Page<Map<String, Object>> mapListPage = PageHelper.startPage(pageFormDTO.getPageNo(), pageFormDTO.getPageSize(), pageFormDTO.getPageFlag()).doSelectPage(() -> {
this.dynamicQuery(pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), baseTableName, pageFormDTO.getConditions(), currentStaffAgencyId, staffOrgPath);
});
List<Map<String, Object>> mapList = mapListPage.getResult();
Map<String, Map<String, Object>> 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<String, FormItemResult> 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<String, IcResiUserImportServiceImpl.ColumnWrapper> 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<String, String> 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<String,Object> 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<String,Object> 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<CustomerGridDTO> 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<String,Cache<String,String>> remoteOptionCacheMap = new HashMap<>();
private void putRemoteValue(Set<FormItemResult> conditionItemSet, String currentStaffAgencyId, Map<String, Object> map, Map<String, Object> originalConditionMap, FormItemResult e, String columnName, String vauleStr) {
try {
Map<String, IcResiUserImportServiceImpl.ColumnWrapper> 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<String> houseIds = new HashSet<>();
houseIds.add(homeId.toString());
Result<List<HouseInfoDTO>> 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<String, String> 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<String, String> 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<String, Object> 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<IcResiUserDao, IcResi
form.setFormCode(formCode);
form.setCustomerId(customerId);
Result<List<FormItemResult>> 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);
}
}

BIN
epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid_for_easy_excel.xlsx

Binary file not shown.
Loading…
Cancel
Save