|
@@ -1,60 +0,0 @@
|
|
|
-package thyyxxk.webserver.service.yibao;
|
|
|
-
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
-import thyyxxk.webserver.dao.his.yibao.ReadCardCallbackDao;
|
|
|
-import thyyxxk.webserver.entity.ResultVo;
|
|
|
-import thyyxxk.webserver.utils.ReadCardUtil;
|
|
|
-import thyyxxk.webserver.utils.ResultVoUtil;
|
|
|
-
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
-
|
|
|
-/**
|
|
|
- * @author dj
|
|
|
- */
|
|
|
-@Slf4j
|
|
|
-@Service
|
|
|
-public class ReadCardCallbackService {
|
|
|
- private final ReadCardCallbackDao dao;
|
|
|
- private final static int CARD_LENGTH = 32;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- public ReadCardCallbackService(ReadCardCallbackDao dao) {
|
|
|
- this.dao = dao;
|
|
|
- }
|
|
|
-
|
|
|
- public Integer setReadCardResult(String inpatientNo, String result, String cardIden, String cardNo, String indiId) {
|
|
|
- inpatientNo = inpatientNo.replaceAll("/", "");
|
|
|
- if (cardIden != null && cardIden.length() == CARD_LENGTH) {
|
|
|
- log.info("写入读卡信息:update a_patient_mi set card_iden={}, card_no={}, indi_id={} " +
|
|
|
- "where inpatient_no={}", cardIden, cardNo, indiId, inpatientNo);
|
|
|
- dao.updateCardIden(inpatientNo, cardIden, cardNo, indiId);
|
|
|
- }
|
|
|
- ReadCardUtil.instance().put(inpatientNo, result);
|
|
|
- return 1;
|
|
|
- }
|
|
|
-
|
|
|
- public ResultVo<String> readCard(String inpatientNo) {
|
|
|
- int count = 0;
|
|
|
- String result = "wait";
|
|
|
- ReadCardUtil.instance().put(inpatientNo, result);
|
|
|
- do {
|
|
|
- result = ReadCardUtil.instance().get(inpatientNo);
|
|
|
- count++;
|
|
|
- try {
|
|
|
- TimeUnit.MILLISECONDS.sleep(1500);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("读卡抛出异常", e);
|
|
|
- }
|
|
|
- } while ("wait".equals(result) && count < 30);
|
|
|
- log.info("读卡 >>> {}, {}", inpatientNo, result);
|
|
|
- if ("success".equals(result)) {
|
|
|
- return ResultVoUtil.success();
|
|
|
- } else {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR, "读卡失败。");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-}
|