|
|
@@ -1,10 +1,14 @@
|
|
|
package com.jyxt.getdatabyrestful.controller;
|
|
|
|
|
|
+import com.jyxt.getdatabyrestful.service.IBPSService;
|
|
|
import com.jyxt.getdatabyrestful.service.LISService;
|
|
|
+import com.jyxt.getdatabyrestful.service.impl.IBPSServiceImpl;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
@@ -17,6 +21,7 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+
|
|
|
@RestController
|
|
|
@CrossOrigin(origins = "*") // 允许所有来源
|
|
|
@RequestMapping("/SampleProcess") // 基础路径
|
|
|
@@ -30,6 +35,11 @@ public class LISController {
|
|
|
@Autowired
|
|
|
LISService lisService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ IBPSService ibpsService;
|
|
|
+
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(LISController.class);
|
|
|
+
|
|
|
// 示例:GET接口
|
|
|
@GetMapping("/test")
|
|
|
@Operation(summary = "示例接口", description = "这是一个示例GET接口,点击右侧'try it out'测试接口能否正常调用")
|
|
|
@@ -49,16 +59,19 @@ public class LISController {
|
|
|
if (configData == null || configData.isEmpty()) {
|
|
|
response.put("state", 404);
|
|
|
response.put("message", "未找到配置信息");
|
|
|
+ log.info("failed!:未找到配置信息");
|
|
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
|
|
|
}
|
|
|
|
|
|
response.put("state", 200);
|
|
|
response.put("message", "成功获取配置");
|
|
|
response.put("data", configData);
|
|
|
+ log.info("success!:成功获取配置");
|
|
|
return ResponseEntity.ok(response);
|
|
|
} catch (Exception e) {
|
|
|
response.put("state", 500);
|
|
|
response.put("message", "服务器内部错误: " + e.getMessage());
|
|
|
+ log.info("failed!:服务器内部错误"+ e.getMessage());
|
|
|
return ResponseEntity.internalServerError().body(response);
|
|
|
}
|
|
|
}
|
|
|
@@ -75,6 +88,7 @@ public class LISController {
|
|
|
if (inputList == null || inputList.isEmpty()) {
|
|
|
response.put("state", 400);
|
|
|
response.put("message", "请求参数不能为空");
|
|
|
+ log.info("failed!:请求参数不能为空");
|
|
|
return ResponseEntity.badRequest().body(response);
|
|
|
}
|
|
|
|
|
|
@@ -83,10 +97,12 @@ public class LISController {
|
|
|
response.put("state", 200);
|
|
|
response.put("message", "成功");
|
|
|
response.put("data", data);
|
|
|
+ log.info("success!:成功");
|
|
|
return ResponseEntity.ok(response);
|
|
|
} catch (Exception e) {
|
|
|
response.put("state", 500);
|
|
|
response.put("message", "服务器内部错误");
|
|
|
+ log.info("failed!:服务器内部错误"+ e.getMessage());
|
|
|
return ResponseEntity.internalServerError().body(response);
|
|
|
}
|
|
|
}
|
|
|
@@ -165,12 +181,19 @@ public class LISController {
|
|
|
try {
|
|
|
int result = lisService.SaveSample(inputList);
|
|
|
response.put("state", result == 0 ? 200 : 500);
|
|
|
- response.put("message", result == 0 ? "保存成功" : "保存失败");
|
|
|
+ if(result == 0){
|
|
|
+ response.put("message", "保存成功");
|
|
|
+ log.info("success!:保存成功");
|
|
|
+ } else {
|
|
|
+ response.put("message", "保存失败");
|
|
|
+ log.info("failed!:保存失败");
|
|
|
+ }
|
|
|
response.put("data", result);
|
|
|
return ResponseEntity.ok(response);
|
|
|
} catch (Exception e) {
|
|
|
response.put("state", 500);
|
|
|
response.put("message", "服务器内部错误");
|
|
|
+ log.info("failed!:服务器内部错误" + e.getMessage());
|
|
|
return ResponseEntity.internalServerError().body(response);
|
|
|
}
|
|
|
}
|
|
|
@@ -196,14 +219,50 @@ public class LISController {
|
|
|
try {
|
|
|
int result = lisService.DestorySample(inputList);
|
|
|
response.put("state", result == 0 ? 200 : 500);
|
|
|
- response.put("message", result == 0 ? "保存成功" : "保存失败");
|
|
|
+ if(result == 0){
|
|
|
+ response.put("message", "保存成功");
|
|
|
+ log.info("success!:保存成功");
|
|
|
+ } else {
|
|
|
+ response.put("message", "保存失败");
|
|
|
+ log.info("failed!:保存失败");
|
|
|
+ }
|
|
|
response.put("data", result);
|
|
|
return ResponseEntity.ok(response);
|
|
|
} catch (Exception e) {
|
|
|
response.put("state", 500);
|
|
|
response.put("message", "服务器内部错误");
|
|
|
+ log.info("failed!:服务器内部错误" + e.getMessage());
|
|
|
+ return ResponseEntity.internalServerError().body(response);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/UpdateActualCount")
|
|
|
+ @Operation(summary = "更新保存标本百分比", description = "")
|
|
|
+ public ResponseEntity<Map<String, Object>> UpdateActualCount() {
|
|
|
+ Map<String, Object> response = new HashMap<>();
|
|
|
+// response.put("state", 200);
|
|
|
+// response.put("message", "更新成功");
|
|
|
+// return ResponseEntity.ok(response);
|
|
|
+ try {
|
|
|
+ int retVal = ibpsService.UpdateActualCount();
|
|
|
+ if (retVal == 1) {
|
|
|
+ response.put("state", 200);
|
|
|
+ response.put("message", "更新成功");
|
|
|
+ log.info("success!:更新成功");
|
|
|
+ return ResponseEntity.ok(response);
|
|
|
+ } else {
|
|
|
+ response.put("state", 404);
|
|
|
+ response.put("message", "更新失败");
|
|
|
+ log.info("failed!:更新失败");
|
|
|
+ return ResponseEntity.status(HttpStatus.EXPECTATION_FAILED).body(response);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ response.put("state", 500);
|
|
|
+ response.put("message", "服务器内部错误: " + e.getMessage());
|
|
|
+ log.info("failed!:服务器内部错误" + e.getMessage());
|
|
|
return ResponseEntity.internalServerError().body(response);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|