forked from luyan/epmet-cloud-lingshan
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
646 lines
28 KiB
646 lines
28 KiB
/**
|
|
* Copyright 2018 人人开源 https://www.renren.io
|
|
* <p>
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
* <p>
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
* <p>
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package com.epmet.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.epmet.commons.rocketmq.messages.IcResiUserAddMQMsg;
|
|
import com.epmet.commons.tools.annotation.LoginUser;
|
|
import com.epmet.commons.tools.aop.NoRepeatSubmit;
|
|
import com.epmet.commons.tools.constant.NumConstant;
|
|
import com.epmet.commons.tools.constant.StrConstant;
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
|
|
import com.epmet.commons.tools.dto.result.OptionDataResultDTO;
|
|
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.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.utils.ExcelUtils;
|
|
import com.epmet.commons.tools.utils.HttpClientManager;
|
|
import com.epmet.commons.tools.utils.IpUtils;
|
|
import com.epmet.commons.tools.utils.Result;
|
|
import com.epmet.commons.tools.validator.ValidatorUtils;
|
|
import com.epmet.constant.SystemMessageType;
|
|
import com.epmet.dto.IcResiUserDTO;
|
|
import com.epmet.dto.form.*;
|
|
import com.epmet.dto.result.*;
|
|
import com.epmet.enums.IcResiUserTableEnum;
|
|
import com.epmet.excel.support.ExportResiUserItemDTO;
|
|
import com.epmet.feign.EpmetMessageOpenFeignClient;
|
|
import com.epmet.feign.OperCustomizeOpenFeignClient;
|
|
import com.epmet.feign.OssFeignClient;
|
|
import com.epmet.service.IcResiUserImportService;
|
|
import com.epmet.service.IcResiUserService;
|
|
import jodd.io.FileUtil;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
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.jetbrains.annotations.NotNull;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.io.File;
|
|
import java.io.FileOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
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.stream.Collectors;
|
|
|
|
|
|
/**
|
|
* 用户基础信息
|
|
*
|
|
* @author generator generator@elink-cn.com
|
|
* @since v1.0.0 2021-10-26
|
|
*/
|
|
@Slf4j
|
|
@RestController
|
|
@RequestMapping("icresiuser")
|
|
public class IcResiUserController {
|
|
|
|
//todo 枚举吧
|
|
private static final String IC_RESI_FORM_CODE = "resi_base_info";
|
|
|
|
/**
|
|
* 居民上传临时目录
|
|
*/
|
|
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 RedisUtils redisUtils;
|
|
@Autowired
|
|
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient;
|
|
|
|
/**
|
|
* 模板枚举
|
|
*/
|
|
public enum IcUserTemplateEnums {
|
|
IC_RESI_IMPORT_TEMPLATE("excel/ic_resi_info_import_cid_for_easy_excel.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;
|
|
}
|
|
}
|
|
|
|
{
|
|
// 初始化上传目录
|
|
String home = System.getProperty("user.home");
|
|
Path importDir = Paths.get(home, "epmet_files", "ic_user_import");
|
|
if (Files.notExists(importDir)) {
|
|
try {
|
|
Files.createDirectories(importDir);
|
|
} catch (IOException e) {
|
|
log.error("创建数字赋能平台上传目录失败");
|
|
}
|
|
}
|
|
IC_RESI_UPLOAD_DIR = importDir;
|
|
|
|
Path exportDir = Paths.get(home, "epmet_files", "ic_user_export");
|
|
if (Files.notExists(exportDir)) {
|
|
try {
|
|
Files.createDirectories(exportDir);
|
|
} catch (IOException e) {
|
|
log.error("创建数字赋能平台下载目录失败");
|
|
}
|
|
}
|
|
IC_RESI_DOWNLOAD_DIR = exportDir;
|
|
}
|
|
|
|
@NoRepeatSubmit
|
|
@PostMapping("delete")
|
|
public Result delete(@LoginUser TokenDto tokenDto, @RequestBody DelIcResiUserFormDTO formDTO) {
|
|
formDTO.setCustomerId(tokenDto.getCustomerId());
|
|
ValidatorUtils.validateEntity(formDTO, DelIcResiUserFormDTO.IdGroup.class);
|
|
icResiUserService.delete(formDTO);
|
|
//推送MQ事件
|
|
IcResiUserAddMQMsg mqMsg = new IcResiUserAddMQMsg();
|
|
mqMsg.setCustomerId(tokenDto.getCustomerId());
|
|
mqMsg.setIcResiUser(formDTO.getIcResiUserId());
|
|
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<IcResiUserFormDTO> 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);
|
|
return new Result();
|
|
}
|
|
|
|
/**
|
|
* @Author sun
|
|
* @Description 党建互联平台--修改居民信息
|
|
**/
|
|
@NoRepeatSubmit
|
|
@PostMapping("edit")
|
|
public Result edit(@LoginUser TokenDto tokenDto, @RequestBody List<IcResiUserFormDTO> formDTO) {
|
|
String resiUserId = icResiUserService.edit(tokenDto, formDTO);
|
|
//推送MQ事件
|
|
IcResiUserAddMQMsg mqMsg = new IcResiUserAddMQMsg();
|
|
mqMsg.setCustomerId(tokenDto.getCustomerId());
|
|
mqMsg.setIcResiUser(resiUserId);
|
|
SystemMsgFormDTO form = new SystemMsgFormDTO();
|
|
form.setMessageType(SystemMessageType.IC_RESI_USER_EDIT);
|
|
form.setContent(mqMsg);
|
|
epmetMessageOpenFeignClient.sendSystemMsgByMQ(form);
|
|
return new Result();
|
|
}
|
|
|
|
/**
|
|
* @Description 根据房间号查人
|
|
* @Param formDTO
|
|
* @Return {@link Result<List<HomeUserResultDTO>>}
|
|
* @Author zhaoqifeng
|
|
* @Date 2021/11/1 11:04
|
|
*/
|
|
@PostMapping("getpeoplebyroom")
|
|
public Result<List<HomeUserResultDTO>> getPeopleByRoom(@RequestBody IcResiUserDTO formDTO) {
|
|
return new Result<List<HomeUserResultDTO>>().ok(icResiUserService.getPeopleByRoom(formDTO.getHomeId()));
|
|
}
|
|
|
|
/**
|
|
* 根据ic_resi_user找家属
|
|
* @param icResiUserId
|
|
* @return
|
|
*/
|
|
@GetMapping("findfamilymem/{icResiUserId}")
|
|
public Result<IcResiUserBriefDTO> findFamilyMem(@PathVariable("icResiUserId") String icResiUserId){
|
|
if(StringUtils.isNotBlank(icResiUserId)){
|
|
return new Result<IcResiUserBriefDTO>().ok(icResiUserService.findFamilyMem(icResiUserId));
|
|
}
|
|
return new Result<>();
|
|
}
|
|
|
|
@PostMapping("listresi")
|
|
public Result<PageData<Map<String, Object>>> queryListResi1(@LoginUser TokenDto tokenDto, @RequestBody IcResiUserPageFormDTO pageFormDTO) {
|
|
//pageFormDTO.setCustomerId("45687aa479955f9d06204d415238f7cc");
|
|
pageFormDTO.setCustomerId(tokenDto.getCustomerId());
|
|
pageFormDTO.setStaffId(tokenDto.getUserId());
|
|
ValidatorUtils.validateEntity(pageFormDTO, IcResiUserPageFormDTO.AddUserInternalGroup.class);
|
|
if(null==pageFormDTO.getConditions()){
|
|
pageFormDTO.setConditions(new ArrayList<>());
|
|
}
|
|
return new Result<PageData<Map<String, Object>>>().ok(icResiUserService.pageResiMap(pageFormDTO));
|
|
}
|
|
|
|
/**
|
|
* 编辑页面,显示居民信息详情
|
|
*
|
|
* @param pageFormDTO
|
|
* @return com.epmet.commons.tools.utils.Result
|
|
* @author yinzuomei
|
|
* @date 2021/10/28 10:29 上午
|
|
*/
|
|
@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(@RequestHeader String customerId,@LoginUser TokenDto tokenDto, @RequestBody IcResiUserPageFormDTO pageFormDTO, HttpServletResponse response) throws Exception {
|
|
//tokenDto.setUserId("9e37adcce6472152e6508a19d3683e02");
|
|
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.setPageFlag(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<String> stopSearchSet = new HashSet<>();
|
|
|
|
//获取表单项
|
|
List<FormItemResult> resiFormAllItems = icResiUserService.listFormItems(customerId, IC_RESI_FORM_CODE);
|
|
Map<String, FormItemResult> allItemMap = resiFormAllItems.stream().collect(Collectors.toMap(FormItemResult::getItemId, o -> o));
|
|
Map<String, ExportResiUserItemDTO> map = new HashMap<>();
|
|
allItemMap.values().forEach(item->{
|
|
String tableName = item.getTableName();
|
|
ExportResiUserItemDTO exportItem = map.getOrDefault(tableName, new ExportResiUserItemDTO());
|
|
map.putIfAbsent(tableName,exportItem);
|
|
String columnName = item.getColumnName().concat(item.getColumnNum() == NumConstant.ZERO ? StrConstant.EPMETY_STR : item.getColumnNum().toString());
|
|
exportItem.getItemMap().put(columnName,item);
|
|
if (item.getOptionSourceType().equals("remote")&&item.getOptionSourceValue().contains(StrConstant.QUESTION_MARK)){
|
|
//多个参数
|
|
String[] paramArr = item.getOptionSourceValue().split(StrConstant.QUESTION_MARK_TRANSFER)[NumConstant.ONE].split(StrConstant.AND_MARK);
|
|
Arrays.stream(paramArr).forEach(o->{
|
|
FormItemResult value = allItemMap.get(o);
|
|
if (value == null){
|
|
return;
|
|
}
|
|
Set<FormItemResult> conditionSet = exportItem.getRemoteItemConditionMap().getOrDefault(item.getItemId(),new HashSet<>());
|
|
conditionSet.add(value);
|
|
exportItem.getRemoteItemConditionMap().putIfAbsent(item.getItemId(),conditionSet);
|
|
});
|
|
}
|
|
});
|
|
|
|
//每个表对应的 item ;key:表名,value:<字段名:item对象>
|
|
Map<String, WriteSheet> childTableWriteSheetMap = new HashMap<>();
|
|
//表数据写入
|
|
//通过枚举获取相关表并按照sheetNo排序
|
|
List<IcResiUserTableEnum> resiTableList = Arrays.stream(IcResiUserTableEnum.values())
|
|
.sorted(Comparator.comparing(IcResiUserTableEnum::getSheetNo))
|
|
.collect(Collectors.toList());
|
|
List<Map<String, Object>> resiResultList = null;
|
|
|
|
pageFormDTO.setPageSize(NumConstant.FIVE_HUNDRED);
|
|
for (IcResiUserTableEnum tableEnum : resiTableList) {
|
|
String tableName = tableEnum.getTableName();
|
|
pageFormDTO.setPageNo(NumConstant.ONE);
|
|
//循环一次 写入一个sheet
|
|
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();
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* desc:根据客户id 下载模版文件 如果不存在则返回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<String> fileUrlResult = ossFeignClient.getOssFileUrl(ossFilePath, null);
|
|
Result<byte[]> 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 void importExcelByEasyExcel(@RequestHeader("customerId") String customerId,@RequestPart("file") MultipartFile file, HttpServletResponse response) {
|
|
if (file.isEmpty()) {
|
|
throw new RenException("请上传文件");
|
|
}
|
|
|
|
// 校验文件类型
|
|
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
|
|
if (!"xls".equals(extension) && !"xlsx".equals(extension)) {
|
|
throw new RenException("文件类型不匹配");
|
|
}
|
|
|
|
Path savePath = null;
|
|
try {
|
|
String fileName = UUID.randomUUID().toString().concat(".").concat(extension);
|
|
savePath = IC_RESI_UPLOAD_DIR.resolve(fileName);
|
|
|
|
IOUtils.copy(file.getInputStream(), new FileOutputStream(savePath.toString()));
|
|
List<FormItemResult> formItemList = icResiUserService.listFormItems(customerId,IC_RESI_FORM_CODE);
|
|
icResiUserImportService.importIcResiInfoFromExcel(formItemList, savePath.toString(), response);
|
|
} catch (IOException e) {
|
|
String errorMsg = ExceptionUtils.getErrorStackTrace(e);
|
|
log.error("【导入居民信息失败】导入失败:{}", errorMsg);
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
|
|
} finally {
|
|
try {
|
|
Files.delete(savePath);
|
|
} catch (IOException e) {
|
|
log.error("【导入居民信息失败】清理上传的文件失败:{}", ExceptionUtils.getErrorStackTrace(e));
|
|
}
|
|
}
|
|
}
|
|
|
|
@PostMapping("test")
|
|
public Result<List<Map<String, Object>>> test(@LoginUser TokenDto tokenDto, @RequestBody DynamicQueryFormDTO formDTO) {
|
|
formDTO.setCustomerId("45687aa479955f9d06204d415238f7cc");
|
|
//formDTO.setCustomerId(tokenDto.getCustomerId());
|
|
return new Result<List<Map<String, Object>>>().ok(icResiUserService.dynamicQuery(formDTO.getCustomerId(),
|
|
formDTO.getFormCode(),
|
|
formDTO.getResultTableName(),
|
|
formDTO.getConditions(),
|
|
tokenDto.getUserId(), null));
|
|
}
|
|
|
|
/**
|
|
* @param formDTO
|
|
* @Description 查询个人数据
|
|
* @author zxc
|
|
* @date 2021/11/3 9:21 上午
|
|
*/
|
|
@PostMapping("persondata")
|
|
public Result<PersonDataResultDTO> personData(@LoginUser TokenDto tokenDto,@RequestBody PersonDataFormDTO formDTO) {
|
|
formDTO.setCustomerId(tokenDto.getCustomerId());
|
|
ValidatorUtils.validateEntity(formDTO,PersonDataFormDTO.PersonDataForm.class);
|
|
return new Result<PersonDataResultDTO>().ok(icResiUserService.personData(formDTO));
|
|
}
|
|
|
|
/**
|
|
* @param formDTO
|
|
* @param tokenDto
|
|
* @Description 根据名字搜索
|
|
* @author zxc
|
|
* @date 2021/11/3 1:42 下午
|
|
*/
|
|
@PostMapping("searchbyname")
|
|
public Result<PageData<SearchByNameResultDTO>> searchByName(@RequestBody SearchByNameFormDTO formDTO, @LoginUser TokenDto tokenDto) {
|
|
ValidatorUtils.validateEntity(formDTO, SearchByNameFormDTO.SearchByNameForm.class);
|
|
return new Result<PageData<SearchByNameResultDTO>>().ok(icResiUserService.searchByName(formDTO, tokenDto));
|
|
}
|
|
|
|
@NotNull
|
|
private CustomerFormResultDTO getResiFormAddItems(String customerId) {
|
|
CustomerFormQueryDTO queryDTO = new CustomerFormQueryDTO();
|
|
queryDTO.setFormCode("resi_base_info");
|
|
queryDTO.setCustomerId(customerId);
|
|
Result<CustomerFormResultDTO> 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<OwnerRelationResultDTO> getOwnerRelation(@RequestBody PersonDataFormDTO formDTO) {
|
|
return new Result<OwnerRelationResultDTO>().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<Map<String, Map<String, String>>> getHomeUserCategoryCount(@RequestBody IcResiUserDTO formDTO) {
|
|
return new Result<Map<String, Map<String, String>>>().ok(icResiUserService.getHomeUserCategoryCount(formDTO.getBuildId()));
|
|
}
|
|
|
|
/**
|
|
* @LoginUser TokenDto tokenDto,
|
|
* 新增需求,需求人列表:展示当前工作人员所属组织+页面已选择所属网格 下的居民列表
|
|
* @param formDTO
|
|
* @return
|
|
*/
|
|
@PostMapping("demandusers")
|
|
public Result<List<DemandUserResDTO>> queryDemandUsers(@RequestBody DemandUserFormDTO formDTO) {
|
|
ValidatorUtils.validateEntity(formDTO, DemandUserFormDTO.InternalGroup.class);
|
|
return new Result<List<DemandUserResDTO>>().ok(icResiUserService.queryDemandUsers(formDTO));
|
|
}
|
|
|
|
/**
|
|
* 下载ic居民信息导入excel模板
|
|
* @param loginUserInfo
|
|
* @return
|
|
*/
|
|
@PostMapping("import/download-template")
|
|
public ResponseEntity<byte[]> downloadIcResiDownloadTemplate(@LoginUser TokenDto loginUserInfo) {
|
|
String customerId = loginUserInfo.getCustomerId();
|
|
|
|
try {
|
|
File icResiImportTemplateFile = getIcResiTemplateFile(customerId, IcUserTemplateEnums.IC_RESI_IMPORT_TEMPLATE);
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
headers.add("Access-Control-Expose-Headers", "Content-Disposition");
|
|
headers.add("content-Type", "application/vnd.ms-excel");
|
|
headers.add("Content-Disposition", "attachment;fileName=" + URLEncoder.encode(IcUserTemplateEnums.IC_RESI_IMPORT_TEMPLATE.getTemplateName(), "UTF-8"));
|
|
|
|
return new ResponseEntity<>(FileUtil.readBytes(icResiImportTemplateFile), headers, HttpStatus.OK);
|
|
} catch (Exception e) {
|
|
String errorStackTrace = ExceptionUtils.getErrorStackTrace(e);
|
|
|
|
log.error("下载IC居民信息导入模板失败:{}", errorStackTrace);
|
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "下载IC居民信息导入模板失败");
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 党员年龄范围统计
|
|
* @Param formDTO
|
|
* @Return {@link Result< List< OptionDataResultDTO >>}
|
|
* @Author zhaoqifeng
|
|
* @Date 2021/12/10 15:52
|
|
*/
|
|
@PostMapping("partymemberagestatistics")
|
|
public Result<List<OptionDataResultDTO>> partyMemberAgeStatistics(@RequestBody PartyMemberStatisticsFormDTO formDTO) {
|
|
ValidatorUtils.validateEntity(formDTO);
|
|
return new Result<List<OptionDataResultDTO>>().ok(icResiUserService.partyMemberAgeStatistics(formDTO));
|
|
}
|
|
|
|
/**
|
|
* 党员年龄列表
|
|
* @Param formDTO
|
|
* @Return {@link Result< PageData< PartyMemberEducationResultDTO>>}
|
|
* @Author zhaoqifeng
|
|
* @Date 2021/12/10 17:54
|
|
*/
|
|
@PostMapping("partymemberagelist")
|
|
public Result<PageData<PartyMemberAgeResultDTO>> partyMemberAgelist(@RequestBody PartyMemberListFormDTO formDTO) {
|
|
ValidatorUtils.validateEntity(formDTO);
|
|
return new Result<PageData<PartyMemberAgeResultDTO>>().ok(icResiUserService.getPartyMemberAgeList(formDTO));
|
|
}
|
|
|
|
/**
|
|
* 党员学历统计
|
|
* @Param formDTO
|
|
* @Return {@link Result< List< OptionDataResultDTO>>}
|
|
* @Author zhaoqifeng
|
|
* @Date 2021/12/10 17:58
|
|
*/
|
|
@PostMapping("partymembereducationstatistics")
|
|
public Result<List<OptionDataResultDTO>> partyMemberEducationStatistics(@RequestBody PartyMemberStatisticsFormDTO formDTO) {
|
|
ValidatorUtils.validateEntity(formDTO);
|
|
return new Result<List<OptionDataResultDTO>>().ok(icResiUserService.partyMemberEducationStatistics(formDTO));
|
|
}
|
|
|
|
/**
|
|
* 党员学历列表
|
|
* @Param formDTO
|
|
* @Return {@link Result< PageData< PartyMemberEducationResultDTO>>}
|
|
* @Author zhaoqifeng
|
|
* @Date 2021/12/10 17:58
|
|
*/
|
|
@PostMapping("partymembereducationlist")
|
|
public Result<PageData<PartyMemberEducationResultDTO>> partyMemberEducationlist(@RequestBody PartyMemberListFormDTO formDTO) {
|
|
ValidatorUtils.validateEntity(formDTO);
|
|
return new Result<PageData<PartyMemberEducationResultDTO>>().ok(icResiUserService.getPartyMemberEducationList(formDTO));
|
|
}
|
|
|
|
/**
|
|
* 根据居民id查询居民信息简介
|
|
* @param resiUserId
|
|
* @return
|
|
*/
|
|
@PostMapping("resi-brief/{resi-user-id}")
|
|
public Result<IcResiUserBriefDTO> getResiBrief(@PathVariable("resi-user-id") String resiUserId, @LoginUser TokenDto loginUser) {
|
|
String customerId = loginUser.getCustomerId();
|
|
IcResiUserBriefDTO r = icResiUserService.getResiBrief(resiUserId, customerId);
|
|
return new Result<IcResiUserBriefDTO>().ok(r);
|
|
}
|
|
|
|
/**
|
|
* 获取ic_resi_user
|
|
* @param icResiUserId
|
|
* @return
|
|
*/
|
|
@PostMapping("geticresiuser/{icResiUserId}")
|
|
public Result<IcResiUserDTO> getIcResiUserDTO(@PathVariable("icResiUserId") String icResiUserId){
|
|
if(StringUtils.isNotBlank(icResiUserId)){
|
|
return new Result<IcResiUserDTO>().ok(icResiUserService.get(icResiUserId));
|
|
}
|
|
return new Result<>();
|
|
}
|
|
}
|
|
|