From a8bb61ea692006fc3ad8747c0ac0832c7ec8f3be Mon Sep 17 00:00:00 2001 From: tangxiaobao <303826152@qq.com> Date: 星期四, 29 七月 2021 18:01:18 +0800 Subject: [PATCH] 防火防汛接口开发 --- springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java | 237 +++++++++++++++++++++++++++++ springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComSwPatrolRecordVO.java | 2 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java | 8 + springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/exceptions/ServiceException.java | 8 + springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/ComSwPatrolRecordPageDTO.java | 6 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java | 23 ++ springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/ComSwPatrolRecordApi.java | 20 + springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationMistakeExcelVO.java | 148 ++++++++++++++++++ springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationServeExcelVO.java | 3 springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ComSwPatrolRecordApi.java | 19 +- springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/PopulationApi.java | 6 11 files changed, 455 insertions(+), 25 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/ComSwPatrolRecordApi.java b/springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/ComSwPatrolRecordApi.java index 7eeae9c..025af16 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/ComSwPatrolRecordApi.java +++ b/springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/ComSwPatrolRecordApi.java @@ -5,6 +5,9 @@ import com.panzhihua.common.model.dtos.community.ComSwPatrolRecordAddDTO; import com.panzhihua.common.model.dtos.community.ComSwPatrolRecordPageDTO; import com.panzhihua.common.model.vos.R; +import com.panzhihua.common.model.vos.community.ComSwDangerReportVO; +import com.panzhihua.common.model.vos.community.ComSwPatrolRecordVO; +import com.panzhihua.common.model.vos.community.ComSwSafetyWorkRecordVO; import com.panzhihua.common.service.community.CommunityService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -32,10 +35,13 @@ * @param comSwPatrolRecordPageDTO 查询参数 * @return 分页集合 */ - @ApiOperation(value = "分页查询巡查记录") + @ApiOperation(value = "分页查询巡查记录", response = ComSwPatrolRecordVO.class) @PostMapping("/pagePatrolRecord") public R pagePatrolRecord(@RequestBody ComSwPatrolRecordPageDTO comSwPatrolRecordPageDTO){ Long communityId = this.getCommunityId(); + if (comSwPatrolRecordPageDTO.getSelectPerson().equals(1)) { + comSwPatrolRecordPageDTO.setPatrolPerson(String.valueOf(this.getLoginUserInfo().getUserId())); + } comSwPatrolRecordPageDTO.setCommunityId(communityId); return communityService.pagePatrolRecord(comSwPatrolRecordPageDTO); } @@ -59,7 +65,7 @@ * @param patrolRecordId 巡查记录id * @return 巡查记录详情查询结果 */ - @ApiOperation(value = "根据巡查记录id查询详情") + @ApiOperation(value = "根据巡查记录id查询详情", response = ComSwPatrolRecordVO.class) @PostMapping("/detailPatrolRecord") public R detailPatrolRecord(@RequestParam(value = "patrolRecordId") Long patrolRecordId) { return communityService.detailPatrolRecord(patrolRecordId); @@ -70,7 +76,7 @@ * @param comSwPatrolRecordPageDTO 查询参数 * @return 安全工作记录分页集合 */ - @ApiOperation(value = "分页查询安全工作记录") + @ApiOperation(value = "分页查询安全工作记录", response = ComSwSafetyWorkRecordVO.class) @PostMapping("/pageSafetyWorkRecord") public R pageSafetyWorkRecord(@RequestBody ComSwPatrolRecordPageDTO comSwPatrolRecordPageDTO){ Long communityId = this.getCommunityId(); @@ -84,7 +90,7 @@ * @param safetyWorkRecordId 安全工作记录 * @return 安全工作记录详情查询结果 */ - @ApiOperation(value = "根据安全工作记录id查询详情") + @ApiOperation(value = "根据安全工作记录id查询详情", response = ComSwSafetyWorkRecordVO.class) @PostMapping("/detailSafetyWorkRecord") public R detailSafetyWorkRecord(@RequestParam(value = "safetyWorkRecordId") Long safetyWorkRecordId) { return communityService.detailSafetyWorkRecord(safetyWorkRecordId); @@ -95,7 +101,7 @@ * @param comSwPatrolRecordPageDTO 查询参数 * @return 隐患报告分页集合 */ - @ApiOperation(value = "分页查询隐患报告") + @ApiOperation(value = "分页查询隐患报告", response = ComSwDangerReportVO.class) @PostMapping("/pageDangerReport") public R pageDangerReport(@RequestBody ComSwPatrolRecordPageDTO comSwPatrolRecordPageDTO){ Long communityId = this.getCommunityId(); @@ -109,7 +115,7 @@ * @param dangerReportId 隐患报告id * @return 隐患报告详情查询结果 */ - @ApiOperation(value = "根据隐患报告id查询详情") + @ApiOperation(value = "根据隐患报告id查询详情", response = ComSwDangerReportVO.class) @PostMapping("/detailDangerReport") public R detailDangerReport(@RequestParam(value = "dangerReportId") Long dangerReportId) { return communityService.detailDangerReport(dangerReportId); @@ -121,7 +127,7 @@ * @param patrolRecordId 巡查记录id * @return 隐患报告详情查询结果 */ - @ApiOperation(value = "根据隐患报告id查询详情") + @ApiOperation(value = "根据巡查记录id查询隐患报告详情", response = ComSwDangerReportVO.class) @PostMapping("/detailDangerReportByPrId") public R detailDangerReportByPrId(@RequestParam(value = "patrolRecordId") Long patrolRecordId) { return communityService.detailDangerReportByPrId(patrolRecordId); diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/exceptions/ServiceException.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/exceptions/ServiceException.java index 7285a2d..fd8f7d5 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/exceptions/ServiceException.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/exceptions/ServiceException.java @@ -10,6 +10,7 @@ private String code; private String msg; + private String data; public ServiceException() { super(); } @@ -27,6 +28,13 @@ this.msg = errorMsg; } + public ServiceException(String errorCode, String errorMsg,String data) { + super(errorCode); + this.code = errorCode; + this.msg = errorMsg; + this.data = data; + } + public ServiceException(String errorCode, String errorMsg, Throwable cause) { super(errorCode, cause); this.code = errorCode; diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java index f5f0949..0970e1c 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java @@ -1,21 +1,37 @@ package com.panzhihua.common.listen; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.event.AnalysisEventListener; +import com.alibaba.excel.write.metadata.WriteSheet; +import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.google.common.collect.Lists; import com.panzhihua.common.constants.BcDictionaryConstants; import com.panzhihua.common.enums.*; +import com.panzhihua.common.excel.CustomSheetWriteHandler; import com.panzhihua.common.exceptions.ServiceException; import com.panzhihua.common.model.vos.BcDictionaryVO; +import com.panzhihua.common.model.vos.LoginUserInfoVO; import com.panzhihua.common.model.vos.R; -import com.panzhihua.common.model.vos.community.ComMngPopulationImportErrorVO; -import com.panzhihua.common.model.vos.community.ComMngPopulationServeExcelVO; +import com.panzhihua.common.model.vos.community.*; +import com.panzhihua.common.model.vos.partybuilding.PartyBuildingMemberVO; import com.panzhihua.common.service.community.CommunityService; import com.panzhihua.common.utlis.*; +import io.swagger.models.auth.In; +import lombok.Data; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Value; import org.springframework.util.ObjectUtils; +import org.springframework.web.bind.annotation.RequestBody; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; @@ -35,10 +51,25 @@ private Map<Integer, String> headData; + private String userName; + // FTP 登录密码 + private String password; + // FTP 服务器地址IP地址 + private String host; + // FTP 端口 + private int port; + private String excelUrl; - public ComMngPopulationServeExcelListen(CommunityService communityService, Long communityId) { + public static String loadUrl; + + public ComMngPopulationServeExcelListen(CommunityService communityService, Long communityId, String userName, String password, String host, int port, String excelUrl) { this.communityService = communityService; this.communityId = communityId; + this.userName = userName; + this.password = password; + this.host = host; + this.port = port; + this.excelUrl = excelUrl; } /** @@ -91,25 +122,34 @@ try { ArrayList<ComMngPopulationServeExcelVO> voList = Lists.newArrayList(); List<ComMngPopulationImportErrorVO> populationImportErrorVOList = new ArrayList<>(); + ArrayList<ComMngPopulationMistakeExcelVO> mistakes = Lists.newArrayList(); for (Map<Integer, String> oneData : list) { ComMngPopulationServeExcelVO vo = new ComMngPopulationServeExcelVO(); //姓名和身份证都为空,为空户,无需操作,否则就解析年龄,性别,出生年月日 if(StringUtils.isNotEmpty(oneData.get(0)) || StringUtils.isNotEmpty(oneData.get(1))){ if(StringUtils.isEmpty(oneData.get(0))){ + ComMngPopulationMistakeExcelVO mistake = new ComMngPopulationMistakeExcelVO(); ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO(); importErrorVO.setErrorPosition("第" + index + "行,第1列"); importErrorVO.setErrorMsg("名字不可为空,请填写姓名"); populationImportErrorVOList.add(importErrorVO); index++; + setMistake(oneData, mistake); + mistake.setMistake("名字不可为空,请填写姓名"); + mistakes.add(mistake); continue; } vo.setName(oneData.get(0)); if(StringUtils.isEmpty(oneData.get(1))){ ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO(); + ComMngPopulationMistakeExcelVO mistake = new ComMngPopulationMistakeExcelVO(); importErrorVO.setErrorPosition("第" + index + "行,第2列"+oneData.get(1)); importErrorVO.setErrorMsg("身份证号不可为空,请填写身份证号"); populationImportErrorVOList.add(importErrorVO); index++; + setMistake(oneData, mistake); + mistake.setMistake("身份证号不可为空,请填写身份证号"); + mistakes.add(mistake); continue; } @@ -120,6 +160,10 @@ importErrorVO.setErrorMsg("身份证号位数有误,请检查身份证号码是否正确"); populationImportErrorVOList.add(importErrorVO); index++; + ComMngPopulationMistakeExcelVO mistake = new ComMngPopulationMistakeExcelVO(); + setMistake(oneData, mistake); + mistake.setMistake("身份证号位数有误,请检查身份证号码是否正确"); + mistakes.add(mistake); continue; } vo.setCardNo(oneData.get(1).toUpperCase()); @@ -155,7 +199,20 @@ vo.setNation(oneData.get(2)); } if(StringUtils.isNotEmpty(oneData.get(3))){ - vo.setPoliticalOutlook(PopulPoliticalOutlookEnum.getCodeByName(oneData.get(3))); + Integer isOk = PopulPoliticalOutlookEnum.getCodeByName(oneData.get(3)); + if(isOk.equals(-1)){ + ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO(); + importErrorVO.setErrorPosition("第" + index + "行,第4列"); + importErrorVO.setErrorMsg("您填写的政治面貌有误"); + populationImportErrorVOList.add(importErrorVO); + index++; + ComMngPopulationMistakeExcelVO mistake = new ComMngPopulationMistakeExcelVO(); + setMistake(oneData, mistake); + mistake.setMistake("您填写的政治面貌有误"); + mistakes.add(mistake); + continue; + } + vo.setPoliticalOutlook(isOk); } if(StringUtils.isNotEmpty(oneData.get(4))){ Integer isOk = PopulHouseUseEnum.getCodeByName(oneData.get(4)); @@ -165,6 +222,10 @@ importErrorVO.setErrorMsg("您填写的是否租住有误"); populationImportErrorVOList.add(importErrorVO); index++; + ComMngPopulationMistakeExcelVO mistake = new ComMngPopulationMistakeExcelVO(); + setMistake(oneData, mistake); + mistake.setMistake("您填写的是否租住有误"); + mistakes.add(mistake); continue; } vo.setIsRent(isOk); @@ -197,6 +258,10 @@ importErrorVO.setErrorMsg("您填写的与户主关系有误"); populationImportErrorVOList.add(importErrorVO); index++; + ComMngPopulationMistakeExcelVO mistake = new ComMngPopulationMistakeExcelVO(); + setMistake(oneData, mistake); + mistake.setMistake("您填写的与户主关系有误"); + mistakes.add(mistake); continue; }else{ vo.setRelation(isOk); @@ -208,6 +273,10 @@ importErrorVO.setErrorMsg("街路巷不可为空"); populationImportErrorVOList.add(importErrorVO); index++; + ComMngPopulationMistakeExcelVO mistake = new ComMngPopulationMistakeExcelVO(); + setMistake(oneData, mistake); + mistake.setMistake("街路巷不可为空"); + mistakes.add(mistake); continue; } vo.setRoad(oneData.get(6)); @@ -217,6 +286,10 @@ importErrorVO.setErrorMsg("小区号不可为空"); populationImportErrorVOList.add(importErrorVO); index++; + ComMngPopulationMistakeExcelVO mistake = new ComMngPopulationMistakeExcelVO(); + setMistake(oneData, mistake); + mistake.setMistake("小区号不可为空"); + mistakes.add(mistake); continue; } vo.setDoorNo(oneData.get(7).trim()); @@ -226,6 +299,10 @@ importErrorVO.setErrorMsg("楼排号不可为空"); populationImportErrorVOList.add(importErrorVO); index++; + ComMngPopulationMistakeExcelVO mistake = new ComMngPopulationMistakeExcelVO(); + setMistake(oneData, mistake); + mistake.setMistake("楼排号不可为空"); + mistakes.add(mistake); continue; } vo.setFloor(oneData.get(8).trim()); @@ -235,6 +312,10 @@ importErrorVO.setErrorMsg("单元号不可为空"); populationImportErrorVOList.add(importErrorVO); index++; + ComMngPopulationMistakeExcelVO mistake = new ComMngPopulationMistakeExcelVO(); + setMistake(oneData, mistake); + mistake.setMistake("单元号不可为空"); + mistakes.add(mistake); continue; } vo.setUnitNo(oneData.get(9).trim()); @@ -244,6 +325,10 @@ importErrorVO.setErrorMsg("户室不可为空"); populationImportErrorVOList.add(importErrorVO); index++; + ComMngPopulationMistakeExcelVO mistake = new ComMngPopulationMistakeExcelVO(); + setMistake(oneData, mistake); + mistake.setMistake("户室不可为空"); + mistakes.add(mistake); continue; } vo.setHouseNo(oneData.get(10).trim()); @@ -261,6 +346,10 @@ importErrorVO.setErrorMsg("您填写的房屋状态有误"); populationImportErrorVOList.add(importErrorVO); index++; + ComMngPopulationMistakeExcelVO mistake = new ComMngPopulationMistakeExcelVO(); + setMistake(oneData, mistake); + mistake.setMistake("您填写的房屋状态有误"); + mistakes.add(mistake); continue; } vo.setHouseStatus(isOk); @@ -273,6 +362,10 @@ importErrorVO.setErrorMsg("您填写的房屋用途有误"); populationImportErrorVOList.add(importErrorVO); index++; + ComMngPopulationMistakeExcelVO mistake = new ComMngPopulationMistakeExcelVO(); + setMistake(oneData, mistake); + mistake.setMistake("您填写的房屋用途有误"); + mistakes.add(mistake); continue; } vo.setHousePurpose(PopulHousePurposeEnum.getCodeByName(oneData.get(14).trim())); @@ -285,6 +378,10 @@ importErrorVO.setErrorMsg("您填写的管控状态有误"); populationImportErrorVOList.add(importErrorVO); index++; + ComMngPopulationMistakeExcelVO mistake = new ComMngPopulationMistakeExcelVO(); + setMistake(oneData, mistake); + mistake.setMistake("您填写的管控状态有误"); + mistakes.add(mistake); continue; } vo.setControlStatus(isOk); @@ -297,7 +394,20 @@ vo.setNativePlace(oneData.get(17).trim()); } if(StringUtils.isNotEmpty(oneData.get(18))){ - vo.setCultureLevel(PopulCultureLevelEnum.getCodeByName(oneData.get(18))); + Integer isOk = PopulCultureLevelEnum.getCodeByName(oneData.get(18)); + if(isOk.equals(-1)){ + ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO(); + importErrorVO.setErrorPosition("第" + index + "行,第19列"); + importErrorVO.setErrorMsg("您填写的文化程度有误"); + populationImportErrorVOList.add(importErrorVO); + index++; + ComMngPopulationMistakeExcelVO mistake = new ComMngPopulationMistakeExcelVO(); + setMistake(oneData, mistake); + mistake.setMistake("您填写的文化程度有误"); + mistakes.add(mistake); + continue; + } + vo.setCultureLevel(isOk); } if(StringUtils.isNotEmpty(oneData.get(19))){ // String ma = convertMarriage(oneData.get(19)); @@ -309,6 +419,10 @@ importErrorVO.setErrorMsg("您填写的婚姻状况有误"); populationImportErrorVOList.add(importErrorVO); index++; + ComMngPopulationMistakeExcelVO mistake = new ComMngPopulationMistakeExcelVO(); + setMistake(oneData, mistake); + mistake.setMistake("您填写的婚姻状况有误"); + mistakes.add(mistake); continue; }else{ vo.setMarriage(isOk); @@ -339,6 +453,10 @@ importErrorVO.setErrorMsg("您填写的本地/外地有误"); populationImportErrorVOList.add(importErrorVO); index++; + ComMngPopulationMistakeExcelVO mistake = new ComMngPopulationMistakeExcelVO(); + setMistake(oneData, mistake); + mistake.setMistake("您填写的本地/外地有误"); + mistakes.add(mistake); continue; } vo.setOutOrLocal(isOk); @@ -361,6 +479,10 @@ importErrorVO.setErrorMsg("您填写的人员类型有误"); populationImportErrorVOList.add(importErrorVO); index++; + ComMngPopulationMistakeExcelVO mistake = new ComMngPopulationMistakeExcelVO(); + setMistake(oneData, mistake); + mistake.setMistake("您填写的人员类型有误"); + mistakes.add(mistake); continue; } vo.setPersonType(isOk); @@ -439,14 +561,29 @@ List<ComMngPopulationServeExcelVO> newVoList = voList.stream().filter(ListUtils.distinctByKey(ComMngPopulationServeExcelVO::getDistinctPass)).collect(Collectors.toList()); R r = communityService.listSavePopulationServeExcelVO(newVoList, communityId); if (!R.isOk(r)) { + List<ComMngPopulationMistakeExcelVO> list = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), ComMngPopulationMistakeExcelVO.class); String errMsg = r.getMsg(); List<ComMngPopulationImportErrorVO> errorList = JSON.parseArray(errMsg,ComMngPopulationImportErrorVO.class); if(!errorList.isEmpty()){ populationImportErrorVOList.addAll(errorList); } + mistakes.addAll(list); + R result = mistakeExportPopulation(mistakes); + loadUrl = (String)result.getData(); + ComMngPopulationImportErrorVO comMngPopulationImportErrorVO = new ComMngPopulationImportErrorVO(); + comMngPopulationImportErrorVO.setErrorPosition("loadUrl"); + comMngPopulationImportErrorVO.setErrorMsg(loadUrl); + populationImportErrorVOList.add(comMngPopulationImportErrorVO); throw new ServiceException("500", JSON.toJSONString(populationImportErrorVOList)); }else{ +// mistakes.addAll((List<ComMngPopulationMistakeExcelVO>)r.getData()); + R result = mistakeExportPopulation(mistakes); + loadUrl = (String)result.getData(); if(!populationImportErrorVOList.isEmpty()){ + ComMngPopulationImportErrorVO comMngPopulationImportErrorVO = new ComMngPopulationImportErrorVO(); + comMngPopulationImportErrorVO.setErrorPosition("loadUrl"); + comMngPopulationImportErrorVO.setErrorMsg(loadUrl); + populationImportErrorVOList.add(comMngPopulationImportErrorVO); throw new ServiceException("500", JSON.toJSONString(populationImportErrorVOList)); } } @@ -469,6 +606,96 @@ } } + private void setMistake(Map<Integer, String> map, ComMngPopulationMistakeExcelVO vo){ + vo.setName(map.get(0)); + vo.setCardNo(map.get(1)); + vo.setNation(map.get(2)); + vo.setPoliticalOutlook(map.get(3)); + vo.setIsRent(map.get(4)); + vo.setRelation(map.get(5)); + vo.setRoad(map.get(6)); + vo.setDoorNo(map.get(7)); + vo.setFloor(map.get(8)); + vo.setUnitNo(map.get(9)); + vo.setHouseNo(map.get(10)); + vo.setBuildPurpose(map.get(11)); + vo.setBuildArea(map.get(12)); + vo.setHouseStatus(map.get(13)); + vo.setHousePurpose(map.get(14)); + vo.setControlStatus(map.get(15)); + vo.setPhone(map.get(16)); + vo.setNativePlace(map.get(17)); + vo.setCultureLevel(map.get(18)); + vo.setMarriage(map.get(19)); + vo.setHealthy(map.get(20)); + vo.setBloodType(map.get(21)); + vo.setReligion(map.get(22)); + vo.setProfession(map.get(23)); + vo.setWorkCompany(map.get(24)); + vo.setOutOrLocal(map.get(25)); + vo.setCensusRegister(map.get(26)); + vo.setResidence(map.get(27)); +// vo.setAddress(map.get(28)); + vo.setPersonType(map.get(28)); + vo.setCountry(map.get(29)); + vo.setStringOfDeparture(map.get(30)); + vo.setPersonStatus(map.get(31)); + vo.setMonthlyIncome(map.get(32)); + vo.setFamilyStatus(map.get(33)); + vo.setGoalInChina(map.get(34)); + vo.setStringOfArrival(map.get(35)); + vo.setRemark(map.get(36)); + vo.setIdCardPositive(map.get(37)); + vo.setIdCardBack(map.get(38)); + vo.setHouseHold(map.get(39)); + vo.setDeath(map.get(40)); + } + + private R mistakeExportPopulation(List<ComMngPopulationMistakeExcelVO> vo) { + //生成动态模板excel通过ftp工具上传到主节点,然后返回模板下载地址 + String ftpUrl = "/mnt/data/web/excel/"; + String name = "实有人口错误数据.xlsx"; + try { + SFTPUtil sftp = new SFTPUtil(userName, password, host, port); + sftp.login(); + boolean existDir = sftp.isExistDir(ftpUrl + name); + if (!existDir) { + String property = System.getProperty("user.dir"); + String fileName = property + File.separator + name; + // 这里 需要指定写用哪个class去写 + ExcelWriter excelWriter = null; + InputStream inputStream = null; + try { + excelWriter = EasyExcel.write(fileName, ComMngPopulationMistakeExcelVO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); + WriteSheet writeSheet = EasyExcel.writerSheet("实有人口错误数据").build(); + excelWriter.write(vo, writeSheet); + excelWriter.finish(); + File file = new File(fileName); + inputStream = new FileInputStream(file); + sftp.uploadMore(ftpUrl, name, inputStream); + sftp.logout(); + inputStream.close(); + String absolutePath = file.getAbsolutePath(); + boolean delete = file.delete(); + log.info("删除excel【{}】结果【{}】", absolutePath, delete); + } finally { + // 千万别忘记finish 会帮忙关闭流 + if (inputStream != null) { + inputStream.close(); + } + if (excelWriter != null) { + excelWriter.finish(); + } + } + } + return R.ok(excelUrl + name); + } catch (Exception e) { + e.printStackTrace(); + log.error("文件传输失败【{}】", e.getMessage()); + return R.fail(); + } + } + private String convertMarriage(String ma) { if(Objects.equals("已",ma) || Objects.equals("一",ma)){ diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/ComSwPatrolRecordPageDTO.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/ComSwPatrolRecordPageDTO.java index eafe074..1706212 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/ComSwPatrolRecordPageDTO.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/ComSwPatrolRecordPageDTO.java @@ -64,4 +64,10 @@ @ApiModelProperty("状态(1.待处理 2.待整改 3.已整改)") private String status; + /** + * 查看人(1.全部 2.只看我的) + */ + @ApiModelProperty("查看人(1.全部 2.只看我的)") + private Integer selectPerson; + } diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationMistakeExcelVO.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationMistakeExcelVO.java new file mode 100644 index 0000000..5fdd5cf --- /dev/null +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationMistakeExcelVO.java @@ -0,0 +1,148 @@ +package com.panzhihua.common.model.vos.community; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.google.common.collect.Lists; +import com.panzhihua.common.model.helper.encrypt.EncryptDecryptClass; +import com.panzhihua.common.model.helper.encrypt.EncryptDecryptField; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @description: 批量导入实有人口 + * @author: llming + */ +@Data +@EncryptDecryptClass +public class ComMngPopulationMistakeExcelVO implements Serializable { + + @ExcelProperty(value = "姓名", index = 0) + private String name; + + @EncryptDecryptField + private String cardNo; + + @ExcelProperty(value = "民族", index = 2) + private String nation; + + @ExcelProperty(value = "政治面貌(群众/中共党员/共青团员)", index = 3) + private String politicalOutlook; + + @ExcelProperty(value = "是否租住", index = 4) + private String isRent; + + @ExcelProperty(value = "与户主关系(户主/配偶/子女/孙女/父母/其他)", index = 5) + private String relation; + + @ExcelProperty(value = "街/路/巷", index = 6) + private String road; + + @ExcelProperty(value = "小区号(政府对于每个小区都有特定编号)", index = 7) + private String doorNo; + + @ExcelProperty(value = "楼排号", index = 8) + private String floor; + + @ExcelProperty(value = "单元号", index = 9) + private String unitNo; + + @ExcelProperty(value = "户室(四位数表示。前两位楼层,后两位户号)", index = 10) + private String houseNo; + + @ExcelProperty(value = "建筑用途", index = 11) + private String buildPurpose; + + @ExcelProperty(value = "建筑面积", index = 12) + private String buildArea; + + @ExcelProperty(value = "房屋状态(自住/租住/其他)", index = 13) + private String houseStatus; + + @ExcelProperty(value = "房屋用途(住宅/公寓/宿舍/仓库/其他)", index = 14) + private String housePurpose; + + @ExcelProperty(value = "管控状态(常规/关注/管控)", index = 15) + private String controlStatus; + + @ExcelProperty(value = "联系方式", index = 16) + private String phone; + + @ExcelProperty(value = "籍贯", index = 17) + private String nativePlace; + + @ExcelProperty(value = "文化程度(1.小学 2.初中 3.高中 4.中专 5.大专 6.本科 7.硕士 8.博士 9.其他)", index = 18) + private String cultureLevel; + + @ExcelProperty(value = "婚姻状况(1.未婚 2.已婚 3.离异 4.丧偶 5.分居 6.其他)", index = 19) + private String marriage; + + @ExcelProperty(value = "健康状况", index = 20) + private String healthy; + + @ExcelProperty(value = "血型", index = 21) + private String bloodType; + + @ExcelProperty(value = "宗教信仰", index = 22) + private String religion; + + @ExcelProperty(value = "职业", index = 23) + private String profession; + + @ExcelProperty(value = "工作单位/学校", index = 24) + private String workCompany; + + @ExcelProperty(value = "本地/外地", index = 25) + private String outOrLocal; + + @ExcelProperty(value = "户口所在地", index = 26) + private String censusRegister; + + @ExcelProperty(value = "是否居住地(是/否)", index = 27) + private String residence; + +// @ExcelProperty(value = "居住地址", index = 28) +// private String address; + + @ExcelProperty(value = "人员类型(户籍人员/留守人员/外地人员/境外人员)", index = 28) + private String personType; + + @ExcelProperty(value = "国家", index = 29) + private String country; + + @ExcelProperty(value = "离开日期(境外人员填写)", index = 30) + private String StringOfDeparture; + + @ExcelProperty(value = "人员状态(正常/失联/出国)", index = 31) + private String personStatus; + + @ExcelProperty(value = "月收入情况", index = 32) + private String monthlyIncome; + + @ExcelProperty(value = "家庭情况", index = 33) + private String familyStatus; + + @ExcelProperty(value = "来华目的(境外人员填写)", index = 34) + private String goalInChina; + + @ExcelProperty(value = "抵达日期(境外人员填写)", index = 35) + private String StringOfArrival; + + @ExcelProperty(value = "备注", index = 36) + private String remark; + + @ExcelProperty(value = "证件照(人面像)照片", index = 37) + private String idCardPositive; + + @ExcelProperty(value = "证件照(国徽面)照片", index = 38) + private String idCardBack; + + @ExcelProperty(value = "户口本照片", index = 39) + private String houseHold; + + @ExcelProperty(value = "是否死亡(是/否)", index = 40) + private String death; + + @ExcelProperty(value = "错误信息", index = 41) + private String mistake; +} diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationServeExcelVO.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationServeExcelVO.java index 0789848..90c6a02 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationServeExcelVO.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationServeExcelVO.java @@ -172,6 +172,9 @@ @ExcelProperty(value = "特殊情况(重大病史/孕)(是/否)", index = 49) private Integer specialCase; + @ExcelProperty(value = "错误信息", index = 50) + private Integer mistake; + /** * 去重字段,使用(姓名+身份证号+街路巷+小区号+楼牌号+单元号+户室)组合字段进行MD5加密实现去重 diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComSwPatrolRecordVO.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComSwPatrolRecordVO.java index 594658b..03c27cd 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComSwPatrolRecordVO.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComSwPatrolRecordVO.java @@ -49,7 +49,7 @@ */ @ApiModelProperty("巡查时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - private Date PatrolTime; + private Date patrolTime; /** * 天气 diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java index 1306b9a..e4986ac 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java @@ -3832,4 +3832,12 @@ */ @PostMapping("/patrolRecord/dangerReport/export") R exportDangerReport(@RequestBody List<Long> dangerReportIds); + + /** + * 巡查记录统计接口 + * + * @return 统计结果 + */ + @PostMapping("/patrolRecord/statistics") + R patrolRecordStatistics(@RequestParam(value = "communityId") Long communityId); } diff --git a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ComSwPatrolRecordApi.java b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ComSwPatrolRecordApi.java index daa3bc8..1c8be1d 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ComSwPatrolRecordApi.java +++ b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ComSwPatrolRecordApi.java @@ -11,9 +11,7 @@ import com.panzhihua.common.model.dtos.community.ComSwPatrolRecordPageDTO; import com.panzhihua.common.model.dtos.community.ExportComMngCarExcelDTO; import com.panzhihua.common.model.vos.R; -import com.panzhihua.common.model.vos.community.ComMngCarExcelVO; -import com.panzhihua.common.model.vos.community.ComMngPopulationTotalVO; -import com.panzhihua.common.model.vos.community.ComSwDangerReportExcelVO; +import com.panzhihua.common.model.vos.community.*; import com.panzhihua.common.service.community.CommunityService; import com.panzhihua.common.utlis.SFTPUtil; import com.panzhihua.community_backstage.excel.CustomSheetWriteHandler; @@ -65,7 +63,7 @@ * @param comSwPatrolRecordPageDTO 查询参数 * @return 分页集合 */ - @ApiOperation(value = "分页查询巡查记录") + @ApiOperation(value = "分页查询巡查记录", response = ComSwPatrolRecordVO.class) @PostMapping("/pagePatrolRecord") public R pagePatrolRecord(@RequestBody ComSwPatrolRecordPageDTO comSwPatrolRecordPageDTO){ Long communityId = this.getCommunityId(); @@ -243,12 +241,17 @@ return R.fail("未查询到隐患报告"); } - @ApiOperation(value = "巡查记录统计接口", response = ComMngPopulationTotalVO.class) - @PostMapping("/statistics") - public R getPopulationTotalByAdmin() { + /** + * 巡查记录统计接口 + * + * @return 统计结果 + */ + @ApiOperation(value = "巡查记录统计接口", response = ComSwPatrolRecordStatisticsVO.class) + @PostMapping("/patrolRecordStatistics") + public R patrolRecordStatistics() { //获取登陆用户绑定社区id Long communityId = this.getLoginUserInfo().getCommunityId(); - return communityService.getPopulationTotalByAdmin(communityId); + return communityService.patrolRecordStatistics(communityId); } } diff --git a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/PopulationApi.java b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/PopulationApi.java index 07aae74..37dbbe6 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/PopulationApi.java +++ b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/PopulationApi.java @@ -90,13 +90,13 @@ InputStream inputStream = null; try { inputStream = file.getInputStream(); - ComMngPopulationServeExcelListen comMngPopulationServeExcelListen = new ComMngPopulationServeExcelListen(communityService, this.getCommunityId()); + ComMngPopulationServeExcelListen comMngPopulationServeExcelListen = new ComMngPopulationServeExcelListen(communityService, this.getCommunityId(),userName,password,host,port,excelUrl); EasyExcel.read(inputStream, null, comMngPopulationServeExcelListen).sheet().doRead(); } catch (IOException e) { log.error("导入模板失败【{}】", e.getMessage()); e.printStackTrace(); } - return R.ok(); + return R.ok(ComMngPopulationServeExcelListen.loadUrl); } /** @@ -134,7 +134,7 @@ try { Long communityId = Long.valueOf(request.getParameter("communityId")); inputStream = file.getInputStream(); - ComMngPopulationServeExcelListen comMngPopulationServeExcelListen = new ComMngPopulationServeExcelListen(communityService, communityId); + ComMngPopulationServeExcelListen comMngPopulationServeExcelListen = new ComMngPopulationServeExcelListen(communityService, communityId,userName,password,host,port,excelUrl); EasyExcel.read(inputStream, null, comMngPopulationServeExcelListen).sheet().doRead(); } catch (IOException e) { log.error("导入模板失败【{}】", e.getMessage()); diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java index a5aa7e2..a2ea07c 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java @@ -363,6 +363,7 @@ @Override @Transactional(rollbackFor = Exception.class) public R listSavePopulation(List<ComMngPopulationServeExcelVO> list, Long communityId) throws Exception { + List<ComMngPopulationMistakeExcelVO> mistakes = new ArrayList<>(); List<ComMngPopulationImportErrorVO> populationImportErrorVOList = new ArrayList<>(); //查询该社区 ComActDO comActDO = comActDAO.selectById(communityId); @@ -400,6 +401,11 @@ importErrorVO.setErrorPosition("街路巷:" + vo.getRoad() + ",小区号:" + vo.getDoorNo()); populationImportErrorVOList.add(importErrorVO); // index++; + ComMngPopulationMistakeExcelVO mistake = new ComMngPopulationMistakeExcelVO(); + BeanUtils.copyProperties(vo,mistake); + setMistake(mistake, vo); + mistake.setMistake("街路巷或小区号不存在,请先在“小区管理”中添加该小区:街路巷:"+ vo.getRoad() +",小区号:" + vo.getDoorNo()); + mistakes.add(mistake); continue; } @@ -467,7 +473,7 @@ this.saveBatch(populationDOList);*/ if (!populationImportErrorVOList.isEmpty()) { - return R.fail(JSON.toJSONString(populationImportErrorVOList)); + return R.fail(mistakes,JSON.toJSONString(populationImportErrorVOList)); } return R.ok(); } @@ -1908,4 +1914,19 @@ return R.ok(this.baseMapper.getVillagePopulationAdmin(new Page(villagePopulationDTO.getPageNum(),villagePopulationDTO.getPageSize()),villagePopulationDTO)); } + private void setMistake(ComMngPopulationMistakeExcelVO mvo, ComMngPopulationServeExcelVO vo){ + mvo.setPoliticalOutlook(PopulPoliticalOutlookEnum.getCnDescByName(vo.getPoliticalOutlook())); + mvo.setIsRent(PopulHouseUseEnum.getCnDescByName(vo.getIsRent())); + mvo.setRelation(PopulRelationEnum.getCnDescByName(vo.getRelation())); + mvo.setHouseStatus(PopulHouseStatusEnum.getCnDescByName(vo.getHouseStatus())); + mvo.setHousePurpose(PopulHousePurposeEnum.getCnDescByName(vo.getHousePurpose())); + mvo.setControlStatus(PopulHouseControlStatusEnum.getCnDescByName(vo.getControlStatus())); + mvo.setCultureLevel(PopulCultureLevelEnum.getCnDescByName(vo.getCultureLevel())); + mvo.setMarriage(PopulMarriageEnum.getCnDescByName(vo.getMarriage())); + mvo.setOutOrLocal(PopulOutOrLocalEnum.getCnDescByName(vo.getOutOrLocal())); + mvo.setResidence(PopulRelationEnum.getCnDescByName(vo.getResidence())); + mvo.setPersonType(PopulPersonTypeEnum.getCnDescByName(vo.getPersonType())); + mvo.setDeath(PopulOutOrLocalEnum.getCnDescByName(vo.getDeath())); + } + } \ No newline at end of file -- Gitblit v1.7.1