|
@@ -1,10 +1,31 @@
|
|
package com.qmth.sop.business.service.impl;
|
|
package com.qmth.sop.business.service.impl;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.qmth.sop.business.bean.params.UserArchivesParam;
|
|
|
|
+import com.qmth.sop.business.bean.result.UserArchivesResult;
|
|
|
|
+import com.qmth.sop.business.entity.SysSupplier;
|
|
|
|
+import com.qmth.sop.business.entity.SysUser;
|
|
import com.qmth.sop.business.entity.TBUserArchives;
|
|
import com.qmth.sop.business.entity.TBUserArchives;
|
|
import com.qmth.sop.business.mapper.TBUserArchivesMapper;
|
|
import com.qmth.sop.business.mapper.TBUserArchivesMapper;
|
|
|
|
+import com.qmth.sop.business.service.SysSupplierService;
|
|
|
|
+import com.qmth.sop.business.service.SysUserRoleService;
|
|
import com.qmth.sop.business.service.TBUserArchivesService;
|
|
import com.qmth.sop.business.service.TBUserArchivesService;
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
|
+import com.qmth.sop.common.contant.SystemConstant;
|
|
|
|
+import com.qmth.sop.common.enums.EducationEnum;
|
|
|
|
+import com.qmth.sop.common.enums.ExceptionResultEnum;
|
|
|
|
+import com.qmth.sop.common.enums.GenderEnum;
|
|
|
|
+import com.qmth.sop.common.enums.RoleTypeEnum;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import java.time.Duration;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -16,5 +37,134 @@ import org.springframework.stereotype.Service;
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper, TBUserArchives> implements TBUserArchivesService {
|
|
public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper, TBUserArchives> implements TBUserArchivesService {
|
|
|
|
+ @Resource
|
|
|
|
+ private SysUserRoleService sysUserRoleService;
|
|
|
|
+ @Resource
|
|
|
|
+ private SysSupplierService sysSupplierService;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public IPage<UserArchivesResult> findUserArchivesPage(String city, Long supplierId, String archivesName, RoleTypeEnum roleType, Boolean authenticationStatus, Long authenticationTimeStart, Long authenticationTimeEnd, Integer remainValidDay, Integer pageNumber, Integer pageSize) {
|
|
|
|
+ if (city != null && city.length() > 0) {
|
|
|
|
+ city = SystemConstant.translateSpecificSign(city);
|
|
|
|
+ }
|
|
|
|
+ if (archivesName != null && archivesName.length() > 0) {
|
|
|
|
+ archivesName = SystemConstant.translateSpecificSign(archivesName);
|
|
|
|
+ }
|
|
|
|
+ // 认证的角色枚举
|
|
|
|
+ List<RoleTypeEnum> authRole = new ArrayList<>();
|
|
|
|
+ authRole.add(RoleTypeEnum.EFFECT_ENGINEER);
|
|
|
|
+ authRole.add(RoleTypeEnum.REGION_COORDINATOR);
|
|
|
|
+ authRole.add(RoleTypeEnum.ASSISTANT_ENGINEER);
|
|
|
|
+
|
|
|
|
+ Long remainValidTime = SystemConstant.processMiniute(Duration.ofDays(remainValidDay));
|
|
|
|
+ IPage<UserArchivesResult> page = this.baseMapper.findUserArchivesPage(new Page<>(pageNumber, pageSize), city, supplierId, archivesName, roleType, authenticationStatus, authenticationTimeStart, authenticationTimeEnd, remainValidTime, System.currentTimeMillis());
|
|
|
|
+ for (UserArchivesResult record : page.getRecords()) {
|
|
|
|
+ List<RoleTypeEnum> roleTypeEnumList = new ArrayList<>();
|
|
|
|
+ Long userId = record.getUserId();
|
|
|
|
+ if (userId != null && userId > 0) {
|
|
|
|
+ for (RoleTypeEnum roleTypeEnum : authRole) {
|
|
|
|
+ // TODO: 2023/8/14 可优化查询
|
|
|
|
+ if (sysUserRoleService.userContainsRoles(userId, roleTypeEnum)) {
|
|
|
|
+ roleTypeEnumList.add(roleTypeEnum);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ record.setRoleTypeList(roleTypeEnumList);
|
|
|
|
+ }
|
|
|
|
+ return page;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ public Long editUserArchives(UserArchivesParam userArchivesParam, SysUser requestUser) {
|
|
|
|
+ Long id = userArchivesParam.getId();
|
|
|
|
+ String code = userArchivesParam.getCode();
|
|
|
|
+ // 校验档案编号唯一
|
|
|
|
+ List<TBUserArchives> codeCheckList = this.list(new QueryWrapper<TBUserArchives>().lambda().eq(TBUserArchives::getCode, code));
|
|
|
|
+ if (codeCheckList.size() > 1) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("系统中存在多个相同的档案编号异常[" + code + "]");
|
|
|
|
+ } else if (codeCheckList.size() == 1) {
|
|
|
|
+ TBUserArchives codeCheck = codeCheckList.get(0);
|
|
|
|
+ if (!Objects.equals(codeCheck.getId(), id)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("系统中已经存在档案编号[" + code + "]");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 校验身份证号唯一
|
|
|
|
+ String identify = userArchivesParam.getIdentity();
|
|
|
|
+ List<TBUserArchives> identifyCheckList = this.list(new QueryWrapper<TBUserArchives>().lambda().eq(TBUserArchives::getIdentity, identify));
|
|
|
|
+ if (identifyCheckList.size() > 1) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("系统中存在多个相同的身份证号异常[" + identify + "]");
|
|
|
|
+ } else if (identifyCheckList.size() == 1) {
|
|
|
|
+ TBUserArchives identifyCheck = identifyCheckList.get(0);
|
|
|
|
+ if (!Objects.equals(identifyCheck.getId(), id)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("系统中已经存在身份证号[" + identify + "]");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 校验手机号唯一
|
|
|
|
+ String mobileNumber = userArchivesParam.getMobileNumber();
|
|
|
|
+ List<TBUserArchives> mobileNumberCheckList = this.list(new QueryWrapper<TBUserArchives>().lambda().eq(TBUserArchives::getMobileNumber, mobileNumber));
|
|
|
|
+ if (mobileNumberCheckList.size() > 1) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("系统中存在多个相同的手机号异常[" + mobileNumber + "]");
|
|
|
|
+ } else if (mobileNumberCheckList.size() == 1) {
|
|
|
|
+ TBUserArchives mobileNumberCheck = mobileNumberCheckList.get(0);
|
|
|
|
+ if (!Objects.equals(mobileNumberCheck.getId(), id)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("系统中已经存在手机号[" + mobileNumber + "]");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String name = userArchivesParam.getName();
|
|
|
|
+ String country = userArchivesParam.getCountry();
|
|
|
|
+ String province = userArchivesParam.getProvince();
|
|
|
|
+ String city = userArchivesParam.getCity();
|
|
|
|
+ String area = userArchivesParam.getArea();
|
|
|
|
+ String address = userArchivesParam.getAddress();
|
|
|
|
+ GenderEnum gender = userArchivesParam.getGender();
|
|
|
|
+ EducationEnum education = userArchivesParam.getEducation();
|
|
|
|
+ String email = userArchivesParam.getEmail();
|
|
|
|
+ String basePhotoPath = userArchivesParam.getBasePhotoPath();
|
|
|
|
+ Long supplierId = userArchivesParam.getSupplierId();
|
|
|
|
+ if (supplierId != null && supplierId > 0) {
|
|
|
|
+ SysSupplier sysSupplier = sysSupplierService.getById(supplierId);
|
|
|
|
+ if (Objects.isNull(sysSupplier)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("供应商不存在");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Long archivesTime = userArchivesParam.getArchivesTime();
|
|
|
|
+ List<RoleTypeEnum> roleTypeList = userArchivesParam.getRoleTypeList();
|
|
|
|
+ Long authenticationTime = userArchivesParam.getAuthenticationTime();
|
|
|
|
+ Double authenticationScore = userArchivesParam.getAuthenticationScore();
|
|
|
|
+ Long authenticationValidTime = userArchivesParam.getAuthenticationValidTime();
|
|
|
|
+ String remark = userArchivesParam.getRemark();
|
|
|
|
+
|
|
|
|
+ TBUserArchives tbUserArchives = new TBUserArchives();
|
|
|
|
+ tbUserArchives.setCode(code);
|
|
|
|
+ tbUserArchives.setName(name);
|
|
|
|
+ tbUserArchives.setCountry(country);
|
|
|
|
+ tbUserArchives.setProvince(province);
|
|
|
|
+ tbUserArchives.setCity(city);
|
|
|
|
+ tbUserArchives.setArea(area);
|
|
|
|
+ tbUserArchives.setAddress(address);
|
|
|
|
+ tbUserArchives.setIdentity(identify);
|
|
|
|
+ tbUserArchives.setGender(gender);
|
|
|
|
+ tbUserArchives.setEducation(education);
|
|
|
|
+ tbUserArchives.setMobileNumber(mobileNumber);
|
|
|
|
+ tbUserArchives.setEmail(email);
|
|
|
|
+ tbUserArchives.setBasePhotoPath(basePhotoPath);
|
|
|
|
+ // 档案表编辑
|
|
|
|
+ if (id == null || id == 0) {
|
|
|
|
+ // 新增
|
|
|
|
+ tbUserArchives.setCreateId(requestUser.getId());
|
|
|
|
+ this.save(tbUserArchives);
|
|
|
|
+ id = tbUserArchives.getId();
|
|
|
|
+ } else {
|
|
|
|
+ // 编辑
|
|
|
|
+ tbUserArchives.setId(id);
|
|
|
|
+ tbUserArchives.setUpdateId(requestUser.getId());
|
|
|
|
+ this.updateById(tbUserArchives);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ // 档案详细表编辑
|
|
|
|
+ // TODO: 2023/8/14 档案详细 用户关联新增
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
}
|
|
}
|