提交 701979ad authored 作者: Matrix's avatar Matrix

[核查模块] 修复了统计数据的统计两次的问题

上级 39d43e47
......@@ -55,7 +55,7 @@ import static java.util.stream.Collectors.*;
@RestController
@RequestMapping(value = "/check/confirm")
@AutoDocument
@Api(tags = "核查模块", value = "核查模块")
@Api(tags = "核查模块", description = "核查模块")
@Transactional
@Slf4j
public class DeviceCheckController {
......
......@@ -59,8 +59,7 @@ public class CheckAreaStatVo {
this.areaName = other.getAreaName();
this.areaStatId = other.getAreaStatId();
this.areaDetailId = other.getAreaDetailId();
this.actualCount = other.getActualCount() + other.getActualCount();
this.supposeCount = other.getSupposeCount() + other.getSupposeCount();
this.actualCount += other.getActualCount();
this.comProgress = other.getComProgress();
this.comSituation = other.getComSituation();
......
......@@ -7,6 +7,7 @@ import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
......@@ -72,7 +73,7 @@ public class CheckDeviceStatVo {
areaMap.computeIfPresent(otherArea.getAreaName(), (k, v) -> v.add(otherArea));
}
areaStatList = (List<CheckAreaStatVo>) areaMap.values();
areaStatList = new ArrayList<>(areaMap.values());
return this;
}
......
......@@ -116,7 +116,7 @@ public class CheckStatVo {
oriModelMap.computeIfPresent(vo.getDeviceModel(), (k, v) -> v.add(vo));
}
deviceStatVoList = (List<CheckDeviceStatVo>) oriModelMap.values();
deviceStatVoList = new ArrayList<>(oriModelMap.values());
return this;
}
......
package com.tykj.dev.misc.exception;
import com.tykj.dev.misc.base.ResultObj;
import org.springframework.http.ResponseEntity;
/**
* 全局错误处理类,用于处理一些不容易定义的错误
*
* @author HuangXiahao
**/
public class ApiException extends RuntimeException {
......@@ -14,6 +16,15 @@ public class ApiException extends RuntimeException {
this.responseEntity = responseEntity;
}
public ApiException(String message) {
this.responseEntity = ResponseEntity.status(400).body(new ResultObj(message));
}
public ApiException(String message, Object data) {
this.responseEntity = ResponseEntity.status(400).body(new ResultObj(data, message));
}
public ResponseEntity getResponseEntity() {
return responseEntity;
}
......
......@@ -33,6 +33,7 @@ public class GlobalExceptionHandler {
@ResponseBody
@ExceptionHandler(Exception.class)
public ResponseEntity errorMessage(Exception e) {
log.error("[其他异常] {}", e.toString());
e.printStackTrace();
return ResultUtil.failed();
}
......@@ -46,9 +47,8 @@ public class GlobalExceptionHandler {
@ExceptionHandler(ApiException.class)
public ResponseEntity errorMessage(ApiException e) {
log.warn("[自定义异常] {}", e.toString());
log.error("错误详情:{}",e.getMessage());
if (e.getResponseEntity() != null) {
return ResponseEntity.status(400).body(e.getResponseEntity().getBody());
return e.getResponseEntity();
}
return ResultUtil.failed();
}
......@@ -61,6 +61,7 @@ public class GlobalExceptionHandler {
@ResponseBody
@ExceptionHandler(BindException.class)
public ResponseEntity errorMessage(BindException e) {
log.error("[参数异常] 检测到用户访问接口没有提供正确的参数 {}", e.toString());
e.printStackTrace();
BindingResult bindingResult = e.getBindingResult();
String message = null;
......@@ -81,7 +82,7 @@ public class GlobalExceptionHandler {
@ResponseBody
@ExceptionHandler(AuthenticationException.class)
public ResponseEntity errorMessage(AuthenticationException e) {
e.printStackTrace();
log.warn("[未登录异常] 检测到用户没有登录");
return ResultUtil.unauthorized();
}
......@@ -94,6 +95,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler(AccessDeniedException.class)
public ResponseEntity errorMessage(AccessDeniedException e) {
e.printStackTrace();
log.warn("[权限异常] {}", e.toString());
return ResponseEntity.status(403).body(new ResultObj(e.getMessage()));
}
......
......@@ -38,7 +38,7 @@ public class ResultUtil<T> {
* 失败返回结果
*/
public static <T> ResponseEntity failed() {
return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
return ResponseEntity.status(500).body(new ResultObj("服务器内部发生错误"));
}
/**
......
......@@ -6,6 +6,7 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
import java.util.Optional;
/**
* @author dengdiyi
......@@ -17,7 +18,7 @@ public interface TaskDao extends JpaRepository<Task, Integer>, JpaSpecificationE
* @param businessType 业务类型
* 根据账单Id和业务类型查询task
*/
Task findByBillIdAndBusinessType(Integer billId, Integer businessType);
Optional<Task> findByBillIdAndBusinessType(Integer billId, Integer businessType);
/**
* 根据账单id、业务类型、任务状态查询task
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论