Browse Source

信访大屏后端1.5

main
parent
commit
f207fddf1f
  1. 25
      src/main/java/com/biutag/supervision/constants/enums/MailTrendSourcesEnum.java
  2. 47
      src/main/java/com/biutag/supervision/controller/datav/DataPetitionComplaintViewController.java
  3. 10
      src/main/java/com/biutag/supervision/mapper/DataPetitionComplaintMapper.java
  4. 11
      src/main/java/com/biutag/supervision/pojo/vo/RecentMailTrendVo.java
  5. 16
      src/main/java/com/biutag/supervision/service/DataPetitionComplaintService.java

25
src/main/java/com/biutag/supervision/constants/enums/MailTrendSourcesEnum.java

@ -0,0 +1,25 @@
package com.biutag.supervision.constants.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum MailTrendSourcesEnum {
ONE(1, 21),
TWO(2, 22),
THREE(3, 23),
FOUR(4, 24);
private final int code; // 前端传来的code
private final int mappedCode; // 后端需要用到的code
public static int getMappedCodeByCode(int code) {
for (MailTrendSourcesEnum value : MailTrendSourcesEnum.values()) {
if (value.code == code) {
return value.getMappedCode();
}
}
throw new IllegalArgumentException("Invalid sourcesCode: " + code);
}
}

47
src/main/java/com/biutag/supervision/controller/datav/DataPetitionComplaintViewController.java

@ -11,15 +11,17 @@ import com.biutag.supervision.mapper.DataPetitionComplaintMapper;
import com.biutag.supervision.pojo.Result; import com.biutag.supervision.pojo.Result;
import com.biutag.supervision.pojo.dto.CaseVerifDepart; import com.biutag.supervision.pojo.dto.CaseVerifDepart;
import com.biutag.supervision.pojo.entity.DataPetitionComplaint; import com.biutag.supervision.pojo.entity.DataPetitionComplaint;
import com.biutag.supervision.pojo.vo.RecentMailTrendVo;
import com.biutag.supervision.service.DataPetitionComplaintService; import com.biutag.supervision.service.DataPetitionComplaintService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -75,5 +77,42 @@ public class DataPetitionComplaintViewController {
return Result.success(data); return Result.success(data);
} }
/**
* 信访数据大屏信访趋势统计
*/
@GetMapping("/getRecentlyMailTrend")
public Result<JSONObject> getRecentlyMailTrend(@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<RecentMailTrendVo> recentMailTrendVoList = dataPetitionComplaintService.getRecentlyMailTrend(sourcesCode, days, endTime);
ArrayList<String> dayList = new ArrayList<>();
ArrayList<String> totalList = new ArrayList<>();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
LocalDate previousDate = null;
for (RecentMailTrendVo recentMailTrendVo : recentMailTrendVoList) {
// 获取当前日期
LocalDate currentDate = LocalDate.parse(recentMailTrendVo.getDayTime(), formatter);
if (previousDate != null) {
while (ChronoUnit.DAYS.between(previousDate, currentDate) > 1) {
previousDate = previousDate.plusDays(1); // 日期加1
String res = previousDate.format(formatter); // 格式化日期
dayList.add(res.substring(res.indexOf('/') + 1)); // 添加到dayList
totalList.add("0"); // 插入没有数据的日期,总数为0
}
}
String res = currentDate.format(formatter);
dayList.add(res.substring(res.indexOf('/') + 1));
totalList.add(recentMailTrendVo.getTotal());
previousDate = currentDate;
}
jsonObject.fluentPut("dayList", dayList);
jsonObject.fluentPut("totalList", totalList);
return Result.success(jsonObject);
}
} }

10
src/main/java/com/biutag/supervision/mapper/DataPetitionComplaintMapper.java

@ -3,6 +3,7 @@ package com.biutag.supervision.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.supervision.pojo.dto.CaseVerifDepart; import com.biutag.supervision.pojo.dto.CaseVerifDepart;
import com.biutag.supervision.pojo.entity.DataPetitionComplaint; import com.biutag.supervision.pojo.entity.DataPetitionComplaint;
import com.biutag.supervision.pojo.vo.RecentMailTrendVo;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import java.util.Date; import java.util.Date;
@ -71,4 +72,13 @@ public interface DataPetitionComplaintMapper extends BaseMapper<DataPetitionComp
"GROUP BY temp.second_depart_id " + "GROUP BY temp.second_depart_id " +
"ORDER BY value DESC") "ORDER BY value DESC")
List<CaseVerifDepart> selectMassMail(Integer id, int isMass, Date beginTime, Date endTime); List<CaseVerifDepart> selectMassMail(Integer id, int isMass, Date beginTime, Date endTime);
@Select("SELECT DATE_FORMAT(dpc.discovery_time, '%Y/%m/%d') AS dayTime, COUNT(*) total " +
"FROM data_petition_complaint dpc " +
"WHERE dpc.discovery_time BETWEEN #{frontDay} AND #{currentDay} " +
"AND problem_sources_code = #{sourcesCode} " +
"GROUP BY dayTime " +
"ORDER BY dpc.discovery_time asc;")
List<RecentMailTrendVo> selectRecentlyMailTrend(Integer sourcesCode, String frontDay, String currentDay);
} }

11
src/main/java/com/biutag/supervision/pojo/vo/RecentMailTrendVo.java

@ -0,0 +1,11 @@
package com.biutag.supervision.pojo.vo;
import lombok.Data;
import java.util.List;
@Data
public class RecentMailTrendVo {
private String dayTime; // 10/01
private String total; // 10
}

16
src/main/java/com/biutag/supervision/service/DataPetitionComplaintService.java

@ -13,12 +13,16 @@ import com.biutag.supervision.mapper.DataPetitionComplaintMapper;
import com.biutag.supervision.pojo.dto.*; import com.biutag.supervision.pojo.dto.*;
import com.biutag.supervision.pojo.entity.DataPetitionComplaint; import com.biutag.supervision.pojo.entity.DataPetitionComplaint;
import com.biutag.supervision.pojo.param.DataPetitionComplaintQueryParam; import com.biutag.supervision.pojo.param.DataPetitionComplaintQueryParam;
import com.biutag.supervision.pojo.vo.RecentMailTrendVo;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.poi.ss.formula.functions.T; import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -202,5 +206,15 @@ public class DataPetitionComplaintService extends ServiceImpl<DataPetitionCompla
} }
public List<RecentMailTrendVo> getRecentlyMailTrend(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<RecentMailTrendVo> recentMailTrendVos =
dataPetitionComplaintMapper.selectRecentlyMailTrend(MailTrendSourcesEnum.getMappedCodeByCode(sourcesCode), frontDay, currentDay);
return recentMailTrendVos;
}
} }

Loading…
Cancel
Save