diff --git a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalPhotoController.java b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalPhotoController.java index c2e6c8b..4fc9493 100644 --- a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalPhotoController.java +++ b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalPhotoController.java @@ -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 getTakePicPhotoStatus( @Validated ReturnedPhotoVo vo) { + public ResponseReult getTakePicPhotoStatus(@Validated ReturnedPhotoVo vo) { ServiceBody 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> getPhotoStat(@RequestHeader HttpHeaders headers, @RequestBody @Validated TerminalPhotoSelectVo vo) { + String requestIp = HeaderUtil.getRequestIp(headers); + vo.setPageindex(1); + vo.setPagesize(100000); + ServiceBody serviceBody = terminalPhotoService.getPhotoList(requestIp, vo); + if (serviceBody.getCode() == ServiceStatus.SUCCESS) { + TerminalPhotoSelectListModel model = serviceBody.getData(); + List result = this.buildPhotoStat(model.getList()); + return ResponseReult.success(result); + } else { + return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg()); + } + } + + private List buildPhotoStat(List list) { + List 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 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 = "请求路径没有或页面跳转路径不对")}) diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatChannel.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatChannel.java new file mode 100644 index 0000000..e7b62a2 --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatChannel.java @@ -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 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); + } +} diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatPreset.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatPreset.java new file mode 100644 index 0000000..1c55d41 --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatPreset.java @@ -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 photoTimes; + + public void addPhoto(TerminalPhotoSelectListModel.PhotoBean photo) { + if (photoTimes == null) { + photoTimes = new ArrayList<>(); + } + photoTimes.add(photo.getPhotoTime()); + } +} diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatTerm.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatTerm.java index 84d899f..720b0ab 100644 --- a/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatTerm.java +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatTerm.java @@ -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 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); + } }