import BaseController from "../baseController";
|
import { Post } from "egg-shell-decorators";
|
import { BaseExpressSpareCode } from "../../entity/express/spare/baseExpressSpareCode";
|
import { IsNull } from "typeorm";
|
|
export default class SpareCodeController extends BaseController {
|
//#region GetCensusList 获得统计数据与剩余未分配单数据
|
/// <summary>
|
/// 获得统计数据与剩余未分配单数据
|
/// </summary>
|
/// <returns>返回列表集合</returns>
|
///
|
@Post()
|
public async getStatInfo() {
|
let where = await this.ctx.service.common.getWhere();
|
try {
|
//统计总数据
|
var dataInfo = await this.dbRead
|
.createQueryBuilder(BaseExpressSpareCode, "t")
|
.select("count(1)", "cnt")
|
.where(where)
|
.getRawOne();
|
|
//统计未使用的数据
|
where["orderCode"] = IsNull();
|
var dataSurInfo = await this.dbRead
|
.createQueryBuilder(BaseExpressSpareCode, "t")
|
.select("count(1)", "cnt")
|
.where(where)
|
.getRawOne();
|
|
this.info.result = true;
|
this.info.data = {
|
sumQuantity: dataInfo.cnt,
|
surplusQuantity: dataSurInfo.cnt
|
};
|
this.ctx.body = this.info;
|
return;
|
} catch (ex) {
|
let msg = "异常错误信息:" + ex.message;
|
this.info.result = false;
|
this.info.msg = msg;
|
this.ctx.body = this.info;
|
return;
|
}
|
}
|
//#endregion
|
}
|