feat: 增加查询各线路下的上图统计功能

dev
huangfeng 10 months ago
parent 354c51422a
commit c62fd4fe14

@ -49,7 +49,11 @@ public class MntnController extends BaseController {
} catch (Exception ex) {
if (!ClearCacheTask.heartbeatMap.containsKey(ip)) {
ClearCacheTask.heartbeatMap.put(ip, 1L);
log.error("上传心跳异常", ex);
if (ex instanceof ApiException) {
log.error("上传心跳异常, " + ex.getMessage());
} else {
log.error("上传心跳异常.", ex);
}
String str = ex.getMessage() + ", ip=" + ip + ", url=" + url + ", " + data;
DingTalkPushUtil.pushText("运维心跳", str);
}

@ -112,20 +112,17 @@ public class TerminalExtController extends BaseController {
@GetMapping("statMaintain")
@ApiOperation("运维统计")
@Log(title = "运维统计", type = "统计")
public ResponseReult<StatMaintain> statMaintain(TerminalSelectVo vo) throws Exception {
if (vo.getStart() == null) {
public ResponseReult<List<StatMaintain>> statMaintain(StatModel model) throws Exception {
if (model.getStart() == null) {
throw new ApiException("start不能为空");
}
if (vo.getEnd() == null) {
if (model.getEnd() == null) {
throw new ApiException("end不能为空");
}
vo.setPageindex(1);
vo.setPagesize(10000);
long cost = System.currentTimeMillis();
StatMaintain result = terminalExtService.statMaintain(vo);
result.setLineId(vo.getLineId());
cost = System.currentTimeMillis() - cost;
log.info("statMaintain cost=" + cost);
if (model.getLineIds() == null) {
throw new ApiException("lineIds不能为空");
}
List<StatMaintain> result = terminalExtService.statMaintain(model);
return ResponseReult.success(result);
}

@ -1,13 +1,13 @@
package com.shxy.xymanager_common.model;
import com.shxy.xymanager_common.entity.MntnDayStat;
import lombok.Data;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Data
public class StatDay {
Date day;
List<StatTerm> termList = new ArrayList<>();
List<MntnDayStat> termList;
}

@ -1,5 +1,6 @@
package com.shxy.xymanager_common.model;
import com.shxy.xymanager_common.entity.Lines;
import com.shxy.xymanager_common.entity.View_Dy_Line_Tower_Terminals;
import com.shxy.xymanager_common.util.DateUtil;
import lombok.Data;
@ -10,9 +11,9 @@ import java.util.List;
@Data
public class StatMaintain {
Lines line;
List<View_Dy_Line_Tower_Terminals> termList;
List<StatDay> dayList = new ArrayList<>();
int lineId;
public void initDayList(Long d1, Long d2) throws Exception {
Date start = new Date(d1 * 1000);

@ -0,0 +1,12 @@
package com.shxy.xymanager_common.model;
import lombok.Data;
import java.util.List;
@Data
public class StatModel {
List<Integer> lineIds;
private Long start;
private Long end;
}

@ -3,7 +3,6 @@ package com.shxy.xymanager_service.impl;
import com.github.pagehelper.PageHelper;
import com.shxy.xymanager_common.entity.*;
import com.shxy.xymanager_common.model.StatTerm;
import com.shxy.xymanager_dao.dao.MntnDayStatMapper;
import com.shxy.xymanager_dao.dao.MntnRawReportsMapper;
import com.shxy.xymanager_service.service.MntnDayStatService;
@ -66,4 +65,14 @@ public class MntnDayStatServiceImpl implements MntnDayStatService {
}
}
}
@Override
public List<MntnDayStat> list(Date day, List<Integer> termIds) {
MntnDayStatExample example = new MntnDayStatExample();
MntnDayStatExample.Criteria criteria = example.createCriteria();
criteria.andDateEqualTo(day);
criteria.andTermIdIn(termIds);
List<MntnDayStat> list = dayStatMapper.selectByExample(example);
return list;
}
}

@ -6,12 +6,8 @@ import com.shxy.xymanager_common.bean.PermissionDetail;
import com.shxy.xymanager_common.entity.*;
import com.shxy.xymanager_common.enums.CommonStatus;
import com.shxy.xymanager_common.exception.ApiException;
import com.shxy.xymanager_common.model.StatDay;
import com.shxy.xymanager_common.model.StatMaintain;
import com.shxy.xymanager_common.model.StatTerm;
import com.shxy.xymanager_common.model.UploadModel;
import com.shxy.xymanager_common.model.*;
import com.shxy.xymanager_common.page.PageUtils;
import com.shxy.xymanager_common.util.DateUtil;
import com.shxy.xymanager_common.util.xinyin.TerminalUtils;
import com.shxy.xymanager_common.vo.TerminalSelectVo;
import com.shxy.xymanager_dao.dao.*;
@ -54,6 +50,8 @@ public class TerminalExtServiceImpl implements TerminalExtService {
NewCacheService newCacheService;
@Resource
TerminalChannelMapperDao channelMapperDao;
@Resource
MntnDayStatService mntnDayStatService;
@Override
@ -289,49 +287,37 @@ public class TerminalExtServiceImpl implements TerminalExtService {
}
@Override
public StatMaintain statMaintain(TerminalSelectVo vo) throws Exception {
public List<StatMaintain> statMaintain(StatModel model) throws Exception {
List<StatMaintain> result = new ArrayList<>();
for (Integer lineId : model.getLineIds()) {
StatMaintain stat = this.statOneLine(lineId, model.getStart(), model.getEnd());
result.add(stat);
}
return result;
}
private StatMaintain statOneLine(Integer lineId, Long start, Long end) throws Exception {
Lines line = newCacheService.getLine(lineId);
StatMaintain stat = new StatMaintain();
stat.initDayList(vo.getStart(), vo.getEnd());
stat.initDayList(start, end);
stat.setLine(line);
TerminalSelectVo vo = new TerminalSelectVo();
vo.setPageindex(1);
vo.setPagesize(10000);
vo.setLineId(lineId);
PageInfo<View_Dy_Line_Tower_Terminals> page = this.getTerminalList(vo);
stat.setTermList(page.getList());
if (!CollectionUtils.isEmpty(stat.getTermList())) {
List<Integer> idList = new ArrayList<>();
for (View_Dy_Line_Tower_Terminals term : stat.getTermList()) {
idList.add(term.getId());
}
if (!CollectionUtils.isEmpty(idList)) {
for (StatDay item : stat.getDayList()) {
this.statOneDay(item, stat.getTermList());
List<MntnDayStat> list = mntnDayStatService.list(item.getDay(), idList);
item.setTermList(list);
}
}
return stat;
}
private void statOneDay(StatDay item, List<View_Dy_Line_Tower_Terminals> list) throws Exception {
long today = DateUtil.getTodayZero().getTime() / 1000;
for (View_Dy_Line_Tower_Terminals term : list) {
Long start = item.getDay().getTime() / 1000;
if (start < today) {
StatTerm statTerm = newCacheService.getOneDayStat(term.getId(), start);
if (statTerm != null) {
item.getTermList().add(statTerm);
}
} else {
Long end = start + 60 * 60 * 24;
MntnRawReportsExample example = new MntnRawReportsExample();
MntnRawReportsExample.Criteria criteria = example.createCriteria();
criteria.andTermIdEqualTo(term.getId());
criteria.andCreateTimeGreaterThanOrEqualTo(start);
criteria.andCreateTimeLessThan(end);
example.setOrderByClause("create_time desc");
PageHelper.startPage(1, 1);
List<MntnRawReports> reportsList = rawReportsMapper.selectByExample(example);
if (!CollectionUtils.isEmpty(reportsList)) {
MntnRawReports reports = reportsList.get(0);
reports.makeRawReport();
StatTerm statTerm = new StatTerm();
statTerm.setTermId(term.getId());
statTerm.setUploads(reports.getReportMap().get("uploads"));
item.getTermList().add(statTerm);
}
}
}
}
}

@ -1,11 +1,16 @@
package com.shxy.xymanager_service.service;
import com.shxy.xymanager_common.entity.MntnDayStat;
import java.util.Date;
import java.util.List;
public interface MntnDayStatService {
long countTotal();
void storeOneDay(Date day, Integer termId);
List<MntnDayStat> list(Date day, List<Integer> termIds);
}

@ -3,6 +3,7 @@ package com.shxy.xymanager_service.service;
import com.github.pagehelper.PageInfo;
import com.shxy.xymanager_common.entity.*;
import com.shxy.xymanager_common.model.StatMaintain;
import com.shxy.xymanager_common.model.StatModel;
import com.shxy.xymanager_common.model.UploadModel;
import com.shxy.xymanager_common.vo.*;
@ -23,5 +24,5 @@ public interface TerminalExtService {
void importTerminal(UploadModel model);
StatMaintain statMaintain(TerminalSelectVo vo) throws Exception;
List<StatMaintain> statMaintain(StatModel model) throws Exception;
}

Loading…
Cancel
Save