From 3b759ef71bb48f9bb6f8445770d20e8ea7921788 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期二, 06 一月 2026 13:58:14 +0800
Subject: [PATCH] Merge branch 'wuhuyancao' of http://139.186.142.91:10010/r/productDev/dmvisit into wuhuyancao

---
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java | 1088 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 983 insertions(+), 105 deletions(-)

diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java
index 34b0097..34f3fb1 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java
@@ -1,5 +1,7 @@
 package com.doumee.service.business.impl;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.TypeReference;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -13,6 +15,7 @@
 import com.doumee.core.dingTalk.DingTalk;
 import com.doumee.core.erp.ErpConstants;
 import com.doumee.core.erp.model.openapi.request.erp.OrgListRequest;
+import com.doumee.core.erp.model.openapi.response.erp.ERPApiResponse;
 import com.doumee.core.erp.model.openapi.response.erp.ErpOrgListResponse;
 import com.doumee.core.exception.BusinessException;
 import com.doumee.core.haikang.model.HKConstants;
@@ -23,6 +26,11 @@
 import com.doumee.core.haikang.model.param.respose.OrgOrUserAddResponse;
 import com.doumee.core.haikang.model.param.respose.OrgUpdateFailureResponse;
 import com.doumee.core.haikang.service.HKService;
+import com.doumee.core.jiandaoyun.api.arch.DeptApiClient;
+import com.doumee.core.jiandaoyun.constants.HttpConstant;
+import com.doumee.core.jiandaoyun.model.dept.DeptEntityModel;
+import com.doumee.core.wms.model.response.WmsBaseDataResponse;
+import com.doumee.core.wms.model.response.WmsBaseResponse;
 import com.doumee.service.business.third.model.LoginUserInfo;
 import com.doumee.service.business.third.model.PageData;
 import com.doumee.service.business.third.model.PageWrap;
@@ -39,10 +47,10 @@
 import com.doumee.dao.system.model.SystemUser;
 import com.doumee.service.business.CompanyService;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
-import com.taobao.api.ApiException;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.SecurityUtils;
+import org.checkerframework.checker.units.qual.C;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -132,7 +140,7 @@
         company.setIsdeleted(Constants.ZERO);
         company.setHkStatus(Constants.ONE);
         company.setStatus(Constants.ZERO);
-        company.setSortnum(Objects.isNull(company.getSortnum())?0:company.getSortnum());
+        company.setSortnum(0);//榛樿鏈�涓婇潰
         company.setHkDate(company.getCreateDate());
         company.setEditDate(company.getCreateDate());
         company.setEditor(company.getCreator());
@@ -169,8 +177,8 @@
         OrgEditRequest request = (getOrgHkEditModel(company));
         BaseResponse result =  HKService.editOrg(request);
         if(result !=null && StringUtils.equals(result.getCode(),HKConstants.RESPONSE_SUCCEE)){
-                //澶勭悊鏂板鎴愬姛鐨勬暟鎹紝淇敼娴峰悍鍚屾鐘舵��
-                return true;
+            //澶勭悊鏂板鎴愬姛鐨勬暟鎹紝淇敼娴峰悍鍚屾鐘舵��
+            return true;
         }
         return false;
     }
@@ -180,7 +188,7 @@
         request.setIndexCodes(new String[]{company.getHkId()});
         BaseResponse<List<OrgUpdateFailureResponse>> result =  HKService.delBatchOrg(request);
         if(result !=null && StringUtils.equals(result.getCode(),HKConstants.RESPONSE_SUCCEE)){
-                //澶勭悊鏂板鎴愬姛鐨勬暟鎹紝淇敼娴峰悍鍚屾鐘舵��
+            //澶勭悊鏂板鎴愬姛鐨勬暟鎹紝淇敼娴峰悍鍚屾鐘舵��
             if(result.getData()!=null && result.getData().size()==0){
                 return true;
             }
@@ -188,7 +196,6 @@
 
         return false;
     }
-
 
     private OrgAddRequest getOrgAddModel(Company c ) {
         OrgAddRequest model = new OrgAddRequest();
@@ -292,7 +299,7 @@
         if(company.getId() == null|| StringUtils.isBlank(company.getName())){
             throw  new BusinessException(ResponseStatus.BAD_REQUEST);
         }
-        if(company.getType()!=null && !(company.getType() ==0 || company.getType() ==1 || company.getType() ==-1)){
+        if(company.getType()!=null && !(company.getType() ==-1 || company.getType() ==0 || company.getType() ==1)){
             throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "瀵逛笉璧凤紝缁勭粐绫诲瀷涓嶆纭紝璇锋寜瑕佹眰濉啓~");
         }
         //鏌ヨ鍚嶇О涓嶈兘閲嶅
@@ -324,7 +331,6 @@
         company.setType(null);
         company.setEditDate(new Date());
         company.setEditor(user.getId());
-
         company.setHkStatus(Constants.ONE);
         company.setHkDate(company.getHkDate());
         company.setHkId(StringUtils.defaultString(model.getHkId(),UUID.randomUUID().toString().replace("-","")));
@@ -334,14 +340,14 @@
         //鏇存柊鐨刢ompanyPath
         String newName = model.getCompanyNamePath().replace(model.getName(),company.getName());
         companyMapper.update(null,new UpdateWrapper<Company>().lambda()
-                        .setSql("company_name_path=REPLACE(company_name_path,'"+ model.getCompanyNamePath()+"','"+newName+"')")
-                        .setSql("hk_company_path=REPLACE(hk_company_path,'"+ model.getCompanyNamePath()+"','"+newName+"')")
+                .setSql("company_name_path=REPLACE(company_name_path,'"+ model.getCompanyNamePath()+"','"+newName+"')")
+                .setSql("hk_company_path=REPLACE(hk_company_path,'"+ model.getCompanyNamePath()+"','"+newName+"')")
                 .likeRight(Company::getCompanyPath,model.getCompanyPath()));
         //涓嬪彂娴峰悍瀹夐槻骞冲彴
         if(StringUtils.isNotBlank(model.getHkId())){
-             if(!editHkOrg(company)){
-                 throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀵逛笉璧凤紝缁勭粐鍚屾涓嬪彂澶辫触锛岃绋嶅悗閲嶈瘯");
-             }
+            if(!editHkOrg(company)){
+                throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀵逛笉璧凤紝缁勭粐鍚屾涓嬪彂澶辫触锛岃绋嶅悗閲嶈瘯");
+            }
         }else{//濡傛灉娌℃湁涓嬪彂杩囷紝鐩存帴鏂板缓瀹夐槻骞冲彴缁勭粐
             if(!addHkOrg(company)){
                 throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀵逛笉璧凤紝缁勭粐鍚屾涓嬪彂澶辫触锛岃绋嶅悗閲嶈瘯");
@@ -787,35 +793,49 @@
     // org_dept_remove 閮ㄩ棬鍒犻櫎 {"timeStamp":"1758785817760","eventId":"47e289f334e041719ed354052da474de","deptId":[1040735458]}
 
     @Override
-    public void ddPushCompanyInfo(String eventType, JSONObject eventData) throws ApiException {
-        JSONArray jsonArray = eventData.getJSONArray("deptId");
-        if(jsonArray.isEmpty()){
-            return;
-        }
-        if(eventType.equals("org_dept_remove")){
-            //鍒犻櫎瀵瑰簲閮ㄩ棬淇℃伅
-            List<Long> deptIdList = new ArrayList<>();
-            for (int i = 0; i < jsonArray.size(); i++) {
-                Long deptId = jsonArray.getLong(i);
-                 deptIdList.add(deptId);
+    public void ddPushCompanyInfo(String eventType, JSONObject eventData)  {
+        try {
+            JSONArray jsonArray = eventData.getJSONArray("deptId");
+            if(jsonArray.isEmpty()){
+                return;
             }
-            if(CollectionUtils.isNotEmpty(deptIdList)){
-                syncDelCompany(deptIdList);
-            }
-        }else if(eventType.equals("org_dept_create")||eventType.equals("org_dept_modify")){
-            for (int i = 0; i < jsonArray.size(); i++) {
-                Company company  = companyMapper.selectOne(new QueryWrapper<Company>().lambda()
-                        .eq(Company::getIsdeleted,Constants.ZERO)
-                        .eq(Company::getErpId,jsonArray.getLong(i))
-                );
-                OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse = dingTalk.syncDepartmentInfo(jsonArray.getLong(i));
-                if(Objects.isNull(company)){
-                    getAddCompanyModel(deptGetResponse,company);
-                }else{
-                    getUpdateCompanyModel(deptGetResponse,company);
+            if(eventType.equals("org_dept_remove")){
+                //鍒犻櫎瀵瑰簲閮ㄩ棬淇℃伅
+                List<Long> deptIdList = new ArrayList<>();
+                for (int i = 0; i < jsonArray.size(); i++) {
+                    Long deptId = jsonArray.getLong(i);
+                    deptIdList.add(deptId);
+                }
+                if(CollectionUtils.isNotEmpty(deptIdList)){
+                    syncDelCompany( companyMapper.selectList(new QueryWrapper<Company>()
+                            .lambda()
+                            .eq(Company::getIsdeleted,Constants.ZERO)
+                            .in(Company::getErpId,deptIdList)
+                    ));
+                }
+            }else if(eventType.equals("org_dept_create")||eventType.equals("org_dept_modify")){
+                for (int i = 0; i < jsonArray.size(); i++) {
+                    Company company  = companyMapper.selectOne(new QueryWrapper<Company>().lambda()
+                            .eq(Company::getIsdeleted,Constants.ZERO)
+                            .eq(Company::getErpId,jsonArray.getLong(i))
+                    );
+                    OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse = dingTalk.syncDepartmentInfo(jsonArray.getLong(i));
+                    Company param = new Company();
+                    param.setName(deptGetResponse.getName());
+                    param.setErpId(deptGetResponse.getDeptId().toString());
+                    param.setErpParentId(deptGetResponse.getParentId().toString());
+                    if(Objects.isNull(company)){
+                        param.setSortnum(deptGetResponse.getOrder().intValue());//榛樿鏈�涓婇潰
+                        getAddCompanyModel(param);
+                    }else{
+                        getUpdateCompanyModel(param,company);
+                    }
                 }
             }
+        }catch (Exception e){
+            throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"鏁版嵁鍚屾澶辫触");
         }
+
     }
 
     private void doHkDeleteOrg(List<Integer> delIds,List<String> delHkIds,  Date date) {
@@ -843,7 +863,7 @@
                     .in(Company::getId, delIds)
                     .notIn(fIds.size()>0,Company::getHkId, fIds));
             companyMapper.update(null,new UpdateWrapper<Company>().lambda()
-                    .set(Company::getHkStatus,Constants.TWO)
+                    .set(Company::getHkStatus,Constants.ZERO)
                     .set(Company::getHkDate,date)
                     .in(Company::getId, delIds)
                     .in(fIds.size()>0,Company::getHkId, fIds));
@@ -851,66 +871,878 @@
     }
 
     @Override
-    public String syncDDCompany() throws ApiException {
-        List<OapiV2DepartmentGetResponse.DeptGetResponse> list = dingTalk.syncAllDDDepartmentList();
-        if(list !=null && list.size()>0){
-            List<Company> addList = new ArrayList<>();
-            List<Company> updateList = new ArrayList<>();
-            List<Long> delIds = new ArrayList<>();//淇敼涓轰娇鐢ㄩ拤閽塱d  erpId
-            List<Company>  allList = companyMapper.selectList(new QueryWrapper<Company>().lambda()
-                    .eq(Company::getIsdeleted,Constants.ZERO).eq(Company::getType,Constants.ONE));
-            dealCompanyChangeList(list,addList,updateList,delIds,allList);
-            if(delIds.size()>0){
-                syncDelCompany(delIds);
+    public String syncDDCompany()  {
+        try {
+            List<OapiV2DepartmentGetResponse.DeptGetResponse> list = dingTalk.syncAllDDDepartmentList();
+            if(list !=null && list.size()>0){
+                List<Company> addList = new ArrayList<>();
+                List<Company> updateList = new ArrayList<>();
+                List<Company> delIds = new ArrayList<>();//淇敼涓轰娇鐢ㄩ拤閽塱d  erpId
+                List<Company>  allList = companyMapper.selectList(new QueryWrapper<Company>().lambda()
+                        .eq(Company::getIsdeleted,Constants.ZERO).eq(Company::getType,Constants.ONE));
+                dealCompanyChangeList(list,addList,updateList,delIds,allList);
+                if(delIds.size()>0){
+                    syncDelCompany(delIds);
+                }
+                return "鍚屾鏁版嵁锛氭柊澧炪��"+addList.size()+"銆戞潯锛屾洿鏂般��"+updateList.size()+"銆戞潯锛屽垹闄ゃ��"+delIds.size()+"銆戞潯";
+            }else{
+                throw  new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "鍚屾閽夐拤鏁版嵁涓虹┖锛�");
             }
-            return "鍚屾鏁版嵁锛氭柊澧炪��"+addList.size()+"銆戞潯锛屾洿鏂般��"+updateList.size()+"銆戞潯锛屽垹闄ゃ��"+delIds.size()+"銆戞潯";
-        }else{
-            throw  new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "鍚屾閽夐拤鏁版嵁涓虹┖锛�");
+        }catch (Exception e){
+            e.printStackTrace();
+            throw  new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "鍚屾閽夐拤鏁版嵁寮傚父锛�");
         }
     }
+    @Override
+    public String syncJdyCompany() {
+        //{
+        //  "dept_no": 1,//鏁板瓧 1 涓烘牴閮ㄩ棬缂栧彿銆�483636217锛氳姕婀栧競鍏徃
+        //  "has_child": true
+        //}
+        DeptApiClient deptApiClient = new DeptApiClient(systemDictDataBiz.queryByCode(Constants.JDY_CONFIG, Constants.JDY_API_KEY).getCode()
+                ,systemDictDataBiz.queryByCode(Constants.JDY_CONFIG, Constants.JDY_API_HOST).getCode());
+        try {
+            int root = 1;
+            try {
+                root = Integer.parseInt(systemDictDataBiz.queryByCode(Constants.JDY_CONFIG, Constants.JDY_COMPANY_ROOT_NO).getCode());
+            }catch (Exception e){
 
-    private void dealCompanyChangeList(List<OapiV2DepartmentGetResponse.DeptGetResponse> list, List<Company> addList, List<Company> updateList, List<Long> delIds, List<Company> allList) {
+            }
+            Map<String, Object> result =  deptApiClient.deptList(root,true,deptApiClient.getDefaultVersion());
+            if(result!=null && result.get("departments")!=null ){
+                TypeReference<List<DeptEntityModel>> typeReference =     new TypeReference<List<DeptEntityModel>>(){};
+                Object obj = result.get("departments");
+                List<DeptEntityModel> list =  com.alibaba.fastjson.JSONObject.parseObject(JSON.toJSONString(obj), typeReference.getType());
+                list = sortJdyListBYParent(list,root);
+                if(list !=null && list.size()>0){
+                    List<Company> addList = new ArrayList<>();
+                    List<Company> updateList = new ArrayList<>();
+                    List<Company> delIds = new ArrayList<>();//淇敼涓轰娇鐢ㄩ拤閽塱d  erpId
+                    List<Company>  allList = companyMapper.selectList(new QueryWrapper<Company>().lambda()
+                            .eq(Company::getIsdeleted,Constants.ZERO).eq(Company::getType,Constants.ONE));
+                    dealCompanyChangeListJdy(list,addList,updateList,delIds,allList);
+                    if(delIds.size()>0){
+                        syncDelCompany(delIds);
+                    }
+                    return "鍚屾鏁版嵁锛氭柊澧炪��"+addList.size()+"銆戞潯锛屾洿鏂般��"+updateList.size()+"銆戞潯锛屽垹闄ゃ��"+delIds.size()+"銆戞潯";
+                }else{
+                    throw  new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "鍚屾绠�鍗曚簯鏁版嵁涓虹┖锛�");
+                }
+            }
+        }catch (BusinessException e){
+            throw  e;
+        }catch (Exception e){
+            throw  new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "鍚屾鏁版嵁寮傚父锛�"+e.getMessage());
+        }
+        return null;
+    }
+
+    private List<DeptEntityModel> sortJdyListBYParent(List<DeptEntityModel> list, int root) {
+        List<DeptEntityModel> all = new ArrayList<>();
+        for(DeptEntityModel t : list){
+            if(Constants.equalsInteger( t.getParent_no(),root)){
+                all.add(t);
+                if(hasChildCompany(list,t.getDept_no())){
+                    all.addAll(sortJdyListBYParent(list,t.getDept_no()));
+                }
+            }
+        }
+        return  all;
+    }
+
+
+    private boolean hasChildCompany(List<DeptEntityModel> list, Integer deptNo) {
+        for(DeptEntityModel t : list){
+            if(Constants.equalsInteger( t.getParent_no(),deptNo)){
+               return true;
+            }
+        }
+        return  false;
+    }
+
+    public static void main(String[] args) {
+        String temp = " [{" +
+                "\"dept_no\": 567064650," +
+                "\"name\": \"瀹¤娲鹃┗鍔瀄"," +
+                "\"parent_no\": 483636217," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567064650\"" +
+                "}, {" +
+                "\"dept_no\": 567086523," +
+                "\"name\": \"姹熷寳鍒嗗眬\"," +
+                "\"parent_no\": 483636217," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567086523\"" +
+                "}, {" +
+                "\"dept_no\": 567354485," +
+                "\"name\": \"绂诲矖閫�鍏讳汉鍛榎"," +
+                "\"parent_no\": 483636217," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567354485\"" +
+                "}, {" +
+                "\"dept_no\": 567303494," +
+                "\"name\": \"绾鐩戝療瀹わ紙宸″療棰嗗灏忕粍鍔炲叕瀹わ級\"," +
+                "\"parent_no\": 483636217," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567303494\"" +
+                "}, {" +
+                "\"dept_no\": 566874731," +
+                "\"name\": \"鏃犱负甯傚眬绂婚��浼戝姙\"," +
+                "\"parent_no\": 566426902," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566874731\"" +
+                "}, {" +
+                "\"dept_no\": 566426902," +
+                "\"name\": \"绂婚��浼戜汉鍛樺\"," +
+                "\"parent_no\": 483636217," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566426902\"" +
+                "}, {" +
+                "\"dept_no\": 566981590," +
+                "\"name\": \"鐗╂祦涓績\"," +
+                "\"parent_no\": 483636217," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566981590\"" +
+                "}, {" +
+                "\"dept_no\": 566499662," +
+                "\"name\": \"鏃犱负甯傚眬锛堣惀閿�閮級\"," +
+                "\"parent_no\": 483636217," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566499662\"" +
+                "}, {" +
+                "\"dept_no\": 567258434," +
+                "\"name\": \"婀炬矚鍖哄眬锛堣惀閿�閮級\"," +
+                "\"parent_no\": 483636217," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567258434\"" +
+                "}, {" +
+                "\"dept_no\": 567458554," +
+                "\"name\": \"涓撳崠鐩戠潱绠$悊绉戯紙鍐呴儴涓撳崠绠$悊鐩戠潱绉戙�佺ń鏌ユ敮闃燂級\"," +
+                "\"parent_no\": 483636217," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567458554\"" +
+                "}, {" +
+                "\"dept_no\": 567139640," +
+                "\"name\": \"婀炬矚鍖哄眬绂婚��浼戝姙\"," +
+                "\"parent_no\": 566426902," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567139640\"" +
+                "}, {" +
+                "\"dept_no\": 566379775," +
+                "\"name\": \"淇℃伅涓績\"," +
+                "\"parent_no\": 483636217," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566379775\"" +
+                "}, {" +
+                "\"dept_no\": 567298538," +
+                "\"name\": \"浼佷笟绠$悊绉慭"," +
+                "\"parent_no\": 483636217," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567298538\"" +
+                "}, {" +
+                "\"dept_no\": 567073617," +
+                "\"name\": \"鍔炲叕瀹"," +
+                "\"parent_no\": 483636217," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567073617\"" +
+                "}, {" +
+                "\"dept_no\": 566496812," +
+                "\"name\": \"绻佹槍鍖哄眬绂婚��浼戝姙\"," +
+                "\"parent_no\": 566426902," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566496812\"" +
+                "}, {" +
+                "\"dept_no\": 566643894," +
+                "\"name\": \"鍗楅櫟鍘垮眬绂婚��浼戝姙\"," +
+                "\"parent_no\": 566426902," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566643894\"" +
+                "}, {" +
+                "\"dept_no\": 566699927," +
+                "\"name\": \"娉曡绉戯紙瑙勮寖绠$悊鍔炲叕瀹わ級\"," +
+                "\"parent_no\": 483636217," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566699927\"" +
+                "}, {" +
+                "\"dept_no\": 567034633," +
+                "\"name\": \"鍏氬缓缇ゅ洟绉戯紙宸ヤ細鍔炲叕瀹わ級\"," +
+                "\"parent_no\": 483636217," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567034633\"" +
+                "}, {" +
+                "\"dept_no\": 567095650," +
+                "\"name\": \"甯傚眬锛堝叕鍙革級棰嗗\"," +
+                "\"parent_no\": 483636217," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567095650\"" +
+                "}, {" +
+                "\"dept_no\": 566464722," +
+                "\"name\": \"璐㈠姟绠$悊绉慭"," +
+                "\"parent_no\": 483636217," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566464722\"" +
+                "}, {" +
+                "\"dept_no\": 567249497," +
+                "\"name\": \"鑺滄箹甯傚眬鐩村睘鍒嗗眬\"," +
+                "\"parent_no\": 483636217," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567249497\"" +
+                "}, {" +
+                "\"dept_no\": 567266572," +
+                "\"name\": \"鍗楅櫟鍘垮眬锛堣惀閿�閮級\"," +
+                "\"parent_no\": 483636217," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567266572\"" +
+                "}, {" +
+                "\"dept_no\": 567394584," +
+                "\"name\": \"绂婚��浼戜汉鍛樺\"," +
+                "\"parent_no\": 566426902," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567394584\"" +
+                "}, {" +
+                "\"dept_no\": 566952603," +
+                "\"name\": \"瀹夊叏绠$悊绉慭"," +
+                "\"parent_no\": 483636217," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566952603\"" +
+                "}, {" +
+                "\"dept_no\": 567418536," +
+                "\"name\": \"绻佹槍鍖哄眬锛堣惀閿�閮級\"," +
+                "\"parent_no\": 483636217," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567418536\"" +
+                "}, {" +
+                "\"dept_no\": 567080624," +
+                "\"name\": \"钀ラ攢涓績\"," +
+                "\"parent_no\": 483636217," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567080624\"" +
+                "}, {" +
+                "\"dept_no\": 567395495," +
+                "\"name\": \"浜哄姏璧勬簮绉慭"," +
+                "\"parent_no\": 483636217," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567395495\"" +
+                "}, {" +
+                "\"dept_no\": 566852695," +
+                "\"name\": \"鏃犱负甯傚眬锛堣惀閿�閮級鍔炲叕瀹"," +
+                "\"parent_no\": 566499662," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566852695\"" +
+                "}, {" +
+                "\"dept_no\": 566597911," +
+                "\"name\": \"鏃犱负甯傚眬锛堣惀閿�閮級瑗勫畨鐑熻崏涓撳崠绠$悊鎵�锛堟湇鍔$珯銆佺ń鏌ヤ腑闃燂級\"," +
+                "\"parent_no\": 566499662," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566597911\"" +
+                "}, {" +
+                "\"dept_no\": 567383562," +
+                "\"name\": \"鏃犱负甯傚眬锛堣惀閿�閮級瀹㈡埛鏈嶅姟閮╘"," +
+                "\"parent_no\": 566499662," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567383562\"" +
+                "}, {" +
+                "\"dept_no\": 566596757," +
+                "\"name\": \"棰嗗鐝瓙\"," +
+                "\"parent_no\": 566499662," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566596757\"" +
+                "}, {" +
+                "\"dept_no\": 567126588," +
+                "\"name\": \"鏃犱负甯傚眬锛堣惀閿�閮級鍩庡尯鐑熻崏涓撳崠绠$悊鎵�锛堟湇鍔$珯銆佺ń鏌ヤ腑闃燂級\"," +
+                "\"parent_no\": 566499662," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567126588\"" +
+                "}, {" +
+                "\"dept_no\": 567423457," +
+                "\"name\": \"鏃犱负甯傚眬锛堣惀閿�閮級鐩戝療娉曡鍔瀄"," +
+                "\"parent_no\": 566499662," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567423457\"" +
+                "}, {" +
+                "\"dept_no\": 567444447," +
+                "\"name\": \"鏃犱负甯傚眬锛堣惀閿�閮級楂樻矡鐑熻崏涓撳崠绠$悊鎵�锛堟湇鍔$珯銆佺ń鏌ヤ腑闃燂級\"," +
+                "\"parent_no\": 566499662," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567444447\"" +
+                "}, {" +
+                "\"dept_no\": 566688696," +
+                "\"name\": \"鏃犱负甯傚眬锛堣惀閿�閮級涓撳崠鐩戠潱绠$悊鍔炲叕瀹わ紙鍐呴儴涓撳崠绠$悊鐩戠潱鍔炲叕瀹ゃ�佺ń鏌ュぇ闃燂級\"," +
+                "\"parent_no\": 566499662," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566688696\"" +
+                "}, {" +
+                "\"dept_no\": 567308492," +
+                "\"name\": \"鍗楅櫟鍘垮眬锛堣惀閿�閮級涓撳崠鐩戠潱绠$悊鍔炲叕瀹わ紙鍐呴儴涓撳崠绠$悊鐩戠潱鍔炲叕瀹ゃ�佺ń鏌ュぇ闃燂級琛屽姩缁刓"," +
+                "\"parent_no\": 567266572," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567308492\"" +
+                "}, {" +
+                "\"dept_no\": 567311569," +
+                "\"name\": \"涓撳崠鐩戠潱绠$悊鍔炲叕瀹わ紙鍐呴儴涓撳崠绠$悊鐩戠潱鍔炲叕瀹ゃ�佺ń鏌ュぇ闃燂級琛屽姩缁刓"," +
+                "\"parent_no\": 566499662," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567311569\"" +
+                "}, {" +
+                "\"dept_no\": 566586834," +
+                "\"name\": \"鐗╂祦涓績鍌ㄩ厤閮╘"," +
+                "\"parent_no\": 566981590," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566586834\"" +
+                "}, {" +
+                "\"dept_no\": 567052635," +
+                "\"name\": \"绋芥煡闃焅"," +
+                "\"parent_no\": 566930600," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567052635\"" +
+                "}, {" +
+                "\"dept_no\": 567250603," +
+                "\"name\": \"涓撳崠鐩戠潱绠$悊鍔炲叕瀹わ紙鍐呴儴涓撳崠绠$悊鐩戠潱鍔炲叕瀹ゃ�佺ń鏌ュぇ闃燂級琛屽姩缁刓"," +
+                "\"parent_no\": 567418536," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567250603\"" +
+                "}, {" +
+                "\"dept_no\": 566714645," +
+                "\"name\": \"鐗╂祦涓績閫佽揣閮╘"," +
+                "\"parent_no\": 566981590," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566714645\"" +
+                "}, {" +
+                "\"dept_no\": 567400554," +
+                "\"name\": \"鐗╂祦涓績缁煎悎閮╘"," +
+                "\"parent_no\": 566981590," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567400554\"" +
+                "}, {" +
+                "\"dept_no\": 901575528," +
+                "\"name\": \"鐗╂祦涓績鎶�鏈儴\"," +
+                "\"parent_no\": 566981590," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"901575528\"" +
+                "}, {" +
+                "\"dept_no\": 567406402," +
+                "\"name\": \"鐗╂祦涓績瀹変繚閮╘"," +
+                "\"parent_no\": 566981590," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567406402\"" +
+                "}, {" +
+                "\"dept_no\": 667523393," +
+                "\"name\": \"鐗╂祦涓績棰嗗\"," +
+                "\"parent_no\": 566981590," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"667523393\"" +
+                "}, {" +
+                "\"dept_no\": 567052636," +
+                "\"name\": \"涓撳崠鐩戠潱绠$悊鍔炲叕瀹わ紙鍐呴儴涓撳崠绠$悊鐩戠潱鍔炲叕瀹ゃ�佺ń鏌ュぇ闃燂級琛屽姩缁刓"," +
+                "\"parent_no\": 567249497," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567052636\"" +
+                "}, {" +
+                "\"dept_no\": 567351557," +
+                "\"name\": \"鐗╂祦涓績涓浆绔橽"," +
+                "\"parent_no\": 566981590," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567351557\"" +
+                "}, {" +
+                "\"dept_no\": 567052634," +
+                "\"name\": \"姹熷寳鍒嗗眬鍔炲叕瀹"," +
+                "\"parent_no\": 567086523," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567052634\"" +
+                "}, {" +
+                "\"dept_no\": 567359469," +
+                "\"name\": \"鍝佺墝閮╘"," +
+                "\"parent_no\": 567080624," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567359469\"" +
+                "}, {" +
+                "\"dept_no\": 821923828," +
+                "\"name\": \"缁煎悎閮╘"," +
+                "\"parent_no\": 567080624," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"821923828\"" +
+                "}, {" +
+                "\"dept_no\": 567151607," +
+                "\"name\": \"姹熷寳鍒嗗眬涓撳崠鐩戠潱绠$悊鍔炲叕瀹わ紙鍐呴儴涓撳崠绠$悊鐩戠潱鍔炲叕瀹ゃ�佺ń鏌ュぇ闃燂級\"," +
+                "\"parent_no\": 567086523," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567151607\"" +
+                "}, {" +
+                "\"dept_no\": 567297546," +
+                "\"name\": \"甯傚満閮╘"," +
+                "\"parent_no\": 567080624," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567297546\"" +
+                "}, {" +
+                "\"dept_no\": 566867618," +
+                "\"name\": \"缁堢閮╘"," +
+                "\"parent_no\": 567080624," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566867618\"" +
+                "}, {" +
+                "\"dept_no\": 567314532," +
+                "\"name\": \"璁㈠崟閮╘"," +
+                "\"parent_no\": 567080624," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567314532\"" +
+                "}, {" +
+                "\"dept_no\": 566848639," +
+                "\"name\": \"姹熷寳鍒嗗眬鐩戝療娉曡鍔瀄"," +
+                "\"parent_no\": 567086523," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566848639\"" +
+                "}, {" +
+                "\"dept_no\": 567272560," +
+                "\"name\": \"涓撳崠鐩戠潱绠$悊鍔炲叕瀹わ紙鍐呴儴涓撳崠绠$悊鐩戠潱鍔炲叕瀹ゃ�佺ń鏌ュぇ闃燂級瀵勯�掔粍\"," +
+                "\"parent_no\": 567258434," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567272560\"" +
+                "}, {" +
+                "\"dept_no\": 566564826," +
+                "\"name\": \"涓撳崠鐩戠潱绠$悊鍔炲叕瀹わ紙鍐呴儴涓撳崠绠$悊鐩戠潱鍔炲叕瀹ゃ�佺ń鏌ュぇ闃燂級琛屽姩缁刓"," +
+                "\"parent_no\": 567258434," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566564826\"" +
+                "}, {" +
+                "\"dept_no\": 567471441," +
+                "\"name\": \"姹熷寳鍒嗗眬瀹㈡埛鏈嶅姟閮╘"," +
+                "\"parent_no\": 567086523," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567471441\"" +
+                "}, {" +
+                "\"dept_no\": 711701716," +
+                "\"name\": \"姹熷寳鍒嗗眬鍩庡寳鐑熻崏涓撳崠绠$悊鎵�锛堟湇鍔$珯锛塡"," +
+                "\"parent_no\": 567086523," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"711701716\"" +
+                "}, {" +
+                "\"dept_no\": 567103611," +
+                "\"name\": \"棰嗗鐝瓙\"," +
+                "\"parent_no\": 567086523," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567103611\"" +
+                "}, {" +
+                "\"dept_no\": 664801291," +
+                "\"name\": \"姹熷寳鍒嗗眬浜屽潩鐑熻崏涓撳崠绠$悊鎵�锛堟湇鍔$珯锛塡"," +
+                "\"parent_no\": 567086523," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"664801291\"" +
+                "}, {" +
+                "\"dept_no\": 566323801," +
+                "\"name\": \"婀炬矚鍖哄眬锛堣惀閿�閮級鍔炲叕瀹"," +
+                "\"parent_no\": 567258434," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566323801\"" +
+                "}, {" +
+                "\"dept_no\": 567343637," +
+                "\"name\": \"婀炬矚鍖哄眬锛堣惀閿�閮級鍩庡尯鐑熻崏涓撳崠绠$悊鎵�锛堟湇鍔$珯銆佺ń鏌ヤ腑闃燂級\"," +
+                "\"parent_no\": 567258434," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567343637\"" +
+                "}, {" +
+                "\"dept_no\": 567087584," +
+                "\"name\": \"婀炬矚鍖哄眬锛堣惀閿�閮級鐩戝療娉曡鍔瀄"," +
+                "\"parent_no\": 567258434," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567087584\"" +
+                "}, {" +
+                "\"dept_no\": 567058556," +
+                "\"name\": \"瀹㈡埛鏈嶅姟閮╘"," +
+                "\"parent_no\": 567249497," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567058556\"" +
+                "}, {" +
+                "\"dept_no\": 566930600," +
+                "\"name\": \"涓撳崠鐩戠潱绠$悊鍔炲叕瀹わ紙鍐呴儴涓撳崠绠$悊鐩戠潱鍔炲叕瀹ゃ�佺ń鏌ュぇ闃燂級\"," +
+                "\"parent_no\": 567249497," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566930600\"" +
+                "}, {" +
+                "\"dept_no\": 566592977," +
+                "\"name\": \"涓撳崠鐩戠潱绠$悊鍔炲叕瀹わ紙鍐呴儴涓撳崠绠$悊鐩戠潱鍔炲叕瀹ゃ�佺ń鏌ュぇ闃燂級琛屽姩缁刓"," +
+                "\"parent_no\": 567086523," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566592977\"" +
+                "}, {" +
+                "\"dept_no\": 567283502," +
+                "\"name\": \"棰嗗鐝瓙\"," +
+                "\"parent_no\": 567249497," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567283502\"" +
+                "}, {" +
+                "\"dept_no\": 567571030," +
+                "\"name\": \"鐩戝療娉曡鍔瀄"," +
+                "\"parent_no\": 567249497," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567571030\"" +
+                "}, {" +
+                "\"dept_no\": 566605742," +
+                "\"name\": \"婀炬矚鍖哄眬锛堣惀閿�閮級瀹㈡埛鏈嶅姟閮╘"," +
+                "\"parent_no\": 567258434," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566605742\"" +
+                "}, {" +
+                "\"dept_no\": 567044634," +
+                "\"name\": \"棰嗗鐝瓙\"," +
+                "\"parent_no\": 567258434," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567044634\"" +
+                "}, {" +
+                "\"dept_no\": 566835635," +
+                "\"name\": \"鍔炲叕瀹"," +
+                "\"parent_no\": 567249497," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566835635\"" +
+                "}, {" +
+                "\"dept_no\": 566844724," +
+                "\"name\": \"鍩庡崡鐑熻崏涓撳崠绠$悊鎵�锛堟湇鍔$珯銆佺ń鏌ヤ腑闃燂級\"," +
+                "\"parent_no\": 567249497," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566844724\"" +
+                "}, {" +
+                "\"dept_no\": 566633782," +
+                "\"name\": \"棰嗗鐝瓙\"," +
+                "\"parent_no\": 567266572," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566633782\"" +
+                "}, {" +
+                "\"dept_no\": 566884644," +
+                "\"name\": \"鍗楅櫟鍘垮眬锛堣惀閿�閮級瀹㈡埛鏈嶅姟閮╘"," +
+                "\"parent_no\": 567266572," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566884644\"" +
+                "}, {" +
+                "\"dept_no\": 566656760," +
+                "\"name\": \"鍗楅櫟鍘垮眬锛堣惀閿�閮級涓撳崠鐩戠潱绠$悊鍔炲叕瀹わ紙鍐呴儴涓撳崠绠$悊鐩戠潱鍔炲叕瀹ゃ�佺ń鏌ュぇ闃燂級\"," +
+                "\"parent_no\": 567266572," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566656760\"" +
+                "}, {" +
+                "\"dept_no\": 567127606," +
+                "\"name\": \"婀炬矚鍖哄眬锛堣惀閿�閮級涓撳崠鐩戠潱绠$悊鍔炲叕瀹わ紙鍐呴儴涓撳崠绠$悊鐩戠潱鍔炲叕瀹ゃ�佺ń鏌ュぇ闃燂級\"," +
+                "\"parent_no\": 567258434," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567127606\"" +
+                "}, {" +
+                "\"dept_no\": 566965621," +
+                "\"name\": \"鍗楅櫟鍘垮眬锛堣惀閿�閮級鐩戝療娉曡鍔瀄"," +
+                "\"parent_no\": 567266572," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566965621\"" +
+                "}, {" +
+                "\"dept_no\": 566889723," +
+                "\"name\": \"鍗楅櫟鍘垮眬锛堣惀閿�閮級鍩庡尯鐑熻崏涓撳崠绠$悊鎵�锛堟湇鍔$珯銆佺ń鏌ヤ腑闃燂級\"," +
+                "\"parent_no\": 567266572," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566889723\"" +
+                "}, {" +
+                "\"dept_no\": 573565486," +
+                "\"name\": \"鍗楅櫟鍘垮眬锛堣惀閿�閮級鍔炲叕瀹"," +
+                "\"parent_no\": 567266572," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"573565486\"" +
+                "}, {" +
+                "\"dept_no\": 566880674," +
+                "\"name\": \"鍗楅櫟鍘垮眬绂诲矖閫�鍏讳汉鍛榎"," +
+                "\"parent_no\": 567354485," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566880674\"" +
+                "}, {" +
+                "\"dept_no\": 567176623," +
+                "\"name\": \"绻佹槍鍘垮眬绂诲矖閫�鍏讳汉鍛榎"," +
+                "\"parent_no\": 567354485," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567176623\"" +
+                "}, {" +
+                "\"dept_no\": 567314533," +
+                "\"name\": \"鑺滄箹甯傚眬绂诲矖閫�鍏讳汉鍛榎"," +
+                "\"parent_no\": 567354485," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567314533\"" +
+                "}, {" +
+                "\"dept_no\": 567340287," +
+                "\"name\": \"鏃犱负鍘垮眬绂诲矖閫�鍏讳汉鍛榎"," +
+                "\"parent_no\": 567354485," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567340287\"" +
+                "}, {" +
+                "\"dept_no\": 566636715," +
+                "\"name\": \"鑺滄箹鍘垮眬绂诲矖閫�鍏讳汉鍛榎"," +
+                "\"parent_no\": 567354485," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566636715\"" +
+                "}, {" +
+                "\"dept_no\": 567368506," +
+                "\"name\": \"绻佹槍鍖哄眬锛堣惀閿�閮級鐩戝療娉曡鍔瀄"," +
+                "\"parent_no\": 567418536," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567368506\"" +
+                "}, {" +
+                "\"dept_no\": 567354486," +
+                "\"name\": \"绻佹槍鍖哄眬锛堣惀閿�閮級鍔炲叕瀹"," +
+                "\"parent_no\": 567418536," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567354486\"" +
+                "}, {" +
+                "\"dept_no\": 566960827," +
+                "\"name\": \"绻佹槍鍖哄眬锛堣惀閿�閮級涓撳崠鐩戠潱绠$悊鍔炲叕瀹わ紙鍐呴儴涓撳崠绠$悊鐩戠潱鍔炲叕瀹ゃ�佺ń鏌ュぇ闃燂級\"," +
+                "\"parent_no\": 567418536," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566960827\"" +
+                "}, {" +
+                "\"dept_no\": 566649730," +
+                "\"name\": \"绻佹槍鍖哄眬锛堣惀閿�閮級鍩庡尯鐑熻崏涓撳崠绠$悊鎵�锛堟湇鍔$珯銆佺ń鏌ヤ腑闃燂級\"," +
+                "\"parent_no\": 567418536," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566649730\"" +
+                "}, {" +
+                "\"dept_no\": 566455834," +
+                "\"name\": \"绻佹槍鍖哄眬锛堣惀閿�閮級瀹㈡埛鏈嶅姟閮╘"," +
+                "\"parent_no\": 567418536," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566455834\"" +
+                "}, {" +
+                "\"dept_no\": 566975648," +
+                "\"name\": \"棰嗗鐝瓙\"," +
+                "\"parent_no\": 567418536," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"566975648\"" +
+                "}, {" +
+                "\"dept_no\": 822153494," +
+                "\"name\": \"鍖哄煙鍒嗕腑蹇僜"," +
+                "\"parent_no\": 567458554," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"822153494\"" +
+                "}, {" +
+                "\"dept_no\": 567328559," +
+                "\"name\": \"涓撳崠鐩戠潱绠$悊绉戯紙鍐呴儴涓撳崠绠$悊鐩戠潱绉戙�佺ń鏌ユ敮闃燂級琛屽姩缁刓"," +
+                "\"parent_no\": 567458554," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567328559\"" +
+                "}, {" +
+                "\"dept_no\": 567476616," +
+                "\"name\": \"涓撳崠鐩戠潱绠$悊绉戯紙鍐呴儴涓撳崠绠$悊鐩戠潱绉戙�佺ń鏌ユ敮闃燂級鏁版嵁鍒嗘瀽缁刓"," +
+                "\"parent_no\": 567458554," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"567476616\"" +
+                "}, {" +
+                "\"dept_no\": 821950791," +
+                "\"name\": \"鐜板満妫�鏌ョ粍\"," +
+                "\"parent_no\": 822153494," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"821950791\"" +
+                "}, {" +
+                "\"dept_no\": 922652428," +
+                "\"name\": \"缁煎悎绠$悊缁刓"," +
+                "\"parent_no\": 822153494," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"922652428\"" +
+                "}, {" +
+                "\"dept_no\": 822188538," +
+                "\"name\": \"鏁版嵁鍒嗘瀽缁刓"," +
+                "\"parent_no\": 822153494," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"822188538\"" +
+                "}, {" +
+                "\"dept_no\": 981649568," +
+                "\"name\": \"閮ㄩ棬棰嗗\"," +
+                "\"parent_no\": 567080624," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"981649568\"" +
+                "}, {" +
+                "\"dept_no\": 982346282," +
+                "\"name\": \"閮ㄩ棬棰嗗\"," +
+                "\"parent_no\": 567458554," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"982346282\"" +
+                "}, {" +
+                "\"dept_no\": 998004621," +
+                "\"name\": \"閮ㄩ棬棰嗗\"," +
+                "\"parent_no\": 822153494," +
+                "\"type\": 0," +
+                "\"status\": 1," +
+                "\"integrate_id\": \"998004621\"" +
+                "}]" ;
+       TypeReference typeReference =
+                new TypeReference<     List<DeptEntityModel> >() {
+                };
+         List<DeptEntityModel> list = com.alibaba.fastjson.JSONObject.parseObject(temp, typeReference.getType());
+        CompanyServiceImpl obj = new CompanyServiceImpl();
+        list = obj.sortJdyListBYParent(list,483636217);
+        list.size();
+
+    }
+
+    private void dealCompanyChangeListJdy(List<DeptEntityModel> list, List<Company> addList, List<Company> updateList,
+                                          List<Company> delIds, List<Company> allList) {
+        Date date = new Date();
+        for(DeptEntityModel respone : list){
+            Company param = new Company();
+            param.setName(respone.getName());
+            param.setErpId(respone.getDept_no().toString());
+            param.setErpParentId(respone.getParent_no() !=null?respone.getParent_no() .toString():null);
+            param.setSortnum(respone.getSeq()!=null?respone.getSeq().intValue():null);//榛樿鏈�涓婇潰
+            //鏍规嵁erpid鏌ヨ浼佷笟淇℃伅锛屽垽鏂槸鏂板杩樻槸鏇存柊
+            Company company = findCompanyByERPId(allList,respone.getDept_no().toString());
+            if(company == null){
+                //灏佽鏂板缁勭粐瀵硅薄鏁版嵁
+                addList.add(getAddCompanyModel(param));
+            }else{
+                updateList.add(getUpdateCompanyModel(param,company));
+            }
+        }
+        if(allList!=null && allList.size()>0){
+            for(Company  c : allList){
+                if(!isCompanyDeletedJdy(c,list)){
+                    delIds.add(c);
+                }
+            }
+        }
+    }
+    private void dealCompanyChangeList(List<OapiV2DepartmentGetResponse.DeptGetResponse> list, List<Company> addList,
+                                       List<Company> updateList, List<Company> delIds, List<Company> allList) {
         Date date = new Date();
         for(OapiV2DepartmentGetResponse.DeptGetResponse respone : list){
+            Company param = new Company();
+            param.setName(respone.getName());
+            param.setErpId(respone.getDeptId().toString());
+            param.setErpParentId(respone.getParentId().toString());
+            param.setSortnum(respone.getOrder().intValue());//榛樿鏈�涓婇潰
             //鏍规嵁erpid鏌ヨ浼佷笟淇℃伅锛屽垽鏂槸鏂板杩樻槸鏇存柊
             Company company = findCompanyByERPId(allList,respone.getDeptId().toString());
             if(company == null){
                 //濡傛灉鏄柊澧�
                 //灏佽鏂板缁勭粐瀵硅薄鏁版嵁
-                addList.add(getAddCompanyModel(respone,new Company()));
+                addList.add(getAddCompanyModel(param));
             }else{
-                updateList.add(getUpdateCompanyModel(respone,company));
+                updateList.add(getUpdateCompanyModel(param,company));
             }
         }
         if(allList!=null && allList.size()>0){
             for(Company  c : allList){
                 if(!isCompanyDeleted(c,list)){
-                    delIds.add(Long.valueOf(c.getErpId()));
+                    delIds.add(c);
                 }
             }
         }
     }
 
-
     /**
      * 鏁寸悊閽夐拤鍚屾 鏂板缁勭粐瀵硅薄
-     * @param deptGetResponse
      * @return
      */
-    private Company getAddCompanyModel(OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse,Company company) {
-        return  syncDDAddCompanyModel(deptGetResponse,company);
+    private Company getAddCompanyModel(Company param ) {
+        return  syncDDAddCompanyModel(param);
     }
 
     /**
      * 鏁寸悊閽夐拤鍚屾 鏂板 闇�瑕佷慨鏀圭殑缁勭粐瀵硅薄
-     * @param deptGetResponse
+     * @param param
      * @param company
      * @return
      */
-    private Company getUpdateCompanyModel(OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse, Company company) {
-        return syncDDEditCompanyModel(deptGetResponse,company);
+    private Company getUpdateCompanyModel(Company param, Company company) {
+        return syncDDEditCompanyModel(param,company);
     }
-
 
     /**
      * 鏍规嵁ERPID  鍒ゆ柇鏁版嵁鏄惁宸插湪闆嗗悎閲屽瓨鍦�
@@ -937,40 +1769,47 @@
         }
         return false;
     }
+    private boolean isCompanyDeletedJdy(Company c, List<DeptEntityModel> list) {
+        for(DeptEntityModel  m : list){
+            if(StringUtils.equals(c.getErpId(),m.getDept_no().toString())){
+                return  true;
+            }
+        }
+        return false;
+    }
 
 
     /**
      * 鏁寸悊 閽夐拤鍚屾鐨� 缁勭粐淇℃伅
-     * @param deptGetResponse
-     * @param company
+     * @param param
      * @return
      */
-    public Company syncDDAddCompanyModel(OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse,Company company){
-        company = new Company();
+    public Company syncDDAddCompanyModel(Company param ){
+        Company  company = new Company();
         company.setCreateDate(new Date());
         company.setIsdeleted(Constants.ZERO);
         company.setStatus(Constants.ZERO);
 
-        company.setName(deptGetResponse.getName());
-        company.setErpId(deptGetResponse.getDeptId().toString());
-        company.setErpParentId(deptGetResponse.getParentId().toString());
-        company.setSortnum(deptGetResponse.getOrder().intValue());//榛樿鏈�涓婇潰
+        company.setName(param.getName());
+        company.setErpId(param.getErpId() );
+        company.setErpParentId(param.getErpParentId());
+        company.setSortnum(param.getSortnum());//榛樿鏈�涓婇潰
 
         company.setType(Constants.ONE);
         String rootOrgId = systemDictDataBiz.queryByCode(Constants.HK_PARAM,Constants.HK_ROOTORG_CODE).getCode();
+        String jdyRootId = systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.JDY_COMPANY_ROOT_NO).getCode();
+        Company root =getRootCompanyModel(rootOrgId,jdyRootId);
+        company.setHkParentId(rootOrgId);
         company.setCompanyPath(company.getId()+"/");//鍚嶇О璺緞
         company.setCompanyNamePath(company.getName());//鍚嶇О璺緞
-        company.setHkParentId(rootOrgId);
         String idPath = "";
-        if(StringUtils.isNotBlank(company.getErpParentId())){
-            Company parent = companyMapper.selectOne(new QueryWrapper<Company>().lambda().eq(Company::getErpId,company.getErpParentId())
+        if(StringUtils.isNotBlank(param.getErpParentId())){
+            Company parent = companyMapper.selectOne(new QueryWrapper<Company>().lambda().eq(Company::getErpId,param.getErpParentId())
                     .eq(Company::getIsdeleted,Constants.ZERO).last(" limit 1 "));
             if(parent == null || Constants.equalsInteger(parent.getIsdeleted(),Constants.ONE)){
-                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "瀵逛笉璧凤紝鐖剁骇缁勭粐淇℃伅涓嶅瓨鍦▇");
+                //鐖剁骇涓嶅瓨鍦ㄧ殑锛岀洿鎺ユ寕鍦ㄦ牴缁勭粐涓�
+                parent = root;
             }
-//            if(StringUtils.isBlank(parent.getHkId())){
-//                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "瀵逛笉璧凤紝鐖剁骇缁勭粐淇℃伅灏氭湭鍚屾涓嬪彂鎴愬姛~");
-//            }
             if(Objects.nonNull(parent.getType())&&!Constants.equalsInteger(parent.getType(),-1)){
                 if(!Constants.equalsInteger(company.getType(),parent.getType())){
                     throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝缁勭粐淇℃伅閿欒");
@@ -996,34 +1835,78 @@
         companyMapper.insert(company);
 
         company.setHkId(UUID.randomUUID().toString().replace("-",""));
+        Company com = new Company();
+        com.setId(company.getId());
+        com.setCompanyPath(idPath+company.getId()+"/");
+        companyMapper.updateById(com);
         //涓嬪彂娴峰悍瀹夐槻骞冲彴
-        Boolean issueStatus = addHkOrg(company);
+    /*    Boolean issueStatus = addHkOrg(company);
         Company com = new Company();
         com.setId(company.getId());
         com.setHkId(issueStatus?company.getHkId():null);
         com.setHkStatus(issueStatus?Constants.ONE:Constants.TWO);
-        com.setCompanyPath(idPath+company.getId()+"/");
-        companyMapper.updateById(com);
+        companyMapper.updateById(com);*/
         return company;
     }
 
+    /**
+     * 鍐呯疆鏍圭粍缁�
+     * @param rootOrgId
+     * @return
+     */
+    private Company getRootCompanyModel(String rootOrgId,String erpId) {
+        Company root = companyMapper.selectOne(new QueryWrapper<Company>().lambda()
+                .eq(Company::getIsdeleted,Constants.ZERO)
+                .isNull(Company::getParentId)
+                .last(" limit 1 "));
+        if(root== null){
+            String name =systemDictDataBiz.queryByCode(Constants.HK_PARAM,Constants.HK_ROOTORG_NAME).getCode();
+            name =StringUtils.defaultString(name,"鏍圭粍缁�");
+            root = new Company();
+            root.setCreateDate(new Date());
+            root.setEditDate(new Date());
+            root.setName(name);
+            root.setType(-1);
+            root.setHkId(rootOrgId);
+            root.setHkStatus(Constants.ONE);
+            root.setIsdeleted(Constants.ZERO);
+            root.setStatus(Constants.ZERO);
+            root.setErpId(erpId);
+            root.setHkCompanyPath(rootOrgId+"/");
+            root.setCompanyNamePath(root.getName());
+            root.setHkDate(new Date());
+            root.setRemark("榛樿鏍圭粍缁�");
+            companyMapper.insert(root);
+            root.setCompanyPath(root.getId()+"/");
+            companyMapper.updateById(root);
+        }
+        return root;
 
-    public Company syncDDEditCompanyModel(OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse,Company company){
-        company.setErpParentId(deptGetResponse.getParentId().toString());
+    }
+
+
+    public Company syncDDEditCompanyModel(Company param,Company company){
+        company.setErpParentId(param.getErpParentId().toString());
+        String rootOrgId = systemDictDataBiz.queryByCode(Constants.HK_PARAM,Constants.HK_ROOTORG_CODE).getCode();
+        String jdyRootId = systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.JDY_COMPANY_ROOT_NO).getCode();
+        Company root =getRootCompanyModel(rootOrgId,jdyRootId);
         String idPath = "";
         if(StringUtils.isNotBlank(company.getErpParentId())){
-            Company parent = companyMapper.selectOne(new QueryWrapper<Company>().lambda().eq(Company::getErpId,company.getErpParentId())
-                    .eq(Company::getIsdeleted,Constants.ZERO).last("limit 1 "));
+            Company parent = companyMapper.selectOne(new QueryWrapper<Company>().lambda()
+                    .eq(Company::getErpId,company.getErpParentId())
+                    .eq(Company::getType,Constants.ONE)
+                    .eq(Company::getIsdeleted,Constants.ZERO)
+                    .last("limit 1 "));
             if(parent == null || Constants.equalsInteger(parent.getIsdeleted(),Constants.ONE)){
-                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "瀵逛笉璧凤紝鐖剁骇缁勭粐淇℃伅涓嶅瓨鍦▇");
+              parent =root;
             }
-            if(Objects.nonNull(parent.getType())&&!Constants.equalsInteger(parent.getType(),-1)){
+           /*if(Objects.nonNull(parent.getType())&&!Constants.equalsInteger(parent.getType(),-1)){
                 if(!Constants.equalsInteger(company.getType(),parent.getType())){
                     throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝缁勭粐淇℃伅閿欒");
                 }
             }else if(Objects.isNull(parent.getType())){
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝缁勭粐淇℃伅閿欒");
-            }
+            }*/
             idPath = parent.getCompanyPath();
             company.setHkParentId(parent.getHkId());
             company.setCompanyPath(parent.getCompanyPath()+company.getId()+"/");
@@ -1031,43 +1914,40 @@
             company.setParentId(parent.getId());
         }
 
-        company.setName(deptGetResponse.getName());
-        company.setErpId(deptGetResponse.getDeptId().toString());
-        company.setErpParentId(deptGetResponse.getParentId().toString());
-        company.setSortnum(deptGetResponse.getOrder().intValue());//榛樿鏈�涓婇潰
+        company.setName(param.getName());
+        company.setErpId(param.getErpId());
+        company.setSortnum(param.getSortnum());//榛樿鏈�涓婇潰
         company.setEditDate(new Date());
-        company.setHkCompanyPath(company.getCompanyNamePath());
+//        company.setHkCompanyPath(company.getCompanyNamePath());
         company.setHkStatus(Constants.ZERO);
         company.setStatus(Constants.ZERO);
-        company.setSortnum(deptGetResponse.getOrder().intValue());
         company.setHkDate(company.getCreateDate());
         company.setEditDate(company.getCreateDate());
         company.setEditor(company.getCreator());
         company.setPinyin(Constants.getChinesePingyin(company.getName()));
         companyMapper.updateById(company);
         //涓嬪彂娴峰悍瀹夐槻骞冲彴
-        Boolean issueStatus = editHkOrg(company);
+     /*   Boolean issueStatus = editHkOrg(company);
         Company com = new Company();
         com.setId(company.getId());
         com.setHkId(issueStatus?company.getHkId():null);
         com.setHkStatus(issueStatus?Constants.ONE:Constants.TWO);
         com.setCompanyPath(idPath+company.getId()+"/");
-        companyMapper.updateById(com);
+        companyMapper.updateById(com);*/
         return company;
     }
 
 
 
-    public void syncDelCompany(List<Long> deptIdList){
-        List<Company> companyList = companyMapper.selectList(new QueryWrapper<Company>()
+    public void syncDelCompany(List<Company> companyList ){
+/*        List<Company> companyList = companyMapper.selectList(new QueryWrapper<Company>()
                 .lambda()
                 .eq(Company::getIsdeleted,Constants.ZERO)
-                .in(Company::getErpId,deptIdList)
-        );
+                .in(Company::getId,deptIdList)
+        );*/
         if(CollectionUtils.isNotEmpty(companyList)){
             List<Integer> delIds = companyList.stream().map(i->i.getId()).collect(Collectors.toList());
             List<String> delHKIds = companyList.stream().filter(i->StringUtils.isNotBlank(i.getHkId())).map(i->i.getHkId()).collect(Collectors.toList());
-
             //鏍囪涓氬姟鍒犻櫎
             companyMapper.update(new UpdateWrapper<Company>().lambda()
                     .set(Company::getIsdeleted,Constants.ONE)
@@ -1078,7 +1958,5 @@
             doHkDeleteOrg(delIds,delHKIds,new Date());
         }
     }
-
-
 
 }

--
Gitblit v1.9.3