|
|
@@ -1,5 +1,8 @@
|
|
|
package com.mokamrp.privates.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.aliyun.oss.OSS;
|
|
|
import com.aliyun.oss.model.PutObjectRequest;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
@@ -8,6 +11,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.mokamrp.privates.config.OSSConfiguration;
|
|
|
import com.mokamrp.privates.entity.GetWorkContactEmployeeHandle;
|
|
|
import com.mokamrp.privates.entity.HubWorkContactEmployeeHandle;
|
|
|
+import com.mokamrp.privates.help.AjaxResult;
|
|
|
import com.mokamrp.privates.mapper.DownfileMapper;
|
|
|
import com.mokamrp.privates.mapper.WorkContactEmployeeMapper;
|
|
|
import com.mokamrp.privates.mapper.pojo.Downfile;
|
|
|
@@ -17,6 +21,14 @@ import com.mokamrp.privates.mapper.vo.WorkContactEmployeeVo;
|
|
|
import com.mokamrp.privates.service.WorkContactEmployeeService;
|
|
|
import com.mokamrp.privates.utils.OssFile;
|
|
|
import com.mokamrp.privates.utils.PageUtil;
|
|
|
+import org.apache.http.HttpEntity;
|
|
|
+import org.apache.http.HttpResponse;
|
|
|
+import org.apache.http.client.methods.HttpPost;
|
|
|
+import org.apache.http.entity.StringEntity;
|
|
|
+import org.apache.http.impl.client.DefaultHttpClient;
|
|
|
+import org.apache.http.message.BasicHeader;
|
|
|
+import org.apache.http.protocol.HTTP;
|
|
|
+import org.apache.http.util.EntityUtils;
|
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -54,17 +66,114 @@ public class WorkContactEmployeeServiceImpl extends ServiceImpl<WorkContactEmplo
|
|
|
@Override
|
|
|
public Map<String, Object> getHubPageList(HubWorkContactEmployeeHandle handle) {
|
|
|
|
|
|
+ List<Map<String,Object>> resList = new ArrayList<Map<String,Object>>();
|
|
|
+
|
|
|
QueryWrapper<WorkContactEmployeeVo> obj = getHubWrapper(handle);
|
|
|
Integer offset = PageUtil.getOffset(handle.getPage(),handle.getPagesize());
|
|
|
- List<WorkContactEmployeeVo> list = mapperObj.getVoList(obj,offset,handle.getPagesize());
|
|
|
+ List<WorkContactEmployeeVo> list = mapperObj.getHubVoList(obj,offset,handle.getPagesize());
|
|
|
Integer total = mapperObj.getHubListTotal(obj);
|
|
|
Map<String, Object> resMap = new HashMap<String, Object>();
|
|
|
+
|
|
|
+ //请求typer,匹配typer标签
|
|
|
+ if (list.size() > 0) {
|
|
|
+ list = getAppIdAndOpenidList(list);
|
|
|
+ list = getTyperTag(list);
|
|
|
+ }
|
|
|
+
|
|
|
resMap.put("list", list);
|
|
|
resMap.put("total", total);
|
|
|
|
|
|
return resMap;
|
|
|
}
|
|
|
|
|
|
+ private List<WorkContactEmployeeVo> getTyperTag(List<WorkContactEmployeeVo> list){
|
|
|
+
|
|
|
+ int j = list.size();
|
|
|
+ int t;
|
|
|
+ JSONArray responseList = new JSONArray();
|
|
|
+ List<Map<String,Object>> resList = new ArrayList<Map<String,Object>>();
|
|
|
+
|
|
|
+ for (int i = 0; i < j; i++) {
|
|
|
+ Map<String, Object> map = new HashMap<String,Object>(); //数据采用的哈希表结构
|
|
|
+ map.put("openid", list.get(i).getOpenId());
|
|
|
+ map.put("appid", list.get(i).getAppId());
|
|
|
+ map.put("private_domain", 1);
|
|
|
+ map.put("main_body", list.get(i).getCompanyName());
|
|
|
+ resList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println(resList);
|
|
|
+
|
|
|
+ /*请求typer*/
|
|
|
+ HttpPost post = new HttpPost("http://yitian.mokagm.com/v1/external/fans/info");
|
|
|
+ // (2) 使用HttpClient发送get请求,获得返回结果HttpResponse
|
|
|
+ DefaultHttpClient http = new DefaultHttpClient();
|
|
|
+ JSONObject jsobj1 = new JSONObject();
|
|
|
+ post.setHeader("Content-Type", "application/json");
|
|
|
+
|
|
|
+ String json = JSON.toJSONString(resList);
|
|
|
+
|
|
|
+ StringEntity s = new StringEntity(json, "utf-8");
|
|
|
+ s.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
|
|
|
+ post.setEntity(s);
|
|
|
+
|
|
|
+ try {
|
|
|
+ HttpResponse response = http.execute(post);
|
|
|
+
|
|
|
+ if (response.getStatusLine().getStatusCode() == 200) {
|
|
|
+ HttpEntity resEntity = response.getEntity();
|
|
|
+ String message = EntityUtils.toString(resEntity, "utf-8");
|
|
|
+ //System.out.println(message);
|
|
|
+ JSONObject jsonObject = JSON.parseObject(message);
|
|
|
+ Object resMap;
|
|
|
+ if (jsonObject.get("data") != null) {
|
|
|
+ System.out.println(jsonObject.get("data"));
|
|
|
+ responseList = jsonObject.getJSONArray("data");
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ System.out.println(e.getMessage());
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ int resLen = responseList.size();
|
|
|
+ for (int i = 0; i < j; i++) {
|
|
|
+ for(t=0;t<resLen;t++) {
|
|
|
+ //匹配成功的
|
|
|
+ if(responseList.getJSONObject(i).get("openid").equals(list.get(i).getOpenId())){
|
|
|
+ list.get(i).setTyperTag(responseList.getJSONObject(i).get("label").toString()+list.get(i).getOpenId()+"--"+responseList.getJSONObject(i).get("openid"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private List<WorkContactEmployeeVo> getAppIdAndOpenidList(List<WorkContactEmployeeVo> list){
|
|
|
+
|
|
|
+ int j = list.size();
|
|
|
+ List<String> userIds = new ArrayList<String>();
|
|
|
+
|
|
|
+ for (int i = 0; i < j; i++) {
|
|
|
+ userIds.add(list.get(i).getClientWxId());
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ 这边欠缺,通过userId兑换appId和openId
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ for (int i = 0; i < j; i++) {
|
|
|
+ list.get(i).setAppId("wx0fc21731a702b4d2");
|
|
|
+ list.get(i).setOpenId("0b11f9c6e87b4dff8efc9c520d8215a7");
|
|
|
+ }
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Map<String, Object> getPageList(GetWorkContactEmployeeHandle handle) {
|
|
|
|
|
|
@@ -205,6 +314,7 @@ public class WorkContactEmployeeServiceImpl extends ServiceImpl<WorkContactEmplo
|
|
|
|
|
|
Integer gender = handle.getGender();
|
|
|
String name = handle.getName();
|
|
|
+ Integer status = handle.getStatus();
|
|
|
String startCreatedAt = handle.getStartCreatedAt();
|
|
|
String endCreatedAt = handle.getEndCreatedAt();
|
|
|
Integer corpId = handle.getCorpId();
|
|
|
@@ -223,6 +333,10 @@ public class WorkContactEmployeeServiceImpl extends ServiceImpl<WorkContactEmplo
|
|
|
obj.ge("c.created_at", startCreatedAt);
|
|
|
}
|
|
|
|
|
|
+ if (status != null) {
|
|
|
+ obj.eq("a.`status`", status);
|
|
|
+ }
|
|
|
+
|
|
|
if (endCreatedAt != null && !endCreatedAt.isEmpty()) {
|
|
|
obj.le("c.created_at", endCreatedAt);
|
|
|
}
|