diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 91a95124..4b030940 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -19,7 +19,7 @@ import HttpSuccess from "../interfaces/http-success"; import HttpStatusCode from "../interfaces/http-status"; import HttpError from "../interfaces/http-error"; import { Command } from "../entities/Command"; -import { Brackets, LessThan, MoreThan, Double, In, Not ,Between } from "typeorm"; +import { Brackets, LessThan, MoreThan, Double, In, Not, Between } from "typeorm"; import { CommandType } from "../entities/CommandType"; import { CommandSend } from "../entities/CommandSend"; import { Profile, CreateProfileAllFields } from "../entities/Profile"; @@ -1013,11 +1013,10 @@ export class CommandController extends Controller { if (command.commandExcecuteDate == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบวันที่คำสั่งมีผล"); - let profiles = command && command.commandRecives.length > 0 - ? command.commandRecives - .filter((x) => x.profileId != null) - .map((x) => x.profileId) - : []; + let profiles = + command && command.commandRecives.length > 0 + ? command.commandRecives.filter((x) => x.profileId != null).map((x) => x.profileId) + : []; await new CallAPI() .PostData(request, "/placement/noti/profiles", { @@ -1073,12 +1072,12 @@ export class CommandController extends Controller { const command = await this.commandRepository.find({ relations: ["commandType", "commandRecives"], - where:{ + where: { commandExcecuteDate: Between(today, tomorrow), - status: "WAITING" - } + status: "WAITING", + }, }); - + const data = { client_id: "gettoken", client_secret: process.env.AUTH_ACCOUNT_SECRET, @@ -1100,27 +1099,27 @@ export class CommandController extends Controller { ]); if (_data == null) { return new HttpError(HttpStatus.UNAUTHORIZED, "ชื่อผู้ใช้งานหรือรหัสผ่านไม่ถูกต้อง"); - } + } command.forEach(async (x) => { - const path = this.commandTypePath(x.commandType.code); - if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); - const msg = { - data: { - id: x.id, - status: "REPORTED", - lastUpdateUserId: "system", - lastUpdateFullName: "system", - // lastUpdateUserId: _data.user.sub, - // lastUpdateFullName: _data.user.name, - lastUpdatedAt: new Date(), - }, - user: _data.user, - token: _data.access_token, - }; - sendToQueue(msg); - }) - + const path = this.commandTypePath(x.commandType.code); + if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); + const msg = { + data: { + id: x.id, + status: "REPORTED", + lastUpdateUserId: "system", + lastUpdateFullName: "system", + // lastUpdateUserId: _data.user.sub, + // lastUpdateFullName: _data.user.name, + lastUpdatedAt: new Date(), + }, + user: _data.user, + token: _data.access_token, + }; + sendToQueue(msg); + }); + return new HttpSuccess(); } @@ -2782,7 +2781,7 @@ export class CommandController extends Controller { case "C-PM-09": return "/retirement/other/out/report"; case "C-PM-10": - return "/xxxxxx"; + return "/probation/report/command10/officer/report"; case "C-PM-11": return "/probation/report/command11/officer/report"; case "C-PM-12": diff --git a/src/controllers/WorkflowController.ts b/src/controllers/WorkflowController.ts index 39410525..3bbd31dc 100644 --- a/src/controllers/WorkflowController.ts +++ b/src/controllers/WorkflowController.ts @@ -1,4 +1,4 @@ -import { Body, Controller, Get, Path, Post, Request, Route, Security, Tags } from "tsoa"; +import { Body, Controller, Get, Post, Request, Route, Security, Tags } from "tsoa"; import { AppDataSource } from "../database/data-source"; import { RequestWithUser } from "../middlewares/user"; import HttpError from "../interfaces/http-error"; @@ -14,7 +14,6 @@ import { StateUserComment } from "../entities/StateUserComment"; import { MetaWorkflow } from "../entities/MetaWorkflow"; import { MetaState } from "../entities/MetaState"; import { MetaStateOperator } from "../entities/MetaStateOperator"; -import { PosMasterAssign } from "../entities/PosMasterAssign"; import { PosMaster } from "../entities/PosMaster"; import { IsNull, Not } from "typeorm";