Browse Source

Merge branch 'develop' of http://39.106.31.193:9211/mengff/jihe-dc into develop

# Conflicts:
#	zc-business/src/main/java/com/zc/business/mapper/DcGantryStatisticsDataMapper.java
#	zc-business/src/main/java/com/zc/business/service/IDcTrafficStatisticsService.java
#	zc-business/src/main/java/com/zc/business/service/impl/DcGantryStatisticsDataImpl.java
#	zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java
develop
xiepufeng 6 months ago
parent
commit
cf5ab21642
  1. 17
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
  2. 7
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java
  3. 11
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysMenu.java
  4. 5
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysMenuMapper.java
  5. 3
      ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java
  6. 19
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java
  7. 26
      ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml
  8. 4
      ruoyi-ui/src/api/menu.js
  9. 4
      ruoyi-ui/src/api/system/menu.js
  10. 2
      ruoyi-ui/src/store/modules/permission.js
  11. 2
      ruoyi-ui/src/utils/auth.js
  12. 4
      ruoyi-ui/src/views/index.vue
  13. 18
      ruoyi-ui/src/views/system/menu/index.vue
  14. 3
      ruoyi-ui/src/views/websocket.vue
  15. 130
      zc-business/src/main/java/com/zc/business/controller/DcTrafficPoliceController.java
  16. 60
      zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java
  17. 100
      zc-business/src/main/java/com/zc/business/controller/WordController.java
  18. 2
      zc-business/src/main/java/com/zc/business/domain/DcRegion.java
  19. 101
      zc-business/src/main/java/com/zc/business/domain/DcTrafficPolice.java
  20. 52
      zc-business/src/main/java/com/zc/business/domain/MdEvent.java
  21. 52
      zc-business/src/main/java/com/zc/business/enums/StakeMarkRange.java
  22. 65
      zc-business/src/main/java/com/zc/business/enums/ValueConverter.java
  23. 17
      zc-business/src/main/java/com/zc/business/mapper/DcGantryStatisticsDataMapper.java
  24. 3
      zc-business/src/main/java/com/zc/business/mapper/DcStakeMarkMapper.java
  25. 64
      zc-business/src/main/java/com/zc/business/mapper/DcTrafficPoliceMapper.java
  26. 1
      zc-business/src/main/java/com/zc/business/service/IDcFacilityService.java
  27. 6
      zc-business/src/main/java/com/zc/business/service/IDcGantryStatisticsDataService.java
  28. 64
      zc-business/src/main/java/com/zc/business/service/IDcTrafficPoliceService.java
  29. 16
      zc-business/src/main/java/com/zc/business/service/IDcTrafficStatisticsService.java
  30. 51
      zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java
  31. 13
      zc-business/src/main/java/com/zc/business/service/impl/DcFacilityServiceImpl.java
  32. 9
      zc-business/src/main/java/com/zc/business/service/impl/DcGantryStatisticsDataImpl.java
  33. 104
      zc-business/src/main/java/com/zc/business/service/impl/DcTrafficPoliceServiceImpl.java
  34. 328
      zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java
  35. 8
      zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java
  36. 7
      zc-business/src/main/resources/mapper/business/DcEventConstructionMapper.xml
  37. 49
      zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml
  38. 4
      zc-business/src/main/resources/mapper/business/DcStakeMarkMapper.xml
  39. 8
      zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml
  40. 84
      zc-business/src/main/resources/mapper/business/DcTrafficPoliceMapper.xml
  41. 10
      zc-business/src/main/resources/mapper/business/MiddleDatabaseMapper.xml

17
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java

@ -1,24 +1,23 @@
package com.ruoyi.web.controller.system;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysMenu;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginBody;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.web.service.SysLoginService;
import com.ruoyi.framework.web.service.SysPermissionService;
import com.ruoyi.system.service.ISysMenuService;
import com.zc.websocket.WebSocketConfigParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Set;
import java.util.*;
/**
* 登录验证
@ -97,11 +96,11 @@ public class SysLoginController
*
* @return 路由信息
*/
@GetMapping("getRouters")
public AjaxResult getRouters()
@GetMapping("getRouters/{distinguish}")
public AjaxResult getRouters(@PathVariable Long distinguish)
{
Long userId = SecurityUtils.getUserId();
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId,distinguish);
return AjaxResult.success(menuService.buildMenus(menus));
}
}

7
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java

@ -67,10 +67,11 @@ public class SysMenuController extends BaseController
/**
* 加载对应角色菜单列表树
*/
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
@GetMapping(value = "/roleMenuTreeselect/{roleId}/{distinguish}")
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId,@PathVariable("distinguish") Long distinguish)
{
List<SysMenu> menus = menuService.selectMenuList(getUserId());
// List<SysMenu> menus = menuService.selectMenuList(getUserId());
List<SysMenu> menus = menuService.selectMenuListDistinguish(getUserId(),distinguish);
AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
ajax.put("menus", menuService.buildMenuTreeSelect(menus));

11
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysMenu.java

@ -66,6 +66,17 @@ public class SysMenu extends BaseEntity
/** 子菜单 */
private List<SysMenu> children = new ArrayList<SysMenu>();
/** 菜单区分标识*/
private Long distinguish;
public Long getDistinguish() {
return distinguish;
}
public void setDistinguish(Long distinguish) {
this.distinguish = distinguish;
}
public Long getMenuId()
{
return menuId;

5
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysMenuMapper.java

@ -47,6 +47,7 @@ public interface SysMenuMapper
* @return 菜单列表
*/
public List<SysMenu> selectMenuTreeAll();
public List<SysMenu> selectMenuTreeDistinguishAll(Long distinguish);
/**
* 根据用户ID查询菜单
@ -54,7 +55,7 @@ public interface SysMenuMapper
* @param userId 用户ID
* @return 菜单列表
*/
public List<SysMenu> selectMenuTreeByUserId(Long userId);
public List<SysMenu> selectMenuTreeByUserId(@Param("userId") Long userId,@Param("distinguish")Long distinguish);
/**
* 根据角色ID查询菜单树信息
@ -112,5 +113,5 @@ public interface SysMenuMapper
* @param parentId 父菜单ID
* @return 结果
*/
public SysMenu checkMenuNameUnique(@Param("menuName") String menuName, @Param("parentId") Long parentId);
public SysMenu checkMenuNameUnique(@Param("menuName") String menuName, @Param("parentId") Long parentId,@Param("distinguish") Long distinguish);
}

3
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java

@ -19,6 +19,7 @@ public interface ISysMenuService
* @return 菜单列表
*/
public List<SysMenu> selectMenuList(Long userId);
public List<SysMenu> selectMenuListDistinguish(Long userId,Long distinguish);
/**
* 根据用户查询系统菜单列表
@ -43,7 +44,7 @@ public interface ISysMenuService
* @param userId 用户ID
* @return 菜单列表
*/
public List<SysMenu> selectMenuTreeByUserId(Long userId);
public List<SysMenu> selectMenuTreeByUserId(Long userId,Long distinguish);
/**
* 根据角色ID查询菜单树信息

19
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java

@ -55,6 +55,13 @@ public class SysMenuServiceImpl implements ISysMenuService
{
return selectMenuList(new SysMenu(), userId);
}
@Override
public List<SysMenu> selectMenuListDistinguish(Long userId,Long distinguish)
{
SysMenu sysMenu = new SysMenu();
sysMenu.setDistinguish(distinguish);
return selectMenuList(sysMenu, userId);
}
/**
* 查询系统菜单列表
@ -69,6 +76,7 @@ public class SysMenuServiceImpl implements ISysMenuService
// 管理员显示所有菜单信息
if (SysUser.isAdmin(userId))
{
menu.setDistinguish(menu.getDistinguish());
menuList = menuMapper.selectMenuList(menu);
}
else
@ -107,16 +115,19 @@ public class SysMenuServiceImpl implements ISysMenuService
* @return 菜单列表
*/
@Override
public List<SysMenu> selectMenuTreeByUserId(Long userId)
public List<SysMenu> selectMenuTreeByUserId(Long userId,Long distinguish)
{
List<SysMenu> menus = null;
if (SecurityUtils.isAdmin(userId))
{
menus = menuMapper.selectMenuTreeAll();
// menus = menuMapper.selectMenuTreeAll();
menus = menuMapper.selectMenuTreeDistinguishAll(distinguish);
//menus = menuMapper.selectMenuTreeByUserId(userId,distinguish);
}
else
{
menus = menuMapper.selectMenuTreeByUserId(userId);
menus = menuMapper.selectMenuTreeByUserId(userId,distinguish);
}
return getChildPerms(menus, 0);
}
@ -321,7 +332,7 @@ public class SysMenuServiceImpl implements ISysMenuService
public String checkMenuNameUnique(SysMenu menu)
{
Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId();
SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId());
SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId(),menu.getDistinguish());
if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue())
{
return UserConstants.NOT_UNIQUE;

26
ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml

@ -25,10 +25,12 @@
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="remark" column="remark" />
<result property="remark" column="remark" />
<result property="distinguish" column="distinguish" />
</resultMap>
<sql id="selectMenuVo">
select menu_id, menu_name, parent_id, order_num, path, component, `query`, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time
select distinguish, menu_id, menu_name, parent_id, order_num, path, component, `query`, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time
from sys_menu
</sql>
@ -41,6 +43,9 @@
<if test="visible != null and visible != ''">
AND visible = #{visible}
</if>
<if test="distinguish != null and distinguish != ''">
AND distinguish=#{distinguish}
</if>
<if test="status != null and status != ''">
AND status = #{status}
</if>
@ -49,10 +54,15 @@
</select>
<select id="selectMenuTreeAll" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
select distinct m.distinguish, m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
from sys_menu m where m.menu_type in ('M', 'C') and m.status = 0
order by m.parent_id, m.order_num
</select>
<select id="selectMenuTreeDistinguishAll" resultMap="SysMenuResult">
select distinct m.distinguish, m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
from sys_menu m where m.menu_type in ('M', 'C') and m.status = 0 AND m.distinguish = #{distinguish}
order by m.parent_id, m.order_num
</select>
<select id="selectMenuListByUserId" parameterType="SysMenu" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
@ -69,18 +79,21 @@
</if>
<if test="status != null and status != ''">
AND m.status = #{status}
</if>
<if test="distinguish != null and distinguish != ''">
AND m.distinguish = #{distinguish}
</if>
order by m.parent_id, m.order_num
</select>
<select id="selectMenuTreeByUserId" parameterType="Long" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
select distinct m.distinguish,m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
from sys_menu m
left join sys_role_menu rm on m.menu_id = rm.menu_id
left join sys_user_role ur on rm.role_id = ur.role_id
left join sys_role ro on ur.role_id = ro.role_id
left join sys_user u on ur.user_id = u.user_id
where u.user_id = #{userId} and m.menu_type in ('M', 'C') and m.status = 0 AND ro.status = 0
where u.user_id = #{userId} and m.menu_type in ('M', 'C') and m.status = 0 AND ro.status = 0 and m.distinguish=#{distinguish}
order by m.parent_id, m.order_num
</select>
@ -122,7 +135,7 @@
<select id="checkMenuNameUnique" parameterType="SysMenu" resultMap="SysMenuResult">
<include refid="selectMenuVo"/>
where menu_name=#{menuName} and parent_id = #{parentId} limit 1
where menu_name=#{menuName} and parent_id = #{parentId} and distinguish=#{distinguish} limit 1
</select>
<update id="updateMenu" parameterType="SysMenu">
@ -143,6 +156,7 @@
<if test="icon !=null and icon != ''">icon = #{icon},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="distinguish != null and distinguish != ''">distinguish = #{distinguish},</if>
update_time = sysdate()
</set>
where menu_id = #{menuId}
@ -166,6 +180,7 @@
<if test="icon != null and icon != ''">icon,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="distinguish != null">distinguish,</if>
create_time
)values(
<if test="menuId != null and menuId != 0">#{menuId},</if>
@ -184,6 +199,7 @@
<if test="icon != null and icon != ''">#{icon},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="distinguish != null ">#{distinguish},</if>
sysdate()
)
</insert>

4
ruoyi-ui/src/api/menu.js

@ -3,7 +3,7 @@ import request from '@/utils/request'
// 获取路由
export const getRouters = () => {
return request({
url: '/getRouters',
url: '/getRouters/'+0,
method: 'get'
})
}
}

4
ruoyi-ui/src/api/system/menu.js

@ -28,7 +28,7 @@ export function treeselect() {
// 根据角色ID查询菜单下拉树结构
export function roleMenuTreeselect(roleId) {
return request({
url: '/system/menu/roleMenuTreeselect/' + roleId,
url: '/system/menu/roleMenuTreeselect/' + roleId+'/1',
method: 'get'
})
}
@ -57,4 +57,4 @@ export function delMenu(menuId) {
url: '/system/menu/' + menuId,
method: 'delete'
})
}
}

2
ruoyi-ui/src/store/modules/permission.js

@ -38,7 +38,7 @@ const permission = {
GenerateRoutes({ commit }) {
return new Promise(resolve => {
// 向后端请求路由数据
getRouters().then(res => {
getRouters(1).then(res => {
const sdata = JSON.parse(JSON.stringify(res.data))
const rdata = JSON.parse(JSON.stringify(res.data))
const sidebarRoutes = filterAsyncRouter(sdata)

2
ruoyi-ui/src/utils/auth.js

@ -1,6 +1,6 @@
import Cookies from 'js-cookie'
const TokenKey = 'DC-Token'
const TokenKey = 'DC-Pro-Token'
export function getToken() {
return Cookies.get(TokenKey)

4
ruoyi-ui/src/views/index.vue

@ -701,7 +701,7 @@ export default {
/************************************ 设备消息 **************************************/
/** 时间按钮选项 */
timeDimensionChange() {
if (this.messageMonitorTimeDimension === 'day') {
/*if (this.messageMonitorTimeDimension === 'day') {
this.messageMonitorTimePick = this.getTodayTime()
const params = {
time: '1h',
@ -763,7 +763,7 @@ export default {
this.getMessageMonitorData(params, 'received_message')
this.getMessageMonitorData(params, 'sent_message')
}
}*/
},
/** 设备消息char初始化 */

18
ruoyi-ui/src/views/system/menu/index.vue

@ -65,6 +65,7 @@
<el-table-column prop="orderNum" label="排序" width="60"></el-table-column>
<el-table-column prop="perms" label="权限标识" :show-overflow-tooltip="true"></el-table-column>
<el-table-column prop="component" label="组件路径" :show-overflow-tooltip="true"></el-table-column>
<el-table-column prop="status" label="状态" width="80">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
@ -77,7 +78,7 @@
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@ -170,6 +171,18 @@
<el-radio label="0"></el-radio>
<el-radio label="1"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="是否dc" prop="distinguish">
<span slot="label">
是否dc后端
</span>
<el-radio-group v-model="form.distinguish">
<el-radio :label=0></el-radio>
<el-radio :label=1></el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12" v-if="form.menuType != 'F'">
@ -376,7 +389,8 @@ export default {
isFrame: "1",
isCache: "0",
visible: "0",
status: "0"
status: "0",
distinguish:0,
};
this.resetForm("form");
},

3
ruoyi-ui/src/views/websocket.vue

@ -19,7 +19,8 @@ export default {
websocket({ password, path, port, interval}) {
// websocket
this.socket.initialize({
url: 'ws://' + location.hostname + ':' + port + path,
// url: 'ws://' + location.hostname + ':' + port + path,
url: 'wss://' + location.hostname + ':' + window.location.port + '/ws' || 80 + '/ws',
password: password,
tokenSN: this.token,
heartRate: interval

130
zc-business/src/main/java/com/zc/business/controller/DcTrafficPoliceController.java

@ -0,0 +1,130 @@
package com.zc.business.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.zc.business.domain.DcTrafficPolice;
import com.zc.business.service.IDcTrafficPoliceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 交管数据Controller
*
* @author ruoyi
* @date 2024-06-06
*/
@Api(tags = "交警信息管理")
@RestController
@RequestMapping("/system/police")
public class DcTrafficPoliceController extends BaseController
{
@Autowired
private IDcTrafficPoliceService dcTrafficPoliceService;
/**
* 查询交管数据列表
*/
@ApiOperation("查询交警列表")
// @PreAuthorize("@ss.hasPermi('system:police:list')")
@GetMapping("/list")
public TableDataInfo list(DcTrafficPolice dcTrafficPolice)
{
startPage();
List<DcTrafficPolice> list = dcTrafficPoliceService.selectDcTrafficPoliceList(dcTrafficPolice);
return getDataTable(list);
}
/**
* 导出交管数据列表
*/
@ApiOperation("导出交管数据列表")
// @PreAuthorize("@ss.hasPermi('system:police:export')")
@Log(title = "交管数据", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DcTrafficPolice dcTrafficPolice)
{
List<DcTrafficPolice> list = dcTrafficPoliceService.selectDcTrafficPoliceList(dcTrafficPolice);
ExcelUtil<DcTrafficPolice> util = new ExcelUtil<>(DcTrafficPolice.class);
util.exportExcel(response, list, "交管数据数据");
}
/**
* 获取交管数据详细信息
*/
@ApiOperation("获取交管数据详细信息")
//@PreAuthorize("@ss.hasPermi('system:police:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(dcTrafficPoliceService.selectDcTrafficPoliceById(id));
} /**
* 获取事件所属交管信息
*/
@ApiOperation("获取事件所属交管信息")
@GetMapping("/enent/{make}")
public AjaxResult getInfoEvent(@PathVariable("make") String make)
{
return AjaxResult.success(dcTrafficPoliceService.selectEvent(make));
}
/**
* 新增交管数据
*/
@ApiOperation("新增交管数据")
// @PreAuthorize("@ss.hasPermi('system:police:add')")
@Log(title = "交管数据", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DcTrafficPolice dcTrafficPolice)
{
return toAjax(dcTrafficPoliceService.insertDcTrafficPolice(dcTrafficPolice));
}
/**
* 修改交管数据
*/
@ApiOperation("修改交管数据")
@PreAuthorize("@ss.hasPermi('system:police:edit')")
@Log(title = "交管数据", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DcTrafficPolice dcTrafficPolice)
{
return toAjax(dcTrafficPoliceService.updateDcTrafficPolice(dcTrafficPolice));
}
/**
* 删除交管数据
*/
@ApiOperation("删除交管数据")
// @PreAuthorize("@ss.hasPermi('system:police:remove')")
@Log(title = "交管数据", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(dcTrafficPoliceService.deleteDcTrafficPoliceByIds(ids));
}
}

60
zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java

@ -162,6 +162,20 @@ public class DcTrafficStatisticsController {
// 将查询结果封装为成功响应并返回
return AjaxResult.success(dcStatisticsData);
}
/**
* 全路段双向实时车流量
* @param startDate 时间
* @param direction 方向
* @param periodType 时间粒子
*/
@ApiOperation("全路段双向实时车流量")
@GetMapping("/history/realTimeTrafficFlow")
public AjaxResult realTimeTrafficFlow(String startDate, String direction,String periodType ){
List<Map<String,String>> mapList = dcGantryStatisticsDataService.realTimeTrafficFlow(startDate,direction,periodType);
// 将查询结果封装为成功响应并返回
return AjaxResult.success(mapList);
}
/**
* 获取门架指标统计数据
@ -243,6 +257,52 @@ public class DcTrafficStatisticsController {
// 将获取到的交通指标数据封装为成功的结果并返回
return AjaxResult.success(jsonArray);
}
/**
* 断面小时车流量分车型
*/
@ApiOperation("断面小时车流量分车型")
@GetMapping("/history/sectionHourlyTrafficFlow")
public AjaxResult sectionHourlyTrafficFlow(String startDate, String endDate) throws HttpException, IOException {
// 调用服务层方法,获取当前交通指标数据
JSONArray jsonArray = dcTrafficStatisticsService.sectionHourlyTrafficFlow(startDate, endDate);
// 将获取到的交通指标数据封装为成功的结果并返回
return AjaxResult.success(jsonArray);
}/**
* 各收费站入口分车型车流量
*/
@ApiOperation("各收费站入口分车型小时车流量")
@GetMapping("/history/trafficFlowAtTollStationEntranceHour")
public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String endDate,String stationType) throws HttpException, IOException {
// 调用服务层方法,获取当前交通指标数据
List<Map<String, String>> jsonArray = dcTrafficStatisticsService.trafficFlowAtTollStationEntrance(startDate, endDate, stationType);
// 将获取到的交通指标数据封装为成功的结果并返回
return AjaxResult.success(jsonArray);
}
/**
* 各收费站入口分车型小时车流量
*/
@ApiOperation("各收费站入口分车型车流量")
@GetMapping("/history/trafficFlowAtTollStationEntrance")
public AjaxResult trafficFlowAtTollStationEntrance(String startDate, String endDate,String stationType) throws HttpException, IOException {
// 调用服务层方法,获取当前交通指标数据
JSONArray jsonArray = dcTrafficStatisticsService.trafficFlowAtTollStationEntranceHour(startDate, endDate, stationType);
// 将获取到的交通指标数据封装为成功的结果并返回
return AjaxResult.success(jsonArray);
}
/**
* 全路段双向实时车流量
* @param startDate 时间
* @param direction 方向
*/
@ApiOperation("全路段双向实时车流量")
@GetMapping("/history/realTimeTrafficFlowHour")
public AjaxResult realTimeTrafficFlowHour(String startDate,Long direction) throws HttpException, IOException{
List<Map<String,Object>> mapList = dcTrafficStatisticsService.realTimeTrafficFlowHour(startDate,direction);
// 将查询结果封装为成功响应并返回
return AjaxResult.success(mapList);
}
}

100
zc-business/src/main/java/com/zc/business/controller/WordController.java

@ -2,6 +2,7 @@ package com.zc.business.controller;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.domain.AjaxResult;
import com.zc.business.domain.DcTrafficSectionData;
import com.zc.business.mapper.DcTrafficIncidentsMapper;
import com.zc.business.utils.PoiUtil;
import io.swagger.annotations.Api;
@ -19,9 +20,12 @@ import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
import static com.zc.business.utils.PoiUtil.*;
@ -128,68 +132,102 @@ public class WordController {
PoiUtil.createHeading2(doc,"天气情况统计");
AjaxResult ajaxResult = weatherForecastController.hourlyWeather();
// AjaxResult ajaxResult = weatherForecastController.hourlyWeather();
HashMap<String,Object> params = new HashMap<>();
params.put("roadId","G003537");
params.put("stakeNum","K60+000|K105+000|K145+000|K165+000|K175+000|K190+000|K200+000|K205+000");
params.put("forecastHour","24");
AjaxResult ajaxResult = weatherForecastController.currentWeatherAndForecastInformation(params);
if (ajaxResult.get("code").equals(200)) {
Map<String,List<Map<String,Object>>> data = (Map<String, List<Map<String,Object>>>) ajaxResult.get("data");
List<Map<String,Object>> data = (List<Map<String,Object>>) ajaxResult.get("data");
if (data != null && data.size() != 0){
XWPFTable table = doc.createTable(9, 25);
XWPFTable table = doc.createTable(9, 10);
//列宽自动分割
CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW();
infoTableWidth.setType(STTblWidth.DXA);
infoTableWidth.setW(BigInteger.valueOf(9072));
data.keySet().forEach(key ->{
if ("hourlyWeather1".equals(key)){
DateTimeFormatter parseFormatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
data.forEach(dataItem ->{
if ("K60+000".equals(dataItem.get("stakeNum"))){
setTableFonts(table.getRow(1).getCell(0), "长清区");
List<Map<String,Object>> weatherList = data.get(key);
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = 0; i < weatherList.size(); i++) {
OffsetDateTime offsetDateTime = OffsetDateTime.parse(weatherList.get(i).get("fxTime").toString());
setTableFonts(table.getRow(0).getCell(i+1),offsetDateTime.format(DateTimeFormatter.ofPattern("dd日HH时")));
setTableFonts(table.getRow(1).getCell(i+1), weatherList.get(i).get("text").toString());
//第一行 格式化时间
LocalDateTime localDateTime = LocalDateTime.parse(weatherList.get(i).get("weatherTime").toString(), parseFormatter);
DateTimeFormatter formatFormatter = DateTimeFormatter.ofPattern("dd日HH时");
setTableFonts(table.getRow(0).getCell(i+1),localDateTime.format(formatFormatter));
setTableFonts(table.getRow(1).getCell(i+1), weatherList.get(i).get("weatherDescription").toString());
}
} else if ("hourlyWeather2".equals(key)){
} else if ("K105+000".equals(dataItem.get("stakeNum"))){
setTableFonts(table.getRow(2).getCell(0), "平阴县");
List<Map<String,Object>> weatherList = data.get(key);
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(2).getCell(i+1), weatherList.get(i).get("text").toString());
setTableFonts(table.getRow(2).getCell(i+1), weatherList.get(i).get("weatherDescription").toString());
}
} else if ("hourlyWeather3".equals(key)){
} else if ("K145+000".equals(dataItem.get("stakeNum"))){
setTableFonts(table.getRow(3).getCell(0), "东平县");
List<Map<String,Object>> weatherList = data.get(key);
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(3).getCell(i+1), weatherList.get(i).get("text").toString());
setTableFonts(table.getRow(3).getCell(i+1), weatherList.get(i).get("weatherDescription").toString());
}
} else if ("hourlyWeather4".equals(key)){
} else if ("K165+000".equals(dataItem.get("stakeNum"))){
setTableFonts(table.getRow(4).getCell(0), "汶上县");
List<Map<String,Object>> weatherList = data.get(key);
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(4).getCell(i+1), weatherList.get(i).get("text").toString());
setTableFonts(table.getRow(4).getCell(i+1), weatherList.get(i).get("weatherDescription").toString());
}
} else if ("hourlyWeather5".equals(key)){
} else if ("K175+000".equals(dataItem.get("stakeNum"))){
setTableFonts(table.getRow(5).getCell(0), "梁山县");
List<Map<String,Object>> weatherList = data.get(key);
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(5).getCell(i+1), weatherList.get(i).get("text").toString());
setTableFonts(table.getRow(5).getCell(i+1), weatherList.get(i).get("weatherDescription").toString());
}
} else if ("hourlyWeather6".equals(key)){
} else if ("K190+000".equals(dataItem.get("stakeNum"))){
setTableFonts(table.getRow(6).getCell(0), "嘉祥县");
List<Map<String,Object>> weatherList = data.get(key);
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(6).getCell(i+1), weatherList.get(i).get("text").toString());
setTableFonts(table.getRow(6).getCell(i+1), weatherList.get(i).get("weatherDescription").toString());
}
} else if ("hourlyWeather7".equals(key)){
} else if ("K200+000".equals(dataItem.get("stakeNum"))){
setTableFonts(table.getRow(7).getCell(0), "巨野县");
List<Map<String,Object>> weatherList = data.get(key);
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(7).getCell(i+1), weatherList.get(i).get("text").toString());
setTableFonts(table.getRow(7).getCell(i+1), weatherList.get(i).get("weatherDescription").toString());
}
} else if ("hourlyWeather8".equals(key)){
} else if ("K205+000".equals(dataItem.get("stakeNum"))){
setTableFonts(table.getRow(8).getCell(0), "郓城县");
List<Map<String,Object>> weatherList = data.get(key);
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(8).getCell(i+1), weatherList.get(i).get("text").toString());
setTableFonts(table.getRow(8).getCell(i+1), weatherList.get(i).get("weatherDescription").toString());
}
}
});
@ -197,6 +235,8 @@ public class WordController {
addDescription(doc,"暂无数据");
}
} else {
addDescription(doc,"暂无数据");
}
//换行

2
zc-business/src/main/java/com/zc/business/domain/DcRegion.java

@ -18,4 +18,6 @@ public class DcRegion {
private String longitude;
@ApiModelProperty("纬度")
private String latitude;
@ApiModelProperty("桩号")
private String stakeNum;
}

101
zc-business/src/main/java/com/zc/business/domain/DcTrafficPolice.java

@ -0,0 +1,101 @@
package com.zc.business.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 交管数据对象 dc_traffic_police
*
* @author ruoyi
* @date 2024-06-06
*/
@ApiModel("交警信息对象")
public class DcTrafficPolice extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
@ApiModelProperty("ID")
private Long id;
/** $column.columnComment */
@ApiModelProperty("名称")
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String name;
@ApiModelProperty("电话")
/** 电话 */
@Excel(name = "电话")
private String phone;
@ApiModelProperty("开始桩号")
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String stakeMake;
/** $column.columnComment */
@ApiModelProperty("结束桩号")
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String endMake;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setPhone(String phone)
{
this.phone = phone;
}
public String getPhone()
{
return phone;
}
public void setStakeMake(String stakeMake)
{
this.stakeMake = stakeMake;
}
public String getStakeMake()
{
return stakeMake;
}
public void setEndMake(String endMake)
{
this.endMake = endMake;
}
public String getEndMake()
{
return endMake;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("name", getName())
.append("phone", getPhone())
.append("stakeMake", getStakeMake())
.append("endMake", getEndMake())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.toString();
}
}

52
zc-business/src/main/java/com/zc/business/domain/MdEvent.java

@ -4,6 +4,7 @@ import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.utils.StringUtils;
import com.zc.business.enums.ValueConverter;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
@ -33,6 +34,10 @@ public class MdEvent
@Excel(name = "交通事件类型")
private String eventTypeCode;
/** 交通事件类型名称 */
@Excel(name = "交通事件类型名称")
private String eventTypeName;
/** 交通事件详情 */
@Excel(name = "交通事件详情")
private String eventDesc;
@ -99,6 +104,10 @@ public class MdEvent
@Excel(name = "交通事件类型子类")
private String eventTypeCode2;
/** 交通事件类型子类名称 */
@Excel(name = "交通事件类型子类名称")
private String eventTypeName2;
/** 交通事件原因 */
@Excel(name = "交通事件原因")
private String eventCause;
@ -534,6 +543,22 @@ public class MdEvent
return deletionTime;
}
public String getEventTypeName() {
return eventTypeName;
}
public void setEventTypeName(String eventTypeName) {
this.eventTypeName = eventTypeName;
}
public String getEventTypeName2() {
return eventTypeName2;
}
public void setEventTypeName2(String eventTypeName2) {
this.eventTypeName2 = eventTypeName2;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -576,6 +601,8 @@ public class MdEvent
.append("isDeleted", getIsDeleted())
.append("deleterUserId", getDeleterUserId())
.append("deletionTime", getDeletionTime())
.append("eventTypeName", getEventTypeName())
.append("eventTypeName2", getEventTypeName2())
.toString();
}
@ -604,6 +631,7 @@ public class MdEvent
// 11-其他事件
String eventType = dcEvent.getEventType().toString();
this.eventTypeCode = eventType;
this.eventTypeName = ValueConverter.eventTypeName(eventType);
if ("1".equals(eventType)){
DcEventAccident dcEventAccident = dcEvent.getDcEventAccident();
if (dcEventAccident != null){
@ -675,25 +703,14 @@ public class MdEvent
this.lane = dcEvent.getLang();
//方向:1-上 2-中 3-下
this.direction = dcEvent.getDirection();
//经纬度
this.longitude = dcEvent.getLongitude();
this.latitude = dcEvent.getDimension();
//事件来源编码
this.eventSourceCode = dcEvent.getEventSource();
//事件来源编码 1-96659,2-交警转接,3-道路巡查,4-视频巡查,5-视频AI,6-一键救援,7-其他
if (dcEvent.getEventSource() != null && dcEvent.getEventSource() > 0){
if (dcEvent.getEventSource() == 1){
this.eventSource = "96659";
} else if (dcEvent.getEventSource() == 2){
this.eventSource = "交警转接";
} else if (dcEvent.getEventSource() == 3){
this.eventSource = "道路巡查";
} else if (dcEvent.getEventSource() == 4){
this.eventSource = "视频巡查";
} else if (dcEvent.getEventSource() == 5){
this.eventSource = "视频AI";
} else if (dcEvent.getEventSource() == 6){
this.eventSource = "一键救援";
} else if (dcEvent.getEventSource() == 7){
this.eventSource = "其他";
}
this.eventSource = ValueConverter.eventSourceName(dcEvent.getEventSource().toString());
}
//事件状态:0-待确认,1-处理中,2-已完成
this.eventStatus = dcEvent.getEventState();
@ -704,7 +721,10 @@ public class MdEvent
this.sectionId = dcEvent.getRoadId().toString();
}
//交通事件类型子类
this.eventTypeCode2 = dcEvent.getEventSubclass();
if (StringUtils.isNotEmpty(dcEvent.getEventSubclass())) {
this.eventTypeCode2 = dcEvent.getEventSubclass();
this.eventTypeName2 = ValueConverter.eventSubclassName(dcEvent.getEventSubclass());
}
//事件原因
this.eventCause = dcEvent.getEventCause();
}

52
zc-business/src/main/java/com/zc/business/enums/StakeMarkRange.java

@ -0,0 +1,52 @@
package com.zc.business.enums;
/**
*
*/
public enum StakeMarkRange {
ONE(54394, 59289, 1,"殷家林枢纽"),
TWO(59289, 72847,2, "大学城立交"),
THREE(72847, 83835,3, "长清立交"),
FOUR(83835, 86499,4, "松竹枢纽"),
FIVE(86499, 99750,5, "孝里立交"),
SIX(99750, 105904, 6,"平阴北立交"),
SEVEN(105904, 117878,7, "平阴立交"),
EIGHT(117878, 126233,8, "孔村枢纽"),
NINE(126233, 145933, 9,"平阴南立交"),
TEN(145933, 155652, 10,"东平立交"),
DONGPING_LAKE_HUB(155652,173950,11,"东平湖枢纽"),
LIANGSHANDONG_INTERCHANGE(173950,179396,12,"梁山东立交"),
LIANGSHAN_INTERCHANGE(179396,190495,13,"梁山立交"),
JIAXIANG_WEST_INTERCHANGE(190495,202979,14,"嘉祥西立交");
private final int stakeMark;
private final int endMark;
private final int identification;
private final String description;
public int getStakeMark() {
return stakeMark;
}
public int getEndMark() {
return endMark;
}
public String getDescription() {
return description;
}
public int getIdentification() {
return identification;
}
StakeMarkRange(int stakeMark, int endMark, int identification, String description) {
this.stakeMark = stakeMark;
this.endMark = endMark;
this.identification = identification;
this.description = description;
}
}

65
zc-business/src/main/java/com/zc/business/enums/ValueConverter.java

@ -26,6 +26,8 @@ public class ValueConverter {
private static final Map<String, String> eventSourceName = new HashMap<>();
// 事件类型名称
private static final Map<String, String> eventTypeName = new HashMap<>();
// 事件子类名称
private static final Map<String, String> eventSubclassName = new HashMap<>();
// 事件字段
private static final Map<String, String> eventLabel = new HashMap<>();
@ -121,6 +123,60 @@ public class ValueConverter {
eventTypeName.put("10","异常天气");
eventTypeName.put("11","其他事件");
eventSubclassName.put("1-1","追尾");
eventSubclassName.put("1-2","侧翻");
eventSubclassName.put("1-3","撞护栏");
eventSubclassName.put("1-4","自然");
eventSubclassName.put("1-5","其他事故");
eventSubclassName.put("2-1","车辆故障");
eventSubclassName.put("3-1","主线封闭和限行");
eventSubclassName.put("3-2","收费站封闭和限行");
eventSubclassName.put("3-3","立交封闭和限行");
eventSubclassName.put("3-4","服务区封闭和限行");
eventSubclassName.put("4-1","道路拥堵");
eventSubclassName.put("4-2","立交拥堵");
eventSubclassName.put("4-3","收费站拥堵");
eventSubclassName.put("4-4","服务区拥堵");
eventSubclassName.put("5-1","行人");
eventSubclassName.put("5-2","非机动车");
eventSubclassName.put("5-3","摩托车");
eventSubclassName.put("5-4","其他");
eventSubclassName.put("6-1","烟雾");
eventSubclassName.put("6-2","倒伏树木");
eventSubclassName.put("6-3","撒落物");
eventSubclassName.put("6-4","动物");
eventSubclassName.put("6-5","其他");
eventSubclassName.put("7-1","道路养护施工");
eventSubclassName.put("7-2","收费站养护施工");
eventSubclassName.put("7-3","服务区养护施工");
eventSubclassName.put("7-4","枢纽立交匝道养护施工");
eventSubclassName.put("7-5","地方道路养护施工");
eventSubclassName.put("7-6","道路工程建设施工");
eventSubclassName.put("7-7","收费站工程建设施工");
eventSubclassName.put("7-8","服务区工程建设施工");
eventSubclassName.put("7-9","枢纽立交匝道工程建设施工");
eventSubclassName.put("7-10","地方道路工程建设施工");
eventSubclassName.put("8-1","封闭、暂停营业");
eventSubclassName.put("8-2","重要设施停用");
eventSubclassName.put("8-3","服务区其他异常");
eventSubclassName.put("9-1","摄像机");
eventSubclassName.put("9-2","护栏");
eventSubclassName.put("9-3","隔离栅");
eventSubclassName.put("9-4","情报板");
eventSubclassName.put("9-5","防炫板");
eventSubclassName.put("9-6","其他");
eventSubclassName.put("10-1","雨");
eventSubclassName.put("10-2","雪");
eventSubclassName.put("10-3","雾");
eventSubclassName.put("10-4","大风");
eventSubclassName.put("10-5","低温寒潮");
eventSubclassName.put("10-6","路面积雪");
eventSubclassName.put("10-7","路面结冰");
eventSubclassName.put("10-8","路面积水");
eventSubclassName.put("10-9","其他");
eventSubclassName.put("11-1","其他事件");
eventLabel.put("id","事件编号");
eventLabel.put("deptId","所属部门");
eventLabel.put("stakeMark","桩号");
@ -255,6 +311,11 @@ public class ValueConverter {
public static Map<String, String> getEventLabel() {
return ValueMappingHolder.eventLabel;
}
public static Map<String, String> getEventSubclassName() {
return ValueMappingHolder.eventSubclassName;
}
/**
* 根据输入值返回转换后的值
* 如果输入值不在映射中则返回输入值本身
@ -288,6 +349,10 @@ public class ValueConverter {
Map<String, String> mapping = getEventLabel();
return mapping.getOrDefault(inputValue, "");
}
public static String eventSubclassName(String inputValue) {
Map<String, String> mapping = getEventSubclassName();
return mapping.getOrDefault(inputValue, inputValue);
}
//测试
// @Test

17
zc-business/src/main/java/com/zc/business/mapper/DcGantryStatisticsDataMapper.java

@ -3,9 +3,11 @@ package com.zc.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zc.business.domain.DcGantryStatisticsData;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 这是一个接口的注释用于描述门架数据统计的Mapper
@ -24,6 +26,14 @@ public interface DcGantryStatisticsDataMapper extends BaseMapper<DcGantryStatist
*/
boolean insertOrUpdate(DcGantryStatisticsData gantryStatisticsData);
/**
* 批量插入或更新门架数据统计
*
* @param dcGantryStatisticsDataList 门架数据统计对象列表包含需要插入或更新的数据
* @return 返回一个整数表示插入或更新操作影响的行数
*/
int insertOrUpdateBatch(List<DcGantryStatisticsData> dcGantryStatisticsDataList);
/**
* 获取最大的统计日期
*
@ -32,11 +42,8 @@ public interface DcGantryStatisticsDataMapper extends BaseMapper<DcGantryStatist
Date getMaxStatisticalDate();
/**
* 批量插入或更新门架数据统计
*
* @param dcGantryStatisticsDataList 门架数据统计对象列表包含需要插入或更新的数据
* @return 返回一个整数表示插入或更新操作影响的行数
* 全路段双向实时车流量
*/
int insertOrUpdateBatch(List<DcGantryStatisticsData> dcGantryStatisticsDataList);
List<Map<String, String>> realTimeTrafficFlow(@Param("startDate") String startDate, @Param("direction")String direction, @Param("periodType")String periodType );
}

3
zc-business/src/main/java/com/zc/business/mapper/DcStakeMarkMapper.java

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zc.business.domain.DcDevice;
import com.zc.business.domain.DcStakeMark;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -18,4 +19,6 @@ public interface DcStakeMarkMapper extends BaseMapper<DcStakeMark> {
boolean batchInsert(List<DcStakeMark> dcStakeMarkList);
DcStakeMark selectByDirection(@Param("stakeMark") String stakeMark,@Param("direction") String direction);
}

64
zc-business/src/main/java/com/zc/business/mapper/DcTrafficPoliceMapper.java

@ -0,0 +1,64 @@
package com.zc.business.mapper;
import com.zc.business.domain.DcTrafficPolice;
import java.util.List;
/**
* 交管数据Mapper接口
*
* @author ruoyi
* @date 2024-06-06
*/
public interface DcTrafficPoliceMapper
{
/**
* 查询交管数据
*
* @param id 交管数据主键
* @return 交管数据
*/
public DcTrafficPolice selectDcTrafficPoliceById(Long id);
/**
* 查询交管数据列表
*
* @param dcTrafficPolice 交管数据
* @return 交管数据集合
*/
List<DcTrafficPolice> selectDcTrafficPoliceList(DcTrafficPolice dcTrafficPolice);
/**
* 新增交管数据
*
* @param dcTrafficPolice 交管数据
* @return 结果
*/
int insertDcTrafficPolice(DcTrafficPolice dcTrafficPolice);
/**
* 修改交管数据
*
* @param dcTrafficPolice 交管数据
* @return 结果
*/
int updateDcTrafficPolice(DcTrafficPolice dcTrafficPolice);
/**
* 删除交管数据
*
* @param id 交管数据主键
* @return 结果
*/
int deleteDcTrafficPoliceById(Long id);
/**
* 批量删除交管数据
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
int deleteDcTrafficPoliceByIds(Long[] ids);
public DcTrafficPolice selectEvent(String make);
}

1
zc-business/src/main/java/com/zc/business/service/IDcFacilityService.java

@ -60,4 +60,5 @@ public interface IDcFacilityService extends IService<DcFacility> {
* @return 设备信息
*/
DcFacility getFacility(String id);
DcFacility getfacilityCode(String id);
}

6
zc-business/src/main/java/com/zc/business/service/IDcGantryStatisticsDataService.java

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.zc.business.domain.DcGantryStatisticsData;
import java.util.List;
import java.util.Map;
/**
* 门架数据统计接口该接口扩展了IService接口用于对DcGantryStatisticsData类型的实体进行数据库操作
@ -42,4 +43,9 @@ public interface IDcGantryStatisticsDataService extends IService<DcGantryStatist
* @return 返回一个DcGantryStatisticsData对象的列表包含统计后的结果
*/
List<DcGantryStatisticsData> gantryData(DcGantryStatisticsData dcGantryStatisticsData);
/**
* 全路段双向实时车流量
*/
List<Map<String, String>> realTimeTrafficFlow(String startDate, String direction,String periodType );
}

64
zc-business/src/main/java/com/zc/business/service/IDcTrafficPoliceService.java

@ -0,0 +1,64 @@
package com.zc.business.service;
import com.zc.business.domain.DcTrafficPolice;
import java.util.List;
/**
* 交管数据Service接口
*
* @author ruoyi
* @date 2024-06-06
*/
public interface IDcTrafficPoliceService
{
/**
* 查询交管数据
*
* @param id 交管数据主键
* @return 交管数据
*/
public DcTrafficPolice selectDcTrafficPoliceById(Long id);
/**
* 查询交管数据列表
*
* @param dcTrafficPolice 交管数据
* @return 交管数据集合
*/
List<DcTrafficPolice> selectDcTrafficPoliceList(DcTrafficPolice dcTrafficPolice);
/**
* 新增交管数据
*
* @param dcTrafficPolice 交管数据
* @return 结果
*/
int insertDcTrafficPolice(DcTrafficPolice dcTrafficPolice);
/**
* 修改交管数据
*
* @param dcTrafficPolice 交管数据
* @return 结果
*/
int updateDcTrafficPolice(DcTrafficPolice dcTrafficPolice);
/**
* 批量删除交管数据
*
* @param ids 需要删除的交管数据主键集合
* @return 结果
*/
int deleteDcTrafficPoliceByIds(Long[] ids);
/**
* 删除交管数据信息
*
* @param id 交管数据主键
* @return 结果
*/
int deleteDcTrafficPoliceById(Long id);
public DcTrafficPolice selectEvent(String make);
}

16
zc-business/src/main/java/com/zc/business/service/IDcTrafficStatisticsService.java

@ -1,12 +1,12 @@
package com.zc.business.service;
import com.alibaba.fastjson.JSONArray;
import com.zc.business.domain.DcGantryMetricsStatisticsData;
import com.zc.business.domain.DcRoadSectionCongestion;
import com.zc.common.core.httpclient.exception.HttpException;
import java.io.IOException;
import java.util.List;
import java.util.Map;
public interface IDcTrafficStatisticsService {
@ -40,4 +40,18 @@ public interface IDcTrafficStatisticsService {
*/
JSONArray gantryMetrics(String startTime, String endTime) throws HttpException, IOException;
/**
* 断面小时车流量分车型
*/
JSONArray sectionHourlyTrafficFlow(String startDate, String endDate) throws HttpException, IOException;
/**
* 各收费站入口分车型小时车流量
*/
List<Map<String, String>>trafficFlowAtTollStationEntrance(String startDate, String endDate, String stationType) throws HttpException, IOException;
JSONArray trafficFlowAtTollStationEntranceHour(String startDate, String endDate, String stationType)throws HttpException, IOException;
List<Map<String, Object>> realTimeTrafficFlowHour(String startDate,Long direction) throws HttpException, IOException;
}

51
zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java

@ -85,6 +85,9 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
@Autowired
private DcPublishManageMapper dcPublishManageMapper;
@Autowired
private DcStakeMarkMapper dcStakeMarkMapper;
private final String HAPPEN = "发生";
private final String EVENT = "事件";
private final String SUBEVENT = "0";
@ -584,8 +587,17 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
//设置事件Id UUID无下划线格式32
String uuid = dcEvent.getId();
int i7 = dcEventMapper.insertDcEvent(dcEvent);
if (i7 > 0) {
//中间库
if (StringUtils.isNotEmpty(dcEvent.getStakeMark()) && StringUtils.isNotEmpty(dcEvent.getDirection())){
DcStakeMark dcStakeMark = dcStakeMarkMapper.selectByDirection(dcEvent.getStakeMark(),dcEvent.getDirection());
if (dcStakeMark != null){
dcEvent.setLongitude(dcStakeMark.getLongitude());
dcEvent.setDimension(dcStakeMark.getLatitude());
}
}
MdEvent mdEvent = new MdEvent(dcEvent);
middleDatabaseService.insertMiddleDatabaseEvent(mdEvent);
@ -734,6 +746,13 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
List<DcEventProcess> dcEventProcessList = new ArrayList<>();
for (DcEvent dcEvent : dcEventList) {
if (StringUtils.isNotEmpty(dcEvent.getStakeMark()) && StringUtils.isNotEmpty(dcEvent.getDirection())){
DcStakeMark dcStakeMark = dcStakeMarkMapper.selectByDirection(dcEvent.getStakeMark(),dcEvent.getDirection());
if (dcStakeMark != null){
dcEvent.setLongitude(dcStakeMark.getLongitude());
dcEvent.setDimension(dcStakeMark.getLatitude());
}
}
MdEvent mdEvent = new MdEvent(dcEvent);
mdEventList.add(mdEvent);
@ -883,6 +902,13 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
//中间库
if (StringUtils.isNotEmpty(dcEvent.getStakeMark()) && StringUtils.isNotEmpty(dcEvent.getDirection())){
DcStakeMark dcStakeMark = dcStakeMarkMapper.selectByDirection(dcEvent.getStakeMark(),dcEvent.getDirection());
if (dcStakeMark != null){
dcEvent.setLongitude(dcStakeMark.getLongitude());
dcEvent.setDimension(dcStakeMark.getLatitude());
}
}
MdEvent mdEvent = new MdEvent(dcEvent);
middleDatabaseService.updateMiddleDatabaseEvent(mdEvent);
@ -1188,18 +1214,25 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
if (dcEvent1 == null) {
return 1;
}
/*
//事件状态已被修改 返回成功
if (dcEvent1.getEventState() == state) {
if (dcEvent1.getEventState() == 1) {
return 1;
}
*/
int i = dcEventMapper.updateDcEventState(id, state);
if (i > 0) {
DcEvent dcEvent = dcEventMapper.selectDcEventMainById(id);
//中间库
if (StringUtils.isNotEmpty(dcEvent.getStakeMark()) && StringUtils.isNotEmpty(dcEvent.getDirection())){
DcStakeMark dcStakeMark = dcStakeMarkMapper.selectByDirection(dcEvent.getStakeMark(),dcEvent.getDirection());
if (dcStakeMark != null){
dcEvent.setLongitude(dcStakeMark.getLongitude());
dcEvent.setDimension(dcStakeMark.getLatitude());
}
}
MdEvent mdEvent = new MdEvent(dcEvent);
middleDatabaseService.insertMiddleDatabaseEvent(mdEvent);
@ -1552,9 +1585,17 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
}
} else if ("dcEventConstruction.trafficCondition".equals(result.getRightPath())) {
if ("1".equals(result.getRight())) {
result.setRight("通行正常");
result.setRight("通行受限");
} else if ("2".equals(result.getRight())) {
result.setRight("通行受阻");
result.setRight("车辆谨慎慢行");
} else if ("3".equals(result.getRight())) {
result.setRight("车辆正常通行");
}
} else if ("dcEventConstruction.constructionMethod".equals(result.getRightPath())) {
if ("1".equals(result.getRight())) {
result.setRight("车道");
} else if ("2".equals(result.getRight())) {
result.setRight("其他");
}
} else if ("dcEventServiceArea.disableFacility".equals(result.getRightPath())) {
if ("1".equals(result.getRight())) {

13
zc-business/src/main/java/com/zc/business/service/impl/DcFacilityServiceImpl.java

@ -8,6 +8,7 @@ import com.ruoyi.common.utils.PageUtils;
import com.zc.business.domain.DcFacility;
import com.zc.business.mapper.DcFacilityMapper;
import com.zc.business.service.IDcFacilityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
@ -23,7 +24,8 @@ import java.util.Objects;
@Service
public class DcFacilityServiceImpl extends ServiceImpl<DcFacilityMapper, DcFacility> implements IDcFacilityService {
@Autowired
private DcFacilityMapper dcFacilityMapper;
public LambdaQueryWrapper<DcFacility> facilityQueryWrapper(DcFacility dcFacility) {
LambdaQueryWrapper<DcFacility> queryWrapper = new LambdaQueryWrapper<>();
@ -140,5 +142,14 @@ public class DcFacilityServiceImpl extends ServiceImpl<DcFacilityMapper, DcFacil
return getById(id);
}
@Override
public DcFacility getfacilityCode(String id) {
LambdaQueryWrapper<DcFacility> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(DcFacility::getFacilityCode, id);
return dcFacilityMapper.selectOne(queryWrapper);
}
}

9
zc-business/src/main/java/com/zc/business/service/impl/DcGantryStatisticsDataImpl.java

@ -23,6 +23,7 @@ import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 门架数据统计服务实现类
@ -195,5 +196,11 @@ public class DcGantryStatisticsDataImpl extends ServiceImpl<DcGantryStatisticsDa
dcTrafficSectionDataList.forEach(YearlyTrafficGantryStatisticsCache::addCacheData);
}
/**
* 全路段双向实时车流量
*/
@Override
public List<Map<String, String>> realTimeTrafficFlow(String startDate, String direction, String periodType ) {
return dcGantryStatisticsDataMapper.realTimeTrafficFlow(startDate,direction,periodType);
}
}

104
zc-business/src/main/java/com/zc/business/service/impl/DcTrafficPoliceServiceImpl.java

@ -0,0 +1,104 @@
package com.zc.business.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.zc.business.domain.DcTrafficPolice;
import com.zc.business.mapper.DcTrafficPoliceMapper;
import com.zc.business.service.IDcTrafficPoliceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 交管数据Service业务层处理
*
* @author ruoyi
* @date 2024-06-06
*/
@Service
public class DcTrafficPoliceServiceImpl implements IDcTrafficPoliceService
{
@Autowired
private DcTrafficPoliceMapper dcTrafficPoliceMapper;
/**
* 查询交管数据
*
* @param id 交管数据主键
* @return 交管数据
*/
@Override
public DcTrafficPolice selectDcTrafficPoliceById(Long id)
{
return dcTrafficPoliceMapper.selectDcTrafficPoliceById(id);
}
/**
* 查询交管数据列表
*
* @param dcTrafficPolice 交管数据
* @return 交管数据
*/
@Override
public List<DcTrafficPolice> selectDcTrafficPoliceList(DcTrafficPolice dcTrafficPolice)
{
return dcTrafficPoliceMapper.selectDcTrafficPoliceList(dcTrafficPolice);
}
/**
* 新增交管数据
*
* @param dcTrafficPolice 交管数据
* @return 结果
*/
@Override
public int insertDcTrafficPolice(DcTrafficPolice dcTrafficPolice)
{
dcTrafficPolice.setCreateTime(DateUtils.getNowDate());
return dcTrafficPoliceMapper.insertDcTrafficPolice(dcTrafficPolice);
}
/**
* 修改交管数据
*
* @param dcTrafficPolice 交管数据
* @return 结果
*/
@Override
public int updateDcTrafficPolice(DcTrafficPolice dcTrafficPolice)
{
dcTrafficPolice.setUpdateTime(DateUtils.getNowDate());
return dcTrafficPoliceMapper.updateDcTrafficPolice(dcTrafficPolice);
}
/**
* 批量删除交管数据
*
* @param ids 需要删除的交管数据主键
* @return 结果
*/
@Override
public int deleteDcTrafficPoliceByIds(Long[] ids)
{
return dcTrafficPoliceMapper.deleteDcTrafficPoliceByIds(ids);
}
/**
* 删除交管数据信息
*
* @param id 交管数据主键
* @return 结果
*/
@Override
public int deleteDcTrafficPoliceById(Long id)
{
return dcTrafficPoliceMapper.deleteDcTrafficPoliceById(id);
}
@Override
public DcTrafficPolice selectEvent(String make) {
return dcTrafficPoliceMapper.selectEvent(make);
}
}

328
zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java

@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zc.business.domain.*;
import com.zc.business.enums.ChannelCongestionLevelEnum;
import com.zc.business.enums.StakeMarkRange;
import com.zc.business.enums.TrafficCompositionRateEnum;
import com.zc.business.service.IDcFacilityService;
import com.zc.business.service.IDcRoadSectionService;
@ -29,7 +30,10 @@ import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.io.IOException;
import java.time.LocalTime;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Service
public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsService {
@ -543,6 +547,330 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
return new JSONArray();
}
/**
* 断面小时车流量分车型
*/
@Override
public JSONArray sectionHourlyTrafficFlow(String startDate, String endDate) throws HttpException, IOException {
OkHttp okHttp = new OkHttp();
RequestParams requestParams = new RequestParams();
requestParams.put("sysid", sysid);
JSONObject parameters = new JSONObject() {
{
put("start_date", startDate);
put("end_date", endDate);
}
};
requestParams.put("parameters", parameters.toJSONString());
Map<String, String> headers = new HashMap<>();
headers.put("Authorization", getAccessToken());
Response response // 请求响应
= okHttp
.headers(headers)
.url(baseUrl + "/api/dc/query/rd_jihe_d_vehtypeflowbydatesection") // 请求地址
.data(requestParams) // 请求参数
.post(); // 请求方法
ResponseBody body = response.body();
if (body != null) {
return JSON.parseArray(body.string());
}
return new JSONArray();
}
/**
* 各收费站入口分车型小时车流量
*/
@Override
public List<Map<String, String>> trafficFlowAtTollStationEntrance(String startDate, String endDate, String stationType) throws HttpException, IOException {
OkHttp okHttp = new OkHttp();
RequestParams requestParams = new RequestParams();
requestParams.put("sysid", sysid);
JSONObject parameters = new JSONObject() {
{
put("start_date", startDate);
put("end_date", endDate);
put("station_type", stationType);
}
};
requestParams.put("parameters", parameters.toJSONString());
Map<String, String> headers = new HashMap<>();
headers.put("Authorization", getAccessToken());
Response response // 请求响应
= okHttp
.headers(headers)
.url(baseUrl + "/api/dc/query/ts_jihe_d_vehtypeflowbyhourstation") // 请求地址
.data(requestParams) // 请求参数
.post(); // 请求方法
ResponseBody body = response.body();
if (body != null) {
JSONArray jsonArray = JSON.parseArray(body.string());
// 使用HashMap来分组并求和
Map<String, Integer> sumByName = new HashMap<>();
List<Map<String, String>> list = new ArrayList();
for (Object item : jsonArray) { // 这里做了微调,直接遍历jsonArray的Object
JSONObject jsonObject = (JSONObject) item;
// 获取当前时间
LocalTime now = LocalTime.now();
// 获取当前小时数(24小时制)
int currentHour = now.getHour();
if (jsonObject.getInteger("data_hour") == currentHour) {
String name = jsonObject.getString("ts_name"); // 更安全的取值方式
int totalFlow = jsonObject.getInteger("total_flow"); // 专门针对Integer类型
sumByName.put(name, totalFlow);
// sumByName.put(name, sumByName.getOrDefault(name, 0) + totalFlow);
}
}
// 输出结果
// 输出结果
// 正确创建新的映射对象并添加到list中
for (Map.Entry<String, Integer> entry : sumByName.entrySet()) {
Map<String, String> singleResult = new HashMap<>(); // 每次循环都创建一个新的映射
singleResult.put("name", entry.getKey());
singleResult.put("value", entry.getValue().toString());
list.add(singleResult);
//System.out.println(entry.getKey() + " 的 total_flow 总和为: " + entry.getValue());
}
return list;
}
return new ArrayList();
}
@Override
public JSONArray trafficFlowAtTollStationEntranceHour(String startDate, String endDate, String stationType) throws HttpException, IOException {
OkHttp okHttp = new OkHttp();
RequestParams requestParams = new RequestParams();
requestParams.put("sysid", sysid);
JSONObject parameters = new JSONObject() {
{
put("start_date", startDate);
put("end_date", endDate);
put("station_type", stationType);
}
};
requestParams.put("parameters", parameters.toJSONString());
Map<String, String> headers = new HashMap<>();
headers.put("Authorization", getAccessToken());
Response response // 请求响应
= okHttp
.headers(headers)
.url(baseUrl + "/api/dc/query/ts_jihe_d_vehtypeflowbyhourstation") // 请求地址
.data(requestParams) // 请求参数
.post(); // 请求方法
ResponseBody body = response.body();
if (body != null) {
return JSON.parseArray(body.string());
}
return new JSONArray();
}
@Override
public List<Map<String, Object>> realTimeTrafficFlowHour(String startDate,Long direction) throws HttpException, IOException {
OkHttp okHttp = new OkHttp();
RequestParams requestParams = new RequestParams();
requestParams.put("sysid", sysid);
JSONObject parameters = new JSONObject() {
{
put("start_date", startDate);
put("end_date", startDate);
}
};
requestParams.put("parameters", parameters.toJSONString());
Map<String, String> headers = new HashMap<>();
headers.put("Authorization", getAccessToken());
Response response // 请求响应
= okHttp
.headers(headers)
.url(baseUrl + "/api/dc/query/gan_jihe_d_vehtypeflow") // 请求地址
.data(requestParams) // 请求参数
.post(); // 请求方法
ResponseBody body = response.body();
if (body != null) {
JSONArray jsonArray = JSON.parseArray(body.string());
// 获取当前时间
LocalTime now = LocalTime.now();
// 获取当前小时数(24小时制)
int currentHour = now.getHour();
// 初始化计数器和描述映射
Map<Integer, Integer> flowCounts = new HashMap<>();
Map<Integer, String> descriptions = new HashMap<>();
for (int i = 1; i <= 14; i++) {
flowCounts.put(i, 0);
descriptions.put(i, "");
}
for (Object item : jsonArray) {
JSONObject jsonObject = (JSONObject) item;
if (jsonObject.getInteger("data_hour") == currentHour) {
int totalFlow = jsonObject.getInteger("total_flow");
String gantryId = jsonObject.getString("gantry_id");
DcFacility dcFacilityAll = new DcFacility();
dcFacilityAll.setFacilityType(10);
dcFacilityAll.setDirection(String.valueOf(direction));
List<DcFacility> dcFacilityList = facilityService.listFacility(dcFacilityAll);
DcFacility dcFacility2 = facilityService.getfacilityCode(gantryId);
if (dcFacility2 != null) {
String stakeMark = dcFacility2.getStakeMark();
boolean exists = dcFacilityList.stream()
.anyMatch(dcFacility -> dcFacility.getId().equals(dcFacility2.getId()));
if (exists) {
int extractedNumber = Integer.parseInt(extract(stakeMark));
int identification = Arrays.stream(StakeMarkRange.values())
.filter(smRange -> extractedNumber >= smRange.getStakeMark() && extractedNumber <= smRange.getEndMark())
.mapToInt(StakeMarkRange::getIdentification)
.findFirst()
.orElse(0);
String description = getDescriptionByIdentification(identification);
descriptions.put(identification, description);
flowCounts.put(identification, flowCounts.get(identification) + totalFlow);
}
}
}
}
// 构建结果列表
List<Map<String, Object>> mapList = new ArrayList<>();
for (int i = 1; i <= 14; i++) {
Map<String, Object> map = new HashMap<>();
map.put("name", descriptions.get(i));
map.put("totalFlow", flowCounts.get(i));
mapList.add(map);
}
return mapList;
}
return null;
}
/**
*
* @param startDate
* @param direction
* @return
* @throws HttpException
* @throws IOException
*/
public List<Map<String, Object>> realTimeTrafficFlowHour2(String startDate,Long direction) throws HttpException, IOException {
OkHttp okHttp = new OkHttp();
RequestParams requestParams = new RequestParams();
requestParams.put("sysid", sysid);
JSONObject parameters = new JSONObject() {
{
put("start_date", startDate);
put("end_date", startDate);
}
};
requestParams.put("parameters", parameters.toJSONString());
Map<String, String> headers = new HashMap<>();
headers.put("Authorization", getAccessToken());
Response response // 请求响应
= okHttp
.headers(headers)
.url(baseUrl + "/api/dc/query/gan_jihe_d_vehtypeflow") // 请求地址
.data(requestParams) // 请求参数
.post(); // 请求方法
ResponseBody body = response.body();
if (body != null) {
JSONArray jsonArray = JSON.parseArray(body.string());
// 使用HashMap来分组并求和
List<Map<String, Object>> list = new ArrayList();
for (Object item : jsonArray) { // 这里做了微调,直接遍历jsonArray的Object
JSONObject jsonObject = (JSONObject) item;
// 获取当前时间
LocalTime now = LocalTime.now();
// 获取当前小时数(24小时制)
int currentHour = now.getHour();
if (jsonObject.getInteger("data_hour") == 16) {
Map<String,Object> sumByName = new HashMap<>();
String name = jsonObject.getString("gantry_name"); // 更安全的取值方式
int totalFlow = jsonObject.getInteger("total_flow"); // 专门针对Integer类型
String gantryId = jsonObject.getString("gantry_id"); // 专门针对Integer类型
String data_hour = jsonObject.getString("data_hour"); // 专门针对Integer类型
sumByName.put("naame", name);
sumByName.put("gantryId", gantryId);
sumByName.put("totalFlow", totalFlow);
sumByName.put("data_hour", data_hour);
list.add(sumByName);
}
}
// 输出结果
return list;
}
return new ArrayList();
}
private static String extract(String input) {
Pattern pattern = Pattern.compile("K(\\d{3})\\+(\\d{3})");
Matcher matcher = pattern.matcher(input);
if (matcher.find()) {
String part1 = matcher.group(1);
String part2 = matcher.group(2);
// 直接拼接两部分数字,无需格式化,这样得到的字符串自然没有前导零
return part1 + part2;
} else {
return "N/A";
}
}
public static String getDescriptionByIdentification(int identification) {
for (StakeMarkRange range : StakeMarkRange.values()) {
if (range.getIdentification() == identification) {
return range.getDescription();
}
}
return "";
}
}

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

@ -14,6 +14,7 @@ import com.zc.business.mapper.DcEventMapper;
import com.zc.business.mapper.DcProcessConfigMapper;
import com.zc.business.mapper.DcWarningMapper;
import com.zc.business.service.IDcEventService;
import com.zc.business.service.IDcTrafficPoliceService;
import com.zc.business.service.IDcWarningService;
import com.zc.business.utils.StakeMarkUtils;
import com.zc.common.core.websocket.WebSocketService;
@ -56,6 +57,8 @@ public class DcWarningServiceImpl implements IDcWarningService
@Autowired
private DcEventProcessServiceImpl dcEventProcessService;
@Autowired
private IDcTrafficPoliceService dcTrafficPoliceService;
@Autowired
private DcProcessConfigMapper dcProcessConfigMapper;
@Resource
private RedisCache redisCache;
@ -643,8 +646,11 @@ public class DcWarningServiceImpl implements IDcWarningService
if (!sortedHashMaps.isEmpty()) {
HashMap<String, Object> map = sortedHashMaps.get(0);
Long id = Long.parseLong(map.get("id").toString());//取出最近的机构id
//todo 交警
List<HashMap<String, Object>> trafficPolice = dcWarningMapper.selectTrafficPolice(id);//交警人员信息
mapAll.put("trafficPolice",trafficPolice);
DcTrafficPolice dcTrafficPolice = dcTrafficPoliceService.selectEvent(dcWarning.getStakeMark());
mapAll.put("trafficPolice",dcTrafficPolice);
}
if (dcDispatch==null){
mapAll.put("existence",0);

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

@ -19,6 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="endStakeMark" column="end_stake_mark" />
<result property="localRoadName" column="local_road_name" />
<result property="location" column="location" />
<result property="constructionMethod" column="construction_method" />
<result property="dcFacility.facilityName" column="facility_name" />
<result property="dcFacility.facilityType" column="facility_type" />
@ -29,11 +30,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectDcEventConstructionVo">
select location,local_road_name,end_stake_mark,id, control_mode, location_type, special_place_description, special_construction, other_construction_name, construction_measurement, facility_id, exits_inlets, lane_occupancy, traffic_condition from dc_event_construction
select construction_method,location,local_road_name,end_stake_mark,id, control_mode, location_type, special_place_description, special_construction, other_construction_name, construction_measurement, facility_id, exits_inlets, lane_occupancy, traffic_condition from dc_event_construction
</sql>
<sql id="selectDcEventConstructionVoById">
SELECT
dc_event_construction.id as id,
dc_event_construction.construction_method as construction_method,
dc_event_construction.control_mode as control_mode,
dc_event_construction.location_type as location_type,
dc_event_construction.special_place_description as special_place_description,
@ -95,6 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="endStakeMark != null">end_stake_mark,</if>
<if test="localRoadName != null">local_road_name,</if>
<if test="location != null">location,</if>
<if test="constructionMethod != null">construction_method,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
@ -111,6 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="endStakeMark != null">#{endStakeMark},</if>
<if test="localRoadName != null">#{localRoadName},</if>
<if test="location != null">#{location},</if>
<if test="constructionMethod != null">#{constructionMethod},</if>
</trim>
</insert>
@ -130,6 +134,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="endStakeMark != null">end_stake_mark = #{endStakeMark},</if>
<if test="localRoadName != null">local_road_name = #{localRoadName},</if>
<if test="location != null">location = #{location},</if>
<if test="constructionMethod != null">construction_method = #{constructionMethod},</if>
</trim>
where id = #{id}
</update>

49
zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml

@ -3,7 +3,10 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zc.business.mapper.DcGantryStatisticsDataMapper">
<resultMap type="map" id="countMap">
<result property="volume" column="total_traffic_volume"/>
<result property="name" column="interval_name"/>
</resultMap>
<!-- 插入或更新交通路段数据 -->
<insert id="insertOrUpdate" parameterType="com.zc.business.domain.DcGantryStatisticsData">
INSERT INTO
@ -166,4 +169,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
dc_gantry_statistics_data
</select>
<select id="realTimeTrafficFlow" resultMap="countMap" resultType="map" >
SELECT
intervals.interval_name,
intervals.stake_make,
intervals.end_make,
COALESCE(SUM(dgsd.traffic_volume), 0) AS total_traffic_volume
FROM
(
SELECT 'K054+394' AS stake_make, 'K059+289' AS end_make, '殷家林枢纽-大学城立交' AS interval_name UNION ALL
SELECT 'K059+289', 'K072+847', '大学城立交-长清立交' UNION ALL
SELECT 'K072+847', 'K083+835', '长清立交-松竹枢纽' UNION ALL
SELECT 'K083+835', 'K086+499', '松竹枢纽-孝里立交' UNION ALL
SELECT 'K086+499', 'K099+750', '孝里立交-平阴北立交' UNION ALL
SELECT 'K099+750', 'K105+904', '平阴北立交-平阴立交' UNION ALL
SELECT 'K105+904', 'K117+878', '平阴立交-孔村枢纽' UNION ALL
SELECT 'K117+878', 'K126+233', '孔村枢纽-平阴南立交' UNION ALL
SELECT 'K126+233', 'K145+933', '平阴南立交-东平立交' UNION ALL
SELECT 'K145+933', 'K155+652', '东平立交-东平湖枢纽' UNION ALL
SELECT 'K155+652', 'K173+950', '东平湖枢纽-梁山东立交' UNION ALL
SELECT 'K173+950', 'K179+396', '梁山东立交-梁山立交' UNION ALL
SELECT 'K179+396', 'K190+495', '梁山立交-嘉祥西立交' UNION ALL
SELECT 'K190+495', 'K202+979', '嘉祥西立交'
) AS intervals
LEFT JOIN (
SELECT
facility_code,
stake_mark,
facility_name,
direction
FROM
dc_facility
WHERE
direction = #{direction}
) AS ps ON ps.stake_mark BETWEEN CONCAT(intervals.stake_make, '+0') AND CONCAT(intervals.end_make, '+0')
LEFT JOIN dc_gantry_statistics_data dgsd ON ps.facility_code = dgsd.gantry_code
AND dgsd.statistical_date =#{startDate}
AND dgsd.period_type =#{periodType}
GROUP BY
intervals.interval_name,
intervals.stake_make,
intervals.end_make;
</select>
</mapper>

4
zc-business/src/main/resources/mapper/business/DcStakeMarkMapper.xml

@ -38,4 +38,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</foreach>
</insert>
<select id="selectByDirection" resultType="com.zc.business.domain.DcStakeMark">
select stake_mark stakeMark, longitude,latitude,direction,location,section_id sectionId,mileage
from dc_stake_mark where stake_mark = #{stakeMark} and direction = #{direction}
</select>
</mapper>

8
zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml

@ -89,7 +89,13 @@
UNION ALL select '4' as eventSource,'视频巡查' as eventSourceName
UNION ALL select '5' as eventSource,'视频AI' as eventSourceName
UNION ALL select '6' as eventSource,'一键救援' as eventSourceName
UNION ALL select '7' as eventSource,'其他' as eventSourceName) t1
UNION ALL select '7' as eventSource,'其他' as eventSourceName
UNION ALL select '8' as eventSource,'雷达识别' as eventSourceName
UNION ALL select '9' as eventSource,'锥桶' as eventSourceName
UNION ALL select '10' as eventSource,'护栏碰撞' as eventSourceName
UNION ALL select '11' as eventSource,'扫码报警' as eventSourceName
UNION ALL select '12' as eventSource,'非机预警' as eventSourceName
UNION ALL select '13' as eventSource,'气象检测器' as eventSourceName) t1
LEFT JOIN
(select event_source eventSource,count(*) num
from dc_event

84
zc-business/src/main/resources/mapper/business/DcTrafficPoliceMapper.xml

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zc.business.mapper.DcTrafficPoliceMapper">
<resultMap type="com.zc.business.domain.DcTrafficPolice" id="DcTrafficPoliceResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="phone" column="phone" />
<result property="stakeMake" column="stake_make" />
<result property="endMake" column="end_make" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectDcTrafficPoliceVo">
select id, name, phone, stake_make, end_make, create_time, update_time from dc_traffic_police
</sql>
<select id="selectDcTrafficPoliceList" parameterType="DcTrafficPolice" resultMap="DcTrafficPoliceResult">
<include refid="selectDcTrafficPoliceVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="phone != null and phone != ''"> and phone = #{phone}</if>
<if test="stakeMake != null and stakeMake != ''"> and stake_make = #{stakeMake}</if>
<if test="endMake != null and endMake != ''"> and end_make = #{endMake}</if>
</where>
</select>
<select id="selectDcTrafficPoliceById" parameterType="Long" resultMap="DcTrafficPoliceResult">
<include refid="selectDcTrafficPoliceVo"/>
where id = #{id}
</select>
<insert id="insertDcTrafficPolice" parameterType="DcTrafficPolice" useGeneratedKeys="true" keyProperty="id">
insert into dc_traffic_police
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">name,</if>
<if test="phone != null">phone,</if>
<if test="stakeMake != null">stake_make,</if>
<if test="endMake != null">end_make,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if>
<if test="phone != null">#{phone},</if>
<if test="stakeMake != null">#{stakeMake},</if>
<if test="endMake != null">#{endMake},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateDcTrafficPolice" parameterType="DcTrafficPolice">
update dc_traffic_police
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="stakeMake != null">stake_make = #{stakeMake},</if>
<if test="endMake != null">end_make = #{endMake},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDcTrafficPoliceById" parameterType="Long">
delete from dc_traffic_police where id = #{id}
</delete>
<delete id="deleteDcTrafficPoliceByIds" parameterType="String">
delete from dc_traffic_police where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectEvent" parameterType="String" resultMap="DcTrafficPoliceResult">
<include refid="selectDcTrafficPoliceVo"/>
WHERE #{make} BETWEEN dc_traffic_police.stake_make AND dc_traffic_police.end_make;
</select>
</mapper>

10
zc-business/src/main/resources/mapper/business/MiddleDatabaseMapper.xml

@ -39,6 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="fusionId != null">fusionId,</if>
<if test="eventName != null">event_name,</if>
<if test="eventTypeCode != null">event_type_code,</if>
<if test="eventTypeName != null">event_type_name,</if>
<if test="eventDesc != null">event_desc,</if>
<if test="occurTime != null">occur_time,</if>
<if test="endTime != null">end_time,</if>
@ -54,6 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="eventLevel != null">event_level,</if>
<if test="sectionId != null">section_id,</if>
<if test="eventTypeCode2 != null">event_type_code2,</if>
<if test="eventTypeName2 != null">event_type_name2,</if>
<if test="eventCause != null">event_cause,</if>
<if test="accidentWeather != null">accident_weather,</if>
<if test="accidentQueue != null">accident_queue,</if>
@ -79,6 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="fusionId != null">#{fusionId},</if>
<if test="eventName != null">#{eventName},</if>
<if test="eventTypeCode != null">#{eventTypeCode},</if>
<if test="eventTypeName != null">#{eventTypeName},</if>
<if test="eventDesc != null">#{eventDesc},</if>
<if test="occurTime != null">#{occurTime},</if>
<if test="endTime != null">#{endTime},</if>
@ -94,6 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="eventLevel != null">#{eventLevel},</if>
<if test="sectionId != null">#{sectionId},</if>
<if test="eventTypeCode2 != null">#{eventTypeCode2},</if>
<if test="eventTypeName2 != null">#{eventTypeName2},</if>
<if test="eventCause != null">#{eventCause},</if>
<if test="accidentWeather != null">#{accidentWeather},</if>
<if test="accidentQueue != null">#{accidentQueue},</if>
@ -238,6 +242,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="mdEvent.fusionId != null">fusionId,</if>
<if test="mdEvent.eventName != null">event_name,</if>
<if test="mdEvent.eventTypeCode != null">event_type_code,</if>
<if test="mdEvent.eventTypeName != null">event_type_name,</if>
<if test="mdEvent.eventDesc != null">event_desc,</if>
<if test="mdEvent.occurTime != null">occur_time,</if>
<if test="mdEvent.endTime != null">end_time,</if>
@ -253,6 +258,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="mdEvent.eventLevel != null">event_level,</if>
<if test="mdEvent.sectionId != null">section_id,</if>
<if test="mdEvent.eventTypeCode2 != null">event_type_code2,</if>
<if test="mdEvent.eventTypeName2 != null">event_type_name2,</if>
<if test="mdEvent.eventCause != null">event_cause,</if>
<if test="mdEvent.accidentWeather != null">accident_weather,</if>
<if test="mdEvent.accidentQueue != null">accident_queue,</if>
@ -278,6 +284,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="mdEvent.fusionId != null">#{mdEvent.fusionId},</if>
<if test="mdEvent.eventName != null">#{mdEvent.eventName},</if>
<if test="mdEvent.eventTypeCode != null">#{mdEvent.eventTypeCode},</if>
<if test="mdEvent.eventTypeName != null">#{mdEvent.eventTypeName},</if>
<if test="mdEvent.eventDesc != null">#{mdEvent.eventDesc},</if>
<if test="mdEvent.occurTime != null">#{mdEvent.occurTime},</if>
<if test="mdEvent.endTime != null">#{mdEvent.endTime},</if>
@ -293,6 +300,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="mdEvent.eventLevel != null">#{mdEvent.eventLevel},</if>
<if test="mdEvent.sectionId != null">#{mdEvent.sectionId},</if>
<if test="mdEvent.eventTypeCode2 != null">#{mdEvent.eventTypeCode2},</if>
<if test="mdEvent.eventTypeName2 != null">#{mdEvent.eventTypeName2},</if>
<if test="mdEvent.eventCause != null">#{mdEvent.eventCause},</if>
<if test="mdEvent.accidentWeather != null">#{mdEvent.accidentWeather},</if>
<if test="mdEvent.accidentQueue != null">#{mdEvent.accidentQueue},</if>
@ -357,6 +365,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="SET" suffixOverrides=",">
<if test="eventName != null">event_name = #{eventName},</if>
<if test="eventTypeCode != null">event_type_code = #{eventTypeCode},</if>
<if test="eventTypeName != null">event_type_name = #{eventTypeName},</if>
<if test="eventDesc != null">event_desc = #{eventDesc},</if>
<if test="occurTime != null">occur_time = #{occurTime},</if>
<if test="endTime != null">end_time = #{endTime},</if>
@ -372,6 +381,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="eventLevel != null">event_level = #{eventLevel},</if>
<if test="sectionId != null">section_id = #{sectionId},</if>
<if test="eventTypeCode2 != null">event_type_code2 = #{eventTypeCode2},</if>
<if test="eventTypeName2 != null">event_type_name2 = #{eventTypeName2},</if>
<if test="eventCause != null">event_cause = #{eventCause},</if>
<if test="accidentWeather != null">accident_weather = #{accidentWeather},</if>
<if test="accidentQueue != null">accident_queue = #{accidentQueue},</if>

Loading…
Cancel
Save