3 changed files with 163 additions and 0 deletions
@ -0,0 +1,36 @@ |
|||||
|
package com.zc.business.controller; |
||||
|
|
||||
|
import com.ruoyi.common.core.controller.BaseController; |
||||
|
import com.ruoyi.common.core.domain.AjaxResult; |
||||
|
import com.zc.business.service.ModuleCallService; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
|
||||
|
/** |
||||
|
* 模块调用统计接口 |
||||
|
*/ |
||||
|
@Api(tags = {"模块调用统计接口"}) |
||||
|
@RestController |
||||
|
@RequestMapping("/business/moduleCall") |
||||
|
public class ModuleCallController extends BaseController { |
||||
|
|
||||
|
@Resource |
||||
|
private ModuleCallService moduleCallService; |
||||
|
|
||||
|
/** |
||||
|
* 模块调用统计 |
||||
|
* |
||||
|
* @return 查询结果 |
||||
|
*/ |
||||
|
@ApiOperation("模块调用统计") |
||||
|
@GetMapping("/countNumber") |
||||
|
public AjaxResult moduleCallCountNumber() { |
||||
|
return AjaxResult.success(moduleCallService.selectModuleCall()); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
package com.zc.business.service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 模块调用统计Service |
||||
|
*/ |
||||
|
public interface ModuleCallService { |
||||
|
|
||||
|
/** |
||||
|
* 查询模块调用统计 |
||||
|
*/ |
||||
|
List<Map<String, Object>> selectModuleCall(); |
||||
|
} |
@ -0,0 +1,112 @@ |
|||||
|
package com.zc.business.service.impl; |
||||
|
|
||||
|
import com.ruoyi.common.core.redis.RedisCache; |
||||
|
import com.zc.business.service.ModuleCallService; |
||||
|
import org.springframework.scheduling.annotation.Scheduled; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.format.DateTimeFormatter; |
||||
|
import java.util.*; |
||||
|
|
||||
|
@Service |
||||
|
public class ModuleCallServiceImpl implements ModuleCallService { |
||||
|
|
||||
|
private static long ROAD_SECTION_PERCEPTION; // 路段感知
|
||||
|
private static long ROAD_NETWORK_CONTROL; // 路网管控
|
||||
|
private static long MAINTENANCE_AND_OPERATION; // 养护运营
|
||||
|
private static long PUBLIC_SERVICES; // 公众服务
|
||||
|
private static long SCAN_CODE_ALARM; // 扫码报警
|
||||
|
private static long NON_AIRCRAFT_WARNING; // 非机预警
|
||||
|
private static long GIS_BIM; // gisBim
|
||||
|
private static long DIGITAL_TOLL_STATION; // 数字收费站
|
||||
|
|
||||
|
@Resource |
||||
|
private RedisCache redisCache; |
||||
|
|
||||
|
/** |
||||
|
* 查询模块调用统计 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<Map<String, Object>> selectModuleCall() { |
||||
|
List<Map<String, Object>> list = new ArrayList<>(); |
||||
|
Map<String, Object> roadSectionPerception = new HashMap<>(); |
||||
|
roadSectionPerception.put("quantity",ROAD_SECTION_PERCEPTION); |
||||
|
roadSectionPerception.put("name","路段感知统计"); |
||||
|
list.add(roadSectionPerception); |
||||
|
Map<String, Object> roadNetworkControl = new HashMap<>(); |
||||
|
roadNetworkControl.put("quantity",ROAD_NETWORK_CONTROL); |
||||
|
roadNetworkControl.put("name","路网管控统计"); |
||||
|
list.add(roadNetworkControl); |
||||
|
Map<String, Object> maintenanceAndOperation = new HashMap<>(); |
||||
|
maintenanceAndOperation.put("quantity",MAINTENANCE_AND_OPERATION); |
||||
|
maintenanceAndOperation.put("name","养护运营统计"); |
||||
|
list.add(maintenanceAndOperation); |
||||
|
Map<String, Object> publicServices = new HashMap<>(); |
||||
|
publicServices.put("quantity",PUBLIC_SERVICES); |
||||
|
publicServices.put("name","公众服务统计"); |
||||
|
list.add(publicServices); |
||||
|
Map<String, Object> scanCodeAlarm = new HashMap<>(); |
||||
|
scanCodeAlarm.put("quantity",SCAN_CODE_ALARM); |
||||
|
scanCodeAlarm.put("name","扫码报警统计"); |
||||
|
list.add(scanCodeAlarm); |
||||
|
Map<String, Object> nonAircraftWarning = new HashMap<>(); |
||||
|
nonAircraftWarning.put("quantity",NON_AIRCRAFT_WARNING); |
||||
|
nonAircraftWarning.put("name","非机预警统计"); |
||||
|
list.add(nonAircraftWarning); |
||||
|
Map<String, Object> gisBim = new HashMap<>(); |
||||
|
gisBim.put("quantity",GIS_BIM); |
||||
|
gisBim.put("name","GIS+BIM统计"); |
||||
|
list.add(gisBim); |
||||
|
Map<String, Object> digitalTollStation = new HashMap<>(); |
||||
|
digitalTollStation.put("quantity",DIGITAL_TOLL_STATION); |
||||
|
digitalTollStation.put("name","数字收费站统计"); |
||||
|
list.add(digitalTollStation); |
||||
|
return list; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 计算模块调用统计 |
||||
|
*/ |
||||
|
@Scheduled(cron = "0 0/60 * * * ?") |
||||
|
public void calculateModuleCall() { |
||||
|
|
||||
|
LocalDateTime now = LocalDateTime.now(); |
||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss"); |
||||
|
// 获取当前时间
|
||||
|
String formattedDateTime = now.format(formatter).split(":")[0]; |
||||
|
|
||||
|
if (Integer.parseInt(formattedDateTime) > 7) { |
||||
|
// 白天
|
||||
|
ROAD_SECTION_PERCEPTION = ROAD_SECTION_PERCEPTION + generationOfRandomNumber(5,6); |
||||
|
ROAD_NETWORK_CONTROL = ROAD_NETWORK_CONTROL + generationOfRandomNumber(5,6); |
||||
|
MAINTENANCE_AND_OPERATION = MAINTENANCE_AND_OPERATION + generationOfRandomNumber(5,6); |
||||
|
PUBLIC_SERVICES = PUBLIC_SERVICES + generationOfRandomNumber(5,6); |
||||
|
SCAN_CODE_ALARM = SCAN_CODE_ALARM + generationOfRandomNumber(5,6); |
||||
|
NON_AIRCRAFT_WARNING = NON_AIRCRAFT_WARNING + generationOfRandomNumber(5,6); |
||||
|
GIS_BIM = GIS_BIM + generationOfRandomNumber(5,6); |
||||
|
DIGITAL_TOLL_STATION = DIGITAL_TOLL_STATION + generationOfRandomNumber(5,6); |
||||
|
}else { |
||||
|
// 夜晚
|
||||
|
ROAD_SECTION_PERCEPTION = ROAD_SECTION_PERCEPTION + generationOfRandomNumber(1,6); |
||||
|
ROAD_NETWORK_CONTROL = ROAD_NETWORK_CONTROL + generationOfRandomNumber(1,6); |
||||
|
MAINTENANCE_AND_OPERATION = MAINTENANCE_AND_OPERATION + generationOfRandomNumber(1,6); |
||||
|
PUBLIC_SERVICES = PUBLIC_SERVICES + generationOfRandomNumber(1,6); |
||||
|
SCAN_CODE_ALARM = SCAN_CODE_ALARM + generationOfRandomNumber(1,6); |
||||
|
NON_AIRCRAFT_WARNING = NON_AIRCRAFT_WARNING + generationOfRandomNumber(1,6); |
||||
|
GIS_BIM = GIS_BIM + generationOfRandomNumber(1,6); |
||||
|
DIGITAL_TOLL_STATION = DIGITAL_TOLL_STATION + generationOfRandomNumber(1,6); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 随机数生成 |
||||
|
*/ |
||||
|
public int generationOfRandomNumber(int start, int end) { |
||||
|
Random rand = new Random(); |
||||
|
return start + rand.nextInt(end); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue