Merge branch 'develop' into working
This commit is contained in:
commit
12b2a2f1fd
3 changed files with 101 additions and 42 deletions
|
|
@ -88,18 +88,6 @@ export class CommandController extends Controller {
|
||||||
) {
|
) {
|
||||||
const [commands, total] = await this.commandRepository
|
const [commands, total] = await this.commandRepository
|
||||||
.createQueryBuilder("command")
|
.createQueryBuilder("command")
|
||||||
.andWhere(
|
|
||||||
new Brackets((qb) => {
|
|
||||||
qb.where(keyword != null && keyword != "" ? "command.commandNo LIKE :keyword" : "1=1", {
|
|
||||||
keyword: `%${keyword}%`,
|
|
||||||
}).orWhere(
|
|
||||||
keyword != null && keyword != "" ? "command.createdFullName LIKE :keyword" : "1=1",
|
|
||||||
{
|
|
||||||
keyword: `%${keyword}%`,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.andWhere(
|
.andWhere(
|
||||||
status != null && status != undefined && status != ""
|
status != null && status != undefined && status != ""
|
||||||
? "command.status IN (:...status)"
|
? "command.status IN (:...status)"
|
||||||
|
|
@ -133,6 +121,18 @@ export class CommandController extends Controller {
|
||||||
: `${commandTypeId}`,
|
: `${commandTypeId}`,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
.andWhere(
|
||||||
|
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}%`,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
)
|
||||||
.orderBy("command.createdAt", "DESC")
|
.orderBy("command.createdAt", "DESC")
|
||||||
.skip((page - 1) * pageSize)
|
.skip((page - 1) * pageSize)
|
||||||
.take(pageSize)
|
.take(pageSize)
|
||||||
|
|
@ -432,13 +432,24 @@ export class CommandController extends Controller {
|
||||||
* @param {string} id Id ผู้ได้รับคำสั่ง
|
* @param {string} id Id ผู้ได้รับคำสั่ง
|
||||||
*/
|
*/
|
||||||
@Delete("tab2/{commandReciveId}")
|
@Delete("tab2/{commandReciveId}")
|
||||||
async DeleteTab2(@Path() commandReciveId: string) {
|
async DeleteTab2(@Path() commandReciveId: string, @Request() request: RequestWithUser) {
|
||||||
const commandRecive = await this.commandReciveRepository.findOne({
|
const commandRecive = await this.commandReciveRepository.findOne({
|
||||||
where: { id: commandReciveId },
|
where: { id: commandReciveId },
|
||||||
|
relations: ["command", "command.commandType"],
|
||||||
});
|
});
|
||||||
if (!commandRecive) {
|
if (!commandRecive) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ได้รับคำสั่ง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ได้รับคำสั่ง");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const path = this.commandTypePath(commandRecive.command.commandType.code);
|
||||||
|
if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ");
|
||||||
|
await new CallAPI()
|
||||||
|
.PostData(request, path + "/delete", {
|
||||||
|
refIds: [commandRecive.refId],
|
||||||
|
})
|
||||||
|
.then(async (res) => {})
|
||||||
|
.catch(() => {});
|
||||||
|
|
||||||
const commandId = commandRecive.commandId;
|
const commandId = commandRecive.commandId;
|
||||||
await this.commandReciveRepository.delete(commandRecive.id);
|
await this.commandReciveRepository.delete(commandRecive.id);
|
||||||
|
|
||||||
|
|
@ -452,6 +463,7 @@ export class CommandController extends Controller {
|
||||||
p.order = i + 1;
|
p.order = i + 1;
|
||||||
await this.commandReciveRepository.save(p);
|
await this.commandReciveRepository.save(p);
|
||||||
});
|
});
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -619,7 +631,6 @@ export class CommandController extends Controller {
|
||||||
if (!command) {
|
if (!command) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ได้รับสำเนาคำสั่ง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ได้รับสำเนาคำสั่ง");
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.commandSendCCRepository.delete({ commandSendId: commandSendId });
|
await this.commandSendCCRepository.delete({ commandSendId: commandSendId });
|
||||||
await this.commandSendRepository.delete(commandSendId);
|
await this.commandSendRepository.delete(commandSendId);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
@ -725,9 +736,10 @@ export class CommandController extends Controller {
|
||||||
* @param {string} id Id คำสั่ง
|
* @param {string} id Id คำสั่ง
|
||||||
*/
|
*/
|
||||||
@Delete("{id}")
|
@Delete("{id}")
|
||||||
async Delete(@Path() id: string) {
|
async Delete(@Path() id: string, @Request() request: RequestWithUser) {
|
||||||
const command = await this.commandRepository.findOne({
|
const command = await this.commandRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
relations: ["commandType", "commandRecives"],
|
||||||
});
|
});
|
||||||
if (!command) {
|
if (!command) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
|
||||||
|
|
@ -735,6 +747,16 @@ export class CommandController extends Controller {
|
||||||
const commandSend = await this.commandSendRepository.find({
|
const commandSend = await this.commandSendRepository.find({
|
||||||
where: { commandId: id },
|
where: { commandId: id },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const path = this.commandTypePath(command.commandType.code);
|
||||||
|
if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ");
|
||||||
|
await new CallAPI()
|
||||||
|
.PostData(request, path + "/delete", {
|
||||||
|
refIds: command.commandRecives.map((x) => x.refId),
|
||||||
|
})
|
||||||
|
.then(async (res) => {})
|
||||||
|
.catch(() => {});
|
||||||
|
|
||||||
await this.commandSendCCRepository.delete({ commandSendId: In(commandSend.map((x) => x.id)) });
|
await this.commandSendCCRepository.delete({ commandSendId: In(commandSend.map((x) => x.id)) });
|
||||||
await this.commandReciveRepository.delete({ commandId: command.id });
|
await this.commandReciveRepository.delete({ commandId: command.id });
|
||||||
await this.commandSendRepository.delete({ commandId: command.id });
|
await this.commandSendRepository.delete({ commandId: command.id });
|
||||||
|
|
@ -873,6 +895,24 @@ export class CommandController extends Controller {
|
||||||
command.isSign = true;
|
command.isSign = true;
|
||||||
if (command.commandExcecuteDate == null)
|
if (command.commandExcecuteDate == null)
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบวันที่คำสั่งมีผล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบวันที่คำสั่งมีผล");
|
||||||
|
|
||||||
|
let profiles = command.commandRecives
|
||||||
|
.filter((x) => x.profileId != null)
|
||||||
|
.map(async (x) => x.profileId);
|
||||||
|
|
||||||
|
await new CallAPI()
|
||||||
|
.PostData(request, "/placement/noti/profiles", {
|
||||||
|
subject: `${command.issue}`,
|
||||||
|
body: `${command.issue}`,
|
||||||
|
receiverUserId: profiles,
|
||||||
|
payload: "",//แนบไฟล์
|
||||||
|
isSendMail: true,
|
||||||
|
isSendInbox: true,
|
||||||
|
receiveDate: command.commandExcecuteDate,
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Error calling API:", error);
|
||||||
|
});
|
||||||
if (
|
if (
|
||||||
new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()) <
|
new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()) <
|
||||||
new Date(
|
new Date(
|
||||||
|
|
@ -979,20 +1019,22 @@ export class CommandController extends Controller {
|
||||||
|
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.PostData(request, path + "/attachment", {
|
.PostData(request, path + "/attachment", {
|
||||||
refIds: command.commandRecives.map((x) => ({
|
refIds: command.commandRecives
|
||||||
refId: x.refId,
|
.filter((x) => x.refId != null)
|
||||||
Sequence: x.order,
|
.map((x) => ({
|
||||||
CitizenId: x.citizenId,
|
refId: x.refId,
|
||||||
Prefix: x.prefix,
|
Sequence: x.order,
|
||||||
FirstName: x.firstName,
|
CitizenId: x.citizenId,
|
||||||
LastName: x.lastName,
|
Prefix: x.prefix,
|
||||||
Amount: x.amount,
|
FirstName: x.firstName,
|
||||||
PositionSalaryAmount: x.positionSalaryAmount,
|
LastName: x.lastName,
|
||||||
MouthSalaryAmount: x.mouthSalaryAmount,
|
Amount: x.amount,
|
||||||
RemarkHorizontal: x.remarkHorizontal,
|
PositionSalaryAmount: x.positionSalaryAmount,
|
||||||
RemarkVertical: x.remarkVertical,
|
MouthSalaryAmount: x.mouthSalaryAmount,
|
||||||
CommandYear: command.commandYear,
|
RemarkHorizontal: x.remarkHorizontal,
|
||||||
})),
|
RemarkVertical: x.remarkVertical,
|
||||||
|
CommandYear: command.commandYear,
|
||||||
|
})),
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
|
|
@ -1025,6 +1067,7 @@ export class CommandController extends Controller {
|
||||||
commandExcecuteDate?: Date | null;
|
commandExcecuteDate?: Date | null;
|
||||||
persons: {
|
persons: {
|
||||||
refId: string;
|
refId: string;
|
||||||
|
profileId?: string|null;
|
||||||
citizenId: string;
|
citizenId: string;
|
||||||
prefix: string;
|
prefix: string;
|
||||||
firstName: string;
|
firstName: string;
|
||||||
|
|
@ -1035,7 +1078,7 @@ export class CommandController extends Controller {
|
||||||
) {
|
) {
|
||||||
let command = new Command();
|
let command = new Command();
|
||||||
let commandCode = null;
|
let commandCode = null;
|
||||||
let null_:any = null
|
let null_: any = null;
|
||||||
if (
|
if (
|
||||||
requestBody.commandId != undefined &&
|
requestBody.commandId != undefined &&
|
||||||
requestBody.commandId != null &&
|
requestBody.commandId != null &&
|
||||||
|
|
@ -1074,13 +1117,13 @@ export class CommandController extends Controller {
|
||||||
command.isAttachment = commandType.isAttachment;
|
command.isAttachment = commandType.isAttachment;
|
||||||
command.status = "NEW";
|
command.status = "NEW";
|
||||||
command.issue = commandType.name;
|
command.issue = commandType.name;
|
||||||
command.commandAffectDate = requestBody.commandAffectDate
|
(command.commandAffectDate = requestBody.commandAffectDate
|
||||||
? new Date(requestBody.commandAffectDate)
|
? new Date(requestBody.commandAffectDate)
|
||||||
: null_,
|
: null_),
|
||||||
command.commandExcecuteDate = requestBody.commandExcecuteDate
|
(command.commandExcecuteDate = requestBody.commandExcecuteDate
|
||||||
? new Date(requestBody.commandExcecuteDate)
|
? new Date(requestBody.commandExcecuteDate)
|
||||||
: null_,
|
: null_),
|
||||||
command.createdUserId = request.user.sub;
|
(command.createdUserId = request.user.sub);
|
||||||
command.createdFullName = request.user.name;
|
command.createdFullName = request.user.name;
|
||||||
command.createdAt = new Date();
|
command.createdAt = new Date();
|
||||||
command.lastUpdateUserId = request.user.sub;
|
command.lastUpdateUserId = request.user.sub;
|
||||||
|
|
@ -1093,7 +1136,7 @@ export class CommandController extends Controller {
|
||||||
if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ");
|
if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ");
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.PostData(request, path, {
|
.PostData(request, path, {
|
||||||
refIds: requestBody.persons.map((x) => x.refId),
|
refIds: requestBody.persons.filter((x) => x.refId != null).map((x) => x.refId),
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
let order =
|
let order =
|
||||||
|
|
|
||||||
|
|
@ -101,11 +101,13 @@ export class CommandRecive extends EntityBase {
|
||||||
@JoinColumn({ name: "commandId" })
|
@JoinColumn({ name: "commandId" })
|
||||||
command: Command;
|
command: Command;
|
||||||
|
|
||||||
// @Column({
|
@Column({
|
||||||
// length: 40,
|
nullable: true,
|
||||||
// comment: "คีย์นอก(FK)ของตาราง profile",
|
length: 40,
|
||||||
// })
|
comment: "คีย์นอก(FK)ของตาราง profile",
|
||||||
// profileId: string;
|
default: null,
|
||||||
|
})
|
||||||
|
profileId: string;
|
||||||
|
|
||||||
// @ManyToOne(() => Profile, (profile) => profile.commandRecives)
|
// @ManyToOne(() => Profile, (profile) => profile.commandRecives)
|
||||||
// @JoinColumn({ name: "profileId" })
|
// @JoinColumn({ name: "profileId" })
|
||||||
|
|
|
||||||
14
src/migration/1728318691161-add_table_assign1.ts
Normal file
14
src/migration/1728318691161-add_table_assign1.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class AddTableAssign11728318691161 implements MigrationInterface {
|
||||||
|
name = 'AddTableAssign11728318691161'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`commandRecive\` ADD \`profileId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง profile'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`commandRecive\` DROP COLUMN \`profileId\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue