Commit 29b05dd5 by lixinming

no message

parent e07fd5c1
......@@ -7,12 +7,13 @@
import { FinancingParamConfig, FinancingParamUpdateConfig } from "../../config/checkParamConfig";
import { ERRORENUM } from "../../config/errorEnum";
import { EnterpriseFinancingInfoConfig } from "../../config/ojbectResultKeyConfig";
import { createFinancing, deleteEnterpriseFinancing, findFinancingCount, findFinancingInfoByTaskIdAndSucc, findFinancingList, groupFindFinancing } from "../../data/enterprise/financing";
import { createFinancing, deleteEnterpriseFinancing, findFinancingCount, findFinancingInfoByTaskIdAndSucc, findFinancingList } from "../../data/enterprise/financing";
import { FinancingListConfig } from "../../config/ojbectResultKeyConfig";
import { BizError } from "../../util/bizError";
import { checkChange, checkParamater, extractData, getTaskId } from "../../util/tools";
import { findEnterpriseInfoByName, findEnterpriseListByFuHuaQiUsccName } from "../../data/enterprise/enterprise";
import { findFuHuaQiByName } from "../../data/fuHuaQi/fuhuaqi";
import moment = require("moment");
/**
......@@ -142,24 +143,25 @@ export async function getFuHuaQiEnterpriseForSelect(uscc:string) {
* @param page 页数
* @returns
*/
export async function financingList(monthData:string, fuHuaQiName:string, industry:[Number], fuHuaQiInvestment:boolean, page:number) {
export async function financingList(monthData:string, fuHuaQiName:string, industry, fuHuaQiInvestment:boolean, page:number) {
let fuHuaQiInfo = await findFuHuaQiByName(fuHuaQiName);
if (!fuHuaQiInfo) throw new BizError(ERRORENUM.未找到数据, `库中不存在${fuHuaQiName}这个孵化器`);
let selectParam:any = {};
let year = monthData.substring(0,5);
let month = monthData.slice(5, monthData.length);
if (monthData) selectParam.year = year; selectParam.month = month;
if (fuHuaQiName) selectParam.fuHuaQiUscc = fuHuaQiInfo.uscc;
if (industry) selectParam.industry = industry;
if (fuHuaQiInvestment) selectParam.fuHuaQiInvestment = fuHuaQiInvestment;
let enterpriseMap = await groupFindFinancing();
if ( monthData.length > 0 ) {
let startT = moment(monthData).startOf('month').valueOf();
let endT = moment(monthData).endOf('month').valueOf();
selectParam.createTime = {'$gt':startT, '$lt':endT};
}
if (fuHuaQiName.length > 0 ) selectParam.fuHuaQiUscc = fuHuaQiInfo.uscc;
if (industry.length >0 ) selectParam.industry = industry;
selectParam.fuHuaQiInvestment = fuHuaQiInvestment;
let dataBaseList = await findFinancingList(selectParam, (page-1)*10 );
let count = await findFinancingCount(selectParam);
let dataList = [];
dataBaseList.forEach( info => {
let changeData = extractData(FinancingListConfig, info);
const Count = enterpriseMap[info.uscc] || 0;
dataList.push(changeData);
});
......
......@@ -22,8 +22,6 @@ const financingSchema = new Schema({
fuHuaQiInvestmentStyle:Number,//孵化器投资方式
draftLock:{type:Boolean, default:false},//草稿锁,true为提交之后,false为草稿
createTime:Number,//录入时间
year:String,//数据年份
month:String,//数据月份
industry:[Number],//领域
});
......@@ -103,22 +101,6 @@ export async function deleteEnterpriseFinancing(uscc:string, taskId:string) {
/**
* 聚合查询 孵化器所拥有的企业数量
* @returns {} key=孵化器统一信用 value=企业数量
*/
export async function groupFindFinancing() {
let match = {draftLock:true};//前置条件
let dataList = await financingModel.aggregate([{$match:match},{$group:{_id:"$fuHuaQiUscc",count:{$sum:1}}}]).exec();
let result = {};
dataList.forEach(info => {
let {_id, count} = info;
result[_id] = count;
});
return result;
}
/**
* 获取所有融资企业
* @param selectParam 查询参数
* @param skipCount 跳过数量
......
......@@ -77,7 +77,6 @@ async function getMonthList(req, res) {
async function getFuHuaQiUserList(req, res) {
let reqConf = {operationName: 'String', page: 'Number' };
let { operationName, page } = checkParamaterType(reqConf, req.body);
const Uscc = req.headers.uscc;
let result = await userBiz.fuHuaQiUserList(operationName, page);
res.success(result);
......@@ -104,7 +103,7 @@ async function getMonthList(req, res) {
* @param res
*/
async function getEnterpriseList(req, res) {
let reqConf = {time: 'Number', fuHuaQiUscc: 'String', industry: 'Number', isNaturalPersonHolding: 'Boolean', page: 'Number' };
let reqConf = {time: 'Number', fuHuaQiUscc: 'String', industry: '[Number]', isNaturalPersonHolding: 'Boolean', page: 'Number' };
let { time, fuHuaQiUscc, industry, isNaturalPersonHolding, page } = checkParamaterType(reqConf, req.body);
let result = await enterpriseBiz.enterpriseList(time, fuHuaQiUscc, industry, isNaturalPersonHolding, page);
......@@ -120,7 +119,6 @@ async function getMonthList(req, res) {
async function updateState(req, res) {
let reqConf = {userState: 'Boolean', uscc: 'String' };
let { userState, uscc } = checkReqParam(reqConf, req.body);
const Uscc = req.headers.uscc;
let result = await userBiz.updateState(uscc, userState);
res.success(result);
......
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