Merge branch 'develop' into adiDev
This commit is contained in:
commit
28492f870f
4 changed files with 111 additions and 9 deletions
|
|
@ -18,7 +18,7 @@ import HttpSuccess from "../interfaces/http-success";
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import { Command } from "../entities/Command";
|
import { Command } from "../entities/Command";
|
||||||
import { Brackets, LessThan, MoreThan, Double, In, Between } from "typeorm";
|
import { Brackets, LessThan, MoreThan, Double, In, Between, IsNull, Not } from "typeorm";
|
||||||
import { CommandType } from "../entities/CommandType";
|
import { CommandType } from "../entities/CommandType";
|
||||||
import { CommandSend } from "../entities/CommandSend";
|
import { CommandSend } from "../entities/CommandSend";
|
||||||
import { Profile, CreateProfileAllFields } from "../entities/Profile";
|
import { Profile, CreateProfileAllFields } from "../entities/Profile";
|
||||||
|
|
@ -1429,6 +1429,53 @@ export class CommandController extends Controller {
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
|
|
||||||
|
if (requestBody.persons != undefined && requestBody.persons.length > 0) {
|
||||||
|
const posMaster = await this.posMasterRepository.find({
|
||||||
|
where: {
|
||||||
|
current_holderId: In(requestBody.persons.map((x) => x.profileId)),
|
||||||
|
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
|
},
|
||||||
|
select: ["orgRootId"],
|
||||||
|
});
|
||||||
|
|
||||||
|
const _posMaster = await this.posMasterRepository.find({
|
||||||
|
where: {
|
||||||
|
orgRootId: In(posMaster.map((x) => x.orgRootId)),
|
||||||
|
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
|
isDirector: true,
|
||||||
|
current_holderId: Not(IsNull()),
|
||||||
|
},
|
||||||
|
relations: ["current_holder", "orgRoot"],
|
||||||
|
});
|
||||||
|
await Promise.all(
|
||||||
|
_posMaster.map(async (item) => {
|
||||||
|
const _commandSend = await this.commandSendRepository.findOne({
|
||||||
|
where: {
|
||||||
|
commandId: command.id,
|
||||||
|
profileId: item.current_holder.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (_commandSend) return;
|
||||||
|
let commandSend = new CommandSend();
|
||||||
|
commandSend.citizenId = item.current_holder.citizenId;
|
||||||
|
commandSend.prefix = item.current_holder.prefix;
|
||||||
|
commandSend.firstName = item.current_holder.firstName;
|
||||||
|
commandSend.lastName = item.current_holder.lastName;
|
||||||
|
commandSend.position = item.current_holder.position;
|
||||||
|
commandSend.org = item.orgRoot.orgRootName;
|
||||||
|
commandSend.profileId = item.current_holder.id;
|
||||||
|
commandSend.commandId = command.id;
|
||||||
|
commandSend.createdUserId = request.user.sub;
|
||||||
|
commandSend.createdFullName = request.user.name;
|
||||||
|
commandSend.createdAt = new Date();
|
||||||
|
commandSend.lastUpdateUserId = request.user.sub;
|
||||||
|
commandSend.lastUpdateFullName = request.user.name;
|
||||||
|
commandSend.lastUpdatedAt = new Date();
|
||||||
|
await this.commandSendRepository.save(commandSend);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
return new HttpSuccess(command.id);
|
return new HttpSuccess(command.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1487,7 +1534,7 @@ export class CommandController extends Controller {
|
||||||
Object.assign(history, { ...data, id: undefined });
|
Object.assign(history, { ...data, id: undefined });
|
||||||
await this.salaryRepo.save(data, { data: req });
|
await this.salaryRepo.save(data, { data: req });
|
||||||
setLogDataDiff(req, { before, after: data });
|
setLogDataDiff(req, { before, after: data });
|
||||||
history.commandId = item.commandId??_null;
|
history.commandId = item.commandId ?? _null;
|
||||||
await this.salaryHistoryRepo.save(history, { data: req });
|
await this.salaryHistoryRepo.save(history, { data: req });
|
||||||
|
|
||||||
const posMaster = await this.posMasterRepository.findOne({
|
const posMaster = await this.posMasterRepository.findOne({
|
||||||
|
|
@ -1707,6 +1754,7 @@ export class CommandController extends Controller {
|
||||||
leaveReason?: string | null;
|
leaveReason?: string | null;
|
||||||
dateLeave?: Date | null;
|
dateLeave?: Date | null;
|
||||||
commandId?: string | null;
|
commandId?: string | null;
|
||||||
|
isGovernment?: boolean | null;
|
||||||
}[];
|
}[];
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
|
|
@ -1737,7 +1785,7 @@ export class CommandController extends Controller {
|
||||||
Object.assign(data, { ...item, ...meta });
|
Object.assign(data, { ...item, ...meta });
|
||||||
const history = new ProfileSalaryHistory();
|
const history = new ProfileSalaryHistory();
|
||||||
Object.assign(history, { ...data, id: undefined });
|
Object.assign(history, { ...data, id: undefined });
|
||||||
|
data.dateGovernment = meta.createdAt;
|
||||||
await this.salaryRepo.save(data, { data: req });
|
await this.salaryRepo.save(data, { data: req });
|
||||||
setLogDataDiff(req, { before, after: data });
|
setLogDataDiff(req, { before, after: data });
|
||||||
history.profileSalaryId = data.id;
|
history.profileSalaryId = data.id;
|
||||||
|
|
@ -1780,6 +1828,7 @@ export class CommandController extends Controller {
|
||||||
isLeave: boolean;
|
isLeave: boolean;
|
||||||
leaveReason?: string | null;
|
leaveReason?: string | null;
|
||||||
dateLeave?: Date | null;
|
dateLeave?: Date | null;
|
||||||
|
isGovernment?: boolean | null;
|
||||||
}[];
|
}[];
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
|
|
@ -1815,7 +1864,7 @@ export class CommandController extends Controller {
|
||||||
});
|
});
|
||||||
const history = new ProfileSalaryHistory();
|
const history = new ProfileSalaryHistory();
|
||||||
Object.assign(history, { ...data, id: undefined });
|
Object.assign(history, { ...data, id: undefined });
|
||||||
|
data.dateGovernment = meta.createdAt;
|
||||||
await this.salaryRepo.save(data, { data: req });
|
await this.salaryRepo.save(data, { data: req });
|
||||||
setLogDataDiff(req, { before, after: data });
|
setLogDataDiff(req, { before, after: data });
|
||||||
history.profileSalaryId = data.id;
|
history.profileSalaryId = data.id;
|
||||||
|
|
@ -1984,6 +2033,7 @@ export class CommandController extends Controller {
|
||||||
amount?: Double | null;
|
amount?: Double | null;
|
||||||
positionSalaryAmount?: Double | null;
|
positionSalaryAmount?: Double | null;
|
||||||
mouthSalaryAmount?: Double | null;
|
mouthSalaryAmount?: Double | null;
|
||||||
|
isGovernment?: boolean | null;
|
||||||
}[];
|
}[];
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
|
|
@ -2036,6 +2086,8 @@ export class CommandController extends Controller {
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
lastUpdatedAt: new Date(),
|
lastUpdatedAt: new Date(),
|
||||||
|
dateGovernment: new Date(),
|
||||||
|
isGovernment: item.isGovernment,
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, meta);
|
Object.assign(data, meta);
|
||||||
|
|
@ -2181,6 +2233,7 @@ export class CommandController extends Controller {
|
||||||
amount?: Double | null;
|
amount?: Double | null;
|
||||||
positionSalaryAmount?: Double | null;
|
positionSalaryAmount?: Double | null;
|
||||||
mouthSalaryAmount?: Double | null;
|
mouthSalaryAmount?: Double | null;
|
||||||
|
isGovernment?: boolean | null;
|
||||||
}[];
|
}[];
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
|
|
@ -2246,6 +2299,8 @@ export class CommandController extends Controller {
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
lastUpdatedAt: new Date(),
|
lastUpdatedAt: new Date(),
|
||||||
|
dateGovernment: new Date(),
|
||||||
|
isGovernment: item.isGovernment,
|
||||||
});
|
});
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.profileRepository.save(_profile),
|
this.profileRepository.save(_profile),
|
||||||
|
|
@ -2390,6 +2445,7 @@ export class CommandController extends Controller {
|
||||||
Object.assign(salaryHistory, { ...profileSal, id: undefined });
|
Object.assign(salaryHistory, { ...profileSal, id: undefined });
|
||||||
profileSal.order = dest_item == null ? 1 : dest_item.order + 1;
|
profileSal.order = dest_item == null ? 1 : dest_item.order + 1;
|
||||||
profileSal.profileId = profile.id;
|
profileSal.profileId = profile.id;
|
||||||
|
profileSal.dateGovernment = meta.createdAt;
|
||||||
await this.salaryRepo.save(profileSal, { data: req });
|
await this.salaryRepo.save(profileSal, { data: req });
|
||||||
setLogDataDiff(req, { before, after: profileSal });
|
setLogDataDiff(req, { before, after: profileSal });
|
||||||
salaryHistory.profileSalaryId = profileSal.id;
|
salaryHistory.profileSalaryId = profileSal.id;
|
||||||
|
|
@ -2498,7 +2554,7 @@ export class CommandController extends Controller {
|
||||||
profileEmployeeId: profile.id,
|
profileEmployeeId: profile.id,
|
||||||
date: new Date(),
|
date: new Date(),
|
||||||
amount: item.amount,
|
amount: item.amount,
|
||||||
commandId: item.commandId,
|
commandId: item.commandId,
|
||||||
positionSalaryAmount: item.positionSalaryAmount,
|
positionSalaryAmount: item.positionSalaryAmount,
|
||||||
mouthSalaryAmount: item.mouthSalaryAmount,
|
mouthSalaryAmount: item.mouthSalaryAmount,
|
||||||
posNo: profile.posMasterNoTemp,
|
posNo: profile.posMasterNoTemp,
|
||||||
|
|
|
||||||
|
|
@ -4123,6 +4123,8 @@ export class PositionController extends Controller {
|
||||||
"next_holder.prefix",
|
"next_holder.prefix",
|
||||||
"next_holder.firstName",
|
"next_holder.firstName",
|
||||||
"next_holder.lastName",
|
"next_holder.lastName",
|
||||||
|
"next_holder.id",
|
||||||
|
"next_holder.citizenId",
|
||||||
])
|
])
|
||||||
.getMany();
|
.getMany();
|
||||||
const _posMaster = posMaster.map((x) => {
|
const _posMaster = posMaster.map((x) => {
|
||||||
|
|
|
||||||
|
|
@ -418,7 +418,10 @@ export class WorkflowController extends Controller {
|
||||||
//noti
|
//noti
|
||||||
let profileNow = workflow.stateOperatorUsers
|
let profileNow = workflow.stateOperatorUsers
|
||||||
.filter((x) => state.stateOperators.map((s) => s.operator).includes(x.operator))
|
.filter((x) => state.stateOperators.map((s) => s.operator).includes(x.operator))
|
||||||
.map((x) => x.profile);
|
.map((x) => ({
|
||||||
|
receiverUserId: x.profile,
|
||||||
|
notiLink: "",
|
||||||
|
}));
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.PostData(req, "/placement/noti/profiles", {
|
.PostData(req, "/placement/noti/profiles", {
|
||||||
subject: `รายการถูกส่ง`,
|
subject: `รายการถูกส่ง`,
|
||||||
|
|
@ -435,7 +438,10 @@ export class WorkflowController extends Controller {
|
||||||
if (_state != null) {
|
if (_state != null) {
|
||||||
let profileNext = workflow.stateOperatorUsers
|
let profileNext = workflow.stateOperatorUsers
|
||||||
.filter((x) => _state.stateOperators.map((s) => s.operator).includes(x.operator))
|
.filter((x) => _state.stateOperators.map((s) => s.operator).includes(x.operator))
|
||||||
.map((x) => x.profile);
|
.map((x) => ({
|
||||||
|
receiverUserId: x.profile,
|
||||||
|
notiLink: "",
|
||||||
|
}));
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.PostData(req, "/placement/noti/profiles", {
|
.PostData(req, "/placement/noti/profiles", {
|
||||||
subject: `ได้รับรายการ`,
|
subject: `ได้รับรายการ`,
|
||||||
|
|
@ -574,9 +580,41 @@ export class WorkflowController extends Controller {
|
||||||
where: {
|
where: {
|
||||||
id: body.stateUserCommentId,
|
id: body.stateUserCommentId,
|
||||||
},
|
},
|
||||||
|
relations: ["state", "state.workflow", "state.stateOperators"],
|
||||||
});
|
});
|
||||||
if (!stateUserComment)
|
if (!stateUserComment)
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลขั้นตอนการอนุมัติ");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลขั้นตอนการอนุมัติ");
|
||||||
|
stateUserComment.state.stateOperators;
|
||||||
|
|
||||||
|
const workflow = await this.workflowRepo.findOne({
|
||||||
|
where: {
|
||||||
|
refId: stateUserComment.state.workflow.refId,
|
||||||
|
sysName: stateUserComment.state.workflow.sysName,
|
||||||
|
},
|
||||||
|
relations: ["stateOperatorUsers"],
|
||||||
|
});
|
||||||
|
if (!workflow) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่สามารถดำเนินการกระบวนการนี้ได้");
|
||||||
|
let profileNow = workflow.stateOperatorUsers
|
||||||
|
.filter((x) =>
|
||||||
|
stateUserComment.state.stateOperators.map((s) => s.operator).includes(x.operator),
|
||||||
|
)
|
||||||
|
.map((x) => ({
|
||||||
|
receiverUserId: x.profile,
|
||||||
|
notiLink: "",
|
||||||
|
}));
|
||||||
|
await new CallAPI()
|
||||||
|
.PostData(req, "/placement/noti/profiles", {
|
||||||
|
subject: `ผู้บังคับบัญชาดำเนินการ`,
|
||||||
|
body: `ผู้บังคับบัญชาดำเนินการ`,
|
||||||
|
receiverUserIds: profileNow,
|
||||||
|
payload: "", //แนบไฟล์
|
||||||
|
isSendMail: true,
|
||||||
|
isSendInbox: true,
|
||||||
|
isSendNotification: true,
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Error calling API:", error);
|
||||||
|
});
|
||||||
let _null: any = null;
|
let _null: any = null;
|
||||||
stateUserComment.isAccept = body.isAccept == null ? _null : body.isAccept;
|
stateUserComment.isAccept = body.isAccept == null ? _null : body.isAccept;
|
||||||
stateUserComment.isApprove = body.isApprove == null ? _null : body.isApprove;
|
stateUserComment.isApprove = body.isApprove == null ? _null : body.isApprove;
|
||||||
|
|
@ -750,7 +788,12 @@ export class WorkflowController extends Controller {
|
||||||
actFullName: null,
|
actFullName: null,
|
||||||
}));
|
}));
|
||||||
const posMasterActs = await this.posMasterActRepo.find({
|
const posMasterActs = await this.posMasterActRepo.find({
|
||||||
where: { posMasterId: In(posMasters.map((x) => x.id)) },
|
where: {
|
||||||
|
posMasterId: In(posMasters.map((x) => x.id)),
|
||||||
|
posMasterChild: {
|
||||||
|
current_holderId: Not(In(posMasters.map((x) => x.current_holderId))),
|
||||||
|
},
|
||||||
|
},
|
||||||
relations: [
|
relations: [
|
||||||
"posMaster",
|
"posMaster",
|
||||||
"posMaster.current_holder",
|
"posMaster.current_holder",
|
||||||
|
|
@ -764,7 +807,7 @@ export class WorkflowController extends Controller {
|
||||||
});
|
});
|
||||||
posMasterActs.map((x) => {
|
posMasterActs.map((x) => {
|
||||||
let item: any = {
|
let item: any = {
|
||||||
id: x.posMaster?.current_holderId || null,
|
id: x.posMasterChild?.current_holderId || null,
|
||||||
prefix: x.posMasterChild?.current_holder?.prefix || "",
|
prefix: x.posMasterChild?.current_holder?.prefix || "",
|
||||||
firstName: x.posMasterChild?.current_holder?.firstName || "",
|
firstName: x.posMasterChild?.current_holder?.firstName || "",
|
||||||
lastName: x.posMasterChild?.current_holder?.lastName || "",
|
lastName: x.posMasterChild?.current_holder?.lastName || "",
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,7 @@ export class CreateProfileSalary {
|
||||||
commandId: string | null;
|
commandId: string | null;
|
||||||
// commandType?: string | null;
|
// commandType?: string | null;
|
||||||
templateDoc: string | null;
|
templateDoc: string | null;
|
||||||
|
isGovernment?: boolean | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateProfileSalaryEmployee {
|
export class CreateProfileSalaryEmployee {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue