提交 0b53a08f authored 作者: gongwenjie's avatar gongwenjie

考勤

上级 1ec38da6
...@@ -4,6 +4,7 @@ import com.zjty.tynotes.attendance.entity.ApprovalInformation; ...@@ -4,6 +4,7 @@ import com.zjty.tynotes.attendance.entity.ApprovalInformation;
import com.zjty.tynotes.attendance.entity.vo.request.AttenRequest; import com.zjty.tynotes.attendance.entity.vo.request.AttenRequest;
import com.zjty.tynotes.attendance.service.AttendanceDetailsService; import com.zjty.tynotes.attendance.service.AttendanceDetailsService;
import com.zjty.tynotes.misc.config.AutoDocument; import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.pas.entity.User;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -37,4 +38,11 @@ public class AttendanceController { ...@@ -37,4 +38,11 @@ public class AttendanceController {
return ok(attendanceDetailsService.findDepartment(request)); return ok(attendanceDetailsService.findDepartment(request));
} }
@ApiOperation(value = "根据权限查询可查看部门列表", response = User.class)
@GetMapping("/findDepartmentList/{id}")
public ResponseEntity findDepartmentList(@PathVariable("id") String id) {
return ok(attendanceDetailsService.findDepartmentList(id));
}
} }
package com.zjty.tynotes.attendance.controller;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiUserGetRequest;
import com.dingtalk.api.response.OapiDepartmentListResponse;
import com.dingtalk.api.response.OapiUserGetResponse;
import com.taobao.api.ApiException;
import com.zjty.tynotes.attendance.entity.CardResult;
import com.zjty.tynotes.attendance.task.CardTask;
import com.zjty.tynotes.attendance.task.MyInit;
import com.zjty.tynotes.misc.config.AutoDocument;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/**
* @Author gwj
* @create 2020/4/3 9:37
*/
@Api(tags = "考勤模块", protocols = "http")
@RestController
@RequestMapping("/ding/test")
@AutoDocument
public class DingTestController {
@Autowired
private MyInit myInit;
@Autowired
private CardTask cardTask;
@GetMapping("/token")
public Object token(){
List<String> responses = new ArrayList<>();
myInit.getToken();
myInit.getDepartmentList();
myInit.getUserList();
List<String> userIds = myInit.userIds;
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/user/get");
OapiUserGetRequest request = new OapiUserGetRequest();
request.setHttpMethod("GET");
userIds.forEach(str->{
request.setUserid(str);
try {
OapiUserGetResponse response = client.execute(request, myInit.token);
responses.add(response.getName());
} catch (ApiException e) {
e.printStackTrace();
}
});
System.out.println(responses.size());
return responses;
}
@GetMapping("/card")
public Object card(){
List<CardResult> cardDetails = cardTask.getCardDetails();
return cardDetails;
}
}
...@@ -25,7 +25,7 @@ import static org.springframework.http.ResponseEntity.ok; ...@@ -25,7 +25,7 @@ import static org.springframework.http.ResponseEntity.ok;
/** /**
* @author mcj * @author mcj
*/ */
@Api(tags = "钉钉", protocols = "http") @Api(tags = "考勤模块", protocols = "http")
@RestController @RestController
@RequestMapping("/attendance/user") @RequestMapping("/attendance/user")
@AutoDocument @AutoDocument
......
...@@ -3,6 +3,7 @@ package com.zjty.tynotes.attendance.dao; ...@@ -3,6 +3,7 @@ package com.zjty.tynotes.attendance.dao;
import com.zjty.tynotes.attendance.entity.ApprovalInformation; import com.zjty.tynotes.attendance.entity.ApprovalInformation;
import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.MongoRepository;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -16,4 +17,10 @@ public interface ApprovalInformationDao extends MongoRepository<ApprovalInformat ...@@ -16,4 +17,10 @@ public interface ApprovalInformationDao extends MongoRepository<ApprovalInformat
List<ApprovalInformation> findAllByApprovalUserIdOneOrApprovalUserIdTwo(String userId); List<ApprovalInformation> findAllByApprovalUserIdOneOrApprovalUserIdTwo(String userId);
List<ApprovalInformation> findAllByStatusIn(List<String> statusList); List<ApprovalInformation> findAllByStatusIn(List<String> statusList);
ApprovalInformation findAllByUserIdAndLeaveStartTimeBeforeAndLeaveEndTimeAfterAndApprovalTypeIn(String userId, Date startTime,Date endTime,List<String> type);
ApprovalInformation findAllByUserIdAndLeaveStartTimeBeforeAndLeaveEndTimeBetweenAndApprovalTypeIn(String userId, Date startTime,Date startTime1,Date endTime,List<String> type);
ApprovalInformation findAllByUserIdAndLeaveStartTimeBetweenAndLeaveEndTimeAfterAndApprovalTypeIn(String userId, Date startTime,Date endTime,Date endTime1,List<String> type);
} }
package com.zjty.tynotes.attendance.entity; package com.zjty.tynotes.attendance.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
...@@ -31,13 +32,16 @@ public class ApprovalInformation { ...@@ -31,13 +32,16 @@ public class ApprovalInformation {
@ApiModelProperty(value = "提交审批用户id",example = "1") @ApiModelProperty(value = "提交审批用户id",example = "1")
private String userId; private String userId;
@ApiModelProperty(value = "提交审批用户姓名",example = "1")
private String name;
@ApiModelProperty(value = "审核审批用户id",example = "1") @ApiModelProperty(value = "审核审批用户id",example = "1")
private String approvalUserIdOne; private String approvalUserIdOne;
@ApiModelProperty(value = "审核审批用户id",example = "1") @ApiModelProperty(value = "审核审批用户id",example = "1")
private String approvalUserIdTwo; private String approvalUserIdTwo;
@ApiModelProperty(value = "审批类型,事假/调休/病假/加班/公出",example = "事假/调休/病假/加班/公出") @ApiModelProperty(value = "审批类型,事假/调休/病假/加班/公出/出差",example = "事假/调休/病假/加班/公出/出差")
private String approvalType; private String approvalType;
@ApiModelProperty(value = "审批状态,0代表待审批,1代表已通过,2代表已拒绝",example = "0/1/2") @ApiModelProperty(value = "审批状态,0代表待审批,1代表已通过,2代表已拒绝",example = "0/1/2")
...@@ -53,9 +57,11 @@ public class ApprovalInformation { ...@@ -53,9 +57,11 @@ public class ApprovalInformation {
private String approvalLevel; private String approvalLevel;
@ApiModelProperty(value = "请假开始时间",example = "2020-03-20 09:00:00") @ApiModelProperty(value = "请假开始时间",example = "2020-03-20 09:00:00")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date leaveStartTime; private Date leaveStartTime;
@ApiModelProperty(value = "请假结束时间",example = "2020-03-21 09:00:00") @ApiModelProperty(value = "请假结束时间",example = "2020-03-21 09:00:00")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date leaveEndTime; private Date leaveEndTime;
@ApiModelProperty(value = "一级审批是否通过",example = "0/1") @ApiModelProperty(value = "一级审批是否通过",example = "0/1")
......
...@@ -14,7 +14,7 @@ import org.springframework.data.mongodb.core.mapping.Document; ...@@ -14,7 +14,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ApiModel(value = "个人考勤信息", description = "个人考勤信息") @ApiModel(value = "部门考勤信息", description = "部门考勤信息")
@Document(collection = "ding_attendepart") @Document(collection = "ding_attendepart")
public class AttendanceDepartment { public class AttendanceDepartment {
private String id; private String id;
...@@ -41,8 +41,11 @@ public class AttendanceDepartment { ...@@ -41,8 +41,11 @@ public class AttendanceDepartment {
private Integer earlyDay; private Integer earlyDay;
@ApiModelProperty(value = "出差天数",example = "1") @ApiModelProperty(value = "出差天数",example = "1")
private Float OutWorkDay; private Float outWorkDay;
@ApiModelProperty(value = "请假天数",example = "1") @ApiModelProperty(value = "请假天数",example = "1")
private Float offFromWorkDay; private Float offFromWorkDay;
@ApiModelProperty(value = "加班时长",example = "1")
private Float overWorkHours;
} }
...@@ -51,18 +51,39 @@ public class AttendanceDetails { ...@@ -51,18 +51,39 @@ public class AttendanceDetails {
@ApiModelProperty(value = "是否旷工0为旷工/1为未旷工",example = "2") @ApiModelProperty(value = "是否旷工0为旷工/1为未旷工",example = "2")
Integer isAbsenteeismDay; Integer isAbsenteeismDay;
@ApiModelProperty(value = "旷工天数",example = "2")
Float absenteeismDay;
@ApiModelProperty(value = "是否加班0为加班/1为未加班",example = "10") @ApiModelProperty(value = "是否加班0为加班/1为未加班",example = "10")
Integer isWorkOverHours; Integer isWorkOverHours;
@ApiModelProperty(value = "是否调休0为调休/1为未调休",example = "1") @ApiModelProperty(value = "加班时长",example = "4")
Float isPaidLeaveDay; Integer workOverHours;
// @ApiModelProperty(value = "是否调休0为调休/1为未调休",example = "1")
// Integer isPaidLeaveDay;
//
// @ApiModelProperty(value = "调休时长",example = "1")
// Float paidLeaveDay;
@ApiModelProperty(value = "是否请假0为请假/1为未请假",example = "1")
Integer isSickLeaveDay;
@ApiModelProperty(value = "请假时长",example = "1")
Float sickLeaveDay;
@ApiModelProperty(value = "是否公出",example = "1")
Integer isOutSideBusinessDay;
@ApiModelProperty(value = "公出天数",example = "1")
Float outSideBusinessDay;
@ApiModelProperty(value = "是否病假0为病假/1为未病假",example = "1") @ApiModelProperty(value = "出差",example = "1")
Float isSickLeaveDay; Integer isOutWorkDay;
@ApiModelProperty(value = "是否公出0为公出/1为未公出",example = "1") @ApiModelProperty(value = "出差时长",example = "1")
Float isOutSideBusinessDay; Float outWorkDay;
@ApiModelProperty(value = "时间",example = "2020-03-22") @ApiModelProperty(value = "时间",example = "2020-03-22 09:00:00")
Date date; Date date;
} }
...@@ -2,6 +2,7 @@ package com.zjty.tynotes.attendance.entity.vo; ...@@ -2,6 +2,7 @@ package com.zjty.tynotes.attendance.entity.vo;
import com.zjty.tynotes.attendance.entity.AttendanceDetails; import com.zjty.tynotes.attendance.entity.AttendanceDetails;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
...@@ -12,11 +13,56 @@ import lombok.NoArgsConstructor; ...@@ -12,11 +13,56 @@ import lombok.NoArgsConstructor;
*/ */
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "返回前台的个人考勤统计信息", description = "返回前台的个人考勤统计信息") @ApiModel(value = "返回前台的个人考勤统计信息", description = "返回前台的个人考勤统计信息")
public class UserAttenVo extends AttendanceDetails { public class UserAttenVo {
@ApiModelProperty(value = "用户编号",example = "1")
private String userId;
@ApiModelProperty(value = "用户姓名",example = "1")
private String name; private String name;
@ApiModelProperty(value = "应出勤天数",example = "1")
private Integer attendanceDay;
@ApiModelProperty(value = "实际出勤天数",example = "1")
private Float realAttendanceDay;
@ApiModelProperty(value = "公出天数",example = "1")
private Float outSideBusinessDay;
@ApiModelProperty(value = "迟到天数",example = "1")
private Integer lateDay;
@ApiModelProperty(value = "早退天数",example = "1")
private Integer leaveEarlyDay;
@ApiModelProperty(value = "出差天数",example = "1")
private Float outWorkDay;
@ApiModelProperty(value = "请假天数",example = "1")
private Float sickLeaveDay;
@ApiModelProperty(value = "加班时长",example = "1")
private Integer overWorkHours;
@ApiModelProperty(value = "旷工天数",example = "1")
private Float absenteeismDay;
public UserAttenVo() {
this.attendanceDay = 0;
this.realAttendanceDay = 0f;
this.outSideBusinessDay = 0f;
this.lateDay = 0;
this.leaveEarlyDay = 0;
this.outWorkDay = 0f;
this.sickLeaveDay = 0f;
this.overWorkHours = 0;
this.absenteeismDay = 0f;
}
public void computerRealAttendanceDay(){
realAttendanceDay = attendanceDay - outSideBusinessDay - outWorkDay - sickLeaveDay - absenteeismDay;
}
} }
...@@ -2,6 +2,9 @@ package com.zjty.tynotes.attendance.service; ...@@ -2,6 +2,9 @@ package com.zjty.tynotes.attendance.service;
import com.zjty.tynotes.attendance.entity.vo.UserAttenVo; import com.zjty.tynotes.attendance.entity.vo.UserAttenVo;
import com.zjty.tynotes.attendance.entity.vo.request.AttenRequest; import com.zjty.tynotes.attendance.entity.vo.request.AttenRequest;
import com.zjty.tynotes.pas.entity.Department;
import java.util.List;
/** /**
* @Author gwj * @Author gwj
...@@ -9,7 +12,24 @@ import com.zjty.tynotes.attendance.entity.vo.request.AttenRequest; ...@@ -9,7 +12,24 @@ import com.zjty.tynotes.attendance.entity.vo.request.AttenRequest;
*/ */
public interface AttendanceDetailsService { public interface AttendanceDetailsService {
/**
* 查询个人考勤
* @param id
* @return
*/
UserAttenVo findPersonnel(AttenRequest id); UserAttenVo findPersonnel(AttenRequest id);
/**
* 查询部门考勤
* @param request
* @return
*/
Object findDepartment(AttenRequest request); Object findDepartment(AttenRequest request);
/**
* 查询可查看的部门列表
* @param id
* @return
*/
List<Department> findDepartmentList(String id);
} }
...@@ -54,8 +54,7 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic ...@@ -54,8 +54,7 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
if(approvalInformation.getApprovalType().equals("调休")){ if(approvalInformation.getApprovalType().equals("调休")){
String userId = approvalInformation.getUserId(); String userId = approvalInformation.getUserId();
AttendanceDetails attendanceDetails = attendanceDetailsDao.findByUserId(userId); UserOverWork userOverWork = userOverWorkDao.findByUserId(userId);
UserOverWork userOverWork = userOverWorkDao.findByUserId(approvalInformation.getUserId());
Long workOverHours = userOverWork.getOverWorkHour(); Long workOverHours = userOverWork.getOverWorkHour();
Date leaveEndTime = approvalInformation.getLeaveEndTime(); Date leaveEndTime = approvalInformation.getLeaveEndTime();
Date leaveStartTime = approvalInformation.getLeaveStartTime(); Date leaveStartTime = approvalInformation.getLeaveStartTime();
...@@ -82,7 +81,7 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic ...@@ -82,7 +81,7 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
} }
} }
approvalInformation.setStatus("待审批"); approvalInformation.setStatus("0");
return approvalInformationDao.save(approvalInformation); return approvalInformationDao.save(approvalInformation);
} }
...@@ -105,6 +104,7 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic ...@@ -105,6 +104,7 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
public ApprovalInformation auditApproval(String userId,String approvalStatus,ApprovalInformation approvalInformation) { public ApprovalInformation auditApproval(String userId,String approvalStatus,ApprovalInformation approvalInformation) {
String departmentId = approvalInformation.getDepartmentId(); String departmentId = approvalInformation.getDepartmentId();
String departmentLevel = iUserService.getDepartmentLevel(departmentId); String departmentLevel = iUserService.getDepartmentLevel(departmentId);
System.out.println(departmentLevel);
if(("1").equals(departmentLevel)||("2").equals(departmentLevel)){ if(("1").equals(departmentLevel)||("2").equals(departmentLevel)){
approvalInformation.setApprovalUserIdOne(userId); approvalInformation.setApprovalUserIdOne(userId);
if(approvalInformation.getApprovalStatus()!=null && approvalInformation.getApprovalStatus().equals("0")){ if(approvalInformation.getApprovalStatus()!=null && approvalInformation.getApprovalStatus().equals("0")){
......
...@@ -42,6 +42,10 @@ public class MyInit implements CommandLineRunner { ...@@ -42,6 +42,10 @@ public class MyInit implements CommandLineRunner {
private String departmentMenberUrl; private String departmentMenberUrl;
@Value("${ding.userDetailsUrl}") @Value("${ding.userDetailsUrl}")
private String userDetailsUrl; private String userDetailsUrl;
@Value("${ding.appKey}")
private String appKey;
@Value("${ding.appSecret}")
private String appSecret;
@Autowired @Autowired
private PasUserDao pasUserDao; private PasUserDao pasUserDao;
...@@ -55,7 +59,7 @@ public class MyInit implements CommandLineRunner { ...@@ -55,7 +59,7 @@ public class MyInit implements CommandLineRunner {
//从钉钉获取的所有人员的id //从钉钉获取的所有人员的id
public List<String> userIds = new ArrayList<>(); public List<String> userIds = new ArrayList<>();
//根据丁丁的人员名单与本地的人员名单作对比后需要绑定的人员 //根据钉钉的人员名单与本地的人员名单作对比后需要绑定的人员
public List<DingUser> dingUserList = new ArrayList<>(); public List<DingUser> dingUserList = new ArrayList<>();
@Override @Override
...@@ -78,8 +82,8 @@ public class MyInit implements CommandLineRunner { ...@@ -78,8 +82,8 @@ public class MyInit implements CommandLineRunner {
public void getToken(){ public void getToken(){
DefaultDingTalkClient client = new DefaultDingTalkClient(tokenUrl); DefaultDingTalkClient client = new DefaultDingTalkClient(tokenUrl);
OapiGettokenRequest request = new OapiGettokenRequest(); OapiGettokenRequest request = new OapiGettokenRequest();
request.setAppkey("dingpzurwgv19x9uzpgd"); request.setAppkey(appKey);
request.setAppsecret("PgRC88Q8ML4S_tabbg5Oxne2fE43eemrHE4mFutcFcnPur4jbs3HshN-cpJAkF7-"); request.setAppsecret(appSecret);
request.setHttpMethod("GET"); request.setHttpMethod("GET");
try { try {
OapiGettokenResponse response = client.execute(request); OapiGettokenResponse response = client.execute(request);
......
...@@ -10,5 +10,5 @@ ding: ...@@ -10,5 +10,5 @@ ding:
# 获取打卡结果地址 # 获取打卡结果地址
userCardUrl: https://oapi.dingtalk.com/attendance/list userCardUrl: https://oapi.dingtalk.com/attendance/list
# 钉钉的appkey # 钉钉的appkey
appKey: dingpzurwgv19x9uzpgd appKey: dingfule26yutybtr2yg
appSecret: PgRC88Q8ML4S_tabbg5Oxne2fE43eemrHE4mFutcFcnPur4jbs3HshN-cpJAkF7- appSecret: 2VpbeeoFMae3dn_eVK5KIBau4ZO0Mh_Z4B-1CwQo1Gs-vh-WtULjBQVqhX6CBF-a
...@@ -56,6 +56,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -56,6 +56,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
httpSecurity httpSecurity
.cors().and() .cors().and()
.authorizeRequests() .authorizeRequests()
.antMatchers("/ding/test/**").permitAll()
.antMatchers("/pas/user/judgeParent/**").permitAll() .antMatchers("/pas/user/judgeParent/**").permitAll()
.antMatchers("/pas/user/test").permitAll() .antMatchers("/pas/user/test").permitAll()
.antMatchers("/pas/user/addGuanLian").permitAll() .antMatchers("/pas/user/addGuanLian").permitAll()
......
...@@ -9,12 +9,12 @@ import com.zjty.tynotes.pas.entity.Authority; ...@@ -9,12 +9,12 @@ import com.zjty.tynotes.pas.entity.Authority;
import com.zjty.tynotes.pas.entity.Day; import com.zjty.tynotes.pas.entity.Day;
import com.zjty.tynotes.pas.entity.Role; import com.zjty.tynotes.pas.entity.Role;
import com.zjty.tynotes.pas.entity.RoleAuthority; import com.zjty.tynotes.pas.entity.RoleAuthority;
import com.zjty.tynotes.pas.entity.vo.JobLeads;
import com.zjty.tynotes.pas.service.IUserService;
import com.zjty.tynotes.pas.service.impl.UserServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -36,6 +36,8 @@ public class TestController { ...@@ -36,6 +36,8 @@ public class TestController {
private RoleDao roleDao; private RoleDao roleDao;
@Autowired @Autowired
private RoleAuthorityDao roleAuthorityDao; private RoleAuthorityDao roleAuthorityDao;
@Autowired
private UserServiceImpl userService;
// @GetMapping("/test") // @GetMapping("/test")
// public void calculate() throws Exception{ // public void calculate() throws Exception{
...@@ -80,4 +82,11 @@ public class TestController { ...@@ -80,4 +82,11 @@ public class TestController {
} }
} }
@GetMapping("/test2/{id}")
public JobLeads addAuthority(@PathVariable String id) throws Exception{
JobLeads jobLeads = userService.findJobLeads(id);
return jobLeads;
}
} }
...@@ -15,6 +15,8 @@ public interface RoleDao extends MongoRepository<Role, String> { ...@@ -15,6 +15,8 @@ public interface RoleDao extends MongoRepository<Role, String> {
List<Role> findAllByDepartmentIdAndIsLeader(String departmentIds,String isLeader); List<Role> findAllByDepartmentIdAndIsLeader(String departmentIds,String isLeader);
List<Role> findAllByDepartmentIdAndIsLeaderAndIsPlus(String departmentIds,String isLeader,String plus);
List<Role> findAllByDepartmentId(String departmentId); List<Role> findAllByDepartmentId(String departmentId);
Role findAllByName(String name); Role findAllByName(String name);
......
...@@ -42,6 +42,9 @@ public class Role { ...@@ -42,6 +42,9 @@ public class Role {
@ApiModelProperty(value = "是否领导",example = "1") @ApiModelProperty(value = "是否领导",example = "1")
private String isLeader;//0代表是该部门领导,1代表为该部门普通员工 private String isLeader;//0代表是该部门领导,1代表为该部门普通员工
@ApiModelProperty(value = "正副经理0为正,1为副",example = "1")
private String isPlus;//0代表是总经理,1代表为该副经理
@Transient @Transient
@ApiModelProperty(value = "权限列表") @ApiModelProperty(value = "权限列表")
List<Authority> authorities; List<Authority> authorities;
......
package com.zjty.tynotes.pas.entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
* @Author gwj
* @create 2020/4/7 10:25
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "领导", description = "返回给任务模块的总监、总经理,副总经理集合")
public class JobLeads {
@ApiModelProperty(value = "总监id集合",example = "[1,2,3]")
private List<String> majordomos;
@ApiModelProperty(value = "总经理id集合",example = "[1,2,3]")
private List<String> generalManagers;
@ApiModelProperty(value = "副经理id集合",example = "[1,2,3]")
private List<String> assistantManagers;
}
...@@ -2,6 +2,7 @@ package com.zjty.tynotes.pas.service.impl; ...@@ -2,6 +2,7 @@ package com.zjty.tynotes.pas.service.impl;
import com.zjty.tynotes.pas.dao.*; import com.zjty.tynotes.pas.dao.*;
import com.zjty.tynotes.pas.entity.*; import com.zjty.tynotes.pas.entity.*;
import com.zjty.tynotes.pas.entity.vo.JobLeads;
import com.zjty.tynotes.pas.entity.vo.PageRequest; import com.zjty.tynotes.pas.entity.vo.PageRequest;
import com.zjty.tynotes.pas.entity.vo.PageResponse; import com.zjty.tynotes.pas.entity.vo.PageResponse;
import com.zjty.tynotes.pas.service.IDepartmentService; import com.zjty.tynotes.pas.service.IDepartmentService;
...@@ -688,5 +689,85 @@ public class UserServiceImpl implements IUserService { ...@@ -688,5 +689,85 @@ public class UserServiceImpl implements IUserService {
} }
public JobLeads findJobLeads(String executorId){
JobLeads jobLeads = new JobLeads();
List<String> majordomos = new ArrayList<>();
List<String> generalManagers = new ArrayList<>();
List<String> assistantManagers = new ArrayList<>();
Optional<User> optional = pasUserDao.findById(executorId);
User user = null;
List<String> departs = new ArrayList<>();
if(optional.isPresent()){
user = optional.get();
List<String> departmentIds = user.getDepartmentIds();
List<String> deIds = new ArrayList<>();//自身或者上级部门
if(departmentIds!=null){
departmentIds.forEach(departmentId -> {
List<String> parentDepartIds = findParentDepartIds(departmentId, new ArrayList<>());
if(parentDepartIds!=null){
parentDepartIds.forEach(str->{
if(!deIds.contains(str)){
deIds.add(str);
}
});
}
});
List<Department> departments = departmentDao.findAllByIdIn(deIds);
if(departments!=null){
departments.forEach(department -> {
if(!department.getLevel().equals("1")&&!department.getLevel().equals("2")){
List<Role> roles = roleDao.findAllByDepartmentIdAndIsLeader(department.getId(), "0");
List<String> roleIds = new ArrayList<>();
if(roles!=null){
roles.forEach(role -> roleIds.add(role.getId()));
}
List<UserRole> userRoles = userRoleDao.findAllByRoleIdIn(roleIds);
if(userRoles!=null){
for (UserRole userRole : userRoles) {
if(!majordomos.contains(userRole.getUserId())){
majordomos.add(userRole.getUserId());
}
}
}
}else if(department.getLevel().equals("1")||department.getLevel().equals("2")){
List<Role> roles2 = roleDao.findAllByDepartmentIdAndIsLeaderAndIsPlus(department.getId(), "0","1");
List<Role> roles = roleDao.findAllByDepartmentIdAndIsLeaderAndIsPlus(department.getId(), "0","0");
List<String> roleIds = new ArrayList<>();
List<String> roleIds2 = new ArrayList<>();
if(roles!=null){
roles.forEach(role -> roleIds.add(role.getId()));
}
if(roles2!=null){
roles2.forEach(role -> roleIds2.add(role.getId()));
}
List<UserRole> userRoles = userRoleDao.findAllByRoleIdIn(roleIds);
List<UserRole> userRoles2 = userRoleDao.findAllByRoleIdIn(roleIds2);
if(userRoles!=null){
for (UserRole userRole : userRoles) {
if(!generalManagers.contains(userRole.getUserId())){
generalManagers.add(userRole.getUserId());
}
}
}
if(userRoles2!=null){
for (UserRole userRole : userRoles2) {
if(!assistantManagers.contains(userRole.getUserId())){
assistantManagers.add(userRole.getUserId());
}
}
}
}
});
}
}
}
jobLeads.setMajordomos(majordomos);
jobLeads.setAssistantManagers(assistantManagers);
jobLeads.setGeneralManagers(generalManagers);
return jobLeads;
}
} }
...@@ -99,7 +99,7 @@ public class Init implements CommandLineRunner { ...@@ -99,7 +99,7 @@ public class Init implements CommandLineRunner {
} else { } else {
System.out.println("77777777777777777"); System.out.println("77777777777777777");
this.root = new User(); this.root = new User();
Role role = new Role(null, "管理员", "管理系统的人员", null, null, null); Role role = new Role(null, "管理员", "管理系统的人员",null, null, null, null);
List<Authority> authorities = new ArrayList<>(); List<Authority> authorities = new ArrayList<>();
Authority authority2 = new Authority(null, "用户管理", "无"); Authority authority2 = new Authority(null, "用户管理", "无");
Authority authority1 = new Authority(null, "权限管理", "无"); Authority authority1 = new Authority(null, "权限管理", "无");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论