Merge branch 'develop' into adiDev
This commit is contained in:
commit
2701359a88
8 changed files with 306 additions and 35 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")
|
||||
|
|
@ -1187,7 +1196,7 @@ export class CommandController extends Controller {
|
|||
await new permission().PermissionGet(request, "COMMAND");
|
||||
const command = await this.commandRepository.findOne({
|
||||
where: { id },
|
||||
relations: ["commandType"],
|
||||
relations: ["commandType", "commandRecives"],
|
||||
});
|
||||
if (!command) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
|
||||
|
|
@ -1217,7 +1226,18 @@ export class CommandController extends Controller {
|
|||
}
|
||||
}
|
||||
if (issue == null) issue = "...................................";
|
||||
const _command = {
|
||||
|
||||
let res: any[] = [];
|
||||
if (command.commandRecives.length > 0) {
|
||||
await new CallAPI()
|
||||
.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),
|
||||
commandYear:
|
||||
|
|
@ -1241,7 +1261,24 @@ 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}`
|
||||
: "๔. ..........................กรรมการ",
|
||||
};
|
||||
|
||||
return new HttpSuccess({
|
||||
template: command.commandType.fileCover,
|
||||
reportName: "docx-report",
|
||||
|
|
@ -1338,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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue