From 2e5c2bc2b7afc7926ec441ff083acd179cb29fc6 Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期三, 25 三月 2026 09:14:20 +0800
Subject: [PATCH] 调整
---
jyz-base-start/src/main/java/com/tievd/jyz/service/IOilRecordService.java | 2
jyz-base-start/src/main/java/com/tievd/jyz/controller/DataTableController.java | 11 +++
jyz-base-start/src/main/java/com/tievd/jyz/service/impl/OilRecordServiceImpl.java | 125 +++++++++++++++++++++++++++++++++++++++++
jyz-base-start/src/main/java/com/tievd/jyz/entity/vo/DataStatisReqVo.java | 6 ++
4 files changed, 144 insertions(+), 0 deletions(-)
diff --git a/jyz-base-start/src/main/java/com/tievd/jyz/controller/DataTableController.java b/jyz-base-start/src/main/java/com/tievd/jyz/controller/DataTableController.java
index e180133..7a40e36 100644
--- a/jyz-base-start/src/main/java/com/tievd/jyz/controller/DataTableController.java
+++ b/jyz-base-start/src/main/java/com/tievd/jyz/controller/DataTableController.java
@@ -127,6 +127,8 @@
@PostMapping("/statTrend")
@Operation(summary = "鍔犳补绔欑粺璁�-椤堕儴鏉″舰鍥�")
public Result<?> statTrend(@RequestBody DataStatisReqVo param) {
+ LoginUser user = SystemContextUtil.currentLoginUser();
+ param.setOrgCodeIfnull(user.getOrgCode());
JSONObject statFan;
if (param.getTrendType() == DataStatisReqVo.TrendType.CLIENT || param.getTrendType() == DataStatisReqVo.TrendType.LOSE_CLIENT) {
statFan = oilRecordService.statTrendClient(param);
@@ -135,6 +137,15 @@
}
return Result.ok(statFan);
}
+
+ @PostMapping("/statTrendDetail")
+ @Operation(summary = "鍔犳补绔欑粺璁�-瓒嬪娍鍒嗘瀽鏄庣粏")
+ public Result<?> statTrendDetail(@RequestBody DataStatisReqVo param) {
+ LoginUser user = SystemContextUtil.currentLoginUser();
+ param.setOrgCodeIfnull(user.getOrgCode());
+ List<Map<String, Object>> list = oilRecordService.statTrendDetail(param);
+ return Result.ok(list);
+ }
}
diff --git a/jyz-base-start/src/main/java/com/tievd/jyz/entity/vo/DataStatisReqVo.java b/jyz-base-start/src/main/java/com/tievd/jyz/entity/vo/DataStatisReqVo.java
index cfe3341..edb793a 100644
--- a/jyz-base-start/src/main/java/com/tievd/jyz/entity/vo/DataStatisReqVo.java
+++ b/jyz-base-start/src/main/java/com/tievd/jyz/entity/vo/DataStatisReqVo.java
@@ -58,6 +58,12 @@
@Schema(description = "HOURS, DAYS, MONTHS")
private StatUnit timeUnit = StatUnit.HOURS;
+
+ @Schema(description = "瓒嬪娍鍥剧偣浣嶆椂闂�")
+ private String statTime;
+
+ @Schema(description = "瓒嬪娍鍥剧郴鍒楀悕绉�")
+ private String seriesName;
private DataStatisReqVo setTimeUnit(String timeUnit){
this.timeUnit = StatUnit.valueOf(timeUnit);
diff --git a/jyz-base-start/src/main/java/com/tievd/jyz/service/IOilRecordService.java b/jyz-base-start/src/main/java/com/tievd/jyz/service/IOilRecordService.java
index 3e0bd48..f7ee057 100644
--- a/jyz-base-start/src/main/java/com/tievd/jyz/service/IOilRecordService.java
+++ b/jyz-base-start/src/main/java/com/tievd/jyz/service/IOilRecordService.java
@@ -50,4 +50,6 @@
JSONObject statTrend(DataStatisReqVo param);
JSONObject statTrendClient(DataStatisReqVo param);
+
+ List<Map<String, Object>> statTrendDetail(DataStatisReqVo param);
}
diff --git a/jyz-base-start/src/main/java/com/tievd/jyz/service/impl/OilRecordServiceImpl.java b/jyz-base-start/src/main/java/com/tievd/jyz/service/impl/OilRecordServiceImpl.java
index 89493f6..1e01e1d 100644
--- a/jyz-base-start/src/main/java/com/tievd/jyz/service/impl/OilRecordServiceImpl.java
+++ b/jyz-base-start/src/main/java/com/tievd/jyz/service/impl/OilRecordServiceImpl.java
@@ -368,6 +368,131 @@
res.put("lineData", lineDatas);
return res;
}
+
+ @Override
+ public List<Map<String, Object>> statTrendDetail(DataStatisReqVo param) {
+ if (param.getTrendType() == null || param.getTimeUnit() == null || param.getStatTime() == null) {
+ return new ArrayList<>();
+ }
+ DataStatisReqVo.TrendType trendType = param.getTrendType();
+ DataStatisReqVo.StatUnit timeUnit = param.getTimeUnit();
+ LocalDateTime[] timeRange = getTrendTimeRange(timeUnit);
+ LocalDateTime timeLimit = timeRange[0];
+ LocalDateTime timeLimitRight = timeRange[1];
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern(timeUnit.statFormat());
+ String statTime = param.getStatTime();
+ List<Map<String, Object>> detailList = new ArrayList<>();
+
+ if (trendType == DataStatisReqVo.TrendType.TRAFFIC) {
+ LambdaQueryWrapper<TrafficFlow> wrapper = new LambdaQueryWrapper<TrafficFlow>()
+ .ge(TrafficFlow::getCaptureTime, timeLimit.toString())
+ .le(TrafficFlow::getCaptureTime, timeLimitRight.toString())
+ .likeRight(TrafficFlow::getOrgCode, param.getOrgCode())
+ .orderByDesc(TrafficFlow::getCaptureTime);
+ List<TrafficFlow> list = trafficFlowMapper.selectList(wrapper);
+ for (TrafficFlow trafficFlow : list) {
+ if (!matchStatTime(trafficFlow.getCaptureTime().toLocalDateTime(), formatter, statTime)) {
+ continue;
+ }
+ Map<String, Object> row = new LinkedHashMap<>();
+ row.put("id", trafficFlow.getId());
+ row.put("captureTime", trafficFlow.getCaptureTime());
+ row.put("carCount", trafficFlow.getCarCount());
+ row.put("modelCode", trafficFlow.getModelCode());
+ row.put("cameraCode", trafficFlow.getCameraCode());
+ detailList.add(row);
+ }
+ return detailList;
+ }
+
+ if (trendType == DataStatisReqVo.TrendType.CLIENT || trendType == DataStatisReqVo.TrendType.LOSE_CLIENT) {
+ LambdaQueryWrapper<OilStatis> wrapper = new LambdaQueryWrapper<OilStatis>()
+ .ge(OilStatis::getUpdateTimeSelf, timeLimit.toString())
+ .le(OilStatis::getUpdateTimeSelf, timeLimitRight.toString())
+ .likeRight(OilStatis::getOrgCode, param.getOrgCode())
+ .orderByDesc(OilStatis::getUpdateTimeSelf);
+ List<OilStatis> list = oilStaticMapper.selectList(wrapper);
+ for (OilStatis oilStatis : list) {
+ if (!matchStatTime(oilStatis.getUpdateTimeSelf().toLocalDateTime(), formatter, statTime)) {
+ continue;
+ }
+ if (trendType == DataStatisReqVo.TrendType.CLIENT
+ && param.getSeriesName() != null
+ && !param.getSeriesName().equals(oilStatis.getClientName())) {
+ continue;
+ }
+ if (trendType == DataStatisReqVo.TrendType.LOSE_CLIENT
+ && (oilStatis.getClientId() == null || oilStatis.getClientId() != SystemConstant.LOSE_CLIENT_ID)) {
+ continue;
+ }
+ Map<String, Object> row = new LinkedHashMap<>();
+ row.put("id", oilStatis.getId());
+ row.put("updateTimeSelf", oilStatis.getUpdateTimeSelf());
+ row.put("licenseNum", oilStatis.getLicenseNum());
+ row.put("clientName", oilStatis.getClientName());
+ row.put("oilCount", oilStatis.getOilCount());
+ row.put("oilSum", oilStatis.getOilSum());
+ detailList.add(row);
+ }
+ return detailList;
+ }
+
+ LambdaQueryWrapper<OilRecord> wrapper = new LambdaQueryWrapper<OilRecord>()
+ .ge(OilRecord::getStartTime, timeLimit.toString())
+ .le(OilRecord::getStartTime, timeLimitRight.toString())
+ .likeRight(OilRecord::getOrgCode, param.getOrgCode())
+ .orderByDesc(OilRecord::getStartTime);
+ List<OilRecord> records = this.list(wrapper);
+ for (OilRecord oilRecord : records) {
+ if (!matchStatTime(oilRecord.getStartTime().toLocalDateTime(), formatter, statTime)) {
+ continue;
+ }
+ if (trendType == DataStatisReqVo.TrendType.OIL
+ && (oilRecord.getBehavior() == null || oilRecord.getBehavior().intValue() != SystemConstant.BEHAVIOR_TYPE_OIL)) {
+ continue;
+ }
+ if (trendType == DataStatisReqVo.TrendType.OIL_vOLUME
+ && (oilRecord.getBehavior() == null || oilRecord.getBehavior().intValue() != SystemConstant.BEHAVIOR_TYPE_OIL)) {
+ continue;
+ }
+ Map<String, Object> row = new LinkedHashMap<>();
+ row.put("id", oilRecord.getId());
+ row.put("startTime", oilRecord.getStartTime());
+ row.put("licenseNum", oilRecord.getLicenseNum());
+ row.put("behavior", oilRecord.getBehavior());
+ row.put("behaviorText", behaviorText(oilRecord.getBehavior()));
+ row.put("oilPosition", oilRecord.getOilPosition());
+ row.put("oilVolume", oilRecord.getOilVolume());
+ row.put("spandTime", oilRecord.getSpandTime());
+ detailList.add(row);
+ }
+ return detailList;
+ }
+
+ private LocalDateTime[] getTrendTimeRange(DataStatisReqVo.StatUnit timeUnit) {
+ LocalDateTime timeLimit = LocalDateTime.now()
+ .minus(timeUnit.value(), ChronoUnit.valueOf(timeUnit.name()))
+ .with(timeUnit.initField(), 1);
+ LocalDateTime timeLimitRight = LocalDateTime.now().with(timeUnit.initField(), 1);
+ return new LocalDateTime[]{timeLimit, timeLimitRight};
+ }
+
+ private boolean matchStatTime(LocalDateTime time, DateTimeFormatter formatter, String statTime) {
+ return formatter.format(time).equals(statTime);
+ }
+
+ private String behaviorText(Byte behavior) {
+ if (behavior == null) {
+ return "";
+ }
+ if (behavior.intValue() == SystemConstant.BEHAVIOR_TYPE_OIL) {
+ return "鍔犳补";
+ }
+ if (behavior.intValue() == SystemConstant.BEHAVIOR_TYPE_TMP) {
+ return "鍋滈潬";
+ }
+ return behavior.toString();
+ }
private <E> JSONObject dataTransLists(
List<E> dataList,
--
Gitblit v1.8.0