fix(time-control): modify select & refactor dates
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
208f38baad
commit
9e4627617d
|
@ -42,27 +42,21 @@ module.exports = Self => {
|
||||||
|
|
||||||
const stmts = [];
|
const stmts = [];
|
||||||
|
|
||||||
const startedMinusOne = new Date(started);
|
|
||||||
startedMinusOne.setDate(started.getDate() - 1);
|
|
||||||
|
|
||||||
const endedPlusOne = new Date(ended);
|
|
||||||
endedPlusOne.setDate(ended.getDate() + 1);
|
|
||||||
|
|
||||||
stmts.push(`
|
stmts.push(`
|
||||||
DROP TEMPORARY TABLE IF EXISTS
|
DROP TEMPORARY TABLE IF EXISTS
|
||||||
tmp.timeControlCalculate,
|
tmp.timeControlCalculate,
|
||||||
tmp.timeBusinessCalculate
|
tmp.timeBusinessCalculate
|
||||||
`);
|
`);
|
||||||
|
|
||||||
stmts.push(new ParameterizedSQL('CALL vn.timeControl_calculateByUser(?, ?, ?)', [userId, startedMinusOne, endedPlusOne]));
|
stmts.push(new ParameterizedSQL('CALL vn.timeControl_calculateByUser(?, ?, ?)', [userId, started, ended]));
|
||||||
|
|
||||||
stmts.push(new ParameterizedSQL('CALL vn.timeBusiness_calculateByUser(?, ?, ?)', [userId, startedMinusOne, endedPlusOne]));
|
stmts.push(new ParameterizedSQL('CALL vn.timeBusiness_calculateByUser(?, ?, ?)', [userId, started, ended]));
|
||||||
|
|
||||||
const resultIndex = stmts.push(new ParameterizedSQL(`
|
const resultIndex = stmts.push(new ParameterizedSQL(`
|
||||||
SELECT tbc.dated, tbc.timeWorkSeconds expectedHours, tcc.timeWorkSeconds workedHours
|
SELECT tcc.dated, tbc.timeWorkSeconds expectedHours, tcc.timeWorkSeconds workedHours
|
||||||
FROM tmp.timeBusinessCalculate tbc
|
FROM tmp.timeControlCalculate tcc
|
||||||
LEFT JOIN tmp.timeControlCalculate tcc ON tcc.dated = tbc.dated
|
LEFT JOIN tmp.timeBusinessCalculate tbc ON tcc.dated = tbc.dated
|
||||||
WHERE tbc.dated BETWEEN ? AND ?
|
WHERE tcc.dated BETWEEN DATE(?) AND DATE(?)
|
||||||
`, [started, ended])) - 1;
|
`, [started, ended])) - 1;
|
||||||
|
|
||||||
stmts.push(`
|
stmts.push(`
|
||||||
|
|
|
@ -171,10 +171,11 @@ class Controller extends Section {
|
||||||
from: from,
|
from: from,
|
||||||
to: to
|
to: to
|
||||||
};
|
};
|
||||||
|
console.log(from, to);
|
||||||
const query = `Workers/${this.$params.id}/getWorkedHours`;
|
const query = `Workers/${this.$params.id}/getWorkedHours`;
|
||||||
return this.$http.get(query, {params}).then(res => {
|
return this.$http.get(query, {params}).then(res => {
|
||||||
const workDays = res.data;
|
const workDays = res.data;
|
||||||
|
console.log(res.data);
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
|
|
||||||
for (const workDay of workDays) {
|
for (const workDay of workDays) {
|
||||||
|
@ -212,7 +213,8 @@ class Controller extends Section {
|
||||||
let todayInWeek = this.weekDays.find(day => day.dated.getTime() === today.getTime());
|
let todayInWeek = this.weekDays.find(day => day.dated.getTime() === today.getTime());
|
||||||
|
|
||||||
if (todayInWeek && todayInWeek.hours && todayInWeek.hours.length) {
|
if (todayInWeek && todayInWeek.hours && todayInWeek.hours.length) {
|
||||||
const remainingTime = todayInWeek.workedHours ? ((todayInWeek.expectedHours - todayInWeek.workedHours) * 1000) : null;
|
const remainingTime = todayInWeek.workedHours ?
|
||||||
|
((todayInWeek.expectedHours - todayInWeek.workedHours) * 1000) : null;
|
||||||
const lastKnownEntry = todayInWeek.hours[todayInWeek.hours.length - 1];
|
const lastKnownEntry = todayInWeek.hours[todayInWeek.hours.length - 1];
|
||||||
const lastKnownTime = new Date(lastKnownEntry.timed).getTime();
|
const lastKnownTime = new Date(lastKnownEntry.timed).getTime();
|
||||||
const finishTimeStamp = lastKnownTime && remainingTime ? lastKnownTime + remainingTime : null;
|
const finishTimeStamp = lastKnownTime && remainingTime ? lastKnownTime + remainingTime : null;
|
||||||
|
|
Loading…
Reference in New Issue