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;
......@@ -123,7 +124,7 @@ public class YgglController {
@Value(value = "${config-8timer.init-password}")
private String pwd;
@Autowired
private YgglMainEmpMapper ygglMainEmpMapper;
......@@ -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,28 +361,36 @@ 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();
if (login == null) {
// 初始化密码 pwd
// 初始化密码 pwd
QyzxEmpLogin qyzxEmpLogin = QyzxEmpLogin.builder().phone(phone).pw(Md5.md5(pwd))
.sts(CommonEnum.U_STS_ON.getType()).orgId(userBean.getOrgCode()).username(name).build();
if (!qyzxEmpLogin.insert()) {
......@@ -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普通员工
// 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();
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.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 {
......@@ -526,7 +506,7 @@ public class YgglController {
return ResultUtil.data(ygglMainEmpPage, "员工搜索成功");
// return ResultUtil.data(ygglMainEmpPage, ygglMainEmps, "员工搜索成功");
}
/**
* 导入员工档案
*/
......@@ -535,32 +515,27 @@ public class YgglController {
@ApiOperationSupport(order = 7)
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 -> {
// list.add(zzglBmgwM.getId());
// 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());
return null;
}
/**
* 导入威力加强版
*
......@@ -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);
......@@ -1645,13 +1621,13 @@ public class YgglController {
Integer empNum = lzygQueryDto.getEmpNum();
// 删除员工档案表
ygglMainEmpMapper.delete(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getEmpNum, empNum));
YgglMainLzb.builder().empNum(empNum).jobStatus(YgEnumInterface.jobStatus.YILIZHI.getType()).sjlzTime(new Date())
.build().update(new UpdateWrapper<YgglMainLzb>().lambda().eq(YgglMainLzb::getEmpNum, empNum));
// 确认离职 删除员工关联表
QyzxEmpEntAsso.builder().empNum(lzygQueryDto.getEmpNum()).build()
.delete(new QueryWrapper<QyzxEmpEntAsso>().lambda().eq(QyzxEmpEntAsso::getEmpNum, empNum));
.delete(new QueryWrapper<QyzxEmpEntAsso>().lambda().eq(QyzxEmpEntAsso::getEmpNum, empNum));
// 初始化 部门主管
zzglBmgwMMapper.update(ZzglBmgwM.builder().leader(null).build(),
......
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