error exe command 40
This commit is contained in:
parent
3f735accdd
commit
e24e5de129
1 changed files with 22 additions and 22 deletions
|
|
@ -6540,13 +6540,11 @@ export class CommandController extends Controller {
|
||||||
}[];
|
}[];
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
// อัปเดตสถานะรวดเดียว
|
|
||||||
await this.posMasterActRepository.update(
|
await this.posMasterActRepository.update(
|
||||||
{ id: In(body.refIds.map((x) => x.refId)) },
|
{ id: In(body.refIds.map((x) => x.refId)) },
|
||||||
{ statusReport: "DONE" },
|
{ statusReport: "DONE" },
|
||||||
);
|
);
|
||||||
|
|
||||||
// ดึงข้อมูลที่จำเป็น
|
|
||||||
const posMasters = await this.posMasterActRepository.find({
|
const posMasters = await this.posMasterActRepository.find({
|
||||||
where: { id: In(body.refIds.map((x) => x.refId)) },
|
where: { id: In(body.refIds.map((x) => x.refId)) },
|
||||||
relations: [
|
relations: [
|
||||||
|
|
@ -6564,7 +6562,6 @@ export class CommandController extends Controller {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
posMasters.map(async (item) => {
|
posMasters.map(async (item) => {
|
||||||
if (item.posMasterChild?.current_holderId) {
|
if (item.posMasterChild?.current_holderId) {
|
||||||
// ปรับ shortName ให้สั้น
|
|
||||||
const shortName =
|
const shortName =
|
||||||
[
|
[
|
||||||
item.posMaster?.orgChild4?.orgChild4ShortName,
|
item.posMaster?.orgChild4?.orgChild4ShortName,
|
||||||
|
|
@ -6572,31 +6569,34 @@ export class CommandController extends Controller {
|
||||||
item.posMaster?.orgChild2?.orgChild2ShortName,
|
item.posMaster?.orgChild2?.orgChild2ShortName,
|
||||||
item.posMaster?.orgChild1?.orgChild1ShortName,
|
item.posMaster?.orgChild1?.orgChild1ShortName,
|
||||||
item.posMaster?.orgRoot?.orgRootShortName,
|
item.posMaster?.orgRoot?.orgRootShortName,
|
||||||
].find(Boolean) || "";
|
].find(Boolean) ?? "";
|
||||||
|
|
||||||
const metaAct = {
|
const metaAct = {
|
||||||
profileId: item.posMasterChild.current_holderId,
|
profileId: item.posMasterChild.current_holderId ?? null,
|
||||||
dateStart: body.refIds[0].commandDateAffect,
|
dateStart: body.refIds[0]?.commandDateAffect ?? null,
|
||||||
dateEnd: null,
|
dateEnd: null,
|
||||||
position: item.posMaster.current_holder.position,
|
position: item.posMaster?.current_holder?.position ?? "-",
|
||||||
status: true,
|
status: true,
|
||||||
commandId: body.refIds[0].commandId,
|
commandId: body.refIds[0]?.commandId ?? null,
|
||||||
createdUserId: req.user.sub,
|
createdUserId: req.user?.sub ?? null,
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user?.name ?? null,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user?.sub ?? null,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user?.name ?? null,
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
lastUpdatedAt: new Date(),
|
lastUpdatedAt: new Date(),
|
||||||
commandNo: body.refIds[0].commandNo,
|
commandNo: body.refIds[0]?.commandNo ?? null,
|
||||||
refCommandNo: `${body.refIds[0].commandNo}/${body.refIds[0].commandYear}`,
|
refCommandNo: `${body.refIds[0]?.commandNo ?? ""}/${body.refIds[0]?.commandYear ?? ""}`,
|
||||||
commandYear: body.refIds[0].commandYear,
|
commandYear: body.refIds[0]?.commandYear ?? null,
|
||||||
posNo: `${shortName} ${item.posMaster.posMasterNo}`,
|
posNo:
|
||||||
|
shortName && item.posMaster?.posMasterNo
|
||||||
|
? `${shortName} ${item.posMaster.posMasterNo}`
|
||||||
|
: item.posMaster?.posMasterNo ?? "-",
|
||||||
posNoAbb: shortName,
|
posNoAbb: shortName,
|
||||||
commandDateAffect: body.refIds[0].commandDateAffect,
|
commandDateAffect: body.refIds[0]?.commandDateAffect ?? null,
|
||||||
commandDateSign: body.refIds[0].commandDateSign,
|
commandDateSign: body.refIds[0]?.commandDateSign ?? null,
|
||||||
commandCode: body.refIds[0].commandCode,
|
commandCode: body.refIds[0]?.commandCode ?? null,
|
||||||
commandName: body.refIds[0].commandName,
|
commandName: body.refIds[0]?.commandName ?? null,
|
||||||
remark: body.refIds[0].remark,
|
remark: body.refIds[0]?.remark ?? null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const dataAct = new ProfileActposition();
|
const dataAct = new ProfileActposition();
|
||||||
|
|
@ -6615,7 +6615,7 @@ export class CommandController extends Controller {
|
||||||
const profileActs = _actposition.map((_data) => ({
|
const profileActs = _actposition.map((_data) => ({
|
||||||
..._data,
|
..._data,
|
||||||
status: false,
|
status: false,
|
||||||
dateEnd: _data.status == true ? new Date() : _data.dateEnd,
|
dateEnd: _data.status === true ? new Date() : _data.dateEnd,
|
||||||
}));
|
}));
|
||||||
await this.actpositionRepository.save(profileActs);
|
await this.actpositionRepository.save(profileActs);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue