首页统计接口
parent
dadc25e141
commit
333426b202
@ -0,0 +1,32 @@
|
|||||||
|
package com.supervision.police.controller;
|
||||||
|
|
||||||
|
import com.supervision.common.domain.R;
|
||||||
|
import com.supervision.police.dto.homepage.HomepageResultDto;
|
||||||
|
import com.supervision.police.service.HomepageService;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@Tag(name = "首页接口")
|
||||||
|
@RequestMapping("/homepage")
|
||||||
|
public class HomepageController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private HomepageService homepageService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取统计数据
|
||||||
|
*
|
||||||
|
* @return HomepageResultDto
|
||||||
|
*/
|
||||||
|
@PostMapping("/queryStatisticsData")
|
||||||
|
public R<HomepageResultDto> queryStatisticsData() {
|
||||||
|
return R.ok(homepageService.queryStatisticsData());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.supervision.police.dto.homepage;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class HomepageResultDto {
|
||||||
|
/**
|
||||||
|
* 案件数量
|
||||||
|
*/
|
||||||
|
private int caseNumber = 0;
|
||||||
|
/**
|
||||||
|
* 案件行为人数量
|
||||||
|
*/
|
||||||
|
private int caseActorNumber = 0;
|
||||||
|
/**
|
||||||
|
* 月新增案件数量
|
||||||
|
*/
|
||||||
|
private int monthlyNewCaseNumber = 0;
|
||||||
|
/**
|
||||||
|
* 较上月新增案件数量
|
||||||
|
*/
|
||||||
|
private int comparedToLastMonthIncreaseNumber = 0;
|
||||||
|
/**
|
||||||
|
* 平均案件定性周期
|
||||||
|
*/
|
||||||
|
private int caseQualificationCycleAvg = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型分数小于70数量
|
||||||
|
*/
|
||||||
|
private int modelScoreLessThan70Number = 0;
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.supervision.police.service;
|
||||||
|
|
||||||
|
import com.supervision.police.dto.homepage.HomepageResultDto;
|
||||||
|
|
||||||
|
public interface HomepageService {
|
||||||
|
/**
|
||||||
|
* 获取统计数据
|
||||||
|
*
|
||||||
|
* @return HomepageResultDto
|
||||||
|
*/
|
||||||
|
HomepageResultDto queryStatisticsData();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.supervision.police.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.supervision.police.domain.CasePerson;
|
||||||
|
import com.supervision.police.domain.ModelCase;
|
||||||
|
import com.supervision.police.dto.homepage.HomepageResultDto;
|
||||||
|
import com.supervision.police.service.CasePersonService;
|
||||||
|
import com.supervision.police.service.HomepageService;
|
||||||
|
import com.supervision.police.service.ModelCaseService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class HomepageServiceImpl implements HomepageService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ModelCaseService modelCaseService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CasePersonService casePersonService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HomepageResultDto queryStatisticsData() {
|
||||||
|
HomepageResultDto homepageResultDto = new HomepageResultDto();
|
||||||
|
List<ModelCase> modelCaseList = modelCaseService.list(new QueryWrapper<ModelCase>().eq("data_status", 1));
|
||||||
|
int currentMonthCaseNumber = (int) modelCaseList.stream().filter(modelCase -> modelCase.getCreateTime().getMonthValue() == 9).count();
|
||||||
|
int lastMonthCaseNumber = (int) modelCaseList.stream().filter(modelCase -> modelCase.getCreateTime().getMonthValue() == 8).count();
|
||||||
|
homepageResultDto.setCaseNumber(modelCaseList.size());
|
||||||
|
homepageResultDto.setCaseActorNumber((int) casePersonService.count(new QueryWrapper<CasePerson>().eq("case_actor_flag", 1)));
|
||||||
|
homepageResultDto.setMonthlyNewCaseNumber(currentMonthCaseNumber);
|
||||||
|
homepageResultDto.setComparedToLastMonthIncreaseNumber(Math.max(currentMonthCaseNumber - lastMonthCaseNumber, 0));
|
||||||
|
homepageResultDto.setModelScoreLessThan70Number((int) modelCaseList.stream().filter(modelCase -> modelCase.getTotalScore() != null && modelCase.getTotalScore() < 70).count());
|
||||||
|
return homepageResultDto;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.supervision.demo;
|
||||||
|
|
||||||
|
import com.supervision.police.service.HomepageService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@SpringBootTest
|
||||||
|
public class HomepageTest {
|
||||||
|
@Autowired
|
||||||
|
private HomepageService homepageService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() {
|
||||||
|
log.info("test");
|
||||||
|
System.out.println(homepageService.queryStatisticsData());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue