|
|
@ -5,19 +5,16 @@ 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.*; |
|
|
|
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; |
|
|
@ -43,6 +40,14 @@ public class StaffServiceImpl implements StaffService { |
|
|
|
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) { |
|
|
@ -188,6 +193,7 @@ public class StaffServiceImpl implements StaffService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void staffTransfer(TokenDto tokenDto, StaffTransferFormDTO fromDTO) { |
|
|
|
//1.获取工作人员与机关关系
|
|
|
|
CustomerStaffAgencyDTO staffAgencyDTO = customerStaffAgencyService.getInfoByUserId(fromDTO.getStaffId()); |
|
|
@ -206,11 +212,37 @@ public class StaffServiceImpl implements StaffService { |
|
|
|
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.修改人员所属组织
|
|
|
|
|
|
|
|
//5.逻辑删除工作人员原组织加入的部门、网格,组织人员总数旧的减1新的加1,部门、网格总人数减1
|
|
|
|
|
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|