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 { OrgChild3 } from "../entities/OrgChild3";
|
||||
import { OrgChild4 } from "../entities/OrgChild4";
|
||||
import { PosType } from "../entities/PosType";
|
||||
import { PosLevel } from "../entities/PosLevel";
|
||||
import Extension from "../interfaces/extension";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
@Route("api/v1/org/report")
|
||||
|
|
@ -26,6 +28,8 @@ export class ReportController extends Controller {
|
|||
private child2Repository = AppDataSource.getRepository(OrgChild2);
|
||||
private child3Repository = AppDataSource.getRepository(OrgChild3);
|
||||
private child4Repository = AppDataSource.getRepository(OrgChild4);
|
||||
private posTypepository = AppDataSource.getRepository(PosType);
|
||||
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
||||
|
||||
/**
|
||||
* API Report1
|
||||
|
|
@ -6252,92 +6256,78 @@ export class ReportController extends Controller {
|
|||
"posMasters.positions.posExecutive",
|
||||
],
|
||||
});
|
||||
let data: any = [];
|
||||
var _data = [
|
||||
{
|
||||
type: "ทั่วไป",
|
||||
level: "ปฎิบัติงาน",
|
||||
total: "0",
|
||||
remark: "-",
|
||||
if (!rootId) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
const posType = await this.posTypepository.find({
|
||||
order: {
|
||||
posTypeRank: "ASC",
|
||||
posLevels: { posLevelRank: "ASC" },
|
||||
},
|
||||
{
|
||||
type: "",
|
||||
level: "ชำนาญงาน",
|
||||
total: "0",
|
||||
remark: "-",
|
||||
},
|
||||
{
|
||||
type: "",
|
||||
level: "อาวุโส",
|
||||
total: "0",
|
||||
remark: "-",
|
||||
},
|
||||
{
|
||||
type: "",
|
||||
level: "รวม",
|
||||
total: "0",
|
||||
relations: ["posLevels"],
|
||||
});
|
||||
|
||||
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: "",
|
||||
},
|
||||
{
|
||||
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: "-",
|
||||
},
|
||||
{
|
||||
type: "",
|
||||
level: "รวม",
|
||||
total: "0",
|
||||
remark: "",
|
||||
},
|
||||
];
|
||||
data.push(_data);
|
||||
});
|
||||
});
|
||||
_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()), 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