Commit c1f6e5ee by 东州 翁

优化了添加员工接口,现在可以正常添加岗位,重写了 人事仪表盘

parent 05ae6411
......@@ -77,7 +77,7 @@ public interface YgEnumInterface {
*/
@Getter
enum jobStatus implements YgEnumInterface{
ZHENSHI(0,"正式"),SHIYONG(1,"试用");
ZHENSHI(1,"正式"),SHIYONG(2,"试用"),LIZHIZHONG(3,"离职中"),YILIZHI(4,"已离职");
private Integer type;
......@@ -91,6 +91,8 @@ public interface YgEnumInterface {
jobStatus zos = (index == null || index.length() == 0) ? YgEnumInterface.jobStatus.ZHENSHI: (index.indexOf(jobStatus.ZHENSHI.name)!= -1)||(index.indexOf(jobStatus.ZHENSHI.type)!= -1) ? jobStatus.ZHENSHI:jobStatus.SHIYONG;
return zos.type.toString();
}
}
/**
......@@ -179,40 +181,71 @@ public interface YgEnumInterface {
@Getter
enum workage implements YgEnumInterface{
//NEW(0,183),HALF(1,365),ONE(2,548),ONEHALF(3,730),TWO(4,913),LONG(5,10000);
NEW(0,183,0),HALF(184,365,0),ONE(366,548,0),ONEHALF(549,730,0),TWO(731,1000,0),LONG(1001,10000,0);
NEW(0,30,0),ROOKIE(31,183,0),HALF(184,365,0),ONE(366,548,0),ONEHALF(549,730,0),TWO(731,1000,0),LONG(1001,10000,0);
private Integer begin;
private Integer end;
private Integer number;
workage(Integer begin, Integer end,Integer number) {
this.begin = begin;
this.end = end;
this.number = number;
}
public static Map<String, Integer> choose(List<YgbintuDto> bintu) {
for (YgbintuDto b : bintu) {
Integer index = b.getWorkage();
for (workage item : workage.values()) {
if (index>= item.begin && index<=item.end) {
item.number++;
System.out.println("item"+ item+":"+item.number);
}
if (index>= item.begin && index<=item.end) item.number++;
}
}
Map<String, Integer> result = new HashMap<String, Integer>();
result.put("x<0.5", NEW.number);
result.put("本月新入职", NEW.number);
result.put("x<0.5", NEW.number+ROOKIE.number);
result.put("0.5<x<1", HALF.number);
result.put("1<x<1.5", ONE.number);
result.put("1.5<x<2", ONEHALF.number);
result.put("2<x<3", TWO.number);
result.put("x++", LONG.number);
NEW.number=0;ROOKIE.number=0;HALF.number=0;ONE.number=0;ONEHALF.number=0;TWO.number=0;LONG.number=0;
return result;
}
}
/**
* 年龄
*/
@Getter
enum age implements YgEnumInterface{
//NEW(0,183),HALF(1,365),ONE(2,548),ONEHALF(3,730),TWO(4,913),LONG(5,10000);
CHILD(1,17,0),TEEN(18,25,0),YOUNG(26,32,0),MAN(33,38,0),MIDDLE(39,45,0),OLD(46,1000,0);
private Integer begin;
private Integer end;
private Integer number;
age(Integer begin, Integer end,Integer number) {
this.begin = begin;
this.end = end;
this.number = number;
}
public static Map<String, Integer> choose(List<YgbintuDto> bintu) {
Integer average = 0;
Integer i = 0;
Integer j = 0;
for (YgbintuDto b : bintu) {
Integer index = b.getAge();
for (; i < age.values().length; i++) {
if (index>= age.values()[i].begin && index<=age.values()[i].end) age.values()[i].number++;j++;
}
average = average + index;
}
Map<String, Integer> result = new HashMap<String, Integer>();
result.put("18以下", CHILD.number);
result.put("18-25", TEEN.number);
result.put("25-32", YOUNG.number);
result.put("32-38", MAN.number);
result.put("38-45", MIDDLE.number);
result.put("45以上", OLD.number);
Integer pInjun = j>0 ?(average/j) :0;
result.put("平均年龄", pInjun);
CHILD.number =0;TEEN.number=0;YOUNG.number=0;MAN.number=0;MIDDLE.number=0;OLD.number=0;
return result;
}
}
}
......@@ -36,6 +36,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.additional.query.impl.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.additional.update.impl.LambdaUpdateChainWrapper;
import com.github.pagehelper.util.StringUtil;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import cn.hutool.core.bean.BeanUtil;
......@@ -65,12 +66,13 @@ import cn.timer.api.config.enuminterface.YgEnumInterface;
import cn.timer.api.config.enums.CommonEnum;
import cn.timer.api.dao.qyzx.QyzxEmpLoginMapper;
import cn.timer.api.dao.yggl.YgAreaDtoMapper;
import cn.timer.api.dao.yggl.YgCartogramDtoMapper;
import cn.timer.api.dao.yggl.YgCityDtoMapper;
import cn.timer.api.dao.yggl.YgMzDtoMapper;
import cn.timer.api.dao.yggl.YgProDtoMapper;
import cn.timer.api.dao.yggl.YgglMainEmpMapper;
import cn.timer.api.dao.yggl.YgglMainLzbMapper;
import cn.timer.api.dao.yggl.YgtitleDtoMapper;
import cn.timer.api.dao.zzgl.ZzglBmgwMMapper;
import cn.timer.api.dto.yggl.AddygdaDto;
import cn.timer.api.dto.yggl.LzbQueryDto;
......@@ -85,7 +87,7 @@ import cn.timer.api.dto.yggl.YgbintuDto;
import cn.timer.api.dto.yggl.YgglCartogramDto;
import cn.timer.api.dto.yggl.YgjgDto;
import cn.timer.api.dto.yggl.YgmzDto;
import cn.timer.api.dto.yggl.YgtitleDto;
import cn.timer.api.dto.yggl.YgCartogramDto;
import cn.timer.api.dto.yggl.YgzzDto;
import cn.timer.api.utils.Md5;
import cn.timer.api.utils.Result;
......@@ -128,10 +130,6 @@ public class YgglController {
@Autowired
private YgMzDtoMapper ygMzDtoMapper;
//weng(人事仪表盘)
@Autowired
private YgtitleDtoMapper ygtitleDtoMapper;
/**
* 获取员工档案
*
......@@ -240,12 +238,15 @@ public class YgglController {
// 添加三张表
// 员工权限表(未定)
// 员工企业关联表和员工档案,员工成长表(未定)
QyzxEmpEntAsso.builder().empNum(qyzxEmpLogin.getId()).orgCode(orgCode).userType(2).build().insert();// 2普通员工
QyzxEmpEntAsso.builder().empNum(qyzxEmpLogin.getId()).orgCode(orgCode).userType(2).status(1).build().insert();// usertype2普通员工 status1正常
YgglMainEmp ygglMainEmp = YgglMainEmp.builder().name(name).phone(phone).zjType(zjType).zjNum(zjNum)
.jobType(jobType).rzTime(rzTime).syq(syq).sex(sex).empNum(qyzxEmpLogin.getId()).orgCode(orgCode)
.build();
ygglMainEmp.insert();
new LambdaUpdateChainWrapper<YgglMainEmp>(ygglMainEmpMapper)
.set(addygdaDto.getBmgwId()!=null, YgglMainEmp::getBmgwId, addygdaDto.getBmgwId())
.eq(YgglMainEmp::getOrgCode, orgCode).eq(YgglMainEmp::getId, ygglMainEmp.getId()).update();
return ResultUtil.data(ygglMainEmp, "新添加员工档案成功!");
} else {
......@@ -255,11 +256,14 @@ public class YgglController {
if (ishad == null) {
// 添加三张表
// 员工权限表(未定)
QyzxEmpEntAsso.builder().empNum(login.getId()).orgCode(orgCode).userType(2).build().insert();// 2普通员工
QyzxEmpEntAsso.builder().empNum(login.getId()).orgCode(orgCode).userType(2).status(1).build().insert();// usertype2普通员工 status1正常
YgglMainEmp ygglMainEmp = YgglMainEmp.builder().name(name).phone(phone).zjType(zjType).zjNum(zjNum)
.jobType(jobType).rzTime(rzTime).syq(syq).sex(sex).empNum(login.getId()).orgCode(orgCode)
.build();
ygglMainEmp.insert();
new LambdaUpdateChainWrapper<YgglMainEmp>(ygglMainEmpMapper)
.set(addygdaDto.getBmgwId()!=null, YgglMainEmp::getBmgwId, addygdaDto.getBmgwId())
.eq(YgglMainEmp::getOrgCode, orgCode).eq(YgglMainEmp::getId, ygglMainEmp.getId()).update();
return ResultUtil.data(ygglMainEmp, "添加员工档案成功!");
} else {
return ResultUtil.error("该手机号已被使用,请输入正确手机号");
......@@ -379,7 +383,7 @@ public class YgglController {
// 员工权限表(未定)
// 员工企业关联表和员工档案,员工成长表(未定)
QyzxEmpEntAsso.builder().empNum(qyzxEmpLogin.getId()).orgCode(userBean.getOrgCode()).userType(2)
.status(1).build().insert();// userType2普通员工
.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())
......@@ -397,8 +401,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(2).build()
.insert();// 2普通员工
QyzxEmpEntAsso.builder().empNum(login.getId()).orgCode(userBean.getOrgCode()).userType(2).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())
......@@ -1666,18 +1670,18 @@ public class YgglController {
}
/**
<<<<<<< HEAD
* 员工信息统计图
* @return 成功信息(weng)
*/
@GetMapping("/Cartogram")
@ApiOperation(value = "获取员工管理统计图信息", httpMethod = "GET", notes = "接口发布说明")
@ApiOperationSupport(order = 63)
public Result<Map<String, Object>> ygCartogram(@CurrentUser UserBean userBean) {
List<YgbintuDto> bintu = ygglMainEmpMapper.rsybp();
@ApiOperationSupport(order = 99)
public Result<YgCartogramDto> ygCartogram(@CurrentUser UserBean userBean) {
Integer orgCode = userBean.getOrgCode();
List<YgbintuDto> bintu = ygglMainEmpMapper.rsybp(orgCode);
bintu.stream().filter(bean ->{
if (bean.getAge() == null) {
bean.setAge(-1);
bean.setAge(0);
}
if (bean.getBm() == null) {
bean.setBm("未分配");
......@@ -1694,30 +1698,48 @@ public class YgglController {
if (bean.getJobStatus() == null) {
bean.setJobStatus(-1);
}
if (bean.getWorkage() == null) {
bean.setWorkage(-1);
}
return true;
}).collect(Collectors.toList());
YgtitleDto title = new LambdaQueryChainWrapper<YgtitleDto>(ygtitleDtoMapper).eq(YgtitleDto::getOrgCode, userBean.getOrgCode()).one();
//Map<String, List<YgbintuDto>> map = bintu.stream().collect(Collectors.groupingBy(YgbintuDto::getGw));岗位
//Map<String, List<YgbintuDto>> map = bintu.stream().collect(Collectors.groupingBy(YgbintuDto::getBm));部门
Map<String, Map<String, Long>> bmgw = bintu.stream().collect(Collectors.groupingBy(YgbintuDto::getBm,Collectors.groupingBy(YgbintuDto::getGw,Collectors.counting())));
Map<String, List<YgbintuDto>> edu = bintu.stream().collect(Collectors.groupingBy(YgbintuDto::getEduname));
Map<Integer, List<YgbintuDto>> jobStatus = bintu.stream().collect(Collectors.groupingBy(YgbintuDto::getJobStatus));
Map<String, List<YgbintuDto>> proname = bintu.stream().collect(Collectors.groupingBy(YgbintuDto::getProname));
Map<String, Long> gw = bintu.stream().collect(Collectors.groupingBy(YgbintuDto::getGw,Collectors.counting()));
Map<String, Long> bm = bintu.stream().collect(Collectors.groupingBy(YgbintuDto::getBm,Collectors.counting()));
//Map<String, Map<String, Long>> bmgw = bintu.stream().collect(Collectors.groupingBy(YgbintuDto::getBm,Collectors.groupingBy(YgbintuDto::getGw,Collectors.counting())));
Map<String, Long> edu = bintu.stream().collect(Collectors.groupingBy(YgbintuDto::getEduname,Collectors.counting()));
Map<Integer,Long> jobStatus = bintu.stream().collect(Collectors.groupingBy(YgbintuDto::getJobStatus,Collectors.counting()));
Map<String, Long> proname = bintu.stream().collect(Collectors.groupingBy(YgbintuDto::getProname,Collectors.counting()));
Map<String, Integer> workage = YgEnumInterface.workage.choose(bintu);
System.out.println(bmgw);
System.out.println(edu);
System.out.println(jobStatus);
System.out.println(proname);
System.out.println(workage);
return ResultUtil.success();
Map<String, Integer> age = YgEnumInterface.age.choose(bintu);
//在职
Integer zaizhi = jobStatus.get(1).intValue()+jobStatus.get(2).intValue();
//本月新入职
Integer xinruzhi = workage.get("本月新入职").intValue();
//本月离职
Integer lizhi = ygglMainEmpMapper.benyueLz(orgCode);
//本月转正
Integer zhuanzhen = ygglMainEmpMapper.benyueZz(orgCode);
//平均年龄
Integer nianlin = age.get("平均年龄").intValue();
YgCartogramDto ybp = new YgCartogramDto();
ybp.setZaizhi(zaizhi);
ybp.setXinruzhi(xinruzhi);
ybp.setLizhi(lizhi);
ybp.setZhuanzhen(zhuanzhen);
ybp.setNianlin(nianlin);
ybp.setBm(bm);
ybp.setGw(gw);
ybp.setEdu(edu);
ybp.setJobStatus(jobStatus);
ybp.setProname(proname);
ybp.setWorkage(workage);
ybp.setAge(age);
return ResultUtil.data(ybp, "获取员工管理统计图信息成功!");
}
/**
* 获取员工社保公积金
=======
* 获取成长记录表
*
>>>>>>> bea51ce9ef8860bb31a1d14ffce121313636951a
* @param
* @return
*/
......
......@@ -3,7 +3,7 @@ import org.springframework.stereotype.Repository;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.timer.api.dto.yggl.YgtitleDto;
import cn.timer.api.dto.yggl.YgCartogramDto;
......@@ -12,6 +12,6 @@ import cn.timer.api.dto.yggl.YgtitleDto;
* @author Tang 2019-11-15
*/
@Repository
public interface YgtitleDtoMapper extends BaseMapper<YgtitleDto> {
public interface YgCartogramDtoMapper extends BaseMapper<YgCartogramDto> {
}
......@@ -3,6 +3,7 @@ package cn.timer.api.dao.yggl;
import java.util.List;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.PathVariable;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
......@@ -25,9 +26,22 @@ public interface YgglMainEmpMapper extends BaseMapper<YgglMainEmp> {
* @param userBean
* @return
*/
List<YgbintuDto> rsybp();
List<YgbintuDto> rsybp(Integer orgCode);
/**
* 查询当月离职人数
* @param userBean
* @return
*/
Integer benyueLz(Integer orgCode);
/**
* 查询当月转正人数
* @param userBean
* @return
*/
Integer benyueZz(Integer orgCode);
/**
* 查询员工信息
* @param userBean
* @return
......
......@@ -52,7 +52,8 @@ public class AddygdaDto extends Page implements Serializable{
@ApiModelProperty(value="性别 0:男;1:女",example="0")
private Integer sex;
@ApiModelProperty(value="部门岗位id",example="0")
private Integer bmgwId;
}
/**
* @date 2020年4月1日
* @author 翁东州
* @方法中文名称:
*/
package cn.timer.api.dto.yggl;
import java.io.Serializable;
import java.util.Map;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @date 2020年4月1日
* @author 翁东州
* @方法中文名称:
*/
public class YgCartogramDto {
@ApiModelProperty(value="统计图--标头 ",example="标头")
private YgtitleDto ygtitleDto;
@ApiModelProperty(value="统计图--饼图和直方图 ",example="饼图和直方图")
private YgbintuDto ygbintuDto;
* @author Tang 2019-11-15
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("统计图--仪表盘内容")
public class YgCartogramDto implements Serializable{
private static final long serialVersionUID = 1L;
@ApiModelProperty(value="在职人数")
private Integer zaizhi;
@ApiModelProperty(value="本月新入职 ")
private Integer xinruzhi;
@ApiModelProperty(value="本月离职")
private Integer lizhi;
@ApiModelProperty(value="本月转正")
private Integer zhuanzhen;
@ApiModelProperty(value="平均年龄")
private Integer nianlin;
@ApiModelProperty(value="部门")
private Map<String, Long> bm;
@ApiModelProperty(value="岗位")
private Map<String, Long> gw;
@ApiModelProperty(value="学历")
private Map<String, Long> edu;
@ApiModelProperty(value="工作状态")
private Map<Integer,Long> jobStatus;
@ApiModelProperty(value="省份")
private Map<String, Long> proname;
@ApiModelProperty(value="工作日")
private Map<String, Integer> workage;
@ApiModelProperty(value="年龄")
private Map<String, Integer> age;
//方法中文名称:
public void setBmgw(Map<String, Map<String, Long>> bmgw2) {
// TODO Auto-generated method stub
}
}
package cn.timer.api.dto.yggl;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author Tang 2019-11-15
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName("yggl_atta_title")
@ApiModel("统计图--标头")
public class YgtitleDto{
@Id
@GeneratedValue
@TableId (type = IdType.AUTO)
@ApiModelProperty(value="id编号",example="1")
private Integer id;
@ApiModelProperty(value="在职人数",example="1")
private Integer zaizhi;
@ApiModelProperty(value="本月新入职 ",example="1")
private Integer xinruzhi;
@ApiModelProperty(value="本月离职",example="1")
private Integer lizhi;
@ApiModelProperty(value="本月转正",example="1")
private Integer zhuanzhen;
@ApiModelProperty(value="平均年龄",example="22")
private Integer nianlin;
@ApiModelProperty(value="组织机构代码",example="117")
private Integer orgCode;
}
......@@ -175,8 +175,19 @@
LEFT JOIN zzgl_bmgw_m bb ON bb.id = b.up_id
LEFT JOIN province_class p ON left (e.`jg`,2) = p.province
LEFT JOIN education_class d ON d.number = e.edu
WHERE e.org_code = 117 AND b.org_code =117;
WHERE e.org_code = #{orgCode}
</select>
<!-- benyueLz本月离职人数 -->
<select id="benyueLz" resultType="Integer">
SELECT COUNT(datediff(CURDATE(),l.sjlz_time)) FROM yggl_main_lzb l WHERE datediff(CURDATE(),l.sjlz_time) <![CDATA[ <= ]]> 30 AND org_code = #{orgCode};
</select>
<!-- benyueZz本月转正人数 -->
<select id="benyueZz" resultType="Integer">
SELECT COUNT(datediff(CURDATE(),e.sjzz_time)) FROM yggl_main_emp e WHERE datediff(CURDATE(),e.sjzz_time) <![CDATA[ <= ]]> 30 AND org_code = #{orgCode};
</select>
<!-- 查询员工信息 搜索 分页 -->
<select id="queryEmpMessage" resultType="cn.timer.api.dto.yggl.YgQueryDto">
SELECT
......
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