no message
This commit is contained in:
parent
6ed7265094
commit
8339e6ce6d
4 changed files with 32 additions and 25 deletions
|
|
@ -28,6 +28,7 @@ import { PosLevel } from "../entities/PosLevel";
|
|||
import { Salarys } from "../entities/Salarys";
|
||||
import { SalaryRanks } from "../entities/SalaryRanks";
|
||||
import CallAPI from "../interfaces/call-api";
|
||||
import { Int32 } from "typeorm/browser";
|
||||
|
||||
@Route("api/v1/salary/period")
|
||||
@Tags("Salary")
|
||||
|
|
@ -772,30 +773,25 @@ export class SalaryPeriodController extends Controller {
|
|||
const salaryProfile = await this.salaryProfileRepository.find({
|
||||
where: { salaryOrgId: In(salaryOrg.map((x) => x.id)) },
|
||||
});
|
||||
await this.salaryOrgRepository.remove(salaryOrg);
|
||||
await this.salaryProfileRepository.remove(salaryProfile);
|
||||
await this.salaryOrgRepository.remove(salaryOrg);
|
||||
|
||||
console.log("11111111111111111111111");
|
||||
let orgs = await new CallAPI().GetData(request, "org/active/root/id");
|
||||
console.log("22222222222222222222222");
|
||||
let orgProfiles: any;
|
||||
await new CallAPI()
|
||||
.PostData(request, "org/profile/salary/gen", {
|
||||
page: 1,
|
||||
pageSize: 100,
|
||||
keyword: "",
|
||||
})
|
||||
.then((x) => {
|
||||
orgProfiles = x.data;
|
||||
});
|
||||
console.log("333333333333333333333");
|
||||
if (orgProfiles.total > 100) {
|
||||
const page = Math.ceil(orgProfiles.total.length / 100);
|
||||
let total = 1000;
|
||||
let _orgProfiles = await new CallAPI().PostData(request, "org/profile/salary/gen", {
|
||||
page: 1,
|
||||
pageSize: 1000,
|
||||
keyword: "",
|
||||
});
|
||||
let orgProfiles = _orgProfiles.data;
|
||||
total = _orgProfiles.total;
|
||||
if (total > 1000) {
|
||||
const page = Math.ceil(total / 1000);
|
||||
for (let index = 2; index <= page; index++) {
|
||||
await new CallAPI()
|
||||
.PostData(request, "org/profile/salary/gen", {
|
||||
page: index,
|
||||
pageSize: 100,
|
||||
pageSize: 1000,
|
||||
keyword: "",
|
||||
})
|
||||
.then((x) => {
|
||||
|
|
@ -803,9 +799,7 @@ export class SalaryPeriodController extends Controller {
|
|||
});
|
||||
}
|
||||
}
|
||||
console.log("44444444444444444444444");
|
||||
let revisionId = await new CallAPI().GetData(request, "org/revision/latest");
|
||||
console.log("55555555555555555555555");
|
||||
|
||||
salaryPeriod.revisionId = revisionId;
|
||||
await this.salaryPeriodRepository.save(salaryPeriod);
|
||||
|
|
|
|||
|
|
@ -37,11 +37,13 @@ export class SalaryOrg extends EntityBase {
|
|||
snapshot: string;
|
||||
|
||||
@Column({
|
||||
default: 0,
|
||||
comment: "จำนวนคนทั้งหมด",
|
||||
})
|
||||
total: number;
|
||||
|
||||
@Column({
|
||||
default: 0,
|
||||
comment: "15%ของจำนวนคน(จำนวนเต็ม)",
|
||||
})
|
||||
fifteenPercent: number;
|
||||
|
|
|
|||
|
|
@ -35,17 +35,12 @@ class CallAPI {
|
|||
const token = request.headers.authorization;
|
||||
const url = process.env.API + path;
|
||||
try {
|
||||
console.log("response");
|
||||
console.log(url);
|
||||
console.log("response");
|
||||
const response = await axios.post(url, {
|
||||
const response = await axios.post(url, sendData, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
json: sendData,
|
||||
});
|
||||
console.log(response);
|
||||
return response.data.result;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateTableSalaryProfileAddRevision31709105846886 implements MigrationInterface {
|
||||
name = 'UpdateTableSalaryProfileAddRevision31709105846886'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`salaryOrg\` CHANGE \`total\` \`total\` int NOT NULL COMMENT 'จำนวนคนทั้งหมด' DEFAULT '0'`);
|
||||
await queryRunner.query(`ALTER TABLE \`salaryOrg\` CHANGE \`fifteenPercent\` \`fifteenPercent\` int NOT NULL COMMENT '15%ของจำนวนคน(จำนวนเต็ม)' DEFAULT '0'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`salaryOrg\` CHANGE \`fifteenPercent\` \`fifteenPercent\` int NOT NULL COMMENT '15%ของจำนวนคน(จำนวนเต็ม)'`);
|
||||
await queryRunner.query(`ALTER TABLE \`salaryOrg\` CHANGE \`total\` \`total\` int NOT NULL COMMENT 'จำนวนคนทั้งหมด'`);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue