Merge branch 'nice' into develop

# Conflicts:
#	src/controllers/KpiUserCapacityController.ts
#	src/controllers/KpiUserEvaluationController.ts
This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-08-22 14:27:49 +07:00
commit dfd9ebb3c1
21 changed files with 526 additions and 236 deletions

View file

@ -10,9 +10,11 @@ import {
Body,
Path,
Request,
Example,
SuccessResponse,
Response,
Query,
ArrayValidator,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success";
@ -29,7 +31,7 @@ import {
updateKpiUserReqEditEvaluation,
updateKpiUserResultEvaluation,
} from "../entities/kpiUserEvaluation";
import { In, Brackets, IsNull, Not } from "typeorm";
import { Like, In, Brackets, IsNull, Not } from "typeorm";
import CallAPI from "../interfaces/call-api";
import { KpiCapacity } from "../entities/kpiCapacity";
import { Position } from "../entities/position";
@ -192,123 +194,6 @@ export class KpiUserEvaluationController extends Controller {
return new HttpSuccess({ data: mapData, total });
}
/**
* API
*
* @summary
*
*/
@Post("list-announce")
async listKpiListEvaluationAnnounce(
@Request() request: RequestWithUser,
@Body()
requestBody: {
page: number;
pageSize: number;
kpiPeriodId?: string;
keyword?: string;
status?: string | null;
results?: string | null;
reqedit?: string | null;
evaluating?: boolean | null;
},
) {
await new permission().PermissionDelete(request, "SYS_RESULT");
let conditionFullName =
"CONCAT(kpiUserEvaluation.prefix, kpiUserEvaluation.firstName, ' ', kpiUserEvaluation.lastName) LIKE :keyword";
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
.createQueryBuilder("kpiUserEvaluation")
.andWhere(requestBody.kpiPeriodId ? "kpiPeriodId LIKE :kpiPeriodId" : "1=1", {
kpiPeriodId: requestBody.kpiPeriodId,
})
.andWhere(
requestBody.status != null && requestBody.status != undefined
? "evaluationstatus LIKE :status"
: "1=1",
{
status:
requestBody.status == null || requestBody.status == undefined
? null
: requestBody.status.trim().toUpperCase(),
},
)
.andWhere(
requestBody.results != null && requestBody.results != undefined
? "evaluationResults LIKE :results"
: "1=1",
{
results:
requestBody.results == null || requestBody.results == undefined
? null
: requestBody.results.trim().toUpperCase(),
},
)
.andWhere(
new Brackets((qb) => {
qb.orWhere("kpiUserEvaluation.prefix LIKE :keyword", {
keyword: `%${requestBody.keyword}%`,
})
.orWhere("kpiUserEvaluation.firstName LIKE :keyword", {
keyword: `%${requestBody.keyword}%`,
})
.orWhere("kpiUserEvaluation.lastName LIKE :keyword", {
keyword: `%${requestBody.keyword}%`,
})
.orWhere("kpiUserEvaluation.org LIKE :keyword", {
keyword: `%${requestBody.keyword}%`,
})
.orWhere("kpiUserEvaluation.position LIKE :keyword", {
keyword: `%${requestBody.keyword}%`,
})
.orWhere("kpiUserEvaluation.posTypeName LIKE :keyword", {
keyword: `%${requestBody.keyword}%`,
})
.orWhere("kpiUserEvaluation.posLevelName LIKE :keyword", {
keyword: `%${requestBody.keyword}%`,
})
.orWhere(conditionFullName, {
keyword: `%${requestBody.keyword}%`,
});
}),
)
.orderBy("kpiUserEvaluation.createdAt", "ASC")
.skip((requestBody.page - 1) * requestBody.pageSize)
.take(requestBody.pageSize)
.getManyAndCount();
const mapData = kpiUserEvaluation.map((item) => {
const fullNameParts = [item.child4, item.child3, item.child2, item.child1, item.org];
const organization = fullNameParts
.filter((part) => part !== undefined && part !== null)
.join("/");
return {
id: item.id,
profileId: item.profileId,
prefix: item.prefix,
firstname: item.firstName,
lastname: item.lastName,
kpiPeriodId: item.kpiPeriodId,
evaluationStatus: item.evaluationStatus,
evaluationResults: item.evaluationResults,
createdAt: item.createdAt,
evaluatorId: item.evaluatorId,
commanderId: item.commanderId,
commanderHighId: item.commanderHighId,
root: item.org ? item.org : null,
rootId: item.orgId ? item.orgId : null,
position: item.position ? item.position : null,
// posTypeId: item.posTypeId,
posTypeName: item.posTypeName ? item.posTypeName : null,
// posLevelId: item.posLevelId,
posLevelName: item.posLevelName ? item.posLevelName : null,
organization: organization ? organization : null,
};
});
return new HttpSuccess({ data: mapData, total });
}
/**
* API
*
@ -317,7 +202,7 @@ export class KpiUserEvaluationController extends Controller {
*/
@Post("list")
async listKpiListEvaluation(
@Request() request: RequestWithUser,
@Request() request: { user: Record<string, any> },
@Body()
requestBody: {
page: number;
@ -330,7 +215,6 @@ export class KpiUserEvaluationController extends Controller {
evaluating?: boolean | null;
},
) {
await new permission().PermissionDelete(request, "SYS_KPI_LIST");
let conditionFullName =
"CONCAT(kpiUserEvaluation.prefix, kpiUserEvaluation.firstName, ' ', kpiUserEvaluation.lastName) LIKE :keyword";
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
@ -1558,8 +1442,10 @@ export class KpiUserEvaluationController extends Controller {
* @param {string} id Guid, *Id (USER)
*/
@Get("reason/{id}")
async getReasonKpiEvaluation(@Path() id: string, @Request() request: RequestWithUser) {
await new permission().PermissionGet(request, "SYS_KPI_LIST");
async getReasonKpiEvaluation(
@Path() id: string,
@Request() request: { user: Record<string, any> },
) {
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
where: { id: id },
select: [
@ -1625,7 +1511,7 @@ export class KpiUserEvaluationController extends Controller {
kpiUserEvaluation.evaluationStatus = "SUMMARY";
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
kpiUserEvaluation.lastUpdateFullName = request.user.name;
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
return new HttpSuccess(kpiUserEvaluation);
}
}