feat: 增加查询图片统计功能

dev
huangfeng 3 months ago
parent f88a5c6c22
commit 9473fea643

@ -19,6 +19,9 @@ import org.springframework.http.HttpHeaders;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@Api(value = "图片接口", tags = "图片接口相关")
@RestController
@ -101,7 +104,7 @@ public class TerminalPhotoController extends BaseController {
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
@RequestMapping("/getTakePicPhotoStatus")
@Log(title = "主动拍照下照片状态查询", type = "查询")
public ResponseReult<Boolean> getTakePicPhotoStatus( @Validated ReturnedPhotoVo vo) {
public ResponseReult<Boolean> getTakePicPhotoStatus(@Validated ReturnedPhotoVo vo) {
ServiceBody<Boolean> serviceBody = terminalPhotoService.getTakePicPhotoStatus(vo);
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
return ResponseReult.success(serviceBody.getData());
@ -137,6 +140,51 @@ public class TerminalPhotoController extends BaseController {
}
}
@ApiOperation(value = "图片统计查询", notes = "图片统计查询接口", httpMethod = "POST")
@RequestMapping("/getPhotoStat")
@Log(title = "图片统计查询", type = "查询")
public ResponseReult<List<StatTerm>> getPhotoStat(@RequestHeader HttpHeaders headers, @RequestBody @Validated TerminalPhotoSelectVo vo) {
String requestIp = HeaderUtil.getRequestIp(headers);
vo.setPageindex(1);
vo.setPagesize(100000);
ServiceBody<TerminalPhotoSelectListModel> serviceBody = terminalPhotoService.getPhotoList(requestIp, vo);
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
TerminalPhotoSelectListModel model = serviceBody.getData();
List<StatTerm> result = this.buildPhotoStat(model.getList());
return ResponseReult.success(result);
} else {
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
}
}
private List<StatTerm> buildPhotoStat(List<TerminalPhotoSelectListModel.PhotoBean> list) {
List<StatTerm> result = new ArrayList<>();
if (list != null) {
for (TerminalPhotoSelectListModel.PhotoBean photo : list) {
StatTerm term = this.findStatTerm(result, photo);
term.addPhoto(photo);
}
}
return result;
}
private StatTerm findStatTerm(List<StatTerm> list, TerminalPhotoSelectListModel.PhotoBean photo) {
StatTerm the = null;
for (StatTerm item : list) {
if (item.getTermId() == photo.getTermid()) {
the = item;
break;
}
}
if (the == null) {
the = new StatTerm();
the.setTermId(photo.getTermid());
the.setCmdid(photo.getCmdid());
list.add(the);
}
return the;
}
@ApiOperation(value = "图片轮询", notes = "图片轮询接口", httpMethod = "POST")
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})

@ -0,0 +1,31 @@
package com.shxy.xymanager_common.model;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class StatChannel {
Integer channelId;
List<StatPreset> presets;
public void addPhoto(TerminalPhotoSelectListModel.PhotoBean photo) {
if (presets == null) {
presets = new ArrayList<>();
}
StatPreset the = null;
for (StatPreset item : presets) {
if (item.getPresetId().intValue() == photo.getPresetId().intValue()) {
the = item;
break;
}
}
if (the == null) {
the = new StatPreset();
the.setPresetId(photo.getPresetId());
presets.add(the);
}
the.addPhoto(photo);
}
}

@ -0,0 +1,20 @@
package com.shxy.xymanager_common.model;
import lombok.Data;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Data
public class StatPreset {
Integer presetId;
List<Date> photoTimes;
public void addPhoto(TerminalPhotoSelectListModel.PhotoBean photo) {
if (photoTimes == null) {
photoTimes = new ArrayList<>();
}
photoTimes.add(photo.getPhotoTime());
}
}

@ -1,9 +1,35 @@
package com.shxy.xymanager_common.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@JsonInclude(JsonInclude.Include.NON_NULL)
@Data
public class StatTerm {
int termId;
Object uploads;
String cmdid;
List<StatChannel> channels;
public void addPhoto(TerminalPhotoSelectListModel.PhotoBean photo) {
if (channels == null) {
channels = new ArrayList<>();
}
StatChannel the = null;
for (StatChannel item : channels) {
if (item.getChannelId().intValue() == photo.getChannelid().intValue()) {
the = item;
break;
}
}
if (the == null) {
the = new StatChannel();
the.setChannelId(photo.getChannelid());
channels.add(the);
}
the.addPhoto(photo);
}
}

Loading…
Cancel
Save