liupeng 3 jaren geleden
bovenliggende
commit
312bb053c4

+ 3 - 3
code/sapparent/sapcms/src/main/java/org/fouram/controller/ReportController.java

@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 
 @Controller
@@ -30,9 +31,8 @@ public class ReportController extends BaseController {
 	 */
 	@GetMapping(value = "/saveReportData", produces = "application/json;charset=utf-8")
 	@ResponseBody
-	public Object saveReportData() {
+	public Object saveReportData(@RequestParam("checkinDay") String checkinDay) {
 		try {
-			String checkinDay = getPageData().getString("checkinDay");
 			if (StringUtils.isBlank(checkinDay)) {
 				return AppUtil.error("参数checkinDay为空");
 			}
@@ -82,7 +82,7 @@ public class ReportController extends BaseController {
 			if (StringUtils.isBlank(checkinDay)) {
 				return AppUtil.error("参数checkinDay为空");
 			}
-			wxCheckService.updateReportResultData(checkinDay, checkinDay);
+			wxCheckService.updateReportResultData(checkinDay);
 			return AppUtil.success();
 		} catch (Exception e) {
 			LoggerUtil.error(e);

+ 16 - 1
code/sapparent/sapservice/src/main/java/org/fouram/core/util/DateUtil.java

@@ -190,6 +190,16 @@ public class DateUtil {
 
 		return dateStr;
 	}
+	
+	public static String getAfterDay(Date date, int daysInt) {
+		Calendar canlendar = Calendar.getInstance();
+		canlendar.setTime(date);
+		canlendar.add(5, daysInt);
+
+		SimpleDateFormat sdfd = new SimpleDateFormat("yyyy-MM-dd");
+		String dateStr = sdfd.format(canlendar.getTime());
+		return dateStr;
+	}
 
 	public static String getAfterDay(int daysInt) {
 		Calendar canlendar = Calendar.getInstance();
@@ -312,7 +322,12 @@ public class DateUtil {
 	}
 
 	public static void main(String[] args) throws Exception {
-		System.out.println(getSubDateList(getAfterDay(-31), getDay()));
+		String checkinDay = "2021-03-03";
+		Date startDate = DateUtil.sdfTime.parse(checkinDay + " 03:00:00");
+		String nextDay = DateUtil.getAfterDay(startDate, 1);
+		Date endDate = DateUtil.sdfTime.parse(nextDay + " 03:00:00");
+		System.out.println(startDate);
+		System.out.println(endDate);
 	}
 
 	// 根据开始日期 增加 月份后 算出 日期(yyyy-mm)

+ 7 - 9
code/sapparent/sapservice/src/main/java/org/fouram/job/CheckTaskSchedule.java

@@ -68,33 +68,31 @@ public class CheckTaskSchedule {
 
 	@Transactional
 	public void executeBiz(String checkinDay) throws Exception {
-		String startDay = checkinDay;
-		String endDay = checkinDay;
 		wxDepartService.saveWxDeparts();
 		wxUserService.saveWxUsers();
 		sapUserService.saveOrUpdateSapUsers();
 		wxUserService.updateAllSapUserId();
-		wxCheckService.saveCheckInOffOuts(startDay, endDay);
+		wxCheckService.saveCheckInOffOuts(checkinDay);
 		// 判断打卡记录小于10条记录认为是假期
 		int checkInTotal = wxCheckService.queryCheckInTotal().intValue();
 		if (checkInTotal < 10) {
 			return;
 		}
-		sapCheckdateService.saveCheckdate(startDay);
+		sapCheckdateService.saveCheckdate(checkinDay);
 		employeeTimeService.saveEmployeeTimes();
-		wxCheckOptionService.saveOptions(endDay);
-		wxApprovalInfoService.saveApprovalInfos(endDay.substring(0, 7));
+		wxCheckOptionService.saveOptions(checkinDay);
+		wxApprovalInfoService.saveApprovalInfos(checkinDay.substring(0, 7));
 		boolean specialCheckinDay = false;
 		// 判断小于50条为特殊日期,比如周六有的部分需要上班的,只针对他们生成打卡记录
 		if (checkInTotal < 50) {
 			specialCheckinDay = true;
 		}
-		wxCheckService.saveReportResultData(startDay, endDay, specialCheckinDay);
-		wxCheckService.updateReportResultData(startDay, endDay);
+		wxCheckService.saveReportResultData(checkinDay, specialCheckinDay);
+		wxCheckService.updateReportResultData(checkinDay);
 	}
 	
 	@Transactional
 	public void reloadBiz(String checkinDay) throws Exception {
-		wxCheckService.updateReportResultData(checkinDay, checkinDay);
+		wxCheckService.updateReportResultData(checkinDay);
 	}
 }

+ 15 - 15
code/sapparent/sapservice/src/main/java/org/fouram/service/WxCheckService.java

@@ -24,14 +24,15 @@ public class WxCheckService extends BaseService {
 	@Autowired
 	private WxUserService wxUserService;
 
-	public void saveCheckInOffOuts(String startDay, String endDay) throws Exception {
+	public void saveCheckInOffOuts(String checkinDay) throws Exception {
 		// 重新生成制定日期范围内的打卡数据
 		update("SapCheckMapper.deleteCheckinList", null);
 		update("SapCheckMapper.deleteCheckoffList", null);
 		update("SapCheckMapper.deleteCheckoutList", null);
 
-		Date startDate = DateUtil.sdfTime.parse(startDay + " 00:00:00");
-		Date endDate = DateUtil.sdfTime.parse(endDay + " 23:59:59");
+		Date startDate = DateUtil.sdfTime.parse(checkinDay + " 03:00:00");
+		String nextDay = DateUtil.getAfterDay(startDate, 1);
+		Date endDate = DateUtil.sdfTime.parse(nextDay + " 03:00:00");
 
 		List<String> userIds = wxUserService.selectAllUserIds();
 		Map<String, List<String>> map = groupList(userIds, 100);
@@ -127,18 +128,17 @@ public class WxCheckService extends BaseService {
 
 	/**
 	 * 当天数据再次执行清空
-	 * @param startDay
-	 * @param endDay
+	 * @param checkinDay
 	 * @param specialCheckinDay
 	 * @throws Exception
 	 */
-	public void saveReportResultData(String startDay, String endDay, boolean specialCheckinDay) throws Exception {
+	public void saveReportResultData(String checkinDay, boolean specialCheckinDay) throws Exception {
 		Map<String, Object> param = Maps.newHashMap();
 		param.put("hour", "");
-		param.put("startDay", startDay);
-		param.put("endDay", endDay);
-		param.put("startDayT", startDay.replace("-", ""));
-		param.put("endDayT", endDay.replace("-", ""));
+		param.put("startDay", checkinDay);
+		param.put("endDay", checkinDay);
+		param.put("startDayT", checkinDay.replace("-", ""));
+		param.put("endDayT", checkinDay.replace("-", ""));
 		param.put("specialCheckinDay", specialCheckinDay);
 
 		// 生成报表数据
@@ -158,13 +158,13 @@ public class WxCheckService extends BaseService {
 		update("SapCheckMapper.updateCheckoffNullException", param);
 	}
 
-	public void updateReportResultData(String startDay, String endDay) throws Exception {
+	public void updateReportResultData(String checkinDay) throws Exception {
 		Map<String, String> param = Maps.newHashMap();
 		param.put("hour", "");
-		param.put("startDay", startDay);
-		param.put("endDay", endDay);
-		param.put("startDayT", startDay.replace("-", ""));
-		param.put("endDayT", endDay.replace("-", ""));
+		param.put("startDay", checkinDay);
+		param.put("endDay", checkinDay);
+		param.put("startDayT", checkinDay.replace("-", ""));
+		param.put("endDayT", checkinDay.replace("-", ""));
 		
 		// 更新补卡日期
 		update("SapCheckMapper.updateBuKaDay", param);