Commit 2ae17a30 by 邓实川

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

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