|
@@ -1,12 +1,17 @@
|
|
|
package thyyxxk.webserver.controller.medicalinsurance;
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
import thyyxxk.webserver.config.auth.PassToken;
|
|
|
+import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
+import thyyxxk.webserver.constants.Capacity;
|
|
|
+import thyyxxk.webserver.entity.ResultVo;
|
|
|
import thyyxxk.webserver.entity.medicalinsurance.inpatient.RdCrdRslt;
|
|
|
+import thyyxxk.webserver.utils.ResultVoUtil;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
* @description: 读卡
|
|
@@ -17,11 +22,33 @@ import thyyxxk.webserver.entity.medicalinsurance.inpatient.RdCrdRslt;
|
|
|
@RestController
|
|
|
@RequestMapping("/siReadCard")
|
|
|
public class SiRdCrdController {
|
|
|
+ private final Map<String, RdCrdRslt> map = new HashMap<>(Capacity.DEFAULT);
|
|
|
+
|
|
|
+ @GetMapping("/request")
|
|
|
+ public ResultVo<RdCrdRslt> request(@RequestParam("prm") String prm) throws Exception {
|
|
|
+ log.info("读卡请求:{}", prm);
|
|
|
+ String patNo = prm.split("_")[1];
|
|
|
+ int count = 0;
|
|
|
+ RdCrdRslt rslt = null;
|
|
|
+ while (null == rslt && count < 40) {
|
|
|
+ TimeUnit.MILLISECONDS.sleep(1500);
|
|
|
+ rslt = map.remove(patNo);
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ if (null == rslt) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR, "读卡失败。");
|
|
|
+ }
|
|
|
+ if (rslt.getCode() != 0) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR, rslt.getMessage());
|
|
|
+ }
|
|
|
+ return ResultVoUtil.success(rslt);
|
|
|
+ }
|
|
|
|
|
|
@PassToken
|
|
|
@PostMapping("/callback")
|
|
|
public String callback(@RequestBody RdCrdRslt rslt) {
|
|
|
log.info("读卡返回:{}", rslt);
|
|
|
+ map.put(rslt.getPatNo(), rslt);
|
|
|
return "回调成功。";
|
|
|
}
|
|
|
|