bug修改

This commit is contained in:
guoshengxiong 2024-04-28 23:47:29 +08:00
parent 97ba255b3f
commit 250cf9cccb
3 changed files with 50 additions and 40 deletions

View File

@ -20,6 +20,7 @@ import com.zhgd.xmgl.modules.worker.entity.DepartmentInfo;
import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo;
import com.zhgd.xmgl.modules.worker.entity.TeamInfo;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import com.zhgd.xmgl.modules.worker.mapper.EnterpriseInfoMapper;
import com.zhgd.xmgl.modules.xz.entity.XzHikvisionSync;
import com.zhgd.xmgl.modules.xz.mapper.XzHikvisionSyncMapper;
import com.zhgd.xmgl.security.util.SecurityUtils;
@ -52,6 +53,9 @@ public class AsyncHikvision {
ProjectVideoHkVqdMapper projectVideoHkVqdMapper;
@Lazy
@Autowired
EnterpriseInfoMapper enterpriseInfoMapper;
@Lazy
@Autowired
private INoticeService noticeService;
@Lazy
@Autowired
@ -60,7 +64,6 @@ public class AsyncHikvision {
@Autowired
private XzHikvisionSyncMapper xzHikvisionSyncMapper;
/**
* 添加劳务人员-海康
*
@ -189,6 +192,23 @@ public class AsyncHikvision {
hikvisionCall.addEnterpriseInfoForHikvision(enterpriseInfo);
} catch (Exception e) {
log.error("海康:", e);
sendNoticeForOrg(enterpriseInfo.getEnterpriseName(), e, "新增");
}
}
private void sendNoticeForOrg(String name, Exception e, String action) {
if (SecurityUtils.getUser().getUserId() != null) {
String title = action + "组织到海康isc失败";
String type = "23";
String msg;
if (HttpUtils.isTimeOut(e)) {
msg = "同步失败,组织名称:" + name + "。失败原因平台连接isc网络异常";
} else if (e instanceof OpenPromptException) {
msg = "同步失败,组织名称:" + name + "。失败原因:" + e.getMessage();
} else {
msg = "同步失败,组织名称:" + name + "。失败原因:下发异常";
}
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), msg, title, type);
}
}
@ -198,6 +218,7 @@ public class AsyncHikvision {
hikvisionCall.editEnterpriseInfoForHikvision(enterpriseInfo);
} catch (Exception e) {
log.error("海康:", e);
sendNoticeForOrg(enterpriseInfo.getEnterpriseName(), e, "编辑");
}
}
@ -207,6 +228,10 @@ public class AsyncHikvision {
hikvisionCall.deleteEnterpriseInfoForHikvision(enterpriseId, projectSn);
} catch (Exception e) {
log.error("海康:", e);
EnterpriseInfo enterpriseInfo = enterpriseInfoMapper.selectById(enterpriseId);
if (enterpriseInfo != null) {
sendNoticeForOrg(enterpriseInfo.getEnterpriseName(), e, "删除");
}
}
}
@ -216,6 +241,7 @@ public class AsyncHikvision {
hikvisionCall.editTeamInfoForHikvision(teamInfo);
} catch (Exception e) {
log.error("海康:", e);
sendNoticeForOrg(teamInfo.getTeamName(), e, "编辑");
}
}
@ -225,6 +251,7 @@ public class AsyncHikvision {
hikvisionCall.deleteTeamInfoForHikvision(teamInfo);
} catch (Exception e) {
log.error("海康:", e);
sendNoticeForOrg(teamInfo.getTeamName(), e, "删除");
}
}
@ -234,6 +261,7 @@ public class AsyncHikvision {
hikvisionCall.addTeamInfoForHikvision(teamInfo);
} catch (Exception e) {
log.error("海康:", e);
sendNoticeForOrg(teamInfo.getTeamName(), e, "新增");
}
}
@ -243,6 +271,7 @@ public class AsyncHikvision {
hikvisionCall.editDepartmentInfoForHikvision(teamInfo);
} catch (Exception e) {
log.error("海康:", e);
sendNoticeForOrg(teamInfo.getDepartmentName(), e, "编辑");
}
}
@ -252,6 +281,7 @@ public class AsyncHikvision {
hikvisionCall.addDepartmentInfoForHikvision(teamInfo);
} catch (Exception e) {
log.error("海康:", e);
sendNoticeForOrg(teamInfo.getDepartmentName(), e, "新增");
}
}
@ -261,6 +291,7 @@ public class AsyncHikvision {
hikvisionCall.deleteDepartmentInfoForHikvision(teamInfo);
} catch (Exception e) {
log.error("海康:", e);
sendNoticeForOrg(teamInfo.getDepartmentName(), e, "删除");
}
}
@ -270,6 +301,7 @@ public class AsyncHikvision {
hikvisionCall.editProjectForHikvision(project);
} catch (Exception e) {
log.error("海康:", e);
sendNoticeForOrg(project.getProjectName(), e, "编辑");
}
}

View File

@ -389,11 +389,6 @@ public class HikvisionCall {
}
}
log.info("服务挂了主动获取门禁点事件的人员通行记录执行完成startTime{}endTime{}", startTime, endTime);
if (SecurityUtils.getUser().getUserId() != null) {
String title = "同步人员通行数据成功";
String msg = title + ",同步时间段startTime" + startTime + "endTime" + endTime;
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), msg, title, "2");
}
});
return Result.ok("已在后台同步人员数据,请耐心等待!");
}
@ -514,11 +509,6 @@ public class HikvisionCall {
} while (total > 0 && listJa.size() > 0);
}
log.info("服务挂了主动获取车辆事件的车辆通行记录执行完成startTime{}endTime{}", startTime, endTime);
if (SecurityUtils.getUser().getUserId() != null) {
String title = "同步车辆通行数据成功";
String msg = title + ",同步时间段startTime" + startTime + "endTime" + endTime;
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), msg, title, "2");
}
});
return Result.ok("已在后台同步车辆通行数据,请耐心等待!");
}

View File

@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhgd.mqtt.bean.PushPayload;
import com.zhgd.mqtt.server.IMqttSender;
import com.zhgd.xmgl.modules.basicdata.entity.Notice;
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
@ -26,11 +25,10 @@ import java.util.Map;
/**
* @Description: 消息通知
* @author pds
* @date 2020-12-24
* @date 2020-12-24
* @version V1.0
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> implements INoticeService {
@Autowired
private NoticeMapper noticeMapper;
@ -47,38 +45,27 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
int pageNo = Integer.parseInt(map.getOrDefault("pageNo", 1).toString());
int pageSize = Integer.parseInt(map.getOrDefault("pageSize", 10).toString());
Page<Notice> page = new Page<>(pageNo, pageSize);
List<Notice> list=noticeMapper.selectNoticePageList(page, map);
List<Notice> list = noticeMapper.selectNoticePageList(page, map);
return page.setRecords(list);
}
@Override
public void addNotice(Notice notice, boolean sendNotice) {
noticeMapper.insert(notice);
if(sendNotice){
/*try {
PushPayload pushMessage = PushPayload.getPushPayloadBuider().setAccountId(notice.getAccountId().toString())
.setTitle(notice.getTitle())
.setContent(notice.getMsg())
.setType(notice.getType())
.bulid();
String kdTopic = scope+notice.getAccountId();
mqttPushClient.sendToMqtt(kdTopic, pushMessage.toString());
}catch (Exception e){
log.error("error",e);
}*/
if (sendNotice) {
sendPushMessage(notice);
}
}
@Override
public void cleanAllNotice(Map<String, Object> map) {
QueryWrapper<Notice> queryWrapper=new QueryWrapper<>();
queryWrapper.lambda().eq(Notice::getAccountId, MapUtils.getString(map,"userId"));
QueryWrapper<Notice> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(Notice::getAccountId, MapUtils.getString(map, "userId"));
noticeMapper.delete(queryWrapper);
}
@Override
public void addUserNotice(Long accountId, String msg, String title,String type) {
public void addUserNotice(Long accountId, String msg, String title, String type) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Notice notice = new Notice();
notice.setAccountId(accountId);
@ -93,25 +80,26 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
@Override
public void sendProjectNoicte(String projectSn, String title, String msg, String type) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<SystemUser> systemUserList=systemUserMapper.selectProjectSystemUserList(projectSn);
List<SystemUser> systemUserList = systemUserMapper.selectProjectSystemUserList(projectSn);
//向项目管理员和子账号推送通知
if(systemUserList.size()>0){
for (SystemUser systemUser:systemUserList){
addProjectNotice(systemUser.getUserId(),msg,title,sdf.format(new Date()),type);
if (systemUserList.size() > 0) {
for (SystemUser systemUser : systemUserList) {
addProjectNotice(systemUser.getUserId(), msg, title, sdf.format(new Date()), type);
}
}
}
private void addProjectNotice(Long accountId,String msg,String title,String time,String type){
private void addProjectNotice(Long accountId, String msg, String title, String time, String type) {
Notice notice = new Notice();
notice.setAccountId(accountId);
notice.setMsg(msg);
notice.setTitle(title);
notice.setSendTime(time);
notice.setType(type);
addNotice(notice,true);
addNotice(notice, true);
}
private void sendPushMessage(Notice notice){
private void sendPushMessage(Notice notice) {
try {
PushPayload pushMessage = PushPayload.getPushPayloadBuider().setAccountId(notice.getAccountId().toString())
.setTitle(notice.getTitle())
@ -119,10 +107,10 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
.setType(notice.getType())
.setItemType("0")
.bulid();
String kdTopic = scope+notice.getAccountId();
String kdTopic = scope + notice.getAccountId();
mqttPushClient.sendToMqtt(kdTopic, pushMessage.toString());
}catch (Exception e){
log.error("error", e);
} catch (Exception e) {
log.error("推送mq出现错误", e);
}
}
}