feat: 增加运维统计每天设备上线情况

dev
huangfeng 11 months ago
parent 6e56157573
commit feeab8fa76

@ -7,10 +7,7 @@ import com.shxy.xymanager_common.base.ResponseReult;
import com.shxy.xymanager_common.entity.*;
import com.shxy.xymanager_common.excel.TerminalExcel;
import com.shxy.xymanager_common.exception.ApiException;
import com.shxy.xymanager_common.model.IccidModel;
import com.shxy.xymanager_common.model.PhotoDayModel;
import com.shxy.xymanager_common.model.TerminalGpsModel;
import com.shxy.xymanager_common.model.UploadModel;
import com.shxy.xymanager_common.model.*;
import com.shxy.xymanager_common.util.EasyExcelUtil;
import com.shxy.xymanager_common.vo.TerminalSelectVo;
import com.shxy.xymanager_dao.dao.TerminalPositionsDao;
@ -112,6 +109,25 @@ public class TerminalExtController extends BaseController {
EasyExcelUtil.createExcel(response, "运维数据", list, TerminalExcel.class);
}
@GetMapping("statMaintain")
@ApiOperation("运维统计")
@Log(title = "运维统计", type = "统计")
public ResponseReult<StatMaintain> statMaintain(TerminalSelectVo vo) throws Exception {
if (vo.getStart() == null) {
throw new ApiException("start不能为空");
}
if (vo.getEnd() == null) {
throw new ApiException("end不能为空");
}
vo.setPageindex(1);
vo.setPagesize(10000);
long cost = System.currentTimeMillis();
StatMaintain result = terminalExtService.statMaintain(vo);
cost = System.currentTimeMillis() - cost;
log.info("statMaintain cost=" + cost);
return ResponseReult.success(result);
}
@GetMapping("listWithAll")
@ApiOperation("查询附带全部额外信息")
@Log(title = "装置查询附带全部额外信息", type = "查询")

@ -0,0 +1,13 @@
package com.shxy.xymanager_common.model;
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<>();
}

@ -0,0 +1,28 @@
package com.shxy.xymanager_common.model;
import com.shxy.xymanager_common.entity.View_Dy_Line_Tower_Terminals;
import com.shxy.xymanager_common.util.DateUtil;
import lombok.Data;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Data
public class StatMaintain {
List<View_Dy_Line_Tower_Terminals> termList;
List<StatDay> dayList = new ArrayList<>();
public void initDayList(Long d1, Long d2) throws Exception {
Date start = new Date(d1 * 1000);
Date end = new Date(d2 * 1000);
start = DateUtil.getDayZero(start);
while (end.compareTo(start) > 0) {
StatDay item = new StatDay();
item.setDay(start);
dayList.add(item);
start = DateUtil.addDay(start, 1);
}
}
}

@ -0,0 +1,9 @@
package com.shxy.xymanager_common.model;
import lombok.Data;
@Data
public class StatTerm {
int termId;
Object uploads;
}

@ -7,6 +7,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.Min;
import java.util.Date;
@Data
@Validated
@ -53,6 +54,10 @@ public class TerminalSelectVo {
private Integer activityId;
private Integer mntn;
// 运维统计用
private Long start;
private Long end;
public boolean needMatch() {
if (StringUtils.isNotBlank(version)) {
return true;

@ -6,8 +6,12 @@ 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.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.*;
@ -280,4 +284,45 @@ public class TerminalExtServiceImpl implements TerminalExtService {
}
}
}
@Override
public StatMaintain statMaintain(TerminalSelectVo vo) throws Exception {
StatMaintain stat = new StatMaintain();
stat.initDayList(vo.getStart(), vo.getEnd());
PageInfo<View_Dy_Line_Tower_Terminals> page = this.getTerminalList(vo);
stat.setTermList(page.getList());
if (!CollectionUtils.isEmpty(stat.getTermList())) {
for (StatDay item : stat.getDayList()) {
this.statOneDay(item, stat.getTermList());
}
}
return stat;
}
private void statOneDay(StatDay item, List<View_Dy_Line_Tower_Terminals> list) {
for (View_Dy_Line_Tower_Terminals term : list) {
long start = item.getDay().getTime() / 1000;
Date end = DateUtil.addDay(item.getDay(), 1);
long max = end.getTime() / 1000;
MntnRawReportsExample example = new MntnRawReportsExample();
MntnRawReportsExample.Criteria criteria = example.createCriteria();
criteria.andTermIdEqualTo(term.getId());
criteria.andCreateTimeGreaterThanOrEqualTo(start);
criteria.andCreateTimeLessThan(max);
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);
}
}
}
}

@ -2,6 +2,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.UploadModel;
import com.shxy.xymanager_common.vo.*;
@ -21,4 +22,6 @@ public interface TerminalExtService {
PageInfo<MntnRawReports> listReport(Integer termId, Integer pageNum, Integer pageSize);
void importTerminal(UploadModel model);
StatMaintain statMaintain(TerminalSelectVo vo) throws Exception;
}

Loading…
Cancel
Save