Commit 6206c124 by zhaoxiqing

gsb

parent dd8a7d55
......@@ -1489,6 +1489,21 @@ class LaoActionApi extends APIBase {
}
}
async workLoadPage2(obj) {
// if (!obj.userId) {
// return system.getResult(null, "用户未登录");
// }
try {
obj.status = 1;
var rs = await this.workloadSve.pageByCondition2(obj);
return system.getResultSuccess(rs);
} catch (e) {
console.log(e);
return system.getErrResult2("您的网络不稳, 请稍后重试")
}
}
async workLoadHistoryInfo(obj) {
if (!obj.userId) {
return system.getResult(null, "用户未登录");
......
......@@ -19,6 +19,27 @@ class WorkloadDao extends Dao {
return rs[0].num || 0;
}
async pagecount(params){
var sql = [];
sql.push("SELECT COUNT(*) AS num FROM workload_info wi LEFT JOIN user_info ui ON wi.user_id = ui.id WHERE `status`=1");
this.setpage(sql, params);
let rs = await this.customQuery(sql.join(" "), params);
if (!rs || rs.length == 0) {
return 0;
}
return rs[0].num || 0;
}
async pageList(params){
var sql = [];
sql.push("SELECT wi.*,ui.com_name,ui.mtchId FROM workload_info wi LEFT JOIN user_info ui ON wi.user_id = ui.id WHERE `status`=1");
this.setpage(sql, params);
sql.push("ORDER BY wi.id DESC");
sql.push("LIMIT :startRow, :pageSize");
return await this.customQuery(sql.join(" "), params);
}
async pageHistory(params) {
var sql = [];
sql.push("SELECT");
......@@ -61,6 +82,12 @@ class WorkloadDao extends Dao {
sql.push("AND id_nu = :id_nu");
}
}
setpage(sql, params) {
if (params.mtchId) {
sql.push("AND ui.mtchId = :mtchId");
}
}
}
module.exports = WorkloadDao;
......@@ -7,6 +7,7 @@ class WorkloadService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(WorkloadService));
this.restClient = system.getObject("util.restClient");
this.usersSve = system.getObject("service.operator.usersSve");
}
async pageByCondition(params) {
......@@ -47,6 +48,28 @@ class WorkloadService extends ServiceBase {
return page;
}
async pageByCondition2(params) {
params.currentPage = Number(params.currentPage || 1);
params.pageSize = Number(params.pageSize || 10);
params.mtchId = this.trim(params.ecompanyId);
let total = await this.dao.pagecount(params);
if (total == 0) {
return {count: 0, rows: []};
}
params.startRow = (params.currentPage - 1) * params.pageSize;
let list = await this.dao.pageList(params);
if (list) {
for (var item of list) {
this.handleDate(item, ['created_time', 'updated_time'], 'YYYY-MM-DD');
this.handleDate(item, ['updated_at', 'created_at'], 'YYYY-MM-DD HH:mm:ss');
}
}
return {count: total, rows: list};
}
async workloadConfirm(params) {
var sql = [];
sql.push("UPDATE");
......@@ -155,6 +178,18 @@ class WorkloadService extends ServiceBase {
return result;
}
}
async getcompany(works){
var user = await this.usersSve.findById(works.user_id)
if(user){
works.userOne = {
tenant : user.com_name,
id:user.id,
};
}
}
}
module.exports = WorkloadService;
\ No newline at end of file
module.exports = WorkloadService;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment