Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop
This commit is contained in:
commit
a14c04a81c
1 changed files with 97 additions and 0 deletions
|
|
@ -30,6 +30,7 @@ import { ProfileFamilyFather } from "../entities/ProfileFamilyFather";
|
|||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import { PosLevel } from "../entities/PosLevel";
|
||||
import { PosType } from "../entities/PosType";
|
||||
import * as fs from "fs";
|
||||
|
||||
@Route("api/v1/org/upload")
|
||||
@Tags("UPLOAD")
|
||||
|
|
@ -652,4 +653,100 @@ export class ImportDataController extends Controller {
|
|||
await this.profileRepo.save(profiles);
|
||||
return new HttpSuccess(getProFile);
|
||||
}
|
||||
|
||||
@Get("uploadSQLStatic")
|
||||
async uploadFileSQLStati() {
|
||||
const filePath = "/src/controllers/backup-employee-temp-bmatest.xlsx"; // Corrected file path
|
||||
if (!fs.existsSync(filePath)) {
|
||||
throw new Error(`File not found: ${filePath}`);
|
||||
}
|
||||
const fileBuffer = fs.readFileSync(filePath);
|
||||
const workbook = xlsx.read(fileBuffer, { type: "buffer" });
|
||||
const sheetName = workbook.SheetNames[0]; // Assuming we're reading the first sheet
|
||||
const sheet = workbook.Sheets[sheetName];
|
||||
const getProFile = xlsx.utils.sheet_to_json(sheet);
|
||||
let profiles: any = [];
|
||||
await Promise.all(
|
||||
getProFile.map(async (item: any) => {
|
||||
// Create a new Profile entity and assign fields from the parsed data
|
||||
|
||||
const profile = new ProfileEmployee();
|
||||
// Check if the profile already exists
|
||||
// const existingProfile = await this.profileEmpRepo.findOne({
|
||||
// where: { id: item["id"] },
|
||||
// });
|
||||
// If profile exists, skip saving
|
||||
// if (existingProfile) {
|
||||
// return;
|
||||
// }
|
||||
// Assign fields from the item to the profile entity
|
||||
profile.id = item["id"];
|
||||
// profile.createdAt = item["createdUserId"] == "NULL" ? null : new Date(item["createdAt"]);
|
||||
profile.createdUserId = item["createdUserId"] == "NULL" ? null : item["createdUserId"];
|
||||
// profile.lastUpdatedAt = item["createdUserId"] == "NULL" ? null : new Date(item["lastUpdatedAt"]);
|
||||
profile.lastUpdateUserId =
|
||||
item["lastUpdateUserId"] == "NULL" ? null : item["lastUpdateUserId"];
|
||||
profile.createdFullName =
|
||||
item["createdFullName"] == "NULL" ? null : item["createdFullName"];
|
||||
profile.lastUpdateFullName =
|
||||
item["lastUpdateFullName"] == "NULL" ? null : item["lastUpdateFullName"];
|
||||
profile.prefix = item["prefix"] == "NULL" ? null : item["prefix"];
|
||||
profile.firstName = item["firstName"] == "NULL" ? null : item["firstName"];
|
||||
profile.lastName = item["lastName"] == "NULL" ? null : item["lastName"];
|
||||
profile.citizenId = item["citizenId"] == "NULL" ? null : item["citizenId"];
|
||||
profile.position = item["position"] == "NULL" ? null : item["position"];
|
||||
profile.posLevelId = item["posLevelId"] == "NULL" ? null : item["posLevelId"];
|
||||
profile.posTypeId = item["posTypeId"] == "NULL" ? null : item["posTypeId"];
|
||||
profile.email = item["email"] == "NULL" ? null : item["email"];
|
||||
profile.phone = item["phone"] == "NULL" ? null : item["phone"];
|
||||
profile.keycloak = item["keycloak"] == "NULL" ? null : item["keycloak"];
|
||||
profile.isProbation = item["isProbation"] == "NULL" ? null : item["isProbation"];
|
||||
// profile.dateRetire = item["dateRetire"] == "NULL" ? null : new Date(item["dateRetire"]);
|
||||
// profile.birthDate = item["birthDate"] == "NULL" ? null : new Date(item["birthDate"]);
|
||||
profile.salaryLevel = item["salaryLevel"] == "NULL" ? null : item["salaryLevel"];
|
||||
profile.ethnicity = item["ethnicity"] == "NULL" ? null : item["ethnicity"];
|
||||
profile.telephoneNumber =
|
||||
item["telephoneNumber"] == "NULL" ? null : item["telephoneNumber"];
|
||||
profile.group = item["group"] == "NULL" ? null : item["group"];
|
||||
profile.gender = item["gender"] == "NULL" ? null : item["gender"];
|
||||
profile.relationship = item["relationship"] == "NULL" ? null : item["relationship"];
|
||||
profile.religion = item["religion"] == "NULL" ? null : item["religion"];
|
||||
profile.bloodGroup = item["bloodGroup"] == "NULL" ? null : item["bloodGroup"];
|
||||
profile.rank = item["rank"] == "NULL" ? null : item["rank"];
|
||||
profile.employeeClass = item["employeeClass"] == "NULL" ? null : item["employeeClass"];
|
||||
profile.avatar = item["avatar"] == "NULL" ? null : item["avatar"];
|
||||
// profile.dateRetireLaw = item["dateRetireLaw"] == "NULL" ? null : new Date(item["dateRetireLaw"]);
|
||||
profile.registrationAddress =
|
||||
item["registrationAddress"] == "NULL" ? null : item["registrationAddress"];
|
||||
profile.registrationProvinceId =
|
||||
item["registrationProvinceId"] == "NULL" ? null : item["registrationProvinceId"];
|
||||
profile.registrationDistrictId =
|
||||
item["registrationDistrictId"] == "NULL" ? null : item["registrationDistrictId"];
|
||||
profile.registrationSubDistrictId =
|
||||
item["registrationSubDistrictId"] == "NULL" ? null : item["registrationSubDistrictId"];
|
||||
profile.registrationZipCode =
|
||||
item["registrationZipCode"] == "NULL" ? null : item["registrationZipCode"];
|
||||
profile.currentAddress = item["currentAddress"] == "NULL" ? null : item["currentAddress"];
|
||||
profile.currentProvinceId =
|
||||
item["currentProvinceId"] == "NULL" ? null : item["currentProvinceId"];
|
||||
profile.currentDistrictId =
|
||||
item["currentDistrictId"] == "NULL" ? null : item["currentDistrictId"];
|
||||
profile.currentSubDistrictId =
|
||||
item["currentSubDistrictId"] == "NULL" ? null : item["currentSubDistrictId"];
|
||||
profile.currentZipCode = item["currentZipCode"] == "NULL" ? null : item["currentZipCode"];
|
||||
profile.avatarName = item["avatarName"] == "NULL" ? null : item["avatarName"];
|
||||
profile.nationality = item["nationality"] == "NULL" ? null : item["nationality"];
|
||||
// profile.dateAppoint = item["dateAppoint"] == "NULL" ? null : new Date(item["dateAppoint"]);
|
||||
// profile.dateStart = item["dateStart"] == "NULL" ? null : new Date(item["dateStart"]);
|
||||
profile.govAgeAbsent = item["govAgeAbsent"] == "NULL" ? null : item["govAgeAbsent"];
|
||||
profile.govAgePlus = item["govAgePlus"] == "NULL" ? null : item["govAgePlus"];
|
||||
profile.reasonSameDate = item["reasonSameDate"] == "NULL" ? null : item["reasonSameDate"];
|
||||
profiles.push(profile);
|
||||
}),
|
||||
);
|
||||
// await this.profileEmpRepo.save(profiles);
|
||||
console.log(profiles);
|
||||
|
||||
return new HttpSuccess(getProFile);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue