diff --git a/ruoyi-admin/src/main/java/com/ruoyi/pt/service/impl/AEventsServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/pt/service/impl/AEventsServiceImpl.java index 4324c20..38e3afe 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/pt/service/impl/AEventsServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/pt/service/impl/AEventsServiceImpl.java @@ -3,21 +3,36 @@ package com.ruoyi.pt.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; +import cn.hutool.http.HttpRequest; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.pt.entity.CasesImport; import com.ruoyi.pt.entity.Events; import com.ruoyi.pt.entity.dto.AEventChangeIsReport; import com.ruoyi.pt.entity.dto.AMassEventsRequest; +import com.ruoyi.pt.entity.dto.RemoteCallsDTO; import com.ruoyi.pt.entity.response.ANew100PageResponse; import com.ruoyi.pt.entity.response.FiveEventCountResponse; import com.ruoyi.pt.mapper.AEventsMapper; import com.ruoyi.pt.service.AEventsService; +import com.ruoyi.pt.service.CasesImportService; +import com.ruoyi.pt.service.RemoteCallsService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.*; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * 群体事件业务处理层 @@ -27,11 +42,23 @@ import java.util.*; */ @Service public class AEventsServiceImpl implements AEventsService { + + public static final Logger log = LoggerFactory.getLogger(AEventsServiceImpl.class); + @Resource private RedisCache redisCache; + @Resource private AEventsMapper aEventsMapper; + @Resource + private CasesImportService casesImportService; + + @Resource + private RemoteCallsService remoteCallsService; + + @Value("${remote.url}") + private String url; /** * 分页条件查询事件表 @@ -82,15 +109,13 @@ public class AEventsServiceImpl implements AEventsService { /** * 事件提级或退回 - * - * @return */ @Override @Transactional(rollbackFor = Exception.class) public void eventChangeIsReport(AEventChangeIsReport events) { events.setAuditTime(DateUtil.date()); //如果工单编号数组不为0,则将其所有工单进行标记 - if(events.getCaseSerial() != null && !events.getCaseSerial().isEmpty()){ + if (events.getCaseSerial() != null && !events.getCaseSerial().isEmpty()) { aEventsMapper.updateCasesImport(events.getCaseSerial(), DateUtil.now()); } aEventsMapper.updateEvent(events); @@ -112,6 +137,53 @@ public class AEventsServiceImpl implements AEventsService { String substring = a1.getInnerEventId().substring(0, 6); a1.setInnerEventId(substring + IdUtil.randomUUID()); aEventsMapper.addAudit(a1); + // 重新上报驾驶舱 + RemoteCallsDTO dto = BeanUtil.copyProperties(a1, RemoteCallsDTO.class); + dto.setContent(dto.getTitle()); + // 创建SimpleDateFormat对象,指定日期格式为yyyy-MM-dd HH:mm:ss + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + // 使用SimpleDateFormat对象将Date对象格式化为字符串 + String firstWarnTime = sdf.format(dto.getFirstWarnTimeDate()); + String eventTime = sdf.format(dto.getEventTimeDate()); + dto.setFirstWarnTime(firstWarnTime); + dto.setEventTime(firstWarnTime); + dto.setLastWarnTime(eventTime); + // 获取relationNums转成数组 + JSONArray jsonArray = JSONUtil.parseArray(dto.getRelationNums()); + List list = jsonArray.toList(String.class); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("CASE_SERIAL", list.get(0)); + CasesImport casesImport = casesImportService.getOne(wrapper); + if (BeanUtil.isNotEmpty(casesImport)) { + // 如果是紧急事件content使用原始工单的content + if ("3".equals(dto.getScenceType())) { + dto.setContent(casesImport.getCaseContent()); + } else { + dto.setContent(dto.getTitle()); + } + // 如果类型是同人事件,上报⼈姓名和电话不取原始工单,直接从预警因素字段取,顿号分隔。 + if ("2".equals(dto.getScenceType())) { + String warnFactor = dto.getWarnFactor(); + String[] split = warnFactor.split("、"); + if (split.length == 2) { + dto.setEventCreatorTel(split[0]); + dto.setEventCreator(split[1]); + } else { + dto.setEventCreatorTel(split[0]); + } + } else { + dto.setEventCreator(casesImport.getCreatorName()); + dto.setEventCreatorTel(casesImport.getCreatorTel()); + } + dto.setEventPlaceName(casesImport.getCaseAddress()); + dto.setEventCoordinate(casesImport.getCaseLnglat()); + String accessToken = remoteCallsService.getAccessToken(); + String jsonStr = JSONUtil.toJsonStr(dto); + HttpRequest.post(url + "/gateway/event/event/eventData/imports") + .header("Authorization", "Bearer " + accessToken) + .body(jsonStr).execute().body(); + log.info("==========重新推送驾驶舱完成========="); + } } } @@ -138,7 +210,7 @@ public class AEventsServiceImpl implements AEventsService { new100PageList.forEach(y -> { String s = msg.get(y.getCaseSerial()); page.getRecords().forEach(x -> { - if (s!=null&&s.equals(x.getInnerEventId())) { + if (s != null && s.equals(x.getInnerEventId())) { y.setNums(x.getNums()); y.setMsgType(x.getMsgType()); y.setInnerEventId(x.getInnerEventId()); @@ -201,9 +273,9 @@ public class AEventsServiceImpl implements AEventsService { */ @Override public Object getErrorMsg() { - if(redisCache.hasKey("isNo")){ + if (redisCache.hasKey("isNo")) { return redisCache.getCacheObject("isNo"); - }else { + } else { return null; } }