|
@@ -8,7 +8,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.persagy.fm.common.constant.enums.ValidEnum;
|
|
|
import com.persagy.fm.common.context.DefaultAppContext;
|
|
|
import com.persagy.fm.common.model.vo.SimpleObjVO;
|
|
|
-import com.persagy.fm.common.response.FmResponseContent;
|
|
|
+import com.persagy.fm.common.utils.ListUtil;
|
|
|
import com.persagy.fm.department.model.vo.DepSimpleObjVO;
|
|
|
import com.persagy.fm.department.service.IDepartmentService;
|
|
|
import com.persagy.fm.person.constant.enums.CertificateTypeEnum;
|
|
@@ -21,13 +21,9 @@ import com.persagy.fm.person.model.vo.ResponsePersonItemVO;
|
|
|
import com.persagy.fm.person.model.vo.ResponsePersonListItemVO;
|
|
|
import com.persagy.fm.person.service.IPersonService;
|
|
|
import com.persagy.fm.profession.service.IProfessionService;
|
|
|
-import com.persagy.fm.saas.account.client.SaasAccountClient;
|
|
|
-import com.persagy.fm.saas.account.constant.enums.AccountTypeEnum;
|
|
|
-import com.persagy.fm.saas.account.model.dto.AddSaasAccountDTO;
|
|
|
-import com.persagy.fm.saas.account.model.dto.DeleteSaasAccountDTO;
|
|
|
-import com.persagy.fm.saas.account.model.dto.EnableSaasAccountDTO;
|
|
|
-import com.persagy.fm.saas.account.model.dto.PageQuerySaasAccountDTO;
|
|
|
+import com.persagy.fm.saas.account.model.dto.*;
|
|
|
import com.persagy.fm.saas.account.model.vo.SaasAccountListItemVO;
|
|
|
+import com.persagy.fm.saas.account.service.ISaasAccountService;
|
|
|
import com.persagy.fm.saas.accountproject.model.dto.AddSaasAccountProjectDTO;
|
|
|
import com.persagy.fm.saas.accountproject.service.ISaasAccountProjectService;
|
|
|
import com.persagy.fm.saas.accountrole.constant.enums.AccountRoleTypeEnum;
|
|
@@ -47,7 +43,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
-import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -64,7 +59,7 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
|
|
|
@Autowired
|
|
|
private IWorkResumeService workResumeService;
|
|
|
@Autowired
|
|
|
- private SaasAccountClient saasAccountClient;
|
|
|
+ private ISaasAccountService saasAccountService;
|
|
|
@Autowired
|
|
|
private PersonMapper personMapper;
|
|
|
@Autowired
|
|
@@ -110,7 +105,7 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
|
|
|
/**
|
|
|
* 账号关联项目
|
|
|
*
|
|
|
- * @param accountId 账号id
|
|
|
+ * @param accountId 账号id
|
|
|
* @param projectIds 项目id列表
|
|
|
* @author lixing
|
|
|
* @version V1.0 2021/3/26 5:23 下午
|
|
@@ -129,10 +124,10 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
|
|
|
/**
|
|
|
* 账号关联角色
|
|
|
*
|
|
|
- * @param accountId 账号id
|
|
|
- * @param mainDuty 主岗id
|
|
|
+ * @param accountId 账号id
|
|
|
+ * @param mainDuty 主岗id
|
|
|
* @param otherDuties 副岗id列表
|
|
|
- * @param otherRoles 其他角色列表
|
|
|
+ * @param otherRoles 其他角色列表
|
|
|
* @author lixing
|
|
|
* @version V1.0 2021/3/26 11:41 上午
|
|
|
*/
|
|
@@ -160,8 +155,8 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
|
|
|
/**
|
|
|
* 账号关联角色
|
|
|
*
|
|
|
- * @param accountId 账号id
|
|
|
- * @param roleId 角色id
|
|
|
+ * @param accountId 账号id
|
|
|
+ * @param roleId 角色id
|
|
|
* @param accountRoleType 关联类型
|
|
|
* @author lixing
|
|
|
* @version V1.0 2021/3/26 11:42 上午
|
|
@@ -220,16 +215,8 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
|
|
|
* @version V1.0 2021/3/23 3:42 下午
|
|
|
*/
|
|
|
private String createAccount(AddPersonDTO addPersonDTO) {
|
|
|
- AddSaasAccountDTO addSaasAccountDTO = new AddSaasAccountDTO();
|
|
|
- addSaasAccountDTO.setDefaultValue();
|
|
|
- addSaasAccountDTO.setUsername(addPersonDTO.getUsername());
|
|
|
- addSaasAccountDTO.setPhoneNum(addPersonDTO.getPhoneNum());
|
|
|
- addSaasAccountDTO.setMail(addPersonDTO.getMail());
|
|
|
- addSaasAccountDTO.setAccountType(AccountTypeEnum.COMMON.getType());
|
|
|
- addSaasAccountDTO.setValidStartTime(new Date());
|
|
|
- addSaasAccountDTO.setValidEndTime(addPersonDTO.getExpireDate());
|
|
|
- FmResponseContent<String> saasAccount = saasAccountClient.createSaasAccount(addSaasAccountDTO);
|
|
|
- return saasAccount.getContent();
|
|
|
+ AddSaasAccountDTO addSaasAccountDTO = ConvertPersonTool.INSTANCE.convert2AddSaasAccountDTO(addPersonDTO);
|
|
|
+ return saasAccountService.createSaasAccount(addSaasAccountDTO);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -246,10 +233,9 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
|
|
|
}
|
|
|
|
|
|
PageQuerySaasAccountDTO pageQuerySaasAccountDTO = new PageQuerySaasAccountDTO();
|
|
|
- pageQuerySaasAccountDTO.setDefaultValue();
|
|
|
pageQuerySaasAccountDTO.setUsername(username);
|
|
|
- FmResponseContent<List<SaasAccountListItemVO>> listFmResponseContent = saasAccountClient.querySaasAccountPageList(pageQuerySaasAccountDTO);
|
|
|
- if (listFmResponseContent.getCount() > 0) {
|
|
|
+ List<SaasAccountListItemVO> accountListItemVoList = saasAccountService.querySaasAccountList(pageQuerySaasAccountDTO);
|
|
|
+ if (!CollectionUtils.isEmpty(accountListItemVoList)) {
|
|
|
throw new IllegalArgumentException("账号已被使用");
|
|
|
}
|
|
|
}
|
|
@@ -263,11 +249,9 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
|
|
|
*/
|
|
|
private void checkPhoneNum(String phoneNum) {
|
|
|
PageQuerySaasAccountDTO pageQuerySaasAccountDTO = new PageQuerySaasAccountDTO();
|
|
|
- pageQuerySaasAccountDTO.setDefaultValue();
|
|
|
- pageQuerySaasAccountDTO.setAccountId(null);
|
|
|
pageQuerySaasAccountDTO.setPhoneNum(phoneNum);
|
|
|
- FmResponseContent<List<SaasAccountListItemVO>> listFmResponseContent = saasAccountClient.querySaasAccountPageList(pageQuerySaasAccountDTO);
|
|
|
- if (listFmResponseContent.getCount() > 0) {
|
|
|
+ List<SaasAccountListItemVO> accountListItemVoList = saasAccountService.querySaasAccountList(pageQuerySaasAccountDTO);
|
|
|
+ if (!CollectionUtils.isEmpty(accountListItemVoList)) {
|
|
|
throw new IllegalArgumentException("手机号已被使用");
|
|
|
}
|
|
|
}
|
|
@@ -387,17 +371,68 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
|
|
|
person = ConvertPersonTool.INSTANCE.convertUpdateDto2Entity(person, updatePersonDTO);
|
|
|
person.setModifier(DefaultAppContext.getContext().getAccountId());
|
|
|
updateById(person);
|
|
|
- // TODO: 2021/4/1
|
|
|
- // 判断是否有账号相关的更新
|
|
|
- // 判断是否有工作信息相关的更新
|
|
|
- List<String> depIds = updatePersonDTO.getDepIds();
|
|
|
+ // 账号基本信息发生改变,更新账号信息
|
|
|
+ SaasAccountListItemVO account = saasAccountService.querySaasAccountDetail(person.getAccountId());
|
|
|
+ if (accountInfoChanged(updatePersonDTO, account)) {
|
|
|
+ UpdateSaasAccountDTO updateSaasAccountDTO = ConvertPersonTool.INSTANCE.
|
|
|
+ convert2UpdateSaasAccountDTO(account, updatePersonDTO);
|
|
|
+ saasAccountService.updateSaasAccount(updateSaasAccountDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新工作信息
|
|
|
+ List<String> depIdsAfterUpdate = updatePersonDTO.getDepIds();
|
|
|
+ updatePersonWorkResumes(depIdsAfterUpdate, personId);
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean accountInfoChanged(UpdatePersonDTO updatePersonDTO, SaasAccountListItemVO account) {
|
|
|
+ if (account != null) {
|
|
|
+ // 账号名称
|
|
|
+ if (account.getUsername() != null &&
|
|
|
+ !account.getUsername().equals(updatePersonDTO.getUsername())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ // 登录权限
|
|
|
+ if (account.getValidEndTime() != null &&
|
|
|
+ !account.getValidEndTime().equals(updatePersonDTO.getExpireDate())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ // 手机号码
|
|
|
+ if (account.getPhoneNum() != null &&
|
|
|
+ !account.getPhoneNum().equals(updatePersonDTO.getPhoneNum())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ // 邮箱
|
|
|
+ if (account.getMail() != null &&
|
|
|
+ !account.getMail().equals(updatePersonDTO.getMail())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new IllegalArgumentException("账号信息为空");
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新人员的工作信息
|
|
|
+ *
|
|
|
+ * @param depIdsAfterUpdate 人员更新后所在的部门
|
|
|
+ * @param personId 人员id
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021/4/6 11:37 上午
|
|
|
+ */
|
|
|
+ private void updatePersonWorkResumes(List<String> depIdsAfterUpdate, String personId) {
|
|
|
List<WorkResume> workResumes = workResumeService.queryWorkResumeListByPersonIdList(Lists.newArrayList(personId));
|
|
|
+ List<String> depIdsBeforeUpdate = workResumes.stream().map(WorkResume::getDepId).collect(Collectors.toList());
|
|
|
|
|
|
+ List<String> addedDepIds = ListUtil.getAddedList(depIdsAfterUpdate, depIdsBeforeUpdate);
|
|
|
+ List<String> deletedDepIds = ListUtil.getDeletedList(depIdsAfterUpdate, depIdsBeforeUpdate);
|
|
|
+
|
|
|
+ workResumeService.updatePersonWorkResume(personId, addedDepIds, deletedDepIds);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<Person> queryByAccountId(String accountId) {
|
|
|
- if(StringUtils.isBlank(accountId)) {
|
|
|
+ if (StringUtils.isBlank(accountId)) {
|
|
|
throw new IllegalArgumentException("根据账号id查询人员,账号id为空");
|
|
|
}
|
|
|
QueryWrapper<Person> queryWrapper = new QueryWrapper<>();
|
|
@@ -523,10 +558,16 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
|
|
|
// 禁用账号
|
|
|
Person person = queryPersonProfile(personId);
|
|
|
String accountId = person.getAccountId();
|
|
|
- DeleteSaasAccountDTO deleteSaasAccountDTO = new DeleteSaasAccountDTO();
|
|
|
- deleteSaasAccountDTO.setDefaultValue();
|
|
|
- deleteSaasAccountDTO.setAccountId(accountId);
|
|
|
- saasAccountClient.disableAccount(deleteSaasAccountDTO);
|
|
|
+
|
|
|
+ // 有可能账号已经被禁用。被禁用的账号再次被禁用会抛出异常。
|
|
|
+ SaasAccountListItemVO saasAccountListItemVO = saasAccountService.querySaasAccountDetail(accountId);
|
|
|
+ if (saasAccountListItemVO != null &&
|
|
|
+ ValidEnum.TRUE.getType().equals(saasAccountListItemVO.getValid())) {
|
|
|
+ DeleteSaasAccountDTO deleteSaasAccountDTO = new DeleteSaasAccountDTO();
|
|
|
+ deleteSaasAccountDTO.setAccountId(accountId);
|
|
|
+ saasAccountService.disableAccount(deleteSaasAccountDTO);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
// 工作信息状态更新为禁用
|
|
|
workResumeService.changeWorkResumeEnableStateByPersonId(
|
|
@@ -566,10 +607,8 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
|
|
|
Person person = queryPersonProfile(personId);
|
|
|
String accountId = person.getAccountId();
|
|
|
EnableSaasAccountDTO enableSaasAccountDTO = new EnableSaasAccountDTO();
|
|
|
- enableSaasAccountDTO.setDefaultValue();
|
|
|
enableSaasAccountDTO.setAccountId(accountId);
|
|
|
- saasAccountClient.enableAccount(enableSaasAccountDTO);
|
|
|
-
|
|
|
+ saasAccountService.enableAccount(enableSaasAccountDTO);
|
|
|
// 工作信息状态更新为启用
|
|
|
workResumeService.changeWorkResumeEnableStateByPersonId(
|
|
|
personId, WorkResumeEnableStateEnum.ENABLE.getType());
|
|
@@ -584,6 +623,7 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
|
|
|
public ResponsePersonItemVO queryPersonDetail(String id) {
|
|
|
return queryPersonDetail(id, null);
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public ResponsePersonItemVO queryPersonDetail(String id, String depId) {
|
|
|
Person person = queryPersonProfile(id);
|
|
@@ -634,7 +674,7 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
|
|
|
responsePersonItemVO.setEnableState(currentWorkResume.getEnableState());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return responsePersonItemVO;
|
|
|
}
|
|
|
|
|
@@ -647,7 +687,7 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
|
|
|
* @version V1.0 2021/4/1 6:00 下午
|
|
|
*/
|
|
|
private List<DepSimpleObjVO> getDepSimpleObjVoList(List<WorkResume> workResumes) {
|
|
|
- if (CollectionUtils.isEmpty(workResumes)){
|
|
|
+ if (CollectionUtils.isEmpty(workResumes)) {
|
|
|
return Lists.newArrayList();
|
|
|
}
|
|
|
List<String> depIds = workResumes.stream().map(WorkResume::getDepId).collect(Collectors.toList());
|
|
@@ -670,6 +710,14 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
|
|
|
return new SimpleObjVO(leaderId, person.getName());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据证件类型id,获取证件类型信息
|
|
|
+ *
|
|
|
+ * @param certificateType 证件类型id
|
|
|
+ * @return 证件类型信息
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021/4/6 11:38 上午
|
|
|
+ */
|
|
|
private SimpleObjVO getCertificateTypeVO(String certificateType) {
|
|
|
SimpleObjVO certificateTypeVO = new SimpleObjVO();
|
|
|
certificateTypeVO.setId(certificateType);
|