Browse Source

Merge remote-tracking branch 'origin_elink/yantai_zhengwu_master'

dev
yinzuomei 2 years ago
parent
commit
d39476f1c5
  1. 10
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java
  2. 9
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcHouseDTO.java
  3. 39
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcPropertyManagementDTO.java
  4. 20
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcPropertyManagementFormDTO.java
  5. 19
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcNeighborHoodDetailDTO.java
  6. 8
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcNeighborHoodResultDTO.java
  7. 38
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/yt/CommunityBuildingManagerResultDTO.java
  8. 165
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CommunityBuildingManagerController.java
  9. 15
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java
  10. 212
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/PropertyManagementController.java
  11. 38
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java
  12. 13
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java
  13. 12
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodPropertyDao.java
  14. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcPropertyManagementDao.java
  15. 120
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/handler/IcPropertyManagementImportListener.java
  16. 61
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/yt/IcPropertyManagementImportExcelData.java
  17. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CommunityBuildingManagerService.java
  18. 7
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java
  19. 9
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcPropertyManagementService.java
  20. 44
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/PropertyManagementService.java
  21. 53
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CommunityBuildingManagerServiceImpl.java
  22. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java
  23. 38
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java
  24. 7
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcPropertyManagementServiceImpl.java
  25. 309
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/PropertyManagementServiceImpl.java
  26. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/customer_staff_import_template.xlsx
  27. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/yantai/community_building_manager_import_temp.xlsx
  28. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/yantai/ic_property_management_temp.xlsx
  29. 6
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CommunityBuildingManagerDao.xml
  30. 28
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml
  31. 16
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodPropertyDao.xml
  32. 4
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcPropertyManagementDao.xml
  33. 14
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java

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

@ -83,4 +83,14 @@ public interface ImportTaskConstants {
* 未做核酸比对
*/
String IC_NAT_COMPARE_RECORD="ic_nat_compare_record";
/**
* 物业表ic_property_management
*/
String IC_PROPERTY_MANAGEMENT="ic_property_management";
/**
* 楼长单元长
*/
String COMMUNITY_BUILDING_MANAGER="community_building_manager";
}

9
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcHouseDTO.java

@ -170,4 +170,13 @@ public class IcHouseDTO implements Serializable {
* 加密后的房主身份证
*/
private String showOwnerIdCard;
/**
* 所在楼层
*/
private String floor;
/**
* 面积
*/
private String area;
}

39
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcPropertyManagementDTO.java

@ -17,10 +17,14 @@
package com.epmet.dto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
@ -37,58 +41,85 @@ public class IcPropertyManagementDTO implements Serializable {
/**
* 物业id
*/
@ExcelIgnore
private String id;
/**
* 物业名称
*/
@ExcelProperty(value = "物业名称")
@ColumnWidth(30)
private String name;
/**
* 客户id
*/
@ExcelIgnore
private String customerId;
/**
* 烟台需求物业联系人姓名
*/
@ExcelProperty(value = "物业联系人")
@ColumnWidth(30)
private String contactName;
/**
* 烟台需求物业联系人电话
*/
@ExcelProperty(value = "联系电话")
@ColumnWidth(30)
private String contactMobile;
/**
* 关联的小区数量
*/
@ExcelIgnore
private Integer totalNeighborHood;
/**
* 导出时候用
* 该物业关联的小区
*/
@ExcelProperty(value = "关联小区")
@ColumnWidth(60)
private String neighborHoodNames;
@ExcelIgnore
List<IcNeighborHoodDTO> neighborHoodList;
/**
* 删除标识 0未删除1已删除
*/
@ExcelIgnore
private String delFlag;
/**
* 乐观锁
*/
@ExcelIgnore
private Integer revision;
/**
* 创建人
*/
@ExcelIgnore
private String createdBy;
/**
* 创建时间
*/
@ExcelIgnore
private Date createdTime;
/**
* 更新人
*/
@ExcelIgnore
private String updatedBy;
/**
* 更新时间
*/
@ExcelIgnore
private Date updatedTime;
/**
* 关联的小区数量
*/
private Integer totalNeighborHood;
}

20
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcPropertyManagementFormDTO.java

@ -17,17 +17,18 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.dto.form.PageFormDTO;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
@Data
public class IcPropertyManagementFormDTO implements Serializable {
public class IcPropertyManagementFormDTO extends PageFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ -40,8 +41,8 @@ public class IcPropertyManagementFormDTO implements Serializable {
public interface UpdateShowGroup extends CustomerClientShowGroup {
}
public interface PageGroup extends CustomerClientShowGroup {
}
// public interface PageGroup extends CustomerClientShowGroup {
// }
@NotBlank(message = "物业id不能为空", groups = {DeleteGroup.class, UpdateShowGroup.class})
private String id;
@ -64,11 +65,12 @@ public class IcPropertyManagementFormDTO implements Serializable {
@Length(max = 30, message = "联系电话不能超过30个字",groups = {AddShowGroup.class, UpdateShowGroup.class})
private String contactMobile;
private String customerId;
/**
* 管理小区id
*/
private List<String> neighborHoodIdList;
@NotNull(message = "pageNo不能为空", groups = PageGroup.class)
private Integer pageNo;
@NotNull(message = "pageSize不能为空", groups = PageGroup.class)
private Integer pageSize;
private String customerId;
}

19
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcNeighborHoodDetailDTO.java

@ -107,5 +107,24 @@ public class IcNeighborHoodDetailDTO {
* 二维码地址
*/
private String qrcodeUrl;
private String viliageTypeName;
private String area;
private String openTypeName;
private String buildYear;
/**
* 烟台需求自然村/小区
*/
private String viliageType;
/**
* 烟台需求开放类型
*/
private String openType;
}

8
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcNeighborHoodResultDTO.java

@ -28,4 +28,12 @@ public class IcNeighborHoodResultDTO extends PageFormDTO {
private String propertyId;
private String agencyName;
private String longitude;
private String viliageTypeName;
private String area;
private String openTypeName;
private String buildYear;
}

38
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/yt/CommunityBuildingManagerResultDTO.java

@ -1,5 +1,8 @@
package com.epmet.dto.result.yt;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
import java.io.Serializable;
@ -19,80 +22,115 @@ public class CommunityBuildingManagerResultDTO implements Serializable {
/**
* 主键烟台需求
*/
@ExcelIgnore
private String id;
/**
* 客户Id customer.id
*/
@ExcelIgnore
private String customerId;
/**
* 姓名
*/
@ExcelProperty(value = "姓名")
@ColumnWidth(20)
private String name;
/**
* 联系电话
*/
@ExcelProperty(value = "联系电话")
@ColumnWidth(25)
private String phone;
/**
* 身份证号
*/
@ExcelProperty(value = "身份证号")
@ColumnWidth(30)
private String idCard;
/**
* 类型0楼长1单元长
*/
@ExcelIgnore
private String type;
@ExcelProperty(value = "类型")
@ColumnWidth(20)
private String typeName;
/**
* 所属区县id取名字关联customer_agency
*/
@ExcelIgnore
private String districtId;
@ExcelProperty(value = "所属区市")
@ColumnWidth(30)
private String districtName;
/**
* 所属街道id取名字关联customer_agency
*/
@ExcelIgnore
private String streetId;
@ExcelProperty(value = "所属镇街")
@ColumnWidth(30)
private String streetName;
/**
* 所属社区id取名字关联customer_agency
*/
@ExcelIgnore
private String communityId;
@ExcelProperty(value = "所属社区")
@ColumnWidth(30)
private String communityName;
/**
* 所属网格id取名字关联customer_grid
*/
@ExcelIgnore
private String gridId;
@ExcelProperty(value = "所属网格")
@ColumnWidth(30)
private String gridName;
/**
* 网格的全路径包含网格id
*/
@ExcelIgnore
private String orgIdPath;
/**
* 所属小区id
*/
@ExcelIgnore
private String viliageId;
@ExcelProperty(value = "所属小区")
@ColumnWidth(30)
private String viliageName;
/**
* 所属楼栋id
*/
@ExcelIgnore
private String buildingId;
@ExcelProperty(value = "楼栋")
@ColumnWidth(20)
private String buildingName;
/**
* 所属单元id; 单元长时必填此列
*/
@ExcelIgnore
private String unitId;
/**
* 所属单元id; 单元长时必填此列
*/
@ExcelProperty(value = "单元")
@ColumnWidth(20)
private String unitName;

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

@ -1,22 +1,46 @@
package com.epmet.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
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.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
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.Result;
import com.epmet.commons.tools.utils.poi.excel.handler.FreezeAndFilter;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.yt.CommunityBuildingManagerPageFormDTO;
import com.epmet.dto.result.CommunityBuildingManagerDTO;
import com.epmet.dto.result.yt.CommunityBuildingManagerResultDTO;
import com.epmet.service.CommunityBuildingManagerService;
import org.apache.commons.lang3.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.net.URLEncoder;
import java.util.Date;
import java.util.List;
@ -26,9 +50,10 @@ import java.util.List;
* @author generator generator@elink-cn.com
* @since v1.0.0 2023-05-06
*/
@Slf4j
@RestController
@RequestMapping("communityBuildingManager")
public class CommunityBuildingManagerController {
public class CommunityBuildingManagerController implements ResultDataResolver {
@Autowired
private CommunityBuildingManagerService communityBuildingManagerService;
@ -68,10 +93,10 @@ public class CommunityBuildingManagerController {
public Result save(@LoginUser TokenDto tokenDto,@RequestBody CommunityBuildingManagerDTO dto){
dto.setCustomerId(tokenDto.getCustomerId());
ValidatorUtils.validateEntity(dto, CommunityBuildingManagerDTO.AddShowGroup.class);
//类型:0楼长;1单元长
/* //类型:0楼长;1单元长
if("1".equals(dto.getType())&& StringUtils.isBlank(dto.getUnitId())){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"单元长必须选择所属单元","单元长必须选择所属单元");
}
}*/
communityBuildingManagerService.save(dto);
return new Result();
}
@ -86,10 +111,10 @@ public class CommunityBuildingManagerController {
@PostMapping("update")
public Result update(@RequestBody CommunityBuildingManagerDTO dto){
ValidatorUtils.validateEntity(dto, CommunityBuildingManagerDTO.UpdateShowGroup.class);
//类型:0楼长;1单元长
/* //类型:0楼长;1单元长
if("1".equals(dto.getType())&& StringUtils.isBlank(dto.getUnitId())){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"单元长必须选择所属单元","单元长必须选择所属单元");
}
}*/
communityBuildingManagerService.update(dto);
return new Result();
}
@ -108,4 +133,132 @@ public class CommunityBuildingManagerController {
return new Result();
}
/**
* 楼长单元长-下载导入模板
* @param response
* @throws IOException
*/
@RequestMapping(value = "download-tem", method = {RequestMethod.GET, RequestMethod.POST})
public void downloadTemplate(HttpServletResponse response) throws IOException {
response.setCharacterEncoding("UTF-8");
response.addHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, "Content-Disposition");
//response.setHeader(HttpHeaders.CONTENT_TYPE, "application/vnd.ms-excel");
response.setHeader(HttpHeaders.CONTENT_TYPE, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode("楼长单元长导入模版", "UTF-8") + ".xlsx");
InputStream is = this.getClass().getClassLoader().getResourceAsStream("excel/yantai/community_building_manager_import_temp.xlsx");
try {
ServletOutputStream os = response.getOutputStream();
IOUtils.copy(is, os);
} finally {
if (is != null) {
is.close();
}
}
}
/**
* 楼长单元长-列表导出
*
* @param tokenDto
* @param formDTO
* @param response
* @return
* @throws IOException
*/
@PostMapping("export")
public void exportCommunityBuildingManager(@LoginUser TokenDto tokenDto, @RequestBody CommunityBuildingManagerPageFormDTO formDTO, HttpServletResponse response) throws IOException {
formDTO.setCustomerId(tokenDto.getCustomerId());
formDTO.setStaffId(tokenDto.getUserId());
ExcelWriter excelWriter = null;
formDTO.setPageNo(NumConstant.ONE);
formDTO.setPageSize(NumConstant.TEN_THOUSAND);
try {
String fileName = "楼长单元长列表导出" + DateUtils.format(new Date()) + ".xlsx";
WriteCellStyle headWriteCellStyle = new WriteCellStyle();
headWriteCellStyle.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex());
WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
FreezeAndFilter writeHandler = new FreezeAndFilter();
excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), CommunityBuildingManagerResultDTO.class)
.registerWriteHandler(horizontalCellStyleStrategy)
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
.registerWriteHandler(writeHandler).build();
WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").registerWriteHandler(new FreezeAndFilter()).build();
PageData<CommunityBuildingManagerResultDTO> data = null;
do {
data = communityBuildingManagerService.page(formDTO);
formDTO.setPageNo(formDTO.getPageNo() + NumConstant.ONE);
excelWriter.write(data.getList(), writeSheet);
} while (org.apache.commons.collections4.CollectionUtils.isNotEmpty(data.getList()) && data.getList().size() == formDTO.getPageSize());
} catch (EpmetException e) {
response.reset();
response.setCharacterEncoding("UTF-8");
response.setHeader("content-type", "application/json; charset=UTF-8");
PrintWriter printWriter = response.getWriter();
Result<Object> result = new Result<>().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), e.getMsg());
printWriter.write(JSON.toJSONString(result));
printWriter.close();
} catch (Exception e) {
log.error("楼长单元长导出异常export exception", e);
} finally {
if (excelWriter != null) {
excelWriter.finish();
}
}
}
/**
* 导入excel
*
* @return
*/
@PostMapping("import")
public Result importExcel(@RequestPart("file") MultipartFile file) {
return new Result();
/*// 1.暂存文件
String originalFilename = file.getOriginalFilename();
String extName = originalFilename.substring(originalFilename.lastIndexOf("."));
Path fileSavePath;
try {
Path importPath = FileUtils.getAndCreateDirUnderEpmetFilesDir(ImportTaskConstants.COMMUNITY_BUILDING_MANAGER, "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(ImportTaskConstants.COMMUNITY_BUILDING_MANAGER + "表 importExcel 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.COMMUNITY_BUILDING_MANAGER),
ServiceConstant.EPMET_COMMON_SERVICE,
EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),
"楼长单元长导入excel错误",
"楼长单元长导入excel错误");
// 3.执行导入
communityBuildingManagerService.execAsyncExcelImport(fileSavePath, rstData.getTaskId());
return new Result();*/
}
}

15
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java

@ -174,6 +174,21 @@ public class IcNeighborHoodController {
return new Result<List<OptionResultDTO>>().ok(list);
}
/**
* 入参gridIdagencyId
* 返回当前组织及下级下的所有小区
* @param tokenDto
* @param formDTO
* @return
*/
@PostMapping("neighborhood-options-yantai")
public Result<List<OptionResultDTO>> queryNeighborHoodOptionsYanTai(@LoginUser TokenDto tokenDto, @RequestBody NeighborHoodOptionFormDTO formDTO) {
formDTO.setCustomerId(tokenDto.getCustomerId());
formDTO.setStaffId(tokenDto.getUserId());
List<OptionResultDTO> list=icNeighborHoodService.queryNeighborHoodOptionsYanTai(formDTO);
return new Result<List<OptionResultDTO>>().ok(list);
}
/**
* 获取用户组织下小区列表
*

212
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/PropertyManagementController.java

@ -17,24 +17,55 @@
package com.epmet.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.annotation.LoginUser;
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.IcPropertyManagementDTO;
import com.epmet.dto.form.IcPropertyManagementFormDTO;
import com.epmet.dto.result.IcPropertyManagementResultDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.service.PropertyManagementService;
import com.epmet.utils.ImportTaskUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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.*;
/**
@ -43,9 +74,10 @@ import java.util.Map;
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-10-25
*/
@Slf4j
@RestController
@RequestMapping("propertymanagement")
public class PropertyManagementController {
public class PropertyManagementController implements ResultDataResolver {
@Autowired
private PropertyManagementService propertyManagementService;
@ -55,7 +87,6 @@ public class PropertyManagementController {
*/
@PostMapping("page")
public Result<PageData<IcPropertyManagementDTO>> page(@RequestBody IcPropertyManagementFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO,IcPropertyManagementFormDTO.PageGroup.class);
return new Result<PageData<IcPropertyManagementDTO>>().ok(propertyManagementService.page(formDTO.getPageNo(),formDTO.getPageSize(),formDTO.getName(),
formDTO.getContactName(),formDTO.getContactMobile()));
}
@ -108,8 +139,169 @@ public class PropertyManagementController {
public Result delete(@RequestBody IcPropertyManagementFormDTO formDTO){
//效验数据
ValidatorUtils.validateEntity(formDTO, IcPropertyManagementFormDTO.DeleteGroup.class);
propertyManagementService.delete(formDTO);
propertyManagementService.delete(formDTO.getId());
return new Result();
}
/**
* 物业管理-批量删除
*
* @param ids
* @return 返回失败的id列表
*/
@PostMapping("delete-batch")
public Result<List<String>> deleteBatch(@RequestBody List<String> ids) {
if (CollectionUtils.isNotEmpty(ids)) {
List<String> failedIdList = propertyManagementService.deleteBatch(ids);
if(CollectionUtils.isEmpty(failedIdList)){
return new Result<>();
}
Result result = new Result<List<String>>().ok(failedIdList);
result.setMsg("部门物业删除失败");
result.setCode(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode());
return result;
}
return new Result();
}
/**
* 物业管理-下载导入模板
* @param response
* @throws IOException
*/
@RequestMapping(value = "download-tem", method = {RequestMethod.GET, RequestMethod.POST})
public void downloadTemplate(HttpServletResponse response) throws IOException {
response.setCharacterEncoding("UTF-8");
response.addHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, "Content-Disposition");
//response.setHeader(HttpHeaders.CONTENT_TYPE, "application/vnd.ms-excel");
response.setHeader(HttpHeaders.CONTENT_TYPE, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode("物业管理导入模版", "UTF-8") + ".xlsx");
InputStream is = this.getClass().getClassLoader().getResourceAsStream("excel/yantai/ic_property_management_temp.xlsx");
try {
ServletOutputStream os = response.getOutputStream();
IOUtils.copy(is, os);
} finally {
if (is != null) {
is.close();
}
}
}
/**
* 物业管理-列表导出
*
* @param tokenDto
* @param formDTO
* @param response
* @return
* @throws IOException
*/
@PostMapping("export")
public void exportIcPropertyManagement(@LoginUser TokenDto tokenDto, @RequestBody IcPropertyManagementFormDTO formDTO, HttpServletResponse response) throws IOException {
formDTO.setCustomerId(tokenDto.getCustomerId());
ExcelWriter excelWriter = null;
formDTO.setPageNo(NumConstant.ONE);
formDTO.setPageSize(NumConstant.TEN_THOUSAND);
try {
String fileName = "物业管理" + DateUtils.format(new Date()) + ".xlsx";
WriteCellStyle headWriteCellStyle = new WriteCellStyle();
headWriteCellStyle.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex());
WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
FreezeAndFilter writeHandler = new FreezeAndFilter();
excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), IcPropertyManagementDTO.class)
.registerWriteHandler(horizontalCellStyleStrategy)
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
.registerWriteHandler(writeHandler).build();
WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").registerWriteHandler(new FreezeAndFilter()).build();
PageData<IcPropertyManagementDTO> data = null;
do {
data = propertyManagementService.page(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getName(), formDTO.getContactName(), formDTO.getContactMobile());
formDTO.setPageNo(formDTO.getPageNo() + NumConstant.ONE);
excelWriter.write(data.getList(), writeSheet);
} while (CollectionUtils.isNotEmpty(data.getList()) && data.getList().size() == formDTO.getPageSize());
} catch (EpmetException e) {
response.reset();
response.setCharacterEncoding("UTF-8");
response.setHeader("content-type", "application/json; charset=UTF-8");
PrintWriter printWriter = response.getWriter();
Result<Object> result = new Result<>().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), e.getMsg());
printWriter.write(JSON.toJSONString(result));
printWriter.close();
} catch (Exception e) {
log.error("物业管理导出异常export exception", e);
} finally {
if (excelWriter != null) {
excelWriter.finish();
}
}
}
/**
* 获取物业详情
*
* @param id
* @return
*/
@PostMapping("detail/{id}")
public Result<IcPropertyManagementDTO> getDetail(@PathVariable("id") String id) {
if (StringUtils.isBlank(id)) {
return new Result<>();
}
return new Result<IcPropertyManagementDTO>().ok(propertyManagementService.getDetail(id));
}
/**
* 导入excel
*
* @return
*/
@PostMapping("import")
public Result importExcel(@RequestPart("file") MultipartFile file) {
// 1.暂存文件
String originalFilename = file.getOriginalFilename();
String extName = originalFilename.substring(originalFilename.lastIndexOf("."));
Path fileSavePath;
try {
Path importPath = FileUtils.getAndCreateDirUnderEpmetFilesDir(ImportTaskConstants.IC_PROPERTY_MANAGEMENT, "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(ImportTaskConstants.IC_PROPERTY_MANAGEMENT + "表 importExcel 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.IC_PROPERTY_MANAGEMENT),
ServiceConstant.EPMET_COMMON_SERVICE,
EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),
"物业管理导入excel错误",
"物业管理导入excel错误");
// 3.执行导入
propertyManagementService.execAsyncExcelImport(fileSavePath, rstData.getTaskId());
return new Result();
}
}

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

@ -8,16 +8,23 @@ import com.epmet.commons.tools.constant.AppClientConstant;
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.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.service.StaffService;
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 javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.List;
/**
@ -25,6 +32,7 @@ import java.util.List;
* @author zhaoqifeng
* @date 2020/4/23 17:59
*/
@Slf4j
@RestController
@RequestMapping("staff")
public class StaffController {
@ -251,4 +259,34 @@ public class StaffController {
return new Result<List<StaffOrgListResultDTO>>().ok(staffService.staffOrgList(tokenDto));
}
/**
* 下载工作人员导入excel模板
*
* @return
*/
@PostMapping("import/download-template")
public void downloadIcResiDownloadTemplate(HttpServletResponse response) {
InputStream is = null;
ServletOutputStream os = null;
try {
os = response.getOutputStream();
is = this.getClass().getClassLoader().getResourceAsStream("excel/customer_staff_import_template.xlsx");
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
response.setHeader("content-Type", "application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode("工作人员导入模板.xlsx", "UTF-8"));
IOUtils.copy(is, os);
} catch (Exception e) {
String errorStackTrace = ExceptionUtils.getErrorStackTrace(e);
log.error("下载工作人员导入模板失败:{}", errorStackTrace);
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "下载工作人员导入模板失败");
} finally {
org.apache.poi.util.IOUtils.closeQuietly(is);
org.apache.poi.util.IOUtils.closeQuietly(os);
}
}
}

13
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java

@ -224,4 +224,17 @@ public interface IcNeighborHoodDao extends BaseDao<IcNeighborHoodEntity> {
IcNeighborHoodEntity getNeighborHoodInfoByName(CheckHouseInfoFormDTO formDTO);
List<OptionResultDTO> queryNeighborHoodOptions(NeighborHoodOptionFormDTO formDTO);
/**
* label: xxx网格-xxx小区
* @param customerId
* @param agencyId
* @param gridId
* @param neighborHoodName
* @return
*/
List<OptionResultDTO> queryNeighborHoodOptionsYanTai(@Param("customerId") String customerId,
@Param("agencyId") String agencyId,
@Param("gridId") String gridId,
@Param("neighborHoodName") String neighborHoodName);
}

12
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodPropertyDao.java

@ -18,8 +18,12 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.IcNeighborHoodDTO;
import com.epmet.entity.IcNeighborHoodPropertyEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 小区物业关系表
@ -29,5 +33,11 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface IcNeighborHoodPropertyDao extends BaseDao<IcNeighborHoodPropertyEntity> {
/**
* 查询物业下的小区名称
* @param propertyId 物业id
* @param agencyId 组织id
* @return 当前物业在 当前组织及下级范围内管理的小区数量
*/
List<IcNeighborHoodDTO> getNeighborHoodList(@Param("propertyId") String propertyId, @Param("agencyId") String agencyId);
}

3
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcPropertyManagementDao.java

@ -62,5 +62,6 @@ public interface IcPropertyManagementDao extends BaseDao<IcPropertyManagementEnt
List<IcPropertyManagementDTO> queryList(@Param("customerId") String customerId,
@Param("name")String name,
@Param("contactName") String contactName,
@Param("contactMobile") String contactMobile);
@Param("contactMobile") String contactMobile,
@Param("agencyId")String agencyId);
}

120
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/handler/IcPropertyManagementImportListener.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.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.entity.IcPropertyManagementEntity;
import com.epmet.excel.yt.IcPropertyManagementImportExcelData;
import com.epmet.service.impl.IcPropertyManagementServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
/**
* @Description
* @Author yzm
* @Date 2023/5/8 14:23
*/
@Slf4j
public class IcPropertyManagementImportListener implements ReadListener<IcPropertyManagementImportExcelData> {
// 最大条数阈值
public static final int MAX_THRESHOLD = 200;
private String currentCustomerId;
private IcPropertyManagementServiceImpl propertyManagementService;
// 错误项列表
private List<IcPropertyManagementImportExcelData.ErrorRow> errorRows = new ArrayList<>();
// 要插入的数据
private List<IcPropertyManagementEntity> insertDatas = new ArrayList<>();
private List<IcPropertyManagementEntity> updateDatas = new ArrayList<>();
public IcPropertyManagementImportListener(String customerId, IcPropertyManagementServiceImpl propertyManagementService) {
this.currentCustomerId = customerId;
this.propertyManagementService = propertyManagementService;
}
@Override
public void invoke(IcPropertyManagementImportExcelData data, AnalysisContext analysisContext) {
try {
// log.warn("有数据吗?"+JSON.toJSONString(data));
// 不能为空先校验数据
ValidatorUtils.validateEntity(data);
// 去除空格
ObjectUtil.objectToTrim(data);
//物业名称唯一
IcPropertyManagementEntity origin=propertyManagementService.getByName(currentCustomerId, data.getName());
IcPropertyManagementEntity propertyManagementEntity = ConvertUtils.sourceToTarget(data, IcPropertyManagementEntity.class);
propertyManagementEntity.setCustomerId(currentCustomerId);
if (null != origin) {
origin.setContactMobile(data.getContactMobile());
origin.setContactName(data.getContactName());
updateDatas.add(origin);
} else {
insertDatas.add(propertyManagementEntity);
}
if (insertDatas.size() == MAX_THRESHOLD) {
execPersist();
}
if (updateDatas.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).getInternalMsg();
} else {
errorMsg = "未知错误";
log.error("【物业管理表ic_property_management导入】出错:{}", ExceptionUtils.getErrorStackTrace(e));
}
IcPropertyManagementImportExcelData.ErrorRow errorRow = ConvertUtils.sourceToTarget(data, IcPropertyManagementImportExcelData.ErrorRow.class);
errorRow.setErrorInfo(errorMsg);
errorRows.add(errorRow);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
// 最后几条达不到阈值,这里必须再调用一次
execPersist();
}
/**
* 执行持久化
*/
private void execPersist() {
try {
if (CollectionUtils.isNotEmpty(insertDatas)) {
propertyManagementService.insertBatch(insertDatas);
}
if (CollectionUtils.isNotEmpty(updateDatas)) {
propertyManagementService.updateBatchById(updateDatas);
}
} finally {
insertDatas.clear();
updateDatas.clear();
}
}
/**
* 获取错误行
*
* @return
*/
public List<IcPropertyManagementImportExcelData.ErrorRow> getErrorRows() {
return errorRows;
}
}

61
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/yt/IcPropertyManagementImportExcelData.java

@ -0,0 +1,61 @@
package com.epmet.excel.yt;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @Description
* @Author yzm
* @Date 2023/5/8 14:24
*/
@Data
public class IcPropertyManagementImportExcelData {
/**
* 物业名称
*/
@NotBlank(message = "物业名称必填")
@ExcelProperty(value = "*物业名称")
private String name;
/**
* 烟台需求物业联系人姓名
*/
@ExcelProperty(value = "物业联系人")
private String contactName;
/**
* 烟台需求物业联系人电话
*/
@ExcelProperty(value = "联系电话")
private String contactMobile;
@Data
public static class ErrorRow {
/**
* 物业名称
*/
@ExcelProperty(value = "*物业名称")
private String name;
/**
* 烟台需求物业联系人姓名
*/
@ExcelProperty(value = "物业联系人")
private String contactName;
/**
* 烟台需求物业联系人电话
*/
@ExcelProperty(value = "联系电话")
private String contactMobile;
@ColumnWidth(60)
@ExcelProperty("错误信息")
private String errorInfo;
}
}

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

@ -7,6 +7,7 @@ import com.epmet.dto.result.CommunityBuildingManagerDTO;
import com.epmet.dto.result.yt.CommunityBuildingManagerResultDTO;
import com.epmet.entity.CommunityBuildingManagerEntity;
import java.nio.file.Path;
import java.util.List;
/**
@ -63,4 +64,6 @@ public interface CommunityBuildingManagerService extends BaseService<CommunityBu
* @return
*/
void delete(List<String> ids);
void execAsyncExcelImport(Path fileSavePath, String taskId);
}

7
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java

@ -203,4 +203,11 @@ public interface IcNeighborHoodService extends BaseService<IcNeighborHoodEntity>
* @return
*/
List<OptionResultDTO> queryNeighborHoodOptions(NeighborHoodOptionFormDTO formDTO);
/**
* 小区下拉框小区名xxx网格-xxx小区
* @param formDTO
* @return
*/
List<OptionResultDTO> queryNeighborHoodOptionsYanTai(NeighborHoodOptionFormDTO formDTO);
}

9
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcPropertyManagementService.java

@ -92,4 +92,13 @@ public interface IcPropertyManagementService extends BaseService<IcPropertyManag
* @date 2021-10-25
*/
void delete(String[] ids);
/**
* 物业名称客户下唯一
* 这里返回值是对象
* @param customerId
* @param name
* @return
*/
IcPropertyManagementEntity getByName(String customerId,String name);
}

44
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/PropertyManagementService.java

@ -22,6 +22,7 @@ import com.epmet.dto.IcPropertyManagementDTO;
import com.epmet.dto.form.IcPropertyManagementFormDTO;
import com.epmet.dto.result.IcPropertyManagementResultDTO;
import java.nio.file.Path;
import java.util.List;
/**
@ -37,7 +38,46 @@ public interface PropertyManagementService {
String add(IcPropertyManagementFormDTO formDTO);
void update(IcPropertyManagementFormDTO formDTO);
void delete(IcPropertyManagementFormDTO formDTO);
/**
* 物业管理批量删除
* @param id
*/
void delete(String id);
PageData<IcPropertyManagementDTO> page(Integer pageNo, Integer pageSize, String name,String contactName,String contactMobile);
/**
* 物业管理-列表查询
* @param pageNo
* @param pageSize
* @param name 物业名称
* @param contactName 物业联系人
* @param contactMobile 联系电话
* @return
*/
PageData<IcPropertyManagementDTO> page(Integer pageNo,
Integer pageSize,
String name,
String contactName,
String contactMobile);
/**
* 查看物业详情
* @param id
* @return
*/
IcPropertyManagementDTO getDetail(String id);
/**
*
* @param fileSavePath
* @param taskId
*/
void execAsyncExcelImport(Path fileSavePath, String taskId);
/**
* 物业管理批量删除
*
* @param ids
* @return 返回失败的id列表
*/
List<String> deleteBatch(List<String> ids);
}

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

@ -1,5 +1,7 @@
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
@ -21,10 +23,15 @@ import com.epmet.service.CommunityBuildingManagerService;
import com.epmet.service.CustomerGridService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.nio.file.Path;
import java.util.Date;
import java.util.List;
/**
@ -33,6 +40,7 @@ import java.util.List;
* @author generator generator@elink-cn.com
* @since v1.0.0 2023-05-06
*/
@Slf4j
@Service
public class CommunityBuildingManagerServiceImpl extends BaseServiceImpl<CommunityBuildingManagerDao, CommunityBuildingManagerEntity> implements CommunityBuildingManagerService {
@ -65,7 +73,7 @@ public class CommunityBuildingManagerServiceImpl extends BaseServiceImpl<Communi
formDTO.getBuildingId(),
formDTO.getUnitId(), null);
PageInfo<CommunityBuildingManagerResultDTO> pageInfo = new PageInfo<>(resList);
return new PageData<>(resList, pageInfo.getTotal(),formDTO.getPageSize());
return new PageData<>(resList, pageInfo.getTotal(), formDTO.getPageSize());
}
/**
@ -105,13 +113,27 @@ public class CommunityBuildingManagerServiceImpl extends BaseServiceImpl<Communi
@Override
@Transactional(rollbackFor = Exception.class)
public void save(CommunityBuildingManagerDTO addFormDto) {
// 唯一性判断,同一个楼可以有多个楼长吗?待定。。。
// 唯一性判断,类型+楼栋id或者类型+单元id唯一
checkUnqiue(addFormDto.getType(), addFormDto.getBuildingId(), addFormDto.getUnitId(), null);
CommunityBuildingManagerEntity entity = ConvertUtils.sourceToTarget(addFormDto, CommunityBuildingManagerEntity.class);
CustomerGridDTO gridDTO = SpringContextUtils.getBean(CustomerGridService.class).get(addFormDto.getGridId());
entity.setOrgIdPath(PidUtils.convertPid2OrgIdPath(gridDTO.getId(), gridDTO.getPids()));
insert(entity);
}
private void checkUnqiue(String type, String buildingId, String unitId, String id) {
// 1号楼只允许有一个楼长
// 1号楼只允许有一个单元长
LambdaQueryWrapper<CommunityBuildingManagerEntity> countQuery = new LambdaQueryWrapper<>();
countQuery.eq(CommunityBuildingManagerEntity::getType, type)
.eq(CommunityBuildingManagerEntity::getBuildingId, buildingId)
.eq(StringUtils.isNotBlank(unitId), CommunityBuildingManagerEntity::getUnitId, unitId)
.ne(StringUtils.isNotBlank(id), CommunityBuildingManagerEntity::getId, id);
if (baseDao.selectCount(countQuery) > NumConstant.ZERO) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所选楼栋(单元)已存在楼长(单元长)", "所选楼栋(单元)已存在楼长(单元长)");
}
}
/**
* 编辑楼长/单元长
* todo: 同步到具体的楼栋
@ -122,6 +144,7 @@ public class CommunityBuildingManagerServiceImpl extends BaseServiceImpl<Communi
@Override
@Transactional(rollbackFor = Exception.class)
public void update(CommunityBuildingManagerDTO updateFormDto) {
checkUnqiue(updateFormDto.getType(), updateFormDto.getBuildingId(), updateFormDto.getUnitId(), updateFormDto.getId());
CommunityBuildingManagerEntity entity = ConvertUtils.sourceToTarget(updateFormDto, CommunityBuildingManagerEntity.class);
CustomerGridDTO gridDTO = SpringContextUtils.getBean(CustomerGridService.class).get(updateFormDto.getGridId());
entity.setOrgIdPath(PidUtils.convertPid2OrgIdPath(gridDTO.getId(), gridDTO.getPids()));
@ -138,7 +161,31 @@ public class CommunityBuildingManagerServiceImpl extends BaseServiceImpl<Communi
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(List<String> ids) {
baseDao.deleteBatchIds(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
});
}
/**
* 执行Excel导入
*
* @param filePath
* @param importTaskId
*/
@Async
@Override
public void execAsyncExcelImport(Path filePath, String importTaskId) {
// todo
return;
}
}

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

@ -243,6 +243,8 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver {
icHouseDTO.setHouseTypeName(HouseTypeEnums.getTypeValue(formDTO.getHouseType()));
icHouseDTO.setPurposeName(HousePurposeEnums.getTypeValue(formDTO.getPurpose()));
icHouseDTO.setRentName(HouseRentFlagEnums.getTypeValue(formDTO.getRentFlag()));
icHouseDTO.setFloor(formDTO.getFloor());
icHouseDTO.setArea(formDTO.getArea());
//设置
icHouseDTO.setHouseName(getHouseName(formDTO));
icHouseDTO.setFullName(icHouseService.getFullName(formDTO.getNeighborHoodId(), formDTO.getBuildingId(), formDTO.getBuildingUnitId(), formDTO.getDoorName()));

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

@ -854,6 +854,23 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
result.setGridName(gridInfoCache.getGridName());
}
result.setPropertyList(propertyManagementDao.selectPropertyNameList(neighborhoodId));
if (StringUtils.isNotBlank(result.getOpenType())){
if (result.getOpenType().equals("1")){
result.setOpenTypeName("封闭式");
}
if (result.getOpenType().equals("2")){
result.setOpenTypeName("开放式");
}
}
if (StringUtils.isNotBlank(result.getViliageType())){
if (result.getViliageType().equals("1")){
result.setViliageTypeName("住宅小区");
}
if (result.getViliageType().equals("2")){
result.setViliageTypeName("自然村");
}
}
return new Result<IcNeighborHoodDetailDTO>().ok(result);
}
@ -875,9 +892,20 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
}
/**
* 小区下拉框小区名xxx网格-xxx小区
*
* @param formDTO
* @return
*/
@Override
public List<OptionResultDTO> queryNeighborHoodOptionsYanTai(NeighborHoodOptionFormDTO formDTO) {
if (StringUtils.isBlank(formDTO.getGridId()) && StringUtils.isBlank(formDTO.getAgencyId())) {
// 默认查询当前工作人员所属组织及下级的
CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId());
formDTO.setAgencyId(staffInfoCacheResult.getAgencyId());
}
List<OptionResultDTO> list = baseDao.queryNeighborHoodOptionsYanTai(formDTO.getCustomerId(),formDTO.getAgencyId(),formDTO.getGridId(),formDTO.getNeighborHoodName());
return list;
}
}

7
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcPropertyManagementServiceImpl.java

@ -17,6 +17,7 @@
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
@ -97,4 +98,10 @@ public class IcPropertyManagementServiceImpl extends BaseServiceImpl<IcPropertyM
baseDao.deleteBatchIds(Arrays.asList(ids));
}
@Override
public IcPropertyManagementEntity getByName(String customerId, String name) {
LambdaQueryWrapper<IcPropertyManagementEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IcPropertyManagementEntity::getCustomerId,customerId).eq(IcPropertyManagementEntity::getName,name);
return baseDao.selectOne(wrapper);
}
}

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

@ -1,39 +1,75 @@
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.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.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.EpmetRequestHolder;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.*;
import com.epmet.constants.ImportTaskConstants;
import com.epmet.dao.IcNeighborHoodPropertyDao;
import com.epmet.dao.IcPropertyManagementDao;
import com.epmet.dto.IcNeighborHoodDTO;
import com.epmet.dto.IcPropertyManagementDTO;
import com.epmet.dto.form.IcPropertyManagementFormDTO;
import com.epmet.dto.form.ImportTaskCommonFormDTO;
import com.epmet.dto.result.IcPropertyManagementResultDTO;
import com.epmet.dto.result.UploadImgResultDTO;
import com.epmet.entity.IcNeighborHoodPropertyEntity;
import com.epmet.entity.IcPropertyManagementEntity;
import com.epmet.excel.handler.IcPropertyManagementImportListener;
import com.epmet.excel.yt.IcPropertyManagementImportExcelData;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.feign.OssFeignClient;
import com.epmet.service.PropertyManagementService;
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.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.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.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.Date;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
@Slf4j
@Service
public class PropertyManagementServiceImpl implements PropertyManagementService {
/**
* 物业表
*/
@Resource
private IcPropertyManagementDao icPropertyManagementDao;
@Resource
private IcNeighborHoodPropertyDao icNeighborHoodPropertyDao;
@Autowired
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient;
@Autowired
private OssFeignClient ossFeignClient;
/**
* 查询当前客户下的物业
@ -57,72 +93,289 @@ public class PropertyManagementServiceImpl implements PropertyManagementService
/**
* 新增物业
* 名称客户下唯一
*
* @param formDTO
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public String add(IcPropertyManagementFormDTO formDTO) {
//物业名字平台内唯一
//如果输入的物业名字已经存在,直接返回物业id
// 物业名字平台内唯一
// 如果输入的物业名字已经存在,直接返回物业id
formDTO.setName(formDTO.getName().trim());
IcPropertyManagementEntity entity = icPropertyManagementDao.selectByName(formDTO.getCustomerId(),formDTO.getName(),null);
IcPropertyManagementEntity entity = icPropertyManagementDao.selectByName(formDTO.getCustomerId(), formDTO.getName(), null);
if (null != entity) {
return entity.getId();
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "物业名称已存在", "物业名称已存在");
}
IcPropertyManagementEntity icPropertyManagementEntity = ConvertUtils.sourceToTarget(formDTO, IcPropertyManagementEntity.class);
icPropertyManagementDao.insert(icPropertyManagementEntity);
if (CollectionUtils.isNotEmpty(formDTO.getNeighborHoodIdList())) {
formDTO.getNeighborHoodIdList().forEach(neighborHoodId -> {
// 插入小区物业关系表
IcNeighborHoodPropertyEntity neighborHoodPropertyEntity = new IcNeighborHoodPropertyEntity();
neighborHoodPropertyEntity.setPropertyId(icPropertyManagementEntity.getId());
neighborHoodPropertyEntity.setNeighborHoodId(neighborHoodId);
icNeighborHoodPropertyDao.insert(neighborHoodPropertyEntity);
});
}
return icPropertyManagementEntity.getId();
}
/**
* 物业管理-修改
*
* @param formDTO
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void update(IcPropertyManagementFormDTO formDTO) {
IcPropertyManagementEntity entity = icPropertyManagementDao.selectByName(EpmetRequestHolder.getLoginUserCustomerId(),formDTO.getName(),formDTO.getId());
IcPropertyManagementEntity entity = icPropertyManagementDao.selectByName(EpmetRequestHolder.getLoginUserCustomerId(), formDTO.getName(), formDTO.getId());
if (null != entity) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"物业名称已存在","物业名称已存在");
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "物业名称已存在", "物业名称已存在");
}
LambdaUpdateWrapper<IcPropertyManagementEntity> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IcPropertyManagementEntity::getId, formDTO.getId())
.set(IcPropertyManagementEntity::getName, formDTO.getName())
.set(IcPropertyManagementEntity::getContactName, formDTO.getContactName())
.set(IcPropertyManagementEntity::getContactMobile, formDTO.getContactMobile())
.set(IcPropertyManagementEntity::getUpdatedTime, new Date())
.set(IcPropertyManagementEntity::getUpdatedBy, EpmetRequestHolder.getLoginUserId());
icPropertyManagementDao.update(null, updateWrapper);
CustomerStaffInfoCacheResult staffInfoCacheResult= CustomerStaffRedis.getStaffInfo(EpmetRequestHolder.getLoginUserCustomerId(),EpmetRequestHolder.getLoginUserId());
// 查询当前物业,在本组织及下级范围内,管理的小区
List<IcNeighborHoodDTO> originNeighborHoodList = icNeighborHoodPropertyDao.getNeighborHoodList(formDTO.getId(), staffInfoCacheResult.getAgencyId());
// 原来存在关联的小区,现在取消勾选了,需要删除物业小区关系表
originNeighborHoodList.forEach(origin -> {
// 举例:原来管理A小区,现在取消勾选
if (!formDTO.getNeighborHoodIdList().contains(origin.getId())) {
LambdaUpdateWrapper<IcNeighborHoodPropertyEntity> updateWrapper1 = new LambdaUpdateWrapper<>();
updateWrapper1.eq(IcNeighborHoodPropertyEntity::getPropertyId, formDTO.getId())
.eq(IcNeighborHoodPropertyEntity::getNeighborHoodId, origin.getId())
.set(IcNeighborHoodPropertyEntity::getDelFlag, NumConstant.ONE_STR)
.set(IcNeighborHoodPropertyEntity::getUpdatedTime, new Date())
.set(IcNeighborHoodPropertyEntity::getUpdatedBy, EpmetRequestHolder.getLoginUserId());
icNeighborHoodPropertyDao.update(null, updateWrapper1);
}
});
if (CollectionUtils.isNotEmpty(formDTO.getNeighborHoodIdList())) {
formDTO.getNeighborHoodIdList().forEach(neighborHoodId -> {
LambdaQueryWrapper<IcNeighborHoodPropertyEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(IcNeighborHoodPropertyEntity::getPropertyId, formDTO.getId())
.eq(IcNeighborHoodPropertyEntity::getNeighborHoodId, neighborHoodId);
if (icNeighborHoodPropertyDao.selectCount(queryWrapper) < NumConstant.ONE) {
// 插入小区物业关系表
IcNeighborHoodPropertyEntity neighborHoodPropertyEntity = new IcNeighborHoodPropertyEntity();
neighborHoodPropertyEntity.setPropertyId(formDTO.getId());
neighborHoodPropertyEntity.setNeighborHoodId(neighborHoodId);
icNeighborHoodPropertyDao.insert(neighborHoodPropertyEntity);
}
//原本已经存在小区和物业的关系,不用再插入
});
}
LambdaUpdateWrapper<IcPropertyManagementEntity> updateWrapper=new LambdaUpdateWrapper<>();
updateWrapper.eq(IcPropertyManagementEntity::getId,formDTO.getId())
.set(IcPropertyManagementEntity::getName,formDTO.getName())
.set(IcPropertyManagementEntity::getContactName,formDTO.getContactName())
.set(IcPropertyManagementEntity::getContactMobile,formDTO.getContactMobile())
.set(IcPropertyManagementEntity::getUpdatedTime,new Date())
.set(IcPropertyManagementEntity::getUpdatedBy,EpmetRequestHolder.getLoginUserId());
icPropertyManagementDao.update(null,updateWrapper);
}
/**
* 单个删除
* @param formDTO
*
* @param id
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(IcPropertyManagementFormDTO formDTO) {
LambdaQueryWrapper<IcNeighborHoodPropertyEntity> queryWrapper=new LambdaQueryWrapper<>();
queryWrapper.eq(IcNeighborHoodPropertyEntity::getPropertyId,formDTO.getId());
if (icNeighborHoodPropertyDao.selectCount(queryWrapper) > 0) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"物业存在与小区关联,无法删除","已与小区关联,无法删除");
public void delete(String id) {
Date now = new Date();
// 删除物业与小区关联关系表
LambdaUpdateWrapper<IcNeighborHoodPropertyEntity> updateWrapper1 = new LambdaUpdateWrapper<>();
updateWrapper1.eq(IcNeighborHoodPropertyEntity::getPropertyId, id)
.set(IcNeighborHoodPropertyEntity::getDelFlag, NumConstant.ONE_STR)
.set(IcNeighborHoodPropertyEntity::getUpdatedTime, now)
.set(IcNeighborHoodPropertyEntity::getUpdatedBy, EpmetRequestHolder.getLoginUserId());
icNeighborHoodPropertyDao.update(null, updateWrapper1);
// 删除物业表
LambdaUpdateWrapper<IcPropertyManagementEntity> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IcPropertyManagementEntity::getId, id)
.set(IcPropertyManagementEntity::getDelFlag, NumConstant.ONE_STR)
.set(IcPropertyManagementEntity::getUpdatedTime, now)
.set(IcPropertyManagementEntity::getUpdatedBy, EpmetRequestHolder.getLoginUserId());
icPropertyManagementDao.update(null, updateWrapper);
}
/**
* 物业管理批量删除
*
* @param ids
* @return 返回失败的id列表
*/
@Override
@Transactional(rollbackFor = Exception.class)
public List<String> deleteBatch(List<String> ids) {
if (CollectionUtils.isEmpty(ids)) {
return new ArrayList<>();
}
List<String> failedIdList = new ArrayList<>();
for (String id : ids) {
Boolean res =true;
try{
//调用单挑删除方法
delete(id);
}catch(EpmetException e){
res=false;
}
if (!res) {
failedIdList.add(id);
}
}
icPropertyManagementDao.deleteById(formDTO.getId());
return failedIdList;
}
/**
* 物业管理-列表查询
*
* @param pageNo
* @param pageSize
* @param name
* @param name 物业名称
* @param contactName 物业联系人
* @param contactMobile 联系电话
* @return
*/
@Override
public PageData<IcPropertyManagementDTO> page(Integer pageNo, Integer pageSize, String name,String contactName,String contactMobile) {
PageHelper.startPage(pageNo,pageSize);
List<IcPropertyManagementDTO> list=icPropertyManagementDao.queryList(EpmetRequestHolder.getLoginUserCustomerId(),name,contactName,contactMobile);
public PageData<IcPropertyManagementDTO> page(Integer pageNo, Integer pageSize, String name, String contactName, String contactMobile) {
CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(EpmetRequestHolder.getLoginUserCustomerId(), EpmetRequestHolder.getLoginUserId());
PageHelper.startPage(pageNo, pageSize);
List<IcPropertyManagementDTO> list = icPropertyManagementDao.queryList(EpmetRequestHolder.getLoginUserCustomerId(), name, contactName, contactMobile, staffInfoCacheResult.getAgencyId());
PageInfo<IcPropertyManagementDTO> pageInfo = new PageInfo<>(list);
return new PageData<>(list, pageInfo.getTotal(),pageSize);
// 导出时需要导出关联的小区名称
pageInfo.getList().forEach(result -> {
List<IcNeighborHoodDTO> neighborHoodList = icNeighborHoodPropertyDao.getNeighborHoodList(result.getId(), staffInfoCacheResult.getAgencyId());
List<String> neighborHoodNames = neighborHoodList.stream()
.map(IcNeighborHoodDTO::getNeighborHoodName)
.distinct().collect(Collectors.toList());
result.setNeighborHoodNames(CollectionUtils.isNotEmpty(neighborHoodList) ? StringUtils.join(neighborHoodNames, StrConstant.COMMA_ZH) : StrConstant.EPMETY_STR);
result.setNeighborHoodList(neighborHoodList);
result.setTotalNeighborHood(CollectionUtils.isNotEmpty(neighborHoodList)?neighborHoodList.size():NumConstant.ZERO);
});
return new PageData<>(list, pageInfo.getTotal(), pageSize);
}
/**
* 查看物业详情
*
* @param id
* @return
*/
@Override
public IcPropertyManagementDTO getDetail(String id) {
CustomerStaffInfoCacheResult staffInfoCacheResult= CustomerStaffRedis.getStaffInfo(EpmetRequestHolder.getLoginUserCustomerId(),EpmetRequestHolder.getLoginUserId());
IcPropertyManagementEntity icPropertyManagementEntity = icPropertyManagementDao.selectById(id);
if (null == icPropertyManagementEntity) {
return null;
}
IcPropertyManagementDTO resultDto = ConvertUtils.sourceToTarget(icPropertyManagementEntity, IcPropertyManagementDTO.class);
List<IcNeighborHoodDTO> neighborHoodList = icNeighborHoodPropertyDao.getNeighborHoodList(id,staffInfoCacheResult.getAgencyId());
List<String> neighborHoodNames = neighborHoodList.stream()
.map(IcNeighborHoodDTO::getNeighborHoodName)
.distinct().collect(Collectors.toList());
resultDto.setNeighborHoodNames(CollectionUtils.isNotEmpty(neighborHoodList) ? StringUtils.join(neighborHoodNames, StrConstant.COMMA_ZH) : StrConstant.EPMETY_STR);
resultDto.setNeighborHoodList(neighborHoodList);
resultDto.setTotalNeighborHood(CollectionUtils.isNotEmpty(neighborHoodList)?neighborHoodList.size():NumConstant.ZERO);
return resultDto;
}
/**
* 执行Excel导入
*
* @param filePath
* @param importTaskId
*/
@Async
@Override
public void execAsyncExcelImport(Path filePath, String importTaskId) {
String userId = null;
try {
userId = EpmetRequestHolder.getLoginUserId();
String customerId = EpmetRequestHolder.getLoginUserCustomerId();
IcPropertyManagementImportListener listener = new IcPropertyManagementImportListener(customerId, SpringContextUtils.getBean(IcPropertyManagementServiceImpl.class));
EasyExcel.read(filePath.toFile(), IcPropertyManagementImportExcelData.class, listener).headRowNumber(1).sheet(0).doRead();
String errorDesFileUrl = null;
List<IcPropertyManagementImportExcelData.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.IC_PROPERTY_MANAGEMENT, "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("【物业管理表ic_property_management】删除错误描述临时文件失败:{}", 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("【物业管理表ic_property_management】finishImportTask失败");
}
} catch (Exception e) {
String errorMsg = ExceptionUtils.getErrorStackTrace(e);
log.error("【物业管理表ic_property_management】出错:{}", errorMsg);
ImportTaskCommonFormDTO importFinishTaskForm = new ImportTaskCommonFormDTO();
importFinishTaskForm.setTaskId(importTaskId);
importFinishTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL);
importFinishTaskForm.setOperatorId(userId);
importFinishTaskForm.setResultDesc("城市管理图层导入失败:系统异常,请查看系统日志");
Result result = commonServiceOpenFeignClient.finishImportTask(importFinishTaskForm);
if (!result.success()) {
log.error("【物业管理表ic_property_management】导入记录状态修改为'完成'失败");
}
} finally {
// 删除临时文件
if (Files.exists(filePath)) {
try {
Files.delete(filePath);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}

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/yantai/community_building_manager_import_temp.xlsx

Binary file not shown.

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

Binary file not shown.

6
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CommunityBuildingManagerDao.xml

@ -30,6 +30,12 @@
<select id="pageList" parameterType="map" resultType="com.epmet.dto.result.yt.CommunityBuildingManagerResultDTO">
SELECT
m.*,
(
case when m.type='0' then '楼长'
when m.type='1' then '单元长'
else '-'
end
)as typeName,
d.ORGANIZATION_NAME AS districtName,
s.ORGANIZATION_NAME AS streetName,
c.ORGANIZATION_NAME AS communityName,

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

@ -130,7 +130,11 @@
d.PROPERTY_ID as propertyId ,
a.LOCATION as location,
a.LONGITUDE as longitude,
a.LATITUDE as latitude
a.LATITUDE as latitude,
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
from ic_neighbor_hood a
left join customer_agency b on a.AGENCY_ID = b.ID and b.DEL_FLAG='0'
@ -695,4 +699,26 @@
ORDER BY
h.NEIGHBOR_HOOD_NAME ASC
</select>
<select id="queryNeighborHoodOptionsYanTai" parameterType="map" resultType="com.epmet.commons.tools.dto.result.OptionResultDTO">
SELECT
concat(cg.grid_name,'-',h.NEIGHBOR_HOOD_NAME) as label,
h.ID as `value`
FROM
ic_neighbor_hood h
left join customer_grid cg on(h.grid_id=cg.id)
WHERE
h.DEL_FLAG = '0'
AND h.CUSTOMER_ID = #{customerId}
<if test=" null != agencyId and agencyId != ''">
AND ( h.AGENCY_ID = #{agencyId} OR h.AGENCY_PIDS LIKE concat( '%', #{agencyId}, '%' ) )
</if>
<if test=" null != neighborHoodName and neighborHoodName != ''">
and h.NEIGHBOR_HOOD_NAME like concat('%',#{neighborHoodName},'%')
</if>
<if test=" null != gridId and gridId != ''">
and h.GRID_ID=#{gridId}
</if>
ORDER BY h.NEIGHBOR_HOOD_NAME ASC
</select>
</mapper>

16
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodPropertyDao.xml

@ -15,5 +15,19 @@
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<!-- 当前物业在 当前组织及下级范围内,管理的小区数量 -->
<select id="getNeighborHoodList" parameterType="java.lang.String" resultType="com.epmet.dto.IcNeighborHoodDTO">
SELECT
p.NEIGHBOR_HOOD_ID as id,
h.NEIGHBOR_HOOD_NAME
FROM
ic_neighbor_hood_property p
INNER JOIN ic_neighbor_hood h ON ( p.NEIGHBOR_HOOD_ID = h.ID )
WHERE
p.PROPERTY_ID = #{propertyId}
AND (h.AGENCY_ID = #{agencyId} or h.AGENCY_PIDS like concat('%',#{agencyId},'%') )
AND p.DEL_FLAG = '0'
AND h.DEL_FLAG = '0'
order by h.CREATED_TIME asc
</select>
</mapper>

4
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcPropertyManagementDao.xml

@ -71,9 +71,7 @@
</select>
<select id="queryList" parameterType="map" resultType="com.epmet.dto.IcPropertyManagementDTO">
select m.*,(
select count(pr.NEIGHBOR_HOOD_ID) from ic_neighbor_hood_property pr where pr.PROPERTY_ID=m.id and pr.del_flag='0'
)as totalNeighborHood
select m.*
from ic_property_management m
where m.del_flag='0'
and m.customer_id=#{customerId}

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

@ -514,13 +514,13 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
staffEntity.setMobile(fromDTO.getMobile());
staffEntity.setGender(fromDTO.getGender());
staffEntity.setWorkType(fromDTO.getWorkType());
staffEntity.setIdCard(customerStaffDTO.getIdCard());
staffEntity.setCulture(customerStaffDTO.getCulture());
staffEntity.setDuty(customerStaffDTO.getDuty());
staffEntity.setPartyPosition(customerStaffDTO.getPartyPosition());
staffEntity.setViliagePosition(customerStaffDTO.getViliagePosition());
staffEntity.setRemark(customerStaffDTO.getRemark());
staffEntity.setAddress(customerStaffDTO.getAddress());
staffEntity.setIdCard(fromDTO.getIdCard());
staffEntity.setCulture(fromDTO.getCulture());
staffEntity.setDuty(fromDTO.getDuty());
staffEntity.setPartyPosition(fromDTO.getPartyPosition());
staffEntity.setViliagePosition(fromDTO.getViliagePosition());
staffEntity.setRemark(fromDTO.getRemark());
staffEntity.setAddress(fromDTO.getAddress());
baseDao.updateById(staffEntity);
//清空权限关联

Loading…
Cancel
Save