PLSUtil工具类新增部分三方接口及封装方法,恢复切换分支后之前优化的bug代码被覆盖的部分代码

pull/4/head
WenShiJun 2024-01-12 16:40:52 +08:00
parent fce0c60fa5
commit 500456a892
10 changed files with 7714 additions and 15 deletions

File diff suppressed because it is too large Load Diff

View File

@ -234,10 +234,10 @@ public class CorpInfoController extends BaseController {
String errInfo = "success"; String errInfo = "success";
PageData pd = new PageData(); PageData pd = new PageData();
pd = this.getPageData(); pd = this.getPageData();
String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件 String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件
if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim()); if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim());
page.setPd(pd); page.setPd(pd);
List<PageData> varList = corpinfoService.list(page); //列出CorpInfo列表 List<PageData> varList = corpinfoService.list(page); //列出CorpInfo列表
map.put("varList", varList); map.put("varList", varList);
map.put("page", page); map.put("page", page);
map.put("result", errInfo); map.put("result", errInfo);
@ -319,14 +319,17 @@ public class CorpInfoController extends BaseController {
PageData corpOfType = new PageData(); PageData corpOfType = new PageData();
corpOfType.put("CORPTYPE_ID", pd.get("CORP_OF_TYPE")); corpOfType.put("CORPTYPE_ID", pd.get("CORP_OF_TYPE"));
corpOfType = corptypeService.findById(corpOfType); corpOfType = corptypeService.findById(corpOfType);
pd.put("CORP_OF_TYPE_NAME", corpOfType.get("NAME")); if (corpOfType != null) {
pd.put("CORP_OF_TYPE_NAME", corpOfType.get("NAME"));
}
} }
if (Tools.notEmpty(pd.getString("CORP_OF_TYPE2"))) { if (Tools.notEmpty(pd.getString("CORP_OF_TYPE2"))) {
PageData corpOfType2 = new PageData(); PageData corpOfType2 = new PageData();
corpOfType2.put("CORPTYPE_ID", pd.get("CORP_OF_TYPE2")); corpOfType2.put("CORPTYPE_ID", pd.get("CORP_OF_TYPE2"));
corpOfType2 = corptypeService.findById(corpOfType2); corpOfType2 = corptypeService.findById(corpOfType2);
pd.put("CORP_OF_TYPE_NAME2", corpOfType2.get("NAME")); if (corpOfType2 != null) {
pd.put("CORP_OF_TYPE_NAME2", corpOfType2.get("NAME"));
}
} }
pd.put("POSSESSION", POSSESSIONALL); pd.put("POSSESSION", POSSESSIONALL);

View File

@ -111,7 +111,7 @@ public class OffDutyController extends BaseController {
PageData pd = new PageData(); PageData pd = new PageData();
PageData npd = new PageData(); PageData npd = new PageData();
pd = this.getPageData(); pd = this.getPageData();
String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件 String KEYWORDS = pd.getString("KEYWORDS");//关键词检索条件
if(Tools.notEmpty(KEYWORDS))npd.put("KEYWORDS", KEYWORDS.trim()); if(Tools.notEmpty(KEYWORDS))npd.put("KEYWORDS", KEYWORDS.trim());
npd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); npd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
npd.put("DEPARTMENT_ID", Jurisdiction.getDEPARTMENT_ID()); npd.put("DEPARTMENT_ID", Jurisdiction.getDEPARTMENT_ID());
@ -139,7 +139,7 @@ public class OffDutyController extends BaseController {
npd.put("DEPARTMENT_IDS", DEPARTMENT_ID); npd.put("DEPARTMENT_IDS", DEPARTMENT_ID);
} }
}else { }else {
if(npd.getString("ISMAIN").equals("0")){ if(npd.getString("ISMAIN") != null && npd.getString("ISMAIN").equals("0")){
npd.put("USER_ID",Jurisdiction.getUSER_ID()); npd.put("USER_ID",Jurisdiction.getUSER_ID());
} }
} }

View File

@ -0,0 +1,19 @@
package com.zcloud.entity;
import lombok.Data;
@Data
public class Camera {
private String camName; // 摄像头名称
private String camNo; // 摄像头编号
private String camIp; // 摄像头 IP 地址
private String port; // 摄像头端口号
private String type; // 摄像头类型
private String camUserName; // 摄像头用户名
private String camPassword; // 摄像头密码
private String lon; // 摄像头经度
private String lat; // 摄像头纬度
private String alt; // 摄像头海拔
private String channel; // 通道号
private String indexcode; // 索引编码
}

View File

@ -0,0 +1,12 @@
package com.zcloud.entity;
import lombok.Data;
@Data
public class Card {
private String cardNo; // 卡号
private String psnId; // 绑定人员Id
private String cardType; // 卡类型
private String cardStatus; // 卡状态
private String remark; // 备注
}

View File

@ -100,6 +100,11 @@ public class TextLibraryServiceImpl implements TextLibraryService {
entity.put("SPECIFICATION_TYPES", _labels.stream().filter(n -> n.get("CATEGORY") != null).filter(n -> n.getString("CATEGORY").equals("SPECIFICATION_TYPES")).collect(Collectors.toList())); entity.put("SPECIFICATION_TYPES", _labels.stream().filter(n -> n.get("CATEGORY") != null).filter(n -> n.getString("CATEGORY").equals("SPECIFICATION_TYPES")).collect(Collectors.toList()));
entity.put("ATTRIBUTE_LIST", _labels.stream().filter(n -> n.get("CATEGORY") != null).filter(n -> n.getString("CATEGORY").equals("ATTRIBUTE_LIST")).collect(Collectors.toList())); entity.put("ATTRIBUTE_LIST", _labels.stream().filter(n -> n.get("CATEGORY") != null).filter(n -> n.getString("CATEGORY").equals("ATTRIBUTE_LIST")).collect(Collectors.toList()));
entity.put("CATEGORY_LIST", _labels.stream().filter(n -> n.get("CATEGORY") != null).filter(n -> n.getString("CATEGORY").equals("CATEGORY_LIST")).collect(Collectors.toList())); entity.put("CATEGORY_LIST", _labels.stream().filter(n -> n.get("CATEGORY") != null).filter(n -> n.getString("CATEGORY").equals("CATEGORY_LIST")).collect(Collectors.toList()));
entity.put("LABEL_NAME", _labels.stream()
.filter(n -> n.getString("LABEL_NAME") != null)
.map(n -> n.getString("LABEL_NAME"))
.findFirst()
.orElse(null));
} }
return list; return list;
} }

View File

@ -1,6 +1,8 @@
package com.zcloud.util; package com.zcloud.util;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.zcloud.entity.Camera;
import com.zcloud.entity.Card;
import com.zcloud.entity.EmployeeData; import com.zcloud.entity.EmployeeData;
import com.zcloud.entity.PageData; import com.zcloud.entity.PageData;
import com.zcloud.service.corp.CorpPlsInfoService; import com.zcloud.service.corp.CorpPlsInfoService;
@ -9,6 +11,8 @@ import okhttp3.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
public class PLSUtil { public class PLSUtil {
@ -18,6 +22,12 @@ public class PLSUtil {
@Autowired @Autowired
public static UsersService usersService; public static UsersService usersService;
/**
*
* @param pd
* @return
* @throws Exception
*/
public static boolean getToken(PageData pd) throws Exception { public static boolean getToken(PageData pd) throws Exception {
boolean tokenUpdated = false; boolean tokenUpdated = false;
pd = corpplsinfoService.findById(pd); pd = corpplsinfoService.findById(pd);
@ -53,6 +63,11 @@ public class PLSUtil {
return tokenUpdated; return tokenUpdated;
} }
/**
*
* @param pd
* @throws Exception
*/
public static void saveUser(PageData pd) throws Exception { public static void saveUser(PageData pd) throws Exception {
if (getToken(pd)) { if (getToken(pd)) {
PageData user = usersService.findByUsername(pd); PageData user = usersService.findByUsername(pd);
@ -78,22 +93,208 @@ public class PLSUtil {
} }
} }
/**
*
* @param pd
* @throws Exception
*/
public static void updateUserCardInfo(PageData pd) throws Exception {
Card card = new Card();
if (getToken(pd)){
card.setCardNo(pd.getString("CARDNO"));
card.setPsnId(pd.getString("PsnId"));
card.setCardType(pd.getString("CARDTYPE"));
card.setCardStatus(pd.getString("CARDSTATUS"));
card.setRemark(pd.getString("REMARK"));
pd = corpplsinfoService.findById(pd);
String token = pd.getString("TOKEN");
String url = pd.getString("POST_URL") + "/deploy/card";
Response response = sendPutHttpRequest(url, card.toString(), token);
if (!response.isSuccessful()) {
throw new IOException(String.valueOf(response));
}
}else {
throw new Exception("无法获取有效的Token");
}
}
/**
*
* @param pd
* @return
* @throws Exception
*/
public static JSONObject cardIdGetUserInfo(PageData pd) throws Exception {
JSONObject result = null;
if (getToken(pd)){
pd = corpplsinfoService.findById(pd);
String token = pd.getString("TOKEN");
String cardId = pd.getString("CARDNO");
String url = pd.getString("POST_URL") + "/deploy/psnmgt/feign-client/getPsnInfoByCardId/" + cardId;
Response response = sendGetHttpRequest(url, null, token);
if (response.isSuccessful()){
String responseBody = response.body().string();
result = new JSONObject(responseBody.isEmpty());
}else {
throw new Exception("请求失败" + response.code());
}
}else {
throw new Exception("无法获取有效的Token");
}
return result;
}
/**
*
* @param pd
* @throws Exception
*/
public static void saveCamera(PageData pd) throws Exception {
Camera camera = new Camera();
if (getToken(pd)) {
camera.setCamName(pd.getString("CAMNAME"));
camera.setCamNo(pd.getString("CAMNO"));
camera.setCamIp(pd.getString("CAMIP"));
camera.setPort(pd.getString("PORT"));
camera.setType(pd.getString("TYPE"));
camera.setCamUserName(pd.getString("CAMUSERNAME"));
camera.setCamPassword(pd.getString("CAMPASSWORD"));
camera.setLon(pd.getString("LON"));
camera.setAlt(pd.getString("ALT"));
camera.setChannel(pd.getString("CHANNEL"));
camera.setIndexcode(pd.getString("INDEXCODE"));
pd = corpplsinfoService.findById(pd);
String token = pd.getString("TOKEN");
String url = pd.getString("POST_URL") + "/device/camera";
Response response = sendPostHttpRequest(url, String.valueOf(camera), token);
if (!response.isSuccessful()){
throw new IOException(String.valueOf(response));
}
}else {
throw new Exception("无法获取有效的Token");
}
}
/**
*
* @param pd
* @throws Exception
*/
public static void updateCamera(PageData pd) throws Exception {
Camera camera = new Camera();
if (getToken(pd)){
camera.setCamName(pd.getString("CAMNAME"));
camera.setCamNo(pd.getString("CAMNO"));
camera.setCamIp(pd.getString("CAMIP"));
camera.setPort(pd.getString("PORT"));
camera.setType(pd.getString("TYPE"));
camera.setCamUserName(pd.getString("CAMUSERNAME"));
camera.setCamPassword(pd.getString("CAMPASSWORD"));
camera.setLon(pd.getString("LON"));
camera.setAlt(pd.getString("ALT"));
camera.setChannel(pd.getString("CHANNEL"));
camera.setIndexcode(pd.getString("INDEXCODE"));
pd = corpplsinfoService.findById(pd);
String token = pd.getString("TOKEN");
String url = pd.getString("POST_URL") + "/device/camera";
Response response = sendPutHttpRequest(url, String.valueOf(camera), token);
if (!response.isSuccessful()){
throw new IOException(String.valueOf(response));
}
}else {
throw new Exception("无法获取有效的Token");
}
}
/**
*
* @param pd
* @return
* @throws Exception
*/
public static JSONObject getAListOfElectronicFences(PageData pd) throws Exception {
if (getToken(pd)) {
pd = corpplsinfoService.findById(pd);
String token = pd.getString("TOKEN");
String url = pd.getString("POST_URL") + "/region/api/electronicFence/getAListOfElectronicFences";
Response response = sendGetHttpRequest(url, null, token);
if (response.isSuccessful()){
String responseBody = response.body().string();
return new JSONObject(responseBody.isEmpty());
}else {
throw new Exception("请求失败" + response.code());
}
}else {
throw new Exception("无法获取有效的Token");
}
}
/**
* post
* @param url
* @param jsonPayload
* @param token
* @return
* @throws IOException
*/
private static Response sendPostHttpRequest(String url, String jsonPayload, String token) throws IOException { private static Response sendPostHttpRequest(String url, String jsonPayload, String token) throws IOException {
OkHttpClient client = new OkHttpClient();
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
RequestBody body = RequestBody.create(JSON, jsonPayload);
Request.Builder builder = new Request.Builder() // 构建一个新的Request对象。
.url(url)// 设置请求的URL。
.post(body);// 设置请求的方法为POST并设置请求体。
//构建请求头
if (token != null && !token.isEmpty()) {// 检查token是否存在且不为空。
builder.addHeader("Authorization", "Bearer " + token);
}
// 构建请求
Request request = builder.build();
//发起请求并响应数据
return client.newCall(request).execute();
}
/**
* PUT
* @param url
* @param jsonPayload
* @param token
* @return
* @throws IOException
*/
private static Response sendPutHttpRequest(String url, String jsonPayload, String token)throws IOException{
OkHttpClient client = new OkHttpClient(); OkHttpClient client = new OkHttpClient();
MediaType JSON = MediaType.parse("application/json; charset=utf-8"); MediaType JSON = MediaType.parse("application/json; charset=utf-8");
RequestBody body = RequestBody.create(JSON, jsonPayload); RequestBody body = RequestBody.create(JSON, jsonPayload);
Request.Builder builder = new Request.Builder() Request.Builder builder = new Request.Builder()
.url(url) .url(url)
.post(body); .put(body);
if (token != null && !token.isEmpty()) { if (token != null && !token.isEmpty()) {
builder.addHeader("Authorization", "Bearer " + token); builder.addHeader("Authorization", "Bearer " + token);
} }
Request request = builder.build(); Request request = builder.build();
return client.newCall(request).execute(); return client.newCall(request).execute();
} }
/**
* get
* @param url
* @param queryParams
* @param token
* @return
* @throws IOException
*/
private static Response sendGetHttpRequest(String url, Map<String, String> queryParams, String token) throws IOException { private static Response sendGetHttpRequest(String url, Map<String, String> queryParams, String token) throws IOException {
OkHttpClient client = new OkHttpClient(); OkHttpClient client = new OkHttpClient();
@ -116,4 +317,32 @@ public class PLSUtil {
//发送请求并返回响应数据 //发送请求并返回响应数据
return client.newCall(request).execute(); return client.newCall(request).execute();
} }
/**
* delete
* @param url
* @param camIds
* @param token
* @return
* @throws IOException
*/
private static Response sendDeleteHttpRequest(String url, List<String> camIds, String token) throws IOException {
OkHttpClient client = new OkHttpClient();
//将要删除的Id列表转换为逗号分隔的字符串
String joinedIds = String.join(",", camIds);
//构建完整的url
url = url + "/" + joinedIds;
Request.Builder builderBuilder = new Request.Builder()
.url(url)
.delete();
if (token != null && !token.isEmpty()) {
builderBuilder.addHeader("Authorization", "Bearer " + token);
}
Request request = builderBuilder.build();
return client.newCall(request).execute();
}
} }

View File

@ -171,8 +171,8 @@
<if test="pd.SPEAKER != null and pd.SPEAKER != ''"><!-- 关键词检索 --> <if test="pd.SPEAKER != null and pd.SPEAKER != ''"><!-- 关键词检索 -->
and f.SPEAKER LIKE CONCAT(CONCAT('%', #{pd.SPEAKER}),'%') and f.SPEAKER LIKE CONCAT(CONCAT('%', #{pd.SPEAKER}),'%')
</if> </if>
<if test="pd.tarinTypeID != null and pd.tarinTypeID != ''"><!-- 培训行业类型 --> <if test="pd.trainingSectionKey != null and pd.trainingSectionKey != ''"><!-- 培训行业类型 -->
and f.TRAINTYPE = #{pd.tarinTypeID} and f.TRAINTYPE = #{pd.trainingSectionKey}
</if> </if>
<if test="pd.TRAINTYPE != null and pd.TRAINTYPE != ''"><!-- 培训行业类型 --> <if test="pd.TRAINTYPE != null and pd.TRAINTYPE != ''"><!-- 培训行业类型 -->
and f.TRAINTYPE = #{pd.TRAINTYPE} and f.TRAINTYPE = #{pd.TRAINTYPE}

View File

@ -184,8 +184,8 @@
f.SPEAKER LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%') f.SPEAKER LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
) )
</if> </if>
<if test="pd.tarinTypeID != null and pd.tarinTypeID != ''"><!-- 培训行业类型 --> <if test="pd.trainingSectionKey != null and pd.trainingSectionKey != ''"><!-- 培训行业类型 -->
and f.TRAINTYPE = #{pd.tarinTypeID} and f.TRAINTYPE = #{pd.trainingSectionKey}
</if> </if>
<if test="pd.TRAINTYPE != null and pd.TRAINTYPE != ''"><!-- 培训行业类型 --> <if test="pd.TRAINTYPE != null and pd.TRAINTYPE != ''"><!-- 培训行业类型 -->
and f.TRAINTYPE = #{pd.TRAINTYPE} and f.TRAINTYPE = #{pd.TRAINTYPE}

View File

@ -1290,7 +1290,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SYS_USER f SYS_USER f
LEFT JOIN OA_DEPARTMENT d ON d.DEPARTMENT_ID = f.DEPARTMENT_ID LEFT JOIN OA_DEPARTMENT d ON d.DEPARTMENT_ID = f.DEPARTMENT_ID
where f.ISDELETE = 0 and f.ISLEADER = '1' where f.ISDELETE = 0 and f.ISLEADER = '1'
<if test="DEPT_IDS != null and DEPT_IDS != ''"> <if test="DEPT_IDS != null and !DEPT_IDS.isEmpty()">
and d.DEPARTMENT_ID in and d.DEPARTMENT_ID in
<foreach item="item" index="index" <foreach item="item" index="index"
collection="DEPT_IDS" open="(" separator="," close=")"> collection="DEPT_IDS" open="(" separator="," close=")">