diff --git a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/LeadPullsController.java b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/LeadPullsController.java index ff831d6..dd48bf6 100644 --- a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/LeadPullsController.java +++ b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/LeadPullsController.java @@ -4,16 +4,11 @@ import com.github.pagehelper.PageInfo; import com.shxy.xymanager_common.base.BaseController; import com.shxy.xymanager_common.base.ResponseReult; import com.shxy.xymanager_common.entity.LeadPulls; -import com.shxy.xymanager_common.entity.View_Dy_Line_Tower_Terminals; -import com.shxy.xymanager_common.page.TableDataInfo; import com.shxy.xymanager_common.util.EasyExcelUtil; -import com.shxy.xymanager_common.vo.TerminalSelectVo; import com.shxy.xymanager_service.service.LeadPullsService; -import com.shxy.xymanager_service.service.TerminalService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; -import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -29,8 +24,6 @@ public class LeadPullsController extends BaseController { @Resource LeadPullsService service; - @Resource - TerminalService terminalService; @GetMapping("list") @ApiOperation("查询列表") @@ -53,24 +46,4 @@ public class LeadPullsController extends BaseController { EasyExcelUtil.createExcel(response, "覆冰数据", result.getList(), LeadPulls.class); } - @GetMapping("latest") - @ApiOperation("查询最新的") - public ResponseReult> latest(Integer dyId, Integer lineId, Integer towerId, - int pageNum, int pageSize) { - TerminalSelectVo vo = new TerminalSelectVo(); - vo.setDyId(dyId); - vo.setLineId(lineId); - vo.setTowerId(towerId); - vo.setPageindex(pageNum); - vo.setPagesize(pageSize); - TableDataInfo result = terminalService.getTerminalList(vo).getData(); - if (!CollectionUtils.isEmpty(result.getList())) { - for (View_Dy_Line_Tower_Terminals terminals : result.getList()) { - LeadPulls last = service.getLast(terminals.getId()); - terminals.setLastLeadPulls(last); - } - } - return ResponseReult.success(result); - } - } diff --git a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalExtController.java b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalExtController.java new file mode 100644 index 0000000..59dea24 --- /dev/null +++ b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalExtController.java @@ -0,0 +1,127 @@ +package com.shxy.xymanager_admin.controller; + +import com.shxy.xymanager_common.base.BaseController; +import com.shxy.xymanager_common.base.ResponseReult; +import com.shxy.xymanager_common.entity.LeadPulls; +import com.shxy.xymanager_common.entity.View_Dy_Line_Tower_Terminals; +import com.shxy.xymanager_common.entity.Weathers; +import com.shxy.xymanager_common.model.PhotoDayModel; +import com.shxy.xymanager_common.model.TerminalGpsModel; +import com.shxy.xymanager_common.page.TableDataInfo; +import com.shxy.xymanager_common.vo.TerminalSelectVo; +import com.shxy.xymanager_service.service.*; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.util.CollectionUtils; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import javax.validation.constraints.NotNull; + +@RestController +@Api(tags = {"装置附带额外信息接口"}) +@RequestMapping("terminal") +@Slf4j +@Validated +public class TerminalExtController extends BaseController { + + @Resource + TerminalService terminalService; + @Resource + TerminalGpsService gpsService; + @Resource + WeatherService weatherService; + @Resource + LeadPullsService leadPullsService; + @Resource + TerminalPhotoService photoService; + + + @GetMapping("listWithGPS") + @ApiOperation("查询附带定位") + public ResponseReult> listWithGPS(Integer dyId, Integer lineId, Integer towerId, String search, + Integer pageNum, Integer pageSize) { + pageNum = this.initPageNum(pageNum); + pageSize = this.initPageSize(pageSize); + TableDataInfo result = this.getTerminalPage(dyId, lineId, towerId, search, + pageNum, pageSize); + if (!CollectionUtils.isEmpty(result.getList())) { + for (View_Dy_Line_Tower_Terminals terminal : result.getList()) { + TerminalGpsModel last = gpsService.getTermLastGPSPosition(terminal.getId()) + .getData(); + terminal.setLastGps(last); + } + } + return ResponseReult.success(result); + } + + @GetMapping("listWithPhoto") + @ApiOperation("查询附带图片统计") + public ResponseReult> listWithPhoto(Integer dyId, Integer lineId, Integer towerId, String search, + @NotNull(message = "start不能为空!") Long start, @NotNull(message = "end不能为空!") Long end, + Integer channelId, + Integer pageNum, Integer pageSize) { + pageNum = this.initPageNum(pageNum); + pageSize = this.initPageSize(pageSize); + TableDataInfo result = this.getTerminalPage(dyId, lineId, towerId, search, + pageNum, pageSize); + if (!CollectionUtils.isEmpty(result.getList())) { + for (View_Dy_Line_Tower_Terminals terminal : result.getList()) { + PhotoDayModel photoInfo = photoService.getDayModel(terminal.getId(), channelId, start, end); + terminal.setPhotoInfo(photoInfo); + } + } + return ResponseReult.success(result); + } + + @GetMapping("listWithWeather") + @ApiOperation("查询附带天气") + public ResponseReult> listWithWeather(Integer dyId, Integer lineId, Integer towerId, String search, + Integer pageNum, Integer pageSize) { + pageNum = this.initPageNum(pageNum); + pageSize = this.initPageSize(pageSize); + TableDataInfo result = this.getTerminalPage(dyId, lineId, towerId, search, + pageNum, pageSize); + if (!CollectionUtils.isEmpty(result.getList())) { + for (View_Dy_Line_Tower_Terminals terminal : result.getList()) { + Weathers last = weatherService.getLast(terminal.getId()); + terminal.setLastWeathers(last); + } + } + return ResponseReult.success(result); + } + + @GetMapping("listWithLeadPull") + @ApiOperation("查询附带拉力") + public ResponseReult> listWithLeadPull(Integer dyId, Integer lineId, Integer towerId, String search, + Integer pageNum, Integer pageSize) { + pageNum = this.initPageNum(pageNum); + pageSize = this.initPageSize(pageSize); + TableDataInfo result = this.getTerminalPage(dyId, lineId, towerId, search, + pageNum, pageSize); + if (!CollectionUtils.isEmpty(result.getList())) { + for (View_Dy_Line_Tower_Terminals terminal : result.getList()) { + LeadPulls last = leadPullsService.getLast(terminal.getId()); + terminal.setLastLeadPulls(last); + } + } + return ResponseReult.success(result); + } + + private TableDataInfo getTerminalPage(Integer dyId, Integer lineId, Integer towerId, String search, + Integer pageNum, Integer pageSize) { + TerminalSelectVo vo = new TerminalSelectVo(); + vo.setDyId(dyId); + vo.setLineId(lineId); + vo.setTowerId(towerId); + vo.setSearch(search); + vo.setPageindex(pageNum); + vo.setPagesize(pageSize); + TableDataInfo result = terminalService.getTerminalList(vo).getData(); + return result; + } +} diff --git a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/WeatherController.java b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/WeatherController.java index 4bfae28..0212b4d 100644 --- a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/WeatherController.java +++ b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/WeatherController.java @@ -3,19 +3,16 @@ package com.shxy.xymanager_admin.controller; import com.github.pagehelper.PageInfo; import com.shxy.xymanager_common.base.BaseController; import com.shxy.xymanager_common.base.ResponseReult; -import com.shxy.xymanager_common.entity.View_Dy_Line_Tower_Terminals; import com.shxy.xymanager_common.entity.Weathers; -import com.shxy.xymanager_common.page.TableDataInfo; -import com.shxy.xymanager_common.vo.TerminalSelectVo; -import com.shxy.xymanager_service.service.TerminalService; +import com.shxy.xymanager_common.util.EasyExcelUtil; import com.shxy.xymanager_service.service.WeatherService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; -import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; @RestController @Api(tags = {"气象相关接口"}) @@ -25,8 +22,6 @@ public class WeatherController extends BaseController { @Resource WeatherService service; - @Resource - TerminalService terminalService; @GetMapping("list") @ApiOperation("查询列表") @@ -38,24 +33,15 @@ public class WeatherController extends BaseController { return ResponseReult.success(result); } - @GetMapping("latest") - @ApiOperation("查询最新的") - public ResponseReult> latest(Integer dyId, Integer lineId, Integer towerId, - int pageNum, int pageSize) { - TerminalSelectVo vo = new TerminalSelectVo(); - vo.setDyId(dyId); - vo.setLineId(lineId); - vo.setTowerId(towerId); - vo.setPageindex(pageNum); - vo.setPagesize(pageSize); - TableDataInfo result = terminalService.getTerminalList(vo).getData(); - if (!CollectionUtils.isEmpty(result.getList())) { - for (View_Dy_Line_Tower_Terminals terminals : result.getList()) { - Weathers last = service.getLast(terminals.getId()); - terminals.setLastWeathers(last); - } - } - return ResponseReult.success(result); + @GetMapping("export") + @ApiOperation("导出") + public void export(Integer lineId, Integer towerId, Integer termId, + Long start, Long end, + Integer pageNum, Integer pageSize, + HttpServletResponse response) throws Exception { + PageInfo result = service.list(lineId, towerId, termId, + start, end, pageNum, pageSize); + EasyExcelUtil.createExcel(response, "覆冰数据", result.getList(), Weathers.class); } } diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/base/BaseController.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/base/BaseController.java index 1981ba1..c45aa07 100644 --- a/xymanager_common/src/main/java/com/shxy/xymanager_common/base/BaseController.java +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/base/BaseController.java @@ -20,6 +20,26 @@ import java.util.List; */ public class BaseController { + protected Integer initPageNum(Integer pageNum) { + if (pageNum == null) { + pageNum = 1; + } + if (pageNum < 0) { + pageNum = 1; + } + return pageNum; + } + + protected Integer initPageSize(Integer pageSize) { + if (pageSize == null) { + pageSize = 10; + } + if (pageSize < 1) { + pageSize = 1; + } + return pageSize; + } + /** * 将前台传递过来的日期格式的字符串,自动转化为Date类型 */ diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/LeadPulls.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/LeadPulls.java index 85be959..2013e56 100644 --- a/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/LeadPulls.java +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/LeadPulls.java @@ -38,7 +38,6 @@ public class LeadPulls { private Long updateTime; @ColumnWidth(20) @ExcelProperty(value = "时间", order = 2) - private Date updateDate; /** diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/View_Dy_Line_Tower_Terminals.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/View_Dy_Line_Tower_Terminals.java index 362acf4..496f134 100644 --- a/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/View_Dy_Line_Tower_Terminals.java +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/View_Dy_Line_Tower_Terminals.java @@ -3,6 +3,8 @@ package com.shxy.xymanager_common.entity; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUnit; import com.shxy.xymanager_common.enums.CommonStatus; +import com.shxy.xymanager_common.model.PhotoDayModel; +import com.shxy.xymanager_common.model.TerminalGpsModel; import com.shxy.xymanager_common.util.MyDateUtils; import com.shxy.xymanager_common.util.xinyin.TerminalUtils; import io.swagger.annotations.ApiModel; @@ -79,11 +81,11 @@ public class View_Dy_Line_Tower_Terminals implements Serializable { @ApiModelProperty(value = "sim卡号", example = "123456") private String sim; - @ApiModelProperty(value = "网络类型", example = "网络类型") + @ApiModelProperty(value = "网络类型", example = "1") private Integer netType; - @ApiModelProperty(value = "网络类型", example = "网络类型") + @ApiModelProperty(value = "网络类型", example = "1") private Integer devType; @ApiModelProperty(value = "设备名称", example = "123456") @@ -96,7 +98,7 @@ public class View_Dy_Line_Tower_Terminals implements Serializable { @ApiModelProperty(value = "最后一次心跳时间", example = "213") private BigInteger lastHeartbeat; - @ApiModelProperty(value = "在线状态", example = "0--掉线1--在线") + @ApiModelProperty(value = "在线状态", example = "1") private Integer onlinestatus; private Integer termcount; @@ -120,4 +122,6 @@ public class View_Dy_Line_Tower_Terminals implements Serializable { private Weathers lastWeathers; private LeadPulls lastLeadPulls; + private TerminalGpsModel lastGps; + private PhotoDayModel photoInfo; } \ No newline at end of file diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/Weathers.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/Weathers.java index edbf9a1..959ea5b 100644 --- a/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/Weathers.java +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/Weathers.java @@ -1,5 +1,11 @@ package com.shxy.xymanager_common.entity; +import com.alibaba.excel.annotation.ExcelIgnore; +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; + +import java.util.Date; + public class Weathers { /** * @@ -8,6 +14,7 @@ public class Weathers { * * @mbg.generated */ + @ExcelIgnore private Long id; /** @@ -17,6 +24,7 @@ public class Weathers { * * @mbg.generated */ + @ExcelIgnore private Integer termId; /** @@ -26,8 +34,13 @@ public class Weathers { * * @mbg.generated */ + @ExcelIgnore private Long updateTime; + @ColumnWidth(20) + @ExcelProperty(value = "时间", order = 2) + private Date updateDate; + /** * * This field was generated by MyBatis Generator. @@ -35,6 +48,7 @@ public class Weathers { * * @mbg.generated */ + @ExcelIgnore private String compId; /** @@ -44,6 +58,8 @@ public class Weathers { * * @mbg.generated */ + @ColumnWidth(16) + @ExcelProperty(value = "10 分钟平均风速(精确到小数点后1位,单位:m/s)", order = 3) private Float avgWindSpeed10min; /** @@ -53,6 +69,8 @@ public class Weathers { * * @mbg.generated */ + @ColumnWidth(16) + @ExcelProperty(value = "10 分钟平均风向(单位:°)", order = 4) private Integer avgWindDir10min; /** @@ -62,6 +80,8 @@ public class Weathers { * * @mbg.generated */ + @ColumnWidth(16) + @ExcelProperty(value = "1分钟平均风速(精确到小数点后1位,单位:m/s)", order = 5) private Float avgWindSpeed1min; /** @@ -71,6 +91,8 @@ public class Weathers { * * @mbg.generated */ + @ColumnWidth(16) + @ExcelProperty(value = "1 分钟平均风向(单位:°)", order = 6) private Float avgWindDir1min; /** @@ -80,6 +102,8 @@ public class Weathers { * * @mbg.generated */ + @ColumnWidth(16) + @ExcelProperty(value = "最大风速(精确到小数点后1位,单位:m/s) 南网规约 10分钟最大风速", order = 7) private Float maxWindSpeed; /** @@ -89,6 +113,7 @@ public class Weathers { * * @mbg.generated */ + @ExcelIgnore private Float extremeWindSpeed; /** @@ -98,6 +123,8 @@ public class Weathers { * * @mbg.generated */ + @ColumnWidth(16) + @ExcelProperty(value = "标准风速(精确到小数点后1位,单位:m/s) 南网规约瞬时风速", order = 8) private Float standardWindSpeed; /** @@ -107,6 +134,8 @@ public class Weathers { * * @mbg.generated */ + @ColumnWidth(16) + @ExcelProperty(value = "瞬时风向", order = 9) private Float windDirection; /** @@ -116,6 +145,8 @@ public class Weathers { * * @mbg.generated */ + @ColumnWidth(16) + @ExcelProperty(value = "气温(精确到小数点后1位,单位:℃)", order = 10) private Float airTemperature; /** @@ -125,6 +156,8 @@ public class Weathers { * * @mbg.generated */ + @ColumnWidth(16) + @ExcelProperty(value = "湿度(单位:%RH)", order = 11) private Integer humidity; /** @@ -134,6 +167,8 @@ public class Weathers { * * @mbg.generated */ + @ColumnWidth(16) + @ExcelProperty(value = "气压(精确到小数点后1位,单位:hPa)", order = 12) private Float airPressure; /** @@ -143,6 +178,8 @@ public class Weathers { * * @mbg.generated */ + @ColumnWidth(16) + @ExcelProperty(value = "降雨量(精确到小数点后1位,单位:mm)", order = 13) private Float precipitation; /** @@ -152,6 +189,7 @@ public class Weathers { * * @mbg.generated */ + @ExcelIgnore private Float precipitationIntensity; /** @@ -161,6 +199,8 @@ public class Weathers { * * @mbg.generated */ + @ColumnWidth(16) + @ExcelProperty(value = "光辐射强度(单位:W/m2)", order = 14) private Integer radiationIntensity; /** @@ -233,6 +273,7 @@ public class Weathers { */ public void setUpdateTime(Long updateTime) { this.updateTime = updateTime; + this.updateDate = new Date(updateTime*1000); } /** @@ -595,7 +636,11 @@ public class Weathers { this.radiationIntensity = radiationIntensity; } + @ColumnWidth(15) + @ExcelProperty(value = "监测终端编号", order = 1) private String cmdid; + + @ExcelIgnore private String phase; public String getCmdid() { @@ -613,4 +658,12 @@ public class Weathers { public void setPhase(String phase) { this.phase = phase; } + + public Date getUpdateDate() { + return updateDate; + } + + public void setUpdateDate(Date updateDate) { + this.updateDate = updateDate; + } } \ No newline at end of file diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/model/PhotoDayModel.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/PhotoDayModel.java new file mode 100644 index 0000000..d12434c --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/PhotoDayModel.java @@ -0,0 +1,18 @@ +package com.shxy.xymanager_common.model; + + +import lombok.Data; + +import java.io.Serializable; + + +@Data +public class PhotoDayModel implements Serializable { + + private long firstPhotoTime; + + private long lastRecvTime; + + private long photoCount; + +} diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalPhotoServiceImpl.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalPhotoServiceImpl.java index 153f92d..41f5a66 100644 --- a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalPhotoServiceImpl.java +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalPhotoServiceImpl.java @@ -27,6 +27,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import org.springframework.web.multipart.MultipartFile; import java.io.File; @@ -793,5 +794,27 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService { } } + @Override + public PhotoDayModel getDayModel(Integer termid, Integer channelId, Long start, Long end) { + TerminalPhotoExample example = new TerminalPhotoExample(); + TerminalPhotoExample.Criteria criteria = example.createCriteria(); + criteria.andTermIdEqualTo(termid); + criteria.andPhotoTimeBetween(start, end); + if (channelId != null){ + criteria.andChannelIdEqualTo(channelId); + } + example.setOrderByClause("photo_time desc"); + List list = terminalPhotoDao.selectByExample(example); + + PhotoDayModel result = new PhotoDayModel(); + if (!CollectionUtils.isEmpty(list)) { + int count = list.size(); + result.setPhotoCount(count); + result.setLastRecvTime(list.get(0).getRecvTime().longValue()); + result.setFirstPhotoTime(list.get(count - 1).getPhotoTime().longValue()); + } + return result; + } + } diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/service/TerminalPhotoService.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/service/TerminalPhotoService.java index e37c09e..7a7dcd2 100644 --- a/xymanager_service/src/main/java/com/shxy/xymanager_service/service/TerminalPhotoService.java +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/service/TerminalPhotoService.java @@ -108,4 +108,6 @@ public interface TerminalPhotoService { */ ServiceBody uploadPhoto(MultipartFile file, Integer termid, String cmdid, Integer channel, BigInteger phototime) throws IOException; + + PhotoDayModel getDayModel(Integer termid, Integer channelId, Long start, Long end); }