提交 bc37cde8 authored 作者: gongwenjie's avatar gongwenjie

合并分支 'gwj' 到 'master'

Gwj 查看合并请求 !68
流水线 #107 已取消 于阶段
......@@ -25,6 +25,9 @@ public class ApprovalInformation {
@ApiModelProperty(value = "id",example = "1")
private String id;
@ApiModelProperty(value = "审批名称",example = "1")
private String title;
@ApiModelProperty(value = "提交审批用户id",example = "1")
private String userId;
......
......@@ -7,7 +7,11 @@ import com.zjty.tynotes.attendance.entity.ApprovalInformation;
import com.zjty.tynotes.attendance.entity.AttendanceDetails;
import com.zjty.tynotes.attendance.entity.UserOverWork;
import com.zjty.tynotes.attendance.service.ApprovalInformationService;
import com.zjty.tynotes.pas.dao.ConfigDao;
import com.zjty.tynotes.pas.dao.DayDao;
import com.zjty.tynotes.pas.dao.DepartmentDao;
import com.zjty.tynotes.pas.entity.Config;
import com.zjty.tynotes.pas.entity.Day;
import com.zjty.tynotes.pas.entity.Department;
import com.zjty.tynotes.pas.service.IUserService;
import org.apache.commons.lang3.StringUtils;
......@@ -15,10 +19,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import javax.validation.constraints.NotEmpty;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @Author gwj
......@@ -36,6 +40,10 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
private DepartmentDao departmentDao;
@Autowired
private UserOverWorkDao userOverWorkDao;
@Autowired
private DayDao dayDao;
@Autowired
private ConfigDao configDao;
@Override
public ApprovalInformation addApproval(ApprovalInformation approvalInformation) {
......@@ -179,4 +187,117 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
});
return approvalInformationList;
}
/**
* 计算调休时长
*/
private Long computeTime(Date startTime,Date endTime){
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// Config config = configDao.findAll().get(0);
// SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd "+config.getWorkTime());
// SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd "+config.getAfterWorkTime());
// String format = sdf.format(startTime);
// try {
// Calendar calendar = Calendar.getInstance();
// Date parse1 = sdf2.parse(format);//该天的上班时间
// Date parse2 = sdf3.parse(format);
// Date parse = sdf.parse(format);
// Day day = dayDao.findByDate(parse);
// String status = day.getStatus();
// long hours = 0;
//
// while(true){
// if(parse1.before(startTime)){
// if(endTime.before(parse2)){
// Long time = endTime.getTime() - startTime.getTime();
// long hour = 1000*60*60;
// if(time%hour==0){
// hours = time/hour;
// }else{
// hours = time/hour + 1;
// }
// }else{
//
// }
// }
// }
//
//
//
//
// //判断该天是否是工作日
// if(status.equals("0")) {
// if(parse1.before(startTime)){
// if(endTime.before(parse2)){
// Long time = endTime.getTime() - startTime.getTime();
// long hour = 1000*60*60;
// if(time%hour==0){
// hours = time/hour;
// }else{
// hours = time/hour + 1;
// }
// }else{
// calendar.setTime(parse1);
// calendar.add(Calendar.DATE,1);
// Date time = calendar.getTime();
// Day day1 = dayDao.findByDate(time);
// if(day1.getStatus().equals("0")){
//
// }
// }
// }
// }else{
// calendar.setTime(parse1);
// calendar.add(Calendar.DATE,1);
// Date time = calendar.getTime();
// calendar.setTime(parse2);
// calendar.add(Calendar.DATE,1);
// Date time1 = calendar.getTime();
// Day day1 = dayDao.findByDate(time);
// if(time.before(endTime)){
// if(endTime.before(parse2)){
//
// }
// }
// }
//
//// if(status.equals("0")){//判断该天是否是工作日
//// if(parse1.before(startTime)&&endTime.before(parse2)){
//// if(endTime.before(parse2)){
//// Long time = endTime.getTime() - startTime.getTime();
//// long hour = 1000*60*60;
//// long hours = 0;
//// if(time%hour==0){
//// hours = time/hour;
//// }else{
//// hours = time/hour + 1;
//// }
//// }else{
//// calendar.setTime(parse1);
//// calendar.add(Calendar.DATE,1);//往后一天的上班时间
//// Date time1 = calendar.getTime();
//// if(endTime.before(time1)){
//// Long time = parse2.getTime() - startTime.getTime();
//// long hour = 1000*60*60;
//// long hours = 0;
//// if(time%hour==0){
//// hours = time/hour;
//// }else{
//// hours = time/hour + 1;
//// }
//// }
//// }
////
//// }
//// }
//
//
//
// } catch (ParseException e) {
// e.printStackTrace();
// }
return null;
}
}
......@@ -137,6 +137,13 @@ public class UserController {
return ok("重置密码失败");
}
@ApiOperation(value = "查询该用户是否是某用户的上级")
@GetMapping("/judgeParent/{id}/{userId}")
public ResponseEntity judgeParent(@PathVariable String id,@PathVariable String userId) {
boolean flag = iUserService.judgeParent(id,userId);
return ok(flag);
}
}
......@@ -14,4 +14,6 @@ public interface DayDao extends MongoRepository<Day,String> {
List<Day> findAllByStatusAndDateBetween(String status, Date startDate, Date lastDate);
List<Day> findAllByDateBetween(Date startDate, Date lastDate);
Day findByDate(Date date);
}
......@@ -153,4 +153,12 @@ public interface IUserService {
* @return
*/
boolean replacePass(String id);
/**
* 判断是否为上级,并且拥有修改任务权限
* @param id
* @param userId
* @return
*/
boolean judgeParent(String id, String userId);
}
......@@ -568,6 +568,89 @@ public class UserServiceImpl implements IUserService {
return false;
}
/**
* 是否为上级,并且拥有修改任务权限
* @param id
* @param userId
* @return
*/
@Override
public boolean judgeParent(String id, String userId) {
List<UserRole> userRoles1 = userRoleDao.findAllByUserId(userId);
List<UserRole> userRoles2 = userRoleDao.findAllByUserId(id);
List<String> roleIds = new ArrayList<>();
List<String> roleIds2 = new ArrayList<>();
boolean flag = false;
if(userRoles2!=null){
userRoles2.forEach(userRole -> roleIds.add(userRole.getRoleId()));
List<Role> roles = roleDao.findAllByIdIn(roleIds);
List<String> departIds = new ArrayList<>();
if(roles!=null){
roles.forEach(role -> {
List<String> authorityIds = new ArrayList<>();
List<RoleAuthority> roleAuthorities = roleAuthorityDao.findAllByRoleId(role.getId());
if(roleAuthorities!=null){
roleAuthorities.forEach(roleAuthority -> {
authorityIds.add(roleAuthority.getAuthorityId());
});
List<Authority> authorities = authorityDao.findAllByIdIn(authorityIds);
if(authorities!=null){
authorities.forEach(authority -> {
if(authority.getName().equals("修改任务")){
departIds.add(role.getDepartmentId());
}
});
}
}
});
}
if(userRoles1!=null){
userRoles1.forEach(userRole -> roleIds2.add(userRole.getRoleId()));
List<Role> roleList = roleDao.findAllByIdIn(roleIds2);
List<String> departmentIds = new ArrayList<>();//自身或者上级部门
roleList.forEach(role -> {
String departmentId = role.getDepartmentId();
List<String> parentDepartIds = findParentDepartIds(departmentId, new ArrayList<String>());
if(parentDepartIds!=null){
parentDepartIds.forEach(str->{
if(!departmentIds.contains(str)){
departmentIds.add(str);
}
});
}
});
for (String str : departmentIds) {
if(departIds.contains(str)){
flag = true;
}
}
}
}
return flag;
}
public List<String> findParentDepartIds(String departmentId,List<String> departmentIds){
departmentIds.add(departmentId);
Optional<Department> optional = departmentDao.findById(departmentId);
Department department = null;
if(optional.isPresent()){
department = optional.get();
String parentId = department.getParentId();
if(StringUtils.isNotBlank(parentId)){
findParentDepartIds(parentId,departmentIds);
}else{
if(!departmentIds.contains(parentId)){
departmentIds.add(parentId);
}
}
}
return departmentIds;
}
/**
* 查询所有上级部门
* @param departIds 需要传入的用户部门集合
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论