import position
This commit is contained in:
parent
cd419686b0
commit
5a00f77744
1 changed files with 15 additions and 23 deletions
|
|
@ -2275,12 +2275,12 @@ export class ImportDataController extends Controller {
|
|||
*/
|
||||
@Post("mapposition-Officer")
|
||||
async MapPositionOfficer(@Request() request: { user: Record<string, any> }) {
|
||||
const [officer, total] = await AppDataSource.getRepository(OFFICER)
|
||||
.createQueryBuilder("OFFICER")
|
||||
// .where({ DEPARTMENT_CODE: "50" })
|
||||
// .skip(0)
|
||||
// .take(20)
|
||||
.getManyAndCount();
|
||||
const officer = await AppDataSource.getRepository(Profile)
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.current_holders", "posMaster")
|
||||
// .where({citizenId: "1720700018869"})
|
||||
.where("posMaster.id IS NULL")
|
||||
.getMany();
|
||||
let rowCount = 0;
|
||||
let _null: any = null;
|
||||
let type_: any = null;
|
||||
|
|
@ -2289,26 +2289,19 @@ export class ImportDataController extends Controller {
|
|||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||
});
|
||||
if (orgRevision == null) return new HttpSuccess();
|
||||
for await (const item of officer) {
|
||||
for await (const _item of officer) {
|
||||
rowCount++;
|
||||
console.log(rowCount);
|
||||
const item = await AppDataSource.getRepository(OFFICER)
|
||||
.createQueryBuilder("OFFICER")
|
||||
.where({ CIT: _item.citizenId })
|
||||
.getOne();
|
||||
|
||||
const existingProfile = await this.profileRepo.findOne({
|
||||
where: { citizenId: item.CIT },
|
||||
});
|
||||
if (existingProfile == null) {
|
||||
continue;
|
||||
}
|
||||
const posMasterCheck = await this.posMasterRepo.findOne({
|
||||
where: { current_holderId: existingProfile.id },
|
||||
});
|
||||
if (posMasterCheck != null) {
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
let posMaster = new PosMaster();
|
||||
let orgRoot = new OrgRoot();
|
||||
if (item.DEPARTMENT_CODE != "50") {
|
||||
orgRoot = (await this.orgRootRepo.findOne({
|
||||
let orgRoot = (await this.orgRootRepo.findOne({
|
||||
where: {
|
||||
DEPARTMENT_CODE: item.DEPARTMENT_CODE,
|
||||
DIVISION_CODE: item.DIVISION_CODE,
|
||||
|
|
@ -2317,7 +2310,6 @@ export class ImportDataController extends Controller {
|
|||
orgRevisionId: orgRevision.id,
|
||||
},
|
||||
})) as OrgRoot;
|
||||
}
|
||||
if (orgRoot != null) {
|
||||
posMaster.orgRootId = orgRoot.id ?? _null;
|
||||
} else {
|
||||
|
|
@ -2333,7 +2325,7 @@ export class ImportDataController extends Controller {
|
|||
if (orgChild1 != null) {
|
||||
posMaster.orgRootId = orgChild1.orgRootId ?? _null;
|
||||
posMaster.orgChild1Id = orgChild1.id ?? _null;
|
||||
} else {
|
||||
} else {
|
||||
let orgChild2 = await this.orgChild2Repo.findOne({
|
||||
where: {
|
||||
DEPARTMENT_CODE: item.DEPARTMENT_CODE,
|
||||
|
|
@ -2388,7 +2380,7 @@ export class ImportDataController extends Controller {
|
|||
posMaster.isStaff = false;
|
||||
posMaster.isDirector = false;
|
||||
posMaster.isSit = false;
|
||||
posMaster.current_holderId = existingProfile.id;
|
||||
posMaster.current_holderId = _item.id;
|
||||
posMaster.posMasterNo = item.SALARY == "" ? _null : Number(item.POS_NUM_CODE);
|
||||
posMaster.orgRevisionId = orgRevision.id;
|
||||
posMaster.posMasterCreatedAt = new Date();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue