master
杨海航 3 months ago
parent d65ab3634c
commit e4e7ee15c6
  1. 7
      src/main/java/digital/laboratory/platform/entrustment/config/ErrorController.java
  2. 9
      src/main/java/digital/laboratory/platform/entrustment/controller/AcceptController.java
  3. 2
      src/main/java/digital/laboratory/platform/entrustment/service/impl/AcceptServiceImpl.java

@ -21,7 +21,6 @@ import java.util.Map;
* resources:
* add-mappings: false
* 只有如此, springboot 才会触发异常
*
*/
@ -31,15 +30,15 @@ public class ErrorController {
@ExceptionHandler(Exception.class)
@ResponseBody
public ResponseEntity error(Exception ex) {
System.out.println("ErrorController.error Exception");
ex.printStackTrace();
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()));
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(R.failed(map, "发生异常 " + ex.getMessage()));
}

@ -1,5 +1,6 @@
package digital.laboratory.platform.entrustment.controller;
import digital.laboratory.platform.common.core.exception.ValidateCodeException;
import digital.laboratory.platform.common.core.util.R;
import digital.laboratory.platform.entrustment.entity.EntrustmentIdentificationMaterial;
import digital.laboratory.platform.entrustment.service.AcceptService;
@ -25,7 +26,13 @@ public class AcceptController {
@PutMapping("/alertMaterialAcceptNo")
@PreAuthorize("@pms.hasPermission('EntrustmentAccept')")
public R alertMaterialAcceptNo(@RequestBody EntrustmentIdentificationMaterial material) {
Boolean success = acceptService.alertMaterialAcceptNo(material);
Boolean success = null;
try {
success = acceptService.alertMaterialAcceptNo(material);
} catch (ValidateCodeException e) {
e.printStackTrace();
return R.failed(e.getMessage());
}
return R.ok(success);
}

@ -49,7 +49,7 @@ public class AcceptServiceImpl implements AcceptService {
* ^ $表示字符串的开始和结束
*/
String regex = "^\\d+-\\d+-\\d+$";
if (Pattern.matches(regex, materialAcceptNo)) {
if (!Pattern.matches(regex, materialAcceptNo)) {
throw new ValidateCodeException(String.format("%s 不符合检材受理编号的规则!", materialAcceptNo));
}
// 校验当前修改的检材受理编号对应的委托的受理编号存不存在, 委托的受理编号是检材受理编号截取最后一个横杠的内容

Loading…
Cancel
Save