Browse Source

Merge remote-tracking branch 'origin/develop' into develop

develop
wangsixiang 10 months ago
parent
commit
6ccf3a6d73
  1. 130
      zc-business/src/main/java/com/zc/business/controller/DcBatchFunctionsJobController.java
  2. 135
      zc-business/src/main/java/com/zc/business/controller/DcBatchFunctionsJobGroupController.java
  3. 42
      zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java
  4. 116
      zc-business/src/main/java/com/zc/business/controller/DcOperLogController.java
  5. 75
      zc-business/src/main/java/com/zc/business/controller/StatusController.java
  6. 38
      zc-business/src/main/java/com/zc/business/domain/DcBatchFunctionsJob.java
  7. 33
      zc-business/src/main/java/com/zc/business/domain/DcBatchFunctionsJobGroup.java
  8. 42
      zc-business/src/main/java/com/zc/business/domain/DcOperLog.java
  9. 13
      zc-business/src/main/java/com/zc/business/domain/Status.java
  10. 15
      zc-business/src/main/java/com/zc/business/interfaces/OperationLog.java
  11. 136
      zc-business/src/main/java/com/zc/business/interfaces/OperationLogAspect.java
  12. 14
      zc-business/src/main/java/com/zc/business/mapper/DcBatchFunctionsJobGroupMapper.java
  13. 14
      zc-business/src/main/java/com/zc/business/mapper/DcBatchFunctionsJobMapper.java
  14. 2
      zc-business/src/main/java/com/zc/business/mapper/DcDeviceMapper.java
  15. 14
      zc-business/src/main/java/com/zc/business/mapper/DcOperLogMapper.java
  16. 1
      zc-business/src/main/java/com/zc/business/mapper/StatusMapper.java
  17. 53
      zc-business/src/main/java/com/zc/business/service/IDcBatchFunctionsJobGroupService.java
  18. 57
      zc-business/src/main/java/com/zc/business/service/IDcBatchFunctionsJobService.java
  19. 4
      zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java
  20. 52
      zc-business/src/main/java/com/zc/business/service/IDcOperLogService.java
  21. 125
      zc-business/src/main/java/com/zc/business/service/impl/DcBatchFunctionsJobGroupServiceImpl.java
  22. 257
      zc-business/src/main/java/com/zc/business/service/impl/DcBatchFunctionsJobServiceImpl.java
  23. 6
      zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java
  24. 795
      zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java
  25. 73
      zc-business/src/main/java/com/zc/business/service/impl/DcOperLogServiceImpl.java
  26. 4
      zc-business/src/main/java/com/zc/business/service/impl/StatusService.java
  27. 36
      zc-business/src/main/java/com/zc/business/task/ScheduledTaskSchedulingTask.java
  28. 67
      zc-business/src/main/java/com/zc/business/utils/ScheduleUtils.java
  29. 20
      zc-business/src/main/java/com/zc/business/utils/ScheduledTaskScheduling.java
  30. 12
      zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml
  31. 3
      zc-business/src/main/resources/mapper/business/DcEventMapper.xml
  32. 29
      zc-business/src/main/resources/mapper/business/StatusMapper.xml

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

@ -0,0 +1,130 @@
package com.zc.business.controller;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.exception.job.TaskException;
import com.zc.business.domain.DcBatchFunctionsJob;
import com.zc.business.service.IDcBatchFunctionsJobService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.quartz.SchedulerException;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
/**
* 定时任务Controller
*
* @author zhaoxianglong
*/
@Api(tags = {"定时任务"})
@RestController
@RequestMapping("/business/dcBatchFunctionsJob")
public class DcBatchFunctionsJobController extends BaseController {
@Resource
private IDcBatchFunctionsJobService dcBatchFunctionsJobService;
//*********************************调用功能记录增删改查******************************************
/**
* 分页查询列表
*
* @param dcBatchFunctionsJob 请求参数
* @return 分页查询结果
*/
@ApiOperation("分页查询列表")
@PreAuthorize("@ss.hasPermi('iot:facility:list')")
@GetMapping("list")
public TableDataInfo listFacility(DcBatchFunctionsJob dcBatchFunctionsJob) {
return getDataTable(dcBatchFunctionsJobService.pageDcBatchFunctionsJob(dcBatchFunctionsJob));
}
/**
* 无分页查询列表
*
* @param dcBatchFunctionsJob 请求参数
* @return 查询结果
*/
@ApiOperation("无分页查询列表")
@PreAuthorize("@ss.hasPermi('iot:facility:query')")
@GetMapping("query")
public AjaxResult queryFacility(DcBatchFunctionsJob dcBatchFunctionsJob) throws SchedulerException {
return AjaxResult.success(dcBatchFunctionsJobService.listDcBatchFunctionsJob(dcBatchFunctionsJob));
}
/**
* 根据id查询信息
*
* @param id id
* @return 查询结果
*/
@ApiOperation("根据id查询信息")
@PreAuthorize("@ss.hasPermi('iot:facility:query')")
@GetMapping("{id}")
public AjaxResult getFacility(@PathVariable String id) {
return AjaxResult.success(dcBatchFunctionsJobService.getById(id));
}
/**
* 新增
*
* @param dcBatchFunctionsJob 新增参数
* @return 新增操作结果
*/
@ApiOperation("新增")
@PreAuthorize("@ss.hasPermi('iot:facility:add')")
@Log(title = "新增", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult addFacility(@Valid @RequestBody DcBatchFunctionsJob dcBatchFunctionsJob) throws SchedulerException, TaskException {
return AjaxResult.success(dcBatchFunctionsJobService.addDcBatchFunctionsJob(dcBatchFunctionsJob));
}
/**
* 修改
*
* @param dcBatchFunctionsJob 修改参数
* @return 修改操作结果
*/
@ApiOperation("修改")
@PreAuthorize("@ss.hasPermi('iot:facility:edit')")
@Log(title = "修改", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult editFacility(@Valid @RequestBody DcBatchFunctionsJob dcBatchFunctionsJob) throws SchedulerException, TaskException {
return toAjax(dcBatchFunctionsJobService.editDcBatchFunctionsJob(dcBatchFunctionsJob));
}
/**
* 删除
*
* @param ids id集
* @return 删除操作结果
*/
@ApiOperation("删除")
@PreAuthorize("@ss.hasPermi('iot:facility:remove')")
@Log(title = "删除", businessType = BusinessType.DELETE)
@DeleteMapping("{ids}")
public AjaxResult removeFacility(@PathVariable List<String> ids) throws SchedulerException, TaskException {
return toAjax(dcBatchFunctionsJobService.removeDcBatchFunctionsJob(ids));
}
/**
* 删除
*
* @return 删除操作结果
*/
@ApiOperation("删除")
@PreAuthorize("@ss.hasPermi('iot:facility:remove')")
@Log(title = "删除", businessType = BusinessType.DELETE)
@DeleteMapping("/time/{groupId}/{time}")
public AjaxResult deletesATaskByTime(@PathVariable String groupId, @PathVariable String time) {
return toAjax(dcBatchFunctionsJobService.deletesATaskByTime(groupId, time));
}
}

135
zc-business/src/main/java/com/zc/business/controller/DcBatchFunctionsJobGroupController.java

@ -0,0 +1,135 @@
package com.zc.business.controller;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.exception.job.TaskException;
import com.zc.business.domain.DcBatchFunctionsJobGroup;
import com.zc.business.service.IDcBatchFunctionsJobGroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.quartz.SchedulerException;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
/**
* 定时任务组Controller
*
* @author zhaoxianglong
*/
@Api(tags = {"定时任务组"})
@RestController
@RequestMapping("/business/dcBatchFunctionsJobGroup")
public class DcBatchFunctionsJobGroupController extends BaseController {
@Resource
private IDcBatchFunctionsJobGroupService dcBatchFunctionsJobGroupService;
//*********************************调用功能记录增删改查******************************************
/**
* 分页查询列表
*
* @param dcBatchFunctionsJobGroup 请求参数
* @return 分页查询结果
*/
@ApiOperation("分页查询列表")
@PreAuthorize("@ss.hasPermi('iot:facility:list')")
@GetMapping("list")
public TableDataInfo listFacility(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup) {
return getDataTable(dcBatchFunctionsJobGroupService.pageDcBatchFunctionsJobGroup(dcBatchFunctionsJobGroup));
}
/**
* 无分页查询列表
*
* @param dcBatchFunctionsJobGroup 请求参数
* @return 查询结果
*/
@ApiOperation("无分页查询列表")
@PreAuthorize("@ss.hasPermi('iot:facility:query')")
@GetMapping("query")
public AjaxResult queryFacility(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup) {
return AjaxResult.success(dcBatchFunctionsJobGroupService.listDcBatchFunctionsJobGroup(dcBatchFunctionsJobGroup));
}
/**
* 根据id查询信息
*
* @param id id
* @return 查询结果
*/
@ApiOperation("根据id查询信息")
@PreAuthorize("@ss.hasPermi('iot:facility:query')")
@GetMapping("{id}")
public AjaxResult getFacility(@PathVariable String id) {
return AjaxResult.success(dcBatchFunctionsJobGroupService.getById(id));
}
/**
* 新增
*
* @param dcBatchFunctionsJobGroup 新增参数
* @return 新增操作结果
*/
@ApiOperation("新增")
@PreAuthorize("@ss.hasPermi('iot:facility:add')")
@Log(title = "新增", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult addFacility(@Valid @RequestBody DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup) {
return AjaxResult.success(dcBatchFunctionsJobGroupService.addDcBatchFunctionsJobGroup(dcBatchFunctionsJobGroup));
}
/**
* 修改
*
* @param dcBatchFunctionsJobGroup 修改参数
* @return 修改操作结果
*/
@ApiOperation("修改")
@PreAuthorize("@ss.hasPermi('iot:facility:edit')")
@Log(title = "修改", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult editFacility(@Valid @RequestBody DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup) {
return AjaxResult.success(dcBatchFunctionsJobGroupService.editDcBatchFunctionsJobGroup(dcBatchFunctionsJobGroup));
}
/**
* 删除
*
* @param ids id集
* @return 删除操作结果
*/
@ApiOperation("删除")
@PreAuthorize("@ss.hasPermi('iot:facility:remove')")
@Log(title = "删除", businessType = BusinessType.DELETE)
@DeleteMapping("{ids}")
public AjaxResult removeFacility(@PathVariable List<String> ids) {
return toAjax(dcBatchFunctionsJobGroupService.removeDcBatchFunctionsJobGroup(ids));
}
//*********************************定时任务组功能******************************************
/**
* 改变状态
*
* @param dcBatchFunctionsJobGroup 请求参数
* @return 删除操作结果
*/
@ApiOperation("改变状态")
@PreAuthorize("@ss.hasPermi('iot:facility:remove')")
@Log(title = "改变状态", businessType = BusinessType.DELETE)
@PostMapping("changeStatus")
public AjaxResult changeStatus(@Valid @RequestBody DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup) throws SchedulerException, TaskException {
return toAjax(dcBatchFunctionsJobGroupService.changeStatus(dcBatchFunctionsJobGroup));
}
}

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

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
@ -12,6 +13,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.zc.business.constant.DeviceTypeConstants;
import com.zc.business.domain.DcDevice;
import com.zc.business.interfaces.OperationLog;
import com.zc.business.request.DeviceGetPropertiesOperateRequest;
import com.zc.business.service.IDcDeviceService;
import com.zc.common.core.httpclient.OkHttp;
@ -30,7 +32,6 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.*;
import java.util.stream.Collectors;
@ -267,12 +268,12 @@ public class DcDeviceController extends BaseController {
JSONObject formatValue = JSON.parseObject(jsonObject.get("formatValue").toString());
map.put("1", formatValue.get("1"));
map.put("3", formatValue.get("3"));
map.put("timestamp", formatValue.get("equipmentReportingTime") == null? "":Long.valueOf(formatValue.get("equipmentReportingTime").toString()));
map.put("timestamp", formatValue.get("equipmentReportingTime") == null ? "" : Long.valueOf(formatValue.get("equipmentReportingTime").toString()));
list.add(map);
});
List<Map<String, Object>> newList = list.stream()
.filter(map-> !map.get("timestamp").equals(""))
.collect(Collectors.toList());
.filter(map -> !map.get("timestamp").equals(""))
.collect(Collectors.toList());
Collections.sort(newList, new Comparator<Map<String, Object>>() {
@Override
public int compare(Map<String, Object> map1, Map<String, Object> map2) {
@ -438,11 +439,17 @@ public class DcDeviceController extends BaseController {
*/
@ApiOperation("设备功能调用")
@PostMapping("/functions/{deviceId}/{functionId}")
@OperationLog(operUrl = "/business/device/functions/{deviceId}/{functionId}")
public AjaxResult invokedFunction(
@PathVariable String deviceId,
@PathVariable String functionId,
@RequestBody HashMap<String, Object> props) throws HttpException, IOException {
return getAjaxResult(deviceId, functionId, props);
}
private AjaxResult getAjaxResult(String deviceId, String functionId, HashMap<String, Object> props) {
if (!StringUtils.hasText(deviceId) || !StringUtils.hasText(functionId)) {
return AjaxResult.error("设备未接入");
}
@ -463,7 +470,6 @@ public class DcDeviceController extends BaseController {
} catch (Exception e) {
return AjaxResult.error("请求失败");
}
}
/**
@ -474,6 +480,7 @@ public class DcDeviceController extends BaseController {
*/
@ApiOperation("批量设备功能调用")
@PostMapping("/batchFunctions")
@OperationLog(operUrl = "/business/device/batchFunctions")
public AjaxResult batchInvokedFunction(@RequestBody Map<String, Object> props) throws HttpException, IOException, InterruptedException {
ArrayList<JSONObject> devices = (ArrayList<JSONObject>) props.get("devices");
ArrayList<JSONObject> functions = (ArrayList<JSONObject>) props.get("functions");
@ -487,7 +494,7 @@ public class DcDeviceController extends BaseController {
JSONObject functionJSONObject = (JSONObject) JSON.toJSON(function);
//JSONObject functionJSONObject = (JSONObject) JSON.toJSON(function.toString()) ;
String functionId = functionJSONObject.getString("functionId");
JSONObject jsonObject = functionJSONObject.getJSONObject("params") != null?functionJSONObject.getJSONObject("params"):new JSONObject();
JSONObject jsonObject = functionJSONObject.getJSONObject("params") != null ? functionJSONObject.getJSONObject("params") : new JSONObject();
resultArray.add(getResult(device, iotDeviceId, functionId, jsonObject));
}
}
@ -502,7 +509,7 @@ public class DcDeviceController extends BaseController {
if (device.getInteger("deviceType").equals(DeviceTypeConstants.ROAD_SECTION_VOICE_BROADCASTING)) {
result.put("result", broadcastController.nearCamListDistance(jsonObject));
} else {
result.put("result", invokedFunction(iotDeviceId, functionId, params));
result.put("result", getAjaxResult(iotDeviceId, functionId, params));
}
return result;
}
@ -522,27 +529,14 @@ public class DcDeviceController extends BaseController {
ArrayList params = (ArrayList) props.get("params");
JSONArray resultArray = new JSONArray();
for (Object param : params) {
resultArray.add(invokedFunction(deviceId, functionId, (HashMap<String, Object>) param));
resultArray.add(getAjaxResult(deviceId, functionId, (HashMap<String, Object>) param));
}
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("SET", "7");
invokedFunction(deviceId, "SETMD", hashMap);
getAjaxResult(deviceId, "SETMD", hashMap);
return AjaxResult.success(resultArray);
}
public HashMap<String, Object> objectToMap(Object obj) {
Map<String, Object> map = new HashMap<>();
for (Field field : obj.getClass().getDeclaredFields()) {
try {
field.setAccessible(true);
map.put(field.getName(), field.get(obj));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
return (HashMap<String, Object>) map;
}
/**
* 查询物联设备事件数据
*
@ -610,4 +604,8 @@ public class DcDeviceController extends BaseController {
@ApiParam(value="方向", name="direction", required=true) @RequestParam ("direction") String direction){
return dcDeviceService.selectNearBoard(stakeMark,direction);
}
public void batchInvokedFunction(Object object) throws HttpException, IOException, InterruptedException {
Map<String, Object> map = new ObjectMapper().convertValue(object, Map.class);
batchInvokedFunction(map);
}
}

116
zc-business/src/main/java/com/zc/business/controller/DcOperLogController.java

@ -0,0 +1,116 @@
package com.zc.business.controller;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.zc.business.domain.DcOperLog;
import com.zc.business.service.IDcOperLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Date;
import java.util.List;
/**
* 调用功能记录Controller
*
* @author zhaoxianglong
*/
@Api(tags = {"调用功能记录"})
@RestController
@RequestMapping("/business/dcOperLog")
public class DcOperLogController extends BaseController {
@Resource
private IDcOperLogService dcOperLogService;
//*********************************调用功能记录增删改查******************************************
/**
* 分页查询列表
*
* @param dcOperLog 请求参数
* @return 分页查询结果
*/
@ApiOperation("分页查询列表")
@PreAuthorize("@ss.hasPermi('iot:facility:list')")
@GetMapping("list")
public TableDataInfo listFacility(DcOperLog dcOperLog,@RequestParam(value = "endTime", required = false)Date endTime,@RequestParam(value = "startTime", required = false)Date startTime) {
return getDataTable(dcOperLogService.pageDcOperLog(dcOperLog,endTime,startTime));
}
/**
* 无分页查询路网设施列表
*
* @param dcOperLog 请求参数
* @return 查询结果
*/
@ApiOperation("无分页查询列表")
@PreAuthorize("@ss.hasPermi('iot:facility:query')")
@GetMapping("query")
public AjaxResult queryFacility(DcOperLog dcOperLog, @RequestParam(value = "endTime", required = false) Date endTime, @RequestParam(value = "startTime", required = false)Date startTime) {
return AjaxResult.success(dcOperLogService.listDcOperLog(dcOperLog,endTime,startTime));
}
/**
* 根据id查询路网设施信息
*
* @param id id
* @return 查询结果
*/
@ApiOperation("根据id查询信息")
@PreAuthorize("@ss.hasPermi('iot:facility:query')")
@GetMapping("{id}")
public AjaxResult getFacility(@PathVariable String id) {
return AjaxResult.success(dcOperLogService.getById(id));
}
/**
* 新增
*
* @param dcOperLog 新增参数
* @return 新增操作结果
*/
@ApiOperation("新增")
@PreAuthorize("@ss.hasPermi('iot:facility:add')")
@Log(title = "新增", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult addFacility(@Valid @RequestBody DcOperLog dcOperLog) {
return toAjax(dcOperLogService.addDcOperLog(dcOperLog));
}
/**
* 修改
*
* @param dcOperLog 修改参数
* @return 修改操作结果
*/
@ApiOperation("修改")
@PreAuthorize("@ss.hasPermi('iot:facility:edit')")
@Log(title = "修改", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult editFacility(@Valid @RequestBody DcOperLog dcOperLog) {
return toAjax(dcOperLogService.editDcOperLog(dcOperLog));
}
/**
* 删除
*
* @param ids id集
* @return 删除操作结果
*/
@ApiOperation("删除")
@PreAuthorize("@ss.hasPermi('iot:facility:remove')")
@Log(title = "删除", businessType = BusinessType.DELETE)
@DeleteMapping("{ids}")
public AjaxResult removeFacility(@PathVariable List<String> ids) {
return toAjax(dcOperLogService.removeDcOperLog(ids));
}
}

75
zc-business/src/main/java/com/zc/business/controller/StatusController.java

@ -9,7 +9,9 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.zc.business.domain.DcDevice;
import com.zc.business.domain.DcRoadSection;
import com.zc.business.domain.Status;
import com.zc.business.service.IDcRoadSectionService;
import com.zc.business.service.impl.DcDeviceServiceImpl;
import com.zc.business.service.impl.StatusService;
import io.swagger.annotations.Api;
@ -36,6 +38,8 @@ public class StatusController extends BaseController {
private DcDeviceServiceImpl dcDeviceService;
@Resource
private RedisCache redisCache;
@Resource
private IDcRoadSectionService dcRoadSectionService;
private static final String ORDERRULE = "orderRule";//排序策略key
@ -362,8 +366,8 @@ public class StatusController extends BaseController {
}else{
String[] rules = {"全部设备","高清网络枪型固定摄像机","高清网络球形摄像机","桥下高清网络球形摄像机","360°全景摄像机","180°全景摄像机",
"门架式可变信息标志","雨棚可变信息标志","站前悬臂式可变信息标志","气象检测器","路段语音广播系统","护栏碰撞预警系统","毫米波雷达",
"合流区预警系统","激光疲劳唤醒","一类交通量调查站","智能行车诱导系统"};
orderRule= Arrays.toString(rules);
"合流区预警系统","激光疲劳唤醒","一类交通量调查站","智能行车诱导系统","智能设备箱"};
orderRule= Arrays.toString(rules).replace("[","").replace("]","").replace(" ","");
ruleMap.put("rule",orderRule);
subMap.put("排序规则",ruleMap);
}
@ -371,4 +375,71 @@ public class StatusController extends BaseController {
}
//设备状态列表按路段
@ApiOperation("设备状态列表按路段")
@GetMapping("/section")
public AjaxResult getSectionList() {
List<Map<String, String>> stringIntegerMap = dcDeviceService.countTheNumberOfEligibleItems();
List<DcRoadSection> dcRoadSections = dcRoadSectionService.selectDcRoadSectionList(new DcRoadSection());
LocalDateTime todayStart = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS);
LocalDateTime currentTime = LocalDateTime.now();
Status status = new Status();
status.setStartTime(todayStart);
status.setTime(currentTime);
status.setUseState(1);
List<Status> listStatus = statusService.listStatusBySection(status);
//根据时间分组
Map<Integer, List<Status>> map = listStatus.stream()
.collect(Collectors.groupingBy(Status -> Status.getTime().getHour()));
if (StringUtils.isEmpty(map)) {
return AjaxResult.success("暂无数据");
}
Map<Integer, List<Status>> ipMap = new TreeMap<>(map);
Integer lastKey = Collections.max(ipMap.keySet());
List<Status> lastEntry = ipMap.get(lastKey);
Map<String, List<Status>> typeMap = lastEntry.stream().filter(iteam -> iteam.getSectionId() != null).collect(Collectors.groupingBy(Status::getSectionId));
Map<String, Map<Object, Object>> subMap = new HashMap<>();
dcRoadSections.forEach((key) -> {
Map<Object, Object> maps = new HashMap<>();
List<Status> groupItems = typeMap.get(String.valueOf(key.getId()));
if (groupItems == null) {
//丢包率
maps.put("lostRate", "0%");
//在线率
maps.put("sucessRate", "0%");
//离线率
maps.put("failRate", "0%");
//已使用数量
maps.put("sumUseState", "0");
//总数
maps.put("sum", stringIntegerMap.stream().filter(iteam -> Objects.equals(String.valueOf(iteam.get("id")), String.valueOf(key.getId()))).collect(Collectors.toList()).get(0).get("number"));
subMap.put(key.getSectionName(), maps);
} else {
double lostRate = groupItems.stream()
.mapToDouble(Status -> Double.parseDouble(Status.getLostRate().replace("%", ""))) // 去掉%,并转换为double
.average().getAsDouble();
double sucessRate = groupItems.stream()
.mapToDouble(Status -> Double.parseDouble(Status.getSuccessRate().replace("%", ""))) // 去掉%,并转换为double
.average().getAsDouble();
String failRate = String.format("%.2f", (100 - sucessRate)) + "%";
//丢包率
maps.put("lostRate", String.format("%.2f", lostRate) + "%");
//在线率
maps.put("sucessRate", String.format("%.2f", sucessRate) + "%");
//离线率
maps.put("failRate", failRate);
//已使用数量
maps.put("sumUseState", String.valueOf(groupItems.size()));
//总数
maps.put("sum", stringIntegerMap.stream().filter(iteam -> Objects.equals(String
.valueOf(iteam.get("id")), String.valueOf(key.getId()))).collect(Collectors.toList()).get(0).get("number"));
subMap.put(key.getSectionName(), maps);
}
});
return AjaxResult.success(subMap);
}
}

38
zc-business/src/main/java/com/zc/business/domain/DcBatchFunctionsJob.java

@ -0,0 +1,38 @@
package com.zc.business.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
@ApiModel(value = "DcBatchFunctionsJob", description = "定时任务实体")
public class DcBatchFunctionsJob {
//@TableId(value = "jobId", type = IdType.AUTO)
private Integer jobId;
@ApiModelProperty("任务组ID")
private String jobGroup;
@ApiModelProperty("调用目标字符串")
private String invokeTarget;
@ApiModelProperty("调用参数")
private String callParameter;
//@ApiModelProperty("cron执行表达式")
@TableField(exist = false)
private String cronExpression;
//@ApiModelProperty("状态")
@TableField(exist = false)
private String status;
@TableField(exist = false)
private String time;
@ApiModelProperty("创建者")
private String createBy;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("修改者")
private Date updateBy;
@ApiModelProperty("修改时间")
private Date updateTime;
}

33
zc-business/src/main/java/com/zc/business/domain/DcBatchFunctionsJobGroup.java

@ -0,0 +1,33 @@
package com.zc.business.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
@ApiModel(value = "DcBatchFunctionsJobGroup", description = "定时任务组实体")
public class DcBatchFunctionsJobGroup {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty("任务组名称")
private String groupName;
@ApiModelProperty("状态")
private String status;
@ApiModelProperty("详细配置")
private String detailedConfiguration;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("创建者")
private String createBy;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("修改者")
private Date updateBy;
@ApiModelProperty("修改时间")
private Date updateTime;
}

42
zc-business/src/main/java/com/zc/business/domain/DcOperLog.java

@ -0,0 +1,42 @@
package com.zc.business.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
@ApiModel(value = "DcOperLog", description = "调用功能记录实体")
public class DcOperLog {
@TableId(value = "id", type = IdType.AUTO)
private String id;
@ApiModelProperty("设备ID")
private String dcDeviceId;
@ApiModelProperty("设备类型")
private String dcDeviceType;
@ApiModelProperty("设备名称")
private String dcDeviceName;
@ApiModelProperty("操作人员")
private String operName;
@ApiModelProperty("部门名称")
private String deptName;
@ApiModelProperty("操作类型")
private String operType;
@ApiModelProperty("主机地址")
private String operIp;
@ApiModelProperty("操作地点")
private String operLocation;
@ApiModelProperty("请求参数")
private String operParam;
@ApiModelProperty("返回参数")
private String jsonResult;
@ApiModelProperty("操作状态")
private Integer status;
@ApiModelProperty("操作时间")
private Date operTime;
}

13
zc-business/src/main/java/com/zc/business/domain/Status.java

@ -22,11 +22,12 @@ public class Status {
return startTime;
}
public Status(long id, String deviceNo, String deviceName, String deviceStatus, LocalDateTime time, LocalDateTime startTime, String deviceIp, String successRate, String lostRate, String direction, String production, String model, String network, String content, String type) {
public Status(long id, String deviceNo, String deviceName, String deviceStatus, String sectionId, LocalDateTime time, LocalDateTime startTime, String deviceIp, String successRate, String lostRate, String direction, String production, String model, String network, String content, String type) {
this.id = id;
this.deviceNo = deviceNo;
this.deviceName = deviceName;
this.deviceStatus = deviceStatus;
this.sectionId = sectionId;
this.time = time;
this.startTime = startTime;
this.deviceIp = deviceIp;
@ -123,6 +124,8 @@ public class Status {
private Long deviceId;
private String sectionId;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern ="yyyy-MM-dd HH:mm:ss")
@Excel(name = "监测时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
@ -237,4 +240,12 @@ public class Status {
public void setUseState(Integer useState) {
this.useState = useState;
}
public String getSectionId() {
return sectionId;
}
public void setSectionId(String sectionId) {
this.sectionId = sectionId;
}
}

15
zc-business/src/main/java/com/zc/business/interfaces/OperationLog.java

@ -0,0 +1,15 @@
package com.zc.business.interfaces;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface OperationLog {
//String value() default "";
String operUrl();
}

136
zc-business/src/main/java/com/zc/business/interfaces/OperationLogAspect.java

@ -0,0 +1,136 @@
package com.zc.business.interfaces;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.ip.IpUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.service.ISysDeptService;
import com.zc.business.domain.DcDevice;
import com.zc.business.domain.DcOperLog;
import com.zc.business.service.IDcDeviceService;
import com.zc.business.service.IDcOperLogService;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
@Aspect
@Component
public class OperationLogAspect {
@AfterReturning(pointcut = "@annotation(operationLog)", returning = "jsonResult")
public void AfterReturning(JoinPoint joinPoint, OperationLog operationLog, Object jsonResult) throws Throwable {
System.out.println("运行成功");
around((ProceedingJoinPoint) joinPoint, operationLog, "0", jsonResult, null);
}
@AfterThrowing(value = "@annotation(operationLog)", throwing = "e")
public void AfterThrowing(JoinPoint joinPoint, OperationLog operationLog, Exception e) throws Throwable {
System.out.println("运行失败");
around((ProceedingJoinPoint) joinPoint, operationLog, "1", null, e);
}
public void around(ProceedingJoinPoint joinPoint, OperationLog operationLog, String state, Object jsonResult, Exception exception) throws Throwable {
ISysDeptService deptService = SpringUtils.getBean(ISysDeptService.class);
IDcOperLogService dcOperLogService = SpringUtils.getBean(IDcOperLogService.class);
IDcDeviceService dcDeviceService = SpringUtils.getBean(IDcDeviceService.class);
try {
DcOperLog dcOperLog = new DcOperLog();
String operUrl = operationLog.operUrl();
LoginUser loginUser;
try {
loginUser = SecurityUtils.getLoginUser();
}catch (Exception e){
loginUser = null;
}
Object[] pointArgs = joinPoint.getArgs();
HttpServletRequest request;
try {
request = ServletUtils.getRequest();
}catch (Exception e){
request = null;
}
if (operUrl.contains("batchFunctions")) {
if (loginUser != null) {
SysDept sysDept = deptService.selectDeptById(loginUser.getDeptId());
dcOperLog.setOperName(loginUser.getUsername());
dcOperLog.setDeptName(sysDept.getDeptName());
dcOperLog.setOperLocation(loginUser.getLoginLocation());
}
dcOperLog.setOperType("2");
dcOperLog.setOperIp(IpUtils.getIpAddr(request));
dcOperLog.setJsonResult(String.valueOf(joinPoint.proceed(pointArgs)));
dcOperLog.setOperTime(new Date());
HashMap<String, ArrayList<JSONObject>> pointArg = (HashMap<String, ArrayList<JSONObject>>) pointArgs[0];
ArrayList<JSONObject> devices = pointArg.get("devices");
ArrayList<JSONObject> functions = pointArg.get("functions");
for (Object dev : devices) {
JSONObject device = (JSONObject) JSON.toJSON(dev);
LambdaQueryWrapper<DcDevice> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(DcDevice::getId, device.get("id"));
List<DcDevice> list = dcDeviceService.list(lambdaQueryWrapper);
if (list.size() > 0) {
DcDevice dcDevice = list.get(0);
dcOperLog.setDcDeviceId(String.valueOf(dcDevice.getId()));
dcOperLog.setDcDeviceName(dcDevice.getDeviceName());
dcOperLog.setDcDeviceType(dcDevice.getDeviceType());
}
for (Object fun : functions) {
JSONObject function = (JSONObject) JSON.toJSON(fun);
dcOperLog.setOperParam(function.getString("params"));
dcOperLogService.addDcOperLog(dcOperLog);
}
}
} else if (operUrl.contains("functions")) {
LambdaQueryWrapper<DcDevice> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(DcDevice::getIotDeviceId, pointArgs[0]);
List<DcDevice> list = dcDeviceService.list(lambdaQueryWrapper);
if (list.size() > 0) {
DcDevice dcDevice = list.get(0);
dcOperLog.setDcDeviceId(String.valueOf(dcDevice.getId()));
dcOperLog.setDcDeviceName(dcDevice.getDeviceName());
dcOperLog.setDcDeviceType(dcDevice.getDeviceType());
}
if (loginUser != null) {
SysDept sysDept = deptService.selectDeptById(loginUser.getDeptId());
dcOperLog.setOperName(loginUser.getUsername());
dcOperLog.setDeptName(sysDept.getDeptName());
dcOperLog.setOperLocation(loginUser.getLoginLocation());
dcOperLog.setOperType("0");
} else {
dcOperLog.setOperType("1");
}
dcOperLog.setOperIp(IpUtils.getIpAddr(request));
dcOperLog.setOperParam(Arrays.toString(joinPoint.getArgs()));
dcOperLog.setJsonResult(String.valueOf(joinPoint.proceed(pointArgs)));
if (Objects.equals(state, "0")) {
dcOperLog.setStatus(0);
} else {
dcOperLog.setStatus(1);
}
dcOperLog.setOperTime(new Date());
dcOperLogService.addDcOperLog(dcOperLog);
}
} catch (Exception e) {
throw e;
}
}
}

14
zc-business/src/main/java/com/zc/business/mapper/DcBatchFunctionsJobGroupMapper.java

@ -0,0 +1,14 @@
package com.zc.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zc.business.domain.DcBatchFunctionsJobGroup;
import org.apache.ibatis.annotations.Mapper;
/**
* 定时任务组Mapper接口
*
* @author zhaoxianglong
*/
@Mapper
public interface DcBatchFunctionsJobGroupMapper extends BaseMapper<DcBatchFunctionsJobGroup> {
}

14
zc-business/src/main/java/com/zc/business/mapper/DcBatchFunctionsJobMapper.java

@ -0,0 +1,14 @@
package com.zc.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zc.business.domain.DcBatchFunctionsJob;
import org.apache.ibatis.annotations.Mapper;
/**
* 定时任务Mapper接口
*
* @author zhaoxianglong
*/
@Mapper
public interface DcBatchFunctionsJobMapper extends BaseMapper<DcBatchFunctionsJob> {
}

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

@ -23,4 +23,6 @@ public interface DcDeviceMapper extends BaseMapper<DcDevice> {
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);
List<Map<String,String>> countTheNumberOfEligibleItems();
}

14
zc-business/src/main/java/com/zc/business/mapper/DcOperLogMapper.java

@ -0,0 +1,14 @@
package com.zc.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zc.business.domain.DcOperLog;
import org.apache.ibatis.annotations.Mapper;
/**
* 调用功能记录Mapper接口
*
* @author zhaoxianglong
*/
@Mapper
public interface DcOperLogMapper extends BaseMapper<DcOperLog> {
}

1
zc-business/src/main/java/com/zc/business/mapper/StatusMapper.java

@ -17,6 +17,7 @@ public interface StatusMapper {
int Add(@Param("status")Status status);
List<Status> listStatus(@Param("status")Status status);
List<Status> listStatusBySection(@Param("status")Status status);
List<Status> export(@Param("status")Status status);
List<Status> deviceStatusListById(@Param("status")Status status);

53
zc-business/src/main/java/com/zc/business/service/IDcBatchFunctionsJobGroupService.java

@ -0,0 +1,53 @@
package com.zc.business.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.exception.job.TaskException;
import com.zc.business.domain.DcBatchFunctionsJobGroup;
import org.quartz.SchedulerException;
import java.util.List;
/**
* 定时任务组Service接口
*
* @author zhaoxianglong
*/
public interface IDcBatchFunctionsJobGroupService extends IService<DcBatchFunctionsJobGroup> {
/**
* 添加信息
*
* @return 操作结果
*/
DcBatchFunctionsJobGroup addDcBatchFunctionsJobGroup(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup);
/**
* 修改信息
*
* @return 操作结果
*/
DcBatchFunctionsJobGroup editDcBatchFunctionsJobGroup(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup);
/**
* 删除
*
* @return 操作结果
*/
boolean removeDcBatchFunctionsJobGroup(List<String> ids);
/**
* 获取列表
*
* @return 结果
*/
List<DcBatchFunctionsJobGroup> pageDcBatchFunctionsJobGroup(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup);
/**
* 获取列表
*
* @return 结果
*/
List<DcBatchFunctionsJobGroup> listDcBatchFunctionsJobGroup(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup);
boolean changeStatus(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup) throws SchedulerException, TaskException;
}

57
zc-business/src/main/java/com/zc/business/service/IDcBatchFunctionsJobService.java

@ -0,0 +1,57 @@
package com.zc.business.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.exception.job.TaskException;
import com.zc.business.domain.DcBatchFunctionsJob;
import org.quartz.SchedulerException;
import java.util.List;
/**
* 定时任务Service接口
*
* @author zhaoxianglong
*/
public interface IDcBatchFunctionsJobService extends IService<DcBatchFunctionsJob> {
/**
* 添加信息
*
* @return 操作结果
*/
DcBatchFunctionsJob addDcBatchFunctionsJob(DcBatchFunctionsJob dcBatchFunctionsJob) throws TaskException, SchedulerException;
/**
* 修改信息
*
* @return 操作结果
*/
boolean editDcBatchFunctionsJob(DcBatchFunctionsJob dcBatchFunctionsJob) throws SchedulerException, TaskException;
/**
* 删除
*
* @return 操作结果
*/
boolean removeDcBatchFunctionsJob(List<String> ids) throws SchedulerException, TaskException;
/**
* 获取列表
*
* @return 结果
*/
List<DcBatchFunctionsJob> pageDcBatchFunctionsJob(DcBatchFunctionsJob dcBatchFunctionsJob);
/**
* 获取列表
*
* @return 结果
*/
List<DcBatchFunctionsJob> listDcBatchFunctionsJob(DcBatchFunctionsJob dcBatchFunctionsJob) throws SchedulerException;
boolean changeStatus(DcBatchFunctionsJob dcBatchFunctionsJob, String status) throws SchedulerException, TaskException;
boolean deletesATaskByTime(String groupId, String time);
}

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

@ -96,7 +96,9 @@ public interface IDcDeviceService extends IService<DcDevice> {
List<DcDevice> numberOfDevicesByType();
List<DcDevice> selectNearCamPile(String direction,String startMileage,String endMileage);
List<Map<String, String>> countTheNumberOfEligibleItems();
List<DcDevice> selectNearCamPile(String direction, String startMileage, String endMileage);
/**
* 查询上游10公里内的情报板

52
zc-business/src/main/java/com/zc/business/service/IDcOperLogService.java

@ -0,0 +1,52 @@
package com.zc.business.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zc.business.domain.DcOperLog;
import java.util.List;
import java.util.Date;
/**
* 调用功能记录Service接口
*
* @author zhaoxianglong
*/
public interface IDcOperLogService extends IService<DcOperLog> {
/**
* 添加信息
*
* @return 操作结果
*/
boolean addDcOperLog(DcOperLog dcOperLog);
/**
* 修改信息
*
* @return 操作结果
*/
boolean editDcOperLog(DcOperLog dcOperLog);
/**
* 删除
*
* @return 操作结果
*/
boolean removeDcOperLog(List<String> ids);
/**
* 获取列表
*
* @return 结果
*/
List<DcOperLog> pageDcOperLog(DcOperLog dcOperLog, Date endTime, Date startTime);
/**
* 获取列表
*
* @return 结果
*/
List<DcOperLog> listDcOperLog(DcOperLog dcOperLog,Date endTime,Date startTime);
}

125
zc-business/src/main/java/com/zc/business/service/impl/DcBatchFunctionsJobGroupServiceImpl.java

@ -0,0 +1,125 @@
package com.zc.business.service.impl;
import com.alibaba.fastjson.JSONArray;
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.exception.job.TaskException;
import com.ruoyi.common.utils.PageUtils;
import com.zc.business.domain.DcBatchFunctionsJob;
import com.zc.business.domain.DcBatchFunctionsJobGroup;
import com.zc.business.mapper.DcBatchFunctionsJobGroupMapper;
import com.zc.business.service.IDcBatchFunctionsJobGroupService;
import com.zc.business.service.IDcBatchFunctionsJobService;
import org.quartz.SchedulerException;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 定时任务组Service业务层处理
*
* @author zhaoxianglong
*/
@Service
public class DcBatchFunctionsJobGroupServiceImpl extends ServiceImpl<DcBatchFunctionsJobGroupMapper, DcBatchFunctionsJobGroup> implements IDcBatchFunctionsJobGroupService {
@Resource
private IDcBatchFunctionsJobService dcBatchFunctionsJobService;
@Override
public DcBatchFunctionsJobGroup addDcBatchFunctionsJobGroup(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup) {
dcBatchFunctionsJobGroup.setCreateTime(new Date());
boolean save = save(dcBatchFunctionsJobGroup);
if (save) {
return dcBatchFunctionsJobGroup;
}
return null;
}
@Override
public DcBatchFunctionsJobGroup editDcBatchFunctionsJobGroup(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup) {
LambdaQueryWrapper<DcBatchFunctionsJobGroup> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(DcBatchFunctionsJobGroup::getId, dcBatchFunctionsJobGroup.getId());
dcBatchFunctionsJobGroup.setUpdateTime(new Date());
boolean update = update(dcBatchFunctionsJobGroup, lambdaQueryWrapper);
if (update) {
return dcBatchFunctionsJobGroup;
}
return null;
}
@Override
public boolean removeDcBatchFunctionsJobGroup(List<String> ids) {
//LambdaQueryWrapper<DcBatchFunctionsJob> lambdaQueryWrapper = new LambdaQueryWrapper<>();
//lambdaQueryWrapper.in(DcBatchFunctionsJob::getJobGroup, ids);
//dcBatchFunctionsJobService.remove(lambdaQueryWrapper);
//List<DcBatchFunctionsJob> list = dcBatchFunctionsJobService.list();
//List<Integer> collect = list.stream().filter(item -> {
// String callParameter = item.getCallParameter();
// return true;
//}).map(DcBatchFunctionsJob::getJobId).collect(Collectors.toList());
//dcBatchFunctionsJobService.removeByIds(collect);
LambdaQueryWrapper<DcBatchFunctionsJobGroup> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(DcBatchFunctionsJobGroup::getId, ids);
List<DcBatchFunctionsJobGroup> list = list(lambdaQueryWrapper);
ArrayList<String> arrayList = new ArrayList<>();
list.forEach(item -> {
JSONArray detailedConfiguration = JSONArray.parseArray(item.getDetailedConfiguration());
detailedConfiguration.forEach(ite -> {
JSONObject jsonObject = (JSONObject) ite;
JSONArray tasks = jsonObject.getJSONArray("tasks");
tasks.forEach(it -> {
arrayList.add(String.valueOf(it));
});
});
});
dcBatchFunctionsJobService.removeByIds(arrayList);
return removeByIds(ids);
}
@Override
public List<DcBatchFunctionsJobGroup> pageDcBatchFunctionsJobGroup(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup) {
PageUtils.startPage();
return list(getDcBatchFunctionsJobGroupLambdaQueryWrapper(dcBatchFunctionsJobGroup));
}
@Override
public List<DcBatchFunctionsJobGroup> listDcBatchFunctionsJobGroup(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup) {
return list(getDcBatchFunctionsJobGroupLambdaQueryWrapper(dcBatchFunctionsJobGroup));
}
private static LambdaQueryWrapper<DcBatchFunctionsJobGroup> getDcBatchFunctionsJobGroupLambdaQueryWrapper(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup) {
LambdaQueryWrapper<DcBatchFunctionsJobGroup> lambdaQueryWrapper = new LambdaQueryWrapper<>();
if (dcBatchFunctionsJobGroup.getId() != null) {
lambdaQueryWrapper.eq(DcBatchFunctionsJobGroup::getId, dcBatchFunctionsJobGroup.getId());
}
if (dcBatchFunctionsJobGroup.getGroupName() != null) {
lambdaQueryWrapper.like(DcBatchFunctionsJobGroup::getGroupName, dcBatchFunctionsJobGroup.getGroupName());
}
if (dcBatchFunctionsJobGroup.getStatus() != null) {
lambdaQueryWrapper.eq(DcBatchFunctionsJobGroup::getStatus, dcBatchFunctionsJobGroup.getStatus());
}
return lambdaQueryWrapper;
}
@Override
public boolean changeStatus(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup) throws TaskException, SchedulerException {
DcBatchFunctionsJob dcBatchFunctionsJob = new DcBatchFunctionsJob();
dcBatchFunctionsJob.setJobGroup(String.valueOf(dcBatchFunctionsJobGroup.getId()));
List<DcBatchFunctionsJob> dcBatchFunctionsJobs = dcBatchFunctionsJobService.listDcBatchFunctionsJob(dcBatchFunctionsJob);
for (DcBatchFunctionsJob batchFunctionsJob : dcBatchFunctionsJobs) {
boolean changeStatus = dcBatchFunctionsJobService.changeStatus(batchFunctionsJob, dcBatchFunctionsJobGroup.getStatus());
if (!changeStatus) {
return false;
}
}
DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup1 = editDcBatchFunctionsJobGroup(dcBatchFunctionsJobGroup);
return dcBatchFunctionsJobGroup1 != null;
}
}

257
zc-business/src/main/java/com/zc/business/service/impl/DcBatchFunctionsJobServiceImpl.java

@ -0,0 +1,257 @@
package com.zc.business.service.impl;
import com.alibaba.fastjson.JSONArray;
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.exception.job.TaskException;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.zc.business.domain.DcBatchFunctionsJob;
import com.zc.business.domain.DcBatchFunctionsJobGroup;
import com.zc.business.mapper.DcBatchFunctionsJobMapper;
import com.zc.business.service.IDcBatchFunctionsJobGroupService;
import com.zc.business.service.IDcBatchFunctionsJobService;
import com.zc.business.utils.ScheduleUtils;
import org.quartz.JobKey;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors;
/**
* 定时任务Service业务层处理
*
* @author zhaoxianglong
*/
@Service
public class DcBatchFunctionsJobServiceImpl extends ServiceImpl<DcBatchFunctionsJobMapper, DcBatchFunctionsJob> implements IDcBatchFunctionsJobService {
@Resource
private Scheduler scheduler;
@Resource
private IDcBatchFunctionsJobGroupService dcBatchFunctionsJobGroupService;
/**
* 项目启动时初始化定时器 主要是防止手动修改数据库导致未同步到定时任务处理不能手动修改数据库ID和任务组名否则会导致脏数据
*/
@PostConstruct
public void init() throws TaskException, SchedulerException {
List<DcBatchFunctionsJob> jobList = list();
for (DcBatchFunctionsJob job : jobList) {
createScheduleJob(job);
}
}
private void createScheduleJob(DcBatchFunctionsJob job) throws SchedulerException, TaskException {
IDcBatchFunctionsJobGroupService dcBatchFunctionsJobGroupService = SpringUtils.getBean(IDcBatchFunctionsJobGroupService.class);
DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup = dcBatchFunctionsJobGroupService.getById(job.getJobGroup());
if (dcBatchFunctionsJobGroup != null) {
JSONArray jsonArray = JSONObject.parseArray(dcBatchFunctionsJobGroup.getDetailedConfiguration());
for (Object o : jsonArray) {
String time = ((JSONObject) o).getString("time");
String[] times = time.split(":");
String cron = times[2] + " " + times[1] + " " + times[0] + " " + " * * ?";
JSONArray tasks = ((JSONObject) o).getJSONArray("tasks");
for (Object task : tasks) {
if (Objects.equals(String.valueOf(job.getJobId()), String.valueOf(task))) {
job.setCronExpression(cron);
job.setStatus(dcBatchFunctionsJobGroup.getStatus());
ScheduleUtils.createScheduleJob(scheduler, job);
}
}
}
}
}
@Override
public DcBatchFunctionsJob addDcBatchFunctionsJob(DcBatchFunctionsJob dcBatchFunctionsJob) throws TaskException, SchedulerException {
DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup = dcBatchFunctionsJobGroupService.getById(dcBatchFunctionsJob.getJobGroup());
if (dcBatchFunctionsJobGroup != null) {
JSONArray detailedConfigurations = JSONArray.parseArray(dcBatchFunctionsJobGroup.getDetailedConfiguration());
String time = dcBatchFunctionsJob.getTime();
if (time == null) {
return null;
}
List<Object> detaileds = detailedConfigurations.stream().filter(detailed ->
Objects.equals((String) ((JSONObject) detailed).get("time"), time)
).collect(Collectors.toList());
Integer id = ThreadLocalRandom.current().nextInt(0, 999999999);
if (detaileds.size() > 0) {
JSONObject detailed = (JSONObject) detaileds.get(0);
JSONArray tasks = detailed.getJSONArray("tasks");
tasks.add(id);
detailed.put("tasks", tasks);
detailedConfigurations.stream().filter(detailedConfiguration -> Objects.equals((String) ((JSONObject) detailed).get("time"), time)).map(detadetailedConfiguration -> detailed);
} else {
JSONArray tasks = new JSONArray();
tasks.add(id);
JSONObject detailedConfiguration = new JSONObject();
detailedConfiguration.put("time", time);
detailedConfiguration.put("tasks", tasks);
detailedConfigurations.add(detailedConfiguration);
}
dcBatchFunctionsJobGroup.setDetailedConfiguration(String.valueOf(detailedConfigurations));
dcBatchFunctionsJobGroupService.editDcBatchFunctionsJobGroup(dcBatchFunctionsJobGroup);
dcBatchFunctionsJob.setJobId(id);
dcBatchFunctionsJob.setCreateTime(new Date());
createScheduleJob(dcBatchFunctionsJob);
boolean save = save(dcBatchFunctionsJob);
if (save) {
return dcBatchFunctionsJob;
} else {
return null;
}
}
return null;
}
@Override
public boolean editDcBatchFunctionsJob(DcBatchFunctionsJob dcBatchFunctionsJob) throws SchedulerException, TaskException {
LambdaQueryWrapper<DcBatchFunctionsJob> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(DcBatchFunctionsJob::getJobId, dcBatchFunctionsJob.getJobId());
dcBatchFunctionsJob.setUpdateTime(new Date());
boolean update = updateSchedulerJob(dcBatchFunctionsJob, dcBatchFunctionsJob.getJobGroup());
if (update) {
return update(dcBatchFunctionsJob, lambdaQueryWrapper);
}
return update;
}
/**
* 更新任务
*
* @param job 任务对象
* @param jobGroup 任务组名
*/
public boolean updateSchedulerJob(DcBatchFunctionsJob job, String jobGroup) throws SchedulerException, TaskException {
Long jobId = Long.valueOf(job.getJobId());
// 判断是否存在
JobKey jobKey = ScheduleUtils.getJobKey(jobId, jobGroup);
if (scheduler.checkExists(jobKey)) {
// 防止创建时存在数据问题 先移除,然后在执行创建操作
scheduler.deleteJob(jobKey);
}
createScheduleJob(job);
return true;
}
@Override
public boolean removeDcBatchFunctionsJob(List<String> ids) throws SchedulerException, TaskException {
for (String id : ids) {
DcBatchFunctionsJob job = new DcBatchFunctionsJob();
job.setJobId(Integer.valueOf(id));
List<DcBatchFunctionsJob> dcBatchFunctionsJobs = listDcBatchFunctionsJob(job);
if (dcBatchFunctionsJobs.size() == 0) {
return false;
}
DcBatchFunctionsJob dcBatchFunctionsJob = dcBatchFunctionsJobs.get(0);
ScheduleUtils.deleteJob(scheduler, dcBatchFunctionsJob);
DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup = dcBatchFunctionsJobGroupService.getById(dcBatchFunctionsJob.getJobGroup());
if (dcBatchFunctionsJobGroup == null) {
return false;
}
JSONArray detailedConfigurations = JSONArray.parseArray(dcBatchFunctionsJobGroup.getDetailedConfiguration());
List<Object> detaileds = detailedConfigurations.stream().filter(detailed -> {
boolean result = false;
boolean tasks = JSONArray.parseArray(String.valueOf(((JSONObject) detailed).get("tasks"))).contains(id);
JSONObject jsonObject = (JSONObject) detailed;
JSONArray jsonArray = jsonObject.getJSONArray("tasks");
boolean contains = jsonArray.contains(id);
for (Object o : jsonArray) {
if (Objects.equals(String.valueOf(o), id)) {
result = true;
}
}
return result;
}).collect(Collectors.toList());
System.out.println(detaileds);
if (detaileds.size() > 0) {
JSONObject detailed = (JSONObject) detaileds.get(0);
JSONArray tasks = detailed.getJSONArray("tasks");
tasks = tasks.stream()
.filter(task -> !Objects.equals(String.valueOf(task), id))
.collect(Collectors.toCollection(JSONArray::new));
detailed.put("tasks", tasks);
detailedConfigurations.stream().filter(detailedConfiguration -> ((JSONObject) detailed).get("time") == dcBatchFunctionsJob.getTime()).map(detadetailedConfiguration -> detailed);
dcBatchFunctionsJobGroup.setDetailedConfiguration(String.valueOf(detailedConfigurations));
dcBatchFunctionsJobGroupService.editDcBatchFunctionsJobGroup(dcBatchFunctionsJobGroup);
}
}
LambdaQueryWrapper<DcBatchFunctionsJob> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(DcBatchFunctionsJob::getJobId, ids);
return remove(lambdaQueryWrapper);
//return true;
}
@Override
public List<DcBatchFunctionsJob> pageDcBatchFunctionsJob(DcBatchFunctionsJob dcBatchFunctionsJob) {
PageUtils.startPage();
return list(getDcBatchFunctionsJobLambdaQueryWrapper(dcBatchFunctionsJob));
}
@Override
public List<DcBatchFunctionsJob> listDcBatchFunctionsJob(DcBatchFunctionsJob dcBatchFunctionsJob) throws SchedulerException {
return list(getDcBatchFunctionsJobLambdaQueryWrapper(dcBatchFunctionsJob));
}
private static LambdaQueryWrapper<DcBatchFunctionsJob> getDcBatchFunctionsJobLambdaQueryWrapper(DcBatchFunctionsJob dcBatchFunctionsJob) {
LambdaQueryWrapper<DcBatchFunctionsJob> lambdaQueryWrapper = new LambdaQueryWrapper<>();
if (dcBatchFunctionsJob.getJobId() != null) {
lambdaQueryWrapper.eq(DcBatchFunctionsJob::getJobId, dcBatchFunctionsJob.getJobId());
}
//if (dcBatchFunctionsJob.getJobName() != null) {
// lambdaQueryWrapper.like(DcBatchFunctionsJob::getJobName, dcBatchFunctionsJob.getJobName());
//}
if (dcBatchFunctionsJob.getJobGroup() != null) {
lambdaQueryWrapper.eq(DcBatchFunctionsJob::getJobGroup, dcBatchFunctionsJob.getJobGroup());
}
return lambdaQueryWrapper;
}
@Override
public boolean changeStatus(DcBatchFunctionsJob dcBatchFunctionsJob, String status) throws SchedulerException, TaskException {
if (Objects.equals(status, "0")) {
scheduler.resumeJob(ScheduleUtils.getJobKey(Long.valueOf(dcBatchFunctionsJob.getJobId()), String.valueOf(dcBatchFunctionsJob.getJobGroup())));
} else {
scheduler.pauseJob(ScheduleUtils.getJobKey(Long.valueOf(dcBatchFunctionsJob.getJobId()), String.valueOf(dcBatchFunctionsJob.getJobGroup())));
}
return true;
}
@Override
public boolean deletesATaskByTime(String groupId, String time) {
DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup = dcBatchFunctionsJobGroupService.getById(groupId);
JSONArray detailedConfiguration = JSONArray.parseArray(dcBatchFunctionsJobGroup.getDetailedConfiguration());
List<Object> filter = detailedConfiguration.stream().filter(item -> Objects.equals(((JSONObject) item).getString("time"), time)).collect(Collectors.toList());
filter.forEach(item -> {
JSONArray tasks = ((JSONObject) item).getJSONArray("tasks");
tasks.forEach(ite -> {
LambdaQueryWrapper<DcBatchFunctionsJob> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(DcBatchFunctionsJob::getJobId, ite);
remove(lambdaQueryWrapper);
});
detailedConfiguration.remove(item);
});
dcBatchFunctionsJobGroup.setDetailedConfiguration(detailedConfiguration.toString());
DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup1 = dcBatchFunctionsJobGroupService.editDcBatchFunctionsJobGroup(dcBatchFunctionsJobGroup);
if (dcBatchFunctionsJobGroup1 != null) {
return true;
} else {
return false;
}
}
}

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

@ -487,6 +487,12 @@ public class DcDeviceServiceImpl extends ServiceImpl<DcDeviceMapper, DcDevice> i
return dcDeviceMapper.numberOfDevicesByType();
}
@Override
public List<Map<String, String>> countTheNumberOfEligibleItems() {
return dcDeviceMapper.countTheNumberOfEligibleItems();
}
public static <T> List<T> castList(Object obj, Class<T> clazz) {
List<T> result = new ArrayList<T>();
if (obj instanceof List<?>) {

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

File diff suppressed because it is too large

73
zc-business/src/main/java/com/zc/business/service/impl/DcOperLogServiceImpl.java

@ -0,0 +1,73 @@
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.utils.PageUtils;
import com.zc.business.domain.*;
import com.zc.business.mapper.DcOperLogMapper;
import com.zc.business.service.*;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* 调用功能记录Service业务层处理
*
* @author zhaoxianglong
*/
@Service
public class DcOperLogServiceImpl extends ServiceImpl<DcOperLogMapper, DcOperLog> implements IDcOperLogService {
@Override
public boolean addDcOperLog(DcOperLog dcOperLog) {
return save(dcOperLog);
}
@Override
public boolean editDcOperLog(DcOperLog dcOperLog) {
LambdaQueryWrapper<DcOperLog> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(DcOperLog::getId, dcOperLog.getId());
return update(dcOperLog, lambdaQueryWrapper);
}
@Override
public boolean removeDcOperLog(List<String> ids) {
return removeByIds(ids);
}
@Override
public List<DcOperLog> pageDcOperLog(DcOperLog dcOperLog, Date endTime, Date startTime) {
PageUtils.startPage();
return list(getDcOperLogLambdaQueryWrapper(dcOperLog,endTime,startTime));
}
@Override
public List<DcOperLog> listDcOperLog(DcOperLog dcOperLog,Date endTime,Date startTime) {
return list(getDcOperLogLambdaQueryWrapper(dcOperLog,endTime,startTime));
}
private static LambdaQueryWrapper<DcOperLog> getDcOperLogLambdaQueryWrapper(DcOperLog dcOperLog,Date endTime,Date startTime) {
LambdaQueryWrapper<DcOperLog> lambdaQueryWrapper = new LambdaQueryWrapper<>();
if (dcOperLog.getId() != null) {
lambdaQueryWrapper.eq(DcOperLog::getId, dcOperLog.getId());
}
if (dcOperLog.getDcDeviceType() != null) {
lambdaQueryWrapper.like(DcOperLog::getDcDeviceType, dcOperLog.getDcDeviceType());
}
if (dcOperLog.getDcDeviceName() != null) {
lambdaQueryWrapper.like(DcOperLog::getDcDeviceName, dcOperLog.getDcDeviceName());
}
if (dcOperLog.getOperName() != null) {
lambdaQueryWrapper.like(DcOperLog::getOperName, dcOperLog.getOperName());
}
if (dcOperLog.getDeptName() != null) {
lambdaQueryWrapper.like(DcOperLog::getDeptName, dcOperLog.getDeptName());
}
if (endTime!=null&&startTime!=null) {
lambdaQueryWrapper.between(DcOperLog::getOperTime, startTime, endTime);
}
lambdaQueryWrapper.select(DcOperLog::getId, DcOperLog::getDcDeviceId, DcOperLog::getDcDeviceType, DcOperLog::getDcDeviceType, DcOperLog::getOperName,DcOperLog::getDeptName, DcOperLog::getOperType, DcOperLog::getOperIp, DcOperLog::getOperLocation,DcOperLog::getOperParam, DcOperLog::getJsonResult, DcOperLog::getStatus, DcOperLog::getOperTime);
return lambdaQueryWrapper;
}
}

4
zc-business/src/main/java/com/zc/business/service/impl/StatusService.java

@ -29,6 +29,10 @@ public class StatusService {
List<Status> list = statusMapper.listStatus(status);
return list;
}
public List<Status> listStatusBySection(Status status) {
List<Status> list = statusMapper.listStatusBySection(status);
return list;
}
public List<Status> export(Status status) {
List<Status> list = statusMapper.export(status);
return list;

36
zc-business/src/main/java/com/zc/business/task/ScheduledTaskSchedulingTask.java

@ -0,0 +1,36 @@
package com.zc.business.task;
import com.alibaba.fastjson.JSONArray;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.zc.business.controller.DcDeviceController;
import com.zc.business.domain.DcBatchFunctionsJob;
import com.zc.business.service.impl.DcBatchFunctionsJobServiceImpl;
import com.zc.common.core.httpclient.exception.HttpException;
import org.quartz.SchedulerException;
import org.springframework.stereotype.Component;
import java.io.IOException;
/**
* 定时任务调度测试
*/
@Component
public class ScheduledTaskSchedulingTask {
public void invokeTarget(DcBatchFunctionsJob dcBatchFunctionsJob) throws HttpException, IOException, InterruptedException, SchedulerException {
DcBatchFunctionsJobServiceImpl dcBatchFunctionsJobService = SpringUtils.getBean(DcBatchFunctionsJobServiceImpl.class);
DcDeviceController deviceController = SpringUtils.getBean(DcDeviceController.class);
DcBatchFunctionsJob job = dcBatchFunctionsJobService.listDcBatchFunctionsJob(dcBatchFunctionsJob).get(0);
if (job != null) {
JSONArray jsonArray = JSONArray.parseArray(job.getCallParameter());
for (Object o : jsonArray) {
deviceController.batchInvokedFunction(o);
}
}
}
}

67
zc-business/src/main/java/com/zc/business/utils/ScheduleUtils.java

@ -0,0 +1,67 @@
package com.zc.business.utils;
import com.ruoyi.common.constant.ScheduleConstants;
import com.ruoyi.common.exception.job.TaskException;
import com.zc.business.domain.DcBatchFunctionsJob;
import org.quartz.*;
/**
* 定时任务工具类
*
* @author ruoyi
*/
public class ScheduleUtils {
/**
* 构建任务键对象
*/
public static JobKey getJobKey(Long jobId, String jobGroup) {
return JobKey.jobKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup);
}
/**
* 创建定时任务
*/
public static void createScheduleJob(Scheduler scheduler, DcBatchFunctionsJob job) throws SchedulerException, TaskException {
Class<? extends Job> jobClass = ScheduledTaskScheduling.class;
// 构建job信息
Long jobId = Long.valueOf(job.getJobId());
String jobGroup = String.valueOf(job.getJobGroup());
JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(getJobKey(jobId, jobGroup)).build();
// 表达式调度构建器
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression());
cronScheduleBuilder = cronScheduleBuilder.withMisfireHandlingInstructionIgnoreMisfires();
// 按新的cronExpression表达式构建一个新的trigger
CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(TriggerKey.triggerKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup))
.withSchedule(cronScheduleBuilder).build();
// 放入参数,运行时的方法可以获取
jobDetail.getJobDataMap().put(ScheduleConstants.TASK_PROPERTIES, job);
// 判断是否存在
if (scheduler.checkExists(ScheduleUtils.getJobKey(jobId, jobGroup))) {
// 防止创建时存在数据问题 先移除,然后在执行创建操作
scheduler.deleteJob(ScheduleUtils.getJobKey(jobId, jobGroup));
}
scheduler.scheduleJob(jobDetail, trigger);
// 暂停任务
if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue()))
{
scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup));
}
}
/**
* 删除定时任务
*/
public static void deleteJob(Scheduler scheduler, DcBatchFunctionsJob job) throws SchedulerException, TaskException {
if (scheduler.checkExists(ScheduleUtils.getJobKey(Long.valueOf(job.getJobId()), String.valueOf(job.getJobGroup())))) {
scheduler.deleteJob(getJobKey(Long.valueOf(job.getJobId()), String.valueOf(job.getJobGroup())));
}
}
}

20
zc-business/src/main/java/com/zc/business/utils/ScheduledTaskScheduling.java

@ -0,0 +1,20 @@
package com.zc.business.utils;
import com.ruoyi.quartz.domain.SysJob;
import com.ruoyi.quartz.util.AbstractQuartzJob;
import com.zc.business.domain.DcBatchFunctionsJob;
import com.zc.business.task.ScheduledTaskSchedulingTask;
import org.quartz.JobExecutionContext;
public class ScheduledTaskScheduling extends AbstractQuartzJob {
@Override
protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception {
ScheduledTaskSchedulingTask scheduledTaskSchedulingTask = new ScheduledTaskSchedulingTask();
DcBatchFunctionsJob dcBatchFunctionsJob = new DcBatchFunctionsJob();
dcBatchFunctionsJob.setJobId(Math.toIntExact(sysJob.getJobId()));
scheduledTaskSchedulingTask.invokeTarget(dcBatchFunctionsJob);
}
}

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

@ -141,5 +141,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where t1.device_type = '2' and t1.direction = #{direction}
and t2.mileage >= #{startMileage} and t2.mileage &lt;= #{endMileage}
</select>
<select id="countTheNumberOfEligibleItems" resultType="java.util.Map">
SELECT dc_road_section.id,
COUNT(dc_device.stake_mark) as number
FROM
dc_road_section
JOIN dc_stake_mark
ON dc_road_section.id = dc_stake_mark.section_id
JOIN dc_device ON dc_stake_mark.stake_mark = dc_device.stake_mark
GROUP BY
dc_road_section.id;
</select>
</mapper>

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

@ -771,7 +771,8 @@
update dc_event
<trim prefix="SET" suffixOverrides=",">
<if test="state != null">event_state = #{state},</if>
start_time = NOW(),
<if test="state ==1" > start_time = NOW(),</if>
<if test="state ==2" > end_time = NOW(),</if>
</trim>
where id = #{id}
</update>

29
zc-business/src/main/resources/mapper/business/StatusMapper.xml

@ -147,6 +147,35 @@
</where>
</select>
<select id="listStatusBySection" parameterType="com.zc.business.domain.Status" resultMap="BaseResultMap">
select s.id, s.device_no, s.device_name, s.device_status,s.time,
d.device_ip,s.success_rate,s.lost_rate,d.direction,e.manufacturer,e.model,d.facilities_type,m.section_id,d.remark,COALESCE(d.child_type,
d.device_type) AS type
from dc_device d
LEFT JOIN dc_stake_mark m on m.stake_mark=d.stake_mark and m.direction = d.direction
LEFT JOIN dc_road_section r on r.id=m.section_id
LEFT JOIN status s on (s.device_id=d.id)
LEFT JOIN dc_product e on e.id=d.product_id
<where>
<if test="status.time != null">
AND s.time BETWEEN #{status.startTime,jdbcType=DATE} AND #{status.time,jdbcType=DATE}
</if>
<if test="status.deviceNo != null">
AND s.device_no = #{status.deviceNo}
</if>
<if test="status.type != null">
AND (d.device_type = #{status.type} or d.child_type=#{status.type})
</if>
<if test="status.deviceId != null">
AND s.device_id = #{status.deviceId}
</if>
<if test="status.useState != null and status.useState != 0">
AND d.use_state = #{status.useState}
</if>
</where>
</select>
<select id="deviceStatusListById" parameterType="com.zc.business.domain.Status" resultMap="BaseResultMap">
select s.id,s.time,s.success_rate,s.lost_rate
from status s

Loading…
Cancel
Save