From 4eb0f5c0cb1faca63580eead054e103026e42dac Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Thu, 4 Nov 2021 17:51:26 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=20=E5=AE=8C?= =?UTF-8?q?=E6=88=90excel=E8=A1=A8=E6=A0=BC=E7=9A=84=E5=9F=BA=E6=9C=AC?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=20=E4=B8=8B=E4=B8=80=E6=AD=A5=EF=BC=9A?= =?UTF-8?q?=E5=81=A5=E5=A3=AE=E6=80=A7=E5=88=A4=E6=96=AD=EF=BC=8C=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E8=AE=B0=E5=BD=95=EF=BC=8Cexcel=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/exception/EpmetErrorCode.java | 2 + .../controller/IcResiUserController.java | 13 +- .../com/epmet/service/IcResiUserService.java | 2 +- .../service/impl/IcResiUserServiceImpl.java | 258 +++++++++++++----- 4 files changed, 189 insertions(+), 86 deletions(-) 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 92c190c7ec..a38091fa60 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 @@ -78,6 +78,8 @@ public enum EpmetErrorCode { HAVE_GUIDE_CANNOT_DEL(8211,"当前分类已经存在办事指南,不允许删除"), GUIDE_CATEGORY_NAME_EXITS(8212,"分类已存在"), CUSTOMER_FORM_NOT_EXITS(8213,"客户未配置表单"), + RESI_NOT_FOUND(8214,"居民信息找不到"), + REQUIRE_PERMISSION(8301, "您没有足够的操作权限"), THIRD_PLAT_REQUEST_ERROR(8302, "请求第三方平台错误"), 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 4ed686ba22..d466e6273e 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 @@ -406,20 +406,11 @@ public class IcResiUserController { /** * excel导入居民基本信息 - * @param loginUser * @return */ @PostMapping("import/excel") - public Result importExcelByEasyExcel(@LoginUser TokenDto loginUser) { - - LoginUserDetailsFormDTO userForm = new LoginUserDetailsFormDTO(); - userForm.setApp(loginUser.getApp()); - userForm.setClient(loginUser.getClient()); - userForm.setUserId(loginUser.getUserId()); - - Result loginUserDetails = epmetUserOpenFeignClient.getLoginUserDetails(userForm); - - Object result = icResiUserService.importIcResiInfoFromExcel(loginUserDetails.getData().getAgencyId()); + public Result importExcelByEasyExcel() { + Object result = icResiUserService.importIcResiInfoFromExcel(); return new Result().ok(result); } 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 0363899e8a..b497302753 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 @@ -130,7 +130,7 @@ public interface IcResiUserService extends BaseService { */ Map queryIcResiDetail(IcResiDetailFormDTO pageFormDTO); - Object importIcResiInfoFromExcel(String currUserAgencyId); + Object importIcResiInfoFromExcel(); List> dynamicQuery(String customerId, String formCode, 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 af1e0e4578..cd357537c3 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 @@ -45,6 +45,7 @@ import com.epmet.dao.IcResiUserDao; import com.epmet.dto.*; import com.epmet.dto.form.*; import com.epmet.dto.result.*; +import com.epmet.entity.IcPartyMemberEntity; import com.epmet.entity.IcResiUserEntity; import com.epmet.excel.handler.DynamicEasyExcelListener; import com.epmet.feign.EpmetAdminOpenFeignClient; @@ -69,6 +70,7 @@ import java.io.File; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * 用户基础信息 @@ -95,7 +97,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl page(Map params) { IPage page = baseDao.selectPage( @@ -484,22 +486,40 @@ public class IcResiUserServiceImpl extends BaseServiceImpl headerColumnWrapper = convertExcelHeaders2DBColumnWrappers(formItemMap, combinedHeaders, dataList, abandonedHeaders); // 持久化 - persist(headerColumnWrapper, dataList, currUserAgencyId, abandonedHeaders, customerItems.get(0).getTableName(), currUserAgencyPids, currentUserId); + persistIcResiBaseInfo(headerColumnWrapper, dataList, currUserAgencyId, abandonedHeaders, currUserAgencyPids, currentUserId); return headers; } @@ -555,11 +575,12 @@ public class IcResiUserServiceImpl extends BaseServiceImpl formItem) ); Map headerColumnWrapper = convertExcelHeaders2DBColumnWrappers(formItemMap, combinedHeaders, dataList, abandonedHeaders); - - return formItemMap; + persistIcResiExtraInfo(headerColumnWrapper, dataList, currUserAgencyId, abandonedHeaders, currentUserId, targetTableName, customerId); + return headerColumnWrapper; } /** - * 持久化 + * 持久化IC居民基础信息 * @param headerColumnWrapper 数据库列包装信息 * @param dataRows 数据行集合 * @param currUserAgencyId 当前用户的组织id * @param checkBoxOptionColumnIdxAndLabel 复选框的列号&label中文 */ - private void persist(Map headerColumnWrapper, List> dataRows, - String currUserAgencyId, Map checkBoxOptionColumnIdxAndLabel, String tableName, - String currUserAgencyPids, String currentUserId) { + private void persistIcResiBaseInfo(Map headerColumnWrapper, List> dataRows, + String currUserAgencyId, Map checkBoxOptionColumnIdxAndLabel, + String currUserAgencyPids, String currentUserId) { + + // 遍历每一行,将行内容转化为 for (Map row : dataRows) { - // 当前行的列们 -// List columnsOfCurrRow = new ArrayList<>(); - - List columnNames = new ArrayList<>(); - List columnValues = new ArrayList<>(); - LinkedHashMap columnAndValues = new LinkedHashMap<>(); - - for (Map.Entry columnWrapperEntry : headerColumnWrapper.entrySet()) { - - ColumnWrapper columnWrapper = columnWrapperEntry.getValue(); - if ("input".equals(columnWrapper.getItemType()) - || "textarea".equals(columnWrapper.getItemType()) - || "datepicker".equals(columnWrapper.getItemType()) - || "timerange".equals(columnWrapper.getItemType()) - ) { - - String cellContent = row.get(columnWrapper.getColIndexs().get(0)); - columnWrapper.setCellContent(cellContent); - columnWrapper.setColValue(cellContent); - - } else if ("select".equals(columnWrapper.getItemType()) - || "radio".equals(columnWrapper.getItemType())){ - - String optionSourceType = columnWrapper.getOptionSourceType(); - // 取单元格的内容 - String cellContent = row.get(columnWrapper.getColIndexs().get(0)); - columnWrapper.setCellContent(cellContent); - - if ("local".equals(optionSourceType)) { - // 根据单元格内容,取到指定的option - Map options = columnWrapper.getOptions(); - String colValue = options.get(cellContent); - columnWrapper.setColValue(colValue); - } else { - // remote类型 - - Map options = listRemoteOptions(headerColumnWrapper, columnWrapper.getOptionSourceValue(), currUserAgencyId); - String colValue = options.get(cellContent); - columnWrapper.setColValue(colValue); - } - } else if ("checkbox".equals(columnWrapper.getItemType())) { - String checkBoxColValue = getCheckBoxColValue(columnWrapper, row, checkBoxOptionColumnIdxAndLabel); - columnWrapper.setColValue(checkBoxColValue); - } - columnAndValues.put(columnWrapper.columnName, columnWrapper.colValue); - } + LinkedHashMap columnAndValues = convertColumnWrappers2Map4Persist(headerColumnWrapper, row, currUserAgencyId, checkBoxOptionColumnIdxAndLabel); columnAndValues.put("IS_ENSURE_HOUSE", "0"); columnAndValues.put("IS_OLD_PEOPLE", "0"); @@ -669,14 +647,146 @@ public class IcResiUserServiceImpl extends BaseServiceImpl { -// System.out.println(c.columnName + "\t" + c.getColValue()); -// }); + // 验证居民信息是否存在 + String idCard = columnAndValues.get("ID_CARD"); + LambdaQueryWrapper idCardQuery = new LambdaQueryWrapper<>(); + idCardQuery.eq(IcResiUserEntity::getIdCard, idCard); + + if (baseDao.selectCount(idCardQuery) > 0) { + log.info("身份证号为【{}】的居民信息已存在,跳过导入", idCard); + } + + baseDao.add("ic_resi_user", columnAndValues); + } + } + + /** + * 持久化IC居民附加信息 + * @param headerColumnWrapper 数据库列包装信息 + * @param dataRows 数据行集合 + * @param currUserAgencyId 当前用户的组织id + * @param checkBoxOptionColumnIdxAndLabel 复选框的列号&label中文 + * @param targetTableName 要插入到哪一个表 + */ + private void persistIcResiExtraInfo(Map headerColumnWrapper, List> dataRows, + String currUserAgencyId, Map checkBoxOptionColumnIdxAndLabel, + String currentUserId, String targetTableName, String customerId) { + + // 遍历每一行,将行内容转化为 + for (Map row : dataRows) { + + LinkedHashMap columnAndValues = convertColumnWrappers2Map4Persist(headerColumnWrapper, row, currUserAgencyId, checkBoxOptionColumnIdxAndLabel); + + // 检验身份证号 + String idCard = columnAndValues.get("ID_CARD"); + if (StringUtils.isBlank(idCard)) { + throw new RenException(EpmetErrorCode.IDCARDNO_ERROR.getCode(), String.format("用户【%s】身份证号未填写或格式错误", columnAndValues.get("NAME"))); + } + + // 检查用户是否存在 + LambdaQueryWrapper idCardQuery = new LambdaQueryWrapper<>(); + idCardQuery.eq(IcResiUserEntity::getIdCard, idCard); + + IcResiUserEntity icResiUserBaseInfo = baseDao.selectOne(idCardQuery); + if (icResiUserBaseInfo == null) { + throw new RenException(EpmetErrorCode.RESI_NOT_FOUND.getCode(), String.format("身份证号为【%s】的居民信息未找到,请确认该居民信息存在", idCard)); + } + + String icResiId = icResiUserBaseInfo.getId(); + + // 验证党员信息是否存在 + if (CollectionUtils.isNotEmpty(baseDao.selectSubTableRecords(customerId, icResiId, targetTableName))) { + log.info("身份证号为【{}】的居民【{}】信息已存在,跳过导入", idCard, targetTableName); + continue; + } + + columnAndValues.put("IC_RESI_USER", icResiId); + + columnAndValues.put("CUSTOMER_ID", loginUserUtil.getCurrentCustomerId()); + columnAndValues.put("CREATED_BY", currentUserId); + columnAndValues.put("UPDATED_BY", currentUserId); + columnAndValues.put("ID", UUID.randomUUID().toString().replace("-", "")); + + columnAndValues = removeNeedlessColumns(columnAndValues); -// System.out.println("-------------------"); + baseDao.add(targetTableName, columnAndValues); + } + } + + /** + * 去掉多余的列 + * @param originColumnAndValues + * @return + */ + private LinkedHashMap removeNeedlessColumns(LinkedHashMap originColumnAndValues) { + List needlessColumns = Arrays.asList("GRID_ID", "VILLAGE_ID", "BUILD_ID", "UNIT_ID", "HOME_ID", + "IS_BDHJ", "NAME", "MOBILE", "GENDER", "ID_CARD", + "BIRTHDAY", "CONTACTS", "CONTACTS_MOBILE"); + + LinkedHashMap newMap = new LinkedHashMap(); + + originColumnAndValues.entrySet().forEach(b -> { + if (!needlessColumns.contains(b.getKey())) { + newMap.put(b.getKey(), b.getValue()); + } + }); + + return newMap; + } + + /** + * 将当前行数据转化成LinkedHashMap,供后续插入 + * @param headerColumnWrapper 当前行的ColumnWrapper,每一个ColumnWrapper元素都是当前行中的一个列 + * @param row 当前行数据 + * @param currUserAgencyId 当前用户所属机构ID + * @param checkBoxOptionColumnIdxAndLabel 复选框options列表。key:列号,value:复选框中文 + * @return + */ + private LinkedHashMap convertColumnWrappers2Map4Persist(Map headerColumnWrapper, Map row, + String currUserAgencyId, Map checkBoxOptionColumnIdxAndLabel) { + LinkedHashMap columnAndValues = new LinkedHashMap<>(); + + for (Map.Entry columnWrapperEntry : headerColumnWrapper.entrySet()) { + + ColumnWrapper columnWrapper = columnWrapperEntry.getValue(); + if ("input".equals(columnWrapper.getItemType()) + || "textarea".equals(columnWrapper.getItemType()) + || "datepicker".equals(columnWrapper.getItemType()) + || "daterange".equals(columnWrapper.getItemType()) + ) { + + String cellContent = row.get(columnWrapper.getColIndexs().get(0)); + columnWrapper.setCellContent(cellContent); + columnWrapper.setColValue(cellContent); + + } else if ("select".equals(columnWrapper.getItemType()) + || "radio".equals(columnWrapper.getItemType())){ + + String optionSourceType = columnWrapper.getOptionSourceType(); + // 取单元格的内容 + String cellContent = row.get(columnWrapper.getColIndexs().get(0)); + columnWrapper.setCellContent(cellContent); + + if ("local".equals(optionSourceType)) { + // 根据单元格内容,取到指定的option + Map options = columnWrapper.getOptions(); + String colValue = options.get(cellContent); + columnWrapper.setColValue(colValue); + } else { + // remote类型 - baseDao.add(tableName, columnAndValues); + Map options = listRemoteOptions(headerColumnWrapper, columnWrapper.getOptionSourceValue(), currUserAgencyId); + String colValue = options.get(cellContent); + columnWrapper.setColValue(colValue); + } + } else if ("checkbox".equals(columnWrapper.getItemType())) { + String checkBoxColValue = getCheckBoxColValue(columnWrapper, row, checkBoxOptionColumnIdxAndLabel); + columnWrapper.setColValue(checkBoxColValue); + } + columnAndValues.put(columnWrapper.columnName, columnWrapper.colValue); } + + return columnAndValues; } /** From 6e8138ecd032a085125dbaa3d2e9703a46fbb938 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Thu, 4 Nov 2021 22:24:05 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=20=E8=B0=83?= =?UTF-8?q?=E6=95=B4ic=E5=B1=85=E6=B0=91=E5=AF=BC=E5=85=A5=EF=BC=8C?= =?UTF-8?q?=E5=B0=86=E5=AF=BC=E5=85=A5=E9=80=BB=E8=BE=91=E7=A7=BB=E5=88=B0?= =?UTF-8?q?=E5=8D=95=E7=8B=AC=E7=9A=84service=E4=B8=ADIcResiUserImportServ?= =?UTF-8?q?ice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/IcResiUserController.java | 6 +- .../service/IcResiUserImportService.java | 12 + .../com/epmet/service/IcResiUserService.java | 2 +- .../impl/IcResiUserImportServiceImpl.java | 718 ++++++++++++++++++ .../service/impl/IcResiUserServiceImpl.java | 654 +--------------- 5 files changed, 739 insertions(+), 653 deletions(-) create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java 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 8bc6cdbcca..f525d82218 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 @@ -33,6 +33,7 @@ import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.OperCustomizeOpenFeignClient; +import com.epmet.service.IcResiUserImportService; import com.epmet.service.IcResiUserService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -67,7 +68,7 @@ public class IcResiUserController { @Autowired private IcResiUserService icResiUserService; @Autowired - private EpmetUserOpenFeignClient epmetUserOpenFeignClient; + private IcResiUserImportService icResiUserImportService; /** * @Author sun @@ -216,12 +217,11 @@ public class IcResiUserController { /** * excel导入居民基本信息 * - * @param loginUser * @return */ @PostMapping("import/excel") public Result importExcelByEasyExcel() { - Object result = icResiUserService.importIcResiInfoFromExcel(); + Object result = icResiUserImportService.importIcResiInfoFromExcel(); return new Result().ok(result); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java new file mode 100644 index 0000000000..be0d40187d --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java @@ -0,0 +1,12 @@ +package com.epmet.service; + +/** + *@Description 居民信息导入service + *@Author wangxianzhang + *@Date 2021/11/4 + */ +public interface IcResiUserImportService { + + Object importIcResiInfoFromExcel(); + +} 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 2a19783293..2e9e5cf70d 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 @@ -70,7 +70,7 @@ public interface IcResiUserService extends BaseService { */ Map queryIcResiDetail(IcResiDetailFormDTO pageFormDTO); - Object importIcResiInfoFromExcel(); + List> dynamicQuery(String customerId, String formCode, 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 new file mode 100644 index 0000000000..4e121b2e8f --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java @@ -0,0 +1,718 @@ +package com.epmet.service.impl; + +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.dto.result.OptionResultDTO; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.feign.ResultDataResolver; +import com.epmet.commons.tools.security.user.LoginUserUtil; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dao.IcResiUserDao; +import com.epmet.dto.*; +import com.epmet.dto.form.AgencyIdFormDTO; +import com.epmet.dto.form.CustomerFormQueryDTO; +import com.epmet.dto.form.HouseFormDTO; +import com.epmet.dto.form.LoginUserDetailsFormDTO; +import com.epmet.dto.result.FormItem; +import com.epmet.dto.result.LoginUserDetailsResultDTO; +import com.epmet.dto.result.OptionDTO; +import com.epmet.entity.IcResiUserEntity; +import com.epmet.excel.handler.DynamicEasyExcelListener; +import com.epmet.feign.EpmetAdminOpenFeignClient; +import com.epmet.feign.EpmetUserOpenFeignClient; +import com.epmet.feign.GovOrgOpenFeignClient; +import com.epmet.feign.OperCustomizeOpenFeignClient; +import com.epmet.service.IcResiUserImportService; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.File; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @ClassName IcResiUserImportServiceImpl + * @Description TODO + * @Author wangxianzhang + * @Date 2021/11/4 8:53 下午 + * @Version 1.0 + */ +@Slf4j +@Service +public class IcResiUserImportServiceImpl implements IcResiUserImportService, ResultDataResolver { + + public static final ThreadLocal errorRow = new ThreadLocal(); + + @Autowired + private LoginUserUtil loginUserUtil; + + @Autowired + private EpmetUserOpenFeignClient epmetUserOpenFeignClient; + + @Autowired + private EpmetAdminOpenFeignClient adminOpenFeignClient; + + @Autowired + private GovOrgOpenFeignClient govOrgOpenFeignClient; + + @Autowired + private OperCustomizeOpenFeignClient operCustomizeOpenFeignClient; + + @Autowired + private IcResiUserDao icResiUserDao; + + /** + * @description 列信息封装 + * + * @return + * @author wxz + * @date 2021.10.28 22:18:05 + */ + @Data + public static class ColumnWrapper { + private String combinedLabel; + private String columnName; + private String itemType; + private String itemId; + private List colIndexs; + //private List colContents; + // 单元格内容 + private String cellContent; + // 数据库中列的值 + private String colValue; + + // key:label,value:value + private Map options; + + /** + * 选项来源,REMOTE;LOCAL;如果是动态加载的下拉框或者CHECKBOX等的情况下使用。URL:接口获取(LABEL,VALUE);JSON:直接从JSON中取 + */ + private String optionSourceType; + + /** + * 来源地址,REMOTE才有,固定格式;如果OPTIONS_SOURCE是URL,则此处填写要调用的接口的URL相对路径,例如:/API/GOV/ORG/XXXX。此处不应设置参数,若需要参数应当完全由后端,通过TOKEN信息来获取 + */ + private String optionSourceValue; + } + + /** + * 错误行信息 + */ + public static class ErrorRow { + private String sheetName; + private String idCard; + private String name; + private String errorInfo; + } + + /** + * 导入居民信息 + * 导入主表和所有子表信息 + * @return + */ + @Override + public Object importIcResiInfoFromExcel() { + String loginUserId = loginUserUtil.getLoginUserId(); + String loginUserApp = loginUserUtil.getLoginUserApp(); + String loginUserClient = loginUserUtil.getLoginUserClient(); + + LoginUserDetailsFormDTO userForm = new LoginUserDetailsFormDTO(); + userForm.setApp(loginUserApp); + userForm.setClient(loginUserClient); + userForm.setUserId(loginUserId); + + LoginUserDetailsResultDTO loginUserDetails = getResultDataOrThrowsException(epmetUserOpenFeignClient.getLoginUserDetails(userForm), ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), 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); + String customerId = agencyInfo.getCustomerId(); + + importIcResiBaseInfoFromExcel(excelPathName, 0, 3, currUserAgencyId, agencyInfo.getPids(), loginUserId); + importIcResiExtraInfoFromExcel(excelPathName, 1, 2, currUserAgencyId, loginUserId, "ic_party_member", customerId); + importIcResiExtraInfoFromExcel(excelPathName, 2, 2, currUserAgencyId, loginUserId, "ic_ensure_house", customerId); + importIcResiExtraInfoFromExcel(excelPathName, 3, 2, currUserAgencyId, loginUserId, "ic_unemployed", customerId); + importIcResiExtraInfoFromExcel(excelPathName, 4, 2, currUserAgencyId, loginUserId, "ic_veterans", customerId); + importIcResiExtraInfoFromExcel(excelPathName, 5, 2, currUserAgencyId, loginUserId, "ic_united_front", customerId); + importIcResiExtraInfoFromExcel(excelPathName, 6, 3, currUserAgencyId, loginUserId, "ic_volunteer", customerId); + importIcResiExtraInfoFromExcel(excelPathName, 7, 2, currUserAgencyId, loginUserId, "ic_old_people", customerId); + importIcResiExtraInfoFromExcel(excelPathName, 8, 3, currUserAgencyId, loginUserId, "ic_special", customerId); + + return null; + } + + /** + * excel导入居民基本信息 + * @param sheetNo + * @param headRowNumber + * @param currUserAgencyId + * @param currUserAgencyPids + * @param currentUserId + * @return + */ + private Object importIcResiBaseInfoFromExcel(String excelPathName, int sheetNo, int headRowNumber, String currUserAgencyId, String currUserAgencyPids, String currentUserId) { + DynamicEasyExcelListener readListener = new DynamicEasyExcelListener(); + EasyExcelFactory.read(new File(excelPathName)).registerReadListener(readListener).headRowNumber(headRowNumber).sheet(sheetNo).doRead(); + + List> headList = readListener.getHeadList(); + List> dataList = readListener.getDataList(); + + Map> headers = mergeHead(headList); + + // 查询form相关信息 + List customerItems = listFormItems("resi_base_info"); + + // 清洗表头数据 + Map abandonedHeaders = washHeaders(headers, customerItems); + + //合并多级表头 + HashMap> combinedHeaders = combineHeaders(headers); + + // 得到客户配置item数据 + Map formItemMap = customerItems.stream().collect( + Collectors.toMap(formItem -> { + String groupLabel = formItem.getGroupLabel(); + String label = formItem.getLabel(); + if (StringUtils.isNotBlank(groupLabel)) { + return groupLabel.concat(":").concat(label); + } else { + return label; + } + }, formItem -> formItem) + ); + Map headerColumnWrapper = convertExcelHeaders2DBColumnWrappers(formItemMap, combinedHeaders, dataList, abandonedHeaders); + + // 持久化 + persistIcResiBaseInfo(headerColumnWrapper, dataList, currUserAgencyId, abandonedHeaders, currUserAgencyPids, currentUserId); + + return headers; + } + + /** + * excel导入居民附加信息 + * @param excelPathName + * @param sheetNo + * @param headRowNumber + * @param currUserAgencyId + * @param currentUserId + * @param targetTableName 要插入哪一个表 + * @return + */ + private Object importIcResiExtraInfoFromExcel(String excelPathName, int sheetNo, int headRowNumber, String currUserAgencyId, String currentUserId, + String targetTableName, String customerId) { + DynamicEasyExcelListener readListener = new DynamicEasyExcelListener(); + EasyExcelFactory.read(new File(excelPathName)).registerReadListener(readListener).headRowNumber(headRowNumber).sheet(sheetNo).doRead(); + + List> headList = readListener.getHeadList(); + List> dataList = readListener.getDataList(); + + Map> headers = mergeHead(headList); + + // 查询form相关信息 + List customerItems = listFormItems("resi_base_info"); + + // 清洗表头数据 + Map abandonedHeaders = washHeaders(headers, customerItems); + + //合并多级表头 + HashMap> combinedHeaders = combineHeaders(headers); + + // 得到客户配置item数据 + Map formItemMap = customerItems.stream().collect( + Collectors.toMap(formItem -> { + String groupLabel = formItem.getGroupLabel(); + String label = formItem.getLabel(); + if (StringUtils.isNotBlank(groupLabel)) { + return groupLabel.concat(":").concat(label); + } else { + return label; + } + }, formItem -> formItem) + ); + Map headerColumnWrapper = convertExcelHeaders2DBColumnWrappers(formItemMap, combinedHeaders, dataList, abandonedHeaders); + persistIcResiExtraInfo(headerColumnWrapper, dataList, currUserAgencyId, abandonedHeaders, currentUserId, targetTableName, customerId); + return headerColumnWrapper; + } + + /** + * 持久化IC居民基础信息 + * @param headerColumnWrapper 数据库列包装信息 + * @param dataRows 数据行集合 + * @param currUserAgencyId 当前用户的组织id + * @param checkBoxOptionColumnIdxAndLabel 复选框的列号&label中文 + */ + private void persistIcResiBaseInfo(Map headerColumnWrapper, List> dataRows, + String currUserAgencyId, Map checkBoxOptionColumnIdxAndLabel, + String currUserAgencyPids, String currentUserId) { + + // 遍历每一行,将行内容转化为 + for (Map row : dataRows) { + + LinkedHashMap columnAndValues = convertColumnWrappers2Map4Persist(headerColumnWrapper, row, currUserAgencyId, checkBoxOptionColumnIdxAndLabel); + + columnAndValues.put("IS_ENSURE_HOUSE", "0"); + columnAndValues.put("IS_OLD_PEOPLE", "0"); + columnAndValues.put("IS_PARTY", "0"); + columnAndValues.put("IS_SPECIAL", "0"); + columnAndValues.put("IS_UNEMPLOYED", "0"); + columnAndValues.put("IS_UNITED_FRONT", "0"); + columnAndValues.put("IS_VETERANS", "0"); + columnAndValues.put("IS_VOLUNTEER", "0"); + + columnAndValues.put("AGENCY_ID", currUserAgencyId); + columnAndValues.put("PIDS", currUserAgencyPids); + columnAndValues.put("CUSTOMER_ID", loginUserUtil.getCurrentCustomerId()); + columnAndValues.put("CREATED_BY", currentUserId); + columnAndValues.put("UPDATED_BY", currentUserId); + columnAndValues.put("ID", UUID.randomUUID().toString().replace("-", "")); + + // 验证居民信息是否存在 + String idCard = columnAndValues.get("ID_CARD"); + LambdaQueryWrapper idCardQuery = new LambdaQueryWrapper<>(); + idCardQuery.eq(IcResiUserEntity::getIdCard, idCard); + + if (icResiUserDao.selectCount(idCardQuery) > 0) { + log.info("身份证号为【{}】的居民信息已存在,跳过导入", idCard); + } + + icResiUserDao.add("ic_resi_user", columnAndValues); + } + } + + /** + * 持久化IC居民附加信息 + * @param headerColumnWrapper 数据库列包装信息 + * @param dataRows 数据行集合 + * @param currUserAgencyId 当前用户的组织id + * @param checkBoxOptionColumnIdxAndLabel 复选框的列号&label中文 + * @param targetTableName 要插入到哪一个表 + */ + private void persistIcResiExtraInfo(Map headerColumnWrapper, List> dataRows, + String currUserAgencyId, Map checkBoxOptionColumnIdxAndLabel, + String currentUserId, String targetTableName, String customerId) { + + // 遍历每一行,将行内容转化为 + for (Map row : dataRows) { + + LinkedHashMap columnAndValues = convertColumnWrappers2Map4Persist(headerColumnWrapper, row, currUserAgencyId, checkBoxOptionColumnIdxAndLabel); + + // 检验身份证号 + String idCard = columnAndValues.get("ID_CARD"); + if (StringUtils.isBlank(idCard)) { + throw new RenException(EpmetErrorCode.IDCARDNO_ERROR.getCode(), String.format("用户【%s】身份证号未填写或格式错误", columnAndValues.get("NAME"))); + } + + // 检查用户是否存在 + LambdaQueryWrapper idCardQuery = new LambdaQueryWrapper<>(); + idCardQuery.eq(IcResiUserEntity::getIdCard, idCard); + + IcResiUserEntity icResiUserBaseInfo = icResiUserDao.selectOne(idCardQuery); + if (icResiUserBaseInfo == null) { + throw new RenException(EpmetErrorCode.RESI_NOT_FOUND.getCode(), String.format("身份证号为【%s】的居民信息未找到,请确认该居民信息存在", idCard)); + } + + String icResiId = icResiUserBaseInfo.getId(); + + // 验证党员信息是否存在 + if (CollectionUtils.isNotEmpty(icResiUserDao.selectSubTableRecords(customerId, icResiId, targetTableName))) { + log.info("身份证号为【{}】的居民【{}】信息已存在,跳过导入", idCard, targetTableName); + continue; + } + + columnAndValues.put("IC_RESI_USER", icResiId); + + columnAndValues.put("CUSTOMER_ID", loginUserUtil.getCurrentCustomerId()); + columnAndValues.put("CREATED_BY", currentUserId); + columnAndValues.put("UPDATED_BY", currentUserId); + columnAndValues.put("ID", UUID.randomUUID().toString().replace("-", "")); + + columnAndValues = removeNeedlessColumns(columnAndValues); + + icResiUserDao.add(targetTableName, columnAndValues); + } + } + + /** + * 去掉多余的列 + * @param originColumnAndValues + * @return + */ + private LinkedHashMap removeNeedlessColumns(LinkedHashMap originColumnAndValues) { + List needlessColumns = Arrays.asList("GRID_ID", "VILLAGE_ID", "BUILD_ID", "UNIT_ID", "HOME_ID", + "IS_BDHJ", "NAME", "MOBILE", "GENDER", "ID_CARD", + "BIRTHDAY", "CONTACTS", "CONTACTS_MOBILE"); + + LinkedHashMap newMap = new LinkedHashMap(); + + originColumnAndValues.entrySet().forEach(b -> { + if (!needlessColumns.contains(b.getKey())) { + newMap.put(b.getKey(), b.getValue()); + } + }); + + return newMap; + } + + /** + * 将当前行数据转化成LinkedHashMap,供后续插入 + * @param headerColumnWrapper 当前行的ColumnWrapper,每一个ColumnWrapper元素都是当前行中的一个列 + * @param row 当前行数据 + * @param currUserAgencyId 当前用户所属机构ID + * @param checkBoxOptionColumnIdxAndLabel 复选框options列表。key:列号,value:复选框中文 + * @return + */ + private LinkedHashMap convertColumnWrappers2Map4Persist(Map headerColumnWrapper, Map row, + String currUserAgencyId, Map checkBoxOptionColumnIdxAndLabel) { + LinkedHashMap columnAndValues = new LinkedHashMap<>(); + + for (Map.Entry columnWrapperEntry : headerColumnWrapper.entrySet()) { + + ColumnWrapper columnWrapper = columnWrapperEntry.getValue(); + if ("input".equals(columnWrapper.getItemType()) + || "textarea".equals(columnWrapper.getItemType()) + || "datepicker".equals(columnWrapper.getItemType()) + || "daterange".equals(columnWrapper.getItemType()) + ) { + + String cellContent = row.get(columnWrapper.getColIndexs().get(0)); + columnWrapper.setCellContent(cellContent); + columnWrapper.setColValue(cellContent); + + } else if ("select".equals(columnWrapper.getItemType()) + || "radio".equals(columnWrapper.getItemType())){ + + String optionSourceType = columnWrapper.getOptionSourceType(); + // 取单元格的内容 + String cellContent = row.get(columnWrapper.getColIndexs().get(0)); + columnWrapper.setCellContent(cellContent); + + if ("local".equals(optionSourceType)) { + // 根据单元格内容,取到指定的option + Map options = columnWrapper.getOptions(); + String colValue = options.get(cellContent); + columnWrapper.setColValue(colValue); + } else { + // remote类型 + + Map options = listRemoteOptions(headerColumnWrapper, columnWrapper.getOptionSourceValue(), currUserAgencyId); + String colValue = options.get(cellContent); + columnWrapper.setColValue(colValue); + } + } else if ("checkbox".equals(columnWrapper.getItemType())) { + String checkBoxColValue = getCheckBoxColValue(columnWrapper, row, checkBoxOptionColumnIdxAndLabel); + columnWrapper.setColValue(checkBoxColValue); + } + columnAndValues.put(columnWrapper.columnName, columnWrapper.colValue); + } + + return columnAndValues; + } + + /** + * 根据formCode查询该form的item列表 + * @param formCode + * @return + */ + private List listFormItems(String formCode) { + CustomerFormQueryDTO form = new CustomerFormQueryDTO(); + form.setFormCode(formCode); + Result> result = operCustomizeOpenFeignClient.listItems(form); + return getResultDataOrThrowsException(result, ServiceConstant.OPER_CUSTOMIZE_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【居民信息excel导入】查询表单相关信息失败"); + } + + /** + * @description 合并头 + * + * @param headers + * @return + * @author wxz + * @date 2021.10.28 21:27:18 + */ + private HashMap> combineHeaders(Map> headers) { + HashMap> itemAndColIndexs = new LinkedHashMap<>(); + + headers.forEach((k, v) -> { + String tempKey = String.join(":", v); + List colIndexs = itemAndColIndexs.get(tempKey); + if (colIndexs == null) { + colIndexs = new ArrayList<>(); + itemAndColIndexs.put(tempKey, colIndexs); + } + colIndexs.add(k); + }); + + return itemAndColIndexs; + } + + /** + * @description 洗头 + * + * @param headers + * @param items + * @return + * @author wxz + * @date 2021.10.28 21:07:12 + */ + private Map washHeaders(Map> headers, List items) { + List itemLabels = items.stream().map(i -> i.getLabel()).collect(Collectors.toList()); + Map abandonedHeaders = new HashMap<>(); + for (Map.Entry> entry:headers.entrySet()) { + Integer colIdx = entry.getKey(); + List v = entry.getValue(); + int lastPartIndex = v.size() - 1; + String lastValuePart = v.get(lastPartIndex); + if (!itemLabels.contains(lastValuePart)) { + // 该部分为options,它的上一级是item,那么去掉options这一级 + v.remove(lastPartIndex); + abandonedHeaders.put(colIdx, lastValuePart); + } + } + + return abandonedHeaders; + } + + /** + * @description 数据整合,将excel表头汉字信息转化成ColumnWrapper列封装数据 + * * key:itemId + * * value:ColumnWrapper列包装信息 + * @param formItemMap item map + * key:itemId; + * value: 合并之后的head字符串,例如:健康信息:监护人 + * @param combinedHeaders 合并之后的head信息。 + * key:合并之后head字符串(例如:党员信息:入党时间); + * value:列号组成的列表(例如[1,2,3]) + * @param datas + * @param abandonedHeaders + * @return + */ + private Map convertExcelHeaders2DBColumnWrappers(Map formItemMap, Map> combinedHeaders, + List> datas, Map abandonedHeaders) { + +// HashMap> tables = new HashMap<>(); + Map columns = new LinkedHashMap<>(combinedHeaders.size()); + + for (Map.Entry> entry : combinedHeaders.entrySet()) { + String combinedHeader = entry.getKey(); + + FormItem item = formItemMap.get(combinedHeader); + + if (item == null) { + // 如果数据库中没有该项,可能是用户自己定义的项,忽略 + continue; + } + + ColumnWrapper columnWrapper = new ColumnWrapper(); + + // 填充options + columnWrapper.setItemType(item.getItemType()); + columnWrapper.setItemId(item.getItemId()); + String groupLabel = item.getGroupLabel(); + String combinedLabel = StringUtils.isBlank(groupLabel) ? item.getLabel() : groupLabel.concat(":").concat(item.getLabel()); + columnWrapper.setCombinedLabel(combinedLabel); + columnWrapper.setColumnName(item.getColumnName()); + columnWrapper.setColIndexs(entry.getValue()); + + columnWrapper.setOptionSourceType(item.getOptionSourceType()); + columnWrapper.setOptionSourceValue(item.getOptionSourceValue()); + columnWrapper.setOptions(item.getOptions().stream().collect(Collectors.toMap(OptionDTO::getLabel, OptionDTO::getValue))); + + columns.put(item.getItemId(), columnWrapper); + } + return columns; + } + + /** + * 获取checkbox列值 + * @param columnWrapper 数据库列包装信息,每一列跳数据对应数据库的一个列 + * @param dataRow 数据行,每一条都是一行中的一个单元格 + * @param checkboxOptions 复选框的选项。k: 列号, value: checkboxlabel中文 + * @return + */ + private String getCheckBoxColValue(ColumnWrapper columnWrapper, Map dataRow, Map checkboxOptions) { + + Map options = columnWrapper.getOptions(); + List colIndexs = columnWrapper.getColIndexs(); + + List optionValues = colIndexs.stream().filter(i -> { + String cellContent = dataRow.get(i); + return StringUtils.isNotBlank(cellContent) && cellContent.equals("是"); + }).map(i -> { + String checkboxOptionLabel = checkboxOptions.get(i); + return options.get(checkboxOptionLabel); + }).collect(Collectors.toList()); + + return String.join(",", optionValues); + } + + /** + * @description 合并表头 + * Map> + * + * @param headList + * @return + * @author wxz + * @date 2021.10.27 16:17:34 + */ + private Map> mergeHead(List> headList) { + + Map lastNotNullHeads = new LinkedHashMap<>(); + + Map> mergedHead = new LinkedHashMap<>(); + + int levelCount = headList.size(); + + Map firstLevel = headList.get(0); + + // 遍历所有列 + for (Map.Entry column : firstLevel.entrySet()) { + Integer columIndex = column.getKey(); + + List labels = new ArrayList<>(); + + // 竖着遍历该列的所有行 + for (int currentLevel = 0; currentLevel < levelCount; currentLevel ++) { + String label = headList.get(currentLevel).get(columIndex); + + if (StringUtils.isNotBlank(label)) { + lastNotNullHeads.put(currentLevel, label); + } else { + if (currentLevel == 0 || StringUtils.isBlank(headList.get(currentLevel - 1).get(columIndex))) { + label = lastNotNullHeads.get(currentLevel); + } + } + + if (StringUtils.isNotBlank(label)) { + labels.add(label); + } + } + + mergedHead.put(columIndex, labels); + } + + return mergedHead; + } + + /** + * 远程获取options + * @param fullUri + * @return + */ + public Map listRemoteOptions(Map columnWrappers, String fullUri, String currUserAgencyId) { + String pureUri = null; + String cascadeItemId = null; + ColumnWrapper cascadeItemColumnWrapper = null; + + if (fullUri.indexOf("?") != -1) { + String[] uriParts = fullUri.split("\\?"); + pureUri = uriParts[0]; + cascadeItemId = uriParts[1]; + + // 根据uri上的id,找到关联的itemid,从而找到关联的item的值 + if (columnWrappers != null){ + cascadeItemColumnWrapper = columnWrappers.get(cascadeItemId); + } + } else { + pureUri = fullUri; + } + + List options = null; + + switch (pureUri) { + case "/epmetuser/icresidemanddict/demandoption": + options = getResultDataOrThrowsException(epmetUserOpenFeignClient.getDemandOptions(), ServiceConstant.EPMET_USER_SERVER, + EpmetErrorCode.SERVER_ERROR.getCode(), null); + break; + case "/gov/org/customergrid/gridoption": + AgencyIdFormDTO form = new AgencyIdFormDTO(); + form.setAgencyId(currUserAgencyId); + options = getResultDataOrThrowsException(govOrgOpenFeignClient.getGridOption(form), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), 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); + 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); + 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); + 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); + 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); + break; + case "/sys/dict/data/education": + options = getResultDataOrThrowsException(adminOpenFeignClient.getEducationOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); + break; + case "/sys/dict/data/house": + options = getResultDataOrThrowsException(adminOpenFeignClient.getHouseOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); + break; + case "/sys/dict/data/nation": + options = getResultDataOrThrowsException(adminOpenFeignClient.getNationOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); + break; + case "/sys/dict/data/ninesmallplaces": + options = getResultDataOrThrowsException(adminOpenFeignClient.getNineSmallPlacesOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); + break; + case "/sys/dict/data/relationship": + options = getResultDataOrThrowsException(adminOpenFeignClient.getRelationshipOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); + break; + + } + + if (options == null) { + return null; + } + + return options.stream().collect(Collectors.toMap(OptionResultDTO::getLabel, OptionResultDTO::getValue)); + + // 通用api调用,无法实现 + /*if (!uri.startsWith("/api")) uri = "/api".concat(uri); + + NamingService namingService = discoveryProperties.namingServiceInstance(); + ResponseEntity>> response = null; + try { + // 调用gateway服务,查询相关接口 + Instance gatewayInstance = namingService.getAllInstances(ServiceConstant.EPMET_GATEWAY).get(0); + String ip = gatewayInstance.getIp(); + int port = gatewayInstance.getPort(); + + String url = String.format("http://%s:%s%s", ip, port, uri); + + ParameterizedTypeReference>> tr = new ParameterizedTypeReference>>() {}; + response = new RestTemplate().exchange(url, HttpMethod.POST, null, tr); + } catch (NacosException e) { + e.printStackTrace(); + } + + if (response != null && (response.getStatusCode() == HttpStatus.OK)) { + List options = response.getBody().getData(); + if (options == null) { + System.out.println(6); + } + return options.stream().collect(Collectors.toMap(OptionResultDTO::getLabel, OptionResultDTO::getValue)); + } else { + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + }*/ + + } + +} 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 fe8905ec2f..0765780072 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 @@ -50,6 +50,7 @@ import com.epmet.entity.IcPartyMemberEntity; import com.epmet.entity.IcResiUserEntity; import com.epmet.excel.handler.DynamicEasyExcelListener; import com.epmet.feign.*; +import com.epmet.service.IcResiUserImportService; import com.epmet.service.IcResiUserService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -75,24 +76,17 @@ import java.util.stream.Stream; */ @Slf4j @Service -public class IcResiUserServiceImpl extends BaseServiceImpl implements IcResiUserService, ResultDataResolver { +public class IcResiUserServiceImpl extends BaseServiceImpl implements IcResiUserService { @Autowired private GovOrgOpenFeignClient govOrgOpenFeignClient; @Autowired private OperCustomizeOpenFeignClient operCustomizeOpenFeignClient; - @Autowired - private EpmetUserOpenFeignClient epmetUserOpenFeignClient; - - @Autowired - private EpmetAdminOpenFeignClient adminOpenFeignClient; - - @Autowired - private LoginUserUtil loginUserUtil; @Autowired private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; - + @Autowired + private IcResiUserImportServiceImpl icResiUserImportService; private QueryWrapper getWrapper(Map params){ String id = (String)params.get(FieldConstant.ID_HUMP); @@ -451,644 +445,6 @@ public class IcResiUserServiceImpl extends BaseServiceImpl> headList = readListener.getHeadList(); - List> dataList = readListener.getDataList(); - - Map> headers = mergeHead(headList); - - // 查询form相关信息 - List customerItems = listFormItems("resi_base_info"); - - // 清洗表头数据 - Map abandonedHeaders = washHeaders(headers, customerItems); - - //合并多级表头 - HashMap> combinedHeaders = combineHeaders(headers); - - // 得到客户配置item数据 - Map formItemMap = customerItems.stream().collect( - Collectors.toMap(formItem -> { - String groupLabel = formItem.getGroupLabel(); - String label = formItem.getLabel(); - if (StringUtils.isNotBlank(groupLabel)) { - return groupLabel.concat(":").concat(label); - } else { - return label; - } - }, formItem -> formItem) - ); - Map headerColumnWrapper = convertExcelHeaders2DBColumnWrappers(formItemMap, combinedHeaders, dataList, abandonedHeaders); - - // 持久化 - persistIcResiBaseInfo(headerColumnWrapper, dataList, currUserAgencyId, abandonedHeaders, currUserAgencyPids, currentUserId); - - return headers; - } - - /** - * excel导入居民附加信息 - * @param excelPathName - * @param sheetNo - * @param headRowNumber - * @param currUserAgencyId - * @param currentUserId - * @param targetTableName 要插入哪一个表 - * @return - */ - private Object importIcResiExtraInfoFromExcel(String excelPathName, int sheetNo, int headRowNumber, String currUserAgencyId, String currentUserId, - String targetTableName, String customerId) { - DynamicEasyExcelListener readListener = new DynamicEasyExcelListener(); - EasyExcelFactory.read(new File(excelPathName)).registerReadListener(readListener).headRowNumber(headRowNumber).sheet(sheetNo).doRead(); - - List> headList = readListener.getHeadList(); - List> dataList = readListener.getDataList(); - - Map> headers = mergeHead(headList); - - // 查询form相关信息 - List customerItems = listFormItems("resi_base_info"); - - // 清洗表头数据 - Map abandonedHeaders = washHeaders(headers, customerItems); - - //合并多级表头 - HashMap> combinedHeaders = combineHeaders(headers); - - // 得到客户配置item数据 - Map formItemMap = customerItems.stream().collect( - Collectors.toMap(formItem -> { - String groupLabel = formItem.getGroupLabel(); - String label = formItem.getLabel(); - if (StringUtils.isNotBlank(groupLabel)) { - return groupLabel.concat(":").concat(label); - } else { - return label; - } - }, formItem -> formItem) - ); - Map headerColumnWrapper = convertExcelHeaders2DBColumnWrappers(formItemMap, combinedHeaders, dataList, abandonedHeaders); - persistIcResiExtraInfo(headerColumnWrapper, dataList, currUserAgencyId, abandonedHeaders, currentUserId, targetTableName, customerId); - return headerColumnWrapper; - } - - /** - * 持久化IC居民基础信息 - * @param headerColumnWrapper 数据库列包装信息 - * @param dataRows 数据行集合 - * @param currUserAgencyId 当前用户的组织id - * @param checkBoxOptionColumnIdxAndLabel 复选框的列号&label中文 - */ - private void persistIcResiBaseInfo(Map headerColumnWrapper, List> dataRows, - String currUserAgencyId, Map checkBoxOptionColumnIdxAndLabel, - String currUserAgencyPids, String currentUserId) { - - // 遍历每一行,将行内容转化为 - for (Map row : dataRows) { - - LinkedHashMap columnAndValues = convertColumnWrappers2Map4Persist(headerColumnWrapper, row, currUserAgencyId, checkBoxOptionColumnIdxAndLabel); - - columnAndValues.put("IS_ENSURE_HOUSE", "0"); - columnAndValues.put("IS_OLD_PEOPLE", "0"); - columnAndValues.put("IS_PARTY", "0"); - columnAndValues.put("IS_SPECIAL", "0"); - columnAndValues.put("IS_UNEMPLOYED", "0"); - columnAndValues.put("IS_UNITED_FRONT", "0"); - columnAndValues.put("IS_VETERANS", "0"); - columnAndValues.put("IS_VOLUNTEER", "0"); - - columnAndValues.put("AGENCY_ID", currUserAgencyId); - columnAndValues.put("PIDS", currUserAgencyPids); - columnAndValues.put("CUSTOMER_ID", loginUserUtil.getCurrentCustomerId()); - columnAndValues.put("CREATED_BY", currentUserId); - columnAndValues.put("UPDATED_BY", currentUserId); - columnAndValues.put("ID", UUID.randomUUID().toString().replace("-", "")); - - // 验证居民信息是否存在 - String idCard = columnAndValues.get("ID_CARD"); - LambdaQueryWrapper idCardQuery = new LambdaQueryWrapper<>(); - idCardQuery.eq(IcResiUserEntity::getIdCard, idCard); - - if (baseDao.selectCount(idCardQuery) > 0) { - log.info("身份证号为【{}】的居民信息已存在,跳过导入", idCard); - } - - baseDao.add("ic_resi_user", columnAndValues); - } - } - - /** - * 持久化IC居民附加信息 - * @param headerColumnWrapper 数据库列包装信息 - * @param dataRows 数据行集合 - * @param currUserAgencyId 当前用户的组织id - * @param checkBoxOptionColumnIdxAndLabel 复选框的列号&label中文 - * @param targetTableName 要插入到哪一个表 - */ - private void persistIcResiExtraInfo(Map headerColumnWrapper, List> dataRows, - String currUserAgencyId, Map checkBoxOptionColumnIdxAndLabel, - String currentUserId, String targetTableName, String customerId) { - - // 遍历每一行,将行内容转化为 - for (Map row : dataRows) { - - LinkedHashMap columnAndValues = convertColumnWrappers2Map4Persist(headerColumnWrapper, row, currUserAgencyId, checkBoxOptionColumnIdxAndLabel); - - // 检验身份证号 - String idCard = columnAndValues.get("ID_CARD"); - if (StringUtils.isBlank(idCard)) { - throw new RenException(EpmetErrorCode.IDCARDNO_ERROR.getCode(), String.format("用户【%s】身份证号未填写或格式错误", columnAndValues.get("NAME"))); - } - - // 检查用户是否存在 - LambdaQueryWrapper idCardQuery = new LambdaQueryWrapper<>(); - idCardQuery.eq(IcResiUserEntity::getIdCard, idCard); - - IcResiUserEntity icResiUserBaseInfo = baseDao.selectOne(idCardQuery); - if (icResiUserBaseInfo == null) { - throw new RenException(EpmetErrorCode.RESI_NOT_FOUND.getCode(), String.format("身份证号为【%s】的居民信息未找到,请确认该居民信息存在", idCard)); - } - - String icResiId = icResiUserBaseInfo.getId(); - - // 验证党员信息是否存在 - if (CollectionUtils.isNotEmpty(baseDao.selectSubTableRecords(customerId, icResiId, targetTableName))) { - log.info("身份证号为【{}】的居民【{}】信息已存在,跳过导入", idCard, targetTableName); - continue; - } - - columnAndValues.put("IC_RESI_USER", icResiId); - - columnAndValues.put("CUSTOMER_ID", loginUserUtil.getCurrentCustomerId()); - columnAndValues.put("CREATED_BY", currentUserId); - columnAndValues.put("UPDATED_BY", currentUserId); - columnAndValues.put("ID", UUID.randomUUID().toString().replace("-", "")); - - columnAndValues = removeNeedlessColumns(columnAndValues); - - baseDao.add(targetTableName, columnAndValues); - } - } - - /** - * 去掉多余的列 - * @param originColumnAndValues - * @return - */ - private LinkedHashMap removeNeedlessColumns(LinkedHashMap originColumnAndValues) { - List needlessColumns = Arrays.asList("GRID_ID", "VILLAGE_ID", "BUILD_ID", "UNIT_ID", "HOME_ID", - "IS_BDHJ", "NAME", "MOBILE", "GENDER", "ID_CARD", - "BIRTHDAY", "CONTACTS", "CONTACTS_MOBILE"); - - LinkedHashMap newMap = new LinkedHashMap(); - - originColumnAndValues.entrySet().forEach(b -> { - if (!needlessColumns.contains(b.getKey())) { - newMap.put(b.getKey(), b.getValue()); - } - }); - - return newMap; - } - - /** - * 将当前行数据转化成LinkedHashMap,供后续插入 - * @param headerColumnWrapper 当前行的ColumnWrapper,每一个ColumnWrapper元素都是当前行中的一个列 - * @param row 当前行数据 - * @param currUserAgencyId 当前用户所属机构ID - * @param checkBoxOptionColumnIdxAndLabel 复选框options列表。key:列号,value:复选框中文 - * @return - */ - private LinkedHashMap convertColumnWrappers2Map4Persist(Map headerColumnWrapper, Map row, - String currUserAgencyId, Map checkBoxOptionColumnIdxAndLabel) { - LinkedHashMap columnAndValues = new LinkedHashMap<>(); - - for (Map.Entry columnWrapperEntry : headerColumnWrapper.entrySet()) { - - ColumnWrapper columnWrapper = columnWrapperEntry.getValue(); - if ("input".equals(columnWrapper.getItemType()) - || "textarea".equals(columnWrapper.getItemType()) - || "datepicker".equals(columnWrapper.getItemType()) - || "daterange".equals(columnWrapper.getItemType()) - ) { - - String cellContent = row.get(columnWrapper.getColIndexs().get(0)); - columnWrapper.setCellContent(cellContent); - columnWrapper.setColValue(cellContent); - - } else if ("select".equals(columnWrapper.getItemType()) - || "radio".equals(columnWrapper.getItemType())){ - - String optionSourceType = columnWrapper.getOptionSourceType(); - // 取单元格的内容 - String cellContent = row.get(columnWrapper.getColIndexs().get(0)); - columnWrapper.setCellContent(cellContent); - - if ("local".equals(optionSourceType)) { - // 根据单元格内容,取到指定的option - Map options = columnWrapper.getOptions(); - String colValue = options.get(cellContent); - columnWrapper.setColValue(colValue); - } else { - // remote类型 - - Map options = listRemoteOptions(headerColumnWrapper, columnWrapper.getOptionSourceValue(), currUserAgencyId); - String colValue = options.get(cellContent); - columnWrapper.setColValue(colValue); - } - } else if ("checkbox".equals(columnWrapper.getItemType())) { - String checkBoxColValue = getCheckBoxColValue(columnWrapper, row, checkBoxOptionColumnIdxAndLabel); - columnWrapper.setColValue(checkBoxColValue); - } - columnAndValues.put(columnWrapper.columnName, columnWrapper.colValue); - } - - return columnAndValues; - } - - /** - * 根据formCode查询该form的item列表 - * @param formCode - * @return - */ - private List listFormItems(String formCode) { - CustomerFormQueryDTO form = new CustomerFormQueryDTO(); - form.setFormCode(formCode); - Result> result = operCustomizeOpenFeignClient.listItems(form); - return getResultDataOrThrowsException(result, ServiceConstant.OPER_CUSTOMIZE_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【居民信息excel导入】查询表单相关信息失败"); - } - - /** - * @description 合并头 - * - * @param headers - * @return - * @author wxz - * @date 2021.10.28 21:27:18 - */ - private HashMap> combineHeaders(Map> headers) { - HashMap> itemAndColIndexs = new LinkedHashMap<>(); - - headers.forEach((k, v) -> { - String tempKey = String.join(":", v); - List colIndexs = itemAndColIndexs.get(tempKey); - if (colIndexs == null) { - colIndexs = new ArrayList<>(); - itemAndColIndexs.put(tempKey, colIndexs); - } - colIndexs.add(k); - }); - - return itemAndColIndexs; - } - - /** - * @description 洗头 - * - * @param headers - * @param items - * @return - * @author wxz - * @date 2021.10.28 21:07:12 - */ - private Map washHeaders(Map> headers, List items) { - List itemLabels = items.stream().map(i -> i.getLabel()).collect(Collectors.toList()); - Map abandonedHeaders = new HashMap<>(); - for (Map.Entry> entry:headers.entrySet()) { - Integer colIdx = entry.getKey(); - List v = entry.getValue(); - int lastPartIndex = v.size() - 1; - String lastValuePart = v.get(lastPartIndex); - if (!itemLabels.contains(lastValuePart)) { - // 该部分为options,它的上一级是item,那么去掉options这一级 - v.remove(lastPartIndex); - abandonedHeaders.put(colIdx, lastValuePart); - } - } - - return abandonedHeaders; - } - - /** - * @description 数据整合,将excel表头汉字信息转化成ColumnWrapper列封装数据 - * * key:itemId - * * value:ColumnWrapper列包装信息 - * @param formItemMap item map - * key:itemId; - * value: 合并之后的head字符串,例如:健康信息:监护人 - * @param combinedHeaders 合并之后的head信息。 - * key:合并之后head字符串(例如:党员信息:入党时间); - * value:列号组成的列表(例如[1,2,3]) - * @param datas - * @param abandonedHeaders - * @return - */ - private Map convertExcelHeaders2DBColumnWrappers(Map formItemMap, Map> combinedHeaders, - List> datas, Map abandonedHeaders) { - -// HashMap> tables = new HashMap<>(); - Map columns = new LinkedHashMap<>(combinedHeaders.size()); - - for (Map.Entry> entry : combinedHeaders.entrySet()) { - String combinedHeader = entry.getKey(); - - FormItem item = formItemMap.get(combinedHeader); - - if (item == null) { - // 如果数据库中没有该项,可能是用户自己定义的项,忽略 - continue; - } - - ColumnWrapper columnWrapper = new ColumnWrapper(); - - // 填充options - columnWrapper.setItemType(item.getItemType()); - columnWrapper.setItemId(item.getItemId()); - String groupLabel = item.getGroupLabel(); - String combinedLabel = StringUtils.isBlank(groupLabel) ? item.getLabel() : groupLabel.concat(":").concat(item.getLabel()); - columnWrapper.setCombinedLabel(combinedLabel); - columnWrapper.setColumnName(item.getColumnName()); - columnWrapper.setColIndexs(entry.getValue()); - - columnWrapper.setOptionSourceType(item.getOptionSourceType()); - columnWrapper.setOptionSourceValue(item.getOptionSourceValue()); - columnWrapper.setOptions(item.getOptions().stream().collect(Collectors.toMap(OptionDTO::getLabel, OptionDTO::getValue))); - - columns.put(item.getItemId(), columnWrapper); - } - return columns; - } - - /** - * 获取checkbox列值 - * @param columnWrapper 数据库列包装信息,每一列跳数据对应数据库的一个列 - * @param dataRow 数据行,每一条都是一行中的一个单元格 - * @param checkboxOptions 复选框的选项。k: 列号, value: checkboxlabel中文 - * @return - */ - private String getCheckBoxColValue(ColumnWrapper columnWrapper, Map dataRow, Map checkboxOptions) { - - Map options = columnWrapper.getOptions(); - List colIndexs = columnWrapper.getColIndexs(); - - List optionValues = colIndexs.stream().filter(i -> { - String cellContent = dataRow.get(i); - return StringUtils.isNotBlank(cellContent) && cellContent.equals("是"); - }).map(i -> { - String checkboxOptionLabel = checkboxOptions.get(i); - return options.get(checkboxOptionLabel); - }).collect(Collectors.toList()); - - return String.join(",", optionValues); - } - - /** - * 远程获取options - * @param fullUri - * @return - */ - private Map listRemoteOptions(Map columnWrappers, String fullUri, String currUserAgencyId) { - String pureUri = null; - String cascadeItemId = null; - ColumnWrapper cascadeItemColumnWrapper = null; - - if (fullUri.indexOf("?") != -1) { - String[] uriParts = fullUri.split("\\?"); - pureUri = uriParts[0]; - cascadeItemId = uriParts[1]; - - // 根据uri上的id,找到关联的itemid,从而找到关联的item的值 - if (columnWrappers != null){ - cascadeItemColumnWrapper = columnWrappers.get(cascadeItemId); - } - } else { - pureUri = fullUri; - } - - List options = null; - - switch (pureUri) { - case "/epmetuser/icresidemanddict/demandoption": - options = getResultDataOrThrowsException(epmetUserOpenFeignClient.getDemandOptions(), ServiceConstant.EPMET_USER_SERVER, - EpmetErrorCode.SERVER_ERROR.getCode(), null); - break; - case "/gov/org/customergrid/gridoption": - AgencyIdFormDTO form = new AgencyIdFormDTO(); - form.setAgencyId(currUserAgencyId); - options = getResultDataOrThrowsException(govOrgOpenFeignClient.getGridOption(form), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), 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); - 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); - 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); - 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); - 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); - break; - case "/sys/dict/data/education": - options = getResultDataOrThrowsException(adminOpenFeignClient.getEducationOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); - break; - case "/sys/dict/data/house": - options = getResultDataOrThrowsException(adminOpenFeignClient.getHouseOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); - break; - case "/sys/dict/data/nation": - options = getResultDataOrThrowsException(adminOpenFeignClient.getNationOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); - break; - case "/sys/dict/data/ninesmallplaces": - options = getResultDataOrThrowsException(adminOpenFeignClient.getNineSmallPlacesOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); - break; - case "/sys/dict/data/relationship": - options = getResultDataOrThrowsException(adminOpenFeignClient.getRelationshipOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); - break; - - } - - if (options == null) { - return null; - } - - return options.stream().collect(Collectors.toMap(OptionResultDTO::getLabel, OptionResultDTO::getValue)); - - // 通用api调用,无法实现 - /*if (!uri.startsWith("/api")) uri = "/api".concat(uri); - - NamingService namingService = discoveryProperties.namingServiceInstance(); - ResponseEntity>> response = null; - try { - // 调用gateway服务,查询相关接口 - Instance gatewayInstance = namingService.getAllInstances(ServiceConstant.EPMET_GATEWAY).get(0); - String ip = gatewayInstance.getIp(); - int port = gatewayInstance.getPort(); - - String url = String.format("http://%s:%s%s", ip, port, uri); - - ParameterizedTypeReference>> tr = new ParameterizedTypeReference>>() {}; - response = new RestTemplate().exchange(url, HttpMethod.POST, null, tr); - } catch (NacosException e) { - e.printStackTrace(); - } - - if (response != null && (response.getStatusCode() == HttpStatus.OK)) { - List options = response.getBody().getData(); - if (options == null) { - System.out.println(6); - } - return options.stream().collect(Collectors.toMap(OptionResultDTO::getLabel, OptionResultDTO::getValue)); - } else { - throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); - }*/ - - } - - /** - * @description 合并表头 - * Map> - * - * @param headList - * @return - * @author wxz - * @date 2021.10.27 16:17:34 - */ - private Map> mergeHead(List> headList) { - - Map lastNotNullHeads = new LinkedHashMap<>(); - - Map> mergedHead = new LinkedHashMap<>(); - - int levelCount = headList.size(); - - Map firstLevel = headList.get(0); - - // 遍历所有列 - for (Map.Entry column : firstLevel.entrySet()) { - Integer columIndex = column.getKey(); - - List labels = new ArrayList<>(); - - // 竖着遍历该列的所有行 - for (int currentLevel = 0; currentLevel < levelCount; currentLevel ++) { - String label = headList.get(currentLevel).get(columIndex); - - if (StringUtils.isNotBlank(label)) { - lastNotNullHeads.put(currentLevel, label); - } else { - if (currentLevel == 0 || StringUtils.isBlank(headList.get(currentLevel - 1).get(columIndex))) { - label = lastNotNullHeads.get(currentLevel); - } - } - - if (StringUtils.isNotBlank(label)) { - labels.add(label); - } - } - - mergedHead.put(columIndex, labels); - } - - return mergedHead; - } - - /** - * @description 列信息封装 - * - * @return - * @author wxz - * @date 2021.10.28 22:18:05 - */ - @Data - public static class ColumnWrapper { - private String combinedLabel; - private String columnName; - private String itemType; - private String itemId; - private List colIndexs; - //private List colContents; - // 单元格内容 - private String cellContent; - // 数据库中列的值 - private String colValue; - - // key:label,value:value - private Map options; - - /** - * 选项来源,REMOTE;LOCAL;如果是动态加载的下拉框或者CHECKBOX等的情况下使用。URL:接口获取(LABEL,VALUE);JSON:直接从JSON中取 - */ - private String optionSourceType; - - /** - * 来源地址,REMOTE才有,固定格式;如果OPTIONS_SOURCE是URL,则此处填写要调用的接口的URL相对路径,例如:/API/GOV/ORG/XXXX。此处不应设置参数,若需要参数应当完全由后端,通过TOKEN信息来获取 - */ - private String optionSourceValue; - } - /** * desc:动态查询 某表的所有字段值 * @param customerId @@ -1185,7 +541,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl stringMap = listRemoteOptions(new HashMap<>(), v.getOptionSourceValue(), null); + Map stringMap = icResiUserImportService.listRemoteOptions(new HashMap<>(), v.getOptionSourceValue(), null); if ("checkbox".equals(v.getItemType())) { stringMap.forEach((label, value) -> map.put(value, temp.toString().contains(value) ? "是" : "否")); } else if ("select".equals(v.getItemType())) { From 84cc673e3f6c6a342025e895519316d7d1fbcfb6 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Fri, 5 Nov 2021 09:21:12 +0800 Subject: [PATCH 3/6] =?UTF-8?q?mq=E4=BA=8B=E4=BB=B6DTO=E5=90=8D=E5=AD=97?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...tatsMQMsg.java => IcResiUserAddMQMsg.java} | 2 +- .../mq/listener/ICWarnStatsEventListener.java | 4 +-- .../service/impl/IcResiUserServiceImpl.java | 25 ++++++------------- 3 files changed, 11 insertions(+), 20 deletions(-) rename epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/{IcWarnStatsMQMsg.java => IcResiUserAddMQMsg.java} (81%) diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/IcWarnStatsMQMsg.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/IcResiUserAddMQMsg.java similarity index 81% rename from epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/IcWarnStatsMQMsg.java rename to epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/IcResiUserAddMQMsg.java index b78863ef4c..328e7419cf 100644 --- a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/IcWarnStatsMQMsg.java +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/IcResiUserAddMQMsg.java @@ -9,7 +9,7 @@ import java.io.Serializable; * @author sun */ @Data -public class IcWarnStatsMQMsg implements Serializable { +public class IcResiUserAddMQMsg implements Serializable { //客户Id private String customerId; diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/mq/listener/ICWarnStatsEventListener.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/mq/listener/ICWarnStatsEventListener.java index 3a16ec247e..905f804351 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/mq/listener/ICWarnStatsEventListener.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/mq/listener/ICWarnStatsEventListener.java @@ -2,7 +2,7 @@ package com.epmet.mq.listener; import com.alibaba.fastjson.JSON; import com.epmet.commons.rocketmq.constants.MQUserPropertys; -import com.epmet.commons.rocketmq.messages.IcWarnStatsMQMsg; +import com.epmet.commons.rocketmq.messages.IcResiUserAddMQMsg; import com.epmet.commons.tools.distributedlock.DistributedLock; import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; @@ -57,7 +57,7 @@ public class ICWarnStatsEventListener implements MessageListenerConcurrently { String pendingMsgLabel = messageExt.getUserProperty(MQUserPropertys.BLOCKED_MSG_LABEL); logger.info("【开放数据事件监听器】-居民信息变动-收到消息内容:{},操作:{}", msg, tags); - IcWarnStatsMQMsg obj = JSON.parseObject(msg, IcWarnStatsMQMsg.class); + IcResiUserAddMQMsg obj = JSON.parseObject(msg, IcResiUserAddMQMsg.class); DistributedLock distributedLock = null; RLock lock = null; diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java index 0765780072..b353507792 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 @@ -17,44 +17,37 @@ package com.epmet.service.impl; -import com.alibaba.excel.EasyExcelFactory; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; -import com.epmet.commons.rocketmq.messages.IcWarnStatsMQMsg; +import com.epmet.commons.rocketmq.messages.IcResiUserAddMQMsg; import com.epmet.commons.tools.constant.FieldConstant; 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.dto.result.OptionResultDTO; import com.epmet.commons.tools.enums.GenderEnum; import com.epmet.commons.tools.enums.HouseTypeEnum; -import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; -import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.security.dto.TokenDto; -import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.SystemMessageType; import com.epmet.constant.UserConstant; import com.epmet.dao.IcResiUserDao; -import com.epmet.dto.*; +import com.epmet.dto.CustomerAgencyDTO; +import com.epmet.dto.CustomerGridDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; -import com.epmet.entity.IcPartyMemberEntity; import com.epmet.entity.IcResiUserEntity; -import com.epmet.excel.handler.DynamicEasyExcelListener; -import com.epmet.feign.*; -import com.epmet.service.IcResiUserImportService; +import com.epmet.feign.EpmetMessageOpenFeignClient; +import com.epmet.feign.GovOrgOpenFeignClient; +import com.epmet.feign.OperCustomizeOpenFeignClient; import com.epmet.service.IcResiUserService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; -import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -62,11 +55,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.io.File; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; -import java.util.stream.Stream; /** * 用户基础信息 @@ -168,7 +159,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl Date: Fri, 5 Nov 2021 09:23:28 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=B1=85=E6=B0=91=E7=B1=BB=E5=88=AB?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/IcResiCategoryStatsConfigDTO.java | 116 ++++++++ .../dto/IcResiCategoryWarnConfigDTO.java | 111 ++++++++ .../IcResiCategoryStatsConfigFormDTO.java | 80 ++++++ .../IcResiCategoryStatsConfigSortFormDTO.java | 51 ++++ .../IcResiCategoryStatsConfigResultDTO.java | 88 ++++++ .../IcResiCategoryStatsConfigConstant.java | 26 ++ .../IcResiCategoryStatsConfigController.java | 94 +++++++ .../IcResiCategoryWarnConfigController.java | 94 +++++++ .../ResiCategoryStatsConfigController.java | 107 +++++++ .../dao/IcResiCategoryStatsConfigDao.java | 33 +++ .../dao/IcResiCategoryWarnConfigDao.java | 33 +++ .../IcResiCategoryStatsConfigEntity.java | 83 ++++++ .../IcResiCategoryWarnConfigEntity.java | 81 ++++++ .../excel/IcResiCategoryStatsConfigExcel.java | 83 ++++++ .../excel/IcResiCategoryWarnConfigExcel.java | 80 ++++++ .../redis/IcResiCategoryStatsConfigRedis.java | 47 ++++ .../redis/IcResiCategoryWarnConfigRedis.java | 47 ++++ .../IcResiCategoryStatsConfigService.java | 95 +++++++ .../IcResiCategoryWarnConfigService.java | 95 +++++++ .../ResiCategoryStatsConfigService.java | 48 ++++ .../IcResiCategoryStatsConfigServiceImpl.java | 104 +++++++ .../IcResiCategoryWarnConfigServiceImpl.java | 104 +++++++ .../ResiCategoryStatsConfigServiceImpl.java | 264 ++++++++++++++++++ .../mapper/IcResiCategoryStatsConfigDao.xml | 26 ++ .../mapper/IcResiCategoryWarnConfigDao.xml | 25 ++ 25 files changed, 2015 insertions(+) create mode 100644 epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/IcResiCategoryStatsConfigDTO.java create mode 100644 epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/IcResiCategoryWarnConfigDTO.java create mode 100644 epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/IcResiCategoryStatsConfigFormDTO.java create mode 100644 epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/IcResiCategoryStatsConfigSortFormDTO.java create mode 100644 epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/IcResiCategoryStatsConfigResultDTO.java create mode 100644 epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/constant/IcResiCategoryStatsConfigConstant.java create mode 100644 epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcResiCategoryStatsConfigController.java create mode 100644 epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcResiCategoryWarnConfigController.java create mode 100644 epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/ResiCategoryStatsConfigController.java create mode 100644 epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcResiCategoryStatsConfigDao.java create mode 100644 epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcResiCategoryWarnConfigDao.java create mode 100644 epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/entity/IcResiCategoryStatsConfigEntity.java create mode 100644 epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/entity/IcResiCategoryWarnConfigEntity.java create mode 100644 epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/excel/IcResiCategoryStatsConfigExcel.java create mode 100644 epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/excel/IcResiCategoryWarnConfigExcel.java create mode 100644 epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/redis/IcResiCategoryStatsConfigRedis.java create mode 100644 epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/redis/IcResiCategoryWarnConfigRedis.java create mode 100644 epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/IcResiCategoryStatsConfigService.java create mode 100644 epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/IcResiCategoryWarnConfigService.java create mode 100644 epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/ResiCategoryStatsConfigService.java create mode 100644 epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcResiCategoryStatsConfigServiceImpl.java create mode 100644 epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcResiCategoryWarnConfigServiceImpl.java create mode 100644 epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/ResiCategoryStatsConfigServiceImpl.java create mode 100644 epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcResiCategoryStatsConfigDao.xml create mode 100644 epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcResiCategoryWarnConfigDao.xml diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/IcResiCategoryStatsConfigDTO.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/IcResiCategoryStatsConfigDTO.java new file mode 100644 index 0000000000..1eb4516551 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/IcResiCategoryStatsConfigDTO.java @@ -0,0 +1,116 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 居民类别配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-04 + */ +@Data +public class IcResiCategoryStatsConfigDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + private String id; + + /** + * 客户id + */ + private String customerId; + + /** + * 项标签 + */ + private String label; + + /** + * 表名 + */ + private String tableName; + + /** + * 列名 + */ + private String columnName; + + /** + * 管理平台分类图标 + */ + private String managementIcon; + + /** + * 数据平台分类图标 + */ + private String dataIcon; + + /** + * 房屋显示分类图标 + */ + private String houseShowIcon; + + /** + * 状态 显示:show;隐藏:hidden + */ + private String status; + + /** + * 排序 + */ + private Integer sort; + + /** + * 删除标识:0.未删除 1.已删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private String revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private String createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/IcResiCategoryWarnConfigDTO.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/IcResiCategoryWarnConfigDTO.java new file mode 100644 index 0000000000..b4a2609d5e --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/IcResiCategoryWarnConfigDTO.java @@ -0,0 +1,111 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 居民类别预警配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-04 + */ +@Data +public class IcResiCategoryWarnConfigDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + private String id; + + /** + * 客户id + */ + private String customerId; + + /** + * 项标签 + */ + private String label; + + /** + * 表名 + */ + private String tableName; + + /** + * 列名 + */ + private String columnName; + + /** + * 排序 + */ + private Integer sort; + + /** + * 等级1阈值 + */ + private Integer level1; + + /** + * 等级2阈值 + */ + private Integer level2; + + /** + * 等级3阈值 + */ + private Integer level3; + + /** + * 删除标识:0.未删除 1.已删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private String revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private String createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/IcResiCategoryStatsConfigFormDTO.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/IcResiCategoryStatsConfigFormDTO.java new file mode 100644 index 0000000000..cb9082c985 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/IcResiCategoryStatsConfigFormDTO.java @@ -0,0 +1,80 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.UpdateGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.Date; + + +/** + * 居民类别配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-04 + */ +@Data +public class IcResiCategoryStatsConfigFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + public interface UpdateStatusGroup {} + public interface SelectGroup {} + + /** + * id + */ + @NotBlank(message = "配置项id不能为空",groups = {UpdateGroup.class,UpdateStatusGroup.class,SelectGroup.class}) + private String id; + + /** + * 管理平台分类图标 + */ + @NotBlank(message = "管理平台分类图标不能为空",groups = {UpdateGroup.class}) + private String managementIcon; + + /** + * 数据平台分类图标 + */ + @NotBlank(message = "管理平台分类图标不能为空",groups = {UpdateGroup.class}) + private String dataIcon; + + /** + * 房屋显示分类图标 + */ + @NotBlank(message = "管理平台分类图标不能为空",groups = {UpdateGroup.class}) + private String houseShowIcon; + + /** + * 状态 显示:show;隐藏:hidden + */ + @NotBlank(message = "状态不能为空",groups = {UpdateStatusGroup.class}) + private String status; + + @NotBlank(message = "是否预警",groups = {UpdateGroup.class}) + private String warn; + + private Integer level1; + + private Integer level2; + + private Integer level3; + +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/IcResiCategoryStatsConfigSortFormDTO.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/IcResiCategoryStatsConfigSortFormDTO.java new file mode 100644 index 0000000000..b5e7347e4c --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/IcResiCategoryStatsConfigSortFormDTO.java @@ -0,0 +1,51 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.form; + +import 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 IcResiCategoryStatsConfigSortFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + @NotBlank(message = "配置项id不能为空") + private String id; + + /** + * 排序 + */ + @NotBlank(message = "排序不能为空") + private Integer sort; + + +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/IcResiCategoryStatsConfigResultDTO.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/IcResiCategoryStatsConfigResultDTO.java new file mode 100644 index 0000000000..d9199b99cc --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/IcResiCategoryStatsConfigResultDTO.java @@ -0,0 +1,88 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 居民类别配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-04 + */ +@Data +public class IcResiCategoryStatsConfigResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + private String id; + + + /** + * 项标签 + */ + private String label; + + + + /** + * 管理平台分类图标 + */ + private String managementIcon; + + /** + * 数据平台分类图标 + */ + private String dataIcon; + + /** + * 房屋显示分类图标 + */ + private String houseShowIcon; + + /** + * 状态 显示:show;隐藏:hidden + */ + private String status; + + /** + * 排序 + */ + private Integer sort; + + private String warn; + /** + * 等级1阈值 + */ + private Integer level1; + /** + * 等级2阈值 + */ + private Integer level2; + /** + * 等级3阈值 + */ + private Integer level3; +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/constant/IcResiCategoryStatsConfigConstant.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/constant/IcResiCategoryStatsConfigConstant.java new file mode 100644 index 0000000000..9919ca35f6 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/constant/IcResiCategoryStatsConfigConstant.java @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + *

+ * https://www.renren.io + *

+ * 版权所有,侵权必究! + */ + +package com.epmet.constant; + +/** + * 常量 + * @author sun + * @since 1.0.0 + */ +public interface IcResiCategoryStatsConfigConstant { + /** + * 是否需要预警 + */ + String WARN_YES = "1"; + String WARN_NO = "0"; + + String IC_RESI_USER = "ic_resi_user"; + + +} diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcResiCategoryStatsConfigController.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcResiCategoryStatsConfigController.java new file mode 100644 index 0000000000..f088a65265 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcResiCategoryStatsConfigController.java @@ -0,0 +1,94 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.page.PageData; +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.UpdateGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.dto.IcResiCategoryStatsConfigDTO; +import com.epmet.excel.IcResiCategoryStatsConfigExcel; +import com.epmet.service.IcResiCategoryStatsConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * 居民类别配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-04 + */ +@RestController +@RequestMapping("icresicategorystatsconfig") +public class IcResiCategoryStatsConfigController { + + @Autowired + private IcResiCategoryStatsConfigService icResiCategoryStatsConfigService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = icResiCategoryStatsConfigService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + IcResiCategoryStatsConfigDTO data = icResiCategoryStatsConfigService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody IcResiCategoryStatsConfigDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + icResiCategoryStatsConfigService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody IcResiCategoryStatsConfigDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + icResiCategoryStatsConfigService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + icResiCategoryStatsConfigService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = icResiCategoryStatsConfigService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, IcResiCategoryStatsConfigExcel.class); + } + +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcResiCategoryWarnConfigController.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcResiCategoryWarnConfigController.java new file mode 100644 index 0000000000..5e1ac6667b --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcResiCategoryWarnConfigController.java @@ -0,0 +1,94 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.page.PageData; +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.UpdateGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.dto.IcResiCategoryWarnConfigDTO; +import com.epmet.excel.IcResiCategoryWarnConfigExcel; +import com.epmet.service.IcResiCategoryWarnConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * 居民类别预警配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-04 + */ +@RestController +@RequestMapping("icresicategorywarnconfig") +public class IcResiCategoryWarnConfigController { + + @Autowired + private IcResiCategoryWarnConfigService icResiCategoryWarnConfigService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = icResiCategoryWarnConfigService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + IcResiCategoryWarnConfigDTO data = icResiCategoryWarnConfigService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody IcResiCategoryWarnConfigDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + icResiCategoryWarnConfigService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody IcResiCategoryWarnConfigDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + icResiCategoryWarnConfigService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + icResiCategoryWarnConfigService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = icResiCategoryWarnConfigService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, IcResiCategoryWarnConfigExcel.class); + } + +} \ 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 new file mode 100644 index 0000000000..be1a538f1b --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/ResiCategoryStatsConfigController.java @@ -0,0 +1,107 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; +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.dto.IcResiCategoryStatsConfigDTO; +import com.epmet.dto.form.IcResiCategoryStatsConfigFormDTO; +import com.epmet.dto.form.IcResiCategoryStatsConfigSortFormDTO; +import com.epmet.dto.form.UpGovRoleFormDTO; +import com.epmet.dto.result.IcResiCategoryStatsConfigResultDTO; +import com.epmet.excel.IcResiCategoryStatsConfigExcel; +import com.epmet.service.IcResiCategoryStatsConfigService; +import com.epmet.service.ResiCategoryStatsConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * 居民类别配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-04 + */ +@RestController +@RequestMapping("resicategorystatsconfig") +public class ResiCategoryStatsConfigController { + + @Autowired + private IcResiCategoryStatsConfigService icResiCategoryStatsConfigService; + @Autowired + private ResiCategoryStatsConfigService resiCategoryStatsConfigService; + + + /** + * 居民类别配置列表 + * @return + */ + @PostMapping("list") + public Result> list(@LoginUser TokenDto tokenDTO){ + String customerId = tokenDTO.getCustomerId(); +// String customerId = "123123"; + return new Result>().ok(resiCategoryStatsConfigService.list(customerId)); + } + + @PostMapping("update") + public Result update(@LoginUser TokenDto tokenDTO,@RequestBody IcResiCategoryStatsConfigFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO, UpdateGroup.class); + String customerId = tokenDTO.getCustomerId(); +// String customerId = "123123"; + resiCategoryStatsConfigService.update(customerId,formDTO); + return new Result(); + } + @PostMapping("updatestatus") + public Result updateStatus(@LoginUser TokenDto tokenDTO,@RequestBody IcResiCategoryStatsConfigFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO, IcResiCategoryStatsConfigFormDTO.UpdateStatusGroup.class); + String customerId = tokenDTO.getCustomerId(); +// String customerId = "123123"; + resiCategoryStatsConfigService.updateStatus(customerId,formDTO); + return new Result(); + } + @PostMapping("updatesort") + public Result updateSort(@LoginUser TokenDto tokenDTO,@RequestBody List formDTOs){ + for(IcResiCategoryStatsConfigSortFormDTO dto : formDTOs){ + ValidatorUtils.validateEntity(dto); + } + String customerId = tokenDTO.getCustomerId(); +// String customerId = "123123"; + resiCategoryStatsConfigService.updateSort(customerId,formDTOs); + return new Result(); + } + + @PostMapping("info") + public Result info(@LoginUser TokenDto tokenDTO,@RequestBody IcResiCategoryStatsConfigFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO, IcResiCategoryStatsConfigFormDTO.SelectGroup.class); + return new Result().ok(resiCategoryStatsConfigService.info(formDTO.getId())); + } + + +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcResiCategoryStatsConfigDao.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcResiCategoryStatsConfigDao.java new file mode 100644 index 0000000000..bb55c52594 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcResiCategoryStatsConfigDao.java @@ -0,0 +1,33 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.IcResiCategoryStatsConfigEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 居民类别配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-04 + */ +@Mapper +public interface IcResiCategoryStatsConfigDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcResiCategoryWarnConfigDao.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcResiCategoryWarnConfigDao.java new file mode 100644 index 0000000000..d9a9e0a2b0 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcResiCategoryWarnConfigDao.java @@ -0,0 +1,33 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.IcResiCategoryWarnConfigEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 居民类别预警配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-04 + */ +@Mapper +public interface IcResiCategoryWarnConfigDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/entity/IcResiCategoryStatsConfigEntity.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/entity/IcResiCategoryStatsConfigEntity.java new file mode 100644 index 0000000000..d0201db93d --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/entity/IcResiCategoryStatsConfigEntity.java @@ -0,0 +1,83 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 居民类别配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-04 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("ic_resi_category_stats_config") +public class IcResiCategoryStatsConfigEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + private String customerId; + + /** + * 项标签 + */ + private String label; + + /** + * 表名 + */ + private String tableName; + + /** + * 列名 + */ + private String columnName; + + /** + * 管理平台分类图标 + */ + private String managementIcon; + + /** + * 数据平台分类图标 + */ + private String dataIcon; + + /** + * 房屋显示分类图标 + */ + private String houseShowIcon; + + /** + * 状态 显示:show;隐藏:hidden + */ + private String status; + + /** + * 排序 + */ + private Integer sort; + +} diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/entity/IcResiCategoryWarnConfigEntity.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/entity/IcResiCategoryWarnConfigEntity.java new file mode 100644 index 0000000000..a15c0c7958 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/entity/IcResiCategoryWarnConfigEntity.java @@ -0,0 +1,81 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 居民类别预警配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-04 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("ic_resi_category_warn_config") +public class IcResiCategoryWarnConfigEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + private String customerId; + + /** + * 项标签 + */ + private String label; + + /** + * 表名 + */ + private String tableName; + + /** + * 列名 + */ + private String columnName; + + /** + * 排序 + */ + private Integer sort; + + /** + * 等级1阈值 + */ + private Integer level1; + + /** + * 等级2阈值 + */ + private Integer level2; + + /** + * 等级3阈值 + */ + private Integer level3; + +} diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/excel/IcResiCategoryStatsConfigExcel.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/excel/IcResiCategoryStatsConfigExcel.java new file mode 100644 index 0000000000..1e8f335885 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/excel/IcResiCategoryStatsConfigExcel.java @@ -0,0 +1,83 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * 居民类别配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-04 + */ +@Data +public class IcResiCategoryStatsConfigExcel { + + @Excel(name = "id") + private String id; + + @Excel(name = "客户id") + private String customerId; + + @Excel(name = "项标签") + private String label; + + @Excel(name = "表名") + private String tableName; + + @Excel(name = "列名") + private String columnName; + + @Excel(name = "管理平台分类图标") + private String managementIcon; + + @Excel(name = "数据平台分类图标") + private String dataIcon; + + @Excel(name = "房屋显示分类图标") + private String houseShowIcon; + + @Excel(name = "状态 显示:show;隐藏:hidden") + private String status; + + @Excel(name = "排序") + private Integer sort; + + @Excel(name = "删除标识:0.未删除 1.已删除") + private String delFlag; + + @Excel(name = "乐观锁") + private String revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private String createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/excel/IcResiCategoryWarnConfigExcel.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/excel/IcResiCategoryWarnConfigExcel.java new file mode 100644 index 0000000000..d9d5edf543 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/excel/IcResiCategoryWarnConfigExcel.java @@ -0,0 +1,80 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * 居民类别预警配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-04 + */ +@Data +public class IcResiCategoryWarnConfigExcel { + + @Excel(name = "id") + private String id; + + @Excel(name = "客户id") + private String customerId; + + @Excel(name = "项标签") + private String label; + + @Excel(name = "表名") + private String tableName; + + @Excel(name = "列名") + private String columnName; + + @Excel(name = "排序") + private Integer sort; + + @Excel(name = "等级1阈值") + private Integer level1; + + @Excel(name = "等级2阈值") + private Integer level2; + + @Excel(name = "等级3阈值") + private Integer level3; + + @Excel(name = "删除标识:0.未删除 1.已删除") + private String delFlag; + + @Excel(name = "乐观锁") + private String revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private String createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/redis/IcResiCategoryStatsConfigRedis.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/redis/IcResiCategoryStatsConfigRedis.java new file mode 100644 index 0000000000..789965c0c9 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/redis/IcResiCategoryStatsConfigRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 居民类别配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-04 + */ +@Component +public class IcResiCategoryStatsConfigRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/redis/IcResiCategoryWarnConfigRedis.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/redis/IcResiCategoryWarnConfigRedis.java new file mode 100644 index 0000000000..eee6ae7fc6 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/redis/IcResiCategoryWarnConfigRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 居民类别预警配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-04 + */ +@Component +public class IcResiCategoryWarnConfigRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/IcResiCategoryStatsConfigService.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/IcResiCategoryStatsConfigService.java new file mode 100644 index 0000000000..b7c5938162 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/IcResiCategoryStatsConfigService.java @@ -0,0 +1,95 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.IcResiCategoryStatsConfigDTO; +import com.epmet.entity.IcResiCategoryStatsConfigEntity; + +import java.util.List; +import java.util.Map; + +/** + * 居民类别配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-04 + */ +public interface IcResiCategoryStatsConfigService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2021-11-04 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2021-11-04 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return IcResiCategoryStatsConfigDTO + * @author generator + * @date 2021-11-04 + */ + IcResiCategoryStatsConfigDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2021-11-04 + */ + void save(IcResiCategoryStatsConfigDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2021-11-04 + */ + void update(IcResiCategoryStatsConfigDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2021-11-04 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/IcResiCategoryWarnConfigService.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/IcResiCategoryWarnConfigService.java new file mode 100644 index 0000000000..bef9c7360f --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/IcResiCategoryWarnConfigService.java @@ -0,0 +1,95 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.IcResiCategoryWarnConfigDTO; +import com.epmet.entity.IcResiCategoryWarnConfigEntity; + +import java.util.List; +import java.util.Map; + +/** + * 居民类别预警配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-04 + */ +public interface IcResiCategoryWarnConfigService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2021-11-04 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2021-11-04 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return IcResiCategoryWarnConfigDTO + * @author generator + * @date 2021-11-04 + */ + IcResiCategoryWarnConfigDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2021-11-04 + */ + void save(IcResiCategoryWarnConfigDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2021-11-04 + */ + void update(IcResiCategoryWarnConfigDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2021-11-04 + */ + void delete(String[] ids); +} \ 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 new file mode 100644 index 0000000000..9f351d91b4 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/ResiCategoryStatsConfigService.java @@ -0,0 +1,48 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +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.result.IcResiCategoryStatsConfigResultDTO; +import com.epmet.entity.IcResiCategoryStatsConfigEntity; + +import java.util.List; +import java.util.Map; + +/** + * 居民类别配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-04 + */ +public interface ResiCategoryStatsConfigService { + + List list(String customerId); + + IcResiCategoryStatsConfigResultDTO info(String id); + + void update(String customerId,IcResiCategoryStatsConfigFormDTO formDTO); + + void updateStatus(String customerId,IcResiCategoryStatsConfigFormDTO formDTO); + + void updateSort(String customerId,List formDTOs); +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcResiCategoryStatsConfigServiceImpl.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcResiCategoryStatsConfigServiceImpl.java new file mode 100644 index 0000000000..368ecec876 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcResiCategoryStatsConfigServiceImpl.java @@ -0,0 +1,104 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.dao.IcResiCategoryStatsConfigDao; +import com.epmet.dto.IcResiCategoryStatsConfigDTO; +import com.epmet.entity.IcResiCategoryStatsConfigEntity; +import com.epmet.redis.IcResiCategoryStatsConfigRedis; +import com.epmet.service.IcResiCategoryStatsConfigService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 居民类别配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-04 + */ +@Service +public class IcResiCategoryStatsConfigServiceImpl extends BaseServiceImpl implements IcResiCategoryStatsConfigService { + + @Autowired + private IcResiCategoryStatsConfigRedis icResiCategoryStatsConfigRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, IcResiCategoryStatsConfigDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, IcResiCategoryStatsConfigDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public IcResiCategoryStatsConfigDTO get(String id) { + IcResiCategoryStatsConfigEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, IcResiCategoryStatsConfigDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(IcResiCategoryStatsConfigDTO dto) { + IcResiCategoryStatsConfigEntity entity = ConvertUtils.sourceToTarget(dto, IcResiCategoryStatsConfigEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(IcResiCategoryStatsConfigDTO dto) { + IcResiCategoryStatsConfigEntity entity = ConvertUtils.sourceToTarget(dto, IcResiCategoryStatsConfigEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcResiCategoryWarnConfigServiceImpl.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcResiCategoryWarnConfigServiceImpl.java new file mode 100644 index 0000000000..3235b04f0d --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcResiCategoryWarnConfigServiceImpl.java @@ -0,0 +1,104 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.dao.IcResiCategoryWarnConfigDao; +import com.epmet.dto.IcResiCategoryWarnConfigDTO; +import com.epmet.entity.IcResiCategoryWarnConfigEntity; +import com.epmet.redis.IcResiCategoryWarnConfigRedis; +import com.epmet.service.IcResiCategoryWarnConfigService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 居民类别预警配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-04 + */ +@Service +public class IcResiCategoryWarnConfigServiceImpl extends BaseServiceImpl implements IcResiCategoryWarnConfigService { + + @Autowired + private IcResiCategoryWarnConfigRedis icResiCategoryWarnConfigRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, IcResiCategoryWarnConfigDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, IcResiCategoryWarnConfigDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public IcResiCategoryWarnConfigDTO get(String id) { + IcResiCategoryWarnConfigEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, IcResiCategoryWarnConfigDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(IcResiCategoryWarnConfigDTO dto) { + IcResiCategoryWarnConfigEntity entity = ConvertUtils.sourceToTarget(dto, IcResiCategoryWarnConfigEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(IcResiCategoryWarnConfigDTO dto) { + IcResiCategoryWarnConfigEntity entity = ConvertUtils.sourceToTarget(dto, IcResiCategoryWarnConfigEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} \ No newline at end of file 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 new file mode 100644 index 0000000000..c5003a5d78 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/ResiCategoryStatsConfigServiceImpl.java @@ -0,0 +1,264 @@ +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.epmet.constant.IcResiCategoryStatsConfigConstant; +import com.epmet.dao.IcFormItemDao; +import com.epmet.dao.IcFormItemGroupDao; +import com.epmet.dao.IcResiCategoryStatsConfigDao; +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.result.IcResiCategoryStatsConfigResultDTO; +import com.epmet.entity.IcFormItemEntity; +import com.epmet.entity.IcFormItemGroupEntity; +import com.epmet.entity.IcResiCategoryStatsConfigEntity; +import com.epmet.entity.IcResiCategoryWarnConfigEntity; +import com.epmet.service.IcResiCategoryStatsConfigService; +import com.epmet.service.IcResiCategoryWarnConfigService; +import com.epmet.service.ResiCategoryStatsConfigService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.*; +import java.util.stream.Collectors; + +@Slf4j +@Service +public class ResiCategoryStatsConfigServiceImpl implements ResiCategoryStatsConfigService { + @Autowired + private IcResiCategoryStatsConfigService icResiCategoryStatsConfigService; + + @Resource + private IcFormItemDao icFormItemDao; + @Resource + private IcFormItemGroupDao icFormItemGroupDao; + @Resource + private IcResiCategoryStatsConfigDao icResiCategoryStatsConfigDao; + @Resource + private IcResiCategoryWarnConfigDao icResiCategoryWarnConfigDao; + @Autowired + private IcResiCategoryWarnConfigService icResiCategoryWarnConfigService; + + @Override + @Transactional(rollbackFor = Exception.class) + public List list(String customerId) { + //1.获取IC_FORM_ITEM 中 用于数据分析字段的 id 和label + List icFormItemEntityList = icFormItemDao.selectList(new QueryWrapper().lambda().eq(IcFormItemEntity::getDataAnalyse, 1)); + if(CollectionUtils.isEmpty(icFormItemEntityList)){ + return new ArrayList<>(); + } + Set groupIds = icFormItemEntityList.stream().filter(item-> !"0".equals(item.getItemGroupId())).map(item->item.getItemGroupId()).collect(Collectors.toSet()); + List icFormItemGroupEntityList = icFormItemGroupDao.selectList(new QueryWrapper().lambda().in(IcFormItemGroupEntity::getId, groupIds)); + //获取tableName和COLUMN_NAME + Map tableColumnMap = new HashMap<>(); + Map idTableMap = new HashMap<>(); + icFormItemEntityList.forEach(item->{ + Map map = new HashMap<>(); + if("0".equals(item.getItemGroupId())){ + tableColumnMap.put(IcResiCategoryStatsConfigConstant.IC_RESI_USER+"-"+item.getColumnName(),item); + idTableMap.put(item.getId(),IcResiCategoryStatsConfigConstant.IC_RESI_USER); + }else{ + List collect = icFormItemGroupEntityList.stream().filter(i -> item.getItemGroupId().equals(i.getId())).collect(Collectors.toList()); + tableColumnMap.put(CollectionUtils.isEmpty(collect)?IcResiCategoryStatsConfigConstant.IC_RESI_USER:collect.get(0).getTableName()+"-"+item.getColumnName(),item); + idTableMap.put(item.getId(),CollectionUtils.isEmpty(collect)?IcResiCategoryStatsConfigConstant.IC_RESI_USER:collect.get(0).getTableName()); + } + + }); + + //2.获取ic_resi_category_stats_config 和 ic_resi_category_warn_config 表中的数据 + List statsConfigEntityList = icResiCategoryStatsConfigDao.selectList(null); + List warnConfigEntityList = icResiCategoryWarnConfigDao.selectList(null); + //3.新增不存在的,删除不在tableColumnMap的 + + Map statsTableColumnMap = new HashMap<>(); + statsConfigEntityList.stream().forEach(item->{ + statsTableColumnMap.put(item.getTableName()+"-"+item.getColumnName(),item); + }); + Map warnTableColumnMap = new HashMap<>(); + warnConfigEntityList.stream().forEach(item->{ + warnTableColumnMap.put(item.getTableName()+"-"+item.getColumnName(),item); + }); + //差集 + //新增 + List newStatsList = tableColumnMap.keySet().stream().filter(item -> !statsTableColumnMap.keySet().contains(item)).collect(Collectors.toList()); + + List newStatsEntityList = new ArrayList<>(); + newStatsList.forEach(item->{ + IcFormItemEntity icFormItemEntity = tableColumnMap.get(item); + IcResiCategoryStatsConfigEntity entity = new IcResiCategoryStatsConfigEntity(); + entity.setCustomerId(customerId); + entity.setLabel(icFormItemEntity.getLabel()); + entity.setTableName(idTableMap.get(icFormItemEntity.getId())); + entity.setColumnName(icFormItemEntity.getColumnName()); + entity.setManagementIcon(""); + entity.setDataIcon(""); + entity.setHouseShowIcon(""); + entity.setStatus("show"); + entity.setSort(0); + newStatsEntityList.add(entity); + }); + if(!CollectionUtils.isEmpty(newStatsEntityList)){ + icResiCategoryStatsConfigService.insertBatch(newStatsEntityList); + } + + List delStatsEntityIdList = new ArrayList<>(); + List delWarnEntityIdList = new ArrayList<>(); + //需要删除的 + List delStatsList = statsTableColumnMap.keySet().stream().filter(item -> !tableColumnMap.keySet().contains(item)).collect(Collectors.toList()); + List delWarnList = warnTableColumnMap.keySet().stream().filter(item -> !tableColumnMap.keySet().contains(item)).collect(Collectors.toList()); + delStatsList.forEach(item->{ + delStatsEntityIdList.add(statsTableColumnMap.get(item).getId()); + }); + delWarnList.forEach(item->{ + delWarnEntityIdList.add(warnTableColumnMap.get(item).getId()); + }); + if(!CollectionUtils.isEmpty(delStatsEntityIdList)){ + icResiCategoryStatsConfigService.deleteBatchIds(delStatsEntityIdList); + } + if(!CollectionUtils.isEmpty(delWarnEntityIdList)){ + icResiCategoryWarnConfigService.deleteBatchIds(delWarnEntityIdList); + } + + //4.返回数据 + List statsConfigList = icResiCategoryStatsConfigDao.selectList(new QueryWrapper().lambda().orderByAsc(IcResiCategoryStatsConfigEntity::getSort)); + List warnConfigList = icResiCategoryWarnConfigDao.selectList(null); + Map warnMap =new HashMap<>(); + warnConfigList.forEach(item->{ + warnMap.put(item.getTableName()+"-"+item.getColumnName(),item); + }); + List result = new ArrayList<>(); + statsConfigList.forEach(item->{ + IcResiCategoryStatsConfigResultDTO icResiCategoryStatsConfigResultDTO = new IcResiCategoryStatsConfigResultDTO(); + icResiCategoryStatsConfigResultDTO.setId(item.getId()); + icResiCategoryStatsConfigResultDTO.setLabel(item.getLabel()); + icResiCategoryStatsConfigResultDTO.setManagementIcon(item.getManagementIcon()); + icResiCategoryStatsConfigResultDTO.setDataIcon(item.getDataIcon()); + icResiCategoryStatsConfigResultDTO.setHouseShowIcon(item.getHouseShowIcon()); + icResiCategoryStatsConfigResultDTO.setStatus(item.getStatus()); + icResiCategoryStatsConfigResultDTO.setSort(item.getSort()); + IcResiCategoryWarnConfigEntity warnConfigEntity = warnMap.get(item.getTableName() + "-" + item.getColumnName()); + if(warnConfigEntity==null){ + icResiCategoryStatsConfigResultDTO.setWarn(IcResiCategoryStatsConfigConstant.WARN_NO); + }else{ + icResiCategoryStatsConfigResultDTO.setWarn(IcResiCategoryStatsConfigConstant.WARN_YES); + icResiCategoryStatsConfigResultDTO.setLevel1(warnConfigEntity.getLevel1()); + icResiCategoryStatsConfigResultDTO.setLevel2(warnConfigEntity.getLevel2()); + icResiCategoryStatsConfigResultDTO.setLevel3(warnConfigEntity.getLevel3()); + } + result.add(icResiCategoryStatsConfigResultDTO); + + }); + return result; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public IcResiCategoryStatsConfigResultDTO info(String id) { + IcResiCategoryStatsConfigResultDTO result =new IcResiCategoryStatsConfigResultDTO(); + IcResiCategoryStatsConfigDTO icResiCategoryStatsConfigDTO = icResiCategoryStatsConfigService.get(id); + if(null == icResiCategoryStatsConfigDTO){ + return result; + } + IcResiCategoryWarnConfigEntity icResiCategoryWarnConfigEntity = icResiCategoryWarnConfigDao.selectOne(new QueryWrapper().lambda() + .eq(IcResiCategoryWarnConfigEntity::getTableName, icResiCategoryStatsConfigDTO.getTableName()) + .eq(IcResiCategoryWarnConfigEntity::getColumnName, icResiCategoryStatsConfigDTO.getColumnName())); + +// IcResiCategoryWarnConfigEntity icResiCategoryWarnConfigEntity = Optional.ofNullable(entity).orElse(new IcResiCategoryWarnConfigEntity()); + result.setId(icResiCategoryStatsConfigDTO.getId()); + result.setLabel(icResiCategoryStatsConfigDTO.getLabel()); + result.setManagementIcon(icResiCategoryStatsConfigDTO.getManagementIcon()); + result.setDataIcon(icResiCategoryStatsConfigDTO.getDataIcon()); + result.setHouseShowIcon(icResiCategoryStatsConfigDTO.getHouseShowIcon()); + result.setStatus(icResiCategoryStatsConfigDTO.getStatus()); + result.setSort(icResiCategoryStatsConfigDTO.getSort()); + result.setWarn(null==icResiCategoryWarnConfigEntity?IcResiCategoryStatsConfigConstant.WARN_NO:IcResiCategoryStatsConfigConstant.WARN_YES); + if(null!=icResiCategoryWarnConfigEntity){ + result.setLevel1(icResiCategoryWarnConfigEntity.getLevel1()); + result.setLevel2(icResiCategoryWarnConfigEntity.getLevel2()); + result.setLevel3(icResiCategoryWarnConfigEntity.getLevel3()); + } + return result; + + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(String customerId,IcResiCategoryStatsConfigFormDTO formDTO) { + IcResiCategoryStatsConfigDTO icResiCategoryStatsConfigDTO = icResiCategoryStatsConfigService.get(formDTO.getId()); + if(null == icResiCategoryStatsConfigDTO){ + return ; + } + //更新配置类别 + IcResiCategoryStatsConfigEntity icResiCategoryStatsConfigEntity = new IcResiCategoryStatsConfigEntity(); + BeanUtils.copyProperties(formDTO,icResiCategoryStatsConfigEntity); + icResiCategoryStatsConfigEntity.setCustomerId(customerId); + icResiCategoryStatsConfigDao.updateById(icResiCategoryStatsConfigEntity); + + //更新配置预警 + if(IcResiCategoryStatsConfigConstant.WARN_YES.equals(formDTO.getWarn())){ + //更新 + IcResiCategoryWarnConfigEntity icResiCategoryWarnConfigEntity = icResiCategoryWarnConfigDao.selectOne(new QueryWrapper().lambda() + .eq(IcResiCategoryWarnConfigEntity::getTableName, icResiCategoryStatsConfigDTO.getTableName()) + .eq(IcResiCategoryWarnConfigEntity::getColumnName, icResiCategoryStatsConfigDTO.getColumnName())); + if(null == icResiCategoryWarnConfigEntity){ + icResiCategoryWarnConfigEntity = new IcResiCategoryWarnConfigEntity(); + icResiCategoryWarnConfigEntity.setCustomerId(customerId); + icResiCategoryWarnConfigEntity.setLabel(icResiCategoryStatsConfigDTO.getLabel()); + icResiCategoryWarnConfigEntity.setTableName(icResiCategoryStatsConfigDTO.getTableName()); + icResiCategoryWarnConfigEntity.setColumnName(icResiCategoryStatsConfigDTO.getColumnName()); + icResiCategoryWarnConfigEntity.setLevel1(formDTO.getLevel1()); + icResiCategoryWarnConfigEntity.setLevel2(formDTO.getLevel2()); + icResiCategoryWarnConfigEntity.setLevel3(formDTO.getLevel3()); + icResiCategoryWarnConfigEntity.setSort(icResiCategoryStatsConfigDTO.getSort()); + icResiCategoryWarnConfigDao.insert(icResiCategoryWarnConfigEntity); + }else{ + icResiCategoryWarnConfigEntity.setCustomerId(customerId); + icResiCategoryWarnConfigEntity.setLabel(icResiCategoryStatsConfigDTO.getLabel()); + icResiCategoryWarnConfigEntity.setTableName(icResiCategoryStatsConfigDTO.getTableName()); + icResiCategoryWarnConfigEntity.setColumnName(icResiCategoryStatsConfigDTO.getColumnName()); + icResiCategoryWarnConfigEntity.setLevel1(formDTO.getLevel1()); + icResiCategoryWarnConfigEntity.setLevel2(formDTO.getLevel2()); + icResiCategoryWarnConfigEntity.setLevel3(formDTO.getLevel3()); + icResiCategoryWarnConfigEntity.setSort(icResiCategoryStatsConfigDTO.getSort()); + icResiCategoryWarnConfigDao.updateById(icResiCategoryWarnConfigEntity); + } + }else if(IcResiCategoryStatsConfigConstant.WARN_NO.equals(formDTO.getWarn())){ + //删除 + icResiCategoryWarnConfigDao.delete(new QueryWrapper().lambda() + .eq(IcResiCategoryWarnConfigEntity::getTableName,icResiCategoryStatsConfigDTO.getTableName()) + .eq(IcResiCategoryWarnConfigEntity::getColumnName,icResiCategoryStatsConfigDTO.getColumnName())); + } + + + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void updateStatus(String customerId,IcResiCategoryStatsConfigFormDTO formDTO) { + //更新配置类别 + IcResiCategoryStatsConfigEntity icResiCategoryStatsConfigEntity = new IcResiCategoryStatsConfigEntity(); + BeanUtils.copyProperties(formDTO,icResiCategoryStatsConfigEntity); + icResiCategoryStatsConfigEntity.setCustomerId(customerId); + icResiCategoryStatsConfigDao.updateById(icResiCategoryStatsConfigEntity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void updateSort(String customerId,List formDTOs) { + List entityList = new ArrayList<>(); + for (IcResiCategoryStatsConfigSortFormDTO formDTO : formDTOs) { + IcResiCategoryStatsConfigEntity icResiCategoryStatsConfigEntity = new IcResiCategoryStatsConfigEntity(); + icResiCategoryStatsConfigEntity.setId(formDTO.getId()); + icResiCategoryStatsConfigEntity.setCustomerId(customerId); + icResiCategoryStatsConfigEntity.setSort(formDTO.getSort()); + entityList.add(icResiCategoryStatsConfigEntity); + } + icResiCategoryStatsConfigService.updateBatchById(entityList); + } +} diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcResiCategoryStatsConfigDao.xml b/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcResiCategoryStatsConfigDao.xml new file mode 100644 index 0000000000..5fb6f245b4 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcResiCategoryStatsConfigDao.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcResiCategoryWarnConfigDao.xml b/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcResiCategoryWarnConfigDao.xml new file mode 100644 index 0000000000..419adda97c --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcResiCategoryWarnConfigDao.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 3d71a6f0337539150e988c688b6469914b5f52aa Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Fri, 5 Nov 2021 11:14:25 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=BF=A1=E6=81=AF-?= =?UTF-8?q?=E5=AE=B6=E5=BA=AD=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commons/tools/enums/RelationshipEnum.java | 58 +++++++++++++++++++ .../epmet/feign/GovOrgOpenFeignClient.java | 3 + .../GovOrgOpenFeignClientFallback.java | 5 ++ .../dto/result/OwnerRelationResultDTO.java | 29 ++++++++++ .../controller/IcResiUserController.java | 13 ++++- .../com/epmet/service/IcResiUserService.java | 13 +++-- .../service/impl/IcResiUserServiceImpl.java | 42 ++++++++++++++ 7 files changed, 158 insertions(+), 5 deletions(-) create mode 100644 epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/RelationshipEnum.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/OwnerRelationResultDTO.java diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/RelationshipEnum.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/RelationshipEnum.java new file mode 100644 index 0000000000..39a0f81550 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/RelationshipEnum.java @@ -0,0 +1,58 @@ +package com.epmet.commons.tools.enums; + +/** + * @author Administrator + */ + +public enum RelationshipEnum { + /** + * 环境变量枚举 + */ + UN_KNOWN("0", "暂不清楚", 0), + SELF("1", "本人", 1), + spouse("2", "配偶", 2), + CHILD("3", "子女", 3), + PARENT("4", "父母", 4), + PARENT_IN_LAW("5", "岳父母或公婆", 5), + GRANDPARENT_IN_LAW("6", "祖父母", 6), + CHILD_IN_LAW("7", "媳婿", 7), + GRANDCHILD("8", "孙子女", 8), + BROTHER_AND_SISTER("9", "兄弟姐妹", 9), + OTHER("10", "其他", 10), + ; + + private final String code; + private final String name; + private final Integer sort; + + + + RelationshipEnum(String code, String name, Integer sort) { + this.code = code; + this.name = name; + this.sort = sort; + } + + public static RelationshipEnum getEnum(String code) { + RelationshipEnum[] values = RelationshipEnum.values(); + for (RelationshipEnum value : values) { + if (value.getCode().equals(code)) { + return value; + } + } + return RelationshipEnum.UN_KNOWN; + } + + + public String getCode() { + return code; + } + + public String getName() { + return name; + } + + public Integer getSort(){ + return sort; + } +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java index 4784584218..5b18f345d2 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java @@ -516,4 +516,7 @@ public interface GovOrgOpenFeignClient { */ @PostMapping("/gov/org/ichouse/selecthouseinfobyidcard") Result> selectHouseInfoByIdCard(@RequestParam("idCard")String idCard); + + @GetMapping("/gov/org/ichouse/{id}") + Result get(@PathVariable("id") String id); } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java index 95219d6b1b..c6e0f96aa4 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java @@ -310,6 +310,11 @@ public class GovOrgOpenFeignClientFallback implements GovOrgOpenFeignClient { return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "selectHouseInfoByIdCard", idCard); } + @Override + public Result get(String id) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "get", id); + } + @Override public Result selectPidsByGridId(String gridId) { return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "selectPidsByGridId", gridId); diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/OwnerRelationResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/OwnerRelationResultDTO.java new file mode 100644 index 0000000000..9a3e0c23d7 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/OwnerRelationResultDTO.java @@ -0,0 +1,29 @@ +package com.epmet.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @Author zhaoqifeng + * @DateTime 2020/11/18 下午1:47 + */ +@NoArgsConstructor +@Data +public class OwnerRelationResultDTO implements Serializable { + + private static final long serialVersionUID = 2876258704168954941L; + private String ownerName; + private List userList; + + @NoArgsConstructor + @Data + public static class UserListBean { + private String userId; + private String userName; + private String isSelf; + private String relation; + } +} 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 f525d82218..7030248522 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 @@ -31,7 +31,6 @@ import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.IcResiUserDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; -import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.OperCustomizeOpenFeignClient; import com.epmet.service.IcResiUserImportService; import com.epmet.service.IcResiUserService; @@ -272,4 +271,16 @@ public class IcResiUserController { return resultForm.getData(); } + /** + * @Description 个人信息-家庭关系 + * @Param formDTO + * @Return {@link Result< OwnerRelationResultDTO>} + * @Author zhaoqifeng + * @Date 2021/11/5 11:13 + */ + @PostMapping("ownerrelation") + public Result getOwnerRelation(@RequestBody PersonDataFormDTO formDTO) { + return new Result().ok(icResiUserService.getOwnerRelation(formDTO.getUserId())); + } + } 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 2e9e5cf70d..ea67a9b872 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 @@ -21,10 +21,7 @@ import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.dto.form.*; -import com.epmet.dto.result.FormItem; -import com.epmet.dto.result.HomeUserResultDTO; -import com.epmet.dto.result.PersonDataResultDTO; -import com.epmet.dto.result.SearchByNameResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.IcResiUserEntity; import java.util.List; @@ -107,4 +104,12 @@ public interface IcResiUserService extends BaseService { */ Map> getDataForExport(Map itemList, String customerId, String formCode, String baseTableName, List conditions); + /** + * @Description 家庭关系 + * @Param userId + * @Return {@link OwnerRelationResultDTO} + * @Author zhaoqifeng + * @Date 2021/11/5 10:28 + */ + OwnerRelationResultDTO getOwnerRelation(String userId); } 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 b353507792..33db29fba4 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 @@ -28,6 +28,7 @@ import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.enums.GenderEnum; import com.epmet.commons.tools.enums.HouseTypeEnum; +import com.epmet.commons.tools.enums.RelationshipEnum; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; @@ -39,6 +40,7 @@ import com.epmet.constant.UserConstant; import com.epmet.dao.IcResiUserDao; import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.CustomerGridDTO; +import com.epmet.dto.IcHouseDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.entity.IcResiUserEntity; @@ -603,4 +605,44 @@ public class IcResiUserServiceImpl extends BaseServiceImpl houseResult = govOrgOpenFeignClient.get(user.getHomeId()); + if (!houseResult.success()) { + throw new RenException(houseResult.getCode(),houseResult.getMsg()); + } + result.setOwnerName(houseResult.getData().getOwnerName()); + + //获取用户所在家庭里所有人员信息 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(IcResiUserEntity::getHomeId, user.getHomeId()); + wrapper.orderByAsc(IcResiUserEntity::getYhzgx); + List resiUserList = baseDao.selectList(wrapper); + List userList = resiUserList.stream().map(item -> { + OwnerRelationResultDTO.UserListBean bean = new OwnerRelationResultDTO.UserListBean(); + bean.setUserId(item.getId()); + bean.setUserName(item.getName()); + bean.setRelation(RelationshipEnum.getEnum(item.getYhzgx()).getName()); + if (userId.equals(item.getId())) { + bean.setIsSelf(NumConstant.ONE_STR); + } + return bean; + }).collect(Collectors.toList()); + result.setUserList(userList); + return result; + } } From 5ea973af033b0d368a48baeecae8091d574d227a Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Fri, 5 Nov 2021 11:22:04 +0800 Subject: [PATCH 6/6] =?UTF-8?q?getcustomerform=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/commons/tools/redis/RedisKeys.java | 8 +++++-- .../com/epmet/redis/CustomerFootBarRedis.java | 24 +++++++++++++++---- .../epmet/service/impl/IcFormServiceImpl.java | 4 ++-- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index 9b7a7afccb..62557e2892 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -586,7 +586,11 @@ public class RedisKeys { * @param customerId * @return */ - public static String getIcFormKey(String formCode,String customerId) { - return rootPrefix.concat("icform:").concat(formCode).concat(":").concat(customerId); + public static String getIcFormKeyForAdd(String formCode,String customerId) { + return rootPrefix.concat("icform:").concat(formCode).concat(":add:").concat(customerId); + } + + public static String getIcFormKeyForExport(String formCode,String customerId) { + return rootPrefix.concat("icform:").concat(formCode).concat(":export:").concat(customerId); } } diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/redis/CustomerFootBarRedis.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/redis/CustomerFootBarRedis.java index 8cded15b44..0c549999ed 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/redis/CustomerFootBarRedis.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/redis/CustomerFootBarRedis.java @@ -51,18 +51,32 @@ public class CustomerFootBarRedis { } public void deleteIcForm(String formCode,String customerId) { - String key = RedisKeys.getIcFormKey(formCode,customerId); + String key = RedisKeys.getIcFormKeyForAdd(formCode,customerId); redisUtils.delete(key); } - public void setCustomerFormResultDTO(String formCode,String customerId, CustomerFormResultDTO value){ - String key = RedisKeys.getIcFormKey(formCode,customerId); + public void setCustomerFormResultDTO(String formCode,String customerId, CustomerFormResultDTO value,Boolean dynamic){ + String key=""; + if (null != dynamic && dynamic) { + //新增表单 + key = RedisKeys.getIcFormKeyForAdd(formCode,customerId); + }else{ + //导出 + key = RedisKeys.getIcFormKeyForExport(formCode,customerId); + } Map map = BeanUtil.beanToMap(value, false, true); redisUtils.hMSet(key, map); } - public CustomerFormResultDTO getCustomerFormResultDTO(String formCode,String customerId){ - String key = RedisKeys.getIcFormKey(formCode,customerId); + public CustomerFormResultDTO getCustomerFormResultDTO(String formCode,String customerId,Boolean dynamic){ + String key=""; + if (null != dynamic && dynamic) { + //新增表单 + key = RedisKeys.getIcFormKeyForAdd(formCode,customerId); + }else{ + //导出 + key = RedisKeys.getIcFormKeyForExport(formCode,customerId); + } Map resultMap = redisUtils.hGetAll(key); if (CollectionUtils.isEmpty(resultMap)) { return null; diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormServiceImpl.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormServiceImpl.java index 23088c3024..06da023015 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormServiceImpl.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormServiceImpl.java @@ -116,7 +116,7 @@ public class IcFormServiceImpl extends BaseServiceImpl */ @Override public CustomerFormResultDTO getCustomerForm(CustomerFormQueryDTO formDto) { - CustomerFormResultDTO customerFormResultDTO = customerFootBarRedis.getCustomerFormResultDTO(formDto.getFormCode(), formDto.getCustomerId()); + CustomerFormResultDTO customerFormResultDTO = customerFootBarRedis.getCustomerFormResultDTO(formDto.getFormCode(), formDto.getCustomerId(),formDto.getDynamic()); if (null != customerFormResultDTO) { return customerFormResultDTO; } @@ -128,7 +128,7 @@ public class IcFormServiceImpl extends BaseServiceImpl List groupList=baseDao.selectListGroup(resultDTO.getFormId()); resultDTO.setItemList(itemList); resultDTO.setGroupList(groupList); - customerFootBarRedis.setCustomerFormResultDTO(formDto.getFormCode(),formDto.getCustomerId(),resultDTO); + customerFootBarRedis.setCustomerFormResultDTO(formDto.getFormCode(),formDto.getCustomerId(),resultDTO,formDto.getDynamic()); return resultDTO; }