Bläddra i källkod

请年假时,先判断是否在出差状态,或者请假日期在节假日日期范围内,如果属于以上两种情况,就不能申请年假

yanliming 3 veckor sedan
förälder
incheckning
2ea9441493

+ 2 - 0
common/src/main/java/com/jpsoft/shinestar/modules/business/service/YearRequestForLeaveInfoService.java

@@ -26,4 +26,6 @@ public interface YearRequestForLeaveInfoService {
 	Page<YearRequestForLeaveInfo> pageMobileSearch(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
 	void approvalRequestForLeave(PersonInfo personInfo, String id, String approvalOpinions, String approvalExplain, int status) throws Exception;
 	String leaveSubmit(PersonPopedom personPopedom,String startTime, String endTime, String startTimeQuantum, String endTimeQuantum, String imageUrl, String reason, String days, String formId, String activityId, String draft, String id) throws Exception;
+
+	boolean isHoliday(String startTime, String endTime)throws Exception;
 }

+ 32 - 8
common/src/main/java/com/jpsoft/shinestar/modules/business/service/impl/YearRequestForLeaveInfoServiceImpl.java

@@ -2,19 +2,17 @@ package com.jpsoft.shinestar.modules.business.service.impl;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 import java.util.*;
 import javax.annotation.Resource;
 
 import cn.hutool.core.date.DateUtil;
+import com.github.pagehelper.util.StringUtil;
 import com.jpsoft.shinestar.config.WxConfig;
-import com.jpsoft.shinestar.modules.base.entity.ApprovalConfig;
-import com.jpsoft.shinestar.modules.base.entity.CompanyInfo;
-import com.jpsoft.shinestar.modules.base.entity.PersonInfo;
-import com.jpsoft.shinestar.modules.base.entity.PersonPopedom;
-import com.jpsoft.shinestar.modules.base.service.ApprovalConfigService;
-import com.jpsoft.shinestar.modules.base.service.CompanyInfoService;
-import com.jpsoft.shinestar.modules.base.service.PersonInfoService;
-import com.jpsoft.shinestar.modules.base.service.PersonPopedomService;
+import com.jpsoft.shinestar.modules.base.entity.*;
+import com.jpsoft.shinestar.modules.base.service.*;
 import com.jpsoft.shinestar.modules.business.dto.UpdatePersonAttendanceDTO;
 import com.jpsoft.shinestar.modules.common.utils.JwtUtil2;
 import com.jpsoft.shinestar.modules.common.utils.WechatMessageUtil;
@@ -76,6 +74,9 @@ public class YearRequestForLeaveInfoServiceImpl implements YearRequestForLeaveIn
 	@Autowired
 	RabbitTemplate rabbitTemplate;
 
+	@Autowired
+	private HolidayInfoService holidayInfoService;
+
 
 	@Override
 	public YearRequestForLeaveInfo get(String id) {
@@ -593,4 +594,27 @@ public class YearRequestForLeaveInfoServiceImpl implements YearRequestForLeaveIn
 			}
 		}
 	}
+
+	//请年假的日期范围是否包含节假日
+	@Override
+	public boolean isHoliday(String startTime, String endTime) throws ParseException {
+		boolean result = false;
+		if (StringUtil.isNotEmpty(startTime)) {
+			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+
+			LocalDate startDate = LocalDate.parse(startTime);
+			LocalDate endDate = LocalDate.parse(endTime);
+
+			//使用循环遍历日期
+			for (LocalDate date = startDate; !date.isAfter(endDate); date = date.plusDays(1)) {
+				List<HolidayInfo> holidayInfoList = holidayInfoService.findByDate(sdf.parse(date.toString()));
+				if (holidayInfoList.size() > 0) {
+					result = true;
+					break;
+				}
+			}
+		}
+
+		return result;
+	}
 }

+ 61 - 51
web/src/main/java/com/jpsoft/shinestar/modules/mobile/controller/YearRequestForLeaveInfoApiController.java

@@ -5,14 +5,8 @@ import cn.hutool.core.util.StrUtil;
 import com.github.pagehelper.Page;
 import com.github.pagehelper.util.StringUtil;
 import com.jpsoft.shinestar.modules.base.dto.ApprovalDTO;
-import com.jpsoft.shinestar.modules.base.entity.CompanyInfo;
-import com.jpsoft.shinestar.modules.base.entity.PersonInfo;
-import com.jpsoft.shinestar.modules.base.entity.PersonPopedom;
-import com.jpsoft.shinestar.modules.base.entity.PersonRoleInfo;
-import com.jpsoft.shinestar.modules.base.service.CompanyInfoService;
-import com.jpsoft.shinestar.modules.base.service.PersonInfoService;
-import com.jpsoft.shinestar.modules.base.service.PersonPopedomService;
-import com.jpsoft.shinestar.modules.base.service.PersonRoleInfoService;
+import com.jpsoft.shinestar.modules.base.entity.*;
+import com.jpsoft.shinestar.modules.base.service.*;
 import com.jpsoft.shinestar.modules.business.dto.YearRequestForLeaveDetailDTO;
 import com.jpsoft.shinestar.modules.business.dto.YearRequestForLeaveInfoDTO;
 import com.jpsoft.shinestar.modules.business.entity.YearRequestForLeaveInfo;
@@ -33,7 +27,9 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 import java.util.*;
 
 
@@ -63,6 +59,12 @@ public class YearRequestForLeaveInfoApiController {
     @Autowired
     private CompanyInfoService companyInfoService;
 
+    @Autowired
+    private HolidayCompanyService holidayCompanyService;
+
+    @Autowired
+    private HolidayInfoService holidayInfoService;
+
 
     @ApiOperation(value = "请假记录分页")
     @PostMapping(value = "pageList")
@@ -118,15 +120,15 @@ public class YearRequestForLeaveInfoApiController {
                 yearRequestForLeaveInfoDTO.setStatus(yearRequestForLeaveInfo.getStatus());
 
                 yearRequestForLeaveInfoDTO.setStatusN(TypeNameUtil.getExamineTypeName(yearRequestForLeaveInfo.getStatus().toString()));
-                yearRequestForLeaveInfoDTO.setStartTime(DateUtil.format(yearRequestForLeaveInfo.getStartTime(),"yyyy-MM-dd"));
+                yearRequestForLeaveInfoDTO.setStartTime(DateUtil.format(yearRequestForLeaveInfo.getStartTime(), "yyyy-MM-dd"));
                 yearRequestForLeaveInfoDTO.setStartTimeQuantum(yearRequestForLeaveInfo.getStartTimeQuantum());
-                yearRequestForLeaveInfoDTO.setEndTime(DateUtil.format(yearRequestForLeaveInfo.getEndTime(),"yyyy-MM-dd"));
+                yearRequestForLeaveInfoDTO.setEndTime(DateUtil.format(yearRequestForLeaveInfo.getEndTime(), "yyyy-MM-dd"));
                 yearRequestForLeaveInfoDTO.setEndTimeQuantum(yearRequestForLeaveInfo.getEndTimeQuantum());
-                if (yearRequestForLeaveInfoDTO.getStatus() == 0){
+                if (yearRequestForLeaveInfoDTO.getStatus() == 0) {
                     yearRequestForLeaveInfoDTO.setMergeStatus("0");
                     yearRequestForLeaveInfoDTO.setMergeStatusN("年假待审核");
                 }
-                if (yearRequestForLeaveInfoDTO.getStatus() == 3){
+                if (yearRequestForLeaveInfoDTO.getStatus() == 3) {
                     yearRequestForLeaveInfoDTO.setMergeStatus("3");
                     yearRequestForLeaveInfoDTO.setMergeStatusN("年假已拒绝");
                 }
@@ -167,12 +169,12 @@ public class YearRequestForLeaveInfoApiController {
             @ApiImplicitParam(name = "activityId", value = "步骤id", required = true, paramType = "form"),
             @ApiImplicitParam(name = "draft", value = "状态(0:草稿,1:提交)", required = true, paramType = "form")
     })
-    public MessageResult<Map> submitYearRequest(String id,String draft,
-                                             String startTime, String endTime,
-                                             String startTimeQuantum,String endTimeQuantum,
-                                             String imageUrl,String reason,String days,
-                                             String formId,String activityId,
-                                             String token, @RequestAttribute String subject) {
+    public MessageResult<Map> submitYearRequest(String id, String draft,
+                                                String startTime, String endTime,
+                                                String startTimeQuantum, String endTimeQuantum,
+                                                String imageUrl, String reason, String days,
+                                                String formId, String activityId,
+                                                String token, @RequestAttribute String subject) {
         MessageResult<Map> msgResult = new MessageResult<>();
 
         try {
@@ -186,7 +188,18 @@ public class YearRequestForLeaveInfoApiController {
             PersonInfo person = personInfoService.get(Long.parseLong(subject));
             PersonPopedom personPopedom = personPopedomService.get(person.getPopedom());
 
-            String ide = yearRequestForLeaveInfoService.leaveSubmit(personPopedom,startTime,endTime, startTimeQuantum, endTimeQuantum, imageUrl,reason,days,formId,activityId,draft,id);
+            if (person.getWorkStatus().equals("3")) {
+                //正在出差中
+                throw new Exception("您的工作状态为出差,不能申请年假,请先结束出差再申请!");
+            }
+
+            boolean rs = yearRequestForLeaveInfoService.isHoliday(startTime, endTime);
+            if(rs){
+                //当前时间范围包含节假日
+                throw new Exception("当前日期范围包含节假日,不能申请年假,请重新选择!");
+            }
+
+            String ide = yearRequestForLeaveInfoService.leaveSubmit(personPopedom, startTime, endTime, startTimeQuantum, endTimeQuantum, imageUrl, reason, days, formId, activityId, draft, id);
 
 
             Map<String, Object> map = new HashMap<>();
@@ -260,7 +273,6 @@ public class YearRequestForLeaveInfoApiController {
             PersonPopedom personPopedom = personPopedomService.get(person.getPopedom());
 
 
-
             //主业务
             YearRequestForLeaveInfo yearRequestForLeaveInfo = yearRequestForLeaveInfoService.get(id);
 
@@ -271,31 +283,29 @@ public class YearRequestForLeaveInfoApiController {
 
             Map<String, Object> map = new HashMap<>();
             map.put("name", yearRequestForLeavePerson.getName());
-            map.put("faceImageUrl",yearRequestForLeavePerson.getFaceImageUrl());
+            map.put("faceImageUrl", yearRequestForLeavePerson.getFaceImageUrl());
             map.put("imageUrl", yearRequestForLeaveInfo.getImageUrl());
             map.put("status", yearRequestForLeaveInfo.getStatus());
             map.put("statusName", TypeNameUtil.getExamineTypeName(yearRequestForLeaveInfo.getStatus().toString()));
-            map.put("startTime", DateUtil.format(yearRequestForLeaveInfo.getStartTime(),"yyyy-MM-dd"));
-            map.put("startTimeQuantum",yearRequestForLeaveInfo.getStartTimeQuantum());
-            map.put("endTime",DateUtil.format(yearRequestForLeaveInfo.getEndTime(),"yyyy-MM-dd"));
-            map.put("endTimeQuantum",yearRequestForLeaveInfo.getEndTimeQuantum());
-            map.put("days",yearRequestForLeaveInfo.getDays());
-            map.put("reason",yearRequestForLeaveInfo.getReason());
-            map.put("createTime",DateUtil.format(yearRequestForLeaveInfo.getCreateTime(),"yyyy-MM-dd HH:mm"));
-
-
-            if (yearRequestForLeaveInfo.getStatus() == 0){
-                map.put("mergeStatus","0");
-                map.put("mergeStatusN","年假待审核");
+            map.put("startTime", DateUtil.format(yearRequestForLeaveInfo.getStartTime(), "yyyy-MM-dd"));
+            map.put("startTimeQuantum", yearRequestForLeaveInfo.getStartTimeQuantum());
+            map.put("endTime", DateUtil.format(yearRequestForLeaveInfo.getEndTime(), "yyyy-MM-dd"));
+            map.put("endTimeQuantum", yearRequestForLeaveInfo.getEndTimeQuantum());
+            map.put("days", yearRequestForLeaveInfo.getDays());
+            map.put("reason", yearRequestForLeaveInfo.getReason());
+            map.put("createTime", DateUtil.format(yearRequestForLeaveInfo.getCreateTime(), "yyyy-MM-dd HH:mm"));
+
+
+            if (yearRequestForLeaveInfo.getStatus() == 0) {
+                map.put("mergeStatus", "0");
+                map.put("mergeStatusN", "年假待审核");
             }
-            if (yearRequestForLeaveInfo.getStatus() == 3){
-                map.put("mergeStatus","3");
-                map.put("mergeStatusN","年假已拒绝");
+            if (yearRequestForLeaveInfo.getStatus() == 3) {
+                map.put("mergeStatus", "3");
+                map.put("mergeStatusN", "年假已拒绝");
             }
 
 
-
-
             messageResult.setData(map);
             messageResult.setCode(200);
             messageResult.setResult(true);
@@ -508,25 +518,25 @@ public class YearRequestForLeaveInfoApiController {
             PersonPopedom personPopedom = personPopedomService.get(person.getPopedom());
 
             Page<YearRequestForLeaveInfo> page = new Page<>();
-            if (type == 0){
-                Map<String,Object> searchParams = new HashMap<>();
-                searchParams.put("type","0");
-                searchParams.put("approvalPersonPopedomId",personPopedom.getId());
+            if (type == 0) {
+                Map<String, Object> searchParams = new HashMap<>();
+                searchParams.put("type", "0");
+                searchParams.put("approvalPersonPopedomId", personPopedom.getId());
                 List<Sort> sortList = new ArrayList<>();
-                sortList.add(new Sort("a.create_time","desc"));
-                page = yearRequestForLeaveInfoService.pageMobileSearch(searchParams,pageIndex,pageSize,true,sortList);
+                sortList.add(new Sort("a.create_time", "desc"));
+                page = yearRequestForLeaveInfoService.pageMobileSearch(searchParams, pageIndex, pageSize, true, sortList);
 
 
-            }else {
+            } else {
                 //操作人的公司
                 CompanyInfo companyInfo = companyInfoService.get(personPopedom.getCompanyId());
-                List<CompanyInfo> companyInfoList = companyInfoService.findAllCompanyByCode("%"+companyInfo.getId()+"%");
-                Map<String,Object> searchParams = new HashMap<>();
-                searchParams.put("type","1");
-                searchParams.put("inCompanyInfo",companyInfoList);
+                List<CompanyInfo> companyInfoList = companyInfoService.findAllCompanyByCode("%" + companyInfo.getId() + "%");
+                Map<String, Object> searchParams = new HashMap<>();
+                searchParams.put("type", "1");
+                searchParams.put("inCompanyInfo", companyInfoList);
                 List<Sort> sortList = new ArrayList<>();
-                sortList.add(new Sort("a.approved_time","desc"));
-                page = yearRequestForLeaveInfoService.pageMobileSearch(searchParams,pageIndex,pageSize,true,sortList);
+                sortList.add(new Sort("a.approved_time", "desc"));
+                page = yearRequestForLeaveInfoService.pageMobileSearch(searchParams, pageIndex, pageSize, true, sortList);
             }
 
             /*List<PersonRoleInfo> personRoleInfoList = personRoleInfoService.findParentId(personPopedom.getPersonRoleId());