Перейти к основному содержимому

Методы для обращения к веб-серверу

Метод запроса статуса карты​

Параметры запроса:

  • CardFID – заводской идентификатор карты, строка 255 символов.
  • APointID – идентификатор терминала предъявления карты.

Результат запроса:

  • AccessStatus
    • 1 – проход разрешен,
    • 0 – проход запрещен,
    • -1 – нет информации.

Алгоритм:

Идентификация карты

  • Карта не найдена. Вернуть "-1", выход
  • Карта найдена. Проверить FORCEEXIT
    • "1" – Вернуть AccessStatus = "1", выход
    • "0" – Получить тип карты. Проверить EXITSTATE этого типа карты.
      • "0" – вернуть AccessStatus = 1
      • "2" – вернуть AccessStatus = 0
      • "1" – Вычислить долг пациента по CL_CALC_STATUS()
        • Долг есть. Вернуть AccessStatus = 0
        • Долга нет. Вернуть AccessStatus = 1

Текст процедуры:

create or alter procedure ACS_CARD_STATE
(
REQUEST TBLOB,
REQUEST_TYPE TICODE = 0,
FROMGRPID TICODE = -1,
DBPASSWORD TTEXT64 = ''
)
returns
(
RESPONSE TBLOB
)
as
declare epasslogid type of column epasslog.epasslogid;
declare current_uid type of column doctor.dcode;
declare current_filial type of column filials.filid;
declare pcode type of column epasslog.pcode;
declare filial type of column epasslog.filial;
declare forceexit type of column epasslog.forceexit;
declare exitstate type of column epasstype.exitstate;
declare currentgrpid ticode;
declare filialgrpid ticode;
declare dbpath type of column filials.dbpath;
declare cardfid TTEXT255;
declare accessstatus integer;
begin
select current_uid, current_filial from s_session_info into current_uid, current_filial;
response = null;
-- AccessStatus:
-- 1 - выход разрешен
-- 0 - выход запрещен
-- -1 - нет информации
accessstatus = -1;
select first 1 paramvalue from acs_handler_urlencoded_params(:request) where paramkey = 'cardfid' into cardfid;
if (:cardfid > '') then
begin
select repl$grpid from repl$getgrpid into currentgrpid;
select e.epasslogid, e.pcode, e.filial, e.forceexit, iif(e.issuetype = 0, t.exitstate, t.exitstate_companion) exitstate
from epasslog e
left join epasstype t on e.eptid = t.eptid
where e.epassnumber = :cardfid and e.returndate is null and e.cancelstate = 0
into epasslogid, pcode, filial, forceexit, exitstate;
select dbpath, grpid from filials where filid = :filial into dbpath, filialgrpid;
if (:epasslogid is not null) then
begin
if (filialgrpid is distinct from currentgrpid) then
begin
execute statement ('execute procedure acs_card_state(?, ?, ?, ?)') (:request, :request_type, :fromgrpid, :dbpassword)
on external :dbpath as user current_user role current_role password :dbpassword
into response;
end
else
begin
if (:forceexit = 1) then
begin
accessstatus = 1;
end
else
begin
accessstatus = case :exitstate
when 0 then 1
when 2 then 0
when 1 then iif((select check_code from cl_calc_status(:current_uid, :current_filial, 0, :pcode, cast('now' as timestamp))) = 3, 0, 1)
end;
end
end
end
end
if (:response is null) then
response = '{ "AccessStatus": ' || :accessstatus || ' }';
suspend;
end
sql

Описание работы запросов:

Метод получения статус карты доступен по основному URL веб-сервера ACS. Чтобы использовать метод, необходимо отправить по этому URL POST-запрос с заголовком Content-Type: application/x-www-form-urlencoded и параметрами:

  • cardfid – номер карты.
  • apointid – идентификатор терминала.
  • event_type – строковый идентификатор метода, для описываемого метода всегда равен строке card_state.

В ответ сервер пришлет JSON-объект, состоящий из одного поля AccessStatus вида:

{ "AccessStatus": N }
json

где N – число, описывающее результат.

Метод возврата карты в картоприемник​

Входящие параметры:

  • CardFID – идентификатор карты.
  • APointID – идентификатор точки приема карты.

Результат:

  • Status – результат.

Алгоритм:

Идентификация карты по CardFID

  • Если карта не идентифицирована, вернуть Status = -1
  • Если карта идентифицирована, установить EPASSLOG.RETURNDATE = NOW(), EPASSLOG.CANCELSTATE = 2, вернуть Status = 1

Текст процедуры:

create or alter procedure ACS_CARD_RETURN
(
REQUEST TBLOB,
REQUEST_TYPE TICODE = 0,
FROMGRPID TICODE = -1,
DBPASSWORD TTEXT64 = ''
)
returns
(
RESPONSE TBLOB
)
as
declare epasslogid type of column epasslog.epasslogid;
declare filial type of column epasslog.filial;
declare currentgrpid ticode;
declare filialgrpid ticode;
declare dbpath type of column filials.dbpath;
declare cardfid TTEXT255;
declare status integer;
begin
response = null;
-- Status:
-- -1 - карта не идентифицирована
-- 1 - операция выполнена
status = -1;
select first 1 paramvalue from acs_handler_urlencoded_params(:request) where paramkey = 'cardfid' into cardfid;
if (:cardfid > '') then
begin
select repl$grpid from repl$getgrpid into currentgrpid;
select e.epasslogid, e.filial
from epasslog e
where e.epassnumber = :cardfid and e.returndate is null and e.cancelstate = 0
into epasslogid, filial;
if (:epasslogid is not null) then
begin
select dbpath, grpid from filials where filid = :filial into dbpath, filialgrpid;
if (filialgrpid is distinct from currentgrpid) then
begin
execute statement ('execute procedure acs_card_return(?, ?, ?, ?)') (:request, :request_type, :fromgrpid, :dbpassword)
on external :dbpath as user current_user role current_role password :dbpassword
into response;
end
else
begin
update epasslog
set returndate = cast('now' as TDATE), cancelstate = 2
where epasslogid = :epasslogid;
status = 1;
end
end
end
if (:response is null) then
response = '{ "Status": ' || :status || ' }';
suspend;
end
sql

Описание работы запросов:

Метод возврата карты в картоприемник доступен по основному URL веб-сервера ACS. Чтобы использовать метод, необходимо отправить по этому URL POST-запрос с заголовком Content-Type: application/x-www-form-urlencoded и параметрами:

  • cardfid – номер карты.
  • apointid – идентификатор терминала.
  • event_type – строковый идентификатор метода, для описываемого метода всегда равен строке card_return.

В ответ сервер пришлет JSON-объект, состоящий из одного поля Status вида:

{ "Status": N }
json

где N – число, описывающее результат.

Была ли статья полезна?