liupeng 4 年 前
コミット
2f8cd862b1

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

@@ -1,5 +1,6 @@
 package org.fouram.controller;
 
+import org.apache.commons.lang3.StringUtils;
 import org.fouram.core.base.controller.BaseController;
 import org.fouram.core.util.AppUtil;
 import org.fouram.core.util.AppUtil.ResultConstant;
@@ -33,7 +34,7 @@ public class ReportController extends BaseController {
 	private SapApprovalInfoService sapApprovalInfoService;
 
 	/**
-	 * http://localhost:8080/sapcms/report/initReport
+	 * http://localhost:8080/sapcms/report/initReport?startDay=2020-05-11&endDay=2020-05-15
 	 * 
 	 * @return
 	 */
@@ -41,8 +42,14 @@ public class ReportController extends BaseController {
 	@ResponseBody
 	public Object initReport() {
 		try {
-			String startDay = "2020-05-11";
-			String endDay = "2020-05-15";
+			String startDay = getPageData().getString("startDay");
+			String endDay = getPageData().getString("endDay");
+			if(StringUtils.isBlank(startDay)) {
+				return AppUtil.error("参数startDay为空");
+			}
+			if(StringUtils.isBlank(endDay)) {
+				return AppUtil.error("参数endDay为空");
+			}
 			wxDepartService.saveDeparts();
 			wxUserService.saveUsers();
 			sapCheckService.saveCheckInOffOuts(startDay, endDay);
@@ -57,7 +64,7 @@ public class ReportController extends BaseController {
 	}
 	
 	/**
-	 * http://localhost:8080/sapcms/report/saveReport
+	 * http://localhost:8080/sapcms/report/saveReport?startDay=2020-05-11&endDay=2020-05-15
 	 * 
 	 * @return
 	 */
@@ -65,8 +72,14 @@ public class ReportController extends BaseController {
 	@ResponseBody
 	public Object saveReport() {
 		try {
-			String startDay = "2020-05-11";
-			String endDay = "2020-05-15";
+			String startDay = getPageData().getString("startDay");
+			String endDay = getPageData().getString("endDay");
+			if(StringUtils.isBlank(startDay)) {
+				return AppUtil.error("参数startDay为空");
+			}
+			if(StringUtils.isBlank(endDay)) {
+				return AppUtil.error("参数endDay为空");
+			}
 			sapCheckService.updateReportBaseData(startDay, endDay);
 			sapCheckService.saveReportResultData(startDay, endDay);
 			return AppUtil.success();

+ 15 - 16
code/sapparent/sapservice/src/main/java/org/fouram/mapper/SapCheckMapper.xml

@@ -74,18 +74,15 @@
 		where EXISTS (SELECT 1 from sap_checkin_option o where a.userId = o.userId)
 		order by a.userId ASC, b.checkinDay asc;
 	</insert>
-	<update id="dropCheckReportUser">
-		drop table if exists sap_check_report_${startDayT}_${endDayT}
-	</update>
-	<insert id="saveCheckReportUser">
-		create table sap_check_report_${startDayT}_${endDayT}
+	<select id="selectReportDayList" resultType="Map">
 		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 
+		from sap_check_report a, sap_checkdate b 
+		where b.weekday = 1 and a.checkinDay=b.checkinDay 
 		where a.checkinDay >= #{startDay} and a.checkinDay &lt;= #{endDay}
 		group by a.userId, a.name;
 	</insert>
@@ -145,36 +142,38 @@
 		where a.userId = b.userId and a.checkinDay = b.checkinDay order by a.exceptionType, a.checkinDate;
 	</select>
 	
-	<update id="deleteCheckin">
+	<update id="deleteCheckinById">
 		delete from sap_checkin where id = #{id}
 	</update>
 	
-	<update id="deleteCheckoff">
+	<update id="deleteCheckoffById">
 		delete from sap_checkoff where id = #{id}
 	</update>
 	
-	<update id="deleteCheckoutStart">
+	<update id="deleteCheckoutStartById">
 		delete from sap_checkout_start where id = #{id}
 	</update>
 	
-	<update id="deleteCheckoutEnd">
+	<update id="deleteCheckoutEndById">
 		delete from sap_checkout_end where id = #{id}
 	</update>
 	
 	<select id="findUserReports" resultType="Map">
-		SELECT a.* from sap_check_report a where 1=1 
+		SELECT a.*,c.firstDepartName,c.secondDepartName 
+		from sap_check_report a, sap_checkdate b, wx_user c 
+		where b.weekday = 1 and a.checkinDay=b.checkinDay and a.userId = c.userId
 		<if test="departId != null and departId != ''">
-			and (firstDepartId=#{departId} or secondDepartId=#{departId})
+			and (a.firstDepartId=#{departId} or a.secondDepartId=#{departId})
 		</if>
 		<if test="startDate != null and startDate != ''">
-			and checkinDay >= #{startDate} 
+			and a.checkinDay >= #{startDate} 
 		</if>
 		<if test="endDate != null and endDate != ''">
-			and checkinDay &lt;= #{endDate} 
+			and a.checkinDay &lt;= #{endDate} 
 		</if>
 		<if test="name != null and name != ''">
-			and name like CONCAT(CONCAT('%', #{name}),'%')
+			and a.name like CONCAT(CONCAT('%', #{name}),'%')
 		</if>
-		order by userId, checkinDay 
+		order by a.userId, a.checkinDay 
 	</select>
 </mapper>

+ 1 - 1
code/sapparent/sapservice/src/main/java/org/fouram/mapper/SapEmployeeTimeMapper.xml

@@ -35,7 +35,7 @@
 		order by a.userId,a.startDate;
 	</select>
 	
-	<update id="updateDelete">
+	<update id="updateDeleteByCode">
 		update sap_employee_time set delFlag=1 where externalCode=#{externalCode}
 	</update>
 </mapper>

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

@@ -87,7 +87,7 @@ public class SapCheckService extends BaseService {
 			if (!checkinDays.contains(sapCheck.getCheckinDay() + sapCheck.getUserId())) {
 				checkinDays.add(sapCheck.getCheckinDay() + sapCheck.getUserId());
 			} else {
-				update("SapCheckMapper.deleteCheckin", sapCheck);
+				update("SapCheckMapper.deleteCheckinById", sapCheck);
 			}
 		}
 
@@ -97,7 +97,7 @@ public class SapCheckService extends BaseService {
 			if (!checkinDays.contains(sapCheck.getCheckinDay() + sapCheck.getUserId())) {
 				checkinDays.add(sapCheck.getCheckinDay() + sapCheck.getUserId());
 			} else {
-				update("SapCheckMapper.deleteCheckoff", sapCheck);
+				update("SapCheckMapper.deleteCheckoffById", sapCheck);
 			}
 		}
 
@@ -107,7 +107,7 @@ public class SapCheckService extends BaseService {
 			if (!checkinDays.contains(sapCheck.getCheckinDay() + sapCheck.getUserId())) {
 				checkinDays.add(sapCheck.getCheckinDay() + sapCheck.getUserId());
 			} else {
-				update("SapCheckMapper.deleteCheckoutStart", sapCheck);
+				update("SapCheckMapper.deleteCheckoutStartById", sapCheck);
 			}
 		}
 
@@ -117,7 +117,7 @@ public class SapCheckService extends BaseService {
 			if (!checkinDays.contains(sapCheck.getCheckinDay() + sapCheck.getUserId())) {
 				checkinDays.add(sapCheck.getCheckinDay() + sapCheck.getUserId());
 			} else {
-				update("SapCheckMapper.deleteCheckoutEnd", sapCheck);
+				update("SapCheckMapper.deleteCheckoutEndById", sapCheck);
 			}
 		}
 		
@@ -127,7 +127,7 @@ public class SapCheckService extends BaseService {
 			if (!checkinDays.contains(sapCheck.getStartDate() + sapCheck.getUserId())) {
 				checkinDays.add(sapCheck.getStartDate() + sapCheck.getUserId());
 			} else {
-				update("SapEmployeeTimeMapper.updateDelete", sapCheck);
+				update("SapEmployeeTimeMapper.updateDeleteByCode", sapCheck);
 			}
 		}
 	}