liuxiaolong
2019-05-06 0bc4f4c791437b39b8c30624f5c21f8c855dc61d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package com.cloud.retrieve.service.impl;
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.cloud.common.utils.RestTemplateUtil;
import com.cloud.model.common.Result;
import com.cloud.retrieve.dao.CulOrDevDao;
import com.cloud.retrieve.service.UserService;
import com.cloud.retrieve.utils.EnumStr;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
 
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
@Service
public class UserServiceImpl implements UserService {
 
    @Autowired
    private EnumStr enumStr;
    @Autowired
    private CulOrDevDao culOrDevDao;
 
    /**
     *  依据 人员id 查询 信息
     * @param perId
     * @return
     */
    @Override
    public Map queryUserInfoById(String perId) {
 
        // 调用 人员模块
        String userHOSTNAME = enumStr.getUserHOSTNAME();
        int userHTTP_port = enumStr.getUserHTTP_PORT();
        String userQueryPerIdUrl = enumStr.getUserQueryPerIdUrl();
        String queryUrl = "http://"+userHOSTNAME+":"+userHTTP_port+userQueryPerIdUrl;
 
        JSONObject dataBaseParams = new JSONObject();
        dataBaseParams.put("personId",perId);
        String resp = RestTemplateUtil.post(queryUrl,
                dataBaseParams, MediaType.APPLICATION_FORM_URLENCODED, false);
        Map map = JSONObject.parseObject(resp, Map.class);
        if (map != null){
            if ("200".equals(map.get("type"))){  //  学生类型
                map.put("phone",null);         // 手机号 处理为空
            }else if ("100".equals(map.get("type"))){
                map.put("no",null);             //  学号处理为空
            }
        }else {
            map = new HashMap();  //  防止  后面调用数据为空
        }
        return map;
    // 本模块直接查询
       /* Map<String, Object> respMap = culOrDevDao.selectPersonDetailById(perId);
       if (respMap != null){
            if ("200".equals(respMap.get("type"))){  //  学生类型
                respMap.put("phone",null);         // 手机号 处理为空
            }else if ("100".equals(respMap.get("type"))){
                respMap.put("no",null);             //  学号处理为空
        }
         }
return respMap;
      */
 
    }
 
    @Override
    public List getEmployerList(String likeValue) {
 
        // 调用 人员模块
        String userHOSTNAME = enumStr.getUserHOSTNAME();
        int userHTTP_port = enumStr.getUserHTTP_PORT();
        String userQueryPersonsUrl = enumStr.getQueryPersonList();
        String queryUrl = "http://"+userHOSTNAME+":"+userHTTP_port+userQueryPersonsUrl;   //  userHOSTNAME
 
        JSONObject dataBaseParams = new JSONObject();
        //  {"start":1,"length":100,"id":"001","groupInformation":"小学"}
        dataBaseParams.put("start",0);
        dataBaseParams.put("length",100);
        dataBaseParams.put("id","001");  // 总库人员表示
        dataBaseParams.put("groupInformation",likeValue);
        String resp = RestTemplateUtil.post(queryUrl,
                dataBaseParams, MediaType.APPLICATION_JSON_UTF8, false);
 
        JSONObject result =  JSONObject.parseObject(resp,JSONObject.class);
        JSONArray list = null;
        list = result.getJSONArray("data");
        return list;
    }
}