wangxianzhang 3 years ago
parent
commit
073aa6a189
  1. 5
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java
  2. 39
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcSocietyOrgDTO.java
  3. 19
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/AddSocietyOrgFormDTO.java
  4. 17
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/EditSocietyOrgFormDTO.java
  5. 8
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/GetListSocietyOrgResultDTO.java
  6. 8
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/SocietyOrgListResultDTO.java
  7. 171
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcSocietyOrgController.java
  8. 4
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcSocietyOrgDao.java
  9. 9
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcSocietyOrgEntity.java
  10. 27
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcSocietyOrgExcel.java
  11. 42
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcSocietyOrgExportExcel.java
  12. 74
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcSocietyOrgImportExcelDTO.java
  13. 157
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/handler/IcSocietyOrgExcelImportListener.java
  14. 10
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcSocietyOrgService.java
  15. 244
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcSocietyOrgServiceImpl.java
  16. 13
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcSocietyOrgDao.xml
  17. BIN
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/templates/societyorg_import_template.xlsx
  18. 8
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/grid/controller/ResiMineGridController.java
  19. 34
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java
  20. 2
      epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

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

@ -62,4 +62,9 @@ public interface ImportTaskConstants {
* 城市管理
*/
String IC_CITY_MANAGEMENT = "ic_city_management";
/**
* 社会组织
*/
String IC_SOCIETY_ORG="ic_society_org";
}

39
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcSocietyOrgDTO.java

@ -39,6 +39,11 @@ public class IcSocietyOrgDTO implements Serializable {
*/
private String id;
/**
* 图片地址
*/
private String imgUrl;
/**
* 客户Id
*/
@ -74,6 +79,11 @@ public class IcSocietyOrgDTO implements Serializable {
*/
private String mobile;
/**
* 服务时间
*/
private String serviceTimeStr;
/**
* 起始服务时间
*/
@ -109,34 +119,5 @@ public class IcSocietyOrgDTO implements Serializable {
*/
private String remarks;
/**
* 删除标识0.未删除 1.已删除
*/
private Integer delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

19
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/AddSocietyOrgFormDTO.java

@ -23,7 +23,7 @@ import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
import java.util.Date;
@ -48,6 +48,11 @@ public class AddSocietyOrgFormDTO implements Serializable {
* agency_id的所有上级
*/
private String pids;
/**
* 社会组织头像
*/
@NotEmpty(message = "组织头像不能为空", groups = { AddSocietyOrgFormDTO.Add.class})
private String[] imageList;
/**
* 社会组织名称
*/
@ -63,7 +68,7 @@ public class AddSocietyOrgFormDTO implements Serializable {
/**
* 负责人
*/
@NotBlank(message = "负责人名称不能为空", groups = { AddSocietyOrgFormDTO.Add.class })
//@NotBlank(message = "负责人名称不能为空", groups = { AddSocietyOrgFormDTO.Add.class })
@Length(max = 20, message = "负责人名称不能超过20个字符",groups = {Add.class})
private String personInCharge;
/**
@ -72,22 +77,24 @@ public class AddSocietyOrgFormDTO implements Serializable {
@NotBlank(message = "负责人电话不能为空", groups = { AddSocietyOrgFormDTO.Add.class })
@Length(max = 11, message = "负责人电话不能超过11个字符",groups = {Add.class})
private String mobile;
/**
* 服务时间
*/
@NotBlank(message = "服务时间不能为空", groups = { AddSocietyOrgFormDTO.Add.class })
private String serviceTimeStr;
/**
* 起始服务时间
*/
@NotNull(message = "起始服务时间不能为空", groups = { AddSocietyOrgFormDTO.Add.class })
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date serviceStartTime;
/**
* 终止服务时间
*/
@NotNull(message = "终止服务时间不能为空", groups = { AddSocietyOrgFormDTO.Add.class })
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date serviceEndTime;
/**
* 绑定管理员[组织下录入的工作人员]
*/
@NotBlank(message = "绑定管理员名称不能为空", groups = { AddSocietyOrgFormDTO.Add.class })
private String adminStaffId;
/**
* 地址
@ -106,4 +113,4 @@ public class AddSocietyOrgFormDTO implements Serializable {
public interface Add extends CustomerClientShowGroup {}
}
}

17
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/EditSocietyOrgFormDTO.java

@ -22,6 +22,7 @@ import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
import java.util.Date;
@ -40,6 +41,12 @@ public class EditSocietyOrgFormDTO implements Serializable {
*/
@NotBlank(message = "社会组织Id不能为空", groups = { Edit.class, Del.class })
private String societyId;
/**
* 社会组织头像
*/
@NotEmpty(message = "组织头像不能为空", groups = { Edit.class})
private String[] imageList;
/**
* 社会组织名称
*/
@ -53,13 +60,19 @@ public class EditSocietyOrgFormDTO implements Serializable {
/**
* 负责人
*/
@Length(max = 20, message = "负责人名称不能超过20个字符",groups = {Edit.class})
//@Length(max = 20, message = "负责人名称不能超过20个字符",groups = {Edit.class})
private String personInCharge;
/**
* 负责人电话
*/
@Length(max = 11, message = "负责人电话不能超过11个字符",groups = {Edit.class})
private String mobile;
/**
* 服务时间
*/
@NotBlank(message = "服务时间不能为空",groups = {Edit.class})
private String serviceTimeStr;
/**
* 起始服务时间
*/
@ -92,4 +105,4 @@ public class EditSocietyOrgFormDTO implements Serializable {
public interface Edit {}
public interface Del {}
}
}

8
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/GetListSocietyOrgResultDTO.java

@ -44,6 +44,10 @@ public class GetListSocietyOrgResultDTO implements Serializable {
private String agencyId;
//社会组织Id
private String societyId;
/**
* 社会组织头像
*/
private String imgUrl;
//社会组织名称
private String societyName;
//服务事项
@ -52,6 +56,10 @@ public class GetListSocietyOrgResultDTO implements Serializable {
private String personInCharge;
//负责人电话
private String mobile;
/**
* 服务时间
*/
private String serviceTimeStr;
//起始服务时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date serviceStartTime;

8
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/SocietyOrgListResultDTO.java

@ -35,6 +35,10 @@ public class SocietyOrgListResultDTO implements Serializable {
private String agencyName;
//社会组织Id
private String societyId;
/**
* 图像
*/
private String imgUrl;
//社会组织名称
private String societyName;
//服务事项
@ -43,6 +47,10 @@ public class SocietyOrgListResultDTO implements Serializable {
private String personInCharge;
//负责人电话
private String mobile;
/**
* 服务时间
*/
private String serviceTimeStr;
//起始服务时间
//@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
//private Date serviceStartTime;

171
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcSocietyOrgController.java

@ -18,34 +18,55 @@
package com.epmet.controller;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.constant.AppClientConstant;
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.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ExcelPoiUtils;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.*;
import com.epmet.commons.tools.utils.poi.excel.handler.FreezeAndFilter;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.constants.ImportTaskConstants;
import com.epmet.dto.IcSocietyOrgDTO;
import com.epmet.dto.form.AddSocietyOrgFormDTO;
import com.epmet.dto.form.EditSocietyOrgFormDTO;
import com.epmet.dto.form.GetListSocietyOrgFormDTO;
import com.epmet.dto.form.ImportTaskCommonFormDTO;
import com.epmet.dto.form.demand.ServiceQueryFormDTO;
import com.epmet.dto.result.GetListSocietyOrgResultDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.dto.result.demand.OptionDTO;
import com.epmet.excel.IcSocietyOrgExcel;
import com.epmet.excel.IcSocietyOrgExportExcel;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.service.IcSocietyOrgService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
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.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.net.URLEncoder;
import java.nio.file.Path;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
@ -58,11 +79,13 @@ import java.util.stream.Collectors;
@Slf4j
@RestController
@RequestMapping("societyorg")
public class IcSocietyOrgController {
public class IcSocietyOrgController implements ResultDataResolver {
private static final String DEFAULT_NO_IMG = "https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/20220826/38eb186191ab48fe8d3920b642b56e64.png";
@Autowired
private IcSocietyOrgService societyOrgService;
@Autowired
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient;
/**
* @Author sun
* @Description 新增社会组织
@ -87,6 +110,19 @@ public class IcSocietyOrgController {
return new Result();
}
/**
* @Author sun
* @Description 删除社会组织
**/
@RequestMapping("detail/{id}")
public Result detail(@LoginUser TokenDto tokenDto, @PathVariable(value = "id") String id) {
IcSocietyOrgDTO icSocietyOrgDTO = societyOrgService.get(id);
if (StringUtils.isBlank(icSocietyOrgDTO.getImgUrl())){
icSocietyOrgDTO.setImgUrl(DEFAULT_NO_IMG);
}
return new Result().ok(icSocietyOrgDTO);
}
/**
* @Author sun
* @Description 删除社会组织
@ -129,14 +165,50 @@ public class IcSocietyOrgController {
**/
@PostMapping("export")
public void export(@LoginUser TokenDto tokenDto, @RequestBody GetListSocietyOrgFormDTO formDTO, HttpServletResponse response) throws Exception {
//废弃原来的导出
// formDTO.setCustomerId(tokenDto.getCustomerId());
// formDTO.setStaffId(tokenDto.getUserId());
// formDTO.setIsPage(false);
// GetListSocietyOrgResultDTO list = societyOrgService.getList(formDTO);
// ExcelUtils.exportExcelToTarget(response, null, list.getList(), IcSocietyOrgExportExcel.class);
formDTO.setCustomerId(tokenDto.getCustomerId());
formDTO.setStaffId(tokenDto.getUserId());
formDTO.setIsPage(false);
GetListSocietyOrgResultDTO list = societyOrgService.getList(formDTO);
ExcelUtils.exportExcelToTarget(response, null, list.getList(), IcSocietyOrgExcel.class);
ExcelWriter excelWriter = null;
formDTO.setPageNo(NumConstant.ONE);
formDTO.setPageSize(NumConstant.TEN_THOUSAND);
try {
String fileName = "社会组织" + DateUtils.format(new Date()) + ".xlsx";
excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), IcSocietyOrgExportExcel.class).build();
WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").registerWriteHandler(new FreezeAndFilter()).build();
GetListSocietyOrgResultDTO data = null;
List<IcSocietyOrgExportExcel> list = null;
do {
data = societyOrgService.getList(formDTO);
list = ConvertUtils.sourceToTarget(data.getList(), IcSocietyOrgExportExcel.class);
formDTO.setPageNo(formDTO.getPageNo() + NumConstant.ONE);
excelWriter.write(list, writeSheet);
} while (org.apache.commons.collections4.CollectionUtils.isNotEmpty(list) && list.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();
}
}
}
/**
* 废弃此方法用下面的importV2
* @Author sun
* @Description 九小场所下组织列表导入
**/
@ -168,4 +240,83 @@ public class IcSocietyOrgController {
return new Result().ok(str);
}
/**
* 下载社会组织导入模板
* @param response
* @throws IOException
*/
@RequestMapping(value = "import-template-download", 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.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode("社区组织导入模板", "UTF-8") + ".xlsx");
InputStream is = this.getClass().getClassLoader().getResourceAsStream("templates/societyorg_import_template.xlsx");
try {
ServletOutputStream os = response.getOutputStream();
IOUtils.copy(is, os);
} finally {
if (is != null) {
is.close();
}
}
}
/**
*
* @param tokenDto
* @param file
* @return
*/
@PostMapping("importV2")
public Result importExcelV2(@LoginUser TokenDto tokenDto, @RequestPart("file") MultipartFile file) {
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("ic_society_org", "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.生成导入任务记录
ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO();
importTaskForm.setOperatorId(userId);
importTaskForm.setBizType(ImportTaskConstants.IC_SOCIETY_ORG);
importTaskForm.setOriginFileName(originalFilename);
ImportTaskCommonResultDTO rstData = getResultDataOrThrowsException(commonServiceOpenFeignClient.createImportTask(importTaskForm),
ServiceConstant.EPMET_COMMON_SERVICE,
EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),
"excel导入社会组织错误",
"社会组织导入失败");
// 3.执行导入
societyOrgService.execAsyncExcelImport(fileSavePath, rstData.getTaskId(),tokenDto.getCustomerId(),tokenDto.getUserId());
return new Result();
}
}

4
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcSocietyOrgDao.java

@ -59,4 +59,8 @@ public interface IcSocietyOrgDao extends BaseDao<IcSocietyOrgEntity> {
* @Description 查询当前组织下的社会组织数据
**/
List<IcSocietyOrgDTO> getByAgencyId(@Param("agencyId") String agencyId);
List<IcSocietyOrgEntity> selectListForUniqueName(@Param("agencyId") String agencyId,
@Param("societyName") String societyName,
@Param("id") String id);
}

9
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcSocietyOrgEntity.java

@ -73,6 +73,11 @@ public class IcSocietyOrgEntity extends BaseEpmetEntity {
private String mobile;
/**
* 服务时间
*/
private String serviceTimeStr;
/**
* 起始服务时间
*/
private Date serviceStartTime;
@ -87,6 +92,10 @@ public class IcSocietyOrgEntity extends BaseEpmetEntity {
*/
private String adminStaffId;
/**
* 图片地址
*/
private String imgUrl;
/**
* 地址
*/

27
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcSocietyOrgExcel.java

@ -34,37 +34,28 @@ import java.io.Serializable;
@Data
public class IcSocietyOrgExcel extends ExcelVerifyInfo implements Serializable {
@Excel(name = "组织名称")
@Excel(name = "所属组织")
@NotBlank(message = "不能为空")
private String agencyName;
@Excel(name = "社会组织名称")
@Excel(name = "组织名称")
@NotBlank(message = "不能为空")
@Length(max=50,message = "不能超过50个字")
private String societyName;
@Excel(name = "服务事项")
@Excel(name = "服务内容")
@NotBlank(message = "不能为空")
@Length(max=1000,message = "不能超过1000个字")
private String serviceMatters;
@Excel(name = "负责人")
@NotBlank(message = "不能为空")
@Length(max=20,message = "不能超过20个字")
private String personInCharge;
@Excel(name = "负责人电话")
@Excel(name = "服务电话")
@NotBlank(message = "不能为空")
@Length(max=11,message = "不能超过11个字")
private String mobile;
@Excel(name = "起始服务时间")
@Excel(name = "服务时间")
@NotBlank(message = "不能为空")
private String serviceStartTime;
@Excel(name = "终止服务时间")
@NotBlank(message = "不能为空")
private String serviceEndTime;
private String serviceTimeStr;
@Excel(name = "管理员姓名")
private String adminStaffName;
@ -72,10 +63,4 @@ public class IcSocietyOrgExcel extends ExcelVerifyInfo implements Serializable {
@Excel(name = "地址")
private String address;
@Excel(name = "经度")
private String longitude;
@Excel(name = "维度")
private String latitude;
}

42
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcSocietyOrgExportExcel.java

@ -0,0 +1,42 @@
package com.epmet.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
/**
* @Description
* @Author yzm
* @Date 2022/8/24 8:41
*/
@Data
public class IcSocietyOrgExportExcel {
@ExcelProperty(value = "所属组织")
@ColumnWidth(30)
private String agencyName;
@ExcelProperty(value = "组织名称")
@ColumnWidth(30)
private String societyName;
@ColumnWidth(50)
@ExcelProperty(value = "服务内容")
private String serviceMatters;
@ColumnWidth(20)
@ExcelProperty(value = "服务电话")
private String mobile;
@ColumnWidth(20)
@ExcelProperty(value = "服务时间")
private String serviceTimeStr;
@ColumnWidth(20)
@ExcelProperty(value = "管理员姓名")
private String adminStaffName;
/*@ColumnWidth(30)
@ExcelProperty(value = "地址")
private String address;*/
}

74
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcSocietyOrgImportExcelDTO.java

@ -0,0 +1,74 @@
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;
/**
* @Description
* @Author yzm
* @Date 2022/8/24 10:46
*/
@Data
public class IcSocietyOrgImportExcelDTO {
@ExcelProperty(value = "组织名称")
@NotBlank(message = "组织名称不能为空")
@Length(max=50,message = "组织名称不能超过50个字")
private String societyName;
@ExcelProperty(value = "服务内容")
@NotBlank(message = "服务内容不能为空")
@Length(max=1000,message = "服务内容不能超过1000个字")
private String serviceMatters;
@ExcelProperty(value = "服务电话")
@NotBlank(message = "服务电话不能为空")
private String mobile;
@ExcelProperty(value = "服务时间")
@NotBlank(message = "服务时间不能为空")
private String serviceTimeStr;
@ExcelProperty(value = "管理员姓名")
private String adminStaffName;
@ExcelProperty(value = "地址")
private String address;
@Data
public static class ErrorRow {
@ColumnWidth(40)
@ExcelProperty(value = "组织名称")
private String societyName;
@ColumnWidth(50)
@ExcelProperty(value = "服务内容")
private String serviceMatters;
@ColumnWidth(20)
@ExcelProperty(value = "服务电话")
private String mobile;
@ColumnWidth(25)
@ExcelProperty(value = "服务时间")
private String serviceTimeStr;
@ColumnWidth(20)
@ExcelProperty(value = "管理员姓名")
private String adminStaffName;
@ColumnWidth(50)
@ExcelProperty(value = "地址")
private String address;
@ColumnWidth(60)
@ExcelProperty("错误信息")
private String errorInfo;
}
}

157
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/handler/IcSocietyOrgExcelImportListener.java

@ -0,0 +1,157 @@
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.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.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.IcSocietyOrgEntity;
import com.epmet.excel.IcSocietyOrgImportExcelDTO;
import com.epmet.service.impl.IcSocietyOrgServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Description
* @Author yzm
* @Date 2022/8/24 11:42
*/
@Slf4j
public class IcSocietyOrgExcelImportListener implements ReadListener<IcSocietyOrgImportExcelDTO> {
// 最大条数阈值
public static final int MAX_THRESHOLD = 2;
private String currentCustomerId;
/**
* 当前操作用户
*/
private CustomerStaffInfoCacheResult staffInfo;
private IcSocietyOrgServiceImpl icSocietyOrgService;
private List<IcSocietyOrgImportExcelDTO.ErrorRow> errorRows = new ArrayList<>();
/**
* 要插入的数据
*/
private List<IcSocietyOrgEntity> insertDatas = new ArrayList<>();
/**
* 根据组织名称更新的数据
*/
private List<IcSocietyOrgEntity> updateDatas = new ArrayList<>();
private Map<String,String> staffMap=new HashMap<>();
public IcSocietyOrgExcelImportListener(String customerId, CustomerStaffInfoCacheResult staffInfo, IcSocietyOrgServiceImpl icSocietyOrgService, Map<String,String> staffMap) {
this.currentCustomerId = customerId;
this.staffInfo = staffInfo;
this.icSocietyOrgService = icSocietyOrgService;
this.staffMap=staffMap;
}
@Override
public void invoke(IcSocietyOrgImportExcelDTO data, AnalysisContext analysisContext) {
try {
// log.warn("有数据吗?"+JSON.toJSONString(data));
// 不能为空先校验数据
ValidatorUtils.validateEntity(data);
// 去除空格
ObjectUtil.objectToTrim(data);
IcSocietyOrgEntity icSocietyOrgEntity = ConvertUtils.sourceToTarget(data, IcSocietyOrgEntity.class);
icSocietyOrgEntity.setCustomerId(currentCustomerId);
icSocietyOrgEntity.setAgencyId(staffInfo.getAgencyId());
icSocietyOrgEntity.setPids(staffInfo.getAgencyPIds());
if(StringUtils.isNotBlank(data.getAdminStaffName())){
String adminStaffId = null;
for(String key:staffMap.keySet()){
if (data.getAdminStaffName().equals(staffMap.get(key))) {
adminStaffId=key;
break;
}
}
if (StringUtils.isBlank(adminStaffId)) {
String msg = String.format("当前组织下没有【%s】", data.getAdminStaffName());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg);
}
icSocietyOrgEntity.setAdminStaffId(adminStaffId);
}
//网格id+场所名称
List<IcSocietyOrgEntity> originList = icSocietyOrgService.selectForUniqueName(icSocietyOrgEntity.getAgencyId(), icSocietyOrgEntity.getSocietyName(), null);
if(CollectionUtils.isEmpty(originList)){
insertDatas.add(icSocietyOrgEntity);
}else{
IcSocietyOrgEntity origin=originList.get(NumConstant.ZERO);
icSocietyOrgEntity.setId(origin.getId());
updateDatas.add(icSocietyOrgEntity);
}
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).getMsg();
}else {
errorMsg = "未知错误";
log.error("【社会组织导入】出错:{}", ExceptionUtils.getErrorStackTrace(e));
}
IcSocietyOrgImportExcelDTO.ErrorRow errorRow = new IcSocietyOrgImportExcelDTO.ErrorRow();
errorRow.setSocietyName(data.getSocietyName());
errorRow.setServiceMatters(data.getServiceMatters());
errorRow.setMobile(data.getMobile());
errorRow.setServiceTimeStr(data.getServiceTimeStr());
errorRow.setAdminStaffName(data.getAdminStaffName());
errorRow.setAddress(data.getAddress());
errorRow.setErrorInfo(errorMsg);
errorRows.add(errorRow);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
log.info("☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆");
// 最后几条达不到阈值,这里必须再调用一次
execPersist();
}
/**
* 执行持久化
*/
private void execPersist() {
try {
if (CollectionUtils.isNotEmpty(insertDatas)) {
icSocietyOrgService.insertBatch(insertDatas);
}
if (CollectionUtils.isNotEmpty(updateDatas)) {
icSocietyOrgService.updateBatchById(updateDatas);
}
} finally {
insertDatas.clear();
updateDatas.clear();
}
}
/**
* 获取错误行
*
* @return
*/
public List<IcSocietyOrgImportExcelDTO.ErrorRow> getErrorRows() {
return errorRows;
}
}

10
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcSocietyOrgService.java

@ -28,6 +28,7 @@ import com.epmet.dto.result.demand.OptionDTO;
import com.epmet.entity.IcSocietyOrgEntity;
import com.epmet.excel.IcSocietyOrgExcel;
import java.nio.file.Path;
import java.text.ParseException;
import java.util.List;
@ -79,4 +80,13 @@ public interface IcSocietyOrgService extends BaseService<IcSocietyOrgEntity> {
List<IcSocietyOrgEntity> queryListById(List<String> socialOrgIds);
IcSocietyOrgDTO get(String id);
/**
* 导入社会组织之前的废弃了
* @param fileSavePath
* @param taskId
* @param customerId
* @param userId
*/
void execAsyncExcelImport(Path fileSavePath, String taskId, String customerId, String userId);
}

244
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcSocietyOrgServiceImpl.java

@ -17,42 +17,58 @@
package com.epmet.service.impl;
import com.alibaba.excel.EasyExcel;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant;
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.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.FileUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.UserDemandConstant;
import com.epmet.constants.ImportTaskConstants;
import com.epmet.dao.IcSocietyOrgDao;
import com.epmet.dto.CustomerStaffDTO;
import com.epmet.dto.IcSocietyOrgDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.form.demand.ServiceQueryFormDTO;
import com.epmet.dto.result.GetListSocietyOrgResultDTO;
import com.epmet.dto.result.OrgInfoResultDTO;
import com.epmet.dto.result.SocietyOrgListResultDTO;
import com.epmet.dto.result.StaffSinGridResultDTO;
import com.epmet.dto.result.*;
import com.epmet.dto.result.demand.OptionDTO;
import com.epmet.entity.IcSocietyOrgEntity;
import com.epmet.excel.IcSocietyOrgExcel;
import com.epmet.excel.IcSocietyOrgImportExcelDTO;
import com.epmet.excel.handler.IcSocietyOrgExcelImportListener;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.feign.OssFeignClient;
import com.epmet.service.IcSocietyOrgService;
import com.epmet.service.IcUserDemandRecService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.entity.ContentType;
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.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.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@ -71,6 +87,10 @@ public class IcSocietyOrgServiceImpl extends BaseServiceImpl<IcSocietyOrgDao, Ic
private IcUserDemandRecService icUserDemandRecService;
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient;
@Autowired
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient;
@Autowired
private OssFeignClient ossFeignClient;
/**
* @Author sun
@ -80,6 +100,10 @@ public class IcSocietyOrgServiceImpl extends BaseServiceImpl<IcSocietyOrgDao, Ic
@Transactional(rollbackFor = Exception.class)
public void add(AddSocietyOrgFormDTO dto) {
IcSocietyOrgEntity entity = ConvertUtils.sourceToTarget(dto, IcSocietyOrgEntity.class);
//图片必填
if(dto.getImageList() != null&& StringUtils.isNotBlank(dto.getImageList()[0])){
entity.setImgUrl(dto.getImageList()[0]);
}
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(dto.getCustomerId(), dto.getStaffId());
entity.setAgencyId(staffInfoCache.getAgencyId());
entity.setPids(staffInfoCache.getAgencyPIds());
@ -97,6 +121,10 @@ public class IcSocietyOrgServiceImpl extends BaseServiceImpl<IcSocietyOrgDao, Ic
throw new RenException(String.format("修改社会组织信息失败,社会组织信息不存在,组织Id->%s", formDTO.getSocietyId()));
}
entity = ConvertUtils.sourceToTarget(formDTO, IcSocietyOrgEntity.class);
//图片必填
if(formDTO.getImageList() != null && StringUtils.isNotBlank(formDTO.getImageList()[0])){
entity.setImgUrl(formDTO.getImageList()[0]);
}
entity.setId(formDTO.getSocietyId());
baseDao.updateById(entity);
}
@ -115,14 +143,17 @@ public class IcSocietyOrgServiceImpl extends BaseServiceImpl<IcSocietyOrgDao, Ic
/**
* @Author sun
* @Description 社会组织列表查询
**/
*
* @return*/
@Override
public GetListSocietyOrgResultDTO getList(GetListSocietyOrgFormDTO formDTO) {
GetListSocietyOrgResultDTO resultDTO = new GetListSocietyOrgResultDTO();
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId());
//2022.1.7 应产品要求 当前组织只能看到自己组织添加的社会组织数据,不允许看其他下级的
//formDTO.setPids(staffInfoCache.getAgencyPIds());
formDTO.setAgencyId(staffInfoCache.getAgencyId());
if(StringUtils.isBlank(formDTO.getAgencyId())){
formDTO.setAgencyId(staffInfoCache.getAgencyId());
}
//1.根据查询条件分页查询社会组织数据
PageInfo<SocietyOrgListResultDTO> result =
PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()).doSelectPageInfo(() -> baseDao.getList(formDTO));
@ -134,14 +165,16 @@ public class IcSocietyOrgServiceImpl extends BaseServiceImpl<IcSocietyOrgDao, Ic
Map<String, Integer> pointMap = icUserDemandRecService.getServicePoint(formDTO.getCustomerId(), UserDemandConstant.SOCIAL_ORG);
//2.查询被绑定管理员信息
UserIdsFormDTO dto = new UserIdsFormDTO();
List<String> staffIdList = result.getList().stream().map(SocietyOrgListResultDTO::getAdminStaffId).collect(Collectors.toList());
staffIdList = staffIdList.stream().distinct().collect(Collectors.toList());
dto.setUserIds(staffIdList);
Result<List<StaffSinGridResultDTO>> listResult = epmetUserOpenFeignClient.getStaffInfoList(dto);
if (!listResult.success()) {
throw new RenException("获取工作人员基本信息失败......");
List<String> staffIdList = result.getList().stream().filter(u->StringUtils.isNotBlank(u.getAdminStaffId())).map(SocietyOrgListResultDTO::getAdminStaffId).collect(Collectors.toList());
if(!CollectionUtils.isEmpty(staffIdList)){
staffIdList = staffIdList.stream().distinct().collect(Collectors.toList());
dto.setUserIds(staffIdList);
Result<List<StaffSinGridResultDTO>> listResult = epmetUserOpenFeignClient.getStaffInfoList(dto);
if (!listResult.success()) {
throw new RenException("获取工作人员基本信息失败......");
}
result.getList().stream().filter(f->StringUtils.isNotBlank(f.getAdminStaffId())).forEach(r -> listResult.getData().stream().filter(u -> r.getAdminStaffId().equals(u.getStaffId())).forEach(u -> r.setAdminStaffName(u.getStaffName())));
}
result.getList().forEach(r -> listResult.getData().stream().filter(u -> r.getAdminStaffId().equals(u.getStaffId())).forEach(u -> r.setAdminStaffName(u.getStaffName())));
//3.查询被绑定管理员信息
OrgInfoFormDTO org = new OrgInfoFormDTO();
@ -221,53 +254,59 @@ public class IcSocietyOrgServiceImpl extends BaseServiceImpl<IcSocietyOrgDao, Ic
if (CollectionUtils.isEmpty(list)) {
return numList;
}
Map<String, String> map=new HashMap<>();
//2.查询绑定的管理员信息
Set<String> staffNames = list.stream().map(item -> item.getAdminStaffName().trim()).collect(Collectors.toSet());
GetByRealNamesFormDTO dto = new GetByRealNamesFormDTO();
dto.setCustomerId(customerId);
dto.setRealNames(staffNames);
Result<List<CustomerStaffDTO>> staffResult = epmetUserOpenFeignClient.getByRealNames(dto);
if (!staffResult.success()) {
throw new RenException("获取工作人员基础信息失败......");
}
if (null == staffResult.getData()) {
Iterator<IcSocietyOrgExcel> iter = list.iterator();
while (iter.hasNext()) {
IcSocietyOrgExcel obj = iter.next();
numList.add(obj.getRowNum());
iterator.remove();
Set<String> staffNames = list.stream().filter(t -> StringUtils.isNotBlank(t.getAdminStaffName())).map(item -> item.getAdminStaffName().trim()).collect(Collectors.toSet());
if(!CollectionUtils.isEmpty(staffNames)){
GetByRealNamesFormDTO dto = new GetByRealNamesFormDTO();
dto.setCustomerId(customerId);
dto.setRealNames(staffNames);
Result<List<CustomerStaffDTO>> staffResult = epmetUserOpenFeignClient.getByRealNames(dto);
if (!staffResult.success()) {
throw new RenException("获取工作人员基础信息失败......");
}
return numList;
if (null == staffResult.getData()) {
Iterator<IcSocietyOrgExcel> iter = list.iterator();
while (iter.hasNext()) {
IcSocietyOrgExcel obj = iter.next();
numList.add(obj.getRowNum());
iterator.remove();
}
return numList;
}
map= staffResult.getData().stream().collect(Collectors.toMap(CustomerStaffDTO::getRealName, CustomerStaffDTO::getUserId));
}
Map<String, String> map = staffResult.getData().stream().collect(Collectors.toMap(CustomerStaffDTO::getRealName, CustomerStaffDTO::getUserId));
//3.遍历封装有效数据
List<IcSocietyOrgEntity> houseEntityList = new ArrayList<>();
Iterator<IcSocietyOrgExcel> iterator1 = list.iterator();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
while (iterator1.hasNext()) {
IcSocietyOrgExcel icHouseExcel = iterator1.next();
IcSocietyOrgExcel icSocietyOrgExcel = iterator1.next();
IcSocietyOrgEntity entity = new IcSocietyOrgEntity();
entity.setCustomerId(customerId);
entity.setAgencyId(staffInfoCache.getAgencyId());
entity.setPids(staffInfoCache.getAgencyPIds());
entity.setSocietyName(icHouseExcel.getSocietyName());
entity.setServiceMatters(icHouseExcel.getServiceMatters());
entity.setPersonInCharge(icHouseExcel.getPersonInCharge());
entity.setMobile(icHouseExcel.getMobile());
entity.setServiceStartTime(sdf.parse(icHouseExcel.getServiceStartTime()));
entity.setServiceEndTime(sdf.parse(icHouseExcel.getServiceEndTime()));
entity.setAdminStaffId(map.containsKey(icHouseExcel.getAdminStaffName().trim()) ? map.get(icHouseExcel.getAdminStaffName().trim()) : "");
if ("".equals(entity.getAdminStaffId())) {
numList.add(icHouseExcel.getRowNum());
log.warn(String.format("绑定的管理员不存在,管理员名称->%s,行号->%s", icHouseExcel.getAdminStaffName(), icHouseExcel.getRowNum()));
entity.setSocietyName(icSocietyOrgExcel.getSocietyName());
entity.setServiceMatters(icSocietyOrgExcel.getServiceMatters());
//负责人去掉
// entity.setPersonInCharge(icSocietyOrgExcel.getPersonInCharge());
entity.setMobile(icSocietyOrgExcel.getMobile());
//服务时间手动输入
entity.setServiceTimeStr(icSocietyOrgExcel.getServiceTimeStr());
// entity.setServiceStartTime(sdf.parse(icHouseExcel.getServiceStartTime()));
// entity.setServiceEndTime(sdf.parse(icHouseExcel.getServiceEndTime()));
entity.setAdminStaffId(MapUtils.isNotEmpty(map)&&map.containsKey(icSocietyOrgExcel.getAdminStaffName().trim()) ? map.get(icSocietyOrgExcel.getAdminStaffName().trim()) : "");
if (StringUtils.isBlank(entity.getAdminStaffId())) {
numList.add(icSocietyOrgExcel.getRowNum());
log.warn(String.format("绑定的管理员不存在,管理员名称->%s,行号->%s", icSocietyOrgExcel.getAdminStaffName(), icSocietyOrgExcel.getRowNum()));
iterator1.remove();
continue;
}
entity.setAddress(icHouseExcel.getAddress());
entity.setLongitude(icHouseExcel.getLongitude());
entity.setLatitude(icHouseExcel.getLatitude());
entity.setAddress(icSocietyOrgExcel.getAddress());
//经纬度不能导入
// entity.setLongitude(icHouseExcel.getLongitude());
// entity.setLatitude(icHouseExcel.getLatitude());
houseEntityList.add(entity);
}
@ -291,4 +330,115 @@ public class IcSocietyOrgServiceImpl extends BaseServiceImpl<IcSocietyOrgDao, Ic
return ConvertUtils.sourceToTarget(entity,IcSocietyOrgDTO.class);
}
}
/**
* 导入社会组织之前的废弃了
*
* @param filePath
* @param importTaskId
* @param customerId
* @param userId
*/
@Override
public void execAsyncExcelImport(Path filePath, String importTaskId,String customerId,String userId) {
try {
//获取当前登录用户所属组织id
CustomerStaffInfoCacheResult staffInfo= queryCurrentStaff(customerId,userId);
//当前组织下的人
AgencyIdFormDTO agencyIdFormDTO=new AgencyIdFormDTO();
agencyIdFormDTO.setAgencyId(staffInfo.getAgencyId());
Result<List<String>> staffIdsRes=govOrgOpenFeignClient.getAgencyStaffs(agencyIdFormDTO);
if (!staffIdsRes.success() || CollectionUtils.isEmpty(staffIdsRes.getData())) {
String msg = "查询当前组织下工作人员列表异常";
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg);
}
Result<CustomerStaffListResultDTO> currentAgencyStaffs=epmetUserOpenFeignClient.getCustomerStaffList(staffIdsRes.getData());
if (!currentAgencyStaffs.success() || null == currentAgencyStaffs.getData() || CollectionUtils.isEmpty(currentAgencyStaffs.getData().getStaffList())) {
String msg = "查询当前组织下工作人员信息异常";
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg);
}
List<StaffListResultDTO> staffList=currentAgencyStaffs.getData().getStaffList();
Map<String,String> staffMap=staffList.stream().collect(Collectors.toMap(StaffListResultDTO::getStaffId, StaffListResultDTO::getStaffName));
IcSocietyOrgExcelImportListener listener = new IcSocietyOrgExcelImportListener(customerId,staffInfo, this,staffMap);
EasyExcel.read(filePath.toFile(), IcSocietyOrgImportExcelDTO.class, listener).headRowNumber(1).sheet(0).doRead();
Path errorDescFile = null;
String errorDesFileUrl = null;
List<IcSocietyOrgImportExcelDTO.ErrorRow> errorRows = listener.getErrorRows();
boolean failed = errorRows.size() > 0;
if (failed) {
// 生成并上传错误文件
try {
// 文件生成
Path errorDescDir = FileUtils.getAndCreateDirUnderEpmetFilesDir("ic_enterprise", "import", "error_des");
String fileName = UUID.randomUUID().toString().concat(".xlsx");
errorDescFile = errorDescDir.resolve(fileName);
FileItemFactory factory = new DiskFileItemFactory(16, errorDescDir.toFile());
FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, fileName);
OutputStream os = fileItem.getOutputStream();
EasyExcel.write(os, IcSocietyOrgImportExcelDTO.ErrorRow.class).sheet("导入失败列表").doWrite(errorRows);
// 文件上传oss
Result<UploadImgResultDTO> errorDesFileUploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem));
if (errorDesFileUploadResult.success()) {
errorDesFileUrl = errorDesFileUploadResult.getData().getUrl();
}
} finally {
if (Files.exists(errorDescFile)) {
Files.delete(errorDescFile);
}
}
}
ImportTaskCommonFormDTO importFinishTaskForm = new ImportTaskCommonFormDTO();
importFinishTaskForm.setTaskId(importTaskId);
importFinishTaskForm.setProcessStatus(failed ? ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL : ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS);
importFinishTaskForm.setOperatorId(userId);
importFinishTaskForm.setResultDesc("");
importFinishTaskForm.setResultDescFilePath(errorDesFileUrl);
Result result = commonServiceOpenFeignClient.finishImportTask(importFinishTaskForm);
if (!result.success()) {
log.error("【社会组织】finishImportTask失败");
}
} catch (Exception e) {
String errorMsg = ExceptionUtils.getErrorStackTrace(e);
log.error("【社会组织】出错:{}", 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("【社会组织】导入记录状态修改为'完成'失败");
}
} finally {
// 删除临时文件
if (Files.exists(filePath)) {
try {
Files.delete(filePath);
} catch (IOException e) {
log.error("method exception", e);
}
}
}
}
private CustomerStaffInfoCacheResult queryCurrentStaff(String customerId, String userId) {
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, userId);
if (null == staffInfo) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询工作人员缓存信息异常", EpmetErrorCode.SERVER_ERROR.getMsg());
}
return staffInfo;
}
public List<IcSocietyOrgEntity> selectForUniqueName(String agencyId, String societyName, String id) {
return baseDao.selectListForUniqueName(agencyId,societyName,id);
}
}

13
epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcSocietyOrgDao.xml

@ -7,10 +7,12 @@
SELECT
agency_id agencyId,
id societyId,
img_url,
society_name societyName,
service_matters serviceMatters,
person_in_charge personInCharge,
mobile mobile,
service_time_str,
service_start_time serviceStartTime,
service_end_time serviceEndTime,
admin_staff_id adminStaffId,
@ -90,4 +92,13 @@
AND agency_id = #{agencyId}
</select>
</mapper>
<select id="selectListForUniqueName" parameterType="map" resultType="com.epmet.entity.IcSocietyOrgEntity">
select o.* from ic_society_org o
where o.del_flag='0'
and o.agency_id = #{agencyId}
and o.society_name =#{societyName}
<if test="null != id and id != '' ">
and o.id != #{id}
</if>
</select>
</mapper>

BIN
epmet-module/epmet-heart/epmet-heart-server/src/main/resources/templates/societyorg_import_template.xlsx

Binary file not shown.

8
epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/grid/controller/ResiMineGridController.java

@ -7,6 +7,7 @@ import com.epmet.dto.form.LatestGridInfoFormDTO;
import com.epmet.dto.result.AllGridsByUserIdResultDTO;
import com.epmet.dto.result.LatestGridInfoResultDTO;
import com.epmet.modules.grid.service.ResiMineGridService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -63,7 +64,12 @@ public class ResiMineGridController {
//formDTO.setAppId(appId);
formDTO.setCustomerId(token.getCustomerId());
formDTO.setUserId(token.getUserId());
return new Result<LatestGridInfoResultDTO>().ok(resiMineGridService.latestGridInfo(formDTO));
LatestGridInfoResultDTO data = resiMineGridService.latestGridInfo(formDTO);
//todo 兼容 一个老的 等删除这个if就行
if ((data == null || StringUtils.isBlank(data.getGridId())&&"c2527f3d5cb8958583cc1348c328a784".equals(token.getCustomerId()))){
return new Result<LatestGridInfoResultDTO>().ok(null);
}
return new Result<LatestGridInfoResultDTO>().ok(data);
}
/**

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

@ -617,25 +617,23 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
List<StaffSinGridResultDTO> staffInfoList = new ArrayList<>();
userIds.forEach(staffId -> {
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), staffId);
if (staffInfo == null) {
log.error("getStaffInfoList fail customerId:{}, staffId:{} not exist in db", formDTO.getCustomerId(), staffId);
return;
if (null != staffInfo) {
StaffSinGridResultDTO resultDTO = new StaffSinGridResultDTO();
resultDTO.setStaffId(staffId);
resultDTO.setStaffName(staffInfo.getRealName());
resultDTO.setHeadPhoto(staffInfo.getHeadPhoto());
resultDTO.setGender(staffInfo.getGender());
List<RoleResultDTO> roleInfoList = new ArrayList<>();
staffInfo.getRoleMap().forEach((key, value) -> {
RoleResultDTO dto = new RoleResultDTO();
dto.setRoleKey(key);
dto.setRoleName(value);
roleInfoList.add(dto);
});
resultDTO.setRoleList(roleInfoList);
staffInfoList.add(resultDTO);
}
StaffSinGridResultDTO resultDTO = new StaffSinGridResultDTO();
resultDTO.setStaffId(staffId);
resultDTO.setStaffName(staffInfo.getRealName());
resultDTO.setHeadPhoto(staffInfo.getHeadPhoto());
resultDTO.setGender(staffInfo.getGender());
List<RoleResultDTO> roleInfoList = new ArrayList<>();
staffInfo.getRoleMap().forEach((key, value) -> {
RoleResultDTO dto = new RoleResultDTO();
dto.setRoleKey(key);
dto.setRoleName(value);
roleInfoList.add(dto);
});
resultDTO.setRoleList(roleInfoList);
staffInfoList.add(resultDTO);
});
/*List<StaffSinGridResultDTO> staffInfoList = customerStaffDao.getStaffInfoList(userIds);

2
epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

@ -1205,7 +1205,7 @@
<select id="getListIcResiUserDTO" parameterType="map" resultType="com.epmet.dto.IcResiUserDTO">
select id, NAME,MOBILE
from ic_resi_user
WHERE DEL_FLAG = '0'
WHERE 1=1
<foreach collection="icResiUserIdList" item="icResiUserId" open="AND (" separator="or" close=")">
id = #{icResiUserId}
</foreach>

Loading…
Cancel
Save