liupeng 5 سال پیش
والد
کامیت
e7b490c6ad

+ 0 - 1
code/sapparent/sapservice/src/main/java/org/fouram/core/plugin/weixin/cp/util/WXCpDepartUtil.java

@@ -40,7 +40,6 @@ public class WXCpDepartUtil {
 	public static Map<String, Long> getChildDepartMap(Long id) throws WxErrorException {
 		Map<String, Long> map = Maps.newHashMap();
 		for (WxCpDepart depart : departService.list(id)) {
-			System.out.println(depart);
 			if (id.equals(depart.getParentId())) {
 				map.put(depart.getName(), depart.getId());
 			}

+ 2 - 2
code/sapparent/sapservice/src/main/java/org/fouram/entity/SapUser.java

@@ -50,8 +50,8 @@ public class SapUser implements Serializable {
 
 	public String toCompareString() {
 		StringBuilder sBuilder = new StringBuilder();
-		sBuilder.append(userId).append(personId).append(name).append(firstOrgName).append(secondOrgName)
-				.append(thirdOrgName).append(fourthOrgName).append(position).append(mobile).append(businessPhone)
+		sBuilder.append(userId).append(personId).append(name).append(firstOrgId).append(secondOrgId)
+				.append(thirdOrgId).append(fourthOrgId).append(position).append(mobile).append(businessPhone)
 				.append(gender).append(email).append(isPrimary);
 		return sBuilder.toString();
 	}

+ 10 - 4
code/sapparent/sapservice/src/main/java/org/fouram/mapper/SapUserMapper.xml

@@ -3,11 +3,15 @@
 <mapper namespace="SapUserMapper">
 	<insert id="saveOne">
 		insert into sap_user(userId,personId,username,name,
+			firstOrgId,secondOrgId,thirdOrgId,fourthOrgId,
 			firstOrgName,secondOrgName,thirdOrgName,fourthOrgName,
+			firstOrgWxDepartId,secondOrgWxDepartId,thirdOrgWxDepartId,fourthOrgWxDepartId,
 			position,formatPosition,mobile,formatMobile,businessPhone,formatBusinessPhone,gender,
 			email,formatEmail,isPrimary,delFlag,createDate) 
 		values (#{userId},#{personId},#{username},#{name},
+			#{firstOrgId},#{secondOrgId},#{thirdOrgId},#{fourthOrgId},
 			#{firstOrgName},#{secondOrgName},#{thirdOrgName},#{fourthOrgName},
+			#{firstOrgWxDepartId},#{secondOrgWxDepartId},#{thirdOrgWxDepartId},#{fourthOrgWxDepartId},
 			#{position},#{formatPosition},#{mobile},#{formatMobile},#{businessPhone},#{formatBusinessPhone},#{gender},
 			#{email},#{formatEmail},#{isPrimary},#{delFlag},#{createDate})
 	</insert>
@@ -15,10 +19,12 @@
 	<update id="updateOne">
 		update sap_user 
 		set username=#{username},name=#{name},personId=#{personId},
-			firstOrgId=#{firstOrgId},firstOrgName=#{firstOrgName},
-			secondOrgId=#{secondOrgId},secondOrgName=#{secondOrgName},
-			thirdOrgId=#{thirdOrgId},thirdOrgName=#{thirdOrgName},
-			fourthOrgId=#{fourthOrgId},fourthOrgName=#{fourthOrgName},
+			firstOrgId=#{firstOrgId},secondOrgId=#{secondOrgId},
+			thirdOrgId=#{thirdOrgId},fourthOrgId=#{fourthOrgId},
+			firstOrgName=#{firstOrgName},secondOrgName=#{secondOrgName},
+			thirdOrgName=#{thirdOrgName},fourthOrgName=#{fourthOrgName},
+			firstOrgWxDepartId=#{firstOrgWxDepartId},secondOrgWxDepartId=#{secondOrgWxDepartId},
+			thirdOrgWxDepartId=#{thirdOrgWxDepartId},fourthOrgWxDepartId=#{fourthOrgWxDepartId},
 			position=#{position},formatPosition=#{formatPosition},
 			mobile=#{mobile},formatMobile=#{formatMobile},
 			businessPhone=#{businessPhone},formatBusinessPhone=#{formatBusinessPhone},

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

@@ -120,7 +120,8 @@ public class SapOrgService extends BaseService {
 		return sapUsers;
 	}
 
-	public void updateAllWxDepartId() throws Exception {
+	public Map<String, Long> updateAllWxDepartId() throws Exception {
+		Map<String, Long> result = Maps.newHashMap();
 		List<SapOrg> firstOrgs = findListByParentId("0");
 		List<SapOrg> allOrgs = Lists.newArrayList();
 		for (SapOrg firstOrg : firstOrgs) {
@@ -148,8 +149,9 @@ public class SapOrgService extends BaseService {
 		
 		for(SapOrg org : allOrgs) {
 			updateWxDepartId(org);
+			result.put(org.getId(), org.getWxDepartId());
 		}
-		
+		return result;
 	}
 
 	@SuppressWarnings("unchecked")

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

@@ -1,6 +1,7 @@
 package org.fouram.service;
 
 import java.util.List;
+import java.util.Map;
 
 import org.fouram.core.base.service.BaseService;
 import org.fouram.core.util.DateUtil;
@@ -25,10 +26,14 @@ public class TaskService extends BaseService {
 			// 接口获取所有有效数据,保存或者更新delFlag=0
 			List<SapUser> getSapUsers = sapUserService.getSapUsers();
 
-			sapOrgService.updateAllWxDepartId();
+			Map<String, Long> orgWxDepartMap = sapOrgService.updateAllWxDepartId();
 
 			LoggerUtil.info("接口获取所有有效数据->" + getSapUsers.size());
 			for (SapUser sapUser : getSapUsers) {
+				sapUser.setFirstOrgWxDepartId(orgWxDepartMap.get(sapUser.getFirstOrgId()));
+				sapUser.setSecondOrgWxDepartId(orgWxDepartMap.get(sapUser.getSecondOrgId()));
+				sapUser.setThirdOrgWxDepartId(orgWxDepartMap.get(sapUser.getThirdOrgId()));
+				sapUser.setFourthOrgWxDepartId(orgWxDepartMap.get(sapUser.getFourthOrgId()));
 				SapUser sapUserDb = sapUserService.selectOne(sapUser.getUserId());
 				if (sapUserDb == null) {
 					sapUserService.saveOneAndSyncWX(sapUser);