|
|
@@ -4,7 +4,6 @@ import java.time.LocalDate;
|
|
4
|
4
|
import java.time.LocalDateTime;
|
|
5
|
5
|
import java.time.ZoneId;
|
|
6
|
6
|
import java.util.Date;
|
|
7
|
|
-import java.util.List;
|
|
8
|
7
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
9
|
8
|
import org.springframework.stereotype.Service;
|
|
10
|
9
|
import com.ruoyi.web.modules.industryservice.support.BreedingIndustryRules;
|
|
|
@@ -14,26 +13,20 @@ import com.ruoyi.web.modules.screen.domain.dto.LivestockResourceProductOutputSum
|
|
14
|
13
|
import com.ruoyi.web.modules.screen.domain.dto.LivestockResourceTechPersonnelDto;
|
|
15
|
14
|
import com.ruoyi.web.modules.screen.domain.dto.LivestockResourceThreeAssetsSumDto;
|
|
16
|
15
|
import com.ruoyi.web.modules.screen.domain.dto.LivestockResourceVaccinationSumDto;
|
|
17
|
|
-import com.ruoyi.web.modules.screen.domain.vo.LivestockResourceActivityTrendVo;
|
|
18
|
|
-import com.ruoyi.web.modules.screen.domain.vo.LivestockResourceCategoryItemVo;
|
|
19
|
|
-import com.ruoyi.web.modules.screen.domain.vo.LivestockResourceCategoryShareVo;
|
|
20
|
16
|
import com.ruoyi.web.modules.screen.domain.vo.LivestockResourceDashboardVo;
|
|
21
|
|
-import com.ruoyi.web.modules.screen.domain.vo.LivestockResourceHourlyHeatVo;
|
|
22
|
17
|
import com.ruoyi.web.modules.screen.domain.vo.LivestockResourceOverviewVo;
|
|
23
|
|
-import com.ruoyi.web.modules.screen.domain.vo.LivestockResourceReplyStatusVo;
|
|
24
|
|
-import com.ruoyi.web.modules.screen.domain.vo.LivestockResourceUserStructureVo;
|
|
25
|
18
|
import com.ruoyi.web.modules.screen.mapper.HomeScreenStatsMapper;
|
|
26
|
19
|
import com.ruoyi.web.modules.screen.mapper.LivestockResourceScreenMapper;
|
|
27
|
20
|
import com.ruoyi.web.modules.screen.service.ILivestockResourceScreenService;
|
|
28
|
21
|
import com.ruoyi.web.modules.screen.support.HomeScreenSupport;
|
|
29
|
|
-import com.ruoyi.web.modules.screen.support.LivestockResourceScreenRules;
|
|
30
|
22
|
import com.ruoyi.web.modules.screen.support.LivestockResourceScreenSupport;
|
|
31
|
23
|
|
|
32
|
24
|
/**
|
|
33
|
25
|
* 大屏畜牧资源统计服务实现。
|
|
34
|
26
|
* <p>
|
|
35
|
|
- * 产业区块:总览、三资、问题上报、产量、疫苗、线下预约、特派员、事业单位、农技课堂、实战培训;
|
|
36
|
|
- * 其余区块仍统计 AI 咨询会话与消息。
|
|
|
27
|
+ * 产业区块:总览、三资、问题上报、产量、疫苗、线下预约、特派员、事业单位、农技课堂、实战培训。
|
|
|
28
|
+ * 已屏蔽 AI 问诊相关区块(活跃度、用户结构、分类、模型调用、分时热度、会话分布、状态、热门问题、关键词)。
|
|
|
29
|
+ * </p>
|
|
37
|
30
|
*/
|
|
38
|
31
|
@Service
|
|
39
|
32
|
public class LivestockResourceScreenServiceImpl implements ILivestockResourceScreenService
|
|
|
@@ -53,11 +46,6 @@ public class LivestockResourceScreenServiceImpl implements ILivestockResourceScr
|
|
53
|
46
|
|
|
54
|
47
|
Date yearStart = toDate(LocalDate.of(year, 1, 1));
|
|
55
|
48
|
Date yearEnd = toDateEndOfDay(statDate);
|
|
56
|
|
- Date sevenStart = toDate(statDate.minusDays(LivestockResourceScreenRules.ACTIVITY_DAYS - 1));
|
|
57
|
|
- Date sevenEnd = yearEnd;
|
|
58
|
|
- LocalDateTime hourlyAnchor = statDateTime.truncatedTo(java.time.temporal.ChronoUnit.HOURS);
|
|
59
|
|
- Date hourlyWindowStart = toDateTime(hourlyAnchor.minusHours(LivestockResourceScreenRules.HOURLY_BUCKETS - 1));
|
|
60
|
|
- Date hourlyWindowEnd = toDateTime(hourlyAnchor.plusHours(1).minusSeconds(1));
|
|
61
|
49
|
|
|
62
|
50
|
LivestockResourceThreeAssetsSumDto assetsSum = livestockResourceScreenMapper.sumRuralThreeAssetsFixed();
|
|
63
|
51
|
LivestockResourceProductOutputSumDto productOutputSum = resolveProductOutputSum(year);
|
|
|
@@ -73,32 +61,6 @@ public class LivestockResourceScreenServiceImpl implements ILivestockResourceScr
|
|
73
|
61
|
livestockResourceScreenMapper.countVetMedicalResource(),
|
|
74
|
62
|
techPersonnel);
|
|
75
|
63
|
|
|
76
|
|
- LivestockResourceActivityTrendVo activityTrend = LivestockResourceScreenSupport.buildActivityTrend(
|
|
77
|
|
- livestockResourceScreenMapper.selectDailySessionCounts(sevenStart, sevenEnd),
|
|
78
|
|
- livestockResourceScreenMapper.selectDailyAiReplyCounts(sevenStart, sevenEnd),
|
|
79
|
|
- statDate);
|
|
80
|
|
-
|
|
81
|
|
- LivestockResourceUserStructureVo userStructure = LivestockResourceScreenSupport.buildUserStructure(
|
|
82
|
|
- livestockResourceScreenMapper.selectUserStructure());
|
|
83
|
|
-
|
|
84
|
|
- long totalAiMessages = safeLong(livestockResourceScreenMapper.countAskerMessagesInYear(yearStart, yearEnd));
|
|
85
|
|
- List<com.ruoyi.web.modules.screen.domain.dto.LivestockResourceCategoryCountDto> categoryRows =
|
|
86
|
|
- livestockResourceScreenMapper.selectAskerCategoryCounts(yearStart, yearEnd);
|
|
87
|
|
- LivestockResourceCategoryShareVo categoryShare = LivestockResourceScreenSupport.buildCategoryShare(
|
|
88
|
|
- categoryRows, totalAiMessages);
|
|
89
|
|
- List<LivestockResourceCategoryItemVo> categoryItems = categoryShare.getItems();
|
|
90
|
|
-
|
|
91
|
|
- LivestockResourceHourlyHeatVo hourlyHeat = LivestockResourceScreenSupport.buildHourlyHeat(
|
|
92
|
|
- livestockResourceScreenMapper.selectHourlySessionCounts(hourlyWindowStart, hourlyWindowEnd),
|
|
93
|
|
- livestockResourceScreenMapper.selectHourlyAiReplyCounts(hourlyWindowStart, hourlyWindowEnd),
|
|
94
|
|
- hourlyAnchor);
|
|
95
|
|
-
|
|
96
|
|
- long yearSessionTotal = safeLong(livestockResourceScreenMapper.countYearSessions(yearStart, yearEnd));
|
|
97
|
|
-
|
|
98
|
|
- long okCount = safeLong(livestockResourceScreenMapper.countAiRepliesOk(yearStart, yearEnd));
|
|
99
|
|
- long failCount = safeLong(livestockResourceScreenMapper.countAiRepliesFail(yearStart, yearEnd));
|
|
100
|
|
- LivestockResourceReplyStatusVo replyStatus = LivestockResourceScreenSupport.buildReplyStatus(okCount, failCount);
|
|
101
|
|
-
|
|
102
|
64
|
LivestockResourceDashboardVo vo = new LivestockResourceDashboardVo();
|
|
103
|
65
|
vo.setStatYear(year);
|
|
104
|
66
|
vo.setStatDate(HomeScreenSupport.formatStatDate(statDate));
|
|
|
@@ -125,20 +87,6 @@ public class LivestockResourceScreenServiceImpl implements ILivestockResourceScr
|
|
125
|
87
|
vo.setAgriClassroom(HomeScreenSupport.buildAgriClassroom(videoCount, trainingPublishCount));
|
|
126
|
88
|
vo.setTrainingTrend(HomeScreenSupport.buildTrainingTrendForStatYear(
|
|
127
|
89
|
homeScreenStatsMapper.selectTrainingTrendByTrainingYear(year), year));
|
|
128
|
|
- vo.setActivityTrend(activityTrend);
|
|
129
|
|
- vo.setUserStructure(userStructure);
|
|
130
|
|
- vo.setCategoryShare(categoryShare);
|
|
131
|
|
- vo.setModelCallAnalysis(LivestockResourceScreenSupport.buildModelCallAnalysis(categoryItems));
|
|
132
|
|
- vo.setHourlyHeat(hourlyHeat);
|
|
133
|
|
- vo.setSessionReplyDistribution(LivestockResourceScreenSupport.buildSessionReplyDistribution(
|
|
134
|
|
- livestockResourceScreenMapper.selectSessionReplyBuckets(yearStart, yearEnd),
|
|
135
|
|
- yearSessionTotal));
|
|
136
|
|
- vo.setReplyStatusDistribution(replyStatus);
|
|
137
|
|
- vo.setHotTopics(LivestockResourceScreenSupport.buildHotTopics(
|
|
138
|
|
- categoryRows, LivestockResourceScreenRules.HOT_TOPIC_TOP));
|
|
139
|
|
- vo.setTopKeywords(LivestockResourceScreenSupport.extractTopKeywords(
|
|
140
|
|
- livestockResourceScreenMapper.selectTextAskerContents(yearStart, yearEnd),
|
|
141
|
|
- LivestockResourceScreenRules.KEYWORD_TOP));
|
|
142
|
90
|
return vo;
|
|
143
|
91
|
}
|
|
144
|
92
|
|
|
|
@@ -204,9 +152,4 @@ public class LivestockResourceScreenServiceImpl implements ILivestockResourceScr
|
|
204
|
152
|
return Date.from(localDate.atTime(23, 59, 59)
|
|
205
|
153
|
.atZone(ZoneId.of(BreedingIndustryRules.ZONE_SHANGHAI)).toInstant());
|
|
206
|
154
|
}
|
|
207
|
|
-
|
|
208
|
|
- private static Date toDateTime(LocalDateTime dateTime)
|
|
209
|
|
- {
|
|
210
|
|
- return Date.from(dateTime.atZone(ZoneId.of(BreedingIndustryRules.ZONE_SHANGHAI)).toInstant());
|
|
211
|
|
- }
|
|
212
|
155
|
}
|