提交 2c924d95 authored 作者: 邓砥奕's avatar 邓砥奕

[统计分析]修改了业务统计,新增了各市告警统计

上级 8db0b79f
......@@ -116,13 +116,12 @@ public class StatisticalController {
/**
* 查询各市告警情况
* @return 各市告警情况对象集合
* @return 各市告警统计对象集合
*/
@ApiOperation(value = "查询各市告警情况")
@GetMapping("/alarmSituation/detail")
public ResponseEntity selectAlarmSituationDetail(){
List<AlarmSituation> alarmSituations = new ArrayList<>();
return ResponseEntity.ok(alarmSituations);
return ResponseEntity.ok(statisticalService.getRfidWarningDetail());
}
/**
......
......@@ -40,5 +40,10 @@ public interface StatisticalService {
* @param type 类型(1:上半年,2:下半年)
* 获取业务统计信息
*/
BusinessSituation getBusinessNum(Integer type) throws ParseException;
List<BusinessSituation> getBusinessNum(Integer type) throws ParseException;
/**
* 获取本季度各市告警统计信息
*/
List<AlarmSituation> getRfidWarningDetail();
}
......@@ -8,7 +8,11 @@ import com.tykj.dev.device.selfcheck.base.SelfCheckSchedulerTask;
import com.tykj.dev.device.selfcheck.repository.SelfCheckBillDao;
import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckBill;
import com.tykj.dev.device.task.repository.TaskDao;
import com.tykj.dev.device.task.service.TaskService;
import com.tykj.dev.device.task.subject.bto.TaskBto;
import com.tykj.dev.device.task.subject.domin.Task;
import com.tykj.dev.device.task.subject.vo.TaskSelectVo;
import com.tykj.dev.device.task.subject.vo.TaskUserVo;
import com.tykj.dev.device.user.subject.dao.AreaDao;
import com.tykj.dev.device.user.subject.dao.UnitsDao;
import com.tykj.dev.device.user.subject.entity.Area;
......@@ -53,10 +57,7 @@ public class StatisticalServiceImpl implements StatisticalService {
private LibraryWarningLogDao libraryWarningLogDao;
@Autowired
private TaskDao taskDao;
@Autowired
private FinalReportDao finalReportDao;
private TaskService taskService;
/**
* 获取装备统计信息
......@@ -264,35 +265,95 @@ public class StatisticalServiceImpl implements StatisticalService {
* 获取业务统计信息
*/
@Override
public BusinessSituation getBusinessNum(Integer type) throws ParseException {
List<Task> tasks;
List<FinalReport> finalReports;
public List<BusinessSituation> getBusinessNum(Integer type) throws ParseException {
List<BusinessSituation> businessSituations = new ArrayList<>();
TaskSelectVo taskSelectVo = new TaskSelectVo();
taskSelectVo.setSelectNum(3);
TaskSelectVo taskSelectVo2 = new TaskSelectVo();
taskSelectVo2.setSelectNum(2);
//跟踪
List<TaskUserVo> trackings = taskService.getList(taskSelectVo);
//待办
List<TaskUserVo> belongings = taskService.getList(taskSelectVo2);
//筛选出来的上半年或下半年待办
List<TaskUserVo> tasks;
//筛选出来的上半年或下半年跟踪
List<TaskUserVo> tasks2;
//上半年
if (type==1){
List<Date> dates = getFirstHalfYear();
tasks = taskDao.findAll().stream()
.filter(task -> task.getCreateTime().after(dates.get(0))&&task.getCreateTime().before(dates.get(1))&&(task.getParentTaskId()==null||task.getParentTaskId()==0))
//筛选出上半年待办
tasks = belongings.stream()
.filter(taskUserVo -> taskUserVo.getCreateTime().after(dates.get(0))&&taskUserVo.getCreateTime().before(dates.get(1)))
.collect(Collectors.toList());
finalReports = finalReportDao.findAll().stream()
.filter(finalReport -> Date.from(finalReport.getCreateTime().atZone(ZoneId.systemDefault()).toInstant()).after(dates.get(0))&&Date.from(finalReport.getCreateTime().atZone(ZoneId.systemDefault()).toInstant()).before(dates.get(1)))
//筛选出上半年跟踪
tasks2 = trackings.stream()
.filter(taskUserVo -> taskUserVo.getCreateTime().after(dates.get(0))&&taskUserVo.getCreateTime().before(dates.get(1)))
.collect(Collectors.toList());
return countBusiness(tasks,finalReports);
businessSituations.add(countBusiness(tasks));
businessSituations.add(countBusiness(tasks2));
return businessSituations;
}
else if (type==2){
List<Date> dates = getLastHalfYear();
tasks = taskDao.findAll().stream()
.filter(task -> task.getCreateTime().after(dates.get(0))&&task.getCreateTime().before(dates.get(1))&&(task.getParentTaskId()==null||task.getParentTaskId()==0))
//筛选出下半年待办
tasks = belongings.stream()
.filter(taskUserVo -> taskUserVo.getCreateTime().after(dates.get(0))&&taskUserVo.getCreateTime().before(dates.get(1)))
.collect(Collectors.toList());
finalReports = finalReportDao.findAll().stream()
.filter(finalReport -> Date.from(finalReport.getCreateTime().atZone(ZoneId.systemDefault()).toInstant()).after(dates.get(0))&&Date.from(finalReport.getCreateTime().atZone(ZoneId.systemDefault()).toInstant()).before(dates.get(1)))
//筛选出下半年跟踪
tasks2 = trackings.stream()
.filter(taskUserVo -> taskUserVo.getCreateTime().after(dates.get(0))&&taskUserVo.getCreateTime().before(dates.get(1)))
.collect(Collectors.toList());
return countBusiness(tasks,finalReports);
businessSituations.add(countBusiness(tasks));
businessSituations.add(countBusiness(tasks2));
return businessSituations;
}
else {
throw new ApiException("type只能为1或2");
}
}
/**
* 获取本季度各市告警统计信息
*/
@Override
public List<AlarmSituation> getRfidWarningDetail() {
List<AlarmSituation> alarmSituations = new ArrayList<>();
List<Area> areas = areaDao.findAreasByType(2);
//每个市进行统计
for (Area area: areas) {
AlarmSituation alarmSituation = new AlarmSituation();
alarmSituation.setArea(area.getName());
//获取市以及子区县所有区域
List<Area> areas1 = areaDao.findAllByFatherId(area.getId());
areas1.add(area);
//获取所有单位名称
List<String> unitNames = new ArrayList<>();
areas1.forEach(area1 -> {
List<Units> units = unitsDao.findAllByAreaId(area1.getId());
if (units.size() == 1) {
unitNames.add(units.get(0).getName());
}
});
//获取当前季度
Integer quarter = getQuarter(new Date());
//获取当前季度该区域所有告警记录
List<LibraryWarningLog> libraryWarningLogs = libraryWarningLogDao.findAll().stream()
.filter(libraryWarningLog -> getQuarter(libraryWarningLog.getCreateTime()).equals(quarter)&&unitNames.contains(libraryWarningLog.getUnit()))
.collect(Collectors.toList());
alarmSituation.setAlarmCount(libraryWarningLogs.size());
//获取盘库异常数量
int inventoryNum = (int)libraryWarningLogs.stream().filter(libraryWarningLog -> libraryWarningLog.getWarningType()==2).count();
//获取未处理数量
int unHandleNum = (int)libraryWarningLogs.stream().filter(libraryWarningLog -> libraryWarningLog.getWarningHandle()==0).count();
alarmSituation.setInventoryCount(inventoryNum);
alarmSituation.setInOutCount(libraryWarningLogs.size()-inventoryNum);
alarmSituation.setUntreatedCount(unHandleNum);
alarmSituations.add(alarmSituation);
}
return alarmSituations;
}
/**
* @param devLifeSector 装备生命状态添统计
* @param deviceLibraries 统计装备
......@@ -422,20 +483,19 @@ public class StatisticalServiceImpl implements StatisticalService {
return dates;
}
private BusinessSituation countBusiness(List<Task> tasks,List<FinalReport> finalReports){
private BusinessSituation countBusiness(List<TaskUserVo> tasks){
int withCount = 0;
int sendRepelCount = 0;
int selfInspection = 0;
int verification = 0;
int train = 0;
int finalAccounts = finalReports.size();
int putStorage = 0;
int apply = 0;
int fielding = 0;
int backPack = 0;
int destruction = 0;
int maintenance = 0;
for (Task task: tasks) {
for (TaskUserVo task: tasks) {
switch (task.getBusinessType()){
case 1:
fielding++;
......@@ -473,6 +533,22 @@ public class StatisticalServiceImpl implements StatisticalService {
default:break;
}
}
return new BusinessSituation(withCount,sendRepelCount,selfInspection,verification,train,finalAccounts,putStorage,apply,fielding,backPack,destruction,maintenance);
return new BusinessSituation(withCount,sendRepelCount,selfInspection,verification,train,putStorage,apply,fielding,backPack,destruction,maintenance);
}
/**
* 当前date属于本年第几个季度
*/
private Integer getQuarter(Date date) {
int month = date.getMonth()+1;
if (month <= 3) {
return 1;
} else if (month <= 6) {
return 2;
} else if (month <= 9) {
return 3;
} else {
return 4;
}
}
}
......@@ -39,11 +39,6 @@ public class BusinessSituation {
*/
private Integer train;
/**
* 决算
*/
private Integer finalAccounts;
/**
* 入库
*/
......
......@@ -293,7 +293,7 @@ public class TaskServiceImpl implements TaskService {
@Override
public List<TaskUserVo> getList(TaskSelectVo taskSelectVo) {
List<TaskUserVo> taskEntities = getTaskUserVoList(taskSelectVo);
if (taskSelectVo.getOrders() != null) {
if (taskSelectVo.getOrders().size()>0) {
//根据vo待办和跟踪时间的查询顺序按顺序或降序排序输出
if (taskSelectVo.getSelectNum() == 2 && "trackingTime".equals(taskSelectVo.getOrders().get(0).getCoulmn())) {
if ("ASC".equals(taskSelectVo.getOrders().get(0).getDirection().toString())) {
......@@ -334,7 +334,7 @@ public class TaskServiceImpl implements TaskService {
.filter(taskUserVo -> find(taskUserVo.getId(), list) > -1)
.collect(Collectors.toList());
//判断是否需要按发起时间排序
if (taskSelectVo.getOrders() != null) {
if (taskSelectVo.getOrders().size()>0) {
if ("createTime".equals(taskSelectVo.getOrders().get(0).getCoulmn())) {
if ("ASC".equals(taskSelectVo.getOrders().get(0).getDirection().toString())) {
return taskUtils.orderByCreateTimeAsc2(taskUserVos);
......
......@@ -42,7 +42,6 @@ public class DeviceUseReportController {
@Autowired
private UseReportFIleService useReportFIleService;
@ApiOperation(value = "模糊查询装备使用报告分页", notes = "可以通过这个接口模糊查询装备使用报告分页")
@PostMapping("/summary")
public ResponseEntity selectDeviceUseReport(@RequestBody DeviceUseReportSelectVo deviceUseReportSelectVo) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论