no message
This commit is contained in:
parent
3803e593a5
commit
b85de85d7e
1 changed files with 2 additions and 89 deletions
|
|
@ -6246,31 +6246,9 @@ export class ReportController extends Controller {
|
|||
|
||||
@Get("report4/{rootId}")
|
||||
async findReport4(@Path() rootId: string) {
|
||||
<<<<<<< HEAD
|
||||
|
||||
const orgRootData = await this.orgRootRepository.findOne({
|
||||
where: { id: rootId }
|
||||
=======
|
||||
const orgRootData = await this.orgRootRepository.find({
|
||||
where: {
|
||||
id: rootId,
|
||||
},
|
||||
order: { orgRootOrder: "ASC" },
|
||||
relations: [
|
||||
"posMasters",
|
||||
"posMasters.positions",
|
||||
"posMasters.positions.posLevel",
|
||||
"posMasters.positions.posType",
|
||||
"posMasters.positions.posExecutive",
|
||||
],
|
||||
});
|
||||
if (!rootId) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
const posType = await this.posTypepository.find({
|
||||
order: {
|
||||
posTypeRank: "ASC",
|
||||
posLevels: { posLevelRank: "ASC" },
|
||||
},
|
||||
relations: ["posLevels"],
|
||||
>>>>>>> develop
|
||||
});
|
||||
if (!orgRootData) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
|
|
@ -6293,7 +6271,7 @@ export class ReportController extends Controller {
|
|||
// .sort((x:any, y:any) => parseInt(x.typeRank) - parseInt(y.typeRank))
|
||||
// .sort((x:any, y:any) => parseInt(x.levelRank) - parseInt(y.levelRank));
|
||||
|
||||
<<<<<<< HEAD
|
||||
|
||||
// console.log("XXX: ",_posMaster)
|
||||
const groupPosMaster = _posMaster.reduce((total: any, idx: any) => {
|
||||
const sortedLevel = idx.level.split(",").sort().join(",");
|
||||
|
|
@ -6334,71 +6312,6 @@ export class ReportController extends Controller {
|
|||
data: result
|
||||
}
|
||||
});
|
||||
=======
|
||||
const posLevel = await this.posLevelRepository.find({
|
||||
order: { posLevelRank: "ASC" },
|
||||
});
|
||||
|
||||
const mapData = posType.map((type) => ({
|
||||
id: type.id,
|
||||
typeName: type.posTypeName,
|
||||
levels: posLevel
|
||||
.filter((level) => level.posTypeId === type.id)
|
||||
.map((level) => ({ levelName: level.posLevelName, id: level.id })),
|
||||
}));
|
||||
|
||||
let _data: any = [];
|
||||
mapData.forEach((type, idx) => {
|
||||
type.levels.forEach((level, idy) => {
|
||||
_data.push({
|
||||
typeName: idy == 0 ? type.typeName : "",
|
||||
levelName: level.levelName,
|
||||
total:
|
||||
orgRootData.length > 0
|
||||
? orgRootData[0].posMasters.flatMap((x) =>
|
||||
x.positions
|
||||
.filter((y) => y.posLevelId === level.id && y.posTypeId === type.id)
|
||||
.map((z) => ({
|
||||
position: z.positionName || "",
|
||||
})),
|
||||
).length
|
||||
: 0,
|
||||
remark: "",
|
||||
});
|
||||
});
|
||||
_data.push({
|
||||
typeName: "",
|
||||
levelName: "รวม",
|
||||
total:
|
||||
orgRootData.length > 0
|
||||
? orgRootData[0].posMasters.flatMap((x) =>
|
||||
x.positions
|
||||
.filter((y) => y.posTypeId === type.id)
|
||||
.map((z) => ({
|
||||
position: z.positionName || "",
|
||||
})),
|
||||
).length
|
||||
: 0,
|
||||
remark: "",
|
||||
});
|
||||
});
|
||||
_data.push({
|
||||
typeName: "",
|
||||
levelName: "รวมทั้งสิ้น",
|
||||
total:
|
||||
orgRootData.length > 0 ? orgRootData[0].posMasters.flatMap((x) => x.positions).length : 0,
|
||||
remark: "",
|
||||
});
|
||||
|
||||
return new HttpSuccess({
|
||||
template: "report4",
|
||||
reportName: "report4",
|
||||
data: {
|
||||
dateCurrent: Extension.ToThaiShortDate(new Date()),
|
||||
rootName: orgRootData.length > 0 ? orgRootData[0].orgRootName : "-",
|
||||
data: _data,
|
||||
},
|
||||
});
|
||||
>>>>>>> develop
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue