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

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

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