Commit 10f90f65 authored by huyuchen's avatar huyuchen

Merge remote-tracking branch 'origin/develop' into develop

parents a3a5b6e4 d5472711
......@@ -23,7 +23,9 @@ import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.Max;
import java.time.LocalDateTime;
/**
......@@ -55,18 +57,21 @@ public class TEmployeeInfo extends BaseEntity {
* 员工类型(字典值,0外包1派遣2代理)
*/
@Schema(description = "员工类型(字典值,0外包1派遣2代理)")
@Max(value = 1,message = "员工类型不可超过1位")
private String empNatrue;
/**
* 员工姓名
*/
@Schema(description = "员工姓名")
@Max(value = 20,message = "员工姓名不可超过20位")
private String empName;
/**
* 身份证号码
*/
@Schema(description = "身份证号码")
@Max(value = 20,message = "身份证号码不可超过20位")
private String empIdcard;
/**
......@@ -97,6 +102,7 @@ public class TEmployeeInfo extends BaseEntity {
* 年龄
*/
@Schema(description = "年龄")
@Max(value = 11,message = "年龄不可超过11位")
private Integer empAge;
/**
......@@ -115,18 +121,21 @@ public class TEmployeeInfo extends BaseEntity {
* 政治面貌
*/
@Schema(description = "政治面貌")
@Max(value = 32,message = "政治面貌不可超过32位")
private String politicalStatus;
/**
* 邮箱
*/
@Schema(description = "邮箱")
@Max(value = 32,message = "邮箱不可超过32位")
private String empEmail;
/**
* 手机号码
*/
@Schema(description = "手机号码")
@Max(value = 11,message = "手机号码不可超过11位")
private String empPhone;
/**
......
......@@ -45,6 +45,9 @@ import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* 人员档案表
......@@ -74,8 +77,6 @@ public class TEmployeeInfoController {
*/
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
//@PreAuthorize("@pms.hasPermission('demo_temployeeinfo_get')")
@SneakyThrows
public R<IPage<TEmployeeInfo>> getTEmployeeInfoPage(Page<TEmployeeInfo> page, TEmployeeInfo tEmployeeInfo) {
YifuUser user = SecurityUtils.getUser();
if (user == null || Common.isEmpty(user.getId())) {
......@@ -151,23 +152,42 @@ public class TEmployeeInfoController {
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('demo_temployeeinfo_get')")
public R<TEmployeeInfo> getById(@PathVariable("id") String id) {
return R.ok(tEmployeeInfoService.getById(id));
}
/**
* @param empName 姓名
* @param empIdCard 身份证
* @Description: 新增人员档案前的校验
* @Author: hgw
* @Date: 2022/6/21 11:53
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.Boolean>
**/
@Operation(summary = "新增人员档案前的校验", description = "新增人员档案前的校验")
@SysLog("新增人员档案前的校验")
@GetMapping("/checkIdCard")
@PreAuthorize("@pms.hasPermission('temployeeinfo_check')")
public R<TEmployeeInfo> checkIdCard(@RequestParam String empName, @RequestParam String empIdCard) {
TEmployeeInfo employeeInfo = new TEmployeeInfo();
employeeInfo.setEmpName(empName);
employeeInfo.setEmpIdcard(empIdCard);
employeeInfo.setDeleteFlag(CommonConstants.STATUS_NORMAL);
return tEmployeeInfoService.checkIdCard(employeeInfo);
}
/**
* 新增人员档案表
*
* @param tEmployeeInfo 人员档案表
* @return R
*/
@Operation(summary = "新增人员档案表", description = "新增人员档案表")
@SysLog("新增人员档案表")
@PostMapping
@PreAuthorize("@pms.hasPermission('demo_temployeeinfo_add')")
public R<Boolean> save(@RequestBody TEmployeeInfo tEmployeeInfo) {
return R.ok(tEmployeeInfoService.save(tEmployeeInfo));
@Operation(summary = "新增人员档案表(附带项目档案、学历)", description = "新增人员档案表")
@SysLog("新增人员档案表(附带项目档案、学历)")
@PostMapping("/addNewEmployee")
@PreAuthorize("@pms.hasPermission('temployeeinfo_add')")
public R<String> addNewEmployee(@Valid @RequestBody TEmployeeInfo tEmployeeInfo) {
return tEmployeeInfoService.addNewEmployee(tEmployeeInfo);
}
/**
......
......@@ -25,6 +25,7 @@ import com.pig4cloud.plugin.excel.vo.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeProject;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmployeeProjectService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeProjectVO;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.Operation;
......@@ -51,6 +52,23 @@ public class TEmployeeProjectController {
private final TEmployeeProjectService tEmployeeProjectService;
/**
* @param empId 人员档案id
* @Description: 根据人员档案id获取项目list
* @Author: hgw
* @Date: 2022/6/21 19:19
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeProject>>
**/
@Operation(summary = "根据人员档案id获取项目list", description = "根据人员档案id获取项目list")
@GetMapping("/getListByEmpId" )
public R<List<TEmployeeProject>> getListByEmpId(@RequestParam String empId) {
TEmployeeProject project = new TEmployeeProject();
project.setEmpId(empId);
project.setProjectStatus(CommonConstants.ZERO_INT);
project.setDeleteFlag(CommonConstants.STATUS_NORMAL);
return R.ok(tEmployeeProjectService.list(Wrappers.query(project)));
}
/**
* 分页查询
* @param page 分页对象
......
......@@ -25,6 +25,8 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 人员档案表
*
......@@ -36,5 +38,7 @@ public interface TEmployeeInfoMapper extends BaseMapper<TEmployeeInfo> {
IPage<TEmployeeInfo> getPage(Page<TEmployeeInfo> page, @Param("employeeInfo") TEmployeeInfo employeeInfo, @Param("sql") String sql);
List<TEmployeeInfo> getList(@Param("employeeInfo") TEmployeeInfo employeeInfo);
int updateEducationOfEmp(@Param("education") EmpEducationUpdateVo education);
}
......@@ -22,6 +22,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateVo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import java.util.List;
/**
* 人员档案表
......@@ -41,5 +44,43 @@ public interface TEmployeeInfoService extends IService<TEmployeeInfo> {
**/
IPage<TEmployeeInfo> getPage(Page<TEmployeeInfo> page, TEmployeeInfo employeeInfo, String sql);
/**
* @param employeeInfo
* @Description: 获取list
* @Author: hgw
* @Date: 2022/6/21 11:56
* @return: java.util.List<com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo>
**/
List<TEmployeeInfo> getList(TEmployeeInfo employeeInfo);
/**
* @Description: code:2 : 该人员在离职库已存在,是否'恢复档案'?
* 其余code就是成功失败,
* 200成功,可以下一步。
* @Author: hgw
* @Date: 2022/6/21 15:36
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo>
**/
R<TEmployeeInfo> checkIdCard(TEmployeeInfo employeeInfo);
/**
* @param employeeInfo
* @Description: 新增档案,附带新增项目档案、学历信息
* @Author: hgw
* @Date: 2022/6/21 18:31
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
R<String> addNewEmployee(TEmployeeInfo employeeInfo);
/**
* @param employeeInfo 档案信息
* @param fileSource 人员档案来源(4人员档案新建、5项目档案新建、1社保/公积金、3商险、2薪酬)
* @Description: 新增人员档案,其他服务新增时调用
* @Author: hgw
* @Date: 2022/6/21 19:03
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo>
**/
R<TEmployeeInfo> saveNewEmpLoyee(TEmployeeInfo employeeInfo, String fileSource);
void updateEducationOfEmp(EmpEducationUpdateVo education);
}
......@@ -23,8 +23,18 @@ import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmployeeInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 人员档案表
*
......@@ -32,13 +42,139 @@ import org.springframework.stereotype.Service;
* @date 2022-06-20 09:55:06
*/
@Service
@RequiredArgsConstructor
public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, TEmployeeInfo> implements TEmployeeInfoService {
// 缓存信息
private final CacheManager cacheManager;
@Override
public IPage<TEmployeeInfo> getPage(Page<TEmployeeInfo> page, TEmployeeInfo employeeInfo, String sql) {
return baseMapper.getPage(page, employeeInfo, sql);
}
@Override
public List<TEmployeeInfo> getList(TEmployeeInfo employeeInfo) {
return baseMapper.getList(employeeInfo);
}
@Override
public R<TEmployeeInfo> checkIdCard(TEmployeeInfo employeeInfo) {
List<TEmployeeInfo> list = baseMapper.getList(employeeInfo);
if (list != null && !list.isEmpty()) {
employeeInfo = list.get(0);
if (employeeInfo.getFileStatus() == CommonConstants.ZERO_INT) {
return R.failed("该人员已存在,禁止重复添加");
} else {
return new R<>(CommonConstants.dingleDigitIntArray[2], "该人员在离职库已存在,是否'恢复档案'?", employeeInfo);
}
} else {
// TODO - 调用校验服务
return R.ok();
}
}
/**
* @param nowNums 数字
* @Description: 获取五位字符型数字
* @Author: hgw
* @Date: 2022/6/21 17:35
* @return: 五位字符型数字
**/
private String getFiveNum(String nowNums) {
if (nowNums.length() >= 5) {
return nowNums.substring(0, 5);
}
String[] zeroArr = {"0", "00", "000", "0000"};
int num = 4 - nowNums.length();
return zeroArr[num] + nowNums;
}
@Override
//@GlobalTransactional // 分布式事务注解
//@Transactional(rollbackFor = Exception)
public R<String> addNewEmployee(TEmployeeInfo employeeInfo) {
// 新建人员档案
R<TEmployeeInfo> checks = this.saveNewEmpLoyee(employeeInfo, CommonConstants.dingleDigitStrArray[4]);
if (checks != null && checks.getCode() != CommonConstants.SUCCESS) return R.failed(checks.getMsg());
// TODO-新建项目-胡雨辰
// TODO-新建学历-房
return R.ok();
}
/**
* @param employeeInfo 姓名、身份证、手机号、员工类型
* @param fileSource 4人员档案新建、5项目档案新建、1社保/公积金、3商险、2薪酬
* @Description: 新增档案
* @Author: hgw
* @Date: 2022/6/21 18:07
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo>
**/
public R<TEmployeeInfo> saveNewEmpLoyee(TEmployeeInfo employeeInfo, String fileSource) {
if (Common.isEmpty(employeeInfo.getEmpName())) {
return R.failed("员工姓名必填!");
}
if (Common.isEmpty(employeeInfo.getEmpIdcard())) {
return R.failed("员工身份证必填!");
}
if (Common.isEmpty(employeeInfo.getEmpPhone())) {
return R.failed("手机号必填!");
}
if (Common.isEmpty(employeeInfo.getEmpNatrue())) {
return R.failed("员工类型必填!");
}
if (Common.isEmpty(fileSource)) {
return R.failed("人员档案来源必填!(4人员档案新建、5项目档案新建、1社保/公积金、3商险、2薪酬)");
}
TEmployeeInfo check = new TEmployeeInfo();
check.setEmpName(employeeInfo.getEmpName());
check.setEmpIdcard(employeeInfo.getEmpIdcard());
check.setDeleteFlag(CommonConstants.STATUS_NORMAL);
R<TEmployeeInfo> checks = this.checkIdCard(check);
if (checks.getCode() != CommonConstants.SUCCESS) {
return R.failed(checks.getMsg());
}
// 校验手机号:
if (Common.isEmpty(employeeInfo.getEmpPhone())) {
return R.failed("手机号必填!");
} else {
check = new TEmployeeInfo();
check.setDeleteFlag(CommonConstants.STATUS_NORMAL);
check.setEmpPhone(employeeInfo.getEmpPhone());
List<TEmployeeInfo> list = baseMapper.getList(employeeInfo);
if (list != null && !list.isEmpty()) {
return R.failed("该手机号已被使用!");
}
// TODO - 调用校验服务-校验手机号
}
// 字典:4人员档案新建、5项目档案新建、1社保/公积金、3商险、2薪酬
employeeInfo.setFileSource(fileSource);
employeeInfo.setStatus(CommonConstants.ONE_INT);
employeeInfo.setFileStatus(CommonConstants.ZERO_INT);
employeeInfo.setProjectNum(CommonConstants.ONE_INT);
employeeInfo.setDeleteFlag(CommonConstants.STATUS_NORMAL);
// 生成主码:
if (Common.isEmpty(employeeInfo.getEmpCode())) {
String nowDay = DateUtil.getThisDay();
Cache cache = cacheManager.getCache(CacheConstants.EVERYDAY_EMP_CODE);
Object nowNumObj = cache.get(nowDay);
int nowNums = 1;
if (!Common.isEmpty(nowNumObj)) {
nowNums = (Integer) nowNumObj + 1;
}
cache.put(nowDay, nowNums);
String numStr = this.getFiveNum(String.valueOf(nowNums));
employeeInfo.setEmpCode(numStr);
}
this.save(employeeInfo);
return R.ok(employeeInfo);
}
@Override
public void updateEducationOfEmp(EmpEducationUpdateVo education) {
baseMapper.updateEducationOfEmp(education);
......
......@@ -163,4 +163,14 @@
order by a.CREATE_TIME desc
</select>
<!-- hgw list查询 -->
<select id="getList" resultMap="tEmployeeInfoMap">
select
<include refid="baseParam"/>
from t_employee_info a
where 1=1
<include refid="employeeInfo_where"/>
order by a.CREATE_TIME desc
</select>
</mapper>
......@@ -73,4 +73,11 @@ public interface CacheConstants {
*/
String DATA_AUTH_DETAILS = "data_auth_details";
/**
* @Description: 每日员工主码缓存
* @Author: hgw
* @Date: 2022/6/21 17:09
**/
String EVERYDAY_EMP_CODE = "everyday_emp_code";
}
......@@ -1351,6 +1351,17 @@ public class DateUtil {
return thisMonth;
}
/**
* @Description: 返回当前年月日字符串
* @Author: hgw
* @Date: 2022/6/21 17:19
* @return: java.lang.String
**/
public static String getThisDay(){
SimpleDateFormat sf = new SimpleDateFormat(DateUtil.ISO_DATE_FORMAT);
return sf.format(new Date());
}
/**
* @param
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment