|
@@ -0,0 +1,272 @@
|
|
|
+package com.example.xiaoshiweixinback.service.importPatent.factorys.permissions;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.example.xiaoshiweixinback.business.utils.LoginUtils;
|
|
|
+import com.example.xiaoshiweixinback.entity.dto.common.ClientDTO;
|
|
|
+import com.google.gson.Gson;
|
|
|
+import okhttp3.MediaType;
|
|
|
+import okhttp3.OkHttpClient;
|
|
|
+import okhttp3.Request;
|
|
|
+import okhttp3.RequestBody;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取权限系统数据接口
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class PermissionService {
|
|
|
+ @Value("${authorUrl}")
|
|
|
+ private String PCSUrl;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据名称模糊查询人员接口
|
|
|
+ * @param personName
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public String getPersonIdByNamePCS(String personName, Boolean ifEqual) throws IOException {
|
|
|
+ OkHttpClient okHttpClient = new OkHttpClient();
|
|
|
+ Request request = new Request.Builder()
|
|
|
+ .url(PCSUrl + "/permission/api/system/getPersonIdByName?personName=" + personName+"&ifEqual="+ifEqual)
|
|
|
+ .get()
|
|
|
+ .build();
|
|
|
+ return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获得所有人员排序接口
|
|
|
+ * @param orderType
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public String getPersonIdOrders(Integer orderType) throws IOException {
|
|
|
+ OkHttpClient okHttpClient = new OkHttpClient();
|
|
|
+ Request request = new Request.Builder()
|
|
|
+ .url(PCSUrl + "/permission/api/system/getPersonIdOrders?orderType=" + orderType)
|
|
|
+ .get()
|
|
|
+ .build();
|
|
|
+ return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据人员ids查询人员列表
|
|
|
+ *
|
|
|
+ * @param ids 人员ids
|
|
|
+ * @return 返回装载着人员列表数据的data的String
|
|
|
+ */
|
|
|
+ public String getPersonnelByIdsFromPCS(List<String> ids) throws IOException {
|
|
|
+ String param = new Gson().toJson(ids);
|
|
|
+ RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), param);
|
|
|
+ OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
|
|
+ .connectTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .writeTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .readTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .build();
|
|
|
+ Request request = new Request.Builder()
|
|
|
+ .url(PCSUrl + "/permission/api/system/getPersonnelByIds")
|
|
|
+ .post(requestBody)
|
|
|
+ .build();
|
|
|
+ return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据客户ids查询客户列表
|
|
|
+ *
|
|
|
+ * @param ids 客户ids
|
|
|
+ * @return 返回装载着客户列表数据的data的String
|
|
|
+ */
|
|
|
+ public String getClientByIdsFromPCS(List<Integer> ids) throws IOException {
|
|
|
+ String param = new Gson().toJson(ids);
|
|
|
+ RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), param);
|
|
|
+ OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
|
|
+ .connectTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .writeTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .readTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .build();
|
|
|
+ Request request = new Request.Builder()
|
|
|
+ .url(PCSUrl + "/permission/api/system/getClintByIds")
|
|
|
+ .post(requestBody)
|
|
|
+ .build();
|
|
|
+ return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据名称模糊查询客户接口
|
|
|
+ * @param clientName
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public String getClientIdByNamePCS(String clientName,Boolean ifEqual) throws IOException {
|
|
|
+ OkHttpClient okHttpClient = new OkHttpClient();
|
|
|
+ Request request = new Request.Builder()
|
|
|
+ .url(PCSUrl + "/permission/api/system/getClientIdByName?clientName=" + clientName+"&ifEqual="+ifEqual)
|
|
|
+ .get()
|
|
|
+ .build();
|
|
|
+ return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获得所有客户排序接口
|
|
|
+ * @param orderType
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public String getClientIdOrders(Integer orderType) throws IOException {
|
|
|
+ OkHttpClient okHttpClient = new OkHttpClient();
|
|
|
+ Request request = new Request.Builder()
|
|
|
+ .url(PCSUrl + "/permission/api/system/getClientIdOrders?orderType=" + orderType)
|
|
|
+ .get()
|
|
|
+ .build();
|
|
|
+ return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @title 添加客户
|
|
|
+ * @description 添加客户
|
|
|
+ * @autor lrj
|
|
|
+ */
|
|
|
+
|
|
|
+ public String addClient(ClientDTO client) throws IOException {
|
|
|
+ OkHttpClient okHttpClient = new OkHttpClient();
|
|
|
+ String param = new Gson().toJson(client);
|
|
|
+ RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), param);
|
|
|
+ Request request = new Request.Builder()
|
|
|
+ .url(PCSUrl + "/permission/api/client/add")
|
|
|
+ .addHeader("Cookie", LoginUtils.getToken())
|
|
|
+ .post(requestBody)
|
|
|
+ .build();
|
|
|
+ return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据部门ids查询部门列表
|
|
|
+ *
|
|
|
+ * @param ids 部门id
|
|
|
+ * @return 返回装载着客户列表数据的data的String
|
|
|
+ */
|
|
|
+ public String getDepartmentByIdsFromPCS(List<String> ids) throws IOException {
|
|
|
+ String param = new Gson().toJson(ids);
|
|
|
+ RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), param);
|
|
|
+ OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
|
|
+ .connectTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .writeTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .readTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .build();
|
|
|
+ Request request = new Request.Builder()
|
|
|
+ .url(PCSUrl + "/permission/api/system/getDeparts")
|
|
|
+ .post(requestBody)
|
|
|
+ .build();
|
|
|
+ return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获得所有部门排序接口
|
|
|
+ * @param orderType
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public String getDepartmentOrders(Integer orderType) throws IOException {
|
|
|
+ OkHttpClient okHttpClient = new OkHttpClient();
|
|
|
+ Request request = new Request.Builder()
|
|
|
+ .url(PCSUrl + "/permission/api/system/getDepartmentOrders?orderType=" + orderType)
|
|
|
+ .get()
|
|
|
+ .build();
|
|
|
+ return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获得所有委托方排序接口
|
|
|
+ * @param orderType
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public String getEntrustsOrder(Integer orderType) throws IOException {
|
|
|
+ OkHttpClient okHttpClient = new OkHttpClient();
|
|
|
+ Request request = new Request.Builder()
|
|
|
+ .url(PCSUrl + "/permission/api/system/getEntrustsOrder?orderType=" + orderType)
|
|
|
+ .get()
|
|
|
+ .build();
|
|
|
+ return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据名称获得委托方id和类型接口
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public String getEntrustsByName(String name,Integer type) throws IOException {
|
|
|
+ OkHttpClient okHttpClient = new OkHttpClient();
|
|
|
+ Request request = new Request.Builder()
|
|
|
+ .url(PCSUrl + "/permission/api/system/getEntrustsByName?name=" + name+"&type="+type)
|
|
|
+ .get()
|
|
|
+ .build();
|
|
|
+ return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据部门ids查询部门列表
|
|
|
+ *
|
|
|
+ * @param ids 部门id
|
|
|
+ * @return 返回装载着客户列表数据的data的String
|
|
|
+ */
|
|
|
+ public String getEntrustsByIdAndType(List<String> ids) throws IOException {
|
|
|
+ String param = new Gson().toJson(ids);
|
|
|
+ RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), param);
|
|
|
+ OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
|
|
+ .connectTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .writeTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .readTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .build();
|
|
|
+ Request request = new Request.Builder()
|
|
|
+ .url(PCSUrl + "/permission/api/system/getEntrustsByIdAndType")
|
|
|
+ .post(requestBody)
|
|
|
+ .build();
|
|
|
+ return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据名称模糊查询部门接口
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public String getDepartmentIdByName(String departmentName, Boolean ifEqual) throws IOException {
|
|
|
+ OkHttpClient okHttpClient = new OkHttpClient();
|
|
|
+ Request request = new Request.Builder()
|
|
|
+ .url(PCSUrl + "/permission/api/system/getDepartmentIdByName?departmentName=" + departmentName+"&ifEqual="+ifEqual)
|
|
|
+ .get()
|
|
|
+ .build();
|
|
|
+ return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<String> getPersonIdsByName(String name){
|
|
|
+
|
|
|
+ List<String> ids = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ String json = this.getPersonIdByNamePCS(name, false);
|
|
|
+ ids = JSON.parseArray(json, String.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ if (ids == null || ids.size() == 0) {
|
|
|
+ ids = new ArrayList<>();
|
|
|
+ ids.add("0");
|
|
|
+ }
|
|
|
+ return ids;
|
|
|
+
|
|
|
+ }
|
|
|
+}
|