fix
This commit is contained in:
parent
7b29823f9e
commit
16d718baa4
1 changed files with 63 additions and 33 deletions
|
|
@ -1086,7 +1086,7 @@ export class PositionController extends Controller {
|
|||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? `CONCAT(current_holder.prefix, current_holder.firstName, current_holder.lastName) like '%${body.keyword}%'`
|
||||
? `CONCAT(current_holder.prefix, current_holder.firstName," ",current_holder.lastName) like '%${body.keyword}%'`
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
|
|
@ -1101,7 +1101,7 @@ export class PositionController extends Controller {
|
|||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? `CONCAT(next_holder.prefix, next_holder.firstName, next_holder.lastName) like '%${body.keyword}%'`
|
||||
? `CONCAT(next_holder.prefix, next_holder.firstName," ",next_holder.lastName) like '%${body.keyword}%'`
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
|
|
@ -1473,12 +1473,6 @@ export class PositionController extends Controller {
|
|||
posMaster.orgRootId = org.id;
|
||||
posMaster.orgRevisionId = org.orgRevisionId;
|
||||
}
|
||||
const lastPosMasterNo = await this.posMasterRepository.find({
|
||||
where:{
|
||||
orgRootId:requestBody.id,
|
||||
orgChild1Id: Not(IsNull())
|
||||
}
|
||||
})
|
||||
}
|
||||
if (requestBody.type == 1) {
|
||||
const org = await this.child1Repository.findOne({
|
||||
|
|
@ -1489,12 +1483,6 @@ export class PositionController extends Controller {
|
|||
posMaster.orgChild1Id = org.id;
|
||||
posMaster.orgRevisionId = org.orgRevisionId;
|
||||
}
|
||||
const lastPosMasterNo = await this.posMasterRepository.find({
|
||||
where:{
|
||||
orgChild1Id:requestBody.id,
|
||||
orgChild2Id: Not(IsNull())
|
||||
}
|
||||
})
|
||||
}
|
||||
if (requestBody.type == 2) {
|
||||
const org = await this.child2Repository.findOne({
|
||||
|
|
@ -1506,12 +1494,6 @@ export class PositionController extends Controller {
|
|||
posMaster.orgChild2Id = org.id;
|
||||
posMaster.orgRevisionId = org.orgRevisionId;
|
||||
}
|
||||
const lastPosMasterNo = await this.posMasterRepository.find({
|
||||
where:{
|
||||
orgChild2Id:requestBody.id,
|
||||
orgChild3Id: Not(IsNull())
|
||||
}
|
||||
})
|
||||
}
|
||||
if (requestBody.type == 3) {
|
||||
const org = await this.child3Repository.findOne({
|
||||
|
|
@ -1525,12 +1507,6 @@ export class PositionController extends Controller {
|
|||
posMaster.orgRevisionId = org.orgRevisionId;
|
||||
}
|
||||
}
|
||||
const lastPosMasterNo = await this.posMasterRepository.find({
|
||||
where:{
|
||||
orgChild3Id:requestBody.id,
|
||||
orgChild4Id: Not(IsNull())
|
||||
}
|
||||
})
|
||||
if (requestBody.type == 4) {
|
||||
const org = await this.child4Repository.findOne({
|
||||
where: { id: requestBody.id },
|
||||
|
|
@ -1543,14 +1519,68 @@ export class PositionController extends Controller {
|
|||
posMaster.orgChild4Id = org.id;
|
||||
posMaster.orgRevisionId = org.orgRevisionId;
|
||||
}
|
||||
const lastPosMasterNo = await this.posMasterRepository.find({
|
||||
where:{
|
||||
orgChild4Id:requestBody.id
|
||||
}
|
||||
})
|
||||
}
|
||||
const allPosMasterNo = posMasters.map(posMaster => posMaster.posMasterNo);
|
||||
const maxPosMasterNo = Math.max(...allPosMasterNo);
|
||||
const type0LastPosMasterNo = requestBody.type == 0
|
||||
? await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgRootId: requestBody.id,
|
||||
orgChild1Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type1LastPosMasterNo = requestBody.type == 1
|
||||
? await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgChild1Id: requestBody.id,
|
||||
orgChild2Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type2LastPosMasterNo = requestBody.type == 2
|
||||
? await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgChild2Id: requestBody.id,
|
||||
orgChild3Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type3LastPosMasterNo = requestBody.type == 3
|
||||
? await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgChild3Id: requestBody.id,
|
||||
orgChild4Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type4LastPosMasterNo = requestBody.type == 4
|
||||
? await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgChild4Id: requestBody.id,
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const allLastPosMasterNo = [
|
||||
...type0LastPosMasterNo,
|
||||
...type1LastPosMasterNo,
|
||||
...type2LastPosMasterNo,
|
||||
...type3LastPosMasterNo,
|
||||
...type4LastPosMasterNo,
|
||||
];
|
||||
console.log("allLast>>>>>>>>:",allLastPosMasterNo);
|
||||
console.log("type>>>>>>>>:",requestBody.type);
|
||||
console.log("data>>>>>>>>:",type2LastPosMasterNo);
|
||||
|
||||
const maxPosMasterNo = Math.max(
|
||||
...allLastPosMasterNo.map((pos) => pos.posMasterNo),
|
||||
0
|
||||
);
|
||||
|
||||
console.log("max>>>>>>>>:",maxPosMasterNo);
|
||||
posMaster.posMasterNo = maxPosMasterNo + 1;
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
posMaster.createdFullName = request.user.name;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue