|
@ -603,73 +603,37 @@ public class StaffServiceImpl implements StaffService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public Result addStaffPy(AddStaffPyFromDTO fromDTO) { |
|
|
public Result addStaffPy(StaffSubmitPyFromDTO fromDTO) { |
|
|
//1.根据新增人员类型判断查询机关信息
|
|
|
CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId()); |
|
|
OrgResultDTO orgDTO = customerAgencyDao.selectAgencyDetail(fromDTO.getOrgId(), fromDTO.getOrgType()); |
|
|
//fromDTO.setApp(tokenDto.getApp());
|
|
|
if (null == orgDTO) { |
|
|
//fromDTO.setClient(tokenDto.getClient());
|
|
|
logger.error(String.format("工作人员新增,根据新增人员组织类型未查询到相关组织信息,orgId->%s,orgType->%s", fromDTO.getOrgId(), fromDTO.getOrgType())); |
|
|
fromDTO.setCustomerId(customerAgencyEntity.getCustomerId()); |
|
|
throw new RenException("根据新增人员组织类型未查询到相关组织信息"); |
|
|
Result<CustomerStaffDTO> result = epmetUserFeignClient.addStaffPy(fromDTO); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//2.调用user服务,新增用户信息
|
|
|
|
|
|
StaffSubmitPyFromDTO submitDTO = ConvertUtils.sourceToTarget(fromDTO, StaffSubmitPyFromDTO.class); |
|
|
|
|
|
submitDTO.setAgencyId(orgDTO.getAgencyId()); |
|
|
|
|
|
Result<CustomerStaffDTO> result = epmetUserFeignClient.addStaffPy(submitDTO); |
|
|
|
|
|
if (!result.success()) { |
|
|
if (!result.success()) { |
|
|
if (result.getCode() != EpmetErrorCode.SERVER_ERROR.getCode()) { |
|
|
if (result.getCode() != EpmetErrorCode.SERVER_ERROR.getCode()) { |
|
|
return new Result().error(result.getCode(), result.getMsg()); |
|
|
return new Result().error(result.getCode(), result.getMsg()); |
|
|
} |
|
|
} |
|
|
return new Result().error(EpmetErrorCode.STAFF_ADD_FAILED.getCode(), EpmetErrorCode.STAFF_ADD_FAILED.getMsg()); |
|
|
return new Result().error(EpmetErrorCode.STAFF_ADD_FAILED.getCode(), EpmetErrorCode.STAFF_ADD_FAILED.getMsg()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//3.人员机关表总人数加一、关系表新增关系数据
|
|
|
|
|
|
//人员机关关系表
|
|
|
//人员机关关系表
|
|
|
CustomerStaffAgencyEntity customerStaffAgencyEntity = new CustomerStaffAgencyEntity(); |
|
|
CustomerStaffAgencyEntity customerStaffAgencyEntity = new CustomerStaffAgencyEntity(); |
|
|
customerStaffAgencyEntity.setCustomerId(fromDTO.getCustomerId()); |
|
|
customerStaffAgencyEntity.setCustomerId(customerAgencyEntity.getCustomerId()); |
|
|
customerStaffAgencyEntity.setUserId(result.getData().getUserId()); |
|
|
customerStaffAgencyEntity.setUserId(result.getData().getUserId()); |
|
|
customerStaffAgencyEntity.setAgencyId(orgDTO.getAgencyId()); |
|
|
customerStaffAgencyEntity.setAgencyId(customerAgencyEntity.getId()); |
|
|
customerStaffAgencyService.insert(customerStaffAgencyEntity); |
|
|
customerStaffAgencyService.insert(customerStaffAgencyEntity); |
|
|
//机关总人数加一
|
|
|
//机关总人数加一
|
|
|
CustomerAgencyEntity agencyEntity = new CustomerAgencyEntity(); |
|
|
customerAgencyEntity.setTotalUser(customerAgencyEntity.getTotalUser() + 1); |
|
|
agencyEntity.setId(orgDTO.getAgencyId()); |
|
|
customerAgencyService.updateById(customerAgencyEntity); |
|
|
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.工作人员注册组织关系表新增数据
|
|
|
//2021.8.25 sun 新增一张工作人员注册组织关系表,所以旧接口新增人员时关系表赋值关系数据
|
|
|
|
|
|
//工作人员注册组织关系表新增数据
|
|
|
StaffOrgRelationEntity staffOrgRelationEntity = new StaffOrgRelationEntity(); |
|
|
StaffOrgRelationEntity staffOrgRelationEntity = new StaffOrgRelationEntity(); |
|
|
staffOrgRelationEntity.setCustomerId(fromDTO.getCustomerId()); |
|
|
staffOrgRelationEntity.setCustomerId(fromDTO.getCustomerId()); |
|
|
if("agency".equals(fromDTO.getOrgType())){ |
|
|
staffOrgRelationEntity.setPids(("".equals(customerAgencyEntity.getPids()) ? "" : customerAgencyEntity.getPids())); |
|
|
staffOrgRelationEntity.setPids(("".equals(orgDTO.getPids()) ? "" : orgDTO.getPids())); |
|
|
|
|
|
}else { |
|
|
|
|
|
staffOrgRelationEntity.setPids(("".equals(orgDTO.getPids()) ? "" : orgDTO.getPids() + ":") + orgDTO.getAgencyId()); |
|
|
|
|
|
} |
|
|
|
|
|
staffOrgRelationEntity.setStaffId(result.getData().getUserId()); |
|
|
staffOrgRelationEntity.setStaffId(result.getData().getUserId()); |
|
|
staffOrgRelationEntity.setOrgId(fromDTO.getOrgId()); |
|
|
staffOrgRelationEntity.setOrgId(customerAgencyEntity.getId()); |
|
|
staffOrgRelationEntity.setOrgType(fromDTO.getOrgType()); |
|
|
staffOrgRelationEntity.setOrgType("agency"); |
|
|
staffOrgRelationService.insert(staffOrgRelationEntity); |
|
|
staffOrgRelationService.insert(staffOrgRelationEntity); |
|
|
|
|
|
|
|
|
return new Result(); |
|
|
return new Result(); |
|
|