提交 10d26492 authored 作者: gongwenjie's avatar gongwenjie

Merge branch 'master' of git.yfzx.zjtys.com.cn:zjm/notes2.0

# Conflicts: # notes-attendance/src/main/java/com/zjty/tynotes/attendance/controller/AttendanceController.java
上级 3b1d11fd
......@@ -2,7 +2,11 @@ package com.zjty.tynotes.attendance.controller;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiAttendanceListRecordRequest;
import com.dingtalk.api.request.OapiAttendanceListRequest;
import com.dingtalk.api.request.OapiUserGetRequest;
import com.dingtalk.api.response.OapiAttendanceListRecordResponse;
import com.dingtalk.api.response.OapiAttendanceListResponse;
import com.dingtalk.api.response.OapiDepartmentListResponse;
import com.dingtalk.api.response.OapiUserGetResponse;
import com.taobao.api.ApiException;
......@@ -58,8 +62,30 @@ public class DingTestController {
@GetMapping("/card")
public Object card(){
List<CardResult> cardDetails = cardTask.getCardDetails();
return cardDetails;
myInit.getToken();
myInit.getDepartmentList();
myInit.getUserList();
List<String> userIds = myInit.userIds;
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/attendance/listRecord");
OapiAttendanceListRecordRequest request = new OapiAttendanceListRecordRequest();
request.setCheckDateFrom("2020-04-04 00:00:00");
request.setCheckDateTo("2020-04-10 00:00:00");
request.setUserIds(userIds);
try {
OapiAttendanceListRecordResponse execute = client.execute(request,myInit.token);
List<OapiAttendanceListRecordResponse.Recordresult> recordresult = execute.getRecordresult();
return recordresult;
} catch (ApiException e) {
e.printStackTrace();
}
return null;
}
@GetMapping("/score")
public Object score(){
String month = "2020-04";
Double aDouble = cardTask.calcuteScore(month);
return aDouble;
}
}
......@@ -18,11 +18,11 @@ public interface ApprovalInformationDao extends MongoRepository<ApprovalInformat
List<ApprovalInformation> findAllByStatusIn(List<String> statusList);
ApprovalInformation findByUserIdAndStatusAndApprovalType(String userId, String status,String type);
List<ApprovalInformation> findAllByUserIdAndLeaveStartTimeLessThanEqualAndLeaveEndTimeGreaterThanEqualAndStatus(String userId, Date startTime ,Date endTime,String status);
ApprovalInformation findAllByUserIdAndLeaveStartTimeLessThanEqualAndLeaveEndTimeGreaterThanEqualAndApprovalTypeIn(String userId, Date startTime ,Date endTime,List<String> type);
ApprovalInformation findAllByUserIdAndLeaveStartTimeBeforeAndLeaveEndTimeBetweenAndApprovalTypeAndStatus(String userId, Date startTime,Date startTime1,Date endTime,String type,String status);
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);
ApprovalInformation findAllByUserIdAndLeaveStartTimeBetweenAndLeaveEndTimeAfterAndApprovalTypeAndStatus(String userId, Date startTime,Date endTime,Date endTime1,String type,String status);
}
......@@ -41,9 +41,15 @@ public class AttendanceDetails {
@ApiModelProperty(value = "是否迟到0为迟到/1为未迟到",example = "1")
Integer isLateDay;
@ApiModelProperty(value = "迟到等级0轻(15分钟以内)/1较轻(1小时以内)/2较严重(4小时以内)/3严重(4小时以上)",example = "1")
Integer lateStatus;
@ApiModelProperty(value = "是否早退0为早退/1为未早退",example = "1")
Integer isLeaveEarlyDay;
@ApiModelProperty(value = "早退等级0轻/1较轻/2较严重/3严重",example = "1")
Integer earlyStatus;
@ApiModelProperty(value = "缺卡次数",example = "2")
Integer lessCard;
......@@ -59,16 +65,22 @@ public class AttendanceDetails {
@ApiModelProperty(value = "加班时长",example = "4")
Integer workOverHours;
// @ApiModelProperty(value = "是否调休0为调休/1为未调休",example = "1")
// Integer isPaidLeaveDay;
//
// @ApiModelProperty(value = "调休时长",example = "1")
// Float paidLeaveDay;
@ApiModelProperty(value = "是否调休0为调休/1为未调休",example = "1")
Integer isPaidLeaveDay;
@ApiModelProperty(value = "调休时长",example = "1")
Float paidLeaveDay;
@ApiModelProperty(value = "是否事假0为事假/1为未事假",example = "1")
Integer isThingLeaveDay;
@ApiModelProperty(value = "事假天数",example = "1")
Float thingLeaveDay;
@ApiModelProperty(value = "是否请假0为请假/1为未请假",example = "1")
@ApiModelProperty(value = "是否病假0为病假/1为未病假",example = "1")
Integer isSickLeaveDay;
@ApiModelProperty(value = "假时长",example = "1")
@ApiModelProperty(value = "假时长",example = "1")
Float sickLeaveDay;
@ApiModelProperty(value = "是否公出",example = "1")
......@@ -87,9 +99,12 @@ public class AttendanceDetails {
Date date;
public AttendanceDetails() {
thingLeaveDay = 0f;
paidLeaveDay = 0f;
workOverHours = 0;
outSideBusinessDay = 0f;
outWorkDay = 0f;
sickLeaveDay = 0f;
absenteeismDay = 0f;
}
}
......@@ -276,7 +276,7 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
/**
* 计算调休时长,请假时长
*/
private Long computeTime(Date startTime,Date endTime) throws Exception{
public Long computeTime(Date startTime,Date endTime) throws Exception{
Config config = configDao.findAll().get(0);
String workTime = config.getWorkTime();//上班时间
String afterWorkTime = config.getAfterWorkTime();//下班时间
......
package com.zjty.tynotes.job.status.entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author gwj
* @create 2020/4/10 13:41
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "返给人员模块的数据协议类", description = "人员的任务信息")
public class UserWorkData {
@ApiModelProperty(value = "人员id", example = "qwer1234")
private String userId;
@ApiModelProperty(value = "任务平均分", example = "70")
private Double averageScore;
@ApiModelProperty(value = "已完成任务个数", example = "3")
private Integer completedNum;
@ApiModelProperty(value = "进行中任务个数", example = "2")
private Integer unCompletedNum;
}
package com.zjty.tynotes.job.status.service;
import com.zjty.tynotes.job.status.entity.Personnel;
import com.zjty.tynotes.job.status.entity.vo.UserWorkData;
import java.util.Date;
import java.util.List;
/**
......@@ -20,4 +22,15 @@ public interface InternalService {
* 根据人员id返回任务数量
*/
int personnelWorkCount(String id);
/**
* 根据时间区间查找人员任务信息
* @param userId
* @param startTime
* @param endTime
* @return
*/
UserWorkData personnelWorkMsg(String userId,Date startTime,Date endTime);
UserWorkData personnelWorkMsgAll(String userId);
}
......@@ -6,6 +6,7 @@ import com.zjty.tynotes.job.common.exception.WorkAttribution;
import com.zjty.tynotes.job.common.exception.WorkAttribution1;
import com.zjty.tynotes.job.status.entity.Personnel;
import com.zjty.tynotes.job.status.entity.RedisPersonalWork;
import com.zjty.tynotes.job.status.entity.vo.UserWorkData;
import com.zjty.tynotes.job.status.service.InternalService;
import com.zjty.tynotes.pas.service.IUserService;
import com.zjty.tynotes.search.subject.service.EsUtil;
......@@ -15,6 +16,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
public class InternalServiceImpl implements InternalService {
......@@ -62,4 +64,14 @@ public class InternalServiceImpl implements InternalService {
return count;
}
@Override
public UserWorkData personnelWorkMsg(String userId, Date startTime, Date endTime) {
return null;
}
@Override
public UserWorkData personnelWorkMsgAll(String userId) {
return null;
}
}
......@@ -11,9 +11,15 @@ import java.util.List;
* @create 2020/3/1 11:14
*/
public interface DayDao extends MongoRepository<Day,String> {
List<Day> findAllByStatusAndDateBetween(String status, Date startDate, Date lastDate);
Day findByStatusAndDateEquals(String status, Date startDate);
List<Day> findAllByStatusAndDateBetween(String status,Date startDate, Date lastDate);
// List<Day> findAllByStatusAndDateGreaterThanEqual(String status, Date startDate);
// List<Day> findAllByStatusAndDateLessThanEqual(String status, Date lastDate);
// List<Day> findAllByStatusAndDateWithin(String status,Date startDate, Date lastDate);
List<Day> findAllByDateBetween(Date startDate, Date lastDate);
Day findByDateEquals(Date date);
Day findByDate(Date date);
}
......@@ -24,4 +24,13 @@ public interface RoleDao extends MongoRepository<Role, String> {
void deleteByName(String name);
Role findByName(String name);
/**
* 查询在该角色id内,以及根据角色是否为领导查询角色集合
* @param ids
* @param isLeader
* @return
*/
List<Role> findAllByIdInAndIsLeader(List<String> ids,String isLeader);
}
......@@ -17,4 +17,5 @@ public interface UserRoleDao extends MongoRepository<UserRole,String> {
void deleteAllByUserId(String userId);
List<UserRole> findAllByRoleIdIn(List<String> roleIds);
}
package com.zjty.tynotes.pas.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
......@@ -28,6 +29,7 @@ public class Day {
@NotEmpty(message = "节假日日期")
@ApiModelProperty(value = "节假日日期",example = "2020/2/1")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date date;
@ApiModelProperty(value = "节假日描述,为工作日还是休息日还是团建,默认0为工作日,1为休息日,2为团建",example = "0")
......
package com.zjty.tynotes.pas.entity.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* @Author gwj
* @create 2020/3/2 11:02
......@@ -49,4 +52,16 @@ public class PageRequest {
* 查询条件:任务数量升降序(默认降序0 1升序)
*/
private Integer sort;
/**
* 起始时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date startTime;
/**
* 结束时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date endTime;
}
......@@ -77,46 +77,78 @@ public class ConfigServiceImpl implements ConfigService {
public List<Day> findHolidaysByMonth(String date) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date date1 = sdf.parse(date);
int year = date1.getYear()+1900;
int month = date1.getMonth()+1;
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR,year);
calendar.set(Calendar.MONTH,month-1);
calendar.set(Calendar.DAY_OF_MONTH,2);
Date firstDate = calendar.getTime();
calendar.set(Calendar.MONTH,month);
Date parse = sdf.parse(date);
calendar.setTime(parse);
calendar.set(Calendar.DAY_OF_MONTH,1);
Date startTime = calendar.getTime();
System.out.println(startTime);
calendar.add(Calendar.MONTH,1);
calendar.set(Calendar.DAY_OF_MONTH,0);
Date lastDate = calendar.getTime();
List<Day> days = dayDao.findAllByDateBetween(firstDate, lastDate);
Date endTime = calendar.getTime();
List<Day> days = dayDao.findAllByDateBetween(startTime, endTime);
List<Day> days1 = new ArrayList<>();
calendar.set(Calendar.DAY_OF_MONTH,1);
if(days==null || days.size()==0){
calendar.set(Calendar.DAY_OF_MONTH,2);
System.out.println(calendar.getTime());
List<String> fullDayList = new ArrayList<>(32);
int count = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
for (int j = 1; j <= count ; j++) {
fullDayList.add(sdf1.format(calendar.getTime()));
calendar.add(Calendar.DAY_OF_MONTH,1);
}
List<Day> days1 = new ArrayList<>();
for (String string : fullDayList) {
Day day = new Day();
day.setStatus("0");
day.setDate(sdf1.parse(string));
day.setDate(calendar.getTime());
days1.add(day);
calendar.add(Calendar.DATE,1);
}
return dayDao.saveAll(days1);
List<Day> days2 = dayDao.saveAll(days1);
days = days2;
}else{
Day startDay = dayDao.findByDateEquals(startTime);
System.out.println(startDay);
Day endDay = dayDao.findByDateEquals(endTime);
days.add(startDay);
days.add(endDay);
}
calendar.set(Calendar.MONTH,month-1);
calendar.set(Calendar.DAY_OF_MONTH,0);
firstDate = calendar.getTime();
calendar.set(Calendar.MONTH,month);
calendar.set(Calendar.DAY_OF_MONTH,1);
lastDate = calendar.getTime();
return dayDao.findAllByDateBetween(firstDate,lastDate);
// Date date1 = sdf.parse(date);
// int year = date1.getYear()+1900;
// int month = date1.getMonth()+1;
// Calendar calendar = Calendar.getInstance();
// calendar.set(Calendar.YEAR,year);
// calendar.set(Calendar.MONTH,month-1);
// calendar.set(Calendar.DAY_OF_MONTH,2);
// Date firstDate = calendar.getTime();
// calendar.set(Calendar.MONTH,month);
// calendar.set(Calendar.DAY_OF_MONTH,0);
// Date lastDate = calendar.getTime();
// List<Day> days = dayDao.findAllByDateBetween(firstDate, lastDate);
// if(days==null || days.size()==0){
//
// calendar.set(Calendar.DAY_OF_MONTH,2);
// System.out.println(calendar.getTime());
// List<String> fullDayList = new ArrayList<>(32);
// int count = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
// for (int j = 1; j <= count ; j++) {
// fullDayList.add(sdf1.format(calendar.getTime()));
// calendar.add(Calendar.DAY_OF_MONTH,1);
// }
// List<Day> days1 = new ArrayList<>();
// for (String string : fullDayList) {
// Day day = new Day();
// day.setStatus("0");
// day.setDate(sdf1.parse(string));
// days1.add(day);
// }
// return dayDao.saveAll(days1);
// }
// calendar.set(Calendar.MONTH,month-1);
// calendar.set(Calendar.DAY_OF_MONTH,0);
// firstDate = calendar.getTime();
// calendar.set(Calendar.MONTH,month);
// calendar.set(Calendar.DAY_OF_MONTH,1);
// lastDate = calendar.getTime();
// return dayDao.findAllByDateBetween(firstDate,lastDate);
return days;
} catch (ParseException e) {
}
......
......@@ -329,14 +329,48 @@ public class UserServiceImpl implements IUserService {
List<String> departmentList = findDepartmentList(userId,authoryName);
List<User> all = pasUserDao.findAll();
List<User> users = new ArrayList<>();
List<UserRole> userRoleList = userRoleDao.findAllByUserId(userId);
List<String> deIds = new ArrayList<>();
if(userRoleList!=null){
List<String> roleIds1 = new ArrayList<>();
userRoleList.forEach(userRole -> {
roleIds1.add(userRole.getRoleId());
});
List<Role> roles = roleDao.findAllByIdIn(roleIds1);
if(roles!=null){
roles.forEach(role -> {
if(role.getIsLeader().equals("1")){
deIds.add(role.getDepartmentId());
}
});
}
}
if(all!=null){
for (User user : all) {
List<String> departmentIds = user.getDepartmentIds();
if(departmentIds!=null){
for (String departId : departmentIds) {
if(departmentList.contains(departId)){
if(deIds.contains(departId)){
List<String> roleIdList = new ArrayList<>();
List<UserRole> userRoles = userRoleDao.findAllByUserId(userId);
if(userRoles!=null){
userRoles.forEach(userRole -> {
roleIdList.add(userRole.getRoleId());
});
}
List<Role> roles = roleDao.findAllByIdIn(roleIdList);
if(roles!=null){
roles.forEach(role -> {
if(role.getDepartmentId().equals(departId)&&role.getIsLeader().equals("1")){
users.add(user);
}
});
}
}else{
users.add(user);
}
break;
}
}
......@@ -776,12 +810,19 @@ public class UserServiceImpl implements IUserService {
String id = authority.getId();
List<RoleAuthority> roleAuthorities = roleAuthorityDao.findAllByAuthorityId(id);
if(roleAuthorities!=null){
List<String> roleIdList = new ArrayList<>();
List<String> roleIds = new ArrayList<>();
List<String> userIds = new ArrayList<>();
roleAuthorities.forEach(roleAuthority -> {
roleIds.add(roleAuthority.getRoleId());
});
List<UserRole> userRoles = userRoleDao.findAllByRoleIdIn(roleIds);
List<Role> roles = roleDao.findAllByIdInAndIsLeader(roleIds, "0");
if(roles!=null){
roles.forEach(role -> {
roleIdList.add(role.getId());
});
}
List<UserRole> userRoles = userRoleDao.findAllByRoleIdIn(roleIdList);
if(userRoles!=null){
userRoles.forEach(userRole -> {
......
......@@ -86,6 +86,16 @@ public class UserVo {
private Integer workCount;
@ApiModelProperty(value = "已完成任务数量",example = "10")
private Integer completedCount;
@ApiModelProperty(value = "进行中任务数量",example = "10")
private Integer workingCount;
@ApiModelProperty(value = "平均评分",example = "10")
private Double averageScore;
// @NotNull(message = "角色Id不可为空")
// @ApiModelProperty(value = "角色id",example = "1")
// private Integer roleId;
......
......@@ -3,6 +3,7 @@ package com.zjty.tynotes.weekly.subject.service.impl;
import com.zjty.tynotes.job.basic.entity.database.Work;
import com.zjty.tynotes.job.basic.repository.WorkRepository;
import com.zjty.tynotes.job.status.entity.Personnel;
import com.zjty.tynotes.job.status.entity.vo.UserWorkData;
import com.zjty.tynotes.job.status.service.InternalService;
import com.zjty.tynotes.pas.dao.*;
import com.zjty.tynotes.pas.entity.*;
......@@ -13,11 +14,13 @@ import com.zjty.tynotes.weekly.subject.entity.vo.Problem;
import com.zjty.tynotes.weekly.subject.entity.vo.UserVo;
import com.zjty.tynotes.weekly.subject.service.UserManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import java.lang.reflect.Array;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
* @Author gwj
......@@ -42,6 +45,9 @@ public class UserManageServiceImpl implements UserManageService {
@Autowired
private InternalService internalService;
private Map<String, UserWorkData> userWorkDataMap = new ConcurrentHashMap<>();
@Autowired
private ProblemDao problemDao;
......@@ -103,7 +109,6 @@ public class UserManageServiceImpl implements UserManageService {
}
}
}
}
}
......@@ -145,7 +150,16 @@ public class UserManageServiceImpl implements UserManageService {
}
List<Role> roles = roleDao.findAllByIdIn(roleIds);
user.setRoles(roles);
userVos.add(new UserVo(user));
UserVo userVo = new UserVo(user);
if(pageRequest.getStartTime()==null&&pageRequest.getEndTime()==null){
UserWorkData userWorkData = userWorkDataMap.get(user.getId());
userVo.setAverageScore(userWorkData.getAverageScore());
userVo.setCompletedCount(userWorkData.getCompletedNum());
userVo.setWorkingCount(userWorkData.getUnCompletedNum());
}else{
internalService.personnelWorkMsg(user.getId(),pageRequest.getStartTime(),pageRequest.getEndTime());
}
userVos.add(userVo);
}
pageResponse.setRows(userVos);
pageResponse.setTotalCount(userList.size());
......@@ -160,7 +174,14 @@ public class UserManageServiceImpl implements UserManageService {
}
List<Role> roles = roleDao.findAllByIdIn(roleIds);
user.setRoles(roles);
userVos.add(new UserVo(user));
UserVo userVo = new UserVo(user);
if(pageRequest.getStartTime()==null&&pageRequest.getEndTime()==null){
UserWorkData userWorkData = userWorkDataMap.get(user.getId());
userVo.setAverageScore(userWorkData.getAverageScore());
userVo.setCompletedCount(userWorkData.getCompletedNum());
userVo.setWorkingCount(userWorkData.getUnCompletedNum());
}
userVos.add(userVo);
}
pageResponse.setRows(userVos);
pageResponse.setTotalCount(userList.size());
......@@ -316,4 +337,22 @@ public class UserManageServiceImpl implements UserManageService {
}
}
@Scheduled(cron = "0/30 * * * * ? ")
public void userWorkDataMap(){
List<User> users = pasUserDao.findAll();
if(users!=null){
users.forEach(user -> {
UserWorkData userWorkData = internalService.personnelWorkMsgAll(user.getId());
if(userWorkData!=null){
userWorkDataMap.put(user.getId(),userWorkData);
}
});
}
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论