liupeng 4 rokov pred
rodič
commit
f5af302f93

+ 8 - 22
code/sapparent/sapservice/src/main/java/org/fouram/mapper/SapCheckMapper.xml

@@ -108,30 +108,26 @@
 			and checkinDay >= #{startDay} and checkinDay <= #{endDay}
 	</update>
 
-	<update id="updateAllExceptionResult">
-		update sap_check_report set result = '异常' 
-		where (LENGTH(checkinException) > 0 or LENGTH(checkoffException) > 0) and result = '正常' 
-			and checkinDay >= #{startDay} and checkinDay &lt;= #{endDay}
-	</update>
-
 	<update id="updateResultOk">
 		update sap_check_report set result = '正常' 
 		where id = #{id}
 	</update>
 	
-	<update id="updateResultOkByAllBuKa">
+	<update id="updateBuKaDay">
 		update sap_check_report a, sap_approval_info b 
-		set a.result = '正常', a.bukaDay = b.`day`
-		where a.checkinDay = b.`day` and a.userId = b.userId and a.result = '异常'
+		set a.bukaDay = b.`day`
+		where a.checkinDay = b.`day` and a.userId = b.userId 
+			and a.checkinDay >= #{startDay} and a.checkinDay &lt;= #{endDay}
 	</update>
 	
-	<update id="updateResultOkByAllLeave">
+	<update id="updateLeaveTime">
 		update sap_check_report a ,sap_employee_time f 
-		SET a.result = '正常',a.leaveCreatedTime = f.createdDateTime, 
+		SET a.leaveCreatedTime = f.createdDateTime, 
 			a.leaveStartDate = f.startDate, a.leaveEndDate = f.endDate,
 			a.leaveDay = f.deductionQuantity, a.leaveComment =f.`comment`
 		where a.userId = f.userId and a.checkinDay >= f.startDate and a.checkinDay &lt;= f.endDate 
-			and f.approvalStatus = 'APPROVED' and f.delFlag=0 and a.result = '异常'
+			and f.approvalStatus = 'APPROVED' and f.delFlag=0 
+			and checkinDay >= #{startDay} and checkinDay &lt;= #{endDay}
 	</update>
 	
 	<update id="updateAllHour">
@@ -225,16 +221,6 @@
 		where workHours is null
 	</update>
 	
-	<select id="selectLeaveDayList" resultType="SapCheckReport">
-		SELECT * from sap_check_report where result = '异常' and leaveDay is not null 
-			and checkinDay >= #{startDay} and checkinDay &lt;= #{endDay}
-	</select>
-	
-	<select id="selectExceptionList" resultType="SapCheckReport">
-		SELECT * from sap_check_report where result = '异常' 
-			and checkinDay >= #{startDay} and checkinDay &lt;= #{endDay}
-	</select>
-	
 	<select id="selectRepeatCheckin" resultType="SapCheck">
 		SELECT a.* from sap_checkin a, (SELECT userId, checkinDay from sap_checkin GROUP BY userId, checkinDay having count(1) > 1) b
 		where a.userId = b.userId and a.checkinDay = b.checkinDay order by a.exceptionType, a.checkinDate;

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

@@ -5,13 +5,11 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.commons.lang3.StringUtils;
 import org.fouram.core.base.service.BaseService;
 import org.fouram.core.plugin.weixin.cp.util.WXCpOaUtil;
 import org.fouram.core.util.BeanUtils;
 import org.fouram.core.util.DateUtil;
 import org.fouram.entity.SapCheck;
-import org.fouram.entity.SapCheckReport;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -139,7 +137,6 @@ public class WxCheckService extends BaseService {
 		update("SapCheckMapper.saveCheckReport", param);
 	}
 
-	@SuppressWarnings("unchecked")
 	public void updateReportResultData(String startDay, String endDay, String hour) throws Exception {
 		Map<String, String> param = Maps.newHashMap();
 		param.put("hour", hour);
@@ -157,25 +154,10 @@ public class WxCheckService extends BaseService {
 		// 更新时间为空的为后台更新未打卡
 		update("SapCheckMapper.updateCheckinNullException", param);
 		update("SapCheckMapper.updateCheckoffNullException", param);
-		// 更新所有异常事件的数据为异常数据
-		update("SapCheckMapper.updateAllExceptionResult", param);
-		// 查询有请假情况的数据-更新为正常
-		List<SapCheckReport> checkReports = (List<SapCheckReport>) findList("SapCheckMapper.selectLeaveDayList", param);
-		for (SapCheckReport checkReport : checkReports) {
-			update("SapCheckMapper.updateResultOk", checkReport.getId());
-		}
-		// 上班和下班正常打卡一次或者有补卡符合一个条件-更新为正常
-		checkReports = (List<SapCheckReport>) findList("SapCheckMapper.selectExceptionList", param);
-		for (SapCheckReport checkReport : checkReports) {
-			if (isOkWorkTime(checkReport) || isOkOffWorkTime(checkReport)
-					|| StringUtils.isNotBlank(checkReport.getBukaDay())) {
-				update("SapCheckMapper.updateResultOk", checkReport.getId());
-			}
-		}
-		// 更新所有有补卡日期的记录为正常
-		update("SapCheckMapper.updateResultOkByAllBuKa", null);
-		// 查询有请假情况的数据-更新为正常
-		update("SapCheckMapper.updateResultOkByAllLeave", null);
+		// 更新补卡日期
+		update("SapCheckMapper.updateBuKaDay", param);
+		// 查询请假日期
+		update("SapCheckMapper.updateLeaveTime", param);
 		// 更新hour字段
 		update("SapCheckMapper.updateAllHour", param);
 		// 新增列:上班时间
@@ -206,44 +188,4 @@ public class WxCheckService extends BaseService {
 		update("SapCheckMapper.updateWorkMinsZero", null);
 		update("SapCheckMapper.updateWorkHours", null);
 	}
-
-	// 是不是正确的上班时间
-	private boolean isOkWorkTime(SapCheckReport checkReport) throws Exception {
-		if (StringUtils.isBlank(checkReport.getCheckinException())) {
-			return true;
-		}
-		if (StringUtils.isNotBlank(checkReport.getCheckoutDate1())) {
-			if (DateUtil.sdfTime.parse(checkReport.getCheckoutDate1()).getTime() <= DateUtil.sdfsTime
-					.parse(checkReport.getCheckinDay() + " " + checkReport.getWorkTime()).getTime()) {
-				return true;
-			}
-		}
-		if (StringUtils.isNotBlank(checkReport.getCheckoutDate2())) {
-			if (DateUtil.sdfTime.parse(checkReport.getCheckoutDate2()).getTime() <= DateUtil.sdfsTime
-					.parse(checkReport.getCheckinDay() + " " + checkReport.getWorkTime()).getTime()) {
-				return true;
-			}
-		}
-		return false;
-	}
-
-	// 是不是正确的下班时间
-	private boolean isOkOffWorkTime(SapCheckReport checkReport) throws Exception {
-		if (StringUtils.isBlank(checkReport.getCheckoffException())) {
-			return true;
-		}
-		if (StringUtils.isNotBlank(checkReport.getCheckoutDate1())) {
-			if (DateUtil.sdfTime.parse(checkReport.getCheckoutDate1()).getTime() >= DateUtil.sdfsTime
-					.parse(checkReport.getCheckinDay() + " " + checkReport.getWorkTime()).getTime()) {
-				return true;
-			}
-		}
-		if (StringUtils.isNotBlank(checkReport.getCheckoutDate2())) {
-			if (DateUtil.sdfTime.parse(checkReport.getCheckoutDate2()).getTime() >= DateUtil.sdfsTime
-					.parse(checkReport.getCheckinDay() + " " + checkReport.getOffWorkTime()).getTime()) {
-				return true;
-			}
-		}
-		return false;
-	}
 }