update org
This commit is contained in:
parent
2094973dd0
commit
40bc95bb87
1 changed files with 24 additions and 20 deletions
|
|
@ -6316,45 +6316,49 @@ export class ImportDataController extends Controller {
|
|||
@Post("updateRetireClearOrg")
|
||||
async updateRetireClearOrg(@Request() request: { user: Record<string, any> }) {
|
||||
const profiles = await this.profileRepo.find({
|
||||
where: {
|
||||
isLeave: true,
|
||||
},
|
||||
where: { isLeave: true },
|
||||
select: ["id"],
|
||||
});
|
||||
|
||||
for (const item of profiles) {
|
||||
const posmaster = await this.posMasterRepo.findOne({
|
||||
const profileIds = profiles.map((p) => p.id);
|
||||
if (profileIds.length > 0) {
|
||||
const posmasters = await this.posMasterRepo.find({
|
||||
where: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: false,
|
||||
orgRevisionIsDraft: true,
|
||||
},
|
||||
next_holderId: item.id,
|
||||
next_holderId: In(profileIds),
|
||||
},
|
||||
});
|
||||
if (!posmaster) continue;
|
||||
posmaster.next_holderId = null;
|
||||
await this.posMasterRepo.save(posmaster);
|
||||
for (const posmaster of posmasters) {
|
||||
posmaster.next_holderId = null;
|
||||
}
|
||||
if (posmasters.length > 0) {
|
||||
await this.posMasterRepo.save(posmasters);
|
||||
}
|
||||
}
|
||||
|
||||
const profileEmps = await this.profileEmpRepo.find({
|
||||
where: {
|
||||
isLeave: true,
|
||||
},
|
||||
where: { isLeave: true },
|
||||
select: ["id"],
|
||||
});
|
||||
|
||||
for (const item of profileEmps) {
|
||||
const posmaster = await this.posMasterEmpRepo.findOne({
|
||||
const profileEmpIds = profileEmps.map((p) => p.id);
|
||||
if (profileEmpIds.length > 0) {
|
||||
const posmasterEmps = await this.posMasterEmpRepo.find({
|
||||
where: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: false,
|
||||
orgRevisionIsDraft: true,
|
||||
},
|
||||
next_holderId: item.id,
|
||||
next_holderId: In(profileEmpIds),
|
||||
},
|
||||
});
|
||||
if (!posmaster) continue;
|
||||
posmaster.next_holderId = null;
|
||||
await this.posMasterEmpRepo.save(posmaster);
|
||||
for (const posmasterEmp of posmasterEmps) {
|
||||
posmasterEmp.next_holderId = null;
|
||||
}
|
||||
if (posmasterEmps.length > 0) {
|
||||
await this.posMasterEmpRepo.save(posmasterEmps);
|
||||
}
|
||||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue