|  |  | @ -1,22 +1,20 @@ | 
			
		
	
		
			
				
					|  |  |  | package com.epmet.service.impl; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.constant.NumConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.exception.EpmetErrorCode; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.exception.RenException; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.security.dto.TokenDto; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.Result; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.CustomerAgencyDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.CustomerStaffAgencyDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.CustomerStaffDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.form.StaffInfoFromDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.form.StaffSubmitFromDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.form.StaffsInAgencyFromDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.*; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.form.*; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.result.*; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.entity.CustomerAgencyEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.entity.CustomerStaffAgencyEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.feign.EpmetHeartOpenFeignClient; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.feign.EpmetUserFeignClient; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.feign.GovProjectOpenFeignClient; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.feign.OperCrmFeignClient; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.CustomerAgencyService; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.CustomerStaffAgencyService; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.StaffService; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.*; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
	
		
			
				
					|  |  | @ -40,6 +38,16 @@ public class StaffServiceImpl implements StaffService { | 
			
		
	
		
			
				
					|  |  |  | 	private CustomerAgencyService customerAgencyService; | 
			
		
	
		
			
				
					|  |  |  | 	@Autowired | 
			
		
	
		
			
				
					|  |  |  | 	private CustomerStaffAgencyService customerStaffAgencyService; | 
			
		
	
		
			
				
					|  |  |  | 	@Autowired | 
			
		
	
		
			
				
					|  |  |  | 	private GovProjectOpenFeignClient govProjectOpenFeignClient; | 
			
		
	
		
			
				
					|  |  |  | 	@Autowired | 
			
		
	
		
			
				
					|  |  |  | 	private EpmetHeartOpenFeignClient epmetHeartOpenFeignClient; | 
			
		
	
		
			
				
					|  |  |  | 	@Autowired | 
			
		
	
		
			
				
					|  |  |  | 	private CustomerDepartmentService customerDepartmentService; | 
			
		
	
		
			
				
					|  |  |  | 	@Autowired | 
			
		
	
		
			
				
					|  |  |  | 	private CustomerGridService customerGridService; | 
			
		
	
		
			
				
					|  |  |  | 	@Autowired | 
			
		
	
		
			
				
					|  |  |  | 	private StaffTransferRecordService staffTransferRecordService; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	@Override | 
			
		
	
		
			
				
					|  |  |  | 	public Result<StaffsInAgencyResultDTO> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { | 
			
		
	
	
		
			
				
					|  |  | @ -183,4 +191,58 @@ public class StaffServiceImpl implements StaffService { | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		return result; | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	@Override | 
			
		
	
		
			
				
					|  |  |  | 	@Transactional(rollbackFor = Exception.class) | 
			
		
	
		
			
				
					|  |  |  | 	public void staffTransfer(TokenDto tokenDto, StaffTransferFormDTO fromDTO) { | 
			
		
	
		
			
				
					|  |  |  | 		//1.获取工作人员与机关关系
 | 
			
		
	
		
			
				
					|  |  |  | 		CustomerStaffAgencyDTO staffAgencyDTO = customerStaffAgencyService.getInfoByUserId(fromDTO.getStaffId()); | 
			
		
	
		
			
				
					|  |  |  | 		String oldAgency = staffAgencyDTO.getAgencyId(); | 
			
		
	
		
			
				
					|  |  |  | 		//2.查询是否有未处理项目
 | 
			
		
	
		
			
				
					|  |  |  | 		ProjectListFromDTO projectFromDTO = new ProjectListFromDTO(); | 
			
		
	
		
			
				
					|  |  |  | 		projectFromDTO.setCustomerId(staffAgencyDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  | 		projectFromDTO.setUserId(fromDTO.getStaffId()); | 
			
		
	
		
			
				
					|  |  |  | 		projectFromDTO.setPageNo(1); | 
			
		
	
		
			
				
					|  |  |  | 		projectFromDTO.setPageSize(10); | 
			
		
	
		
			
				
					|  |  |  | 		Result<List<PendProjectListResultDTO>> pendResult = govProjectOpenFeignClient.getPendProjectList(projectFromDTO); | 
			
		
	
		
			
				
					|  |  |  | 		if (!pendResult.success()) { | 
			
		
	
		
			
				
					|  |  |  | 			throw new RenException(pendResult.getCode(), pendResult.getMsg()); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		if (null != pendResult.getData() && pendResult.getData().size() > NumConstant.ZERO) { | 
			
		
	
		
			
				
					|  |  |  | 			throw new RenException(EpmetErrorCode.EXIT_PEND_PROJECT.getCode()); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		//3.查询是否有活动未结束
 | 
			
		
	
		
			
				
					|  |  |  | 		Result<List<ActInfoDTO>> actInfoResult = epmetHeartOpenFeignClient.getPublishedAct(fromDTO.getStaffId()); | 
			
		
	
		
			
				
					|  |  |  | 		if (!actInfoResult.success()) { | 
			
		
	
		
			
				
					|  |  |  | 			throw new RenException(actInfoResult.getCode(), actInfoResult.getMsg()); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		if (null != actInfoResult.getData() && actInfoResult.getData().size() > NumConstant.ZERO) { | 
			
		
	
		
			
				
					|  |  |  | 			throw new RenException(EpmetErrorCode.EXIT_PUBLISHED_ACTIVITY.getCode()); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		//4.修改人员所属组织
 | 
			
		
	
		
			
				
					|  |  |  | 		CustomerStaffAgencyDTO staffAgency = new CustomerStaffAgencyDTO(); | 
			
		
	
		
			
				
					|  |  |  | 		staffAgency.setId(staffAgencyDTO.getId()); | 
			
		
	
		
			
				
					|  |  |  | 		staffAgency.setAgencyId(fromDTO.getAgencyId()); | 
			
		
	
		
			
				
					|  |  |  | 		customerStaffAgencyService.update(staffAgency); | 
			
		
	
		
			
				
					|  |  |  | 		//原来组织总人数减一
 | 
			
		
	
		
			
				
					|  |  |  | 		CustomerAgencyDTO oldAgencyDTO = customerAgencyService.get(oldAgency); | 
			
		
	
		
			
				
					|  |  |  | 		oldAgencyDTO.setTotalUser(oldAgencyDTO.getTotalUser() - NumConstant.ONE); | 
			
		
	
		
			
				
					|  |  |  | 		customerAgencyService.update(oldAgencyDTO); | 
			
		
	
		
			
				
					|  |  |  | 		//新组织总人数加一
 | 
			
		
	
		
			
				
					|  |  |  | 		CustomerAgencyDTO newAgencyDTO = customerAgencyService.get(fromDTO.getAgencyId()); | 
			
		
	
		
			
				
					|  |  |  | 		newAgencyDTO.setTotalUser(newAgencyDTO.getTotalUser() - NumConstant.ONE); | 
			
		
	
		
			
				
					|  |  |  | 		customerAgencyService.update(newAgencyDTO); | 
			
		
	
		
			
				
					|  |  |  | 		//5.逻辑删除工作人员原组织加入的部门、网格,部门、网格总人数减1
 | 
			
		
	
		
			
				
					|  |  |  | 		customerDepartmentService.updateDepartment(fromDTO.getStaffId()); | 
			
		
	
		
			
				
					|  |  |  | 		customerGridService.updateGrid(fromDTO.getStaffId()); | 
			
		
	
		
			
				
					|  |  |  | 		//6.操作记录表新增调动记录
 | 
			
		
	
		
			
				
					|  |  |  | 		StaffTransferRecordDTO staffTransferRecordDTO = new StaffTransferRecordDTO(); | 
			
		
	
		
			
				
					|  |  |  | 		staffTransferRecordDTO.setCustomerId(tokenDto.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  | 		staffTransferRecordDTO.setOperateStaffId(tokenDto.getUserId()); | 
			
		
	
		
			
				
					|  |  |  | 		staffTransferRecordDTO.setOperatedStaffId(fromDTO.getStaffId()); | 
			
		
	
		
			
				
					|  |  |  | 		staffTransferRecordDTO.setOldAgencyId(oldAgency); | 
			
		
	
		
			
				
					|  |  |  | 		staffTransferRecordDTO.setAgencyId(fromDTO.getAgencyId()); | 
			
		
	
		
			
				
					|  |  |  | 		staffTransferRecordDTO.setRemarks(fromDTO.getRemarks()); | 
			
		
	
		
			
				
					|  |  |  | 		staffTransferRecordService.save(staffTransferRecordDTO); | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
	
		
			
				
					|  |  | 
 |