|
@ -1,14 +1,17 @@ |
|
|
package com.epmet.service.impl; |
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
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.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.redis.RedisKeys; |
|
|
import com.epmet.commons.tools.redis.RedisKeys; |
|
|
import com.epmet.commons.tools.redis.RedisUtils; |
|
|
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.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.constant.CustomerAgencyConstant; |
|
|
import com.epmet.constant.CustomerAgencyConstant; |
|
|
|
|
|
import com.epmet.constant.OrgInfoConstant; |
|
|
import com.epmet.dao.CustomerAgencyDao; |
|
|
import com.epmet.dao.CustomerAgencyDao; |
|
|
import com.epmet.dao.CustomerStaffAgencyDao; |
|
|
import com.epmet.dao.CustomerStaffAgencyDao; |
|
|
import com.epmet.dto.*; |
|
|
import com.epmet.dto.*; |
|
@ -24,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
@ -68,6 +72,8 @@ public class StaffServiceImpl implements StaffService { |
|
|
private CustomerStaffGridService customerStaffGridService; |
|
|
private CustomerStaffGridService customerStaffGridService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private StaffOrgRelationService staffOrgRelationService; |
|
|
private StaffOrgRelationService staffOrgRelationService; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private CustomerStaffRedis customerStaffRedis; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Result<StaffsInAgencyResultDTO> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { |
|
|
public Result<StaffsInAgencyResultDTO> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { |
|
@ -243,6 +249,7 @@ public class StaffServiceImpl implements StaffService { |
|
|
if (null != actInfoResult.getData() && actInfoResult.getData().size() > NumConstant.ZERO) { |
|
|
if (null != actInfoResult.getData() && actInfoResult.getData().size() > NumConstant.ZERO) { |
|
|
throw new RenException(EpmetErrorCode.EXIT_PUBLISHED_ACTIVITY.getCode()); |
|
|
throw new RenException(EpmetErrorCode.EXIT_PUBLISHED_ACTIVITY.getCode()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//4.修改人员所属组织
|
|
|
//4.修改人员所属组织
|
|
|
CustomerStaffAgencyDTO staffAgency = new CustomerStaffAgencyDTO(); |
|
|
CustomerStaffAgencyDTO staffAgency = new CustomerStaffAgencyDTO(); |
|
|
staffAgency.setId(staffAgencyDTO.getId()); |
|
|
staffAgency.setId(staffAgencyDTO.getId()); |
|
@ -283,6 +290,143 @@ public class StaffServiceImpl implements StaffService { |
|
|
//2021.6.7 添加逻辑-人员调动删除token sun end
|
|
|
//2021.6.7 添加逻辑-人员调动删除token sun end
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 工作人员调动 |
|
|
|
|
|
* |
|
|
|
|
|
* @param tokenDto |
|
|
|
|
|
* @param fromDTO |
|
|
|
|
|
* @return void |
|
|
|
|
|
* @author zhaoqifeng |
|
|
|
|
|
* @date 2020/8/27 16:13 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public void staffTransferV2(TokenDto tokenDto, StaffTransferV2FormDTO fromDTO) { |
|
|
|
|
|
if (tokenDto.getUserId().equals(fromDTO.getStaffId())) { |
|
|
|
|
|
throw new RenException(EpmetErrorCode.CAN_NOT_SELF.getCode()); |
|
|
|
|
|
} |
|
|
|
|
|
//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.修改人员所属组织
|
|
|
|
|
|
String agencyId = null; |
|
|
|
|
|
String orgType = null; |
|
|
|
|
|
String orgId = null; |
|
|
|
|
|
if (OrgInfoConstant.AGENCY.equals(fromDTO.getOrgType())) { |
|
|
|
|
|
agencyId = fromDTO.getOrgId(); |
|
|
|
|
|
} else if (OrgInfoConstant.DEPT.equals(fromDTO.getOrgType())) { |
|
|
|
|
|
orgType = fromDTO.getOrgType(); |
|
|
|
|
|
orgId = fromDTO.getOrgId(); |
|
|
|
|
|
CustomerDepartmentDTO departmentDTO = customerDepartmentService.get(orgId); |
|
|
|
|
|
agencyId = departmentDTO.getAgencyId(); |
|
|
|
|
|
} else { |
|
|
|
|
|
orgType = fromDTO.getOrgType(); |
|
|
|
|
|
orgId = fromDTO.getOrgId(); |
|
|
|
|
|
CustomerGridDTO gridDTO = customerGridService.get(orgId); |
|
|
|
|
|
agencyId = gridDTO.getPid(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CustomerStaffAgencyDTO staffAgency = new CustomerStaffAgencyDTO(); |
|
|
|
|
|
staffAgency.setId(staffAgencyDTO.getId()); |
|
|
|
|
|
staffAgency.setAgencyId(agencyId); |
|
|
|
|
|
customerStaffAgencyService.update(staffAgency); |
|
|
|
|
|
//原来组织总人数减一
|
|
|
|
|
|
CustomerAgencyDTO oldAgencyDTO = customerAgencyService.get(oldAgency); |
|
|
|
|
|
oldAgencyDTO.setTotalUser(oldAgencyDTO.getTotalUser() - NumConstant.ONE); |
|
|
|
|
|
customerAgencyService.update(oldAgencyDTO); |
|
|
|
|
|
//新组织总人数加一
|
|
|
|
|
|
CustomerAgencyDTO newAgencyDTO = customerAgencyService.get(agencyId); |
|
|
|
|
|
newAgencyDTO.setTotalUser(newAgencyDTO.getTotalUser() + NumConstant.ONE); |
|
|
|
|
|
customerAgencyService.update(newAgencyDTO); |
|
|
|
|
|
//逻辑删除工作人员原组织加入的部门、网格,部门、网格总人数减1
|
|
|
|
|
|
customerDepartmentService.updateDepartment(fromDTO.getStaffId()); |
|
|
|
|
|
customerGridService.updateGrid(fromDTO.getStaffId()); |
|
|
|
|
|
if (OrgInfoConstant.DEPT.equals(orgType)) { |
|
|
|
|
|
//添加新的部门关系
|
|
|
|
|
|
CustomerStaffDepartmentDTO staffDepartmentDTO = new CustomerStaffDepartmentDTO(); |
|
|
|
|
|
staffDepartmentDTO.setCustomerId(tokenDto.getCustomerId()); |
|
|
|
|
|
staffDepartmentDTO.setDepartmentId(orgId); |
|
|
|
|
|
staffDepartmentDTO.setUserId(fromDTO.getStaffId()); |
|
|
|
|
|
customerStaffDepartmentService.save(staffDepartmentDTO); |
|
|
|
|
|
//新部门总人数+1
|
|
|
|
|
|
CustomerDepartmentDTO departmentDTO = customerDepartmentService.get(orgId); |
|
|
|
|
|
departmentDTO.setTotalUser(departmentDTO.getTotalUser() + NumConstant.ONE); |
|
|
|
|
|
departmentDTO.setUpdatedBy(null); |
|
|
|
|
|
departmentDTO.setUpdatedTime(null); |
|
|
|
|
|
customerDepartmentService.update(departmentDTO); |
|
|
|
|
|
} |
|
|
|
|
|
if (OrgInfoConstant.GRID.equals(orgType)) { |
|
|
|
|
|
//添加新的网格关系
|
|
|
|
|
|
CustomerStaffGridDTO staffGridDTO = new CustomerStaffGridDTO(); |
|
|
|
|
|
staffGridDTO.setCustomerId(tokenDto.getCustomerId()); |
|
|
|
|
|
staffGridDTO.setGridId(orgId); |
|
|
|
|
|
staffGridDTO.setUserId(fromDTO.getStaffId()); |
|
|
|
|
|
customerStaffGridService.save(staffGridDTO); |
|
|
|
|
|
//新网格总人数+1
|
|
|
|
|
|
CustomerGridDTO gridDTO = customerGridService.get(orgId); |
|
|
|
|
|
gridDTO.setTotalUser(gridDTO.getTotalUser() + NumConstant.ONE); |
|
|
|
|
|
gridDTO.setUpdatedBy(null); |
|
|
|
|
|
gridDTO.setUpdatedTime(null); |
|
|
|
|
|
customerGridService.update(gridDTO); |
|
|
|
|
|
} |
|
|
|
|
|
//6.更改工作人员组织角色
|
|
|
|
|
|
StaffRoleDTO staffRoleDTO = new StaffRoleDTO(); |
|
|
|
|
|
staffRoleDTO.setOrgId(agencyId); |
|
|
|
|
|
staffRoleDTO.setStaffId(fromDTO.getStaffId()); |
|
|
|
|
|
Result result = epmetUserOpenFeignClient.changeRoleOrg(staffRoleDTO); |
|
|
|
|
|
if (!result.success()) { |
|
|
|
|
|
throw new RenException(result.getCode(), result.getMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
//7.操作记录表新增调动记录
|
|
|
|
|
|
//获取工作人员注册组织关系
|
|
|
|
|
|
StaffOrgRelationDTO staffOrgRelation = staffOrgRelationService.getByStaffId(fromDTO.getStaffId()); |
|
|
|
|
|
StaffTransferRecordDTO staffTransferRecordDTO = new StaffTransferRecordDTO(); |
|
|
|
|
|
staffTransferRecordDTO.setCustomerId(tokenDto.getCustomerId()); |
|
|
|
|
|
staffTransferRecordDTO.setOperateStaffId(tokenDto.getUserId()); |
|
|
|
|
|
staffTransferRecordDTO.setOperatedStaffId(fromDTO.getStaffId()); |
|
|
|
|
|
staffTransferRecordDTO.setOldAgencyId(oldAgency); |
|
|
|
|
|
if (!OrgInfoConstant.AGENCY.equals(staffOrgRelation.getOrgType())) { |
|
|
|
|
|
staffTransferRecordDTO.setOldOrgType(staffOrgRelation.getOrgType()); |
|
|
|
|
|
staffTransferRecordDTO.setOldOrgId(staffOrgRelation.getOrgId()); |
|
|
|
|
|
} |
|
|
|
|
|
staffTransferRecordDTO.setAgencyId(agencyId); |
|
|
|
|
|
staffTransferRecordDTO.setOrgType(orgType); |
|
|
|
|
|
staffTransferRecordDTO.setOrgId(orgId); |
|
|
|
|
|
staffTransferRecordDTO.setRemarks(fromDTO.getRemarks()); |
|
|
|
|
|
staffTransferRecordService.save(staffTransferRecordDTO); |
|
|
|
|
|
//8.更改注册关系
|
|
|
|
|
|
staffOrgRelation.setOrgId(fromDTO.getOrgId()); |
|
|
|
|
|
staffOrgRelation.setOrgType(fromDTO.getOrgType()); |
|
|
|
|
|
staffOrgRelation.setUpdatedBy(null); |
|
|
|
|
|
staffOrgRelation.setUpdatedTime(null); |
|
|
|
|
|
staffOrgRelationService.update(staffOrgRelation); |
|
|
|
|
|
//9..清除可能存在的工作人员登陆token
|
|
|
|
|
|
String key = RedisKeys.getCpUserKey("gov", "wxmp", fromDTO.getStaffId()); |
|
|
|
|
|
redisUtils.delete(key); |
|
|
|
|
|
//10 清除工作人员缓存
|
|
|
|
|
|
customerStaffRedis.delStaffInfoFormCache(tokenDto.getCustomerId(), fromDTO.getStaffId()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 根据staffId查询用户基本信息 |
|
|
* 根据staffId查询用户基本信息 |
|
|
* @author sun |
|
|
* @author sun |
|
|