bug修改

This commit is contained in:
guoshengxiong 2024-04-19 15:33:40 +08:00
parent 1d05f53d0a
commit 55f9664f04
5 changed files with 28 additions and 15 deletions

View File

@ -5,6 +5,8 @@ import cn.hutool.http.HttpUtil;
import com.gexin.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import java.net.SocketTimeoutException;
/**
* http 工具类打印日志
*
@ -40,5 +42,14 @@ public class HttpUtils {
return rs;
}
/**
* 是否网络异常
*
* @param e
* @return
*/
public static boolean isTimeOut(Exception e) {
return e instanceof java.net.ConnectException || e instanceof SocketTimeoutException;
}
}

View File

@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zhgd.jeecg.common.execption.OpenPromptException;
import com.zhgd.jeecg.common.util.pass.HttpUtils;
import com.zhgd.xmgl.call.HikvisionCall;
import com.zhgd.xmgl.modules.basicdata.service.INoticeService;
import com.zhgd.xmgl.modules.car.entity.CarInfo;
@ -27,6 +28,7 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.net.SocketTimeoutException;
import java.util.ArrayList;
import java.util.List;
@ -76,8 +78,8 @@ public class AsyncHikvision {
String title = action + "人员到海康isc失败";
String type = "23";
String msg;
if (e instanceof java.net.ConnectException) {
msg = "同步失败,人员名称:" + workerInfo.getWorkerName() + ",身份证号:" + workerInfo.getIdCard() + "。失败原因:网络超时";
if (HttpUtils.isTimeOut(e)) {
msg = "同步失败,人员名称:" + workerInfo.getWorkerName() + ",身份证号:" + workerInfo.getIdCard() + "。失败原因:网络异常";
} else if (e instanceof OpenPromptException) {
msg = "同步失败,人员名称:" + workerInfo.getWorkerName() + ",身份证号:" + workerInfo.getIdCard() + "。失败原因:" + e.getMessage();
} else {
@ -296,7 +298,7 @@ public class AsyncHikvision {
hikvisionCall.updatePersonAuth(workerInfo, ds, sucSb, failSb, 0);
}
} catch (Exception e) {
if (e instanceof java.net.ConnectException) {
if (HttpUtils.isTimeOut(e)) {
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), "网络异常", "人员下发设备提醒", "1");
} else {
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), e.getMessage(), "人员下发设备提醒", "1");
@ -345,7 +347,7 @@ public class AsyncHikvision {
hikvisionCall.updatePersonAuth(workerInfo, ds, sucSb, failSb, 2);
}
} catch (Exception e) {
if (e instanceof java.net.ConnectException) {
if (HttpUtils.isTimeOut(e)) {
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), "网络异常", "人员下发设备提醒", "1");
} else {
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), e.getMessage(), "人员下发设备提醒", "1");

View File

@ -989,7 +989,7 @@ public class HikvisionCall {
jo.put("paramValue", Arrays.asList(String.valueOf(workerInfo.getId())));
String rs = HikvisionUtil.doPost(host, path, jo.toJSONString(), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
if (rs == null) {
throw new OpenAlertException("海康查询人员网络超时,名称:" + workerInfo.getWorkerName());
throw new OpenAlertException("海康查询人员网络异常,名称:" + workerInfo.getWorkerName());
}
JSONObject joData = HikvisionUtil.getJSONObjectData(rs);
if (joData != null) {
@ -1588,7 +1588,7 @@ public class HikvisionCall {
String body = jo.toJSONString();
String rs = HikvisionUtil.doPost(host, path, body, null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
if (StringUtils.isBlank(rs)) {
throw new OpenAlertException("海康网络超时");
throw new OpenAlertException("海康网络异常");
}
return rs;
}
@ -1967,7 +1967,7 @@ public class HikvisionCall {
log.error(workerInfo.getWorkerName() + "" + dev.getDevName() + " fail" + sdRs.toJSONString() + ",");
String code = sdRs.getString("code");
if (Objects.equals(code, "0x15403007") || Objects.equals(code, "0x02401033")) {
failSb.append(workerInfo.getWorkerName() + "" + dev.getDevName() + ",失败原因:网络超时");
failSb.append(workerInfo.getWorkerName() + "" + dev.getDevName() + ",失败原因:网络异常");
} else {
failSb.append(workerInfo.getWorkerName() + "" + dev.getDevName() + ",下发异常;");
}

View File

@ -46,22 +46,23 @@ public class CompanyFileServiceImpl extends ServiceImpl<CompanyFileMapper, Compa
int pageNo = Integer.parseInt(map.getOrDefault("pageNo", 1).toString());
int pageSize = Integer.parseInt(map.getOrDefault("pageSize", 10).toString());
Page<EntityMap> page = new Page<>(pageNo, pageSize);
//查父级企业sn
Set<String> inSnList = new HashSet<>();
if (StrUtil.isNotBlank(projectSn)) {
Company c = companyMapper.getCompanyForProjectByProjectSn(projectSn);
if (c == null) {
throw new OpenAlertException("企业不存在");
}
map.put("sn", c.getCompanySn());
inSnList.add(c.getCompanySn());
} else {
map.put("sn", companySn);
inSnList.add(companySn);
}
//查父级企业sn
Set<String> inSnList = new HashSet<>();
inSnList.add(companySn);
Company c1 = null;
do {
c1 = companyMapper.getParentCompanySn(map);
if (c1 != null) {
if (c1 != null && StrUtil.isNotBlank(c1.getCompanySn())) {
inSnList.add(c1.getCompanySn());
map.put("sn", c1.getCompanySn());
inSnList.add(c1.getHeadquartersSn());

View File

@ -365,6 +365,9 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
}
WorkerInfo oldWorkerInfo = workerInfoMapper.selectById(workerInfo.getId());
workerInfoMapper.updateById(workerInfo);
//同步海康
asyncHikvision.editWorkerForHikvision(workerInfo);
projectUfaceConfigService.updateWorkerInfo(workerInfo, oldWorkerInfo);
//上传住建
//housingDataCall.sendUpdateWork(workerInfo.getProjectSn(),workerInfo.getId());
@ -380,10 +383,6 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
govtOpenApiService.workerInfoAddSync(workerInfo);
}
asyncJiLianDa.saveWorkerInfo(workerInfo);
//同步海康
asyncHikvision.editWorkerForHikvision(workerInfo);
return workerInfo;
}