digital sign
This commit is contained in:
parent
0b2650e17c
commit
016fb3da91
5 changed files with 193 additions and 53 deletions
|
|
@ -59,6 +59,7 @@ import { ProfileEducationHistory } from "../entities/ProfileEducationHistory";
|
|||
import { CreateProfileCertificate, ProfileCertificate } from "../entities/ProfileCertificate";
|
||||
import { ProfileCertificateHistory } from "../entities/ProfileCertificateHistory";
|
||||
import permission from "../interfaces/permission";
|
||||
import { CommandSign } from "../entities/CommandSign";
|
||||
|
||||
@Route("api/v1/org/command")
|
||||
@Tags("Command")
|
||||
|
|
@ -93,6 +94,7 @@ export class CommandController extends Controller {
|
|||
private certificateRepo = AppDataSource.getRepository(ProfileCertificate);
|
||||
private certificateHistoryRepo = AppDataSource.getRepository(ProfileCertificateHistory);
|
||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||
private commandSignRepository = AppDataSource.getRepository(CommandSign);
|
||||
|
||||
/**
|
||||
* API list รายการคำสั่ง
|
||||
|
|
@ -249,9 +251,16 @@ export class CommandController extends Controller {
|
|||
new Brackets((qb) => {
|
||||
qb.where(keyword != null && keyword != "" ? "command.commandNo LIKE :keyword" : "1=1", {
|
||||
keyword: `%${keyword}%`,
|
||||
}).orWhere(keyword != null && keyword != "" ? "command.issue LIKE :keyword" : "1=1", {
|
||||
keyword: `%${keyword}%`,
|
||||
});
|
||||
})
|
||||
.orWhere(keyword != null && keyword != "" ? "command.issue LIKE :keyword" : "1=1", {
|
||||
keyword: `%${keyword}%`,
|
||||
})
|
||||
.orWhere(
|
||||
keyword != null && keyword != "" ? "command.createdFullName LIKE :keyword" : "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("command.createdAt", "DESC")
|
||||
|
|
@ -1219,16 +1228,15 @@ export class CommandController extends Controller {
|
|||
if (issue == null) issue = "...................................";
|
||||
|
||||
let res: any[] = [];
|
||||
if(command.commandRecives.length > 0) {
|
||||
if (command.commandRecives.length > 0) {
|
||||
await new CallAPI()
|
||||
.GetData(request, `/probation/report/command10/appoints/${command.commandRecives[0].refId}`)
|
||||
.then((x) => {
|
||||
res = x.data
|
||||
})
|
||||
.catch((x) => {
|
||||
});
|
||||
.GetData(request, `/probation/report/command10/appoints/${command.commandRecives[0].refId}`)
|
||||
.then((x) => {
|
||||
res = x;
|
||||
})
|
||||
.catch((x) => {});
|
||||
}
|
||||
|
||||
|
||||
let _command = {
|
||||
issue: issue,
|
||||
commandNo: command.commandNo == null ? "" : Extension.ToThaiNumber(command.commandNo),
|
||||
|
|
@ -1253,18 +1261,22 @@ export class CommandController extends Controller {
|
|||
authorizedUserFullName: "...................................",
|
||||
authorizedPosition: "...................................",
|
||||
commandAffectDate: "...................................",
|
||||
name1: res && res.length > 0
|
||||
? `${res[0].name}..........................${res[0].role}`
|
||||
: "",
|
||||
name2: res && res.length > 1
|
||||
? `${res[1].name}..........................${res[1].role}`
|
||||
: "",
|
||||
name3: res && res.length > 2
|
||||
? `${res[2].name}..........................${res[2].role}`
|
||||
: "",
|
||||
name4: res && res.length > 3
|
||||
? `${res[3].name}..........................${res[3].role}`
|
||||
: "",
|
||||
name1:
|
||||
res && res.length > 0
|
||||
? `๑. ${res[0].name}.........${res[0].role}`
|
||||
: "๑. ..........................ประธาน",
|
||||
name2:
|
||||
res && res.length > 1
|
||||
? `๒. ${res[1].name}.........${res[1].role}`
|
||||
: "๒. ..........................กรรมการ",
|
||||
name3:
|
||||
res && res.length > 2
|
||||
? `๓. ${res[2].name}.........${res[2].role}`
|
||||
: "๓. ..........................กรรมการ",
|
||||
name4:
|
||||
res && res.length > 3
|
||||
? `๔. ${res[3].name}.........${res[3].role}`
|
||||
: "๔. ..........................กรรมการ",
|
||||
};
|
||||
|
||||
return new HttpSuccess({
|
||||
|
|
@ -1363,6 +1375,118 @@ export class CommandController extends Controller {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* API รายละเอียดรายการคำสั่ง step
|
||||
*
|
||||
* @summary API รายละเอียดรายการคำสั่ง step
|
||||
*
|
||||
* @param {string} id Id คำสั่ง
|
||||
*/
|
||||
@Get("step/{id}")
|
||||
async GetByIdStep(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionGet(request, "COMMAND");
|
||||
const command = await this.commandRepository.findOne({
|
||||
where: { id },
|
||||
relations: ["commandSigns"],
|
||||
});
|
||||
if (!command) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
|
||||
}
|
||||
|
||||
const _command = command.commandSigns.map((item) => ({
|
||||
id: item.id,
|
||||
prefix: item.prefix,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
position: item.position,
|
||||
profileId: item.profileId,
|
||||
}));
|
||||
return new HttpSuccess(_command);
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขรายการ body คำสั่ง step
|
||||
*
|
||||
* @summary API แก้ไขรายการ body คำสั่ง step
|
||||
*
|
||||
* @param {string} id Id คำสั่ง
|
||||
*/
|
||||
@Put("step-add/{id}")
|
||||
async PutStepAdd(
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
requestBody: {
|
||||
profileId: string;
|
||||
isSignatory: boolean;
|
||||
},
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "COMMAND");
|
||||
const command = await this.commandRepository.findOne({ where: { id: id } });
|
||||
if (!command) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
|
||||
}
|
||||
const profile = await this.profileRepository.findOne({ where: { id: requestBody.profileId } });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งานนี้");
|
||||
}
|
||||
command.status = "PENDING";
|
||||
command.isDraft = true;
|
||||
const commandSign = new CommandSign();
|
||||
commandSign.prefix = profile.prefix;
|
||||
commandSign.firstName = profile.firstName;
|
||||
commandSign.lastName = profile.lastName;
|
||||
commandSign.position = profile.position;
|
||||
commandSign.isSignatory = requestBody.isSignatory;
|
||||
commandSign.profileId = requestBody.profileId;
|
||||
commandSign.commandId = command.id;
|
||||
commandSign.createdUserId = request.user.sub;
|
||||
commandSign.createdFullName = request.user.name;
|
||||
commandSign.createdAt = new Date();
|
||||
commandSign.lastUpdateUserId = request.user.sub;
|
||||
commandSign.lastUpdateFullName = request.user.name;
|
||||
commandSign.lastUpdatedAt = new Date();
|
||||
await this.commandSignRepository.save(commandSign);
|
||||
await this.commandRepository.save(command);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขรายการ body คำสั่ง step-comment
|
||||
*
|
||||
* @summary API แก้ไขรายการ body คำสั่ง step-comment
|
||||
*
|
||||
* @param {string} id Id คำสั่ง
|
||||
*/
|
||||
@Put("step-comment/{id}")
|
||||
async PutStepComment(
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
requestBody: {
|
||||
comment: string;
|
||||
},
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "COMMAND");
|
||||
const commandSign = await this.commandSignRepository.findOne({
|
||||
where: { id: id },
|
||||
relations: ["command"],
|
||||
});
|
||||
if (!commandSign) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
|
||||
}
|
||||
commandSign.comment = requestBody.comment;
|
||||
commandSign.lastUpdateUserId = request.user.sub;
|
||||
commandSign.lastUpdateFullName = request.user.name;
|
||||
commandSign.lastUpdatedAt = new Date();
|
||||
await this.commandSignRepository.save(commandSign);
|
||||
if(commandSign.isSignatory == true)
|
||||
await this.PutSelectPending(commandSign.commandId, { sign: true }, request);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API สร้างรายการ body คำสั่ง
|
||||
*
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@ export class CommandTypeController extends Controller {
|
|||
if (!_commandType) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
if(_commandType.code == "C-PM-10") {
|
||||
let _commandType10: any
|
||||
if (_commandType.code == "C-PM-10") {
|
||||
let _commandType10: any;
|
||||
_commandType10 = {
|
||||
id: _commandType.id,
|
||||
name: _commandType.name,
|
||||
|
|
@ -135,11 +135,11 @@ export class CommandTypeController extends Controller {
|
|||
detailFooter: _commandType.detailFooter,
|
||||
subtitle: _commandType.subtitle,
|
||||
isAttachment: _commandType.isAttachment,
|
||||
name1: "..........................ประธาน",
|
||||
name2: "..........................ผู้บังคับบัญชา",
|
||||
name3: "..........................ผู้ดูแล",
|
||||
name4: "..........................ผู้ดูแล",
|
||||
}
|
||||
name1: "๑. ..........................ประธาน",
|
||||
name2: "๒. ..........................กรรมการ",
|
||||
name3: "๓. ..........................กรรมการ",
|
||||
name4: "๔. ..........................กรรมการ",
|
||||
};
|
||||
_commandType = _commandType10;
|
||||
}
|
||||
return new HttpSuccess(_commandType);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ export class CommandSign extends EntityBase {
|
|||
comment: "เป็นผู้มีอำนาจลงนาม",
|
||||
default: false,
|
||||
})
|
||||
isActive: boolean;
|
||||
isSignatory: boolean;
|
||||
|
||||
@Column({
|
||||
length: 40,
|
||||
|
|
|
|||
|
|
@ -52,30 +52,32 @@ class CallAPI {
|
|||
api_key: process.env.API_KEY,
|
||||
},
|
||||
});
|
||||
if (log) addLogSequence(request, {
|
||||
action: "request",
|
||||
status: "success",
|
||||
description: "connected",
|
||||
request: {
|
||||
method: "POST",
|
||||
url: url,
|
||||
payload: JSON.stringify(sendData),
|
||||
response: JSON.stringify(response.data.result),
|
||||
},
|
||||
});
|
||||
if (log)
|
||||
addLogSequence(request, {
|
||||
action: "request",
|
||||
status: "success",
|
||||
description: "connected",
|
||||
request: {
|
||||
method: "POST",
|
||||
url: url,
|
||||
payload: JSON.stringify(sendData),
|
||||
response: JSON.stringify(response.data.result),
|
||||
},
|
||||
});
|
||||
return response.data.result;
|
||||
} catch (error) {
|
||||
if (log) addLogSequence(request, {
|
||||
action: "request",
|
||||
status: "error",
|
||||
description: "unconnected",
|
||||
request: {
|
||||
method: "POST",
|
||||
url: url,
|
||||
payload: JSON.stringify(sendData),
|
||||
response: JSON.stringify(error),
|
||||
},
|
||||
});
|
||||
if (log)
|
||||
addLogSequence(request, {
|
||||
action: "request",
|
||||
status: "error",
|
||||
description: "unconnected",
|
||||
request: {
|
||||
method: "POST",
|
||||
url: url,
|
||||
payload: JSON.stringify(sendData),
|
||||
response: JSON.stringify(error),
|
||||
},
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
14
src/migration/1730463698383-add_table_commandSign1.ts
Normal file
14
src/migration/1730463698383-add_table_commandSign1.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class AddTableCommandSign11730463698383 implements MigrationInterface {
|
||||
name = 'AddTableCommandSign11730463698383'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`commandSign\` CHANGE \`isActive\` \`isSignatory\` tinyint NOT NULL COMMENT 'เป็นผู้มีอำนาจลงนาม' DEFAULT '0'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`commandSign\` CHANGE \`isSignatory\` \`isActive\` tinyint NOT NULL COMMENT 'เป็นผู้มีอำนาจลงนาม' DEFAULT '0'`);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue