Commit 86fdf3e2 by 东州 翁 Committed by chenzg

添加获取登录人和上级主管的empNum和名称

parent bbdafffe
...@@ -194,4 +194,7 @@ public class YgglMainEmp extends Model<YgglMainEmp> { ...@@ -194,4 +194,7 @@ public class YgglMainEmp extends Model<YgglMainEmp> {
@Transient @Transient
@TableField(exist = false) @TableField(exist = false)
private String error;//错误信息提示 private String error;//错误信息提示
} }
\ No newline at end of file
...@@ -10,6 +10,7 @@ import javax.persistence.GeneratedValue; ...@@ -10,6 +10,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import com.alibaba.druid.sql.ast.expr.SQLCaseExpr.Item;
import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
...@@ -99,4 +100,22 @@ public class ZzglBmgwM extends Model<ZzglBmgwM> { ...@@ -99,4 +100,22 @@ public class ZzglBmgwM extends Model<ZzglBmgwM> {
}); });
} }
} }
// 遍历,获取该员工所有上级部门(weng)
public static void getUpDepts(ArrayList<Integer> list, Integer objId, List<ZzglBmgwM> objs) {//7290
if (objId != null) {
for (ZzglBmgwM bmgw : objs) {
Integer bmgwId = bmgw.getId();
Integer upId = bmgw.getUpId();
if (bmgwId.equals(objId)) {
list.add(bmgwId);
if (upId!=null) {
getUpDepts(list, upId, objs);
}
}
}
}
}
} }
\ No newline at end of file
...@@ -8,7 +8,8 @@ package cn.timer.api.controller.yggl; ...@@ -8,7 +8,8 @@ package cn.timer.api.controller.yggl;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
...@@ -162,14 +163,67 @@ public class YgglController { ...@@ -162,14 +163,67 @@ public class YgglController {
*/ */
@GetMapping(value = "/loginerChargers") @GetMapping(value = "/loginerChargers")
@ApiOperation(value = " 获取登录人和上级主管的empNum和名称", httpMethod = "GET", notes = "接口发布说明") @ApiOperation(value = " 获取登录人和上级主管的empNum和名称", httpMethod = "GET", notes = "接口发布说明")
@ApiOperationSupport(order = 68) @ApiOperationSupport(order = 69)
public Result<LoginerChargeDto> loginerChargers(@CurrentUser UserBean userBean) { public Result<List<LoginerChargeDto>> loginerChargers(@CurrentUser UserBean userBean) {
Integer orgCode = userBean.getOrgCode();
ArrayList<Integer> list = new ArrayList<Integer>();
Integer empNum = userBean.getEmpNum();
List<LoginerChargeDto> loginerCharges = new ArrayList<LoginerChargeDto>();
Integer gw = empNumConfirm(orgCode, empNum).getBmgwId();
List<ZzglBmgwM> zzglBmgwMs = new LambdaQueryChainWrapper<ZzglBmgwM>(zzglBmgwMMapper).eq(ZzglBmgwM::getOrgCode, orgCode).list();
//获取该员工的上级部门id 的数组list
ZzglBmgwM.getUpDepts(list, gw, zzglBmgwMs);
List<Integer> leaderList = new ArrayList<Integer>();
for (Integer zzglId : list) {
for (ZzglBmgwM zzglBmgwM : zzglBmgwMs) {
if (zzglId.equals(zzglBmgwM.getId()) && zzglBmgwM.getLeader()!=null) {
return ResultUtil.error("获取登录人和上级主管的empNum和名称失败"); leaderList.add(zzglBmgwM.getLeader());
}
}
}
List<YgglMainEmp> ygglMainEmps = empNumsConfirm(orgCode, leaderList);
List<LoginerChargeDto> loginerChargeDtos =new ArrayList<LoginerChargeDto>();
for (YgglMainEmp m : ygglMainEmps) {
loginerChargeDtos.add(new LoginerChargeDto(m.getEmpNum(),m.getName()));
}
Collections.reverse(loginerChargeDtos);
return ResultUtil.data(loginerChargeDtos, "获取上级部门的部门id");
}
//根据传来的empNum获取该人员信息,没有则传全部
public List<YgglMainEmp> empNumsConfirm(Integer orgCode,List<Integer> empNumList) {
List<YgglMainEmp> all = new LambdaQueryChainWrapper<YgglMainEmp>(ygglMainEmpMapper).eq(YgglMainEmp::getOrgCode, orgCode).list();
List<YgglMainEmp> ygglMainEmps = new ArrayList<YgglMainEmp>();
if (empNumList.size()!=0) {
for (Integer empNum : empNumList) {
all.stream().filter(item -> empNum.equals(item.getEmpNum())).forEach(action ->{
ygglMainEmps.add(action);
});
}
}else {
ygglMainEmps.addAll(all);
} }
return ygglMainEmps;
}
//根据传来的empNum获取该人员信息
public YgglMainEmp empNumConfirm(Integer orgCode,Integer empNum) {
YgglMainEmp one = new LambdaQueryChainWrapper<YgglMainEmp>(ygglMainEmpMapper).eq(YgglMainEmp::getOrgCode, orgCode).eq(YgglMainEmp::getEmpNum, empNum).one();
return one;
}
/**
* 获取企业到期时间和版本
*
* @param
* @return
*/
@GetMapping(value = "/endtimeVersion")
@ApiOperation(value = "获取企业到期时间和版本", httpMethod = "GET", notes = "接口发布说明")
@ApiOperationSupport(order = 70)
public Result<YgglMainEmp> endtimeVersion(@CurrentUser UserBean userBean) {
return ResultUtil.error();
}
/** /**
* 获取员工档案 * 获取员工档案
* *
......
...@@ -32,15 +32,11 @@ public class LoginerChargeDto implements Serializable{ ...@@ -32,15 +32,11 @@ public class LoginerChargeDto implements Serializable{
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value="员工empNum",example="9688") @ApiModelProperty(value="主管empNum",example="9688")
private Integer empNum; private Integer leaderEmpNum;
@ApiModelProperty(value="上级主管empNum",example="000")
private Integer upEmpNum;
@ApiModelProperty(value="主管名称",example="李大力") @ApiModelProperty(value="主管名称",example="李大力")
private String charge; private String charge;
@ApiModelProperty(value="上级主管",example="")
private LoginerChargeDto loginerChargeDto;
} }
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