Commit e87d4e3a9fba17b5fa375bf19ac12075a9c7bb41
1 parent
efa9935f
Exists in
master
翼学云读写 接口
Showing
9 changed files
with
507 additions
and
19 deletions
Show diff stats
cloud/common/pom.xml
... | ... | @@ -90,6 +90,16 @@ |
90 | 90 | <version>0.0.20131108.vaadin1</version> |
91 | 91 | <scope>compile</scope> |
92 | 92 | </dependency> |
93 | + <dependency> | |
94 | + <groupId>dom4j</groupId> | |
95 | + <artifactId>dom4j</artifactId> | |
96 | + <version>1.6.1</version> | |
97 | + </dependency> | |
98 | + <dependency> | |
99 | + <groupId>commons-httpclient</groupId> | |
100 | + <artifactId>commons-httpclient</artifactId> | |
101 | + <version>3.1</version> | |
102 | + </dependency> | |
93 | 103 | </dependencies> |
94 | 104 | |
95 | 105 | <build> | ... | ... |
cloud/common/src/main/java/com/sincere/common/util/DateUtils.java
cloud/common/src/main/java/com/sincere/common/util/HttpClientUtils.java
1 | 1 | package com.sincere.common.util; |
2 | 2 | |
3 | -import com.alibaba.fastjson.JSONArray; | |
4 | 3 | import com.alibaba.fastjson.JSONObject; |
4 | +import org.apache.commons.httpclient.HttpClient; | |
5 | +import org.apache.commons.httpclient.methods.InputStreamRequestEntity; | |
6 | +import org.apache.commons.httpclient.methods.PostMethod; | |
7 | +import org.apache.commons.httpclient.methods.RequestEntity; | |
5 | 8 | import org.apache.http.HttpEntity; |
6 | 9 | import org.apache.http.HttpStatus; |
7 | 10 | import org.apache.http.client.config.RequestConfig; |
... | ... | @@ -12,13 +15,15 @@ import org.apache.http.entity.StringEntity; |
12 | 15 | import org.apache.http.impl.client.CloseableHttpClient; |
13 | 16 | import org.apache.http.impl.client.HttpClients; |
14 | 17 | import org.apache.http.util.EntityUtils; |
15 | -import org.springframework.boot.autoconfigure.SpringBootApplication; | |
16 | 18 | |
19 | +import java.io.ByteArrayInputStream; | |
17 | 20 | import java.io.IOException; |
18 | 21 | import java.io.InputStream; |
19 | 22 | import java.net.HttpURLConnection; |
20 | 23 | import java.net.URL; |
21 | -import java.util.Date; | |
24 | +import java.util.List; | |
25 | + | |
26 | +import static jdk.nashorn.internal.runtime.ECMAErrors.getMessage; | |
22 | 27 | |
23 | 28 | /** |
24 | 29 | * HttpClient4.3工具类 |
... | ... | @@ -36,15 +41,15 @@ public class HttpClientUtils { |
36 | 41 | } |
37 | 42 | |
38 | 43 | public static void main(String[] args){ |
39 | -// JSONObject object = HttpClientUtils.httpGet("http://60.190.202.57:1000/api/EasyN/GeAttendDetailNew?Id=158&TemplateId=0IZBD9624P&Type=0&time=2019-12-12&UserId=P113111&SchoolId=16"); | |
40 | -// JSONArray data = (JSONArray)object.get("data"); | |
41 | - String msg = "[{\"stuCount\":393,\"stuAttendCount\":341,\"noAttendCount\":52,\"sNoAttendCount\":52,\"leaveCount\":0,\"state\":\"已结束\",\"id\":310,\"templateId\":\"OCQQMV0ZXM\",\"color\":3}]"; | |
42 | - JSONArray data = JSONArray.parseArray(msg); | |
43 | - for(int i = 0 ; i < data.size() ; i++){ | |
44 | - JSONObject object = data.getJSONObject(i); | |
45 | - System.out.println(object.get("stuCount")); | |
46 | - } | |
47 | - System.out.println("1"); | |
44 | +// String url = "http://http://zhktest.114school.com.cn/szkjapi/toyxy/addTeacherOrg" ; | |
45 | +// String json = "{\"name\": \"子部门\",\"groupname\": \"父部门\",\"schoolid\": \"16\",\"token\": \"05719991\"}" ; | |
46 | +// JSONObject jsonObject = HttpClientUtils.httpPostJson(url,json); | |
47 | +// System.out.println(jsonObject.toJSONString()); | |
48 | + | |
49 | + String url = "http://115.239.135.60/token/yxt" ; | |
50 | + String json = "key=SZKJ&secret=87dyNIZReZNl6LXGsihfyX3unYgwukSk" ; | |
51 | + JSONObject jsonObject = HttpClientUtils.httpPost(url,json); | |
52 | + System.out.println(jsonObject.toJSONString()); | |
48 | 53 | } |
49 | 54 | |
50 | 55 | /** |
... | ... | @@ -170,4 +175,55 @@ public class HttpClientUtils { |
170 | 175 | } |
171 | 176 | return null ; |
172 | 177 | } |
178 | + | |
179 | + /** | |
180 | + * | |
181 | + * @param wsdl | |
182 | + * @param ns | |
183 | + * @param method | |
184 | + * @param list 参数 | |
185 | + * @return | |
186 | + */ | |
187 | + public synchronized static String invoiceWebService(String wsdl, String ns, String method, List<String> list){ | |
188 | + StringBuffer stringBuffer = new StringBuffer(); | |
189 | + //拼接参数 | |
190 | + for (int i = 0; i < list.size(); i++) { | |
191 | + stringBuffer.append("<arg" + i + ">" + list.get(i) + "</arg" + i + ">"); | |
192 | + } | |
193 | + //拼接SOAP | |
194 | + StringBuffer soapRequestData = new StringBuffer(""); | |
195 | + soapRequestData.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ser=\"http://service.info.employee.staffing.talentbase.neusoft.com/\">"); | |
196 | + soapRequestData.append("<soapenv:Header/>"); | |
197 | + soapRequestData.append("<soapenv:Body>"); | |
198 | + soapRequestData.append("<ser:" + method + ">"); | |
199 | + soapRequestData.append(stringBuffer); | |
200 | + soapRequestData.append("</ser:" + method + ">"); | |
201 | + soapRequestData.append("</soapenv:Body>" + "</soapenv:Envelope>"); | |
202 | + PostMethod postMethod = new PostMethod(wsdl); | |
203 | + // 然后把Soap请求数据添加到PostMethod中 | |
204 | + byte[] b = null; | |
205 | + InputStream is = null; | |
206 | + try { | |
207 | + b = soapRequestData.toString().getBytes("utf-8"); | |
208 | + is = new ByteArrayInputStream(b, 0, b.length); | |
209 | + RequestEntity re = new InputStreamRequestEntity(is, b.length, "text/xml; charset=UTF-8"); | |
210 | + postMethod.setRequestEntity(re); | |
211 | + HttpClient httpClient = new HttpClient(); | |
212 | + int status = httpClient.executeMethod(postMethod); | |
213 | + if (status == 200) { | |
214 | + return postMethod.getResponseBodyAsString() ; | |
215 | + } | |
216 | + } catch (Exception e) { | |
217 | + e.printStackTrace(); | |
218 | + } finally { | |
219 | + try{ | |
220 | + if (is != null) { | |
221 | + is.close(); | |
222 | + } | |
223 | + }catch (Exception e){ | |
224 | + | |
225 | + } | |
226 | + } | |
227 | + return null; | |
228 | + } | |
173 | 229 | } | ... | ... |
cloud/common/src/main/java/com/sincere/common/util/Xml2JsonUtils.java
0 → 100644
... | ... | @@ -0,0 +1,113 @@ |
1 | +package com.sincere.common.util; | |
2 | + | |
3 | +import com.alibaba.fastjson.JSONArray; | |
4 | +import com.alibaba.fastjson.JSONObject; | |
5 | +import org.dom4j.*; | |
6 | + | |
7 | +import java.util.List; | |
8 | + | |
9 | +/** | |
10 | + * @author chen | |
11 | + * @version 1.0 | |
12 | + * @date 2019/12/26 0026 10:19 | |
13 | + */ | |
14 | +public class Xml2JsonUtils { | |
15 | + | |
16 | + | |
17 | + public static void main(String[] args) throws Exception { | |
18 | + String xmlStr= | |
19 | + "<JXT Name=\"TeacherInfo\">" + | |
20 | + "<resultInfo><userID>9943601</userID><name>abd</name><classID>05750400</classID><account>13388685716</account><cardID></cardID><cardID2></cardID2><cardID3></cardID3><cardID4></cardID4><cardID5></cardID5><career>校管理员</career><familyPhone1></familyPhone1><familyPhone2>0</familyPhone2><familyPhone3>0</familyPhone3><tempString></tempString><tempString2></tempString2><tempString3></tempString3></resultInfo>" + | |
21 | + "<resultInfo><userID>18639924</userID><name>计老师</name><classID>05750400-D000001</classID><account>15757371362</account><cardID></cardID><cardID2></cardID2><cardID3></cardID3><cardID4></cardID4><cardID5></cardID5><career>教师</career><familyPhone1></familyPhone1><familyPhone2>0</familyPhone2><familyPhone3>0</familyPhone3><tempString></tempString><tempString2></tempString2><tempString3></tempString3></resultInfo>" + | |
22 | + "<resultInfo><userID>30962787</userID><name>王佳奕1</name><classID>05750400-D000001</classID><account>13000000000</account><cardID></cardID><cardID2></cardID2><cardID3></cardID3><cardID4></cardID4><cardID5></cardID5><career>教师</career><familyPhone1></familyPhone1><familyPhone2>0</familyPhone2><familyPhone3>0</familyPhone3><tempString></tempString><tempString2></tempString2><tempString3></tempString3></resultInfo>" + | |
23 | + "</JXT>"; | |
24 | + Document doc= DocumentHelper.parseText(xmlStr); | |
25 | + JSONObject json=new JSONObject(); | |
26 | + dom4j2Json(doc.getRootElement(),json); | |
27 | + System.out.println("xml2Json:"+json.toJSONString()); | |
28 | + } | |
29 | + | |
30 | + /** | |
31 | + * xml转json | |
32 | + * @param xmlStr | |
33 | + * @return | |
34 | + * @throws DocumentException | |
35 | + */ | |
36 | + public static JSONObject xml2Json(String xmlStr){ | |
37 | + try{ | |
38 | + Document doc= DocumentHelper.parseText(xmlStr); | |
39 | + JSONObject json=new JSONObject(); | |
40 | + dom4j2Json(doc.getRootElement(), json); | |
41 | + return json; | |
42 | + }catch (Exception e){ | |
43 | + | |
44 | + } | |
45 | + return null ; | |
46 | + } | |
47 | + | |
48 | + /** | |
49 | + * xml转json | |
50 | + * @param element | |
51 | + * @param json | |
52 | + */ | |
53 | + public static void dom4j2Json(Element element,JSONObject json){ | |
54 | + //如果是属性 | |
55 | + for(Object o:element.attributes()){ | |
56 | + Attribute attr=(Attribute)o; | |
57 | + if(!isEmpty(attr.getValue())){ | |
58 | + json.put("@"+attr.getName(), attr.getValue()); | |
59 | + } | |
60 | + } | |
61 | + List<Element> chdEl=element.elements(); | |
62 | + if(chdEl.isEmpty()&&!isEmpty(element.getText())){//如果没有子元素,只有一个值 | |
63 | + json.put(element.getName(), element.getText()); | |
64 | + } | |
65 | + | |
66 | + for(Element e:chdEl){//有子元素 | |
67 | + if(!e.elements().isEmpty()){//子元素也有子元素 | |
68 | + JSONObject chdjson=new JSONObject(); | |
69 | + dom4j2Json(e,chdjson); | |
70 | + Object o=json.get(e.getName()); | |
71 | + if(o!=null){ | |
72 | + JSONArray jsona=null; | |
73 | + if(o instanceof JSONObject){//如果此元素已存在,则转为jsonArray | |
74 | + JSONObject jsono=(JSONObject)o; | |
75 | + json.remove(e.getName()); | |
76 | + jsona=new JSONArray(); | |
77 | + jsona.add(jsono); | |
78 | + jsona.add(chdjson); | |
79 | + } | |
80 | + if(o instanceof JSONArray){ | |
81 | + jsona=(JSONArray)o; | |
82 | + jsona.add(chdjson); | |
83 | + } | |
84 | + json.put(e.getName(), jsona); | |
85 | + }else{ | |
86 | + if(!chdjson.isEmpty()){ | |
87 | + json.put(e.getName(), chdjson); | |
88 | + } | |
89 | + } | |
90 | + | |
91 | + | |
92 | + }else{//子元素没有子元素 | |
93 | + for(Object o:element.attributes()){ | |
94 | + Attribute attr=(Attribute)o; | |
95 | + if(!isEmpty(attr.getValue())){ | |
96 | + json.put("@"+attr.getName(), attr.getValue()); | |
97 | + } | |
98 | + } | |
99 | + if(!e.getText().isEmpty()){ | |
100 | + json.put(e.getName(), e.getText()); | |
101 | + } | |
102 | + } | |
103 | + } | |
104 | + } | |
105 | + | |
106 | + public static boolean isEmpty(String str) { | |
107 | + | |
108 | + if (str == null || str.trim().isEmpty() || "null".equals(str)) { | |
109 | + return true; | |
110 | + } | |
111 | + return false; | |
112 | + } | |
113 | +} | ... | ... |
cloud/quartz/pom.xml
... | ... | @@ -12,13 +12,13 @@ |
12 | 12 | <artifactId>quartz</artifactId> |
13 | 13 | |
14 | 14 | <dependencies> |
15 | - <dependency> | |
16 | - <groupId>taobao-sdk-java-auto</groupId> | |
17 | - <artifactId>ding</artifactId> | |
18 | - <scope>system</scope> | |
19 | - <version>1</version> | |
20 | - <systemPath>${project.basedir}/lib/taobao-sdk-java-auto_1479188381469-20191205.jar</systemPath> | |
21 | - </dependency> | |
15 | +<!-- <dependency>--> | |
16 | +<!-- <groupId>taobao-sdk-java-auto</groupId>--> | |
17 | +<!-- <artifactId>ding</artifactId>--> | |
18 | +<!-- <scope>system</scope>--> | |
19 | +<!-- <version>1</version>--> | |
20 | +<!-- <systemPath>${project.basedir}/lib/taobao-sdk-java-auto_1479188381469-20191205.jar</systemPath>--> | |
21 | +<!-- </dependency>--> | |
22 | 22 | <dependency> |
23 | 23 | <groupId>com.sincere</groupId> |
24 | 24 | <artifactId>common</artifactId> | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/third/yixueyun/YXYReadService.java
0 → 100644
... | ... | @@ -0,0 +1,113 @@ |
1 | +package com.sincere.quartz.third.yixueyun; | |
2 | + | |
3 | +import com.alibaba.fastjson.JSONArray; | |
4 | +import com.alibaba.fastjson.JSONObject; | |
5 | +import com.sincere.common.util.DateUtils; | |
6 | +import com.sincere.common.util.HttpClientUtils; | |
7 | +import com.sincere.common.util.Xml2JsonUtils; | |
8 | +import com.sincere.quartz.feign.ScFeign; | |
9 | +import org.apache.commons.lang3.StringUtils; | |
10 | +import org.springframework.beans.factory.annotation.Autowired; | |
11 | +import org.springframework.stereotype.Service; | |
12 | + | |
13 | +import java.math.BigInteger; | |
14 | +import java.security.MessageDigest; | |
15 | +import java.util.ArrayList; | |
16 | +import java.util.Date; | |
17 | +import java.util.List; | |
18 | + | |
19 | +@Service | |
20 | +public class YXYReadService { | |
21 | + | |
22 | + private static String SI = "SZ" ; | |
23 | + private static int SI_CODE = 12345678 ; | |
24 | + | |
25 | + private static String nameSpace = "http://service.pubinfo.com.cn" ; | |
26 | + private static String getAllTeacher = "http://122.229.30.149:8282/DataSynService/GetTeacherInfo"; | |
27 | + private static String getAllTeacher_method = "getTeacherInfo" ; | |
28 | + private static String getAddTeacher = "http://122.229.30.149:8282/DataSynService/GetIncrementTeacherInfo" ; | |
29 | + private static String getAddTeacher_method = "getIncrementTeacherInfo" ; | |
30 | + | |
31 | + private static String getAllStudent = "http://122.229.30.149:8282/DataSynService/GetStudentInfo" ; | |
32 | + private static String getALlStudent_method = "getStudentInfo"; | |
33 | + private static String getAddStudent = "http://122.229.30.149:8282/DataSynService/GetIncrementStudentInfo" ; | |
34 | + private static String getAddStudent_method = "getIncrementStudentInfo" ; | |
35 | + | |
36 | + private static String getAllDept = "http://122.229.30.149:8282/DataSynService/GetDeptInfo" ; | |
37 | + private static String getALlDept_method = "getDeptInfo"; | |
38 | + | |
39 | + @Autowired | |
40 | + ScFeign scFeign ; | |
41 | + | |
42 | + public void sync(){ | |
43 | + List list = new ArrayList(); | |
44 | + list.add(SI); | |
45 | + list.add(getPassword(SI_CODE)); | |
46 | + list.add("05750400"); | |
47 | + String wsdl =getAllDept ; | |
48 | + String ns = nameSpace; | |
49 | + String method = getALlDept_method; | |
50 | + JSONArray jsonArray = getMessage(wsdl, ns, method, list); | |
51 | + System.out.println(jsonArray.toJSONString()); | |
52 | + } | |
53 | + | |
54 | + private void syncDept(){ | |
55 | + | |
56 | + } | |
57 | + | |
58 | + private void syncTeacher(){ | |
59 | + | |
60 | + } | |
61 | + | |
62 | + private void syncStudent(){ | |
63 | + | |
64 | + } | |
65 | + | |
66 | + private JSONArray getMessage(String wsdl, String ns, String method, List<String> list){ | |
67 | + String resultXml = HttpClientUtils.invoiceWebService(wsdl,ns,method,list); | |
68 | + if(StringUtils.isNotBlank(resultXml)){ | |
69 | + int begin = resultXml.indexOf("<JXT"); | |
70 | + int end = resultXml.indexOf("</JXT"); | |
71 | + String str = resultXml.substring(begin, end+9); | |
72 | + str = str.replaceAll("<", "<"); | |
73 | + str = str.replaceAll(">", ">"); | |
74 | + JSONObject json = Xml2JsonUtils.xml2Json(str); | |
75 | + if(json != null){ | |
76 | + return (JSONArray)json.get("resultInfo") ; | |
77 | + } | |
78 | + } | |
79 | + return null ; | |
80 | + } | |
81 | + | |
82 | + private String getPassword(int si){ | |
83 | + int date = Integer.valueOf(DateUtils.date2String(new Date(),DateUtils.format5)); | |
84 | + String pwd = String.valueOf(si&date) ; | |
85 | + while (pwd.length() < 6){ | |
86 | + pwd = "0" + pwd ; | |
87 | + } | |
88 | + pwd = pwd.substring(pwd.length() - 6); | |
89 | + return EncodeByMD5(pwd); | |
90 | + } | |
91 | + | |
92 | + private String EncodeByMD5(String str) { | |
93 | + try { | |
94 | + // 生成一个MD5加密计算摘要 | |
95 | + MessageDigest md = MessageDigest.getInstance("MD5"); | |
96 | + // 计算md5函数 | |
97 | + md.update(str.getBytes("UTF-8")); | |
98 | + // digest()最后确定返回md5 hash值,返回值为8为字符串。因为md5 hash值是16位的hex值,实际上就是8位的字符 | |
99 | + // BigInteger函数则将8位的字符串转换成16位hex值,用字符串来表示;得到字符串形式的hash值 | |
100 | + String md5 = new BigInteger(1, md.digest()).toString(16); | |
101 | + //BigInteger会把0省略掉,需补全至32位 | |
102 | + return fillMD5(md5); | |
103 | + } catch (Exception e) { | |
104 | + throw new RuntimeException("MD5加密错误:" + e.getMessage(), e); | |
105 | + } | |
106 | + } | |
107 | + | |
108 | + private String fillMD5(String md5){ | |
109 | + //如果不够32位则回调自身补零,最后返回32位长度的签名 | |
110 | + return md5.length()==32?md5:fillMD5("0"+md5); | |
111 | + } | |
112 | + | |
113 | +} | |
0 | 114 | \ No newline at end of file | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/third/yixueyun/YXYResult.java
0 → 100644
... | ... | @@ -0,0 +1,59 @@ |
1 | +package com.sincere.quartz.third.yixueyun; | |
2 | + | |
3 | +import java.io.Serializable; | |
4 | +import java.util.List; | |
5 | + | |
6 | +/** | |
7 | + * @author chen | |
8 | + * @version 1.0 | |
9 | + * @date 2019/12/24 0024 10:42 | |
10 | + */ | |
11 | +public class YXYResult implements Serializable { | |
12 | + | |
13 | + private int code ; | |
14 | + private String message ; | |
15 | + private int total ; | |
16 | + private int pass ; | |
17 | + private List<YXYResultDetail> data ; | |
18 | + | |
19 | + | |
20 | + public int getCode() { | |
21 | + return code; | |
22 | + } | |
23 | + | |
24 | + public void setCode(int code) { | |
25 | + this.code = code; | |
26 | + } | |
27 | + | |
28 | + public String getMessage() { | |
29 | + return message; | |
30 | + } | |
31 | + | |
32 | + public void setMessage(String message) { | |
33 | + this.message = message; | |
34 | + } | |
35 | + | |
36 | + public int getTotal() { | |
37 | + return total; | |
38 | + } | |
39 | + | |
40 | + public void setTotal(int total) { | |
41 | + this.total = total; | |
42 | + } | |
43 | + | |
44 | + public int getPass() { | |
45 | + return pass; | |
46 | + } | |
47 | + | |
48 | + public void setPass(int pass) { | |
49 | + this.pass = pass; | |
50 | + } | |
51 | + | |
52 | + public List<YXYResultDetail> getData() { | |
53 | + return data; | |
54 | + } | |
55 | + | |
56 | + public void setData(List<YXYResultDetail> data) { | |
57 | + this.data = data; | |
58 | + } | |
59 | +} | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/third/yixueyun/YXYResultDetail.java
0 → 100644
... | ... | @@ -0,0 +1,39 @@ |
1 | +package com.sincere.quartz.third.yixueyun; | |
2 | + | |
3 | +import java.io.Serializable; | |
4 | + | |
5 | +/** | |
6 | + * @author chen | |
7 | + * @version 1.0 | |
8 | + * @date 2019/12/24 0024 10:43 | |
9 | + */ | |
10 | +public class YXYResultDetail implements Serializable { | |
11 | + | |
12 | + private String id ; | |
13 | + private String name ; | |
14 | + private String err ; | |
15 | + | |
16 | + public String getId() { | |
17 | + return id; | |
18 | + } | |
19 | + | |
20 | + public void setId(String id) { | |
21 | + this.id = id; | |
22 | + } | |
23 | + | |
24 | + public String getName() { | |
25 | + return name; | |
26 | + } | |
27 | + | |
28 | + public void setName(String name) { | |
29 | + this.name = name; | |
30 | + } | |
31 | + | |
32 | + public String getErr() { | |
33 | + return err; | |
34 | + } | |
35 | + | |
36 | + public void setErr(String err) { | |
37 | + this.err = err; | |
38 | + } | |
39 | +} | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/third/yixueyun/YXYWriteService.java
0 → 100644
... | ... | @@ -0,0 +1,96 @@ |
1 | +package com.sincere.quartz.third.yixueyun; | |
2 | + | |
3 | +import com.alibaba.fastjson.JSON; | |
4 | +import com.alibaba.fastjson.JSONObject; | |
5 | +import com.sincere.common.util.HttpClientUtils; | |
6 | +import com.sincere.quartz.feign.ScFeign; | |
7 | +import org.springframework.beans.factory.annotation.Autowired; | |
8 | +import org.springframework.stereotype.Service; | |
9 | + | |
10 | +/** | |
11 | + * @author chen | |
12 | + * @version 1.0 | |
13 | + * @date 2019/12/24 0024 9:14 | |
14 | + */ | |
15 | +@Service | |
16 | +public class YXYWriteService { | |
17 | + private String TOKEN="" ; | |
18 | + | |
19 | + private static String key = "SZKJ"; | |
20 | + private static String secret = "87dyNIZReZNl6LXGsihfyX3unYgwukSk" ; | |
21 | + private static String prefix_url = "http://115.239.135.60"; | |
22 | + | |
23 | + private static String suffix_org_add = "/szkjapi/toyxybatch/addTeacherOrg" ; //部门添加 | |
24 | + private static String suffix_class_add = "/szkjapi/toyxybatch/addClass" ; //班级添加 | |
25 | + private static String suffix_student_add = "/szkjapi/toyxybatch/addStudent" ; //学生添加 | |
26 | + private static String suffix_teacher_add = "/szkjapi/toyxybatch/addTeacher" ; //老师添加 | |
27 | + | |
28 | + private static String suffix_org_update = "/szkjapi/toyxybatch/modifyOrg" ; //部门 班级修改 | |
29 | + private static String suffix_student_update = "/szkjapi/toyxybatch/modifyStudent" ; //学生修改 | |
30 | + private static String suffix_teacher_update = "/szkjapi/toyxybatch/modifyTeacher" ; //老师修改 | |
31 | + | |
32 | + private static String suffix_org_delete = "/szkjapi/toyxybatch/deleteOrg" ; //部门 班级 删除 | |
33 | + private static String suffix_user_delete = "/szkjapi/toyxybatch/deleteUser" ; //老师学生 删除 | |
34 | + | |
35 | + | |
36 | + @Autowired | |
37 | + ScFeign scFeign ; | |
38 | + | |
39 | + public void sync(){ | |
40 | + //查出要同步的学校 | |
41 | + | |
42 | + //同步的部门 ,新增 修改 删除 | |
43 | + syncDept(); | |
44 | + //同步的老师 | |
45 | + syncTeacher(); | |
46 | + //同步的学生 | |
47 | + syncStudent(); | |
48 | + //同步的班级 | |
49 | + syncClass(); | |
50 | + } | |
51 | + | |
52 | + private void syncDept(){ | |
53 | + | |
54 | + } | |
55 | + | |
56 | + private void syncTeacher(){ | |
57 | + | |
58 | + } | |
59 | + | |
60 | + private void syncClass(){ | |
61 | + | |
62 | + } | |
63 | + | |
64 | + private void syncStudent(){ | |
65 | + | |
66 | + } | |
67 | + | |
68 | + | |
69 | + private YXYResult getResult(String url , String json){ | |
70 | + YXYResult result = invokeApi(url,TOKEN,json); | |
71 | + if(result.getCode() == 2){ | |
72 | + TOKEN = getToken(); | |
73 | + result = invokeApi(url,TOKEN,json); | |
74 | + } | |
75 | + return result ; | |
76 | + } | |
77 | + | |
78 | + private String getToken(){ | |
79 | + String url = prefix_url+"/token/yxt" ; | |
80 | + String json = "key="+key+"&secret="+secret ; | |
81 | + JSONObject jsonObject = HttpClientUtils.httpPost(url,json); | |
82 | + return (String)jsonObject.get("token") ; | |
83 | + } | |
84 | + | |
85 | + private YXYResult invokeApi(String url , String token , String json){ | |
86 | + try{ | |
87 | + JSONObject jsonObject = HttpClientUtils.httpPostJson(url+"?token="+token,json); | |
88 | + return JSON.toJavaObject(jsonObject,YXYResult.class); | |
89 | + }catch (Exception e){ | |
90 | + e.printStackTrace(); | |
91 | + return new YXYResult(); | |
92 | + } | |
93 | + | |
94 | + } | |
95 | + | |
96 | +} | ... | ... |