|
@@ -16,6 +16,7 @@ import org.springframework.http.HttpHeaders;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
|
+import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@@ -53,8 +54,7 @@ public class SapOrgService extends BaseService {
|
|
return (SapOrg) findObject("SapOrgMapper.selectOne", sapOrg);
|
|
return (SapOrg) findObject("SapOrgMapper.selectOne", sapOrg);
|
|
}
|
|
}
|
|
|
|
|
|
- private String saveOrUpdateSapOrg(String parentId, String sapCode, String sapName, String level)
|
|
|
|
- throws Exception {
|
|
|
|
|
|
+ private String saveOrUpdateSapOrg(String parentId, String sapCode, String sapName, String level) throws Exception {
|
|
SapOrg sapOrg = selectOne(parentId, sapCode, level);
|
|
SapOrg sapOrg = selectOne(parentId, sapCode, level);
|
|
if (sapOrg != null) {
|
|
if (sapOrg != null) {
|
|
sapOrg.setSapName(sapName);
|
|
sapOrg.setSapName(sapName);
|
|
@@ -119,39 +119,43 @@ public class SapOrgService extends BaseService {
|
|
}
|
|
}
|
|
return sapUsers;
|
|
return sapUsers;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void updateAllWxDepartId() throws Exception {
|
|
public void updateAllWxDepartId() throws Exception {
|
|
- Map<String, Long> map = Maps.newHashMap();
|
|
|
|
List<SapOrg> firstOrgs = findListByParentId("0");
|
|
List<SapOrg> firstOrgs = findListByParentId("0");
|
|
|
|
+ List<SapOrg> allOrgs = Lists.newArrayList();
|
|
for (SapOrg firstOrg : firstOrgs) {
|
|
for (SapOrg firstOrg : firstOrgs) {
|
|
- map.put(firstOrg.getId(),
|
|
|
|
- WXCpDepartUtil.createOrUpdate(firstOrg.getWxDepartId(), 1L, firstOrg.getSapName()));
|
|
|
|
|
|
+ firstOrg.setWxDepartId(WXCpDepartUtil.createOrUpdate(firstOrg.getWxDepartId(), 1L, firstOrg.getSapName()));
|
|
|
|
+ allOrgs.add(firstOrg);
|
|
List<SapOrg> sencodOrgs = findListByParentId(firstOrg.getParentId());
|
|
List<SapOrg> sencodOrgs = findListByParentId(firstOrg.getParentId());
|
|
for (SapOrg sencodOrg : sencodOrgs) {
|
|
for (SapOrg sencodOrg : sencodOrgs) {
|
|
- map.put(firstOrg.getId(), WXCpDepartUtil.createOrUpdate(sencodOrg.getWxDepartId(),
|
|
|
|
|
|
+ sencodOrg.setWxDepartId(WXCpDepartUtil.createOrUpdate(sencodOrg.getWxDepartId(),
|
|
firstOrg.getWxDepartId(), sencodOrg.getSapName()));
|
|
firstOrg.getWxDepartId(), sencodOrg.getSapName()));
|
|
|
|
+ allOrgs.add(sencodOrg);
|
|
List<SapOrg> thirdOrgs = findListByParentId(sencodOrg.getParentId());
|
|
List<SapOrg> thirdOrgs = findListByParentId(sencodOrg.getParentId());
|
|
for (SapOrg thirdOrg : thirdOrgs) {
|
|
for (SapOrg thirdOrg : thirdOrgs) {
|
|
- map.put(firstOrg.getId(), WXCpDepartUtil.createOrUpdate(thirdOrg.getWxDepartId(),
|
|
|
|
|
|
+ thirdOrg.setWxDepartId(WXCpDepartUtil.createOrUpdate(thirdOrg.getWxDepartId(),
|
|
sencodOrg.getWxDepartId(), thirdOrg.getSapName()));
|
|
sencodOrg.getWxDepartId(), thirdOrg.getSapName()));
|
|
|
|
+ allOrgs.add(thirdOrg);
|
|
List<SapOrg> fourthOrgs = findListByParentId(thirdOrg.getParentId());
|
|
List<SapOrg> fourthOrgs = findListByParentId(thirdOrg.getParentId());
|
|
for (SapOrg fourthOrg : fourthOrgs) {
|
|
for (SapOrg fourthOrg : fourthOrgs) {
|
|
- map.put(firstOrg.getId(), WXCpDepartUtil.createOrUpdate(fourthOrg.getWxDepartId(),
|
|
|
|
|
|
+ fourthOrg.setWxDepartId(WXCpDepartUtil.createOrUpdate(fourthOrg.getWxDepartId(),
|
|
thirdOrg.getWxDepartId(), fourthOrg.getSapName()));
|
|
thirdOrg.getWxDepartId(), fourthOrg.getSapName()));
|
|
|
|
+ allOrgs.add(fourthOrg);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- List<SapOrg> orgs = findListByParentId(null);
|
|
|
|
- for(SapOrg org : orgs) {
|
|
|
|
- org.setWxDepartId(map.get(org.getId()));
|
|
|
|
|
|
+
|
|
|
|
+ for(SapOrg org : allOrgs) {
|
|
updateWxDepartId(org);
|
|
updateWxDepartId(org);
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@SuppressWarnings("unchecked")
|
|
public List<SapOrg> findListByParentId(String parentId) throws Exception {
|
|
public List<SapOrg> findListByParentId(String parentId) throws Exception {
|
|
- return (List<SapOrg>) findList("SapOrgMapper.findListByParentId", parentId);
|
|
|
|
|
|
+ SapOrg org = SapOrg.builder().parentId(parentId).build();
|
|
|
|
+ return (List<SapOrg>) findList("SapOrgMapper.findListByParentId", org);
|
|
}
|
|
}
|
|
|
|
|
|
public void updateWxDepartId(SapOrg org) throws Exception {
|
|
public void updateWxDepartId(SapOrg org) throws Exception {
|