202501011 更新

master
陈江保 3 days ago
parent 1083fc878a
commit d6137fb59c
  1. 71
      src/main/java/digital/laboratory/platform/entrustment/config/ErrorController.java
  2. 47
      src/main/java/digital/laboratory/platform/entrustment/controller/EntrustmentController.java
  3. 8
      src/main/java/digital/laboratory/platform/entrustment/service/impl/EntrustMaterialCheckoutResultServiceImpl.java

@ -1,71 +0,0 @@
package digital.laboratory.platform.entrustment.config;
import digital.laboratory.platform.common.core.util.R;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.NoHandlerFoundException;
import java.util.HashMap;
import java.util.Map;
/**
* Spring Boot 自定义异常处理
* 所有的异常都派生自 Exception, 如果我们定义了某个异常的处理 Handler, Spring Boot 会调用用对应的异常 Handler, 否则会调用 Exception Handler.
* 有一个前提是在 application.yml 中定义两个属性, springboot 在没有找到 url 的处理器触发异常; springboot 不要自作多情加 /error 这个 map
* mvc:
* throw-exception-if-no-handler-found: true
* web:
* resources:
* add-mappings: false
* 只有如此, springboot 才会触发异常
*/
@ControllerAdvice
public class ErrorController {
@ExceptionHandler(Exception.class)
@ResponseBody
public ResponseEntity error(Exception ex) {
System.out.println("ErrorController.error Exception");
ex.printStackTrace();
Map<String, Object> map = new HashMap<>();
map.put("Exception", ex.getClass().getName());
map.put("message", ex.getMessage());
map.put("localizedMessage", ex.getLocalizedMessage());
map.put("toString", ex.toString());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(R.failed(map, "发生异常 " + ex.getMessage()));
}
@ExceptionHandler(value = {NoHandlerFoundException.class})
@ResponseBody
public ResponseEntity error(NoHandlerFoundException ex) {
//System.out.println("ErrorController.error NoHandlerFoundException");
//ex.printStackTrace();
// //ex.getRawStatusCode()
Map<String, Object> map = new HashMap<>();
map.put("Exception", ex.getClass().getName());
map.put("message", ex.getMessage());
map.put("localizedMessage", ex.getLocalizedMessage());
map.put("requestURL", ex.getRequestURL());
map.put("httpMethod", ex.getHttpMethod());
// map.put("cause", ex.getCause().toString());
map.put("toString", ex.toString());
// map.put("comments", "单独的 ExceptionHandler, 系统管理捕获的全局异常 NoHandlerFoundException");
// //return map;
// //ResponseEntity<Map<String,Object>> r = new ResponseEntity<Map<String,Object>>(map, HttpStatus.INTERNAL_SERVER_ERROR);
// //ResponseEntity<Map<String,Object>> r = new ResponseEntity<Map<String,Object>>(map, HttpStatus.NOT_FOUND);
// //return r;
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body(map);
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(R.failed(map, "没有找到"));
}
}

@ -2195,53 +2195,6 @@ public class EntrustmentController {
return R.ok(entrustmentService.updateImportData(excuteType)); return R.ok(entrustmentService.updateImportData(excuteType));
} }
//=====================================================================================
// 测试, 为现有的案件创建一些委托
@GetMapping("/create100")
public R xxx_TestCreate100() {
List<CaseEventVO> cjs = caseEventService.getCaseVoList(null, null, null, null);
for (CaseEvent cj : cjs) {
int num = RandomUtil.randomInt(1, 4);
for (int i = 0; i < num; i++) {
List<Entrustment> ces = entrustmentService.list(Wrappers.<Entrustment>query()
.eq("case_id", cj.getId()));
if (ces.size() >= num) {
break;
}
Entrustment entrustment = new Entrustment();
entrustment.setCaseId(cj.getId());
//entrustment.setEntrustmentNo(entrustmentService.getNewEntrustmentNo(cj.getCaseNo()));
entrustment.setEntrustmentNo(entrustmentService.getNewEntrustmentNo());
//entrustment.setEntrustmentTime(LocalDateTime.now());
entrustment.setClientOrgId("");
//entrustment.setClientOrgName("");
entrustment.setDeliverer1Name("李宏亮");
entrustment.setDeliverer1Phone("13985001001");
entrustment.setDeliverer1Id("522122199504042035");
entrustment.setDeliverer2Name("西门吹雪");
entrustment.setDeliverer2Phone("13985001002");
entrustment.setDeliverer2Id("522122190504042031");
//entrustment.setIdentificationOrgName("国家毒品实验室陕西分中心"); // 鉴定机构名称
entrustment.setIdentificationDomain("毒品检验"); // 鉴定专业
entrustment.setQualitativeAnalysis(true); // 定性分析
entrustment.setQuantitativeAnalysis(true); // 定量分析
entrustment.setOtherIdentificationRequests("无"); // 鉴定要求
entrustment.setId(IdWorker.get32UUID().toUpperCase());
if (entrustmentService.save(entrustment)) {
System.out.println("新增委托成功");
} else {
System.out.println("新增委托失败");
}
}
}
return R.ok("已经为每个案件创建了 一些 委托");
}
@GetMapping("/get/quantity/for/Inspection") @GetMapping("/get/quantity/for/Inspection")
@ApiOperation(value = "送检系统统计当前用户(机构)送检且已受理的所有检材数量", notes = "送检系统统计当前用户(机构)送检且已受理的所有检材数量") @ApiOperation(value = "送检系统统计当前用户(机构)送检且已受理的所有检材数量", notes = "送检系统统计当前用户(机构)送检且已受理的所有检材数量")
public R<List<MarkersVO>> getQuantityForInspection(HttpServletRequest httpServletRequest) { public R<List<MarkersVO>> getQuantityForInspection(HttpServletRequest httpServletRequest) {

@ -204,6 +204,9 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus
.in(Entrustment::getStatus, EntrustStatusConstants.ENTRUST_STATUS_ACCEPTED.getStatus(), EntrustStatusConstants.ENTRUST_STATUS_TEST_FINISH.getStatus(), EntrustStatusConstants.ENTRUST_STATUS_COMPLETED.getStatus()) .in(Entrustment::getStatus, EntrustStatusConstants.ENTRUST_STATUS_ACCEPTED.getStatus(), EntrustStatusConstants.ENTRUST_STATUS_TEST_FINISH.getStatus(), EntrustStatusConstants.ENTRUST_STATUS_COMPLETED.getStatus())
); );
List<String> entrustIds = entrustmentList.stream().map(Entrustment::getId).collect(Collectors.toList()); List<String> entrustIds = entrustmentList.stream().map(Entrustment::getId).collect(Collectors.toList());
if (CollUtil.isEmpty(entrustIds)) {
throw new CheckedException("没有查询到符合条件的委托信息!");
}
// 获取检材信息, 排序的原因是需要数据是有序的 // 获取检材信息, 排序的原因是需要数据是有序的
List<EntrustmentIdentificationMaterial> materialList = entrustmentIdentificationMaterialService.list( List<EntrustmentIdentificationMaterial> materialList = entrustmentIdentificationMaterialService.list(
Wrappers.<EntrustmentIdentificationMaterial>lambdaQuery() Wrappers.<EntrustmentIdentificationMaterial>lambdaQuery()
@ -851,8 +854,13 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus
public R getExcelByResult(HttpServletResponse response, ResultExcelDTO excelDTO) throws IOException { public R getExcelByResult(HttpServletResponse response, ResultExcelDTO excelDTO) throws IOException {
if (excelDTO.getExportForBigDataPlatform() != null && excelDTO.getExportForBigDataPlatform()) { if (excelDTO.getExportForBigDataPlatform() != null && excelDTO.getExportForBigDataPlatform()) {
try {
// 导出可上传至禁毒大数据平台文件 // 导出可上传至禁毒大数据平台文件
exportForBigDataPlatform(excelDTO, response); exportForBigDataPlatform(excelDTO, response);
} catch (Exception e) {
e.printStackTrace();
return R.failed(e.getMessage());
}
} else { } else {
// 获取查询数据 // 获取查询数据
List<EntrustmentIdentificationMaterialVO> resultData = this.getResultData(excelDTO); List<EntrustmentIdentificationMaterialVO> resultData = this.getResultData(excelDTO);

Loading…
Cancel
Save