liupeng 4 rokov pred
rodič
commit
e42cc3aaa3

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

@@ -69,7 +69,7 @@
 		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
 		LEFT JOIN sap_checkout_end g on a.userId = g.userId and b.checkinDay = g.checkinDay
-		LEFT JOIN sap_employee_time f on a.userId = f.userId and b.checkinDay = f.startDate and f.approvalStatus = 'APPROVED'
+		LEFT JOIN sap_employee_time f on a.userId = f.userId and b.checkinDay = f.startDate and f.approvalStatus = 'APPROVED' and f.delFlag=0
 		LEFT JOIN sap_approval_info m on a.userId = m.userId and b.checkinDay = m.`day`
 		where EXISTS (SELECT 1 from sap_checkin_option o where a.userId = o.userId)
 		order by a.userId ASC, b.checkinDay asc;

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

@@ -27,4 +27,15 @@
 			#{originalQuantityInDays}
 		)
 	</insert>
+	
+	<select id="selectRepeat" resultType="SapEmployeeTime">
+		SELECT a.* from sap_employee_time a, (SELECT userId, startDate 
+			from sap_employee_time where delFlag=0 GROUP BY userId, startDate having count(1) > 1) b
+		where a.delFlag=0 and a.userId = b.userId and a.startDate = b.startDate 
+		order by a.userId,a.startDate;
+	</select>
+	
+	<update id="updateDelete">
+		update sap_employee_time set delFlag=1 where externalCode=#{externalCode}
+	</update>
 </mapper>

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

@@ -13,6 +13,7 @@ import org.fouram.core.util.DateUtil;
 import org.fouram.core.util.Tools;
 import org.fouram.entity.SapCheck;
 import org.fouram.entity.SapCheckReport;
+import org.fouram.entity.SapEmployeeTime;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -119,6 +120,16 @@ public class SapCheckService extends BaseService {
 				update("SapCheckMapper.deleteCheckoutEnd", sapCheck);
 			}
 		}
+		
+		List<SapEmployeeTime> employeeTimes = (List<SapEmployeeTime>) findList("SapEmployeeTimeMapper.selectRepeat", null);
+		checkinDays = Sets.newHashSet();
+		for (SapEmployeeTime sapCheck : employeeTimes) {
+			if (!checkinDays.contains(sapCheck.getStartDate() + sapCheck.getUserId())) {
+				checkinDays.add(sapCheck.getStartDate() + sapCheck.getUserId());
+			} else {
+				update("SapEmployeeTimeMapper.updateDelete", sapCheck);
+			}
+		}
 	}
 
 	@SuppressWarnings("unchecked")