diff --git a/src/main/java/com/biutag/supervision/controller/datav/DataPetitionComplaintViewController.java b/src/main/java/com/biutag/supervision/controller/datav/DataPetitionComplaintViewController.java index d2769f0..6b0ff92 100644 --- a/src/main/java/com/biutag/supervision/controller/datav/DataPetitionComplaintViewController.java +++ b/src/main/java/com/biutag/supervision/controller/datav/DataPetitionComplaintViewController.java @@ -6,12 +6,12 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.biutag.supervision.constants.enums.DepartGroupEnum; import com.biutag.supervision.constants.enums.RepeatEnum; -import com.biutag.supervision.mapper.DataCaseVerifMapper; import com.biutag.supervision.mapper.DataPetitionComplaintMapper; import com.biutag.supervision.pojo.Result; import com.biutag.supervision.pojo.dto.CaseVerifDepart; import com.biutag.supervision.pojo.entity.DataPetitionComplaint; -import com.biutag.supervision.pojo.vo.RecentMailTrendVo; +import com.biutag.supervision.pojo.vo.RecentMailTrendByDayVo; +import com.biutag.supervision.pojo.vo.RecentMailTrendByMonthVo; import com.biutag.supervision.service.DataPetitionComplaintService; import lombok.RequiredArgsConstructor; import org.springframework.format.annotation.DateTimeFormat; @@ -80,20 +80,20 @@ public class DataPetitionComplaintViewController { /** * 信访数据大屏信访趋势统计 */ - @GetMapping("/getRecentlyMailTrend") - public Result getRecentlyMailTrend(@RequestParam Integer sourcesCode, + @GetMapping("/getRecentlyMailTrendByDay") + public Result getRecentlyMailTrendByDay(@RequestParam Integer sourcesCode, @RequestParam Integer days, @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime, @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime ) { JSONObject jsonObject = new JSONObject(); // 库中的数据 2024/10/24 22 - List recentMailTrendVoList = dataPetitionComplaintService.getRecentlyMailTrend(sourcesCode, days, endTime); + List recentMailTrendVoList = dataPetitionComplaintService.getRecentlyMailTrendByDay(sourcesCode, days, endTime); ArrayList dayList = new ArrayList<>(); ArrayList totalList = new ArrayList<>(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd"); LocalDate previousDate = null; - for (RecentMailTrendVo recentMailTrendVo : recentMailTrendVoList) { + for (RecentMailTrendByDayVo recentMailTrendVo : recentMailTrendVoList) { // 获取当前日期 LocalDate currentDate = LocalDate.parse(recentMailTrendVo.getDayTime(), formatter); if (previousDate != null) { @@ -115,4 +115,26 @@ public class DataPetitionComplaintViewController { } + + @GetMapping("/getRecentlyMailTrendMonth") + public Result getRecentlyMailTrendByMonth(@RequestParam Integer sourcesCode, + @RequestParam Integer year + ) { + JSONObject jsonObject = new JSONObject(); + List recentMailTrendVoList = dataPetitionComplaintService.getRecentlyMailTrendByMonth(sourcesCode, String.valueOf(year)); + ArrayList monthList = new ArrayList<>(); + ArrayList totalList = new ArrayList<>(); + for (RecentMailTrendByMonthVo recentMailTrendByMonthVo : recentMailTrendVoList) { + monthList.add(recentMailTrendByMonthVo.getMonthTime().substring(recentMailTrendByMonthVo.getMonthTime().indexOf("-")+1)); + totalList.add(recentMailTrendByMonthVo.getTotal()); + } + jsonObject.fluentPut("monthList", monthList); + jsonObject.fluentPut("totalList", totalList); + return Result.success(jsonObject); + } + + + + + } diff --git a/src/main/java/com/biutag/supervision/mapper/DataPetitionComplaintMapper.java b/src/main/java/com/biutag/supervision/mapper/DataPetitionComplaintMapper.java index 96eb1c0..1562724 100644 --- a/src/main/java/com/biutag/supervision/mapper/DataPetitionComplaintMapper.java +++ b/src/main/java/com/biutag/supervision/mapper/DataPetitionComplaintMapper.java @@ -3,7 +3,8 @@ package com.biutag.supervision.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.biutag.supervision.pojo.dto.CaseVerifDepart; import com.biutag.supervision.pojo.entity.DataPetitionComplaint; -import com.biutag.supervision.pojo.vo.RecentMailTrendVo; +import com.biutag.supervision.pojo.vo.RecentMailTrendByDayVo; +import com.biutag.supervision.pojo.vo.RecentMailTrendByMonthVo; import org.apache.ibatis.annotations.Select; import java.util.Date; @@ -79,6 +80,19 @@ public interface DataPetitionComplaintMapper extends BaseMapper selectRecentlyMailTrend(Integer sourcesCode, String frontDay, String currentDay); + List selectRecentlyMailTrendByDay(Integer sourcesCode, String frontDay, String currentDay); + + + + + @Select("SELECT DATE_FORMAT(dpc.discovery_time, '%Y-%m') AS monthTime, COUNT(*) total " + + "FROM data_petition_complaint dpc " + + "WHERE YEAR(dpc.discovery_time) = #{year} " + + "AND problem_sources_code = #{sourcesCode} " + + "GROUP BY monthTime " + + "ORDER BY monthTime asc;") + List selectRecentlyMailTrendByMonth(Integer sourcesCode, String year); + + } diff --git a/src/main/java/com/biutag/supervision/pojo/vo/RecentMailTrendVo.java b/src/main/java/com/biutag/supervision/pojo/vo/RecentMailTrendByDayVo.java similarity index 81% rename from src/main/java/com/biutag/supervision/pojo/vo/RecentMailTrendVo.java rename to src/main/java/com/biutag/supervision/pojo/vo/RecentMailTrendByDayVo.java index 6d8598a..cafad1d 100644 --- a/src/main/java/com/biutag/supervision/pojo/vo/RecentMailTrendVo.java +++ b/src/main/java/com/biutag/supervision/pojo/vo/RecentMailTrendByDayVo.java @@ -5,7 +5,7 @@ import lombok.Data; import java.util.List; @Data -public class RecentMailTrendVo { +public class RecentMailTrendByDayVo { private String dayTime; // 10/01 private String total; // 10 } diff --git a/src/main/java/com/biutag/supervision/pojo/vo/RecentMailTrendByMonthVo.java b/src/main/java/com/biutag/supervision/pojo/vo/RecentMailTrendByMonthVo.java new file mode 100644 index 0000000..c95d291 --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/vo/RecentMailTrendByMonthVo.java @@ -0,0 +1,9 @@ +package com.biutag.supervision.pojo.vo; + +import lombok.Data; + +@Data +public class RecentMailTrendByMonthVo { + private String MonthTime; // 24/01 + private String total; // 10 +} diff --git a/src/main/java/com/biutag/supervision/service/DataPetitionComplaintService.java b/src/main/java/com/biutag/supervision/service/DataPetitionComplaintService.java index 3676f3d..7bc8ebb 100644 --- a/src/main/java/com/biutag/supervision/service/DataPetitionComplaintService.java +++ b/src/main/java/com/biutag/supervision/service/DataPetitionComplaintService.java @@ -13,9 +13,9 @@ import com.biutag.supervision.mapper.DataPetitionComplaintMapper; import com.biutag.supervision.pojo.dto.*; import com.biutag.supervision.pojo.entity.DataPetitionComplaint; import com.biutag.supervision.pojo.param.DataPetitionComplaintQueryParam; -import com.biutag.supervision.pojo.vo.RecentMailTrendVo; +import com.biutag.supervision.pojo.vo.RecentMailTrendByDayVo; +import com.biutag.supervision.pojo.vo.RecentMailTrendByMonthVo; import lombok.RequiredArgsConstructor; -import org.apache.poi.ss.formula.functions.T; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; @@ -206,15 +206,21 @@ public class DataPetitionComplaintService extends ServiceImpl getRecentlyMailTrend(Integer sourcesCode, Integer days, Date endTime) { + public List getRecentlyMailTrendByDay(Integer sourcesCode, Integer days, Date endTime) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd"); // 将 endTime 转换为 LocalDate LocalDate endLocalDate = endTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); String currentDay = endLocalDate.format(formatter); // 前端页面的最后查询日期 LocalDate frontDateDay = endLocalDate.minusDays(days); // days天前 String frontDay = frontDateDay.format(formatter); - List recentMailTrendVos = - dataPetitionComplaintMapper.selectRecentlyMailTrend(MailTrendSourcesEnum.getMappedCodeByCode(sourcesCode), frontDay, currentDay); + List recentMailTrendVos = + dataPetitionComplaintMapper.selectRecentlyMailTrendByDay(MailTrendSourcesEnum.getMappedCodeByCode(sourcesCode), frontDay, currentDay); + return recentMailTrendVos; + } + + public List getRecentlyMailTrendByMonth(Integer sourcesCode, String year) { + List recentMailTrendVos = + dataPetitionComplaintMapper.selectRecentlyMailTrendByMonth(MailTrendSourcesEnum.getMappedCodeByCode(sourcesCode), year); return recentMailTrendVos; } }