|
@@ -20,6 +20,8 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
|
|
|
+import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
|
+
|
|
@Service
|
|
@Service
|
|
public class SapOrgService extends BaseService {
|
|
public class SapOrgService extends BaseService {
|
|
|
|
|
|
@@ -95,7 +97,8 @@ public class SapOrgService extends BaseService {
|
|
String firstOrgId = null;
|
|
String firstOrgId = null;
|
|
if (Tools.notEmpty(businessUnitCode)) {
|
|
if (Tools.notEmpty(businessUnitCode)) {
|
|
sapUser.setFirstOrgName(businessUnitMap.get(businessUnitCode));
|
|
sapUser.setFirstOrgName(businessUnitMap.get(businessUnitCode));
|
|
- firstOrgId = saveOrUpdateSapOrg(WebConstants.TOP_DEPART, businessUnitCode, sapUser.getFirstOrgName(), "1");
|
|
|
|
|
|
+ firstOrgId = saveOrUpdateSapOrg(WebConstants.TOP_DEPART.toString(), businessUnitCode,
|
|
|
|
+ sapUser.getFirstOrgName(), "1");
|
|
sapUser.setFirstOrgId(firstOrgId);
|
|
sapUser.setFirstOrgId(firstOrgId);
|
|
}
|
|
}
|
|
String secondOrgId = null;
|
|
String secondOrgId = null;
|
|
@@ -123,38 +126,39 @@ public class SapOrgService extends BaseService {
|
|
|
|
|
|
public Map<String, Long> updateAllWxDepartId() throws Exception {
|
|
public Map<String, Long> updateAllWxDepartId() throws Exception {
|
|
Map<String, Long> result = Maps.newHashMap();
|
|
Map<String, Long> result = Maps.newHashMap();
|
|
- List<SapOrg> firstOrgs = findListByParentId(WebConstants.TOP_DEPART);
|
|
|
|
|
|
+ List<SapOrg> firstOrgs = findListByParentId(WebConstants.TOP_DEPART.toString());
|
|
List<SapOrg> allOrgs = Lists.newArrayList();
|
|
List<SapOrg> allOrgs = Lists.newArrayList();
|
|
for (SapOrg firstOrg : firstOrgs) {
|
|
for (SapOrg firstOrg : firstOrgs) {
|
|
- firstOrg.setWxDepartId(WXCpDepartUtil.createOrUpdate(firstOrg.getWxDepartId(), 1L, firstOrg.getSapName()));
|
|
|
|
|
|
+ firstOrg.setWxDepartId(getWxDepartId(firstOrg, WebConstants.TOP_DEPART));
|
|
allOrgs.add(firstOrg);
|
|
allOrgs.add(firstOrg);
|
|
List<SapOrg> sencodOrgs = findListByParentId(firstOrg.getId());
|
|
List<SapOrg> sencodOrgs = findListByParentId(firstOrg.getId());
|
|
for (SapOrg sencodOrg : sencodOrgs) {
|
|
for (SapOrg sencodOrg : sencodOrgs) {
|
|
- sencodOrg.setWxDepartId(WXCpDepartUtil.createOrUpdate(sencodOrg.getWxDepartId(),
|
|
|
|
- firstOrg.getWxDepartId(), sencodOrg.getSapName()));
|
|
|
|
|
|
+ sencodOrg.setWxDepartId(getWxDepartId(sencodOrg, firstOrg.getWxDepartId()));
|
|
allOrgs.add(sencodOrg);
|
|
allOrgs.add(sencodOrg);
|
|
List<SapOrg> thirdOrgs = findListByParentId(sencodOrg.getId());
|
|
List<SapOrg> thirdOrgs = findListByParentId(sencodOrg.getId());
|
|
for (SapOrg thirdOrg : thirdOrgs) {
|
|
for (SapOrg thirdOrg : thirdOrgs) {
|
|
- thirdOrg.setWxDepartId(WXCpDepartUtil.createOrUpdate(thirdOrg.getWxDepartId(),
|
|
|
|
- sencodOrg.getWxDepartId(), thirdOrg.getSapName()));
|
|
|
|
|
|
+ thirdOrg.setWxDepartId(getWxDepartId(thirdOrg, sencodOrg.getWxDepartId()));
|
|
allOrgs.add(thirdOrg);
|
|
allOrgs.add(thirdOrg);
|
|
List<SapOrg> fourthOrgs = findListByParentId(thirdOrg.getId());
|
|
List<SapOrg> fourthOrgs = findListByParentId(thirdOrg.getId());
|
|
for (SapOrg fourthOrg : fourthOrgs) {
|
|
for (SapOrg fourthOrg : fourthOrgs) {
|
|
- fourthOrg.setWxDepartId(WXCpDepartUtil.createOrUpdate(fourthOrg.getWxDepartId(),
|
|
|
|
- thirdOrg.getWxDepartId(), fourthOrg.getSapName()));
|
|
|
|
|
|
+ fourthOrg.setWxDepartId(getWxDepartId(fourthOrg, thirdOrg.getWxDepartId()));
|
|
allOrgs.add(fourthOrg);
|
|
allOrgs.add(fourthOrg);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- for(SapOrg org : allOrgs) {
|
|
|
|
|
|
+
|
|
|
|
+ for (SapOrg org : allOrgs) {
|
|
updateWxDepartId(org);
|
|
updateWxDepartId(org);
|
|
result.put(org.getId(), org.getWxDepartId());
|
|
result.put(org.getId(), org.getWxDepartId());
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private Long getWxDepartId(SapOrg org, Long parentId) throws WxErrorException {
|
|
|
|
+ return WXCpDepartUtil.createOrUpdate(org.getWxDepartId(), parentId, org.getSapName());
|
|
|
|
+ }
|
|
|
|
+
|
|
@SuppressWarnings("unchecked")
|
|
@SuppressWarnings("unchecked")
|
|
public List<SapOrg> findListByParentId(String parentId) throws Exception {
|
|
public List<SapOrg> findListByParentId(String parentId) throws Exception {
|
|
SapOrg org = SapOrg.builder().parentId(parentId).build();
|
|
SapOrg org = SapOrg.builder().parentId(parentId).build();
|