Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop
This commit is contained in:
commit
ebe1eea5e0
5 changed files with 80 additions and 0 deletions
|
|
@ -255,6 +255,8 @@ export class EmployeePositionController extends Controller {
|
|||
? null
|
||||
: `${position.posType.posTypeShortName} ${position.posLevel.posLevelName}`,
|
||||
positionIsSelected: position.positionIsSelected,
|
||||
isOfficer: posMaster.isOfficer,
|
||||
isDirecter: posMaster.isDirector,
|
||||
})),
|
||||
};
|
||||
return new HttpSuccess(formattedData);
|
||||
|
|
@ -611,6 +613,8 @@ export class EmployeePositionController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลอัตรากำลัง");
|
||||
}
|
||||
posMaster.posMasterNo = requestBody.posMasterNo;
|
||||
posMaster.isDirector = requestBody.isDirector;
|
||||
posMaster.isOfficer = requestBody.isOfficer;
|
||||
posMaster.posMasterNoPrefix = requestBody.posMasterNoPrefix;
|
||||
posMaster.posMasterNoSuffix = requestBody.posMasterNoSuffix;
|
||||
posMaster.reason = requestBody.reason == null ? "" : requestBody.reason;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ import { ProfileFamilyCouple } from "../entities/ProfileFamilyCouple";
|
|||
import { ProfileFamilyMother } from "../entities/ProfileFamilyMother";
|
||||
import { ProfileFamilyFather } from "../entities/ProfileFamilyFather";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import { PosLevel } from "../entities/PosLevel";
|
||||
import { PosType } from "../entities/PosType";
|
||||
|
||||
@Route("api/v1/org/upload")
|
||||
@Tags("UPLOAD")
|
||||
|
|
@ -40,6 +42,8 @@ export class ImportDataController extends Controller {
|
|||
private salaryRepository = AppDataSource.getRepository(ProfileSalary);
|
||||
private profileRepo = AppDataSource.getRepository(Profile);
|
||||
private profileEmpRepo = AppDataSource.getRepository(ProfileEmployee);
|
||||
private posLevelRepo = AppDataSource.getRepository(PosLevel);
|
||||
private posTypeRepo = AppDataSource.getRepository(PosType);
|
||||
/**
|
||||
* API upload EDU
|
||||
*
|
||||
|
|
@ -594,4 +598,58 @@ export class ImportDataController extends Controller {
|
|||
await this.salaryRepository.save(profiles);
|
||||
return new HttpSuccess(allData);
|
||||
}
|
||||
|
||||
@Post("uploadposSQL")
|
||||
@UseInterceptors(FileInterceptor("file"))
|
||||
async UploadPOSFileSQL(@UploadedFile() file: Express.Multer.File) {
|
||||
const workbook = xlsx.read(file.buffer, { type: "buffer" });
|
||||
const sheetName = workbook.SheetNames[0];
|
||||
const sheet = workbook.Sheets[sheetName];
|
||||
const getProFile = xlsx.utils.sheet_to_json(sheet);
|
||||
let profiles: any = [];
|
||||
await Promise.all(
|
||||
getProFile.map(async (item: any) => {
|
||||
// Find profile by ID
|
||||
let profile = await this.profileRepo.findOne({
|
||||
where: { citizenId: item["ID"] },
|
||||
});
|
||||
if (!profile) {
|
||||
return; // Skip processing this item
|
||||
}
|
||||
|
||||
if (item["MP_CEE_TYPE"] === "NULL") {
|
||||
profile.posTypeId = null;
|
||||
} else {
|
||||
// Find posType by posTypeName
|
||||
const posType = await this.posTypeRepo.findOne({
|
||||
where: { posTypeName: item["MP_CEE_TYPE"] },
|
||||
});
|
||||
if (!posType) {
|
||||
return; // Skip processing this item
|
||||
}
|
||||
profile.posTypeId = posType.id;
|
||||
}
|
||||
// Check if posLevelName is "NULL"
|
||||
if (item["MP_CEE_POSITION"] === "NULL") {
|
||||
profile.posLevelId = null;
|
||||
} else {
|
||||
// Find posLevel by posLevelName
|
||||
const posLevel = await this.posLevelRepo.findOne({
|
||||
where: { posLevelName: item["MP_CEE_POSITION"] },
|
||||
});
|
||||
if (!posLevel) {
|
||||
console.error(
|
||||
`posLevel with name ${item["MP_CEE_POSITION"]} not found for profile ID ${profile.id}`,
|
||||
);
|
||||
return; // Skip processing this item
|
||||
}
|
||||
profile.posLevelId = posLevel.id;
|
||||
}
|
||||
|
||||
profiles.push(profile);
|
||||
}),
|
||||
);
|
||||
await this.profileRepo.save(profiles);
|
||||
return new HttpSuccess(getProFile);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -797,6 +797,8 @@ export class PositionController extends Controller {
|
|||
if (!posMaster) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลอัตรากำลัง");
|
||||
}
|
||||
posMaster.isDirector = requestBody.isDirector;
|
||||
posMaster.isOfficer = requestBody.isOfficer;
|
||||
posMaster.posMasterNo = requestBody.posMasterNo;
|
||||
posMaster.posMasterNoPrefix = requestBody.posMasterNoPrefix;
|
||||
posMaster.posMasterNoSuffix = requestBody.posMasterNoSuffix;
|
||||
|
|
@ -949,6 +951,8 @@ export class PositionController extends Controller {
|
|||
position.positionExecutiveField = x.posDictExecutiveField;
|
||||
position.positionArea = x.posDictArea;
|
||||
position.isSpecial = x.isSpecial;
|
||||
position.isOfficer = x.isOfficer;
|
||||
position.isDirector = x.isDirector;
|
||||
position.positionIsSelected = x.positionIsSelected;
|
||||
position.posMasterId = posMaster.id;
|
||||
position.createdUserId = request.user.sub;
|
||||
|
|
@ -1001,6 +1005,8 @@ export class PositionController extends Controller {
|
|||
positionArea: position.positionArea,
|
||||
positionIsSelected: position.positionIsSelected,
|
||||
isSpecial: position.isSpecial,
|
||||
isOfficer: posMaster.isOfficer,
|
||||
isDirecter: posMaster.isDirector,
|
||||
})),
|
||||
};
|
||||
return new HttpSuccess(formattedData);
|
||||
|
|
|
|||
|
|
@ -237,6 +237,12 @@ export class CreateEmployeePosMaster {
|
|||
|
||||
@Column()
|
||||
reason: string | null;
|
||||
|
||||
@Column()
|
||||
isDirector: boolean;
|
||||
|
||||
@Column()
|
||||
isOfficer: boolean;
|
||||
}
|
||||
|
||||
export type UpdateEmployeePosMaster = Partial<EmployeePosMaster>;
|
||||
|
|
|
|||
|
|
@ -236,6 +236,12 @@ export class CreatePosMaster {
|
|||
|
||||
@Column()
|
||||
reason: string | null;
|
||||
|
||||
@Column()
|
||||
isDirector: boolean;
|
||||
|
||||
@Column()
|
||||
isOfficer: boolean;
|
||||
}
|
||||
|
||||
export type UpdatePosMaster = Partial<PosMaster>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue