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