Commit 1a68a9beee6c768e19a06d6e7bdc4f4caf847c5b

Authored by 陶汉栋
2 parents 4716fae1 8d9531c0
Exists in master

Merge remote-tracking branch 'origin/master'

cloud/quartz/src/main/java/com/sincere/quartz/third/yixueyun/YXYReadService.java
... ... @@ -5,12 +5,13 @@ import com.alibaba.fastjson.JSONObject;
5 5 import com.sincere.common.util.DateUtils;
6 6 import com.sincere.common.util.HttpClientUtils;
7 7 import com.sincere.common.util.Xml2JsonUtils;
8   -import com.sincere.quartz.feign.ScFeign;
9 8 import com.sincere.quartz.model.YxyAgency;
10 9 import com.sincere.quartz.model.YxyStudent;
11 10 import com.sincere.quartz.model.YxyTeacher;
12 11 import com.sincere.quartz.service.YxyService;
13 12 import org.apache.commons.lang3.StringUtils;
  13 +import org.slf4j.Logger;
  14 +import org.slf4j.LoggerFactory;
14 15 import org.springframework.beans.factory.annotation.Autowired;
15 16 import org.springframework.stereotype.Service;
16 17  
... ... @@ -42,6 +43,8 @@ public class YXYReadService {
42 43 @Autowired
43 44 YxyService yxyService ;
44 45  
  46 + private Logger logger = LoggerFactory.getLogger(YXYReadService.class);
  47 +
45 48 public void sync(){
46 49 List<String> areaCodeList = new ArrayList<>();
47 50 areaCodeList.add("0571") ;
... ... @@ -59,34 +62,41 @@ public class YXYReadService {
59 62 yxyService.updateStudent();
60 63 yxyService.updateTeacher();
61 64 for(String areaCode : areaCodeList){
62   - // 先获取学校,部门,年级 班级
63   - // 再根据学校 获取老师 学生
64   - List list = new ArrayList();
65   - list.add(SI);
66   - list.add(getPassword(SI_CODE));
67   - list.add(areaCode);
68   - String wsdl =getAllDept ;
69   - String ns = nameSpace;
70   - String method = getALlDept_method;
71   - JSONArray jsonArray = getMessage(wsdl, ns, method, list);
72   - if(jsonArray != null){
73   - List<String> schoolList = new ArrayList<>();
74   - for(int i = 0 ; i < jsonArray.size() ; i++){
75   - JSONObject object = (JSONObject) jsonArray.get(i) ;
76   - YxyAgency agency = new YxyAgency() ;
77   - agency.setDeptId(object.get("deptID").toString());
78   - agency.setDeptName(object.get("deptName").toString());
79   - agency.setSuperDeptId(object.get("superDeptID").toString());
80   - if(areaCode.equals(object.get("superDeptID").toString())){
81   - schoolList.add(object.get("deptID").toString()) ;
  65 + try{
  66 + // 先获取学校,部门,年级 班级
  67 + // 再根据学校 获取老师 学生
  68 + List list = new ArrayList();
  69 + list.add(SI);
  70 + list.add(getPassword(SI_CODE));
  71 + list.add(areaCode);
  72 + String wsdl =getAllDept ;
  73 + String ns = nameSpace;
  74 + String method = getALlDept_method;
  75 + JSONArray jsonArray = getMessage(wsdl, ns, method, list);
  76 + if(jsonArray != null){
  77 + List<String> schoolList = new ArrayList<>();
  78 + for(int i = 0 ; i < jsonArray.size() ; i++){
  79 + logger.info("市编码:" + areaCode);
  80 + JSONObject object = (JSONObject) jsonArray.get(i) ;
  81 + YxyAgency agency = new YxyAgency() ;
  82 + agency.setDeptId(object.get("deptID").toString());
  83 + agency.setDeptName(object.get("deptName").toString());
  84 + agency.setSuperDeptId(object.get("superDeptID").toString());
  85 + if(areaCode.equals(object.get("superDeptID").toString())){
  86 + logger.info("学校:" + object.get("deptName").toString());
  87 + schoolList.add(object.get("deptID").toString()) ;
  88 + }
  89 + yxyService.insertAgency(agency);
  90 + }
  91 + for(String schoolId : schoolList){
  92 + syncTeacher(schoolId) ;
  93 + syncStudent(schoolId) ;
82 94 }
83   - yxyService.insertAgency(agency);
84   - }
85   - for(String schoolId : schoolList){
86   - syncTeacher(schoolId) ;
87   - syncStudent(schoolId) ;
88 95 }
  96 + }catch (Exception e){
  97 + e.printStackTrace();
89 98 }
  99 +
90 100 }
91 101 }
92 102  
... ... @@ -100,6 +110,7 @@ public class YXYReadService {
100 110 String ns = nameSpace;
101 111 String method = getALlStudent_method;
102 112 JSONArray jsonArray = getMessage(wsdl, ns, method, list);
  113 + logger.info("学校ID为:"+schoolId + "共有学生" + jsonArray.size() +"人");
103 114 if(jsonArray != null){
104 115 for(int i = 0 ; i < jsonArray.size() ; i++){
105 116 JSONObject object = (JSONObject) jsonArray.get(i) ;
... ... @@ -122,6 +133,7 @@ public class YXYReadService {
122 133 String ns = nameSpace;
123 134 String method = getAllTeacher_method;
124 135 JSONArray jsonArray = getMessage(wsdl, ns, method, list);
  136 + logger.info("学校ID为:"+schoolId + "共有老师" + jsonArray.size() +"人");
125 137 if(jsonArray != null){
126 138 for(int i = 0 ; i < jsonArray.size() ; i++){
127 139 JSONObject object = (JSONObject) jsonArray.get(i) ;
... ...