import ตำแหน่ง
This commit is contained in:
parent
7b955739ba
commit
f1f7412db0
3 changed files with 160 additions and 132 deletions
|
|
@ -2277,11 +2277,11 @@ export class ImportDataController extends Controller {
|
|||
async MapPositionOfficer(@Request() request: { user: Record<string, any> }) {
|
||||
const [officer, total] = await AppDataSource.getRepository(OFFICER)
|
||||
.createQueryBuilder("OFFICER")
|
||||
.where({ DEPARTMENT_CODE: "50" })
|
||||
// .where({ DEPARTMENT_CODE: "50" })
|
||||
// .skip(0)
|
||||
// .take(20)
|
||||
.getManyAndCount();
|
||||
let rowCount = 0;
|
||||
let rowCount = 0;
|
||||
let _null: any = null;
|
||||
let type_: any = null;
|
||||
let level_: any = null;
|
||||
|
|
@ -2305,77 +2305,84 @@ export class ImportDataController extends Controller {
|
|||
if (posMasterCheck != null) {
|
||||
continue;
|
||||
}
|
||||
let orgRoot = new OrgRoot();
|
||||
let orgChild1 = new OrgChild1();
|
||||
let orgChild2 = new OrgChild2();
|
||||
let orgChild3 = new OrgChild3();
|
||||
if ((item.DEPARTMENT_CODE = "50")) {
|
||||
orgRoot = (await this.orgRootRepo.findOne({
|
||||
where: { orgRootName: item.DIVISION_NAME, orgRevisionId: orgRevision.id },
|
||||
})) as OrgRoot;
|
||||
if (orgRoot == null) {
|
||||
continue;
|
||||
}
|
||||
orgChild1 = (await this.orgChild1Repo.findOne({
|
||||
where: {
|
||||
orgChild1Name: item.SECTION_NAME,
|
||||
orgRoot: { orgRootName: item.DIVISION_NAME },
|
||||
orgRevisionId: orgRevision.id,
|
||||
},
|
||||
})) as OrgChild1;
|
||||
orgChild2 = (await this.orgChild2Repo.findOne({
|
||||
where: {
|
||||
orgChild2Name: item.JOB_NAME,
|
||||
orgChild1: {
|
||||
orgChild1Name: item.SECTION_NAME,
|
||||
orgRoot: { orgRootName: item.DIVISION_NAME },
|
||||
},
|
||||
orgRevisionId: orgRevision.id,
|
||||
},
|
||||
})) as OrgChild2;
|
||||
} else {
|
||||
orgRoot = (await this.orgRootRepo.findOne({
|
||||
where: { orgRootName: item.DEPARTMENT_NAME, orgRevisionId: orgRevision.id },
|
||||
})) as OrgRoot;
|
||||
if (orgRoot == null) {
|
||||
continue;
|
||||
}
|
||||
orgChild1 = (await this.orgChild1Repo.findOne({
|
||||
where: {
|
||||
orgChild1Name: item.DIVISION_NAME,
|
||||
orgRoot: { orgRootName: item.DEPARTMENT_NAME },
|
||||
orgRevisionId: orgRevision.id,
|
||||
},
|
||||
})) as OrgChild1;
|
||||
orgChild2 = (await this.orgChild2Repo.findOne({
|
||||
where: {
|
||||
orgChild2Name: item.SECTION_NAME,
|
||||
orgChild1: {
|
||||
orgChild1Name: item.DIVISION_NAME,
|
||||
orgRoot: { orgRootName: item.DEPARTMENT_NAME },
|
||||
},
|
||||
orgRevisionId: orgRevision.id,
|
||||
},
|
||||
})) as OrgChild2;
|
||||
orgChild3 = (await this.orgChild3Repo.findOne({
|
||||
where: {
|
||||
orgChild3Name: item.JOB_NAME,
|
||||
orgChild2: {
|
||||
orgChild2Name: item.SECTION_NAME,
|
||||
orgChild1: {
|
||||
orgChild1Name: item.DIVISION_NAME,
|
||||
orgRoot: { orgRootName: item.DEPARTMENT_NAME },
|
||||
},
|
||||
},
|
||||
orgRevisionId: orgRevision.id,
|
||||
},
|
||||
})) as OrgChild3;
|
||||
}
|
||||
let posMaster = new PosMaster();
|
||||
posMaster.orgRootId = orgRoot?.id ?? _null;
|
||||
posMaster.orgChild1Id = orgChild1?.id ?? _null;
|
||||
posMaster.orgChild2Id = orgChild2?.id ?? _null;
|
||||
posMaster.orgChild3Id = orgChild3?.id ?? _null;
|
||||
let orgRoot = new OrgRoot();
|
||||
if (item.DEPARTMENT_CODE != "50") {
|
||||
orgRoot = (await this.orgRootRepo.findOne({
|
||||
where: {
|
||||
DEPARTMENT_CODE: item.DEPARTMENT_CODE,
|
||||
DIVISION_CODE: item.DIVISION_CODE,
|
||||
SECTION_CODE: item.SECTION_CODE,
|
||||
JOB_CODE: item.JOB_CODE,
|
||||
orgRevisionId: orgRevision.id,
|
||||
},
|
||||
})) as OrgRoot;
|
||||
}
|
||||
if (orgRoot != null) {
|
||||
posMaster.orgRootId = orgRoot.id ?? _null;
|
||||
} else {
|
||||
let orgChild1 = await this.orgChild1Repo.findOne({
|
||||
where: {
|
||||
DEPARTMENT_CODE: item.DEPARTMENT_CODE,
|
||||
DIVISION_CODE: item.DIVISION_CODE,
|
||||
SECTION_CODE: item.SECTION_CODE,
|
||||
JOB_CODE: item.JOB_CODE,
|
||||
orgRevisionId: orgRevision.id,
|
||||
},
|
||||
});
|
||||
if (orgChild1 != null) {
|
||||
posMaster.orgRootId = orgChild1.orgRootId ?? _null;
|
||||
posMaster.orgChild1Id = orgChild1.id ?? _null;
|
||||
} else {
|
||||
let orgChild2 = await this.orgChild2Repo.findOne({
|
||||
where: {
|
||||
DEPARTMENT_CODE: item.DEPARTMENT_CODE,
|
||||
DIVISION_CODE: item.DIVISION_CODE,
|
||||
SECTION_CODE: item.SECTION_CODE,
|
||||
JOB_CODE: item.JOB_CODE,
|
||||
orgRevisionId: orgRevision.id,
|
||||
},
|
||||
});
|
||||
if (orgChild2 != null) {
|
||||
posMaster.orgRootId = orgChild2.orgRootId ?? _null;
|
||||
posMaster.orgChild1Id = orgChild2.orgChild1Id ?? _null;
|
||||
posMaster.orgChild2Id = orgChild2.id ?? _null;
|
||||
} else {
|
||||
let orgChild3 = await this.orgChild3Repo.findOne({
|
||||
where: {
|
||||
DEPARTMENT_CODE: item.DEPARTMENT_CODE,
|
||||
DIVISION_CODE: item.DIVISION_CODE,
|
||||
SECTION_CODE: item.SECTION_CODE,
|
||||
JOB_CODE: item.JOB_CODE,
|
||||
orgRevisionId: orgRevision.id,
|
||||
},
|
||||
});
|
||||
if (orgChild3 != null) {
|
||||
posMaster.orgRootId = orgChild3.orgRootId ?? _null;
|
||||
posMaster.orgChild1Id = orgChild3.orgChild1Id ?? _null;
|
||||
posMaster.orgChild2Id = orgChild3.orgChild2Id ?? _null;
|
||||
posMaster.orgChild3Id = orgChild3.id ?? _null;
|
||||
} else {
|
||||
let orgChild4 = await this.orgChild4Repo.findOne({
|
||||
where: {
|
||||
DEPARTMENT_CODE: item.DEPARTMENT_CODE,
|
||||
DIVISION_CODE: item.DIVISION_CODE,
|
||||
SECTION_CODE: item.SECTION_CODE,
|
||||
JOB_CODE: item.JOB_CODE,
|
||||
orgRevisionId: orgRevision.id,
|
||||
},
|
||||
});
|
||||
if (orgChild4 != null) {
|
||||
posMaster.orgRootId = orgChild4.id ?? _null;
|
||||
posMaster.orgChild1Id = orgChild4.id ?? _null;
|
||||
posMaster.orgChild2Id = orgChild4.id ?? _null;
|
||||
posMaster.orgChild3Id = orgChild4.id ?? _null;
|
||||
posMaster.orgChild4Id = orgChild4.id ?? _null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
posMaster.statusReport = "PENDING";
|
||||
posMaster.isCondition = false;
|
||||
posMaster.isStaff = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue