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 com.gexin.fastjson.JSON;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.net.SocketTimeoutException;
/** /**
* http 工具类打印日志 * http 工具类打印日志
* *
@ -40,5 +42,14 @@ public class HttpUtils {
return rs; 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.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zhgd.jeecg.common.execption.OpenPromptException; 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.call.HikvisionCall;
import com.zhgd.xmgl.modules.basicdata.service.INoticeService; import com.zhgd.xmgl.modules.basicdata.service.INoticeService;
import com.zhgd.xmgl.modules.car.entity.CarInfo; 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.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.net.SocketTimeoutException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -76,8 +78,8 @@ public class AsyncHikvision {
String title = action + "人员到海康isc失败"; String title = action + "人员到海康isc失败";
String type = "23"; String type = "23";
String msg; String msg;
if (e instanceof java.net.ConnectException) { if (HttpUtils.isTimeOut(e)) {
msg = "同步失败,人员名称:" + workerInfo.getWorkerName() + ",身份证号:" + workerInfo.getIdCard() + "。失败原因:网络超时"; msg = "同步失败,人员名称:" + workerInfo.getWorkerName() + ",身份证号:" + workerInfo.getIdCard() + "。失败原因:网络异常";
} else if (e instanceof OpenPromptException) { } else if (e instanceof OpenPromptException) {
msg = "同步失败,人员名称:" + workerInfo.getWorkerName() + ",身份证号:" + workerInfo.getIdCard() + "。失败原因:" + e.getMessage(); msg = "同步失败,人员名称:" + workerInfo.getWorkerName() + ",身份证号:" + workerInfo.getIdCard() + "。失败原因:" + e.getMessage();
} else { } else {
@ -296,7 +298,7 @@ public class AsyncHikvision {
hikvisionCall.updatePersonAuth(workerInfo, ds, sucSb, failSb, 0); hikvisionCall.updatePersonAuth(workerInfo, ds, sucSb, failSb, 0);
} }
} catch (Exception e) { } catch (Exception e) {
if (e instanceof java.net.ConnectException) { if (HttpUtils.isTimeOut(e)) {
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), "网络异常", "人员下发设备提醒", "1"); noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), "网络异常", "人员下发设备提醒", "1");
} else { } else {
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), e.getMessage(), "人员下发设备提醒", "1"); noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), e.getMessage(), "人员下发设备提醒", "1");
@ -345,7 +347,7 @@ public class AsyncHikvision {
hikvisionCall.updatePersonAuth(workerInfo, ds, sucSb, failSb, 2); hikvisionCall.updatePersonAuth(workerInfo, ds, sucSb, failSb, 2);
} }
} catch (Exception e) { } catch (Exception e) {
if (e instanceof java.net.ConnectException) { if (HttpUtils.isTimeOut(e)) {
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), "网络异常", "人员下发设备提醒", "1"); noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), "网络异常", "人员下发设备提醒", "1");
} else { } else {
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), e.getMessage(), "人员下发设备提醒", "1"); 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()))); jo.put("paramValue", Arrays.asList(String.valueOf(workerInfo.getId())));
String rs = HikvisionUtil.doPost(host, path, jo.toJSONString(), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret()); String rs = HikvisionUtil.doPost(host, path, jo.toJSONString(), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
if (rs == null) { if (rs == null) {
throw new OpenAlertException("海康查询人员网络超时,名称:" + workerInfo.getWorkerName()); throw new OpenAlertException("海康查询人员网络异常,名称:" + workerInfo.getWorkerName());
} }
JSONObject joData = HikvisionUtil.getJSONObjectData(rs); JSONObject joData = HikvisionUtil.getJSONObjectData(rs);
if (joData != null) { if (joData != null) {
@ -1588,7 +1588,7 @@ public class HikvisionCall {
String body = jo.toJSONString(); String body = jo.toJSONString();
String rs = HikvisionUtil.doPost(host, path, body, null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret()); String rs = HikvisionUtil.doPost(host, path, body, null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
if (StringUtils.isBlank(rs)) { if (StringUtils.isBlank(rs)) {
throw new OpenAlertException("海康网络超时"); throw new OpenAlertException("海康网络异常");
} }
return rs; return rs;
} }
@ -1967,7 +1967,7 @@ public class HikvisionCall {
log.error(workerInfo.getWorkerName() + "" + dev.getDevName() + " fail" + sdRs.toJSONString() + ","); log.error(workerInfo.getWorkerName() + "" + dev.getDevName() + " fail" + sdRs.toJSONString() + ",");
String code = sdRs.getString("code"); String code = sdRs.getString("code");
if (Objects.equals(code, "0x15403007") || Objects.equals(code, "0x02401033")) { if (Objects.equals(code, "0x15403007") || Objects.equals(code, "0x02401033")) {
failSb.append(workerInfo.getWorkerName() + "" + dev.getDevName() + ",失败原因:网络超时"); failSb.append(workerInfo.getWorkerName() + "" + dev.getDevName() + ",失败原因:网络异常");
} else { } else {
failSb.append(workerInfo.getWorkerName() + "" + dev.getDevName() + ",下发异常;"); 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 pageNo = Integer.parseInt(map.getOrDefault("pageNo", 1).toString());
int pageSize = Integer.parseInt(map.getOrDefault("pageSize", 10).toString()); int pageSize = Integer.parseInt(map.getOrDefault("pageSize", 10).toString());
Page<EntityMap> page = new Page<>(pageNo, pageSize); Page<EntityMap> page = new Page<>(pageNo, pageSize);
//查父级企业sn
Set<String> inSnList = new HashSet<>();
if (StrUtil.isNotBlank(projectSn)) { if (StrUtil.isNotBlank(projectSn)) {
Company c = companyMapper.getCompanyForProjectByProjectSn(projectSn); Company c = companyMapper.getCompanyForProjectByProjectSn(projectSn);
if (c == null) { if (c == null) {
throw new OpenAlertException("企业不存在"); throw new OpenAlertException("企业不存在");
} }
map.put("sn", c.getCompanySn()); map.put("sn", c.getCompanySn());
inSnList.add(c.getCompanySn());
} else { } else {
map.put("sn", companySn); map.put("sn", companySn);
inSnList.add(companySn);
} }
//查父级企业sn
Set<String> inSnList = new HashSet<>();
inSnList.add(companySn);
Company c1 = null; Company c1 = null;
do { do {
c1 = companyMapper.getParentCompanySn(map); c1 = companyMapper.getParentCompanySn(map);
if (c1 != null) { if (c1 != null && StrUtil.isNotBlank(c1.getCompanySn())) {
inSnList.add(c1.getCompanySn()); inSnList.add(c1.getCompanySn());
map.put("sn", c1.getCompanySn()); map.put("sn", c1.getCompanySn());
inSnList.add(c1.getHeadquartersSn()); inSnList.add(c1.getHeadquartersSn());

View File

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