Commit 2ae17a30 by 邓实川

员工管理添加员工优化,组织管理部门树结构优化

parent 36400bd1
......@@ -51,6 +51,7 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNodeConfig;
import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.util.IdcardUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
......@@ -168,12 +169,14 @@ public class YgglController {
if (ygglMainEmp != null) {
Integer gw = ygglMainEmp.getBmgwId();
ZzglBmgwM gwObj = new LambdaQueryChainWrapper<ZzglBmgwM>(zzglBmgwMMapper).select(ZzglBmgwM::getUpId,ZzglBmgwM::getName)
.eq(ZzglBmgwM::getId, gw).eq(ZzglBmgwM::getOrgCode, orgCode).one();
ZzglBmgwM gwObj = new LambdaQueryChainWrapper<ZzglBmgwM>(zzglBmgwMMapper)
.select(ZzglBmgwM::getUpId, ZzglBmgwM::getName).eq(ZzglBmgwM::getId, gw)
.eq(ZzglBmgwM::getOrgCode, orgCode).one();
if (gwObj != null) {
ZzglBmgwM bmObj = new LambdaQueryChainWrapper<ZzglBmgwM>(zzglBmgwMMapper).select(ZzglBmgwM::getId,ZzglBmgwM::getName)
.eq(ZzglBmgwM::getId, gwObj.getUpId()).eq(ZzglBmgwM::getOrgCode, orgCode).one();
ZzglBmgwM bmObj = new LambdaQueryChainWrapper<ZzglBmgwM>(zzglBmgwMMapper)
.select(ZzglBmgwM::getId, ZzglBmgwM::getName).eq(ZzglBmgwM::getId, gwObj.getUpId())
.eq(ZzglBmgwM::getOrgCode, orgCode).one();
loginInfo.setBmId(bmObj != null ? bmObj.getId() : null);
loginInfo.setBmName(bmObj != null ? bmObj.getName() : null);
}
......@@ -350,6 +353,7 @@ public class YgglController {
/**
* 添加员工档案
*
* @param userBean
* @param addygdaDto
* @return
......@@ -357,23 +361,31 @@ public class YgglController {
@PostMapping(value = "/addygda")
@ApiOperation(value = "添加员工档案", httpMethod = "POST", notes = "接口发布说明")
@ApiOperationSupport(order = 4)
public Result<Object> addygda(@CurrentUser UserBean userBean,@Validated @RequestBody AddygdaDto addygdaDto) throws Exception{
public Result<Object> addygda(@CurrentUser UserBean userBean, @Validated @RequestBody AddygdaDto addygdaDto)
throws Exception {
Integer orgCode = userBean.getOrgCode();
String name = addygdaDto.getName();
String phone = addygdaDto.getPhone();
Integer zjType = addygdaDto.getZjType();
String zjNum = addygdaDto.getZjNum();
Integer jobType = addygdaDto.getJobType();
Date rzTime = addygdaDto.getRzTime();
Date rzTime = null;
if (addygdaDto.getRzTime() == null)
rzTime = new Date();
else
rzTime = addygdaDto.getRzTime();
Integer syq = addygdaDto.getSyq();
Integer sex = addygdaDto.getSex();
Integer bmgwId = addygdaDto.getBmgwId();
if (StrUtil.hasBlank(phone) || StrUtil.hasBlank(name) || StrUtil.hasBlank(zjNum)) {
return ResultUtil.error("请输入员工姓名,手机号和身份证号");
}
if (!ObjectUtil.isAllNotEmpty(name,phone,zjType,zjNum,jobType,rzTime,syq,bmgwId,sex)) {
if (!ObjectUtil.isAllNotEmpty(name, phone, zjType, zjNum, jobType, rzTime, syq, bmgwId, sex)) {
return ResultUtil.error("请完善员工信息!");
}
if (!IdcardUtil.isValidCard(zjNum)) {
return ResultUtil.error("请输入有效的证件信息!");
}
QyzxEmpLogin login = new LambdaQueryChainWrapper<QyzxEmpLogin>(qyzxEmpLoginMapper)
.eq(!StrUtil.hasBlank(phone), QyzxEmpLogin::getPhone, phone).one();
......@@ -388,71 +400,39 @@ public class YgglController {
// 添加三张表
// 员工权限表(未定)
// 员工企业关联表和员工档案,员工成长表(未定)
QyzxEmpEntAsso.builder()
.empNum(qyzxEmpLogin.getId())
.orgCode(orgCode)
.userType(CommonEnum.U_TYPE_EMP.getType())
.status(1)
.build()
.insert();// usertype2普通员工 status1正常
YgglMainEmp ygglMainEmp = YgglMainEmp.builder()
.name(name)
.phone(phone)
.zjType(zjType)
.zjNum(zjNum)
.jobType(jobType)
.jobStatus(YgEnumInterface.jobStatus.SHIYONG.getType())
.rzTime(rzTime)
.syq(syq)
.sex(sex)
.empNum(qyzxEmpLogin.getId())
.orgCode(orgCode)
.build();
QyzxEmpEntAsso.builder().empNum(qyzxEmpLogin.getId()).orgCode(orgCode)
.userType(CommonEnum.U_TYPE_EMP.getType()).status(1).build().insert();// usertype2普通员工 status1正常
YgglMainEmp ygglMainEmp = YgglMainEmp.builder().name(name).phone(phone).zjType(zjType).zjNum(zjNum)
.jobType(jobType).jobStatus(YgEnumInterface.jobStatus.SHIYONG.getType()).rzTime(rzTime).syq(syq)
.sex(sex).empNum(qyzxEmpLogin.getId()).orgCode(orgCode).build();
ygglMainEmp.insert();
if (addygdaDto.getBmgwId() != null) {
new LambdaUpdateChainWrapper<YgglMainEmp>(ygglMainEmpMapper)
.set(YgglMainEmp::getBmgwId, addygdaDto.getBmgwId())
.eq(YgglMainEmp::getOrgCode, orgCode).eq(YgglMainEmp::getId, ygglMainEmp.getId()).update();
.set(YgglMainEmp::getBmgwId, addygdaDto.getBmgwId()).eq(YgglMainEmp::getOrgCode, orgCode)
.eq(YgglMainEmp::getId, ygglMainEmp.getId()).update();
}
return ResultUtil.data(ygglMainEmp, "新添加员工档案成功!");
} else {
YgglMainEmp ishad = ygglMainEmpMapper.selectOne(new QueryWrapper<YgglMainEmp>()
.lambda()
.eq(YgglMainEmp::getPhone, phone)
.eq(YgglMainEmp::getOrgCode, orgCode));
YgglMainEmp ishad = ygglMainEmpMapper.selectOne(new QueryWrapper<YgglMainEmp>().lambda()
.eq(YgglMainEmp::getPhone, phone).eq(YgglMainEmp::getOrgCode, orgCode));
if (ishad == null) {
// 添加三张表
// 员工权限表(未定)
QyzxEmpEntAsso.builder()
.empNum(login.getId())
.orgCode(orgCode)
.userType(CommonEnum.U_TYPE_EMP.getType())
.status(1)
.build()
.insert();// usertype2普通员工
QyzxEmpEntAsso.builder().empNum(login.getId()).orgCode(orgCode)
.userType(CommonEnum.U_TYPE_EMP.getType()).status(1).build().insert();// usertype2普通员工
// status1正常
YgglMainEmp ygglMainEmp = YgglMainEmp.builder()
.name(name)
.phone(phone)
.zjType(zjType)
.zjNum(zjNum)
.jobType(jobType)
.jobStatus(YgEnumInterface.jobStatus.SHIYONG.getType())
.rzTime(rzTime)
.syq(syq)
.sex(sex)
.empNum(login.getId())
.orgCode(orgCode)
.build();
YgglMainEmp ygglMainEmp = YgglMainEmp.builder().name(name).phone(phone).zjType(zjType).zjNum(zjNum)
.jobType(jobType).jobStatus(YgEnumInterface.jobStatus.SHIYONG.getType()).rzTime(rzTime).syq(syq)
.sex(sex).empNum(login.getId()).orgCode(orgCode).build();
ygglMainEmp.insert();
if (addygdaDto.getBmgwId() != null) {
new LambdaUpdateChainWrapper<YgglMainEmp>(ygglMainEmpMapper)
.set(YgglMainEmp::getBmgwId, addygdaDto.getBmgwId())
.eq(YgglMainEmp::getOrgCode, orgCode).eq(YgglMainEmp::getId, ygglMainEmp.getId()).update();
.set(YgglMainEmp::getBmgwId, addygdaDto.getBmgwId()).eq(YgglMainEmp::getOrgCode, orgCode)
.eq(YgglMainEmp::getId, ygglMainEmp.getId()).update();
}
return ResultUtil.data(ygglMainEmp, "添加员工档案成功!");
} else {
......@@ -536,14 +516,11 @@ public class YgglController {
public Result<List<YgDrjqbDto>> importEmpRecord(
@CurrentUser UserBean userBean/* ,@Validated @RequestBody List<AddygdaDto> listAddygdaDto */) {
List<QyzxEmpLogin> listEl = qyzxEmpLoginMapper.selectList(new QueryWrapper<QyzxEmpLogin>().lambda()
.select(QyzxEmpLogin::getPhone));
List<QyzxEmpLogin> listEl = qyzxEmpLoginMapper
.selectList(new QueryWrapper<QyzxEmpLogin>().lambda().select(QyzxEmpLogin::getPhone));
listEl = listEl != null ? listEl.stream()
.filter(o -> o != null && o.getPhone() != null)
.collect(Collectors.toList()) : null;
.filter(o -> o != null && o.getPhone() != null).collect(Collectors.toList()) : null;
System.out.println(JSONUtil.parseObj(listEl));
// listEl.stream().filter(predicate)
// listEl.stream().filter(item -> objId.equals(item.getUpId())).forEach(zzglBmgwM -> {
......@@ -551,10 +528,8 @@ public class YgglController {
// getDepts(list, zzglBmgwM.getId(), objs);
// });
//抽取 登录表 的phone的集合
List<String> listPhone = listEl.stream()
.map(QyzxEmpLogin::getPhone)
.collect(Collectors.toList());
// 抽取 登录表 的phone的集合
List<String> listPhone = listEl.stream().map(QyzxEmpLogin::getPhone).collect(Collectors.toList());
System.out.println(JSONUtil.parseObj(listPhone));
listEl.stream().filter(i -> i != null).collect(Collectors.<QyzxEmpLogin>toList());
......@@ -616,8 +591,8 @@ public class YgglController {
}
// 员工权限表(未定)
// 员工企业关联表和员工档案,员工成长表(未定)
QyzxEmpEntAsso.builder().empNum(qyzxEmpLogin.getId()).orgCode(userBean.getOrgCode()).userType(CommonEnum.U_TYPE_EMP.getType())
.status(1).build().insert();// userType2普通员工,status1正常
QyzxEmpEntAsso.builder().empNum(qyzxEmpLogin.getId()).orgCode(userBean.getOrgCode())
.userType(CommonEnum.U_TYPE_EMP.getType()).status(1).build().insert();// userType2普通员工,status1正常
YgglMainEmp emp = YgglMainEmp.builder().name(e.getName()).phone(e.getPhone()).zjType(0).zjNum(e.getZj())
.jobType(jobType).rzTime(rzdate).updateTime(new Date()).updateMan(userBean.getEmpNum()).syq(syq)
.sex(sex).jobNum(jobNum).bmgwId(gw).empNum(qyzxEmpLogin.getId()).orgCode(userBean.getOrgCode())
......@@ -635,8 +610,8 @@ public class YgglController {
.eq("phone", e.getPhone()).eq("org_code", userBean.getOrgCode()));
if (ishad == null) {
// 员工权限表(未定)
QyzxEmpEntAsso.builder().empNum(login.getId()).orgCode(userBean.getOrgCode()).userType(CommonEnum.U_TYPE_EMP.getType()).status(1)
.build().insert();// userType2普通员工,status1正常
QyzxEmpEntAsso.builder().empNum(login.getId()).orgCode(userBean.getOrgCode())
.userType(CommonEnum.U_TYPE_EMP.getType()).status(1).build().insert();// userType2普通员工,status1正常
YgglMainEmp emp = YgglMainEmp.builder().name(e.getName()).phone(e.getPhone()).zjType(0)
.zjNum(e.getZj()).jobType(jobType).rzTime(rzdate).updateTime(new Date())
.updateMan(userBean.getEmpNum()).syq(syq).sex(sex).jobNum(jobNum).empNum(login.getId())
......@@ -1625,7 +1600,8 @@ public class YgglController {
updateWrapper.eq("emp_num", empNum);
UpdateWrapper<YgglMainLzb> updateWrapper1 = new UpdateWrapper<YgglMainLzb>();
updateWrapper1.eq("emp_num", empNum);
YgglMainEmp.builder().empNum(lzygQueryDto.getEmpNum()).jobStatus(YgEnumInterface.jobStatus.LIZHIZHONG.getType()).build().update(updateWrapper);
YgglMainEmp.builder().empNum(lzygQueryDto.getEmpNum()).jobStatus(YgEnumInterface.jobStatus.LIZHIZHONG.getType())
.build().update(updateWrapper);
YgglMainLzb.builder().jobStatus(YgEnumInterface.jobStatus.LIZHIZHONG.getType()).lzTime(lzygQueryDto.getLzTime())
.lzyy(lzygQueryDto.getLzyy()).lzbz(lzygQueryDto.getLzbz()).build().update(updateWrapper1);
......
package cn.timer.api.controller.zzgl;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.transaction.Transactional;
......@@ -27,11 +22,7 @@ import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapp
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.bean.copier.ValueProvider;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNode;
......@@ -114,14 +105,14 @@ public class ZzglController {
// treeNodeConfig.setDeep(10);
//转换器
List<Tree<String>> treeNodes = TreeUtil.build(nodeList, "0", treeNodeConfig,
List<Tree<String>> treeNodes = TreeUtil.build(zzglBmgwMs, "0", treeNodeConfig,
(treeNode, tree) -> {
tree.setId(treeNode.getId());
tree.setParentId(treeNode.getParentId());
tree.setWeight(treeNode.getWeight());
tree.setId(Convert.toStr(treeNode.getId()));
tree.setParentId(Convert.toStr(treeNode.getUpId()));
// tree.setWeight(treeNode.getWeight());
tree.setName(treeNode.getName());
// 扩展属性 ...
// tree.putExtra("extraField", 666);
tree.putExtra("leader", treeNode.getLeader());
// tree.putExtra("other", new Object());
});
......
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