122 lines
4.7 KiB
Plaintext
122 lines
4.7 KiB
Plaintext
package com.sercurityControl.proteam.dutyTask.controller;
|
|
|
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.securityControl.common.core.utils.StringUtils;
|
|
import com.securityControl.common.core.utils.aes.DateTimeHelper;
|
|
import com.securityControl.common.core.web.domain.AjaxResult;
|
|
import com.securityControl.common.log.annotation.Log;
|
|
import com.securityControl.common.log.enums.BusinessType;
|
|
import com.sercurityControl.proteam.dutyTask.domain.AbnormalRepDto;
|
|
import com.sercurityControl.proteam.dutyTask.domain.AbnormalRepVo;
|
|
import com.sercurityControl.proteam.dutyTask.service.AbnormalRepService;
|
|
import com.sercurityControl.proteam.util.OssUtil;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* 异常上报统计->控制层
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/pot/abnormalRep/")
|
|
@Slf4j
|
|
public class AbnormalRepController {
|
|
|
|
Logger logger = LoggerFactory.getLogger(AbnormalRepController.class);
|
|
|
|
@Resource(name = "AbnormalRepService")
|
|
private AbnormalRepService service;
|
|
|
|
@Autowired
|
|
private OssUtil ossUtil;
|
|
|
|
/**
|
|
* @return java.util.Map<java.lang.String, java.lang.Object>
|
|
* @author cw chen
|
|
* @description 异常上报统计列表
|
|
* @Param dto
|
|
* @date 2023-06-26 11:04
|
|
*/
|
|
@PostMapping(value = "getAbnormalRepList")
|
|
@Log(title = "异常上报统计", menu = "异常上报统计->异常上报统计列表", businessType = BusinessType.QUERY, details = "异常上报统计列表")
|
|
public Map<String, Object> getAbnormalRepList(AbnormalRepDto dto) {
|
|
if (StringUtils.isBlank(dto.getDate())) {
|
|
dto.setStartTime(DateTimeHelper.getNowDate());
|
|
dto.setEndTime(DateTimeHelper.getNowDate());
|
|
} else {
|
|
String[] dateArr = dto.getDate().split(" - ");
|
|
dto.setStartTime(dateArr[0]);
|
|
dto.setEndTime(dateArr[1]);
|
|
}
|
|
PageHelper.startPage(Integer.parseInt(dto.getPage()), Integer.parseInt(dto.getLimit()));
|
|
Map<String, Object> map = new HashMap<String, Object>(16);
|
|
try {
|
|
PageInfo<AbnormalRepVo> pageInfo = service.getAbnormalRepList(dto);
|
|
map.put("code", 200);
|
|
map.put("msg", "获取数据成功");
|
|
map.put("count", pageInfo.getTotal());
|
|
map.put("curr", Integer.parseInt(dto.getPage()));
|
|
map.put("limit", Integer.parseInt(dto.getLimit()));
|
|
map.put("data", pageInfo.getList());
|
|
} catch (Exception e) {
|
|
map.put("code", 500);
|
|
map.put("msg", "获取数据失败");
|
|
map.put("count", 0);
|
|
map.put("curr", Integer.parseInt(dto.getPage()));
|
|
map.put("limit", Integer.parseInt(dto.getLimit()));
|
|
map.put("data", null);
|
|
logger.error("数据获取失败", e);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
/**
|
|
* @return com.securityControl.common.core.web.domain.AjaxResult
|
|
* @author cw chen
|
|
* @description 根据id获取异常照片
|
|
* @Param id
|
|
* @date 2023-06-26 16:41
|
|
*/
|
|
@PostMapping("getAbnormalImgById")
|
|
public AjaxResult getAbnormalImgById(String id) {
|
|
List<Map<String, String>> listMap = new ArrayList<>();
|
|
try {
|
|
List<String> list = service.getAbnormalImgById(id);
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
list.forEach(item -> {
|
|
Map<String, String> map = new HashMap<>(16);
|
|
if (StringUtils.isNotBlank(item)) {
|
|
if (item.indexOf("jpg") > 0) { // 服务器文件
|
|
map.put("type", "1");
|
|
map.put("path", item);
|
|
} else { // oss文件
|
|
map.put("type", "2");
|
|
map.put("path", ossUtil.getBase64List(item, 1).get(0));
|
|
}
|
|
}else{ // oss文件
|
|
map.put("type", "2");
|
|
map.put("path", "1");
|
|
}
|
|
listMap.add(map);
|
|
});
|
|
}
|
|
} catch (Exception e) {
|
|
logger.error("服务异常,请稍后重试", e);
|
|
}
|
|
return AjaxResult.success("异常照片获取成功", listMap);
|
|
}
|
|
|
|
}
|