/** * 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.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.excel.write.metadata.fill.FillWrapper; import com.alibaba.fastjson.JSON; import com.epmet.commons.rocketmq.messages.IcResiUserAddMQMsg; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.annotation.MaskResponse; import com.epmet.commons.tools.annotation.ReportRequest; import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.Constant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.distributedlock.DistributedLock; import com.epmet.commons.tools.dto.form.IcExportTemplateSaveFormDTO; import com.epmet.commons.tools.dto.form.mq.MqBaseFormDTO; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.dto.result.OptionDataResultDTO; import com.epmet.commons.tools.enums.IcFormCodeEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.ExceptionUtils; 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.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; 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.*; import com.epmet.commons.tools.utils.poi.excel.handler.FreezeAndFilter; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.constant.SystemMessageType; import com.epmet.constants.ImportTaskConstants; import com.epmet.dto.IcResiUserDTO; import com.epmet.dto.form.*; import com.epmet.dto.form.resi.IcResiPageNonDynamicFormDTO; import com.epmet.dto.result.*; import com.epmet.dto.result.demand.OptionDTO; import com.epmet.dto.result.resi.IcResiNonDynamicResultDTO; import com.epmet.enums.IcResiUserTableEnum; import com.epmet.excel.PartyMemberAgeExportExcel; import com.epmet.excel.PartyMemberEducationExportExcel; import com.epmet.excel.support.ExportResiUserItemDTO; import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.OperCustomizeOpenFeignClient; import com.epmet.feign.OssFeignClient; import com.epmet.resi.partymember.dto.partymember.IcPartyMemberDTO; import com.epmet.send.SendMqMsgUtil; import com.epmet.service.IcResiUserExportService; import com.epmet.service.IcResiUserImportService; import com.epmet.service.IcResiUserService; import com.github.pagehelper.Page; import feign.RequestInterceptor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.apache.poi.poifs.filesystem.OfficeXmlFileException; import org.jetbrains.annotations.NotNull; import org.redisson.api.RLock; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.net.URLEncoder; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; /** * 用户基础信息 * * @author generator generator@elink-cn.com * @since v1.0.0 2021-10-26 */ @Slf4j @RestController @RequestMapping("icresiuser") public class IcResiUserController implements ResultDataResolver { /** * 居民上传临时目录 */ private Path IC_RESI_UPLOAD_DIR; /** * 居民下载模版临时目录 */ private String OSS_TEMP_RESI_TEMP_DIR = "file-template/resi-template/"; /** * 本地模版缓存目录 */ private Path IC_RESI_DOWNLOAD_DIR; @Autowired private OssFeignClient ossFeignClient; @Autowired private OperCustomizeOpenFeignClient operCustomizeOpenFeignClient; @Autowired private IcResiUserService icResiUserService; @Autowired private IcResiUserImportService icResiUserImportService; @Autowired private IcResiUserExportService icResiUserExportService; @Autowired private RedisUtils redisUtils; @Autowired private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; @Autowired private LoginUserUtil loginUserUtil; @Autowired private RequestInterceptor requestInterceptor; @Autowired private ExecutorService executorService; @Autowired private DistributedLock distributedLock; /** * 模板枚举 */ public enum IcUserTemplateEnums { IC_RESI_IMPORT_TEMPLATE("excel/ic_resi_import_template.xls", "居民信息导入模板.xls"), IC_RESI_EXPORT_TEMPLATE("excel/ic_resi_info_cid_for_easy_excel.xlsx", "居民信息导出模板.xlsx"); private String pathInApp; private String templateName; IcUserTemplateEnums(String pathInApp, String templateName) { this.pathInApp = pathInApp; this.templateName = templateName; } public String getPathInApp() { return pathInApp; } public String getTemplateName() { return templateName; } } { // 初始化上传目录 try { IC_RESI_UPLOAD_DIR = com.epmet.commons.tools.utils.FileUtils.getAndCreateDirUnderEpmetFilesDir("ic_user_import"); } catch (IOException e) { log.error("初始化居民信息上传目录失败:{}", ExceptionUtils.getErrorStackTrace(e)); } Path exportDir = Paths.get(System.getProperty("user.home"), "epmet_files", "ic_user_export"); if (Files.notExists(exportDir)) { try { Files.createDirectories(exportDir); } catch (IOException e) { log.error("创建数字赋能平台下载目录失败"); } } IC_RESI_DOWNLOAD_DIR = exportDir; } /** * 批量删除居民信息 * @param tokenDto * @param formDTO * @return */ @NoRepeatSubmit @PostMapping("delete") public Result delete(@LoginUser TokenDto tokenDto, @RequestBody DelIcResiUserFormDTO formDTO) { formDTO.setCustomerId(tokenDto.getCustomerId()); formDTO.setCurrentStaffId(tokenDto.getUserId()); ValidatorUtils.validateEntity(formDTO, DelIcResiUserFormDTO.IdGroup.class); formDTO.getUserIds().forEach(userId -> { formDTO.setIcResiUserId(userId); icResiUserService.delete(formDTO); //推送MQ事件 IcResiUserAddMQMsg mqMsg = new IcResiUserAddMQMsg(); mqMsg.setCustomerId(tokenDto.getCustomerId()); mqMsg.setIcResiUser(userId); SystemMsgFormDTO form = new SystemMsgFormDTO(); form.setMessageType(SystemMessageType.IC_RESI_USER_DEL); form.setContent(mqMsg); epmetMessageOpenFeignClient.sendSystemMsgByMQ(form); }); return new Result(); } /** * @Author sun * @Description 党建互联平台--保存居民信息 **/ @NoRepeatSubmit @PostMapping("add") public Result add(@LoginUser TokenDto tokenDto, @RequestBody List formDTO) { String resiUserId = icResiUserService.add(tokenDto, formDTO); //推送MQ事件 IcResiUserAddMQMsg mqMsg = new IcResiUserAddMQMsg(); mqMsg.setCustomerId(tokenDto.getCustomerId()); mqMsg.setIcResiUser(resiUserId); SystemMsgFormDTO form = new SystemMsgFormDTO(); form.setMessageType(SystemMessageType.IC_RESI_USER_ADD); form.setContent(mqMsg); epmetMessageOpenFeignClient.sendSystemMsgByMQ(form); this.sendVolunteerMsg(tokenDto.getCustomerId(), resiUserId); return new Result(); } /** * desc:发送 志愿者变动消息 * * @param customerId * @param resiUserId */ private void sendVolunteerMsg(String customerId, String resiUserId) { //发送志愿者人员消息变动 boolean flag = SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendRocketMqMsg(SystemMessageType.VOLUNTEER_CHANGED, new MqBaseFormDTO(customerId, resiUserId)); if (!flag) { throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "发送志愿者变动消息失败", "发送志愿者变动消息失败"); } } /** * @Author sun * @Description 党建互联平台--修改居民信息 **/ @NoRepeatSubmit @PostMapping("edit") public Result edit(@LoginUser TokenDto tokenDto, @RequestBody List formDTO) { RLock lock = null; try { lock = distributedLock.getLock(RedisKeys.getXiaoquEditLock(tokenDto.getCustomerId()), 120L, 3L, TimeUnit.SECONDS); String resiUserId = icResiUserService.edit(tokenDto, formDTO); //推送MQ事件 editResiMq(tokenDto.getCustomerId(), resiUserId); this.sendVolunteerMsg(tokenDto.getCustomerId(), resiUserId); } finally { distributedLock.unLock(lock); } return new Result(); } /** * 更新居民的所属网格-》来源于小区更改所属网格 目前只有网格, * * @param formDTO * @return * @remark:后续如果有其他的变动需要调用的话 可以丰富参数 修改方法名 */ @NoRepeatSubmit @PostMapping("changeIcResiUserBelongTo") Result changeIcResiUserBelongTo(@LoginUser TokenDto tokenDto, @RequestBody IcUserBelongToChangedFormDTO formDTO) { formDTO.setCustomerId(tokenDto.getCustomerId()); ValidatorUtils.validateEntity(formDTO); List changedUserIds = icResiUserService.changeIcResiUserBelongTo(tokenDto, formDTO); //推送MQ事件 if (CollectionUtils.isNotEmpty(changedUserIds)) { changedUserIds.forEach(resiUserId -> editResiMq(tokenDto.getCustomerId(), resiUserId)); } return new Result().ok(true); } /** * 租客房东根据身份证更新头像 * * @param formDTO * @return com.epmet.commons.tools.utils.Result * @author zhy * @date 2022/4/26 10:48 */ @PostMapping("rent/updateimage") public Result updateImage(@LoginUser TokenDto tokenDto, @RequestBody RentTenantFormDTO formDTO) { // 身份证号验证 if (StringUtils.isNotBlank(formDTO.getUser().getIdCard())) { checkIdCard(formDTO.getUser().getIdCard()); } if (StringUtils.isNotBlank(formDTO.getIdCard())) { checkIdCard(formDTO.getIdCard()); } String resiUserId = icResiUserService.updateImage(tokenDto, formDTO); //推送MQ事件 editResiMq(formDTO.getCustomerId(), resiUserId); return new Result(); } private void checkIdCard(String idCard) { // 证件类型判断----start---- IdCardRegexUtils regex = IdCardRegexUtils.parse(idCard); if (regex == null) { throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "证件号解析错误", "证件号解析错误"); } } private void editResiMq(String customerId, String userId) { //推送MQ事件 IcResiUserAddMQMsg mqMsg = new IcResiUserAddMQMsg(); mqMsg.setCustomerId(customerId); log.info("customer id is {}", customerId); mqMsg.setIcResiUser(userId); SystemMsgFormDTO form = new SystemMsgFormDTO(); form.setMessageType(SystemMessageType.IC_RESI_USER_EDIT); form.setContent(mqMsg); epmetMessageOpenFeignClient.sendSystemMsgByMQ(form); } /** * 租客房东黑名单查询个人数据 * * @param formDTO * @return com.epmet.commons.tools.utils.Result * @author zhy * @date 2022/4/26 15:51 */ @PostMapping("rent/getrentresiuserinfo") public Result getRentResiUserInfo(@RequestBody RentTenantDataFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, RentTenantDataFormDTO.RentTenantDataForm.class); return new Result().ok(icResiUserService.getRentResiUserInfo(formDTO)); } /** * 租客房东黑名单查询个人数据 * * @param idCard * @return com.epmet.commons.tools.utils.Result * @author zhy * @date 2022/4/26 15:51 */ @PostMapping("rent/getresiuserinfo/{idCard}") public Result> getRentResiUserInfoByIdCard(@PathVariable("idCard") String idCard) { return new Result>().ok(icResiUserService.getRentResiUserInfoByIdCard(idCard)); } /** * @Description 根据房间号查人 * @Param formDTO * @Return {@link Result>} * @Author zhaoqifeng * @Date 2021/11/1 11:04 */ @PostMapping("getpeoplebyroom") public Result> getPeopleByRoom(@RequestBody IcResiUserDTO formDTO) { return new Result>().ok(icResiUserService.getPeopleByRoom(formDTO.getHomeId())); } /** * 根据ic_resi_user找家属 * * @param icResiUserId * @return */ @GetMapping("findfamilymem/{icResiUserId}") public Result findFamilyMem(@PathVariable("icResiUserId") String icResiUserId) { if (StringUtils.isNotBlank(icResiUserId)) { return new Result().ok(icResiUserService.findFamilyMem(icResiUserId)); } return new Result<>(); } @ReportRequest @PostMapping("listresi") @MaskResponse(fieldNames = {"MOBILE", "ID_CARD"}, fieldsMaskType = {MaskResponse.MASK_TYPE_MOBILE, MaskResponse.MASK_TYPE_ID_CARD}) public Result>> queryListResi1(@LoginUser TokenDto tokenDto, @RequestBody IcResiUserPageFormDTO pageFormDTO) { //pageFormDTO.setCustomerId("45687aa479955f9d06204d415238f7cc"); pageFormDTO.setCustomerId(tokenDto.getCustomerId()); pageFormDTO.setStaffId(tokenDto.getUserId()); pageFormDTO.setListType("resi"); ValidatorUtils.validateEntity(pageFormDTO, IcResiUserPageFormDTO.AddUserInternalGroup.class); if (null == pageFormDTO.getConditions()) { pageFormDTO.setConditions(new ArrayList<>()); } return new Result>>().ok(icResiUserService.pageResiMap(pageFormDTO)); } /** * 编辑页面,显示居民信息详情 * * @param pageFormDTO * @return com.epmet.commons.tools.utils.Result * @author yinzuomei * @date 2021/10/28 10:29 上午 */ @MaskResponse(fieldNames = {"NAME", "MOBILE","ID_CARD"}, fieldsMaskType = {MaskResponse.MASK_TYPE_CHINESE_NAME,MaskResponse.MASK_TYPE_MOBILE, MaskResponse.MASK_TYPE_ID_CARD}) @PostMapping("detail") public Result queryIcResiDetail(@LoginUser TokenDto tokenDto, @RequestBody IcResiDetailFormDTO pageFormDTO) { //pageFormDTO.setCustomerId("45687aa479955f9d06204d415238f7cc"); pageFormDTO.setCustomerId(tokenDto.getCustomerId()); ValidatorUtils.validateEntity(pageFormDTO, IcResiDetailFormDTO.AddUserInternalGroup.class); return new Result().ok(icResiUserService.queryIcResiDetail(pageFormDTO)); } /** * desc: 导出居民信息 * * @param customerId * @param tokenDto * @param pageFormDTO * @param response * @return void * @author LiuJanJun * @date 2021/11/19 4:24 下午 * @remark:分页批量导出 oss目录在 各个环境对应的前缀文件夹/file-template/resi-template/客户ID.xlsx, * 如果某个客户需要更新模版 则替换掉上面的模版文件;然后 更新缓存里的值或者删除也行 再导出就会下载新的模版了 */ @NoRepeatSubmit @RequestMapping(value = "/exportExcel") public void exportExcelByEasyExcel(@LoginUser TokenDto tokenDto, @RequestBody IcResiUserPageFormDTO pageFormDTO, HttpServletResponse response) throws Exception { long startM = System.currentTimeMillis(); String customerId = tokenDto.getCustomerId(); CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(customerId, tokenDto.getUserId()); String staffOrgPath = null; if (StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds()) && !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())) { staffOrgPath = staffInfoCacheResult.getAgencyPIds().concat(StrConstant.COLON).concat(staffInfoCacheResult.getAgencyId()); } else { staffOrgPath = staffInfoCacheResult.getAgencyId(); } pageFormDTO.setCustomerId(customerId); pageFormDTO.setIsPage(false); //获取模版文件 File file = getIcResiTemplateFile(customerId, IcUserTemplateEnums.IC_RESI_EXPORT_TEMPLATE); ExcelWriter excelWriter = null; try { excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel("居民基本信息.xlsx", response)).withTemplate(file).build(); //子表是否停止查询 Set stopSearchSet = new HashSet<>(); //获取表单项 List resiFormAllItems = icResiUserService.listFormItems(customerId, IcFormCodeEnum.RESI_BASE_INFO.getCode()); Map allItemMap = resiFormAllItems.stream().collect(Collectors.toMap(FormItemResult::getItemId, o -> o)); Map map = new HashMap<>(); allItemMap.values().forEach(item -> { String tableName = item.getTableName(); ExportResiUserItemDTO exportItem = map.getOrDefault(tableName, new ExportResiUserItemDTO()); map.putIfAbsent(tableName, exportItem); String columnName = item.getColumnName().concat(item.getColumnNum() == NumConstant.ZERO ? StrConstant.EPMETY_STR : item.getColumnNum().toString()); exportItem.getItemMap().put(columnName, item); if (Constant.OPITON_SOURCE_REMOTE.equals(item.getOptionSourceType()) && item.getOptionSourceValue().contains(StrConstant.QUESTION_MARK)) { //多个参数 String[] paramArr = item.getOptionSourceValue().split(StrConstant.QUESTION_MARK_TRANSFER)[NumConstant.ONE].split(StrConstant.AND_MARK); Arrays.stream(paramArr).forEach(o -> { FormItemResult value = allItemMap.get(o); if (value == null) { return; } Set conditionSet = exportItem.getRemoteItemConditionMap().getOrDefault(item.getItemId(), new HashSet<>()); conditionSet.add(value); exportItem.getRemoteItemConditionMap().putIfAbsent(item.getItemId(), conditionSet); }); } }); //每个表对应的 item ;key:表名,value:<字段名:item对象> Map childTableWriteSheetMap = new HashMap<>(); //表数据写入 //通过枚举获取相关表并按照sheetNo排序 List resiTableList = Arrays.stream(IcResiUserTableEnum.values()) .filter((v) -> v.getSheetNo() != null) .sorted(Comparator.comparing(IcResiUserTableEnum::getSheetNo)) .collect(Collectors.toList()); List> resiResultList = null; pageFormDTO.setPageSize(NumConstant.ONE_THOUSAND); for (IcResiUserTableEnum tableEnum : resiTableList) { String tableName = tableEnum.getTableName(); pageFormDTO.setPageNo(NumConstant.ONE); //循环一次 写入一个sheet do { resiResultList = icResiUserService.getDataForExport(map.get(tableName), tableName, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath); //如果 返回的条数小于每页显示的数 则退出查询 if (resiResultList.size() < pageFormDTO.getPageSize()) { stopSearchSet.add(tableName); } //如果没有 构建新的writeSheet WriteSheet writeSheet = childTableWriteSheetMap.getOrDefault(tableName, EasyExcel.writerSheet(tableEnum.getSheetNo()).build()); childTableWriteSheetMap.putIfAbsent(tableName, writeSheet); //写入数据 excelWriter.fill(new FillWrapper("t" + (tableEnum.getSheetNo() + NumConstant.ONE), resiResultList), writeSheet); pageFormDTO.setPageNo(pageFormDTO.getPageNo() + NumConstant.ONE); //重置数据 resiResultList.clear(); //如果包含则说明子表的数据 已经查询完毕 无需再继续查询了 } while (!stopSearchSet.contains(tableName)); } } finally { if (excelWriter != null) { excelWriter.finish(); } log.info("exportExcelByEasyExcel resi info cost time:{}s", (System.currentTimeMillis() - startM) / NumConstant.ONE_THOUSAND); } } /** * desc: 自定义导出居民信息 * * @param tokenDto * @param pageFormDTO * @param response * @return void * @author LiuJanJun * @date 2021/11/19 4:24 下午 * @remark:分页批量导出 oss目录在 各个环境对应的前缀文件夹/file-template/resi-template/客户ID.xlsx, * 如果某个客户需要更新模版 则替换掉上面的模版文件;然后 更新缓存里的值或者删除也行 再导出就会下载新的模版了 */ @NoRepeatSubmit @RequestMapping(value = "/exportExcelCustom") public void exportExcelCustom(@LoginUser TokenDto tokenDto, @RequestBody ExportResiUserFormDTO pageFormDTO, HttpServletResponse response) throws Exception { try { //获取导出配置 String aDefault = tokenDto.getCustomerId().concat(StrConstant.UNDER_LINE).concat("default"); if (pageFormDTO.getTemplateId().equals(aDefault)) { log.info("通过原来的模板下载,tokenDto:{}", JSON.toJSONString(tokenDto)); this.exportExcelByEasyExcel(tokenDto, pageFormDTO.getSearchForm(), response); } else { icResiUserExportService.exportIcResiUser(tokenDto, pageFormDTO, response,false); } } catch (EpmetException e) { response.reset(); response.setCharacterEncoding("UTF-8"); response.setHeader("content-type", "application/json; charset=UTF-8"); PrintWriter printWriter = response.getWriter(); Result result = new Result<>().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), e.getMsg()); printWriter.write(JSON.toJSONString(result)); printWriter.close(); } } /** * desc: 自定义导出居民信息 不下载只有数据 * * @param tokenDto * @param pageFormDTO * @param response * @return void * @author LiuJanJun * @date 2021/11/19 4:24 下午 * @remark 用于报表调用的接口 试试 */ @ReportRequest //@NoRepeatSubmit @RequestMapping(value = "/exportExcelCustomData") public Map exportExcelCustomData(@LoginUser TokenDto tokenDto, @RequestParam("templateId") String templateId, @RequestBody ExportResiUserFormDTO pageFormDTO) throws Exception { log.warn("pageFormDTO入参【"+JSON.toJSONString(pageFormDTO)+"】"); // pageFormDTO.setTemplateId(templateId); pageFormDTO.setTemplateId(tokenDto.getCustomerId().concat("_").concat(templateId)); if (null == pageFormDTO.getSearchForm()) { IcResiUserPageFormDTO searchForm = new IcResiUserPageFormDTO(); searchForm.setFormCode("resi_base_info"); searchForm.setCustomerId(tokenDto.getCustomerId()); searchForm.setStaffId(tokenDto.getUserId()); // searchForm.setPageNo(pageFormDTO.getPageNo()); // searchForm.setPageSize(pageFormDTO.getPageSize()); List conditions=new ArrayList<>(); // ResiUserQueryValueDTO temp=new ResiUserQueryValueDTO(); // temp.setColumnName(""); // temp.setColumnValue(Arrays.asList("IS_UNEMPLOYED")); // temp.setQueryType("resi_category"); // temp.setTableName("ic_resi_user"); // conditions.add(temp); searchForm.setConditions(conditions); pageFormDTO.setSearchForm(searchForm); } pageFormDTO.getSearchForm().setPageNo(pageFormDTO.getPageNo()); pageFormDTO.getSearchForm().setPageSize(pageFormDTO.getPageSize()); if (null == pageFormDTO.getExportConfig()) { IcExportTemplateSaveFormDTO exportTemplateSaveFormDTO = new IcExportTemplateSaveFormDTO(); exportTemplateSaveFormDTO.setFormCode("resi_base_info"); exportTemplateSaveFormDTO.setIsSaveTemp(false); pageFormDTO.setExportConfig(exportTemplateSaveFormDTO); } //固定通用客户Id // pageFormDTO.setCustomerId("jmreport_resi_default"); pageFormDTO.setCustomerId(tokenDto.getCustomerId()); Page> maps = icResiUserExportService.exportIcResiUser(tokenDto, pageFormDTO, null, true); Map result = new HashMap<>(); result.put("total",maps.getPages()); result.put("count",maps.getTotal()); result.put("data",maps.getResult()); return result; } /** * desc:根据客户id 先从oss下载模版,如果有没有则使用系统默认模板 如果不存在则返回null * * @param customerId * @return */ private File getIcResiTemplateFile(String customerId, IcUserTemplateEnums template) throws Exception { String fileType = ".xlsx"; String fileName = customerId + fileType; File file = new File(IC_RESI_DOWNLOAD_DIR.resolve(fileName).toString()); String serverIp = IpUtils.getServerIp(); Object isChanged = redisUtils.hGet(RedisKeys.getResiTempChangedKey(customerId), serverIp); //如果 redis 不存在这个机器的key 或者值为1 则重新下载 if (!file.exists() || isChanged == null || NumConstant.ONE_STR.equals(isChanged.toString())) { if (file.exists()) { file.delete(); } String ossFilePath = OSS_TEMP_RESI_TEMP_DIR + fileName; Result fileUrlResult = ossFeignClient.getOssFileUrl(ossFilePath, null); Result result = HttpClientManager.getInstance().getDownloadFilebytes(fileUrlResult.getData(), null); //获取模版失败 则把默认文件写入 if (result == null || !result.success()) { log.warn("获取居民模版失败,path:{},走默认模版", ossFilePath); InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream(template.getPathInApp()); FileUtils.copyInputStreamToFile(resourceAsStream, file); log.warn("getIcResiTemplateFile copy default file to template,customerId:{}", customerId); } else { log.warn("getIcResiTemplateFile reload file form oss default file to template,customerId:{}", customerId); FileUtils.writeByteArrayToFile(file, result.getData()); } redisUtils.hSet(RedisKeys.getResiTempChangedKey(customerId), serverIp, NumConstant.ZERO_STR); return file; } return file; } /** * excel导入居民基本信息 * * @return */ @NoRepeatSubmit @PostMapping("importExcel") public Result importExcelByEasyExcel(@RequestHeader("customerId") String customerId, @RequestPart("file") MultipartFile file, HttpServletRequest multipartRequest, HttpServletResponse response) { if (file.isEmpty()) { throw new RenException("请上传文件"); } String originalFilename = file.getOriginalFilename(); // 一.校验文件类型 String extension = FilenameUtils.getExtension(originalFilename); if (!"xls".equals(extension) && !"xlsx".equals(extension)) { throw new RenException("文件类型不匹配"); } String operatorId = loginUserUtil.getLoginUserId(); String importTaskId = icResiUserImportService.createImportTaskRecord(operatorId, ImportTaskConstants.BIZ_TYPE_RESI, originalFilename); // 二.缓存上传的文件 Path importTempFileSavePath; try { String fileName = UUID.randomUUID().toString().concat(".").concat(extension); importTempFileSavePath = IC_RESI_UPLOAD_DIR.resolve(fileName); IOUtils.copy(file.getInputStream(), new FileOutputStream(importTempFileSavePath.toString())); } catch (Exception e) { log.error("【上传居民信息】保存上传的文件失败:{}", ExceptionUtils.getErrorStackTrace(e)); throw new RenException("上传失败"); } // 三.异步执行导入 executorService.execute(() -> { boolean isAllSuccess = false; RLock lock = null; try { lock = distributedLock.getLock(RedisKeys.getXiaoquEditLock(customerId), 120L, 3L, TimeUnit.SECONDS); List formItemList = icResiUserService.listFormItems(customerId, IcFormCodeEnum.RESI_BASE_INFO.getCode()); isAllSuccess = icResiUserImportService.importIcResiInfoFromExcel(importTaskId, formItemList, importTempFileSavePath.toString(), response, IC_RESI_UPLOAD_DIR); } catch (Throwable e) { String errorMsg = ExceptionUtils.getThrowableErrorStackTrace(e); log.error("【导入居民信息失败】导入失败:{}", errorMsg); String resultDesc; if (e instanceof OfficeXmlFileException) { resultDesc = "文件格式异常,请确保使用下载的模板文件"; } else { resultDesc = "系统异常,请查看系统日志"; } // 要将导入任务状态设置为结束但不成功。不报错即成功,没有返回值 icResiUserImportService.finishImportTask(importTaskId, operatorId, ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL, resultDesc, null); } finally { try { // 都导入成功了没问题,才删除 if (importTempFileSavePath != null) { Files.delete(importTempFileSavePath); //if (isAllSuccess) { // Files.delete(importTempFileSavePath); //} else { // log.error("【导入居民信息】未完全成功,上传文件:{}", importTempFileSavePath); //} } } catch (IOException e) { log.error("【导入居民信息失败】清理上传的文件失败:{}", ExceptionUtils.getErrorStackTrace(e)); } //推送MQ事件 IcResiUserAddMQMsg mqMsg = new IcResiUserAddMQMsg(); mqMsg.setCustomerId(EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID)); //mqMsg.setIcResiUser(resiUserId); SystemMsgFormDTO form = new SystemMsgFormDTO(); form.setMessageType(SystemMessageType.IC_RESI_USER_ADD); form.setContent(mqMsg); epmetMessageOpenFeignClient.sendSystemMsgByMQ(form); //解锁 if (lock != null) { lock.unlock(); } } }); return new Result(); } /** * @param formDTO * @Description 查询个人数据 * @author zxc * @date 2021/11/3 9:21 上午 */ @MaskResponse(fieldNames = {"name", "mobile"}, fieldsMaskType = {MaskResponse.MASK_TYPE_CHINESE_NAME,MaskResponse.MASK_TYPE_MOBILE}) @PostMapping("persondata") public Result personData(@LoginUser TokenDto tokenDto, @RequestBody PersonDataFormDTO formDTO) { formDTO.setCustomerId(tokenDto.getCustomerId()); ValidatorUtils.validateEntity(formDTO, PersonDataFormDTO.PersonDataForm.class); return new Result().ok(icResiUserService.personData(formDTO)); } /** * @param formDTO * @param tokenDto * @Description 根据名字搜索 * @author zxc * @date 2021/11/3 1:42 下午 */ @PostMapping("searchbyname") public Result> searchByName(@RequestBody SearchByNameFormDTO formDTO, @LoginUser TokenDto tokenDto) { formDTO.setCustomerId(tokenDto.getCustomerId()); formDTO.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(formDTO, SearchByNameFormDTO.SearchByNameForm.class); return new Result>().ok(icResiUserService.searchByName(formDTO)); } /** * 需求: http://zentao.elinkservice.cn/task-view-4193.html 第11条 * * @param formDTO * @param tokenDto * @return 根据分类搜索 */ @MaskResponse(fieldNames = {"name", "mobile","idCard"}, fieldsMaskType = {MaskResponse.MASK_TYPE_CHINESE_NAME,MaskResponse.MASK_TYPE_MOBILE, MaskResponse.MASK_TYPE_ID_CARD}) @PostMapping("searchbycategory") public Result> search(@RequestBody SearchByNameFormDTO formDTO, @LoginUser TokenDto tokenDto) { formDTO.setCustomerId(tokenDto.getCustomerId()); formDTO.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(formDTO, SearchByNameFormDTO.SearchByCategoryForm.class); return new Result>().ok(icResiUserService.searchByName(formDTO)); } @NotNull private CustomerFormResultDTO getResiFormAddItems(String customerId) { CustomerFormQueryDTO queryDTO = new CustomerFormQueryDTO(); queryDTO.setFormCode(IcFormCodeEnum.RESI_BASE_INFO.getCode()); queryDTO.setCustomerId(customerId); Result resultForm = operCustomizeOpenFeignClient.getCustomerForm(queryDTO); if (resultForm == null || !resultForm.success() || resultForm.getData() == null) { throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); } 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())); } /** * @Description 获取一栋楼每个房间人员分类的数量 * @Param formDTO * @Return {@link Result< Map< String, Map< String, String>>>} * @Author zhaoqifeng * @Date 2021/11/5 15:10 */ @PostMapping("categorycount") public Result>> getHomeUserCategoryCount(@RequestBody IcResiUserDTO formDTO) { return new Result>>().ok(icResiUserService.getHomeUserCategoryCount(formDTO.getBuildId())); } /** * @param formDTO * @return * @LoginUser TokenDto tokenDto, * 新增需求,需求人列表:展示当前工作人员所属组织+页面已选择所属网格 下的居民列 */ @PostMapping("demandusers") public Result> queryDemandUsers(@LoginUser TokenDto tokenDto, @RequestBody DemandUserFormDTO formDTO) { formDTO.setCustomerId(tokenDto.getCustomerId()); formDTO.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(formDTO, DemandUserFormDTO.InternalGroup.class); return new Result>().ok(icResiUserService.queryDemandUsers(formDTO)); } /** * 下载ic居民信息导入excel模板 * * @return */ @PostMapping("import/download-template") public void downloadIcResiDownloadTemplate(HttpServletResponse response) { InputStream is = null; ServletOutputStream os = null; try { os = response.getOutputStream(); is = this.getClass().getClassLoader().getResourceAsStream(IcUserTemplateEnums.IC_RESI_IMPORT_TEMPLATE.getPathInApp()); response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); response.setHeader("content-Type", "application/vnd.ms-excel"); response.setHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode(IcUserTemplateEnums.IC_RESI_IMPORT_TEMPLATE.getTemplateName(), "UTF-8")); IOUtils.copy(is, os); } catch (Exception e) { String errorStackTrace = ExceptionUtils.getErrorStackTrace(e); log.error("下载IC居民信息导入模板失败:{}", errorStackTrace); throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "下载IC居民信息导入模板失败"); } finally { org.apache.poi.util.IOUtils.closeQuietly(is); org.apache.poi.util.IOUtils.closeQuietly(os); } } /** * 党员年龄范围统计 * * @Param formDTO * @Return {@link Result< List< OptionDataResultDTO >>} * @Author zhaoqifeng * @Date 2021/12/10 15:52 */ @PostMapping("partymemberagestatistics") public Result> partyMemberAgeStatistics(@RequestBody PartyMemberStatisticsFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO); return new Result>().ok(icResiUserService.partyMemberAgeStatistics(formDTO)); } /** * 党员年龄列表 * * @Param formDTO * @Return {@link Result< PageData< PartyMemberEducationResultDTO>>} * @Author zhaoqifeng * @Date 2021/12/10 17:54 */ @PostMapping("partymemberagelist") @MaskResponse(fieldNames = {"mobile"}, fieldsMaskType = {MaskResponse.MASK_TYPE_MOBILE}) public Result> partyMemberAgelist(@RequestBody PartyMemberListFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO); return new Result>().ok(icResiUserService.getPartyMemberAgeList(formDTO)); } @NoRepeatSubmit @PostMapping("partymemberagelist/export") public void partyMemberAgeListExport(@LoginUser TokenDto tokenDto, @RequestBody PartyMemberListFormDTO formDTO, HttpServletResponse response) { ExcelWriter excelWriter = null; formDTO.setPageSize(NumConstant.TEN_THOUSAND); formDTO.setIsPage(false); List exportList = new ArrayList<>(); try { String fileName = ""; switch (formDTO.getCode()) { case NumConstant.ZERO_STR: fileName = "50岁以下党员信息.xlsx"; break; case NumConstant.ONE_STR: fileName = "50-59岁党员信息.xlsx"; break; case NumConstant.TWO_STR: fileName = "60-69岁党员信息.xlsx"; break; case NumConstant.THREE_STR: fileName = "70-79岁党员信息.xlsx"; break; case NumConstant.FOUR_STR: fileName = "80岁以上党员信息.xlsx"; break; default: fileName = "党员年龄信息.xlsx"; break; } excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), PartyMemberAgeExportExcel.class).build(); WriteSheet writeSheet = EasyExcel.writerSheet("党员列表").registerWriteHandler(new FreezeAndFilter()).build(); List list = icResiUserService.getPartyMemberAgeList(formDTO).getList(); AtomicInteger i = new AtomicInteger(1); if (CollectionUtils.isNotEmpty(list)) { exportList = list.stream().map(item -> { PartyMemberAgeExportExcel excel = ConvertUtils.sourceToTarget(item, PartyMemberAgeExportExcel.class); excel.setIndex(i.getAndIncrement()); return excel; }).collect(Collectors.toList()); } excelWriter.write(exportList, writeSheet); } catch (Exception e) { log.error("export exception", e); } finally { if (excelWriter != null) { excelWriter.finish(); } } } /** * 党员学历统计 * * @Param formDTO * @Return {@link Result< List< OptionDataResultDTO>>} * @Author zhaoqifeng * @Date 2021/12/10 17:58 */ @PostMapping("partymembereducationstatistics") public Result> partyMemberEducationStatistics(@RequestBody PartyMemberStatisticsFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO); return new Result>().ok(icResiUserService.partyMemberEducationStatistics(formDTO)); } /** * 党员学历列表 * * @Param formDTO * @Return {@link Result< PageData< PartyMemberEducationResultDTO>>} * @Author zhaoqifeng * @Date 2021/12/10 17:58 */ @PostMapping("partymembereducationlist") @MaskResponse(fieldNames = {"mobile"}, fieldsMaskType = {MaskResponse.MASK_TYPE_MOBILE}) public Result> partyMemberEducationlist(@RequestBody PartyMemberListFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO); return new Result>().ok(icResiUserService.getPartyMemberEducationList(formDTO)); } @NoRepeatSubmit @PostMapping("partymembereducationlist/export") public void partyMemberEducationListExport(@LoginUser TokenDto tokenDto, @RequestBody PartyMemberListFormDTO formDTO, HttpServletResponse response) { ExcelWriter excelWriter = null; formDTO.setPageSize(NumConstant.TEN_THOUSAND); formDTO.setIsPage(false); List exportList = new ArrayList<>(); try { String fileName = ""; switch (formDTO.getCode()) { case NumConstant.ZERO_STR: fileName = "小学及文盲党员信息.xlsx"; break; case NumConstant.ONE_STR: fileName = "初中学历党员信息.xlsx"; break; case NumConstant.TWO_STR: fileName = "高中学历党员信息.xlsx"; break; case NumConstant.THREE_STR: fileName = "大专学历党员信息.xlsx"; break; case NumConstant.FOUR_STR: fileName = "本科学历党员信息.xlsx"; break; case NumConstant.FIVE_STR: fileName = "硕士学历党员信息.xlsx"; break; case NumConstant.SIX_STR: fileName = "博士学历党员信息.xlsx"; break; default: fileName = "党员学历信息.xlsx"; break; } excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), PartyMemberEducationExportExcel.class).build(); WriteSheet writeSheet = EasyExcel.writerSheet("党员列表").registerWriteHandler(new FreezeAndFilter()).build(); List list = icResiUserService.getPartyMemberEducationList(formDTO).getList(); AtomicInteger i = new AtomicInteger(1); if (CollectionUtils.isNotEmpty(list)) { exportList = list.stream().map(item -> { PartyMemberEducationExportExcel excel = ConvertUtils.sourceToTarget(item, PartyMemberEducationExportExcel.class); excel.setIndex(i.getAndIncrement()); return excel; }).collect(Collectors.toList()); } excelWriter.write(exportList, writeSheet); } catch (Exception e) { log.error("export exception", e); } finally { if (excelWriter != null) { excelWriter.finish(); } } } /** * 根据居民id查询居民信息简介 * * @param resiUserId * @return */ @PostMapping("resi-brief/{resi-user-id}") public Result getResiBrief(@PathVariable("resi-user-id") String resiUserId, @LoginUser TokenDto loginUser) { String customerId = loginUser.getCustomerId(); IcResiUserBriefDTO r = icResiUserService.getResiBrief(resiUserId, customerId); return new Result().ok(r); } /** * 获取ic_resi_user * * @param icResiUserId * @return */ @PostMapping("geticresiuser/{icResiUserId}") public Result getIcResiUserDTO(@PathVariable("icResiUserId") String icResiUserId) { if (StringUtils.isNotBlank(icResiUserId)) { return new Result().ok(icResiUserService.get(icResiUserId)); } return new Result<>(); } /** * 获取ic_resi_user * 目前只返回id, name * @param icResiUserIdList * @return */ @PostMapping(value = "list-icresiuser") public Result> getListIcResiUserDTO(@RequestBody List icResiUserIdList) { if (CollectionUtils.isEmpty(icResiUserIdList)) { return new Result<>(); } return new Result>().ok(icResiUserService.getListIcResiUserDTO(icResiUserIdList)); } /** * 【社区查询】搜索居民们 * * @param input * @return */ @PostMapping("search") public Result>> searchResi(@RequestBody IcResiUserPageFormDTO input, @LoginUser TokenDto loginUser) { if (StringUtils.isBlank(input.getKeyword())) { PageData> r = new PageData>(new ArrayList<>(), NumConstant.ZERO_L); return new Result>>().ok(r); } input.setKeyword(input.getKeyword().trim()); input.setCustomerId(loginUser.getCustomerId()); input.setStaffId(loginUser.getUserId()); input.setFormCode(IcFormCodeEnum.RESI_BASE_INFO.getCode()); input.setConditions(new ArrayList<>()); if (input.getPageNo() == null) { input.setPageNo(NumConstant.ONE); } if (input.getPageSize() == null) { input.setPageSize(NumConstant.TWENTY); } PageData> r = icResiUserService.pageResiMap(input); return new Result>>().ok(r); } /** * @param formDTO * @param tokenDto * @Description 【社区查询】人员预警右侧列表 * @author zxc * @date 2022/1/17 4:25 下午 */ @PostMapping("personwarn/rightlist") @MaskResponse(fieldNames = "mobile", fieldsMaskType = {MaskResponse.MASK_TYPE_MOBILE}) public Result personWarnRightList(@RequestBody PersonWarnRightListFormDTO formDTO, @LoginUser TokenDto tokenDto) { ValidatorUtils.validateEntity(formDTO, PersonWarnRightListFormDTO.PersonWarnRightListForm.class); return new Result().ok(icResiUserService.personWarnRightList(formDTO, tokenDto)); } /** * Desc: 根据房屋IDs查询房屋下是否有存在居民的 * * @param ids * @author zxc * @date 2022/3/2 10:32 上午 */ @PostMapping("getexistuserbyhouseids") public Result> getExistUserByHouseIds(@RequestBody List ids) { return new Result>().ok(icResiUserService.getExistUserByHouseIds(ids)); } /** * @Author sun * @Description 【人房】居民总数饼图 **/ @PostMapping("userchart") public Result userChart(@LoginUser TokenDto tokenDto, @RequestBody UserChartFormDTO formDTO) { formDTO.setCustomerId(tokenDto.getCustomerId()); formDTO.setUserId(tokenDto.getUserId()); return new Result().ok(icResiUserService.userChart(formDTO)); } /** * @Author sun * @Description 【人房】居民总数列表数据 **/ @PostMapping("userchartlist") public Result> userChartList(@RequestBody UserChartFormDTO formDTO) { return new Result>().ok(icResiUserService.userChartList(formDTO)); } /** * 根据房屋主键查询户内家庭成员简信息 * * @param houseId 房屋主键 * @param loginUser 登录用户 * @return com.epmet.commons.tools.utils.Result> * @author work@yujt.net.cn * @date 2022/4/21/0021 15:00 */ @PostMapping("listhomeuserbrief/{houseId}") public Result> listHomeUserBrief(@PathVariable("houseId") String houseId, @LoginUser TokenDto loginUser) { String customerId = loginUser.getCustomerId(); List r = icResiUserService.listHomeUserBrief(houseId, customerId); return new Result().ok(r); } /** * 根据房屋id,查询居民信息表中-家庭信息-本人 的居民。如果有多个,返回最近一个 * * @param homeId * @param loginUser * @return */ @PostMapping("queryhousehold/{homeId}") public Result queryHouseHold(@PathVariable("homeId") String homeId, @LoginUser TokenDto loginUser) { String customerId = loginUser.getCustomerId(); HouseHolderResDTO res = icResiUserService.queryHouseHold(homeId, customerId); return new Result().ok(res); } /** * 迁入管理、出生管理,勾选了补充居民信息,输入身份证号后,调用接口校验是否可继续执行 * * @param tokenDto * @param formDto * @return */ @PostMapping("checkuser") public Result checkUser(@LoginUser TokenDto tokenDto, @RequestBody SyncResiResDTO formDto) { ValidatorUtils.validateEntity(formDto, SyncResiResDTO.FormShow.class, SyncResiResDTO.FormInternal.class); return new Result().ok(icResiUserService.checkUser(tokenDto.getCustomerId(), formDto.getIdCard(), formDto.getAgencyId())); } /** * desc:条件获取房屋内的居民 按房屋分组 * * @param formDTO * @return */ @PostMapping("getResiUserGroupHomeId") Result> getResiUserGroupHomeId(@RequestBody RentTenantDataFormDTO formDTO) { return new Result().ok(icResiUserService.getResiUserGroupHomeId(formDTO)); } /** * 使用身份证号查询家属信息 * * @param idCard * @return */ @GetMapping("findFamilyMemByIdCard/{id-card}") public Result findFamilyMemByIdCard(@PathVariable("id-card") String idCard) { IcResiUserBriefDTO r = icResiUserService.findFamilyMemByIdCard(idCard); return new Result().ok(r); } /** * 身份证号查询居民信息 * * @param idCard * @return */ @PostMapping("getByResiIdCard/{idcard}") public Result getByResiIdCard(@PathVariable("idcard") String idCard) { IcResiUserDTO resi = icResiUserService.getByResiId(idCard); return new Result().ok(resi); } /** * 根据身份证号查询ic_resi_user.id+居民端用户id * * @param idCard * @return */ @PostMapping("getAllUserIds") public Result> getAllUserIds(@RequestParam("idcard") String idCard, @RequestParam("customerId") String customerId) { List list = icResiUserService.getAllUserIds(idCard, customerId); return new Result>().ok(list); } /** * 党员信息同步 * * @Param formDTO * @Return {@link Result} * @Author zhaoqifeng * @Date 2022/5/17 19:14 */ @PostMapping("icPartyMemberSync") public Result icPartyMemberSync(@RequestBody IcPartyMemberDTO formDTO) { IcPartyMemberDTO dto = icResiUserService.icPartyMemberSync(formDTO); if (StringUtils.isNotBlank(dto.getIcResiUser())) { this.sendVolunteerMsg(formDTO.getCustomerId(), dto.getIcResiUser()); } return new Result().ok(dto); } /** * 根据身份证获取居民信息(党员管理用,主要显示住址) * * @Param tokenDto * @Param formDTO * @Return {@link Result< IcResiUserInfoDTO>} * @Author zhaoqifeng * @Date 2022/5/20 10:11 */ @PostMapping("getUserByIdCard") public Result getUserByIdCard(@LoginUser TokenDto tokenDto, @RequestBody IcResiUserDTO formDTO) { formDTO.setCustomerId(tokenDto.getCustomerId()); return new Result().ok(icResiUserService.getUserByIdCard(formDTO)); } /** * 绑定房屋 * * @param form * @return com.epmet.commons.tools.utils.Result * @author LZN * @date 2022/6/22 16:29 */ @PostMapping("/bindHome") public Result bindHome(@RequestBody BindHomeFormDTO form, @LoginUser TokenDto tokenDto) { form.setCustomerId(tokenDto.getCustomerId()); form.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(form); icResiUserService.bindHome(form); return new Result(); } /** * 根据身份证获取居民角色(目前只有是否是志愿者) * * @Param tokenDto * @Param formDTO * @Return {@link Result} * @Author zhaoqifeng * @Date 2022/5/31 9:47 */ @PostMapping("getUserRoleByIdCard") public Result getUserRoleByIdCard(@LoginUser TokenDto tokenDto, @RequestBody IcResiUserDTO formDTO) { formDTO.setCustomerId(tokenDto.getCustomerId()); return new Result().ok(icResiUserService.getUserRoleByIdCard(formDTO)); } /** * 获取组织下的志愿者 * 居民信息里的志愿者 * @Param formDTO * @Return {@link Result>} * @Author zhaoqifeng * @Date 2022/6/16 15:22 */ @PostMapping("getVolunteerList") public Result> getVolunteerList(@RequestBody IcResiUserDTO formDTO) { return new Result>().ok(icResiUserService.getVolunteerList(formDTO.getCustomerId(), formDTO.getAgencyId())); } /** * 获取居民信息对应的居民用户ID * * @Param icUserId * @Return {@link Result>} * @Author zhaoqifeng * @Date 2022/6/16 15:40 */ @PostMapping("getUserId/{icUserId}") public Result> getUserId(@PathVariable("icUserId") String icUserId) { return new Result>().ok(icResiUserService.getUserId(icUserId)); } /** * 居民信息里的志愿者 * 社区自组织-添加成员可用 * @Param formDTO * @Return {@link Result>} * @Author zhaoqifeng * @Date 2022/6/16 15:22 */ @PostMapping("volunteer-list") public Result> queryVolunteerList(@LoginUser TokenDto tokenDto) { return new Result>().ok(icResiUserService.queryVolunteerList(tokenDto.getCustomerId(), tokenDto.getUserId())); } /** * 获取录入居民的数量 * * @Param formDTO * @Return {@link Result>} * @Author zhaoqifeng * @Date 2022/6/30 9:35 */ @PostMapping("getIcUserCount") public Result> getIcUserCount(@RequestBody IcUserCountFormDTO formDTO) { return new Result>().ok(icResiUserService.getIcUserCount(formDTO)); } /** * 综合治理图层:查询居民信息 * @param tokenDto * @param pageFormDTO * @return */ @PostMapping("listresi-zhzl") @MaskResponse(fieldNames = {"MOBILE", "ID_CARD", "NAME"}, fieldsMaskType = {MaskResponse.MASK_TYPE_MOBILE, MaskResponse.MASK_TYPE_ID_CARD, MaskResponse.MASK_TYPE_CHINESE_NAME}) public Result>> listResiZhzl(@LoginUser TokenDto tokenDto, @RequestBody IcResiUserPageFormDTO pageFormDTO) { pageFormDTO.setCustomerId(tokenDto.getCustomerId()); pageFormDTO.setStaffId(tokenDto.getUserId()); pageFormDTO.setListType("zhzl"); pageFormDTO.setIsPage(true); ValidatorUtils.validateEntity(pageFormDTO, IcResiUserPageFormDTO.AddUserInternalGroup.class); if (null == pageFormDTO.getConditions()) { pageFormDTO.setConditions(new ArrayList<>()); } return new Result>>().ok(icResiUserService.listResiZhzl(pageFormDTO)); } /** * Desc: 居民首次进入小程序,可以根据输入身份证信息查询在数字社区居民信息中的网格,匹配不成功提示 * @param tokenDto * @param formDTO * @author zxc * @date 2022/8/5 11:17 */ @PostMapping("icUserMatchGrid") public Result icUserMatchGrid(@RequestBody IcUserMatchGridFormDTO formDTO){ ValidatorUtils.validateEntity(formDTO, IcUserMatchGridFormDTO.IcUserMatchGridForm.class); return new Result().ok(icResiUserService.icUserMatchGrid(formDTO)); } /** * 居民列表分页查询 非动态 * @param input * @return */ @PostMapping("/nonDynamic/listResi") public Result> listResiNonDynamic(@RequestBody IcResiPageNonDynamicFormDTO input) { String gridId = input.getGridId(); String name = input.getName(); Integer pageNo = input.getPageNo(); Integer pageSize = input.getPageSize(); Boolean fuzzy = input.getFuzzy(); String mobile = input.getMobile(); PageData page = icResiUserService.listResiNonDynamic(fuzzy, gridId, name, mobile, pageNo, pageSize); return new Result>().ok(page); } /** * @Author sun * @Description 【人房概览】居民统计数点击查询列表 **/ @PostMapping("icuserstatislist") public Result> icUserStatisList(@LoginUser TokenDto tokenDto, @RequestBody UserChartFormDTO formDTO) { formDTO.setCustomerId(tokenDto.getCustomerId()); formDTO.setUserId(tokenDto.getUserId()); return new Result>().ok(icResiUserService.icUserStatisList(formDTO)); } /** * 更新育龄妇女状态定时任务 * @Param * @Return {@link Result} * @Author zhaoqifeng * @Date 2022/9/8 17:19 */ @PostMapping("updateYlfn") public Result updateYlfn() { icResiUserService.updateYlfn(); return new Result(); } }