no message
This commit is contained in:
parent
4d24a34674
commit
6ed7265094
2 changed files with 56 additions and 31 deletions
|
|
@ -775,13 +775,37 @@ export class SalaryPeriodController extends Controller {
|
|||
await this.salaryOrgRepository.remove(salaryOrg);
|
||||
await this.salaryProfileRepository.remove(salaryProfile);
|
||||
|
||||
console.log("11111111111111111111111");
|
||||
let orgs = await new CallAPI().GetData(request, "org/active/root/id");
|
||||
let orgProfiles = await new CallAPI().PostData(request, "org/profile/salary/gen", {
|
||||
page: 1,
|
||||
pageSize: 100,
|
||||
keyword: "",
|
||||
});
|
||||
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);
|
||||
for (let index = 2; index <= page; index++) {
|
||||
await new CallAPI()
|
||||
.PostData(request, "org/profile/salary/gen", {
|
||||
page: index,
|
||||
pageSize: 100,
|
||||
keyword: "",
|
||||
})
|
||||
.then((x) => {
|
||||
Array.prototype.push.apply(orgProfiles, x.data);
|
||||
});
|
||||
}
|
||||
}
|
||||
console.log("44444444444444444444444");
|
||||
let revisionId = await new CallAPI().GetData(request, "org/revision/latest");
|
||||
console.log("55555555555555555555555");
|
||||
|
||||
salaryPeriod.revisionId = revisionId;
|
||||
await this.salaryPeriodRepository.save(salaryPeriod);
|
||||
|
|
@ -882,42 +906,39 @@ export class SalaryPeriodController extends Controller {
|
|||
*/
|
||||
async CronjobSalaryPeriod() {
|
||||
const current = new Date();
|
||||
let salaryPeriod: any
|
||||
let salaryPeriod: any;
|
||||
// console.log(current.getDate(), current.getMonth() , current.getFullYear())
|
||||
if(current.getDate() == 1 && current.getMonth() == 2){
|
||||
salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
if (current.getDate() == 1 && current.getMonth() == 2) {
|
||||
salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
year: current.getFullYear(),
|
||||
period: "MAR",
|
||||
isActive: true
|
||||
}
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
else if(current.getDate() == 1 && current.getMonth() == 3){
|
||||
salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
} else if (current.getDate() == 1 && current.getMonth() == 3) {
|
||||
salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
year: current.getFullYear(),
|
||||
period: "APR",
|
||||
isActive: true
|
||||
}
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
else if(current.getDate() == 1 && current.getMonth() == 8){
|
||||
salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
} else if (current.getDate() == 1 && current.getMonth() == 8) {
|
||||
salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
year: current.getFullYear(),
|
||||
period: "SEP",
|
||||
isActive: true
|
||||
}
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
else if(current.getDate() == 1 && current.getMonth() == 9){
|
||||
salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
} else if (current.getDate() == 1 && current.getMonth() == 9) {
|
||||
salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
year: current.getFullYear(),
|
||||
period: "OCT",
|
||||
isActive: true
|
||||
}
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class CallAPI {
|
|||
//Get
|
||||
public async GetData(request: any, @Path() path: any) {
|
||||
const token = request.headers.authorization;
|
||||
const url = process.env.ORG_API + path;
|
||||
const url = process.env.API + path;
|
||||
try {
|
||||
const response = await axios.get(url, {
|
||||
headers: {
|
||||
|
|
@ -33,8 +33,11 @@ class CallAPI {
|
|||
//Post
|
||||
public async PostData(request: any, @Path() path: any, sendData: any) {
|
||||
const token = request.headers.authorization;
|
||||
const url = process.env.ORG_API + path;
|
||||
const url = process.env.API + path;
|
||||
try {
|
||||
console.log("response");
|
||||
console.log(url);
|
||||
console.log("response");
|
||||
const response = await axios.post(url, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
|
|
@ -42,6 +45,7 @@ class CallAPI {
|
|||
},
|
||||
json: sendData,
|
||||
});
|
||||
console.log(response);
|
||||
return response.data.result;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue