Commit 931bfbd0 by lixinming

孵化器列表 导出bug

parent aead318c
......@@ -62,7 +62,10 @@ export async function fuHuaQiBaseList(lv:number, institutionalNature:number, ind
selectParam.operationName = {"$regex":`${name}`};
}
let enterpriseMap = await enterpriseData.groupFindEnterpriseCount();//计算孵化器拥有的累计企业数量
let enterpriseMap = await enterpriseData.groupFindEnterpriseCountByParam({draftLock:true});//计算孵化器拥有的累计企业数量
let shiTiEnterpriseMap = await enterpriseData.groupFindEnterpriseCountByParam({draftLock:true, state:configEnum.FUHUASTATE.实体孵化});//实体
let xuNiEnterpriseMap = await enterpriseData.groupFindEnterpriseCountByParam({draftLock:true, state:configEnum.FUHUASTATE.虚拟孵化});//虚拟
let dataBaseList = await fuhuaqiData.findFuHuaQiListByPage(selectParam, (page-1)*10 );
let count = await fuhuaqiData.findFuHuaQiCount(selectParam);
......@@ -73,10 +76,13 @@ export async function fuHuaQiBaseList(lv:number, institutionalNature:number, ind
/**截取所需字段 */
let changeData:any = extractData(splitResultConfig.FuHuaQiBaseListConfig, info, true);
const EnterpriseTotal = enterpriseMap[info.uscc] || 0; //企业总数
let numOfEntities = EnterpriseTotal - (info.virtualEnterpriseNum || 0 ); //实体企业
changeData.enterpriseTotal = EnterpriseTotal; //在孵化企业总数
changeData.numOfEntities = numOfEntities < 0 ? 0 : numOfEntities;
changeData.enterpriseTotal = enterpriseMap[info.uscc] || 0; //企业孵化总数(包括历史)
changeData.virtualEnterpriseNum = xuNiEnterpriseMap[info.uscc] || 0;//虚拟企业数量
changeData.shiTiEnterpriseNum = shiTiEnterpriseMap[info.uscc] || 0;//实体企业数量
changeData.zaiFuEnterpriseNum = changeData.shiTiEnterpriseNum + changeData.virtualEnterpriseNum;
let outEnterpriseNum = changeData.enterpriseTotal - changeData.zaiFuEnterpriseNum ;
changeData.outEnterpriseNum = outEnterpriseNum < 0 ? 0 : outEnterpriseNum;
/**备案地址转换 */
if (changeData.hatchingGround) {
......@@ -161,31 +167,39 @@ export async function outPutFuHuaQiBaseData(lv:number, institutionalNature:numbe
}
}
let enterpriseMap = await enterpriseData.groupFindEnterpriseCount();//计算所有孵化器拥有的企业总数
let enterpriseMap = await enterpriseData.groupFindEnterpriseCountByParam({draftLock:true});//计算孵化器拥有的累计企业数量
let shiTiEnterpriseMap = await enterpriseData.groupFindEnterpriseCountByParam({draftLock:true, state:configEnum.FUHUASTATE.实体孵化});//实体
let xuNiEnterpriseMap = await enterpriseData.groupFindEnterpriseCountByParam({draftLock:true, state:configEnum.FUHUASTATE.虚拟孵化});//虚拟
let dataBaseList = await fuhuaqiData.findFuHuaQiList(selectParam);
/**拼接二维数组 */
let keyList = [
"name", "operationName", "uscc", "enterpriseTotal", "virtualEnterpriseNum", "numOfEntities", "logonTime", "incubatedAcreage",
"acreageTotal", "acreagePersonalUse", "lv", "identificationTime", "industry", "institutionalNature",
"liaison", "liaisonPhone", "personInCharge", "personInChargePhone", "operationModel", "foundingTeamType",
"name", "operationName", "uscc", "enterpriseTotal", "virtualEnterpriseNum", "shiTiEnterpriseNum","zaiFuEnterpriseNum", "outEnterpriseNum",
"logonTime", "incubatedAcreage","acreageTotal", "acreagePersonalUse", "lv", "identificationTime",
"industry", "institutionalNature","liaison", "liaisonPhone", "personInCharge", "personInChargePhone",
"operationModel", "foundingTeamType",
];
let titleList = [
"名称", "运营机构名称", "统一信用代码", "企业总数", "虚拟孵化", "实体孵化",
"名称", "运营机构名称", "统一信用代码", "累计孵化企业数量", "虚拟孵化", "实体孵化","在孵企业数","迁出企业数",
"注册时间", "在孵面积", "孵化器总面积", "孵化器自用面积", "孵化器级别", "认定时间",
"领域", "机构性质", "联系人", "联系电话", "负责人", "负责人联系电话"
"领域", "机构性质", "联系人", "联系电话", "负责人", "负责人联系电话",
"运营模式","孵化器创始团队"
];
let dataList = [];
let maxTeamNumber = 0;//最大团队数
let maxHatching = 0;//最大场地数
dataBaseList.forEach( info => {
let {uscc} = info;
/**截取需要的返回字段 */
let changeData:any = extractData(splitResultConfig.FuHuaQiBaseListConfig, info, true);
const EnterpriseTotal = enterpriseMap[info.uscc] || 0; //企业总数
let numOfEntities = EnterpriseTotal - (info.virtualEnterpriseNum || 0 ); //实体企业
changeData.enterpriseTotal = EnterpriseTotal;
changeData.numOfEntities = numOfEntities < 0 ? 0 : numOfEntities;
changeData.enterpriseTotal = enterpriseMap[uscc] || 0; //企业孵化总数(包括历史)
changeData.virtualEnterpriseNum = xuNiEnterpriseMap[uscc] || 0;//虚拟企业数量
changeData.shiTiEnterpriseNum = shiTiEnterpriseMap[uscc] || 0;//实体企业数量
changeData.zaiFuEnterpriseNum = changeData.shiTiEnterpriseNum + changeData.virtualEnterpriseNum;
let outEnterpriseNum = changeData.enterpriseTotal - changeData.zaiFuEnterpriseNum ;
changeData.outEnterpriseNum = outEnterpriseNum <= 0 ? 0 : outEnterpriseNum;
/**枚举转换 */
changeData.lv = changeEnumValue(configEnum.FUHUAQILV, changeData.lv);
......@@ -204,25 +218,28 @@ export async function outPutFuHuaQiBaseData(lv:number, institutionalNature:numbe
/**生成除了创始团队和场地之外的 小数组 */
let subList = [];
keyList.forEach(subInfo => {
subList.push(changeData[subInfo] || '');
keyList.forEach(key => {
let value = changeData[key];
if (value == null || value == undefined) value = "-";
subList.push(value);
});
dataList.push(subList);
});
/**根据最大的创始团队数量 生成标题 */
let teamKeyList = ["type", "memberName", "memberSex", "memberAge", "memberDEGREE", "memberSchool", "des"];
let teamTitleList = ["人才类型", "成员姓名", "成员性别", "成员年龄", "成员最高学历", "毕业学校", "履历描述"];
let teamKeyList = ["memberName", "memberSexStr", "memberAge", "memberDEGREEStr", "memberSchool", "des"];
let teamTitleList = ["成员姓名", "成员性别", "成员年龄", "成员最高学历", "毕业学校", "履历描述"];
for (let i = 0; i < maxTeamNumber; i++) {//平铺的插入数据
let teamNum = i+1;
teamTitleList.forEach(title => {
titleList.push(`成员${teamNum}-${title}`);
});
}
let firstTitleAndTeamTitleIndex = titleList.length-1;
/**根据最大的场地数量 生成标题 */
let hatchingKeyList = [ "personInChargeAdd", "siteAcreage", "leasePrice" ];
// let hatchingKeyList = [ "personInChargeAddress", "siteAcreage", "leasePrice" ];
let hatchingTitleList = ["孵化场地地址", "孵化场地面积", "孵化场地出租单价" ];
for (let i = 0; i < maxHatching; i++) {
let hatchingNumber = i+1;
......@@ -238,27 +255,25 @@ export async function outPutFuHuaQiBaseData(lv:number, institutionalNature:numbe
dataBaseList.forEach((info, index) => {
if (info.foundingTeam && info.foundingTeam.length ) {
info.foundingTeam.forEach(teamInfo => {
teamInfo.type = changeEnumValue(configEnum.TEAM, teamInfo.type);
teamInfo.memberSex = changeEnumValue(configEnum.SEX, teamInfo.memberSex);
teamInfo.memberDEGREE = changeEnumValue(configEnum.DEGREE, teamInfo.memberDEGREE);
teamInfo.memberSexStr = changeEnumValue(configEnum.SEX, teamInfo.memberSex);
teamInfo.memberDEGREEStr = changeEnumValue(configEnum.DEGREE, teamInfo.memberDEGREE);
teamKeyList.forEach( teamKey => {
dataList[index].push(teamInfo[teamKey]);
});
});
}
if (info.hatchingGround && info.hatchingGround.length ) {
info.hatchingGround.forEach((hatchingInfo, hatchingIndex) => {1
hatchingKeyList.forEach( (hatchingKey, hatchingKeyIndex) => {
let addIndex = teamKeyList.length + ( (hatchingIndex * 3 ) + (hatchingKeyIndex) )
dataList[index][addIndex] = hatchingInfo[hatchingKey];
});
info.hatchingGround.forEach((hatchingInfo, hatchingIndex) => {
let itemStartIndex = firstTitleAndTeamTitleIndex+(hatchingIndex*3);
let personInChargeAdd = hatchingInfo["personInChargeAddress"] ? JSON.stringify(hatchingInfo["personInChargeAddress"]) : '-';
dataList[index][itemStartIndex+1] = personInChargeAdd;
dataList[index][itemStartIndex+2] = hatchingInfo["siteAcreage"] || "-";
dataList[index][itemStartIndex+3] = hatchingInfo["leasePrice"] || "-";
});
}
});
/**最后将标题作数组为二维数组的第一个子数组 */
/**将标题作数组为二维数组的第一个子数组 */
dataList.unshift(titleList)
return dataList;
}
......
......@@ -211,9 +211,8 @@ export async function findEnterpriseTotalByFuHuaQiUscc(fuHuaQiUscc:string) {
* 聚合查询 孵化器所拥有的企业数量
* @returns {} key=孵化器统一信用 value=企业数量
*/
export async function groupFindEnterpriseCount() {
let match = {draftLock:true};//前置条件
let dataList = await enterpriseModel.aggregate([{$match:match},{$group:{_id:"$fuHuaQiUscc",count:{$sum:1}}}]).exec();
export async function groupFindEnterpriseCountByParam(param) {
let dataList = await enterpriseModel.aggregate([{$match:param},{$group:{_id:"$fuHuaQiUscc",count:{$sum:1}}}]).exec();
let result = {};
dataList.forEach(info => {
let {_id, count} = info;
......
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