Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop
# Conflicts: # src/controllers/ReportController.ts
This commit is contained in:
commit
a967afeb87
1 changed files with 71 additions and 81 deletions
|
|
@ -10,6 +10,8 @@ import { OrgChild1 } from "../entities/OrgChild1";
|
||||||
import { OrgChild2 } from "../entities/OrgChild2";
|
import { OrgChild2 } from "../entities/OrgChild2";
|
||||||
import { OrgChild3 } from "../entities/OrgChild3";
|
import { OrgChild3 } from "../entities/OrgChild3";
|
||||||
import { OrgChild4 } from "../entities/OrgChild4";
|
import { OrgChild4 } from "../entities/OrgChild4";
|
||||||
|
import { PosType } from "../entities/PosType";
|
||||||
|
import { PosLevel } from "../entities/PosLevel";
|
||||||
import Extension from "../interfaces/extension";
|
import Extension from "../interfaces/extension";
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
@Route("api/v1/org/report")
|
@Route("api/v1/org/report")
|
||||||
|
|
@ -26,6 +28,8 @@ export class ReportController extends Controller {
|
||||||
private child2Repository = AppDataSource.getRepository(OrgChild2);
|
private child2Repository = AppDataSource.getRepository(OrgChild2);
|
||||||
private child3Repository = AppDataSource.getRepository(OrgChild3);
|
private child3Repository = AppDataSource.getRepository(OrgChild3);
|
||||||
private child4Repository = AppDataSource.getRepository(OrgChild4);
|
private child4Repository = AppDataSource.getRepository(OrgChild4);
|
||||||
|
private posTypepository = AppDataSource.getRepository(PosType);
|
||||||
|
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API Report1
|
* API Report1
|
||||||
|
|
@ -6252,92 +6256,78 @@ export class ReportController extends Controller {
|
||||||
"posMasters.positions.posExecutive",
|
"posMasters.positions.posExecutive",
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
let data: any = [];
|
if (!rootId) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
var _data = [
|
const posType = await this.posTypepository.find({
|
||||||
{
|
order: {
|
||||||
type: "ทั่วไป",
|
posTypeRank: "ASC",
|
||||||
level: "ปฎิบัติงาน",
|
posLevels: { posLevelRank: "ASC" },
|
||||||
total: "0",
|
|
||||||
remark: "-",
|
|
||||||
},
|
},
|
||||||
{
|
relations: ["posLevels"],
|
||||||
type: "",
|
});
|
||||||
level: "ชำนาญงาน",
|
|
||||||
total: "0",
|
const posLevel = await this.posLevelRepository.find({
|
||||||
remark: "-",
|
order: { posLevelRank: "ASC" },
|
||||||
},
|
});
|
||||||
{
|
|
||||||
type: "",
|
const mapData = posType.map((type) => ({
|
||||||
level: "อาวุโส",
|
id: type.id,
|
||||||
total: "0",
|
typeName: type.posTypeName,
|
||||||
remark: "-",
|
levels: posLevel
|
||||||
},
|
.filter((level) => level.posTypeId === type.id)
|
||||||
{
|
.map((level) => ({ levelName: level.posLevelName, id: level.id })),
|
||||||
type: "",
|
}));
|
||||||
level: "รวม",
|
|
||||||
total: "0",
|
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: "",
|
remark: "",
|
||||||
},
|
});
|
||||||
{
|
});
|
||||||
type: "วิชาการ",
|
_data.push({
|
||||||
level: "ปฎิบัติการ",
|
typeName: "",
|
||||||
total: "0",
|
levelName: "รวมทั้งสิ้น",
|
||||||
remark: "-",
|
total:
|
||||||
},
|
orgRootData.length > 0 ? orgRootData[0].posMasters.flatMap((x) => x.positions).length : 0,
|
||||||
{
|
remark: "",
|
||||||
type: "",
|
});
|
||||||
level: "ชำนาญการ",
|
|
||||||
total: "0",
|
|
||||||
remark: "-",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "",
|
|
||||||
level: "รวม",
|
|
||||||
total: "0",
|
|
||||||
remark: "",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "อำนวยการ",
|
|
||||||
level: "ต้น",
|
|
||||||
total: "0",
|
|
||||||
remark: "-",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "",
|
|
||||||
level: "สูง",
|
|
||||||
total: "0",
|
|
||||||
remark: "-",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "",
|
|
||||||
level: "รวม",
|
|
||||||
total: "0",
|
|
||||||
remark: "",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "บริหาร",
|
|
||||||
level: "ต้น",
|
|
||||||
total: "0",
|
|
||||||
remark: "-",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "",
|
|
||||||
level: "สูง",
|
|
||||||
total: "0",
|
|
||||||
remark: "-",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "",
|
|
||||||
level: "รวม",
|
|
||||||
total: "0",
|
|
||||||
remark: "",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
data.push(_data);
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
template: "report4",
|
template: "report4",
|
||||||
reportName: "report4",
|
reportName: "report4",
|
||||||
data: { dateCurrent: Extension.ToThaiShortDate(new Date()), data: _data },
|
data: {
|
||||||
|
dateCurrent: Extension.ToThaiShortDate(new Date()),
|
||||||
|
rootName: orgRootData.length > 0 ? orgRootData[0].orgRootName : "-",
|
||||||
|
data: _data,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue