liupeng 4 年之前
父節點
當前提交
be2705f440

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

@@ -47,15 +47,15 @@ public class ReportController extends BaseController {
 			wxUserService.saveUsers();
 			sapCheckService.saveCheckInOffOuts(startDay, endDay);
 			employeeTimeService.saveEmployeeTimes();
-			sapCheckOptionService.saveOptions();
-			sapApprovalInfoService.saveApprovalInfos(endDay);
+			sapCheckOptionService.saveOptions(endDay);
+			sapApprovalInfoService.saveApprovalInfos(endDay.substring(0, 7));
 			return AppUtil.success();
 		} catch (Exception e) {
 			LoggerUtil.error(e);
 			return AppUtil.error(ResultConstant.WEB_ERR_MSG);
 		}
 	}
-
+	
 	/**
 	 * http://localhost:8080/sapcms/report/saveReport
 	 * 

+ 31 - 27
code/sapparent/sapservice/src/main/java/org/fouram/mapper/SapCheckMapper.xml

@@ -2,7 +2,7 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="SapCheckMapper">
 	<update id="deleteCheckinList">
-		delete from sap_checkin where checkinDay >= #{startDay} and checkinDay &lt;= #{endDay}
+		truncate table sap_checkin
 	</update>
 	<insert id="saveCheckin">
 		insert into sap_checkin(userId,groupName,checkinType,checkinDate,checkinDay,exceptionType,
@@ -11,7 +11,7 @@
 			#{checkinTime},#{locationTitle},#{locationDetail},#{wifiName},#{wifiMac})
 	</insert>
 	<update id="deleteCheckoffList">
-		delete from sap_checkoff where checkinDay >= #{startDay} and checkinDay &lt;= #{endDay}
+		truncate table sap_checkoff
 	</update>
 	<insert id="saveCheckoff">
 		insert into sap_checkoff(userId,groupName,checkinType,checkinDate,checkinDay,exceptionType,
@@ -20,7 +20,7 @@
 			#{checkinTime},#{locationTitle},#{locationDetail},#{wifiName},#{wifiMac})
 	</insert>
 	<update id="deleteCheckoutList">
-		delete from sap_checkout where checkinDay >= #{startDay} and checkinDay &lt;= #{endDay}
+		truncate table sap_checkout
 	</update>
 	<insert id="saveCheckout">
 		insert into sap_checkout(userId,groupName,checkinType,checkinDate,checkinDay,exceptionType,
@@ -28,34 +28,33 @@
 		values (#{userId},#{groupName},#{checkinType},#{checkinDate},#{checkinDay},#{exceptionType},
 			#{checkinTime},#{locationTitle},#{locationDetail},#{wifiName},#{wifiMac})
 	</insert>
-	<update id="deleteCheckoutStart">
-		delete from sap_checkout_start where checkinDay >= #{startDay} and checkinDay &lt;= #{endDay}
+	<update id="deleteCheckoutStartList">
+		truncate table sap_checkout_start
 	</update>
 	<insert id="saveCheckoutStart1">
 		insert into sap_checkout_start
 		SELECT a.* from sap_checkout a, (SELECT userId, checkinDay from sap_checkout GROUP BY userId, checkinDay having count(1) = 1) b
 		where a.userId = b.userId and a.checkinDay = b.checkinDay 
-			and checkinDay >= #{startDay} and checkinDay &lt;= #{endDay}
 	</insert>
 	<insert id="saveCheckoutStart2">
 		insert into sap_checkout_start
-		SELECT a.* from sap_checkout a, (SELECT userId, checkinDay,min(checkinDate) as checkinDate from sap_checkout GROUP BY userId, checkinDay having count(1) > 1) b
+		SELECT a.* from sap_checkout a, (SELECT userId, checkinDay,min(checkinDate) as checkinDate from sap_checkout
+			GROUP BY userId, checkinDay having count(1) > 1) b
 		where a.userId = b.userId and a.checkinDay = b.checkinDay and a.checkinDate = b.checkinDate 
-				and checkinDay >= #{startDay} and checkinDay &lt;= #{endDay}
 		ORDER BY a.userId, a.checkinDay, a.checkinDate;
 	</insert>
-	<update id="deleteCheckoutEnd">
-		delete from sap_checkout_end where checkinDay >= #{startDay} and checkinDay &lt;= #{endDay}
+	<update id="deleteCheckoutEndList">
+		truncate table sap_checkout_end
 	</update>
 	<insert id="saveCheckoutEnd">
 		insert into sap_checkout_end
-		SELECT a.* from sap_checkout a, (SELECT userId, checkinDay,max(checkinDate) as checkinDate from sap_checkout GROUP BY userId, checkinDay having count(1) > 1) b
+		SELECT a.* from sap_checkout a, (SELECT userId, checkinDay,max(checkinDate) as checkinDate from sap_checkout 
+			GROUP BY userId, checkinDay having count(1) > 1) b
 		where a.userId = b.userId and a.checkinDay = b.checkinDay and a.checkinDate = b.checkinDate 
-			and checkinDay >= #{startDay} and checkinDay &lt;= #{endDay}
 		ORDER BY a.userId, a.checkinDay, a.checkinDate;
 	</insert>
-	<update id="truncateCheckReport">
-		truncate table sap_check_report
+	<update id="deleteCheckReport">
+		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,
@@ -64,7 +63,8 @@
 			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
-		from wx_user a join sap_checkdate b on b.weekday = 1
+		from wx_user a join sap_checkdate b on b.weekday = 1 and a.delFlag=0 
+			and b.checkinDay >= #{startDay} and b.checkinDay &lt;= #{endDay}
 		LEFT JOIN sap_checkin c on a.userId = c.userId and b.checkinDay = c.checkinDay
 		LEFT JOIN sap_checkoff d on a.userId = d.userId and b.checkinDay = d.checkinDay
 		LEFT JOIN sap_checkout_start e on a.userId = e.userId and b.checkinDay = e.checkinDay
@@ -75,34 +75,40 @@
 		order by a.userId ASC, b.checkinDay asc;
 	</insert>
 	<update id="dropCheckReportUser">
-		drop table sap_check_report_user
+		drop table if exists sap_check_report_${startDayT}_${endDayT}
 	</update>
 	<insert id="saveCheckReportUser">
-		create table sap_check_report_user
+		create table sap_check_report_${startDayT}_${endDayT}
 		SELECT a.userId, a.name, 
 		replace(group_concat(case when a.checkinDay = '2020-05-11' then a.result else '' end ),',','') as '2020-05-11',
 		replace(group_concat(case when a.checkinDay = '2020-05-12' then a.result else '' end ),',','') as '2020-05-12',
 		replace(group_concat(case when a.checkinDay = '2020-05-13' then a.result else '' end ),',','') as '2020-05-13',
 		replace(group_concat(case when a.checkinDay = '2020-05-14' then a.result else '' end ),',','') as '2020-05-14',
 		replace(group_concat(case when a.checkinDay = '2020-05-15' then a.result else '' end ),',','') as '2020-05-15'
-		from sap_check_report a group by a.userId, a.name;
+		from sap_check_report a 
+		where a.checkinDay >= #{startDay} and a.checkinDay &lt;= #{endDay}
+		group by a.userId, a.name;
 	</insert>
 	
 	<update id="updateHrsdWorkTime">
-		update sap_check_report set workTime = '10:00' where groupName like '%华人时代%'
+		update sap_check_report set workTime = '10:00' where groupName like '%华人时代%' 
+			and checkinDay >= #{startDay} and checkinDay &lt;= #{endDay}
 	</update>
 
 	<update id="updateCheckinException">
-		update sap_check_report set checkinException = '未打卡后台更新' where checkinDate is null
+		update sap_check_report set checkinException = '未打卡后台更新' where checkinDate is null 
+			and checkinDay >= #{startDay} and checkinDay &lt;= #{endDay}
 	</update>
 	
 	<update id="updateCheckoffException">
 		update sap_check_report set checkoffException = '未打卡后台更新' where checkoffDate is null
+			and checkinDay >= #{startDay} and checkinDay &lt;= #{endDay}
 	</update>
 
 	<update id="updateAllExceptionResult">
 		update sap_check_report set result = '异常' 
-		where (LENGTH(checkinException) > 0 or LENGTH(checkoffException) > 0) and result = '正常'
+		where (LENGTH(checkinException) > 0 or LENGTH(checkoffException) > 0) and result = '正常' 
+			and checkinDay >= #{startDay} and checkinDay &lt;= #{endDay}
 	</update>
 
 	<update id="updateResultOk">
@@ -110,15 +116,13 @@
 	</update>
 	
 	<select id="selectLeaveDayList" resultType="SapCheckReport">
-		SELECT * from sap_check_report where result = '异常' and leaveDay is not null;
-	</select>
-	
-	<select id="selectCheckoutList" resultType="SapCheckReport">
-		SELECT * from sap_check_report where result = '异常' and checkoutDate1 is not null;
+		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 = '异常'
+		SELECT * from sap_check_report where result = '异常' 
+			and checkinDay >= #{startDay} and checkinDay &lt;= #{endDay}
 	</select>
 	
 	<select id="selectRepeatCheckin" resultType="SapCheck">

+ 6 - 2
code/sapparent/sapservice/src/main/java/org/fouram/mapper/WxUserMapper.xml

@@ -10,13 +10,17 @@
 		values (#{userId},#{name},#{departId},#{firstDepartName},#{secondDepartName},'0')
 	</insert>
 	
+	<update id="updateAllDelete">
+		update wx_user set delFlag=1
+	</update>
+	
 	<update id="update">
 		update wx_user 
-		set departId=#{departId},firstDepartName=#{firstDepartName},secondDepartName=#{secondDepartName}
+		set departId=#{departId},firstDepartName=#{firstDepartName},secondDepartName=#{secondDepartName},delFlag=0
 		where userId=#{userId}
 	</update>
 	
 	<select id="selectAllUserIds" resultType="String">
-		SELECT userId from wx_user
+		SELECT userId from wx_user where delFlag=0
 	</select>
 </mapper>

+ 2 - 3
code/sapparent/sapservice/src/main/java/org/fouram/service/SapApprovalInfoService.java

@@ -15,13 +15,12 @@ public class SapApprovalInfoService extends BaseService {
 	/**
 	 * 保存补卡记录
 	 * 
-	 * @param startDate
-	 * @param endDate
+	 * @param yearMonth
 	 * @throws Exception
 	 */
 	public void saveApprovalInfos(String yearMonth) throws Exception {
 		Date startDate = DateUtil.sdfTime.parse(yearMonth + "-01 00:00:00");
-		Date endDate = DateUtil.sdfTime.parse(DateUtil.getLastDay(yearMonth));
+		Date endDate = DateUtil.sdfTime.parse(DateUtil.getLastDay(yearMonth) + " 23:59:59");
 		List<SapApprovalInfo> approvalInfos = WXCpOaUtil.getApprovalDetailList(startDate, endDate);
 		for (SapApprovalInfo approvalInfo : approvalInfos) {
 			if (selectListByUserIdAndDay(approvalInfo).isEmpty()) {

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

@@ -22,11 +22,11 @@ public class SapCheckOptionService extends BaseService {
 	@Autowired
 	private WxUserService wxUserService;
 
-	public void saveOptions() throws Exception {
+	public void saveOptions(String endDay) throws Exception {
 		List<String> userIds = wxUserService.selectAllUserIds();
 		Map<String, List<String>> map = groupList(userIds);
 		List<Date> datetimes = Lists.newArrayList();
-		datetimes.add(DateUtil.sdfTime.parse("2020-05-07 00:00:00"));
+		datetimes.add(DateUtil.sdfTime.parse(endDay + " 00:00:00"));
 		for (String key : map.keySet()) {
 			List<WxCpCheckinOption> options = WXCpOaUtil.getCheckinOption(datetimes, map.get(key));
 			for (WxCpCheckinOption option : options) {

+ 23 - 23
code/sapparent/sapservice/src/main/java/org/fouram/service/SapCheckService.java

@@ -28,14 +28,10 @@ public class SapCheckService extends BaseService {
 	private WxUserService wxUserService;
 
 	public void saveCheckInOffOuts(String startDay, String endDay) throws Exception {
-		Map<String, String> param = Maps.newHashMap();
-		param.put("startDay", startDay);
-		param.put("endDay", endDay);
-
 		// 重新生成制定日期范围内的打卡数据
-		update("SapCheckMapper.deleteCheckinList", param);
-		update("SapCheckMapper.deleteCheckoffList", param);
-		update("SapCheckMapper.deleteCheckoutList", param);
+		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");
@@ -62,11 +58,11 @@ public class SapCheckService extends BaseService {
 		}
 
 		// 生成制定日期每天外出打开开始和结束时间
-		update("SapCheckMapper.deleteCheckoutStart", param);
-		update("SapCheckMapper.deleteCheckoutEnd", param);
-		update("SapCheckMapper.saveCheckoutStart1", param);
-		update("SapCheckMapper.saveCheckoutStart2", param);
-		update("SapCheckMapper.saveCheckoutEnd", param);
+		update("SapCheckMapper.deleteCheckoutStartList", null);
+		update("SapCheckMapper.deleteCheckoutEndList", null);
+		update("SapCheckMapper.saveCheckoutStart1", null);
+		update("SapCheckMapper.saveCheckoutStart2", null);
+		update("SapCheckMapper.saveCheckoutEnd", null);
 	}
 
 	public void saveCheckin(SapCheck check) throws Exception {
@@ -127,16 +123,22 @@ public class SapCheckService extends BaseService {
 
 	@SuppressWarnings("unchecked")
 	public void saveReportResultData(String startDay, String endDay) throws Exception {
+		Map<String, String> param = Maps.newHashMap();
+		param.put("startDay", startDay);
+		param.put("endDay", endDay);
+		param.put("startDayT", startDay.replace("-", ""));
+		param.put("endDayT", endDay.replace("-", ""));
+
 		// 生成报表数据
-		update("SapCheckMapper.truncateCheckReport", null);
-		update("SapCheckMapper.saveCheckReport", null);
+		update("SapCheckMapper.deleteCheckReport", param);
+		update("SapCheckMapper.saveCheckReport", param);
 		// 更新华人时代人员上班时间可以推迟30分钟
-		update("SapCheckMapper.updateHrsdWorkTime", null);
+		update("SapCheckMapper.updateHrsdWorkTime", param);
 		// 更新当前未打卡情况,未更新微信端应该是晚上才更新的
-		update("SapCheckMapper.updateCheckinException", null);
-		update("SapCheckMapper.updateCheckoffException", null);
+		update("SapCheckMapper.updateCheckinException", param);
+		update("SapCheckMapper.updateCheckoffException", param);
 		// 更新所有异常事件的数据为异常数据
-		update("SapCheckMapper.updateAllExceptionResult", null);
+		update("SapCheckMapper.updateAllExceptionResult", param);
 		// 查询有请假情况的数据
 		List<SapCheckReport> checkReports = (List<SapCheckReport>) findList("SapCheckMapper.selectLeaveDayList", null);
 		for (SapCheckReport checkReport : checkReports) {
@@ -150,18 +152,16 @@ public class SapCheckService extends BaseService {
 			}
 		}
 
-//		checkReports = (List<SapCheckReport>) findList("SapCheckMapper.selectCheckoutList", null);
 		checkReports = (List<SapCheckReport>) findList("SapCheckMapper.selectExceptionList", null);
 		for (SapCheckReport checkReport : checkReports) {
-			// TODO 由于刚开始使用微信打开,所以特殊处理下,上下班只要一个正常就算正常或者有补卡
 			if (isOkWorkTime(checkReport) || isOkOffWorkTime(checkReport)
 					|| StringUtils.isNotBlank(checkReport.getBukaDay())) {
 				update("SapCheckMapper.updateResultOk", checkReport.getId());
 			}
 		}
-		// 生成报表用户数据
-		update("SapCheckMapper.dropCheckReportUser", null);
-		update("SapCheckMapper.saveCheckReportUser", null);
+		
+		update("SapCheckMapper.dropCheckReportUser", param);
+		update("SapCheckMapper.saveCheckReportUser", param);
 	}
 
 	// 是不是正确的上班时间

+ 2 - 0
code/sapparent/sapservice/src/main/java/org/fouram/service/WxUserService.java

@@ -23,6 +23,8 @@ public class WxUserService extends BaseService {
 	private Map<Long, List<WxDepart>> userDepartMap = Maps.newHashMap();
 
 	public void saveUsers() throws Exception {
+		update("WxUserMapper.updateAllDelete", null);
+		
 		List<WxCpUser> users = WXCpUserUtil.listAllUser();
 		List<WxDepart> departs = null;
 		WxUser wxUser = null;

+ 1 - 0
code/sapparent/sapservice/src/main/resources/spring/shiro.xml

@@ -49,6 +49,7 @@
 				/*/*Anon = anon
 				/API/* = anon
 				/task/* = anon
+				/report/* = anon
 				/** = authc
 			</value>  
 		</property>