Browse Source

Merge remote-tracking branch 'origin_elink/yantai_zhengwu_master' into master1

# Conflicts:
#	epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java
#	epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_template.xlsx
#	epmet-module/gov-org/gov-org-server/src/main/resources/excel/neighbor_template.xlsx
#	epmet-module/gov-org/gov-org-server/src/main/resources/excel/yantai/community_building_manager_import_temp.xlsx
dev
yinzuomei 3 years ago
parent
commit
c880ea1045
  1. 9
      epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/SysDictDataServiceImpl.java
  2. 4
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/DictTypeEnum.java
  3. 8
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java
  4. 5
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java
  5. 11
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcBuildingDTO.java
  6. 40
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java
  7. 4
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcBulidingAddFormDTO.java
  8. 7
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CommunityBuildingManagerDTO.java
  9. 12
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcBulidingDetailDTO.java
  10. 4
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcHouseListResultDTO.java
  11. 25
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CommunityBuildingManagerController.java
  12. 65
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java
  13. 5
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CommunityBuildingManagerEntity.java
  14. 12
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/IcBuildingEntity.java
  15. 75
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/CustomerStaffImportExcelData.java
  16. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcBuildingExcel.java
  17. 13
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcNeighborHoodExcel.java
  18. 120
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/handler/CommunityBuildingManagerImportListener.java
  19. 202
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/handler/CustomerStaffImportListener.java
  20. 116
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/yt/CommunityBuildingManagerImportExcelData.java
  21. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingInfoModel.java
  22. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseInfoModel.java
  23. 12
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodInfoModel.java
  24. 14
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CommunityBuildingManagerService.java
  25. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcBuildingService.java
  26. 4
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java
  27. 402
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CommunityBuildingManagerServiceImpl.java
  28. 20
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingServiceImpl.java
  29. 127
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java
  30. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/PropertyManagementServiceImpl.java
  31. 201
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java
  32. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/building_export.xlsx
  33. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/building_export_0510.xlsx
  34. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/building_template.xlsx
  35. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/building_template_0510.xlsx
  36. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/customer_staff_import_template.xlsx
  37. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_export_for_easyexcel.xlsx
  38. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_export_for_easyexcel_0510.xlsx
  39. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_template.xlsx
  40. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_template_0510.xlsx
  41. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/neighbor_export.xlsx
  42. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/neighbor_export_0510.xlsx
  43. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/neighbor_template.xlsx
  44. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/neighbor_template_0510.xlsx
  45. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/yantai/community_building_manager_import_temp.xlsx
  46. 13
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml
  47. 12
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml
  48. 24
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml
  49. 35
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java
  50. 55
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncRecordDeathServiceImpl.java
  51. 92
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java
  52. 12
      epmet-user/epmet-user-server/src/main/resources/mapper/DataSyncRecordDeathDao.xml

9
epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/SysDictDataServiceImpl.java

@ -28,15 +28,13 @@ import com.epmet.dto.SysDictDataDTO;
import com.epmet.entity.SysDictDataEntity;
import com.epmet.entity.SysDictTypeEntity;
import com.epmet.service.SysDictDataService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -276,6 +274,9 @@ public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataDao, SysD
@Override
public Map<String, String> dictMap(String dictType) {
List<DictListResultDTO> resultDTOList = baseDao.selectDictList(dictType);
if(CollectionUtils.isEmpty(resultDTOList)){
return new HashMap<>();
}
return resultDTOList.stream().collect(Collectors.toMap(DictListResultDTO::getValue, DictListResultDTO::getLabel));
}

4
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/DictTypeEnum.java

@ -34,6 +34,10 @@ public enum DictTypeEnum {
TRAFFIC_TYPE("traffic_type", "交通方式", 36),
SOJOURN_HISTORY("sojourn_history", "7天内旅居史情况", 37),
TRIP_DATA_TYPE("trip_data_type", "行程记录类型", 39),
YT_KEY_POINT_USER_TYPE("yt_key_point_user_type","重点人群",40),
YT_POPULATION_TYPE("yt_population_type","人口类型",41),
YT_POLITICS_STATUS("yt_politics_status","政治面貌",42),
YT_ID_CARD_TYPE("yt_id_card_type","证件类型",43),
;
private final String code;

8
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java

@ -723,6 +723,14 @@ public class EpmetUserServiceImpl implements EpmetUserService {
formDTO.setPageNo(pageIndex);
//1.分页查询排好序的工作人员Id列表【原本1/2步可以用一个sql,但涉及2需要按1的顺序排序,sql复杂且效率低,所以拆开】
LinkedList<String> staffIds = customerStaffDao.selectOrderRole(formDTO);
if (staffIds!=null && formDTO.getStaffIds()!=null){
formDTO.getStaffIds().forEach(
staffId->{
if (!staffIds.contains(staffId)){
staffIds.add(staffId);
}
});
}
//2.批量查询工作人员信息,按传入顺序排序
if(CollectionUtils.isEmpty(staffIds)){
return new ArrayList<>();

5
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java

@ -93,4 +93,9 @@ public interface ImportTaskConstants {
* 楼长单元长
*/
String COMMUNITY_BUILDING_MANAGER="community_building_manager";
/**
* 客户
*/
String BIZ_TYPE_CUSTOMER_STAFF="customer_staff";
}

11
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcBuildingDTO.java

@ -96,6 +96,16 @@ public class IcBuildingDTO implements Serializable {
*/
private String buildingLeaderMobile;
/**
* 烟台需求楼长身份证号
*/
private String buildingLeaderIdCard;
/**
* 烟台需求类型0楼长1单元长
*/
private String buildingLeaderType;
/**
* 中心点位经度
*/
@ -156,4 +166,5 @@ public class IcBuildingDTO implements Serializable {
*/
private Integer realPerson;
}

40
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java

@ -1,5 +1,6 @@
package com.epmet.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import com.epmet.commons.tools.constant.NumConstant;
import lombok.Data;
@ -183,4 +184,43 @@ public class ImportGeneralDTO implements Serializable {
*/
private Boolean buildingUpdateStatus = false;
private Boolean neighborHoodUpdateStatus = false;
/**
* 烟台需求自然村/小区
*/
private String viliageType;
/**
* 烟台需求自然村/小区
*/
private String viliageTypeName;
/**
* 烟台需求面积
*/
private String area;
/**
* 烟台需求开放类型
*/
private String openType;
/**
* 烟台需求开放类型
*/
private String openTypeName;
/**
* 烟台需求建筑年代
*/
private String buildYear;
/**
* 所在楼层
*/
private String floor;
private String buildingLeaderIdCard;
private String buildingLeaderType;
private String buildingLeaderTypeNum;
}

4
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcBulidingAddFormDTO.java

@ -150,5 +150,9 @@ public class IcBulidingAddFormDTO implements Serializable {
*/
private Integer realPerson;
private String buildingLeaderType;
private String buildingLeaderIdCard;
}

7
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CommunityBuildingManagerDTO.java

@ -60,6 +60,7 @@ public class CommunityBuildingManagerDTO implements Serializable {
*/
@NotBlank(message ="类型不能为空" ,groups = {AddShowGroup.class,UpdateShowGroup.class})
private String type;
private String typeName;
/**
* 所属区县id取名字关联customer_agency
@ -84,6 +85,7 @@ public class CommunityBuildingManagerDTO implements Serializable {
*/
@NotBlank(message ="所属网格不能为空" ,groups = {AddShowGroup.class,UpdateShowGroup.class})
private String gridId;
private String gridName;
/**
* 网格的全路径包含网格id
@ -95,16 +97,19 @@ public class CommunityBuildingManagerDTO implements Serializable {
*/
@NotBlank(message ="所属小区不能为空" ,groups = {AddShowGroup.class,UpdateShowGroup.class})
private String viliageId;
private String viliageName;
/**
* 所属楼栋id
*/
@NotBlank(message ="楼栋不能为空" ,groups = {AddShowGroup.class,UpdateShowGroup.class})
private String buildingId;
private String buildingName;
/**
* 所属单元id; 单元长时必填此列
* 所属单元id
*/
private String unitId;
private String unitName;
}

12
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcBulidingDetailDTO.java

@ -121,4 +121,16 @@ public class IcBulidingDetailDTO implements Serializable {
*/
private Integer realPerson;
/**
* 烟台需求楼长身份证号
*/
private String buildingLeaderIdCard;
/**
* 烟台需求类型0楼长1单元长
*/
private String buildingLeaderType;
private String buildingLeaderTypeName;
}

4
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcHouseListResultDTO.java

@ -89,5 +89,9 @@ public class IcHouseListResultDTO implements Serializable {
*/
private String houseCode;
private String area;
private String floor;
}

25
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CommunityBuildingManagerController.java

@ -10,20 +10,26 @@ import com.alibaba.fastjson.JSON;
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.ServiceConstant;
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.feign.ResultDataResolver;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.FileUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.poi.excel.handler.FreezeAndFilter;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.constants.ImportTaskConstants;
import com.epmet.dto.form.yt.CommunityBuildingManagerPageFormDTO;
import com.epmet.dto.result.CommunityBuildingManagerDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.dto.result.yt.CommunityBuildingManagerResultDTO;
import com.epmet.service.CommunityBuildingManagerService;
import com.epmet.utils.ImportTaskUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.poi.ss.usermodel.IndexedColors;
@ -36,12 +42,15 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.net.URLEncoder;
import java.nio.file.Path;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/**
@ -84,7 +93,7 @@ public class CommunityBuildingManagerController implements ResultDataResolver {
/**
* 新增楼长/单元长
* todo: 同步到具体的楼栋
* 同步到具体的楼栋
* @param dto
* @return
*/
@ -103,7 +112,7 @@ public class CommunityBuildingManagerController implements ResultDataResolver {
/**
* 编辑楼长/单元长
* todo: 同步到具体的楼栋
* 同步到具体的楼栋
* @param dto
* @return
*/
@ -121,7 +130,7 @@ public class CommunityBuildingManagerController implements ResultDataResolver {
/**
* 批量删除楼长/单元长
* todo: 同时清空楼栋表里的信息
* 同时清空楼栋表里的信息
* @param ids
* @return
*/
@ -215,9 +224,11 @@ public class CommunityBuildingManagerController implements ResultDataResolver {
* @return
*/
@PostMapping("import")
public Result importExcel(@RequestPart("file") MultipartFile file) {
return new Result();
/*// 1.暂存文件
public Result importExcel(@LoginUser TokenDto tokenDto,@RequestPart("file") MultipartFile file) {
// 只有社区级账号可以导入
communityBuildingManagerService.checkImportPermission(tokenDto.getCustomerId(),tokenDto.getUserId());
// 1.暂存文件
String originalFilename = file.getOriginalFilename();
String extName = originalFilename.substring(originalFilename.lastIndexOf("."));
@ -255,7 +266,7 @@ public class CommunityBuildingManagerController implements ResultDataResolver {
// 3.执行导入
communityBuildingManagerService.execAsyncExcelImport(fileSavePath, rstData.getTaskId());
return new Result();*/
return new Result();
}

65
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java

@ -5,27 +5,40 @@ package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.annotation.RequirePermission;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.enums.RequirePermissionEnum;
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.feign.ResultDataResolver;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.EpmetRequestHolder;
import com.epmet.commons.tools.utils.FileUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.constants.ImportTaskConstants;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.remote.EpmetUserRemoteService;
import com.epmet.service.StaffService;
import com.epmet.utils.ImportTaskUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
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.HttpServletResponse;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.nio.file.Path;
import java.util.List;
import java.util.UUID;
/**
* 组织结构-工作人员
@ -35,9 +48,11 @@ import java.util.List;
@Slf4j
@RestController
@RequestMapping("staff")
public class StaffController {
public class StaffController implements ResultDataResolver {
@Autowired
private StaffService staffService;
@Autowired
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
/**
* 组织首页-工作人员列表
* @param fromDTO
@ -233,6 +248,54 @@ public class StaffController {
return staffService.addStaffV2(fromDTO);
}
@PostMapping("staffimport")
public Result buildingImportExcel(@RequestParam("file") MultipartFile file,@RequestParam("orgType") String orgType,@RequestParam("orgId") String orgId){
String userId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID);
// 1.暂存文件
String originalFilename = file.getOriginalFilename();
String extName = originalFilename.substring(originalFilename.lastIndexOf("."));
Path fileSavePath;
try {
Path importPath = FileUtils.getAndCreateDirUnderEpmetFilesDir("staff", "import");
fileSavePath = importPath.resolve(UUID.randomUUID().toString().concat(extName));
} catch (IOException e) {
String errorMsg = ExceptionUtils.getErrorStackTrace(e);
log.error("【核酸检测导入】创建临时存储文件失败:{}", errorMsg);
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "文件上传失败", "文件上传失败");
}
InputStream is = null;
FileOutputStream os = null;
try {
is = file.getInputStream();
os = new FileOutputStream(fileSavePath.toString());
IOUtils.copy(is, os);
} catch (Exception e) {
log.error("method exception", e);
} finally {
org.apache.poi.util.IOUtils.closeQuietly(is);
org.apache.poi.util.IOUtils.closeQuietly(os);
}
// 2.生成导入任务记录
ImportTaskCommonResultDTO rstData = getResultDataOrThrowsException(
ImportTaskUtils.createImportTask(originalFilename, ImportTaskConstants.BIZ_TYPE_CUSTOMER_STAFF),
ServiceConstant.EPMET_COMMON_SERVICE,
EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),
"excel导入客户信息错误",
"导入客户信息失败");
// 3.执行导入
staffService.execAsyncExcelImport(fileSavePath, rstData.getTaskId(),orgType,orgId);
return new Result();
}
/**
* 通讯录人员添加-平阴
* @author zhy

5
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CommunityBuildingManagerEntity.java

@ -1,5 +1,7 @@
package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
@ -21,6 +23,7 @@ public class CommunityBuildingManagerEntity extends BaseEpmetEntity {
/**
* 客户Id customer.id
*/
@TableField(fill = FieldFill.INSERT)
private String customerId;
/**
@ -79,7 +82,7 @@ public class CommunityBuildingManagerEntity extends BaseEpmetEntity {
private String buildingId;
/**
* 所属单元id; 单元长时必填此列
* 所属单元id
*/
private String unitId;

12
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/IcBuildingEntity.java

@ -92,6 +92,16 @@ public class IcBuildingEntity extends BaseEpmetEntity {
*/
private String buildingLeaderMobile;
/**
* 烟台需求楼长身份证号
*/
private String buildingLeaderIdCard;
/**
* 烟台需求类型0楼长1单元长
*/
private String buildingLeaderType;
/**
* 中心点位经度
*/
@ -122,4 +132,6 @@ public class IcBuildingEntity extends BaseEpmetEntity {
*/
private Integer realPerson;
}

75
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/CustomerStaffImportExcelData.java

@ -0,0 +1,75 @@
package com.epmet.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.util.Date;
/**
* 核酸检测信息导入excel数据
*/
@Data
public class CustomerStaffImportExcelData {
@NotBlank(message = "姓名为必填项")
@ExcelProperty("姓名※")
private String name;
@NotBlank(message = "手机号为必填项")
@ExcelProperty("联系电话※")
@Length(max = 15, message = "手机号长度不正确,应小于15位")
private String mobile;
@NotBlank(message = "身份证号为必填项")
@ExcelProperty("身份证号※")
@Length(max = 18, message = "证身份证号长度不正确,应小于18位")
private String idCard;
@ExcelProperty("村居委员职务")
private String viliagePosition;
@ExcelProperty("党组织职务")
private String partyPosition;
@NotBlank(message = "居住地址为必填项")
@ExcelProperty("居住地址※")
private String address;
@NotBlank(message = "文化程度为必填项")
@ExcelProperty("文化程度※")
private String cultureName;
@NotBlank(message = "性别为必填项")
@ExcelProperty("性别※")
private String genderName;
@NotBlank(message = "专兼职为必填项")
@ExcelProperty("专兼职※")
private String workTypeName;
@NotBlank(message = "工作职责为必填项")
@ExcelProperty("工作职责※")
private String duty;
@ExcelProperty("备注")
private String remark;
@Data
public static class RowRemarkMessage {
@ColumnWidth(60)
@ExcelProperty("姓名")
private String name;
@ColumnWidth(60)
@ExcelProperty("联系电话")
private String mobile;
@ColumnWidth(60)
@ExcelProperty("错误信息")
private String errorInfo;
}
}

6
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcBuildingExcel.java

@ -130,4 +130,10 @@ public class IcBuildingExcel extends ExcelVerifyInfo implements Serializable {
@Excel(name = "楼长电话")
private String buildingLeaderMobile;
@Excel(name = "楼长身份证号")
private String buildingLeaderIdCard;
@Excel(name = "楼长类型")
private String buildingLeaderType;
}

13
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcNeighborHoodExcel.java

@ -18,6 +18,7 @@
package com.epmet.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.epmet.util.ExcelVerifyInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
@ -108,6 +109,18 @@ public class IcNeighborHoodExcel extends ExcelVerifyInfo implements Serializable
@Length(max=50,message = "不能超过50个字")
private String neighborHoodName;
@Excel(name = "小区/自然村类型")
private String viliageTypeName;
@Excel(name = "面积")
private String area;
@Excel(name = "开放类型")
private String openTypeName;
@Excel(name = "建筑年代")
private String buildYear;
@Excel(name = "关联物业")
private String propertyName;

120
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/handler/CommunityBuildingManagerImportListener.java

@ -0,0 +1,120 @@
package com.epmet.excel.handler;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.ValidateException;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.ObjectUtil;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.result.CommunityBuildingManagerDTO;
import com.epmet.excel.yt.CommunityBuildingManagerImportExcelData;
import com.epmet.service.impl.CommunityBuildingManagerServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @Description
* @Author yzm
* @Date 2023/5/9 16:26
*/
@Slf4j
public class CommunityBuildingManagerImportListener implements ReadListener<CommunityBuildingManagerImportExcelData> {
// 最大条数阈值
public static final int MAX_THRESHOLD = 200;
private Map<String, String> gridMap;
private String customerId;
private String staffId;
private String agencyId;
private String districtId;
private String streetId;
private String rediPrex;
private CommunityBuildingManagerServiceImpl communityBuildingManagerService;
// 错误项列表
private List<CommunityBuildingManagerImportExcelData.ErrorRow> errorRows = new ArrayList<>();
// 要插入的数据
private List<CommunityBuildingManagerDTO> excelDataList = new ArrayList<>();
public CommunityBuildingManagerImportListener(Map<String, String> gridMap,String customerId, String staffId, String agencyId, String districtId, String streetId, String rediPrex, CommunityBuildingManagerServiceImpl communityBuildingManagerService) {
this.gridMap=gridMap;
this.customerId = customerId;
this.staffId = staffId;
this.agencyId=agencyId;
this.districtId=districtId;
this.streetId=streetId;
this.rediPrex=rediPrex;
this.communityBuildingManagerService = communityBuildingManagerService;
}
@Override
public void invoke(CommunityBuildingManagerImportExcelData data, AnalysisContext analysisContext) {
try {
// log.warn("有数据吗?"+JSON.toJSONString(data));
// 不能为空先校验数据
ValidatorUtils.validateEntity(data);
// 去除空格
ObjectUtil.objectToTrim(data);
CommunityBuildingManagerDTO communityBuildingManagerDTO = ConvertUtils.sourceToTarget(data, CommunityBuildingManagerDTO.class);
communityBuildingManagerDTO.setCustomerId(customerId);
communityBuildingManagerDTO.setCommunityId(agencyId);
communityBuildingManagerDTO.setType("单元长".equals(data.getTypeName()) ? NumConstant.ONE_STR : NumConstant.ZERO_STR);
excelDataList.add(communityBuildingManagerDTO);
if (excelDataList.size() == MAX_THRESHOLD) {
execPersist();
}
} catch (Exception e) {
String errorMsg = null;
if (e instanceof ValidateException) {
errorMsg = ((ValidateException) e).getMsg();
} else if (e instanceof EpmetException) {
errorMsg = ((EpmetException) e).getMsg();
} else {
errorMsg = "未知错误";
log.error("【楼长单元长ic_property_management导入】出错:{}", ExceptionUtils.getErrorStackTrace(e));
}
CommunityBuildingManagerImportExcelData.ErrorRow errorRow = ConvertUtils.sourceToTarget(data, CommunityBuildingManagerImportExcelData.ErrorRow.class);
errorRow.setErrorInfo(errorMsg);
errorRows.add(errorRow);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
// 最后几条达不到阈值,这里必须再调用一次
execPersist();
}
/**
* 执行持久化
*/
private void execPersist() {
try {
if (CollectionUtils.isNotEmpty(excelDataList)) {
communityBuildingManagerService.handleImportExcelData(gridMap,customerId,staffId,agencyId, districtId, streetId,rediPrex,excelDataList,this);
}
} finally {
excelDataList.clear();
}
}
/**
* 获取错误行
*
* @return
*/
public List<CommunityBuildingManagerImportExcelData.ErrorRow> getErrorRows() {
return errorRows;
}
}

202
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/handler/CustomerStaffImportListener.java

@ -0,0 +1,202 @@
package com.epmet.excel.handler;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
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.ValidateException;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.AddStaffV2FromDTO;
import com.epmet.excel.CustomerStaffImportExcelData;
import com.epmet.service.impl.StaffServiceImpl;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
/**
* 核酸检测excel导入监听器
*/
@Data
@Slf4j
public class CustomerStaffImportListener implements ReadListener<CustomerStaffImportExcelData> {
/**
* 最大条数阈值
*/
public static final int MAX_THRESHOLD = 200;
private String currentUserId;
private String currentCustomerId;
private String currentOrgType;
private String currentOrgId;
private CustomerStaffImportExcelData dataB;
/**
* 数据
*/
private List<AddStaffV2FromDTO> datas = new ArrayList<>();
/**
* 错误项列表
*/
private List<CustomerStaffImportExcelData.RowRemarkMessage> errorRows = new ArrayList<>();
/**
* 其他被标记出来的列表列表
*/
private List<CustomerStaffImportExcelData.RowRemarkMessage> otherRows = new ArrayList<>();
private StaffServiceImpl staffService;
public CustomerStaffImportListener(String currentUserId, String currentCustomerId, String currentOrgType,String currentOrgId,StaffServiceImpl staffService) {
this.currentUserId = currentUserId;
this.currentCustomerId = currentCustomerId;
this.staffService = staffService;
this.currentOrgType = currentOrgType;
this.currentOrgId = currentOrgId;
}
@Override
public void invoke(CustomerStaffImportExcelData data, AnalysisContext context) {
try {
dataB = data;
// 先校验数据
ValidatorUtils.validateEntity(data);
AddStaffV2FromDTO fromDTO = ConvertUtils.sourceToTarget(data, AddStaffV2FromDTO.class);
fromDTO.setCustomerId(currentCustomerId);
//因为添加的是工作人员,这里写死吧!
fromDTO.setApp("gov");
fromDTO.setClient("wxmp");
//当前登录用户
fromDTO.setCurrentUserId(currentUserId);
fromDTO.setOrgId(currentOrgId);
fromDTO.setOrgType(currentOrgType);
if (StringUtils.isNotBlank(data.getWorkTypeName())){
if (data.getWorkTypeName().equals("专职")){
fromDTO.setWorkType("fulltime");
}
if (data.getWorkTypeName().equals("兼职")){
fromDTO.setWorkType("parttime");
}
}
if (StringUtils.isNotBlank(data.getGenderName())){
if (data.getGenderName().equals("男")){
fromDTO.setGender(1);
}
if (data.getGenderName().equals("女")){
fromDTO.setGender(2);
}
if (data.getGenderName().equals("未知")){
fromDTO.setGender(0);
}
}
//0小学及文盲,1初中,2高中,3大专,4本科,5硕士,6博士,7中专
if (StringUtils.isNotBlank(data.getCultureName())){
if (data.getCultureName().equals("小学及文盲")){
fromDTO.setCulture("0");
}
if (data.getCultureName().equals("初中")){
fromDTO.setCulture("1");
}
if (data.getCultureName().equals("高中")){
fromDTO.setCulture("2");
}
if (data.getCultureName().equals("大专")){
fromDTO.setCulture("3");
}
if (data.getCultureName().equals("本科")){
fromDTO.setCulture("4");
}
if (data.getCultureName().equals("硕士")){
fromDTO.setCulture("5");
}
if (data.getCultureName().equals("博士")){
fromDTO.setCulture("6");
}
}
datas.add(fromDTO);
if (datas.size() == MAX_THRESHOLD) {
execPersist();
}
} catch (Exception e) {
String errorMsg = null;
if (e instanceof ValidateException) {
errorMsg = ((ValidateException) e).getMsg();
} else {
log.error("【客户信息导入】出错:{}", e.getStackTrace());
errorMsg = ((EpmetException)e).getInternalMsg();
log.error("【客户信息导入】出错:{}", ExceptionUtils.getErrorStackTrace(e));
}
CustomerStaffImportExcelData.RowRemarkMessage errorRow = new CustomerStaffImportExcelData.RowRemarkMessage();
errorRow.setErrorInfo(errorMsg);
errorRow.setName(data.getName());
errorRow.setMobile(data.getMobile());
errorRows.add(errorRow);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
// 最后几条达不到阈值,这里必须再调用一次
try {
execPersist();
}catch (Exception e) {
String errorMsg = null;
if (e instanceof ValidateException) {
errorMsg = ((ValidateException) e).getMsg();
} else {
log.error("【客户信息导入】出错:{}", e.getStackTrace());
errorMsg = ((EpmetException)e).getInternalMsg();
log.error("【客户信息导入】出错:{}", ExceptionUtils.getErrorStackTrace(e));
}
CustomerStaffImportExcelData.RowRemarkMessage errorRow = new CustomerStaffImportExcelData.RowRemarkMessage();
errorRow.setErrorInfo(errorMsg);
errorRow.setName(dataB.getName());
errorRow.setMobile(dataB.getMobile());
errorRows.add(errorRow);
}
}
/**
* 执行持久化
*/
private void execPersist() {
try {
if (datas != null && datas.size() > 0) {
// icNatService.batchPersist(datas, this);
staffService.exportAdd(datas,this);
}
}finally {
datas.clear();
}
}
/**
* 获取错误行
* @return
*/
public List<CustomerStaffImportExcelData.RowRemarkMessage> getErrorRows() {
return errorRows;
}
}

116
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/yt/CommunityBuildingManagerImportExcelData.java

@ -0,0 +1,116 @@
package com.epmet.excel.yt;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
/**
* @Description
* @Author yzm
* @Date 2023/5/9 16:13
*/
@Data
public class CommunityBuildingManagerImportExcelData {
/**
* 姓名
*/
@ExcelProperty(value = "*姓名")
@Length(max = 50, message = "姓名最多输入50字")
@NotBlank(message = "姓名不能为空")
private String name;
/**
* 联系电话
*/
@ExcelProperty(value = "*联系电话")
@Length(max = 50, message = "联系电话最多输入50字")
@NotBlank(message = "联系电话不能为空")
private String phone;
/**
* 身份证号
*/
@ExcelProperty(value = "*身份证号")
@Length(max = 50, message = "身份证号最多输入50字")
@NotBlank(message = "身份证号不能为空")
private String idCard;
/**
* 类型0楼长1单元长
*/
@ExcelProperty(value = "*类型")
@NotBlank(message = "类型不能为空")
private String typeName;
@ExcelProperty(value = "*所属网格")
@NotBlank(message = "所属网格不能为空")
private String gridName;
@ExcelProperty(value = "*所属小区")
@NotBlank(message = "所属小区不能为空")
private String viliageName;
@ExcelProperty(value = "*楼栋")
@NotBlank(message = "楼栋不能为空")
private String buildingName;
@ExcelProperty(value = "单元")
private String unitName;
@Data
public static class ErrorRow {
/**
* 姓名
*/
@ExcelProperty(value = "*姓名")
@ColumnWidth(20)
private String name;
/**
* 联系电话
*/
@ExcelProperty(value = "*联系电话")
@ColumnWidth(20)
private String phone;
/**
* 身份证号
*/
@ExcelProperty(value = "*身份证号")
@ColumnWidth(25)
private String idCard;
/**
* 类型0楼长1单元长
*/
@ExcelProperty(value = "*类型")
@ColumnWidth(15)
private String typeName;
@ExcelProperty(value = "*所属网格")
@ColumnWidth(30)
private String gridName;
@ExcelProperty(value = "*所属小区")
@ColumnWidth(30)
private String viliageName;
@ExcelProperty(value = "*楼栋")
@ColumnWidth(20)
private String buildingName;
@ExcelProperty(value = "单元")
@ColumnWidth(20)
private String unitName;
@ColumnWidth(60)
@ExcelProperty("错误信息")
private String errorInfo;
}
}

6
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingInfoModel.java

@ -44,6 +44,12 @@ public class BuildingInfoModel {
@ExcelProperty(value = "楼长电话")
private String buildingLeaderMobile;
@ExcelProperty(value = "楼长身份证号")
private String buildingLeaderIdCard;
@ExcelProperty(value = "楼长类型")
private String buildingLeaderType;
@ExcelProperty(value = "排序")
private BigDecimal sort;

6
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseInfoModel.java

@ -37,6 +37,12 @@ public class HouseInfoModel {
@ExcelProperty(value = "房屋类型")
private String houseType;
@ExcelProperty(value = "所在楼层")
private String floor;
@ExcelProperty(value = "面积(平方米)")
private String area;
@ExcelProperty(value = "房屋用途")
private String purpose;

12
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodInfoModel.java

@ -21,6 +21,18 @@ public class NeighborHoodInfoModel {
@ExcelProperty(value = "小区名称")
private String neighborHoodName;
@ExcelProperty(value = "小区/自然村类型")
private String viliageTypeName;
@ExcelProperty(value = "面积")
private String area;
@ExcelProperty(value = "开放类型")
private String openTypeName;
@ExcelProperty(value = "建筑年代")
private String buildYear;
@ExcelProperty(value = "关联物业")
private String propertyName;

14
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CommunityBuildingManagerService.java

@ -40,7 +40,7 @@ public interface CommunityBuildingManagerService extends BaseService<CommunityBu
/**
* 新增楼长/单元长
* todo: 同步到具体的楼栋表
* 同步到具体的楼栋表
*
* @param dto
* @return
@ -49,7 +49,7 @@ public interface CommunityBuildingManagerService extends BaseService<CommunityBu
/**
* 编辑楼长/单元长
* todo: 同步到具体的楼栋
* 同步到具体的楼栋
*
* @param dto
* @return
@ -58,7 +58,7 @@ public interface CommunityBuildingManagerService extends BaseService<CommunityBu
/**
* 批量删除楼长/单元长
* todo: 同时清空楼栋表里的信息
* 同时清空楼栋表里的信息
*
* @param ids
* @return
@ -66,4 +66,12 @@ public interface CommunityBuildingManagerService extends BaseService<CommunityBu
void delete(List<String> ids);
void execAsyncExcelImport(Path fileSavePath, String taskId);
/**
* 楼长单元长功能只能社区级工作人员导入
*
* @param customerId
* @param userId
*/
void checkImportPermission(String customerId, String userId);
}

6
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcBuildingService.java

@ -133,4 +133,10 @@ public interface IcBuildingService extends BaseService<IcBuildingEntity> {
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.IcBuildingDTO>
*/
Result<IcBulidingDetailDTO> getBuildingDetail(String buildingId);
/**
* 更新ic_building的楼长信息那4列building_leader_namebuilding_leader_mobilebuilding_leader_id_cardbuilding_leader_type
* @param updateList
*/
void updateBuildingLeader(List<IcBuildingDTO> updateList);
}

4
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java

@ -4,7 +4,9 @@ import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import org.springframework.web.bind.annotation.RequestParam;
import java.nio.file.Path;
import java.util.List;
/**
@ -154,4 +156,6 @@ public interface StaffService {
* @Date 2021/9/8 16:57
*/
List<StaffOrgListResultDTO> staffOrgList(TokenDto tokenDto);
void execAsyncExcelImport(Path fileSavePath, String taskId,String orgType, String orgId);
}

402
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CommunityBuildingManagerServiceImpl.java

@ -1,38 +1,67 @@
package com.epmet.service.impl;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
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.OptionResultDTO;
import com.epmet.commons.tools.enums.OrgLevelEnum;
import com.epmet.commons.tools.enums.OrgTypeEnum;
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.page.PageData;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.redis.common.CustomerOrgRedis;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.EpmetRequestHolder;
import com.epmet.commons.tools.utils.PidUtils;
import com.epmet.commons.tools.utils.SpringContextUtils;
import com.epmet.commons.tools.utils.*;
import com.epmet.constants.ImportTaskConstants;
import com.epmet.dao.CommunityBuildingManagerDao;
import com.epmet.dao.IcBuildingDao;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.CustomerGridDTO;
import com.epmet.dto.IcBuildingDTO;
import com.epmet.dto.form.ImportTaskCommonFormDTO;
import com.epmet.dto.form.NeighborHoodOptionFormDTO;
import com.epmet.dto.form.yt.CommunityBuildingManagerPageFormDTO;
import com.epmet.dto.result.CommunityBuildingManagerDTO;
import com.epmet.dto.result.UploadImgResultDTO;
import com.epmet.dto.result.yt.CommunityBuildingManagerResultDTO;
import com.epmet.entity.CommunityBuildingManagerEntity;
import com.epmet.service.CommunityBuildingManagerService;
import com.epmet.service.CustomerGridService;
import com.epmet.entity.IcBuildingEntity;
import com.epmet.excel.handler.CommunityBuildingManagerImportListener;
import com.epmet.excel.yt.CommunityBuildingManagerImportExcelData;
import com.epmet.excel.yt.IcPropertyManagementImportExcelData;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.feign.OssFeignClient;
import com.epmet.service.*;
import com.epmet.utils.ImportTaskUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.entity.ContentType;
import org.apache.poi.util.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
* 楼长单元长信息表烟台
@ -43,7 +72,17 @@ import java.util.List;
@Slf4j
@Service
public class CommunityBuildingManagerServiceImpl extends BaseServiceImpl<CommunityBuildingManagerDao, CommunityBuildingManagerEntity> implements CommunityBuildingManagerService {
@Autowired
private IcBuildingDao icBuildingDao;
@Autowired
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient;
@Autowired
private OssFeignClient ossFeignClient;
@Autowired
private CustomerGridService customerGridService;
@Autowired
private RedisUtils redisUtils;
/**
* 列表分页查询
*
@ -105,7 +144,7 @@ public class CommunityBuildingManagerServiceImpl extends BaseServiceImpl<Communi
/**
* 新增楼长/单元长
* todo: 同步到具体的楼栋表
* 同步到具体的楼栋表
*
* @param addFormDto
* @return
@ -119,6 +158,16 @@ public class CommunityBuildingManagerServiceImpl extends BaseServiceImpl<Communi
CustomerGridDTO gridDTO = SpringContextUtils.getBean(CustomerGridService.class).get(addFormDto.getGridId());
entity.setOrgIdPath(PidUtils.convertPid2OrgIdPath(gridDTO.getId(), gridDTO.getPids()));
insert(entity);
// 同步更新至ic_building
LambdaUpdateWrapper<IcBuildingEntity> buildingUpdate = new LambdaUpdateWrapper<>();
buildingUpdate.eq(IcBuildingEntity::getId, entity.getBuildingId())
.set(IcBuildingEntity::getBuildingLeaderName, entity.getName())
.set(IcBuildingEntity::getBuildingLeaderMobile, entity.getPhone())
.set(IcBuildingEntity::getBuildingLeaderIdCard, entity.getIdCard())
.set(IcBuildingEntity::getBuildingLeaderType, entity.getType())
.set(IcBuildingEntity::getUpdatedBy, EpmetRequestHolder.getLoginUserId())
.set(IcBuildingEntity::getUpdatedTime, new Date());
icBuildingDao.update(null, buildingUpdate);
}
private void checkUnqiue(String type, String buildingId, String unitId, String id) {
@ -136,7 +185,7 @@ public class CommunityBuildingManagerServiceImpl extends BaseServiceImpl<Communi
/**
* 编辑楼长/单元长
* todo: 同步到具体的楼栋
* 同步到具体的楼栋
*
* @param updateFormDto
* @return
@ -149,11 +198,21 @@ public class CommunityBuildingManagerServiceImpl extends BaseServiceImpl<Communi
CustomerGridDTO gridDTO = SpringContextUtils.getBean(CustomerGridService.class).get(updateFormDto.getGridId());
entity.setOrgIdPath(PidUtils.convertPid2OrgIdPath(gridDTO.getId(), gridDTO.getPids()));
updateById(entity);
// 同步更新至ic_building
LambdaUpdateWrapper<IcBuildingEntity> buildingUpdate = new LambdaUpdateWrapper<>();
buildingUpdate.eq(IcBuildingEntity::getId, updateFormDto.getBuildingId())
.set(IcBuildingEntity::getBuildingLeaderName, updateFormDto.getName())
.set(IcBuildingEntity::getBuildingLeaderMobile, updateFormDto.getPhone())
.set(IcBuildingEntity::getBuildingLeaderIdCard, updateFormDto.getIdCard())
.set(IcBuildingEntity::getBuildingLeaderType, updateFormDto.getType())
.set(IcBuildingEntity::getUpdatedBy, EpmetRequestHolder.getLoginUserId())
.set(IcBuildingEntity::getUpdatedTime, new Date());
icBuildingDao.update(null, buildingUpdate);
}
/**
* 批量删除楼长/单元长
* todo: 同时清空楼栋表里的信息
* 同时清空楼栋表里的信息
*
* @param ids
* @return
@ -161,18 +220,40 @@ public class CommunityBuildingManagerServiceImpl extends BaseServiceImpl<Communi
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(List<String> ids) {
Date now=new Date();
ids.forEach(id->{
LambdaUpdateWrapper<CommunityBuildingManagerEntity> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(CommunityBuildingManagerEntity::getId, id)
.set(CommunityBuildingManagerEntity::getDelFlag, NumConstant.ONE_STR)
.set(CommunityBuildingManagerEntity::getUpdatedBy, EpmetRequestHolder.getLoginUserId())
.set(CommunityBuildingManagerEntity::getUpdatedTime, now);
baseDao.update(null, updateWrapper);
// todo
Date now = new Date();
ids.forEach(id -> {
CommunityBuildingManagerEntity origin = baseDao.selectById(id);
if (null != origin) {
LambdaUpdateWrapper<CommunityBuildingManagerEntity> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(CommunityBuildingManagerEntity::getId, id)
.set(CommunityBuildingManagerEntity::getDelFlag, NumConstant.ONE_STR)
.set(CommunityBuildingManagerEntity::getUpdatedBy, EpmetRequestHolder.getLoginUserId())
.set(CommunityBuildingManagerEntity::getUpdatedTime, now);
baseDao.update(null, updateWrapper);
if (StringUtils.isNotBlank(origin.getBuildingId())) {
// 清空楼栋表的楼长4列信息
LambdaUpdateWrapper<IcBuildingEntity> buildingUpdate = new LambdaUpdateWrapper<>();
buildingUpdate.eq(IcBuildingEntity::getId, origin.getBuildingId())
.set(IcBuildingEntity::getBuildingLeaderName, StrConstant.EPMETY_STR)
.set(IcBuildingEntity::getBuildingLeaderMobile, StrConstant.EPMETY_STR)
.set(IcBuildingEntity::getBuildingLeaderIdCard, StrConstant.EPMETY_STR)
.set(IcBuildingEntity::getBuildingLeaderType, StrConstant.EPMETY_STR)
.set(IcBuildingEntity::getUpdatedBy, EpmetRequestHolder.getLoginUserId())
.set(IcBuildingEntity::getUpdatedTime, now);
icBuildingDao.update(null, buildingUpdate);
}
}
});
}
@Override
public void checkImportPermission(String customerId, String userId) {
CustomerStaffInfoCacheResult result = CustomerStaffRedis.getStaffInfo(customerId, userId);
CustomerAgencyDTO agencyDTO = SpringContextUtils.getBean(CustomerAgencyService.class).get(result.getAgencyId());
if (!OrgLevelEnum.COMMUNITY.getCode().equals(agencyDTO.getLevel())) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "楼长单元长导入功能只有社区账号才可以正常导入", "请使用社区级账号导入excel");
}
}
/**
* 执行Excel导入
@ -183,8 +264,283 @@ public class CommunityBuildingManagerServiceImpl extends BaseServiceImpl<Communi
@Async
@Override
public void execAsyncExcelImport(Path filePath, String importTaskId) {
// todo
return;
String staffId = EpmetRequestHolder.getLoginUserId();
String customerId = EpmetRequestHolder.getLoginUserCustomerId();
// 当前登录用户缓存信息
CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(customerId, staffId);
// 当前登录用户所属组织信息
CustomerAgencyDTO community = SpringContextUtils.getBean(CustomerAgencyService.class).get(staffInfoCacheResult.getAgencyId());
String streetId = community.getPid();
// 社区上级街道信息
CustomerAgencyDTO street = SpringContextUtils.getBean(CustomerAgencyService.class).get(streetId);
String districtId = street.getPid();
//查询当前社区下的网格列表
List<OptionResultDTO> gridList=customerGridService.getGridOption(staffInfoCacheResult.getAgencyId(), "addorupdate");
Map<String, String> gridMap = gridList.stream().collect(Collectors.toMap(OptionResultDTO::getLabel, OptionResultDTO::getValue));
String uuid = IdWorker.getIdStr();
String redisKey = "community_building_manager_import".concat(StrConstant.COLON).concat(uuid);
try {
CommunityBuildingManagerImportListener listener = new CommunityBuildingManagerImportListener(gridMap,customerId,staffId,staffInfoCacheResult.getAgencyId(),districtId,streetId,redisKey,
SpringContextUtils.getBean(CommunityBuildingManagerServiceImpl.class));
EasyExcel.read(filePath.toFile(), CommunityBuildingManagerImportExcelData.class, listener).headRowNumber(1).sheet(0).doRead();
String errorDesFileUrl = null;
List<CommunityBuildingManagerImportExcelData.ErrorRow> errorRows = listener.getErrorRows();
boolean failed = errorRows.size() > 0;
// 合并到一起写入
// errorRows.addAll(otherRows);
// 生成并上传描述文件
OutputStream os = null;
FileItem fileItem = null;
if (errorRows.size() > 0) {
try {
// 文件生成
Path errorDescDir = FileUtils.getAndCreateDirUnderEpmetFilesDir(ImportTaskConstants.COMMUNITY_BUILDING_MANAGER, "import", "error_des");
String fileName = UUID.randomUUID().toString().concat(".xlsx");
fileItem = new DiskFileItemFactory(DiskFileItemFactory.DEFAULT_SIZE_THRESHOLD, errorDescDir.toFile())
.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), false, fileName);
os = fileItem.getOutputStream();
EasyExcel.write(os, IcPropertyManagementImportExcelData.ErrorRow.class).sheet("信息列表").doWrite(errorRows);
// 文件上传oss
Result<UploadImgResultDTO> errorDesFileUploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem));
if (errorDesFileUploadResult.success()) {
errorDesFileUrl = errorDesFileUploadResult.getData().getUrl();
}
} finally {
IOUtils.closeQuietly(os);
if (!fileItem.isInMemory()) {
try {
fileItem.delete();
} catch (Exception e) {
log.error("【楼长单元长表community_building_manager】删除错误描述临时文件失败:{}", ExceptionUtils.getErrorStackTrace(e));
}
}
}
}
Result result = ImportTaskUtils.finishImportTask(
importTaskId,
failed ? ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL : ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS,
errorDesFileUrl,
"");
if (!result.success()) {
log.error("【楼长单元长表community_building_manager】finishImportTask失败");
}
} catch (Exception e) {
String errorMsg = ExceptionUtils.getErrorStackTrace(e);
log.error("【楼长单元长表community_building_manager】出错:{}", errorMsg);
ImportTaskCommonFormDTO importFinishTaskForm = new ImportTaskCommonFormDTO();
importFinishTaskForm.setTaskId(importTaskId);
importFinishTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL);
importFinishTaskForm.setOperatorId(staffId);
importFinishTaskForm.setResultDesc("物业管理表导入失败:系统异常,请查看系统日志");
Result result = commonServiceOpenFeignClient.finishImportTask(importFinishTaskForm);
if (!result.success()) {
log.error("【楼长单元长表community_building_manager】导入记录状态修改为'完成'失败");
}
} finally {
// 删除临时文件
if (Files.exists(filePath)) {
try {
Files.delete(filePath);
} catch (IOException e) {
e.printStackTrace();
}
}
//删除小区缓存、楼栋缓存、单元缓存
redisUtils.deleteByPrex(redisKey+"*");
}
}
/**
* @param customerId
* @param staffId
* @param agencyId
* @param rediPrex
* @param excelDataList
* @param listener
*/
public void handleImportExcelData(Map<String, String> gridMap,
String customerId,
String staffId,
String agencyId,
String districtId,
String streetId,
String rediPrex,
List<CommunityBuildingManagerDTO> excelDataList,
CommunityBuildingManagerImportListener listener) {
List<CommunityBuildingManagerEntity> insertList = new ArrayList<>();
List<CommunityBuildingManagerEntity> updateList = new ArrayList<>();
List<IcBuildingDTO> buildingUpdateList=new ArrayList<>();
for (CommunityBuildingManagerDTO dto : excelDataList) {
try {
CommunityBuildingManagerEntity entity = ConvertUtils.sourceToTarget(dto, CommunityBuildingManagerEntity.class);
entity.setDistrictId(districtId);
entity.setStreetId(streetId);
// 所属网格
if (MapUtils.isEmpty(gridMap) || !gridMap.containsKey(dto.getGridName()) || StringUtils.isBlank(gridMap.get(dto.getGridName()))) {
CommunityBuildingManagerImportExcelData.ErrorRow errorRow = ConvertUtils.sourceToTarget(dto, CommunityBuildingManagerImportExcelData.ErrorRow.class);
errorRow.setErrorInfo("网格不存在");
listener.getErrorRows().add(errorRow);
continue;
}
String gridId = gridMap.get(dto.getGridName());
entity.setGridId(gridId);
entity.setOrgIdPath(CustomerOrgRedis.getOrgIdPath(gridId, OrgTypeEnum.GRID.getCode()));
// 查询当前网格下的小区
// 所属小区
Map<String, String> viliageMap =queryViliageList(customerId,staffId,agencyId,gridId,rediPrex);
if (MapUtils.isEmpty(viliageMap) || !viliageMap.containsKey(dto.getViliageName()) || StringUtils.isBlank(viliageMap.get(dto.getViliageName()))) {
CommunityBuildingManagerImportExcelData.ErrorRow errorRow = ConvertUtils.sourceToTarget(dto, CommunityBuildingManagerImportExcelData.ErrorRow.class);
errorRow.setErrorInfo("小区不存在");
listener.getErrorRows().add(errorRow);
continue;
}
String viliageId = viliageMap.get(dto.getViliageName());
entity.setViliageId(viliageId);
// 查询当前小区下的楼栋
// 所属楼栋
// List<OptionResultDTO> buildingList=queryBuildingList(viliageId,rediPrex);
// Map<String, String> buildingMap = buildingList.stream().collect(Collectors.toMap(OptionResultDTO::getLabel, OptionResultDTO::getValue));
Map<String, String> buildingMap =queryBuildingList(viliageId,rediPrex);;
if (MapUtils.isEmpty(buildingMap) || !buildingMap.containsKey(dto.getBuildingName()) || StringUtils.isBlank(buildingMap.get(dto.getBuildingName()))) {
CommunityBuildingManagerImportExcelData.ErrorRow errorRow = ConvertUtils.sourceToTarget(dto, CommunityBuildingManagerImportExcelData.ErrorRow.class);
errorRow.setErrorInfo("楼栋不存在");
listener.getErrorRows().add(errorRow);
continue;
}
String buildingId = buildingMap.get(dto.getBuildingName());
entity.setBuildingId(buildingId);
// 所属单元
String unitId = "";
if (StringUtils.isNotBlank(dto.getUnitName())) {
// 查询楼栋下的单元列表
// List<OptionResultDTO> unitList=queryUnitList(buildingId,rediPrex);
// Map<String, String> unitMap = unitList.stream().collect(Collectors.toMap(OptionResultDTO::getLabel, OptionResultDTO::getValue));
Map<String, String> unitMap = queryUnitList(buildingId, rediPrex);
if (MapUtils.isEmpty(unitMap) || !unitMap.containsKey(dto.getUnitName()) || StringUtils.isBlank(unitMap.get(dto.getUnitName()))) {
CommunityBuildingManagerImportExcelData.ErrorRow errorRow = ConvertUtils.sourceToTarget(dto, CommunityBuildingManagerImportExcelData.ErrorRow.class);
errorRow.setErrorInfo("单元不存在");
listener.getErrorRows().add(errorRow);
continue;
}
unitId = unitMap.get(dto.getUnitName());
}
entity.setUnitId(unitId);
LambdaQueryWrapper<CommunityBuildingManagerEntity> countQuery = new LambdaQueryWrapper<>();
countQuery.eq(CommunityBuildingManagerEntity::getType, entity.getType())
.eq(CommunityBuildingManagerEntity::getBuildingId, buildingId)
.eq(StringUtils.isNotBlank(unitId), CommunityBuildingManagerEntity::getUnitId, unitId)
.ne(StringUtils.isNotBlank(entity.getId()),CommunityBuildingManagerEntity::getId, entity.getId());
CommunityBuildingManagerEntity origin = baseDao.selectOne(countQuery);
if (null == origin) {
insertList.add(entity);
} else {
entity.setId(origin.getId());
updateList.add(entity);
}
// 同步更新至ic_building
IcBuildingDTO icBuildingDTO = new IcBuildingDTO();
icBuildingDTO.setId(entity.getBuildingId());
icBuildingDTO.setBuildingLeaderMobile(entity.getPhone());
icBuildingDTO.setBuildingLeaderIdCard(entity.getIdCard());
icBuildingDTO.setBuildingLeaderType(entity.getType());
icBuildingDTO.setBuildingLeaderName(entity.getName());
icBuildingDTO.setUpdatedBy(staffId);
icBuildingDTO.setUpdatedTime(new Date());
buildingUpdateList.add(icBuildingDTO);
} catch (Exception e) {
CommunityBuildingManagerImportExcelData.ErrorRow errorRow = ConvertUtils.sourceToTarget(dto, CommunityBuildingManagerImportExcelData.ErrorRow.class);
errorRow.setErrorInfo("数据处理异常");
listener.getErrorRows().add(errorRow);
}
}
// 同步到ic_building
if(!CollectionUtils.isEmpty(insertList)){
this.insertBatch(insertList);
}
if(!CollectionUtils.isEmpty(updateList)){
this.updateBatchById(updateList);
}
if(!CollectionUtils.isEmpty(buildingUpdateList)){
SpringContextUtils.getBean(IcBuildingService.class).updateBuildingLeader(buildingUpdateList);
}
}
private Map<String, String> queryViliageList(String customerId, String staffId, String agencyId, String gridId, String rediPrex) {
String redisKey = rediPrex.concat(StrConstant.COLON).concat("viliage_list").concat(StrConstant.COLON).concat(gridId);
Map<String, Object> viliageMap = redisUtils.hGetAll(redisKey);
if (MapUtils.isEmpty(viliageMap)) {
NeighborHoodOptionFormDTO neighborHoodOptionFormDTO = new NeighborHoodOptionFormDTO();
neighborHoodOptionFormDTO.setCustomerId(customerId);
neighborHoodOptionFormDTO.setStaffId(staffId);
neighborHoodOptionFormDTO.setAgencyId(agencyId);
neighborHoodOptionFormDTO.setGridId(gridId);
List<OptionResultDTO> resultList = SpringContextUtils.getBean(IcNeighborHoodService.class).queryNeighborHoodOptions(neighborHoodOptionFormDTO);
viliageMap = resultList.stream().collect(Collectors.toMap(OptionResultDTO::getLabel, OptionResultDTO::getValue));
// 有效时间1小时
redisUtils.hMSet(redisKey, viliageMap, RedisUtils.HOUR_ONE_EXPIRE);
}
Map<String, String> resultMap = new HashMap<>();
viliageMap.forEach((k, v) ->
resultMap.put(k, (String) v)
);
return resultMap;
}
private Map<String, String> queryBuildingList(String viliageId, String rediPrex) {
String redisKey = rediPrex.concat(StrConstant.COLON).concat("building_List").concat(StrConstant.COLON).concat(viliageId);
Map<String, Object> buildingMap = redisUtils.hGetAll(redisKey);
if (MapUtils.isEmpty(buildingMap)) {
List<OptionResultDTO> resultList = SpringContextUtils.getBean(IcBuildingService.class).getBuildingOptions(viliageId);
buildingMap = resultList.stream().collect(Collectors.toMap(OptionResultDTO::getLabel, OptionResultDTO::getValue));
// 有效时间1小时
redisUtils.hMSet(redisKey, buildingMap, RedisUtils.HOUR_ONE_EXPIRE);
}
Map<String, String> resultMap = new HashMap<>();
buildingMap.forEach((k, v) ->
resultMap.put(k, (String) v)
);
return resultMap;
}
private Map<String, String> queryUnitList(String buildingId, String rediPrex) {
String redisKey = rediPrex.concat(StrConstant.COLON).concat("unit_List").concat(StrConstant.COLON).concat(buildingId);
Map<String, Object> unitMap = redisUtils.hGetAll(redisKey);
if (MapUtils.isEmpty(unitMap)) {
List<OptionResultDTO> resultList = SpringContextUtils.getBean(IcBuildingUnitService.class).getUnitOptions(buildingId);
unitMap = resultList.stream().collect(Collectors.toMap(OptionResultDTO::getLabel, OptionResultDTO::getValue));
// 有效时间1小时
redisUtils.hMSet(redisKey, unitMap, RedisUtils.HOUR_ONE_EXPIRE);
}
Map<String, String> resultMap = new HashMap<>();
unitMap.forEach((k, v) ->
resultMap.put(k, (String) v)
);
return resultMap;
}

20
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingServiceImpl.java

@ -21,6 +21,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
@ -197,4 +198,23 @@ public class IcBuildingServiceImpl extends BaseServiceImpl<IcBuildingDao, IcBuil
return new Result<IcBulidingDetailDTO>().ok(baseDao.getBuildingDetail(buildingId));
}
/**
* 更新ic_building的楼长信息那4列building_leader_namebuilding_leader_mobilebuilding_leader_id_cardbuilding_leader_type
*
* @param updateList
*/
@Override
public void updateBuildingLeader(List<IcBuildingDTO> updateList) {
updateList.forEach(dto -> {
LambdaUpdateWrapper<IcBuildingEntity> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IcBuildingEntity::getId, dto.getId())
.set(IcBuildingEntity::getBuildingLeaderName, dto.getBuildingLeaderName())
.set(IcBuildingEntity::getBuildingLeaderMobile, dto.getBuildingLeaderMobile())
.set(IcBuildingEntity::getBuildingLeaderIdCard, dto.getBuildingLeaderIdCard())
.set(IcBuildingEntity::getBuildingLeaderType, dto.getBuildingLeaderType())
.set(IcBuildingEntity::getUpdatedBy, dto.getUpdatedBy())
.set(null != dto.getUpdatedTime(), IcBuildingEntity::getUpdatedTime, dto.getUpdatedTime());
baseDao.update(null, updateWrapper);
});
}
}

127
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java

@ -128,6 +128,12 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
private IcHouseDao icHouseDao;
@Autowired
private RedisUtils redisUtils;
@Autowired
private CommunityBuildingManagerDao communityBuildingManagerDao;
@Autowired
private IcNeighborHoodDao neighborHoodDao;
@Autowired
private CustomerAgencyDao customerAgencyDao;
@Override
public PageData<IcNeighborHoodDTO> page(Map<String, Object> params) {
@ -642,8 +648,17 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
private String getBuildingId(String customerId, ImportGeneralDTO info) {
//根据小区ID和楼栋名获取楼栋信息
IcBuildingDTO building = icBuildingService.getBuildingInfo(info.getNeighborHoodId(), info.getBuildingName());
if (StringUtils.isNotBlank(info.getBuildingLeaderType())){
if (info.getBuildingLeaderType().equals("楼长")){
info.setBuildingLeaderTypeNum("0");
}
if (info.getBuildingLeaderType().equals("单元长")){
info.setBuildingLeaderTypeNum("1");
}
}
if (null != building) {
info.setBuildingExistStatus(true);
if (info.getBuildingUpdateStatus()){
if (info.getTotalUnitNum() < building.getTotalUnitNum()){
/**
@ -684,6 +699,61 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
}
icBuildingUnitService.insertBatch(unitList, NumConstant.ONE_HUNDRED);
}
LambdaQueryWrapper<CommunityBuildingManagerEntity> manager = new LambdaQueryWrapper<CommunityBuildingManagerEntity>().eq(CommunityBuildingManagerEntity::getBuildingId,info.getBuildingId());
CommunityBuildingManagerEntity communityBuildingManagerEntity = communityBuildingManagerDao.selectOne(manager);
if (StringUtils.isNotBlank(info.getBuildingLeaderTypeNum())&&
StringUtils.isNotBlank(info.getBuildingLeaderIdCard())&&
StringUtils.isNotBlank(info.getBuildingLeaderMobile())&&
StringUtils.isNotBlank(info.getBuildingLeaderName())){
if (communityBuildingManagerEntity!=null){
communityBuildingManagerEntity.setIdCard(info.getBuildingLeaderIdCard());
communityBuildingManagerEntity.setPhone(info.getBuildingLeaderMobile());
communityBuildingManagerEntity.setType(info.getBuildingLeaderTypeNum());
communityBuildingManagerEntity.setName(info.getBuildingLeaderName());
communityBuildingManagerDao.updateById(communityBuildingManagerEntity);
}else{
communityBuildingManagerEntity= new CommunityBuildingManagerEntity();
communityBuildingManagerEntity.setIdCard(info.getBuildingLeaderIdCard());
communityBuildingManagerEntity.setPhone(info.getBuildingLeaderMobile());
communityBuildingManagerEntity.setType(info.getBuildingLeaderTypeNum());
communityBuildingManagerEntity.setName(info.getBuildingLeaderName());
communityBuildingManagerEntity.setBuildingId(building.getId());
IcBuildingEntity buildingEntity = icBuildingDao.selectById(building.getId());
if (buildingEntity.getNeighborHoodId()!=null){
communityBuildingManagerEntity.setViliageId(buildingEntity.getNeighborHoodId());
IcNeighborHoodEntity neighborHood = neighborHoodDao.selectById(buildingEntity.getNeighborHoodId());
communityBuildingManagerEntity.setGridId(neighborHood.getGridId());
communityBuildingManagerEntity.setOrgIdPath(neighborHood.getAgencyPids()+":"+neighborHood.getAgencyId()+":"+neighborHood.getGridId());
List<String> agencyIds = new ArrayList<>(Arrays.asList(neighborHood.getAgencyPids().split(":")));
agencyIds.add(neighborHood.getAgencyId());
LambdaQueryWrapper<CustomerAgencyEntity> queryWrapper = new LambdaQueryWrapper<CustomerAgencyEntity>().in(CustomerAgencyEntity::getId,agencyIds);
List<CustomerAgencyEntity> customerAgencyEntities = customerAgencyDao.selectList(queryWrapper);
for (CustomerAgencyEntity customerAgencyEntity : customerAgencyEntities) {
if (customerAgencyEntity.getLevel().equals("community")){
communityBuildingManagerEntity.setCommunityId(customerAgencyEntity.getId());
}
if (customerAgencyEntity.getLevel().equals("street")){
communityBuildingManagerEntity.setStreetId(customerAgencyEntity.getId());
}
if (customerAgencyEntity.getLevel().equals("district")){
communityBuildingManagerEntity.setDistrictId(customerAgencyEntity.getId());
}
}
}
communityBuildingManagerDao.insert(communityBuildingManagerEntity);
}
}else{
if (communityBuildingManagerEntity!=null){
communityBuildingManagerDao.deleteById(communityBuildingManagerEntity);
}
}
}
return building.getId();
}
@ -699,6 +769,42 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
buildingEntity.setBuildingLeaderName(info.getBuildingLeaderName());
buildingEntity.setBuildingLeaderMobile(info.getBuildingLeaderMobile());
icBuildingService.insert(buildingEntity);
if (StringUtils.isNotBlank(info.getBuildingLeaderTypeNum())&&
StringUtils.isNotBlank(info.getBuildingLeaderIdCard())&&
StringUtils.isNotBlank(info.getBuildingLeaderMobile())&&
StringUtils.isNotBlank(info.getBuildingLeaderName())){
CommunityBuildingManagerEntity communityBuildingManagerEntity= new CommunityBuildingManagerEntity();
communityBuildingManagerEntity.setIdCard(info.getBuildingLeaderIdCard());
communityBuildingManagerEntity.setPhone(info.getBuildingLeaderMobile());
communityBuildingManagerEntity.setType(info.getBuildingLeaderTypeNum());
communityBuildingManagerEntity.setName(info.getBuildingLeaderName());
communityBuildingManagerEntity.setBuildingId(buildingEntity.getId());
communityBuildingManagerEntity.setViliageId(buildingEntity.getNeighborHoodId());
IcNeighborHoodEntity neighborHood = neighborHoodDao.selectById(buildingEntity.getNeighborHoodId());
communityBuildingManagerEntity.setGridId(neighborHood.getGridId());
communityBuildingManagerEntity.setOrgIdPath(neighborHood.getAgencyPids()+":"+neighborHood.getAgencyId()+":"+neighborHood.getGridId());
List<String> agencyIds = new ArrayList<>(Arrays.asList(neighborHood.getAgencyPids().split(":")));
agencyIds.add(neighborHood.getAgencyId());
LambdaQueryWrapper<CustomerAgencyEntity> queryWrapper = new LambdaQueryWrapper<CustomerAgencyEntity>().in(CustomerAgencyEntity::getId,agencyIds);
List<CustomerAgencyEntity> customerAgencyEntities = customerAgencyDao.selectList(queryWrapper);
for (CustomerAgencyEntity customerAgencyEntity : customerAgencyEntities) {
if (customerAgencyEntity.getLevel().equals("community")){
communityBuildingManagerEntity.setCommunityId(customerAgencyEntity.getId());
}
if (customerAgencyEntity.getLevel().equals("street")){
communityBuildingManagerEntity.setStreetId(customerAgencyEntity.getId());
}
if (customerAgencyEntity.getLevel().equals("district")){
communityBuildingManagerEntity.setDistrictId(customerAgencyEntity.getId());
}
}
communityBuildingManagerDao.insert(communityBuildingManagerEntity);
}
if (null != info.getTotalUnitNum() && info.getTotalUnitNum() > NumConstant.ZERO) {
//设置楼宇单元
List<IcBuildingUnitEntity> unitList = new ArrayList<>();
@ -814,6 +920,27 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
@Override
@Transactional
public void updateNeighborHood(List<ImportGeneralDTO> needUpdateList) {
needUpdateList.forEach(
needUpdate->{
if (StringUtils.isNotBlank(needUpdate.getViliageTypeName())){
if (needUpdate.getViliageTypeName().equals("自然村")){
needUpdate.setViliageType("2");
}
if (needUpdate.getViliageTypeName().equals("住宅小区")){
needUpdate.setViliageType("1");
}
}
if (StringUtils.isNotBlank(needUpdate.getOpenTypeName())){
if (needUpdate.getOpenTypeName().equals("封闭式")){
needUpdate.setOpenType("1");
}
if (needUpdate.getOpenTypeName().equals("开放式")){
needUpdate.setOpenType("2");
}
}
});
if (CollectionUtils.isNotEmpty(needUpdateList)){
baseDao.updateNeighborHood(needUpdateList);
}

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/PropertyManagementServiceImpl.java

@ -359,7 +359,7 @@ public class PropertyManagementServiceImpl implements PropertyManagementService
importFinishTaskForm.setTaskId(importTaskId);
importFinishTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL);
importFinishTaskForm.setOperatorId(userId);
importFinishTaskForm.setResultDesc("城市管理图层导入失败:系统异常,请查看系统日志");
importFinishTaskForm.setResultDesc("物业管理表导入失败:系统异常,请查看系统日志");
Result result = commonServiceOpenFeignClient.finishImportTask(importFinishTaskForm);
if (!result.success()) {

201
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java

@ -1,18 +1,21 @@
package com.epmet.service.impl;
import com.alibaba.excel.EasyExcel;
import com.epmet.commons.tools.constant.AppClientConstant;
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.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.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.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.*;
import com.epmet.constant.OrgInfoConstant;
import com.epmet.constants.ImportTaskConstants;
import com.epmet.dao.CustomerStaffAgencyDao;
import com.epmet.dao.StaffOrgRelationDao;
import com.epmet.dto.*;
@ -20,17 +23,31 @@ import com.epmet.dto.form.*;
import com.epmet.dto.form.yantai.YtSyncStaffIdFormDTO;
import com.epmet.dto.result.*;
import com.epmet.entity.*;
import com.epmet.excel.CustomerStaffImportExcelData;
import com.epmet.excel.handler.CustomerStaffImportListener;
import com.epmet.feign.*;
import com.epmet.remote.EpmetUserRemoteService;
import com.epmet.service.*;
import com.epmet.utils.ImportTaskUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.entity.ContentType;
import org.apache.poi.util.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.annotation.Resource;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -41,6 +58,7 @@ import java.util.stream.Collectors;
* @dscription
* @date 2020/4/23 18:05
*/
@Slf4j
@Service
public class StaffServiceImpl implements StaffService {
private static final Logger logger = LoggerFactory.getLogger(StaffServiceImpl.class);
@ -80,6 +98,10 @@ public class StaffServiceImpl implements StaffService {
private GovAccessFeignClient govAccessFeignClient;
@Autowired
private EpmetThirdOpenFeignClient epmetThirdOpenFeignClient;
@Autowired
private EpmetUserRemoteService userRemoteService;
@Autowired
private OssFeignClient ossFeignClient;
@Override
public Result<StaffsInAgencyResultDTO> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) {
@ -745,5 +767,180 @@ public class StaffServiceImpl implements StaffService {
return list;
}
@Override
public void execAsyncExcelImport(Path filePath, String importTaskId,String orgType, String orgId) {
try {
CustomerStaffImportListener listener = new CustomerStaffImportListener(userRemoteService.getLoginUserDetails().getUserId(), userRemoteService.getLoginUserDetails().getCustomerId(), orgType,orgId,this);
EasyExcel.read(filePath.toFile(), CustomerStaffImportExcelData.class, listener).headRowNumber(1).sheet(0).doRead();
String errorDesFileUrl = null;
List<CustomerStaffImportExcelData.RowRemarkMessage> errorRows = listener.getErrorRows();
List<CustomerStaffImportExcelData.RowRemarkMessage> otherRows = listener.getOtherRows();
boolean failed = errorRows.size() > 0;
// 合并到一起写入
errorRows.addAll(otherRows);
// 生成并上传描述文件
OutputStream os = null;
FileItem fileItem = null;
if (errorRows.size() > 0) {
try {
// 文件生成
Path errorDescDir = FileUtils.getAndCreateDirUnderEpmetFilesDir("staff", "import", "error_des");
String timeMillis = String.valueOf(System.currentTimeMillis());
String fileName = "staff_import_error_".concat(timeMillis).concat(".xlsx");
fileItem = new DiskFileItemFactory(DiskFileItemFactory.DEFAULT_SIZE_THRESHOLD, errorDescDir.toFile())
.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), false, fileName);
os = fileItem.getOutputStream();
EasyExcel.write(os, CustomerStaffImportExcelData.RowRemarkMessage.class).sheet("信息列表").doWrite(errorRows);
// 文件上传oss
Result<UploadImgResultDTO> errorDesFileUploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem));
if (errorDesFileUploadResult.success()) {
errorDesFileUrl = errorDesFileUploadResult.getData().getUrl();
}
} finally {
IOUtils.closeQuietly(os);
try {
fileItem.delete();
} catch (Exception e){
log.error("【客户信息导入】删除临时描述文件失败:{}", ExceptionUtils.getErrorStackTrace(e));
}
}
}
// 完成导入
Result result = ImportTaskUtils.finishImportTask(importTaskId,
failed ? ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL : ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS,
errorDesFileUrl,
"");
if (!result.success()) {
log.error("【客户信息导入】导入记录状态修改为'finished_success'失败");
}
} catch (Exception e) {
String errorMsg = ExceptionUtils.getErrorStackTrace(e);
log.error("【客户信息导入】出错:{}", errorMsg);
Result result = ImportTaskUtils.finishImportTask(importTaskId, ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL, null, "导入失败");
if (!result.success()) {
log.error("【客户信息导入】导入记录状态修改为'finished_fail'失败");
}
} finally {
// 删除临时文件
if (Files.exists(filePath)) {
try {
Files.delete(filePath);
} catch (IOException e) {
log.error("method exception", e);
}
}
}
}
/**
* 批量持久化
* @param addStaffV2FromDTOList
*/
public void exportAdd(List<AddStaffV2FromDTO> addStaffV2FromDTOList, CustomerStaffImportListener listener) {
addStaffV2FromDTOList.forEach(fromDTO -> {
//1.根据新增人员类型判断查询机关信息
OrgResultDTO orgDTO = customerAgencyDao.selectAgencyDetail(fromDTO.getOrgId(), fromDTO.getOrgType());
if (null == orgDTO) {
logger.warn(String.format("工作人员新增,根据新增人员组织类型未查询到相关组织信息,orgId->%s,orgType->%s", fromDTO.getOrgId(), fromDTO.getOrgType()));
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"根据新增人员组织类型未查询到相关组织信息","组织不存在");
}
//2.调用user服务,新增用户信息
StaffSubmitFromDTO submitDTO = ConvertUtils.sourceToTarget(fromDTO, StaffSubmitFromDTO.class);
submitDTO.setAgencyId(orgDTO.getAgencyId());
Result<CustomerStaffDTO> result = epmetUserFeignClient.addStaff(submitDTO);
if (!result.success()) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),result.getInternalMsg(),result.getMsg());
}
//3.人员机关表总人数加一、关系表新增关系数据
//人员机关关系表
CustomerStaffAgencyEntity customerStaffAgencyEntity = new CustomerStaffAgencyEntity();
customerStaffAgencyEntity.setCustomerId(fromDTO.getCustomerId());
customerStaffAgencyEntity.setUserId(result.getData().getUserId());
customerStaffAgencyEntity.setAgencyId(orgDTO.getAgencyId());
customerStaffAgencyService.insert(customerStaffAgencyEntity);
//机关总人数加一
CustomerAgencyEntity agencyEntity = new CustomerAgencyEntity();
agencyEntity.setId(orgDTO.getAgencyId());
agencyEntity.setTotalUser(orgDTO.getTotalUser() + 1);
customerAgencyService.updateById(agencyEntity);
//4.部门、网格主表、关系表修改、新增数据
if ("dept".equals(fromDTO.getOrgType())) {
CustomerStaffDepartmentEntity dept = new CustomerStaffDepartmentEntity();
dept.setCustomerId(fromDTO.getCustomerId());
dept.setUserId(result.getData().getUserId());
dept.setDepartmentId(fromDTO.getOrgId());
customerStaffDepartmentService.insert(dept);
CustomerDepartmentEntity departmentEntity = new CustomerDepartmentEntity();
departmentEntity.setId(fromDTO.getOrgId());
departmentEntity.setTotalUser(orgDTO.getDeptTotalUser() + 1);
customerDepartmentService.updateById(departmentEntity);
}
if ("grid".equals(fromDTO.getOrgType())) {
CustomerStaffGridEntity grid = new CustomerStaffGridEntity();
grid.setCustomerId(fromDTO.getCustomerId());
grid.setUserId(result.getData().getUserId());
grid.setGridId(fromDTO.getOrgId());
customerStaffGridService.insert(grid);
CustomerGridEntity gridEntity = new CustomerGridEntity();
gridEntity.setId(fromDTO.getOrgId());
gridEntity.setTotalUser(orgDTO.getGridTotalUser() + 1);
customerGridService.updateById(gridEntity);
}
//5.工作人员注册组织关系表新增数据
StaffOrgRelationEntity staffOrgRelationEntity = new StaffOrgRelationEntity();
staffOrgRelationEntity.setCustomerId(fromDTO.getCustomerId());
if("agency".equals(fromDTO.getOrgType())){
staffOrgRelationEntity.setPids(("".equals(orgDTO.getPids()) ? "" : orgDTO.getPids()));
}else {
staffOrgRelationEntity.setPids(("".equals(orgDTO.getPids()) ? "" : orgDTO.getPids() + ":") + orgDTO.getAgencyId());
}
staffOrgRelationEntity.setStaffId(result.getData().getUserId());
staffOrgRelationEntity.setOrgId(fromDTO.getOrgId());
staffOrgRelationEntity.setOrgType(fromDTO.getOrgType());
staffOrgRelationService.insert(staffOrgRelationEntity);
if (CollectionUtils.isNotEmpty(fromDTO.getNewRoles())){
Result roleUserAccess = govAccessFeignClient.roleUser(new RoleUserFormDTO(fromDTO.getNewRoles(), customerStaffAgencyEntity.getUserId(),fromDTO.getCustomerId()));
if (!roleUserAccess.success()){
throw new EpmetException("save data to gov-role-user failure");
}
}
//如果是烟台的需要更新 根据手机号+姓名 更新data_sync_user_data置为已创建、记录staffId
// 开发环境默认:45687aa479955f9d06204d415238f7cc
// 测试环境:0c41b272ee9ee95ac6f184ad548a30eb
// 烟台: 1535072605621841922
if ("1535072605621841922".equals(fromDTO.getCustomerId())
|| "45687aa479955f9d06204d415238f7cc".equals(fromDTO.getCustomerId())
|| "0c41b272ee9ee95ac6f184ad548a30eb".equals(fromDTO.getCustomerId())) {
YtSyncStaffIdFormDTO ytSyncStaffIdFormDTO = ConvertUtils.sourceToTarget(fromDTO,YtSyncStaffIdFormDTO.class);
ytSyncStaffIdFormDTO.setStaffId(result.getData().getUserId());
ytSyncStaffIdFormDTO.setOperUserId(fromDTO.getCurrentUserId());
epmetThirdOpenFeignClient.dataSyncUpdateStaff(ytSyncStaffIdFormDTO);
}
});
}
}

BIN
epmet-module/gov-org/gov-org-server/src/main/resources/excel/building_export.xlsx

Binary file not shown.

BIN
epmet-module/gov-org/gov-org-server/src/main/resources/excel/building_export_0510.xlsx

Binary file not shown.

BIN
epmet-module/gov-org/gov-org-server/src/main/resources/excel/building_template.xlsx

Binary file not shown.

BIN
epmet-module/gov-org/gov-org-server/src/main/resources/excel/building_template_0510.xlsx

Binary file not shown.

BIN
epmet-module/gov-org/gov-org-server/src/main/resources/excel/customer_staff_import_template.xlsx

Binary file not shown.

BIN
epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_export_for_easyexcel.xlsx

Binary file not shown.

BIN
epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_export_for_easyexcel_0510.xlsx

Binary file not shown.

BIN
epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_template.xlsx

Binary file not shown.

BIN
epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_template_0510.xlsx

Binary file not shown.

BIN
epmet-module/gov-org/gov-org-server/src/main/resources/excel/neighbor_export.xlsx

Binary file not shown.

BIN
epmet-module/gov-org/gov-org-server/src/main/resources/excel/neighbor_export_0510.xlsx

Binary file not shown.

BIN
epmet-module/gov-org/gov-org-server/src/main/resources/excel/neighbor_template.xlsx

Binary file not shown.

BIN
epmet-module/gov-org/gov-org-server/src/main/resources/excel/neighbor_template_0510.xlsx

Binary file not shown.

BIN
epmet-module/gov-org/gov-org-server/src/main/resources/excel/yantai/community_building_manager_import_temp.xlsx

Binary file not shown.

13
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml

@ -54,6 +54,12 @@
<if test="buildingLeaderMobile != null and buildingLeaderMobile != '' ">
BUILDING_LEADER_MOBILE = #{buildingLeaderMobile},
</if>
<if test="buildingLeaderIdCard != null and buildingLeaderIdCard != '' ">
BUILDING_LEADER_ID_CARD = #{buildingLeaderIdCard},
</if>
<if test="buildingLeaderTypeNum != null and buildingLeaderTypeNum != '' ">
BUILDING_LEADER_TYPE = #{buildingLeaderTypeNum},
</if>
<if test="sort != null">
SORT = #{sort},
</if>
@ -149,7 +155,9 @@
c.ORGANIZATION_NAME as agencyName,
d.GRID_NAME as gridName,
a.BUILDING_LEADER_NAME AS buildingLeaderName,
a.BUILDING_LEADER_MOBILE AS buildingLeaderMobile
a.BUILDING_LEADER_MOBILE AS buildingLeaderMobile,
a.BUILDING_LEADER_ID_CARD AS buildingLeaderIdCard,
if(a.BUILDING_LEADER_TYPE = 0,'楼长',if(a.BUILDING_LEADER_TYPE = 1,'单元长','')) AS buildingLeaderType
from ic_building a
LEFT JOIN ic_neighbor_hood b on a.NEIGHBOR_HOOD_ID = b.ID and b.DEL_FLAG='0'
@ -453,6 +461,9 @@
</select>
<select id="getBuildingDetail" resultType="com.epmet.dto.result.IcBulidingDetailDTO">
SELECT
b.BUILDING_LEADER_ID_CARD as buildingLeaderIdCard,
b.BUILDING_LEADER_TYPE as buildingLeaderType,
if(b.BUILDING_LEADER_TYPE = 0,'楼长',if(b.BUILDING_LEADER_TYPE = 1,'单元长','')) as buildingLeaderTypeName,
b.ID AS buildingId,
b.BUILDING_NAME,
b.NEIGHBOR_HOOD_ID,

12
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml

@ -62,6 +62,16 @@
when id = #{h.houseId} then #{h.ownerIdCard}
</foreach>
</trim>
<trim prefix="FLOOR =(case" suffix="end),">
<foreach collection="houses" item="h">
when id = #{h.houseId} then #{h.floor}
</foreach>
</trim>
<trim prefix="AREA =(case" suffix="end),">
<foreach collection="houses" item="h">
when id = #{h.houseId} then #{h.area}
</foreach>
</trim>
<trim prefix="SORT =(case" suffix="end),">
<foreach collection="houses" item="h">
when id = #{h.houseId} then #{h.sort}
@ -104,6 +114,8 @@
a.OWNER_PHONE as ownerPhone,
a.OWNER_ID_CARD as ownerIdCard,
a.HOUSE_CODE,
a.FLOOR as floor,
a.AREA as area,
a.ID as houseId,
c.ID as neighborHoodId,

24
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml

@ -39,6 +39,26 @@
when id = #{l.neighborHoodId} then #{l.remark}
</foreach>
</trim>
<trim prefix="AREA =(case" suffix="end),">
<foreach collection="list" item="l">
when id = #{l.neighborHoodId} then #{l.area}
</foreach>
</trim>
<trim prefix="BUILD_YEAR =(case" suffix="end),">
<foreach collection="list" item="l">
when id = #{l.neighborHoodId} then #{l.buildYear}
</foreach>
</trim>
<trim prefix="VILIAGE_TYPE =(case" suffix="end),">
<foreach collection="list" item="l">
when id = #{l.neighborHoodId} then #{l.viliageType}
</foreach>
</trim>
<trim prefix="OPEN_TYPE =(case" suffix="end),">
<foreach collection="list" item="l">
when id = #{l.neighborHoodId} then #{l.openType}
</foreach>
</trim>
UPDATED_TIME = NOW()
</trim>
WHERE DEL_FLAG = '0'
@ -169,6 +189,10 @@
</select>
<select id="searchAllNeighborhood" resultType="com.epmet.excel.IcNeighborHoodExcel">
select
a.AREA as area,
a.BUILD_YEAR as buildYear,
if(a.VILIAGE_TYPE =1 ,'住宅小区',if(a.VILIAGE_TYPE = 2,'自然村','')) as viliageTypeName,
if(a.OPEN_TYPE =1 ,'封闭式',if(a.OPEN_TYPE = 2,'开放式','')) as openTypeName,
a.NEIGHBOR_HOOD_NAME as neighborHoodName,
a.ADDRESS as address,
a.REMARK as remark,

35
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java

@ -402,29 +402,30 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
baseDao.insert(staffEntity);
CustomerAgencyUserRoleDTO dto = new CustomerAgencyUserRoleDTO();
//工作人员角色关联表
fromDTO.getRoles().forEach(role -> {
StaffRoleEntity staffRoleEntity = new StaffRoleEntity();
staffRoleEntity.setStaffId(userEntity.getId());
staffRoleEntity.setRoleId(role);
staffRoleEntity.setOrgId(fromDTO.getAgencyId());
staffRoleEntity.setCustomerId(fromDTO.getCustomerId());
staffRoleService.insert(staffRoleEntity);
});
if (fromDTO.getRoles()!=null){
fromDTO.getRoles().forEach(role -> {
StaffRoleEntity staffRoleEntity = new StaffRoleEntity();
staffRoleEntity.setStaffId(userEntity.getId());
staffRoleEntity.setRoleId(role);
staffRoleEntity.setOrgId(fromDTO.getAgencyId());
staffRoleEntity.setCustomerId(fromDTO.getCustomerId());
staffRoleService.insert(staffRoleEntity);
});
// 角色放缓存
List<RoleKeyValueResultDTO> roleKeyValue = govStaffRoleDao.selectRoleKeyName(fromDTO.getRoles());
Map m = new HashMap(16);
roleKeyValue.forEach(r -> {
m.put(r.getRoleKey(), r.getRoleName());
});
dto.setRoles(m);
}
// 角色放缓存
CustomerAgencyUserRoleDTO dto = new CustomerAgencyUserRoleDTO();
List<RoleKeyValueResultDTO> roleKeyValue = govStaffRoleDao.selectRoleKeyName(fromDTO.getRoles());
dto.setCustomerId(fromDTO.getCustomerId());
dto.setStaffId(userEntity.getId());
dto.setAgencyId(fromDTO.getAgencyId());
Map m = new HashMap(16);
roleKeyValue.forEach(r -> {
m.put(r.getRoleKey(), r.getRoleName());
});
dto.setRoles(m);
CustomerStaffRedis.delStaffInfoFormCache(dto.getCustomerId(), dto.getStaffId());
return new Result<CustomerStaffDTO>().ok(ConvertUtils.sourceToTarget(staffEntity, CustomerStaffDTO.class));
}

55
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncRecordDeathServiceImpl.java

@ -14,16 +14,20 @@ import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.redis.common.bean.GridInfoCache;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.SpringContextUtils;
import com.epmet.dao.DataSyncRecordDeathDao;
import com.epmet.dao.IcResiUserDao;
import com.epmet.dto.ChangeDeathDTO;
import com.epmet.dto.DataSyncRecordDeathDTO;
import com.epmet.dto.form.dataSync.DataSyncRecordDeathPageFormDTO;
import com.epmet.entity.DataSyncRecordDeathEntity;
import com.epmet.entity.IcResiUserEntity;
import com.epmet.service.DataSyncRecordDeathService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -38,6 +42,8 @@ import java.util.Map;
*/
@Service
public class DataSyncRecordDeathServiceImpl extends BaseServiceImpl<DataSyncRecordDeathDao, DataSyncRecordDeathEntity> implements DataSyncRecordDeathService {
@Autowired
private IcResiUserDao icResiUserDao;
/**
* 列表查询
@ -124,27 +130,48 @@ public class DataSyncRecordDeathServiceImpl extends BaseServiceImpl<DataSyncReco
// 已处理的跳过
continue;
}
entity.setDealStatus(NumConstant.ONE);
try {
ChangeDeathDTO changeDeathDTO = new ChangeDeathDTO();
changeDeathDTO.setStaffId(userId);
changeDeathDTO.setUserId(entity.getIcResiUserId());
changeDeathDTO.setGridId(entity.getGridId());
changeDeathDTO.setName(entity.getName());
changeDeathDTO.setIdCard(entity.getIdCard());
// 手机号没有值
changeDeathDTO.setMobile(StrConstant.EPMETY_STR);
changeDeathDTO.setDeathDate(DateUtils.stringToDate(entity.getDeathDate(), "yyyy-MM-dd"));
changeDeathDTO.setJoinReason("来源于数据比对-死亡人员数据");
SpringContextUtils.getBean(ChangeDeathServiceImpl.class).save(changeDeathDTO);
entity.setDealStatus(NumConstant.ONE);
Boolean existedFlag=true;
LambdaQueryWrapper<IcResiUserEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(IcResiUserEntity::getIdCard, entity.getIdCard())
.eq(IcResiUserEntity::getCustomerId, entity.getCustomerId())
.eq(IcResiUserEntity::getDelFlag, NumConstant.ZERO_STR)
.select(IcResiUserEntity::getId);
IcResiUserEntity icResiUserEntity = icResiUserDao.selectOne(queryWrapper);
if (null == icResiUserEntity) {
existedFlag = false;
entity.setDealStatus(NumConstant.TWO);
entity.setIcResiUserId(null);
entity.setDealResult("居民信息表不存在此居民");
}else{
entity.setIcResiUserId(icResiUserEntity.getId());
}
if(existedFlag){
ChangeDeathDTO changeDeathDTO = new ChangeDeathDTO();
changeDeathDTO.setStaffId(userId);
changeDeathDTO.setUserId(entity.getIcResiUserId());
changeDeathDTO.setGridId(entity.getGridId());
changeDeathDTO.setName(entity.getName());
changeDeathDTO.setIdCard(entity.getIdCard());
// 手机号没有值
changeDeathDTO.setMobile(StrConstant.EPMETY_STR);
changeDeathDTO.setDeathDate(DateUtils.stringToDate(entity.getDeathDate(), "yyyy-MM-dd"));
changeDeathDTO.setJoinReason("来源于数据比对-死亡人员数据");
Result result=SpringContextUtils.getBean(ChangeDeathServiceImpl.class).save(changeDeathDTO);
if(!result.success()){
entity.setDealStatus(NumConstant.TWO);
entity.setDealResult("同步死亡人员返回失败");
}
}
} catch (EpmetException epmetException) {
//0:未处理;1:处理成功;2处理失败
entity.setDealStatus(NumConstant.TWO);
entity.setDealResult("系统内部异常:" + epmetException.getMsg());
epmetException.printStackTrace();
} catch (Exception e) {
//0:未处理;1:处理成功;2处理失败
entity.setDealStatus(NumConstant.TWO);
entity.setDealResult("未知错误");

92
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java

@ -796,7 +796,6 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
/**
* @description: 生成居民变更记录
* @param null:
* @return
* @author: sun
*/
@ -922,15 +921,8 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
@Override
public PageData<Map<String, Object>> pageResiMap(IcResiUserPageFormDTO formDTO) {
// 查询列表展示项,如果没有,直接返回
CustomerFormQueryDTO queryDTO1 = ConvertUtils.sourceToTarget(formDTO,CustomerFormQueryDTO.class);
Result<List<IcFormResColumnDTO>> resultColumnRes = operCustomizeOpenFeignClient.queryConditions(queryDTO1);
if (!resultColumnRes.success() || CollectionUtils.isEmpty(resultColumnRes.getData())) {
log.warn("没有配置列表展示列");
return new PageData(new ArrayList(), NumConstant.ZERO);
}
List<IcFormResColumnDTO> resultColumns = resultColumnRes.getData();
List<IcFormResColumnDTO> resultColumns = queryResultColumns(formDTO);
// 查询结果列对应的表:
Set<String> resultColumnTables = resultColumns.stream().map(IcFormResColumnDTO::getTableName).collect(Collectors.toSet());
@ -984,7 +976,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
}).collect(Collectors.toList());
}
// 查询列表展示项需要用到哪些子表
Result<List<SubTableJoinDTO>> subTablesRes = operCustomizeOpenFeignClient.querySubTables(queryDTO1);
Result<List<SubTableJoinDTO>> subTablesRes = operCustomizeOpenFeignClient.querySubTables(ConvertUtils.sourceToTarget(formDTO,CustomerFormQueryDTO.class));
List<SubTableJoinDTO> subTables = subTablesRes.getData();
// log.info("1、所有的子表subTables:"+JSON.toJSONString(subTables,true));
@ -1041,7 +1033,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
}
List<Map<String, Object>> list = pageInfo.getList();
//查询网格名称
//查询网格名称、房屋名称用
List<String> gridIds = new ArrayList<>();
Set<String> houseIds = new HashSet<>();
for (Map<String, Object> map : list) {
@ -1052,25 +1044,48 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
houseIds.add(map.get(UserConstant.HOME_ID).toString());
}
}
Result<List<AllGridsByUserIdResultDTO>> gridInfoRes = govOrgOpenFeignClient.getGridListByGridIds(gridIds);
List<AllGridsByUserIdResultDTO> gridInfoList = gridInfoRes.success() && !CollectionUtils.isEmpty(gridInfoRes.getData()) ? gridInfoRes.getData() : new ArrayList<>();
Map<String, AllGridsByUserIdResultDTO> gridInfoMap = gridInfoList.stream().collect(Collectors.toMap(AllGridsByUserIdResultDTO::getGridId, Function.identity()));
Map<String, AllGridsByUserIdResultDTO> gridInfoMap =getGridInfoMap(gridIds);
//查询房子名称
Result<List<HouseInfoDTO>> houseInfoRes = govOrgOpenFeignClient.queryListHouseInfo(houseIds, formDTO.getCustomerId());
List<HouseInfoDTO> houseInfoDTOList = houseInfoRes.success() && !CollectionUtils.isEmpty(houseInfoRes.getData()) ? houseInfoRes.getData() : new ArrayList<>();
Map<String, HouseInfoDTO> houseInfoMap = houseInfoDTOList.stream().collect(Collectors.toMap(HouseInfoDTO::getHomeId, Function.identity()));
Map<String, HouseInfoDTO> houseInfoMap =getHouseInfoMap(houseIds,formDTO.getCustomerId());
handleList(list,gridInfoMap,houseInfoMap,formDTO.getCustomerId());
pageInfo.setList(list);
if (formDTO.getIsPage()) {
return new PageData<>(pageInfo.getList(), pageInfo.getTotal(), formDTO.getPageSize());
}
return new PageData<>(pageInfo.getList(), pageInfo.getTotal());
}
private List<IcFormResColumnDTO> queryResultColumns(IcResiUserPageFormDTO formDTO) {
// 查询列表展示项,如果没有,直接返回
CustomerFormQueryDTO queryDTO1 = ConvertUtils.sourceToTarget(formDTO,CustomerFormQueryDTO.class);
Result<List<IcFormResColumnDTO>> resultColumnRes = operCustomizeOpenFeignClient.queryConditions(queryDTO1);
if (!resultColumnRes.success() || CollectionUtils.isEmpty(resultColumnRes.getData())) {
log.error(formDTO.getCustomerId()+"没有配置列表展示列");
// return new PageData(new ArrayList(), NumConstant.ZERO);
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"居民信息表单未配置列表展示项","居民信息表单未配置列表展示项");
}
List<IcFormResColumnDTO> resultColumns = resultColumnRes.getData();
return resultColumns;
}
private void handleList(List<Map<String, Object>> list, Map<String, AllGridsByUserIdResultDTO> gridInfoMap, Map<String, HouseInfoDTO> houseInfoMap,String customerId) {
if(CollectionUtils.isEmpty(list)){
return;
}
//查询需求分类字典
UserDemandNameQueryFormDTO userDemandNameQueryFormDTO = new UserDemandNameQueryFormDTO();
userDemandNameQueryFormDTO.setCustomerId(formDTO.getCustomerId());
userDemandNameQueryFormDTO.setCustomerId(customerId);
userDemandNameQueryFormDTO.setCodeSet(new HashSet<>());
Result<List<IcResiDemandDictDTO>> demandNameRes = heartOpenFeignClient.queryDemandNames(userDemandNameQueryFormDTO);
if (!demandNameRes.success() || CollectionUtils.isEmpty(demandNameRes.getData())) {
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "获取需求分类字典表数据异常", EpmetErrorCode.SERVER_ERROR.getMsg());
}
Map<String, IcResiDemandDictDTO> demandDictMap = demandNameRes.getData().stream().collect(Collectors.toMap(IcResiDemandDictDTO::getCategoryCode, Function.identity()));
// 重点人群+人口类型+政治面貌需要特殊赋值
Result<Map<String, String>> keyPointUserTypeMapRes = epmetAdminOpenFeignClient.dictMap(DictTypeEnum.YT_KEY_POINT_USER_TYPE.getCode());
Result<Map<String, String>> populationTypeMapRes = epmetAdminOpenFeignClient.dictMap(DictTypeEnum.YT_POPULATION_TYPE.getCode());
Result<Map<String, String>> politicsStatusMapRes = epmetAdminOpenFeignClient.dictMap(DictTypeEnum.YT_POLITICS_STATUS.getCode());
Result<Map<String, String>> idCardTypeMapRes = epmetAdminOpenFeignClient.dictMap(DictTypeEnum.YT_ID_CARD_TYPE.getCode());
for (Map<String, Object> resultMap : list) {
String gridIdValue = null != resultMap.get(UserConstant.GRID_ID) ? resultMap.get(UserConstant.GRID_ID).toString() : StrConstant.EPMETY_STR;
resultMap.put("GRID_ID_VALUE", gridIdValue);
@ -1120,12 +1135,39 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
resultMap.put(UserConstant.GENDER, GenderEnum.UN_KNOWN.getName());
}
}
// 烟台需求:列表又又又又增加了:重点人群、国籍、人口类型、政治面貌,其中 重点人群+人口类型+政治面貌需要特殊赋值
if (resultMap.containsKey("KEY_POINT_USER_TYPE")) {
String keyPointUserTypeValue = (String) resultMap.get("KEY_POINT_USER_TYPE");
resultMap.put("KEY_POINT_USER_TYPE", keyPointUserTypeMapRes.getData().get(keyPointUserTypeValue));
}
if (resultMap.containsKey("POPULATION_TYPE")) {
String populationTypeValue = (String) resultMap.get("POPULATION_TYPE");
resultMap.put("POPULATION_TYPE", populationTypeMapRes.getData().get(populationTypeValue));
}
if (resultMap.containsKey("POLITICS_STATUS")) {
String politicsStatusValue = (String) resultMap.get("POLITICS_STATUS");
resultMap.put("POLITICS_STATUS", politicsStatusMapRes.getData().get(politicsStatusValue));
}
if (resultMap.containsKey("ID_CARD_TYPE")) {
String idCardTypeValue = (String) resultMap.get("ID_CARD_TYPE");
resultMap.put("ID_CARD_TYPE", idCardTypeMapRes.getData().get(idCardTypeValue));
}
}
pageInfo.setList(list);
if (formDTO.getIsPage()) {
return new PageData<>(pageInfo.getList(), pageInfo.getTotal(), formDTO.getPageSize());
}
return new PageData<>(pageInfo.getList(), pageInfo.getTotal());
}
private Map<String, HouseInfoDTO> getHouseInfoMap(Set<String> houseIds,String customerId) {
//查询房子名称
Result<List<HouseInfoDTO>> houseInfoRes = govOrgOpenFeignClient.queryListHouseInfo(houseIds, customerId);
List<HouseInfoDTO> houseInfoDTOList = houseInfoRes.success() && !CollectionUtils.isEmpty(houseInfoRes.getData()) ? houseInfoRes.getData() : new ArrayList<>();
Map<String, HouseInfoDTO> houseInfoMap = houseInfoDTOList.stream().collect(Collectors.toMap(HouseInfoDTO::getHomeId, Function.identity()));
return houseInfoMap;
}
private Map<String, AllGridsByUserIdResultDTO> getGridInfoMap(List<String> gridIds) {
Result<List<AllGridsByUserIdResultDTO>> gridInfoRes = govOrgOpenFeignClient.getGridListByGridIds(gridIds);
List<AllGridsByUserIdResultDTO> gridInfoList = gridInfoRes.success() && !CollectionUtils.isEmpty(gridInfoRes.getData()) ? gridInfoRes.getData() : new ArrayList<>();
Map<String, AllGridsByUserIdResultDTO> gridInfoMap = gridInfoList.stream().collect(Collectors.toMap(AllGridsByUserIdResultDTO::getGridId, Function.identity()));
return gridInfoMap;
}
private String queryUserDemandName(String icResiUserId, Map<String, IcResiDemandDictDTO> demandDictMap) {

12
epmet-user/epmet-user-server/src/main/resources/mapper/DataSyncRecordDeathDao.xml

@ -32,17 +32,7 @@
<select id="pageSelect" parameterType="map" resultType="com.epmet.dto.DataSyncRecordDeathDTO">
SELECT
d.id,
d.`NAME`,
d.ID_CARD,
d.DEATH_DATE,
d.AGE,
d.ADDRESS,
d.IC_RESI_USER_ID,
d.GRID_ID,
d.AGENCY_ID,
d.CREMATION_TIME,
d.ORGAN_NAME
d.*
FROM
data_sync_record_death d
WHERE

Loading…
Cancel
Save