liupeng 4 rokov pred
rodič
commit
f192ceb406

+ 33 - 0
code/sapparent/sapservice/src/main/java/org/fouram/core/util/DateUtil.java

@@ -480,4 +480,37 @@ public class DateUtil {
 		StringUtils.strip(list.toString(), "[]");// 去掉符号[]
 		return list;
 	}
+
+	public static String secToTime(int time) {
+		String timeStr = null;
+		int hour = 0;
+		int minute = 0;
+		int second = 0;
+		if (time <= 0)
+			return "00:00";
+		else {
+			minute = time / 60;
+			if (minute < 60) {
+				second = time % 60;
+				timeStr = unitFormat(minute) + ":" + unitFormat(second);
+			} else {
+				hour = minute / 60;
+				if (hour > 99)
+					return "99:59:59";
+				minute = minute % 60;
+				second = time - hour * 3600 - minute * 60;
+				timeStr = unitFormat(hour) + ":" + unitFormat(minute);
+			}
+		}
+		return timeStr;
+	}
+
+	private static String unitFormat(int i) {
+		String retStr = null;
+		if (i >= 0 && i < 10)
+			retStr = "0" + Integer.toString(i);
+		else
+			retStr = "" + i;
+		return retStr;
+	}
 }

+ 14 - 2
code/sapparent/sapservice/src/main/java/org/fouram/mapper/SapCheckMapper.xml

@@ -57,9 +57,9 @@
 		delete from sap_check_report where checkinDay >= #{startDay} and checkinDay &lt;= #{endDay}
 	</update>
 	<insert id="saveCheckReport">
-		insert into sap_check_report(userId,groupName,workTime,offWorkTime,name,checkinDay,checkinDate,checkinException,checkoffDate,checkoffException,
+		insert into sap_check_report(userId,groupName,name,checkinDay,checkinDate,checkinException,checkoffDate,checkoffException,
 			checkoutDate1,checkoutDate2,leaveCreatedTime,leaveStartDate,leaveEndDate,leaveDay,leaveComment,bukaDay,result)
-		select a.userId,c.groupName,'9:30','18:30',a.`name`,b.checkinDay, c.checkinDate as checkinDate,c.exceptionType as checkinException,
+		select a.userId,c.groupName,a.`name`,b.checkinDay, c.checkinDate as checkinDate,c.exceptionType as checkinException,
 			d.checkinDate as checkoffDate,d.exceptionType as checkoffException,e.checkinDate as checkoutDate1,g.checkinDate as checkoutDate2,
 			f.createdDateTime as leaveCreatedTime, f.startDate as leaveStartDate,
 			f.endDate as leaveEndDate,f.deductionQuantity as leaveDay,f.`comment` as leaveComment, m.`day` as bukaDay, '正常' as result
@@ -76,6 +76,18 @@
 		order by a.userId ASC, b.checkinDay asc;
 	</insert>
 	
+	<update id="updateWorkTime">
+		update sap_check_report a, sap_checkin_option b 
+		set a.workTime = b.workTime 
+		where a.userId = b.userId and a.workTime is null
+	</update>
+	
+	<update id="updateOffWorkTime">
+		update sap_check_report a, sap_checkin_option b 
+		set a.offWorkTime = b.offWorkTime 
+		where a.userId = b.userId and a.offWorkTime is null
+	</update>
+	
 	<update id="updateNoNeedOffwork">
 		update sap_check_report a, sap_checkin_option b 
 		set a.noNeedOffwork = b.noNeedOffwork 

+ 4 - 2
code/sapparent/sapservice/src/main/java/org/fouram/service/WxCheckOptionService.java

@@ -35,12 +35,14 @@ public class WxCheckOptionService extends BaseService {
 				if (option.getGroup() != null && !checkinDate.isEmpty()
 						&& checkinDate.get(0).getCheckinTime().length > 0) {
 					SapCheckOption check = selectByUserId(option.getUserId());
-					if(check == null) {
+					if (check == null) {
 						check = new SapCheckOption();
 						CheckinTime checkinTime = checkinDate.get(0).getCheckinTime()[0];
 						check.setUserId(option.getUserId());
 						check.setWorkSec(checkinTime.getWorkSec());
+						check.setWorkTime(DateUtil.secToTime(check.getWorkSec().intValue()));
 						check.setOffWorkSec(checkinTime.getOffWorkSec());
+						check.setWorkTime(DateUtil.secToTime(check.getOffWorkSec().intValue()));
 						check.setNoNeedOffwork(checkinDate.get(0).getNoNeedOffwork());
 						save(check);
 					}
@@ -52,7 +54,7 @@ public class WxCheckOptionService extends BaseService {
 	public void save(SapCheckOption check) throws Exception {
 		save("SapCheckOptionMapper.save", check);
 	}
-	
+
 	public SapCheckOption selectByUserId(String userId) throws Exception {
 		return (SapCheckOption) findObject("SapCheckOptionMapper.selectByUserId", userId);
 	}

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

@@ -148,6 +148,9 @@ public class WxCheckService extends BaseService {
 		param.put("startDayT", startDay.replace("-", ""));
 		param.put("endDayT", endDay.replace("-", ""));
 		
+		// 更新打卡规则时间
+		update("SapCheckMapper.updateWorkTime", null);
+		update("SapCheckMapper.updateOffWorkTime", null);
 		// 更新noNeedOffwork
 		update("SapCheckMapper.updateNoNeedOffwork", null);
 		update("SapCheckMapper.updateNoNeedOffworkDefault", null);