Browse Source

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

develop
xiepufeng 1 year ago
parent
commit
86e4fdad3b
  1. 12
      ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java
  2. 12
      zc-business/pom.xml
  3. 18
      zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java
  4. 15
      zc-business/src/main/java/com/zc/business/controller/DcEmergencyPlansController.java
  5. 56
      zc-business/src/main/java/com/zc/business/controller/DcEventController.java
  6. 98
      zc-business/src/main/java/com/zc/business/controller/DcEventImportantController.java
  7. 174
      zc-business/src/main/java/com/zc/business/controller/DcEventImportantFileController.java
  8. 20
      zc-business/src/main/java/com/zc/business/controller/DcEventProcessController.java
  9. 32
      zc-business/src/main/java/com/zc/business/controller/DcWarningController.java
  10. 103
      zc-business/src/main/java/com/zc/business/controller/MsmController.java
  11. 13
      zc-business/src/main/java/com/zc/business/controller/VideoController.java
  12. 95
      zc-business/src/main/java/com/zc/business/controller/WeiboAuthUtil.java
  13. 36
      zc-business/src/main/java/com/zc/business/domain/DcDispatch.java
  14. 79
      zc-business/src/main/java/com/zc/business/domain/DcDispatchResource.java
  15. 22
      zc-business/src/main/java/com/zc/business/domain/DcEmployees.java
  16. 8
      zc-business/src/main/java/com/zc/business/domain/DcEvent.java
  17. 183
      zc-business/src/main/java/com/zc/business/domain/DcEventImportant.java
  18. 173
      zc-business/src/main/java/com/zc/business/domain/DcEventImportantFile.java
  19. 39
      zc-business/src/main/java/com/zc/business/domain/DcEventProcess.java
  20. 2
      zc-business/src/main/java/com/zc/business/domain/DcEventTrafficControl.java
  21. 2
      zc-business/src/main/java/com/zc/business/domain/DcVehicles.java
  22. 2
      zc-business/src/main/java/com/zc/business/domain/DcWarning.java
  23. 21
      zc-business/src/main/java/com/zc/business/domain/EventPlanAssoc.java
  24. 50
      zc-business/src/main/java/com/zc/business/enums/EventSubclassEnum.java
  25. 164
      zc-business/src/main/java/com/zc/business/enums/ValueConverter.java
  26. 2
      zc-business/src/main/java/com/zc/business/enums/WarningSubclassEnum.java
  27. 4
      zc-business/src/main/java/com/zc/business/mapper/DcDeviceMapper.java
  28. 71
      zc-business/src/main/java/com/zc/business/mapper/DcEventImportantFileMapper.java
  29. 61
      zc-business/src/main/java/com/zc/business/mapper/DcEventImportantMapper.java
  30. 32
      zc-business/src/main/java/com/zc/business/mapper/DcEventMapper.java
  31. 10
      zc-business/src/main/java/com/zc/business/mapper/DcEventProcessMapper.java
  32. 26
      zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java
  33. 19
      zc-business/src/main/java/com/zc/business/service/DcEmergencyPlansService.java
  34. 8
      zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java
  35. 71
      zc-business/src/main/java/com/zc/business/service/IDcEventImportantFileService.java
  36. 61
      zc-business/src/main/java/com/zc/business/service/IDcEventImportantService.java
  37. 11
      zc-business/src/main/java/com/zc/business/service/IDcEventProcessService.java
  38. 38
      zc-business/src/main/java/com/zc/business/service/IDcEventService.java
  39. 11
      zc-business/src/main/java/com/zc/business/service/IDcWarningService.java
  40. 21
      zc-business/src/main/java/com/zc/business/service/IMsmService.java
  41. 32
      zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java
  42. 331
      zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java
  43. 135
      zc-business/src/main/java/com/zc/business/service/impl/DcEventImportantFileServiceImpl.java
  44. 93
      zc-business/src/main/java/com/zc/business/service/impl/DcEventImportantServiceImpl.java
  45. 53
      zc-business/src/main/java/com/zc/business/service/impl/DcEventProcessServiceImpl.java
  46. 754
      zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java
  47. 494
      zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java
  48. 200
      zc-business/src/main/java/com/zc/business/service/impl/MsmServiceImpl.java
  49. 83
      zc-business/src/main/java/com/zc/business/utils/HttpUtil.java
  50. 216
      zc-business/src/main/java/com/zc/business/utils/PoiUtil.java
  51. 82
      zc-business/src/main/java/com/zc/business/utils/diff/AlgorithmEnum.java
  52. 208
      zc-business/src/main/java/com/zc/business/utils/diff/Diff.java
  53. 49
      zc-business/src/main/java/com/zc/business/utils/diff/algorithm/AbstractObjectAndArray.java
  54. 34
      zc-business/src/main/java/com/zc/business/utils/diff/algorithm/AbstractPrimitiveAndOther.java
  55. 66
      zc-business/src/main/java/com/zc/business/utils/diff/algorithm/AlgorithmModule.java
  56. 9
      zc-business/src/main/java/com/zc/business/utils/diff/algorithm/Comparator.java
  57. 22
      zc-business/src/main/java/com/zc/business/utils/diff/algorithm/array/AbstractArray.java
  58. 43
      zc-business/src/main/java/com/zc/business/utils/diff/algorithm/array/ArrayComparator.java
  59. 252
      zc-business/src/main/java/com/zc/business/utils/diff/algorithm/array/SimilarArrayComparator.java
  60. 62
      zc-business/src/main/java/com/zc/business/utils/diff/algorithm/array/SimpleArrayComparator.java
  61. 27
      zc-business/src/main/java/com/zc/business/utils/diff/algorithm/nulls/DefaultNullComparator.java
  62. 25
      zc-business/src/main/java/com/zc/business/utils/diff/algorithm/nulls/NullComparator.java
  63. 128
      zc-business/src/main/java/com/zc/business/utils/diff/algorithm/object/AbstractObject.java
  64. 30
      zc-business/src/main/java/com/zc/business/utils/diff/algorithm/object/LeftJoinObjectComparator.java
  65. 40
      zc-business/src/main/java/com/zc/business/utils/diff/algorithm/object/ObjectComparator.java
  66. 33
      zc-business/src/main/java/com/zc/business/utils/diff/algorithm/object/SimpleObjectComparator.java
  67. 38
      zc-business/src/main/java/com/zc/business/utils/diff/algorithm/other/DefaultOtherComparator.java
  68. 24
      zc-business/src/main/java/com/zc/business/utils/diff/algorithm/other/OtherComparator.java
  69. 39
      zc-business/src/main/java/com/zc/business/utils/diff/algorithm/primitive/DefaultPrimitiveComparator.java
  70. 23
      zc-business/src/main/java/com/zc/business/utils/diff/algorithm/primitive/PrimitiveComparator.java
  71. 20
      zc-business/src/main/java/com/zc/business/utils/diff/model/Constants.java
  72. 61
      zc-business/src/main/java/com/zc/business/utils/diff/model/DiffContext.java
  73. 122
      zc-business/src/main/java/com/zc/business/utils/diff/model/PathModule.java
  74. 71
      zc-business/src/main/java/com/zc/business/utils/diff/model/Result.java
  75. 66
      zc-business/src/main/java/com/zc/business/utils/diff/model/ResultConvertUtil.java
  76. 69
      zc-business/src/main/java/com/zc/business/utils/diff/model/SingleNodeDifference.java
  77. 21
      zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml
  78. 13
      zc-business/src/main/resources/mapper/business/DcEmployeesMapper.xml
  79. 106
      zc-business/src/main/resources/mapper/business/DcEventImportantFileMapper.xml
  80. 121
      zc-business/src/main/resources/mapper/business/DcEventImportantMapper.xml
  81. 1194
      zc-business/src/main/resources/mapper/business/DcEventMapper.xml
  82. 43
      zc-business/src/main/resources/mapper/business/DcEventProcessMapper.xml
  83. 73
      zc-business/src/main/resources/mapper/business/DcWarningMapper.xml
  84. 37
      zc-business/src/main/resources/mapper/business/EventPlanAssocMapper.xml
  85. BIN
      zc-business/src/main/resources/wordTemplate/importantTemplate.docx

12
ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java

@ -8,6 +8,7 @@ import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Calendar;
import java.util.Date;
import org.apache.commons.lang3.time.DateFormatUtils;
@ -184,4 +185,15 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
return Date.from(zdt.toInstant());
}
/**
* 获取当前时间,time分钟后的时间
*/
public static Date getObtainDateAfter(int time){
Date now = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(now);
calendar.add(Calendar.MINUTE, time);
Date fiveMinutesLater = calendar.getTime();
return fiveMinutesLater;
}
}

12
zc-business/pom.xml

@ -71,6 +71,18 @@
<artifactId>poi-tl</artifactId>
<version>1.9.1</version>
</dependency>
<!-- aliyun-java-sdk-core -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.6.3</version>
</dependency>
<!-- aliyun-java-sdk-dysmsapi -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>2.2.1</version>
</dependency>
</dependencies>
<groupId>com.zc</groupId>

18
zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java

@ -19,6 +19,7 @@ import com.zc.common.core.httpclient.exception.HttpException;
import com.zc.common.core.httpclient.request.RequestParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.v3.oas.annotations.Parameter;
import okhttp3.Response;
import org.springframework.beans.factory.annotation.Value;
@ -574,4 +575,21 @@ public class DcDeviceController extends BaseController {
return JSON.parseObject(response.body().string(), AjaxResult.class);
}
/**
* @Description 查询上游10公里内的情报板
*
* @author liuwenge
* @date 2024/4/15 14:22
* @param stakeMark
* @param direction
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@ApiOperation("查询上游10公里内的情报板")
@PostMapping("/selectNearBoard")
public AjaxResult selectNearBoard(@ApiParam(value="桩号", name="stakeMark", required=true) @RequestParam ("stakeMark") String stakeMark,
@ApiParam(value="方向", name="direction", required=true) @RequestParam ("direction") String direction){
return dcDeviceService.selectNearBoard(stakeMark,direction);
}
}

15
zc-business/src/main/java/com/zc/business/controller/DcEmergencyPlansController.java

@ -63,13 +63,14 @@ public class DcEmergencyPlansController extends BaseController {
public AjaxResult listByEventType(@RequestBody DcEvent dcEvent) {
List<DcEmergencyPlans> dcEmergencyPlansList = dcEmergencyPlansService.selectDcEmergencyPlansByEventType(dcEvent);
dcEmergencyPlansService.dispositionDeviceContent(dcEmergencyPlansList,dcEvent);
return AjaxResult.success(dcEmergencyPlansList);
}
/**
* 感知事件-根据事件数据查询事件预案列表
*/
@ApiOperation("感知事件-根据事件数据查询事件预案列表")
// @ApiOperation("感知事件-根据事件数据查询事件预案列表")
@PreAuthorize("@ss.hasPermi('business:plans:list')")
@PostMapping("/list/warning/type")
public AjaxResult listByEventType(@RequestBody DcWarning dcWarning) {
@ -91,7 +92,7 @@ public class DcEmergencyPlansController extends BaseController {
/**
* 感知事件-情报板确认回显原始模板
*/
@ApiOperation("感知事件-情报板确认回显原始模板")
// @ApiOperation("感知事件-情报板确认回显原始模板")
@PreAuthorize("@ss.hasPermi('business:plans:list')")
@PostMapping("/warning/board/confirm")
public AjaxResult warningBoardConfirm(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
@ -101,7 +102,7 @@ public class DcEmergencyPlansController extends BaseController {
/**
* 感知事件-情报板自动生成文字
*/
@ApiOperation("感知事件-情报板自动生成文字")
// @ApiOperation("感知事件-情报板自动生成文字")
@PostMapping("/warning/automatic")
public AjaxResult warningAutomaticGeneration(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
return AjaxResult.success(dcEmergencyPlansService.warningAutomaticGeneration(dcEventAnDcEmergencyPlans));
@ -110,7 +111,7 @@ public class DcEmergencyPlansController extends BaseController {
/**
* 交通事件-情报板自动生成文字
*/
@ApiOperation("交通事件-情报板自动生成文字")
// @ApiOperation("交通事件-情报板自动生成文字")
@PostMapping("/event/automatic")
public AjaxResult eventAutomaticGeneration(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
return AjaxResult.success(dcEmergencyPlansService.eventAutomaticGeneration(dcEventAnDcEmergencyPlans));
@ -138,7 +139,7 @@ public class DcEmergencyPlansController extends BaseController {
/**
* 感知事件确定
*/
@ApiOperation("感知事件确认")
// @ApiOperation("感知事件确认")
@PreAuthorize("@ss.hasPermi('business:plans:edit')")
@PostMapping("/warning/confirm")
public AjaxResult warningConfirm(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
@ -149,7 +150,7 @@ public class DcEmergencyPlansController extends BaseController {
* 新增事件预案
*/
@ApiOperation("新增预案")
// @PreAuthorize("@ss.hasPermi('business:plans:add')")
@PreAuthorize("@ss.hasPermi('business:plans:add')")
@PostMapping
public AjaxResult add(@RequestBody DcEmergencyPlans dcEmergencyPlans) {
return toAjax(dcEmergencyPlansService.insertDcEmergencyPlans(dcEmergencyPlans));
@ -159,7 +160,7 @@ public class DcEmergencyPlansController extends BaseController {
* 修改事件预案
*/
@ApiOperation("修改预案")
// @PreAuthorize("@ss.hasPermi('business:plans:edit')")
@PreAuthorize("@ss.hasPermi('business:plans:edit')")
@PutMapping
public AjaxResult update(@RequestBody DcEmergencyPlans dcEmergencyPlans) {
return toAjax(dcEmergencyPlansService.updateDcEmergencyPlans(dcEmergencyPlans));

56
zc-business/src/main/java/com/zc/business/controller/DcEventController.java

@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletResponse;
import com.zc.business.domain.DcEvent;
import com.zc.business.service.IDcEventService;
import com.zc.common.core.websocket.WebSocketService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -94,6 +95,7 @@ public class DcEventController extends BaseController
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id)
{
DcEvent dcEvent = dcEventService.selectDcEventById(id);
return AjaxResult.success(dcEvent);
}
@ -122,10 +124,8 @@ public class DcEventController extends BaseController
//@PreAuthorize("@ss.hasPermi('system:event:add')")
@Log(title = "事件信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DcEvent dcEvent)
{
return toAjax(dcEventService.insertDcEvent(dcEvent));
}
@ -161,5 +161,57 @@ public class DcEventController extends BaseController
return map;
}
@ApiOperation("根据事件id修改事件状态")
// @PreAuthorize("@ss.hasPermi('system:event:edit')")
@Log(title = "事件信息", businessType = BusinessType.UPDATE)
@PutMapping("/dcEventState/{id}/{state}")
public AjaxResult dcEventState(@PathVariable("id") String id,@PathVariable("state") int state)
{
return toAjax(dcEventService.updateDcEventState(id,state));
}
/**
* @Description 查询事件流程状态
*
* @author liuwenge
* @date 2024/4/11 11:19
* @param eventId 事件id
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@ApiOperation("查询事件流程状态")
@GetMapping( "/getProcessNode/{eventId}")
public AjaxResult getProcessNode(@ApiParam(name = "eventId", value = "事件id", required = true) @PathVariable("eventId") String eventId){
return dcEventService.getProcessNode(eventId);
}
/**
* @Description 解除事件
*
* @author liuwenge
* @date 2024/4/11 14:12
* @param eventId
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@ApiOperation("解除事件")
@PostMapping("/completeEvent")
public AjaxResult completeEvent(String eventId){
return dcEventService.completeEvent(eventId);
}
/**
* @Description 解除事件
*
* @author liuwenge
* @date 2024/4/11 14:12
* @param eventId
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@ApiOperation("无需清障")
@PostMapping("/skipClear")
public AjaxResult skipClear(String eventId){
return dcEventService.skipClear(eventId);
}
}

98
zc-business/src/main/java/com/zc/business/controller/DcEventImportantController.java

@ -0,0 +1,98 @@
package com.zc.business.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.zc.business.domain.DcEventImportant;
import com.zc.business.service.IDcEventImportantService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 事件侧重要素Controller
*
* @author ruoyi
* @date 2024-04-11
*/
@RestController
@RequestMapping("/business/eventImportant")
public class DcEventImportantController extends BaseController
{
@Autowired
private IDcEventImportantService dcEventImportantService;
/**
* 查询事件侧重要素列表
*/
@GetMapping("/list")
public TableDataInfo list(DcEventImportant dcEventImportant)
{
startPage();
List<DcEventImportant> list = dcEventImportantService.selectDcEventImportantList(dcEventImportant);
return getDataTable(list);
}
/**
* 导出事件侧重要素列表
*/
@Log(title = "事件侧重要素", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DcEventImportant dcEventImportant)
{
List<DcEventImportant> list = dcEventImportantService.selectDcEventImportantList(dcEventImportant);
ExcelUtil<DcEventImportant> util = new ExcelUtil<>(DcEventImportant.class);
util.exportExcel(response, list, "事件侧重要素数据");
}
/**
* 获取事件侧重要素详细信息
*/
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id)
{
return AjaxResult.success(dcEventImportantService.selectDcEventImportantByEventId(id));
}
/**
* 新增事件侧重要素
*/
@Log(title = "事件侧重要素", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DcEventImportant dcEventImportant)
{
return toAjax(dcEventImportantService.insertDcEventImportant(dcEventImportant));
}
/**
* 修改事件侧重要素
*/
@Log(title = "事件侧重要素", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DcEventImportant dcEventImportant)
{
return toAjax(dcEventImportantService.updateDcEventImportant(dcEventImportant));
}
/**
* 删除事件侧重要素
*/
@Log(title = "事件侧重要素", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(dcEventImportantService.deleteDcEventImportantByEventIds(ids));
}
}

174
zc-business/src/main/java/com/zc/business/controller/DcEventImportantFileController.java

@ -0,0 +1,174 @@
package com.zc.business.controller;
import java.io.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.zc.business.utils.PoiUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
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.zc.business.domain.DcEventImportantFile;
import com.zc.business.service.IDcEventImportantFileService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 重要事件文件内容Controller
*
* @author ruoyi
* @date 2024-04-12
*/
@Api(tags = "重要事件文件内容")
@RestController
@RequestMapping("/business/eventImportantFile")
public class DcEventImportantFileController extends BaseController
{
@Autowired
private IDcEventImportantFileService dcEventImportantFileService;
/**
* 分页查询重要事件文件内容
*/
@ApiOperation("分页查询重要事件文件内容")
@GetMapping("/page")
public TableDataInfo page(DcEventImportantFile dcEventImportantFile)
{
startPage();
List<DcEventImportantFile> list = dcEventImportantFileService.selectDcEventImportantFileList(dcEventImportantFile);
return getDataTable(list);
}
/**
* 无分页查询重要事件文件内容列表
*/
@ApiOperation("无分页查询重要事件文件内容列表")
@GetMapping("/list")
public List<DcEventImportantFile> list(DcEventImportantFile dcEventImportantFile)
{
return dcEventImportantFileService.selectDcEventImportantFileList(dcEventImportantFile);
}
/**
* 导出重要事件文件内容列表
*/
@Log(title = "重要事件文件内容", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DcEventImportantFile dcEventImportantFile)
{
List<DcEventImportantFile> list = dcEventImportantFileService.selectDcEventImportantFileList(dcEventImportantFile);
ExcelUtil<DcEventImportantFile> util = new ExcelUtil<>(DcEventImportantFile.class);
util.exportExcel(response, list, "重要事件文件内容数据");
}
/**
* 下载重要事件文件
*/
@ApiOperation("下载重要事件文件")
@Log(title = "下载重要事件文件", businessType = BusinessType.EXPORT)
@PostMapping("/download")
public void download(HttpServletResponse response, DcEventImportantFile dcEventImportantFile)
{
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("wordTemplate/importantTemplate.docx");
XWPFDocument document = null;
try {
//获取docx解析对象
document = new XWPFDocument(inputStream);
Map<String,Object> textMap = new HashMap<>();
textMap.put("${fromDept}",dcEventImportantFile.getFromDept());
textMap.put("${createTime}",dcEventImportantFile.getCreateTime());
textMap.put("${title}",dcEventImportantFile.getTitle());
textMap.put("${toDept}",dcEventImportantFile.getToDept());
textMap.put("${content}",dcEventImportantFile.getContent());
textMap.put("${createName}",dcEventImportantFile.getCreateName());
textMap.put("${phoneNumber}",dcEventImportantFile.getPhoneNumber());
textMap.put("${issued}",dcEventImportantFile.getIssued());
//解析替换文本段落对象
PoiUtil.changeText(document, textMap);
document.write(response.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
}finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/**
* 获取重要事件文件内容详细信息
*/
@ApiOperation("获取重要事件文件内容详细信息")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id)
{
return AjaxResult.success(dcEventImportantFileService.selectDcEventImportantFileByEventId(id));
}
/**
* 新增重要事件文件内容
*/
@ApiOperation("新增重要事件文件内容")
@Log(title = "重要事件文件内容", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DcEventImportantFile dcEventImportantFile)
{
return toAjax(dcEventImportantFileService.insertDcEventImportantFile(dcEventImportantFile));
}
/**
* 修改重要事件文件内容
*/
@ApiOperation("修改重要事件文件内容")
@Log(title = "重要事件文件内容", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DcEventImportantFile dcEventImportantFile)
{
return toAjax(dcEventImportantFileService.updateDcEventImportantFile(dcEventImportantFile));
}
/**
* 删除重要事件文件内容
*/
@ApiOperation("删除重要事件文件内容")
@Log(title = "重要事件文件内容", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(dcEventImportantFileService.deleteDcEventImportantFileByEventIds(ids));
}
/**
* 获取重要事件状态
*/
@ApiOperation("获取重要事件状态")
@GetMapping("/getImportantFileStatus/{eventId}")
public AjaxResult getImportantFileStatus(@PathVariable("eventId") String eventId){
return dcEventImportantFileService.getImportantFileStatus(eventId);
}
}

20
zc-business/src/main/java/com/zc/business/controller/DcEventProcessController.java

@ -47,9 +47,18 @@ public class DcEventProcessController extends BaseController
* 查询事件处理流程列表
*/
@ApiOperation("查询事件处理流程列表")
// @PreAuthorize("@ss.hasPermi('system:process:list')")
@GetMapping("/list")
public TableDataInfo list(DcEventProcess dcEventProcess)
public List<DcEventProcess> list(DcEventProcess dcEventProcess)
{
return dcEventProcessService.selectDcEventProcessList(dcEventProcess);
}
/**
* 分页查询事件处理流程列表
*/
@ApiOperation("分页查询事件处理流程列表")
@GetMapping("/page")
public TableDataInfo page(DcEventProcess dcEventProcess)
{
startPage();
List<DcEventProcess> list = dcEventProcessService.selectDcEventProcessList(dcEventProcess);
@ -90,12 +99,7 @@ public class DcEventProcessController extends BaseController
// @PreAuthorize("@ss.hasPermi('system:process:add')")
@Log(title = "事件处理流程", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DcEventProcess dcEventProcess) throws IOException, InvalidExtensionException {
//如果有文件传入
if(!dcEventProcess.getFile().isEmpty()){
String address =FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), dcEventProcess.getFile(), MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
dcEventProcess.setContext(address);
}
public AjaxResult add(@RequestBody DcEventProcess dcEventProcess){
return toAjax(dcEventProcessService.insertDcEventProcess(dcEventProcess));
}

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

@ -1,6 +1,9 @@
package com.zc.business.controller;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.zc.business.domain.DcDispatch;
import com.zc.business.domain.DcDispatchResource;
import com.zc.business.domain.DcWarningBatchConvert;
import com.zc.business.service.IDcWarningService;
import com.ruoyi.common.annotation.Log;
@ -10,12 +13,16 @@ import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.zc.business.domain.DcWarning;
import com.zc.business.service.IDeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
@ -29,6 +36,7 @@ import java.util.List;
* @date 2024-01-26
*/
@Api(tags = "感知事件")
@Component
@RestController
@RequestMapping("/business/warning")
public class DcWarningController extends BaseController
@ -36,6 +44,11 @@ public class DcWarningController extends BaseController
@Autowired
private IDcWarningService dcWarningService;
//定时任务,定时结束部分事件
public void updateEndSection(){
IDcWarningService ben = SpringUtils.getBean(IDcWarningService.class);
ben.updateEndSection();
}
/**
* 查询预警信息列表
*/
@ -136,4 +149,23 @@ public class DcWarningController extends BaseController
return dcWarningService.batchConvert(dcWarningBatchConvert);
}
//指挥调度
@PostMapping("/commandAndDispatch")
public AjaxResult commandAndDispatch(@RequestBody DcWarning dcWarning){
if (StringUtils.isBlank(dcWarning.getStakeMark())){
return AjaxResult.error("参数错误");
}
return (dcWarningService.commandAndDispatch(dcWarning));
}
//指挥调度记录新增
@PostMapping("/insertDispatch")
public AjaxResult insertDispatch(@RequestBody DcDispatch dcDispatch){
return AjaxResult.success(dcWarningService.insertDispatch(dcDispatch));
}
//指挥调度资源新增
@PostMapping("/insertSource")
public AjaxResult insertDispatchSource(@RequestBody DcDispatchResource dcDispatchResource){
return toAjax(dcWarningService.insertDispatchSource(dcDispatchResource));
}
}

103
zc-business/src/main/java/com/zc/business/controller/MsmController.java

@ -0,0 +1,103 @@
package com.zc.business.controller;
import com.alibaba.fastjson.JSONArray;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.zc.business.domain.DcWarning;
import com.zc.business.service.IMsmService;
import com.zc.business.utils.HttpUtil;
import org.apache.commons.lang3.StringUtils;
import org.omg.CORBA.INTERNAL;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.lang.reflect.Array;
import java.rmi.MarshalledObject;
import java.util.ArrayList;
import java.util.HashMap;
/**
* 王思祥
* 推送业务
*/
@RestController
@RequestMapping("/business/sms")
public class MsmController extends BaseController {
@Autowired
private IMsmService msmService;
/**
* 短信推送业务,阿里云短信业务
*/
@PostMapping("/push")
public Boolean alibabaCloudSms(@RequestBody HashMap map)
{
String type = map.get("type").toString();
if (map==null|| StringUtils.isBlank(map.get("phone").toString())){
return false;
}
String string = map.get("phone").toString();
return msmService.send(string);
}
//调用微信推送
@PostMapping("/wenXinPush")
public AjaxResult commandAndDispatch(@RequestBody HashMap map){
return AjaxResult.success(msmService.wenXinSend("wx9ee0e3babfd8d2af","de2ecb80b30d63135918ba3ae6ffb711"));
}
//整合推送
@PostMapping("/pushAll")
public AjaxResult pushAll(@RequestBody HashMap map)
{
if (map == null || StringUtils.isBlank(map.get("type").toString())) {
return AjaxResult.error("参数错误");
}
ArrayList<String> array = (ArrayList<String>) map.get("type");
Boolean send = null;
Integer data = null;
String weiXin = "微信推送失败"; // 初始化为成功状态
String message = "短信推送失败"; // 初始化为失败状态
for (String type : array) {
if ("1".equals(type)) { //短信
if (map == null || StringUtils.isBlank(map.get("phone").toString())) {
return AjaxResult.error("手机号为空");
}
String string = map.get("phone").toString();
send = msmService.send(string);
continue;
}
if ("2".equals(type)) { //微信
JSONArray objects = msmService.wenXinSend("wx9ee0e3babfd8d2af", "de2ecb80b30d63135918ba3ae6ffb711");
data = (Integer) objects.get(0);
continue;
}
}
if (send==null){
message=null;
}else if (send){
message = "短信推送成功"; // 如果 send 为 true,则短信推送成功
}
if (data==null){
weiXin=null;
}else if (data==0){
weiXin = "微信推送成功"; // 如果所有 dateValue 都为0,则微信推送成功
}
if (message!=null&&"短信推送成功".equals(message) &&weiXin!=null&&"微信推送成功".equals(weiXin)) {
return AjaxResult.success(message +","+ weiXin);
} else if (message==null&&weiXin!=null&&"微信推送成功".equals(weiXin)){
return AjaxResult.success(weiXin);
}else if (message!=null&&"短信推送成功".equals(message)&&weiXin==null){
return AjaxResult.success(message);
}else if (message!=null&&"短信推送失败".equals(message)&&weiXin==null){
return AjaxResult.error(message);
}else if (message==null&&"微信推送失败".equals(weiXin)){
return AjaxResult.error(weiXin);
}else {
return AjaxResult.error(message +","+ weiXin);
}
}
}

13
zc-business/src/main/java/com/zc/business/controller/VideoController.java

@ -401,7 +401,7 @@ public class VideoController extends BaseController {
public Object nearCamPileNum(@ApiParam(value = "桩号", name = "pileNum", required = true) String pileNum) throws HttpException, IOException {
// 获取济菏运管中心相机信息
JSONObject camInfo = getCamByDept("1301730");
/*JSONObject camInfo = getCamByDept("1301730");
if (!camInfo.containsKey("data")) {
return camInfo;
@ -435,8 +435,17 @@ public class VideoController extends BaseController {
.filter(item -> "1".equals(item.get("camOrientation")) && Integer.parseInt(item.get("distance").toString()) < 2000)
.sorted(comparing(item -> Integer.parseInt(item.get("distance").toString())))
.collect(Collectors.toList());
result.put("downCamera",downCameraList);
result.put("downCamera",downCameraList);*/
Map<String,Object> result = new HashMap<>();
Integer pileNumDistance = pileNumTransformMetre(pileNum);
String startMileage = String.valueOf(pileNumDistance - 2000);
String endMileage = String.valueOf(pileNumDistance + 2000);
List<DcDevice> upCameraList = iDcDeviceService.selectNearCamPile("1",startMileage,endMileage);
List<DcDevice> downCameraList = iDcDeviceService.selectNearCamPile("3",startMileage,endMileage);
result.put("upCamera",upCameraList);
result.put("downCamera",downCameraList);
return AjaxResult.success(result);
}

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

@ -0,0 +1,95 @@
package com.zc.business.controller;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
/**
* @author 王思祥
* @ClassName DcWarningPush 微博推送
*/
public class WeiboAuthUtil {
//1.登录传入重定向的url,用户授权后返回授权的code,2.使用code取得认证权限token 3.调用接口参数
//1.登录获取用户的回调code
private static final String APP_KEY = "你的App Key";
private static final String AUTH_URL = "https://api.weibo.com/oauth2/authorize";
private static final String APP_SECRET = "你的App Secret";
private static final String REDIRECT_URI = "你的回调URL";
//获取授权后的code
public String tokenCode(){
String url="https://api.weibo.com/oauth2/authorize?client_id="+APP_KEY+"&redirect_uri="+AUTH_URL;
String token=null;
try {
URL urlGet = new URL(url); //创建链接
HttpURLConnection http = (HttpURLConnection) urlGet.openConnection();
http.setRequestMethod("GET");
http.setDoInput(true); //打开获取返回数据
http.connect(); //发送链接
InputStream is = http.getInputStream(); //
int size = is.available();
byte[] jsonBytes = new byte[size];
is.read(jsonBytes);
token = new String(jsonBytes, "UTF-8");
System.err.println(token);
JSONObject jsonObject = JSONObject.parseObject(token);
is.close();
return jsonObject.get("code").toString();
}catch (Exception e){
e.printStackTrace();
}
return "";
}
//获取toke
public String token(String code)throws IOException {
HttpClient httpClient = HttpClients.createDefault();
String tokenUrl = REDIRECT_URI + "?client_id=" + APP_KEY
+ "&client_secret=" + APP_SECRET
+ "&grant_type=authorization_code"
+ "&code=" + code
+ "&redirect_uri=" + URLEncoder.encode(REDIRECT_URI, "UTF-8");
HttpGet httpGet = new HttpGet(tokenUrl);
HttpResponse response = httpClient.execute(httpGet);
HttpEntity entity = response.getEntity();
if (entity != null) {
String responseBody = EntityUtils.toString(entity, "UTF-8");
org.json.JSONObject jsonObject = new org.json.JSONObject(responseBody);
return jsonObject.optString("access_token");
}
return null;
}
//执行调用推送api
public static void main(String[] args) throws Exception {
WeiboAuthUtil weiboAuthUtil = new WeiboAuthUtil();
String code = weiboAuthUtil.tokenCode();
String accessToken = weiboAuthUtil.token(code);//认证后的code放入,获取token
// 创建HttpClient实例
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
// 构建请求URL,这里以获取用户信息为例
String url = "https://api.weibo.com/2/users/show.json?access_token=" + accessToken + "&uid=用户UID";
// 创建HttpGet请求
HttpGet httpGet = new HttpGet(url);
// 执行请求并获取响应
try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
HttpEntity entity = response.getEntity();
if (entity != null) {
// 读取响应内容
String responseString = EntityUtils.toString(entity, "UTF-8");
System.out.println(responseString);
}
}
}
}
}

36
zc-business/src/main/java/com/zc/business/domain/DcDispatch.java

@ -52,6 +52,42 @@ private String organizationName;
private Date endTime;
/** 1-人员2-车辆 */
@Excel(name = "1-人员 2-车辆")
private Integer dispatchType;
/** $column.columnComment */
@Excel(name = "资源id", readConverterExp = "$column.readConverterExp()")
private Long resourceId;
/** $column.columnComment */
@Excel(name = "调度记录id", readConverterExp = "$column.readConverterExp()")
private Long dispatchId;
public Integer getDispatchType() {
return dispatchType;
}
public void setDispatchType(Integer dispatchType) {
this.dispatchType = dispatchType;
}
public Long getResourceId() {
return resourceId;
}
public void setResourceId(Long resourceId) {
this.resourceId = resourceId;
}
public Long getDispatchId() {
return dispatchId;
}
public void setDispatchId(Long dispatchId) {
this.dispatchId = dispatchId;
}
public String getOrganizationName() {
return organizationName;
}

79
zc-business/src/main/java/com/zc/business/domain/DcDispatchResource.java

@ -0,0 +1,79 @@
package com.zc.business.domain;
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_dispatch_resource
*
* @author ruoyi
* @date 2024-04-15
*/
public class DcDispatchResource extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 1-人员2-车辆 */
@Excel(name = "1-人员 2-车辆")
private Integer dispatchType;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long resourceId;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long dispatchId;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setDispatchType(Integer dispatchType)
{
this.dispatchType = dispatchType;
}
public Integer getDispatchType()
{
return dispatchType;
}
public void setResourceId(Long resourceId)
{
this.resourceId = resourceId;
}
public Long getResourceId()
{
return resourceId;
}
public void setDispatchId(Long dispatchId)
{
this.dispatchId = dispatchId;
}
public Long getDispatchId()
{
return dispatchId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("dispatchType", getDispatchType())
.append("resourceId", getResourceId())
.append("dispatchId", getDispatchId())
.toString();
}
}

22
zc-business/src/main/java/com/zc/business/domain/DcEmployees.java

@ -49,6 +49,27 @@ public class DcEmployees extends BaseEntity
private String organizationName;
private Long parentId;
//人员类型1为路管人员2为应急人员
@Excel(name = "人员类型 1-路管人员 2-交警人员")
private Long employeesType;
//类型参数
private String type;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Long getEmployeesType() {
return employeesType;
}
public void setEmployeesType(Long employeesType) {
this.employeesType = employeesType;
}
public Long getParentId() {
return parentId;
@ -130,6 +151,7 @@ public class DcEmployees extends BaseEntity
.append("contactNumber", getContactNumber())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("employeesType", getEmployeesType())
.toString();
}
}

8
zc-business/src/main/java/com/zc/business/domain/DcEvent.java

@ -229,6 +229,10 @@ public class DcEvent {
private List<DcProcessConfig> processConfigList;
@ApiModelProperty("事件标题")
private String eventTitle;
@ApiModelProperty("维度")
private String dimension;
@ApiModelProperty("经度")
private String longitude;
/**
* 2014/2/21新增
*/
@ -298,6 +302,6 @@ public class DcEvent {
private String remark;
private String subclass;
@ApiModelProperty("关联管制事件id")
private String linkId;
}

183
zc-business/src/main/java/com/zc/business/domain/DcEventImportant.java

@ -0,0 +1,183 @@
package com.zc.business.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
import java.util.Map;
/**
* @Description 事件侧重要素
*
* @author liuwenge
* @date 2024/4/11 18:28
*/
@ApiModel("事件侧重要素")
public class DcEventImportant
{
@ApiModelProperty(value = "事件id")
private String id;
@ApiModelProperty(value = "事件id")
private String eventId;
@ApiModelProperty(value = "车型及车牌号")
private String plateNumber;
@ApiModelProperty(value = "分流点名称及桩号")
private String diversionPoint;
@ApiModelProperty(value = "目前进度")
private String currentProgress;
@ApiModelProperty(value = "已采取措施")
private String takeSteps;
@ApiModelProperty(value = "是否启动预案")
private Integer planStatus;
@ApiModelProperty(value = "交警是否到达")
private Integer trafficPoliceStatus;
@ApiModelProperty(value = "医疗是否到达")
private Integer medicalStatus;
@ApiModelProperty(value = "消防是否到达")
private Integer fireStatus;
@ApiModelProperty(value = "是否做好情报板提示工作")
private Integer boardStatus;
@ApiModelProperty(value = "是否有危化品泄漏")
private Integer chemicalsStatus;
@ApiModelProperty(value = "预案等级")
private String planLevel;
@ApiModelProperty(value = "危化品名称")
private String chemicalsName;
@ApiModelProperty(value = "危化品泄露程度")
private String leakageLevel;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getEventId() {
return eventId;
}
public void setEventId(String eventId) {
this.eventId = eventId;
}
public String getPlateNumber() {
return plateNumber;
}
public void setPlateNumber(String plateNumber) {
this.plateNumber = plateNumber;
}
public String getDiversionPoint() {
return diversionPoint;
}
public void setDiversionPoint(String diversionPoint) {
this.diversionPoint = diversionPoint;
}
public String getCurrentProgress() {
return currentProgress;
}
public void setCurrentProgress(String currentProgress) {
this.currentProgress = currentProgress;
}
public String getTakeSteps() {
return takeSteps;
}
public void setTakeSteps(String takeSteps) {
this.takeSteps = takeSteps;
}
public Integer getPlanStatus() {
return planStatus;
}
public void setPlanStatus(Integer planStatus) {
this.planStatus = planStatus;
}
public Integer getTrafficPoliceStatus() {
return trafficPoliceStatus;
}
public void setTrafficPoliceStatus(Integer trafficPoliceStatus) {
this.trafficPoliceStatus = trafficPoliceStatus;
}
public Integer getMedicalStatus() {
return medicalStatus;
}
public void setMedicalStatus(Integer medicalStatus) {
this.medicalStatus = medicalStatus;
}
public Integer getFireStatus() {
return fireStatus;
}
public void setFireStatus(Integer fireStatus) {
this.fireStatus = fireStatus;
}
public Integer getBoardStatus() {
return boardStatus;
}
public void setBoardStatus(Integer boardStatus) {
this.boardStatus = boardStatus;
}
public Integer getChemicalsStatus() {
return chemicalsStatus;
}
public void setChemicalsStatus(Integer chemicalsStatus) {
this.chemicalsStatus = chemicalsStatus;
}
public String getPlanLevel() {
return planLevel;
}
public void setPlanLevel(String planLevel) {
this.planLevel = planLevel;
}
public String getChemicalsName() {
return chemicalsName;
}
public void setChemicalsName(String chemicalsName) {
this.chemicalsName = chemicalsName;
}
public String getLeakageLevel() {
return leakageLevel;
}
public void setLeakageLevel(String leakageLevel) {
this.leakageLevel = leakageLevel;
}
}

173
zc-business/src/main/java/com/zc/business/domain/DcEventImportantFile.java

@ -0,0 +1,173 @@
package com.zc.business.domain;
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_event_important_file
*
* @author ruoyi
* @date 2024-04-12
*/
public class DcEventImportantFile
{
private static final long serialVersionUID = 1L;
private Long id;
/** 事件id */
private String eventId;
/** 报送单位 */
@Excel(name = "报送单位")
private String fromDept;
/** 报送时间 */
@Excel(name = "报送时间")
private String createTime;
/** 标题 */
@Excel(name = "标题")
private String title;
/** 发至单位 */
@Excel(name = "发至单位")
private String toDept;
/** 内容 */
@Excel(name = "内容")
private String content;
/** 填报人 */
@Excel(name = "填报人")
private String createName;
/** 联系电话 */
@Excel(name = "联系电话")
private String phoneNumber;
/** 签发人 */
@Excel(name = "签发人")
private String issued;
/** 类型 1:初报,2续报,3终报 */
@Excel(name = "类型 1:初报,2续报,3终报")
private String type;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public void setEventId(String eventId)
{
this.eventId = eventId;
}
public String getEventId()
{
return eventId;
}
public void setFromDept(String fromDept)
{
this.fromDept = fromDept;
}
public String getFromDept()
{
return fromDept;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public void setTitle(String title)
{
this.title = title;
}
public String getTitle()
{
return title;
}
public void setToDept(String toDept)
{
this.toDept = toDept;
}
public String getToDept()
{
return toDept;
}
public void setContent(String content)
{
this.content = content;
}
public String getContent()
{
return content;
}
public void setCreateName(String createName)
{
this.createName = createName;
}
public String getCreateName()
{
return createName;
}
public void setPhoneNumber(String phoneNumber)
{
this.phoneNumber = phoneNumber;
}
public String getPhoneNumber()
{
return phoneNumber;
}
public void setIssued(String issued)
{
this.issued = issued;
}
public String getIssued()
{
return issued;
}
public void setType(String type)
{
this.type = type;
}
public String getType()
{
return type;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("eventId", getEventId())
.append("fromDept", getFromDept())
.append("createTime", getCreateTime())
.append("title", getTitle())
.append("toDept", getToDept())
.append("content", getContent())
.append("createName", getCreateName())
.append("phoneNumber", getPhoneNumber())
.append("issued", getIssued())
.append("type", getType())
.toString();
}
}

39
zc-business/src/main/java/com/zc/business/domain/DcEventProcess.java

@ -47,17 +47,14 @@ public class DcEventProcess
private Integer source;
/** 1-节点
2-信息发布
2-信息发布
3-设备管控
4-文件生成
*/
@ApiModelProperty(value="流程类型")
@Excel(name = "1-节点 2-信息发布 ")
@ApiModelProperty(value="流程类型 1-节点,2-信息发布,3-设备管控,4-文件生成")
@Excel(name = "流程类型")
private Integer processType;
/** $column.columnComment */
@ApiModelProperty("内容")
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String context;
/** $column.columnComment */
@ApiModelProperty("流程ID")
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
@ -68,6 +65,20 @@ public class DcEventProcess
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String processName;
/** $column.columnComment */
@ApiModelProperty("内容")
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String context;
/** $column.type */
@ApiModelProperty("内容类型")
@Excel(name = "${type}", readConverterExp = "$column.readConverterExp()")
private String type;
@ApiModelProperty("上传文件")
private MultipartFile file;
public MultipartFile getFile() {
return file;
}
@ -76,9 +87,6 @@ public class DcEventProcess
this.file = file;
}
@ApiModelProperty("上传文件")
private MultipartFile file;
public void setId(Long id)
{
this.id = id;
@ -161,6 +169,14 @@ public class DcEventProcess
return processName;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -173,6 +189,7 @@ public class DcEventProcess
.append("context", getContext())
.append("processId", getProcessId())
.append("processName", getProcessName())
.append("type", getType())
.toString();
}
}

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

@ -97,4 +97,6 @@ public class DcEventTrafficControl extends BaseEntity
@TableField(exist = false)
private DcFacility dcFacility;
@TableField(exist = false)
private Long[] facilityIds; // 数组存储多个设备ID
}

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

@ -27,7 +27,7 @@ public class DcVehicles extends BaseEntity
private String vehiclePlate;
/** 车辆类型 */
@Excel(name = "车辆类型")
@Excel(name = "车辆类型",readConverterExp = "1=吊车,2=清障车,3=高空作业车,4=水车,5=除雪车")
private Integer vehicleType;
/** 1-可用2-使用中 */

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

@ -98,7 +98,7 @@ public class DcWarning extends BaseEntity
//事件原因
private String eventCause;
//完结时间
@JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
private Date endTime;
//操作员
private String userName;

21
zc-business/src/main/java/com/zc/business/domain/EventPlanAssoc.java

@ -36,16 +36,17 @@ public class EventPlanAssoc {
private Integer emergencyPlansId;
/**
* 执行控制设备 (设备id用逗号隔开)
* 控制类型 1执行此操作 2恢复操作
*/
@ApiModelProperty("执行控制设备")
private String executingControlDevice;
@ApiModelProperty("控制类型")
private Integer operationType;
/**
* 恢复控制设备 (设备id用逗号隔开)
* 控制设备 (设备id用逗号隔开)
*/
@ApiModelProperty("恢复控制设备")
private String recoveredControlDevice;
@ApiModelProperty("控制设备")
private String controlDevice;
@ApiModelProperty("创建时间")
private Date createTime;
@ -56,11 +57,5 @@ public class EventPlanAssoc {
* 执行操作结果
*/
@ApiModelProperty("执行操作结果")
private String executingControlResult;
/**
* 恢复操作结果
*/
@ApiModelProperty("恢复操作结果")
private String recoveredControlResult;
private String controlResult;
}

50
zc-business/src/main/java/com/zc/business/enums/EventSubclassEnum.java

@ -5,28 +5,34 @@ package com.zc.business.enums;
* @author wangjiabao
*/
public enum EventSubclassEnum {
REAR_END_COLLISION("1-1", "追尾","前方发生追尾 注意避让"),
ROLLOVER("1-2", "侧翻","前方发生侧翻 注意避让"),
COLLISION_WITH_GUARDRAIL("1-3", "撞护栏","前方车撞击护栏注意避让"),
NATURAL("1-4", "自然","前方发生自然现象请注意"),
OTHER_ACCIDENTS("1-5", "其他事故","前方发生事故谨慎驾驶"),
VEHICLE_MALFUNCTION("2-1", "车辆故障","前方发生故障注意避让"),
ROAD_CONGESTION("4-1", "道路拥堵","前方道路拥堵"),
OVERPASS_CONGESTION("4-2", "立交拥堵","前方立交拥堵"),
TOLL_STATION_CONGESTION("4-3", "收费站拥堵","前方收费站拥堵"),
SERVICE_AREA_CONGESTION("4-4", "服务区拥堵","前方服务区拥堵"),
PEDESTRIAN("5-1", "行人","有行人穿行请注意"),
NON_MOTOR_VEHICLES("5-2", "非机动车","有非机动车上路请注意"),
MOTORCYCLE("5-3", "摩托车","有摩托车上路请注意"),
OTHER("5-4", "其他","有非法上路车辆"),
SMOKE("6-1", "烟雾","烟雾道路请注意驾驶"),
FALLEN_TREES("6-2", "倒伏树木","有倒伏树木请注意"),
SCATTERED_MATERIALS("6-3", "洒落物","有洒落物请注意"),
ANIMAL("6-4", "动物","有动物请注意"),
OTHER_OBSTACLES("6-5", "其他障碍","有不明障碍请注意"),
CLOSED_OR_SUSPENDED_OPERATIONS("8-1", "封闭、暂停营业","服务区封闭、暂停营业"),
SHUTDOWN_OF_IMPORTANT_FACILITIES("8-2", "重要设施停用","服务区重要设施停用"),
OTHER_ABNORMALITIES_IN_THE_SERVICE_AREA("8-3", "服务区其他异常","服务区设备停用"),
REAR_END_COLLISION("1-1", "追尾","前方*发生追尾 注意避让"),
ROLLOVER("1-2", "侧翻","前方*发生侧翻 注意避让"),
COLLISION_WITH_GUARDRAIL("1-3", "撞护栏","前方*车撞击护栏注意避让"),
NATURAL("1-4", "自然","前方*发生自然现象请注意"),
OTHER_ACCIDENTS("1-5", "其他事故","前方*发生事故谨慎驾驶"),
VEHICLE_MALFUNCTION("2-1", "车辆故障","前方*发生故障注意避让"),
THE_MAIN_LINE_IS_CLOSED_AND_RESTRICTED("3-1", "主线封闭和限行","前方*主线封闭和限行"),
TOLL_BOOTHS_ARE_CLOSED_AND_RESTRICTED("3-2", "收费站封闭和限行","前方*收费站封闭和限行"),
THE_INTERCHANGE_IS_CLOSED_AND_RESTRICTED("3-3", "立交封闭和限行","前方*立交封闭和限行"),
THE_SERVICE_AREA_IS_CLOSED_AND_RESTRICTED("3-4", "服务区封闭和限行","前方*服务区封闭和限行"),
ROAD_CONGESTION("4-1", "道路拥堵","前方*道路拥堵"),
OVERPASS_CONGESTION("4-2", "立交拥堵","前方*立交拥堵"),
TOLL_STATION_CONGESTION("4-3", "收费站拥堵","前方*收费站拥堵"),
SERVICE_AREA_CONGESTION("4-4", "服务区拥堵","前方*服务区拥堵"),
PEDESTRIAN("5-1", "行人","前方*有行人穿行请注意"),
NON_MOTOR_VEHICLES("5-2", "非机动车","前方*有非机动车上路请注意"),
MOTORCYCLE("5-3", "摩托车","前方*有摩托车上路请注意"),
OTHER("5-4", "其他","前方*有非法上路车辆"),
SMOKE("6-1", "烟雾","前方*烟雾道路请注意驾驶"),
FALLEN_TREES("6-2", "倒伏树木","前方*有倒伏树木请注意"),
SCATTERED_MATERIALS("6-3", "洒落物","前方*有洒落物请注意"),
ANIMAL("6-4", "动物","前方*有动物请注意"),
OTHER_OBSTACLES("6-5", "其他障碍","前方*有不明障碍请注意"),
CLOSED_OR_SUSPENDED_OPERATIONS("8-1", "封闭、暂停营业","前方*服务区封闭、暂停营业"),
SHUTDOWN_OF_IMPORTANT_FACILITIES("8-2", "重要设施停用","前方*服务区重要设施停用"),
OTHER_ABNORMALITIES_IN_THE_SERVICE_AREA("8-3", "服务区其他异常","前方*服务区设备停用"),
RAIN("10-1", "雨","雨天请谨慎驾驶"),
SNOW("10-2", "雪","雪天路滑请谨慎驾驶"),
HEAVY_FOG("10-3", "大雾","大雾天气请谨慎驾驶"),

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

@ -22,6 +22,13 @@ public class ValueConverter {
private static final Map<String, String> valueMappingSon = new HashMap<>();
// 静态映射,用于存储转换关系 事件源转换
private static final Map<Integer, Integer> valueMappingSource = new HashMap<>();
// 事件来源名称
private static final Map<String, String> eventSourceName = new HashMap<>();
// 事件类型名称
private static final Map<String, String> eventTypeName = new HashMap<>();
// 事件字段
private static final Map<String, String> eventLabel = new HashMap<>();
static {
valueMappingSource.put(1,5);
valueMappingSource.put(4,7);
@ -87,6 +94,135 @@ public class ValueConverter {
valueMappingSon.put("11-2", "2-1");
valueMappingSon.put("11-3", "2-1");
valueMappingSon.put("99-1", "11-1");
eventSourceName.put("1","96659");
eventSourceName.put("2","交警转接");
eventSourceName.put("3","道路巡查");
eventSourceName.put("4","视频巡查");
eventSourceName.put("5","视频AI");
eventSourceName.put("6","一键救援");
eventSourceName.put("7","其他");
eventTypeName.put("1","交通事故");
eventTypeName.put("2","车辆故障");
eventTypeName.put("3","交通管制");
eventTypeName.put("4","交通拥堵");
eventTypeName.put("5","非法上路");
eventTypeName.put("6","路障清除");
eventTypeName.put("7","施工建设");
eventTypeName.put("8","服务区异常");
eventTypeName.put("9","设施设备隐患");
eventTypeName.put("10","异常天气");
eventTypeName.put("11","其他事件");
eventLabel.put("id","事件编号");
eventLabel.put("deptId","所属部门");
eventLabel.put("stakeMark","桩号");
eventLabel.put("direction","方向");
eventLabel.put("userId","处理人员");
eventLabel.put("startTime","开始时间");
eventLabel.put("endTime","结束时间");
eventLabel.put("estimatedEndTime","预计解除时间");
eventLabel.put("eventLevel","事件等级");
// eventLabel.put("eventType","事件类型");
eventLabel.put("eventCause","事件原因");
eventLabel.put("description","描述");
eventLabel.put("eventState","状态");
eventLabel.put("eventSource","来源");
// eventLabel.put("eventNature","事件性质");
eventLabel.put("eventSourceTips","来源补充说明");
eventLabel.put("occurrenceTime","发生时间");
// eventLabel.put("isPerceived","是否感知事件");
eventLabel.put("lang","影响车道");
eventLabel.put("roadName","高速名称");
eventLabel.put("eventTitle","时间标题");
eventLabel.put("remark","备注");
eventLabel.put("dcEventAbnormalWeather.weatherSituation","天气情况");
eventLabel.put("dcEventAbnormalWeather.emergencyLevel","紧急级别");
eventLabel.put("dcEventAbnormalWeather.endStakeMark","终止桩号");
eventLabel.put("dcEventAbnormalWeather.numericalValue","异常天气数值");
eventLabel.put("dcEventAccident.reporterName","报警人姓名");
eventLabel.put("dcEventAccident.reporterPhoneNumber","报警人电话");
eventLabel.put("dcEventAccident.locationType","地点");
eventLabel.put("dcEventAccident.trafficJam","压车(公里)");
eventLabel.put("dcEventAccident.weatherCondition","天气情况");
eventLabel.put("dcEventAccident.impactLevel","影响");
eventLabel.put("dcEventAccident.isReverseCargo","是否倒货");
eventLabel.put("dcEventAccident.isMaintenance","是否养护事故");
eventLabel.put("dcEventAccident.policeContact","交警电话");
eventLabel.put("dcEventAccident.towingServiceContact","清障电话");
eventLabel.put("dcEventAccident.congestionAhead","前方是否拥堵");
eventLabel.put("dcEventAccident.atIntersection","是否分岔口");
eventLabel.put("dcEventAccident.onCurve","是否处在弯道");
eventLabel.put("dcEventAccident.spillageItem","洒落物名称");
eventLabel.put("dcEventAccident.vehicleOwnerPhone","车主电话");
eventLabel.put("dcEventAccident.smallCar","小型车(辆)");
eventLabel.put("dcEventAccident.trucks","货车(辆)");
eventLabel.put("dcEventAccident.buses","客车(辆)");
eventLabel.put("dcEventAccident.tankers","罐车(辆)");
eventLabel.put("dcEventAccident.minorInjuries","轻伤(人)");
eventLabel.put("dcEventAccident.seriousInjuries","重伤(人)");
eventLabel.put("dcEventAccident.fatalities","死亡(人)");
eventLabel.put("dcEventAccident.isPrivate","私密事件");
eventLabel.put("dcEventAccident.facilityId","设施关联");
eventLabel.put("dcEventAccident.rampId","匝道id");
eventLabel.put("dcEventAccident.location","地点");
eventLabel.put("dcEventConstruction.controlMode","管制方式");
eventLabel.put("dcEventConstruction.locationType","地点类型");
eventLabel.put("dcEventConstruction.specialPlaceDescription","特殊地点描述");
eventLabel.put("dcEventConstruction.specialConstruction","专项施工");
eventLabel.put("dcEventConstruction.otherConstructionName","其他施工名称");
eventLabel.put("dcEventConstruction.constructionMeasurement","施工措施");
eventLabel.put("dcEventConstruction.facilityId","设施id");
eventLabel.put("dcEventConstruction.exitsInlets","出入口");
eventLabel.put("dcEventConstruction.laneOccupancy","占用车道");
eventLabel.put("dcEventConstruction.trafficCondition","通行情况");
eventLabel.put("dcEventConstruction.constructionMethod","施工方式");
eventLabel.put("dcEventConstruction.localRoadName","地方道路名称");
eventLabel.put("dcEventConstruction.endStakeMark","结束桩号");
eventLabel.put("dcEventConstruction.location","地点");
eventLabel.put("dcEventServiceArea.exitsInlets","出入口");
eventLabel.put("dcEventServiceArea.facilityId","服务区");
eventLabel.put("dcEventServiceArea.disableFacility","停用设施");
eventLabel.put("dcEventTrafficCongestion.congestionMileage","拥堵里程(公里)");
eventLabel.put("dcEventTrafficCongestion.maxCongestionMileage","最大拥堵里程(公里)");
eventLabel.put("dcEventTrafficCongestion.congestionCause","拥堵原因");
eventLabel.put("dcEventTrafficCongestion.facilityId","设施id");
eventLabel.put("dcEventTrafficCongestion.rampId","匝道");
eventLabel.put("dcEventTrafficCongestion.location","地点");
eventLabel.put("dcEventTrafficCongestion.detailedReasons","详细原因");
eventLabel.put("dcEventTrafficCongestion.locationType","地点类型");
eventLabel.put("dcEventTrafficCongestion.locationDescription","地点描述");
eventLabel.put("dcEventTrafficCongestion.endStakeMark","终止桩号");
eventLabel.put("dcEventVehicleAccident.reporterName","报警人姓名");
eventLabel.put("dcEventVehicleAccident.reporterPhoneNumber","报警人电话");
eventLabel.put("dcEventVehicleAccident.locationType","地点方式");
eventLabel.put("dcEventVehicleAccident.trafficJam","压车(公里)");
eventLabel.put("dcEventVehicleAccident.weatherCondition","天气情况");
eventLabel.put("dcEventVehicleAccident.congestionAhead","前方是否拥堵");
eventLabel.put("dcEventVehicleAccident.atIntersection","是否分岔口");
eventLabel.put("dcEventVehicleAccident.onCurve","是否处在弯道");
eventLabel.put("dcEventVehicleAccident.smallCar","小型车(辆)");
eventLabel.put("dcEventVehicleAccident.trucks","货车(辆)");
eventLabel.put("dcEventVehicleAccident.buses","客车(辆)");
eventLabel.put("dcEventVehicleAccident.tankers","罐车(辆)");
eventLabel.put("dcEventVehicleAccident.minorInjuries","轻伤(人)");
eventLabel.put("dcEventVehicleAccident.seriousInjuries","重伤(人)");
eventLabel.put("dcEventVehicleAccident.fatalities","死亡(人)");
eventLabel.put("dcEventVehicleAccident.isPrivate","私密事件");
eventLabel.put("dcEventVehicleAccident.facilityId","设施id");
eventLabel.put("dcEventVehicleAccident.rampId","匝道");
eventLabel.put("dcEventVehicleAccident.location","地点");
eventLabel.put("dcEventTrafficControl.controlType","管制分类");
eventLabel.put("dcEventTrafficControl.controlCause","管制原因");
eventLabel.put("dcEventTrafficControl.exitsInlets","出入口");
eventLabel.put("dcEventTrafficControl.facilityId","设施id");
eventLabel.put("dcEventTrafficControl.rampId","匝道");
eventLabel.put("dcEventTrafficControl.causeType","原因类型");
eventLabel.put("dcEventTrafficControl.measure","措施");
eventLabel.put("dcEventTrafficControl.classify","分类");
eventLabel.put("dcEventTrafficControl.limitedType","限制类型");
// eventLabel.put("dcEventTrafficControl.vehicleType","车辆类型");
}
}
@ -100,6 +236,18 @@ public class ValueConverter {
public static Map<Integer, Integer> getValueMappingSource() {
return ValueMappingHolder.valueMappingSource;
}
public static Map<String, String> getEventSourceName() {
return ValueMappingHolder.eventSourceName;
}
public static Map<String, String> getEventTypeName() {
return ValueMappingHolder.eventTypeName;
}
public static Map<String, String> getEventLabel() {
return ValueMappingHolder.eventLabel;
}
/**
* 根据输入值返回转换后的值
* 如果输入值不在映射中则返回输入值本身
@ -118,6 +266,22 @@ public class ValueConverter {
Map<Integer, Integer> mapping = getValueMappingSource();
return mapping.getOrDefault(inputValue, inputValue);
}
public static String eventSourceName(String inputValue) {
Map<String, String> mapping = getEventSourceName();
return mapping.getOrDefault(inputValue, inputValue);
}
public static String eventTypeName(String inputValue) {
Map<String, String> mapping = getEventTypeName();
return mapping.getOrDefault(inputValue, inputValue);
}
public static String eventLabel(String inputValue) {
Map<String, String> mapping = getEventLabel();
return mapping.getOrDefault(inputValue, inputValue);
}
//测试
// @Test
// public void text(){

2
zc-business/src/main/java/com/zc/business/enums/WarningSubclassEnum.java

@ -27,7 +27,7 @@ public enum WarningSubclassEnum {
EMERGENCY_LANE_BLOCKED("4-7", "应急车道被占用", "发生"),
VEHICLE_EXIT_EMERGENCY_LANE("4-8", "车离开应急车道", "发生"),
OTHER_CONDITION("4-9", "其他", "发生停车"),
OTHER_UNKNOWN("4-10", "未知车", "发生停车"),
OTHER_UNKNOWN("4-10", "未知车", "发生停车"),
REVERSING_OR_GOING_BACKWARDS("5-1", "倒车/逆行", "发生"),
LINEBALL("5-2", "压线", "发生压线"),
TURNROUND("5-3", "掉头", "发生掉头"),

4
zc-business/src/main/java/com/zc/business/mapper/DcDeviceMapper.java

@ -3,8 +3,10 @@ package com.zc.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zc.business.domain.DcDevice;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 设备Mapper接口
@ -18,5 +20,7 @@ public interface DcDeviceMapper extends BaseMapper<DcDevice> {
List<DcDevice> numberOfDevicesByType(DcDevice dcDevice);
List<DcDevice> numberOfDevicesByType();
List<DcDevice> selectNearCamPile(@Param("direction") String direction,@Param("startMileage") String startMileage,@Param("endMileage") String endMileage);
List<DcDevice> selectNearBoard(@Param("direction") String direction,@Param("startMileage") Integer startMileage,@Param("endMileage") Integer endMileage);
}

71
zc-business/src/main/java/com/zc/business/mapper/DcEventImportantFileMapper.java

@ -0,0 +1,71 @@
package com.zc.business.mapper;
import java.util.List;
import com.ruoyi.common.core.domain.AjaxResult;
import com.zc.business.domain.DcEventImportantFile;
/**
* 重要事件文件内容Mapper接口
*
* @author ruoyi
* @date 2024-04-12
*/
public interface DcEventImportantFileMapper
{
/**
* 查询重要事件文件内容
*
* @param id 重要事件文件内容主键
* @return 重要事件文件内容
*/
public DcEventImportantFile selectDcEventImportantFileByEventId(String id);
/**
* 查询重要事件文件内容列表
*
* @param dcEventImportantFile 重要事件文件内容
* @return 重要事件文件内容集合
*/
List<DcEventImportantFile> selectDcEventImportantFileList(DcEventImportantFile dcEventImportantFile);
/**
* 新增重要事件文件内容
*
* @param dcEventImportantFile 重要事件文件内容
* @return 结果
*/
int insertDcEventImportantFile(DcEventImportantFile dcEventImportantFile);
/**
* 修改重要事件文件内容
*
* @param dcEventImportantFile 重要事件文件内容
* @return 结果
*/
int updateDcEventImportantFile(DcEventImportantFile dcEventImportantFile);
/**
* 删除重要事件文件内容
*
* @param id 重要事件文件内容主键
* @return 结果
*/
int deleteDcEventImportantFileByEventId(String id);
/**
* 批量删除重要事件文件内容
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
int deleteDcEventImportantFileByEventIds(String[] ids);
/**
* 获取重要事件状态
*
* @param eventId 事件id
* @return 结果
*/
int getImportantFileStatus(String eventId);
}

61
zc-business/src/main/java/com/zc/business/mapper/DcEventImportantMapper.java

@ -0,0 +1,61 @@
package com.zc.business.mapper;
import java.util.List;
import com.zc.business.domain.DcEventImportant;
/**
* 事件侧重要素Mapper接口
*
* @author ruoyi
* @date 2024-04-11
*/
public interface DcEventImportantMapper
{
/**
* 查询事件侧重要素
*
* @param id 事件侧重要素主键
* @return 事件侧重要素
*/
public DcEventImportant selectDcEventImportantByEventId(String id);
/**
* 查询事件侧重要素列表
*
* @param dcEventImportant 事件侧重要素
* @return 事件侧重要素集合
*/
List<DcEventImportant> selectDcEventImportantList(DcEventImportant dcEventImportant);
/**
* 新增事件侧重要素
*
* @param dcEventImportant 事件侧重要素
* @return 结果
*/
int insertDcEventImportant(DcEventImportant dcEventImportant);
/**
* 修改事件侧重要素
*
* @param dcEventImportant 事件侧重要素
* @return 结果
*/
int updateDcEventImportant(DcEventImportant dcEventImportant);
/**
* 删除事件侧重要素
*
* @param id 事件侧重要素主键
* @return 结果
*/
int deleteDcEventImportantByEventId(String id);
/**
* 批量删除事件侧重要素
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
int deleteDcEventImportantByEventIds(String[] ids);
}

32
zc-business/src/main/java/com/zc/business/mapper/DcEventMapper.java

@ -4,7 +4,9 @@ package com.zc.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zc.business.domain.DcEvent;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -50,6 +52,15 @@ public interface DcEventMapper extends BaseMapper<DcEvent>
*/
int updateDcEvent(DcEvent dcEvent);
/**
* 修改事件性质 关联管制事件id
*
* @param dcEvent 事件信息
* @return 结果
*/
int updateDcEventLinkId(DcEvent dcEvent);
/**
* 删除事件信息
*
@ -83,6 +94,27 @@ public interface DcEventMapper extends BaseMapper<DcEvent>
*/
boolean batchInsertDcEvent(List<DcEvent> eventList);
int updateDcEventState(@Param("id") String id,@Param("state") int state);
/**
* @Description 查询事件流程状态
*
* @author liuwenge
* @date 2024/4/11 11:19
* @param eventId 事件id
* @return com.ruoyi.common.core.domain.AjaxResult
*/
List<Map<String,Object>> getProcessNode(@Param("eventId") String eventId);
/**
* @Description 解除事件
*
* @author liuwenge
* @date 2024/4/11 14:15
* @param eventId
* @return boolean
*/
boolean completeEvent(@Param("eventId") String eventId);
}

10
zc-business/src/main/java/com/zc/business/mapper/DcEventProcessMapper.java

@ -35,6 +35,14 @@ public interface DcEventProcessMapper
*/
int insertDcEventProcess(DcEventProcess dcEventProcess);
/**
* 批量新增事件处理流程
*
* @param dcEventProcessList 事件处理流程
* @return 结果
*/
boolean batchInsertDcEventProcess(List<DcEventProcess> dcEventProcessList);
/**
* 修改事件处理流程
*
@ -65,4 +73,6 @@ public interface DcEventProcessMapper
* @return
*/
List<DcEventProcess> selectDcDispatchByEventId(String id);
int selectFinalNode(String eventId);
}

26
zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java

@ -1,12 +1,17 @@
package com.zc.business.mapper;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import cn.hutool.core.lang.hash.Hash;
import com.zc.business.domain.DcDispatch;
import com.zc.business.domain.DcDispatchResource;
import com.zc.business.domain.DcRoadSection;
import com.zc.business.domain.DcWaringStrategy;
import com.zc.business.domain.DcWarning;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.core.parameters.P;
/**
* 预警信息Mapper接口
@ -83,5 +88,24 @@ public interface DcWarningMapper
public List<DcWaringStrategy> selectDcWaringStrategyList(@Param("warningSource")String warningSource,@Param
("warningType")String warningType,@Param("warningSubclass")String warningSubclass,@Param("strategy")Integer strategy);
//修改配置
public Integer updateOtherConfig(@Param("id")String id,@Param("otherConfig")String otherConfig);
public Integer updateOtherConfig(@Param("id")String id,@Param("otherConfig")String otherConfig,@Param("endTime") Date endTime );
//定时结束部分事件
public Integer updateEndSection(@Param("dcWarningList") List<DcWarning> dcWarningList);
//查询当天全部可以结束的事件
public List<DcWarning> selectEndSection();
//依据桩号返回驻点id
public Long selectSectionId(@Param("stakeMark")String stakeMark,@Param("direction")String direction);
//依据桩号获取最近距离的驻点
public List<HashMap<String,Object>> selectRecentlySection();
//查询某个机构的全部应急人员信息
public List<HashMap<String,Object>> selectOrganizationEmployees(@Param("organizationId")Long organizationId);
//查询某个机构当天的值班信息
public List<HashMap<String,Object>> selectShifts(@Param("station") Long station);
//查询某个机构的车辆信息
public List<HashMap<String,Object>> selectVehicles(@Param("organizationId")Long organizationId);
//新增调度资源信息
public Integer insertDispatchResource(DcDispatchResource dcDispatchResource);
//新增调度记录信息
public Integer insertDcDispatch(DcDispatch dcDispatch);
}

19
zc-business/src/main/java/com/zc/business/service/DcEmergencyPlansService.java

@ -1,6 +1,6 @@
package com.zc.business.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zc.business.domain.*;
import java.util.List;
@ -39,6 +39,11 @@ public interface DcEmergencyPlansService {
*/
List<DcEmergencyPlans> selectDcEmergencyPlansByEventType(DcEvent event);
/**
* 处置设备智能发布的内容
*/
void dispositionDeviceContent(List<DcEmergencyPlans> list, DcEvent dcEvent);
/**
* 感知事件-根据事件类型查询事件预案
*
@ -63,7 +68,7 @@ public interface DcEmergencyPlansService {
* @param dcEventAnDcEmergencyPlans 事件数据 事件预案数据
* @return 结果
*/
JSONArray executionEventConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans);
JSONObject executionEventConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans);
/**
* 根据事件id-查询预案事件关联表
@ -79,7 +84,7 @@ public interface DcEmergencyPlansService {
* @param dcEventAnDcEmergencyPlans 事件数据 事件预案数据
* @return 结果
*/
JSONArray executionWarningConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans);
JSONObject executionWarningConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans);
/**
* 感知事件-情报板自动生成
@ -111,14 +116,6 @@ public interface DcEmergencyPlansService {
*/
int updateDcEmergencyPlans(DcEmergencyPlans dcEmergencyPlans);
/**
* 批量修改事件预案
*
* @param dcEmergencyPlansList 事件预案
* @return 结果
*/
int updateBatchDcEmergencyPlans(List<DcEmergencyPlans> dcEmergencyPlansList);
/**
* 批量删除事件预案
*

8
zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java

@ -2,6 +2,7 @@ package com.zc.business.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.zc.business.domain.DcDevice;
import com.zc.business.domain.DcStakeMark;
@ -81,4 +82,11 @@ public interface IDcDeviceService extends IService<DcDevice> {
List<DcDevice> numberOfDevicesByType(DcDevice dcDevice);
List<DcDevice> numberOfDevicesByType();
List<DcDevice> selectNearCamPile(String direction,String startMileage,String endMileage);
/**
* 查询上游10公里内的情报板
*/
AjaxResult selectNearBoard(String stakeMark, String direction);
}

71
zc-business/src/main/java/com/zc/business/service/IDcEventImportantFileService.java

@ -0,0 +1,71 @@
package com.zc.business.service;
import java.util.List;
import com.ruoyi.common.core.domain.AjaxResult;
import com.zc.business.domain.DcEventImportantFile;
/**
* 重要事件文件内容Service接口
*
* @author ruoyi
* @date 2024-04-12
*/
public interface IDcEventImportantFileService
{
/**
* 查询重要事件文件内容
*
* @param id 重要事件文件内容主键
* @return 重要事件文件内容
*/
public DcEventImportantFile selectDcEventImportantFileByEventId(String id);
/**
* 查询重要事件文件内容列表
*
* @param dcEventImportantFile 重要事件文件内容
* @return 重要事件文件内容集合
*/
List<DcEventImportantFile> selectDcEventImportantFileList(DcEventImportantFile dcEventImportantFile);
/**
* 新增重要事件文件内容
*
* @param dcEventImportantFile 重要事件文件内容
* @return 结果
*/
int insertDcEventImportantFile(DcEventImportantFile dcEventImportantFile);
/**
* 修改重要事件文件内容
*
* @param dcEventImportantFile 重要事件文件内容
* @return 结果
*/
int updateDcEventImportantFile(DcEventImportantFile dcEventImportantFile);
/**
* 批量删除重要事件文件内容
*
* @param ids 需要删除的重要事件文件内容主键集合
* @return 结果
*/
int deleteDcEventImportantFileByEventIds(String[] ids);
/**
* 删除重要事件文件内容信息
*
* @param id 重要事件文件内容主键
* @return 结果
*/
int deleteDcEventImportantFileByEventId(String id);
/**
* 获取重要事件状态
*
* @param eventId 事件id
* @return 结果
*/
AjaxResult getImportantFileStatus(String eventId);
}

61
zc-business/src/main/java/com/zc/business/service/IDcEventImportantService.java

@ -0,0 +1,61 @@
package com.zc.business.service;
import java.util.List;
import com.zc.business.domain.DcEventImportant;
/**
* 事件侧重要素Service接口
*
* @author ruoyi
* @date 2024-04-11
*/
public interface IDcEventImportantService
{
/**
* 查询事件侧重要素
*
* @param id 事件侧重要素主键
* @return 事件侧重要素
*/
public DcEventImportant selectDcEventImportantByEventId(String id);
/**
* 查询事件侧重要素列表
*
* @param dcEventImportant 事件侧重要素
* @return 事件侧重要素集合
*/
List<DcEventImportant> selectDcEventImportantList(DcEventImportant dcEventImportant);
/**
* 新增事件侧重要素
*
* @param dcEventImportant 事件侧重要素
* @return 结果
*/
int insertDcEventImportant(DcEventImportant dcEventImportant);
/**
* 修改事件侧重要素
*
* @param dcEventImportant 事件侧重要素
* @return 结果
*/
int updateDcEventImportant(DcEventImportant dcEventImportant);
/**
* 批量删除事件侧重要素
*
* @param ids 需要删除的事件侧重要素主键集合
* @return 结果
*/
int deleteDcEventImportantByEventIds(String[] ids);
/**
* 删除事件侧重要素信息
*
* @param id 事件侧重要素主键
* @return 结果
*/
int deleteDcEventImportantByEventId(String id);
}

11
zc-business/src/main/java/com/zc/business/service/IDcEventProcessService.java

@ -1,6 +1,9 @@
package com.zc.business.service;
import java.io.IOException;
import java.util.List;
import com.ruoyi.common.exception.file.InvalidExtensionException;
import com.zc.business.domain.DcEventProcess;
/**
@ -35,6 +38,14 @@ public interface IDcEventProcessService
*/
int insertDcEventProcess(DcEventProcess dcEventProcess);
/**
* 批量新增事件处理流程
*
* @param dcEventProcessList 事件处理流程
* @return 结果
*/
boolean batchInsertDcEventProcess(List<DcEventProcess> dcEventProcessList);
/**
* 修改事件处理流程
*

38
zc-business/src/main/java/com/zc/business/service/IDcEventService.java

@ -1,6 +1,7 @@
package com.zc.business.service;
import com.ruoyi.common.core.domain.AjaxResult;
import com.zc.business.domain.DcEvent;
import java.util.List;
@ -57,6 +58,11 @@ public interface IDcEventService
*/
public int updateDcEvent(DcEvent dcEvent);
/**
* @param dcEvent
* @return int
*/
/**
* 批量删除事件信息
*
@ -89,4 +95,36 @@ public interface IDcEventService
Map<String,Object> selectCount();
List<DcEvent> eventPileNumberQueryEvent(Map<String, Object> parameter);
int updateDcEventState(String id, int state);
/**
* @Description 查询事件流程状态
*
* @author liuwenge
* @date 2024/4/11 11:19
* @param eventId 事件id
* @return com.ruoyi.common.core.domain.AjaxResult
*/
AjaxResult getProcessNode(String eventId);
/**
* @Description 解除事件
*
* @author liuwenge
* @date 2024/4/11 14:13
* @param eventId
* @return com.ruoyi.common.core.domain.AjaxResult
*/
AjaxResult completeEvent(String eventId);
/**
* @Description 无需清障
*
* @author liuwenge
* @date 2024/4/11 14:13
* @param eventId
* @return com.ruoyi.common.core.domain.AjaxResult
*/
AjaxResult skipClear(String eventId);
}

11
zc-business/src/main/java/com/zc/business/service/IDcWarningService.java

@ -4,8 +4,11 @@ import java.util.HashMap;
import java.util.List;
import com.ruoyi.common.core.domain.AjaxResult;
import com.zc.business.domain.DcDispatch;
import com.zc.business.domain.DcDispatchResource;
import com.zc.business.domain.DcWarning;
import com.zc.business.domain.DcWarningBatchConvert;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestBody;
/**
@ -81,4 +84,12 @@ public interface IDcWarningService
*/
AjaxResult batchConvert(DcWarningBatchConvert dcWarningBatchConvert);
//定时结束部分事件
Integer updateEndSection();
//指挥调度
AjaxResult commandAndDispatch(DcWarning dcWarning);
//新增指挥调度资源记录
public DcDispatch insertDispatch(DcDispatch dcDispatch);
//新增指挥调度资源记录
public Integer insertDispatchSource(DcDispatchResource dcDispatchResource);
}

21
zc-business/src/main/java/com/zc/business/service/IMsmService.java

@ -0,0 +1,21 @@
package com.zc.business.service;
import com.alibaba.fastjson.JSONArray;
import com.ruoyi.common.core.domain.AjaxResult;
public interface IMsmService {
/**
* 发送短信
*
* @param phone 手机号
* @return
*/
public boolean send(String phone);
/**
* 微信推送
*
* @return
*/
JSONArray wenXinSend(String appId, String appSecret);
}

32
zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java

@ -3,9 +3,11 @@ package com.zc.business.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.StakeMarkUtils;
import com.zc.business.constant.RedisKeyConstants;
import com.zc.business.domain.DcDevice;
import com.zc.business.domain.DcProduct;
@ -467,5 +469,35 @@ public class DcDeviceServiceImpl extends ServiceImpl<DcDeviceMapper, DcDevice> i
}
return null;
}
@Override
public List<DcDevice> selectNearCamPile(String direction,String startMileage,String endMileage){
return dcDeviceMapper.selectNearCamPile(direction,startMileage,endMileage);
}
/**
* @Description 获取事发地上游10公里内的情报板
*
* @author liuwenge
* @date 2024/4/15 14:18
* @param stakeMark 桩号
* @param direction 方向
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@Override
public AjaxResult selectNearBoard(String stakeMark, String direction){
Integer mileage = Integer.valueOf(StakeMarkUtils.formatMetre(stakeMark));
List<DcDevice> boardList = new ArrayList<>();
if ("1".equals(direction)){
Integer start = mileage - 10000;
boardList = dcDeviceMapper.selectNearBoard(direction,start,mileage);
} else if ("3".equals(direction)){
Integer end = mileage + 10000;
boardList = dcDeviceMapper.selectNearBoard(direction,mileage,end);
}
return AjaxResult.success(boardList);
}
}

331
zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java

@ -9,6 +9,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.zc.business.constant.DeviceFunctionIdConstants;
import com.zc.business.constant.DeviceTypeConstants;
import com.zc.business.controller.BroadcastController;
@ -20,6 +21,7 @@ import com.zc.business.mapper.EventPlanAssocMapper;
import com.zc.business.service.DcEmergencyPlansService;
import com.zc.business.service.DcExecuteActionService;
import com.zc.business.service.IDcDeviceService;
import com.zc.business.service.IDcFacilityService;
import com.zc.common.core.httpclient.exception.HttpException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@ -50,6 +52,9 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
@Resource
private EventPlanAssocMapper eventPlanAssocMapper;
@Resource
private IDcFacilityService dcFacilityService;
@Resource
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
@ -110,8 +115,6 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
return dcEmergencyPlansList.stream()
.filter(dcEmergencyPlans -> {
String triggerMechanism = dcEmergencyPlans.getTriggerMechanism();
// JSONObject triggerJson = JSONObject.parseObject(triggerMechanism);
// String eventSubclass = triggerJson.get("eventSubclass").toString();
return triggerMechanism.equals(event.getSubclass());
})
.collect(Collectors.toList());
@ -120,8 +123,6 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
return dcEmergencyPlansList.stream()
.filter(dcEmergencyPlans -> {
String triggerMechanism = dcEmergencyPlans.getTriggerMechanism();
// JSONObject triggerJson = JSONObject.parseObject(triggerMechanism);
// String locationType = triggerJson.get("locationType").toString();
DcEventVehicleAccident dcEventVehicleAccident = event.getDcEventVehicleAccident();
String eventLocationType = dcEventVehicleAccident.getLocationType().toString();
return triggerMechanism.equals(eventLocationType);
@ -132,9 +133,6 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
return dcEmergencyPlansList.stream()
.filter(dcEmergencyPlans -> {
String triggerMechanism = dcEmergencyPlans.getTriggerMechanism();
// JSONObject triggerJson = JSONObject.parseObject(triggerMechanism);
// 分类
// Integer classify = Integer.parseInt(triggerJson.get("classify").toString());
// 事件--交通管制数据
DcEventTrafficControl dcEventTrafficControl = event.getDcEventTrafficControl();
Integer eventClassify = Integer.parseInt(dcEventTrafficControl.getClassify().toString());
@ -148,6 +146,110 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
}
/**
* 处置设备智能发布的内容
*/
@Override
public void dispositionDeviceContent(List<DcEmergencyPlans> list, DcEvent dcEvent) {
// 事件桩号
dcEvent.setStakeMark(dcEvent.getStakeMark().replace("K", ""));
String[] markArray = dcEvent.getStakeMark().split("\\+");
if (markArray[1].length() < 3) {
// 不足三位 补零
markArray[1] = String.format("%0" + 3 + "d", markArray[1]);
}
// 情报板 语音广播
list.forEach(dcEmergencyPlans -> {
List<DcExecuteAction> dcExecuteActions = dcEmergencyPlans.getDcExecuteAction();
dcExecuteActions.forEach(dcExecuteAction -> {
JSONObject executeConfig = JSON.parseObject(dcExecuteAction.getExecuteConfig());
if (dcExecuteAction.getDeviceType() == DeviceTypeEnum.ROAD_SECTION_VOICE_BROADCASTING.getCode()
&& executeConfig.get("operationType").equals("2")) {
// 执行操作中智能发布语音广播
String content = intelligentPublishingOfInformation(dcEvent);
updateIntelligentPublishingContent(dcExecuteAction,markArray,dcEvent,content,dcEvent.getDirection());
} else if (dcExecuteAction.getDeviceType() == DeviceTypeEnum.VARIABLE_INFORMATION_FLAG.getCode()
&& executeConfig.get("operationType").equals("2")) {
// 执行操作中智能发布情报板
String content = intelligentPublishingOfInformation(dcEvent);
updateIntelligentPublishingContent(dcExecuteAction,markArray,dcEvent,content,dcEvent.getDirection());
}
});
});
}
/**
* 更改智能发布中的发布内容-计算公里数
*/
public void updateIntelligentPublishingContent(DcExecuteAction dcExecuteAction,
String[] markArray,
DcEvent dcEvent,
String content,
String direction) {
List<DcDevice> deviceList = ruleFiltering(dcExecuteAction, markArray, dcEvent.getDirection());
JSONObject executeConfig = JSON.parseObject(dcExecuteAction.getExecuteConfig());
List<Map<String,Object>> contentList = new ArrayList<>();
deviceList.forEach(dcDevice -> {
Map<String,Object> map = new HashMap<>();
map.put("dcDeviceId",dcDevice.getId());
map.put("deviceName",dcDevice.getDeviceName());
// 公里数
int kilometers = 0;
// 米数
int meters = 0;
dcDevice.setStakeMark(dcDevice.getStakeMark().replace("K", ""));
String[] deviceMarkArray = dcDevice.getStakeMark().split("\\+");
if (deviceMarkArray[1].length() < 3) {
// 不足三位 补零
deviceMarkArray[1] = String.format("%0" + 3 + "d", deviceMarkArray[1]);
}
if (direction.equals("菏泽方向") || direction.equals("1")) {
kilometers = Math.abs(Integer.parseInt(markArray[0]) - Integer.parseInt(deviceMarkArray[0]));
meters = Integer.parseInt(markArray[1]) - Integer.parseInt(deviceMarkArray[1]);
}else {
kilometers = Math.abs(Integer.parseInt(deviceMarkArray[0]) - Integer.parseInt(markArray[0]));
meters = Integer.parseInt(deviceMarkArray[1]) - Integer.parseInt(markArray[1]);
}
double roundedDistance = Math.round((kilometers + meters / 1000.0) * 10.0) / 10.0;
if (roundedDistance < 1) {
map.put("content",content.replace("*",(int) (roundedDistance * 1000)+"米"));
}else {
if (roundedDistance % 1 == 0) {
// 去除掉1.0公里的情况
map.put("content",content.replace("*",(int)roundedDistance+"公里"));
}else {
map.put("content",content.replace("*",roundedDistance+"公里"));
}
}
if (dcExecuteAction.getDeviceType() == DeviceTypeEnum.VARIABLE_INFORMATION_FLAG.getCode()) {
// 情报板
// stopTime
map.put("stopTime", "50");
// inScreenMode
map.put("inScreenMode", "1");
// fontSpacing
map.put("fontSpacing", "0");
// fontColor
map.put("fontColor", "ffff00");
// fontType
map.put("fontType", "1");
// fontSize
map.put("fontSize", "36");
// screenSize 768*64 宽度和高度
map.put("screenSize", "768*64");
// formatStyle
map.put("formatStyle", "2");
}
contentList.add(map);
});
executeConfig.put("contentList",contentList);
dcExecuteAction.setExecuteConfig(executeConfig.toJSONString());
}
/**
* 感知事件 - 根据事件类型查询事件预案
*
@ -196,8 +298,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
markArray[1] = String.format("%0" + 3 + "d", markArray[1]);
}
DcExecuteAction executeAction = dcEventAnDcEmergencyPlans.getDcEmergencyPlans().getExecuteAction();
Integer operationType = dcEventAnDcEmergencyPlans.getOperationType();
List<DcDevice> dcDevices = ruleFiltering(executeAction, markArray, direction, operationType);
List<DcDevice> dcDevices = ruleFiltering(executeAction, markArray, direction);
return getBoardTemplate(dcDevices);
}
@ -218,8 +319,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
markArray[1] = String.format("%0" + 3 + "d", markArray[1]);
}
DcExecuteAction executeAction = dcEventAnDcEmergencyPlans.getDcEmergencyPlans().getExecuteAction();
Integer operationType = dcEventAnDcEmergencyPlans.getOperationType();
List<DcDevice> dcDevices = ruleFiltering(executeAction, markArray, direction, operationType);
List<DcDevice> dcDevices = ruleFiltering(executeAction, markArray, direction);
return getBoardTemplate(dcDevices);
}
@ -289,12 +389,9 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
* @param direction
* @return
*/
public List<DcDevice> ruleFiltering(DcExecuteAction dcExecuteAction, String[] markArray, String direction, Integer operationType) {
public List<DcDevice> ruleFiltering(DcExecuteAction dcExecuteAction, String[] markArray, String direction) {
Integer searchRule = dcExecuteAction.getSearchRule();
// 区分执行操作还是恢复操作
JSONObject otherConfig = operationType.equals(1)?
JSON.parseObject(dcExecuteAction.getExecuteConfig()): JSON.parseObject(dcExecuteAction.getRecoverConfig());
List<String> start = new ArrayList<>();
List<String> end = new ArrayList<>();
// 设备列表
@ -306,13 +403,13 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
// 指定设备资源
// 根据设备id,获取设备集合
LambdaQueryWrapper<DcDevice> queryWrapper = new LambdaQueryWrapper<>();
List<String> deviceList = (List<String>) otherConfig.get("deviceList");
String[] deviceList = dcExecuteAction.getDeviceList().split(",");
queryWrapper.in(DcDevice::getIotDeviceId, deviceList);
dcDevices = dcDeviceService.list(queryWrapper);
} else if (searchRule.equals(2)) {
// 事件上游最近
if (direction.equals("菏泽方向")) {
if (direction.equals("菏泽方向") || direction.equals("1")) {
// 上行 取最大的几个
start.add("55");
start.add("379");
@ -351,8 +448,8 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
}
} else if (searchRule.equals(3)) {
// 事件下游最近
if (direction.equals("菏泽方向")) {
// 事件下游最近 没有这个类型
if (direction.equals("菏泽方向") || direction.equals("1")) {
// 上行 取最大的几个
start.add(markArray[0]);
start.add(markArray[1]);
@ -406,8 +503,29 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
// 根据桩号范围,查询附近设备
dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameter);
}
return dcDevices;
//将0公里和负数的设备去掉
return dcDevices.stream()
.filter(device -> {
device.setStakeMark(device.getStakeMark().replace("K", ""));
String[] deviceMarkArray = device.getStakeMark().split("\\+");
if (deviceMarkArray[1].length() < 3) {
deviceMarkArray[1] = String.format("%0" + 3 + "d", deviceMarkArray[1]);
}
int kilometers = 0;
int meters = 0;
if (direction.equals("菏泽方向") || direction.equals("1")) {
// 菏泽方向 桩号增大 设备桩号要小于事件桩号
kilometers = Integer.parseInt(markArray[0]) - Integer.parseInt(deviceMarkArray[0]);
meters = Integer.parseInt(markArray[1]) - Integer.parseInt(deviceMarkArray[1]);
}else {
// 济南方向 桩号减小 设备桩号要大于事件桩号
kilometers = Integer.parseInt(deviceMarkArray[0]) - Integer.parseInt(markArray[0]);
meters = Integer.parseInt(deviceMarkArray[1]) - Integer.parseInt(markArray[1]);
}
double roundedDistance = Math.round((kilometers + meters / 1000.0) * 10.0) / 10.0;
return kilometers >= 0 && roundedDistance > 0;
})
.collect(Collectors.toList());
}
@ -418,7 +536,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
* @return 结果
*/
@Override
public JSONArray executionEventConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
public JSONObject executionEventConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
// 获取事件数据
DcEvent dcEvent = dcEventAnDcEmergencyPlans.getDcEvent();
// 方向
@ -478,8 +596,17 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
@Override
public DcInfoBoardTemplate eventAutomaticGeneration(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
// 根据交通事件的事件类型,生成相应的情报板内容
DcEvent dcEvent = dcEventAnDcEmergencyPlans.getDcEvent();
DcInfoBoardTemplate dcInfoBoardTemplate = dcEventAnDcEmergencyPlans.getDcInfoBoardTemplate();
DcEvent dcEvent = dcEventAnDcEmergencyPlans.getDcEvent();
dcInfoBoardTemplate.setContent(intelligentPublishingOfInformation(dcEvent));
return dcInfoBoardTemplate;
}
/**
* 智能发布信息匹配
*/
public String intelligentPublishingOfInformation(DcEvent dcEvent) {
String content = "请注意前方危险";
int eventType = Integer.parseInt(dcEvent.getEventType().toString());
if (eventType == EventTypeEnum.ABNORMAL_WEATHER.getCode() ||
eventType == EventTypeEnum.TRAFFIC_ACCIDENT.getCode() ||
@ -488,42 +615,41 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
eventType == EventTypeEnum.SERVICE_AREA_ABNORMALITY.getCode() ||
eventType == EventTypeEnum.ROADBLOCK_CLEARANCE.getCode()) {
String content = Arrays.stream(EventSubclassEnum.values())
content = Arrays.stream(EventSubclassEnum.values())
.filter(eventSubclassEnum -> eventSubclassEnum.getCode().equals(dcEvent.getSubclass()))
.findFirst()
.map(EventSubclassEnum::getText)
.orElse("请注意前方危险");
dcInfoBoardTemplate.setContent(content);
} else if (eventType == EventTypeEnum.VEHICLE_MALFUNCTION.getCode()) {
// 车辆故障
DcEventVehicleAccident dcEventVehicleAccident = dcEvent.getDcEventVehicleAccident();
int locationType = Integer.parseInt(dcEventVehicleAccident.getLocationType().toString());
// 路广设施id
Integer facilityId = dcEventVehicleAccident.getFacilityId();
DcFacility facility = dcFacilityService.getFacility(facilityId.toString());
String facilityName = facility.getFacilityName();
if (locationType == 1) {
dcInfoBoardTemplate.setContent("高速主线发生车辆故障");
} else if (locationType == 2) {
dcInfoBoardTemplate.setContent("服务区发生车辆故障");
} else if (locationType == 3) {
dcInfoBoardTemplate.setContent("立交桥发生车辆故障");
} else if (locationType == 4) {
dcInfoBoardTemplate.setContent("收费站发生车辆故障");
content = "前方*高速主线发生车辆故障";
} else if (locationType == 2 || locationType == 3 || locationType == 4) {
// 服务区、立交、收费站
content = "前方*"+facilityName+"发生车辆故障";
}
} else if (eventType == EventTypeEnum.TRAFFIC_CONTROL.getCode()) {
// 交通管制
DcEventTrafficControl dcEventTrafficControl = dcEvent.getDcEventTrafficControl();
int classify = Integer.parseInt(dcEventTrafficControl.getClassify().toString());
String content = Arrays.stream(ClassifyEnum.values())
content = Arrays.stream(ClassifyEnum.values())
.filter(eventSubclassEnum -> eventSubclassEnum.getCode() == classify)
.findFirst()
.map(ClassifyEnum::getText)
.orElse("前方存在限行或关闭");
dcInfoBoardTemplate.setContent(content);
.orElse("前方*存在限行或关闭");
} else {
// 施工建设
dcInfoBoardTemplate.setContent("前方施工请注意驾驶");
content = "前方*施工请注意驾驶";
}
return dcInfoBoardTemplate;
return content;
}
/**
@ -533,7 +659,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
* @return
*/
@Override
public JSONArray executionWarningConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
public JSONObject executionWarningConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
// 获取事件数据
DcWarning dcWarning = dcEventAnDcEmergencyPlans.getDcWarning();
@ -550,7 +676,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
* @param dcEventAnDcEmergencyPlans 事件数据 事件预案数据
* @return
*/
public JSONArray executionConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans,
public JSONObject executionConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans,
String stakeMark,
String direction,
String id) {
@ -574,7 +700,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
//获取事件预案中的操作配置
dcEmergencyPlans.getDcExecuteAction()
.forEach(dcExecuteAction -> {
List<DcDevice> dcDevices = ruleFiltering(dcExecuteAction, markArray, direction, operationType);
List<DcDevice> dcDevices = ruleFiltering(dcExecuteAction, markArray, direction);
JSONObject otherConfig = operationType.equals(1)?
JSON.parseObject(dcExecuteAction.getExecuteConfig()): JSON.parseObject(dcExecuteAction.getRecoverConfig());
try {
@ -600,32 +726,32 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
});
// 创建一个 预案事件关联对象
EventPlanAssoc eventPlanAssoc = new EventPlanAssoc();
JSONObject resultObject = new JSONObject();
// 事件编号
eventPlanAssoc.setEventId(id);
eventPlanAssoc.setOperationType(dcEventAnDcEmergencyPlans.getOperationType());
EventPlanAssoc selectEventPlanAssoc = eventPlanAssocMapper.selectByEventId(eventPlanAssoc);
// 区分是执行操作 还是 恢复操作
if (dcEventAnDcEmergencyPlans.getOperationType().equals(1) && StringUtils.isEmpty(selectEventPlanAssoc.getId())) {
// 首次执行操作
if (selectEventPlanAssoc == null) {
// 执行新增
eventPlanAssoc.setEmergencyPlansId(dcEmergencyPlans.getId());
eventPlanAssoc.setExecutingControlDevice(deviceIds.toString().replaceFirst(";", ""));
eventPlanAssoc.setExecutingControlResult(resultArray.toJSONString());
eventPlanAssoc.setControlDevice(deviceIds.toString().replaceFirst(";", ""));
eventPlanAssoc.setControlResult(resultArray.toJSONString());
eventPlanAssoc.setCreateTime(DateUtils.getNowDate());
// IdUtils.fastSimpleUUID()
eventPlanAssoc.setId(IdUtils.fastSimpleUUID());
eventPlanAssocMapper.insertEventPlanAssoc(eventPlanAssoc);
}
else if (StringUtils.isNotEmpty(selectEventPlanAssoc.getId()) && dcEventAnDcEmergencyPlans.getOperationType().equals(1)) {
// 多次执行操作
selectEventPlanAssoc.setExecutingControlResult(resultArray.toJSONString());
resultObject.put("eventPlanAssocId",eventPlanAssoc.getId());
}else {
// 执行修改操作
selectEventPlanAssoc.setUpdateTime(DateUtils.getNowDate());
selectEventPlanAssoc.setControlDevice(deviceIds.toString().replaceFirst(";", ""));
selectEventPlanAssoc.setControlResult(resultArray.toJSONString());
eventPlanAssocMapper.updateEventPlanAssoc(selectEventPlanAssoc);
resultObject.put("eventPlanAssocId",selectEventPlanAssoc.getId());
}
else {
// 恢复操作 未执行的事件不能进行恢复操作
selectEventPlanAssoc.setUpdateTime(DateUtils.getNowDate());
selectEventPlanAssoc.setRecoveredControlDevice(deviceIds.toString().replaceFirst(";", ""));
selectEventPlanAssoc.setRecoveredControlResult(resultArray.toJSONString());
eventPlanAssocMapper.updateEventPlanAssoc(selectEventPlanAssoc);
}
return resultArray;
resultObject.put("deviceOperationResult",resultArray);
return resultObject;
}
/**
@ -635,7 +761,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
List<DcDevice> dcDevices,
JSONObject otherConfig,
JSONArray resultArray) {
CountDownLatch latch = new CountDownLatch(dcDevices.size());
for (DcDevice device : dcDevices) {
@ -653,18 +779,24 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
props.put("onWorkStatus", otherConfig.get("state").toString());
props.put("inWorkStatus", otherConfig.get("state").toString());
props.put("mode", controlModel);
JSONObject result = new JSONObject();
if (controlModel.equals("01")) {
String startTime = otherConfig.get("startTime").toString();
String endTime = otherConfig.get("endTime").toString();
props.put("mode", "01");
props.put("startDisplayTime", startTime);
props.put("endDisplayTime", endTime);
}
result.put("content","时间自动");
} else if (controlModel.equals("00")) {
result.put("content","手动");
}else {
result.put("content","万年历");
}
AjaxResult ajaxResult = dcDeviceController.invokedFunction(iotDeviceId, functionId, props);
// 将调用结果存入到 resultArray(操作结果) 中
JSONObject result = new JSONObject();
result.put("device", device.getId());
result.put("deviceName",device.getDeviceName());
result.put("result", ajaxResult);
resultArray.add(result);
@ -673,19 +805,40 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
else if (device.getDeviceType().equals(DeviceTypeConstants.VARIABLE_INFORMATION_FLAG.toString())) {
if (operationType == 1) {
// 情报板发布全流程
boardReleaseProcess(props, iotDeviceId, otherConfig, device, resultArray);
if (otherConfig.get("operationType").equals("2")) {
JSONArray contentList = JSON.parseArray(otherConfig.get("contentList").toString());
JSONObject foundContent = contentList.stream()
.map(content -> JSON.parseObject(content.toString()))
.filter(jsonObject ->
Integer.parseInt(jsonObject.get("dcDeviceId").toString()) == device.getId())
.findFirst()
.orElse(null);
if (foundContent == null) {
// 说明没有匹配到设备
JSONObject errorResult = new JSONObject();
errorResult.put("device",device.getId());
errorResult.put("errorMessage","未匹配到对应的模板内容");
resultArray.add(errorResult);
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("dcInfoBoardTemplate",foundContent);
boardReleaseProcess(props, iotDeviceId, jsonObject, device, resultArray);
}else {
boardReleaseProcess(props, iotDeviceId, otherConfig, device, resultArray);
}
} else {
// 恢复操作
if (otherConfig.get("operationType").equals("2")) {
// 还原上次
props.put("fileId", "10");
functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_1B;
AjaxResult ajaxResult1B;
ajaxResult1B = dcDeviceController.invokedFunction(iotDeviceId, functionId, props);
AjaxResult ajaxResult1B = dcDeviceController.invokedFunction(iotDeviceId, functionId, props);
JSONObject result = new JSONObject();
result.put("device", device.getId());
result.put("deviceName",device.getDeviceName());
result.put("content","还原上次");
result.put("result", ajaxResult1B);
resultArray.add(result);
}else {
@ -702,7 +855,27 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
params.put("name", "task-event");
params.put("outVVol", "8");
params.put("priority", "1");
params.put("text", otherConfig.get("content"));
if (otherConfig.get("operationType").equals("2")) {
// 智能发布
JSONArray contentList = JSON.parseArray(otherConfig.get("contentList").toString());
JSONObject foundContent = contentList.stream()
.map(content -> JSON.parseObject(content.toString()))
.filter(jsonObject ->
Integer.parseInt(jsonObject.get("dcDeviceId").toString()) == device.getId())
.findFirst()
.orElse(null);
if (foundContent == null) {
// 说明没有匹配到设备
JSONObject errorResult = new JSONObject();
errorResult.put("device",device.getId());
errorResult.put("deviceName",device.getDeviceName());
errorResult.put("errorMessage","未匹配到对应的广播内容");
resultArray.add(errorResult);
}
params.put("text", foundContent.get("content"));
}else {
params.put("text", otherConfig.get("content"));
}
params.put("repeatTimes", "3");
params.put("functionType", "startPaTts");
JSONArray termList = new JSONArray();
@ -712,6 +885,8 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
JSONObject returnResult = broadcastController.nearCamListDistance(params);
JSONObject result = new JSONObject();
result.put("device", device.getId());
result.put("deviceName",device.getDeviceName());
result.put("content",params.get("text"));
result.put("result", returnResult);
resultArray.add(result);
@ -724,6 +899,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
AjaxResult ajaxResultState = dcDeviceController.invokedFunction(iotDeviceId, functionId, new HashMap<>());
JSONObject result = new JSONObject();
result.put("device", device.getId());
result.put("deviceName",device.getDeviceName());
result.put("result", ajaxResultState);
resultArray.add(result);
@ -736,6 +912,8 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
AjaxResult ajaxResult = dcDeviceController.invokedFunction(iotDeviceId, functionId, propsTime);
JSONObject resultTime = new JSONObject();
resultTime.put("device", device.getId());
resultTime.put("deviceName",device.getDeviceName());
resultTime.put("content","操作时长"+otherConfig.get("operationDuration"));
resultTime.put("result", ajaxResult);
resultArray.add(resultTime);
@ -743,10 +921,18 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
} catch (HttpException | IOException e) {
log.error(e.toString());
throw new RuntimeException(e);
} finally {
latch.countDown(); // 确保在异常情况下也能减少CountDownLatch计数
}
});
}
try {
latch.await(); // 等待所有线程执行完毕
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
/**
@ -765,8 +951,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_11;
props.put("fileName", "play011.lst");
props.put("size", "65535");
AjaxResult ajaxResult11;
ajaxResult11 = dcDeviceController.invokedFunction(iotDeviceId, functionId, props);
AjaxResult ajaxResult11 = dcDeviceController.invokedFunction(iotDeviceId, functionId, props);
if (ajaxResult11.get("code").equals(200)) {
// 2:执行13功能码
HashMap<String, Object> props11 = new HashMap<>();
@ -797,8 +982,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
parameters.put("formatStyle", dcInfoBoardTemplate.getFormatStyle());
list.add(parameters);
props11.put("parameters", list);
AjaxResult ajaxResult13 = null;
ajaxResult13 = dcDeviceController.invokedFunction(iotDeviceId, functionId, props11);
AjaxResult ajaxResult13 = dcDeviceController.invokedFunction(iotDeviceId, functionId, props11);
JSONObject result = new JSONObject();
if (ajaxResult13.get("code").equals(200)) {
HashMap<String, Object> props1B = new HashMap<>();
@ -807,11 +991,15 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
props1B.put("fileId", "11");
AjaxResult ajaxResult1B = dcDeviceController.invokedFunction(iotDeviceId, functionId, props1B);
result.put("device", device.getId());
result.put("deviceName",device.getDeviceName());
result.put("content",dcInfoBoardTemplate.getContent());
result.put("result", ajaxResult1B);
resultArray.add(result);
} else {
result.put("device", device.getId());
result.put("deviceName",device.getDeviceName());
result.put("content","发布失败");
result.put("result", ajaxResult13);
resultArray.add(result);
}
@ -889,11 +1077,6 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
return dcExecuteActionService.updateDcExecuteActionBatch(dcExecuteActionList);
}
@Override
public int updateBatchDcEmergencyPlans(List<DcEmergencyPlans> dcEmergencyPlansList) {
return 0;
}
/**
* 批量删除事件预案
*

135
zc-business/src/main/java/com/zc/business/service/impl/DcEventImportantFileServiceImpl.java

@ -0,0 +1,135 @@
package com.zc.business.service.impl;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.zc.business.domain.DcEventProcess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zc.business.mapper.DcEventImportantFileMapper;
import com.zc.business.domain.DcEventImportantFile;
import com.zc.business.service.IDcEventImportantFileService;
/**
* 重要事件文件内容Service业务层处理
*
* @author ruoyi
* @date 2024-04-12
*/
@Service
public class DcEventImportantFileServiceImpl implements IDcEventImportantFileService
{
@Autowired
private DcEventImportantFileMapper dcEventImportantFileMapper;
@Autowired
private DcEventProcessServiceImpl dcEventProcessService;
/**
* 查询重要事件文件内容
*
* @param id 重要事件文件内容主键
* @return 重要事件文件内容
*/
@Override
public DcEventImportantFile selectDcEventImportantFileByEventId(String id)
{
return dcEventImportantFileMapper.selectDcEventImportantFileByEventId(id);
}
/**
* 查询重要事件文件内容列表
*
* @param dcEventImportantFile 重要事件文件内容
* @return 重要事件文件内容
*/
@Override
public List<DcEventImportantFile> selectDcEventImportantFileList(DcEventImportantFile dcEventImportantFile)
{
return dcEventImportantFileMapper.selectDcEventImportantFileList(dcEventImportantFile);
}
/**
* 新增重要事件文件内容
*
* @param dcEventImportantFile 重要事件文件内容
* @return 结果
*/
@Override
public int insertDcEventImportantFile(DcEventImportantFile dcEventImportantFile)
{
int i = dcEventImportantFileMapper.insertDcEventImportantFile(dcEventImportantFile);
if (i > 0){
DcEventProcess dcEventProcess = new DcEventProcess();
dcEventProcess.setEventId(dcEventImportantFile.getEventId());
dcEventProcess.setOperationTime(new Date());
dcEventProcess.setOperator(SecurityUtils.getUserId().toString());
dcEventProcess.setSource(1);
dcEventProcess.setProcessType(4);
dcEventProcess.setProcessId(dcEventImportantFile.getId());
String context = "重要事件";
if ("1".equals(dcEventImportantFile.getType())){
context = "重要事件初报";
} else if ("2".equals(dcEventImportantFile.getType())){
context = "重要事件续报";
} else if ("3".equals(dcEventImportantFile.getType())){
context = "重要事件终报";
}
dcEventProcess.setContext(context);
dcEventProcessService.insertDcEventProcess(dcEventProcess);
}
return i;
}
/**
* 修改重要事件文件内容
*
* @param dcEventImportantFile 重要事件文件内容
* @return 结果
*/
@Override
public int updateDcEventImportantFile(DcEventImportantFile dcEventImportantFile)
{
return dcEventImportantFileMapper.updateDcEventImportantFile(dcEventImportantFile);
}
/**
* 批量删除重要事件文件内容
*
* @param ids 需要删除的重要事件文件内容主键
* @return 结果
*/
@Override
public int deleteDcEventImportantFileByEventIds(String[] ids)
{
return dcEventImportantFileMapper.deleteDcEventImportantFileByEventIds(ids);
}
/**
* 删除重要事件文件内容信息
*
* @param id 重要事件文件内容主键
* @return 结果
*/
@Override
public int deleteDcEventImportantFileByEventId(String id)
{
return dcEventImportantFileMapper.deleteDcEventImportantFileByEventId(id);
}
/**
* 获取重要事件状态
*
* @param eventId 事件id
* @return 结果
*/
@Override
public AjaxResult getImportantFileStatus(String eventId){
int num = dcEventImportantFileMapper.getImportantFileStatus(eventId);
return AjaxResult.success(num);
}
}

93
zc-business/src/main/java/com/zc/business/service/impl/DcEventImportantServiceImpl.java

@ -0,0 +1,93 @@
package com.zc.business.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zc.business.mapper.DcEventImportantMapper;
import com.zc.business.domain.DcEventImportant;
import com.zc.business.service.IDcEventImportantService;
/**
* 事件侧重要素Service业务层处理
*
* @author ruoyi
* @date 2024-04-11
*/
@Service
public class DcEventImportantServiceImpl implements IDcEventImportantService
{
@Autowired
private DcEventImportantMapper dcEventImportantMapper;
/**
* 查询事件侧重要素
*
* @param id 事件侧重要素主键
* @return 事件侧重要素
*/
@Override
public DcEventImportant selectDcEventImportantByEventId(String id)
{
return dcEventImportantMapper.selectDcEventImportantByEventId(id);
}
/**
* 查询事件侧重要素列表
*
* @param dcEventImportant 事件侧重要素
* @return 事件侧重要素
*/
@Override
public List<DcEventImportant> selectDcEventImportantList(DcEventImportant dcEventImportant)
{
return dcEventImportantMapper.selectDcEventImportantList(dcEventImportant);
}
/**
* 新增事件侧重要素
*
* @param dcEventImportant 事件侧重要素
* @return 结果
*/
@Override
public int insertDcEventImportant(DcEventImportant dcEventImportant)
{
return dcEventImportantMapper.insertDcEventImportant(dcEventImportant);
}
/**
* 修改事件侧重要素
*
* @param dcEventImportant 事件侧重要素
* @return 结果
*/
@Override
public int updateDcEventImportant(DcEventImportant dcEventImportant)
{
return dcEventImportantMapper.updateDcEventImportant(dcEventImportant);
}
/**
* 批量删除事件侧重要素
*
* @param ids 需要删除的事件侧重要素主键
* @return 结果
*/
@Override
public int deleteDcEventImportantByEventIds(String[] ids)
{
return dcEventImportantMapper.deleteDcEventImportantByEventIds(ids);
}
/**
* 删除事件侧重要素信息
*
* @param id 事件侧重要素主键
* @return 结果
*/
@Override
public int deleteDcEventImportantByEventId(String id)
{
return dcEventImportantMapper.deleteDcEventImportantByEventId(id);
}
}

53
zc-business/src/main/java/com/zc/business/service/impl/DcEventProcessServiceImpl.java

@ -1,6 +1,13 @@
package com.zc.business.service.impl;
import java.io.IOException;
import java.util.List;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.exception.file.InvalidExtensionException;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.common.utils.file.MimeTypeUtils;
import com.zc.business.domain.DcEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zc.business.mapper.DcEventProcessMapper;
@ -18,6 +25,8 @@ public class DcEventProcessServiceImpl implements IDcEventProcessService
{
@Autowired
private DcEventProcessMapper dcEventProcessMapper;
@Autowired
private DcEventServiceImpl dcEventService;
/**
* 查询事件处理流程
@ -52,9 +61,53 @@ public class DcEventProcessServiceImpl implements IDcEventProcessService
@Override
public int insertDcEventProcess(DcEventProcess dcEventProcess)
{
//如果有文件传入
if(!dcEventProcess.getFile().isEmpty()){
try {
String address = FileUploadUtils.upload(RuoYiConfig.getUploadPath(), dcEventProcess.getFile(), MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
dcEventProcess.setContext(address);
String type = address.split("\\.")[1];
dcEventProcess.setType(type);
} catch (IOException | InvalidExtensionException e){
e.printStackTrace();
}
}
//判断是否最后一个节点
if (dcEventProcess.getProcessType() != null && dcEventProcess.getProcessType() == 1){
int finalNode = dcEventProcessMapper.selectFinalNode(dcEventProcess.getEventId());
if (finalNode == dcEventProcess.getProcessId()){
dcEventService.updateDcEventState(dcEventProcess.getEventId(),2);
}
}
return dcEventProcessMapper.insertDcEventProcess(dcEventProcess);
}
/**
* 新增事件处理流程
*
* @param dcEventProcessList 事件处理流程
* @return 结果
*/
@Override
public boolean batchInsertDcEventProcess(List<DcEventProcess> dcEventProcessList)
{
dcEventProcessList.forEach(dcEventProcess -> {
//如果有文件传入
if(!dcEventProcess.getFile().isEmpty()){
try {
String address = FileUploadUtils.upload(RuoYiConfig.getUploadPath(), dcEventProcess.getFile(), MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
dcEventProcess.setContext(address);
String type = address.split("\\.")[1];
dcEventProcess.setType(type);
} catch (IOException | InvalidExtensionException e){
e.printStackTrace();
}
}
});
return dcEventProcessMapper.batchInsertDcEventProcess(dcEventProcessList);
}
/**
* 修改事件处理流程
*

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

@ -1,23 +1,34 @@
package com.zc.business.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.system.service.ISysDeptService;
import com.sun.xml.bind.v2.TODO;
import com.zc.business.domain.*;
import com.zc.business.enums.EventSubclassEnum;
import com.zc.business.enums.ValueConverter;
import com.zc.business.mapper.*;
import com.zc.business.service.IDcEventProcessService;
import com.zc.business.service.IDcEventService;
import com.zc.business.service.IMiddleDatabaseService;
import com.zc.business.utils.diff.Diff;
import com.zc.business.utils.diff.model.Result;
import com.zc.common.core.websocket.WebSocketService;
import org.junit.Test;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -67,8 +78,13 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
//查询路网信息
@Autowired
private DcFacilityServiceImpl dcFacilityService;
//事件处置记录
@Autowired
private IDcEventProcessService dcEventProcessService;
private final String HAPPEN = "发生";
private final String EVENT = "事件";
private final String SUBEVENT = "0";
/**
* 查询事件信息
*
@ -121,6 +137,11 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
*/
@Override
public int insertDcEvent(DcEvent dcEvent) {
String dcEventId =dcEvent.getId();
//获取事件类型
int eventType = Math.toIntExact(dcEvent.getEventType());
@ -131,7 +152,7 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
//获取部门信息
dcEvent.setDeptId(SecurityUtils.getDeptId());
//用户
dcEvent.setUserId(SecurityUtils.getUserId());
dcEvent.setUserId(SecurityUtils.getUserId());
dcEvent.setCreateTime(DateUtils.getNowDate());
@ -170,11 +191,16 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
int i7 = dcEventMapper.insertDcEvent(dcEvent);
if (i7>0 && eventType != 3){
extracted(dcEvent);//事件推送到 首页
}
if (i7 > 0) {
//中间库
MdEvent mdEvent = new MdEvent(dcEvent);
middleDatabaseService.insertMiddleDatabaseEvent(mdEvent);
if (dcEvent.getDcEventTrafficControl().getFacilityIds().length<1 &&dcEventId == null){//非 事件处置 和收费站等多条数据添加
//中间库
MdEvent mdEvent = new MdEvent(dcEvent);
middleDatabaseService.insertMiddleDatabaseEvent(mdEvent);
}
switch (eventType) {
//交通事故
case 1:
@ -196,8 +222,149 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
//交通管制
case 3:
if (dcEvent.getDcEventTrafficControl() != null) {
dcEvent.getDcEventTrafficControl().setId(uuid);
int i6 = dcEventTrafficControlMapper.insertDcEventTrafficControl(dcEvent.getDcEventTrafficControl());
//TODO 插入多个收费站
if (dcEvent.getDcEventTrafficControl().getFacilityIds().length==1){//facilityIds==1 说明只选择了一个收费站
if (dcEventId !=null){//不等于空 事件处置页面 修改
dcEventMapper.deleteDcEventById(uuid);//删除添加的事件主类
DcEvent dcEvent1 = new DcEvent();
dcEvent1.setId(dcEventId);//事件id
dcEvent1.setEventNature(1l);//首发事件
dcEvent1.setLinkId(uuid);//关联管制事件id
dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质
dcEvent.getDcEventTrafficControl().setId(uuid);
dcEvent.getDcEventTrafficControl().setFacilityId(dcEvent.getDcEventTrafficControl().getFacilityIds()[0]);//取出数组字段赋值 设施id
int i6 = dcEventTrafficControlMapper.insertDcEventTrafficControl(dcEvent.getDcEventTrafficControl());//
}else {
//中间库
MdEvent mdEvent = new MdEvent(dcEvent);
middleDatabaseService.insertMiddleDatabaseEvent(mdEvent);
extracted(dcEvent);//事件推送到 首页
dcEvent.getDcEventTrafficControl().setId(uuid);
dcEvent.getDcEventTrafficControl().setFacilityId(dcEvent.getDcEventTrafficControl().getFacilityIds()[0]);//取出数组字段赋值 设施id
int i6 = dcEventTrafficControlMapper.insertDcEventTrafficControl(dcEvent.getDcEventTrafficControl());
}
}else if (dcEvent.getDcEventTrafficControl().getFacilityIds().length>1){//facilityIds1=1 说明只选择了多个收费站
if (dcEventId !=null){//不等于空 事件处置页面 修改
dcEventMapper.deleteDcEventById(uuid);//删除添加的事件主类
DcEvent dcEvent1 = new DcEvent();
dcEvent1.setId(dcEventId);//事件id
dcEvent1.setEventNature(1l);//首发事件
Map<String,String> map = new HashMap<>();
for (int i = 0; i < dcEvent.getDcEventTrafficControl().getFacilityIds().length; i++) { //设置事件Id UUID无下划线格式32
String facilityUUID = IdUtils.fastSimpleUUID();
map.put("facilityId"+i,facilityUUID);//每循环一次生成一个uuid
}
StringBuilder sb2 = new StringBuilder();
// 遍历map,
int a = 0;
for (Map.Entry<String, String> entry : map.entrySet()) {
sb2.append(entry.getValue());
if (dcEvent.getDcEventTrafficControl().getFacilityIds().length-a !=1){
sb2.append(",");
}
a++;
}
String linkId2 = sb2.toString();
dcEvent1.setLinkId(linkId2);//关联管制事件id
dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质
for (int i = 0; i < dcEvent.getDcEventTrafficControl().getFacilityIds().length; i++) {
dcEvent.getDcEventTrafficControl().setId(map.get("facilityId"+i));//交通管制事件id
dcEvent.getDcEventTrafficControl().setFacilityId(dcEvent.getDcEventTrafficControl().getFacilityIds()[i]);//取出数组字段赋值 设施id
// 使用StringBuilder来构建逗号分隔的字符串
//新增第一条数据
dcEvent.setId(map.get("facilityId" + i));
dcEvent.setEventState(0L);
dcEvent.setDeptId(SecurityUtils.getDeptId());
dcEvent.setUserId(SecurityUtils.getUserId());
dcEvent.setCreateTime(DateUtils.getNowDate());
dcEvent.setEventNature(2L);//关联管制
StringBuilder sb = new StringBuilder();
// 遍历map,排除与当前索引i对应的键
for (Map.Entry<String, String> entry : map.entrySet()) {
if (!entry.getKey().equals("facilityId" + i)) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(entry.getValue());
}
}
String linkId = sb.toString();
dcEvent.setLinkId(linkId);
//交通管制
if (eventType == 3 && dcEvent.getDcEventTrafficControl().getFacilityIds()[i] != null) {
String facilityId = String.valueOf(dcEvent.getDcEventTrafficControl().getFacilityIds()[i]);
dcEvent.setStakeMark(extracted(facilityId));
}
dcEventMapper.insertDcEvent(dcEvent);
extracted(dcEvent);
//中间库
MdEvent mdEvent = new MdEvent(dcEvent);
middleDatabaseService.insertMiddleDatabaseEvent(mdEvent);
int i6 = dcEventTrafficControlMapper.insertDcEventTrafficControl(dcEvent.getDcEventTrafficControl());
}
}else {
dcEventMapper.deleteDcEventById(uuid);//删除添加的事件主类
Map<String,String> map = new HashMap<>();
for (int i = 0; i < dcEvent.getDcEventTrafficControl().getFacilityIds().length; i++) { //设置事件Id UUID无下划线格式32
String facilityUUID = IdUtils.fastSimpleUUID();
map.put("facilityId"+i,facilityUUID);//每循环一次生成一个uuid
}
for (int i = 0; i < dcEvent.getDcEventTrafficControl().getFacilityIds().length; i++) {
dcEvent.getDcEventTrafficControl().setId(map.get("facilityId" + i));//交通管制事件id
dcEvent.getDcEventTrafficControl().setFacilityId(dcEvent.getDcEventTrafficControl().getFacilityIds()[i]);//取出数组字段赋值 设施id
//新增第一条数据
dcEvent.setId(map.get("facilityId" + i));
dcEvent.setEventState(0L);
dcEvent.setDeptId(SecurityUtils.getDeptId());
dcEvent.setUserId(SecurityUtils.getUserId());
dcEvent.setCreateTime(DateUtils.getNowDate());
dcEvent.setEventNature(2L);//关联管制
// 使用StringBuilder来构建逗号分隔的字符串
StringBuilder sb = new StringBuilder();
// 遍历map,排除与当前索引i对应的键
for (Map.Entry<String, String> entry : map.entrySet()) {
if (!entry.getKey().equals("facilityId" + i)) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(entry.getValue());
}
}
String linkId = sb.toString();
dcEvent.setLinkId(linkId);
System.out.println(linkId);
//交通管制
if (eventType == 3 && dcEvent.getDcEventTrafficControl().getFacilityIds()[i] != null) {
String facilityId = String.valueOf(dcEvent.getDcEventTrafficControl().getFacilityIds()[i]);
dcEvent.setStakeMark(extracted(facilityId));
}
//中间库
MdEvent mdEvent = new MdEvent(dcEvent);
middleDatabaseService.insertMiddleDatabaseEvent(mdEvent);
dcEventMapper.insertDcEvent(dcEvent);
extracted(dcEvent);
int i6 = dcEventTrafficControlMapper.insertDcEventTrafficControl(dcEvent.getDcEventTrafficControl());
}
}
}
}
break;
//交通拥堵
@ -253,6 +420,28 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
}
}
/**
* 推送 事件信息
* @param dcEvent
*/
private void extracted(DcEvent dcEvent) {
String direction = "";// 方向
String EventSubclass = "";// 事件类型
if (dcEvent.getDirection().equals("1")) {
direction="菏泽方向";
}else {
direction="济南方向";
}
for (EventSubclassEnum eventSubclass : EventSubclassEnum.values()) {
if (eventSubclass.getCode().equals(dcEvent.getEventSubclass())) {
EventSubclass=eventSubclass.getInfo();
break;
}
}
String content= direction+" " + dcEvent.getStakeMark()+" "+HAPPEN+EventSubclass+EVENT ;
WebSocketService.broadcast(SUBEVENT, content); //推送事件消息 0不是感知事件
}
//根据路网设施查询桩号
private String extracted(String facilityId) {
DcFacility facility = dcFacilityService.getFacility(facilityId);
@ -342,6 +531,25 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
break;
}
//事件处置流程记录
DcEventProcess dcEventProcess = new DcEventProcess();
dcEventProcess.setEventId(dcEvent.getId());
dcEventProcess.setOperationTime(new Date());
dcEventProcess.setOperator(SecurityUtils.getUserId().toString());
dcEventProcess.setSource(1);
List<DcProcessConfig> processConfigList = dcProcessConfigMapper.selectDcProcessConfigByEventType(dcEvent.getEventType().intValue());
if (processConfigList != null && processConfigList.size() > 0){
DcProcessConfig dcProcessConfig = processConfigList.get(0);
dcEventProcess.setProcessType(1);
dcEventProcess.setProcessId(Long.valueOf(dcProcessConfig.getNodeNode()));
dcEventProcess.setProcessName(dcProcessConfig.getProcessNode());
}
String sourceName = ValueConverter.eventSourceName(dcEvent.getEventSource().toString());
String typeName = ValueConverter.eventTypeName(dcEvent.getEventType().toString());
dcEventProcess.setContext("由" + sourceName + "上报了一起" + typeName + "事件");
dcEventProcessService.insertDcEventProcess(dcEventProcess);
return i7;
} else {
return -1;
@ -364,6 +572,8 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
if (flag) {
//中间库
List<MdEvent> mdEventList = new ArrayList<>();
List<DcEventProcess> dcEventProcessList = new ArrayList<>();
for (DcEvent dcEvent : dcEventList) {
MdEvent mdEvent = new MdEvent(dcEvent);
mdEventList.add(mdEvent);
@ -433,8 +643,29 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
break;
}
//事件处置流程记录
DcEventProcess dcEventProcess = new DcEventProcess();
dcEventProcess.setEventId(dcEvent.getId());
dcEventProcess.setOperationTime(new Date());
dcEventProcess.setOperator(SecurityUtils.getUserId().toString());
dcEventProcess.setSource(1);
List<DcProcessConfig> processConfigList = dcProcessConfigMapper.selectDcProcessConfigByEventType(dcEvent.getEventType().intValue());
if (processConfigList != null && processConfigList.size() > 0){
DcProcessConfig dcProcessConfig = processConfigList.get(0);
dcEventProcess.setProcessType(1);
dcEventProcess.setProcessId(Long.valueOf(dcProcessConfig.getNodeNode()));
dcEventProcess.setProcessName(dcProcessConfig.getProcessNode());
}
String sourceName = ValueConverter.eventSourceName(dcEvent.getEventSource().toString());
String typeName = ValueConverter.eventTypeName(dcEvent.getEventType().toString());
dcEventProcess.setContext("由" + sourceName + "上报了一起" + typeName + "事件");
dcEventProcessList.add(dcEventProcess);
}
middleDatabaseService.batchInsertMiddleDatabaseEvent(mdEventList);
//批量插入事件流程记录表
dcEventProcessService.batchInsertDcEventProcess(dcEventProcessList);
}
return flag;
@ -448,10 +679,24 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
*/
@Override
public int updateDcEvent(DcEvent dcEvent) {
DcEvent oldEvent = selectEventSubclassById(dcEvent.getEventType().intValue(),dcEvent.getId());
dcEvent.setUpdateTime(DateUtils.getNowDate());
int i7 = dcEventMapper.updateDcEvent(dcEvent);
if (i7 > 0) {
String context = comparisonInfo(oldEvent,dcEvent);
//事件处置流程记录
DcEventProcess dcEventProcess = new DcEventProcess();
dcEventProcess.setEventId(dcEvent.getId());
dcEventProcess.setOperationTime(new Date());
dcEventProcess.setOperator(SecurityUtils.getUserId().toString());
dcEventProcess.setSource(1);
dcEventProcess.setContext(context);
dcEventProcessService.insertDcEventProcess(dcEventProcess);
//中间库
MdEvent mdEvent = new MdEvent(dcEvent);
middleDatabaseService.updateMiddleDatabaseEvent(mdEvent);
@ -511,6 +756,8 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
}
/**
* 批量删除事件信息
*
@ -723,6 +970,33 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
return dcEvents;
}
@Override
public int updateDcEventState(String id, int state) {
int i = dcEventMapper.updateDcEventState(id,state);
if (i > 0){
DcEvent dcEvent = dcEventMapper.selectDcEventById(id);
//事件处置流程记录
DcEventProcess dcEventProcess = new DcEventProcess();
dcEventProcess.setEventId(dcEvent.getId());
dcEventProcess.setOperationTime(new Date());
dcEventProcess.setOperator(SecurityUtils.getUserId().toString());
dcEventProcess.setSource(1);
List<DcProcessConfig> processConfigList = dcProcessConfigMapper.selectDcProcessConfigByEventType(dcEvent.getEventType().intValue());
if (processConfigList != null && processConfigList.size() > 0){
DcProcessConfig dcProcessConfig = processConfigList.get(0);
dcEventProcess.setProcessType(1);
dcEventProcess.setProcessId(Long.valueOf(dcProcessConfig.getNodeNode()));
dcEventProcess.setProcessName(dcProcessConfig.getProcessNode());
}
String sourceName = ValueConverter.eventSourceName(dcEvent.getEventSource().toString());
String typeName = ValueConverter.eventTypeName(dcEvent.getEventType().toString());
dcEventProcess.setContext("由" + sourceName + "上报了一起" + typeName + "事件");
dcEventProcessService.insertDcEventProcess(dcEventProcess);
}
return i;
}
public static <T> List<T> castList(Object obj, Class<T> clazz) {
List<T> result = new ArrayList<T>();
if (obj instanceof List<?>) {
@ -733,4 +1007,462 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
}
return null;
}
/**
* @Description 事件信息比对
*
* @author liuwenge
* @date 2024/4/10 16:24
* @param oldEvent 旧数据
* @param newEvent 新数据
* @return java.lang.String
*/
public String comparisonInfo(DcEvent oldEvent,DcEvent newEvent){
String context = "";
if (oldEvent == null || newEvent == null){
return context;
}
Diff diff = new Diff();
List<Result> diffList = diff.diff(JSON.toJSON(oldEvent).toString(),JSON.toJSON(newEvent).toString());
for (Result result : diffList) {
if ("ADD".equals(result.getDiffType()) || "MODIFY".equals(result.getDiffType())){
if ("startTime".equals(result.getRightPath())
|| "endTime".equals(result.getRightPath())
|| "estimatedEndTime".equals(result.getRightPath())
|| "occurrenceTime".equals(result.getRightPath())){
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date date = new Date();
date.setTime(Long.parseLong(result.getRight().toString()));
result.setRight(df.format(date));;
} catch (Exception e){
e.printStackTrace();
}
} else if ("direction".equals(result.getRightPath())){
if ("1".equals(result.getRight())){
result.setRight("上行");
} else if ("2".equals(result.getRight())){
result.setRight("中");
} else if ("3".equals(result.getRight())){
result.setRight("下行");
}
} else if ("eventState".equals(result.getRightPath())){
if ("0".equals(result.getRight())){
result.setRight("待确认");
} else if ("1".equals(result.getRight())){
result.setRight("处理中");
} else if ("2".equals(result.getRight())){
result.setRight("已完成");
}
} else if ("eventSource".equals(result.getRightPath())){
result.setRight(ValueConverter.eventSourceName(result.getRight().toString()));
} else if ("lang".equals(result.getRightPath())){
String langStr = "";
String langArr[] = result.getRight().toString().split(",");
for (String lang : langArr) {
if ("1".equals(lang)){
langStr = langStr + "行1,";
} else if ("2".equals(lang)){
langStr = langStr + "行2,";
} else if ("3".equals(lang)){
langStr = langStr + "行3,";
} else if ("4".equals(lang)){
langStr = langStr + "行4,";
} else if ("0".equals(lang)){
langStr = langStr + "应急车道,";
}
}
if (langStr.length() > 0){
langStr = langStr.substring(0,langStr.length() -1);
}
result.setRight(langStr);
} else if ("dcEventAbnormalWeather.weatherSituation".equals(result.getRightPath())){
if ("1-1".equals(result.getRight())){
result.setRight("雨雾");
} else if ("1-2".equals(result.getRight())){
result.setRight("雨雪");
} else if ("1-3".equals(result.getRight())){
result.setRight("中雨");
} else if ("1-4".equals(result.getRight())){
result.setRight("小雨");
} else if ("1-5".equals(result.getRight())){
result.setRight("大雨");
} else if ("1-6".equals(result.getRight())){
result.setRight("暴雨");
} else if ("2-1".equals(result.getRight())){
result.setRight("小雪");
} else if ("2-2".equals(result.getRight())){
result.setRight("中雪");
} else if ("2-3".equals(result.getRight())){
result.setRight("大雪");
} else if ("2-4".equals(result.getRight())){
result.setRight("暴雪");
} else if ("2-5".equals(result.getRight())){
result.setRight("大暴雪");
} else if ("2-6".equals(result.getRight())){
result.setRight("特大暴雪");
} else if ("3-1".equals(result.getRight())){
result.setRight("轻雾");
} else if ("3-2".equals(result.getRight())){
result.setRight("大雾");
} else if ("3-3".equals(result.getRight())){
result.setRight("浓雾");
} else if ("3-4".equals(result.getRight())){
result.setRight("强浓雾");
} else if ("3-5".equals(result.getRight())){
result.setRight("团雾");
}
} else if ("dcEventAbnormalWeather.emergencyLevel".equals(result.getRightPath())){
if ("1".equals(result.getRight())){
result.setRight("一般");
} else if ("2".equals(result.getRight())){
result.setRight("紧急");
}
} else if ("dcEventAccident.locationType".equals(result.getRightPath())){
if ("1".equals(result.getRight())){
result.setRight("高速主线");
} else if ("2".equals(result.getRight())){
result.setRight("服务区");
} else if ("3".equals(result.getRight())){
result.setRight("立交桥");
} else if ("4".equals(result.getRight())){
result.setRight("收费站");
}
} else if ("dcEventAccident.weatherCondition".equals(result.getRightPath())){
if ("1".equals(result.getRight())){
result.setRight("晴");
} else if ("2".equals(result.getRight())){
result.setRight("雨");
} else if ("3".equals(result.getRight())){
result.setRight("雪");
} else if ("4".equals(result.getRight())){
result.setRight("雾");
} else if ("5".equals(result.getRight())){
result.setRight("其他");
}
} else if ("dcEventAccident.impactLevel".equals(result.getRightPath())){
if ("1".equals(result.getRight())){
result.setRight("无");
} else if ("2".equals(result.getRight())){
result.setRight("危化品泄漏");
} else if ("3".equals(result.getRight())){
result.setRight("整车自燃");
} else if ("4".equals(result.getRight())){
result.setRight("车辆复燃");
} else if ("5".equals(result.getRight())){
result.setRight("散装人工倒货");
}
} else if ("dcEventAccident.isReverseCargo".equals(result.getRightPath())
|| "dcEventAccident.isMaintenance".equals(result.getRightPath())
|| "dcEventAccident.congestionAhead".equals(result.getRightPath())
|| "dcEventAccident.atIntersection".equals(result.getRightPath())
|| "dcEventAccident.onCurve".equals(result.getRightPath())
|| "dcEventAccident.isPrivate".equals(result.getRightPath())
|| "dcEventVehicleAccident.congestionAhead".equals(result.getRightPath())
|| "dcEventVehicleAccident.atIntersection".equals(result.getRightPath())
|| "dcEventVehicleAccident.onCurve".equals(result.getRightPath())
|| "dcEventVehicleAccident.isPrivate".equals(result.getRightPath())){
if ("0".equals(result.getRight())){
result.setRight("否");
} else if ("1".equals(result.getRight())){
result.setRight("是");
}
} else if ("dcEventConstruction.controlMode".equals(result.getRightPath())){
if ("1".equals(result.getRight())){
result.setRight("封闭");
} else if ("2".equals(result.getRight())){
result.setRight("不封闭");
}
} else if ("dcEventConstruction.locationType".equals(result.getRightPath())){
if ("1".equals(result.getRight())){
result.setRight("单点");
} else if ("2".equals(result.getRight())){
result.setRight("多点");
}
} else if ("dcEventConstruction.specialConstruction".equals(result.getRightPath())){
if ("1".equals(result.getRight())){
result.setRight("专项工程施工");
} else if ("2".equals(result.getRight())){
result.setRight("改扩建专项工程施工");
} else if ("3".equals(result.getRight())){
result.setRight("桥梁专项工程施工");
} else if ("4".equals(result.getRight())){
result.setRight("其他专项工程施工");
}
} else if ("dcEventConstruction.constructionMeasurement".equals(result.getRightPath())){
if ("0".equals(result.getRight())){
result.setRight("无");
} else if ("1".equals(result.getRight())){
result.setRight("并道行驶");
} else if ("2".equals(result.getRight())){
result.setRight("临时保通");
} else if ("3".equals(result.getRight())){
result.setRight("借路侧服务区通行");
}
} else if ("dcEventConstruction.exitsInlets".equals(result.getRightPath())
|| "dcEventServiceArea.exitsInlets".equals(result.getRightPath())
|| "dcEventTrafficControl.exitsInlets".equals(result.getRightPath())){
if ("1".equals(result.getRight())){
result.setRight("出口");
} else if ("2".equals(result.getRight())){
result.setRight("入口");
}
} else if ("dcEventConstruction.trafficCondition".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())){
result.setRight("卫生间");
} else if ("2".equals(result.getRight())){
result.setRight("餐厅");
} else if ("3".equals(result.getRight())){
result.setRight("停车场");
} else if ("4".equals(result.getRight())){
result.setRight("加油站");
} else if ("5".equals(result.getRight())){
result.setRight("充电桩");
}
} else if ("dcEventTrafficCongestion.congestionCause".equals(result.getRightPath())){
if ("1".equals(result.getRight())){
result.setRight("车流量大");
} else if ("2".equals(result.getRight())){
result.setRight("交通事故");
} else if ("3".equals(result.getRight())){
result.setRight("恶劣天气");
} else if ("4".equals(result.getRight())){
result.setRight("施工");
} else if ("5".equals(result.getRight())){
result.setRight("其他");
}
} else if ("dcEventTrafficCongestion.location".equals(result.getRightPath())){
if ("1".equals(result.getRight())){
result.setRight("入口");
} else if ("2".equals(result.getRight())){
result.setRight("出口");
} else if ("3".equals(result.getRight())){
result.setRight("入口内广场");
} else if ("4".equals(result.getRight())){
result.setRight("出口内广场");
} else if ("5".equals(result.getRight())){
result.setRight("外广场");
} else if ("6".equals(result.getRight())){
result.setRight("入口车道");
} else if ("7".equals(result.getRight())){
result.setRight("出口车道");
} else if ("8".equals(result.getRight())){
result.setRight("入口匝道");
} else if ("9".equals(result.getRight())){
result.setRight("出口匝道");
}
} else if ("dcEventTrafficCongestion.locationType".equals(result.getRightPath())
|| "dcEventVehicleAccident.locationType".equals(result.getRightPath())){
if ("1".equals(result.getRight())){
result.setRight("高速主线");
} else if ("2".equals(result.getRight())){
result.setRight("服务区");
} else if ("3".equals(result.getRight())){
result.setRight("立交桥");
} else if ("4".equals(result.getRight())){
result.setRight("收费站");
}
} else if ("dcEventTrafficCongestion.weatherCondition".equals(result.getRightPath())){
if ("1".equals(result.getRight())){
result.setRight("晴");
} else if ("2".equals(result.getRight())){
result.setRight("雨");
} else if ("3".equals(result.getRight())){
result.setRight("雪");
} else if ("4".equals(result.getRight())){
result.setRight("雾");
} else if ("5".equals(result.getRight())){
result.setRight("其他");
}
} else if ("dcEventTrafficControl.controlType".equals(result.getRightPath())){
if ("1".equals(result.getRight())){
result.setRight("封闭");
} else if ("2".equals(result.getRight())){
result.setRight("限行");
}
} else if ("dcEventTrafficControl.controlCause".equals(result.getRightPath())){
if ("1".equals(result.getRight())){
result.setRight("车流量大");
} else if ("2".equals(result.getRight())){
result.setRight("交通事故");
} else if ("3".equals(result.getRight())){
result.setRight("恶劣天气");
} else if ("4".equals(result.getRight())){
result.setRight("施工");
} else if ("5".equals(result.getRight())){
result.setRight("警备任务");
} else if ("6".equals(result.getRight())){
result.setRight("其他");
}
} else if ("dcEventTrafficControl.causeType".equals(result.getRightPath())){
if ("3-1".equals(result.getRight())){
result.setRight("雨");
} else if ("3-2".equals(result.getRight())){
result.setRight("雪");
} else if ("3-3".equals(result.getRight())){
result.setRight("雾");
} else if ("3-4".equals(result.getRight())){
result.setRight("道路积水");
} else if ("3-5".equals(result.getRight())){
result.setRight("道路湿滑");
} else if ("3-6".equals(result.getRight())){
result.setRight("道路结冰");
} else if ("3-7".equals(result.getRight())){
result.setRight("沙尘暴");
} else if ("4-1".equals(result.getRight())){
result.setRight("专项工程施工");
} else if ("4-2".equals(result.getRight())){
result.setRight("改扩建工程施工");
} else if ("4-3".equals(result.getRight())){
result.setRight("其他施工");
}
} else if ("dcEventTrafficControl.measure".equals(result.getRightPath())){
if ("1".equals(result.getRight())){
result.setRight("临时关闭");
} else if ("2".equals(result.getRight())){
result.setRight("限行车辆");
} else if ("3".equals(result.getRight())){
result.setRight("限行车道");
} else if ("4".equals(result.getRight())){
result.setRight("限行车道且限行车辆");
} else if ("5".equals(result.getRight())){
result.setRight("间隔放行");
} else if ("6".equals(result.getRight())){
result.setRight("并道行驶");
} else if ("7".equals(result.getRight())){
result.setRight("限速");
}
} else if ("dcEventTrafficControl.classify".equals(result.getRightPath())){
if ("1".equals(result.getRight())){
result.setRight("主线关闭");
} else if ("2".equals(result.getRight())){
result.setRight("主线限行");
} else if ("3".equals(result.getRight())){
result.setRight("主线间隔放行");
} else if ("4".equals(result.getRight())){
result.setRight("主线并道");
} else if ("5".equals(result.getRight())){
result.setRight("主线限速");
}
} else if ("dcEventTrafficControl.limitedType".equals(result.getRightPath())){
if ("1".equals(result.getRight())){
result.setRight("只允许");
} else if ("2".equals(result.getRight())){
result.setRight("禁止");
}
}
String label = ValueConverter.eventLabel(result.getRightPath());
context = context + label + "修改为:" + result.getRight() + ",";
}
}
if (context.length() > 0){
context = context.substring(0,context.length() -1);
}
return context;
}
/**
* @Description 查询事件流程状态
*
* @author liuwenge
* @date 2024/4/11 11:19
* @param eventId 事件id
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@Override
public AjaxResult getProcessNode(String eventId){
List<Map<String,Object>> processNode = dcEventMapper.getProcessNode(eventId);
return AjaxResult.success(processNode);
}
/**
* @Description 解除事件
*
* @author liuwenge
* @date 2024/4/11 14:13
* @param eventId
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@Override
public AjaxResult completeEvent(String eventId){
boolean flag = dcEventMapper.completeEvent(eventId);
if (flag){
DcEvent dcEvent = dcEventMapper.selectDcEventById(eventId);
String datePoor = getDatePoor(dcEvent.getEndTime(),dcEvent.getStartTime());
//事件处置流程记录
DcEventProcess dcEventProcess = new DcEventProcess();
dcEventProcess.setEventId(eventId);
dcEventProcess.setOperationTime(new Date());
dcEventProcess.setOperator(SecurityUtils.getUserId().toString());
dcEventProcess.setSource(1);
dcEventProcess.setContext("事件解除,处置完毕,处置时长:" + datePoor);
dcEventProcessService.insertDcEventProcess(dcEventProcess);
return AjaxResult.success("解除事件成功");
}
return AjaxResult.error("解除事件失败");
}
/**
* @Description 无需清障
*
* @author liuwenge
* @date 2024/4/11 14:13
* @param eventId
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@Override
public AjaxResult skipClear(String eventId){
//事件处置流程记录
DcEventProcess dcEventProcess = new DcEventProcess();
dcEventProcess.setEventId(eventId);
dcEventProcess.setOperationTime(new Date());
dcEventProcess.setOperator(SecurityUtils.getUserId().toString());
dcEventProcess.setSource(1);
dcEventProcess.setProcessType(1);
dcEventProcess.setProcessId(6L);
dcEventProcess.setProcessName("清障结束");
dcEventProcess.setContext("选择不需要清障");
dcEventProcessService.insertDcEventProcess(dcEventProcess);
return AjaxResult.success("无需清障成功");
}
//时间比对
public static String getDatePoor(Date endDate, Date nowDate) {
long nd = 1000 * 24 * 60 * 60;
long nh = 1000 * 60 * 60;
long nm = 1000 * 60;
long ns = 1000;
// 获得两个时间的毫秒时间差异
long diff = endDate.getTime() - nowDate.getTime();
// 计算差多少天
long day = diff / nd;
// 计算差多少小时
long hour = diff % nd / nh;
// 计算差多少分钟
long min = diff % nd % nh / nm;
// 计算差多少秒//输出结果
long sec = diff % nd % nh % nm / ns;
return day + "天" + hour + "小时" + min + "分钟" + sec + "秒";
}
}

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

@ -7,28 +7,36 @@ import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.zc.business.domain.DcDispatch;
import com.zc.business.domain.DcDispatchResource;
import com.zc.business.domain.DcEvent;
import com.zc.business.domain.DcWaringStrategy;
import com.zc.business.domain.DcWarning;
import com.zc.business.domain.DcWarningBatchConvert;
import com.zc.business.enums.ValueConverter;
import com.zc.business.enums.WarningSubclassEnum;
import com.zc.business.mapper.DcEventMapper;
import com.zc.business.mapper.DcWarningMapper;
import com.zc.business.service.IDcEventService;
import com.zc.business.service.IDcWarningService;
import com.zc.business.utils.StakeMarkUtils;
import com.zc.common.core.websocket.WebSocketService;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.json.JSONObject;
import org.json.JSONArray;
import java.util.stream.Collectors;
/**
* 预警信息Service业务层处理
*
@ -47,7 +55,9 @@ public class DcWarningServiceImpl implements IDcWarningService
private IDcEventService dcEventService;
@Resource
private RedisCache redisCache;
private final String HAPPEN = "发生";
private final String EVENT = "事件";
private final String SUBEVENT = "1";
private static final String WARNINGSTRATEGY = "warningStrategy";//redis策略缓存的key
private static final String WARNINGDATA = "warningData:";//redis事件缓存的key
private static String JUDGE = "1"; //自定义判断参数,1为满足0为不满足
@ -120,8 +130,13 @@ public class DcWarningServiceImpl implements IDcWarningService
HashMap redisValueTwo = redisWarningStrategy.get(redisKye+"2");//查看传入的事件类型是否配置策略2(延迟策略)
if (redisValueTwo!=null){ //执行策略2,
String strategyTime = redisValueTwo.get("strategyTime").toString();//策略时长
if (dataId==null){//如果不存在直接加入数据库,加入缓存,配置对应的过期时间
dcWarning.setEndTime(DateUtils.getObtainDateAfter(Integer.parseInt(strategyTime)));//注入过期时间
if (dataId==null){//如果不存在直接加入数据库,加入缓存,配置对应的缓存过期时间以及数据库过期时间
int insertDcWarning = dcWarningMapper.insertDcWarning(dcWarning);//加入数据库
//事件推送至 Websocket
extracted(dcWarning);
if (insertDcWarning==0){
return 0;
}
@ -131,10 +146,12 @@ public class DcWarningServiceImpl implements IDcWarningService
}
//redis存在数据,取出redis的id找对对应事件的配置,合成事件配置,重新定义延迟时间
HashMap<String, Object> map = dcWarningMapper.selectDcWarningById(dataId);
if (map==null||(map.get("warningState")!=null&&!map.get("warningState").toString().equals("1"))){//redis中有id但是数据库中没有这条数据,或则数据库中有数据但是状态不为上报,那就删除这条redis数据,新数据加入到数据库,并加入到redis
if (map==null||(map.get("warningState")!=null&&map.get("warningState").toString().equals("4"))){//redis中有id但是数据库中没有这条数据,或则数据库中有数据但是状态不为结束,那就删除这条redis数据,新数据加入到数据库,并加入到redis
redisCache.deleteObject(WARNINGDATA+key);
String id = dcWarning.getId();
redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES);
//事件推送至 Websocket
extracted(dcWarning);
return dcWarningMapper.insertDcWarning(dcWarning);
}
String otherConfig="";
@ -156,185 +173,209 @@ public class DcWarningServiceImpl implements IDcWarningService
jsonObjectOne.put("videoList",videoList);
}
redisCache.setCacheObject(WARNINGDATA+key,dataId,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//重新设置延迟时间
return dcWarningMapper.updateOtherConfig(dataId,jsonObjectOne.toString());//修改数据库配置
return dcWarningMapper.updateOtherConfig(dataId,jsonObjectOne.toString(),dcWarning.getEndTime());//修改数据库配置
}
DcWarningServiceImpl dcWarningService = new DcWarningServiceImpl();//合成工具类
JSONObject jsonObject = dcWarningService.mergeJsonObjects(jsonObjectOne, jsonObjectTwo);
redisCache.setCacheObject(WARNINGDATA+key,dataId,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//重新设置延迟时间
return dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString());//修改数据库配置
return dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString(),dcWarning.getEndTime());//修改数据库配置
}
//事件推送至 Websocket
extracted(dcWarning);
return dcWarningMapper.insertDcWarning(dcWarning);//如果没有配置策略直接加入数据库;
}
//优先级策略(还差优先级策略需要配置)
public int priority(DcWarning dcWarning){
dcWarning.setCreateTime(DateUtils.getNowDate());
//设置事件Id UUID无下划线格式32
String uuid = IdUtils.fastSimpleUUID();
dcWarning.setId(uuid);
if (StringUtils.isBlank(dcWarning.getStakeMark())||dcWarning.getWarningSource()==null||dcWarning.getWarningType()==null||
StringUtils.isBlank(dcWarning.getWarningSubclass())||StringUtils.isBlank(dcWarning.getDirection())){
return 0;
}
String redisKye=dcWarning.getWarningSource().toString()+dcWarning.getWarningType().toString()+dcWarning.getWarningSubclass();//配置数据的key 事件源+事件类型+策略
Map<String, HashMap> redisWarningStrategy = redisCache.getCacheMap(WARNINGSTRATEGY);//获取缓存全部的配置数据
if (redisWarningStrategy==null||redisWarningStrategy.size()==0){//如果缓存为空,查询数据重新加入缓存
Map<String, JSONObject> redisMap = new HashMap<>();
List<DcWaringStrategy> dcWaringStrategies = dcWarningMapper.selectDcWaringStrategyList();//数据库全部配置数据
for (DcWaringStrategy waringStrategy : dcWaringStrategies) {
String key = waringStrategy.getWarningSource().toString() + waringStrategy.getWarningType().toString()
+ waringStrategy.getWarningSubclass()+waringStrategy.getStrategy().toString();//redis配置数据key
JSONObject jsonObject = new JSONObject();
jsonObject.put("strategy", waringStrategy.getStrategy());//策略模式
jsonObject.put("strategyTime", waringStrategy.getStrategyTime());//模式时长,单位为分钟
jsonObject.put("priority", waringStrategy.getPriority());//优先级
redisMap.put(key, jsonObject);
}
redisCache.setCacheMap(WARNINGSTRATEGY, redisMap);//数据库配置数据加入缓存中
redisWarningStrategy = redisCache.getCacheMap(WARNINGSTRATEGY);//缓存数据为空重新加入到缓存在取出缓存的配置
}
String key=dcWarning.getStakeMark()+dcWarning.getDirection()+dcWarning.getWarningSource().
toString()+dcWarning.getWarningType().toString()+dcWarning.getWarningSubclass();//key,redis存储事件的key(桩号+方向+事件源+类型)
String dataId = redisCache.getCacheObject(WARNINGDATA + key);//查看redis是否存在数据(id的值)
HashMap redisValueOne = redisWarningStrategy.get(redisKye+"1");//查看传入的事件类型是否配置策略1(优先级策略)
if(redisValueOne!=null){//执行策略1(暂时未定义,定义后开发)
String priority = redisValueOne.get("priority").toString();//全部的优先等级
String[] split = priority.split(",");
for (int i = 0; i < split.length; i++){
String priorityValue=split[i];//取出当前循环的优先级类型
String keys=dcWarning.getStakeMark()+dcWarning.getDirection()+dcWarning.getWarningSource().
toString()+dcWarning.getWarningType().toString()+priorityValue;//redis存储事件的key
String dataIds = redisCache.getCacheObject(WARNINGDATA + keys);//查看redis是否存在数据(id的值)
if (dataIds==null){ //没有对应的优先级类型的id值,结束当前循环
continue;
}
//redis存在数据,取出redis的id找对对应事件的配置,合成事件配置
HashMap<String, Object> map = dcWarningMapper.selectDcWarningById(dataId);
if (map==null){//redis中有id但是数据库中没有这条数据,那就直接新增这个事件
return dcWarningMapper.insertDcWarning(dcWarning);
}
String warningState = map.get("warningState").toString();//事件上报状态
if ("1".equals(warningState)==false){ //状态不为上报,不用合成事件,删除之前的redis数据
redisCache.deleteObject(WARNINGDATA+keys);
continue;
}
String otherConfig="";
if (map.get("otherConfig")!=null){
otherConfig = map.get("otherConfig").toString(); //取出原id的配置信息
}
String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息
JSONObject jsonObjectOne = new JSONObject(otherConfig);
JSONObject jsonObjectTwo = new JSONObject(otherConfigString);
DcWarningServiceImpl dcWarningService = new DcWarningServiceImpl();//合成新的json
JSONObject jsonObject = dcWarningService.mergeJsonObjects(jsonObjectOne, jsonObjectTwo);
return dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString());//修改数据库配置
}
}
HashMap redisValueTwo = redisWarningStrategy.get(redisKye+"2");//查看传入的事件类型是否配置策略2(延迟策略)
if (redisValueTwo!=null){ //执行策略2,执行到这里说明1不存在或者1未满足过滤条件
String strategyTime = redisValueTwo.get("strategyTime").toString();//策略时长
if (dataId==null){//如果不存在直接加入数据库,加入缓存,配置对应的过期时间
int insertDcWarning = dcWarningMapper.insertDcWarning(dcWarning);//加入数据库
if (insertDcWarning==0){
return 0;
}
String id = dcWarning.getId();//取出加入后的id作为value
redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//加入缓存并设置延迟时间(单位分钟)
return 1;//结束
}
//redis存在数据,取出redis的id找对对应事件的配置,合成事件配置,重新定义延迟时间
HashMap<String, Object> map = dcWarningMapper.selectDcWarningById(dataId);
if (map==null){//redis中有id但是数据库中没有这条数据,那就删除这条redis数据,新数据加入到数据库,并加入到redis
redisCache.deleteObject(WARNINGDATA+key);
dcWarningMapper.insertDcWarning(dcWarning);
String id = dcWarning.getId();
redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES);
return 1;
}
String otherConfig="";
if (map.get("otherConfig")!=null){
otherConfig = map.get("otherConfig").toString(); //取出原id的配置信息
}
String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息
JSONObject jsonObjectOne = new JSONObject(otherConfig);
JSONObject jsonObjectTwo = new JSONObject(otherConfigString);
DcWarningServiceImpl dcWarningService = new DcWarningServiceImpl();//合成新的json
JSONObject jsonObject = dcWarningService.mergeJsonObjects(jsonObjectOne, jsonObjectTwo);
Integer integer = dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString());//修改数据库配置
redisCache.setCacheObject(WARNINGDATA+key,dataId,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//重新设置延迟时间
if (integer==0){
return 0;
}
return 1;
}
HashMap redisValueThree = redisWarningStrategy.get(redisKye+"3");//查看传入的事件类型是否配置策略3(时间窗口策略)
if (redisValueTwo==null&&redisValueThree!=null){ //执行策略3,执行到这里说明1不存在或者2不存在或者1未满足过滤条件
String strategyTime = redisValueThree.get("strategyTime").toString();//策略时长
if (dataId==null){//如果不存在直接加入数据库,加入缓存,配置对应的过期时间
int insertDcWarning = dcWarningMapper.insertDcWarning(dcWarning);//加入数据库
if (insertDcWarning==0){
return 0;
}
String id = dcWarning.getId();//取出加入后的id作为value
redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//加入缓存并设置延迟时间(单位分钟)
return 1;//结束
}
//redis存在数据,取出redis的id找对对应事件的配置,合成事件配置
HashMap<String, Object> map = dcWarningMapper.selectDcWarningById(dataId);
if (map==null){//redis中有id但是数据库中没有这条数据,那就删除这条redis数据,新数据加入到数据库,并加入到redis
redisCache.deleteObject(WARNINGDATA+key);
dcWarningMapper.insertDcWarning(dcWarning);
String id = dcWarning.getId();
redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES);
return 1;
}
String otherConfig="";
otherConfig = map.get("otherConfig").toString();//取出原id的配置信息
String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息
JSONObject jsonObjectOne = new JSONObject(otherConfig);
JSONObject jsonObjectTwo = new JSONObject(otherConfigString);
JSONObject jsonObject = new DcWarningServiceImpl().mergeJsonObjects(jsonObjectOne, jsonObjectTwo);//合成新的json
Integer integer = dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString());//修改数据库配置
if (integer==0){
return 0;
}
return 1;
/**
* 事件推送至 Websocket
* @param dcWarning
*/
private void extracted(DcWarning dcWarning) {
String direction = "";// 方向
String EventSubclass = "";// 事件类型
if (dcWarning.getDirection().equals("1")) {
direction="菏泽方向";
}else {
direction="济南方向";
}
HashMap redisValueFour = redisWarningStrategy.get(redisKye+"4");//查看传入的事件类型是否配置策略3(自动结束策略)
if (redisValueTwo==null&&redisValueThree==null&&redisValueFour!=null){ //执行策略4,执行到这里说明1不存在或者2、3不存在或者1未满足过滤条件
if (dataId==null){//如果不存在直接加入数据库,加入缓存
int insertDcWarning = dcWarningMapper.insertDcWarning(dcWarning);//加入数据库
if (insertDcWarning==0){
return 0;
}
String id = dcWarning.getId();//取出加入后的id作为value
redisCache.setCacheObject(WARNINGDATA+key,id,24,TimeUnit.HOURS);//加入缓存,防止redis数据累计,这里也要设置过期时间,设置为24小时
return 1;//结束
}
//redis存在数据,取出redis的id找对对应事件的配置,合成事件配置
HashMap<String, Object> map = dcWarningMapper.selectDcWarningById(dataId);
if (map==null){//redis中有id但是数据库中没有这条数据,那就删除这条redis数据,新数据加入到数据库,并加入到redis
redisCache.deleteObject(WARNINGDATA+key);
dcWarningMapper.insertDcWarning(dcWarning);
String id = dcWarning.getId();
redisCache.setCacheObject(WARNINGDATA+key,id);
return 1;
}
String otherConfig="";
otherConfig = map.get("otherConfig").toString();//取出原id的配置信息
String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息
JSONObject jsonObjectOne = new JSONObject(otherConfig);
JSONObject jsonObjectTwo = new JSONObject(otherConfigString);
JSONObject jsonObject = new DcWarningServiceImpl().mergeJsonObjects(jsonObjectOne, jsonObjectTwo);//合成新的json
Integer integer = dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString());//修改数据库配置
redisCache.deleteObject(WARNINGDATA + key);//删除redis存储的数据
if (integer==0){
return 0;
for (WarningSubclassEnum eventSubclass : WarningSubclassEnum.values()) {
if (eventSubclass.getCode().equals(dcWarning.getWarningSubclass())) {
EventSubclass=eventSubclass.getInfo();
break;
}
return 1;
}
return dcWarningMapper.insertDcWarning(dcWarning);//如果没有配置策略直接加入数据库;
String content= direction+" " + dcWarning.getStakeMark()+" "+HAPPEN+EventSubclass+EVENT ;
WebSocketService.broadcast(SUBEVENT, content); //推送事件消息 0不是感知事件
}
//优先级策略(还差优先级策略需要配置)
// public int priority(DcWarning dcWarning){
// dcWarning.setCreateTime(DateUtils.getNowDate());
// //设置事件Id UUID无下划线格式32
// String uuid = IdUtils.fastSimpleUUID();
// dcWarning.setId(uuid);
// if (StringUtils.isBlank(dcWarning.getStakeMark())||dcWarning.getWarningSource()==null||dcWarning.getWarningType()==null||
// StringUtils.isBlank(dcWarning.getWarningSubclass())||StringUtils.isBlank(dcWarning.getDirection())){
// return 0;
// }
// String redisKye=dcWarning.getWarningSource().toString()+dcWarning.getWarningType().toString()+dcWarning.getWarningSubclass();//配置数据的key 事件源+事件类型+策略
// Map<String, HashMap> redisWarningStrategy = redisCache.getCacheMap(WARNINGSTRATEGY);//获取缓存全部的配置数据
// if (redisWarningStrategy==null||redisWarningStrategy.size()==0){//如果缓存为空,查询数据重新加入缓存
// Map<String, JSONObject> redisMap = new HashMap<>();
// List<DcWaringStrategy> dcWaringStrategies = dcWarningMapper.selectDcWaringStrategyList();//数据库全部配置数据
// for (DcWaringStrategy waringStrategy : dcWaringStrategies) {
// String key = waringStrategy.getWarningSource().toString() + waringStrategy.getWarningType().toString()
// + waringStrategy.getWarningSubclass()+waringStrategy.getStrategy().toString();//redis配置数据key
// JSONObject jsonObject = new JSONObject();
// jsonObject.put("strategy", waringStrategy.getStrategy());//策略模式
// jsonObject.put("strategyTime", waringStrategy.getStrategyTime());//模式时长,单位为分钟
// jsonObject.put("priority", waringStrategy.getPriority());//优先级
// redisMap.put(key, jsonObject);
// }
// redisCache.setCacheMap(WARNINGSTRATEGY, redisMap);//数据库配置数据加入缓存中
// redisWarningStrategy = redisCache.getCacheMap(WARNINGSTRATEGY);//缓存数据为空重新加入到缓存在取出缓存的配置
// }
// String key=dcWarning.getStakeMark()+dcWarning.getDirection()+dcWarning.getWarningSource().
// toString()+dcWarning.getWarningType().toString()+dcWarning.getWarningSubclass();//key,redis存储事件的key(桩号+方向+事件源+类型)
// String dataId = redisCache.getCacheObject(WARNINGDATA + key);//查看redis是否存在数据(id的值)
// HashMap redisValueOne = redisWarningStrategy.get(redisKye+"1");//查看传入的事件类型是否配置策略1(优先级策略)
// if(redisValueOne!=null){//执行策略1(暂时未定义,定义后开发)
// String priority = redisValueOne.get("priority").toString();//全部的优先等级
// String[] split = priority.split(",");
// for (int i = 0; i < split.length; i++){
// String priorityValue=split[i];//取出当前循环的优先级类型
// String keys=dcWarning.getStakeMark()+dcWarning.getDirection()+dcWarning.getWarningSource().
// toString()+dcWarning.getWarningType().toString()+priorityValue;//redis存储事件的key
// String dataIds = redisCache.getCacheObject(WARNINGDATA + keys);//查看redis是否存在数据(id的值)
// if (dataIds==null){ //没有对应的优先级类型的id值,结束当前循环
// continue;
// }
// //redis存在数据,取出redis的id找对对应事件的配置,合成事件配置
// HashMap<String, Object> map = dcWarningMapper.selectDcWarningById(dataId);
// if (map==null){//redis中有id但是数据库中没有这条数据,那就直接新增这个事件
// return dcWarningMapper.insertDcWarning(dcWarning);
// }
// String warningState = map.get("warningState").toString();//事件上报状态
// if ("1".equals(warningState)==false){ //状态不为上报,不用合成事件,删除之前的redis数据
// redisCache.deleteObject(WARNINGDATA+keys);
// continue;
// }
// String otherConfig="";
// if (map.get("otherConfig")!=null){
// otherConfig = map.get("otherConfig").toString(); //取出原id的配置信息
// }
// String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息
// JSONObject jsonObjectOne = new JSONObject(otherConfig);
// JSONObject jsonObjectTwo = new JSONObject(otherConfigString);
// DcWarningServiceImpl dcWarningService = new DcWarningServiceImpl();//合成新的json
// JSONObject jsonObject = dcWarningService.mergeJsonObjects(jsonObjectOne, jsonObjectTwo);
// return dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString());//修改数据库配置
// }
// }
// HashMap redisValueTwo = redisWarningStrategy.get(redisKye+"2");//查看传入的事件类型是否配置策略2(延迟策略)
// if (redisValueTwo!=null){ //执行策略2,执行到这里说明1不存在或者1未满足过滤条件
// String strategyTime = redisValueTwo.get("strategyTime").toString();//策略时长
// if (dataId==null){//如果不存在直接加入数据库,加入缓存,配置对应的过期时间
// int insertDcWarning = dcWarningMapper.insertDcWarning(dcWarning);//加入数据库
// if (insertDcWarning==0){
// return 0;
// }
// String id = dcWarning.getId();//取出加入后的id作为value
// redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//加入缓存并设置延迟时间(单位分钟)
// return 1;//结束
// }
// //redis存在数据,取出redis的id找对对应事件的配置,合成事件配置,重新定义延迟时间
// HashMap<String, Object> map = dcWarningMapper.selectDcWarningById(dataId);
// if (map==null){//redis中有id但是数据库中没有这条数据,那就删除这条redis数据,新数据加入到数据库,并加入到redis
// redisCache.deleteObject(WARNINGDATA+key);
// dcWarningMapper.insertDcWarning(dcWarning);
// String id = dcWarning.getId();
// redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES);
// return 1;
// }
// String otherConfig="";
// if (map.get("otherConfig")!=null){
// otherConfig = map.get("otherConfig").toString(); //取出原id的配置信息
// }
// String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息
// JSONObject jsonObjectOne = new JSONObject(otherConfig);
// JSONObject jsonObjectTwo = new JSONObject(otherConfigString);
// DcWarningServiceImpl dcWarningService = new DcWarningServiceImpl();//合成新的json
// JSONObject jsonObject = dcWarningService.mergeJsonObjects(jsonObjectOne, jsonObjectTwo);
// Integer integer = dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString());//修改数据库配置
// redisCache.setCacheObject(WARNINGDATA+key,dataId,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//重新设置延迟时间
// if (integer==0){
// return 0;
// }
// return 1;
// }
// HashMap redisValueThree = redisWarningStrategy.get(redisKye+"3");//查看传入的事件类型是否配置策略3(时间窗口策略)
// if (redisValueTwo==null&&redisValueThree!=null){ //执行策略3,执行到这里说明1不存在或者2不存在或者1未满足过滤条件
// String strategyTime = redisValueThree.get("strategyTime").toString();//策略时长
// if (dataId==null){//如果不存在直接加入数据库,加入缓存,配置对应的过期时间
// int insertDcWarning = dcWarningMapper.insertDcWarning(dcWarning);//加入数据库
// if (insertDcWarning==0){
// return 0;
// }
// String id = dcWarning.getId();//取出加入后的id作为value
// redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//加入缓存并设置延迟时间(单位分钟)
// return 1;//结束
// }
// //redis存在数据,取出redis的id找对对应事件的配置,合成事件配置
// HashMap<String, Object> map = dcWarningMapper.selectDcWarningById(dataId);
// if (map==null){//redis中有id但是数据库中没有这条数据,那就删除这条redis数据,新数据加入到数据库,并加入到redis
// redisCache.deleteObject(WARNINGDATA+key);
// dcWarningMapper.insertDcWarning(dcWarning);
// String id = dcWarning.getId();
// redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES);
// return 1;
// }
// String otherConfig="";
// otherConfig = map.get("otherConfig").toString();//取出原id的配置信息
// String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息
// JSONObject jsonObjectOne = new JSONObject(otherConfig);
// JSONObject jsonObjectTwo = new JSONObject(otherConfigString);
// JSONObject jsonObject = new DcWarningServiceImpl().mergeJsonObjects(jsonObjectOne, jsonObjectTwo);//合成新的json
// Integer integer = dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString());//修改数据库配置
// if (integer==0){
// return 0;
// }
// return 1;
// }
// HashMap redisValueFour = redisWarningStrategy.get(redisKye+"4");//查看传入的事件类型是否配置策略3(自动结束策略)
// if (redisValueTwo==null&&redisValueThree==null&&redisValueFour!=null){ //执行策略4,执行到这里说明1不存在或者2、3不存在或者1未满足过滤条件
// if (dataId==null){//如果不存在直接加入数据库,加入缓存
// int insertDcWarning = dcWarningMapper.insertDcWarning(dcWarning);//加入数据库
// if (insertDcWarning==0){
// return 0;
// }
// String id = dcWarning.getId();//取出加入后的id作为value
// redisCache.setCacheObject(WARNINGDATA+key,id,24,TimeUnit.HOURS);//加入缓存,防止redis数据累计,这里也要设置过期时间,设置为24小时
// return 1;//结束
// }
// //redis存在数据,取出redis的id找对对应事件的配置,合成事件配置
// HashMap<String, Object> map = dcWarningMapper.selectDcWarningById(dataId);
// if (map==null){//redis中有id但是数据库中没有这条数据,那就删除这条redis数据,新数据加入到数据库,并加入到redis
// redisCache.deleteObject(WARNINGDATA+key);
// dcWarningMapper.insertDcWarning(dcWarning);
// String id = dcWarning.getId();
// redisCache.setCacheObject(WARNINGDATA+key,id);
// return 1;
// }
// String otherConfig="";
// otherConfig = map.get("otherConfig").toString();//取出原id的配置信息
// String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息
// JSONObject jsonObjectOne = new JSONObject(otherConfig);
// JSONObject jsonObjectTwo = new JSONObject(otherConfigString);
// JSONObject jsonObject = new DcWarningServiceImpl().mergeJsonObjects(jsonObjectOne, jsonObjectTwo);//合成新的json
// Integer integer = dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString());//修改数据库配置
// redisCache.deleteObject(WARNINGDATA + key);//删除redis存储的数据
// if (integer==0){
// return 0;
// }
// return 1;
// }
// return dcWarningMapper.insertDcWarning(dcWarning);//如果没有配置策略直接加入数据库;
// }
private JSONObject mergeJsonObjects(JSONObject jsonObjectOne, JSONObject jsonObjectTwo){
// 合并videoList
if (jsonObjectTwo.has("videoList")) {
@ -406,14 +447,16 @@ public class DcWarningServiceImpl implements IDcWarningService
StringUtils.isBlank(dcWarning.getDirection())){
return AjaxResult.error("参数错误");
}
ArrayList<HashMap<String,Object>> hashMaps = new ArrayList<>();
dcWarning.setUserId(SecurityUtils.getUserId());
int updateState = dcWarningMapper.updateState(dcWarning);//感知事件状态改变为已完成
if (updateState==0){
return AjaxResult.error("操作失败");
}
String stakeMark = dcWarning.getStakeMark();
DcEvent dcEvent = new DcEvent();
dcEvent.setId(dcWarning.getId());//id
dcEvent.setStakeMark(dcWarning.getStakeMark());//桩号
dcEvent.setStakeMark(stakeMark);//桩号
dcEvent.setDirection(dcWarning.getDirection());//方向
dcEvent.setDeptId(dcWarning.getDeptId());//部门
dcEvent.setOccurrenceTime(dcWarning.getWarningTime());//预警时间
@ -442,6 +485,32 @@ public class DcWarningServiceImpl implements IDcWarningService
dcEvent.setCreateTime(DateUtils.getNowDate());//创建时间
dcEvent.setUserId(SecurityUtils.getUserId());//处置人员
int insertDcEvent = dcEventService.insertDcEventWarning(dcEvent);
List<HashMap<String, Object>> mapList = dcWarningMapper.selectRecentlySection();//全部机构的桩号和名称
for (HashMap<String,Object> map:mapList){
if (StringUtils.isBlank(map.get("stakeMark").toString())){
continue;
}
Long id = (Long) map.get("id");//机构的id
String stakeMarkNew = map.get("stakeMark").toString();//机构桩号
StakeMarkUtils stakeMarkUtils = new StakeMarkUtils();
Integer itselfStakeMark = stakeMarkUtils.stakeMarkToInt(stakeMarkNew);//机构本身的米数
Integer afferentStakeMark = stakeMarkUtils.stakeMarkToInt(stakeMark);//传入的桩号米数
Integer difference =Math.abs(afferentStakeMark-itselfStakeMark); //计算距离绝对值
map.put("difference",difference/1000.0);//米转公里加入到map
map.put("id",id);
hashMaps.add(map);
}
List<HashMap<String, Object>> sortedHashMaps = hashMaps.stream().sorted(Comparator.comparing(map -> {
return (Double) map.get("difference"); })).collect(Collectors.toList());
HashMap<String, Object> map = sortedHashMaps.get(0);
Long id = (Long) map.get("id");//取出最近的机构id
if (id!=null){
DcDispatch dcDispatch = new DcDispatch();
dcDispatch.setEventId(dcWarning.getId());
dcDispatch.setOrganizationId(id);
dcWarningMapper.insertDcDispatch(dcDispatch);//事件绑定记录
}
if (insertDcEvent==0){
return AjaxResult.error("操作失败");
}
@ -532,4 +601,83 @@ public class DcWarningServiceImpl implements IDcWarningService
return AjaxResult.success("批量操作成功");
}
//定时结束部分事件
@Override
public Integer updateEndSection() {
List<DcWarning> dcWarnings = dcWarningMapper.selectEndSection();//全部应该结束事件的id
if (dcWarnings.size()==0){
return 1;
}
return dcWarningMapper.updateEndSection(dcWarnings);
}
@Override
public AjaxResult commandAndDispatch(DcWarning dcWarning) {
//逻辑,调用全部的机构信息,计算传入的桩号与机构桩号的距离作为排序使用,使用机构的id调出车辆,人员,值班等信息
List<HashMap<String, Object>> mapList = dcWarningMapper.selectRecentlySection();//全部机构的桩号和名称
ArrayList<HashMap<String,Object>> hashMaps = new ArrayList<>();
for (HashMap<String,Object> map:mapList){
if (StringUtils.isBlank(map.get("stakeMark").toString())){
continue;
}
String stakeMark = map.get("stakeMark").toString();
StakeMarkUtils stakeMarkUtils = new StakeMarkUtils();
Integer itselfStakeMark = stakeMarkUtils.stakeMarkToInt(stakeMark);//桩号本身的米数
Integer afferentStakeMark = stakeMarkUtils.stakeMarkToInt(dcWarning.getStakeMark());//传入的桩号米数
Integer difference =Math.abs(afferentStakeMark-itselfStakeMark); //计算距离绝对值
map.put("difference",difference/1000.0);//米转公里加入到map
Long id = (Long) map.get("id");//机构的id,用户获取人员、值班、车辆等信息
List<HashMap<String, Object>> employeesMap = dcWarningMapper.selectOrganizationEmployees(id);//人员map
List<HashMap<String, Object>> shiftsMap = dcWarningMapper.selectShifts(id);//值班map
List<HashMap<String, Object>> vehiclesMap = dcWarningMapper.selectVehicles(id);//车辆map
map.put("employeesMap",employeesMap);
map.put("shiftsMap",shiftsMap);
map.put("vehiclesMap",vehiclesMap);
hashMaps.add(map);
}
List<HashMap<String, Object>> sortedHashMaps = hashMaps.stream().sorted(Comparator.comparing(map -> {
return (Double) map.get("difference"); })).collect(Collectors.toList());
return AjaxResult.success(sortedHashMaps);
}
@Override
public DcDispatch insertDispatch(DcDispatch dcDispatch) {
dcWarningMapper.insertDcDispatch(dcDispatch);
return dcDispatch;
}
@Override
public Integer insertDispatchSource(DcDispatchResource dcDispatchResource) {
return dcWarningMapper.insertDispatchResource(dcDispatchResource);
}
//依据桩号计算出记录最近的机构id
public AjaxResult stake(DcWarning dcWarning){
String stakeMark = dcWarning.getStakeMark();
ArrayList<HashMap<String,Object>> hashMaps = new ArrayList<>();
List<HashMap<String, Object>> mapList = dcWarningMapper.selectRecentlySection();//全部机构的桩号和名称
for (HashMap<String,Object> map:mapList){
if (StringUtils.isBlank(map.get("stakeMark").toString())){
continue;
}
Long id = (Long) map.get("id");//机构的id
String stakeMarkNew = map.get("stakeMark").toString();//机构桩号
StakeMarkUtils stakeMarkUtils = new StakeMarkUtils();
Integer itselfStakeMark = stakeMarkUtils.stakeMarkToInt(stakeMarkNew);//机构本身的米数
Integer afferentStakeMark = stakeMarkUtils.stakeMarkToInt(stakeMark);//传入的桩号米数
Integer difference =Math.abs(afferentStakeMark-itselfStakeMark); //计算距离绝对值
map.put("difference",difference/1000.0);//米转公里加入到map
map.put("id",id);
hashMaps.add(map);
}
List<HashMap<String, Object>> sortedHashMaps = hashMaps.stream().sorted(Comparator.comparing(map -> {
return (Double) map.get("difference"); })).collect(Collectors.toList());
if (!sortedHashMaps.isEmpty()){
HashMap<String, Object> map = sortedHashMaps.get(0);
Long id = (Long) map.get("id");
return AjaxResult.success(id);
}
return null;
}
}

200
zc-business/src/main/java/com/zc/business/service/impl/MsmServiceImpl.java

@ -0,0 +1,200 @@
package com.zc.business.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.profile.DefaultProfile;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.zc.business.service.IMsmService;
import com.zc.business.utils.HttpUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* 短信业务实现类
*/
@Service
public class MsmServiceImpl implements IMsmService {
private static final String WEIXINTUISONTOKEN = "weixintuisontoken";//redis策略缓存的key
/**
* 发送短信
*
* @param phone 手机号
* @return
*/
public boolean send(String phone) {
//地域节点、阿里云的id、秘钥
DefaultProfile profile = DefaultProfile.getProfile("cn-qingdao",
"LTAI5tENd3j1tP5t2fF4fxaX", "i86Yenj13XRd2aeZMtybpKxsqI1VRU");
IAcsClient client = new DefaultAcsClient(profile);
SendSmsRequest request = new SendSmsRequest();
request.setSysRegionId("cn-qingdao");//地域节点
request.putQueryParameter("PhoneNumbers", phone); //手机号,要填绑定测试的手机号码
request.putQueryParameter("SignName", "阿里云短信测试"); //阿里云签名名称
request.putQueryParameter("TemplateCode", "SMS_154950909"); //阿里云模板code
String code = String.format("%04d", new Random().nextInt(10000));//验证码
HashMap<Object, Object> map = new HashMap<>();
map.put("code", code); //参数加入到map
JSONObject json = new JSONObject(map); //map参数转为JSON传入到模板即可
request.putQueryParameter("TemplateParam", json);
try {
SendSmsResponse response = client.getAcsResponse(request);
if (response != null && response.getCode() != null && response.getCode().equals("OK")) {
return true;
}
return false;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
//测试短信推送
// public static void main(String[] args) {
// MsmServiceImpl msmService = new MsmServiceImpl();
// boolean send = msmService.send("19806114248");
// System.out.println(send);
// }
//微信推送
@Override
public JSONArray wenXinSend(String appId, String appSecret) {
MsmServiceImpl msmService = new MsmServiceImpl();
return msmService.sendTemp(appId, appSecret);
}
//获取微信token
public static com.alibaba.fastjson.JSONObject getAccessToken(String appId, String appSecret) {
String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appId + "&secret=" + appSecret;
String accessToken = null;
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);
accessToken = new String(jsonBytes, "UTF-8");
System.err.println(accessToken);
jsonObj = com.alibaba.fastjson.JSONObject.parseObject(accessToken);
is.close();
} catch (Exception e) {
e.printStackTrace();
}
return jsonObj;
}
//执行微信推送
public JSONArray sendTemp(String appId, String appSecret) {
JSONArray objects = new JSONArray();
ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(100);
MsmServiceImpl msmService = new MsmServiceImpl();
RedisCache redisCache = SpringUtils.getBean(RedisCache.class);
String accessToken = redisCache.getCacheObject(WEIXINTUISONTOKEN);
if (StringUtils.isBlank(accessToken)) {
accessToken = msmService.getAccessToken(appId, appSecret).getString("access_token");//获取到了access_token
String expiresIn = msmService.getAccessToken(appId, appSecret).getString("expires_in");//token有效秒数
redisCache.setCacheObject(WEIXINTUISONTOKEN, accessToken, Integer.parseInt(expiresIn), TimeUnit.SECONDS);//把token存入到redis中,并设置过期时间(时间来自于微信接口返回)
}
JSONArray userListOpenid = msmService.getUserListOpenid(accessToken);
CountDownLatch latch = new CountDownLatch(userListOpenid.size());
for (Object openid : userListOpenid) {
String token = accessToken;
executor.execute(() -> {
// 封装要发送的json
Map<String, Object> map = new HashMap();
map.put("template_id", "D_yBiN7aDl2pw3bhSqU_Fbi0D8BHXL0qeBjhusWVO68");//模板消息id
map.put("touser", openid.toString());//这里的openid是全部关注公众号的openid
// 封装data
com.alibaba.fastjson.JSONObject data = new com.alibaba.fastjson.JSONObject();
com.alibaba.fastjson.JSONObject name = new com.alibaba.fastjson.JSONObject();
name.put("value", "做一个身体和心灵都勇敢的人,趁着身体未老,心灵还透明。晚安!");
data.put("name", name);
com.alibaba.fastjson.JSONObject weather = new com.alibaba.fastjson.JSONObject();
weather.put("value", "阴天 19°c");
data.put("weather", weather);
com.alibaba.fastjson.JSONObject birthday = new com.alibaba.fastjson.JSONObject();
birthday.put("value", "53 天");
data.put("birthday", birthday);
map.put("data", data);
String r = HttpUtil.getJsonData(com.alibaba.fastjson.JSONObject.parseObject(JSON.toJSONString(map)),
"https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + token); //发送模板消息
System.out.println("-->" + r);
try {
JSONObject jsonObject = new JSONObject(r);
Object errcode = jsonObject.get("errcode");
objects.add(errcode);
} catch (Exception e) {
e.printStackTrace();
} finally {
latch.countDown();
}
});
}
try {
latch.await(); // 等待所有线程执行完毕
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} finally {
executor.shutdown();
}
return objects;
//map.put("url","https://www.vipkes.cn");//用户点击模板消息,要跳转的地址
// 封装miniprogram 跳转小程序用,不跳不要填
// Map<String, String> mapA = new HashMap<>();
// mapA.put("appid", ""); //小程序appid
// mapA.put("pagepath", ""); //小程序页面pagepath
// map.put("miniprogram", mapA);
}
//获取微信公众号全部关注人的openid
public static JSONArray getUserListOpenid(String accessToken) {
String url = "https://api.weixin.qq.com/cgi-bin/user/get?access_token=" + accessToken;
;
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");
jsonObj = com.alibaba.fastjson.JSONObject.parseObject(userOpenid);
is.close();
} catch (Exception e) {
e.printStackTrace();
}
com.alibaba.fastjson.JSONObject data = jsonObj.getJSONObject("data");
return data.getJSONArray("openid");
}
}

83
zc-business/src/main/java/com/zc/business/utils/HttpUtil.java

@ -0,0 +1,83 @@
package com.zc.business.utils;
import com.alibaba.fastjson.JSONObject;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
public class HttpUtil {
public static String getJsonData(JSONObject jsonParam, String urls) {
StringBuffer sb = new StringBuffer();
try {
// 创建url资源
URL url = new URL(urls);
// 建立http连接
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
// 设置允许输出
conn.setDoOutput(true);
// 设置允许输入
conn.setDoInput(true);
// 设置不用缓存
conn.setUseCaches(false);
// 设置传递方式
conn.setRequestMethod("POST");
// 设置维持长连接
conn.setRequestProperty("Connection", "Keep-Alive");
// 设置文件字符集:
conn.setRequestProperty("Charset", "UTF-8");
// 转换为字节数组
byte[] data = (jsonParam.toString()).getBytes();
// 设置文件长度
conn.setRequestProperty("Content-Length", String.valueOf(data.length));
// 设置文件类型:
conn.setRequestProperty("contentType", "application/json");
// 开始连接请求
conn.connect();
//OutputStream out = new DataOutputStream(conn.getOutputStream()) ;
//防止消息乱码
OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream(), "utf-8");
// 写入请求的字符串
out.write(jsonParam.toString());
out.flush();
out.close();
System.out.println(conn.getResponseCode());
// 请求返回的状态
if (HttpURLConnection.HTTP_OK == conn.getResponseCode()) {
System.out.println("连接成功");
// 请求返回的数据
InputStream in1 = conn.getInputStream();
try {
String readLine = new String();
BufferedReader responseReader = new BufferedReader(new InputStreamReader(in1, "UTF-8"));
while ((readLine = responseReader.readLine()) != null) {
sb.append(readLine).append("\n");
}
responseReader.close();
System.out.println(sb.toString());
} catch (Exception e1) {
e1.printStackTrace();
}
} else {
System.out.println("error++");
}
} catch (Exception e) {
}
return sb.toString();
}
}

216
zc-business/src/main/java/com/zc/business/utils/PoiUtil.java

@ -5,6 +5,7 @@ import com.google.common.base.Strings;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.util.Units;
import org.apache.poi.xddf.usermodel.chart.XDDFChartData;
import org.apache.poi.xddf.usermodel.chart.XDDFDataSource;
import org.apache.poi.xddf.usermodel.chart.XDDFDataSourcesFactory;
@ -18,10 +19,8 @@ import org.springframework.util.StringUtils;
import java.io.*;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.Map.Entry;
/**
* @author : LCheng
@ -30,8 +29,6 @@ import java.util.Map;
*/
public class PoiUtil {
public static int headingCount1 = 1;
public static int headingCount2 = 1;
/**
* 根据word模板导出 针对图表柱状图折线图饼图等的处理
@ -365,5 +362,212 @@ public class PoiUtil {
tocField.setInstr(tocFieldCode);
tocField.setDirty(STOnOff.TRUE);
}
/**
* 替换段落文本
* @param document docx解析对象
* @param textMap 需要替换的信息集合
*/
public static void changeText(XWPFDocument document, Map<String, Object> textMap){
//获取段落集合
// 获取段落集合
Iterator<XWPFParagraph> iterator = document.getParagraphsIterator();
XWPFParagraph paragraph = null;
while (iterator.hasNext()) {
paragraph = iterator.next();
// 判断此段落是否需要替换
if (checkText(paragraph.getText())) {
replaceValue(paragraph, textMap);
}
}
}
/***
* @Description :检查文本中是否包含指定的字符(此处为$)
* @param text
* @return boolean
* @Date 2022/11/17 17:22
*/
public static boolean checkText(String text) {
boolean check = false;
if (text.contains("$")) {
check = true;
}
return check;
}
/**
* 替换图片
*
* @param document
* @param picData
* @throws Exception
*/
public static void changePic(XWPFDocument document, Map<String, Object> picData) throws Exception {
// 获取段落集合
Iterator<XWPFParagraph> iterator = document.getParagraphsIterator();
XWPFParagraph paragraph;
while (iterator.hasNext()) {
paragraph = iterator.next();
// 判断此段落是否需要替换
String text = paragraph.getText();
if (checkText(text)) {
replacePicValue(paragraph, picData);
}
}
}
/***
* @Description :替换表格内的文字
* @param document
* @param data
* @return void
* @Date 2022/11/18 11:29
*/
public static void changeTableText(XWPFDocument document, Map<String, Object> data) {
// 获取文件的表格
Iterator<XWPFTable> tableList = document.getTablesIterator();
XWPFTable table;
List<XWPFTableRow> rows;
List<XWPFTableCell> cells;
// 循环所有需要进行替换的文本,进行替换
while (tableList.hasNext()) {
table = tableList.next();
if (checkText(table.getText())) {
rows = table.getRows();
// 遍历表格,并替换模板
for (XWPFTableRow row : rows) {
cells = row.getTableCells();
for (XWPFTableCell cell : cells) {
// 判断单元格是否需要替换
if (checkText(cell.getText())) {
List<XWPFParagraph> paragraphs = cell.getParagraphs();
for (XWPFParagraph paragraph : paragraphs) {
replaceValue(paragraph, data);
}
}
}
}
}
}
}
/***
* @Description :替换表格内图片
* @param document
* @param picData
* @return void
* @Date 2022/11/18 11:29
*/
public static void changeTablePic(XWPFDocument document, Map<String, Object> picData) throws Exception {
// 获取文件的表格
Iterator<XWPFTable> tableList = document.getTablesIterator();
XWPFTable table;
List<XWPFTableRow> rows;
List<XWPFTableCell> cells;
// 循环所有需要进行替换的文本,进行替换
while (tableList.hasNext()) {
table = tableList.next();
if (checkText(table.getText())) {
rows = table.getRows();
// 遍历表格,并替换模板
for (XWPFTableRow row : rows) {
cells = row.getTableCells();
for (XWPFTableCell cell : cells) {
// 判断单元格是否需要替换
if (checkText(cell.getText())) {
List<XWPFParagraph> paragraphs = cell.getParagraphs();
for (XWPFParagraph paragraph : paragraphs) {
replacePicValue(paragraph, picData);
}
}
}
}
}
}
}
/***
* @Description :替换内容
* @param paragraph
* @param textMap
* @return void
* @Date 2022/11/18 11:33
*/
public static void replaceValue(XWPFParagraph paragraph, Map<String, Object> textMap) {
XWPFRun run, nextRun;
String runsText;
List<XWPFRun> runs = paragraph.getRuns();
for (int i = 0; i < runs.size(); i++) {
run = runs.get(i);
runsText = run.getText(0);
if (runsText.contains("${") || (runsText.contains("$") && runs.get(i + 1).getText(0).substring(0, 1).equals("{"))) {
while (!runsText.contains("}")) {
nextRun = runs.get(i + 1);
runsText = runsText + nextRun.getText(0);
//删除该节点下的数据
paragraph.removeRun(i + 1);
}
Object value = changeValue(runsText, textMap);
//判断key在Map中是否存在
if (textMap.containsKey(runsText)) {
if (value != null) {
run.setText(value.toString(), 0);
} else {
run.setText("", 0);
}
} else {
//如果匹配不到,则不修改
run.setText(runsText, 0);
}
}
}
}
/***
* @Description :替换图片内容
* @param paragraph
* @param picData
* @return void
* @Date 2022/11/18 11:33
*/
public static void replacePicValue(XWPFParagraph paragraph, Map<String, Object> picData) throws Exception {
List<XWPFRun> runs = paragraph.getRuns();
for (XWPFRun run : runs) {
Object value = changeValue(run.toString(), picData);
if (picData.containsKey(run.toString())) {
//清空内容
run.setText("", 0);
FileInputStream is = new FileInputStream((String) value);
//图片宽度、高度
int width = Units.toEMU(100), height = Units.toEMU(100);
//添加图片信息,段落高度需要在模板中自行调整
run.addPicture(is, XWPFDocument.PICTURE_TYPE_PNG, (String) value, width, height);
}
}
}
/***
* @Description :匹配参数
* @param value
* @param textMap
* @return java.lang.Object
* @Date 2022/11/18 11:33
*/
public static Object changeValue(String value, Map<String, Object> textMap) {
Object valu = "";
for (Map.Entry<String, Object> textSet : textMap.entrySet()) {
// 匹配模板与替换值 格式${key}
String key = textSet.getKey();
if (value.contains(key)) {
valu = textSet.getValue();
}
}
return valu;
}
}

82
zc-business/src/main/java/com/zc/business/utils/diff/AlgorithmEnum.java

@ -0,0 +1,82 @@
package com.zc.business.utils.diff;
import com.zc.business.utils.diff.algorithm.AlgorithmModule;
import com.zc.business.utils.diff.algorithm.array.SimilarArrayComparator;
import com.zc.business.utils.diff.algorithm.array.SimpleArrayComparator;
import com.zc.business.utils.diff.algorithm.nulls.DefaultNullComparator;
import com.zc.business.utils.diff.algorithm.object.LeftJoinObjectComparator;
import com.zc.business.utils.diff.algorithm.object.SimpleObjectComparator;
import com.zc.business.utils.diff.algorithm.other.DefaultOtherComparator;
import com.zc.business.utils.diff.algorithm.primitive.DefaultPrimitiveComparator;
/**
* 算法模型枚举类提供一些默认实现的算法模型
* @Author JingWei
* @create 2022/3/2
*/
public enum AlgorithmEnum {
/**
* 默认的比较算法模型
*/
DEFAULT(defaultAlgorithmModule()),
/**
* 数组比较采用Simple对象比较采用Simple
*/
SIMPLE_ARRAY_AND_SIMPLE_OBJECT(simpleAndSimpleAlgorithmModule()),
/**
* 数组比较采用Simple对象比较采用LeftJoin
*/
SIMPLE_ARRAY_AND_LEFTJOIN_OBJECT(simpleAndLeftJoinAlgorithmModule()),
/**
* 数组比较采用Similar对象比较采用LeftJoin
*/
SIMLAR_ARRAY_AND_LEFTJOIN_OBJECT(similarAndLeftJoinAlgorithmModule()),
/**
* 数组比较采用Similar对象比较采用Simple
*/
MOST_COMMONLY_USED(similarAndSimpleAlgorithmModule());
final private AlgorithmModule algorithmModule;
AlgorithmEnum(AlgorithmModule algorithmModule) {
this.algorithmModule = algorithmModule;
}
public AlgorithmModule getAlgorithmModule() {
return algorithmModule;
}
private static AlgorithmModule defaultAlgorithmModule() {
return new AlgorithmModule(new SimpleObjectComparator(), new SimilarArrayComparator(),
new DefaultPrimitiveComparator(), new DefaultNullComparator(), new DefaultOtherComparator());
}
private static AlgorithmModule simpleAndSimpleAlgorithmModule() {
return new AlgorithmModule(new SimpleObjectComparator(), new SimpleArrayComparator(),
new DefaultPrimitiveComparator(), new DefaultNullComparator(), new DefaultOtherComparator());
}
private static AlgorithmModule simpleAndLeftJoinAlgorithmModule() {
return new AlgorithmModule(new LeftJoinObjectComparator(), new SimpleArrayComparator(),
new DefaultPrimitiveComparator(), new DefaultNullComparator(), new DefaultOtherComparator());
}
private static AlgorithmModule similarAndLeftJoinAlgorithmModule() {
return new AlgorithmModule(new LeftJoinObjectComparator(), new SimilarArrayComparator(),
new DefaultPrimitiveComparator(), new DefaultNullComparator(), new DefaultOtherComparator());
}
private static AlgorithmModule similarAndSimpleAlgorithmModule() {
return new AlgorithmModule(new SimpleObjectComparator(), new SimilarArrayComparator(),
new DefaultPrimitiveComparator(), new DefaultNullComparator(), new DefaultOtherComparator());
}
}

208
zc-business/src/main/java/com/zc/business/utils/diff/Diff.java

@ -0,0 +1,208 @@
package com.zc.business.utils.diff;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.zc.business.utils.diff.algorithm.AlgorithmModule;
import com.zc.business.utils.diff.algorithm.array.ArrayComparator;
import com.zc.business.utils.diff.algorithm.array.SimilarArrayComparator;
import com.zc.business.utils.diff.algorithm.nulls.DefaultNullComparator;
import com.zc.business.utils.diff.algorithm.nulls.NullComparator;
import com.zc.business.utils.diff.algorithm.object.ObjectComparator;
import com.zc.business.utils.diff.algorithm.object.SimpleObjectComparator;
import com.zc.business.utils.diff.algorithm.other.DefaultOtherComparator;
import com.zc.business.utils.diff.algorithm.other.OtherComparator;
import com.zc.business.utils.diff.algorithm.primitive.DefaultPrimitiveComparator;
import com.zc.business.utils.diff.algorithm.primitive.PrimitiveComparator;
import com.zc.business.utils.diff.model.DiffContext;
import com.zc.business.utils.diff.model.PathModule;
import com.zc.business.utils.diff.model.Result;
import com.zc.business.utils.diff.model.ResultConvertUtil;
import java.util.List;
/**
* DIFF入口用于比较两个Json字符串
* @Author JingWei
* @create 2022/2/25
*/
public class Diff {
/**
* 算法模型根据传入的算法模型使用该算法模型进行diff比较
*/
private AlgorithmEnum algorithmEnum;
/**
* 特殊路径集合当前路径符合特殊路径且特殊路径下比较结果相同会在返回结果中做额外标识标识
*/
private List<String> specialPath;
/**
* 噪音字段集合如果当前路径符合噪音字段路径则不会比较
*/
private List<String> noisePahList;
/**
* 以下为5种可以自定义的比较器条件是algorithmEnum为空如果algorithmEnum有值直接使用algorithmEnum对应算法模型比较器不生效
*/
private ObjectComparator objectComparator;
private ArrayComparator arrayComparator;
private PrimitiveComparator primitiveComparator;
private NullComparator nullComparator;
private OtherComparator otherComparator;
/**
* @param a 要比较的第一个JsonElement
* @param b 要比较的第二个JsonElement
* @return 用来展示的diff结果
*/
public List<Result> diffElement(JsonElement a, JsonElement b) {
DiffContext diffContext;
//用噪音路径和自定义路径构造路径模型
PathModule pathModule = new PathModule(noisePahList, specialPath);
//如果有算法模型直接使用算法模型
if(algorithmEnum != null){
diffContext = algorithmEnum.getAlgorithmModule().diffElement(a, b, pathModule);
}//如果也没有比较器,直接用默认算法模型
else if(objectComparator == null && arrayComparator == null && primitiveComparator == null && nullComparator == null && otherComparator == null){
diffContext = AlgorithmEnum.DEFAULT.getAlgorithmModule().diffElement(a, b, pathModule);
}//如果有比较器,为空的比较器用默认替换,然后构造算法模型,
else {
constrcutDefaultComparator();
diffContext = new AlgorithmModule(objectComparator, arrayComparator, primitiveComparator, nullComparator, otherComparator).diffElement(a, b, pathModule);
}
return ResultConvertUtil.constructResult(diffContext);
}
/**
* @param strA 要比较的第一个字符串
* @param strB 要比较的第二个字符串
* @return 用来展示的diff结果
*/
public List<Result> diff(String strA, String strB) {
return diffElement(new JsonParser().parse(strA), new JsonParser().parse(strB));
}
public Diff() {
}
/**
* 没有初始的比较器替换成默认的
*/
private void constrcutDefaultComparator() {
//如果没有初始化算法,则采用默认的算法。
if(objectComparator == null){
objectComparator = defaultObjectComparator();
}
if(arrayComparator == null){
arrayComparator = defaultArrayComparator();
}
if(primitiveComparator == null){
primitiveComparator = defaultPrimitiveComparator();
}
if(nullComparator == null){
nullComparator = defaultNullComparator();
}
if(otherComparator == null){
otherComparator = defaultOtherComparator();
}
}
private ObjectComparator defaultObjectComparator() {
return new SimpleObjectComparator();
}
private ArrayComparator defaultArrayComparator() {
return new SimilarArrayComparator();
}
private PrimitiveComparator defaultPrimitiveComparator() {
return new DefaultPrimitiveComparator();
}
private NullComparator defaultNullComparator() {
return new DefaultNullComparator();
}
private OtherComparator defaultOtherComparator() {
return new DefaultOtherComparator();
}
/**
* 选择算法模型
* @param algorithmEnum 算法模型枚举类
* @return 对象本身
*/
public Diff withAlgorithmEnum(AlgorithmEnum algorithmEnum){
this.algorithmEnum = algorithmEnum;
return this;
}
/**
* 设置自定义路径
* @param specialPath 自定义路径列表
* @return 对象本身
*/
public Diff withSpecialPath(List<String> specialPath){
this.specialPath = specialPath;
return this;
}
/**
* 设置噪音路径
* @param noisePahList 噪音路径列表
* @return 对象本身
*/
public Diff withNoisePahList(List<String> noisePahList){
this.noisePahList = noisePahList;
return this;
}
/**
* 自定义对象比较器
* @param objectComparator 对象比较器
* @return 对象本身
*/
public Diff withObjectComparator(ObjectComparator objectComparator) {
this.objectComparator = objectComparator;
return this;
}
/**
* 自定义数组比较器
* @param arrayComparator 数组比较器
* @return 对象本身
*/
public Diff withArrayComparator(ArrayComparator arrayComparator) {
this.arrayComparator = arrayComparator;
return this;
}
/**
* 自定义基本类型比较器
* @param primitiveComparator 基本类型比较器
* @return 对象本身
*/
public Diff withPrimitiveAlgorithm(PrimitiveComparator primitiveComparator) {
this.primitiveComparator = primitiveComparator;
return this;
}
/**
* 自定义空类型比较器
* @param nullComparator 空类型比较器
* @return 对象本身
*/
public Diff withNullComparator(NullComparator nullComparator) {
this.nullComparator = nullComparator;
return this;
}
/**
* 自定义其他类型比较器
* @param otherComparator 其他类型比较器
* @return 对象本身
*/
public Diff withOtheComparator(OtherComparator otherComparator) {
this.otherComparator = otherComparator;
return this;
}
}

49
zc-business/src/main/java/com/zc/business/utils/diff/algorithm/AbstractObjectAndArray.java

@ -0,0 +1,49 @@
package com.zc.business.utils.diff.algorithm;
import com.google.gson.JsonElement;
import com.zc.business.utils.diff.model.Constants;
import com.zc.business.utils.diff.model.DiffContext;
import com.zc.business.utils.diff.model.PathModule;
import com.zc.business.utils.diff.model.SingleNodeDifference;
/**
* 数组和对象比较的公有方法抽象类
* @Author JingWei
* @create 2022/3/1
*/
public abstract class AbstractObjectAndArray {
protected AlgorithmModule algorithmModule;
/**
* diff算法比较核心方法比较2个JsonElement的入口
* @param a 比较的第一个JsonElement
* @param b 比较的第二个JsonElement
* @param pathModule 路径模型
* @return 不同的比较结果
*/
public DiffContext diffElement(JsonElement a, JsonElement b, PathModule pathModule) {
return algorithmModule.diffElement(a, b, pathModule);
}
/**
* 构造算法模型,比如使用对象和数组类型算法比较时内部会用到其他类型的算法
* @param algorithmModule 算法模型
*/
public void constructAlgorithmModule(AlgorithmModule algorithmModule) {
this.algorithmModule = algorithmModule;
}
/**
* 如果下层diff结果不同会把下层diff结果加入到上层diff结果中去
* @param parentResult 上层结果
* @param childResult 下层结果
*/
public void parentContextAddChildContext(DiffContext parentResult, DiffContext childResult) {
if(childResult.isSame() == Constants.DIFFERENT) {
for (SingleNodeDifference singleNodeDifference : childResult.getDiffResultModels()) {
parentResult.getDiffResultModels().add(singleNodeDifference);
}
parentResult.setSame(false);
}
}
}

34
zc-business/src/main/java/com/zc/business/utils/diff/algorithm/AbstractPrimitiveAndOther.java

@ -0,0 +1,34 @@
package com.zc.business.utils.diff.algorithm;
import com.google.gson.JsonElement;
/**
* 基本类型和其它类型比较的公有方法抽象类
* @Author JingWei
* @create 2022/1/11
*/
public abstract class AbstractPrimitiveAndOther {
/**
* 将比较的元素转换成String类型方便结果展示
* @param element 元素
* @return 元素转换成的字符串
*/
protected static String jsonElement2Str(JsonElement element){
//该对象不存在的情况
if(element == null){
return null;
} else if (element.isJsonObject()) {
return "{省略内部字段}";
} else if (element.isJsonArray()) {
return "[省略内部元素]";
} else if (element.isJsonPrimitive()) {
return element.getAsJsonPrimitive().getAsString();
} else if (element.isJsonNull()) {
return "null";
}else{
throw new RuntimeException("异常");
}
}
}

66
zc-business/src/main/java/com/zc/business/utils/diff/algorithm/AlgorithmModule.java

@ -0,0 +1,66 @@
package com.zc.business.utils.diff.algorithm;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.zc.business.utils.diff.algorithm.array.ArrayComparator;
import com.zc.business.utils.diff.algorithm.nulls.NullComparator;
import com.zc.business.utils.diff.algorithm.object.ObjectComparator;
import com.zc.business.utils.diff.algorithm.other.OtherComparator;
import com.zc.business.utils.diff.algorithm.primitive.PrimitiveComparator;
import com.zc.business.utils.diff.model.DiffContext;
import com.zc.business.utils.diff.model.PathModule;
/**
* 算法模型
* 算法模型包含5种比较器对象数组基本类型空类型其他类型比较器
* 当2个JsonElement的子类同时为对象数组基本类型空类型使用前4种比较器当2个JsonElement的子类类型不相同时使用其它类型比较器
* @Author JingWei
* @create 2022/1/13
*/
public class AlgorithmModule{
protected ObjectComparator objectAlgorithm;
protected ArrayComparator arrayAlgorithm;
protected PrimitiveComparator primitiveComparator;
protected NullComparator nullComparator;
protected OtherComparator otherComparator;
public AlgorithmModule(ObjectComparator objectAlgorithm, ArrayComparator arrayAlgorithm,
PrimitiveComparator primitiveComparator, NullComparator nullComparator, OtherComparator otherComparator) {
this.arrayAlgorithm = arrayAlgorithm;
this.objectAlgorithm = objectAlgorithm;
this.primitiveComparator = primitiveComparator;
this.nullComparator = nullComparator;
this.otherComparator = otherComparator;
objectAlgorithm.constructAlgorithmModule(this);
arrayAlgorithm.constructAlgorithmModule(this);
}
/**
* 判断要比较的两个JsonElement的类型并根据类型调用对应的算法进行比较
* @param a 要比较的第一个元素
* @param b 要比较的第二个元素
* @param pathModule 路径模型
* @return 返回比较结果
*/
public DiffContext diffElement(JsonElement a, JsonElement b, PathModule pathModule) {
if (a instanceof JsonObject && b instanceof JsonObject) {
return objectAlgorithm.diff( (JsonObject) a, (JsonObject) b, pathModule);
} else if (a instanceof JsonArray && b instanceof JsonArray) {
return arrayAlgorithm.diffArray((JsonArray) a, (JsonArray) b, pathModule);
} else if (a instanceof JsonPrimitive && b instanceof JsonPrimitive) {
return primitiveComparator.diff((JsonPrimitive) a, (JsonPrimitive) b, pathModule);
} else if (a instanceof JsonNull && b instanceof JsonNull) {
return nullComparator.diff((JsonNull) a, (JsonNull) b, pathModule);
} else {
return otherComparator.diff(a, b, pathModule);
}
}
public ArrayComparator getArrayAlgorithm() {
return arrayAlgorithm;
}
}

9
zc-business/src/main/java/com/zc/business/utils/diff/algorithm/Comparator.java

@ -0,0 +1,9 @@
package com.zc.business.utils.diff.algorithm;
/**
* 比较器最顶层的接口逻辑意义
* @Author JingWei
* @create 2022/3/2
*/
public interface Comparator {
}

22
zc-business/src/main/java/com/zc/business/utils/diff/algorithm/array/AbstractArray.java

@ -0,0 +1,22 @@
package com.zc.business.utils.diff.algorithm.array;
import com.zc.business.utils.diff.algorithm.AbstractObjectAndArray;
/**
* 数组比较的公有方法抽象类
* @Author JingWei
* @create 2022/3/1
*/
public abstract class AbstractArray extends AbstractObjectAndArray implements ArrayComparator {
/**
* 数组索引号加一个中括号表示数组路径
* @param i 数组元素的索引号
* @return 索引号增加中括号
*/
protected String constructArrayPath(Integer i){
if(i == null || i < 0 ){
throw new RuntimeException("数组索引号入参为空或者为负。 入参:" + i);
}
return "[" + i + "]";
}
}

43
zc-business/src/main/java/com/zc/business/utils/diff/algorithm/array/ArrayComparator.java

@ -0,0 +1,43 @@
package com.zc.business.utils.diff.algorithm.array;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.zc.business.utils.diff.algorithm.AlgorithmModule;
import com.zc.business.utils.diff.algorithm.Comparator;
import com.zc.business.utils.diff.model.DiffContext;
import com.zc.business.utils.diff.model.PathModule;
/**
* 数组类型比较器接口用于2个JsonElement均为数组时对2个元素进行比较
* @Author JingWei
* @create 2022/2/23
*/
public interface ArrayComparator extends Comparator {
/**
* 对两个JsonArray进行比较的方法
* @param a 要比较的第一个JsonArray
* @param b 要比较的第二个JsonArray
* @param pathModule 路径模型
* @return 返回不相等的结果
*/
DiffContext diffArray(JsonArray a, JsonArray b, PathModule pathModule) ;
/**
* 对象内部包含其他非数组类型对这些类型比较需要使用JsonElement比较方法
* @param a 要比较的第一个JsonElement
* @param b 要比较的第一个JsonElement
* @param pathModule 路径模型
* @return 返回不相等的结果
*/
DiffContext diffElement(JsonElement a, JsonElement b, PathModule pathModule);
/**
* 构造算法模型数组中元素比较需要使用到其他非数组算法
* @param algorithmModule 算法模型包含对象数组基本类型空类型其他类型算法
*/
void constructAlgorithmModule(AlgorithmModule algorithmModule);
}

252
zc-business/src/main/java/com/zc/business/utils/diff/algorithm/array/SimilarArrayComparator.java

@ -0,0 +1,252 @@
package com.zc.business.utils.diff.algorithm.array;
import com.google.gson.JsonArray;
import com.zc.business.utils.diff.model.DiffContext;
import com.zc.business.utils.diff.model.PathModule;
import com.zc.business.utils.diff.model.SingleNodeDifference;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
/**
* 相似度数组算法比较器:当数组进行比较找不到相等元素时通过算法优先找最接近的元素进行匹配
*
* 举例
*"[{\"a\":7,\"b\":5,\"c\":6},{\"a\":6,\"b\":2,\"c\":3}]"
*"[{\"a\":1,\"b\":2,\"c\":3},{\"a\":4,\"b\":5,\"c\":6},{\"a\":7,\"b\":8,\"c\":9}]"比较
* 数组一中第一个元素依次和数组二中元素比较分别有3组不同1组不同2组不同
* 数组一中第二个元素依次和数组二中元素比较分别有1组不同3组不同3组不同
* 得到相似矩阵如下
* 3 1 2
* 1 3 3
* 遍历矩阵所有元素找到值最小的元素并且行和列的其他元素不能再被使用行和列即为要比较的2个元素在各自数组中的索引号
* 第一次找到1第二次找到另外一个1.
* 遍历矩阵中未使用所有列列索引号为多余的元素在数组中的位置
* 只有第三列可以使用 第二组中第3个元素为新增元素
*
* @Author JingWei
* @create 2022/2/24
*/
public class SimilarArrayComparator extends AbstractArray {
/**
* USEABLE表示当前位置可以使用
*/
private final boolean USEABLE = false;
/**
* USED表示当前位置已经被使用过
*/
private final boolean USED = true;
/**
* @param a 要比较的第一个数组
* @param b 要比较的第二个数组
* @param pathModule 路径模型
* @return 返回不相等的结果
*/
@Override
public DiffContext diffArray(JsonArray a, JsonArray b, PathModule pathModule) {
DiffContext diffContext;
//a数组长度小于等于b,直接使用diff数组比较算法
if(a.size() <= b.size()){
diffContext = diff(a, b, pathModule);
}
//当a数组长度大于b时,需要交换pathModule中a和b路径, 并交换数组a和b,再使用diff数组比较算法
else {
exchangeLeftAndRightPath(pathModule);
diffContext = diff(b, a, pathModule);
exchangeLeftAndRightPath(pathModule);
exchangeResult(diffContext);
}
return diffContext;
}
/**
* 交换返回结果中每一个路径和结果
* @param diffContext 返回结果
*/
private void exchangeResult(DiffContext diffContext) {
List<SingleNodeDifference> singleNodeDifferences = diffContext.getDiffResultModels();
for(SingleNodeDifference singleNodeDifference : singleNodeDifferences){
exchangePathAndResult(singleNodeDifference);
}
}
/**
* 交换返回结果中的路径和结果
* @param singleNodeDifference 返回结果
*/
private void exchangePathAndResult(SingleNodeDifference singleNodeDifference) {
String tempStringA = singleNodeDifference.getLeftPath();
Object tempLeft = singleNodeDifference.getLeft();
singleNodeDifference.setLeftPath(singleNodeDifference.getRightPath());
singleNodeDifference.setRightPath(tempStringA);
singleNodeDifference.setLeft(singleNodeDifference.getRight());
singleNodeDifference.setRight(tempLeft);
}
/**
* 将路径模型中a和b的路径交换
* @param pathModule 路径模型
*/
private void exchangeLeftAndRightPath(PathModule pathModule) {
LinkedList<String> tempA = pathModule.getLeftPath();
pathModule.setLeftPath(pathModule.getRightPath());
pathModule.setRightPath(tempA);
}
/**
* 数组比较核心算法支持数组a长度小于b长度时使用
*/
DiffContext diff(JsonArray a, JsonArray b, PathModule pathModule ) {
int rowlength = a.size();
int linelength = b.size();
//a数组中m个元素,与b数组中n个元素比较,共比较m*n次,所有比较结果会得组成一个矩阵,矩阵中的数字用来存储比较结果。
int [][] similarMatrix = new int[rowlength][linelength];
//创建一个行和列数组 用来判断当前行和列是否被使用过
boolean []row = new boolean[rowlength];
boolean []line = new boolean[linelength];
for (int i = 0; i < rowlength; i++) {
pathModule.addLeftPath(constructArrayPath(i));
//a数组中m个元素,与b数组中n个元素比较,比较结果生成一个m*n的矩阵
constructSimilarMatrix(a, b, i, pathModule, similarMatrix, row, line);
pathModule.removeLastLeftPath();
}
return obtainDiffResult(a, b, pathModule, row, line, similarMatrix);
}
/**
* 通过相似度矩阵获取比较结果 第一步在矩阵找到最小的数字即找到最接近的几对结果 第二步找剩余未使用的列数即多余的元素
*/
private DiffContext obtainDiffResult(JsonArray a, JsonArray b, PathModule pathModule, boolean[] row, boolean[] line, int[][] similarMatrix) {
DiffContext arrayDiffContext = new DiffContext();
//找到a和b都有的结果,并且是最接近的几对结果
obtainModifyDiffResult(a,b,pathModule,row,line,similarMatrix, arrayDiffContext);
//a没有b有的结果,即新增的结果
obtainAddDiffResult(b,pathModule,line, arrayDiffContext);
return arrayDiffContext;
}
/**
* 得到新增的结果由于b数组长度大于a会有几个元素多余在选出a和b最接近的几对元素后剩下的几个元素被认为是新增的
*/
private void obtainAddDiffResult(JsonArray b, PathModule pathModule, boolean[] line, DiffContext arrayDiffContext) {
for (int j = 0; j < line.length; j++) {
if (line[j] == USED) {
continue;
}
DiffContext addOrDeleteDiffContext = constructAddContext(b, j, pathModule);
parentContextAddChildContext(arrayDiffContext, addOrDeleteDiffContext);
}
}
/**
* 从m*n的矩阵中选出最接近的几组结果矩阵中的数字越小说明2个元素比较时结果相差越少
*/
private void obtainModifyDiffResult(JsonArray a, JsonArray b, PathModule pathModule, boolean[] row, boolean[] line, int[][] similarMatrix, DiffContext arrayDiffContext) {
int counts = 0;
//找到还未使用行的数量(行数小于列数)
for (boolean value : row) {
if (Objects.equals(USEABLE, value)) {
counts++;
}
}
//不同结果对数等于未使用的行数
for (int n = 0; n < counts; n++) {
int bestLineIndex = 0;
int bestRowIndex = 0;
int minDiffPair = Integer.MAX_VALUE;
//遍历矩阵中所有元素,找最小的数字,矩阵中的数字越小,说明2个元素比较时结果相差越少
for (int i = 0; i < row.length; i++) {
for (int j = 0; j < line.length; j++) {
//如果行或列被使用,跳过该行
if (row[i] == USED || line[j] == USED) {
continue;
}
//如果当前元素数字更小,那么把当前行和列保存下来,数字更新为当前最优结果
if (similarMatrix[i][j] < minDiffPair) {
bestRowIndex = i;
bestLineIndex = j;
minDiffPair = similarMatrix[i][j];
}
}
}
//将找到的最优结果添加到返回结果中
DiffContext modifyDiffContext = constructModifyContext(a, b, bestRowIndex, bestLineIndex, pathModule);
row[bestRowIndex] = USED;
line[bestLineIndex] = USED;
parentContextAddChildContext(arrayDiffContext, modifyDiffContext);
}
}
/**
* 此时a数组没有该元素b数组有元素结果为新增
* @param b 数组
* @param index 索引号
* @param pathModule 路径模型
* @return 生成的不同结果
*/
private DiffContext constructAddContext(JsonArray b, int index, PathModule pathModule) {
pathModule.addAllpath(constructArrayPath(index));
DiffContext diffContext = diffElement(null, b.get(index), pathModule);
pathModule.removeAllLastPath();
return diffContext;
}
/**
* 返回两个数组对应索引号元素比较结果
* @param a 数组a
* @param b 数组b
* @param i 数组a中元素的索引号
* @param bestLineIndex 数组b中元素的索引号即找到的和a中元素接接近的元素索引号
* @param pathModule 路径模型
* @return 返回不同的结果
*/
private DiffContext constructModifyContext(JsonArray a, JsonArray b, int i, int bestLineIndex, PathModule pathModule) {
pathModule.addLeftPath(constructArrayPath(i));
pathModule.addRightPath(constructArrayPath(bestLineIndex));
DiffContext diffContext = diffElement(a.get(i), b.get(bestLineIndex), pathModule);
pathModule.removeAllLastPath();
return diffContext;
}
/**
* 用数组a的一个元素与数组b中所有元素分别比较会得到n次比较结果结果为不相等的结果对数在矩阵中更新n次结果
*/
private void constructSimilarMatrix(JsonArray arrayA, JsonArray arrayB, int rowIndex, PathModule pathModule, int [][]similarArray, boolean[] row, boolean[] line) {
if(rowIndex < 0 || rowIndex >= arrayB.size()){
throw new RuntimeException("索引号入参超出数组长度。 索引号:" + rowIndex +" 数组B:" + arrayB);
}
for (int j = 0; j < arrayB.size(); j++) {
if (line[j] == USEABLE) {
pathModule.addRightPath(constructArrayPath(j));
DiffContext diffContext = diffElement(arrayA.get(rowIndex), arrayB.get(j), pathModule);
pathModule.removeLastRightPath();
if (diffContext.isSame()) {
row[rowIndex] = USED;
line[j] = USED;
return;
} else if(existSpecialPath(diffContext.getSpecialPathResult())){
similarArray[rowIndex][j] = 0 ;
} else {
similarArray[rowIndex][j] = diffContext.getDiffResultModels().size();
}
}
}
}
/**
* 判断比较结果是否有特殊路径
*/
private boolean existSpecialPath(LinkedList<String> specialPathResult) {
return specialPathResult != null && !specialPathResult.isEmpty();
}
}

62
zc-business/src/main/java/com/zc/business/utils/diff/algorithm/array/SimpleArrayComparator.java

@ -0,0 +1,62 @@
package com.zc.business.utils.diff.algorithm.array;
import com.google.gson.JsonArray;
import com.zc.business.utils.diff.model.DiffContext;
import com.zc.business.utils.diff.model.PathModule;
/**
* 简单数组比较器数组对比时按照索引号顺序依次进行比较
* [A,B,C] [C,B,A]比较时依次找索引号为0为1为2进行比较相同结果对为<A,C> <B,B> <C,A>不同结果<A,C> <C,A>会加入到返回结果中
* @Author JingWei
* @create 2022/1/14
*/
public class SimpleArrayComparator extends AbstractArray {
/**
* 对两个JsonArray进行比较的方法
* @param a 要比较的第一个数组
* @param b 要比较的第二个数组
* @param pathModule 路径模型
* @return 返回不相等的比较结果
*/
@Override
public DiffContext diffArray(JsonArray a, JsonArray b, PathModule pathModule) {
DiffContext arrayDiffContext = new DiffContext();
int maxLength = Math.max(a.size(), b.size());
//根据数组a和b长度的大的值进行遍历
for (int i = 0; i < maxLength; i++) {
pathModule.addAllpath(constructArrayPath(i));
DiffContext diffContext = generateDiffResult(a,b,i,pathModule);
parentContextAddChildContext(arrayDiffContext, diffContext);
}
return arrayDiffContext;
}
/**
* 生成比较结果,分以下3种情况考虑
* i < a.size() && i < b.size()
* a.size() <= i
* b.size() <= i
* @param a 数组a
* @param b 数组b
* @param i 数组a和b中正在比较的元素索引号
* @param pathModule 路径模型
* @return 返回不相等的比较结果
*/
private DiffContext generateDiffResult(JsonArray a, JsonArray b, int i, PathModule pathModule) {
if(i >= a.size() && i >= b.size()){
throw new RuntimeException("数组索引号入参超过数组长度。 索引号:" + i + " 数组a:" + a + "数组b:" + b);
}
DiffContext diffContext;
if(i < a.size() && i < b.size()){
diffContext = diffElement(a.get(i), b.get(i), pathModule);
}else if (i >= a.size()){
diffContext = diffElement(null, b.get(i), pathModule);
}else{
diffContext = diffElement(a.get(i), null, pathModule);
}
return diffContext;
}
}

27
zc-business/src/main/java/com/zc/business/utils/diff/algorithm/nulls/DefaultNullComparator.java

@ -0,0 +1,27 @@
package com.zc.business.utils.diff.algorithm.nulls;
import com.google.gson.JsonNull;
import com.zc.business.utils.diff.model.DiffContext;
import com.zc.business.utils.diff.model.PathModule;
/**
* 当要比较的两个JsonElement都为空类型时默认实现的算法比较器
* @Author JingWei
* @create 2022/1/10
*/
public class DefaultNullComparator implements NullComparator {
/**
* 当要比较的两个JsonElement是空类型时默认比较方法
* @param a 第一个空类型
* @param b 第二个空类型
* @param pathModule 路径模型
* @return 返回结果
*/
@Override
public DiffContext diff(JsonNull a, JsonNull b, PathModule pathModule){
return new DiffContext();
}
}

25
zc-business/src/main/java/com/zc/business/utils/diff/algorithm/nulls/NullComparator.java

@ -0,0 +1,25 @@
package com.zc.business.utils.diff.algorithm.nulls;
import com.google.gson.JsonNull;
import com.zc.business.utils.diff.algorithm.Comparator;
import com.zc.business.utils.diff.model.DiffContext;
import com.zc.business.utils.diff.model.PathModule;
/**
* 空类型比较器接口用于2个JsonElement均为JsonNull时对2个元素进行比较
* @Author JingWei
* @create 2022/2/23
*/
public interface NullComparator extends Comparator {
/**
* 对两个JsonNull进行比较时需要实现此方法
* @param a 要比较的第一个JsonNull
* @param b 要比较的第二个JsonNull
* @param pathModule 路径模型
* @return 返回不同的比较结果
*/
DiffContext diff(JsonNull a, JsonNull b, PathModule pathModule);
}

128
zc-business/src/main/java/com/zc/business/utils/diff/algorithm/object/AbstractObject.java

@ -0,0 +1,128 @@
package com.zc.business.utils.diff.algorithm.object;
import com.google.common.base.Joiner;
import com.google.gson.JsonObject;
import com.zc.business.utils.diff.algorithm.AbstractObjectAndArray;
import com.zc.business.utils.diff.model.Constants;
import com.zc.business.utils.diff.model.DiffContext;
import com.zc.business.utils.diff.model.PathModule;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 对象比较的一些公有方法抽象类
* @Author JingWei
* @create 2022/2/24
*/
public abstract class AbstractObject extends AbstractObjectAndArray implements ObjectComparator {
/**
* 对两个对象进行比较遍历keySet中的所有key 在a和b对象中找对应的value值进行比较
* @param a 要比较的第一个对象
* @param b 要比较的第二个对象
* @param keySet key的集合
* @param pathModule 路径模型
* @return 不同的比较结果
*/
protected DiffContext diffValueByKey(JsonObject a, JsonObject b, Set<String> keySet, PathModule pathModule) {
DiffContext objectDiffContext = new DiffContext();
LinkedList<String> specialPathResult = new LinkedList<>();
for (String key : keySet) {
//更新a和b当前路径
pathModule.addAllpath(key);
//如果对象当前路径在噪音路径集合中,直接跳过比较
if (!needDiff(pathModule.getNoisePahList(), pathModule.getLeftPath())) {
pathModule.removeAllLastPath();
continue;
}
//生成比较结果
DiffContext diffContext = diffElement(a.get(key), b.get(key), pathModule);
parentContextAddChildContext(objectDiffContext, diffContext);
//特殊路径处理
specialPathHandle(diffContext.isSame(), specialPathResult, pathModule);
pathModule.removeAllLastPath();
}
objectDiffContext.setSpecialPathResult(specialPathResult);
return objectDiffContext;
}
/**
* 如果比较的路径为特殊路径并且比较相等特殊路径会被标识添加到返回结果中
* @param isSame 比较结果是否相等
* @param specialPathResult 返回的特殊路径结果
* @param pathModule 路径模型
*/
private void specialPathHandle(boolean isSame,LinkedList<String> specialPathResult, PathModule pathModule) {
//如果比较结果不等,直接返回。
if (!isSame){
return;
}
//如果存在特殊路径,将特殊路径加入到集合中
String specialPath = getSpecialPath(pathModule);
if( existPath(specialPath)){
specialPathResult.add(specialPath);
}
}
/**
* 校验路径是否存在即路径是否为空
* @param specialPath 特殊路径
* @return 特殊路径是否为空
*/
private boolean existPath(String specialPath) {
return specialPath != null;
}
/**
* 判断当前路径是否在特殊路径集合中如果在则返回特殊路径
* @param pathModule 路径模型
* @return 返回的特殊路径字符串
*/
protected String getSpecialPath(PathModule pathModule) {
if(pathModule == null || pathModule.getSpecialPath() == null || pathModule.getSpecialPath().isEmpty()){
return null;
}
String currentPath = listJoin(pathModule.getLeftPath());
if(pathModule.getSpecialPath().contains(currentPath)){
return currentPath;
}
return null;
}
/**
* 判断当前字段是否需要diff如果在噪音字段集合中则不需要diff返回false
* @param noisePahList 噪音路径列表
* @param pathList 当前路径
* @return 当前路径是否在噪音路径中
*/
protected boolean needDiff(List<String> noisePahList, LinkedList<String> pathList) {
if(noisePahList == null || pathList == null || noisePahList.isEmpty() || pathList.isEmpty()){
return true;
}
String path = listJoin(pathList);
if(noisePahList.contains(path)){
return false;
}
return true;
}
/**
* 将path路径列表改为字符串
* @param path 当前路径
* @return 当前路径字符串
*/
protected String listJoin(LinkedList<String> path) {
if(path == null){
throw new RuntimeException("当前路径不能为空");
}
List<String> collect = path.stream().filter(e -> e.charAt(0) != '[').collect(Collectors.toList());
return Joiner.on(Constants.MERGE_PATH).join(collect);
}
}

30
zc-business/src/main/java/com/zc/business/utils/diff/algorithm/object/LeftJoinObjectComparator.java

@ -0,0 +1,30 @@
package com.zc.business.utils.diff.algorithm.object;
import com.google.gson.JsonObject;
import com.zc.business.utils.diff.model.DiffContext;
import com.zc.business.utils.diff.model.PathModule;
/**
* 左匹配对象比较器当对两个JsonObject进行比较时只对第一个对象中keySet中存在keyValue值进行比较
*
* 举例
* {"a":1,"b":2,"c":3}{"a":1,"b":4,"c":3,"d":4}进行比较
* 只会比较第一个对象中有的字段即比较第一个对象中有的"a","b","c"3个字段第二个对象中的"d"字段没有被比较
*
* @Author JingWei
* @create 2022/2/18
*/
public class LeftJoinObjectComparator extends AbstractObject {
/**
* @param a 要比较的第一个JsonObject
* @param b 要比较的第二个JsonObject
* @param pathModule 路径模型
* @return 不同的比较结果
*/
@Override
public DiffContext diff(JsonObject a, JsonObject b, PathModule pathModule){
//用a的keySet作为遍历集合。
return diffValueByKey(a, b, a.keySet(), pathModule);
}
}

40
zc-business/src/main/java/com/zc/business/utils/diff/algorithm/object/ObjectComparator.java

@ -0,0 +1,40 @@
package com.zc.business.utils.diff.algorithm.object;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.zc.business.utils.diff.algorithm.AlgorithmModule;
import com.zc.business.utils.diff.algorithm.Comparator;
import com.zc.business.utils.diff.model.DiffContext;
import com.zc.business.utils.diff.model.PathModule;
/**
* 对象类型比较器接口用于2个JsonElement均为JsonObject时对2个元素进行比较
* @Author JingWei
* @create 2022/2/23
*/
public interface ObjectComparator extends Comparator {
/**
* 对两个JsonObject进行比较时需要实现此方法
* @param a 要比较的第一个JsonObject
* @param b 要比较的第二个JsonObject
* @param pathModule 路径模型
* @return 返回不同的比较结果
*/
DiffContext diff(JsonObject a, JsonObject b, PathModule pathModule);
/**
* 对象内部包含其他非JsonObject类型对这些类型比较需要使用JsonElement比较方法
* @param a 元素a
* @param b 元素b
* @param pathModule 路径模型
* @return 返回不同的比较结果
*/
DiffContext diffElement(JsonElement a, JsonElement b, PathModule pathModule);
/**
* 构造算法模型对象比较时内部元素比较需要使用到其他非数组算法
* @param algorithmModule 算法模型包含对象数组基本类型空类型其他类型算法
*/
void constructAlgorithmModule(AlgorithmModule algorithmModule);
}

33
zc-business/src/main/java/com/zc/business/utils/diff/algorithm/object/SimpleObjectComparator.java

@ -0,0 +1,33 @@
package com.zc.business.utils.diff.algorithm.object;
import com.google.common.collect.Sets;
import com.google.gson.JsonObject;
import com.zc.business.utils.diff.model.DiffContext;
import com.zc.business.utils.diff.model.PathModule;
import java.util.Set;
/**
* 简单对象比较器当对两个JsonObject进行比较时两个对象所有keySet中key对应的Value都会被比较
* 举例
* {"b":2,"c":3}{"a":1,"d":4}进行比较
* 会比较两个对象中所有的字段即比较两个对象中并集"a","b","c","d"4个字段
* @Author JingWei
* @create 2022/2/16
*/
public class SimpleObjectComparator extends AbstractObject {
/**
* @param a 要比较的第一个JsonObject
* @param b 要比较的第二个JsonObject
* @param pathModule 路径模型
* @return 不同的比较结果
*/
@Override
public DiffContext diff(JsonObject a, JsonObject b, PathModule pathModule) {
Set<String> unionSet = Sets.union(a.keySet(), b.keySet());
//用a和b的keySet的并集作为遍历集合。
return diffValueByKey(a, b, unionSet, pathModule);
}
}

38
zc-business/src/main/java/com/zc/business/utils/diff/algorithm/other/DefaultOtherComparator.java

@ -0,0 +1,38 @@
package com.zc.business.utils.diff.algorithm.other;
import com.google.common.base.Joiner;
import com.google.gson.JsonElement;
import com.zc.business.utils.diff.algorithm.AbstractPrimitiveAndOther;
import com.zc.business.utils.diff.model.Constants;
import com.zc.business.utils.diff.model.DiffContext;
import com.zc.business.utils.diff.model.PathModule;
import com.zc.business.utils.diff.model.SingleNodeDifference;
import java.util.ArrayList;
import java.util.List;
/**
* 当要比较的两个JsonElement的不同时为对象组数基本类型时默认实现的比较器
* @Author JingWei
* @create 2022/1/10
*/
public class DefaultOtherComparator extends AbstractPrimitiveAndOther implements OtherComparator {
/**
* @param a 要比较的第一个JsonElement
* @param b 要比较的第二个JsonElement
* @param pathModule 路径模型
* @return 不同的比较结果
*/
@Override
public DiffContext diff(JsonElement a, JsonElement b, PathModule pathModule){
//比较结果一定会不同,因为要比较的a和b类型不同才会调用该方法。
DiffContext otherDiffContext = new DiffContext(Constants.DIFFERENT);
List<SingleNodeDifference> singleNodeDifferences = new ArrayList<>();
singleNodeDifferences.add(new SingleNodeDifference(Joiner.on(Constants.MERGE_PATH).join(pathModule.getLeftPath()), Joiner.on(Constants.MERGE_PATH).join(pathModule.getRightPath()), jsonElement2Str(a), jsonElement2Str(b)));
otherDiffContext.setDiffResultModels(singleNodeDifferences);
return otherDiffContext;
}
}

24
zc-business/src/main/java/com/zc/business/utils/diff/algorithm/other/OtherComparator.java

@ -0,0 +1,24 @@
package com.zc.business.utils.diff.algorithm.other;
import com.google.gson.JsonElement;
import com.zc.business.utils.diff.algorithm.Comparator;
import com.zc.business.utils.diff.model.DiffContext;
import com.zc.business.utils.diff.model.PathModule;
/**
* 其他类型比较器接口用于2个JsonElement不同时为对象数组基本类型时对2个元素进行比较
*
* 举例第一个要比较类型为对象类型第二个要比较类型为数组类型
* @Author JingWei
* @create 2022/2/23
*/
public interface OtherComparator extends Comparator {
/**
* 对两个JsonElement进行比较并且两个JsonElement的类型不相等时需要实现此方法
* @param a 要比较的第一个JsonElement
* @param b 要比较的第二个JsonElement
* @return 不同的比较结果
*/
DiffContext diff(JsonElement a, JsonElement b, PathModule pathModule);
}

39
zc-business/src/main/java/com/zc/business/utils/diff/algorithm/primitive/DefaultPrimitiveComparator.java

@ -0,0 +1,39 @@
package com.zc.business.utils.diff.algorithm.primitive;
import com.google.common.base.Joiner;
import com.google.gson.JsonPrimitive;
import com.zc.business.utils.diff.algorithm.AbstractPrimitiveAndOther;
import com.zc.business.utils.diff.model.Constants;
import com.zc.business.utils.diff.model.DiffContext;
import com.zc.business.utils.diff.model.PathModule;
import com.zc.business.utils.diff.model.SingleNodeDifference;
import java.util.ArrayList;
import java.util.List;
/**
* 当要比较的两个JsonElement是基本类型时默认实现的比较器
* @Author JingWei
* @create 2022/1/10
*/
public class DefaultPrimitiveComparator extends AbstractPrimitiveAndOther implements PrimitiveComparator {
/**
* @param a 要比较的第一个JsonPrimitive
* @param b 要比较的第二个JsonPrimitive
* @param pathModule 路径模型
* @return 不同的比较结果
*/
@Override
public DiffContext diff(JsonPrimitive a, JsonPrimitive b, PathModule pathModule){
DiffContext primitiveDiffContext = new DiffContext();
//如果a和b不相等,返回a和b的比较结果。
if(Constants.DIFFERENT == a.equals(b)) {
List<SingleNodeDifference> singleNodeDifferences = new ArrayList<>();
singleNodeDifferences.add(new SingleNodeDifference(Joiner.on(Constants.MERGE_PATH).join(pathModule.getLeftPath()), Joiner.on(Constants.MERGE_PATH).join(pathModule.getRightPath()), jsonElement2Str(a), jsonElement2Str(b)));
primitiveDiffContext.setDiffResultModels(singleNodeDifferences);
primitiveDiffContext.setSame(Constants.DIFFERENT);
}
return primitiveDiffContext;
}
}

23
zc-business/src/main/java/com/zc/business/utils/diff/algorithm/primitive/PrimitiveComparator.java

@ -0,0 +1,23 @@
package com.zc.business.utils.diff.algorithm.primitive;
import com.google.gson.JsonPrimitive;
import com.zc.business.utils.diff.algorithm.Comparator;
import com.zc.business.utils.diff.model.DiffContext;
import com.zc.business.utils.diff.model.PathModule;
/**
* 基本类型比较器接口用于2个JsonElement均为基本类型的时对2个元素进行比较
* @Author JingWei
* @create 2022/2/23
*/
public interface PrimitiveComparator extends Comparator {
/**
* 对两个基本类型进行比较时需要实现此方法
* @param a 要比较的第一个JsonPrimitive
* @param b 要比较的第二个JsonPrimitive
* @param pathModule 路径模型
* @return 不同的比较结果
*/
DiffContext diff(JsonPrimitive a, JsonPrimitive b, PathModule pathModule);
}

20
zc-business/src/main/java/com/zc/business/utils/diff/model/Constants.java

@ -0,0 +1,20 @@
package com.zc.business.utils.diff.model;
/**
* 常量
* @Author JingWei
* @create 2022/3/2
*/
public class Constants {
/**
* 描述比较结果不同
*/
public static final boolean DIFFERENT = false;
/**
* 描述比较结果相同
*/
public static final boolean SAME = true;
public static final String SPLIT_PATH = "\\.";
public static final String MERGE_PATH = ".";
}

61
zc-business/src/main/java/com/zc/business/utils/diff/model/DiffContext.java

@ -0,0 +1,61 @@
package com.zc.business.utils.diff.model;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
/**
* diff比较上下文
* @Author JingWei
* @create 2022/3/2
*/
public class DiffContext {
/**
* 比较结果是否相同
*/
private boolean isSame;
/**
* 比较结果不同时存储所有不同的结果对
*/
private List<SingleNodeDifference> singleNodeDifferences;
/**
* 比较结果中出现了特殊路径下值相等的情况会存储该特殊路径
*/
private LinkedList<String> specialPathResult;
public DiffContext(boolean isSame) {
this.isSame = isSame;
this.singleNodeDifferences = new ArrayList<>();
}
public boolean isSame() {
return isSame;
}
public void setSame(boolean same) {
isSame = same;
}
public List<SingleNodeDifference> getDiffResultModels() {
return singleNodeDifferences;
}
public void setDiffResultModels(List<SingleNodeDifference> singleNodeDifferences) {
this.singleNodeDifferences = singleNodeDifferences;
}
public DiffContext() {
this.isSame = true;
this.singleNodeDifferences = new ArrayList<>();
}
public LinkedList<String> getSpecialPathResult() {
return specialPathResult;
}
public void setSpecialPathResult(LinkedList<String> specialPathResult) {
this.specialPathResult = specialPathResult;
}
}

122
zc-business/src/main/java/com/zc/business/utils/diff/model/PathModule.java

@ -0,0 +1,122 @@
package com.zc.business.utils.diff.model;
import java.util.LinkedList;
import java.util.List;
/**
* 路径模型
* A和B比较时实时更新当前正在进行比较的元素路径
*
* @Author JingWei
* @create 2022/2/15
*/
public class PathModule {
/**
* 对象A当前遍历到的路径
*/
private LinkedList<String> leftPath;
/**
* 对象B当前遍历到的路径
*/
private LinkedList<String> rightPath;
/**
* 特殊路径集合当前路径符合特殊路径且特殊路径下比较结果相同会在返回结果中做额外标识标识
*/
private List<String> specialPath;
/**
* 噪音字段集合如果当前路径符合噪音字段路径则不会比较
*/
private List<String> noisePahList;
public PathModule() {
this.leftPath = new LinkedList<>();
this.rightPath = new LinkedList<>();
}
public PathModule(List<String> noisePahList) {
this.leftPath = new LinkedList<>();
this.rightPath = new LinkedList<>();
this.noisePahList = noisePahList;
}
public PathModule(List<String> noisePahList, List<String> specialPath) {
this.leftPath = new LinkedList<>();
this.rightPath = new LinkedList<>();
this.noisePahList = noisePahList;
this.specialPath = specialPath;
}
public List<String> getNoisePahList() {
return noisePahList;
}
public void setNoisePahList(List<String> noisePahList) {
this.noisePahList = noisePahList;
}
public List<String> getSpecialPath() {
return specialPath;
}
public void setSpecialPath(LinkedList<String> specialPath) {
this.specialPath = specialPath;
}
public LinkedList<String> getLeftPath() {
return leftPath;
}
public void setLeftPath(LinkedList<String> leftPath) {
this.leftPath = leftPath;
}
public LinkedList<String> getRightPath() {
return rightPath;
}
public void setRightPath(LinkedList<String> rightPath) {
this.rightPath = rightPath;
}
/**
* 同时在A和B路径列表最后加上一个Path路径
*/
public void addAllpath(String lastPath) {
leftPath.add(lastPath);
rightPath.add(lastPath);
}
public void addLeftPath(String lastPath) {
leftPath.add(lastPath);
}
public void addRightPath(String lastPath) {
rightPath.add(lastPath);
}
/**
* 同时移除A和B路径列表中最后的一个路径
*/
public void removeAllLastPath() {
leftPath.removeLast();
rightPath.removeLast();
}
/**
* 移除A路径列表中最后的一个路径
*/
public void removeLastLeftPath() {
leftPath.removeLast();
}
/**
* 移除B路径列表中最后的一个路径
*/
public void removeLastRightPath() {
rightPath.removeLast();
}
}

71
zc-business/src/main/java/com/zc/business/utils/diff/model/Result.java

@ -0,0 +1,71 @@
package com.zc.business.utils.diff.model;
import java.io.Serializable;
/**
* diff比较最终结果
* @Author JingWei
* @create 2022/3/2
*/
public class Result implements Serializable {
/**
* 第一个对象路径
*/
private String leftPath;
/**
* 第二个对象路径
*/
private String rightPath;
/**
* 第一个对象值
*/
private Object left;
/**
* 第二个对象值
*/
private Object right;
/**
* 比较结果
*/
private String diffType;
public String getLeftPath() {
return leftPath;
}
public String getRightPath() {
return rightPath;
}
public void setLeftPath(String leftPath) {
this.leftPath = leftPath;
}
public void setRightPath(String rightPath) {
this.rightPath = rightPath;
}
public Object getLeft() {
return left;
}
public void setLeft(Object left) {
this.left = left;
}
public Object getRight() {
return right;
}
public void setRight(Object right) {
this.right = right;
}
public String getDiffType() {
return diffType;
}
public void setDiffType(String diffType) {
this.diffType = diffType;
}
}

66
zc-business/src/main/java/com/zc/business/utils/diff/model/ResultConvertUtil.java

@ -0,0 +1,66 @@
package com.zc.business.utils.diff.model;
import java.util.ArrayList;
import java.util.Objects;
/**
* 结果转换工具:将diff上下文转换成diff最终结果
* @Author JingWei
* @create 2022/2/25
*/
public class ResultConvertUtil {
public static final String OBJECT_NULL = null;
//diff结果类型分为修改、新增、删除
public static final String TYPE_MODIFY = "MODIFY";
public static final String TYPE_ADD = "ADD";
public static final String TYPE_DELETE = "DELETE";
/**
* 将diff上下文转换成diff最终结果
* @param diffContext diff比较的直接结果
* @return diff展示的结果
*/
public static ArrayList<Result> constructResult(DiffContext diffContext) {
ArrayList<Result> list = new ArrayList<>();
for (SingleNodeDifference resultModel : diffContext.getDiffResultModels()) {
Result printModel = convert(resultModel);
boolean leftAndRightBothNull = (Objects.equals(OBJECT_NULL,resultModel.getLeft()))
&& Objects.equals(OBJECT_NULL,resultModel.getRight()) ;
//判断两个对象是否同时为空
if (leftAndRightBothNull) {
printModel.setDiffType(TYPE_MODIFY);
}
//这种情况为对象A中keySet没这个key,或者A数组长度小于B 数组中没这个元素。
else if (Objects.equals(OBJECT_NULL,resultModel.getLeft()) ) {
printModel.setDiffType(TYPE_ADD);
printModel.setLeftPath(null);
}
//这种情况为对象B中keySet没这个key,或者B数组长度小于A 数组中没这个元素。
else if (Objects.equals(OBJECT_NULL,resultModel.getRight()) ) {
printModel.setDiffType(TYPE_DELETE);
printModel.setRightPath(null);
}
//其他情况
else {
printModel.setDiffType(TYPE_MODIFY);
}
list.add(printModel);
}
return list;
}
/**
* 数据模型转换增加类型字段
* @param resultModel 比较结果
* @return 展示模型
*/
private static Result convert(SingleNodeDifference resultModel) {
Result printModel = new Result();
printModel.setLeft(resultModel.getLeft());
printModel.setRight(resultModel.getRight());
printModel.setLeftPath(resultModel.getLeftPath());
printModel.setRightPath(resultModel.getRightPath());
return printModel;
}
}

69
zc-business/src/main/java/com/zc/business/utils/diff/model/SingleNodeDifference.java

@ -0,0 +1,69 @@
package com.zc.business.utils.diff.model;
import java.io.Serializable;
/**
* 单对元素比较结果
* @Author JingWei
* @create 2022/3/2
*/
public class SingleNodeDifference implements Serializable {
/**
* 第一个对象路径
*/
private String leftPath;
/**
* 第二个对象路径
*/
private String rightPath;
/**
* 第一个对象值
*/
private Object left;
/**
* 第二个对象值
*/
private Object right;
/**
* 比较结果
*/
public SingleNodeDifference(String leftPath, String rightPath, Object left, Object right) {
this.leftPath = leftPath;
this.rightPath = rightPath;
this.left = left;
this.right = right;
}
public String getLeftPath() {
return leftPath;
}
public void setLeftPath(String leftPath) {
this.leftPath = leftPath;
}
public String getRightPath() {
return rightPath;
}
public void setRightPath(String rightPath) {
this.rightPath = rightPath;
}
public Object getLeft() {
return left;
}
public void setLeft(Object left) {
this.left = left;
}
public Object getRight() {
return right;
}
public void setRight(Object right) {
this.right = right;
}
}

21
zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml

@ -118,4 +118,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
GROUP BY device_type, child_type;
</select>
<select id="selectNearCamPile" resultMap="DcDevice">
select t1.id, t1.iot_device_id, t1.group_id, t1.product_id, t1.stake_mark, t1.direction, t1.device_name,
t1.device_code, t1.device_type,t1.installation_Date,t1.production_date,t1.durable_years,t1.installation_site,
t1.use_state,t1.device_state,t1.other_config,t1.remark,t1.create_time,t1.update_time,t1.facilities_type,
t1.device_ip,t1.stake_mark_range,t1.device_img,t1.child_type,t1.facilities_type,t2.longitude,t2.latitude
from dc_device t1
left join dc_stake_mark t2 on t1.stake_mark = t2.stake_mark and t1.direction = t2.direction
where !ISNULL(t1.iot_device_id) and t1.device_type = '1' and t1.direction = #{direction}
and t2.mileage >= #{startMileage} and t2.mileage &lt;= #{endMileage}
</select>
<select id="selectNearBoard" resultType="com.zc.business.domain.DcDevice">
select t1.id, t1.iot_device_id, t1.group_id, t1.product_id, t1.stake_mark, t1.direction, t1.device_name,
t1.device_code, t1.device_type,t1.installation_Date,t1.production_date,t1.durable_years,t1.installation_site,
t1.use_state,t1.device_state,t1.other_config,t1.remark,t1.create_time,t1.update_time,t1.facilities_type,
t1.device_ip,t1.stake_mark_range,t1.device_img,t1.child_type,t1.facilities_type,t2.longitude,t2.latitude
from dc_device t1
left join dc_stake_mark t2 on t1.stake_mark = t2.stake_mark and t1.direction = t2.direction
where t1.device_type = '2' and t1.direction = #{direction}
and t2.mileage >= #{startMileage} and t2.mileage &lt;= #{endMileage}
</select>
</mapper>

13
zc-business/src/main/resources/mapper/business/DcEmployeesMapper.xml

@ -14,13 +14,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" />
<result property="postName" column="post_name" />
<result property="organizationName" column="organization_name" />
<result property="employeesType" column="employees_type" />
</resultMap>
<sql id="selectDcEmployeesVo">
select employees.id, employees.post_id, employees.organization_id,
select employees.employees_type,employees.id, employees.post_id, employees.organization_id,
organization.organization_name,post.post_name,
employees.name, employees.contact_number,
employees.create_time, employees.update_time from dc_employees as employees
employees.create_time, employees.update_time,
CASE
WHEN employees.employees_type = 1 THEN '路管人员'
WHEN employees.employees_type = 2 THEN '交警人员'
END AS type
from dc_employees as employees
left join dc_organization as organization on organization.id=employees.organization_id
left join sys_post as post on post.post_id=employees.post_id
</sql>
@ -50,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="contactNumber != null and contactNumber != ''">contact_number,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="employeesType != null">employees_type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
@ -59,6 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="contactNumber != null and contactNumber != ''">#{contactNumber},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="employeesType != null">#{employeesType},</if>
</trim>
</insert>
@ -71,6 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="contactNumber != null and contactNumber != ''">contact_number = #{contactNumber},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="employeesType != null">employees_type = #{employeesType},</if>
</trim>
where id = #{id}
</update>

106
zc-business/src/main/resources/mapper/business/DcEventImportantFileMapper.xml

@ -0,0 +1,106 @@
<?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.DcEventImportantFileMapper">
<resultMap type="DcEventImportantFile" id="DcEventImportantFileResult">
<result property="id" column="id" />
<result property="eventId" column="event_id" />
<result property="fromDept" column="from_dept" />
<result property="createTime" column="create_time" />
<result property="title" column="title" />
<result property="toDept" column="to_dept" />
<result property="content" column="content" />
<result property="createName" column="create_name" />
<result property="phoneNumber" column="phone_number" />
<result property="issued" column="issued" />
<result property="type" column="type" />
</resultMap>
<sql id="selectDcEventImportantFileVo">
select id,event_id, from_dept, create_time, title, to_dept, content, create_name, phone_number, issued, type from dc_event_important_file
</sql>
<select id="selectDcEventImportantFileList" parameterType="DcEventImportantFile" resultMap="DcEventImportantFileResult">
<include refid="selectDcEventImportantFileVo"/>
<where>
<if test="eventId != null and fromDept != ''"> and event_id = #{eventId}</if>
<if test="fromDept != null and fromDept != ''"> and from_dept = #{fromDept}</if>
<if test="title != null and title != ''"> and title = #{title}</if>
<if test="toDept != null and toDept != ''"> and to_dept = #{toDept}</if>
<if test="content != null and content != ''"> and content = #{content}</if>
<if test="createName != null and createName != ''"> and create_name like concat('%', #{createName}, '%')</if>
<if test="phoneNumber != null and phoneNumber != ''"> and phone_number = #{phoneNumber}</if>
<if test="issued != null and issued != ''"> and issued = #{issued}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
</where>
</select>
<select id="selectDcEventImportantFileByEventId" parameterType="String" resultMap="DcEventImportantFileResult">
<include refid="selectDcEventImportantFileVo"/>
where id = #{id}
</select>
<select id="getImportantFileStatus" resultType="java.lang.Integer">
SELECT IFNULL(max(type),0) type
FROM `dc_event_important_file`
where event_id = #{eventId}
</select>
<insert id="insertDcEventImportantFile" parameterType="DcEventImportantFile" useGeneratedKeys="true" keyProperty="id">
insert into dc_event_important_file
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="eventId != null">event_id,</if>
<if test="fromDept != null">from_dept,</if>
<if test="createTime != null">create_time,</if>
<if test="title != null">title,</if>
<if test="toDept != null">to_dept,</if>
<if test="content != null">content,</if>
<if test="createName != null">create_name,</if>
<if test="phoneNumber != null">phone_number,</if>
<if test="issued != null">issued,</if>
<if test="type != null">type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="eventId != null">#{eventId},</if>
<if test="fromDept != null">#{fromDept},</if>
<if test="createTime != null">#{createTime},</if>
<if test="title != null">#{title},</if>
<if test="toDept != null">#{toDept},</if>
<if test="content != null">#{content},</if>
<if test="createName != null">#{createName},</if>
<if test="phoneNumber != null">#{phoneNumber},</if>
<if test="issued != null">#{issued},</if>
<if test="type != null">#{type},</if>
</trim>
</insert>
<update id="updateDcEventImportantFile" parameterType="DcEventImportantFile">
update dc_event_important_file
<trim prefix="SET" suffixOverrides=",">
<if test="eventId != null">event_id = #{eventId},</if>
<if test="fromDept != null">from_dept = #{fromDept},</if>
<if test="fromDept != null">from_dept = #{fromDept},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="title != null">title = #{title},</if>
<if test="toDept != null">to_dept = #{toDept},</if>
<if test="content != null">content = #{content},</if>
<if test="createName != null">create_name = #{createName},</if>
<if test="phoneNumber != null">phone_number = #{phoneNumber},</if>
<if test="issued != null">issued = #{issued},</if>
<if test="type != null">type = #{type},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDcEventImportantFileByEventId" parameterType="String">
delete from dc_event_important_file where id = #{id}
</delete>
<delete id="deleteDcEventImportantFileByEventIds" parameterType="String">
delete from dc_event_important_file where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

121
zc-business/src/main/resources/mapper/business/DcEventImportantMapper.xml

@ -0,0 +1,121 @@
<?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.DcEventImportantMapper">
<resultMap type="DcEventImportant" id="DcEventImportantResult">
<result property="id" column="id" />
<result property="eventId" column="event_id" />
<result property="plateNumber" column="plate_number" />
<result property="diversionPoint" column="diversion_point" />
<result property="currentProgress" column="current_progress" />
<result property="takeSteps" column="take_steps" />
<result property="planStatus" column="plan_status" />
<result property="trafficPoliceStatus" column="traffic_police_status" />
<result property="medicalStatus" column="medical_status" />
<result property="fireStatus" column="fire_status" />
<result property="boardStatus" column="board_status" />
<result property="chemicalsStatus" column="chemicals_status" />
<result property="planLevel" column="plan_level" />
<result property="chemicalsName" column="chemicals_name" />
<result property="leakageLevel" column="leakage_level" />
</resultMap>
<sql id="selectDcEventImportantVo">
select id, event_id, plate_number, diversion_point, current_progress, take_steps, plan_status, traffic_police_status, medical_status, fire_status, board_status, chemicals_status, plan_level, chemicals_name, leakage_level from dc_event_important
</sql>
<select id="selectDcEventImportantList" parameterType="DcEventImportant" resultMap="DcEventImportantResult">
<include refid="selectDcEventImportantVo"/>
<where>
<if test="eventId != null and eventId != ''"> and event_id = #{eventId}</if>
<if test="plateNumber != null and plateNumber != ''"> and plate_number = #{plateNumber}</if>
<if test="diversionPoint != null and diversionPoint != ''"> and diversion_point = #{diversionPoint}</if>
<if test="currentProgress != null and currentProgress != ''"> and current_progress = #{currentProgress}</if>
<if test="takeSteps != null and takeSteps != ''"> and take_steps = #{takeSteps}</if>
<if test="planStatus != null "> and plan_status = #{planStatus}</if>
<if test="trafficPoliceStatus != null "> and traffic_police_status = #{trafficPoliceStatus}</if>
<if test="medicalStatus != null "> and medical_status = #{medicalStatus}</if>
<if test="fireStatus != null "> and fire_status = #{fireStatus}</if>
<if test="boardStatus != null "> and board_status = #{boardStatus}</if>
<if test="chemicalsStatus != null "> and chemicals_status = #{chemicalsStatus}</if>
<if test="planLevel != null and planLevel != ''"> and plan_level = #{planLevel}</if>
<if test="chemicalsName != null and chemicalsName != ''"> and chemicals_name like concat('%', #{chemicalsName}, '%')</if>
<if test="leakageLevel != null and leakageLevel != ''"> and leakage_level = #{leakageLevel}</if>
</where>
</select>
<select id="selectDcEventImportantByEventId" parameterType="String" resultMap="DcEventImportantResult">
<include refid="selectDcEventImportantVo"/>
where event_id = #{eventId}
</select>
<insert id="insertDcEventImportant" parameterType="DcEventImportant">
insert into dc_event_important
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="eventId != null">event_id,</if>
<if test="plateNumber != null">plate_number,</if>
<if test="diversionPoint != null">diversion_point,</if>
<if test="currentProgress != null">current_progress,</if>
<if test="takeSteps != null">take_steps,</if>
<if test="planStatus != null">plan_status,</if>
<if test="trafficPoliceStatus != null">traffic_police_status,</if>
<if test="medicalStatus != null">medical_status,</if>
<if test="fireStatus != null">fire_status,</if>
<if test="boardStatus != null">board_status,</if>
<if test="chemicalsStatus != null">chemicals_status,</if>
<if test="planLevel != null">plan_level,</if>
<if test="chemicalsName != null">chemicals_name,</if>
<if test="leakageLevel != null">leakage_level,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="eventId != null">#{eventId},</if>
<if test="plateNumber != null">#{plateNumber},</if>
<if test="diversionPoint != null">#{diversionPoint},</if>
<if test="currentProgress != null">#{currentProgress},</if>
<if test="takeSteps != null">#{takeSteps},</if>
<if test="planStatus != null">#{planStatus},</if>
<if test="trafficPoliceStatus != null">#{trafficPoliceStatus},</if>
<if test="medicalStatus != null">#{medicalStatus},</if>
<if test="fireStatus != null">#{fireStatus},</if>
<if test="boardStatus != null">#{boardStatus},</if>
<if test="chemicalsStatus != null">#{chemicalsStatus},</if>
<if test="planLevel != null">#{planLevel},</if>
<if test="chemicalsName != null">#{chemicalsName},</if>
<if test="leakageLevel != null">#{leakageLevel},</if>
</trim>
</insert>
<update id="updateDcEventImportant" parameterType="DcEventImportant">
update dc_event_important
<trim prefix="SET" suffixOverrides=",">
<if test="eventId != null">event_id = #{eventId},</if>
<if test="plateNumber != null">plate_number = #{plateNumber},</if>
<if test="diversionPoint != null">diversion_point = #{diversionPoint},</if>
<if test="currentProgress != null">current_progress = #{currentProgress},</if>
<if test="takeSteps != null">take_steps = #{takeSteps},</if>
<if test="planStatus != null">plan_status = #{planStatus},</if>
<if test="trafficPoliceStatus != null">traffic_police_status = #{trafficPoliceStatus},</if>
<if test="medicalStatus != null">medical_status = #{medicalStatus},</if>
<if test="fireStatus != null">fire_status = #{fireStatus},</if>
<if test="boardStatus != null">board_status = #{boardStatus},</if>
<if test="chemicalsStatus != null">chemicals_status = #{chemicalsStatus},</if>
<if test="planLevel != null">plan_level = #{planLevel},</if>
<if test="chemicalsName != null">chemicals_name = #{chemicalsName},</if>
<if test="leakageLevel != null">leakage_level = #{leakageLevel},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDcEventImportantByEventId" parameterType="String">
delete from dc_event_important where id = #{id}
</delete>
<delete id="deleteDcEventImportantByEventIds" parameterType="String">
delete from dc_event_important where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

1194
zc-business/src/main/resources/mapper/business/DcEventMapper.xml

File diff suppressed because it is too large

43
zc-business/src/main/resources/mapper/business/DcEventProcessMapper.xml

@ -14,10 +14,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="context" column="context" />
<result property="processId" column="process_id" />
<result property="processName" column="process_name" />
<result property="type" column="type" />
</resultMap>
<sql id="selectDcEventProcessVo">
select id, event_id, operation_time, operator, source, process_type, context, process_id, process_name from dc_event_process
select id, event_id, operation_time, operator, source, process_type, context, process_id, process_name, `type` from dc_event_process
</sql>
<select id="selectDcEventProcessList" parameterType="DcEventProcess" resultMap="DcEventProcessResult">
@ -29,6 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="source != null "> and source = #{source}</if>
<if test="processType != null "> and process_type = #{processType}</if>
<if test="context != null and context != ''"> and context = #{context}</if>
<if test="type != null and type != ''"> and `type` = #{type}</if>
<if test="processId != null "> and process_id = #{processId}</if>
<if test="processName != null and processName != ''"> and process_name like concat('%', #{processName}, '%')</if>
</where>
@ -51,6 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="context != null">context,</if>
<if test="processId != null">process_id,</if>
<if test="processName != null">process_name,</if>
<if test="type != null">`type`,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
@ -62,9 +65,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="context != null">#{context},</if>
<if test="processId != null">#{processId},</if>
<if test="processName != null">#{processName},</if>
<if test="type != null">#{type},</if>
</trim>
</insert>
<insert id="batchInsertDcEventProcess">
<foreach collection ="list" item="item" index= "index" separator =";">
insert into dc_event_process
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="item.id != null">id,</if>
<if test="item.eventId != null and item.eventId != ''">event_id,</if>
<if test="item.operationTime != null">operation_time,</if>
<if test="item.operator != null and item.operator != ''">operator,</if>
<if test="item.source != null">source,</if>
<if test="item.processType != null">process_type,</if>
<if test="item.context != null">context,</if>
<if test="item.processId != null">process_id,</if>
<if test="item.processName != null">process_name,</if>
<if test="item.type != null">`type`,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="item.id != null">#{item.id},</if>
<if test="item.eventId != null and item.eventId != ''">#{item.eventId},</if>
<if test="item.operationTime != null">#{item.operationTime},</if>
<if test="item.operator != null and item.operator != ''">#{item.operator},</if>
<if test="item.source != null">#{item.source},</if>
<if test="item.processType != null">#{item.processType},</if>
<if test="item.context != null">#{item.context},</if>
<if test="item.processId != null">#{item.processId},</if>
<if test="item.processName != null">#{item.processName},</if>
<if test="item.type != null">#{item.type},</if>
</trim>
</foreach>
</insert>
<update id="updateDcEventProcess" parameterType="DcEventProcess">
update dc_event_process
<trim prefix="SET" suffixOverrides=",">
@ -74,6 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="source != null">source = #{source},</if>
<if test="processType != null">process_type = #{processType},</if>
<if test="context != null">context = #{context},</if>
<if test="type != null">`type` = #{type},</if>
<if test="processId != null">process_id = #{processId},</if>
<if test="processName != null">process_name = #{processName},</if>
</trim>
@ -96,5 +131,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where event_id = #{id}
ORDER BY operation_time ASC;
</select>
<select id="selectFinalNode" resultType="java.lang.Integer">
SELECT IFNULL(max(t2.node_node),0) finalNode
FROM `dc_event` t1
LEFT JOIN dc_process_config t2 on t1.event_type = t2.event_type
where t1.id = #{eventId};
</select>
</mapper>

73
zc-business/src/main/resources/mapper/business/DcWarningMapper.xml

@ -122,6 +122,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="otherConfig != null">other_config,</if>
<if test="lane != null">lane,</if>
<if test="vehicleType != null">vehicle_type,</if>
<if test="endTime != null">end_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
@ -142,9 +143,47 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="otherConfig != null">#{otherConfig},</if>
<if test="lane != null">#{lane},</if>
<if test="vehicleType != null">#{vehicleType},</if>
<if test="endTime != null">#{endTime},</if>
</trim>
</insert>
<insert id="insertDispatchResource" parameterType="DcDispatchResource">
insert into dc_dispatch_resource
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="dispatchType != null">dispatch_type,</if>
<if test="resourceId != null">resource_id,</if>
<if test="dispatchId != null">dispatch_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="dispatchType != null">#{dispatchType},</if>
<if test="resourceId != null">#{resourceId},</if>
<if test="dispatchId != null">#{dispatchId},</if>
</trim>
</insert>
<insert id="insertDcDispatch" parameterType="DcDispatch" useGeneratedKeys="true" keyProperty="id">
insert into dc_dispatch
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="organizationId != null">organization_id,</if>
<if test="eventId != null and eventId != ''">event_id,</if>
<if test="dispatchName != null">dispatch_name,</if>
<if test="dispatchStatus != null">dispatch_status,</if>
<if test="startTime != null">start_time,</if>
<if test="endTime != null">end_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="organizationId != null">#{organizationId},</if>
<if test="eventId != null and eventId != ''">#{eventId},</if>
<if test="dispatchName != null">#{dispatchName},</if>
<if test="dispatchStatus != null">#{dispatchStatus},</if>
<if test="startTime != null">#{startTime},</if>
<if test="endTime != null">#{endTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateDcWarning" parameterType="DcWarning">
update dc_warning
<trim prefix="SET" suffixOverrides=",">
@ -182,9 +221,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<update id="updateOtherConfig">
update dc_warning set other_config=#{otherConfig},update_time=now() where id=#{id}
update dc_warning set other_config=#{otherConfig},update_time=now(),end_time=#{endTime} where id=#{id}
</update>
<update id="updateEndSection">
update dc_warning set warning_state = 4
where id in
<foreach collection="dcWarningList" item="item" index="index"
separator="," open="(" close=")">
#{item.id}
</foreach>
</update>
<delete id="deleteDcWarningById" parameterType="Integer">
delete from dc_warning where id = #{id}
</delete>
@ -233,5 +279,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="strategy != null "> and strategy = #{strategy}</if>
</where>
</select>
<select id="selectEndSection" resultType="com.zc.business.domain.DcWarning">
select id from dc_warning where YEAR(end_time) = YEAR(CURDATE()) and warning_state!=4 and now()>end_time
</select>
<select id="selectSectionId" resultType="java.lang.Long">
select section_id from dc_satke_mark where stake_mark=#{stakeMark} and direction=#{direction}
</select>
<select id="selectRecentlySection" resultType="hashmap">
select id,organization_name organizationName,stake_mark stakeMark from dc_organization
</select>
<select id="selectOrganizationEmployees" resultType="java.util.HashMap">
select name,contact_number contactNumber from dc_employees where organization_id=#{organizationId} and employees_type=2
</select>
<select id="selectShifts" resultType="java.util.HashMap">
select shifts.scheduling,employees.name shiftsName,employees.contact_number shiftsNumber from dc_shifts as shifts
left join dc_employees as employees on shifts.employees_id=employees.id
where shifts.station=#{station} and DATE(date) = CURDATE();
</select>
<select id="selectVehicles" resultType="java.util.HashMap">
select vehicle_type vehicleType,vehicle_plate vehiclePlate from dc_vehicles
where vehicle_status=1 and organization_id=#{organizationId}
</select>
</mapper>

37
zc-business/src/main/resources/mapper/business/EventPlanAssocMapper.xml

@ -7,36 +7,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertEventPlanAssoc" parameterType="EventPlanAssoc">
insert into event_plan_assoc
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">id,</if>
<if test="eventId != null and eventId != ''">event_id,</if>
<if test="emergencyPlansId != null">emergency_plans_id,</if>
<if test="executingControlDevice != null and executingControlDevice != ''">executing_control_device,</if>
<if test="recoveredControlDevice != null and recoveredControlDevice != ''">recovered_control_device,</if>
<if test="controlDevice != null and controlDevice != ''">control_device,</if>
<if test="operationType != null">operation_type,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="executingControlResult != null and executingControlResult !=''">executing_control_result,</if>
<if test="recoveredControlResult != null and recoveredControlResult !=''">recovered_control_result,</if>
<if test="controlResult != null and controlResult !=''">control_result,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">#{id},</if>
<if test="eventId != null and eventId != ''">#{eventId},</if>
<if test="emergencyPlansId != null">#{emergencyPlansId},</if>
<if test="executingControlDevice != null and executingControlDevice != ''">#{executingControlDevice},</if>
<if test="recoveredControlDevice != null and recoveredControlDevice != ''">#{recoveredControlDevice},</if>
<if test="controlDevice != null and controlDevice != ''">#{controlDevice},</if>
<if test="operationType != null">#{operationType},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="executingControlResult != null and executingControlResult !=''">#{executingControlResult},</if>
<if test="recoveredControlResult != null and recoveredControlResult !=''">#{recoveredControlResult}</if>
<if test="controlResult != null and controlResult !=''">#{controlResult},</if>
</trim>
</insert>
<sql id="selectEventPlanAssocVo">
select id,event_id,emergency_plans_id,executing_control_device,recovered_control_device,create_time,update_time,
executing_control_result,recovered_control_result
select id,event_id,emergency_plans_id,control_device,create_time,update_time,
control_result,operation_type
from event_plan_assoc
</sql>
<select id="selectByEventId" parameterType="EventPlanAssoc" resultType="EventPlanAssoc">
<include refid="selectEventPlanAssocVo"/>
where event_id = #{eventId}
where event_id = #{eventId} and operation_type = #{operationType}
</select>
<update id="updateEventPlanAssoc" parameterType="EventPlanAssoc">
@ -44,18 +44,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="SET" suffixOverrides=",">
<if test="eventId != null and eventId != ''">event_id = #{eventId},</if>
<if test="emergencyPlansId != null">emergency_plans_id = #{emergencyPlansId},</if>
<if test="executingControlDevice != null and executingControlDevice != ''">
executing_control_device = #{executingControlDevice},
<if test="controlDevice != null and controlDevice != ''">
control_device = #{controlDevice},
</if>
<if test="recoveredControlDevice != null and recoveredControlDevice != ''">
recovered_control_device = #{recoveredControlDevice},
<if test="operationType != null">
operation_type = #{operationType},
</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="executingControlResult != null and executingControlResult !=''">
executing_control_result = #{executingControlResult},
</if>
<if test="recoveredControlResult != null and recoveredControlResult !=''">
recovered_control_result = #{recoveredControlResult},
<if test="controlResult != null and controlResult !=''">
control_result = #{controlResult},
</if>
</trim>
where id = #{id}

BIN
zc-business/src/main/resources/wordTemplate/importantTemplate.docx

Binary file not shown.
Loading…
Cancel
Save