调用bug修改
This commit is contained in:
parent
183665b000
commit
2e220a9fcb
@ -3,12 +3,19 @@ package com.zhgd.config;
|
|||||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||||
import ch.qos.logback.core.filter.Filter;
|
import ch.qos.logback.core.filter.Filter;
|
||||||
import ch.qos.logback.core.spi.FilterReply;
|
import ch.qos.logback.core.spi.FilterReply;
|
||||||
|
import com.zhgd.xmgl.util.LogMdcUtil;
|
||||||
|
|
||||||
|
import static com.zhgd.xmgl.util.LogMdcUtil.isAddTraceTrail;
|
||||||
|
|
||||||
public class LogPrintFilter extends Filter<ILoggingEvent> {
|
public class LogPrintFilter extends Filter<ILoggingEvent> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FilterReply decide(ILoggingEvent event) {
|
public FilterReply decide(ILoggingEvent event) {
|
||||||
if (StdOutImplCustom.isPrint()) {
|
if (LogMdcUtil.isPrint()) {
|
||||||
|
boolean addTraceTrail = isAddTraceTrail();
|
||||||
|
if (addTraceTrail) {
|
||||||
|
LogMdcUtil.setStackInfo();
|
||||||
|
}
|
||||||
return FilterReply.ACCEPT;
|
return FilterReply.ACCEPT;
|
||||||
} else {
|
} else {
|
||||||
return FilterReply.DENY;
|
return FilterReply.DENY;
|
||||||
|
|||||||
@ -1,15 +1,7 @@
|
|||||||
package com.zhgd.config;
|
package com.zhgd.config;
|
||||||
|
|
||||||
import com.WisdomSiteApplication;
|
import com.zhgd.xmgl.util.LogMdcUtil;
|
||||||
import com.zhgd.xmgl.config.TaskAspect;
|
|
||||||
import com.zhgd.xmgl.constant.Cts;
|
|
||||||
import com.zhgd.xmgl.util.ThreadLocalUtil;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.ibatis.logging.Log;
|
import org.apache.ibatis.logging.Log;
|
||||||
import org.springframework.boot.CommandLineRunner;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class StdOutImplCustom implements Log {
|
public class StdOutImplCustom implements Log {
|
||||||
|
|
||||||
@ -17,21 +9,14 @@ public class StdOutImplCustom implements Log {
|
|||||||
// Do Nothing
|
// Do Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Boolean isPrint() {
|
|
||||||
if (!Objects.equals(TaskAspect.onlyPrintInterface, 1)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return WisdomSiteApplication.runSucess && Objects.equals(ThreadLocalUtil.getByKey(Cts.TL_IS_FROM_WEB, Boolean.class), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDebugEnabled() {
|
public boolean isDebugEnabled() {
|
||||||
return isPrint();
|
return LogMdcUtil.isPrint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isTraceEnabled() {
|
public boolean isTraceEnabled() {
|
||||||
return isPrint();
|
return LogMdcUtil.isPrint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -47,14 +32,14 @@ public class StdOutImplCustom implements Log {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void debug(String s) {
|
public void debug(String s) {
|
||||||
if (isPrint()) {
|
if (LogMdcUtil.isPrint()) {
|
||||||
System.out.println(s);
|
System.out.println(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void trace(String s) {
|
public void trace(String s) {
|
||||||
if (isPrint()) {
|
if (LogMdcUtil.isPrint()) {
|
||||||
System.out.println(s);
|
System.out.println(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor;
|
|||||||
import com.zhgd.annotation.DataScope;
|
import com.zhgd.annotation.DataScope;
|
||||||
import com.zhgd.xmgl.security.util.SecurityUtils;
|
import com.zhgd.xmgl.security.util.SecurityUtils;
|
||||||
import com.zhgd.xmgl.util.EnvironmentUtil;
|
import com.zhgd.xmgl.util.EnvironmentUtil;
|
||||||
|
import com.zhgd.xmgl.util.LogMdcUtil;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.sf.jsqlparser.schema.Table;
|
import net.sf.jsqlparser.schema.Table;
|
||||||
@ -69,8 +70,8 @@ public class DataScopeInterceptor extends JsqlParserSupport implements InnerInte
|
|||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
|
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
|
||||||
for (StackTraceElement e : stackTrace) {
|
for (StackTraceElement e : stackTrace) {
|
||||||
if (e.getClassName().startsWith("com.zhgd") && notInPackage(e.getClassName()) && !e.getClassName().contains("$$")) {
|
if (e.getClassName().startsWith("com.zhgd") && LogMdcUtil.notInPackage(e.getClassName()) && !e.getClassName().contains("$$")) {
|
||||||
sb.append(StrUtil.subAfter(e.getClassName(),".",true));
|
sb.append(StrUtil.subAfter(e.getClassName(), ".", true));
|
||||||
sb.append(".");
|
sb.append(".");
|
||||||
sb.append(e.getMethodName());
|
sb.append(e.getMethodName());
|
||||||
sb.append("(");
|
sb.append("(");
|
||||||
@ -85,10 +86,6 @@ public class DataScopeInterceptor extends JsqlParserSupport implements InnerInte
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean notInPackage(String className) {
|
|
||||||
return !className.startsWith("com.zhgd.mybatis") && !className.startsWith("com.zhgd.xmgl.config") && !className.startsWith("com.zhgd.xmgl.security");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getCallPosition() {
|
private static String getCallPosition() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
|
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
|
||||||
|
|||||||
@ -160,12 +160,14 @@ public class AsyncHikvision {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Async("carInfoExecutor")
|
@Async("carInfoExecutor")
|
||||||
public void addCarInfoForHikvisionAsyc(CarInfo carInfo) {
|
public void addCarInfoForHikvisionAsyc(CarInfo carInfo, Boolean existIsc) {
|
||||||
try {
|
try {
|
||||||
hikvisionCall.saveCarInfoFromHikvision(carInfo);
|
hikvisionCall.saveCarInfoFromHikvision(carInfo);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("海康:", e);
|
log.error("海康:", e);
|
||||||
sendNoticeForCar(carInfo, e, "添加");
|
sendNoticeForCar(carInfo, e, "添加");
|
||||||
|
} finally {
|
||||||
|
xzHikvisionCompareDataService.compareRetrySuccess(existIsc, carInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,22 +198,26 @@ public class AsyncHikvision {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Async("carInfoExecutor")
|
@Async("carInfoExecutor")
|
||||||
public void editCarInfoForHikvisionAsync(CarInfo carInfo, CarInfo old) {
|
public void editCarInfoForHikvisionAsync(CarInfo carInfo, CarInfo old, Boolean existIsc) {
|
||||||
try {
|
try {
|
||||||
hikvisionCall.editCarInfoForHikvision(carInfo, old);
|
hikvisionCall.editCarInfoForHikvision(carInfo, old);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("海康:", e);
|
log.error("海康:", e);
|
||||||
sendNoticeForCar(carInfo, e, "编辑");
|
sendNoticeForCar(carInfo, e, "编辑");
|
||||||
|
} finally {
|
||||||
|
xzHikvisionCompareDataService.compareRetrySuccess(existIsc, carInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async("carInfoExecutor")
|
@Async("carInfoExecutor")
|
||||||
public void deleteCarInfoForHikvisionAsync(CarInfo carInfo, boolean isSetBlack) {
|
public void deleteCarInfoForHikvisionAsync(CarInfo carInfo, boolean isSetBlack, Boolean existIsc) {
|
||||||
try {
|
try {
|
||||||
hikvisionCall.deleteCarInfoForHikvision(carInfo, isSetBlack);
|
hikvisionCall.deleteCarInfoForHikvision(carInfo, isSetBlack);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("海康:", e);
|
log.error("海康:", e);
|
||||||
sendNoticeForCar(carInfo, e, "删除");
|
sendNoticeForCar(carInfo, e, "删除");
|
||||||
|
} finally {
|
||||||
|
xzHikvisionCompareDataService.compareRetrySuccess(existIsc, carInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1127,6 +1127,9 @@ public class HikvisionCall {
|
|||||||
success = true;
|
success = true;
|
||||||
msg = "同步成功,人员名称:" + workerInfo.getWorkerName() + ",身份证号:" + workerInfo.getIdCard();
|
msg = "同步成功,人员名称:" + workerInfo.getWorkerName() + ",身份证号:" + workerInfo.getIdCard();
|
||||||
title += "成功";
|
title += "成功";
|
||||||
|
} else if (Objects.equals(msg1, "Person Not Exists")) {
|
||||||
|
msg = "同步失败,人员名称:" + workerInfo.getWorkerName() + ",身份证号:" + workerInfo.getIdCard() + "。失败原因:人员不存在";
|
||||||
|
title += "失败";
|
||||||
} else {
|
} else {
|
||||||
msg = "同步失败,人员名称:" + workerInfo.getWorkerName() + ",身份证号:" + workerInfo.getIdCard() + "。失败原因:下发异常";
|
msg = "同步失败,人员名称:" + workerInfo.getWorkerName() + ",身份证号:" + workerInfo.getIdCard() + "。失败原因:下发异常";
|
||||||
title += "失败";
|
title += "失败";
|
||||||
@ -1421,7 +1424,7 @@ public class HikvisionCall {
|
|||||||
jo.put("searchKey", carInfo.getCarNumber());
|
jo.put("searchKey", carInfo.getCarNumber());
|
||||||
jo.put("pageNo", 1);
|
jo.put("pageNo", 1);
|
||||||
jo.put("pageSize", 1);
|
jo.put("pageSize", 1);
|
||||||
JSONObject joRs = queryAlarmCarPage(project, jo);
|
JSONObject joRs = HikvisionUtil.getBlackCarList(project, jo);
|
||||||
if (HikvisionUtil.isSuccess(joRs)) {
|
if (HikvisionUtil.isSuccess(joRs)) {
|
||||||
JSONObject dataJo = HikvisionUtil.getJSONObjectData(joRs);
|
JSONObject dataJo = HikvisionUtil.getJSONObjectData(joRs);
|
||||||
JSONArray listJa = dataJo.getJSONArray("list");
|
JSONArray listJa = dataJo.getJSONArray("list");
|
||||||
@ -1497,22 +1500,6 @@ public class HikvisionCall {
|
|||||||
return JSON.parseObject(HikvisionUtil.doPost(host, path, JSON.toJSONString(param), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret()));
|
return JSON.parseObject(HikvisionUtil.doPost(host, path, JSON.toJSONString(param), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询布防车辆
|
|
||||||
*
|
|
||||||
* @param project
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public JSONObject queryAlarmCarPage(Project project, JSONObject param) throws Exception {
|
|
||||||
if (project == null || !Objects.equals(project.getSyncHikvision(), 1)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final String ARTEMIS_PATH = "/artemis";
|
|
||||||
final String path = ARTEMIS_PATH + "/api/pms/v1/alarmCar/page";
|
|
||||||
String host = "https://" + project.getArtemisConfigHost();
|
|
||||||
return JSON.parseObject(HikvisionUtil.doPost(host, path, JSON.toJSONString(param), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存固定车
|
* 保存固定车
|
||||||
*
|
*
|
||||||
@ -1872,7 +1859,7 @@ public class HikvisionCall {
|
|||||||
if (project == null || !Objects.equals(project.getSyncHikvision(), 1)) {
|
if (project == null || !Objects.equals(project.getSyncHikvision(), 1)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Pair<Boolean, String> existAndIndexCode = existAndGetEnterpriseOrgIndexCodeByEnterpriseId(project, enterpriseInfo.getId());
|
Pair<Boolean, String> existAndIndexCode = existAndGetEnterpriseOrgIndexCodeByEnterpriseId(project, String.valueOf(enterpriseInfo.getId()));
|
||||||
HikvisionOrganization hikvisionOrganization = getHikvisionOrganization(enterpriseInfo, existAndIndexCode.getRight());
|
HikvisionOrganization hikvisionOrganization = getHikvisionOrganization(enterpriseInfo, existAndIndexCode.getRight());
|
||||||
if (existAndIndexCode.getLeft()) {
|
if (existAndIndexCode.getLeft()) {
|
||||||
editOrgFromHttp(project, hikvisionOrganization);
|
editOrgFromHttp(project, hikvisionOrganization);
|
||||||
@ -1881,10 +1868,10 @@ public class HikvisionCall {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Pair<Boolean, String> existAndGetEnterpriseOrgIndexCodeByEnterpriseId(Project project, Long enterpriseId) throws Exception {
|
private Pair<Boolean, String> existAndGetEnterpriseOrgIndexCodeByEnterpriseId(Project project, String enterpriseId) throws Exception {
|
||||||
EnterpriseInfo enterpriseInfo = BeanUtil.toBean(enterpriseInfoService.getEnterpriseInfoById(new MapBuilder<String, Object>()
|
EnterpriseInfo enterpriseInfo = BeanUtil.toBean(enterpriseInfoService.getEnterpriseInfoById(new MapBuilder<String, Object>()
|
||||||
.put(Cts.PROJECT_SN, project.getProjectSn()).put(Cts.ENTERPRISE_ID, enterpriseId).build()), EnterpriseInfo.class);
|
.put(Cts.PROJECT_SN, project.getProjectSn()).put(Cts.ENTERPRISE_ID, enterpriseId).build()), EnterpriseInfo.class);
|
||||||
JSONArray orgList = getOrgList(project, StrUtil.join(",", enterpriseInfo.getId(), enterpriseInfo.getProjectEnterprise().getId()), project.getProjectSn());
|
JSONArray orgList = getOrgList(project, StrUtil.join(",", enterpriseId, enterpriseInfo != null ? enterpriseInfo.getProjectEnterprise().getId() : ""), project.getProjectSn());
|
||||||
String index = null;
|
String index = null;
|
||||||
if (CollUtil.isEmpty(orgList)) {
|
if (CollUtil.isEmpty(orgList)) {
|
||||||
index = String.valueOf(enterpriseInfo.getProjectEnterprise().getId());
|
index = String.valueOf(enterpriseInfo.getProjectEnterprise().getId());
|
||||||
@ -1906,7 +1893,7 @@ public class HikvisionCall {
|
|||||||
if (project == null || !Objects.equals(project.getSyncHikvision(), 1)) {
|
if (project == null || !Objects.equals(project.getSyncHikvision(), 1)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Pair<Boolean, String> pair = existAndGetEnterpriseOrgIndexCodeByEnterpriseId(project, Long.valueOf(enterpriseId));
|
Pair<Boolean, String> pair = existAndGetEnterpriseOrgIndexCodeByEnterpriseId(project, String.valueOf(enterpriseId));
|
||||||
String rs = HikvisionUtil.deleteOrgByIndexCodes(project, Arrays.asList(pair.getRight()));
|
String rs = HikvisionUtil.deleteOrgByIndexCodes(project, Arrays.asList(pair.getRight()));
|
||||||
sendNoticeForOrg("删除组织到海康isc", rs, enterpriseName);
|
sendNoticeForOrg("删除组织到海康isc", rs, enterpriseName);
|
||||||
}
|
}
|
||||||
@ -1930,7 +1917,7 @@ public class HikvisionCall {
|
|||||||
hikvisionOrganization.setClientId(null);
|
hikvisionOrganization.setClientId(null);
|
||||||
hikvisionOrganization.setOrgIndexCode(String.valueOf(teamInfo.getId()));
|
hikvisionOrganization.setOrgIndexCode(String.valueOf(teamInfo.getId()));
|
||||||
hikvisionOrganization.setOrgName(teamInfo.getTeamName());
|
hikvisionOrganization.setOrgName(teamInfo.getTeamName());
|
||||||
hikvisionOrganization.setParentIndexCode(existAndGetEnterpriseOrgIndexCodeByEnterpriseId(project, teamInfo.getEnterpriseId()).getRight());
|
hikvisionOrganization.setParentIndexCode(existAndGetEnterpriseOrgIndexCodeByEnterpriseId(project, String.valueOf(teamInfo.getEnterpriseId())).getRight());
|
||||||
return hikvisionOrganization;
|
return hikvisionOrganization;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2003,7 +1990,7 @@ public class HikvisionCall {
|
|||||||
hikvisionOrganization.setClientId(null);
|
hikvisionOrganization.setClientId(null);
|
||||||
hikvisionOrganization.setOrgIndexCode(String.valueOf(departmentInfo.getId()));
|
hikvisionOrganization.setOrgIndexCode(String.valueOf(departmentInfo.getId()));
|
||||||
hikvisionOrganization.setOrgName(departmentInfo.getDepartmentName());
|
hikvisionOrganization.setOrgName(departmentInfo.getDepartmentName());
|
||||||
hikvisionOrganization.setParentIndexCode(existAndGetEnterpriseOrgIndexCodeByEnterpriseId(project, departmentInfo.getEnterpriseId()).getRight());
|
hikvisionOrganization.setParentIndexCode(existAndGetEnterpriseOrgIndexCodeByEnterpriseId(project, String.valueOf(departmentInfo.getEnterpriseId())).getRight());
|
||||||
return hikvisionOrganization;
|
return hikvisionOrganization;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2193,7 +2180,11 @@ public class HikvisionCall {
|
|||||||
public void bindOrNotCarCategory(Project project, Integer operation, String categoryCode, CarInfo carInfo) throws Exception {
|
public void bindOrNotCarCategory(Project project, Integer operation, String categoryCode, CarInfo carInfo) throws Exception {
|
||||||
String carId = this.getRemoteCarIdByCarNumber(carInfo.getCarNumber(), project);
|
String carId = this.getRemoteCarIdByCarNumber(carInfo.getCarNumber(), project);
|
||||||
JSONObject param = new JSONObject();
|
JSONObject param = new JSONObject();
|
||||||
param.put("vehicleIds", carId == null ? carInfo.getId() : carId);
|
Object vehicleIds = carId == null ? carInfo.getId() : carId;
|
||||||
|
if (vehicleIds == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
param.put("vehicleIds", vehicleIds);
|
||||||
param.put("operation", operation);
|
param.put("operation", operation);
|
||||||
param.put("categoryCode", categoryCode);
|
param.put("categoryCode", categoryCode);
|
||||||
JSONObject jo = HikvisionUtil.bindCarCategory(project, param);
|
JSONObject jo = HikvisionUtil.bindCarCategory(project, param);
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
package com.zhgd.xmgl.config;
|
package com.zhgd.xmgl.config;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.zhgd.xmgl.util.RequestIdUtil;
|
import com.zhgd.xmgl.util.LogMdcUtil;
|
||||||
import com.zhgd.xmgl.util.ThreadLocalUtil;
|
import com.zhgd.xmgl.util.ThreadLocalUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.slf4j.MDC;
|
import org.slf4j.MDC;
|
||||||
@ -26,14 +26,14 @@ public class MdcThreadPoolTaskExecutor extends ThreadPoolTaskExecutor {
|
|||||||
if (null != context) {
|
if (null != context) {
|
||||||
MDC.setContextMap(context); //主线程MDC赋予子线程
|
MDC.setContextMap(context); //主线程MDC赋予子线程
|
||||||
} else {
|
} else {
|
||||||
RequestIdUtil.setRequestId(); //主线程没有MDC就自己生成一个
|
LogMdcUtil.setRequestId(); //主线程没有MDC就自己生成一个
|
||||||
}
|
}
|
||||||
ThreadLocalUtil.set(tlJo);
|
ThreadLocalUtil.set(tlJo);
|
||||||
try {
|
try {
|
||||||
task.run();
|
task.run();
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
RequestIdUtil.clear();
|
LogMdcUtil.clear();
|
||||||
ThreadLocalUtil.remove();
|
ThreadLocalUtil.remove();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("MDC clear exception:{}", e.getMessage());
|
log.warn("MDC clear exception:{}", e.getMessage());
|
||||||
@ -54,14 +54,14 @@ public class MdcThreadPoolTaskExecutor extends ThreadPoolTaskExecutor {
|
|||||||
if (null != context) {
|
if (null != context) {
|
||||||
MDC.setContextMap(context); //主线程MDC赋予子线程
|
MDC.setContextMap(context); //主线程MDC赋予子线程
|
||||||
} else {
|
} else {
|
||||||
RequestIdUtil.setRequestId(); //主线程没有MDC就自己生成一个
|
LogMdcUtil.setRequestId(); //主线程没有MDC就自己生成一个
|
||||||
}
|
}
|
||||||
ThreadLocalUtil.set(tlJo);
|
ThreadLocalUtil.set(tlJo);
|
||||||
try {
|
try {
|
||||||
return task.call();
|
return task.call();
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
RequestIdUtil.clear();
|
LogMdcUtil.clear();
|
||||||
ThreadLocalUtil.remove();
|
ThreadLocalUtil.remove();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("MDC clear exception:{}", e.getMessage());
|
log.warn("MDC clear exception:{}", e.getMessage());
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
package com.zhgd.xmgl.config;
|
package com.zhgd.xmgl.config;
|
||||||
|
|
||||||
import com.zhgd.config.StdOutImplCustom;
|
|
||||||
import com.zhgd.xmgl.constant.Cts;
|
import com.zhgd.xmgl.constant.Cts;
|
||||||
import com.zhgd.xmgl.util.RequestIdUtil;
|
import com.zhgd.xmgl.util.LogMdcUtil;
|
||||||
import com.zhgd.xmgl.util.ThreadLocalUtil;
|
import com.zhgd.xmgl.util.ThreadLocalUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
@ -45,7 +44,7 @@ public class TaskAspect {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
if (null == context) {
|
if (null == context) {
|
||||||
RequestIdUtil.setRequestId("-t"); //主线程没有MDC就自己生成一个
|
LogMdcUtil.setRequestId("-t"); //主线程没有MDC就自己生成一个
|
||||||
ThreadLocalUtil.addInKey(Cts.TL_IS_FROM_TASK, true);
|
ThreadLocalUtil.addInKey(Cts.TL_IS_FROM_TASK, true);
|
||||||
log.info("task方法开始:{}", methodName);
|
log.info("task方法开始:{}", methodName);
|
||||||
}
|
}
|
||||||
@ -68,7 +67,7 @@ public class TaskAspect {
|
|||||||
Object proceed = jointPoint.proceed();
|
Object proceed = jointPoint.proceed();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (StdOutImplCustom.isPrint()) {
|
if (LogMdcUtil.isPrint()) {
|
||||||
throw e;
|
throw e;
|
||||||
} else {
|
} else {
|
||||||
log.error("", e);
|
log.error("", e);
|
||||||
@ -76,7 +75,7 @@ public class TaskAspect {
|
|||||||
} finally {
|
} finally {
|
||||||
if (null == context) {
|
if (null == context) {
|
||||||
log.info("task方法结束:{}", methodName);
|
log.info("task方法结束:{}", methodName);
|
||||||
RequestIdUtil.clear();
|
LogMdcUtil.clear();
|
||||||
ThreadLocalUtil.remove();
|
ThreadLocalUtil.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import com.zhgd.xmgl.async.AsyncHikvision;
|
|||||||
import com.zhgd.xmgl.modules.car.entity.CarInfo;
|
import com.zhgd.xmgl.modules.car.entity.CarInfo;
|
||||||
import com.zhgd.xmgl.modules.car.entity.vo.CountCarModuleTypeVo;
|
import com.zhgd.xmgl.modules.car.entity.vo.CountCarModuleTypeVo;
|
||||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||||
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|||||||
@ -25,10 +25,12 @@ import com.zhgd.xmgl.modules.car.mapper.*;
|
|||||||
import com.zhgd.xmgl.modules.car.service.ICarInfoService;
|
import com.zhgd.xmgl.modules.car.service.ICarInfoService;
|
||||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||||
import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
|
import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
|
||||||
|
import com.zhgd.xmgl.modules.project.service.impl.ProjectServiceImpl;
|
||||||
import com.zhgd.xmgl.modules.worker.mapper.WorkerInfoMapper;
|
import com.zhgd.xmgl.modules.worker.mapper.WorkerInfoMapper;
|
||||||
import com.zhgd.xmgl.modules.worker.service.impl.EnterpriseInfoServiceImpl;
|
import com.zhgd.xmgl.modules.worker.service.impl.EnterpriseInfoServiceImpl;
|
||||||
import com.zhgd.xmgl.modules.xz.entity.XzHikvisionSync;
|
import com.zhgd.xmgl.modules.xz.entity.XzHikvisionSync;
|
||||||
import com.zhgd.xmgl.modules.xz.mapper.XzHikvisionSyncMapper;
|
import com.zhgd.xmgl.modules.xz.mapper.XzHikvisionSyncMapper;
|
||||||
|
import com.zhgd.xmgl.modules.xz.service.impl.XzHikvisionCompareDataServiceImpl;
|
||||||
import com.zhgd.xmgl.util.MessageUtil;
|
import com.zhgd.xmgl.util.MessageUtil;
|
||||||
import com.zhgd.xmgl.util.PageUtil;
|
import com.zhgd.xmgl.util.PageUtil;
|
||||||
import com.zhgd.xmgl.util.PathUtil;
|
import com.zhgd.xmgl.util.PathUtil;
|
||||||
@ -63,6 +65,12 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
|
|||||||
ProjectCarCameraConfigServiceImpl projectCarCameraConfigService;
|
ProjectCarCameraConfigServiceImpl projectCarCameraConfigService;
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
|
XzHikvisionCompareDataServiceImpl xzHikvisionCompareDataService;
|
||||||
|
@Lazy
|
||||||
|
@Autowired
|
||||||
|
ProjectServiceImpl projectService;
|
||||||
|
@Lazy
|
||||||
|
@Autowired
|
||||||
private XzHikvisionSyncMapper xzHikvisionSyncMapper;
|
private XzHikvisionSyncMapper xzHikvisionSyncMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private EnterpriseInfoServiceImpl enterpriseInfoService;
|
private EnterpriseInfoServiceImpl enterpriseInfoService;
|
||||||
@ -367,7 +375,7 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
|
|||||||
} else if (Objects.equals(carInfo.getCarModuleType(), 2) || Objects.equals(carInfo.getCarModuleType(), 3)) {
|
} else if (Objects.equals(carInfo.getCarModuleType(), 2) || Objects.equals(carInfo.getCarModuleType(), 3)) {
|
||||||
xzHikvisionSyncMapper.insert(new XzHikvisionSync().setProjectSn(carInfo.getProjectSn()).setType(6).setOperate(1).setWhoId(carInfo.getId()).setBigType(2).setCreateDate(getSyncTimeWithInitIfAbsent(2, carInfo.getId())));
|
xzHikvisionSyncMapper.insert(new XzHikvisionSync().setProjectSn(carInfo.getProjectSn()).setType(6).setOperate(1).setWhoId(carInfo.getId()).setBigType(2).setCreateDate(getSyncTimeWithInitIfAbsent(2, carInfo.getId())));
|
||||||
}
|
}
|
||||||
asyncHikvision.addCarInfoForHikvisionAsyc(carInfo);
|
asyncHikvision.addCarInfoForHikvisionAsyc(carInfo, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,7 +393,7 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
|
|||||||
xzHikvisionSyncMapper.insert(new XzHikvisionSync().setProjectSn(carInfo.getProjectSn()).setType(6).setOperate(3).setWhoId(carInfo.getId()).setBigType(2).setCreateDate(getSyncTimeWithInitIfAbsent(2, carInfo.getId())));
|
xzHikvisionSyncMapper.insert(new XzHikvisionSync().setProjectSn(carInfo.getProjectSn()).setType(6).setOperate(3).setWhoId(carInfo.getId()).setBigType(2).setCreateDate(getSyncTimeWithInitIfAbsent(2, carInfo.getId())));
|
||||||
}
|
}
|
||||||
xzHikvisionSyncMapper.insert(new XzHikvisionSync().setProjectSn(carInfo.getProjectSn()).setType(7).setOperate(isSetBlack ? 1 : 3).setWhoId(carInfo.getId()).setBigType(2).setCreateDate(getSyncTimeWithInitIfAbsent(2, carInfo.getId())));
|
xzHikvisionSyncMapper.insert(new XzHikvisionSync().setProjectSn(carInfo.getProjectSn()).setType(7).setOperate(isSetBlack ? 1 : 3).setWhoId(carInfo.getId()).setBigType(2).setCreateDate(getSyncTimeWithInitIfAbsent(2, carInfo.getId())));
|
||||||
asyncHikvision.deleteCarInfoForHikvisionAsync(carInfo, isSetBlack);
|
asyncHikvision.deleteCarInfoForHikvisionAsync(carInfo, isSetBlack, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -407,7 +415,7 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
|
|||||||
if (old.getIsBlack() == 1) {
|
if (old.getIsBlack() == 1) {
|
||||||
xzHikvisionSyncMapper.insert(new XzHikvisionSync().setProjectSn(carInfo.getProjectSn()).setType(7).setOperate(3).setWhoId(carInfo.getId()).setBigType(2).setCreateDate(getSyncTimeWithInitIfAbsent(2, carInfo.getId())));
|
xzHikvisionSyncMapper.insert(new XzHikvisionSync().setProjectSn(carInfo.getProjectSn()).setType(7).setOperate(3).setWhoId(carInfo.getId()).setBigType(2).setCreateDate(getSyncTimeWithInitIfAbsent(2, carInfo.getId())));
|
||||||
}
|
}
|
||||||
asyncHikvision.editCarInfoForHikvisionAsync(carInfo, old);
|
asyncHikvision.editCarInfoForHikvisionAsync(carInfo, old, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -330,26 +330,28 @@ public class XzHikvisionCompareDataServiceImpl extends ServiceImpl<XzHikvisionCo
|
|||||||
private void syncCar(XzHikvisionCompareData data) throws Exception {
|
private void syncCar(XzHikvisionCompareData data) throws Exception {
|
||||||
ProjectInfoExtVo projectInfoBySn = projectService.getProjectInfoBySn(data.getProjectSn());
|
ProjectInfoExtVo projectInfoBySn = projectService.getProjectInfoBySn(data.getProjectSn());
|
||||||
CarInfo carInfo = carInfoService.queryById(data.getUniqueId());
|
CarInfo carInfo = carInfoService.queryById(data.getUniqueId());
|
||||||
Boolean existIsc = null;
|
|
||||||
if (data.getExistIsc() == 1 && data.getExistMyPlatform() == 0) {
|
if (data.getExistIsc() == 1 && data.getExistMyPlatform() == 0) {
|
||||||
//查询id是否存在平台,存在就更新,不存在就删除
|
//查询id是否存在平台,存在就更新,不存在就删除
|
||||||
if (carInfo != null) {
|
if (carInfo != null) {
|
||||||
//同步海康
|
//同步海康
|
||||||
carInfoService.editCarInfoForHikvision(carInfo, carInfo);
|
asyncHikvision.editCarInfoForHikvisionAsync(carInfo, carInfo, true);
|
||||||
existIsc = true;
|
|
||||||
} else {
|
} else {
|
||||||
carInfo = new CarInfo();
|
carInfo = new CarInfo();
|
||||||
carInfo.setCarNumber(data.getCarNumber());
|
carInfo.setCarNumber(data.getCarNumber());
|
||||||
carInfo.setProjectSn(data.getProjectSn());
|
carInfo.setProjectSn(data.getProjectSn());
|
||||||
carInfoService.deleteCarInfoForHikvision(carInfo, false);
|
asyncHikvision.deleteCarInfoForHikvisionAsync(carInfo, false, false);
|
||||||
existIsc = false;
|
|
||||||
}
|
}
|
||||||
compareRetrySuccess(projectInfoBySn, carInfo, existIsc);
|
|
||||||
} else if (data.getExistIsc() == 0 && data.getExistMyPlatform() == 1) {
|
} else if (data.getExistIsc() == 0 && data.getExistMyPlatform() == 1) {
|
||||||
//查询id是否存在isc,存在就更新,不存在就新增
|
//查询id是否存在isc,存在就更新,不存在就新增
|
||||||
JSONObject rtJo;
|
JSONObject rtJo;
|
||||||
if (Objects.equals(carInfo.getCarModuleType(), 1)) {
|
if (Objects.equals(carInfo.getCarModuleType(), 1)) {
|
||||||
rtJo = HikvisionUtil.getFixCarListByCarNumber(data.getCarNumber(), projectInfoBySn, 1);
|
rtJo = HikvisionUtil.getFixCarListByCarNumber(data.getCarNumber(), projectInfoBySn, 1);
|
||||||
|
} else if (Objects.equals(carInfo.getIsBlack(), 1)) {
|
||||||
|
JSONObject jo = new JSONObject();
|
||||||
|
jo.put("searchKey", carInfo.getCarNumber());
|
||||||
|
jo.put("pageNo", 1);
|
||||||
|
jo.put("pageSize", 1);
|
||||||
|
rtJo = HikvisionUtil.getBlackCarList(projectInfoBySn, jo);
|
||||||
} else {
|
} else {
|
||||||
rtJo = HikvisionUtil.getReservationCarInfoList(carInfo.getCarNumber(), projectInfoBySn);
|
rtJo = HikvisionUtil.getReservationCarInfoList(carInfo.getCarNumber(), projectInfoBySn);
|
||||||
}
|
}
|
||||||
@ -357,17 +359,15 @@ public class XzHikvisionCompareDataServiceImpl extends ServiceImpl<XzHikvisionCo
|
|||||||
JSONArray list = HikvisionUtil.getJSONObjectData(rtJo).getJSONArray("list");
|
JSONArray list = HikvisionUtil.getJSONObjectData(rtJo).getJSONArray("list");
|
||||||
if (CollUtil.isEmpty(list)) {
|
if (CollUtil.isEmpty(list)) {
|
||||||
//新增
|
//新增
|
||||||
carInfoService.addCarInfoForHikvision(carInfo, asyncHikvision);
|
asyncHikvision.addCarInfoForHikvisionAsyc(carInfo, true);
|
||||||
} else {
|
} else {
|
||||||
//更新
|
//更新
|
||||||
asyncHikvision.editCarInfoForHikvisionAsync(carInfo, carInfo);
|
asyncHikvision.editCarInfoForHikvisionAsync(carInfo, carInfo, true);
|
||||||
}
|
}
|
||||||
existIsc = true;
|
|
||||||
} else {
|
} else {
|
||||||
log.error("校验数据同步海康失败,失败原因:{}", rtJo.toJSONString());
|
log.error("校验数据同步海康失败,失败原因:{}", rtJo.toJSONString());
|
||||||
existIsc = false;
|
compareRetrySuccess(projectInfoBySn, carInfo, false);
|
||||||
}
|
}
|
||||||
compareRetrySuccess(projectInfoBySn, carInfo, existIsc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,7 +377,7 @@ public class XzHikvisionCompareDataServiceImpl extends ServiceImpl<XzHikvisionCo
|
|||||||
* @param existSuc isc存在车辆就成功,反之
|
* @param existSuc isc存在车辆就成功,反之
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private void compareRetrySuccess(ProjectInfoExtVo projectInfoBySn, CarInfo carInfo, boolean existSuc) throws Exception {
|
public void compareRetrySuccess(ProjectInfoExtVo projectInfoBySn, CarInfo carInfo, boolean existSuc) throws Exception {
|
||||||
//验证执行是否成功
|
//验证执行是否成功
|
||||||
JSONArray listJa;
|
JSONArray listJa;
|
||||||
if (carInfo.getCarModuleType() == null) {
|
if (carInfo.getCarModuleType() == null) {
|
||||||
@ -438,6 +438,22 @@ public class XzHikvisionCompareDataServiceImpl extends ServiceImpl<XzHikvisionCo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否从数据校验这里来
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public void compareRetrySuccess(Boolean existIsc, CarInfo carInfo) {
|
||||||
|
try {
|
||||||
|
if (existIsc != null) {
|
||||||
|
ProjectInfoExtVo projectInfoBySn = projectService.getProjectInfoBySn(carInfo.getProjectSn());
|
||||||
|
xzHikvisionCompareDataService.compareRetrySuccess(projectInfoBySn, carInfo, existIsc);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCompareDataForEnterprise(Project project, String orgName, int existIsc, int existMyPlatform, String uniqueId) {
|
public void addCompareDataForEnterprise(Project project, String orgName, int existIsc, int existMyPlatform, String uniqueId) {
|
||||||
XzHikvisionCompareData data = new XzHikvisionCompareData();
|
XzHikvisionCompareData data = new XzHikvisionCompareData();
|
||||||
|
|||||||
@ -2,7 +2,7 @@ package com.zhgd.xmgl.security;
|
|||||||
|
|
||||||
import com.zhgd.xmgl.constant.Cts;
|
import com.zhgd.xmgl.constant.Cts;
|
||||||
import com.zhgd.xmgl.security.util.SecurityUtils;
|
import com.zhgd.xmgl.security.util.SecurityUtils;
|
||||||
import com.zhgd.xmgl.util.RequestIdUtil;
|
import com.zhgd.xmgl.util.LogMdcUtil;
|
||||||
import com.zhgd.xmgl.util.ThreadLocalUtil;
|
import com.zhgd.xmgl.util.ThreadLocalUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -16,14 +16,14 @@ public class RequestIdFilter implements Filter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||||
RequestIdUtil.setRequestId("-i");
|
LogMdcUtil.setRequestId("-i");
|
||||||
ThreadLocalUtil.addInKey(Cts.TL_IS_FROM_WEB, true);
|
ThreadLocalUtil.addInKey(Cts.TL_IS_FROM_WEB, true);
|
||||||
ThreadLocalUtil.addInKey(Cts.TL_AUTH_USER, SecurityUtils.getUser());
|
ThreadLocalUtil.addInKey(Cts.TL_AUTH_USER, SecurityUtils.getUser());
|
||||||
try {
|
try {
|
||||||
filterChain.doFilter(servletRequest, servletResponse);
|
filterChain.doFilter(servletRequest, servletResponse);
|
||||||
} finally {
|
} finally {
|
||||||
log.info("接口结束...");
|
log.info("接口结束...");
|
||||||
RequestIdUtil.clear();
|
LogMdcUtil.clear();
|
||||||
ThreadLocalUtil.remove();
|
ThreadLocalUtil.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -177,6 +177,7 @@ public class HikvisionTask {
|
|||||||
public void compareHikvisionForCar(Project project) throws Exception {
|
public void compareHikvisionForCar(Project project) throws Exception {
|
||||||
compareHikvisionForFixCar(project);
|
compareHikvisionForFixCar(project);
|
||||||
compareHikvisionForReservationCar(project);
|
compareHikvisionForReservationCar(project);
|
||||||
|
compareHikvisionForBlackCar(project);
|
||||||
xzHikvisionCompareDataService.addSuccessShow(project.getProjectSn(), "4");
|
xzHikvisionCompareDataService.addSuccessShow(project.getProjectSn(), "4");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,6 +359,22 @@ public class HikvisionTask {
|
|||||||
compareAndAddData(project, listJa, carInfoList);
|
compareAndAddData(project, listJa, carInfoList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void compareHikvisionForBlackCar(Project project) throws Exception {
|
||||||
|
JSONObject param = new JSONObject();
|
||||||
|
HikvisionUtil.addPageParamIfAbsent(param);
|
||||||
|
JSONObject jo = new JSONObject();
|
||||||
|
jo.put("pageNo", 1);
|
||||||
|
jo.put("pageSize", 1000);
|
||||||
|
JSONObject joRs = HikvisionUtil.getBlackCarList(project, jo);
|
||||||
|
JSONObject dataJo = HikvisionUtil.getJSONObjectData(joRs);
|
||||||
|
JSONArray listJa = dataJo.getJSONArray("list");
|
||||||
|
List<CarInfo> carInfoList = carInfoService.selectCarList(new MapBuilder<String, Object>()
|
||||||
|
.put(Cts.PROJECT_SN, project.getProjectSn())
|
||||||
|
.put("isBlack", 1)
|
||||||
|
.build());
|
||||||
|
compareAndAddData(project, listJa, carInfoList);
|
||||||
|
}
|
||||||
|
|
||||||
private void compareAndAddData(Project project, JSONArray listJa, List<CarInfo> carInfoList) {
|
private void compareAndAddData(Project project, JSONArray listJa, List<CarInfo> carInfoList) {
|
||||||
if (CollUtil.isEmpty(listJa)) {
|
if (CollUtil.isEmpty(listJa)) {
|
||||||
for (CarInfo carInfo : carInfoList) {
|
for (CarInfo carInfo : carInfoList) {
|
||||||
|
|||||||
@ -399,4 +399,20 @@ public class HikvisionUtil {
|
|||||||
String rs = doPost(host, path, jo.toJSONString(), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
String rs = doPost(host, path, jo.toJSONString(), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
||||||
return rs;
|
return rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询黑名单(布防)车辆
|
||||||
|
*
|
||||||
|
* @param project
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static JSONObject getBlackCarList(Project project, JSONObject param) throws Exception {
|
||||||
|
if (project == null || !Objects.equals(project.getSyncHikvision(), 1)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final String ARTEMIS_PATH = "/artemis";
|
||||||
|
final String path = ARTEMIS_PATH + "/api/pms/v1/alarmCar/page";
|
||||||
|
String host = "https://" + project.getArtemisConfigHost();
|
||||||
|
return JSON.parseObject(doPost(host, path, JSON.toJSONString(param), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
85
src/main/java/com/zhgd/xmgl/util/LogMdcUtil.java
Normal file
85
src/main/java/com/zhgd/xmgl/util/LogMdcUtil.java
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
package com.zhgd.xmgl.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.WisdomSiteApplication;
|
||||||
|
import com.zhgd.xmgl.config.TaskAspect;
|
||||||
|
import com.zhgd.xmgl.constant.Cts;
|
||||||
|
import org.slf4j.MDC;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class LogMdcUtil {
|
||||||
|
public static final String REQUEST_ID = "requestId";
|
||||||
|
public static final String STACK_INFO = "stackInfo";
|
||||||
|
|
||||||
|
public static void setRequestId() {
|
||||||
|
MDC.put(REQUEST_ID, getRandomStr());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setRequestId(String s) {
|
||||||
|
MDC.put(REQUEST_ID, getRandomStr() + s);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getRequestId() {
|
||||||
|
return MDC.get(REQUEST_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getRandomStr() {
|
||||||
|
return IdUtil.fastSimpleUUID().substring(0, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setStackInfo() {
|
||||||
|
MDC.put(STACK_INFO, getCallPositionForDev());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clear() {
|
||||||
|
MDC.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否打印日志
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Boolean isPrint() {
|
||||||
|
if (!Objects.equals(TaskAspect.onlyPrintInterface, 1)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return WisdomSiteApplication.runSucess && Objects.equals(ThreadLocalUtil.getByKey(Cts.TL_IS_FROM_WEB, Boolean.class), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否添加堆栈到日志尾巴
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isAddTraceTrail() {
|
||||||
|
return Objects.equals(TaskAspect.onlyPrintInterface, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getCallPositionForDev() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("^^^********^^^");
|
||||||
|
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
|
||||||
|
for (StackTraceElement e : stackTrace) {
|
||||||
|
if (e.getClassName().startsWith("com.zhgd") && notInPackage(e.getClassName()) && !e.getClassName().contains("$$")) {
|
||||||
|
sb.append(StrUtil.subAfter(e.getClassName(), ".", true));
|
||||||
|
sb.append(".");
|
||||||
|
sb.append(e.getMethodName());
|
||||||
|
sb.append("(");
|
||||||
|
sb.append(StrUtil.subAfter(e.getClassName(), ".", true));
|
||||||
|
sb.append(".java:");
|
||||||
|
sb.append(e.getLineNumber());
|
||||||
|
sb.append(")");
|
||||||
|
sb.append(" > ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean notInPackage(String className) {
|
||||||
|
return !className.startsWith("com.zhgd.mybatis") && !className.startsWith("com.zhgd.xmgl.config") && !className.startsWith("com.zhgd.xmgl.security")
|
||||||
|
&& !className.contains("LogMdcUtil") && !className.contains("LogPrintFilter");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,29 +0,0 @@
|
|||||||
package com.zhgd.xmgl.util;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
|
||||||
import org.slf4j.MDC;
|
|
||||||
|
|
||||||
public class RequestIdUtil {
|
|
||||||
public static final String REQUEST_ID = "requestId";
|
|
||||||
|
|
||||||
public static void setRequestId() {
|
|
||||||
MDC.put(REQUEST_ID, getRandomStr());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getRequestId() {
|
|
||||||
return MDC.get(REQUEST_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setRequestId(String s) {
|
|
||||||
MDC.put(REQUEST_ID, getRandomStr() + s);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getRandomStr() {
|
|
||||||
return IdUtil.fastSimpleUUID().substring(0, 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void clear() {
|
|
||||||
MDC.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -6,7 +6,9 @@
|
|||||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||||
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
|
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
|
||||||
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%highlight(%X{requestId})][%thread] %highlight(%-5level) %cyan(%logger{50}).%method:%L - %highlight(%msg) %n</pattern>
|
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%highlight(%X{requestId})][%thread] %highlight(%-5level)
|
||||||
|
%cyan(%logger{50}).%method:%L - %highlight(%msg) %X{stackInfo} %n
|
||||||
|
</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
<filter class="com.zhgd.config.LogPrintFilter">
|
<filter class="com.zhgd.config.LogPrintFilter">
|
||||||
</filter>
|
</filter>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user