Browse Source

感知事件转交通修改,发布渠道整理

develop
wangsixiang 7 months ago
parent
commit
56bbe92a51
  1. 32
      zc-business/src/main/java/com/zc/business/controller/WeiboAuthUtil.java
  2. 36
      zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java
  3. 7
      zc-business/src/main/resources/mapper/business/DcPublishingChannelsMapper.xml

32
zc-business/src/main/java/com/zc/business/controller/WeiboAuthUtil.java

@ -10,6 +10,14 @@ import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
@ -31,6 +39,7 @@ public class WeiboAuthUtil {
e.printStackTrace();
}
}
private static void postWeibo(String status) throws Exception {
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(WEIBO_API_URL);
@ -57,5 +66,28 @@ public class WeiboAuthUtil {
// 关闭HttpClient连接
httpClient.close();
}
//测试调用其它的api是否可以使用,这里调用的是(通过地址编码获取地址名称)
//public static void main(String[] args) {
// String apiUrl = "https://api.weibo.com/2/statuses/mentions.json";
// String accessToken = "2.00oesadIn1MNEC0296dd00f87jmhaC"; // 请替换为你的微博访问令牌
// String url = "https://api.weibo.com/2/common/code_to_location.json" + "?access_token=" + accessToken + "&codes=" + "100";
// com.alibaba.fastjson.JSONObject jsonObj = null;
// try {
// URL urlGet = new URL(url);
// HttpURLConnection http = (HttpURLConnection) urlGet.openConnection();
// http.setRequestMethod("GET"); // 必须是get方式请求
// http.setDoInput(true);
// http.connect();
// InputStream is = http.getInputStream();
// int size = is.available();
// byte[] jsonBytes = new byte[size];
// is.read(jsonBytes);
// String userOpenid = new String(jsonBytes, "UTF-8");
// System.out.println(userOpenid);
// is.close();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
}

36
zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java

@ -445,12 +445,14 @@ public class DcWarningServiceImpl implements IDcWarningService
{
return dcWarningMapper.deleteDcWarningById(id);
}
//感知事件转交通事件(感知事件状态改为处置中把感知事件的数据整理新增到交通事件)
//感知事件转交通事件(感知事件状态改为处置中,把感知事件的数据整理新增到交通事件)
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult updateWarningConvert(DcWarning dcWarning) {
if (dcWarning==null||dcWarning.getId()==null|| StringUtils.isBlank(dcWarning.getStakeMark())||
StringUtils.isBlank(dcWarning.getDirection())){
if (dcWarning==null||dcWarning.getId()==null|| dcWarning.getStakeMark()==null||
StringUtils.isBlank(dcWarning.getStakeMark())||dcWarning.getDirection()==null||
StringUtils.isBlank(dcWarning.getDirection()) ||
dcWarning.getWarningType()==null|| dcWarning.getWarningSource()==null){
return AjaxResult.error("参数错误");
}
ArrayList<HashMap<String,Object>> hashMaps = new ArrayList<>();
@ -475,23 +477,28 @@ public class DcWarningServiceImpl implements IDcWarningService
if (dcWarning.getWarningType()!=null) {
dcEvent.setEventType((long) ValueConverter.convertValueHost(dcWarning.getWarningType()));//事件主类
}
if (StringUtils.isBlank(dcWarning.getWarningSubclass())&&dcWarning.getWarningType()!=7&&
if (dcWarning.getWarningSubclass()!=null&&StringUtils.isBlank(dcWarning.getWarningSubclass())&&dcWarning.getWarningType()!=7&&
dcWarning.getWarningType()!=10) {
dcEvent.setEventSubclass(ValueConverter.convertValueSon(dcWarning.getWarningSubclass()));//事件子类(7与10不转)
}
if (StringUtils.isBlank(dcWarning.getWarningSubclass())&&(dcWarning.getWarningType()==7||
if (dcWarning.getWarningSubclass()!=null&&StringUtils.isBlank(dcWarning.getWarningSubclass())&&(dcWarning.getWarningType()==7||
dcWarning.getWarningType()==10)){
dcEvent.setEventSubclass(dcWarning.getWarningSubclass());//事件子类(7与10主类对应的子类直接set)
}
dcEvent.setOccurrenceTime(dcWarning.getWarningTime());//发生时间
dcEvent.setStartTime(DateUtils.getNowDate());//开始时间
dcEvent.setEstimatedEndTime(DateUtils.getObtainDateAfter(180));//预计结束时间,开始时间+3小时
dcEvent.setEventTitle(dcWarning.getWarningTitle());//标题
dcEvent.setLang(dcWarning.getLane());//车道
dcEvent.setRemark(dcEvent.getRemark());//备注
dcEvent.setRemark(dcWarning.getRemark());//备注
dcEvent.setIsPerceived(1);//是否感知事件
dcEvent.setEventState(Long.valueOf(1));//状态为处理中
dcEvent.setCreateTime(DateUtils.getNowDate());//创建时间
dcEvent.setUserId(SecurityUtils.getUserId());//处置人员
int insertDcEvent = dcEventService.insertDcEventWarning(dcEvent);
if (insertDcEvent==0){
return AjaxResult.error("操作失败");
}
List<HashMap<String, Object>> mapList = dcWarningMapper.selectRecentlySection();//全部机构的桩号和名称
for (HashMap<String,Object> map:mapList){
if (StringUtils.isBlank(map.get("stakeMark").toString())){
@ -518,10 +525,13 @@ public class DcWarningServiceImpl implements IDcWarningService
DcDispatchResource dcDispatchResource = new DcDispatchResource();
dcDispatch.setDeptId(SecurityUtils.getLoginUser().getDeptId());
dcDispatch.setEventId(dcWarning.getId());
dcDispatch.setStartTime(DateUtils.getNowDate());
dcDispatch.setDispatchStatus(2L);//进行中状态
dcDispatch.setRemark(dcWarning.getRemark());
dcWarningMapper.insertDcDispatch(dcDispatch);//事件绑定信息记录
Long dispatchId = dcDispatch.getId();//信息记录id
List<HashMap<String, Object>> employeesMap = dcWarningMapper.selectOrganizationEmployees(dispatchId);//人员map
if (employeesMap != null) {
List<HashMap<String, Object>> employeesMap = dcWarningMapper.selectOrganizationEmployees(id);//人员map
if (employeesMap != null&&employeesMap.size()>0) {
// 生成一个随机索引,范围在0到列表长度减1之间
int randomIndex = ThreadLocalRandom.current().nextInt(employeesMap.size());
HashMap<String, Object> randomEmployee = employeesMap.get(randomIndex);
@ -531,8 +541,8 @@ public class DcWarningServiceImpl implements IDcWarningService
dcDispatchResource.setDispatchId(dispatchId);//信息记录id
dcWarningMapper.insertDispatchResource(dcDispatchResource);
}
List<HashMap<String, Object>> vehiclesMap = dcWarningMapper.selectVehicles(dispatchId);//车辆map
if (vehiclesMap != null) {
List<HashMap<String, Object>> vehiclesMap = dcWarningMapper.selectVehicles(id);//车辆map
if (vehiclesMap != null&&vehiclesMap.size()>0) {
// 生成一个随机索引,范围在0到列表长度减1之间
int randomIndex = ThreadLocalRandom.current().nextInt(vehiclesMap.size());
HashMap<String, Object> randomEmployee = employeesMap.get(randomIndex);
@ -544,10 +554,6 @@ public class DcWarningServiceImpl implements IDcWarningService
}
}
}
if (insertDcEvent==0){
return AjaxResult.error("操作失败");
}
//事件处置流程记录
DcEventProcess dcEventProcess = new DcEventProcess();
dcEventProcess.setEventId(dcEvent.getId());

7
zc-business/src/main/resources/mapper/business/DcPublishingChannelsMapper.xml

@ -17,12 +17,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectDcPublishingChannelsVo">
select id, data_category, info_level, enabled, audit_method, publish_channels, enable_date, create_time, update_time from dc_publishing_channels
select id, data_category, info_level, enabled,
audit_method, publish_channels,
enable_date, create_time, update_time from dc_publishing_channels
</sql>
<select id="selectDcPublishingChannelsList" parameterType="DcPublishingChannels" resultMap="DcPublishingChannelsResult">
<include refid="selectDcPublishingChannelsVo"/>
<where>
<where>
<if test="enableDate != null "> and enable_date = #{enableDate}</if>
<if test="dataCategory != null "> and data_category = #{dataCategory}</if>
<if test="infoLevel != null "> and info_level = #{infoLevel}</if>
<if test="enabled != null "> and enabled = #{enabled}</if>

Loading…
Cancel
Save