diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java index f25fd4269a..f35891c2a5 100644 --- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java @@ -93,4 +93,9 @@ public interface ImportTaskConstants { * 楼长单元长 */ String COMMUNITY_BUILDING_MANAGER="community_building_manager"; + + /** + * 客户 + */ + String BIZ_TYPE_CUSTOMER_STAFF="customer_staff"; } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java index d424f60202..23807cd908 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java @@ -5,27 +5,40 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.annotation.RequirePermission; import com.epmet.commons.tools.constant.AppClientConstant; +import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.enums.RequirePermissionEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.EpmetRequestHolder; +import com.epmet.commons.tools.utils.FileUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.constants.ImportTaskConstants; import com.epmet.dto.form.*; import com.epmet.dto.result.*; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; +import com.epmet.remote.EpmetUserRemoteService; import com.epmet.service.StaffService; +import com.epmet.utils.ImportTaskUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; +import java.io.FileOutputStream; +import java.io.IOException; import java.io.InputStream; import java.net.URLEncoder; +import java.nio.file.Path; import java.util.List; +import java.util.UUID; /** * 组织结构-工作人员 @@ -35,9 +48,11 @@ import java.util.List; @Slf4j @RestController @RequestMapping("staff") -public class StaffController { +public class StaffController implements ResultDataResolver { @Autowired private StaffService staffService; + @Autowired + private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient; /** * 组织首页-工作人员列表 * @param fromDTO @@ -233,6 +248,54 @@ public class StaffController { return staffService.addStaffV2(fromDTO); } + @PostMapping("staffimport") + public Result buildingImportExcel(@RequestParam("file") MultipartFile file,@RequestParam("orgType") String orgType,@RequestParam("orgId") String orgId){ + + String userId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID); + + // 1.暂存文件 + String originalFilename = file.getOriginalFilename(); + String extName = originalFilename.substring(originalFilename.lastIndexOf(".")); + + Path fileSavePath; + try { + Path importPath = FileUtils.getAndCreateDirUnderEpmetFilesDir("ic_nat", "import"); + fileSavePath = importPath.resolve(UUID.randomUUID().toString().concat(extName)); + } catch (IOException e) { + String errorMsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【核酸检测导入】创建临时存储文件失败:{}", errorMsg); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "文件上传失败", "文件上传失败"); + } + + InputStream is = null; + FileOutputStream os = null; + + try { + is = file.getInputStream(); + os = new FileOutputStream(fileSavePath.toString()); + IOUtils.copy(is, os); + } catch (Exception e) { + log.error("method exception", e); + } finally { + org.apache.poi.util.IOUtils.closeQuietly(is); + org.apache.poi.util.IOUtils.closeQuietly(os); + } + + // 2.生成导入任务记录 + ImportTaskCommonResultDTO rstData = getResultDataOrThrowsException( + ImportTaskUtils.createImportTask(originalFilename, ImportTaskConstants.BIZ_TYPE_CUSTOMER_STAFF), + ServiceConstant.EPMET_COMMON_SERVICE, + EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), + "excel导入客户信息错误", + "导入客户信息失败"); + + // 3.执行导入 + staffService.execAsyncExcelImport(fileSavePath, rstData.getTaskId(),orgType,orgId); + + return new Result(); + + } + /** * 【通讯录】人员添加-平阴 * @author zhy diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/CustomerStaffImportExcelData.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/CustomerStaffImportExcelData.java new file mode 100644 index 0000000000..b5a1b08e1d --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/CustomerStaffImportExcelData.java @@ -0,0 +1,68 @@ +package com.epmet.excel; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import java.util.Date; + +/** + * 核酸检测信息导入excel数据 + */ +@Data +public class CustomerStaffImportExcelData { + + @NotBlank(message = "姓名为必填项") + @ExcelProperty("姓名※") + private String name; + + @NotBlank(message = "手机号为必填项") + @ExcelProperty("联系电话※") + @Length(max = 15, message = "手机号长度不正确,应小于15位") + private String mobile; + + @NotBlank(message = "身份证号为必填项") + @ExcelProperty("身份证号※") + @Length(max = 18, message = "证身份证号长度不正确,应小于18位") + private String idCard; + + @ExcelProperty("村居委员职务") + private Date viliagePosition; + + @ExcelProperty("党组织职务") + private Date partyPosition; + + @NotBlank(message = "居住地址为必填项") + @ExcelProperty("居住地址※") + private String address; + + @NotBlank(message = "文化程度为必填项") + @ExcelProperty("文化程度※") + private String cultureName; + + @NotBlank(message = "性别为必填项") + @ExcelProperty("性别※") + private String genderName; + + @NotBlank(message = "专兼职为必填项") + @ExcelProperty("专兼职※") + private String workTypeName; + + @NotBlank(message = "工作职责为必填项") + @ExcelProperty("工作职责※") + private String duty; + + @ExcelProperty("备注") + private String remark; + + @Data + public static class RowRemarkMessage { + + + @ColumnWidth(60) + @ExcelProperty("错误信息") + private String errorInfo; + } +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/handler/CustomerStaffImportListener.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/handler/CustomerStaffImportListener.java new file mode 100644 index 0000000000..28d91229af --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/handler/CustomerStaffImportListener.java @@ -0,0 +1,178 @@ +package com.epmet.excel.handler; + +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.read.listener.ReadListener; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.exception.ValidateException; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.AddStaffV2FromDTO; +import com.epmet.excel.CustomerStaffImportExcelData; +import com.epmet.service.impl.StaffServiceImpl; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * 核酸检测excel导入监听器 + */ +@Data +@Slf4j +public class CustomerStaffImportListener implements ReadListener { + + /** + * 最大条数阈值 + */ + public static final int MAX_THRESHOLD = 200; + + private String currentUserId; + + private String currentCustomerId; + + private String currentOrgType; + + private String currentOrgId; + + + /** + * 数据 + */ + private List datas = new ArrayList<>(); + + /** + * 错误项列表 + */ + private List errorRows = new ArrayList<>(); + /** + * 其他被标记出来的列表列表 + */ + private List otherRows = new ArrayList<>(); + + private StaffServiceImpl staffService; + + public CustomerStaffImportListener(String currentUserId, String currentCustomerId, String currentOrgType,String currentOrgId,StaffServiceImpl staffService) { + this.currentUserId = currentUserId; + this.currentCustomerId = currentCustomerId; + this.staffService = staffService; + this.currentOrgType = currentOrgType; + this.currentOrgId = currentOrgId; + } + + @Override + public void invoke(CustomerStaffImportExcelData data, AnalysisContext context) { + + try { + // 先校验数据 + ValidatorUtils.validateEntity(data); + + AddStaffV2FromDTO fromDTO = ConvertUtils.sourceToTarget(data, AddStaffV2FromDTO.class); + + fromDTO.setCustomerId(currentCustomerId); + //因为添加的是工作人员,这里写死吧! + fromDTO.setApp("gov"); + fromDTO.setClient("wxmp"); + //当前登录用户 + fromDTO.setCurrentUserId(currentUserId); + fromDTO.setOrgId(currentOrgId); + fromDTO.setOrgType(currentOrgType); + + if (StringUtils.isNotBlank(data.getWorkTypeName())){ + if (data.getWorkTypeName().equals("专职")){ + fromDTO.setWorkType("fulltime"); + } + if (data.getWorkTypeName().equals("兼职")){ + fromDTO.setWorkType("parttime"); + } + } + + if (StringUtils.isNotBlank(data.getGenderName())){ + if (data.getGenderName().equals("男")){ + fromDTO.setGender(1); + } + if (data.getGenderName().equals("女")){ + fromDTO.setGender(2); + } + if (data.getGenderName().equals("未知")){ + fromDTO.setGender(0); + } + } + //0小学及文盲,1初中,2高中,3大专,4本科,5硕士,6博士,7中专 + if (StringUtils.isNotBlank(data.getCultureName())){ + if (data.getCultureName().equals("小学及文盲")){ + fromDTO.setCulture("0"); + } + if (data.getCultureName().equals("初中")){ + fromDTO.setCulture("1"); + } + if (data.getCultureName().equals("高中")){ + fromDTO.setCulture("2"); + } + if (data.getCultureName().equals("大专")){ + fromDTO.setCulture("3"); + } + if (data.getCultureName().equals("本科")){ + fromDTO.setCulture("4"); + } + if (data.getCultureName().equals("硕士")){ + fromDTO.setCulture("5"); + } + if (data.getCultureName().equals("博士")){ + fromDTO.setCulture("6"); + } + } + + + datas.add(fromDTO); + + if (datas.size() == MAX_THRESHOLD) { + execPersist(); + } + } catch (Exception e) { + String errorMsg = null; + if (e instanceof ValidateException) { + errorMsg = ((ValidateException) e).getMsg(); + } else { + log.error("【客户信息导入】出错:{}", e.getStackTrace()); + errorMsg = ((EpmetException)e).getInternalMsg(); + log.error("【客户信息导入】出错:{}", ExceptionUtils.getErrorStackTrace(e)); + } + + CustomerStaffImportExcelData.RowRemarkMessage errorRow = new CustomerStaffImportExcelData.RowRemarkMessage(); + errorRow.setErrorInfo(errorMsg); + errorRows.add(errorRow); + } + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + // 最后几条达不到阈值,这里必须再调用一次 + execPersist(); + } + + /** + * 执行持久化 + */ + private void execPersist() { + try { + if (datas != null && datas.size() > 0) { +// icNatService.batchPersist(datas, this); + staffService.exportAdd(datas,this); + } + } finally { + datas.clear(); + } + } + + /** + * 获取错误行 + * @return + */ + public List getErrorRows() { + return errorRows; + } +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java index 5a4a989166..6bbb42094e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java @@ -4,7 +4,9 @@ import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.*; import com.epmet.dto.result.*; +import org.springframework.web.bind.annotation.RequestParam; +import java.nio.file.Path; import java.util.List; /** @@ -154,4 +156,6 @@ public interface StaffService { * @Date 2021/9/8 16:57 */ List staffOrgList(TokenDto tokenDto); + + void execAsyncExcelImport(Path fileSavePath, String taskId,String orgType, String orgId); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java index a81f868ac5..7a3e7db3fc 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java @@ -1,18 +1,21 @@ package com.epmet.service.impl; +import com.alibaba.excel.EasyExcel; +import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.security.dto.TokenDto; -import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.*; import com.epmet.constant.OrgInfoConstant; +import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.CustomerStaffAgencyDao; import com.epmet.dao.StaffOrgRelationDao; import com.epmet.dto.*; @@ -20,17 +23,31 @@ import com.epmet.dto.form.*; import com.epmet.dto.form.yantai.YtSyncStaffIdFormDTO; import com.epmet.dto.result.*; import com.epmet.entity.*; +import com.epmet.excel.CustomerStaffImportExcelData; +import com.epmet.excel.handler.CustomerStaffImportListener; import com.epmet.feign.*; +import com.epmet.remote.EpmetUserRemoteService; import com.epmet.service.*; +import com.epmet.utils.ImportTaskUtils; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.lang3.StringUtils; +import org.apache.http.entity.ContentType; +import org.apache.poi.util.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.commons.CommonsMultipartFile; import javax.annotation.Resource; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -41,6 +58,7 @@ import java.util.stream.Collectors; * @dscription * @date 2020/4/23 18:05 */ +@Slf4j @Service public class StaffServiceImpl implements StaffService { private static final Logger logger = LoggerFactory.getLogger(StaffServiceImpl.class); @@ -80,6 +98,10 @@ public class StaffServiceImpl implements StaffService { private GovAccessFeignClient govAccessFeignClient; @Autowired private EpmetThirdOpenFeignClient epmetThirdOpenFeignClient; + @Autowired + private EpmetUserRemoteService userRemoteService; + @Autowired + private OssFeignClient ossFeignClient; @Override public Result getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { @@ -745,5 +767,180 @@ public class StaffServiceImpl implements StaffService { return list; } + @Override + public void execAsyncExcelImport(Path filePath, String importTaskId,String orgType, String orgId) { + + try { + + CustomerStaffImportListener listener = new CustomerStaffImportListener(userRemoteService.getLoginUserDetails().getUserId(), userRemoteService.getLoginUserDetails().getCustomerId(), orgType,orgId,this); + + EasyExcel.read(filePath.toFile(), CustomerStaffImportExcelData.class, listener).headRowNumber(2).sheet(0).doRead(); + + String errorDesFileUrl = null; + + List errorRows = listener.getErrorRows(); + List otherRows = listener.getOtherRows(); + + boolean failed = errorRows.size() > 0; + + // 合并到一起写入 + errorRows.addAll(otherRows); + + // 生成并上传描述文件 + OutputStream os = null; + FileItem fileItem = null; + if (errorRows.size() > 0) { + try { + // 文件生成 + Path errorDescDir = FileUtils.getAndCreateDirUnderEpmetFilesDir("ic_nat", "import", "error_des"); + String timeMillis = String.valueOf(System.currentTimeMillis()); + String fileName = "icnat_import_error_".concat(timeMillis).concat(".xlsx"); + + fileItem = new DiskFileItemFactory(DiskFileItemFactory.DEFAULT_SIZE_THRESHOLD, errorDescDir.toFile()) + .createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), false, fileName); + + os = fileItem.getOutputStream(); + + EasyExcel.write(os, CustomerStaffImportExcelData.RowRemarkMessage.class).sheet("信息列表").doWrite(errorRows); + // 文件上传oss + Result errorDesFileUploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); + if (errorDesFileUploadResult.success()) { + errorDesFileUrl = errorDesFileUploadResult.getData().getUrl(); + } + } finally { + IOUtils.closeQuietly(os); + try { + fileItem.delete(); + } catch (Exception e){ + log.error("【客户信息导入】删除临时描述文件失败:{}", ExceptionUtils.getErrorStackTrace(e)); + } + } + } + + // 完成导入 + Result result = ImportTaskUtils.finishImportTask(importTaskId, + failed ? ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL : ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS, + errorDesFileUrl, + ""); + + if (!result.success()) { + log.error("【客户信息导入】导入记录状态修改为'finished_success'失败"); + } + } catch (Exception e) { + String errorMsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【客户信息导入】出错:{}", errorMsg); + + Result result = ImportTaskUtils.finishImportTask(importTaskId, ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL, null, "导入失败"); + + if (!result.success()) { + log.error("【客户信息导入】导入记录状态修改为'finished_fail'失败"); + } + } finally { + // 删除临时文件 + if (Files.exists(filePath)) { + try { + Files.delete(filePath); + } catch (IOException e) { + log.error("method exception", e); + } + } + } + } + + /** + * 批量持久化 + * @param addStaffV2FromDTOList + */ + public void exportAdd(List addStaffV2FromDTOList, CustomerStaffImportListener listener) { + + addStaffV2FromDTOList.forEach(fromDTO -> { + + //1.根据新增人员类型判断查询机关信息 + OrgResultDTO orgDTO = customerAgencyDao.selectAgencyDetail(fromDTO.getOrgId(), fromDTO.getOrgType()); + if (null == orgDTO) { + logger.warn(String.format("工作人员新增,根据新增人员组织类型未查询到相关组织信息,orgId->%s,orgType->%s", fromDTO.getOrgId(), fromDTO.getOrgType())); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"根据新增人员组织类型未查询到相关组织信息","组织不存在"); + } + + //2.调用user服务,新增用户信息 + StaffSubmitFromDTO submitDTO = ConvertUtils.sourceToTarget(fromDTO, StaffSubmitFromDTO.class); + submitDTO.setAgencyId(orgDTO.getAgencyId()); + Result result = epmetUserFeignClient.addStaff(submitDTO); + if (!result.success()) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),result.getInternalMsg(),result.getMsg()); + } + + //3.人员机关表总人数加一、关系表新增关系数据 + //人员机关关系表 + CustomerStaffAgencyEntity customerStaffAgencyEntity = new CustomerStaffAgencyEntity(); + customerStaffAgencyEntity.setCustomerId(fromDTO.getCustomerId()); + customerStaffAgencyEntity.setUserId(result.getData().getUserId()); + customerStaffAgencyEntity.setAgencyId(orgDTO.getAgencyId()); + customerStaffAgencyService.insert(customerStaffAgencyEntity); + //机关总人数加一 + CustomerAgencyEntity agencyEntity = new CustomerAgencyEntity(); + agencyEntity.setId(orgDTO.getAgencyId()); + agencyEntity.setTotalUser(orgDTO.getTotalUser() + 1); + customerAgencyService.updateById(agencyEntity); + + //4.部门、网格主表、关系表修改、新增数据 + if ("dept".equals(fromDTO.getOrgType())) { + CustomerStaffDepartmentEntity dept = new CustomerStaffDepartmentEntity(); + dept.setCustomerId(fromDTO.getCustomerId()); + dept.setUserId(result.getData().getUserId()); + dept.setDepartmentId(fromDTO.getOrgId()); + customerStaffDepartmentService.insert(dept); + CustomerDepartmentEntity departmentEntity = new CustomerDepartmentEntity(); + departmentEntity.setId(fromDTO.getOrgId()); + departmentEntity.setTotalUser(orgDTO.getDeptTotalUser() + 1); + customerDepartmentService.updateById(departmentEntity); + } + if ("grid".equals(fromDTO.getOrgType())) { + CustomerStaffGridEntity grid = new CustomerStaffGridEntity(); + grid.setCustomerId(fromDTO.getCustomerId()); + grid.setUserId(result.getData().getUserId()); + grid.setGridId(fromDTO.getOrgId()); + customerStaffGridService.insert(grid); + CustomerGridEntity gridEntity = new CustomerGridEntity(); + gridEntity.setId(fromDTO.getOrgId()); + gridEntity.setTotalUser(orgDTO.getGridTotalUser() + 1); + customerGridService.updateById(gridEntity); + } + + //5.工作人员注册组织关系表新增数据 + StaffOrgRelationEntity staffOrgRelationEntity = new StaffOrgRelationEntity(); + staffOrgRelationEntity.setCustomerId(fromDTO.getCustomerId()); + if("agency".equals(fromDTO.getOrgType())){ + staffOrgRelationEntity.setPids(("".equals(orgDTO.getPids()) ? "" : orgDTO.getPids())); + }else { + staffOrgRelationEntity.setPids(("".equals(orgDTO.getPids()) ? "" : orgDTO.getPids() + ":") + orgDTO.getAgencyId()); + } + staffOrgRelationEntity.setStaffId(result.getData().getUserId()); + staffOrgRelationEntity.setOrgId(fromDTO.getOrgId()); + staffOrgRelationEntity.setOrgType(fromDTO.getOrgType()); + staffOrgRelationService.insert(staffOrgRelationEntity); + + if (CollectionUtils.isNotEmpty(fromDTO.getNewRoles())){ + Result roleUserAccess = govAccessFeignClient.roleUser(new RoleUserFormDTO(fromDTO.getNewRoles(), customerStaffAgencyEntity.getUserId(),fromDTO.getCustomerId())); + if (!roleUserAccess.success()){ + throw new EpmetException("save data to gov-role-user failure"); + } + } + //如果是烟台的需要更新 根据手机号+姓名 更新data_sync_user_data置为已创建、记录staffId + // 开发环境默认:45687aa479955f9d06204d415238f7cc + // 测试环境:0c41b272ee9ee95ac6f184ad548a30eb + // 烟台: 1535072605621841922 + if ("1535072605621841922".equals(fromDTO.getCustomerId()) + || "45687aa479955f9d06204d415238f7cc".equals(fromDTO.getCustomerId()) + || "0c41b272ee9ee95ac6f184ad548a30eb".equals(fromDTO.getCustomerId())) { + YtSyncStaffIdFormDTO ytSyncStaffIdFormDTO = ConvertUtils.sourceToTarget(fromDTO,YtSyncStaffIdFormDTO.class); + ytSyncStaffIdFormDTO.setStaffId(result.getData().getUserId()); + ytSyncStaffIdFormDTO.setOperUserId(fromDTO.getCurrentUserId()); + epmetThirdOpenFeignClient.dataSyncUpdateStaff(ytSyncStaffIdFormDTO); + } + + }); + } + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/excel/customer_staff_import_template.xlsx b/epmet-module/gov-org/gov-org-server/src/main/resources/excel/customer_staff_import_template.xlsx index df7f412647..7567850518 100644 Binary files a/epmet-module/gov-org/gov-org-server/src/main/resources/excel/customer_staff_import_template.xlsx and b/epmet-module/gov-org/gov-org-server/src/main/resources/excel/customer_staff_import_template.xlsx differ