|
|
|
@ -2,6 +2,7 @@ package com.hnac.hzims.basic.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import com.hnac.hzims.basic.entity.CertificatetEntity; |
|
|
|
|
import com.hnac.hzims.basic.entity.PersonManagemetEntity; |
|
|
|
@ -22,6 +23,9 @@ import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import javax.xml.ws.WebServiceException; |
|
|
|
|
import java.lang.reflect.Field; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
@ -37,7 +41,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
public class PresonManagementServiceImpl extends BaseServiceImpl<PersonManagemetMapper, PersonManagemetEntity> implements IImsPresonManagementService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ISysClient sysClient; |
|
|
|
|
private final ISysClient sysClient; |
|
|
|
|
private final IImsCertificatetService certificatetService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -59,44 +63,51 @@ public class PresonManagementServiceImpl extends BaseServiceImpl<PersonManagemet
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public Boolean submit(PersonManagemetVo personManagemetVo) { |
|
|
|
|
try { |
|
|
|
|
public R submit(PersonManagemetVo personManagemetVo) throws IllegalAccessException { |
|
|
|
|
if (ObjectUtil.isNotEmpty(personManagemetVo)) { |
|
|
|
|
PersonManagemetEntity personManagemetEntity = new PersonManagemetEntity(); |
|
|
|
|
BeanUtil.copy(personManagemetVo, personManagemetEntity); |
|
|
|
|
if (StringUtils.isBlank(personManagemetEntity.getUnitName())){ |
|
|
|
|
String deptId = AuthUtil.getDeptId(); |
|
|
|
|
R<String> deptName = sysClient.getDeptName(Long.valueOf(deptId)); |
|
|
|
|
if (deptName.isSuccess()&&StringUtils.isBlank(deptName.getData())){ |
|
|
|
|
personManagemetEntity.setUnitName(deptName.getData()); |
|
|
|
|
if (!allFieldsNull(personManagemetEntity)) { |
|
|
|
|
if (StringUtils.isBlank(personManagemetEntity.getUnitName())){ |
|
|
|
|
String deptId = AuthUtil.getDeptId(); |
|
|
|
|
R<String> deptName = sysClient.getDeptName(Long.valueOf(deptId)); |
|
|
|
|
if (deptName.isSuccess()&&StringUtils.isNotBlank(deptName.getData())){ |
|
|
|
|
personManagemetEntity.setUnitName(deptName.getData()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(personManagemetEntity)) { |
|
|
|
|
this.saveOrUpdate(personManagemetEntity); |
|
|
|
|
Integer count = baseMapper.selectCount(Wrappers.<PersonManagemetEntity>query().lambda() |
|
|
|
|
.eq(PersonManagemetEntity::getUserId, personManagemetEntity.getUserId()) |
|
|
|
|
.eq(PersonManagemetEntity::getIsDeleted, 0)); |
|
|
|
|
if (count>0){ |
|
|
|
|
return R.fail("该用户已存在,请重新编辑!"); |
|
|
|
|
} |
|
|
|
|
this.saveOrUpdate(personManagemetEntity); |
|
|
|
|
} |
|
|
|
|
if (CollectionUtil.isNotEmpty(personManagemetVo.getCertificatetEntityList())) { |
|
|
|
|
List<CertificatetEntity> certificatetList = personManagemetVo.getCertificatetEntityList().stream().map( |
|
|
|
|
s -> { |
|
|
|
|
s.setPersonId(personManagemetEntity.getId().toString()); |
|
|
|
|
if (System.currentTimeMillis() > s.getDeadTime().getTime()){ |
|
|
|
|
s.setStatus(2); |
|
|
|
|
}else { |
|
|
|
|
s.setStatus(1); |
|
|
|
|
if(StringUtils.isBlank(s.getPersonId())){ |
|
|
|
|
s.setPersonId(personManagemetEntity.getId().toString()); |
|
|
|
|
} |
|
|
|
|
return s; |
|
|
|
|
} |
|
|
|
|
).collect(Collectors.toList()); |
|
|
|
|
certificatetService.saveOrUpdateBatch(certificatetList); |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
return R.success("保存成功"); |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("入参 personManagemetVo" + personManagemetVo + ":" + e); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return R.fail("保存失败"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static boolean allFieldsNull(Object obj) throws IllegalAccessException { |
|
|
|
|
for (Field field : obj.getClass().getDeclaredFields()) { |
|
|
|
|
field.setAccessible(true); |
|
|
|
|
if (field.get(obj) != null) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public Boolean removeByPersonManagemetVo(PersonManagemetVo personManagemetVo) { |
|
|
|
|