Commit f3fa4a40 by 东州 翁 Committed by chenzg

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

parent 63342889
......@@ -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;
}
}
}
......@@ -8,6 +8,7 @@ package cn.timer.api.controller.yggl;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
......@@ -15,6 +16,7 @@ import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.transaction.Transactional;
......@@ -34,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;
......@@ -63,11 +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.zzgl.ZzglBmgwMMapper;
import cn.timer.api.dto.yggl.AddygdaDto;
import cn.timer.api.dto.yggl.LzbQueryDto;
......@@ -78,9 +83,11 @@ import cn.timer.api.dto.yggl.YgDrjqbDto;
import cn.timer.api.dto.yggl.YgDrsDto;
import cn.timer.api.dto.yggl.YgProDto;
import cn.timer.api.dto.yggl.YgQueryDto;
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.YgCartogramDto;
import cn.timer.api.dto.yggl.YgzzDto;
import cn.timer.api.utils.Md5;
import cn.timer.api.utils.Result;
......@@ -231,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 {
......@@ -246,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("该手机号已被使用,请输入正确手机号");
......@@ -370,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())
......@@ -388,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())
......@@ -1657,7 +1670,75 @@ public class YgglController {
}
/**
* 获取成长记录表
* 员工信息统计图
* @return 成功信息(weng)
*/
@GetMapping("/Cartogram")
@ApiOperation(value = "获取员工管理统计图信息", httpMethod = "GET", notes = "接口发布说明")
@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(0);
}
if (bean.getBm() == null) {
bean.setBm("未分配");
}
if (bean.getGw() == null) {
bean.setGw("未分配");
}
if (bean.getProname() == null) {
bean.setProname("未分配");
}
if (bean.getEduname() == null) {
bean.setEduname("未分配");
}
if (bean.getJobStatus() == null) {
bean.setJobStatus(-1);
}
if (bean.getWorkage() == null) {
bean.setWorkage(-1);
}
return true;
}).collect(Collectors.toList());
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);
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, "获取员工管理统计图信息成功!");
}
/**
* 获取员工社保公积金
*
* @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