Merge branch 'develop' into dev
* develop: (25 commits) fix + test retirement #1903, #1904, #1892 fix employee fix fix add employee-temp xlsx template (report5) test comment all privilage validate test comment _workflow privilage validate test try catch avatar profile recheck script retire 30/10 fix(ex/retirement): document ที่ตำแหน่งแสดงไม่ตรงกับทะเบียนประวัติ #1899 (#204) #1889 feat(ExRetirment):get document import salary add api key #1885 update update timezone revert #1885 #1885 #1884 ...
This commit is contained in:
commit
e4200bf2b4
27 changed files with 1325 additions and 5267 deletions
|
|
@ -13,12 +13,16 @@ import { OrganizationController } from "./controllers/OrganizationController";
|
||||||
import logMiddleware from "./middlewares/logs";
|
import logMiddleware from "./middlewares/logs";
|
||||||
import { CommandController } from "./controllers/CommandController";
|
import { CommandController } from "./controllers/CommandController";
|
||||||
import { ProfileSalaryController } from "./controllers/ProfileSalaryController";
|
import { ProfileSalaryController } from "./controllers/ProfileSalaryController";
|
||||||
|
import { DateSerializer } from "./interfaces/date-serializer";
|
||||||
|
|
||||||
import { initWebSocket } from "./services/webSocket";
|
import { initWebSocket } from "./services/webSocket";
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
await AppDataSource.initialize();
|
await AppDataSource.initialize();
|
||||||
|
|
||||||
|
// Setup custom Date serialization for local timezone
|
||||||
|
DateSerializer.setupDateSerialization();
|
||||||
|
|
||||||
initWebSocket();
|
initWebSocket();
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
@ -62,7 +66,9 @@ async function main() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const cronTime_Oct = "0 0 1 10 *";
|
// const cronTime_Oct = "0 0 1 10 *";
|
||||||
|
// Test #1892
|
||||||
|
const cronTime_Oct = "0 0 31 10 *";
|
||||||
cron.schedule(cronTime_Oct, async () => {
|
cron.schedule(cronTime_Oct, async () => {
|
||||||
try {
|
try {
|
||||||
const commandController = new CommandController();
|
const commandController = new CommandController();
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ import { In } from "typeorm";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { ApiName } from "../entities/ApiName";
|
import { ApiName } from "../entities/ApiName";
|
||||||
import { ApiHistory } from "../entities/ApiHistory";
|
import { ApiHistory } from "../entities/ApiHistory";
|
||||||
|
|
||||||
|
const jwt = require("jsonwebtoken");
|
||||||
@Route("api/v1/org/apiKey")
|
@Route("api/v1/org/apiKey")
|
||||||
@Tags("ApiKey")
|
@Tags("ApiKey")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -32,6 +34,32 @@ export class ApiKeyController extends Controller {
|
||||||
private apiNameRepository = AppDataSource.getRepository(ApiName);
|
private apiNameRepository = AppDataSource.getRepository(ApiName);
|
||||||
private apiHistoryRepository = AppDataSource.getRepository(ApiHistory);
|
private apiHistoryRepository = AppDataSource.getRepository(ApiHistory);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API ตรวจสอบและถอดรหัส JWT token
|
||||||
|
*
|
||||||
|
* @summary ตรวจสอบ JWT API Key
|
||||||
|
*/
|
||||||
|
@Post("verify")
|
||||||
|
async verifyApiKey(@Body() requestBody: { token: string }) {
|
||||||
|
try {
|
||||||
|
const jwtSecret = process.env.JWT_SECRET || "your-default-secret-key";
|
||||||
|
console.log("JWT_SECRET from env:", process.env.JWT_SECRET ? "exists" : "not found");
|
||||||
|
console.log("Using secret:", jwtSecret);
|
||||||
|
|
||||||
|
const decoded = jwt.verify(requestBody.token, jwtSecret);
|
||||||
|
return new HttpSuccess({
|
||||||
|
valid: true,
|
||||||
|
data: decoded,
|
||||||
|
});
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error("JWT Verification Error:", error.message);
|
||||||
|
return new HttpSuccess({
|
||||||
|
valid: false,
|
||||||
|
error: error.message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API สร้าง Api Key
|
* API สร้าง Api Key
|
||||||
*
|
*
|
||||||
|
|
@ -52,8 +80,33 @@ export class ApiKeyController extends Controller {
|
||||||
const apiName = await this.apiNameRepository.find({
|
const apiName = await this.apiNameRepository.find({
|
||||||
where: { id: In(requestBody.apiId) },
|
where: { id: In(requestBody.apiId) },
|
||||||
});
|
});
|
||||||
|
|
||||||
const apiKey = Object.assign(new ApiKey(), requestBody);
|
const apiKey = Object.assign(new ApiKey(), requestBody);
|
||||||
apiKey.keyApi = require("crypto").randomBytes(64).toString("base64");
|
|
||||||
|
// Create JWT token with embedded data
|
||||||
|
const tokenPayload = {
|
||||||
|
keyId: apiKey.id || require("crypto").randomUUID(),
|
||||||
|
name: apiKey.name,
|
||||||
|
accessType: apiKey.accessType,
|
||||||
|
dnaRootId: apiKey.dnaRootId,
|
||||||
|
dnaChild1Id: apiKey.dnaChild1Id,
|
||||||
|
dnaChild2Id: apiKey.dnaChild2Id,
|
||||||
|
dnaChild3Id: apiKey.dnaChild3Id,
|
||||||
|
dnaChild4Id: apiKey.dnaChild4Id,
|
||||||
|
apiIds: requestBody.apiId,
|
||||||
|
createdBy: request.user.sub,
|
||||||
|
createdAt: new Date().toISOString(),
|
||||||
|
iat: Math.floor(Date.now() / 1000),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Sign JWT with secret (you should use environment variable for the secret)
|
||||||
|
const jwtSecret = process.env.JWT_SECRET || "your-default-secret-key";
|
||||||
|
|
||||||
|
const jwtToken = jwt.sign(tokenPayload, jwtSecret, {
|
||||||
|
expiresIn: "365d", // 1 year expiration
|
||||||
|
});
|
||||||
|
|
||||||
|
apiKey.keyApi = jwtToken;
|
||||||
apiKey.apiNames = apiName;
|
apiKey.apiNames = apiName;
|
||||||
apiKey.createdUserId = request.user.sub;
|
apiKey.createdUserId = request.user.sub;
|
||||||
apiKey.createdFullName = request.user.name;
|
apiKey.createdFullName = request.user.name;
|
||||||
|
|
@ -104,6 +157,12 @@ export class ApiKeyController extends Controller {
|
||||||
createdUserId: _data.createdUserId,
|
createdUserId: _data.createdUserId,
|
||||||
createdFullName: _data.createdFullName,
|
createdFullName: _data.createdFullName,
|
||||||
name: _data.name,
|
name: _data.name,
|
||||||
|
accessType: _data.accessType,
|
||||||
|
dnaRootId: _data.dnaRootId,
|
||||||
|
dnaChild1Id: _data.dnaChild1Id,
|
||||||
|
dnaChild2Id: _data.dnaChild2Id,
|
||||||
|
dnaChild3Id: _data.dnaChild3Id,
|
||||||
|
dnaChild4Id: _data.dnaChild4Id,
|
||||||
apiNames: _data.apiNames.map((x) => ({
|
apiNames: _data.apiNames.map((x) => ({
|
||||||
id: x.id,
|
id: x.id,
|
||||||
name: x.name,
|
name: x.name,
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ import {
|
||||||
getUserByUsername,
|
getUserByUsername,
|
||||||
getRoleMappings,
|
getRoleMappings,
|
||||||
removeUserRoles,
|
removeUserRoles,
|
||||||
|
getToken,
|
||||||
} from "../keycloak";
|
} from "../keycloak";
|
||||||
import { ProfileEducation, CreateProfileEducation } from "../entities/ProfileEducation";
|
import { ProfileEducation, CreateProfileEducation } from "../entities/ProfileEducation";
|
||||||
import { ProfileEducationHistory } from "../entities/ProfileEducationHistory";
|
import { ProfileEducationHistory } from "../entities/ProfileEducationHistory";
|
||||||
|
|
@ -1476,24 +1477,25 @@ export class CommandController extends Controller {
|
||||||
}
|
}
|
||||||
// @Get("XXX")
|
// @Get("XXX")
|
||||||
async cronjobUpdateRetirementStatus(/*@Request() request: RequestWithUser*/) {
|
async cronjobUpdateRetirementStatus(/*@Request() request: RequestWithUser*/) {
|
||||||
let body = {
|
// let body = {
|
||||||
client_id: "gettoken",
|
// client_id: "gettoken",
|
||||||
client_secret: process.env.AUTH_ACCOUNT_SECRET,
|
// client_secret: process.env.AUTH_ACCOUNT_SECRET,
|
||||||
grant_type: "client_credentials",
|
// grant_type: "client_credentials",
|
||||||
};
|
// };
|
||||||
const postData = querystring.stringify(body);
|
// const postData = querystring.stringify(body);
|
||||||
const response = await axios.post(
|
// const response = await axios.post(
|
||||||
`${process.env.KC_URL}/realms/${process.env.KC_REALMS}/protocol/openid-connect/token`,
|
// `${process.env.KC_URL}/realms/${process.env.KC_REALMS}/protocol/openid-connect/token`,
|
||||||
postData,
|
// postData,
|
||||||
{
|
// {
|
||||||
headers: {
|
// headers: {
|
||||||
"Content-Type": "application/x-www-form-urlencoded",
|
// "Content-Type": "application/x-www-form-urlencoded",
|
||||||
api_key: process.env.API_KEY,
|
// api_key: process.env.API_KEY,
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
);
|
// );
|
||||||
const adminToken = response.data.access_token;
|
// const adminToken = response.data.access_token;
|
||||||
// const adminToken = request.headers["authorization"]?.replace("Bearer ", "");
|
// const adminToken = request.headers["authorization"]?.replace("Bearer ", "");
|
||||||
|
const adminToken = await getToken() ?? "";
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
today.setUTCHours(0, 0, 0, 0);
|
today.setUTCHours(0, 0, 0, 0);
|
||||||
let type: string = "OFFICER";
|
let type: string = "OFFICER";
|
||||||
|
|
|
||||||
|
|
@ -1006,6 +1006,7 @@ export class EmployeePositionController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("master/list")
|
@Post("master/list")
|
||||||
async listEmp(
|
async listEmp(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
id: string;
|
id: string;
|
||||||
|
|
@ -1026,7 +1027,7 @@ export class EmployeePositionController extends Controller {
|
||||||
let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||||
let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||||
let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||||
|
let _data = await new permission().PermissionOrgList(request, "SYS_ORG_EMP");
|
||||||
if (body.type === 0) {
|
if (body.type === 0) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgRootId: body.id,
|
orgRootId: body.id,
|
||||||
|
|
@ -1139,6 +1140,56 @@ export class EmployeePositionController extends Controller {
|
||||||
.leftJoinAndSelect("positions.posType", "posType")
|
.leftJoinAndSelect("positions.posType", "posType")
|
||||||
.leftJoinAndSelect("positions.posLevel", "posLevel")
|
.leftJoinAndSelect("positions.posLevel", "posLevel")
|
||||||
.where(conditions)
|
.where(conditions)
|
||||||
|
.andWhere(
|
||||||
|
_data.root != undefined && _data.root != null
|
||||||
|
? _data.root[0] != null
|
||||||
|
? `posMaster.orgRootId IN (:...root)`
|
||||||
|
: `posMaster.orgRootId is null`
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
root: _data.root,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
_data.child1 != undefined && _data.child1 != null
|
||||||
|
? _data.child1[0] != null
|
||||||
|
? `posMaster.orgChild1Id IN (:...child1)`
|
||||||
|
: `posMaster.orgChild1Id is null`
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
child1: _data.child1,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
_data.child2 != undefined && _data.child2 != null
|
||||||
|
? _data.child2[0] != null
|
||||||
|
? `posMaster.orgChild2Id IN (:...child2)`
|
||||||
|
: `posMaster.orgChild2Id is null`
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
child2: _data.child2,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
_data.child3 != undefined && _data.child3 != null
|
||||||
|
? _data.child3[0] != null
|
||||||
|
? `posMaster.orgChild3Id IN (:...child3)`
|
||||||
|
: `posMaster.orgChild3Id is null`
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
child3: _data.child3,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
_data.child4 != undefined && _data.child4 != null
|
||||||
|
? _data.child4[0] != null
|
||||||
|
? `posMaster.orgChild4Id IN (:...child4)`
|
||||||
|
: `posMaster.orgChild4Id is null`
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
child4: _data.child4,
|
||||||
|
},
|
||||||
|
)
|
||||||
.orWhere(
|
.orWhere(
|
||||||
new Brackets((qb) => {
|
new Brackets((qb) => {
|
||||||
qb.andWhere(
|
qb.andWhere(
|
||||||
|
|
@ -1330,6 +1381,40 @@ export class EmployeePositionController extends Controller {
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if(_data.privilege === 'NORMAL'|| _data.privilege === 'PARENT'|| _data.privilege === 'CHILD'){ //PARENT จะไม่มีทางเห็น ROOT , CHILD ยึดจาก CHILD ที่อยู่ลงไปข้างล่างและจะไม่เห็น CHILD ที่อยู่เหนือกว่า
|
||||||
|
const nextChildMap:any = { //เอาไวเช็ค CHILD ถัดไป
|
||||||
|
0: _data.child1,
|
||||||
|
1: _data.child2,
|
||||||
|
2: _data.child3,
|
||||||
|
3: _data.child4,
|
||||||
|
};
|
||||||
|
const childValue = nextChildMap[body.type];
|
||||||
|
if(_data.privilege === 'NORMAL'){
|
||||||
|
if (Array.isArray(childValue) && childValue.some(item => item != null)) {
|
||||||
|
return new HttpSuccess({ data: [], total: 0 });
|
||||||
|
}
|
||||||
|
}else if(_data.privilege === 'PARENT'){
|
||||||
|
if (body.type == 0){
|
||||||
|
return new HttpSuccess({ data: [], total: 0 });
|
||||||
|
}
|
||||||
|
} else if (_data.privilege === 'CHILD') {
|
||||||
|
const higherChildChecks = [
|
||||||
|
{ type: [0], child: _data.child1, next: _data.child2 },
|
||||||
|
{ type: [0, 1], child: _data.child2, next: _data.child3 },
|
||||||
|
{ type: [0, 1, 2], child: _data.child3, next: _data.child4 },
|
||||||
|
{ type: [0, 1, 2, 3], child: _data.child4, next: true },
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const check of higherChildChecks) {
|
||||||
|
if (Array.isArray(check.child) && check.next == null) {
|
||||||
|
if (check.type.includes(body.type)) {
|
||||||
|
return new HttpSuccess({ data: [], total: 0 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return new HttpSuccess({ data: formattedData, total });
|
return new HttpSuccess({ data: formattedData, total });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -754,6 +754,7 @@ export class EmployeeTempPositionController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("master/list")
|
@Post("master/list")
|
||||||
async listEmp(
|
async listEmp(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
id: string;
|
id: string;
|
||||||
|
|
@ -774,7 +775,7 @@ export class EmployeeTempPositionController extends Controller {
|
||||||
let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||||
let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||||
let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||||
|
let _data = await new permission().PermissionOrgList(request, "SYS_ORG_TEMP");
|
||||||
if (body.type === 0) {
|
if (body.type === 0) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgRootId: body.id,
|
orgRootId: body.id,
|
||||||
|
|
@ -887,6 +888,56 @@ export class EmployeeTempPositionController extends Controller {
|
||||||
.leftJoinAndSelect("positions.posType", "posType")
|
.leftJoinAndSelect("positions.posType", "posType")
|
||||||
.leftJoinAndSelect("positions.posLevel", "posLevel")
|
.leftJoinAndSelect("positions.posLevel", "posLevel")
|
||||||
.where(conditions)
|
.where(conditions)
|
||||||
|
.andWhere(
|
||||||
|
_data.root != undefined && _data.root != null
|
||||||
|
? _data.root[0] != null
|
||||||
|
? `posMaster.orgRootId IN (:...root)`
|
||||||
|
: `posMaster.orgRootId is null`
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
root: _data.root,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
_data.child1 != undefined && _data.child1 != null
|
||||||
|
? _data.child1[0] != null
|
||||||
|
? `posMaster.orgChild1Id IN (:...child1)`
|
||||||
|
: `posMaster.orgChild1Id is null`
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
child1: _data.child1,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
_data.child2 != undefined && _data.child2 != null
|
||||||
|
? _data.child2[0] != null
|
||||||
|
? `posMaster.orgChild2Id IN (:...child2)`
|
||||||
|
: `posMaster.orgChild2Id is null`
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
child2: _data.child2,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
_data.child3 != undefined && _data.child3 != null
|
||||||
|
? _data.child3[0] != null
|
||||||
|
? `posMaster.orgChild3Id IN (:...child3)`
|
||||||
|
: `posMaster.orgChild3Id is null`
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
child3: _data.child3,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
_data.child4 != undefined && _data.child4 != null
|
||||||
|
? _data.child4[0] != null
|
||||||
|
? `posMaster.orgChild4Id IN (:...child4)`
|
||||||
|
: `posMaster.orgChild4Id is null`
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
child4: _data.child4,
|
||||||
|
},
|
||||||
|
)
|
||||||
.orWhere(
|
.orWhere(
|
||||||
new Brackets((qb) => {
|
new Brackets((qb) => {
|
||||||
qb.andWhere(
|
qb.andWhere(
|
||||||
|
|
@ -1078,6 +1129,39 @@ export class EmployeeTempPositionController extends Controller {
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
if(_data.privilege === 'NORMAL'|| _data.privilege === 'PARENT'|| _data.privilege === 'CHILD'){ //PARENT จะไม่มีทางเห็น ROOT , CHILD ยึดจาก CHILD ที่อยู่ลงไปข้างล่างและจะไม่เห็น CHILD ที่อยู่เหนือกว่า
|
||||||
|
const nextChildMap:any = { //เอาไวเช็ค CHILD ถัดไป
|
||||||
|
0: _data.child1,
|
||||||
|
1: _data.child2,
|
||||||
|
2: _data.child3,
|
||||||
|
3: _data.child4,
|
||||||
|
};
|
||||||
|
const childValue = nextChildMap[body.type];
|
||||||
|
if(_data.privilege === 'NORMAL'){
|
||||||
|
if (Array.isArray(childValue) && childValue.some(item => item != null)) {
|
||||||
|
return new HttpSuccess({ data: [], total: 0 });
|
||||||
|
}
|
||||||
|
}else if(_data.privilege === 'PARENT'){
|
||||||
|
if (body.type == 0){
|
||||||
|
return new HttpSuccess({ data: [], total: 0 });
|
||||||
|
}
|
||||||
|
} else if (_data.privilege === 'CHILD') {
|
||||||
|
const higherChildChecks = [
|
||||||
|
{ type: [0], child: _data.child1, next: _data.child2 },
|
||||||
|
{ type: [0, 1], child: _data.child2, next: _data.child3 },
|
||||||
|
{ type: [0, 1, 2], child: _data.child3, next: _data.child4 },
|
||||||
|
{ type: [0, 1, 2, 3], child: _data.child4, next: true },
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const check of higherChildChecks) {
|
||||||
|
if (Array.isArray(check.child) && check.next == null) {
|
||||||
|
if (check.type.includes(body.type)) {
|
||||||
|
return new HttpSuccess({ data: [], total: 0 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return new HttpSuccess({ data: formattedData, total });
|
return new HttpSuccess({ data: formattedData, total });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1958,6 +2042,7 @@ export class EmployeeTempPositionController extends Controller {
|
||||||
},
|
},
|
||||||
relations: [
|
relations: [
|
||||||
"positions",
|
"positions",
|
||||||
|
"positions.posType",
|
||||||
"orgRevision",
|
"orgRevision",
|
||||||
"orgRoot",
|
"orgRoot",
|
||||||
"orgChild1",
|
"orgChild1",
|
||||||
|
|
@ -1993,6 +2078,7 @@ export class EmployeeTempPositionController extends Controller {
|
||||||
profile.posTypeId = position?.posTypeId ?? _null;
|
profile.posTypeId = position?.posTypeId ?? _null;
|
||||||
profile.position = position?.positionName ?? _null;
|
profile.position = position?.positionName ?? _null;
|
||||||
profile.employeeOc = Org ?? _null;
|
profile.employeeOc = Org ?? _null;
|
||||||
|
profile.positionEmployeeGroupId = position?.posType?.posTypeName ?? _null;
|
||||||
profile.positionEmployeePositionId = position?.positionName ?? _null;
|
profile.positionEmployeePositionId = position?.positionName ?? _null;
|
||||||
await this.profileRepository.save(profile);
|
await this.profileRepository.save(profile);
|
||||||
}
|
}
|
||||||
|
|
@ -2029,22 +2115,22 @@ export class EmployeeTempPositionController extends Controller {
|
||||||
if (!dataMaster) {
|
if (!dataMaster) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งนี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งนี้");
|
||||||
}
|
}
|
||||||
if (dataMaster.current_holderId != null) {
|
// if (dataMaster.current_holderId != null) {
|
||||||
const profile = await this.profileRepository.findOne({
|
// const profile = await this.profileRepository.findOne({
|
||||||
where: {
|
// where: {
|
||||||
id: dataMaster.current_holderId,
|
// id: dataMaster.current_holderId,
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
const _null: any = null;
|
// const _null: any = null;
|
||||||
if (profile != null) {
|
// if (profile != null) {
|
||||||
profile.posLevelId = _null;
|
// profile.posLevelId = _null;
|
||||||
profile.posTypeId = _null;
|
// profile.posTypeId = _null;
|
||||||
profile.position = _null;
|
// profile.position = _null;
|
||||||
profile.employeeOc = _null;
|
// profile.employeeOc = _null;
|
||||||
profile.positionEmployeePositionId = _null;
|
// profile.positionEmployeePositionId = _null;
|
||||||
await this.profileRepository.save(profile);
|
// await this.profileRepository.save(profile);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
await this.employeeTempPosMasterRepository.update(id, {
|
await this.employeeTempPosMasterRepository.update(id, {
|
||||||
isSit: false,
|
isSit: false,
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,8 @@ export class ExRetirementController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถขอ Token ได้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถขอ Token ได้");
|
||||||
}
|
}
|
||||||
|
|
||||||
const scope = requestBody.type === "officer" ? "getOfficerRetireData" : "";
|
// const scope = requestBody.type === "officer" ? "getOfficerRetireData" : "";
|
||||||
|
const scope = "getOfficerRetireData";
|
||||||
const startRecord = requestBody.page !== 1 ? (requestBody.page - 1) * 25 : 0;
|
const startRecord = requestBody.page !== 1 ? (requestBody.page - 1) * 25 : 0;
|
||||||
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
|
|
@ -78,6 +79,7 @@ export class ExRetirementController extends Controller {
|
||||||
formData.append("citizenID", requestBody.citizenID);
|
formData.append("citizenID", requestBody.citizenID);
|
||||||
formData.append("firstNameTH", requestBody.firstNameTH);
|
formData.append("firstNameTH", requestBody.firstNameTH);
|
||||||
formData.append("lastNameTH", requestBody.lastNameTH);
|
formData.append("lastNameTH", requestBody.lastNameTH);
|
||||||
|
formData.append("officerTypeID", requestBody.type === "officer" ? "1" : "2");
|
||||||
|
|
||||||
const res = await axios.post(API_URL_BANGKOK + "/getData", formData, {
|
const res = await axios.post(API_URL_BANGKOK + "/getData", formData, {
|
||||||
headers: {
|
headers: {
|
||||||
|
|
@ -96,6 +98,48 @@ export class ExRetirementController extends Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get("/document/{documentId}")
|
||||||
|
async getDocument(@Path("documentId") officerDocumentID: string, @Request() req: any) {
|
||||||
|
let retryCount = 0;
|
||||||
|
const maxRetries = 2;
|
||||||
|
while (retryCount < maxRetries) {
|
||||||
|
try {
|
||||||
|
const token = await getToken(clientId, clientSecret);
|
||||||
|
if (!token) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถขอ Token ได้");
|
||||||
|
}
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("scope", "getOfficerRetireFile");
|
||||||
|
formData.append("officerDocumentID", officerDocumentID);
|
||||||
|
|
||||||
|
const res = await axios.post(API_URL_BANGKOK + "/getData", formData, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
responseType: "arraybuffer",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!req.res.headersSent && !req.res.destroyed) {
|
||||||
|
// Set response headers
|
||||||
|
req.res.setHeader("Content-Type", "application/pdf");
|
||||||
|
req.res.setHeader("Content-Disposition", `inline; filename="${officerDocumentID}.pdf"`);
|
||||||
|
req.res.setHeader("Content-Length", res.data.byteLength.toString());
|
||||||
|
|
||||||
|
req.res.end(Buffer.from(res.data));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
if (error.response?.status === 500 && retryCount < maxRetries - 1) {
|
||||||
|
TokenCache.delete(`${clientId}:${clientSecret}`);
|
||||||
|
retryCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ไม่สามารถติดต่อ API ได้");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getToken(ClientID: string, ClientSecret: string): Promise<string> {
|
async function getToken(ClientID: string, ClientSecret: string): Promise<string> {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { Controller, Post, Route, Security, Tags, Request, UploadedFile } from "tsoa";
|
import { Controller, Post, Route, Security, Tags, Request, UploadedFile } from "tsoa";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import { In, IsNull, LessThanOrEqual, Not } from "typeorm";
|
import { In, IsNull, LessThanOrEqual, Not, Between } from "typeorm";
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
import { UseInterceptors } from "@nestjs/common";
|
import { UseInterceptors } from "@nestjs/common";
|
||||||
import { Profile } from "../entities/Profile";
|
import { Profile } from "../entities/Profile";
|
||||||
|
|
@ -631,465 +631,529 @@ export class ImportDataController extends Controller {
|
||||||
async UploadFileSQLSalary(@Request() request: { user: Record<string, any> }) {
|
async UploadFileSQLSalary(@Request() request: { user: Record<string, any> }) {
|
||||||
let rowCount = 0;
|
let rowCount = 0;
|
||||||
let _null: any = null;
|
let _null: any = null;
|
||||||
let sqlStatements: string[] = [];
|
const batchSize = 200; // เพิ่ม batch size เพื่อประสิทธิภาพที่ดีขึ้น
|
||||||
|
|
||||||
const [profiles, total] = await AppDataSource.getRepository(Profile)
|
// นับจำนวน profiles ทั้งหมดก่อน
|
||||||
.createQueryBuilder("profile")
|
const profileRepo = AppDataSource.getRepository(Profile);
|
||||||
.select(["profile.citizenId", "profile.id"])
|
const totalProfiles = await profileRepo.count();
|
||||||
.orderBy("profile.citizenId", "ASC")
|
|
||||||
// .where("profile.citizenId = '3101702379675'")
|
console.log(
|
||||||
// .where({
|
`Starting OPTIMIZED batch processing: ${totalProfiles} profiles, batch size: ${batchSize}`,
|
||||||
// citizenId: In([
|
);
|
||||||
// // "1100600109451",
|
|
||||||
// // "1209900075508",
|
for (let offset = 0; offset < totalProfiles; offset += batchSize) {
|
||||||
// // "1739900231556",
|
const profiles = await profileRepo
|
||||||
// // "1809900305214",
|
.createQueryBuilder("profile")
|
||||||
// // "1920600228762",
|
.select(["profile.citizenId", "profile.id"])
|
||||||
// // "3101600963742",
|
.orderBy("profile.citizenId", "ASC")
|
||||||
// // "3102401171243",
|
.skip(offset)
|
||||||
// // "3120100454406",
|
.take(batchSize)
|
||||||
// // "3180100306172",
|
.getMany();
|
||||||
// // "3700100094722",
|
|
||||||
// // "3809900116957",
|
console.log(
|
||||||
// "3940900213929",
|
`Processing batch ${Math.floor(offset / batchSize) + 1}/${Math.ceil(totalProfiles / batchSize)} - Querying ${profiles.length} profiles`,
|
||||||
// ]),
|
);
|
||||||
// })
|
|
||||||
.leftJoinAndSelect("profile.profileSalary", "profileSalary")
|
const batchRecords = []; // Array สำหรับเก็บ records ที่จะ batch insert
|
||||||
// .where({ citizenId: "3101702379675" })
|
|
||||||
.where("profileSalary.id IS NULL")
|
// OPTIMIZATION 1: ดึงข้อมูล HR ทั้งหมดของ batch ในครั้งเดียว
|
||||||
// .skip(0)
|
const citizenIds = profiles.map((p) => p.citizenId);
|
||||||
// .take(10000)
|
const allHrData = await this.HR_POSITION_OFFICERRepo.createQueryBuilder("hr")
|
||||||
.getManyAndCount();
|
.where("hr.CIT IN (:...citizenIds)", { citizenIds })
|
||||||
for await (const _item of profiles) {
|
.andWhere("hr.FLAG_PERSON_TYPE = :flag", { flag: "1" })
|
||||||
// ดึงข้อมูลมาโดยไม่ใส่ order
|
.orderBy("hr.CIT", "ASC")
|
||||||
const existingProfile = await this.HR_POSITION_OFFICERRepo.find({
|
.addOrderBy(
|
||||||
where: { CIT: _item.citizenId, FLAG_PERSON_TYPE: "1" },
|
"CASE WHEN hr.MP_POS_DATE IS NULL OR hr.MP_POS_DATE = '' THEN 1 ELSE 0 END",
|
||||||
|
"ASC",
|
||||||
|
)
|
||||||
|
.addOrderBy("STR_TO_DATE(SUBSTRING_INDEX(hr.MP_POS_DATE, ' ', 1), '%d/%m/%Y')", "ASC")
|
||||||
|
.addOrderBy("hr.ORDER_MOVE_POSITION", "ASC")
|
||||||
|
.getMany();
|
||||||
|
|
||||||
|
// จัดกลุ่มข้อมูล HR ตาม citizenId
|
||||||
|
const hrDataByCitizenId = new Map();
|
||||||
|
allHrData.forEach((hr) => {
|
||||||
|
if (!hrDataByCitizenId.has(hr.CIT)) {
|
||||||
|
hrDataByCitizenId.set(hr.CIT, []);
|
||||||
|
}
|
||||||
|
hrDataByCitizenId.get(hr.CIT).push(hr);
|
||||||
});
|
});
|
||||||
|
|
||||||
// sort ด้วย JavaScript
|
// OPTIMIZATION 2: ดึง existing ProfileSalary ทั้งหมดของ batch ในครั้งเดียว
|
||||||
existingProfile.sort((a, b) => {
|
const allHrIds = allHrData.map((hr) => hr.id.toString());
|
||||||
let dateA = new Date().getTime();
|
const existingSalaries = await this.salaryRepo.find({
|
||||||
let dateB = new Date().getTime();
|
where: { refId: In(allHrIds) },
|
||||||
|
select: ["refId"],
|
||||||
if (a.MP_POS_DATE) {
|
|
||||||
const [datePart] = a.MP_POS_DATE.split(" ");
|
|
||||||
const [day, month, year] = datePart.split("/");
|
|
||||||
dateA = new Date(`${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`).getTime();
|
|
||||||
}
|
|
||||||
if (b.MP_POS_DATE) {
|
|
||||||
const [datePart] = b.MP_POS_DATE.split(" ");
|
|
||||||
const [day, month, year] = datePart.split("/");
|
|
||||||
dateB = new Date(`${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`).getTime();
|
|
||||||
}
|
|
||||||
if (dateA !== dateB) {
|
|
||||||
return dateA - dateB; // ASC
|
|
||||||
}
|
|
||||||
return a.ORDER_MOVE_POSITION - b.ORDER_MOVE_POSITION; // ASC
|
|
||||||
});
|
});
|
||||||
|
const existingSalaryRefIds = new Set(existingSalaries.map((s) => s.refId));
|
||||||
|
|
||||||
let order = 1;
|
for (const _item of profiles) {
|
||||||
for await (const item of existingProfile) {
|
const existingProfile = hrDataByCitizenId.get(_item.citizenId) || [];
|
||||||
rowCount++;
|
|
||||||
const profileSalary: any = new ProfileSalary();
|
|
||||||
profileSalary.profileId = _item.id;
|
|
||||||
profileSalary.order = order;
|
|
||||||
order = order + 1;
|
|
||||||
profileSalary.commandNo = isNaN(item.MP_COMMAND_NUM) ? null : item.MP_COMMAND_NUM;
|
|
||||||
profileSalary.commandYear = isNaN(item.MP_COMMAND_NUM)
|
|
||||||
? null
|
|
||||||
: item.CUR_YEAR > 2500
|
|
||||||
? item.CUR_YEAR - 543
|
|
||||||
: item.CUR_YEAR;
|
|
||||||
|
|
||||||
let MP_COMMAND_DATE = "";
|
let order = 1;
|
||||||
if (item.MP_COMMAND_DATE) {
|
for (const item of existingProfile) {
|
||||||
const [datePart] = item.MP_COMMAND_DATE.split(" ");
|
rowCount++;
|
||||||
const [day, month, year] = datePart.split("/");
|
|
||||||
MP_COMMAND_DATE = `${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`;
|
// ใช้ Set lookup แทนการ query database
|
||||||
}
|
if (existingSalaryRefIds.has(item.id.toString())) continue;
|
||||||
let MP_POS_DATE = "";
|
const profileSalary: any = new ProfileSalary();
|
||||||
if (item.MP_POS_DATE) {
|
profileSalary.profileId = _item.id;
|
||||||
const [datePart] = item.MP_POS_DATE.split(" ");
|
profileSalary.order = order;
|
||||||
const [day, month, year] = datePart.split("/");
|
order = order + 1;
|
||||||
MP_POS_DATE = `${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`;
|
profileSalary.commandNo = isNaN(item.MP_COMMAND_NUM) ? null : item.MP_COMMAND_NUM;
|
||||||
}
|
|
||||||
profileSalary.commandDateSign = MP_COMMAND_DATE == null ? _null : new Date(MP_COMMAND_DATE);
|
// แก้ไข logic การกำหนด commandYear
|
||||||
profileSalary.commandDateAffect = MP_POS_DATE == null ? _null : new Date(MP_POS_DATE);
|
if (isNaN(item.CUR_YEAR) || item.CUR_YEAR == null) {
|
||||||
if (
|
profileSalary.commandYear = null;
|
||||||
[
|
} else {
|
||||||
"0",
|
profileSalary.commandYear = item.CUR_YEAR > 2500 ? item.CUR_YEAR - 543 : item.CUR_YEAR;
|
||||||
"11",
|
}
|
||||||
"22",
|
|
||||||
"31",
|
let MP_COMMAND_DATE = "";
|
||||||
"39",
|
if (item.MP_COMMAND_DATE && item.MP_COMMAND_DATE.trim() !== "") {
|
||||||
"45",
|
try {
|
||||||
"46",
|
const [datePart] = item.MP_COMMAND_DATE.split(" ");
|
||||||
"47",
|
const [day, month, year] = datePart.split("/");
|
||||||
"49",
|
if (day && month && year) {
|
||||||
"50",
|
MP_COMMAND_DATE = `${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`;
|
||||||
"51",
|
}
|
||||||
"60",
|
} catch (error) {
|
||||||
"61",
|
console.warn(`Invalid MP_COMMAND_DATE format: ${item.MP_COMMAND_DATE}`);
|
||||||
"62",
|
}
|
||||||
"99",
|
}
|
||||||
].includes(item.FLAG_TO_NAME_CODE)
|
let MP_POS_DATE = "";
|
||||||
) {
|
if (item.MP_POS_DATE && item.MP_POS_DATE.trim() !== "") {
|
||||||
profileSalary.commandCode = "0";
|
try {
|
||||||
profileSalary.commandName = "อื่น ๆ";
|
const [datePart] = item.MP_POS_DATE.split(" ");
|
||||||
} else if (["1", "58"].includes(item.FLAG_TO_NAME_CODE)) {
|
const [day, month, year] = datePart.split("/");
|
||||||
profileSalary.commandCode = "1";
|
if (day && month && year) {
|
||||||
profileSalary.commandName = "บรรจุและแต่งตั้งผู้สอบแข่งขันได้";
|
MP_POS_DATE = `${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`;
|
||||||
} else if (["23"].includes(item.FLAG_TO_NAME_CODE)) {
|
}
|
||||||
profileSalary.commandCode = "2";
|
} catch (error) {
|
||||||
profileSalary.commandName = "บรรจุและแต่งตั้งผู้ได้รับคัดเลือก";
|
console.warn(`Invalid MP_POS_DATE format: ${item.MP_POS_DATE}`);
|
||||||
} else if (["3", "6", "34", "36", "37"].includes(item.FLAG_TO_NAME_CODE)) {
|
}
|
||||||
profileSalary.commandCode = "3";
|
}
|
||||||
profileSalary.commandName = "แต่งตั้ง ย้าย";
|
profileSalary.commandDateSign =
|
||||||
} else if (["10", "55", "56"].includes(item.FLAG_TO_NAME_CODE)) {
|
MP_COMMAND_DATE == null ? _null : new Date(MP_COMMAND_DATE);
|
||||||
profileSalary.commandCode = "4";
|
profileSalary.commandDateAffect = MP_POS_DATE == null ? _null : new Date(MP_POS_DATE);
|
||||||
profileSalary.commandName = "เลื่อน";
|
|
||||||
} else if (["14"].includes(item.FLAG_TO_NAME_CODE)) {
|
|
||||||
profileSalary.commandCode = "5";
|
|
||||||
profileSalary.commandName = "เลื่อนเงินเดือนตามปกติ";
|
|
||||||
} else if (
|
|
||||||
["8", "20", "24", "25", "43", "44", "52", "66", "67"].includes(item.FLAG_TO_NAME_CODE)
|
|
||||||
) {
|
|
||||||
profileSalary.commandCode = "6";
|
|
||||||
profileSalary.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ";
|
|
||||||
} else if (["-"].includes(item.FLAG_TO_NAME_CODE)) {
|
|
||||||
profileSalary.commandCode = "7";
|
|
||||||
profileSalary.commandName = "เงินพิเศษอื่น ๆ";
|
|
||||||
} else if (["38", "40", "53", "54"].includes(item.FLAG_TO_NAME_CODE)) {
|
|
||||||
profileSalary.commandCode = "8";
|
|
||||||
profileSalary.commandName = "ปรับโครงสร้าง";
|
|
||||||
} else if (["12"].includes(item.FLAG_TO_NAME_CODE)) {
|
|
||||||
profileSalary.commandCode = "9";
|
|
||||||
profileSalary.commandName = "พ้นทดลองปฏิบัติราชการ";
|
|
||||||
} else if (["2", "18"].includes(item.FLAG_TO_NAME_CODE)) {
|
|
||||||
profileSalary.commandCode = "10";
|
|
||||||
profileSalary.commandName = "บรรจุกลับ";
|
|
||||||
} else if (["4", "32", "33"].includes(item.FLAG_TO_NAME_CODE)) {
|
|
||||||
profileSalary.commandCode = "11";
|
|
||||||
profileSalary.commandName = "รับโอน";
|
|
||||||
} else if (["5"].includes(item.FLAG_TO_NAME_CODE)) {
|
|
||||||
profileSalary.commandCode = "12";
|
|
||||||
profileSalary.commandName = "ให้โอน";
|
|
||||||
} else if (["15", "95"].includes(item.FLAG_TO_NAME_CODE)) {
|
|
||||||
profileSalary.commandCode = "13";
|
|
||||||
profileSalary.commandName = "แก้ไขคำสั่ง";
|
|
||||||
} else if (["19"].includes(item.FLAG_TO_NAME_CODE)) {
|
|
||||||
profileSalary.commandCode = "14";
|
|
||||||
profileSalary.commandName = "ยกเลิกคำสั่ง";
|
|
||||||
} else if (["27", "35"].includes(item.FLAG_TO_NAME_CODE)) {
|
|
||||||
profileSalary.commandCode = "15";
|
|
||||||
profileSalary.commandName = "ลาออกจากราชการ";
|
|
||||||
} else if (["13", "17", "21", "28", "29", "30", "59"].includes(item.FLAG_TO_NAME_CODE)) {
|
|
||||||
profileSalary.commandCode = "16";
|
|
||||||
profileSalary.commandName = "พ้นจากราชการ";
|
|
||||||
} else if (["7", "9", "16", "26", "63", "68"].includes(item.FLAG_TO_NAME_CODE)) {
|
|
||||||
profileSalary.commandCode = "17";
|
|
||||||
profileSalary.commandName = "รักษาราชการ, ช่วยราชการ";
|
|
||||||
}
|
|
||||||
if (item.FLAG_TO_NAME_CODE == null && item.FLAG_TO_NAME == "ลาศึกษาต่อ") {
|
|
||||||
profileSalary.commandCode = "0";
|
|
||||||
profileSalary.commandName = "อื่น ๆ";
|
|
||||||
} else if (
|
|
||||||
item.FLAG_TO_NAME_CODE == null &&
|
|
||||||
(item.FLAG_TO_NAME == "เลื่อน 1 ขั้นและเลื่อนระดับ" ||
|
|
||||||
item.FLAG_TO_NAME == "เลื่อน 0.5 ขั้นและเลื่อนระดับ")
|
|
||||||
) {
|
|
||||||
profileSalary.commandCode = "4";
|
|
||||||
profileSalary.commandName = "เลื่อน";
|
|
||||||
} else if (item.FLAG_TO_NAME_CODE == null && item.FLAG_TO_NAME == "เลื่อนเงินเดือน") {
|
|
||||||
profileSalary.commandCode = "5";
|
|
||||||
profileSalary.commandName = "เลื่อนเงินเดือนตามปกติ";
|
|
||||||
} else if (
|
|
||||||
item.FLAG_TO_NAME_CODE == null &&
|
|
||||||
(item.FLAG_TO_NAME == "ปรับตามบัญชีเงินเดือนใหม่" ||
|
|
||||||
item.FLAG_TO_NAME == "เลื่อนเงินเดือน" ||
|
|
||||||
item.FLAG_TO_NAME == "ปรับเงินเดือนตาม กพ.")
|
|
||||||
) {
|
|
||||||
profileSalary.commandCode = "6";
|
|
||||||
profileSalary.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ";
|
|
||||||
} else if (
|
|
||||||
item.FLAG_TO_NAME_CODE == null &&
|
|
||||||
item.FLAG_TO_NAME == "แต่งตั้งตามการปรับปรุงโครงฯ"
|
|
||||||
) {
|
|
||||||
profileSalary.commandCode = "8";
|
|
||||||
profileSalary.commandName = "ปรับโครงสร้าง";
|
|
||||||
} else if (item.FLAG_TO_NAME_CODE == null && item.FLAG_TO_NAME == "พ้นทดลองปฏิบัติราชการ") {
|
|
||||||
profileSalary.commandCode = "9";
|
|
||||||
profileSalary.commandName = "พ้นทดลองปฏิบัติราชการ";
|
|
||||||
} else if (item.FLAG_TO_NAME_CODE == null && item.FLAG_TO_NAME == "ให้โอนมา") {
|
|
||||||
profileSalary.commandCode = "11";
|
|
||||||
profileSalary.commandName = "รับโอน";
|
|
||||||
} else if (
|
|
||||||
item.FLAG_TO_NAME_CODE == null &&
|
|
||||||
item.FLAG_TO_NAME == "โอนไปปฏิบัติราชการที่อื่น"
|
|
||||||
) {
|
|
||||||
profileSalary.commandCode = "12";
|
|
||||||
profileSalary.commandName = "ให้โอน";
|
|
||||||
} else if (item.FLAG_TO_NAME_CODE == null && item.FLAG_TO_NAME == "ยกเลิกคำสั่ง") {
|
|
||||||
profileSalary.commandCode = "14";
|
|
||||||
profileSalary.commandName = "ยกเลิกคำสั่ง";
|
|
||||||
} else if (item.FLAG_TO_NAME_CODE == null && item.FLAG_TO_NAME == "รักษาการในตำแหน่ง") {
|
|
||||||
profileSalary.commandCode = "17";
|
|
||||||
profileSalary.commandName = "รักษาราชการ, ช่วยราชการ";
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
(profileSalary.commandCode == null || profileSalary.commandCode == undefined) &&
|
|
||||||
(profileSalary.commandName == null || profileSalary.commandName == undefined)
|
|
||||||
) {
|
|
||||||
if (
|
if (
|
||||||
[
|
[
|
||||||
"อื่นๆ",
|
"0",
|
||||||
"กลับไปปฏิบัติงานทางต้นสังกัด",
|
"11",
|
||||||
"เปลี่ยนประเภทข้าราชการ",
|
"22",
|
||||||
"โอนสับเปลี่ยน",
|
"31",
|
||||||
"เข้ารับฝึกอบรม",
|
"39",
|
||||||
"ดูงาน",
|
"45",
|
||||||
"ศึกษาต่อ",
|
"46",
|
||||||
"ขยายเวลาเข้ารับการฝึกอบรม",
|
"47",
|
||||||
"ขยายเวลาศึกษาต่อ",
|
"49",
|
||||||
"รายงานตัวกลับเข้าปฏิบัติราชการ",
|
"50",
|
||||||
"ไม่ได้เลื่อนขั้น",
|
"51",
|
||||||
"ตัดเงินเดือน",
|
"60",
|
||||||
"ลดขั้นเงินเดือน",
|
"61",
|
||||||
"ให้ข้าราชการกลับเข้ารับราชการ",
|
"62",
|
||||||
"ไม่ระบุ",
|
"99",
|
||||||
].includes(item.FLAG_TO_NAME)
|
].includes(item.FLAG_TO_NAME_CODE)
|
||||||
) {
|
) {
|
||||||
profileSalary.commandCode = "0";
|
profileSalary.commandCode = "0";
|
||||||
profileSalary.commandName = "อื่น ๆ";
|
profileSalary.commandName = "อื่น ๆ";
|
||||||
} else if (
|
} else if (["1", "58"].includes(item.FLAG_TO_NAME_CODE)) {
|
||||||
[
|
|
||||||
"บรรจุและแต่งตั้งผู้สอบแข่งขันได้",
|
|
||||||
"ทดลองปฎิบัติราชการ",
|
|
||||||
"ทดลองปฏิบัติราชการและปรับวุฒิ",
|
|
||||||
"บรรจุใหม่",
|
|
||||||
].includes(item.FLAG_TO_NAME)
|
|
||||||
) {
|
|
||||||
profileSalary.commandCode = "1";
|
profileSalary.commandCode = "1";
|
||||||
profileSalary.commandName = "บรรจุและแต่งตั้งผู้สอบแข่งขันได้";
|
profileSalary.commandName = "บรรจุและแต่งตั้งผู้สอบแข่งขันได้";
|
||||||
} else if (["บรรจุและแต่งตั้งผู้ได้รับการคัดเลือก"].includes(item.FLAG_TO_NAME)) {
|
} else if (["23"].includes(item.FLAG_TO_NAME_CODE)) {
|
||||||
profileSalary.commandCode = "2";
|
profileSalary.commandCode = "2";
|
||||||
profileSalary.commandName = "บรรจุและแต่งตั้งผู้ได้รับคัดเลือก";
|
profileSalary.commandName = "บรรจุและแต่งตั้งผู้ได้รับคัดเลือก";
|
||||||
} else if (
|
} else if (["3", "6", "34", "36", "37"].includes(item.FLAG_TO_NAME_CODE)) {
|
||||||
[
|
|
||||||
"แต่งตั้ง (ย้ายสับเปลี่ยน)",
|
|
||||||
"แต่งตั้ง (ย้าย)",
|
|
||||||
"แต่งตั้ง",
|
|
||||||
"เปลี่ยนสายงาน",
|
|
||||||
"เปลี่ยนตำแหน่ง",
|
|
||||||
"ตัดโอนตำแหน่ง",
|
|
||||||
].includes(item.FLAG_TO_NAME)
|
|
||||||
) {
|
|
||||||
profileSalary.commandCode = "3";
|
profileSalary.commandCode = "3";
|
||||||
profileSalary.commandName = "แต่งตั้ง ย้าย";
|
profileSalary.commandName = "แต่งตั้ง ย้าย";
|
||||||
} else if (
|
} else if (["10", "55", "56"].includes(item.FLAG_TO_NAME_CODE)) {
|
||||||
["เลื่อนและแต่งตั้ง", "เลื่อนระดับ", "เลื่อนเงินเดือนและระดับ"].includes(
|
|
||||||
item.FLAG_TO_NAME,
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
profileSalary.commandCode = "4";
|
profileSalary.commandCode = "4";
|
||||||
profileSalary.commandName = "เลื่อน";
|
profileSalary.commandName = "เลื่อน";
|
||||||
} else if (["เลื่อนขั้นเงินเดือน", "เลื่อนเงินเดือน"].includes(item.FLAG_TO_NAME)) {
|
} else if (["14"].includes(item.FLAG_TO_NAME_CODE)) {
|
||||||
profileSalary.commandCode = "5";
|
profileSalary.commandCode = "5";
|
||||||
profileSalary.commandName = "เลื่อนเงินเดือนตามปกติ";
|
profileSalary.commandName = "เลื่อนเงินเดือนตามปกติ";
|
||||||
} else if (
|
} else if (
|
||||||
[
|
["8", "20", "24", "25", "43", "44", "52", "66", "67"].includes(item.FLAG_TO_NAME_CODE)
|
||||||
"ปรับเงินเดือนตามคุณวุฒิ",
|
|
||||||
"ได้รับเงินตอบแทนพิเศษ",
|
|
||||||
"เงินเพิ่มการครองชีพชั่วคราว",
|
|
||||||
"เลื่อนขั้นเงินเดือนกรณีพิเศษ",
|
|
||||||
"ปรับอัตราเงินเดือนตามบัญชีอัตราเงินเดือนใหม่ ท้าย พ.ร.บ. เงินเดือนและเงินประจำตำ",
|
|
||||||
"ปรับอัตราเงินเดือนตามพระราชกฤษฎีกา การปรับอัตราเงินเดือนของข้าราชการ",
|
|
||||||
"เลื่อนขั้นเงินเดือน (เพิ่มเติม)",
|
|
||||||
"ปรับอัตราเงินเดือน",
|
|
||||||
"ให้ข้าราชการได้รับเงินเดือนตามคุณวุฒิ",
|
|
||||||
].includes(item.FLAG_TO_NAME)
|
|
||||||
) {
|
) {
|
||||||
profileSalary.commandCode = "6";
|
profileSalary.commandCode = "6";
|
||||||
profileSalary.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ";
|
profileSalary.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ";
|
||||||
} else if (["--"].includes(item.FLAG_TO_NAME)) {
|
} else if (["-"].includes(item.FLAG_TO_NAME_CODE)) {
|
||||||
profileSalary.commandCode = "7";
|
profileSalary.commandCode = "7";
|
||||||
profileSalary.commandName = "เงินพิเศษอื่น ๆ";
|
profileSalary.commandName = "เงินพิเศษอื่น ๆ";
|
||||||
|
} else if (["38", "40", "53", "54"].includes(item.FLAG_TO_NAME_CODE)) {
|
||||||
|
profileSalary.commandCode = "8";
|
||||||
|
profileSalary.commandName = "ปรับโครงสร้าง";
|
||||||
|
} else if (["12"].includes(item.FLAG_TO_NAME_CODE)) {
|
||||||
|
profileSalary.commandCode = "9";
|
||||||
|
profileSalary.commandName = "พ้นทดลองปฏิบัติราชการ";
|
||||||
|
} else if (["2", "18"].includes(item.FLAG_TO_NAME_CODE)) {
|
||||||
|
profileSalary.commandCode = "10";
|
||||||
|
profileSalary.commandName = "บรรจุกลับ";
|
||||||
|
} else if (["4", "32", "33"].includes(item.FLAG_TO_NAME_CODE)) {
|
||||||
|
profileSalary.commandCode = "11";
|
||||||
|
profileSalary.commandName = "รับโอน";
|
||||||
|
} else if (["5"].includes(item.FLAG_TO_NAME_CODE)) {
|
||||||
|
profileSalary.commandCode = "12";
|
||||||
|
profileSalary.commandName = "ให้โอน";
|
||||||
|
} else if (["15", "95"].includes(item.FLAG_TO_NAME_CODE)) {
|
||||||
|
profileSalary.commandCode = "13";
|
||||||
|
profileSalary.commandName = "แก้ไขคำสั่ง";
|
||||||
|
} else if (["19"].includes(item.FLAG_TO_NAME_CODE)) {
|
||||||
|
profileSalary.commandCode = "14";
|
||||||
|
profileSalary.commandName = "ยกเลิกคำสั่ง";
|
||||||
|
} else if (["27", "35"].includes(item.FLAG_TO_NAME_CODE)) {
|
||||||
|
profileSalary.commandCode = "15";
|
||||||
|
profileSalary.commandName = "ลาออกจากราชการ";
|
||||||
|
} else if (["13", "17", "21", "28", "29", "30", "59"].includes(item.FLAG_TO_NAME_CODE)) {
|
||||||
|
profileSalary.commandCode = "16";
|
||||||
|
profileSalary.commandName = "พ้นจากราชการ";
|
||||||
|
} else if (["7", "9", "16", "26", "63", "68"].includes(item.FLAG_TO_NAME_CODE)) {
|
||||||
|
profileSalary.commandCode = "17";
|
||||||
|
profileSalary.commandName = "รักษาราชการ, ช่วยราชการ";
|
||||||
|
}
|
||||||
|
if (item.FLAG_TO_NAME_CODE == null && item.FLAG_TO_NAME == "ลาศึกษาต่อ") {
|
||||||
|
profileSalary.commandCode = "0";
|
||||||
|
profileSalary.commandName = "อื่น ๆ";
|
||||||
} else if (
|
} else if (
|
||||||
["ปรับโครงสร้าง", "แต่งตั้ง (จัดคนลงกรอบ)", "แต่งตั้งตามแผนอัตรากำลังฯ"].includes(
|
item.FLAG_TO_NAME_CODE == null &&
|
||||||
item.FLAG_TO_NAME,
|
(item.FLAG_TO_NAME == "เลื่อน 1 ขั้นและเลื่อนระดับ" ||
|
||||||
)
|
item.FLAG_TO_NAME == "เลื่อน 0.5 ขั้นและเลื่อนระดับ")
|
||||||
|
) {
|
||||||
|
profileSalary.commandCode = "4";
|
||||||
|
profileSalary.commandName = "เลื่อน";
|
||||||
|
} else if (item.FLAG_TO_NAME_CODE == null && item.FLAG_TO_NAME == "เลื่อนเงินเดือน") {
|
||||||
|
profileSalary.commandCode = "5";
|
||||||
|
profileSalary.commandName = "เลื่อนเงินเดือนตามปกติ";
|
||||||
|
} else if (
|
||||||
|
item.FLAG_TO_NAME_CODE == null &&
|
||||||
|
(item.FLAG_TO_NAME == "ปรับตามบัญชีเงินเดือนใหม่" ||
|
||||||
|
item.FLAG_TO_NAME == "เลื่อนเงินเดือน" ||
|
||||||
|
item.FLAG_TO_NAME == "ปรับเงินเดือนตาม กพ.")
|
||||||
|
) {
|
||||||
|
profileSalary.commandCode = "6";
|
||||||
|
profileSalary.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ";
|
||||||
|
} else if (
|
||||||
|
item.FLAG_TO_NAME_CODE == null &&
|
||||||
|
item.FLAG_TO_NAME == "แต่งตั้งตามการปรับปรุงโครงฯ"
|
||||||
) {
|
) {
|
||||||
profileSalary.commandCode = "8";
|
profileSalary.commandCode = "8";
|
||||||
profileSalary.commandName = "ปรับโครงสร้าง";
|
profileSalary.commandName = "ปรับโครงสร้าง";
|
||||||
} else if (["พ้นทดลองปฏิบัติราชการ"].includes(item.FLAG_TO_NAME)) {
|
} else if (
|
||||||
|
item.FLAG_TO_NAME_CODE == null &&
|
||||||
|
item.FLAG_TO_NAME == "พ้นทดลองปฏิบัติราชการ"
|
||||||
|
) {
|
||||||
profileSalary.commandCode = "9";
|
profileSalary.commandCode = "9";
|
||||||
profileSalary.commandName = "พ้นทดลองปฏิบัติราชการ";
|
profileSalary.commandName = "พ้นทดลองปฏิบัติราชการ";
|
||||||
} else if (
|
} else if (item.FLAG_TO_NAME_CODE == null && item.FLAG_TO_NAME == "ให้โอนมา") {
|
||||||
[
|
|
||||||
"บรรจุกลับ",
|
|
||||||
"บรรจุกลับข้าราชการ",
|
|
||||||
"บรรจุและแต่งตั้งผู้ไปรับราชการทหารกลับเข้ารับราชการ",
|
|
||||||
].includes(item.FLAG_TO_NAME)
|
|
||||||
) {
|
|
||||||
profileSalary.commandCode = "10";
|
|
||||||
profileSalary.commandName = "บรรจุกลับ";
|
|
||||||
} else if (
|
|
||||||
[
|
|
||||||
"รับโอนข้าราชการตามกฎหมายอื่น",
|
|
||||||
"รับโอนข้าราชการตามกฎหมายอื่น ผู้สอบแข่งขันได้",
|
|
||||||
"รับโอนข้าราชการตามกฏหมายอื่น โดยการคัดเลือก",
|
|
||||||
].includes(item.FLAG_TO_NAME)
|
|
||||||
) {
|
|
||||||
profileSalary.commandCode = "11";
|
profileSalary.commandCode = "11";
|
||||||
profileSalary.commandName = "รับโอน";
|
profileSalary.commandName = "รับโอน";
|
||||||
} else if (["ให้โอน"].includes(item.FLAG_TO_NAME)) {
|
} else if (
|
||||||
|
item.FLAG_TO_NAME_CODE == null &&
|
||||||
|
item.FLAG_TO_NAME == "โอนไปปฏิบัติราชการที่อื่น"
|
||||||
|
) {
|
||||||
profileSalary.commandCode = "12";
|
profileSalary.commandCode = "12";
|
||||||
profileSalary.commandName = "ให้โอน";
|
profileSalary.commandName = "ให้โอน";
|
||||||
} else if (["แก้ไขคำสั่ง"].includes(item.FLAG_TO_NAME)) {
|
} else if (item.FLAG_TO_NAME_CODE == null && item.FLAG_TO_NAME == "ยกเลิกคำสั่ง") {
|
||||||
profileSalary.commandCode = "13";
|
|
||||||
profileSalary.commandName = "แก้ไขคำสั่ง";
|
|
||||||
} else if (["ยกเลิกคำสั่ง"].includes(item.FLAG_TO_NAME)) {
|
|
||||||
profileSalary.commandCode = "14";
|
profileSalary.commandCode = "14";
|
||||||
profileSalary.commandName = "ยกเลิกคำสั่ง";
|
profileSalary.commandName = "ยกเลิกคำสั่ง";
|
||||||
} else if (
|
} else if (item.FLAG_TO_NAME_CODE == null && item.FLAG_TO_NAME == "รักษาการในตำแหน่ง") {
|
||||||
[
|
|
||||||
"ลาออกจากราชการ",
|
|
||||||
"พ้นจากราชการ/ลาออกจากราชการตามมาตรการพัฒนาและบริหารกำลังคน",
|
|
||||||
].includes(item.FLAG_TO_NAME)
|
|
||||||
) {
|
|
||||||
profileSalary.commandCode = "15";
|
|
||||||
profileSalary.commandName = "ลาออกจากราชการ";
|
|
||||||
} else if (
|
|
||||||
[
|
|
||||||
"พ้นจากราชการ/เพื่อไปปฏิบัติราชการทหาร",
|
|
||||||
"เกษียณ",
|
|
||||||
"ไม่พ้นทดลองปฏิบัติราชการ",
|
|
||||||
"พ้นจากราชการ/ให้ออก",
|
|
||||||
"พ้นจากราชการ/ไล่ออก",
|
|
||||||
"พ้นจากราชการ/เสียชีวิต",
|
|
||||||
"พ้นจากราชการ/ปลดออก",
|
|
||||||
].includes(item.FLAG_TO_NAME)
|
|
||||||
) {
|
|
||||||
profileSalary.commandCode = "16";
|
|
||||||
profileSalary.commandName = "พ้นจากราชการ";
|
|
||||||
} else if (
|
|
||||||
[
|
|
||||||
"แต่งตั้งข้าราชการรักษาราชการแทน",
|
|
||||||
"ช่วยราชการ",
|
|
||||||
"รักษาการ",
|
|
||||||
"รักษาราชการแทน",
|
|
||||||
"มอบหมายให้ปฏิบัติหน้าที่",
|
|
||||||
"มอบหมายข้าราชการปฏิบัติหน้าที่แทน",
|
|
||||||
].includes(item.FLAG_TO_NAME)
|
|
||||||
) {
|
|
||||||
profileSalary.commandCode = "17";
|
profileSalary.commandCode = "17";
|
||||||
profileSalary.commandName = "รักษาราชการ, ช่วยราชการ";
|
profileSalary.commandName = "รักษาราชการ, ช่วยราชการ";
|
||||||
} else {
|
|
||||||
profileSalary.commandCode = "0";
|
|
||||||
profileSalary.commandName = item.FLAG_TO_NAME;
|
|
||||||
}
|
}
|
||||||
}
|
if (
|
||||||
profileSalary.posNoAbb = item.POS_NUM_NAME;
|
(profileSalary.commandCode == null || profileSalary.commandCode == undefined) &&
|
||||||
profileSalary.posNo = item.POS_NUM_CODE;
|
(profileSalary.commandName == null || profileSalary.commandName == undefined)
|
||||||
profileSalary.positionName = item.WORK_LINE_NAME;
|
) {
|
||||||
var positionType = _null;
|
if (
|
||||||
var positionLevel = _null;
|
[
|
||||||
if (item.MP_CEE == "21") {
|
"อื่นๆ",
|
||||||
positionType = "ทั่วไป";
|
"กลับไปปฏิบัติงานทางต้นสังกัด",
|
||||||
positionLevel = "ปฏิบัติงาน";
|
"เปลี่ยนประเภทข้าราชการ",
|
||||||
} else if (item.MP_CEE == "22") {
|
"โอนสับเปลี่ยน",
|
||||||
positionType = "ทั่วไป";
|
"เข้ารับฝึกอบรม",
|
||||||
positionLevel = "ชำนาญงาน";
|
"ดูงาน",
|
||||||
} else if (item.MP_CEE == "23") {
|
"ศึกษาต่อ",
|
||||||
positionType = "ทั่วไป";
|
"ขยายเวลาเข้ารับการฝึกอบรม",
|
||||||
positionLevel = "อาวุโส";
|
"ขยายเวลาศึกษาต่อ",
|
||||||
} else if (item.MP_CEE == "24") {
|
"รายงานตัวกลับเข้าปฏิบัติราชการ",
|
||||||
positionType = "ทั่วไป";
|
"ไม่ได้เลื่อนขั้น",
|
||||||
positionLevel = "อาวุโสเฉพาะสายงานที่กำหนด";
|
"ตัดเงินเดือน",
|
||||||
} else if (item.MP_CEE == "25") {
|
"ลดขั้นเงินเดือน",
|
||||||
positionType = "ทั่วไป";
|
"ให้ข้าราชการกลับเข้ารับราชการ",
|
||||||
positionLevel = "ทักษะพิเศษ";
|
"ไม่ระบุ",
|
||||||
} else if (item.MP_CEE == "26") {
|
].includes(item.FLAG_TO_NAME)
|
||||||
positionType = "วิชาการ";
|
) {
|
||||||
positionLevel = "ปฏิบัติการ";
|
profileSalary.commandCode = "0";
|
||||||
} else if (item.MP_CEE == "27") {
|
profileSalary.commandName = "อื่น ๆ";
|
||||||
positionType = "วิชาการ";
|
} else if (
|
||||||
positionLevel = "ชำนาญการ";
|
[
|
||||||
} else if (item.MP_CEE == "28") {
|
"บรรจุและแต่งตั้งผู้สอบแข่งขันได้",
|
||||||
positionType = "วิชาการ";
|
"ทดลองปฎิบัติราชการ",
|
||||||
positionLevel = "ชำนาญการพิเศษ";
|
"ทดลองปฏิบัติราชการและปรับวุฒิ",
|
||||||
} else if (item.MP_CEE == "29") {
|
"บรรจุใหม่",
|
||||||
positionType = "วิชาการ";
|
].includes(item.FLAG_TO_NAME)
|
||||||
positionLevel = "เชี่ยวชาญ";
|
) {
|
||||||
} else if (item.MP_CEE == "30") {
|
profileSalary.commandCode = "1";
|
||||||
positionType = "วิชาการ";
|
profileSalary.commandName = "บรรจุและแต่งตั้งผู้สอบแข่งขันได้";
|
||||||
positionLevel = "ทรงคุณวุฒิ";
|
} else if (["บรรจุและแต่งตั้งผู้ได้รับการคัดเลือก"].includes(item.FLAG_TO_NAME)) {
|
||||||
} else if (item.MP_CEE == "31") {
|
profileSalary.commandCode = "2";
|
||||||
positionType = "วิชาการ";
|
profileSalary.commandName = "บรรจุและแต่งตั้งผู้ได้รับคัดเลือก";
|
||||||
positionLevel = "ทรงคุณวุฒิเฉพาะสายงานที่กำหนด";
|
} else if (
|
||||||
} else if (item.MP_CEE == "32") {
|
[
|
||||||
positionType = "อำนวยการ";
|
"แต่งตั้ง (ย้ายสับเปลี่ยน)",
|
||||||
positionLevel = "ต้น";
|
"แต่งตั้ง (ย้าย)",
|
||||||
} else if (item.MP_CEE == "33") {
|
"แต่งตั้ง",
|
||||||
positionType = "อำนวยการ";
|
"เปลี่ยนสายงาน",
|
||||||
positionLevel = "สูง";
|
"เปลี่ยนตำแหน่ง",
|
||||||
} else if (item.MP_CEE == "34") {
|
"ตัดโอนตำแหน่ง",
|
||||||
positionType = "บริหาร";
|
].includes(item.FLAG_TO_NAME)
|
||||||
positionLevel = "ต้น";
|
) {
|
||||||
} else if (item.MP_CEE == "35") {
|
profileSalary.commandCode = "3";
|
||||||
positionType = "บริหาร";
|
profileSalary.commandName = "แต่งตั้ง ย้าย";
|
||||||
positionLevel = "สูง";
|
} else if (
|
||||||
} else {
|
["เลื่อนและแต่งตั้ง", "เลื่อนระดับ", "เลื่อนเงินเดือนและระดับ"].includes(
|
||||||
profileSalary.positionCee = item.MP_CEE;
|
item.FLAG_TO_NAME,
|
||||||
}
|
)
|
||||||
profileSalary.positionType = positionType;
|
) {
|
||||||
profileSalary.positionLevel = positionLevel;
|
profileSalary.commandCode = "4";
|
||||||
profileSalary.orgRoot = item.DEPARTMENT_NAME;
|
profileSalary.commandName = "เลื่อน";
|
||||||
profileSalary.orgChild1 = item.DIVISION_NAME;
|
} else if (["เลื่อนขั้นเงินเดือน", "เลื่อนเงินเดือน"].includes(item.FLAG_TO_NAME)) {
|
||||||
profileSalary.orgChild2 = item.SECTION_NAME;
|
profileSalary.commandCode = "5";
|
||||||
profileSalary.orgChild3 = item.JOB_NAME;
|
profileSalary.commandName = "เลื่อนเงินเดือนตามปกติ";
|
||||||
if (item.DEPARTMENT_CODE == "50") {
|
} else if (
|
||||||
profileSalary.orgRoot = item.DIVISION_NAME;
|
[
|
||||||
profileSalary.orgChild1 = item.SECTION_NAME;
|
"ปรับเงินเดือนตามคุณวุฒิ",
|
||||||
profileSalary.orgChild2 = item.JOB_NAME;
|
"ได้รับเงินตอบแทนพิเศษ",
|
||||||
}
|
"เงินเพิ่มการครองชีพชั่วคราว",
|
||||||
profileSalary.positionExecutive = item.ADMIN_NAME ?? _null;
|
"เลื่อนขั้นเงินเดือนกรณีพิเศษ",
|
||||||
profileSalary.amount = isNaN(item.SALARY) ? null : item.SALARY;
|
"ปรับอัตราเงินเดือนตามบัญชีอัตราเงินเดือนใหม่ ท้าย พ.ร.บ. เงินเดือนและเงินประจำตำ",
|
||||||
profileSalary.remark = item.REMARK;
|
"ปรับอัตราเงินเดือนตามพระราชกฤษฎีกา การปรับอัตราเงินเดือนของข้าราชการ",
|
||||||
profileSalary.refId = item.id;
|
"เลื่อนขั้นเงินเดือน (เพิ่มเติม)",
|
||||||
profileSalary.isEntry = false;
|
"ปรับอัตราเงินเดือน",
|
||||||
|
"ให้ข้าราชการได้รับเงินเดือนตามคุณวุฒิ",
|
||||||
|
].includes(item.FLAG_TO_NAME)
|
||||||
|
) {
|
||||||
|
profileSalary.commandCode = "6";
|
||||||
|
profileSalary.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ";
|
||||||
|
} else if (["--"].includes(item.FLAG_TO_NAME)) {
|
||||||
|
profileSalary.commandCode = "7";
|
||||||
|
profileSalary.commandName = "เงินพิเศษอื่น ๆ";
|
||||||
|
} else if (
|
||||||
|
["ปรับโครงสร้าง", "แต่งตั้ง (จัดคนลงกรอบ)", "แต่งตั้งตามแผนอัตรากำลังฯ"].includes(
|
||||||
|
item.FLAG_TO_NAME,
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
profileSalary.commandCode = "8";
|
||||||
|
profileSalary.commandName = "ปรับโครงสร้าง";
|
||||||
|
} else if (["พ้นทดลองปฏิบัติราชการ"].includes(item.FLAG_TO_NAME)) {
|
||||||
|
profileSalary.commandCode = "9";
|
||||||
|
profileSalary.commandName = "พ้นทดลองปฏิบัติราชการ";
|
||||||
|
} else if (
|
||||||
|
[
|
||||||
|
"บรรจุกลับ",
|
||||||
|
"บรรจุกลับข้าราชการ",
|
||||||
|
"บรรจุและแต่งตั้งผู้ไปรับราชการทหารกลับเข้ารับราชการ",
|
||||||
|
].includes(item.FLAG_TO_NAME)
|
||||||
|
) {
|
||||||
|
profileSalary.commandCode = "10";
|
||||||
|
profileSalary.commandName = "บรรจุกลับ";
|
||||||
|
} else if (
|
||||||
|
[
|
||||||
|
"รับโอนข้าราชการตามกฎหมายอื่น",
|
||||||
|
"รับโอนข้าราชการตามกฎหมายอื่น ผู้สอบแข่งขันได้",
|
||||||
|
"รับโอนข้าราชการตามกฏหมายอื่น โดยการคัดเลือก",
|
||||||
|
].includes(item.FLAG_TO_NAME)
|
||||||
|
) {
|
||||||
|
profileSalary.commandCode = "11";
|
||||||
|
profileSalary.commandName = "รับโอน";
|
||||||
|
} else if (["ให้โอน"].includes(item.FLAG_TO_NAME)) {
|
||||||
|
profileSalary.commandCode = "12";
|
||||||
|
profileSalary.commandName = "ให้โอน";
|
||||||
|
} else if (["แก้ไขคำสั่ง"].includes(item.FLAG_TO_NAME)) {
|
||||||
|
profileSalary.commandCode = "13";
|
||||||
|
profileSalary.commandName = "แก้ไขคำสั่ง";
|
||||||
|
} else if (["ยกเลิกคำสั่ง"].includes(item.FLAG_TO_NAME)) {
|
||||||
|
profileSalary.commandCode = "14";
|
||||||
|
profileSalary.commandName = "ยกเลิกคำสั่ง";
|
||||||
|
} else if (
|
||||||
|
[
|
||||||
|
"ลาออกจากราชการ",
|
||||||
|
"พ้นจากราชการ/ลาออกจากราชการตามมาตรการพัฒนาและบริหารกำลังคน",
|
||||||
|
].includes(item.FLAG_TO_NAME)
|
||||||
|
) {
|
||||||
|
profileSalary.commandCode = "15";
|
||||||
|
profileSalary.commandName = "ลาออกจากราชการ";
|
||||||
|
} else if (
|
||||||
|
[
|
||||||
|
"พ้นจากราชการ/เพื่อไปปฏิบัติราชการทหาร",
|
||||||
|
"เกษียณ",
|
||||||
|
"ไม่พ้นทดลองปฏิบัติราชการ",
|
||||||
|
"พ้นจากราชการ/ให้ออก",
|
||||||
|
"พ้นจากราชการ/ไล่ออก",
|
||||||
|
"พ้นจากราชการ/เสียชีวิต",
|
||||||
|
"พ้นจากราชการ/ปลดออก",
|
||||||
|
].includes(item.FLAG_TO_NAME)
|
||||||
|
) {
|
||||||
|
profileSalary.commandCode = "16";
|
||||||
|
profileSalary.commandName = "พ้นจากราชการ";
|
||||||
|
} else if (
|
||||||
|
[
|
||||||
|
"แต่งตั้งข้าราชการรักษาราชการแทน",
|
||||||
|
"ช่วยราชการ",
|
||||||
|
"รักษาการ",
|
||||||
|
"รักษาราชการแทน",
|
||||||
|
"มอบหมายให้ปฏิบัติหน้าที่",
|
||||||
|
"มอบหมายข้าราชการปฏิบัติหน้าที่แทน",
|
||||||
|
].includes(item.FLAG_TO_NAME)
|
||||||
|
) {
|
||||||
|
profileSalary.commandCode = "17";
|
||||||
|
profileSalary.commandName = "รักษาราชการ, ช่วยราชการ";
|
||||||
|
} else {
|
||||||
|
profileSalary.commandCode = "0";
|
||||||
|
profileSalary.commandName = item.FLAG_TO_NAME;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
profileSalary.posNoAbb = item.POS_NUM_NAME;
|
||||||
|
profileSalary.posNo = item.POS_NUM_CODE;
|
||||||
|
profileSalary.positionName = item.WORK_LINE_NAME;
|
||||||
|
var positionType = _null;
|
||||||
|
var positionLevel = _null;
|
||||||
|
if (item.MP_CEE == "21") {
|
||||||
|
positionType = "ทั่วไป";
|
||||||
|
positionLevel = "ปฏิบัติงาน";
|
||||||
|
} else if (item.MP_CEE == "22") {
|
||||||
|
positionType = "ทั่วไป";
|
||||||
|
positionLevel = "ชำนาญงาน";
|
||||||
|
} else if (item.MP_CEE == "23") {
|
||||||
|
positionType = "ทั่วไป";
|
||||||
|
positionLevel = "อาวุโส";
|
||||||
|
} else if (item.MP_CEE == "24") {
|
||||||
|
positionType = "ทั่วไป";
|
||||||
|
positionLevel = "อาวุโสเฉพาะสายงานที่กำหนด";
|
||||||
|
} else if (item.MP_CEE == "25") {
|
||||||
|
positionType = "ทั่วไป";
|
||||||
|
positionLevel = "ทักษะพิเศษ";
|
||||||
|
} else if (item.MP_CEE == "26") {
|
||||||
|
positionType = "วิชาการ";
|
||||||
|
positionLevel = "ปฏิบัติการ";
|
||||||
|
} else if (item.MP_CEE == "27") {
|
||||||
|
positionType = "วิชาการ";
|
||||||
|
positionLevel = "ชำนาญการ";
|
||||||
|
} else if (item.MP_CEE == "28") {
|
||||||
|
positionType = "วิชาการ";
|
||||||
|
positionLevel = "ชำนาญการพิเศษ";
|
||||||
|
} else if (item.MP_CEE == "29") {
|
||||||
|
positionType = "วิชาการ";
|
||||||
|
positionLevel = "เชี่ยวชาญ";
|
||||||
|
} else if (item.MP_CEE == "30") {
|
||||||
|
positionType = "วิชาการ";
|
||||||
|
positionLevel = "ทรงคุณวุฒิ";
|
||||||
|
} else if (item.MP_CEE == "31") {
|
||||||
|
positionType = "วิชาการ";
|
||||||
|
positionLevel = "ทรงคุณวุฒิเฉพาะสายงานที่กำหนด";
|
||||||
|
} else if (item.MP_CEE == "32") {
|
||||||
|
positionType = "อำนวยการ";
|
||||||
|
positionLevel = "ต้น";
|
||||||
|
} else if (item.MP_CEE == "33") {
|
||||||
|
positionType = "อำนวยการ";
|
||||||
|
positionLevel = "สูง";
|
||||||
|
} else if (item.MP_CEE == "34") {
|
||||||
|
positionType = "บริหาร";
|
||||||
|
positionLevel = "ต้น";
|
||||||
|
} else if (item.MP_CEE == "35") {
|
||||||
|
positionType = "บริหาร";
|
||||||
|
positionLevel = "สูง";
|
||||||
|
} else {
|
||||||
|
profileSalary.positionCee = item.MP_CEE;
|
||||||
|
}
|
||||||
|
profileSalary.positionType = positionType;
|
||||||
|
profileSalary.positionLevel = positionLevel;
|
||||||
|
profileSalary.orgRoot = item.DEPARTMENT_NAME;
|
||||||
|
profileSalary.orgChild1 = item.DIVISION_NAME;
|
||||||
|
profileSalary.orgChild2 = item.SECTION_NAME;
|
||||||
|
profileSalary.orgChild3 = item.JOB_NAME;
|
||||||
|
if (item.DEPARTMENT_CODE == "50") {
|
||||||
|
profileSalary.orgRoot = item.DIVISION_NAME;
|
||||||
|
profileSalary.orgChild1 = item.SECTION_NAME;
|
||||||
|
profileSalary.orgChild2 = item.JOB_NAME;
|
||||||
|
}
|
||||||
|
profileSalary.positionExecutive = item.ADMIN_NAME ?? _null;
|
||||||
|
profileSalary.amount = isNaN(item.SALARY) ? null : item.SALARY;
|
||||||
|
profileSalary.remark = item.REMARK;
|
||||||
|
profileSalary.refId = item.id;
|
||||||
|
profileSalary.isEntry = false;
|
||||||
|
|
||||||
const sal_pos_amount_1: any =
|
const sal_pos_amount_1: any =
|
||||||
item.SAL_POS_AMOUNT_1 == null || item.SAL_POS_AMOUNT_1 == ""
|
item.SAL_POS_AMOUNT_1 == null || item.SAL_POS_AMOUNT_1 == ""
|
||||||
? _null
|
? _null
|
||||||
: Number(item.SAL_POS_AMOUNT_1);
|
: isNaN(Number(item.SAL_POS_AMOUNT_1))
|
||||||
const sal_pos_amount_2: any =
|
? _null
|
||||||
item.SAL_POS_AMOUNT_2 == null || item.SAL_POS_AMOUNT_2 == ""
|
: Number(item.SAL_POS_AMOUNT_1);
|
||||||
? _null
|
const sal_pos_amount_2: any =
|
||||||
: Number(item.SAL_POS_AMOUNT_2);
|
item.SAL_POS_AMOUNT_2 == null || item.SAL_POS_AMOUNT_2 == ""
|
||||||
profileSalary.positionSalaryAmount = sal_pos_amount_1 ?? sal_pos_amount_2;
|
? _null
|
||||||
const special_amt: any =
|
: isNaN(Number(item.SAL_POS_AMOUNT_2))
|
||||||
item.SPECIAL_AMT == null || item.SPECIAL_AMT == "" ? _null : Number(item.SPECIAL_AMT);
|
? _null
|
||||||
profileSalary.amountSpecial = special_amt;
|
: Number(item.SAL_POS_AMOUNT_2);
|
||||||
profileSalary.posNumCodeSit = item.POS_NUM_CODE_SIT;
|
profileSalary.positionSalaryAmount = sal_pos_amount_1 ?? sal_pos_amount_2;
|
||||||
profileSalary.posNumCodeSitAbb = item.POS_NUM_CODE_SIT_ABB;
|
|
||||||
|
|
||||||
profileSalary.createdUserId = request.user.sub;
|
const special_amt: any =
|
||||||
profileSalary.createdFullName = request.user.name;
|
item.SPECIAL_AMT == null || item.SPECIAL_AMT == ""
|
||||||
profileSalary.lastUpdateUserId = request.user.sub;
|
? _null
|
||||||
profileSalary.lastUpdateFullName = request.user.name;
|
: isNaN(Number(item.SPECIAL_AMT))
|
||||||
profileSalary.createdAt = new Date().toISOString().split("T")[0];
|
? _null
|
||||||
profileSalary.lastUpdatedAt = new Date().toISOString().split("T")[0];
|
: Number(item.SPECIAL_AMT);
|
||||||
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
profileSalary.amountSpecial = special_amt;
|
||||||
|
profileSalary.posNumCodeSit = item.POS_NUM_CODE_SIT;
|
||||||
|
profileSalary.posNumCodeSitAbb = item.POS_NUM_CODE_SIT_ABB;
|
||||||
|
|
||||||
|
profileSalary.createdUserId = request.user.sub;
|
||||||
|
profileSalary.createdFullName = request.user.name;
|
||||||
|
profileSalary.lastUpdateUserId = request.user.sub;
|
||||||
|
profileSalary.lastUpdateFullName = request.user.name;
|
||||||
|
profileSalary.createdAt = new Date().toISOString().split("T")[0];
|
||||||
|
profileSalary.lastUpdatedAt = new Date().toISOString().split("T")[0];
|
||||||
|
|
||||||
|
// เพิ่มลงใน batch array แทนการ save ทันที
|
||||||
|
batchRecords.push(profileSalary);
|
||||||
|
}
|
||||||
|
order = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Batch insert สำหรับ batch นี้
|
||||||
|
if (batchRecords.length > 0) {
|
||||||
try {
|
try {
|
||||||
await this.salaryRepo.save(profileSalary);
|
// Debug: ตรวจสอบ NaN values ก่อน save
|
||||||
|
const hasNaN = batchRecords.some((record) => {
|
||||||
|
return Object.values(record).some((value) => typeof value === "number" && isNaN(value));
|
||||||
|
});
|
||||||
|
|
||||||
|
if (hasNaN) {
|
||||||
|
console.warn(
|
||||||
|
`Warning: Found NaN values in batch ${Math.floor(offset / batchSize) + 1}`,
|
||||||
|
);
|
||||||
|
// แทนที่ NaN ด้วย null
|
||||||
|
batchRecords.forEach((record) => {
|
||||||
|
Object.keys(record).forEach((key) => {
|
||||||
|
if (typeof record[key] === "number" && isNaN(record[key])) {
|
||||||
|
console.warn(`Replacing NaN in field ${key} with null`);
|
||||||
|
record[key] = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.salaryRepo.save(batchRecords);
|
||||||
|
console.log(
|
||||||
|
`Saved ${batchRecords.length} records for batch ${Math.floor(offset / batchSize) + 1}`,
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error executing function from controller:", item.CIT);
|
console.error(`Error saving batch ${Math.floor(offset / batchSize) + 1}:`, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
order = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(`Total processed: ${rowCount} records`);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6226,4 +6290,26 @@ export class ImportDataController extends Controller {
|
||||||
return groups;
|
return groups;
|
||||||
}, {});
|
}, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post("updateCommandYearNull")
|
||||||
|
async updateCommandYearNull(@Request() request: { user: Record<string, any> }) {
|
||||||
|
const profiles = await this.salaryRepo.find({
|
||||||
|
where: {
|
||||||
|
createdAt: Between(
|
||||||
|
new Date("2025-10-23T00:00:00.000Z"),
|
||||||
|
new Date("2025-10-25T00:00:00.000Z"),
|
||||||
|
),
|
||||||
|
commandYear: IsNull(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const item of profiles) {
|
||||||
|
console.log(item.id);
|
||||||
|
if (item.commandDateAffect) {
|
||||||
|
item.commandYear = item.commandDateAffect.getFullYear();
|
||||||
|
await this.salaryRepo.save(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6108,7 +6108,7 @@ export class OrganizationController extends Controller {
|
||||||
if (!orgRevision) {
|
if (!orgRevision) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
}
|
}
|
||||||
let _data = {
|
let _data:any = {
|
||||||
root: null,
|
root: null,
|
||||||
child1: null,
|
child1: null,
|
||||||
child2: null,
|
child2: null,
|
||||||
|
|
@ -6122,6 +6122,62 @@ export class OrganizationController extends Controller {
|
||||||
_data = await new permission().PermissionOrgList(request, system.trim().toUpperCase());
|
_data = await new permission().PermissionOrgList(request, system.trim().toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const profile = await this.profileRepo.findOne({
|
||||||
|
where: { keycloak: request.user.sub },
|
||||||
|
relations: ["permissionProfiles", "current_holders"],
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!profile) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งานในทะเบียนประวัติ");
|
||||||
|
}
|
||||||
|
|
||||||
|
let _privilege = await new permission().PermissionOrgList(request, system);
|
||||||
|
const attrOwnership = _privilege.root === null ? true : false;
|
||||||
|
|
||||||
|
if (orgRevision.orgRevisionIsDraft && !orgRevision.orgRevisionIsCurrent && !attrOwnership) {
|
||||||
|
if(Array.isArray(profile.permissionProfiles) && profile.permissionProfiles.length > 0){
|
||||||
|
_data.root = profile.permissionProfiles.map((x) => x.orgRootId);
|
||||||
|
}else{
|
||||||
|
return new HttpSuccess({ remark: "", data: [] });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// กำหนดการเข้าถึงข้อมูลตามสถานะและสิทธิ์
|
||||||
|
const isCurrentActive = !orgRevision.orgRevisionIsDraft && orgRevision.orgRevisionIsCurrent;
|
||||||
|
if (isCurrentActive) {
|
||||||
|
if(_privilege.privilege !== "OWNER"){
|
||||||
|
if(_privilege.privilege == "NORMAL"){
|
||||||
|
const holder = profile.current_holders.find(x => x.orgRevisionId === id);
|
||||||
|
if (!holder) return;
|
||||||
|
_data.root = [holder.orgRootId];
|
||||||
|
_data.child1 = [holder.orgChild1Id];
|
||||||
|
_data.child2 = [holder.orgChild2Id];
|
||||||
|
_data.child3 = [holder.orgChild3Id];
|
||||||
|
_data.child4 = [holder.orgChild4Id];
|
||||||
|
}else if(_privilege.privilege == "CHILD"){
|
||||||
|
const holder = profile.current_holders.find(x => x.orgRevisionId === id);
|
||||||
|
if (!holder) return;
|
||||||
|
_data.root = [holder.orgRootId];
|
||||||
|
if (_privilege.root && _privilege.child1 === null) {
|
||||||
|
} else if (_privilege.child1 && _privilege.child2 === null) {
|
||||||
|
_data.child1 = [holder.orgChild1Id];
|
||||||
|
} else if (_privilege.child2 && _privilege.child3 === null) {
|
||||||
|
_data.child1 = [holder.orgChild1Id];
|
||||||
|
_data.child2 = [holder.orgChild2Id];
|
||||||
|
} else if (_privilege.child3 && _privilege.child4 === null) {
|
||||||
|
_data.child1 = [holder.orgChild1Id];
|
||||||
|
_data.child2 = [holder.orgChild2Id];
|
||||||
|
_data.child3 = [holder.orgChild3Id];
|
||||||
|
_data.child4 = [holder.orgChild4Id];
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
_data.root = [profile.current_holders.find((x) => x.orgRevisionId === id)?.orgRootId];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!attrOwnership) _data = _privilege;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const orgRootData = await AppDataSource.getRepository(OrgRoot)
|
const orgRootData = await AppDataSource.getRepository(OrgRoot)
|
||||||
.createQueryBuilder("orgRoot")
|
.createQueryBuilder("orgRoot")
|
||||||
.where("orgRoot.orgRevisionId = :id", { id })
|
.where("orgRoot.orgRevisionId = :id", { id })
|
||||||
|
|
|
||||||
|
|
@ -29,16 +29,26 @@ export class ProfileAvatarController extends Controller {
|
||||||
|
|
||||||
@Get("profileId/{id}")
|
@Get("profileId/{id}")
|
||||||
async getProfile(@Path() id: string, @Request() req: RequestWithUser) {
|
async getProfile(@Path() id: string, @Request() req: RequestWithUser) {
|
||||||
let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_OFFICER");
|
try {
|
||||||
if (_workflow == false)
|
// let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_OFFICER");
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id);
|
// if (_workflow == false)
|
||||||
const profile = await this.profileRepository.findOne({
|
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id);
|
||||||
where: { id },
|
const profile = await this.profileRepository.findOne({
|
||||||
});
|
where: { id },
|
||||||
|
});
|
||||||
|
|
||||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
||||||
return new HttpSuccess(profile);
|
return new HttpSuccess(profile);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in getProfile:", error);
|
||||||
|
|
||||||
|
if (error instanceof HttpError) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new HttpError(HttpStatus.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาดภายในระบบ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("profileId-admin/{id}")
|
@Get("profileId-admin/{id}")
|
||||||
|
|
|
||||||
|
|
@ -7365,40 +7365,45 @@ export class ProfileController extends Controller {
|
||||||
nodeDnaId: null,
|
nodeDnaId: null,
|
||||||
type: profile.employeeClass,
|
type: profile.employeeClass,
|
||||||
salary: profile.amount,
|
salary: profile.amount,
|
||||||
posNo:
|
posNo: null
|
||||||
root?.orgRootShortName && posMaster?.posMasterNo
|
// root?.orgRootShortName && posMaster?.posMasterNo
|
||||||
? `${root?.orgRootShortName} ${posMaster?.posMasterNo}`
|
// ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}`
|
||||||
: "",
|
// : "",
|
||||||
};
|
};
|
||||||
if (_profile.child4Id != null) {
|
if (_profile.child4Id != null) {
|
||||||
_profile.node = 4;
|
_profile.node = 4;
|
||||||
_profile.nodeId = _profile.child4Id;
|
_profile.nodeId = _profile.child4Id;
|
||||||
_profile.nodeDnaId = _profile.child4DnaId;
|
_profile.nodeDnaId = _profile.child4DnaId;
|
||||||
_profile.nodeShortName = _profile.child4ShortName;
|
_profile.nodeShortName = _profile.child4ShortName;
|
||||||
|
_profile.posNo = `${_profile.child4ShortName} ${_profile.posMasterNo}`;
|
||||||
} else if (_profile.child3Id != null) {
|
} else if (_profile.child3Id != null) {
|
||||||
_profile.node = 3;
|
_profile.node = 3;
|
||||||
_profile.nodeId = _profile.child3Id;
|
_profile.nodeId = _profile.child3Id;
|
||||||
_profile.nodeDnaId = _profile.child3DnaId;
|
_profile.nodeDnaId = _profile.child3DnaId;
|
||||||
_profile.nodeShortName = _profile.child3ShortName;
|
_profile.nodeShortName = _profile.child3ShortName;
|
||||||
|
_profile.posNo = `${_profile.child3ShortName} ${_profile.posMasterNo}`;
|
||||||
} else if (_profile.child2Id != null) {
|
} else if (_profile.child2Id != null) {
|
||||||
_profile.node = 2;
|
_profile.node = 2;
|
||||||
_profile.nodeId = _profile.child2Id;
|
_profile.nodeId = _profile.child2Id;
|
||||||
_profile.nodeDnaId = _profile.child2DnaId;
|
_profile.nodeDnaId = _profile.child2DnaId;
|
||||||
_profile.nodeShortName = _profile.child2ShortName;
|
_profile.nodeShortName = _profile.child2ShortName;
|
||||||
|
_profile.posNo = `${_profile.child2ShortName} ${_profile.posMasterNo}`;
|
||||||
} else if (_profile.child1Id != null) {
|
} else if (_profile.child1Id != null) {
|
||||||
_profile.node = 1;
|
_profile.node = 1;
|
||||||
_profile.nodeId = _profile.child1Id;
|
_profile.nodeId = _profile.child1Id;
|
||||||
_profile.nodeDnaId = _profile.child1DnaId;
|
_profile.nodeDnaId = _profile.child1DnaId;
|
||||||
_profile.nodeShortName = _profile.child1ShortName;
|
_profile.nodeShortName = _profile.child1ShortName;
|
||||||
|
_profile.posNo = `${_profile.child1ShortName} ${_profile.posMasterNo}`;
|
||||||
} else if (_profile.rootId != null) {
|
} else if (_profile.rootId != null) {
|
||||||
_profile.node = 0;
|
_profile.node = 0;
|
||||||
_profile.nodeId = _profile.rootId;
|
_profile.nodeId = _profile.rootId;
|
||||||
_profile.nodeDnaId = _profile.rootDnaId;
|
_profile.nodeDnaId = _profile.rootDnaId;
|
||||||
_profile.nodeShortName = _profile.rootShortName;
|
_profile.nodeShortName = _profile.rootShortName;
|
||||||
|
_profile.posNo = `${_profile.rootShortName} ${_profile.posMasterNo}`;
|
||||||
}
|
}
|
||||||
return new HttpSuccess(_profile);
|
return new HttpSuccess(_profile);
|
||||||
}
|
}
|
||||||
|
// ขรก.
|
||||||
let orgRevisionPublish: any = await this.orgRevisionRepo
|
let orgRevisionPublish: any = await this.orgRevisionRepo
|
||||||
.createQueryBuilder("orgRevision")
|
.createQueryBuilder("orgRevision")
|
||||||
.where("orgRevision.orgRevisionIsDraft = false")
|
.where("orgRevision.orgRevisionIsDraft = false")
|
||||||
|
|
@ -7529,10 +7534,10 @@ export class ProfileController extends Controller {
|
||||||
nodeDnaId: null,
|
nodeDnaId: null,
|
||||||
salary: profile ? profile.amount : null,
|
salary: profile ? profile.amount : null,
|
||||||
amountSpecial: profile ? profile.amountSpecial : null,
|
amountSpecial: profile ? profile.amountSpecial : null,
|
||||||
posNo:
|
posNo: null
|
||||||
root?.orgRootShortName && posMaster?.posMasterNo
|
// root?.orgRootShortName && posMaster?.posMasterNo
|
||||||
? `${root?.orgRootShortName} ${posMaster?.posMasterNo}`
|
// ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}`
|
||||||
: "",
|
// : "",
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_profile.child4Id != null) {
|
if (_profile.child4Id != null) {
|
||||||
|
|
@ -7540,26 +7545,31 @@ export class ProfileController extends Controller {
|
||||||
_profile.nodeId = _profile.child4Id;
|
_profile.nodeId = _profile.child4Id;
|
||||||
_profile.nodeDnaId = _profile.child4DnaId;
|
_profile.nodeDnaId = _profile.child4DnaId;
|
||||||
_profile.nodeShortName = _profile.child4ShortName;
|
_profile.nodeShortName = _profile.child4ShortName;
|
||||||
|
_profile.posNo = `${_profile.child4ShortName} ${posMaster?.posMasterNo}`;
|
||||||
} else if (_profile.child3Id != null) {
|
} else if (_profile.child3Id != null) {
|
||||||
_profile.node = 3;
|
_profile.node = 3;
|
||||||
_profile.nodeId = _profile.child3Id;
|
_profile.nodeId = _profile.child3Id;
|
||||||
_profile.nodeDnaId = _profile.child3DnaId;
|
_profile.nodeDnaId = _profile.child3DnaId;
|
||||||
_profile.nodeShortName = _profile.child3ShortName;
|
_profile.nodeShortName = _profile.child3ShortName;
|
||||||
|
_profile.posNo = `${_profile.child3ShortName} ${posMaster?.posMasterNo}`;
|
||||||
} else if (_profile.child2Id != null) {
|
} else if (_profile.child2Id != null) {
|
||||||
_profile.node = 2;
|
_profile.node = 2;
|
||||||
_profile.nodeId = _profile.child2Id;
|
_profile.nodeId = _profile.child2Id;
|
||||||
_profile.nodeDnaId = _profile.child2DnaId;
|
_profile.nodeDnaId = _profile.child2DnaId;
|
||||||
_profile.nodeShortName = _profile.child2ShortName;
|
_profile.nodeShortName = _profile.child2ShortName;
|
||||||
|
_profile.posNo = `${_profile.child2ShortName} ${posMaster?.posMasterNo}`;
|
||||||
} else if (_profile.child1Id != null) {
|
} else if (_profile.child1Id != null) {
|
||||||
_profile.node = 1;
|
_profile.node = 1;
|
||||||
_profile.nodeId = _profile.child1Id;
|
_profile.nodeId = _profile.child1Id;
|
||||||
_profile.nodeDnaId = _profile.child1DnaId;
|
_profile.nodeDnaId = _profile.child1DnaId;
|
||||||
_profile.nodeShortName = _profile.child1ShortName;
|
_profile.nodeShortName = _profile.child1ShortName;
|
||||||
|
_profile.posNo = `${_profile.child1ShortName} ${posMaster?.posMasterNo}`;
|
||||||
} else if (_profile.rootId != null) {
|
} else if (_profile.rootId != null) {
|
||||||
_profile.node = 0;
|
_profile.node = 0;
|
||||||
_profile.nodeId = _profile.rootId;
|
_profile.nodeId = _profile.rootId;
|
||||||
_profile.nodeDnaId = _profile.rootDnaId;
|
_profile.nodeDnaId = _profile.rootDnaId;
|
||||||
_profile.nodeShortName = _profile.rootShortName;
|
_profile.nodeShortName = _profile.rootShortName;
|
||||||
|
_profile.posNo = `${_profile.rootShortName} ${posMaster?.posMasterNo}`;
|
||||||
}
|
}
|
||||||
return new HttpSuccess(_profile);
|
return new HttpSuccess(_profile);
|
||||||
}
|
}
|
||||||
|
|
@ -9763,9 +9773,13 @@ export class ProfileController extends Controller {
|
||||||
keyword?: string;
|
keyword?: string;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
let conditionFullName =
|
const orgRevisionActive = await this.orgRevisionRepo.findOne({
|
||||||
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
|
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||||
const [findProfile, total] = await AppDataSource.getRepository(Profile)
|
});
|
||||||
|
if (!orgRevisionActive) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||||
|
}
|
||||||
|
let query = AppDataSource.getRepository(Profile)
|
||||||
.createQueryBuilder("profile")
|
.createQueryBuilder("profile")
|
||||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
.leftJoinAndSelect("profile.posType", "posType")
|
.leftJoinAndSelect("profile.posType", "posType")
|
||||||
|
|
@ -9778,103 +9792,83 @@ export class ProfileController extends Controller {
|
||||||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||||
.leftJoinAndSelect("current_holders.positions", "positions")
|
.leftJoinAndSelect("current_holders.positions", "positions")
|
||||||
.leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
.leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
||||||
.where(`profile.position LIKE :keyword`, {
|
.andWhere(
|
||||||
keyword: `%${body.keyword}%`,
|
new Brackets(qb => {
|
||||||
})
|
qb.where("profile.position LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
.orWhere(`profile.prefix LIKE :keyword`, {
|
.orWhere("posLevel.posLevelName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
keyword: `%${body.keyword}%`,
|
.orWhere("posType.posTypeName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
})
|
.orWhere("CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword", { keyword: `%${body.keyword}%` });
|
||||||
.orWhere(`profile.firstName LIKE :keyword`, {
|
})
|
||||||
keyword: `%${body.keyword}%`,
|
)
|
||||||
})
|
|
||||||
.orWhere(`profile.lastName LIKE :keyword`, {
|
|
||||||
keyword: `%${body.keyword}%`,
|
|
||||||
})
|
|
||||||
.orWhere(`posLevel.posLevelName LIKE :keyword`, {
|
|
||||||
keyword: `%${body.keyword}%`,
|
|
||||||
})
|
|
||||||
.orWhere(`posType.posTypeName LIKE :keyword`, {
|
|
||||||
keyword: `%${body.keyword}%`,
|
|
||||||
})
|
|
||||||
.orWhere(conditionFullName, {
|
|
||||||
keyword: `%${body.keyword}%`,
|
|
||||||
})
|
|
||||||
.andWhere("profile.isLeave = false")
|
.andWhere("profile.isLeave = false")
|
||||||
.orderBy("profile.citizenId", "ASC")
|
.andWhere("current_holders.orgRevisionId = :orgRevisionId", { orgRevisionId: orgRevisionActive.id });
|
||||||
.skip((body.page - 1) * body.pageSize)
|
|
||||||
.take(body.pageSize)
|
|
||||||
.getManyAndCount();
|
|
||||||
|
|
||||||
const orgRevisionActive = await this.orgRevisionRepo.findOne({
|
const [findProfile, total] = await query
|
||||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
.orderBy("profile.citizenId", "ASC")
|
||||||
});
|
.skip((body.page - 1) * body.pageSize)
|
||||||
const findRevision = await this.orgRevisionRepo.findOne({
|
.take(body.pageSize)
|
||||||
where: { orgRevisionIsCurrent: true },
|
.getManyAndCount();
|
||||||
});
|
|
||||||
if (!findRevision) {
|
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
|
||||||
}
|
|
||||||
|
|
||||||
const mapDataProfile = await Promise.all(
|
const mapDataProfile = await Promise.all(
|
||||||
findProfile.map(async (item: Profile) => {
|
findProfile.map(async (item: Profile) => {
|
||||||
const posMaster =
|
const posMaster =
|
||||||
item.current_holders == null ||
|
item.current_holders == null ||
|
||||||
item.current_holders.length == 0 ||
|
item.current_holders.length == 0 ||
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
|
||||||
? null
|
? null
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id);
|
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id);
|
||||||
const position =
|
const position =
|
||||||
posMaster == null ||
|
posMaster == null ||
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.positions == null ||
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.positions == null ||
|
||||||
item.current_holders?.find((x) => x.orgRevisionId == findRevision.id)?.positions.length ==
|
item.current_holders?.find((x) => x.orgRevisionId == orgRevisionActive.id)?.positions.length ==
|
||||||
0 ||
|
0 ||
|
||||||
item.current_holders
|
item.current_holders
|
||||||
.find((x) => x.orgRevisionId == findRevision.id)
|
.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||||
?.positions?.find((position) => position.positionIsSelected == true) == null
|
?.positions?.find((position) => position.positionIsSelected == true) == null
|
||||||
? null
|
? null
|
||||||
: item.current_holders
|
: item.current_holders
|
||||||
.find((x) => x.orgRevisionId == findRevision.id)
|
.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||||
?.positions?.find((position) => position.positionIsSelected == true);
|
?.positions?.find((position) => position.positionIsSelected == true);
|
||||||
const posExecutive =
|
const posExecutive =
|
||||||
position == null ||
|
position == null ||
|
||||||
item.current_holders
|
item.current_holders
|
||||||
.find((x) => x.orgRevisionId == findRevision.id)
|
.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||||
?.positions?.find((position) => position.positionIsSelected == true)?.posExecutive ==
|
?.positions?.find((position) => position.positionIsSelected == true)?.posExecutive ==
|
||||||
null ||
|
null ||
|
||||||
item.current_holders
|
item.current_holders
|
||||||
.find((x) => x.orgRevisionId == findRevision.id)
|
.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||||
?.positions?.find((position) => position.positionIsSelected == true)?.posExecutive
|
?.positions?.find((position) => position.positionIsSelected == true)?.posExecutive
|
||||||
?.posExecutiveName == null
|
?.posExecutiveName == null
|
||||||
? null
|
? null
|
||||||
: item.current_holders
|
: item.current_holders
|
||||||
.find((x) => x.orgRevisionId == findRevision.id)
|
.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||||
?.positions?.find((position) => position.positionIsSelected == true)?.posExecutive
|
?.positions?.find((position) => position.positionIsSelected == true)?.posExecutive
|
||||||
.posExecutiveName;
|
.posExecutiveName;
|
||||||
|
|
||||||
const shortName =
|
const shortName =
|
||||||
item.current_holders.length == 0
|
item.current_holders.length == 0
|
||||||
? null
|
? null
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild4 !=
|
||||||
null
|
null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild3 !=
|
||||||
null
|
null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||||
?.orgChild2 != null
|
?.orgChild2 != null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||||
?.orgChild1 != null
|
?.orgChild1 != null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) !=
|
||||||
null &&
|
null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||||
?.orgRoot != null
|
?.orgRoot != null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import { AppDataSource } from "../database/data-source";
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
import { Brackets, Double, In, IsNull, Like, Not } from "typeorm";
|
import { Brackets, Double, In, IsNull, Like, Not } from "typeorm";
|
||||||
import { OrgRevision } from "../entities/OrgRevision";
|
import { OrgRevision } from "../entities/OrgRevision";
|
||||||
import {
|
import {
|
||||||
|
|
@ -2039,9 +2040,13 @@ export class ProfileEmployeeController extends Controller {
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
}
|
}
|
||||||
await new permission().PermissionOrgUserDelete(request, "SYS_REGISTRY_EMP", result.id);
|
try{
|
||||||
await this.informationHistoryRepository.delete({ profileEmployeeId: id });
|
await new permission().PermissionOrgUserDelete(request, "SYS_REGISTRY_EMP", result.id);
|
||||||
await this.profileRepo.remove(result);
|
await this.informationHistoryRepository.delete({ profileEmployeeId: id });
|
||||||
|
await this.profileRepo.remove(result);
|
||||||
|
} catch {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถลบข้อมูลได้ เนื่องจากข้อมูลนี้ถูกใช้งานในระบบอื่น");
|
||||||
|
}
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3583,36 +3588,41 @@ export class ProfileEmployeeController extends Controller {
|
||||||
nodeDnaId: null,
|
nodeDnaId: null,
|
||||||
salary: profile ? profile.amount : null,
|
salary: profile ? profile.amount : null,
|
||||||
amountSpecial: profile ? profile.amountSpecial : null,
|
amountSpecial: profile ? profile.amountSpecial : null,
|
||||||
posNo:
|
posNo: null
|
||||||
root?.orgRootShortName && posMaster?.posMasterNo
|
// root?.orgRootShortName && posMaster?.posMasterNo
|
||||||
? `${root?.orgRootShortName} ${posMaster?.posMasterNo}`
|
// ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}`
|
||||||
: "",
|
// : "",
|
||||||
};
|
};
|
||||||
if (_profile.child4Id != null) {
|
if (_profile.child4Id != null) {
|
||||||
_profile.node = 4;
|
_profile.node = 4;
|
||||||
_profile.nodeId = _profile.child4Id;
|
_profile.nodeId = _profile.child4Id;
|
||||||
_profile.nodeDnaId = _profile.child4DnaId;
|
_profile.nodeDnaId = _profile.child4DnaId;
|
||||||
_profile.nodeShortName = _profile.child4ShortName;
|
_profile.nodeShortName = _profile.child4ShortName;
|
||||||
|
_profile.posNo = `${_profile.child4ShortName} ${_profile.posMasterNo}`;
|
||||||
} else if (_profile.child3Id != null) {
|
} else if (_profile.child3Id != null) {
|
||||||
_profile.node = 3;
|
_profile.node = 3;
|
||||||
_profile.nodeId = _profile.child3Id;
|
_profile.nodeId = _profile.child3Id;
|
||||||
_profile.nodeDnaId = _profile.child3DnaId;
|
_profile.nodeDnaId = _profile.child3DnaId;
|
||||||
_profile.nodeShortName = _profile.child3ShortName;
|
_profile.nodeShortName = _profile.child3ShortName;
|
||||||
|
_profile.posNo = `${_profile.child3ShortName} ${_profile.posMasterNo}`;
|
||||||
} else if (_profile.child2Id != null) {
|
} else if (_profile.child2Id != null) {
|
||||||
_profile.node = 2;
|
_profile.node = 2;
|
||||||
_profile.nodeId = _profile.child2Id;
|
_profile.nodeId = _profile.child2Id;
|
||||||
_profile.nodeDnaId = _profile.child2DnaId;
|
_profile.nodeDnaId = _profile.child2DnaId;
|
||||||
_profile.nodeShortName = _profile.child2ShortName;
|
_profile.nodeShortName = _profile.child2ShortName;
|
||||||
|
_profile.posNo = `${_profile.child2ShortName} ${_profile.posMasterNo}`;
|
||||||
} else if (_profile.child1Id != null) {
|
} else if (_profile.child1Id != null) {
|
||||||
_profile.node = 1;
|
_profile.node = 1;
|
||||||
_profile.nodeId = _profile.child1Id;
|
_profile.nodeId = _profile.child1Id;
|
||||||
_profile.nodeDnaId = _profile.child1DnaId;
|
_profile.nodeDnaId = _profile.child1DnaId;
|
||||||
_profile.nodeShortName = _profile.child1ShortName;
|
_profile.nodeShortName = _profile.child1ShortName;
|
||||||
|
_profile.posNo = `${_profile.child1ShortName} ${_profile.posMasterNo}`;
|
||||||
} else if (_profile.rootId != null) {
|
} else if (_profile.rootId != null) {
|
||||||
_profile.node = 0;
|
_profile.node = 0;
|
||||||
_profile.nodeId = _profile.rootId;
|
_profile.nodeId = _profile.rootId;
|
||||||
_profile.nodeDnaId = _profile.rootDnaId;
|
_profile.nodeDnaId = _profile.rootDnaId;
|
||||||
_profile.nodeShortName = _profile.rootShortName;
|
_profile.nodeShortName = _profile.rootShortName;
|
||||||
|
_profile.posNo = `${_profile.rootShortName} ${_profile.posMasterNo}`;
|
||||||
}
|
}
|
||||||
return new HttpSuccess(_profile);
|
return new HttpSuccess(_profile);
|
||||||
}
|
}
|
||||||
|
|
@ -4409,11 +4419,16 @@ export class ProfileEmployeeController extends Controller {
|
||||||
page: number;
|
page: number;
|
||||||
pageSize: number;
|
pageSize: number;
|
||||||
keyword?: string;
|
keyword?: string;
|
||||||
|
type?: string;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
let conditionFullName =
|
const orgRevisionActive = await this.orgRevisionRepo.findOne({
|
||||||
"CONCAT(profileEmployee.prefix, profileEmployee.firstName, ' ', profileEmployee.lastName) LIKE :keyword";
|
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||||
const [findProfile, total] = await AppDataSource.getRepository(ProfileEmployee)
|
});
|
||||||
|
if (!orgRevisionActive) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||||
|
}
|
||||||
|
let query = AppDataSource.getRepository(ProfileEmployee)
|
||||||
.createQueryBuilder("profileEmployee")
|
.createQueryBuilder("profileEmployee")
|
||||||
.leftJoinAndSelect("profileEmployee.posLevel", "posLevel")
|
.leftJoinAndSelect("profileEmployee.posLevel", "posLevel")
|
||||||
.leftJoinAndSelect("profileEmployee.posType", "posType")
|
.leftJoinAndSelect("profileEmployee.posType", "posType")
|
||||||
|
|
@ -4425,88 +4440,78 @@ export class ProfileEmployeeController extends Controller {
|
||||||
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||||
.leftJoinAndSelect("current_holders.positions", "positions")
|
.leftJoinAndSelect("current_holders.positions", "positions")
|
||||||
.where(`profileEmployee.position LIKE :keyword`, {
|
.andWhere(
|
||||||
keyword: `%${body.keyword}%`,
|
new Brackets(qb => {
|
||||||
})
|
qb.where("profileEmployee.position LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
.orWhere(`profileEmployee.prefix LIKE :keyword`, {
|
.orWhere("posLevel.posLevelName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
keyword: `%${body.keyword}%`,
|
.orWhere("posType.posTypeName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
})
|
.orWhere("CONCAT(profileEmployee.prefix, profileEmployee.firstName, ' ', profileEmployee.lastName) LIKE :keyword", { keyword: `%${body.keyword}%` });
|
||||||
.orWhere(`profileEmployee.firstName LIKE :keyword`, {
|
})
|
||||||
keyword: `%${body.keyword}%`,
|
)
|
||||||
})
|
|
||||||
.orWhere(`profileEmployee.lastName LIKE :keyword`, {
|
|
||||||
keyword: `%${body.keyword}%`,
|
|
||||||
})
|
|
||||||
.orWhere(`posLevel.posLevelName LIKE :keyword`, {
|
|
||||||
keyword: `%${body.keyword}%`,
|
|
||||||
})
|
|
||||||
.orWhere(`posType.posTypeName LIKE :keyword`, {
|
|
||||||
keyword: `%${body.keyword}%`,
|
|
||||||
})
|
|
||||||
.orWhere(conditionFullName, {
|
|
||||||
keyword: `%${body.keyword}%`,
|
|
||||||
})
|
|
||||||
.andWhere("profileEmployee.isLeave = false")
|
.andWhere("profileEmployee.isLeave = false")
|
||||||
|
.andWhere("current_holders.orgRevisionId = :orgRevisionId", { orgRevisionId: orgRevisionActive.id });
|
||||||
|
|
||||||
|
if (body.type) {
|
||||||
|
const typeUpper = body.type.trim().toUpperCase();
|
||||||
|
if (typeUpper === "EMPLOYEE") {
|
||||||
|
query = query.andWhere("profileEmployee.employeeClass = 'PERM'");
|
||||||
|
}
|
||||||
|
else if (typeUpper === "TEMP"){
|
||||||
|
query = query.andWhere("profileEmployee.employeeClass = 'TEMP'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const [findProfile, total] = await query
|
||||||
.orderBy("profileEmployee.citizenId", "ASC")
|
.orderBy("profileEmployee.citizenId", "ASC")
|
||||||
.skip((body.page - 1) * body.pageSize)
|
.skip((body.page - 1) * body.pageSize)
|
||||||
.take(body.pageSize)
|
.take(body.pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
||||||
const orgRevisionActive = await this.orgRevisionRepo.findOne({
|
|
||||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
|
||||||
});
|
|
||||||
const findRevision = await this.orgRevisionRepo.findOne({
|
|
||||||
where: { orgRevisionIsCurrent: true },
|
|
||||||
});
|
|
||||||
if (!findRevision) {
|
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
|
||||||
}
|
|
||||||
|
|
||||||
const mapDataProfile = await Promise.all(
|
const mapDataProfile = await Promise.all(
|
||||||
findProfile.map(async (item: ProfileEmployee) => {
|
findProfile.map(async (item: ProfileEmployee) => {
|
||||||
const posMaster =
|
const posMaster =
|
||||||
item.current_holders == null ||
|
item.current_holders == null ||
|
||||||
item.current_holders.length == 0 ||
|
item.current_holders.length == 0 ||
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
|
||||||
? null
|
? null
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id);
|
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id);
|
||||||
const position =
|
const position =
|
||||||
posMaster == null ||
|
posMaster == null ||
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.positions == null ||
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.positions == null ||
|
||||||
item.current_holders?.find((x) => x.orgRevisionId == findRevision.id)?.positions.length ==
|
item.current_holders?.find((x) => x.orgRevisionId == orgRevisionActive.id)?.positions.length ==
|
||||||
0 ||
|
0 ||
|
||||||
item.current_holders
|
item.current_holders
|
||||||
.find((x) => x.orgRevisionId == findRevision.id)
|
.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||||
?.positions?.find((position) => position.positionIsSelected == true) == null
|
?.positions?.find((position) => position.positionIsSelected == true) == null
|
||||||
? null
|
? null
|
||||||
: item.current_holders
|
: item.current_holders
|
||||||
.find((x) => x.orgRevisionId == findRevision.id)
|
.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||||
?.positions?.find((position) => position.positionIsSelected == true);
|
?.positions?.find((position) => position.positionIsSelected == true);
|
||||||
|
|
||||||
const shortName =
|
const shortName =
|
||||||
item.current_holders.length == 0
|
item.current_holders.length == 0
|
||||||
? null
|
? null
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild4 !=
|
||||||
null
|
null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild3 !=
|
||||||
null
|
null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||||
?.orgChild2 != null
|
?.orgChild2 != null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||||
?.orgChild1 != null
|
?.orgChild1 != null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) !=
|
||||||
null &&
|
null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||||
?.orgRoot != null
|
?.orgRoot != null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ import axios from "axios";
|
||||||
import { deleteUser } from "../keycloak";
|
import { deleteUser } from "../keycloak";
|
||||||
import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory";
|
import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory";
|
||||||
import { getTopDegrees } from "../services/PositionService";
|
import { getTopDegrees } from "../services/PositionService";
|
||||||
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
@Route("api/v1/org/profile-temp")
|
@Route("api/v1/org/profile-temp")
|
||||||
@Tags("ProfileEmployee")
|
@Tags("ProfileEmployee")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -1027,8 +1028,13 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
}
|
}
|
||||||
await this.informationHistoryRepository.delete({ profileEmployeeId: id });
|
|
||||||
await this.profileRepo.remove(result);
|
try{
|
||||||
|
await this.informationHistoryRepository.delete({ profileEmployeeId: id });
|
||||||
|
await this.profileRepo.remove(result);
|
||||||
|
} catch {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถลบข้อมูลได้ เนื่องจากข้อมูลนี้ถูกใช้งานในระบบอื่น");
|
||||||
|
}
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,7 @@ export class ProfileGovernmentHistoryController extends Controller {
|
||||||
let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER");
|
let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER");
|
||||||
if (_workflow == false)
|
if (_workflow == false)
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
|
|
||||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||||
select: ["id"],
|
select: ["id"],
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -155,10 +156,22 @@ export class ProfileGovernmentHistoryController extends Controller {
|
||||||
orgRevisionIsCurrent: true,
|
orgRevisionIsCurrent: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ค้นหา profile ก่อน
|
||||||
const record = await this.profileRepo.findOne({
|
const record = await this.profileRepo.findOne({
|
||||||
|
where: { id: profileId },
|
||||||
|
relations: ["posType", "posLevel"],
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!record) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล profile");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ค้นหา profileSalary แยกต่างหาก
|
||||||
|
const profileWithSalary = await this.profileRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
id: profileId,
|
id: profileId,
|
||||||
profileSalary: {
|
profileSalary: {
|
||||||
commandCode: In([
|
commandCode: In([
|
||||||
"0",
|
"0",
|
||||||
"9",
|
"9",
|
||||||
|
|
@ -175,16 +188,19 @@ export class ProfileGovernmentHistoryController extends Controller {
|
||||||
"15",
|
"15",
|
||||||
"16",
|
"16",
|
||||||
]),
|
]),
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
relations: ["posType", "posLevel", "profileSalary"],
|
relations: ["profileSalary"],
|
||||||
order: {
|
order: {
|
||||||
profileSalary: {
|
profileSalary: {
|
||||||
order: "DESC",
|
order: "DESC",
|
||||||
createdAt: "DESC"
|
createdAt: "DESC",
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ใช้ profileSalary จาก query ที่สอง หรือ [] ถ้าไม่เจอ
|
||||||
|
record.profileSalary = profileWithSalary?.profileSalary || [];
|
||||||
const posMaster = await this.posMasterRepo.findOne({
|
const posMaster = await this.posMasterRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
orgRevisionId: orgRevision?.id,
|
orgRevisionId: orgRevision?.id,
|
||||||
|
|
@ -236,8 +252,8 @@ export class ProfileGovernmentHistoryController extends Controller {
|
||||||
orgShortName = posMaster.orgChild4?.orgChild4ShortName ?? "";
|
orgShortName = posMaster.orgChild4?.orgChild4ShortName ?? "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let _OrgLeave:any = []
|
let _OrgLeave: any = [];
|
||||||
let _profileSalary:any = null;
|
let _profileSalary: any = null;
|
||||||
if (record?.isLeave && record?.profileSalary.length > 0) {
|
if (record?.isLeave && record?.profileSalary.length > 0) {
|
||||||
// _OrgLeave = [
|
// _OrgLeave = [
|
||||||
// record?.profileSalary[0].orgChild4 ? record?.profileSalary[0].orgChild4 : null,
|
// record?.profileSalary[0].orgChild4 ? record?.profileSalary[0].orgChild4 : null,
|
||||||
|
|
@ -247,15 +263,14 @@ export class ProfileGovernmentHistoryController extends Controller {
|
||||||
// record?.profileSalary[0].orgRoot ? record?.profileSalary[0].orgRoot : null,
|
// record?.profileSalary[0].orgRoot ? record?.profileSalary[0].orgRoot : null,
|
||||||
// ];
|
// ];
|
||||||
if (record.leaveType == "RETIRE") {
|
if (record.leaveType == "RETIRE") {
|
||||||
_profileSalary = record?.profileSalary.length > 1
|
_profileSalary =
|
||||||
? record?.profileSalary[1]
|
record?.profileSalary.length > 1
|
||||||
: record?.profileSalary.length > 0
|
? record?.profileSalary[1]
|
||||||
|
: record?.profileSalary.length > 0
|
||||||
? record?.profileSalary[0]
|
? record?.profileSalary[0]
|
||||||
: null;
|
: null;
|
||||||
} else {
|
} else {
|
||||||
_profileSalary = record?.profileSalary.length > 0
|
_profileSalary = record?.profileSalary.length > 0 ? record?.profileSalary[0] : null;
|
||||||
? record?.profileSalary[0]
|
|
||||||
: null;
|
|
||||||
}
|
}
|
||||||
if (_profileSalary) {
|
if (_profileSalary) {
|
||||||
_OrgLeave = [
|
_OrgLeave = [
|
||||||
|
|
@ -269,17 +284,20 @@ export class ProfileGovernmentHistoryController extends Controller {
|
||||||
_OrgLeave = [];
|
_OrgLeave = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const orgLeave = _OrgLeave.filter((x:any) => x !== undefined && x !== null).join("\n");
|
const orgLeave = _OrgLeave.filter((x: any) => x !== undefined && x !== null).join("\n");
|
||||||
const data = {
|
const data = {
|
||||||
org: record?.isLeave == false ? org : orgLeave, //สังกัด
|
org: record?.isLeave == false ? org : orgLeave, //สังกัด
|
||||||
positionField: position == null ? null : position.positionField, //สายงาน
|
positionField: position == null ? null : position.positionField, //สายงาน
|
||||||
position: record?.position, //ตำแหน่ง
|
position: record?.position, //ตำแหน่ง
|
||||||
posLevel: record?.posLevel == null ? null : record?.posLevel.posLevelName, //ระดับ
|
posLevel: record?.posLevel == null ? null : record?.posLevel.posLevelName, //ระดับ
|
||||||
posMasterNo: record?.isLeave == false
|
posMasterNo:
|
||||||
? posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNo}`
|
record?.isLeave == false
|
||||||
: _profileSalary != null
|
? posMaster == null
|
||||||
? `${_profileSalary.posNoAbb} ${_profileSalary.posNo}`
|
? null
|
||||||
: null, //เลขที่ตำแหน่ง
|
: `${orgShortName} ${posMaster.posMasterNo}`
|
||||||
|
: _profileSalary != null
|
||||||
|
? `${_profileSalary.posNoAbb} ${_profileSalary.posNo}`
|
||||||
|
: null, //เลขที่ตำแหน่ง
|
||||||
posType: record?.posType == null ? null : record?.posType.posTypeName, //ประเภท
|
posType: record?.posType == null ? null : record?.posType.posTypeName, //ประเภท
|
||||||
posExecutive:
|
posExecutive:
|
||||||
position == null || position.posExecutive == null
|
position == null || position.posExecutive == null
|
||||||
|
|
@ -310,7 +328,19 @@ export class ProfileGovernmentHistoryController extends Controller {
|
||||||
orgRevisionIsCurrent: true,
|
orgRevisionIsCurrent: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ค้นหา profile ก่อน
|
||||||
const record = await this.profileRepo.findOne({
|
const record = await this.profileRepo.findOne({
|
||||||
|
where: { id: profileId },
|
||||||
|
relations: ["posType", "posLevel"],
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!record) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล profile");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ค้นหา profileSalary แยกต่างหาก
|
||||||
|
const profileWithSalary = await this.profileRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
id: profileId,
|
id: profileId,
|
||||||
profileSalary: {
|
profileSalary: {
|
||||||
|
|
@ -330,20 +360,19 @@ export class ProfileGovernmentHistoryController extends Controller {
|
||||||
"15",
|
"15",
|
||||||
"16",
|
"16",
|
||||||
]),
|
]),
|
||||||
}
|
},
|
||||||
},
|
|
||||||
relations: {
|
|
||||||
posType: true,
|
|
||||||
posLevel: true,
|
|
||||||
profileSalary: true
|
|
||||||
},
|
},
|
||||||
|
relations: ["profileSalary"],
|
||||||
order: {
|
order: {
|
||||||
profileSalary: {
|
profileSalary: {
|
||||||
order: "DESC",
|
order: "DESC",
|
||||||
createdAt: "DESC"
|
createdAt: "DESC",
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ใช้ profileSalary จาก query ที่สอง หรือ [] ถ้าไม่เจอ
|
||||||
|
record.profileSalary = profileWithSalary?.profileSalary || [];
|
||||||
const posMaster = await this.posMasterRepo.findOne({
|
const posMaster = await this.posMasterRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
orgRevisionId: orgRevision?.id,
|
orgRevisionId: orgRevision?.id,
|
||||||
|
|
@ -395,8 +424,8 @@ export class ProfileGovernmentHistoryController extends Controller {
|
||||||
orgShortName = posMaster.orgChild4?.orgChild4ShortName;
|
orgShortName = posMaster.orgChild4?.orgChild4ShortName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let _OrgLeave:any = []
|
let _OrgLeave: any = [];
|
||||||
let _profileSalary:any = null;
|
let _profileSalary: any = null;
|
||||||
if (record?.isLeave && record?.profileSalary.length > 0) {
|
if (record?.isLeave && record?.profileSalary.length > 0) {
|
||||||
// _OrgLeave = [
|
// _OrgLeave = [
|
||||||
// record?.profileSalary[0].orgChild4 ? record?.profileSalary[0].orgChild4 : null,
|
// record?.profileSalary[0].orgChild4 ? record?.profileSalary[0].orgChild4 : null,
|
||||||
|
|
@ -406,15 +435,14 @@ export class ProfileGovernmentHistoryController extends Controller {
|
||||||
// record?.profileSalary[0].orgRoot ? record?.profileSalary[0].orgRoot : null,
|
// record?.profileSalary[0].orgRoot ? record?.profileSalary[0].orgRoot : null,
|
||||||
// ];
|
// ];
|
||||||
if (record.leaveType == "RETIRE") {
|
if (record.leaveType == "RETIRE") {
|
||||||
_profileSalary = record?.profileSalary.length > 1
|
_profileSalary =
|
||||||
? record?.profileSalary[1]
|
record?.profileSalary.length > 1
|
||||||
: record?.profileSalary.length > 0
|
? record?.profileSalary[1]
|
||||||
|
: record?.profileSalary.length > 0
|
||||||
? record?.profileSalary[0]
|
? record?.profileSalary[0]
|
||||||
: null;
|
: null;
|
||||||
} else {
|
} else {
|
||||||
_profileSalary = record?.profileSalary.length > 0
|
_profileSalary = record?.profileSalary.length > 0 ? record?.profileSalary[0] : null;
|
||||||
? record?.profileSalary[0]
|
|
||||||
: null;
|
|
||||||
}
|
}
|
||||||
if (_profileSalary) {
|
if (_profileSalary) {
|
||||||
_OrgLeave = [
|
_OrgLeave = [
|
||||||
|
|
@ -428,7 +456,7 @@ export class ProfileGovernmentHistoryController extends Controller {
|
||||||
_OrgLeave = [];
|
_OrgLeave = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const orgLeave = _OrgLeave.filter((x:any) => x !== undefined && x !== null).join("\n");
|
const orgLeave = _OrgLeave.filter((x: any) => x !== undefined && x !== null).join("\n");
|
||||||
const data = {
|
const data = {
|
||||||
org: record?.isLeave == false ? org : orgLeave, //สังกัด
|
org: record?.isLeave == false ? org : orgLeave, //สังกัด
|
||||||
positionField: position == null ? null : position.positionField, //สายงาน
|
positionField: position == null ? null : position.positionField, //สายงาน
|
||||||
|
|
@ -458,7 +486,7 @@ export class ProfileGovernmentHistoryController extends Controller {
|
||||||
govAgeAbsent: record?.govAgeAbsent,
|
govAgeAbsent: record?.govAgeAbsent,
|
||||||
govAgePlus: record?.govAgePlus,
|
govAgePlus: record?.govAgePlus,
|
||||||
reasonSameDate: record?.reasonSameDate,
|
reasonSameDate: record?.reasonSameDate,
|
||||||
isLeave: record?.isLeave
|
isLeave: record?.isLeave,
|
||||||
};
|
};
|
||||||
|
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess(data);
|
||||||
|
|
|
||||||
|
|
@ -149,36 +149,16 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
orgRevisionIsCurrent: true,
|
orgRevisionIsCurrent: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ค้นหา profile ก่อน
|
||||||
const record = await this.profileEmployeeRepo.findOne({
|
const record = await this.profileEmployeeRepo.findOne({
|
||||||
where: {
|
where: { id: profileEmployeeId },
|
||||||
id: profileEmployeeId,
|
relations: ["posType", "posLevel"],
|
||||||
// profileSalary: {
|
|
||||||
// commandCode: In([
|
|
||||||
// "0",
|
|
||||||
// "9",
|
|
||||||
// "1",
|
|
||||||
// "2",
|
|
||||||
// "3",
|
|
||||||
// "4",
|
|
||||||
// "8",
|
|
||||||
// "10",
|
|
||||||
// "11",
|
|
||||||
// "12",
|
|
||||||
// "13",
|
|
||||||
// "14",
|
|
||||||
// "15",
|
|
||||||
// "16",
|
|
||||||
// ]),
|
|
||||||
// }
|
|
||||||
},
|
|
||||||
relations: ["posType", "posLevel"/*, "profileSalary"*/],
|
|
||||||
// order: {
|
|
||||||
// profileSalary: {
|
|
||||||
// order: "DESC",
|
|
||||||
// createdAt: "DESC"
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!record) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล profile");
|
||||||
|
}
|
||||||
const posMaster = await this.posMasterRepo.findOne({
|
const posMaster = await this.posMasterRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
orgRevisionId: orgRevision?.id,
|
orgRevisionId: orgRevision?.id,
|
||||||
|
|
@ -217,10 +197,10 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
orgShortName = posMaster.orgChild4?.orgChild4ShortName;
|
orgShortName = posMaster.orgChild4?.orgChild4ShortName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let _OrgLeave:any = []
|
let _OrgLeave: any = [];
|
||||||
let orgLeave:string = ""
|
let orgLeave: string = "";
|
||||||
let posNoLeave:string = ""
|
let posNoLeave: string = "";
|
||||||
let _profileSalary:any = null;
|
let _profileSalary: any = null;
|
||||||
if (record?.isLeave /*&& record?.profileSalary.length > 0*/) {
|
if (record?.isLeave /*&& record?.profileSalary.length > 0*/) {
|
||||||
const profileSalary = await this.salaryRepo.find({
|
const profileSalary = await this.salaryRepo.find({
|
||||||
select: [
|
select: [
|
||||||
|
|
@ -230,7 +210,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
"orgChild3",
|
"orgChild3",
|
||||||
"orgChild4",
|
"orgChild4",
|
||||||
"posNoAbb",
|
"posNoAbb",
|
||||||
"posNo"
|
"posNo",
|
||||||
],
|
],
|
||||||
where: {
|
where: {
|
||||||
profileEmployeeId: profileEmployeeId,
|
profileEmployeeId: profileEmployeeId,
|
||||||
|
|
@ -253,8 +233,8 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
},
|
},
|
||||||
order: {
|
order: {
|
||||||
order: "DESC",
|
order: "DESC",
|
||||||
createdAt: "DESC"
|
createdAt: "DESC",
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
// _OrgLeave = [
|
// _OrgLeave = [
|
||||||
// profileSalary.length > 0 && profileSalary[0].orgChild4 ? profileSalary[0].orgChild4 : null,
|
// profileSalary.length > 0 && profileSalary[0].orgChild4 ? profileSalary[0].orgChild4 : null,
|
||||||
|
|
@ -264,15 +244,14 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
// profileSalary.length > 0 && profileSalary[0].orgRoot ? profileSalary[0].orgRoot : null,
|
// profileSalary.length > 0 && profileSalary[0].orgRoot ? profileSalary[0].orgRoot : null,
|
||||||
// ];
|
// ];
|
||||||
if (record.leaveType == "RETIRE") {
|
if (record.leaveType == "RETIRE") {
|
||||||
_profileSalary = profileSalary.length > 1
|
_profileSalary =
|
||||||
? profileSalary[1]
|
profileSalary.length > 1
|
||||||
: profileSalary.length > 0
|
? profileSalary[1]
|
||||||
? profileSalary[0]
|
: profileSalary.length > 0
|
||||||
: null;
|
? profileSalary[0]
|
||||||
|
: null;
|
||||||
} else {
|
} else {
|
||||||
_profileSalary = profileSalary.length > 0
|
_profileSalary = profileSalary.length > 0 ? profileSalary[0] : null;
|
||||||
? profileSalary[0]
|
|
||||||
: null
|
|
||||||
}
|
}
|
||||||
if (_profileSalary) {
|
if (_profileSalary) {
|
||||||
_OrgLeave = [
|
_OrgLeave = [
|
||||||
|
|
@ -285,10 +264,9 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
} else {
|
} else {
|
||||||
_OrgLeave = [];
|
_OrgLeave = [];
|
||||||
}
|
}
|
||||||
orgLeave = _OrgLeave.filter((x:any) => x !== undefined && x !== null).join("\n");
|
orgLeave = _OrgLeave.filter((x: any) => x !== undefined && x !== null).join("\n");
|
||||||
posNoLeave = _profileSalary != null
|
posNoLeave =
|
||||||
? `${_profileSalary.posNoAbb} ${_profileSalary.posNo}`
|
_profileSalary != null ? `${_profileSalary.posNoAbb} ${_profileSalary.posNo}` : "";
|
||||||
: ""
|
|
||||||
}
|
}
|
||||||
const data = {
|
const data = {
|
||||||
org: record?.isLeave == false ? org : orgLeave, //สังกัด
|
org: record?.isLeave == false ? org : orgLeave, //สังกัด
|
||||||
|
|
@ -297,9 +275,12 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
record?.posLevel == null
|
record?.posLevel == null
|
||||||
? null
|
? null
|
||||||
: `${record?.posType?.posTypeShortName ?? ""} ${record?.posLevel?.posLevelName ?? ""}`, //ระดับ
|
: `${record?.posType?.posTypeShortName ?? ""} ${record?.posLevel?.posLevelName ?? ""}`, //ระดับ
|
||||||
posMasterNo: record?.isLeave == false
|
posMasterNo:
|
||||||
? posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNo}`
|
record?.isLeave == false
|
||||||
: posNoLeave/*record && record?.profileSalary.length > 0
|
? posMaster == null
|
||||||
|
? null
|
||||||
|
: `${orgShortName} ${posMaster.posMasterNo}`
|
||||||
|
: posNoLeave /*record && record?.profileSalary.length > 0
|
||||||
? `${record?.profileSalary[0].posNoAbb} ${record?.profileSalary[0].posNo}`
|
? `${record?.profileSalary[0].posNoAbb} ${record?.profileSalary[0].posNo}`
|
||||||
: null*/, //เลขที่ตำแหน่ง
|
: null*/, //เลขที่ตำแหน่ง
|
||||||
posType: record?.posType == null ? null : record?.posType.posTypeName, //ประเภท
|
posType: record?.posType == null ? null : record?.posType.posTypeName, //ประเภท
|
||||||
|
|
@ -326,34 +307,16 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
orgRevisionIsCurrent: true,
|
orgRevisionIsCurrent: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ค้นหา profile ก่อน
|
||||||
const record = await this.profileEmployeeRepo.findOne({
|
const record = await this.profileEmployeeRepo.findOne({
|
||||||
where: {
|
where: { id: profileEmployeeId },
|
||||||
id: profileEmployeeId,
|
relations: ["posType", "posLevel"],
|
||||||
// profileSalary:{
|
|
||||||
// commandCode: In([
|
|
||||||
// "0",
|
|
||||||
// "9",
|
|
||||||
// "1",
|
|
||||||
// "2",
|
|
||||||
// "3",
|
|
||||||
// "4",
|
|
||||||
// "8",
|
|
||||||
// "10",
|
|
||||||
// "11",
|
|
||||||
// "12",
|
|
||||||
// "13",
|
|
||||||
// "14",
|
|
||||||
// "15",
|
|
||||||
// "16",
|
|
||||||
// ]),
|
|
||||||
// }
|
|
||||||
},
|
|
||||||
relations: {
|
|
||||||
posType: true,
|
|
||||||
posLevel: true,
|
|
||||||
// profileSalary: true
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!record) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล profile");
|
||||||
|
}
|
||||||
const posMaster = await this.posMasterRepo.findOne({
|
const posMaster = await this.posMasterRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
orgRevisionId: orgRevision?.id,
|
orgRevisionId: orgRevision?.id,
|
||||||
|
|
@ -392,10 +355,10 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
orgShortName = posMaster.orgChild4?.orgChild4ShortName;
|
orgShortName = posMaster.orgChild4?.orgChild4ShortName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let _OrgLeave:any = []
|
let _OrgLeave: any = [];
|
||||||
let orgLeave:string = ""
|
let orgLeave: string = "";
|
||||||
let posNoLeave:string = ""
|
let posNoLeave: string = "";
|
||||||
let _profileSalary:any = null;
|
let _profileSalary: any = null;
|
||||||
if (record?.isLeave /*&& record?.profileSalary.length > 0*/) {
|
if (record?.isLeave /*&& record?.profileSalary.length > 0*/) {
|
||||||
const profileSalary = await this.salaryRepo.find({
|
const profileSalary = await this.salaryRepo.find({
|
||||||
select: [
|
select: [
|
||||||
|
|
@ -405,7 +368,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
"orgChild3",
|
"orgChild3",
|
||||||
"orgChild4",
|
"orgChild4",
|
||||||
"posNoAbb",
|
"posNoAbb",
|
||||||
"posNo"
|
"posNo",
|
||||||
],
|
],
|
||||||
where: {
|
where: {
|
||||||
profileEmployeeId: profileEmployeeId,
|
profileEmployeeId: profileEmployeeId,
|
||||||
|
|
@ -428,8 +391,8 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
},
|
},
|
||||||
order: {
|
order: {
|
||||||
order: "DESC",
|
order: "DESC",
|
||||||
createdAt: "DESC"
|
createdAt: "DESC",
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
// _OrgLeave = [
|
// _OrgLeave = [
|
||||||
// profileSalary.length > 0 && profileSalary[0].orgChild4 ? profileSalary[0].orgChild4 : null,
|
// profileSalary.length > 0 && profileSalary[0].orgChild4 ? profileSalary[0].orgChild4 : null,
|
||||||
|
|
@ -439,15 +402,14 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
// profileSalary.length > 0 && profileSalary[0].orgRoot ? profileSalary[0].orgRoot : null,
|
// profileSalary.length > 0 && profileSalary[0].orgRoot ? profileSalary[0].orgRoot : null,
|
||||||
// ];
|
// ];
|
||||||
if (record.leaveType == "RETIRE") {
|
if (record.leaveType == "RETIRE") {
|
||||||
_profileSalary = profileSalary.length > 1
|
_profileSalary =
|
||||||
? profileSalary[1]
|
profileSalary.length > 1
|
||||||
: profileSalary.length > 0
|
? profileSalary[1]
|
||||||
? profileSalary[0]
|
: profileSalary.length > 0
|
||||||
: null;
|
? profileSalary[0]
|
||||||
|
: null;
|
||||||
} else {
|
} else {
|
||||||
_profileSalary = profileSalary.length > 0
|
_profileSalary = profileSalary.length > 0 ? profileSalary[0] : null;
|
||||||
? profileSalary[0]
|
|
||||||
: null;
|
|
||||||
}
|
}
|
||||||
if (_profileSalary) {
|
if (_profileSalary) {
|
||||||
_OrgLeave = [
|
_OrgLeave = [
|
||||||
|
|
@ -460,23 +422,23 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
} else {
|
} else {
|
||||||
_OrgLeave = [];
|
_OrgLeave = [];
|
||||||
}
|
}
|
||||||
orgLeave = _OrgLeave.filter((x:any) => x !== undefined && x !== null).join("\n");
|
orgLeave = _OrgLeave.filter((x: any) => x !== undefined && x !== null).join("\n");
|
||||||
posNoLeave = _profileSalary != null
|
posNoLeave =
|
||||||
? `${_profileSalary.posNoAbb} ${_profileSalary.posNo}`
|
_profileSalary != null ? `${_profileSalary.posNoAbb} ${_profileSalary.posNo}` : "";
|
||||||
: ""
|
|
||||||
}
|
}
|
||||||
const data = {
|
const data = {
|
||||||
org: record?.isLeave == false ? org : orgLeave, //สังกัด
|
org: record?.isLeave == false ? org : orgLeave, //สังกัด
|
||||||
position: record?.position, //ตำแหน่ง
|
position: record?.position, //ตำแหน่ง
|
||||||
posLevel: record?.posLevel == null && record?.posType == null
|
posLevel:
|
||||||
? null
|
record?.posLevel == null && record?.posType == null
|
||||||
: `${record?.posType.posTypeShortName} ${record?.posLevel.posLevelName}`, //ระดับ
|
? null
|
||||||
|
: `${record?.posType.posTypeShortName} ${record?.posLevel.posLevelName}`, //ระดับ
|
||||||
posMasterNo:
|
posMasterNo:
|
||||||
record?.isLeave == false
|
record?.isLeave == false
|
||||||
? posMaster == null
|
? posMaster == null
|
||||||
? null
|
? null
|
||||||
: `${orgShortName} ${posMaster.posMasterNo}`
|
: `${orgShortName} ${posMaster.posMasterNo}`
|
||||||
: posNoLeave/*record && record.profileSalary.length > 0
|
: posNoLeave /*record && record.profileSalary.length > 0
|
||||||
? `${record?.profileSalary[0].posNoAbb} ${record?.profileSalary[0].posNo}`
|
? `${record?.profileSalary[0].posNoAbb} ${record?.profileSalary[0].posNo}`
|
||||||
: null*/, //เลขที่ตำแหน่ง
|
: null*/, //เลขที่ตำแหน่ง
|
||||||
posType: record?.posType == null ? null : record?.posType.posTypeName, //ประเภท
|
posType: record?.posType == null ? null : record?.posType.posTypeName, //ประเภท
|
||||||
|
|
@ -490,7 +452,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
govAgeAbsent: record?.govAgeAbsent ?? null, // ขาดราชการ
|
govAgeAbsent: record?.govAgeAbsent ?? null, // ขาดราชการ
|
||||||
govAgePlus: record?.govAgePlus, // อายุราชการเกื้อกูล
|
govAgePlus: record?.govAgePlus, // อายุราชการเกื้อกูล
|
||||||
dateRetireLaw: record?.dateRetireLaw ?? null, // วันที่เกษียฯอายุราชการตามกฎหมาย
|
dateRetireLaw: record?.dateRetireLaw ?? null, // วันที่เกษียฯอายุราชการตามกฎหมาย
|
||||||
isLeave: record?.isLeave
|
isLeave: record?.isLeave,
|
||||||
};
|
};
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess(data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11052,6 +11052,12 @@ export class ReportController extends Controller {
|
||||||
acc[key] = { ...curr, total: 1 };
|
acc[key] = { ...curr, total: 1 };
|
||||||
} else {
|
} else {
|
||||||
acc[key].total += 1;
|
acc[key].total += 1;
|
||||||
|
acc[key].total += 1;
|
||||||
|
const combinedPositions = new Set([
|
||||||
|
...acc[key].positions.split(", "),
|
||||||
|
...curr.positions.split(", "),
|
||||||
|
]);
|
||||||
|
acc[key].positions = Array.from(combinedPositions).join(", ");
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
@ -11155,13 +11161,20 @@ export class ReportController extends Controller {
|
||||||
const _posMaster = posMaster.map((x) => ({
|
const _posMaster = posMaster.map((x) => ({
|
||||||
type: [...new Set(x.positions.flatMap((y) => y.posType.posTypeName))].join(","),
|
type: [...new Set(x.positions.flatMap((y) => y.posType.posTypeName))].join(","),
|
||||||
typeRank: [...new Set(x.positions.flatMap((y) => y.posType.posTypeRank))].join(""),
|
typeRank: [...new Set(x.positions.flatMap((y) => y.posType.posTypeRank))].join(""),
|
||||||
|
typeShortNameAndRank: [
|
||||||
|
...new Set(
|
||||||
|
x.positions.map(
|
||||||
|
(y) => `${y.posType.posTypeShortName} ${y.posLevel.posLevelRank}`
|
||||||
|
)
|
||||||
|
),
|
||||||
|
].join(", "),
|
||||||
level: [...new Set(x.positions.flatMap((y) => y.posLevel.posLevelName))].join(","),
|
level: [...new Set(x.positions.flatMap((y) => y.posLevel.posLevelName))].join(","),
|
||||||
levelRank: [
|
levelRank: [
|
||||||
...new Set(
|
...new Set(
|
||||||
x.positions.flatMap((y) => `${y.posType.posTypeRank}${y.posLevel.posLevelRank}`),
|
x.positions.flatMap((y) => `${y.posType.posTypeRank}${y.posLevel.posLevelRank}`),
|
||||||
),
|
),
|
||||||
].join(""),
|
].join(""),
|
||||||
positions: [...new Set(x.positions.flatMap((y) => y.positionName))].join(""),
|
positions: [...new Set(x.positions.map((y) => y.positionName))].join(", "),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const groupedData = _posMaster.reduce((acc: any, curr: any) => {
|
const groupedData = _posMaster.reduce((acc: any, curr: any) => {
|
||||||
|
|
@ -11170,14 +11183,21 @@ export class ReportController extends Controller {
|
||||||
acc[key] = { ...curr, total: 1 };
|
acc[key] = { ...curr, total: 1 };
|
||||||
} else {
|
} else {
|
||||||
acc[key].total += 1;
|
acc[key].total += 1;
|
||||||
|
const combinedPositions = new Set([
|
||||||
|
...acc[key].positions.split(", "),
|
||||||
|
...curr.positions.split(", "),
|
||||||
|
]);
|
||||||
|
acc[key].positions = Array.from(combinedPositions).join(", ");
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
|
// console.log("groupedData>>>",groupedData);
|
||||||
|
|
||||||
let result = Object.values(groupedData)
|
let result = Object.values(groupedData)
|
||||||
.map((x: any) => ({
|
.map((x: any) => ({
|
||||||
type: x.type,
|
type: x.type,
|
||||||
typeRank: parseInt(x.typeRank),
|
typeRank: parseInt(x.typeRank),
|
||||||
|
typeShortNameAndRank: x.typeShortNameAndRank,
|
||||||
level: x.level,
|
level: x.level,
|
||||||
levelRank: parseInt(x.levelRank),
|
levelRank: parseInt(x.levelRank),
|
||||||
|
|
||||||
|
|
@ -11208,9 +11228,10 @@ export class ReportController extends Controller {
|
||||||
if (x.type !== tmpType && tmpType != "") {
|
if (x.type !== tmpType && tmpType != "") {
|
||||||
_total = total - x.total;
|
_total = total - x.total;
|
||||||
_reslut.push({
|
_reslut.push({
|
||||||
type: "",
|
type: "รวม",
|
||||||
typeRank: "",
|
typeRank: "",
|
||||||
level: "รวม",
|
typeShortNameAndRank: "",
|
||||||
|
level: "",
|
||||||
levelRank: "",
|
levelRank: "",
|
||||||
total: _total,
|
total: _total,
|
||||||
remark: "",
|
remark: "",
|
||||||
|
|
@ -11226,25 +11247,27 @@ export class ReportController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
_reslut.push({
|
_reslut.push({
|
||||||
type: "",
|
type: "รวม",
|
||||||
typeRank: "",
|
typeRank: "",
|
||||||
level: "รวม",
|
typeShortNameAndRank: "",
|
||||||
|
level: "",
|
||||||
levelRank: "",
|
levelRank: "",
|
||||||
total: total,
|
total: total,
|
||||||
remark: "",
|
remark: "",
|
||||||
});
|
});
|
||||||
_reslut.push({
|
_reslut.push({
|
||||||
type: "",
|
type: "รวมทั้งสิ้น",
|
||||||
typeRank: "",
|
typeRank: "",
|
||||||
level: "รวมทั้งสิ้น",
|
typeShortNameAndRank: "",
|
||||||
|
level: "",
|
||||||
levelRank: "",
|
levelRank: "",
|
||||||
total: allTotal,
|
total: allTotal,
|
||||||
remark: "",
|
remark: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
template: "report4",
|
template: "report5",
|
||||||
reportName: "report4",
|
reportName: "report5",
|
||||||
data: {
|
data: {
|
||||||
dateCurrent: Extension.ToThaiShortDate(new Date()),
|
dateCurrent: Extension.ToThaiShortDate(new Date()),
|
||||||
rootName: orgRootData ? orgRootData.orgRootName : "-",
|
rootName: orgRootData ? orgRootData.orgRootName : "-",
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,54 @@ export class ApiKey extends EntityBase {
|
||||||
})
|
})
|
||||||
keyApi: string;
|
keyApi: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "accessType",
|
||||||
|
length: 40,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
accessType: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "dnaRootId",
|
||||||
|
length: 40,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
dnaRootId: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "dnaChild1Id",
|
||||||
|
length: 40,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
dnaChild1Id: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "dnaChild2Id",
|
||||||
|
length: 40,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
dnaChild2Id: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "dnaChild3Id",
|
||||||
|
length: 40,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
dnaChild3Id: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "dnaChild4Id",
|
||||||
|
length: 40,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
dnaChild4Id: string;
|
||||||
|
|
||||||
@ManyToMany(() => ApiName, (apiName) => apiName.apiKeys)
|
@ManyToMany(() => ApiName, (apiName) => apiName.apiKeys)
|
||||||
apiNames: ApiName[];
|
apiNames: ApiName[];
|
||||||
|
|
||||||
|
|
@ -34,4 +82,22 @@ export class CreateApiKey {
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
apiId: string[];
|
apiId: string[];
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
accessType?: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
dnaRootId?: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
dnaChild1Id?: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
dnaChild2Id?: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
dnaChild3Id?: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
dnaChild4Id?: string;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
24
src/interfaces/date-serializer.ts
Normal file
24
src/interfaces/date-serializer.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
// Custom Date serializer for local timezone
|
||||||
|
export class DateSerializer {
|
||||||
|
static toLocalTime(date: Date): string | null {
|
||||||
|
if (!date) return null;
|
||||||
|
|
||||||
|
// Convert UTC date to Thailand timezone (+07:00)
|
||||||
|
const offset = 7 * 60; // Thailand is UTC+7
|
||||||
|
const localTime = new Date(date.getTime() + offset * 60 * 1000);
|
||||||
|
|
||||||
|
// Format as ISO string but replace Z with +07:00
|
||||||
|
const isoString = localTime.toISOString();
|
||||||
|
return isoString.replace("Z", "+07:00");
|
||||||
|
}
|
||||||
|
|
||||||
|
static setupDateSerialization() {
|
||||||
|
// Override Date.prototype.toJSON to use local time
|
||||||
|
Date.prototype.toJSON = function () {
|
||||||
|
const offset = 7 * 60; // Thailand timezone offset in minutes
|
||||||
|
const localTime = new Date(this.getTime() + offset * 60 * 1000);
|
||||||
|
const isoString = localTime.toISOString();
|
||||||
|
return isoString.replace("Z", "+07:00");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -70,6 +70,12 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) {
|
||||||
if (req.url.startsWith("/api/v1/org/profile-employee/")) system = "registry";
|
if (req.url.startsWith("/api/v1/org/profile-employee/")) system = "registry";
|
||||||
if (req.url.startsWith("/api/v1/org/profile-temp/")) system = "registry";
|
if (req.url.startsWith("/api/v1/org/profile-temp/")) system = "registry";
|
||||||
|
|
||||||
|
if (req.url.startsWith("/api/v1/org/commandType/admin")) system = "admin";
|
||||||
|
if (req.url.startsWith("/api/v1/org/commandSys/")) system = "admin";
|
||||||
|
if (req.url.startsWith("/api/v1/org/commandSalary/")) system = "admin";
|
||||||
|
if (req.url.startsWith("/api/v1/org/apiKey/")) system = "admin";
|
||||||
|
if (req.url.startsWith("/api/v1/org/api-manage/")) system = "admin";
|
||||||
|
|
||||||
const level = LOG_LEVEL_MAP[process.env.LOG_LEVEL ?? "debug"] || 4;
|
const level = LOG_LEVEL_MAP[process.env.LOG_LEVEL ?? "debug"] || 4;
|
||||||
const profileByKeycloak = await repoProfile.findOne({
|
const profileByKeycloak = await repoProfile.findOne({
|
||||||
where: { keycloak: req.app.locals.logData.userId },
|
where: { keycloak: req.app.locals.logData.userId },
|
||||||
|
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
||||||
|
|
||||||
export class Update2107202611411754401420685 implements MigrationInterface {
|
|
||||||
name = 'Update2107202611411754401420685'
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE \`commandRecive\` ADD \`posNo\` varchar(255) NULL COMMENT 'เลขที่ตำแหน่ง'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`birthDateOld\` datetime NULL COMMENT 'วันเกิดเดิม โดยจะบันทึกเมื่อมีการแก้ไขข้อมูลส่วนตัว'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`profileHistory\` ADD \`birthDateOld\` datetime NULL COMMENT 'วันเกิดเดิม โดยจะบันทึกเมื่อมีการแก้ไขข้อมูลส่วนตัว'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`profileTraining\` CHANGE \`isEntry\` \`isEntry\` tinyint NOT NULL COMMENT 'ข้อมูลจาก Entry' DEFAULT 0`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`metaStateOperator\` CHANGE \`createdFullName\` \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'System Administrator'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`metaStateOperator\` CHANGE \`lastUpdateFullName\` \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'System Administrator'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`metaWorkflow\` CHANGE \`createdFullName\` \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'System Administrator'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`metaWorkflow\` CHANGE \`lastUpdateFullName\` \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'System Administrator'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`metaState\` CHANGE \`createdFullName\` \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'System Administrator'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`metaState\` CHANGE \`lastUpdateFullName\` \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'System Administrator'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` ADD CONSTRAINT \`FK_f1ded3e1f83ab2437f739a14f38\` FOREIGN KEY (\`profileSalaryId\`) REFERENCES \`profileSalary\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` DROP FOREIGN KEY \`FK_f1ded3e1f83ab2437f739a14f38\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`metaState\` CHANGE \`lastUpdateFullName\` \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`metaState\` CHANGE \`createdFullName\` \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`metaWorkflow\` CHANGE \`lastUpdateFullName\` \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`metaWorkflow\` CHANGE \`createdFullName\` \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`metaStateOperator\` CHANGE \`lastUpdateFullName\` \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`metaStateOperator\` CHANGE \`createdFullName\` \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`profileTraining\` CHANGE \`isEntry\` \`isEntry\` tinyint NOT NULL DEFAULT '0'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`profileHistory\` DROP COLUMN \`birthDateOld\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`birthDateOld\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`commandRecive\` DROP COLUMN \`posNo\``);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1,20 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
||||||
|
|
||||||
export class UpdateRegistryFixLengthPrefix1756357065498 implements MigrationInterface {
|
|
||||||
name = 'UpdateRegistryFixLengthPrefix1756357065498'
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registryEmployee\` DROP COLUMN \`prefix\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registryEmployee\` ADD \`prefix\` varchar(40) NULL COMMENT 'คำนำหน้าชื่อ เช่น นาย นาง นางสาว'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registry\` DROP COLUMN \`prefix\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registry\` ADD \`prefix\` varchar(40) NULL COMMENT 'คำนำหน้าชื่อ เช่น นาย นาง นางสาว'`);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registry\` DROP COLUMN \`prefix\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registry\` ADD \`prefix\` varchar(20) NULL COMMENT 'คำนำหน้าชื่อ เช่น นาย นาง นางสาว'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registryEmployee\` DROP COLUMN \`prefix\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registryEmployee\` ADD \`prefix\` varchar(20) NULL COMMENT 'คำนำหน้าชื่อ เช่น นาย นาง นางสาว'`);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
||||||
|
|
||||||
export class UpdateRegistrymployereAddFieldEmployeeClass1756364862810 implements MigrationInterface {
|
|
||||||
name = 'UpdateRegistrymployereAddFieldEmployeeClass1756364862810'
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registryEmployee\` ADD \`employeeClass\` varchar(40) NULL COMMENT 'ประเภทลูกจ้าง (perm->ลูกจ้างประจำ temp->ลูกจ้างชั่วคราว)'`);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registryEmployee\` DROP COLUMN \`employeeClass\``);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
||||||
|
|
||||||
export class UpdateDataTypeFieldsRegistryAndRegistryEmpployee1757484721787 implements MigrationInterface {
|
|
||||||
name = 'UpdateDataTypeFieldsRegistryAndRegistryEmpployee1757484721787'
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registry\` DROP COLUMN \`degrees\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registry\` ADD \`degrees\` text NULL COMMENT 'วุฒิการศึกษา'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registry\` DROP COLUMN \`educationLevels\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registry\` ADD \`educationLevels\` text NULL COMMENT 'ระดับศึกษา'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registry\` DROP COLUMN \`fields\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registry\` ADD \`fields\` text NULL COMMENT 'สาขาวิชา/ทาง'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registryEmployee\` DROP COLUMN \`degrees\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registryEmployee\` ADD \`degrees\` text NULL COMMENT 'วุฒิการศึกษา'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registryEmployee\` DROP COLUMN \`educationLevels\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registryEmployee\` ADD \`educationLevels\` text NULL COMMENT 'ระดับศึกษา'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registryEmployee\` DROP COLUMN \`fields\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registryEmployee\` ADD \`fields\` text NULL COMMENT 'สาขาวิชา/ทาง'`);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registryEmployee\` DROP COLUMN \`fields\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registryEmployee\` ADD \`fields\` varchar(255) NULL COMMENT 'สาขาวิชา/ทาง'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registryEmployee\` DROP COLUMN \`educationLevels\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registryEmployee\` ADD \`educationLevels\` varchar(255) NULL COMMENT 'ระดับศึกษา'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registryEmployee\` DROP COLUMN \`degrees\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registryEmployee\` ADD \`degrees\` varchar(255) NULL COMMENT 'วุฒิการศึกษา'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registry\` DROP COLUMN \`fields\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registry\` ADD \`fields\` varchar(255) NULL COMMENT 'สาขาวิชา/ทาง'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registry\` DROP COLUMN \`educationLevels\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registry\` ADD \`educationLevels\` varchar(255) NULL COMMENT 'ระดับศึกษา'`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registry\` DROP COLUMN \`degrees\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`registry\` ADD \`degrees\` varchar(255) NULL COMMENT 'วุฒิการศึกษา'`);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdateTableApiKeyAddAccessType1761330464755 implements MigrationInterface {
|
||||||
|
name = 'UpdateTableApiKeyAddAccessType1761330464755'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`apiKey\` ADD \`accessType\` varchar(40) NULL COMMENT 'accessType'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`apiKey\` ADD \`dnaRootId\` varchar(40) NULL COMMENT 'dnaRootId'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`apiKey\` ADD \`dnaChild1Id\` varchar(40) NULL COMMENT 'dnaChild1Id'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`apiKey\` ADD \`dnaChild2Id\` varchar(40) NULL COMMENT 'dnaChild2Id'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`apiKey\` ADD \`dnaChild3Id\` varchar(40) NULL COMMENT 'dnaChild3Id'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`apiKey\` ADD \`dnaChild4Id\` varchar(40) NULL COMMENT 'dnaChild4Id'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`apiKey\` DROP COLUMN \`dnaChild4Id\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`apiKey\` DROP COLUMN \`dnaChild3Id\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`apiKey\` DROP COLUMN \`dnaChild2Id\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`apiKey\` DROP COLUMN \`dnaChild1Id\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`apiKey\` DROP COLUMN \`dnaRootId\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`apiKey\` DROP COLUMN \`accessType\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue