mirror of
https://github.com/sergeyyarkov/asu_tools_service.git
synced 2026-10-11 10:29:22 +03:00
refactor
This commit is contained in:
parent
821ee79873
commit
9e7daddf51
@ -47,22 +47,10 @@ export default async (ctx) => {
|
|||||||
|
|
||||||
let parseResultCount = { equipments: 0, applicants: 0, executors: 0, reportsFullfilled: 0 };
|
let parseResultCount = { equipments: 0, applicants: 0, executors: 0, reportsFullfilled: 0 };
|
||||||
|
|
||||||
// res.res.setHeaders(
|
|
||||||
// new Headers({
|
|
||||||
// Connection: "keep-alive",
|
|
||||||
// "Cache-Control": "no-cache",
|
|
||||||
// "Content-Type": "text/event-stream"
|
|
||||||
// })
|
|
||||||
// );
|
|
||||||
|
|
||||||
// ctx.res.res.on("close", () => (isReqClosed = true));
|
|
||||||
|
|
||||||
if (excelFilePath) {
|
if (excelFilePath) {
|
||||||
const workbook = xlsx.readFile(excelFilePath, xlsxParseOptions);
|
const workbook = xlsx.readFile(excelFilePath, xlsxParseOptions);
|
||||||
const sheet = workbook.Sheets[sheetName];
|
const sheet = workbook.Sheets[sheetName];
|
||||||
|
|
||||||
console.log();
|
|
||||||
|
|
||||||
if (!sheet) throw new Error("Invalid reports workbook.", { cause: { statusCode: 400 } });
|
if (!sheet) throw new Error("Invalid reports workbook.", { cause: { statusCode: 400 } });
|
||||||
|
|
||||||
res.sendJson({ message: "OK" });
|
res.sendJson({ message: "OK" });
|
||||||
|
|||||||
@ -1,7 +1,13 @@
|
|||||||
import { clients } from "#root/index.js";
|
import { clients } from "#root/index.js";
|
||||||
import crypto from "node:crypto";
|
import crypto from "node:crypto";
|
||||||
|
|
||||||
/** @type {import("#root/http-server/types/http-server.js").HttpRouteHandler} */
|
/**
|
||||||
|
* URL: /api/reports_status_parse
|
||||||
|
* Method: GET
|
||||||
|
* Description: Отправляет частями в формате JSON информацию о текущем статусе парсинга отчетов
|
||||||
|
*
|
||||||
|
* @type {import("#root/http-server/types/http-server.js").HttpRouteHandler}
|
||||||
|
*/
|
||||||
export default (ctx) => {
|
export default (ctx) => {
|
||||||
const { res } = ctx;
|
const { res } = ctx;
|
||||||
const clientId = crypto.randomUUID();
|
const clientId = crypto.randomUUID();
|
||||||
|
|||||||
@ -11,7 +11,13 @@ var reportItemSchema = yup.object({
|
|||||||
executor_ids: yup.array(yup.number()).required()
|
executor_ids: yup.array(yup.number()).required()
|
||||||
});
|
});
|
||||||
|
|
||||||
/** @type {import("#root/http-server/types/http-server.js").HttpRouteHandler} */
|
/**
|
||||||
|
* URL: /api/reports_sync
|
||||||
|
* Method: POST
|
||||||
|
* Description: Синхронизирует принятые отчеты с отчетами в БД
|
||||||
|
*
|
||||||
|
* @type {import("#root/http-server/types/http-server.js").HttpRouteHandler}
|
||||||
|
*/
|
||||||
export default async ({ res, data }) => {
|
export default async ({ res, data }) => {
|
||||||
const inputSchema = yup.object({ reports: yup.array(reportItemSchema).required() }).required();
|
const inputSchema = yup.object({ reports: yup.array(reportItemSchema).required() }).required();
|
||||||
|
|
||||||
@ -19,5 +25,7 @@ export default async ({ res, data }) => {
|
|||||||
throw new BadRequestError(err.message);
|
throw new BadRequestError(err.message);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO ...
|
||||||
|
|
||||||
res.sendJson({ data });
|
res.sendJson({ data });
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user