Merge branch 'develop' into adiDev
This commit is contained in:
commit
fb3dd54518
10 changed files with 467 additions and 109 deletions
|
|
@ -3446,6 +3446,7 @@ export class CommandController extends Controller {
|
|||
RemarkHorizontal?: any | null;
|
||||
RemarkVertical?: any | null;
|
||||
CommandYear?: any | null;
|
||||
CommandExcecuteDate?: Date | null;
|
||||
}[];
|
||||
},
|
||||
) {
|
||||
|
|
@ -3515,7 +3516,9 @@ export class CommandController extends Controller {
|
|||
"/" +*/
|
||||
_organizationNew ?? "-",
|
||||
// date: Extension.ToThaiShortDate_noPrefix(new Date()),
|
||||
dateStart: "-",
|
||||
dateStart: item.CommandExcecuteDate
|
||||
? Extension.ToThaiShortDate(item.CommandExcecuteDate)
|
||||
: "-",
|
||||
dateEnd: "-",
|
||||
order:
|
||||
posMasterAct.posMasterOrder == null
|
||||
|
|
|
|||
|
|
@ -95,7 +95,6 @@ export class OrganizationController extends Controller {
|
|||
activeName: orgRevisionActive == null ? null : orgRevisionActive.orgRevisionName,
|
||||
draftId: orgRevisionDraf == null ? null : orgRevisionDraf.id,
|
||||
draftName: orgRevisionDraf == null ? null : orgRevisionDraf.orgRevisionName,
|
||||
|
||||
orgPublishDate: orgRevisionDraf == null ? null : orgRevisionDraf.orgPublishDate,
|
||||
isPublic: orgRevisionDraf == null || orgRevisionDraf.orgRevisionName == null ? false : true,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -337,6 +337,105 @@ export class PositionController extends Controller {
|
|||
return new HttpSuccess(posDict.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขตำแหน่ง
|
||||
*
|
||||
* @summary แก้ไขตำแหน่ง (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Put("position/executive/{id}")
|
||||
@Example([
|
||||
{
|
||||
positionName: "นักบริหาร",
|
||||
positionField: "บริหาร",
|
||||
posTypeId: "08db9e81-fc46-4e95-8b33-be4ca0016abf",
|
||||
posLevelId: "08db9e81-fc46-4e95-8b33-be4ca0016abf",
|
||||
posExecutiveId: "08db9e81-fc46-4e95-8b33-be4ca0016abf",
|
||||
positionExecutiveField: "นักบริหาร",
|
||||
positionArea: "บริหาร",
|
||||
},
|
||||
])
|
||||
async updatePositionExecutive(
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
requestBody: UpdatePosDict,
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
// await new permission().PermissionUpdate(request, "SYS_ORG");
|
||||
const posDict = await this.posDictRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!posDict) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
const checkPosTypeId = await this.posTypeRepository.findOne({
|
||||
where: { id: requestBody.posTypeId },
|
||||
});
|
||||
if (!checkPosTypeId) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล PosTypeId");
|
||||
}
|
||||
|
||||
const checkPosLevelId = await this.posLevelRepository.findOne({
|
||||
where: { id: requestBody.posLevelId },
|
||||
});
|
||||
if (!checkPosLevelId) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล PosLevelId");
|
||||
}
|
||||
|
||||
const _null: any = null;
|
||||
if (requestBody.posExecutiveId == "") {
|
||||
requestBody.posExecutiveId = _null;
|
||||
}
|
||||
|
||||
if (requestBody.posExecutiveId != null && requestBody.posExecutiveId != "") {
|
||||
const checkPosExecutiveId = await this.posExecutiveRepository.findOne({
|
||||
where: { id: requestBody.posExecutiveId },
|
||||
});
|
||||
if (!checkPosExecutiveId) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล PosExecutiveId");
|
||||
}
|
||||
}
|
||||
|
||||
const rowRepeated = await this.posDictRepository.findOne({
|
||||
where: {
|
||||
id: Not(id),
|
||||
posDictName: requestBody.posDictName,
|
||||
posDictField: requestBody.posDictField,
|
||||
posTypeId: requestBody.posTypeId,
|
||||
posLevelId: requestBody.posLevelId,
|
||||
posExecutiveId: requestBody.posExecutiveId ? requestBody.posExecutiveId : "",
|
||||
posDictExecutiveField: requestBody.posDictExecutiveField
|
||||
? requestBody.posDictExecutiveField
|
||||
: "",
|
||||
posDictArea: requestBody.posDictArea ? requestBody.posDictArea : "",
|
||||
isSpecial: requestBody.isSpecial,
|
||||
},
|
||||
});
|
||||
if (rowRepeated) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ข้อมูล Row นี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
const before = structuredClone(posDict);
|
||||
Object.assign(posDict, requestBody);
|
||||
posDict.lastUpdateUserId = request.user.sub;
|
||||
posDict.lastUpdateFullName = request.user.name;
|
||||
posDict.lastUpdatedAt = new Date();
|
||||
posDict.posDictName = requestBody.posDictName;
|
||||
posDict.posDictField = requestBody.posDictField;
|
||||
posDict.posTypeId = requestBody.posTypeId;
|
||||
posDict.posLevelId = requestBody.posLevelId;
|
||||
posDict.posExecutiveId = requestBody.posExecutiveId ? requestBody.posExecutiveId : null;
|
||||
posDict.posDictExecutiveField = requestBody.posDictExecutiveField
|
||||
? requestBody.posDictExecutiveField
|
||||
: "";
|
||||
posDict.posDictArea = requestBody.posDictArea ? requestBody.posDictArea : "";
|
||||
posDict.isSpecial = requestBody.isSpecial;
|
||||
// this.posDictRepository.merge(posDict, requestBody);
|
||||
await this.posDictRepository.save(posDict, { data: request });
|
||||
setLogDataDiff(request, { before, after: posDict });
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขตำแหน่ง
|
||||
*
|
||||
|
|
@ -1122,13 +1221,13 @@ export class PositionController extends Controller {
|
|||
where: { posMasterId: posMaster.id },
|
||||
relations: ["posType", "posLevel", "posExecutive"],
|
||||
// order: { lastUpdatedAt: "ASC" },
|
||||
order: {
|
||||
order: {
|
||||
posType: {
|
||||
posTypeRank: "ASC"
|
||||
posTypeRank: "ASC",
|
||||
},
|
||||
posLevel: {
|
||||
posLevelRank: "ASC"
|
||||
}
|
||||
posLevelRank: "ASC",
|
||||
},
|
||||
},
|
||||
});
|
||||
const formattedData = {
|
||||
|
|
@ -1423,7 +1522,7 @@ export class PositionController extends Controller {
|
|||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition);
|
||||
})
|
||||
}),
|
||||
)
|
||||
.orWhere(
|
||||
new Brackets((qb) => {
|
||||
|
|
@ -1438,13 +1537,13 @@ export class PositionController extends Controller {
|
|||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition);
|
||||
})
|
||||
}),
|
||||
)
|
||||
.orderBy("posMaster.posMasterOrder", "ASC")
|
||||
.skip((body.page - 1) * body.pageSize)
|
||||
.take(body.pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
|
||||
//แก้ค้นหา
|
||||
let _position: any[] = [];
|
||||
let x: any = null;
|
||||
|
|
@ -2007,6 +2106,8 @@ export class PositionController extends Controller {
|
|||
profilePostype: type == null || type.posTypeName == null ? null : type.posTypeName,
|
||||
profilePoslevel: level == null || level.posLevelName == null ? null : level.posLevelName,
|
||||
authRoleId: posMaster.authRoleId,
|
||||
isCondition: posMaster.isCondition,
|
||||
conditionReason: posMaster.conditionReason,
|
||||
authRoleName:
|
||||
authRoleName == null || authRoleName.roleName == null ? null : authRoleName.roleName,
|
||||
positions: positions.map((position: any) => ({
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import { OrgChild4 } from "../entities/OrgChild4";
|
|||
import { PosType } from "../entities/PosType";
|
||||
import { PosLevel } from "../entities/PosLevel";
|
||||
import { PosMaster } from "../entities/PosMaster";
|
||||
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||
import Extension from "../interfaces/extension";
|
||||
import { LeaveType } from "../entities/LeaveType";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
|
|
@ -33,6 +34,7 @@ export class ReportController extends Controller {
|
|||
private posTypepository = AppDataSource.getRepository(PosType);
|
||||
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
||||
private posMasterRepository = AppDataSource.getRepository(PosMaster);
|
||||
private empPosMasterRepository = AppDataSource.getRepository(EmployeePosMaster);
|
||||
|
||||
/**
|
||||
* API Report1
|
||||
|
|
@ -6246,7 +6248,6 @@ export class ReportController extends Controller {
|
|||
|
||||
@Get("report4/{rootId}")
|
||||
async findReport4(@Path() rootId: string) {
|
||||
|
||||
const orgRootData = await this.orgRootRepository.findOne({
|
||||
where: { id: rootId }
|
||||
});
|
||||
|
|
@ -6262,56 +6263,212 @@ export class ReportController extends Controller {
|
|||
.addOrderBy("posLevel.posLevelRank", "ASC")
|
||||
.getMany();
|
||||
|
||||
const _posMaster = posMaster.map((x) => ({
|
||||
type: [...new Set(x.positions.flatMap((y) => y.posType.posTypeName))].join(","),
|
||||
typeRank: [...new Set(x.positions.flatMap((y) => y.posType.posTypeRank))].join(""),
|
||||
level: [...new Set(x.positions.flatMap((y) => y.posLevel.posLevelName))].join(","),
|
||||
levelRank: [...new Set(x.positions.flatMap((y) => `${y.posType.posTypeRank}${y.posLevel.posLevelRank}`))].join(""),
|
||||
}))
|
||||
// .sort((x:any, y:any) => parseInt(x.typeRank) - parseInt(y.typeRank))
|
||||
// .sort((x:any, y:any) => parseInt(x.levelRank) - parseInt(y.levelRank));
|
||||
const _posMaster = posMaster
|
||||
.map((x) => ({
|
||||
type: [...new Set(x.positions.flatMap((y) => y.posType.posTypeName))].join(","),
|
||||
typeRank: [...new Set(x.positions.flatMap((y) => y.posType.posTypeRank))].join(""),
|
||||
level: [...new Set(x.positions.flatMap((y) => y.posLevel.posLevelName))].join(","),
|
||||
levelRank: [...new Set(x.positions.flatMap((y) => `${y.posType.posTypeRank}${y.posLevel.posLevelRank}`))].join(""),
|
||||
}))
|
||||
|
||||
|
||||
// console.log("XXX: ",_posMaster)
|
||||
const groupPosMaster = _posMaster.reduce((total: any, idx: any) => {
|
||||
const sortedLevel = idx.level.split(",").sort().join(",");
|
||||
const key = `${idx.type}-${sortedLevel}`;
|
||||
|
||||
if (!total[key]) {
|
||||
total[key] = {
|
||||
type: idx.type,
|
||||
typeRank: idx.typeRank,
|
||||
level: sortedLevel,
|
||||
LeaveType: idx.levelRank,
|
||||
total: 0,
|
||||
remark: ""
|
||||
};
|
||||
const groupedData = _posMaster.reduce((acc:any, curr:any) => {
|
||||
const key = `${curr.type}|${curr.typeRank}|${curr.level}|${curr.levelRank}`;
|
||||
if (!acc[key]) {
|
||||
acc[key] = { ...curr, total: 1 };
|
||||
} else {
|
||||
acc[key].total += 1;
|
||||
}
|
||||
total[key].total += 1;
|
||||
return total;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
let result = Object.values(groupPosMaster)
|
||||
.sort((x:any, y:any) => parseInt(x.typeRank) - parseInt(y.typeRank))
|
||||
.sort((x:any, y:any) => parseInt(x.levelRank) - parseInt(y.levelRank));;
|
||||
// let _TypeTemp = "";
|
||||
// result = result.map((item: any) => {
|
||||
// if (item.type === _TypeTemp) {
|
||||
// return { ...item, type: "" };
|
||||
// }
|
||||
// _TypeTemp = item.type;
|
||||
// return item;
|
||||
// });
|
||||
|
||||
let result = Object.values(groupedData)
|
||||
.map((x: any) => ({
|
||||
type: x.type,
|
||||
typeRank: parseInt(x.typeRank),
|
||||
level: x.level,
|
||||
levelRank: parseInt(x.levelRank),
|
||||
total: x.total,
|
||||
remark: "",
|
||||
}))
|
||||
.sort((x, y) => {
|
||||
if (x.typeRank !== y.typeRank) {
|
||||
return x.typeRank - y.typeRank;
|
||||
}
|
||||
return x.levelRank - y.levelRank;
|
||||
});
|
||||
let tmpType: string = "";
|
||||
let allTotal: number = 0;
|
||||
let total: number = 0;
|
||||
let _total: number = 0;
|
||||
let _reslut = new Array();
|
||||
|
||||
result.forEach((x:any, idx:number) => {
|
||||
allTotal += x.total;
|
||||
total += x.total;
|
||||
if(x.type === tmpType) {
|
||||
_reslut.push({
|
||||
...x,
|
||||
type: ""
|
||||
})
|
||||
}else {
|
||||
if(x.type !== tmpType && tmpType != "") {
|
||||
_total = total - x.total;
|
||||
_reslut.push({
|
||||
type: "",
|
||||
typeRank: "",
|
||||
level: "รวม",
|
||||
levelRank: "",
|
||||
total: _total,
|
||||
remark: "",
|
||||
})
|
||||
total = x.total;
|
||||
_total = 0;
|
||||
}
|
||||
_reslut.push({
|
||||
...x
|
||||
})
|
||||
}
|
||||
tmpType = x.type;
|
||||
});
|
||||
|
||||
_reslut.push({
|
||||
type: "",
|
||||
typeRank: "",
|
||||
level: "รวม",
|
||||
levelRank: "",
|
||||
total: total,
|
||||
remark: "",
|
||||
})
|
||||
_reslut.push({
|
||||
type: "",
|
||||
typeRank: "",
|
||||
level: "รวมทั้งสิ้น",
|
||||
levelRank: "",
|
||||
total: allTotal,
|
||||
remark: "",
|
||||
});
|
||||
|
||||
return new HttpSuccess({
|
||||
template: "report4",
|
||||
reportName: "report4",
|
||||
data: {
|
||||
dateCurrent: Extension.ToThaiShortDate(new Date()),
|
||||
rootName: orgRootData ? orgRootData.orgRootName : "-",
|
||||
data: result
|
||||
data: _reslut
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Get("report4-employee/{rootId}")
|
||||
async findReportEmp4(@Path() rootId: string) {
|
||||
const orgRootData = await this.orgRootRepository.findOne({
|
||||
where: { id: rootId }
|
||||
});
|
||||
if (!orgRootData) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
const posMaster = await this.empPosMasterRepository
|
||||
.createQueryBuilder("posMaster")
|
||||
.leftJoinAndSelect("posMaster.positions", "position")
|
||||
.leftJoinAndSelect("position.posType", "posType")
|
||||
.leftJoinAndSelect("position.posLevel", "posLevel")
|
||||
.where("posMaster.orgRootId = :rootId", { rootId })
|
||||
.orderBy("posType.posTypeRank", "ASC")
|
||||
.addOrderBy("posLevel.posLevelRank", "ASC")
|
||||
.getMany();
|
||||
|
||||
const _posMaster = posMaster
|
||||
.map((x) => ({
|
||||
type: [...new Set(x.positions.flatMap((y) => y.posType.posTypeName))].join(","),
|
||||
typeRank: [...new Set(x.positions.flatMap((y) => y.posType.posTypeRank))].join(""),
|
||||
level: [...new Set(x.positions.flatMap((y) => y.posLevel.posLevelName))].join(","),
|
||||
levelRank: [...new Set(x.positions.flatMap((y) => `${y.posType.posTypeRank}${y.posLevel.posLevelRank}`))].join(""),
|
||||
}))
|
||||
|
||||
const groupedData = _posMaster.reduce((acc:any, curr:any) => {
|
||||
const key = `${curr.type}|${curr.typeRank}|${curr.level}|${curr.levelRank}`;
|
||||
if (!acc[key]) {
|
||||
acc[key] = { ...curr, total: 1 };
|
||||
} else {
|
||||
acc[key].total += 1;
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
let result = Object.values(groupedData)
|
||||
.map((x: any) => ({
|
||||
type: x.type,
|
||||
typeRank: parseInt(x.typeRank),
|
||||
level: x.level,
|
||||
levelRank: parseInt(x.levelRank),
|
||||
total: x.total,
|
||||
remark: "",
|
||||
}))
|
||||
.sort((x, y) => {
|
||||
if (x.typeRank !== y.typeRank) {
|
||||
return x.typeRank - y.typeRank;
|
||||
}
|
||||
return x.levelRank - y.levelRank;
|
||||
});
|
||||
let tmpType: string = "";
|
||||
let allTotal: number = 0;
|
||||
let total: number = 0;
|
||||
let _total: number = 0;
|
||||
let _reslut = new Array();
|
||||
|
||||
result.forEach((x:any, idx:number) => {
|
||||
allTotal += x.total;
|
||||
total += x.total;
|
||||
if(x.type === tmpType) {
|
||||
_reslut.push({
|
||||
...x,
|
||||
type: ""
|
||||
})
|
||||
}else {
|
||||
if(x.type !== tmpType && tmpType != "") {
|
||||
_total = total - x.total;
|
||||
_reslut.push({
|
||||
type: "",
|
||||
typeRank: "",
|
||||
level: "รวม",
|
||||
levelRank: "",
|
||||
total: _total,
|
||||
remark: "",
|
||||
})
|
||||
total = x.total;
|
||||
_total = 0;
|
||||
}
|
||||
_reslut.push({
|
||||
...x
|
||||
})
|
||||
}
|
||||
tmpType = x.type;
|
||||
});
|
||||
|
||||
_reslut.push({
|
||||
type: "",
|
||||
typeRank: "",
|
||||
level: "รวม",
|
||||
levelRank: "",
|
||||
total: total,
|
||||
remark: "",
|
||||
})
|
||||
_reslut.push({
|
||||
type: "",
|
||||
typeRank: "",
|
||||
level: "รวมทั้งสิ้น",
|
||||
levelRank: "",
|
||||
total: allTotal,
|
||||
remark: "",
|
||||
});
|
||||
|
||||
return new HttpSuccess({
|
||||
template: "report4",
|
||||
reportName: "report4",
|
||||
data: {
|
||||
dateCurrent: Extension.ToThaiShortDate(new Date()),
|
||||
rootName: orgRootData ? orgRootData.orgRootName : "-",
|
||||
data: _reslut
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -435,58 +435,62 @@ export class KeycloakController extends Controller {
|
|||
) {
|
||||
let condition: any = {};
|
||||
|
||||
if (req.user.role.includes("ADMIN")) {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
relations:[
|
||||
"current_holders",
|
||||
"current_holders.orgRevision",
|
||||
],
|
||||
where: {
|
||||
if (req.user.role.includes("ADMIN") && !req.user.role.includes("SUPER_ADMIN")) {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
relations: ["current_holders", "current_holders.orgRevision"],
|
||||
where: {
|
||||
keycloak: req.user.sub,
|
||||
current_holders:{
|
||||
orgRevision:{
|
||||
current_holders: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false
|
||||
}
|
||||
}
|
||||
}
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if(profile?.current_holders[0].orgRootId && profile?.current_holders[0].orgChild1Id == null){
|
||||
condition =
|
||||
`current_holders.orgRootId = '${profile?.current_holders[0].orgRootId}'
|
||||
if (
|
||||
profile?.current_holders[0]?.orgRootId &&
|
||||
profile?.current_holders[0]?.orgChild1Id == null
|
||||
) {
|
||||
condition = `current_holders.orgRootId = '${profile?.current_holders[0]?.orgRootId}'
|
||||
and current_holders.orgChild1Id IS NULL
|
||||
and current_holders.orgChild2Id IS NULL
|
||||
and current_holders.orgChild3Id IS NULL
|
||||
and current_holders.orgChild4Id IS NULL`;
|
||||
}else if(profile?.current_holders[0].orgChild1Id && profile?.current_holders[0].orgChild2Id == null){
|
||||
condition =
|
||||
`current_holders.orgRootId = '${profile?.current_holders[0].orgRootId}'
|
||||
and current_holders.orgChild1Id '${profile?.current_holders[0].orgChild1Id}'
|
||||
} else if (
|
||||
profile?.current_holders[0]?.orgChild1Id &&
|
||||
profile?.current_holders[0]?.orgChild2Id == null
|
||||
) {
|
||||
condition = `current_holders.orgRootId = '${profile?.current_holders[0]?.orgRootId}'
|
||||
and current_holders.orgChild1Id = '${profile?.current_holders[0]?.orgChild1Id}'
|
||||
and current_holders.orgChild2Id IS NULL
|
||||
and current_holders.orgChild3Id IS NULL
|
||||
and current_holders.orgChild4Id IS NULL`;
|
||||
}else if(profile?.current_holders[0].orgChild2Id && profile?.current_holders[0].orgChild3Id == null){
|
||||
condition =
|
||||
`current_holders.orgRootId = '${profile?.current_holders[0].orgRootId}'
|
||||
and current_holders.orgChild1Id '${profile?.current_holders[0].orgChild1Id}'
|
||||
and current_holders.orgChild2Id '${profile?.current_holders[0].orgChild2Id}'
|
||||
} else if (
|
||||
profile?.current_holders[0]?.orgChild2Id &&
|
||||
profile?.current_holders[0]?.orgChild3Id == null
|
||||
) {
|
||||
condition = `current_holders.orgRootId = '${profile?.current_holders[0]?.orgRootId}'
|
||||
and current_holders.orgChild1Id = '${profile?.current_holders[0]?.orgChild1Id}'
|
||||
and current_holders.orgChild2Id = '${profile?.current_holders[0]?.orgChild2Id}'
|
||||
and current_holders.orgChild3Id IS NULL
|
||||
and current_holders.orgChild4Id IS NULL`;
|
||||
}else if(profile?.current_holders[0].orgChild3Id && profile?.current_holders[0].orgChild4Id == null){
|
||||
condition =
|
||||
`current_holders.orgRootId = '${profile?.current_holders[0].orgRootId}'
|
||||
and current_holders.orgChild1Id '${profile?.current_holders[0].orgChild1Id}'
|
||||
and current_holders.orgChild2Id '${profile?.current_holders[0].orgChild2Id}'
|
||||
and current_holders.orgChild3Id '${profile?.current_holders[0].orgChild3Id}'
|
||||
} else if (
|
||||
profile?.current_holders[0]?.orgChild3Id &&
|
||||
profile?.current_holders[0]?.orgChild4Id == null
|
||||
) {
|
||||
condition = `current_holders.orgRootId = '${profile?.current_holders[0]?.orgRootId}'
|
||||
and current_holders.orgChild1Id = '${profile?.current_holders[0]?.orgChild1Id}'
|
||||
and current_holders.orgChild2Id = '${profile?.current_holders[0]?.orgChild2Id}'
|
||||
and current_holders.orgChild3Id = '${profile?.current_holders[0]?.orgChild3Id}'
|
||||
and current_holders.orgChild4Id IS NULL`;
|
||||
}else if(profile?.current_holders[0].orgChild4Id){
|
||||
condition =
|
||||
`current_holders.orgRootId = '${profile?.current_holders[0].orgRootId}'
|
||||
and current_holders.orgChild1Id '${profile?.current_holders[0].orgChild1Id}'
|
||||
and current_holders.orgChild2Id '${profile?.current_holders[0].orgChild2Id}'
|
||||
and current_holders.orgChild3Id '${profile?.current_holders[0].orgChild3Id}'
|
||||
and current_holders.orgChild4Id '${profile?.current_holders[0].orgChild4Id}'`;
|
||||
} else if (profile?.current_holders[0]?.orgChild4Id) {
|
||||
condition = `current_holders.orgRootId = '${profile?.current_holders[0]?.orgRootId}'
|
||||
and current_holders.orgChild1Id = '${profile?.current_holders[0]?.orgChild1Id}'
|
||||
and current_holders.orgChild2Id = '${profile?.current_holders[0]?.orgChild2Id}'
|
||||
and current_holders.orgChild3Id = '${profile?.current_holders[0]?.orgChild3Id}'
|
||||
and current_holders.orgChild4Id = '${profile?.current_holders[0]?.orgChild4Id}'`;
|
||||
}
|
||||
}
|
||||
let profiles: any = [];
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ export class WorkflowController extends Controller {
|
|||
let profileNow = _workflow.stateOperatorUsers
|
||||
.filter((x) => _state.stateOperators.map((s) => s.operator).includes(x.operator))
|
||||
.map((x) => ({
|
||||
receiverUserId: x.profileId,
|
||||
receiverUserId: x.profileType == "OFFICER" ? x.profileId : x.profileEmployeeId,
|
||||
notiLink: "",
|
||||
}));
|
||||
await new CallAPI()
|
||||
|
|
@ -313,7 +313,15 @@ export class WorkflowController extends Controller {
|
|||
system: string;
|
||||
},
|
||||
) {
|
||||
const stateOperatorUser = await this.stateOperatorUserRepo.findOne({
|
||||
const workflow = await this.workflowRepo.findOne({
|
||||
where: {
|
||||
refId: body.refId,
|
||||
sysName: body.system,
|
||||
},
|
||||
});
|
||||
if (!workflow) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่สามารถดำเนินการกระบวนการนี้ได้");
|
||||
|
||||
let stateOperatorUser = await this.stateOperatorUserRepo.findOne({
|
||||
where: {
|
||||
workflow: {
|
||||
refId: body.refId,
|
||||
|
|
@ -325,13 +333,20 @@ export class WorkflowController extends Controller {
|
|||
},
|
||||
relations: ["workflow"],
|
||||
});
|
||||
const workflow = await this.workflowRepo.findOne({
|
||||
where: {
|
||||
refId: body.refId,
|
||||
sysName: body.system,
|
||||
},
|
||||
});
|
||||
if (!workflow) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่สามารถดำเนินการกระบวนการนี้ได้");
|
||||
if (stateOperatorUser) {
|
||||
stateOperatorUser = await this.stateOperatorUserRepo.findOne({
|
||||
where: {
|
||||
workflow: {
|
||||
refId: body.refId,
|
||||
sysName: body.system,
|
||||
},
|
||||
profileEmployee: {
|
||||
keycloak: req.user.sub,
|
||||
},
|
||||
},
|
||||
relations: ["workflow"],
|
||||
});
|
||||
}
|
||||
const operator = await this.stateOperatorRepo.findOne({
|
||||
where: {
|
||||
operator: stateOperatorUser?.operator || "",
|
||||
|
|
@ -424,7 +439,16 @@ export class WorkflowController extends Controller {
|
|||
system: string;
|
||||
},
|
||||
) {
|
||||
const stateOperatorUserNow = await this.stateOperatorUserRepo.findOne({
|
||||
const workflow = await this.workflowRepo.findOne({
|
||||
where: {
|
||||
refId: body.refId,
|
||||
sysName: body.system,
|
||||
},
|
||||
relations: ["stateOperatorUsers"],
|
||||
});
|
||||
if (!workflow) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่สามารถดำเนินการกระบวนการนี้ได้");
|
||||
|
||||
let stateOperatorUserNow = await this.stateOperatorUserRepo.findOne({
|
||||
where: {
|
||||
workflow: {
|
||||
refId: body.refId,
|
||||
|
|
@ -435,7 +459,20 @@ export class WorkflowController extends Controller {
|
|||
},
|
||||
},
|
||||
});
|
||||
const stateOperatorUser = await this.stateOperatorUserRepo.find({
|
||||
if (stateOperatorUserNow == null) {
|
||||
stateOperatorUserNow = await this.stateOperatorUserRepo.findOne({
|
||||
where: {
|
||||
workflow: {
|
||||
refId: body.refId,
|
||||
sysName: body.system,
|
||||
},
|
||||
profileEmployee: {
|
||||
keycloak: req.user.sub,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
let stateOperatorUser = await this.stateOperatorUserRepo.find({
|
||||
where: {
|
||||
workflow: {
|
||||
refId: body.refId,
|
||||
|
|
@ -447,17 +484,22 @@ export class WorkflowController extends Controller {
|
|||
operator: stateOperatorUserNow?.operator || "",
|
||||
},
|
||||
});
|
||||
if (stateOperatorUser == null) {
|
||||
stateOperatorUser = await this.stateOperatorUserRepo.find({
|
||||
where: {
|
||||
workflow: {
|
||||
refId: body.refId,
|
||||
sysName: body.system,
|
||||
},
|
||||
profileEmployee: {
|
||||
keycloak: Not(req.user.sub),
|
||||
},
|
||||
operator: stateOperatorUserNow?.operator || "",
|
||||
},
|
||||
});
|
||||
}
|
||||
await this.stateOperatorUserRepo.remove(stateOperatorUser);
|
||||
|
||||
const workflow = await this.workflowRepo.findOne({
|
||||
where: {
|
||||
refId: body.refId,
|
||||
sysName: body.system,
|
||||
},
|
||||
relations: ["stateOperatorUsers"],
|
||||
});
|
||||
if (!workflow) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่สามารถดำเนินการกระบวนการนี้ได้");
|
||||
|
||||
const state = await this.stateRepo.findOne({
|
||||
where: {
|
||||
id: workflow.stateId,
|
||||
|
|
@ -476,7 +518,7 @@ export class WorkflowController extends Controller {
|
|||
let profileNow = workflow.stateOperatorUsers
|
||||
.filter((x) => state.stateOperators.map((s) => s.operator).includes(x.operator))
|
||||
.map((x) => ({
|
||||
receiverUserId: x.profileId,
|
||||
receiverUserId: x.profileType == "OFFICER" ? x.profileId : x.profileEmployeeId,
|
||||
notiLink: "",
|
||||
}));
|
||||
await new CallAPI()
|
||||
|
|
@ -496,7 +538,7 @@ export class WorkflowController extends Controller {
|
|||
let profileNext = workflow.stateOperatorUsers
|
||||
.filter((x) => _state.stateOperators.map((s) => s.operator).includes(x.operator))
|
||||
.map((x) => ({
|
||||
receiverUserId: x.profileId,
|
||||
receiverUserId: x.profileType == "OFFICER" ? x.profileId : x.profileEmployeeId,
|
||||
notiLink: "",
|
||||
}));
|
||||
await new CallAPI()
|
||||
|
|
@ -656,7 +698,7 @@ export class WorkflowController extends Controller {
|
|||
stateUserComment.state.stateOperators.map((s) => s.operator).includes(x.operator),
|
||||
)
|
||||
.map((x) => ({
|
||||
receiverUserId: x.profileId,
|
||||
receiverUserId: x.profileType == "OFFICER" ? x.profileId : x.profileEmployeeId,
|
||||
notiLink: "",
|
||||
}));
|
||||
await new CallAPI()
|
||||
|
|
|
|||
|
|
@ -17,6 +17,13 @@ export class OrgRevision extends EntityBase {
|
|||
})
|
||||
orgRevisionName: string;
|
||||
|
||||
@Column({
|
||||
comment: "หมายเหตุ",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
remark: string;
|
||||
|
||||
@Column({
|
||||
comment: "สถานะเป็นโครงสร้างปัจจุบันหรือไม่",
|
||||
default: false,
|
||||
|
|
@ -82,5 +89,8 @@ export class CreateOrgRevision {
|
|||
|
||||
@Column("uuid")
|
||||
orgRevisionId?: string;
|
||||
|
||||
@Column()
|
||||
remark: string;
|
||||
}
|
||||
export type UpdateOrgRevision = Partial<OrgRevision>;
|
||||
|
|
|
|||
14
src/migration/1732085607231-update_workflow_add_employee.ts
Normal file
14
src/migration/1732085607231-update_workflow_add_employee.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateWorkflowAddEmployee1732085607231 implements MigrationInterface {
|
||||
name = 'UpdateWorkflowAddEmployee1732085607231'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`workflow\` DROP COLUMN \`profileType\``);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`workflow\` ADD \`profileType\` varchar(255) NULL COMMENT 'ผู้ใช้งาน'`);
|
||||
}
|
||||
|
||||
}
|
||||
14
src/migration/1732087058773-update_workflow_add_employee1.ts
Normal file
14
src/migration/1732087058773-update_workflow_add_employee1.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateWorkflowAddEmployee11732087058773 implements MigrationInterface {
|
||||
name = 'UpdateWorkflowAddEmployee11732087058773'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`workflow\` ADD \`profileType\` varchar(255) NULL COMMENT 'ผู้ใช้งาน'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`workflow\` DROP COLUMN \`profileType\``);
|
||||
}
|
||||
|
||||
}
|
||||
14
src/migration/1732163306077-updata_org_add_remark.ts
Normal file
14
src/migration/1732163306077-updata_org_add_remark.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdataOrgAddRemark1732163306077 implements MigrationInterface {
|
||||
name = 'UpdataOrgAddRemark1732163306077'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`orgRevision\` ADD \`remark\` varchar(255) NULL COMMENT 'หมายเหตุ'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`orgRevision\` DROP COLUMN \`remark\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue