แก้สถ่นะออกคำสั่ง
This commit is contained in:
parent
26a16c6833
commit
9da9b812c1
1 changed files with 128 additions and 12 deletions
|
|
@ -658,6 +658,94 @@ export class CommandController extends Controller {
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API ลบรายการผู้ได้รับคำสั่ง
|
||||||
|
*
|
||||||
|
* @summary API ลบรายการผู้ได้รับคำสั่ง
|
||||||
|
*
|
||||||
|
* @param {string} id Id ผู้ได้รับคำสั่ง
|
||||||
|
*/
|
||||||
|
@Delete("tab2Cancel17/{refId}")
|
||||||
|
async DeleteTab2Cancel17(@Path() refId: string, @Request() request: RequestWithUser) {
|
||||||
|
await new permission().PermissionUpdate(request, "COMMAND");
|
||||||
|
const commandRecive = await this.commandReciveRepository.findOne({
|
||||||
|
where: { refId: refId, command: { commandType: { commandCode: "C-PM-17" } } },
|
||||||
|
relations: ["command", "command.commandType"],
|
||||||
|
});
|
||||||
|
if (!commandRecive) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ได้รับคำสั่ง");
|
||||||
|
}
|
||||||
|
|
||||||
|
const path = 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;
|
||||||
|
await this.commandReciveRepository.delete(commandRecive.id);
|
||||||
|
|
||||||
|
const commandReciveList = await this.commandReciveRepository.find({
|
||||||
|
where: {
|
||||||
|
commandId: commandId,
|
||||||
|
},
|
||||||
|
order: { order: "ASC" },
|
||||||
|
});
|
||||||
|
commandReciveList.map(async (p, i) => {
|
||||||
|
p.order = i + 1;
|
||||||
|
await this.commandReciveRepository.save(p);
|
||||||
|
});
|
||||||
|
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API ลบรายการผู้ได้รับคำสั่ง
|
||||||
|
*
|
||||||
|
* @summary API ลบรายการผู้ได้รับคำสั่ง
|
||||||
|
*
|
||||||
|
* @param {string} id Id ผู้ได้รับคำสั่ง
|
||||||
|
*/
|
||||||
|
@Delete("tab2Cancel23/{refId}")
|
||||||
|
async DeleteTab2Cancel23(@Path() refId: string, @Request() request: RequestWithUser) {
|
||||||
|
await new permission().PermissionUpdate(request, "COMMAND");
|
||||||
|
const commandRecive = await this.commandReciveRepository.findOne({
|
||||||
|
where: { refId: refId, command: { commandType: { commandCode: "C-PM-23" } } },
|
||||||
|
relations: ["command", "command.commandType"],
|
||||||
|
});
|
||||||
|
if (!commandRecive) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ได้รับคำสั่ง");
|
||||||
|
}
|
||||||
|
|
||||||
|
const path = 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;
|
||||||
|
await this.commandReciveRepository.delete(commandRecive.id);
|
||||||
|
|
||||||
|
const commandReciveList = await this.commandReciveRepository.find({
|
||||||
|
where: {
|
||||||
|
commandId: commandId,
|
||||||
|
},
|
||||||
|
order: { order: "ASC" },
|
||||||
|
});
|
||||||
|
commandReciveList.map(async (p, i) => {
|
||||||
|
p.order = i + 1;
|
||||||
|
await this.commandReciveRepository.save(p);
|
||||||
|
});
|
||||||
|
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API รายละเอียดรายการคำสั่ง tab3
|
* API รายละเอียดรายการคำสั่ง tab3
|
||||||
*
|
*
|
||||||
|
|
@ -1171,6 +1259,15 @@ export class CommandController extends Controller {
|
||||||
command.lastUpdateUserId = request.user.sub;
|
command.lastUpdateUserId = request.user.sub;
|
||||||
command.lastUpdateFullName = request.user.name;
|
command.lastUpdateFullName = request.user.name;
|
||||||
command.lastUpdatedAt = new Date();
|
command.lastUpdatedAt = new Date();
|
||||||
|
const path = commandTypePath(command.commandType.code);
|
||||||
|
if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ");
|
||||||
|
await new CallAPI()
|
||||||
|
.PostData(request, path, {
|
||||||
|
refIds: command.commandRecives.filter((x) => x.refId != null).map((x) => x.refId),
|
||||||
|
status: "WAITING",
|
||||||
|
})
|
||||||
|
.then(async (res) => {})
|
||||||
|
.catch(() => {});
|
||||||
await this.commandRepository.save(command);
|
await this.commandRepository.save(command);
|
||||||
} else {
|
} else {
|
||||||
const path = commandTypePath(command.commandType.code);
|
const path = commandTypePath(command.commandType.code);
|
||||||
|
|
@ -2015,6 +2112,7 @@ export class CommandController extends Controller {
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.PostData(request, path, {
|
.PostData(request, path, {
|
||||||
refIds: requestBody.persons.filter((x) => x.refId != null).map((x) => x.refId),
|
refIds: requestBody.persons.filter((x) => x.refId != null).map((x) => x.refId),
|
||||||
|
status: "REPORT",
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
let order =
|
let order =
|
||||||
|
|
@ -2647,11 +2745,10 @@ export class CommandController extends Controller {
|
||||||
firstName: _posMasterOfficer?.current_holder.firstName,
|
firstName: _posMasterOfficer?.current_holder.firstName,
|
||||||
lastName: _posMasterOfficer?.current_holder.lastName,
|
lastName: _posMasterOfficer?.current_holder.lastName,
|
||||||
// organizationName: _posMasterOfficer.orgRoot ? _posMasterOfficer.orgRoot.orgRootName : _null,
|
// organizationName: _posMasterOfficer.orgRoot ? _posMasterOfficer.orgRoot.orgRootName : _null,
|
||||||
organizationName: _posMasterOfficer.orgChild1
|
organizationName: _posMasterOfficer.orgChild1
|
||||||
? _posMasterOfficer.orgChild1.orgChild1Name + "\n" +
|
? _posMasterOfficer.orgChild1.orgChild1Name + "\n" + _posMasterOfficer.orgRoot.orgRootName
|
||||||
_posMasterOfficer.orgRoot.orgRootName
|
|
||||||
: _posMasterOfficer.orgChild1 == null && _posMasterOfficer.orgRoot
|
: _posMasterOfficer.orgChild1 == null && _posMasterOfficer.orgRoot
|
||||||
? _posMasterOfficer.orgRoot.orgRootName
|
? _posMasterOfficer.orgRoot.orgRootName
|
||||||
: _null,
|
: _null,
|
||||||
positionName: _posMasterOfficer?.current_holder.position ?? _null,
|
positionName: _posMasterOfficer?.current_holder.position ?? _null,
|
||||||
profileId: _posMasterOfficer?.current_holder.id ?? _null,
|
profileId: _posMasterOfficer?.current_holder.id ?? _null,
|
||||||
|
|
@ -2751,15 +2848,34 @@ export class CommandController extends Controller {
|
||||||
firstName: x?.current_holder.firstName,
|
firstName: x?.current_holder.firstName,
|
||||||
lastName: x?.current_holder.lastName,
|
lastName: x?.current_holder.lastName,
|
||||||
// organizationName: x.orgRoot ? x.orgRoot.orgRootName : _null,
|
// organizationName: x.orgRoot ? x.orgRoot.orgRootName : _null,
|
||||||
organizationName: x.orgChild1 == null
|
organizationName:
|
||||||
? x.orgRoot.orgRootName
|
x.orgChild1 == null
|
||||||
: x.orgChild2 == null
|
? x.orgRoot.orgRootName
|
||||||
|
: x.orgChild2 == null
|
||||||
? x.orgChild1.orgChild1Name + "\n" + x.orgRoot.orgRootName
|
? x.orgChild1.orgChild1Name + "\n" + x.orgRoot.orgRootName
|
||||||
: x.orgChild3 == null
|
: x.orgChild3 == null
|
||||||
? x.orgChild2.orgChild2Name + "\n" + x.orgChild1.orgChild1Name + "\n" + x.orgRoot.orgRootName
|
? x.orgChild2.orgChild2Name +
|
||||||
: x.orgChild4 == null
|
"\n" +
|
||||||
? x.orgChild3.orgChild3Name + "\n" + x.orgChild2.orgChild2Name + "\n" + x.orgChild1.orgChild1Name + "\n" + x.orgRoot.orgRootName
|
x.orgChild1.orgChild1Name +
|
||||||
: x.orgChild4.orgChild4Name + "\n" + x.orgChild3.orgChild3Name + "\n" + x.orgChild2.orgChild2Name + "\n" + x.orgChild1.orgChild1Name + "\n" + x.orgRoot.orgRootName,
|
"\n" +
|
||||||
|
x.orgRoot.orgRootName
|
||||||
|
: x.orgChild4 == null
|
||||||
|
? x.orgChild3.orgChild3Name +
|
||||||
|
"\n" +
|
||||||
|
x.orgChild2.orgChild2Name +
|
||||||
|
"\n" +
|
||||||
|
x.orgChild1.orgChild1Name +
|
||||||
|
"\n" +
|
||||||
|
x.orgRoot.orgRootName
|
||||||
|
: x.orgChild4.orgChild4Name +
|
||||||
|
"\n" +
|
||||||
|
x.orgChild3.orgChild3Name +
|
||||||
|
"\n" +
|
||||||
|
x.orgChild2.orgChild2Name +
|
||||||
|
"\n" +
|
||||||
|
x.orgChild1.orgChild1Name +
|
||||||
|
"\n" +
|
||||||
|
x.orgRoot.orgRootName,
|
||||||
positionName: x?.current_holder.position ?? _null,
|
positionName: x?.current_holder.position ?? _null,
|
||||||
profileId: x?.current_holder.id ?? _null,
|
profileId: x?.current_holder.id ?? _null,
|
||||||
});
|
});
|
||||||
|
|
@ -3163,7 +3279,7 @@ export class CommandController extends Controller {
|
||||||
profile.leaveType = _null;
|
profile.leaveType = _null;
|
||||||
profile.position = item.positionNameNew ?? _null;
|
profile.position = item.positionNameNew ?? _null;
|
||||||
profile.posTypeId = item.positionTypeNew ?? _null;
|
profile.posTypeId = item.positionTypeNew ?? _null;
|
||||||
profile.posLevelId = item.positionLevelNew ?? _null
|
profile.posLevelId = item.positionLevelNew ?? _null;
|
||||||
}
|
}
|
||||||
let userKeycloakId;
|
let userKeycloakId;
|
||||||
const checkUser = await getUserByUsername(profile.citizenId);
|
const checkUser = await getUserByUsername(profile.citizenId);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue