liupeng 4 years ago
parent
commit
2180b56d6c

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

@@ -69,8 +69,8 @@
 		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 b.checkinDay <= f.endDate 
-			and f.approvalStatus = 'APPROVED' and f.delFlag=0
+		LEFT JOIN sap_employee_time f on (a.userId = f.userId or a.sapUserId = f.userId) and b.checkinDay >= f.startDate 
+			and b.checkinDay <= f.endDate 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;

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

@@ -57,13 +57,16 @@
 		where userId=#{userId} and departId=#{departId}
 	</update>
 	
-	<update id="updateAllSapUserIds">
-		update wx_user a set a.sapUserIds = (
-			select GROUP_CONCAT(b.userId, ',') 
-			from sap_user b 
+	<update id="updateAllSapUserId">
+		update wx_user a set a.sapUserId = (
+			select b.userId from sap_user b 
 			where (a.userId = b.userId or a.userId = b.email 
 				or a.userId = b.username or a.userId = b.formatMobile) and a.name = b.name 
-			GROUP BY b.personId) 
-		where a.sapUserIds is null;
+			and b.isPrimary = 1) 
+		where a.sapUserId is null
 	</update>
+	
+	<select id="selectSapUserId" resultType="String">
+		SELECT sapUserId from wx_user where delFlag=0 and sapUserIds is not null
+	</select>
 </mapper>

+ 1 - 1
code/sapparent/sapservice/src/main/java/org/fouram/service/CheckTaskService.java

@@ -57,7 +57,7 @@ public class CheckTaskService {
 		LoggerUtil.info("saveWxUsers:" + DateUtil.getTime());
 		sapUserService.saveOrUpdateSapUsers();
 		LoggerUtil.info("saveOrUpdateSapUsers:" + DateUtil.getTime());
-		wxUserService.updateAllSapUserIds();
+		wxUserService.updateAllSapUserId();
 		LoggerUtil.info("updateAllSapUserIds:" + DateUtil.getTime());
 		wxCheckService.saveCheckInOffOuts(startDay, endDay);
 		LoggerUtil.info("saveCheckInOffOuts:" + DateUtil.getTime());

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

@@ -23,9 +23,9 @@ public class SapEmployeeTimeService extends BaseService {
 	@Autowired
 	private WxUserService wxUserService;
 
-	public String getUserIdList(List<String> sapUsers) {
+	public String getUserIdList(List<String> sapUserIds) {
 		String userIds = "";
-		for (String sapUser : sapUsers) {
+		for (String sapUser : sapUserIds) {
 			userIds += "'" + sapUser + "',";
 		}
 		return userIds;
@@ -33,8 +33,8 @@ public class SapEmployeeTimeService extends BaseService {
 
 	@SuppressWarnings("unchecked")
 	public void saveEmployeeTimes() throws Exception {
-		List<String> allUserIds = wxUserService.selectAllUserIds();
-		Map<String, List<String>> map = groupList(allUserIds, 25);
+		List<String> allSapUserIds = wxUserService.selectSapUserId();
+		Map<String, List<String>> map = groupList(allSapUserIds, 25);
 		String url = null;
 		for (String key : map.keySet()) {
 			System.out.println(getUserIdList(map.get(key)));

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

@@ -113,6 +113,11 @@ public class WxUserService extends BaseService {
 	public List<String> selectAllUserIds() throws Exception {
 		return (List<String>) findList("WxUserMapper.selectAllUserIds", null);
 	}
+	
+	@SuppressWarnings("unchecked")
+	public List<String> selectSapUserId() throws Exception {
+		return (List<String>) findList("WxUserMapper.selectSapUserId", null);
+	}
 
 	public String getFullDepartName(String userId) throws Exception {
 		List<WxUserDepart> wxUserDeparts = selectWxUserDepartsByUserId(userId);
@@ -129,7 +134,7 @@ public class WxUserService extends BaseService {
 		}
 	}
 
-	public void updateAllSapUserIds() throws Exception {
-		update("WxUserMapper.updateAllSapUserIds", null);
+	public void updateAllSapUserId() throws Exception {
+		update("WxUserMapper.updateAllSapUserId", null);
 	}
 }