Commit de471ad3 by lixinming

no message

parent cb3c6871
......@@ -17,11 +17,13 @@
"moment": "^2.24.0",
"mongoose": "^5.4.0",
"mysql": "^2.18.1",
"mysql2": "^3.13.0",
"node-xlsx": "^0.16.1",
"nodemailer": "^6.1.1",
"officegen": "^0.6.5",
"qs": "^6.11.0",
"request": "^2.88.0",
"sequelize": "^6.37.5",
"svg-captcha": "^1.3.12",
"tencentcloud-sdk-nodejs": "^4.0.562",
"ws": "^5.2.2",
......
This source diff could not be displayed because it is too large. You can view the blob instead.
<config>
<port>7077</port>
<port>13281</port>
<mongodb>
<path>127.0.0.1</path>
<port>27017</port>
<w>1</w>
<!-- <dataBase>baseDB</dataBase> -->
<dataBase>zjsc0809</dataBase>
<dataBase>zjnt</dataBase>
<wtimeoutMS>30000</wtimeoutMS>
</mongodb>
<!-- 小程序的secret 和 appid -->
<secret>5907d55efdd2f6b3e11e719b8d781111</secret>
<appId>wxbfc5695971b3e395</appId>
<!-- 获取小程序的openId地址 -->
<getOpenIdUrl>https://api.weixin.qq.com/sns/jscode2session</getOpenIdUrl>
<!-- 短信相关配置 -->
<sms>
<sdkAppId>1400799515</sdkAppId>
<appKey>a36634bd106ee72eeea4a4bb4e62a03b</appKey>
<smsSign>张江科创服务中心</smsSign>
<!-- 修改密码的模板id -->
<changePwd>1729284</changePwd>
<!-- 填报提示 -->
<pointOut>1729286</pointOut>
<!-- 初始化账号提示 -->
<initPointOut>1729288</initPointOut>
</sms>
<!-- <baidumap>KI1jEpifrEQtgr7ZJ2zAOKlUw1tme7Eb</baidumap> -->
<!-- <baidumap>QCxLry4y9BjIDRDIsGAerkcHrnrbo55I</baidumap> 夏-->
<baidumap>yvr5gS5rGO6tFfq3gERdRfzTRsguXG9T</baidumap>
</config>
/**
* 企业标签 管理后台
* 6.0功能
*
*/
import { findEnterpriseByUscc, findEnterpriseCount, findEnterpriseListToPage } from "../../../data/enterprise/enterprise";
import { findLabelLogByParam } from "../../../data/enterprise/enterpriseLabelLog";
import { getEffectiveLabelMap, selectLabelList } from "../../../data/label";
import { changeEnumValue, eccEnumValue } from "../../../util/verificationEnum";
import moment = require("moment");
import { updateLabelToEnterprise } from "../../label";
import { ENTERPRISESYSTEMLABEL, LABELGOAL, LABELTYPE, LABELUPDATEROAD } from "../../../config/enum/labelEnum";
/**
* 企业标签列表
* @param name
* @param page
* @param labelIdList
* @returns
*/
export async function enterpriseLabelList(name:string, page:number, labelIdList) {
let selectParam:any = {};
if (name) selectParam.operationName = {"$regex":`${name}`};
if (labelIdList.length) {
selectParam.labels = {"$elemMatch":{labelId:{"$in":labelIdList} } }
}
let dbList = await findEnterpriseListToPage(selectParam, (page-1)*10);
let count = await findEnterpriseCount(selectParam);
let labelMap = await getEffectiveLabelMap(LABELGOAL.企业);
let dataList = [];
dbList.forEach(info => {
let {name, labels, uscc} = info;
let changeList = [];
labels.forEach(labelItem => {
let {state, labelId} = labelItem;
if (labelMap[labelId]) {
let {labelName, labelType} = labelMap[labelId];
changeList.push({
state,
labelName,
labelType,
labelTypeStr:changeEnumValue(LABELTYPE, labelType)
});
}
});
dataList.push({
name,
labels:changeList,
uscc
});
});
return {count, dataList, pageCount:Math.ceil(count/10) };
}
/**
* 企业标签动态列表
* @param uscc
*/
export async function enterpriseLabelLogList(uscc:string) {
let dblist = await findLabelLogByParam({uscc});
let labelMap = await getEffectiveLabelMap(LABELGOAL.企业);
let dataList = [];
dblist.sort((a,b) => {return b.ct - a.ct});
dblist.forEach(info => {
let {ct, road, labelId, desc} = info;
let descStr = '';
switch (labelId) {
case ENTERPRISESYSTEMLABEL.在孵企业:
if (road == LABELUPDATEROAD.失效) descStr = '孵化时间到期';
else descStr = desc;
break;
case ENTERPRISESYSTEMLABEL.入驻非孵:
if (road == LABELUPDATEROAD.失效) descStr = '企业迁出';
else descStr = '孵化时间到期或注册地为非张江企业';
break;
case ENTERPRISESYSTEMLABEL.迁出企业:
if (road == LABELUPDATEROAD.失效) descStr = '';
else descStr = desc;
break;
case ENTERPRISESYSTEMLABEL.高新企业:
if (road == LABELUPDATEROAD.失效) descStr = '';
else descStr = desc || "张江后台更新";
break;
case ENTERPRISESYSTEMLABEL.专精特新:
if (road == LABELUPDATEROAD.失效) descStr = '';
else descStr = desc;
break;
case ENTERPRISESYSTEMLABEL.上市企业:
if (road == LABELUPDATEROAD.失效) descStr = '';
else descStr = desc;
break;
case ENTERPRISESYSTEMLABEL.小巨人:
if (road == LABELUPDATEROAD.失效) descStr = '';
else descStr = desc;
break;
case ENTERPRISESYSTEMLABEL.融资企业:
if (road == LABELUPDATEROAD.失效) descStr = '';
else descStr = desc;
break;
case ENTERPRISESYSTEMLABEL.虚拟企业:
if (road == LABELUPDATEROAD.失效) descStr = '';
else descStr = desc;
break;
case ENTERPRISESYSTEMLABEL.毕业企业:
if (road == LABELUPDATEROAD.失效) descStr = '';
else descStr = desc;
break;
case ENTERPRISESYSTEMLABEL.拟毕业企业:
if (road == LABELUPDATEROAD.失效) descStr = '';
else descStr = '触发条件,符合毕业企业要求';
break;
default:
if (road == LABELUPDATEROAD.失效) descStr = '';
else descStr = desc || "张江后台更新";
break;
}
dataList.push({
logTime:moment(ct).format("YYYY-MM-DD"),
state:road == LABELUPDATEROAD.失效 ? "失效" : "生效",
labelName:labelMap[labelId].labelName,
desc:descStr
});
});
return {dataList};
}
/**
* 批量添加企业标签
* @param uscc
* @param labelIdList
* @returns
*/
export async function addEnterpriseLabel(uscc:string, labelIdList) {
//只能添加自定义标签
let labelMap = await getEffectiveLabelMap(LABELGOAL.企业);
let enterpriseInfo = await findEnterpriseByUscc(uscc);
let dbLabelList = enterpriseInfo.labels || [];
let newLabelList = [];
dbLabelList.forEach(info => {
let {labelId, state} = info;
if (labelMap[labelId]) {
if (state && labelMap[labelId].labelType == LABELTYPE.系统标签 ) {
newLabelList.push(labelId);
}
}
});
await updateLabelToEnterprise(uscc, newLabelList.concat(labelIdList));
return {isSuccess:true};
}
/**
* 批量删除企业标签
* @param uscc
* @param labelIdList
* @returns
*/
export async function deleteEnterpriseLabel(uscc:string, labelIdList) {
let labelMap = await getEffectiveLabelMap(LABELGOAL.企业);
let enterpriseInfo = await findEnterpriseByUscc(uscc);
let dbLabelList = enterpriseInfo.labels || [];
let newLabelList = [];
dbLabelList.forEach(info => {
let {labelId, state} = info;
if (labelMap[labelId]) {
if (state && labelMap[labelId].labelType == LABELTYPE.系统标签 ) {
newLabelList.push(labelId);
}
}
});
await updateLabelToEnterprise(uscc, newLabelList.concat(labelIdList));
return {isSuccess:true};
}
/**
* 标签管理选择框
* @param goal
* @returns
*/
export async function getLabelListByGoal(goal:number) {
eccEnumValue("获取标签管理", "goal", LABELGOAL, goal );
let list = await selectLabelList({goal, state:false, labelType:LABELTYPE.自定义标签});
let dataList = [];
list.forEach(info => {
dataList.push({
key:info.labelName,
value:info.id
});
});
return {dataList}
}
\ No newline at end of file
/**
* 新的任务系统(自定义任务)
* 6.0版本
*/
import moment = require("moment");
import { changeEnumValue, eccEnumValue } from "../../../util/verificationEnum";
import { FUHUAQICUSTOMTASKTYPE, TASKTYPEENUM } from "../../../config/enum";
import * as customTaskData from "../../../data/fuHuaQi/customTask";
import { BizError } from "../../../util/bizError";
import { ERRORENUM } from "../../../config/errorEnum";
import * as taskData from "../../../data/fuHuaQi/monthTask/task";
import * as dangJianTaskData from "../../../data/fuHuaQi/monthTask/dangJian";
import * as monthTableData from "../../../data/fuHuaQi/monthTask/monthTable";
import { findAllNotDisabledFuHuaQi } from "../../../data/fuHuaQi/fuhuaqi";
import { generateMonthTaskId } from "../../../tools/taskTool";
/**
* 创建自定义任务
* @param fuHuaQiTaskType
* @param dataCycle 数据周期
* @param startMs
* @param endMs
*/
export async function createTask(fuHuaQiTaskType:number, dataCycle:number, startMs:number, endMs:number) {
eccEnumValue("创建自定义任务", "", FUHUAQICUSTOMTASKTYPE, fuHuaQiTaskType);
if (fuHuaQiTaskType == FUHUAQICUSTOMTASKTYPE.月度任务) {
await createCustomMonthTask(dataCycle, startMs, endMs);
} else if (fuHuaQiTaskType == FUHUAQICUSTOMTASKTYPE.党建任务) {
await createCustomYearTask(dataCycle, startMs, endMs);
}
return {isSuccess:true};
}
/**
* 创建自定义月度任务
*/
async function createCustomMonthTask(dataCycle:number, startMs:number, endMs:number) {
//计算周期
let dataCycleTime = moment(dataCycle);
let cycleNum = dataCycleTime.format("YYYYMM");//数据周期格式化 数据月
const DataMonth = dataCycleTime.month() + 1;
const DataYear = dataCycleTime.year();
//限制 不能创建未来数据月的任务
if (parseInt(cycleNum) >= parseInt(moment().startOf('month').format('YYYYMM'))) throw new BizError(ERRORENUM.不可以创建未来数据月的任务);
if (parseInt(cycleNum) >= parseInt(moment(startMs).format('YYYYMM')) ) throw new BizError(ERRORENUM.填报周期不能小于数据周期);
let customTaskId = `${FUHUAQICUSTOMTASKTYPE.月度任务}_${cycleNum}`;//id规则是 任务类型_周期月
let taskInfo = await customTaskData.findCustomTaskByTaskId(customTaskId);
if (taskInfo && taskInfo.customTaskId) throw new BizError(ERRORENUM.该数据周期已存在此类型任务);
await customTaskData.addTask(customTaskId, FUHUAQICUSTOMTASKTYPE.月度任务, parseInt(cycleNum), startMs, endMs);
//创建的时候要创建对应的任务
//确保数据月数据唯一
//说明 原本任务系统的key为数据填报月与数据月就差一个月
//后来改了之后 填报月与数据月可能差很多个月 为了保证数据与以前的兼容性 以及key的唯一性
//这里的key取数据月后一个月
let taskKey = dataCycleTime.add(1, 'months').format("YYYYM");
let taskCount = await taskData.findTaskCountByParamCount({key:taskKey});
if (taskCount) {
new BizError(ERRORENUM.该数据周期已存在此类型任务, `task表重复创建了${taskKey}的任务`);
return;
}
let addList = [];//任务列表
let monthList = [];//月度填报列表
const MonthTableName = `${ dataCycleTime.month()+1}月孵化器月度填报`;
let fuHuaQiList = await findAllNotDisabledFuHuaQi();
fuHuaQiList.forEach(info => {
let { uscc } = info;
let taskId = generateMonthTaskId(uscc);
addList.push(
{ key:taskKey, customTaskId:customTaskId, startTime:startMs, endTime:endMs, type:TASKTYPEENUM.孵化器月度填报, month:DataMonth, taskId, fuHuaQiUscc:uscc, isSubmit:false, year:DataYear},
{ key:taskKey, customTaskId:customTaskId, startTime:startMs, endTime:endMs, type:TASKTYPEENUM.新注册或迁入企业登记, month:DataMonth, taskId, fuHuaQiUscc:uscc, isSubmit:false , year:DataYear},
{ key:taskKey, customTaskId:customTaskId, startTime:startMs, endTime:endMs, type:TASKTYPEENUM.融资企业填报, taskId, month:DataMonth, fuHuaQiUscc:uscc, isSubmit:false, year:DataYear});
/**任务报表的初始状态为 草稿(draftLock=fals) 未被编辑(isUpdate=false) */
monthList.push({ taskId, name:MonthTableName, fuHuaQiUscc:uscc, month:DataMonth, year:DataYear, draftLock:false, isUpdate:false });
});
try {
//初始化 任务列表
await taskData.createTaskToList(addList);
//初始化月度报表
await monthTableData.createMonthTableToList(monthList);
} catch(err) {
new BizError(ERRORENUM.系统错误, '添加任务和月度报表的时候 出现了异常 请检查数据库 ', err);
}
}
/**
* 创建自定义年度任务
*/
async function createCustomYearTask(dataCycle:number, startMs:number, endMs:number) {
//自定义任务id
let cycleNum = new Date().getFullYear();
let customTaskId = `${FUHUAQICUSTOMTASKTYPE.党建任务}_${cycleNum}`;
let taskInfo = await customTaskData.findCustomTaskByTaskId(customTaskId);
if (taskInfo && taskInfo.customTaskId) throw new BizError(ERRORENUM.该数据周期已存在此类型任务);
await customTaskData.addTask(customTaskId, FUHUAQICUSTOMTASKTYPE.党建任务, cycleNum, startMs, endMs);
//创建的时候要创建对应的任务
//确保数据月数据唯一
//说明 原本任务系统的key为数据填报月与数据月就差一个月
//后来改了之后 填报月与数据月可能差很多个月 为了保证数据与以前的兼容性 以及key的唯一性
//这里的key取数据月后一个月
let taskCount = await dangJianTaskData.findCountByParam({key:cycleNum});
if (taskCount) {
new BizError(ERRORENUM.该数据周期已存在此类型任务, `task表重复创建了${cycleNum}的任务`);
return;
}
let addList = [];//任务列表
let fuHuaQiList = await findAllNotDisabledFuHuaQi();
fuHuaQiList.forEach(info => {
let { uscc } = info;
let taskId = `${uscc}${cycleNum}`;
addList.push({
taskId,
key:cycleNum,
draftLock:false,
fuHuaQiUscc:uscc
});
});
try {
//初始化 任务列表
await dangJianTaskData.createTaskToList(addList);
} catch(err) {
new BizError(ERRORENUM.系统错误, '添加党建任务的时候 出现了异常 请检查数据库 ', err);
}
}
/**
* 任务列表
* @param fuHuaQiTaskType
* @param dataCycle
*/
export async function taskList(fuHuaQiTaskType:number, dataCycle:number, pageNumber:number) {
let param:any = {};
if (fuHuaQiTaskType) param.customTaskType = fuHuaQiTaskType;
if (dataCycle) param.dataCycle = dataCycle;
let dbList = await customTaskData.findCustomTaskListByPage(param, (pageNumber-1)*10);
let dataCount = await customTaskData.findCustomTaskCount(param);
let nowMs = new Date().valueOf();
let dataList = [];
dbList.forEach(info => {
let {customTaskId, customTaskType, dataCycle, startMs, endMs, isExtension} = info;
let stateStr = "";
let state = 0;
if (nowMs < startMs) {
stateStr = "即将开始";
state = 1;
}
else if (nowMs > startMs && nowMs < endMs) {
stateStr = "进行中";
state = 2;
if (isExtension) {
stateStr = "补录中";
state = 3;
}
} else if (endMs< nowMs) {
stateStr = "已完成";
state = 4;
}
let dataCycleStr = "";
if (customTaskType == FUHUAQICUSTOMTASKTYPE.月度任务) dataCycleStr = moment(`${dataCycle}01`).format("YYYY-MM");
else if (customTaskType == FUHUAQICUSTOMTASKTYPE.党建任务) dataCycleStr = `${dataCycle}年度`;
dataList.push({
id:customTaskId,
stateStr,
state,
rate:100,
customTaskType:changeEnumValue(FUHUAQICUSTOMTASKTYPE, customTaskType),
dataCycle:dataCycleStr,
fillingInCycle:`${moment(startMs).format("YYYY.MM.DD")}-${moment(endMs).format("YYYY.MM.DD")}`
});
});
return {dataCount, dataList};
}
/**
* 数据下载
* @param id
*/
export async function dataDw(id:string) {
}
/**
* 修改周期
*/
export async function changeCycle(id:string, startMs:number, endMs:number) {
let taskInfo = await customTaskData.findCustomTaskByTaskId(id);
if (!taskInfo || !taskInfo.customTaskId) {
throw new BizError(ERRORENUM.任务不存在);
}
if (startMs< taskInfo.startMs) throw new BizError(ERRORENUM.任务延期不可将开始时间提前);
if (endMs <= startMs) throw new BizError(ERRORENUM.任务延期结束时间要大于开始时间);
taskInfo.startMs = startMs;
taskInfo.endMs = endMs;
taskInfo.isExtension = true;
await taskInfo.save();
//修改对应任务的开始结束时间
await taskData.upodateTaskStartAdnEndTime({customTaskId:id}, {startTime:startMs, endTime:endMs});
return {isSuccess:true};
}
/**
* 提前回收
* @param id
*/
export async function recovery(id:string) {
let taskInfo = await customTaskData.findCustomTaskByTaskId(id);
if (!taskInfo || !taskInfo.customTaskId) {
throw new BizError(ERRORENUM.任务不存在);
}
let nowMs = new Date().valueOf();
if (taskInfo.endMs < nowMs) throw new BizError(ERRORENUM.不可提前回收已完成任务);
taskInfo.endMs = nowMs;
await taskInfo.save();
//修改对应任务的开始结束时间
await taskData.upodateTaskStartAdnEndTime({customTaskId:id}, { endTime:nowMs});
return {isSuccess:true};
}
\ No newline at end of file
/**
* 孵化器标签管理 管理后台
* 6.0功能
*/
import moment = require("moment");
import { findLabelLogByParam } from "../../../data/fuHuaQi/fuHuaQiLabelLog";
import { findFuHuaQiByUSCC, findFuHuaQiCount, findFuHuaQiListByPage } from "../../../data/fuHuaQi/fuhuaqi";
import { getEffectiveLabelMap } from "../../../data/label";
import { changeEnumValue } from "../../../util/verificationEnum";
import { updateLabelToFuHuaQi } from "../../label";
import { LABELGOAL, LABELTYPE, LABELUPDATEROAD, FHQSYSTEMLABEL } from "../../../config/enum/labelEnum";
/**
* 孵化器标签列表
* @param name
* @param page
* @param labelIdList
* @returns
*/
export async function fuHuaQiLabelList(name:string, page:number, labelIdList) {
let selectParam:any = {userState:false};
if (name) selectParam.operationName = {"$regex":`${name}`};
if (labelIdList.length) {
selectParam.labels = {"$elemMatch":{labelId:{"$in":labelIdList} } }
}
let dbList = await findFuHuaQiListByPage(selectParam, (page-1)*10);
let count = await findFuHuaQiCount(selectParam);
//全量的 孵化器标签map 结构式 {id:{labelName, labelType}}
let labelMap = await getEffectiveLabelMap(LABELGOAL.孵化器);
let dataList = [];
dbList.forEach(info => {
let {name, labels, uscc} = info;
let changeList = [];
labels.forEach(labelItem => {
let {state, labelId} = labelItem;
if (labelMap[labelId]) {
let {labelName, labelType} = labelMap[labelId];
changeList.push({
state,
labelName,
labelType,
labelTypeStr:changeEnumValue(LABELTYPE, labelType)
});
}
});
dataList.push({
name,
labels:changeList,
uscc
});
});
return {count, dataList, pageCount:Math.ceil(count/10) };
}
/**
* 孵化器标签动态列表
* @param uscc
*/
export async function labelLogList(uscc:string) {
let dblist = await findLabelLogByParam({uscc});
let labelMap = await getEffectiveLabelMap(LABELGOAL.孵化器);
let dataList = [];
dblist.sort((a,b) => {return b.ct - a.ct});
dblist.forEach(info => {
let {ct, road, labelId, desc} = info;
let descStr = '';
switch (labelId) {
case FHQSYSTEMLABEL.专业技术平台:
if (road == LABELUPDATEROAD.失效) descStr = '';
else descStr = desc;
break;
default:
if (road == LABELUPDATEROAD.失效) descStr = '';
else descStr = desc || "张江后台更新";
break;
}
dataList.push({
logTime:moment(ct).format("YYYY-MM-DD"),
state:road == LABELUPDATEROAD.失效 ? "失效" : "生效",
labelName:labelMap[labelId].labelName,
desc:descStr
});
});
return {dataList};
}
/**
* 批量添加孵化器标签
* @param uscc
* @param labelIdList 生效的标签,如果传空数组,那么会清空除系统标签外的所有标签
* @returns
*/
export async function addFuHuaQiLabel(uscc:string, labelIdList) {
let labelMap = await getEffectiveLabelMap(LABELGOAL.孵化器);
let fuHuaQiInfo = await findFuHuaQiByUSCC(uscc);
let dbLabelList = fuHuaQiInfo.labels || [];
let newLabelList = [];
dbLabelList.forEach(info => {
let {labelId, state} = info;
if (labelMap[labelId]) {
if (state && labelMap[labelId].labelType == LABELTYPE.系统标签 ) {
newLabelList.push(labelId);
}
}
});
await updateLabelToFuHuaQi(uscc, newLabelList.concat(labelIdList));
return {isSuccess:true};
}
/**
* 批量删除孵化器标签
* @param uscc
* @param labelIdList 生效的标签,如果传空数组,那么会清空除系统标签外的所有标签
* @returns
*/
export async function deleteFuHUaQiLabel(uscc:string, labelIdList) {
let labelMap = await getEffectiveLabelMap(LABELGOAL.孵化器);
let fuHuaQiInfo = await findFuHuaQiByUSCC(uscc);
let dbLabelList = fuHuaQiInfo.labels || [];
let newLabelList = [];
dbLabelList.forEach(info => {
let {labelId, state} = info;
if (labelMap[labelId]) {
if (state && labelMap[labelId].labelType == LABELTYPE.系统标签 ) {
newLabelList.push(labelId);
}
}
});
await updateLabelToFuHuaQi(uscc, newLabelList.concat(labelIdList));
return {isSuccess:true};
}
\ No newline at end of file
/**
* 管理后台 月度任务相关
* 作者:lxm
*/
import { ERRORENUM } from "../../../config/errorEnum";
import { BizError } from "../../../util/bizError";
import * as monthData from "../../../data/fuHuaQi/monthTask/monthTable";
import * as fuhuaqiData from "../../../data/fuHuaQi/fuhuaqi";
import { OUTPUTTYPE } from "../../../config/enum";
/**
* 月度出租率数据列表
* @param state 填报状态
* @param year 数据年份
* @param month 数据月份
* @param page 页面
*/
export async function monthTableList(state:number, year:number, month:number, page:number) {
let selectParam:any = {};
if ( !(state >=1 || state <=3) ) throw new BizError(ERRORENUM.参数错误, `state状态不合法 不合法值为 ${state}`);
if (state == 2 || state == 3) {
selectParam.draftLock = state == 2 ? true : false;
}
if (year) selectParam.year = year;
if (month) selectParam.month = month;
let dataBaseList = await monthData.findMonthTableListToPage(selectParam, (page-1)*10 );
let count = await monthData.findMonthTableListCount(selectParam);
let operationNameMap = await fuhuaqiData.findFuHuaQiOperationNameMapByParam({});
let dataList = [];
dataBaseList.forEach( info => {
let state = info.draftLock==false?'未填报':'已填报';
let occupancyRate = info.occupancyRate == null || info.occupancyRate == undefined ? '-' : info.occupancyRate;
if (state == "未填报" && occupancyRate != "-") state = "填写未提交";
let onceInfo = {
operationName:operationNameMap[info.fuHuaQiUscc] || '',
time:`${info.year}${info.month}月`,
state,
occupancyRate
};
dataList.push(onceInfo);
});
return {count, dataList}
}
/**
* 导出月度出租率数据列表
* @param state 填报状态
* @param year 数据年份
* @param month 数据月份
* @param page 页面
*/
export async function outPutMonthTableList(state:number, year:number, month:number, type:number) {
let selectParam:any = {};
if ( !(state >=1 || state <=3) ) throw new BizError(ERRORENUM.参数错误, `state状态不合法 不合法值为 ${state}`);
if (type == OUTPUTTYPE.当前数据 ) {
if (state == 2 || state == 3) {
selectParam.draftLock = state == 2 ? true : false;
}
if (year) selectParam.year = year;
if (month) selectParam.month = month;
}
let dataBaseList = await monthData.findMonthTableList(selectParam);
let operationNameMap = await fuhuaqiData.findFuHuaQiOperationNameMapByParam({});
let keyList = [ "operationName", "state", "time", "occupancyRate"];
let titleList = [ "运营机构名称","填报状态","数据月份","出租率(%)"];
let dataList = [titleList];
dataBaseList.forEach( info => {
let state = info.draftLock==false?'未填报':'已填报';
let occupancyRate = info.occupancyRate == null || info.occupancyRate == undefined ? '-' : info.occupancyRate;
if (state == "未填报" && occupancyRate != "-") state = "填写未提交";
let onceInfo = {
operationName:operationNameMap[info.fuHuaQiUscc] || '',
time:`${info.year}${info.month}月`,
state,
occupancyRate
};
let subList = [];
keyList.forEach(subInfo => {
subList.push(onceInfo[subInfo] || '');
});
dataList.push(subList);
});
return dataList;
}
\ No newline at end of file
/**
* 管理后台 任务中心相关逻辑
*/
import { OUTPUTTYPE, TASKTYPEENUM } from "../../../config/enum";
import * as taskData from "../../../data/fuHuaQi/monthTask/task";
import * as fuhuaqiData from "../../../data/fuHuaQi/fuhuaqi";
import { BizError } from "../../../util/bizError";
import { ERRORENUM } from "../../../config/errorEnum";
import { findBusinessDataByParam, findBusinessDataByParamToPage, findBusinessDataCountByParam } from "../../../data/fuHuaQi/quarterTask/businessData";
/**
* 融资企业填报任务 列表
* @param upState 填报状态
* @param time 日期
* @param page 页数
*/
export async function financingTaskList(state:number, time:number, page:number) {
if ( !(state >=1 || state <=3) ) throw new BizError(ERRORENUM.参数错误, `state状态不合法 不合法值为 ${state}`);
let selectParam:any= {type:TASKTYPEENUM.融资企业填报};
if (state > 1) {
selectParam.isSubmit = state == 2 ? true : false;
}
if (time) {
selectParam.year = new Date(time).getFullYear();
selectParam.month = new Date(time).getMonth() + 1;
}
let nameMap = await fuhuaqiData.findFuHuaQiOperationNameMapByParam({});
let taskList = await taskData.findTaskListByParamAndPage(selectParam, (page -1)*10);
let reslutList = [];
taskList.forEach(info => {
let {submitCount, fuHuaQiUscc, month, year, isSubmit } = info;
let item = {
name : nameMap[fuHuaQiUscc],
addCount:submitCount,
dataTime:`${year}${month}`,
state:isSubmit? "已填报": "未填报"
};
reslutList.push(item);
});
let count = await taskData.findTaskCountByParamCount(selectParam);
let pageCount = Math.ceil(count/10);
return {count, dataList:reslutList, pageCount};
}
/**
* 导出融资企业填报任务 列表
* @param upState 填报状态
* @param time 日期
* @param type 查询类型
*/
export async function outPutFinancingTaskList(state:number, time:number, type:number) {
if ( !(state >=1 || state <=3) ) throw new BizError(ERRORENUM.参数错误, `state状态不合法 不合法值为 ${state}`);
let selectParam:any= {type:TASKTYPEENUM.融资企业填报};
let name = "全部";
if (type == OUTPUTTYPE.当前数据 ) {
if (state == 2 || state == 3) {
selectParam.draftLock = state == 2 ? true : false;
}
if (time) {
selectParam.year = new Date(time).getFullYear();
selectParam.month = new Date(time).getMonth() + 1;
name = `${selectParam.year}${selectParam.month}月`;
}
name = "当前";
}
let nameMap = await fuhuaqiData.findFuHuaQiOperationNameMapByParam({});
let taskList = await taskData.findTaskListByParam(selectParam);
let dataList = [["运营机构名称", "填报状态", "数据月份", "本月新增数量"]];
taskList.forEach(info => {
let {submitCount, fuHuaQiUscc, month, year, isSubmit } = info;
let name = nameMap[fuHuaQiUscc];
let state = isSubmit? "已填报": "未填报" ;
let dataTime = `${year}${month}`;
dataList.push([name, state, dataTime, submitCount]);
});
return { dataList, name };
}
/**
* 新增企业任务 列表
* @param upState 填报状态
* @param time 日期
*/
export async function addEnterpriseTaskList(state:number, time:number, page:number) {
if ( !(state >=1 || state <=3) ) throw new BizError(ERRORENUM.参数错误, `state状态不合法 不合法值为 ${state}`);
let selectParam:any= {type:TASKTYPEENUM.新注册或迁入企业登记};
if (state>1) {
selectParam.isSubmit = state == 2 ? true : false;
}
if (time) {
selectParam.year = new Date(time).getFullYear();
selectParam.month = new Date(time).getMonth() + 1;
}
let nameMap = await fuhuaqiData.findFuHuaQiOperationNameMapByParam({});
let taskList = await taskData.findTaskListByParamAndPage(selectParam, (page -1)*10);
let reslutList = [];
taskList.forEach(info => {
let {submitCount, fuHuaQiUscc, month, year, isSubmit } = info;
let item = {
name : nameMap[fuHuaQiUscc],
addCount:submitCount,
dataTime:`${year}${month}`,
state:isSubmit? "已填报": "未填报"
};
reslutList.push(item);
});
let count = await taskData.findTaskCountByParamCount(selectParam);
let pageCount = Math.ceil(count/10);
return {count, dataList:reslutList, pageCount};
}
/**
* 导出新增企业任务 列表
* @param upState 填报状态
* @param time 日期
* @param type 查询类型
*/
export async function outPutAddEnterpriseTaskList(state:number, time:number, type:number) {
if ( !(state >=1 || state <=3) ) throw new BizError(ERRORENUM.参数错误, `state状态不合法 不合法值为 ${state}`);
let selectParam:any= {type:TASKTYPEENUM.新注册或迁入企业登记};
let name = "全部";
if (type == OUTPUTTYPE.当前数据 ) {
if (state == 2 || state == 3) {
selectParam.draftLock = state == 2 ? true : false;
}
if (time) {
selectParam.year = new Date(time).getFullYear();
selectParam.month = new Date(time).getMonth() + 1;
name = `${selectParam.year}${selectParam.month}月`;
}
name = "当前";
}
let nameMap = await fuhuaqiData.findFuHuaQiOperationNameMapByParam({});
let taskList = await taskData.findTaskListByParam(selectParam);
let dataList = [["运营机构名称", "填报状态", "数据月份", "本月新增数量"]];
taskList.forEach(info => {
let {submitCount, fuHuaQiUscc, month, year, isSubmit } = info;
let name = nameMap[fuHuaQiUscc];
let state = isSubmit? "已填报": "未填报" ;
let dataTime = `${year}${month}`;
dataList.push([name, state, dataTime, submitCount]);
});
return { dataList, name };
}
/**
* 获取季度任务列表
* @param state
* @param year
* @param quarter
*/
export async function quarterTaskList(state:number, year:number, quarter:number, page:number) {
if ( !(state >=1 || state <=3) ) throw new BizError(ERRORENUM.参数错误, `state状态不合法 不合法值为 ${state}`);
let selectParam:any = {};
if (state == 2) {//提交
selectParam.draftLock = true;
} else if (state == 3) {//未提交
selectParam.draftLock = false;
}
if (year) selectParam.year = year;
if (quarter) selectParam.quarter = quarter;
let dataBaseList = await findBusinessDataByParamToPage(selectParam, (page-1)*10);
let fuhuaqiNameMap = await fuhuaqiData.findFuHuaQiOperationNameMapByParam({});
let dataList = [];
dataBaseList.forEach(info => {
dataList.push({
operationName:fuhuaqiNameMap[info.fuHuaQiUscc],
state:info.draftLock ? "已填报" : "未填报",
time:`${info.year}年第${info.quarter}季度`,
TR:info.TR,
ROR:info.ROR,
RR:info.RR,
FS:info.FS,
MIS:info.MIS,
NP:info.NP,
TP:info.TP
});
});
let count = await findBusinessDataCountByParam(selectParam);
return {count, dataList, pageCount:Math.ceil(count/10) };
}
/**
* 导出季度任务列表
* @param state
* @param year
* @param quarter
*/
export async function outPutQuarterTaskDataList(type:number, state:number, year:number, quarter:number) {
if ( !(state >=1 || state <=3) ) throw new BizError(ERRORENUM.参数错误, `state状态不合法 不合法值为 ${state}`);
let name = "全部";
let selectParam:any = {};
if (type == OUTPUTTYPE.当前数据 ) {
name = "当前";
if (state == 2) {//提交
selectParam.draftLock = true;
} else if (state == 3) {//未提交
selectParam.draftLock = false;
}
if (year) selectParam.year = year;
if (quarter) selectParam.quarter = quarter;
}
let dataBaseList = await findBusinessDataByParam(selectParam);
let fuhuaqiNameMap = await fuhuaqiData.findFuHuaQiOperationNameMapByParam({});
let dataList = [["运营机构名称", "填报状态", "数据填报季度", "综合收入", "投资收入", "租金收入", "财政补贴", "其他", "净利润", "纳税"]];
dataBaseList.forEach(info => {
let itemList = [
fuhuaqiNameMap[info.fuHuaQiUscc],
info.state ? "已填报" : "未填报",
`${info.year}年第${info.quarter}季度`,
info.TR,
info.ROR,
info.RR,
info.FS,
info.MIS,
info.NP,
info.TP
];
dataList.push(itemList);
});
return {dataList, name};
}
/**
* 管理后台 资讯逻辑
* 作者:lxm
*/
import moment = require("moment");
import { ERRORENUM } from "../../config/errorEnum";
import * as informationData from "../../data/guanWeiHui/information";
import { getInformationId } from "../../tools/system";
import { BizError } from "../../util/bizError";
/**
* 管理后台添加资讯
* @param desc 内容
* @param title 标题
* @param source 来源
* @param coverImg 封面图片地址
* @returns
*/
export async function addOnceInformation(desc:string, title:string ,source:string, coverImg:string ) {
let id = getInformationId();
await informationData.createInformation(id, desc, title, source, coverImg);
return {isSuccess:true};
}
/**
* 打开资讯
* @param id 标识
* @param isPermanent 是否永久有效
* @param closeTimeMs 有效时间
* @returns
*/
export async function openInformation(id:string, isPermanent:boolean, closeTimeMs:number) {
if ( isPermanent ) closeTimeMs = 0;
else {
if (!closeTimeMs) throw new BizError(ERRORENUM.参数错误, "开启任务时 缺少创建时间");
}
let dataBaseData = await informationData.selectInformationDataById(id);
if (dataBaseData.state) throw new BizError(ERRORENUM.请不要重复开启资讯);
dataBaseData.isPermanent = isPermanent;
dataBaseData.closeTimeMs = closeTimeMs;
dataBaseData.state = true;
await dataBaseData.save();
return {isSuccess:true};
}
/**
* 关闭资讯
* @param id 资讯标识
* @returns
*/
export async function closeInformation(id:string) {
let dataBaseData = await informationData.selectInformationDataById(id);
dataBaseData.state = false;
await dataBaseData.save();
return {isSuccess:true};
}
/**
* 回显示资讯信息
* @param id 标识
* @returns
*/
export async function selectOnceInformationDate(id:string) {
let onceDataInfo = await informationData.selectInformationDataById(id);
let result = {
id:onceDataInfo.id,
title:onceDataInfo.title,
desc:onceDataInfo.desc,
source:onceDataInfo.source,
coverImg:onceDataInfo.coverImg,
url:`/policy/${onceDataInfo.coverImg}`,
};
return {dataInfo:result};
}
/**
* 删除资讯信息
* @param id 标识
* @returns
*/
export async function deleteOnceInformationDate(id:string) {
let onceDataInfo = await informationData.selectInformationDataById(id);
if (onceDataInfo.state) throw new BizError(ERRORENUM.请先关闭该资讯, "未关闭资讯进行删除操作");
await informationData.deleteInformationData(id);
return {isSuccess:true};
}
/**
* 修改资讯信息
* @param id 标识
* @param desc 内容
* @param title 标题
* @param source 来源
* @param coverImg 图片地址
* @returns
*/
export async function updateOnceInformation(id:string, desc:string, title:string ,source:string, coverImg:string ) {
let onceDataInfo = await informationData.selectInformationDataById(id);
if (onceDataInfo.state) throw new BizError(ERRORENUM.请先关闭该资讯, "未关闭资讯进行修改操作");
onceDataInfo.coverImg = coverImg;
onceDataInfo.title = title;
onceDataInfo.desc = desc;
onceDataInfo.source = source;
await onceDataInfo.save();
return {isSuccess:true};
}
/**
* 查询资讯列表
* @param selectTitle 标题
* @param createTime 创建时间
* @param state 状态
* @param page 分页
* @returns
*/
export async function selectInformation(selectTitle:string, createTime:number, state:number, page:number) {
let selectParam = {};
if (state == 2 || state == 3) {
if (state == 2) {
selectParam = {state:true, "$or":[{closeTimeMs: {"$gt":new Date().valueOf()} }, {isPermanent:true}] };
} else {
selectParam = {"$or":[{closeTimeMs: {"$lt":new Date().valueOf()} }, {state:false}] };
}
}
if (selectTitle) {
selectParam["title"] = {"$regex":`${selectTitle}`};
}
if (createTime) {
selectParam["$and"] = [{"createTimeMs":{"$gt":createTime }}, {"createTimeMs":{"$lt":createTime+(3600*26*1000) }}]
}
let dataBaseList = await informationData.selectInformationByParamToPage(selectParam, (page-1)* 10);
let count = await informationData.selectInformationByParamCount(selectParam);
let pageCount = count ? Math.ceil(count/10) : 0;
let dataList = [];
dataBaseList.forEach(info => {
let {title, createTimeMs, state, closeTimeMs, isPermanent, id} = info;
let stateStr = "下线";
if (state) {
stateStr = "上线";
if (!isPermanent && closeTimeMs< new Date().valueOf()) stateStr = "下线";
}
dataList.push({
id,
title,
createTime:moment(createTimeMs).format("YYYY-MM-DD"),
state,
stateStr
});
});
return {dataList, pageCount, count};
}
/**
* 管理后台-标签系统-标签管理
* 6.0功能
*/
import { LABELGOAL, LABELTYPE } from "../../config/enum/labelEnum";
import { ERRORENUM } from "../../config/errorEnum";
import { createLabel, findOnceLabel, selectLabelCount, selectLabelListToPage } from "../../data/label";
import { getLabelId } from "../../tools/system";
import { BizError } from "../../util/bizError";
import { changeEnumValue, eccEnumValue } from "../../util/verificationEnum";
/**
* 创建自定义标签
*/
export async function addLabel(name:string, goal:number) {
eccEnumValue("创建标签", "goal", LABELGOAL, goal);
let labelId = getLabelId();
await createLabel(goal, LABELTYPE.自定义标签, name, labelId);
return {isSuccess:true};
}
/**
* 修改自定义标签名字
* @param id
* @param name
*/
export async function updateLabelName(id:string, name:string) {
let labelInfo = await findOnceLabel(id);
labelInfo.labelName = name;
await labelInfo.save();
return {isSuccess:true};
}
/**
* 自定义标签列表列表
* @returns
*/
export async function labelList(pageNumber:number) {
let selectParam = {state:false, labelType:LABELTYPE.自定义标签};
let dbList = await selectLabelListToPage(selectParam, (pageNumber-1)*10);
let dataCount = await selectLabelCount(selectParam);
let dataList = [];
dbList.forEach(info => {
dataList.push({
labelName:info.labelName,
goal:changeEnumValue(LABELGOAL, info.goal),
id:info.id
});
});
return {dataList, dataCount};
}
/**
* 删除自定义标签
* @param id
* @returns
*/
export async function deleteLabel(id:string) {
let labelInfo = await findOnceLabel(id);
if (!labelInfo || !labelInfo.id) throw new BizError(ERRORENUM.目标数据不存在);
if (labelInfo.labelType != LABELTYPE.自定义标签) throw new BizError(ERRORENUM.不能删除非自定义标签)
labelInfo.state = true;
await labelInfo.save();
return {isSuccess:true};
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
/**
* 管理后台 数字看板 孵化器看板 基本信息 主要逻辑
* 作者:lxm
*/
import moment = require("moment");
import { GuanWeiHuiChnageFuHuaQiBaseConfig } from "../../../../config/eccParam/admin";
import { FUHUAINDUSTRY, FUHUAQILV, INDUSTRY, INSTITUTIONALNATURE, OPERATIONMODEL, SCOREWAYS, STATEENUM } from "../../../../config/enum";
import { ERRORENUM } from "../../../../config/errorEnum";
import { StarConfig } from "../../../../config/scoreConfig";
import { findFuHuaQiByUSCC } from "../../../../data/fuHuaQi/fuhuaqi";
import * as i18nRegisterData from "../../../../data/fuHuaQi/instituQualify/i18nRegister";
import * as zjBeyondLayoutData from "../../../../data/fuHuaQi/instituQualify/zjBeyondLayout";
import * as scoreData from "../../../../data/fuHuaQi/score";
import { BizError } from "../../../../util/bizError";
import { checkChange } from "../../../../util/piecemeal";
import { changeEnumValue, eccEnumValue } from "../../../../util/verificationEnum";
import { eccFormParam } from "../../../../util/verificationParam";
import { updateScore } from "../../../mobileFuHuaQi/fuHuaQi/score";
/**
* 获取孵化器基本信息
* @param uscc 孵化器统一信用代码
*/
export async function fuHuaQiBaseData(uscc:string) {
let fuHuaQiInfo = await findFuHuaQiByUSCC(uscc);
if (!fuHuaQiInfo || !fuHuaQiInfo.uscc) throw new BizError(ERRORENUM.不合规操作);
/**基本信息 */
let name = fuHuaQiInfo.name; //名称
let acreageTotal = fuHuaQiInfo.acreageTotal; //孵化器总面积(㎡)
let incubatedAcreage = fuHuaQiInfo.incubatedAcreage; //在孵面积(㎡)
let acreagePersonalUse = fuHuaQiInfo.acreagePersonalUse; //孵化器自用面积(㎡)
let foundingTeamCount = fuHuaQiInfo.foundingTeam ? fuHuaQiInfo.foundingTeam.length : 0; //创业团队
let hatchingGroundCount = fuHuaQiInfo.hatchingGround ? fuHuaQiInfo.hatchingGround.length : 0; //经备案孵化场地
//张江以为布局数量+国际化登记数量=基地数量
let baseCount = await i18nRegisterData.getI18nRegisterCountByParam({uscc}) + await zjBeyondLayoutData.getZjBeyondLayoutCountByParam({uscc});
const BaseData = {
name, acreageTotal, incubatedAcreage, acreagePersonalUse, foundingTeamCount, hatchingGroundCount, baseCount
};
const FuHuaQiData = {
operationName:fuHuaQiInfo.operationName,//运营机构名称 不可修改
name,//名称
uscc:fuHuaQiInfo.uscc,//统一信用代码 也是登录账号 不可修改
lv:changeEnumValue(FUHUAQILV, fuHuaQiInfo.lv),//孵化器级别
identificationTime:moment(fuHuaQiInfo.identificationTime).format("YYYY-MM-DD"),//认定时间
logonTime:moment(fuHuaQiInfo.logonTime).format("YYYY-MM-DD"),//注册时间
industry:changeEnumValue(INDUSTRY, fuHuaQiInfo.industry),//孵化领域
institutionalNature:changeEnumValue(INSTITUTIONALNATURE, fuHuaQiInfo.institutionalNature),//机构性质
isCreatePTP:changeEnumValue(STATEENUM, fuHuaQiInfo.isCreatePTP),//是成立创投基金
liaison:fuHuaQiInfo.liaison,//联系人
personInCharge:fuHuaQiInfo.personInCharge,//负责人
personInChargePhone:fuHuaQiInfo.personInChargePhone,//负责人联系电话
introduction:fuHuaQiInfo.introduction,//孵化器简介
};
let scoreInfoData = await scoreData.findFuHuaQiScoreInfo(uscc);
let { startScore, myDataScore, baseDataScore, myEnterpriseScore, taskScore } = scoreInfoData;
let count = Math.ceil(startScore +myDataScore +baseDataScore +myEnterpriseScore +taskScore);
let newStar = starCount(count);
let keyList = [
"name", "acreageTotal", "incubatedAcreage", "acreagePersonalUse", "foundingTeamCount", "hatchingGroundCount",
"operationName", "name", "uscc", "lv", "identificationTime", "industry", "institutionalNature", "isParticipateInPTP", "liaison", "personInCharge", "personInChargePhone",
];
let notCount = 0;
keyList.forEach(key => {
if (fuHuaQiInfo[key] == undefined) notCount += 1;
});
const ScoreData = { score:count, star:newStar, infoIntegrity:Math.ceil(((keyList.length-notCount)/keyList.length)*10000)/100 };
const PTPData = !fuHuaQiInfo.isCreatePTP ? {} : {
scalePTP: fuHuaQiInfo.scalePTP,//基金规模
participatingFundCompany: fuHuaQiInfo.isParticipateInPTP ? fuHuaQiInfo.participatingFundCompany : '',//参股基金公司名
};
return {baseData:BaseData, PTPData, scoreData:ScoreData, fuHuaQiData:FuHuaQiData};
}
/**
* 根据分数算星数
* @param socre 分数
* @returns 星数
*/
function starCount(socre:number) {
let star = 1;
for (let i = 0; i < StarConfig.length; i++) {
let {name, value, starNum} = StarConfig[i];
if ( socre <= value ) {
star = starNum;
break;
}
}
return star;
}
/**
* 修改孵化器基本信息
* @param uscc
* @param param
*/
export async function updateFuHuaQiBaseData(uscc:string, param) {
/**校验表单内容 */
eccFormParam("更新孵化器机构信息数据", GuanWeiHuiChnageFuHuaQiBaseConfig, param);
/**校验是否符合枚举范围 */
if (param.lv) eccEnumValue("管委会更新孵化器信息", " 孵化器级别 ", FUHUAQILV, param.lv);
if (param.industry) eccEnumValue("管委会更新孵化器信息", " 领域 ", FUHUAINDUSTRY, param.industry);
if (param.institutionalNature) eccEnumValue("更新孵化器机构信息数据", " 机构性质 ", INSTITUTIONALNATURE, param.institutionalNature);
if (param.operationModel && param.operationModel.length) eccEnumValue("更新孵化器机构信息数据", " 运营模式 ", OPERATIONMODEL, param.operationModel);
//限制企业简介长度
if (param.introduction) {
if (param.introduction.length > 200) throw new BizError(ERRORENUM.字数超过200限制, "更新孵化器机构信息数据 孵化器简介");
}
let baseDataInfo = await findFuHuaQiByUSCC(param.uscc);
/**赋值内容 */
let changeList = checkChange(param, baseDataInfo);
for (let i = 0; i < changeList.length; i++) {
let key = changeList[i];
if (key == "operationName" || key == "uscc") continue;
baseDataInfo[key] = param[key];
}
await baseDataInfo.save();
/**更新分数 */
await updateScore(param.uscc, SCOREWAYS.我的信息, false);
return {isSuccess:true};
}
\ No newline at end of file
/**
* 管理后台 数字看板 孵化器看板 价值分析 主要逻辑
* 作者:lxm
*/
import moment = require("moment");
import { findTeamDataByParams } from "../../../../data/enterprise/quarterTask/team";
import * as i18nRegisterData from "../../../../data/fuHuaQi/instituQualify/i18nRegister";
import * as icrData from "../../../../data/fuHuaQi/instituQualify/icr";
import { findFinancingList } from "../../../../data/fuHuaQi/monthTask/financing";
import { findBusinessDataByParam } from "../../../../data/fuHuaQi/quarterTask/businessData";
import { findOneFuHuaQiMonthTaskData } from "../../../../data/fuHuaQi/monthTask/task";
import { TASKTYPEENUM } from "../../../../config/enum";
export async function getValueStats(uscc) {
const ThisYear = new Date().getFullYear();
let i18nCount = await i18nRegisterData.getI18nRegisterCountByParam({uscc});//国际合作/大企业合作机构数
let icrCount = await icrData.getIcrCountByParam({uscc}); //大学/科研院所合作机构
/**季度任务查询条件 */
let queryDataMap = { };//格式 {"YYYY-季度":{TP:0, member:0, index:1}},
let quarterTaskParam:any = {fuHuaQiUscc:uscc};
let {declarationYear, declarationQuarter} = getDeclarationTime();
if (ThisYear != declarationYear) {
quarterTaskParam.year = declarationYear;
for (let i = 1; i <= 4; i++ ) {
let key = `${declarationYear}-Q${i}`;
queryDataMap[key] = {key, TP:0, member:0,index:i};
}
} else {
quarterTaskParam["$or"] = [
{year:ThisYear},
{year:declarationYear, declarationQuarter:{"$gte":declarationQuarter+1}}
];
for (let i = 4; i >= (declarationQuarter+1); i--) {
let key = `${declarationYear-1}-Q${i}`;
queryDataMap[key] = {key, TP:0, member:0,index:4-i};
}
for (let i =1; i < (declarationQuarter+1); i++) {
let key = `${ThisYear}-Q${i}`;
queryDataMap[key] = {key, TP:0, member:0,index:4+i};
}
}
let businessData = await findBusinessDataByParam(quarterTaskParam);
businessData.forEach(info => {
let {quarter,year, TP, draftLock} = info;
queryDataMap[`${year}-Q${quarter}`].TP = draftLock ? TP : '未填报';
});
let teamData = await findTeamDataByParams(quarterTaskParam);
//获取未填报
let notSubmitMap = {};
teamData.forEach(info => {
let {year, quarter, isSubmit, fhqIsSubmit} = info;
if (!notSubmitMap[`${year}-Q${quarter}`]) notSubmitMap[`${year}-Q${quarter}`] = -1;
if ((isSubmit == true || fhqIsSubmit == true) && notSubmitMap[`${year}-Q${quarter}`] == -1 ) {
notSubmitMap[`${year}-Q${quarter}`] = 1;
}
});
teamData.forEach(info => {
let { year, quarter } = info;
let quarterDataCount = 0;
quarterDataCount += info.doctor || 0;//博士
quarterDataCount += info.master || 0;//硕士
quarterDataCount += info.undergraduate || 0;//本科
quarterDataCount += info.juniorCollege || 0;//专科
quarterDataCount += info.other || 0;//其他
queryDataMap[`${year}-Q${quarter}`].member += quarterDataCount;
});
let quaryDataRank = Object.values(queryDataMap).sort((a:any, b:any) => {return a.index - b.index});
let tpList = [];
let jyrsqsList = [];
let queryList = [];
quaryDataRank.forEach((info:any) => {
queryList.push(info.key);
tpList.push( info.TP );
if (notSubmitMap[info.key] == -1) jyrsqsList.push( '未填报' );
else jyrsqsList.push( info.member );
});
/**融资企业数量趋势 */
let startTime = new Date(moment().subtract(6, 'months').format("YYYY-MM")+"-01 00:00:00").valueOf();
let financingData = await findFinancingList({fuHuaQiUscc:uscc, timeToObtainInvestment:{"$gt":startTime} });
let financingMap = {};//结构 {"YYYY-MM":{distinctKey:0,} }
for (let i = 1; i <= 6; i++) {
let itemDate = moment().subtract(i, 'months');
let key = itemDate.format("YYYY-MM");
let selectMonth = itemDate.month()+1;
let selectYear = itemDate.year();
let itemData = await findOneFuHuaQiMonthTaskData({fuHuaQiUscc:uscc, type:TASKTYPEENUM.融资企业填报,month:selectMonth, year:selectYear});
let ms = moment().subtract(i, 'months').valueOf();
financingMap[key]={ms, key, data:{}, fuHuaQiSubmit:itemData && itemData.isSubmit==true};
}
financingData.forEach(info => {
let { uscc, investmentInstitutionsName, timeToObtainInvestment, draftLock } = info;
let distinctKey = uscc + investmentInstitutionsName + timeToObtainInvestment;
let month = moment(timeToObtainInvestment).format("YYYY-MM");
if (financingMap[month]) financingMap[month].data[distinctKey] = 1;
});
let financingRankList = Object.values(financingMap).sort((a:any, b:any) => {return a.ms - b.ms});
let rzqyslqs = [];
financingRankList.forEach((info:any) => {
let {data, ms, key, fuHuaQiSubmit} = info;
let count = fuHuaQiSubmit ? Object.keys(data || {}).length : "未填报";
rzqyslqs.push({
month:key,
count
});
});
//识别 rzqyslqs 中的未填报数据
return { jyrsqs:{jyrsqsList, queryList}, i18nCount, icrCount, rzqyslqs, tpInfo:{tpList, queryList} };
}
function getDeclarationTime() {
let thisYear = new Date().getFullYear();
let thisQuarter = moment().quarter();//当月填报季度
if ( (thisQuarter - 1) < 1 ) {
thisYear = moment().subtract(1, 'years').year();
thisQuarter = 4;
} else thisQuarter = thisQuarter - 1;
return {declarationYear:thisYear, declarationQuarter:thisQuarter};
}
\ No newline at end of file
/**
* 管理后台 数字看板 孵化器看板 风险预警 主要逻辑
* 作者:lxm
*/
import { FUHUASTATE, TASKTYPEENUM } from "../../../../config/enum";
import { findEnterpriseCount, findEnterpriseList, findEnterpriseListToPage5, findEnterpriseTotalByFuHuaQiUscc } from "../../../../data/enterprise/enterprise";
import { findTaskListByParam } from "../../../../data/fuHuaQi/monthTask/task";
import { changeEnumValue } from "../../../../util/verificationEnum";
/**
* 概览
* @param uscc
* @returns
*/
export async function worningTips(uscc:string) {
let year = new Date().getFullYear();
/**查找孵化器本年未填报 */
let notSubmittedDataList = await findTaskListByParam({fuHuaQiUscc:uscc, year, isSubmit:false});
let notSubmittedList = [];
notSubmittedDataList.forEach(info => {
let {type, month} = info;
notSubmittedList.push({
month:`${month}月份`,
title:`${changeEnumValue(TASKTYPEENUM, type)}`
});
});
let fuHuaQiTaskNotFillingCount = notSubmittedDataList.length;//未填报任务数
/**查找办公地点冲突的企业 */
let enterpriseList = await findEnterpriseList({fuHuaQiUscc:uscc});
let distinctMap = {};
let logonAddressDistinctList = [];
enterpriseList.forEach(info => {
let {uscc, name, logonAddress} = info;
if (logonAddress && logonAddress[3]) {
let addStr = logonAddress[3];
if (!distinctMap[addStr]) distinctMap[addStr] = name;
else {
logonAddressDistinctList.push({name, target:distinctMap[addStr], addStr});
}
}
});
let addConflictCount = logonAddressDistinctList.length;
/**出租率异常 */
let param = {
fuHuaQiUscc:uscc,
state:FUHUASTATE.实体孵化,
leasedArea:0
};
let fuHuaQiLettingRateCoutn = await findEnterpriseCount(param);
return {fuHuaQiTaskNotFillingCount, addConflictCount, fuHuaQiLettingRateCoutn};
}
/**
* 孵化器本年未填报
* @param uscc
* @param page
* @returns
*/
export async function fuHuaQiTaskNotFillingList(uscc:string, page:number) {
let year = new Date().getFullYear();
let notSubmittedDataList = await findTaskListByParam({fuHuaQiUscc:uscc, year, isSubmit:false});
let notSubmittedList = [];
notSubmittedDataList.forEach(info => {
let {type, month} = info;
notSubmittedList.push({
month:`${month}月份`,
title:`${changeEnumValue(TASKTYPEENUM, type)}`
});
});
let dataList = notSubmittedList.splice((page-1)*5,5);
let count = notSubmittedDataList.length;
return { count, dataList, pageCount:Math.ceil(count/5)};
}
/**
* 孵化器旗下企业办公地点冲突的企业
* @param uscc
* @param page
*/
export async function fuHuQiAddConflictList(uscc:string, page:number) {
let enterpriseList = await findEnterpriseList({fuHuaQiUscc:uscc});
let distinctMap = {};
let logonAddressDistinctList = [];
enterpriseList.forEach(info => {
let {uscc, name, logonAddress} = info;
if (logonAddress && logonAddress[3]) {
let addStr = logonAddress[3];
if (!distinctMap[addStr]) distinctMap[addStr] = name;
else {
logonAddressDistinctList.push({name, target:distinctMap[addStr], addStr});
}
}
});
let count = logonAddressDistinctList.length;
let dataList = logonAddressDistinctList.splice((page-1)*5, 5);
return { count, dataList, pageCount:Math.ceil(count/5)};
}
/**
* 孵化器出租率异常
* 实际上只是返回该孵化器下实孵企业孵化面积为0的 2023.8.4需求
* @param uscc
* @param page
*/
export async function fuHuaQiLettingRateList(uscc:string, page:number) {
let param = {
fuHuaQiUscc:uscc,
state:FUHUASTATE.实体孵化,
leasedArea:0
};
let list = await findEnterpriseListToPage5(param, (page-1)*5);
let count = await findEnterpriseCount(param);
let dataList = [];
list.forEach(info => {
let {name, leasedArea} = info;
dataList.push({name, leasedArea, bcos:"租赁面积为0"});
});
return {dataList, count, pageCount:Math.ceil(count/5)};
}
\ No newline at end of file
/**
* 管理后台 数据看板 张江看板 企业信息
*/
import moment = require("moment");
import { ENTERPRISETEAM, FINANCINGROUNDS, FUHUASTATE } from "../../../../config/enum";
import { findEnterpriseCount, statsIntellectualPropertyData } from "../../../../data/enterprise/enterprise";
import { statsEnterpriseFinancing, statsEnterpriseFinancingByTime } from "../../../../data/enterprise/financingInfo";
import { statsBusinessDataByParam } from "../../../../data/enterprise/quarterTask/businessdata";
import { changeEnumValue } from "../../../../util/verificationEnum";
import { statsEnterpriseTeamData } from "../../../../data/enterprise/quarterTask/team";
import { statsEnterpriseInitalTeamsType } from "../../../../data/enterprise/initialTeam";
export async function enterpriseBaseData() {
let dqstqy = await findEnterpriseCount({state:FUHUASTATE.实体孵化});//当前实孵企业
let dqxnqy = await findEnterpriseCount({state:FUHUASTATE.虚拟孵化});//当前虚拟企业
let businessData = await statsBusinessDataByParam();
let businessDataList = [ //经营数据
{key:"营业收入", count:Math.round(businessData.BICount/10000)}, //营业收入
{key:"研发投入", count:Math.round(businessData.RDCount/10000)}, //研发投入
{key:"纳税", count:Math.round(businessData.TXPCount/10000)} //纳税
];
let intellectualPropertyData = await statsIntellectualPropertyData();
let intellectualPropertyDataList = [//专利数据
{key:"海外专利", count:intellectualPropertyData.alienPatent}, //海外专利
{key:"一类专利", count:intellectualPropertyData.classIPatent}, //一类专利
{key:"二类专利", count:intellectualPropertyData.secondClassPatent} //二类专利
];
let gnylcrCount = 0;//国内一流人才
let gjylcrCount = 0;//国际一流人才
let initalTeamsList = await statsEnterpriseInitalTeamsType();
initalTeamsList.forEach(item => {
if (item._id == ENTERPRISETEAM.国内一流人才) gnylcrCount += item.count;
else if (item._id == ENTERPRISETEAM.国际一流人才) gjylcrCount += item.count;
});
let gnylrczb = Math.round( gjylcrCount/(gjylcrCount + gnylcrCount) *100)/100
let gjylrczb = 1 - gnylrczb;
let initalTeamsData = {gnylrczb, gjylrczb};
let financingRoundsDataList = await statsEnterpriseFinancing();
let financingRoundsList = [];//融资轮次
financingRoundsDataList.forEach(info => {
financingRoundsList.push({
key:changeEnumValue(FINANCINGROUNDS, info._id),
count:info.count
});
});
let financingStatsStartTime = moment().subtract(12, 'months').format("YYYY-MM")+'-01 00:00:00';
let financingStatsList:any = await statsEnterpriseFinancingByTime(new Date(financingStatsStartTime).valueOf());
financingStatsList.sort((a, b) => {return a.ms - b.ms});
let financingTrendList = [];//融资趋势
financingStatsList.forEach(info => {
let month = new Date(info.ms).getMonth() + 1;
financingTrendList.push({
key:month+'月',
count:info.count
});
});
/**从业人员数 */
let {declarationQuarter, declarationYear} = getDeclarationTime();
let enterpriseTeamData = await statsEnterpriseTeamData(declarationYear, declarationQuarter);
let enterpriseTeamDataList = [//从业人员数
{key:"博士", count:enterpriseTeamData.doctorCount},//博士
{key:"硕士", count:enterpriseTeamData.masterCount},//硕士
{key:"本科", count:enterpriseTeamData.undergraduateCount},//本科
{key:"专科", count:enterpriseTeamData.juniorCollegeCount},//专科
{key:"其他", count:enterpriseTeamData.otherCount},//其他
];
return {dqstqy, dqxnqy, businessDataList, intellectualPropertyDataList, initalTeamsData, financingRoundsList, financingTrendList, enterpriseTeamDataList};
}
function getDeclarationTime() {
let thisYear = new Date().getFullYear();
let thisQuarter = moment().quarter();//当月填报季度
if ( (thisQuarter - 1) < 1 ) {
thisYear = moment().subtract(1, 'years').year();
thisQuarter = 4;
} else thisQuarter = thisQuarter - 1;
return {declarationYear:thisYear, declarationQuarter:thisQuarter};
}
/**
* 管理后台 -> 数据看板 -> 张江看板 -> 企业风险预警
*/
import moment = require("moment");
import { statsBusinessCount } from "../../../../data/enterprise/quarterTask/businessdata";
import { statsEnterpriseTeamCountByNull } from "../../../../data/enterprise/quarterTask/team";
/**
* 企业预警 概览
*/
export async function enterpriseWarningData() {
let revenueCount = await getBussinessAnomalyCount();//营收数据
let tpxCount = await getEnterpriseTXPAnomalyCount();//纳税异常数
let teamCount = await getTeamAnomalyCount();//团队异常数
return {revenueCount, tpxCount, teamCount};
}
/**
* 营收数据异常
* @param page
* @returns
*/
export async function bussinessAnomaly(page:number) {
let {declarationQuarter, declarationYear} = getDeclarationTime();
let param:any = {"$and":[{BI:0}, {"$or":[{isSubmit:true}, {fhqIsSubmit:true}] }]};
if (declarationQuarter - 1 == 0 ) { /**跨年运算 */
param["$and"].push({
"$or":[
{year:declarationYear, quarter:declarationQuarter},
{year:declarationYear-1, quarter:4}
]
});
} else {
param["$and"].push({year:declarationYear});
param["$and"].push({quarter:{"$gte":declarationQuarter-1}});
}
/**param格式预期 = {"$and":[{"$or":[{},{}] }], {"$or":[{}, {}] }, {}} */
let warnData = await statsBusinessCount(param);
let warnList = [];
warnData.forEach(info => {
warnList.push({name:info._id, bcos:"多次填报为0"});
});
let count = warnList.length;
let dataList = warnList.splice((page-1)*5, page*5);
let pageCount = Math.ceil(count/5);
return {count, pageCount, dataList};
}
async function getBussinessAnomalyCount() {
let {declarationQuarter, declarationYear} = getDeclarationTime();
let param:any = {"$and":[{BI:0}, {"$or":[{isSubmit:true}, {fhqIsSubmit:true}] }]};
if (declarationQuarter - 1 == 0 ) { /**跨年运算 */
param["$and"].push({
"$or":[
{year:declarationYear, quarter:declarationQuarter},
{year:declarationYear-1, quarter:4}
]
});
} else {
param["$and"].push({year:declarationYear});
param["$and"].push({quarter:{"$gte":declarationQuarter-1}});
}
/**param格式预期 = {"$and":[{"$or":[{},{}] }], {"$or":[{}, {}] }, {}} */
let warnData = await statsBusinessCount(param);
return warnData.length;
}
/**
* 企业纳税异常数据
* @returns
*/
export async function enterpriseTXPAnomaly(page:number) {
let {declarationQuarter, declarationYear} = getDeclarationTime();
let param:any = {"$and":[{TXP:0}, {"$or":[{isSubmit:true}, {fhqIsSubmit:true}] }]};
if (declarationQuarter - 1 == 0 ) { /**跨年运算 */
param["$and"].push({
"$or":[
{year:declarationYear, quarter:declarationQuarter},
{year:declarationYear-1, quarter:4}
]
});
} else {
param["$and"].push({year:declarationYear});
param["$and"].push({quarter:{"$gte":declarationQuarter-1}});
}
/**param格式预期 = {"$and":[{"$or":[{},{}] }], {"$or":[{}, {}] }, {}} */
let warnData = await statsBusinessCount(param);
let warnList = [];
warnData.forEach(info => {
warnList.push({name:info._id, bcos:"多次填报为0"});
});
let count = warnList.length;
let dataList = warnList.splice((page-1)*5, page*5);
let pageCount = Math.ceil(count/5);
return {count, pageCount, dataList};
}
async function getEnterpriseTXPAnomalyCount() {
let {declarationQuarter, declarationYear} = getDeclarationTime();
let param:any = {"$and":[{TXP:0}, {"$or":[{isSubmit:true}, {fhqIsSubmit:true}] }]};
if (declarationQuarter - 1 == 0 ) { /**跨年运算 */
param["$and"].push({
"$or":[
{year:declarationYear, quarter:declarationQuarter},
{year:declarationYear-1, quarter:4}
]
});
} else {
param["$and"].push({year:declarationYear});
param["$and"].push({quarter:{"$gte":declarationQuarter-1}});
}
/**param格式预期 = {"$and":[{"$or":[{},{}] }], {"$or":[{}, {}] }, {}} */
let warnData = await statsBusinessCount(param);
return warnData.length;
}
/**
* 团队异常
* @param page
* @returns
*/
export async function teamAnomaly(page:number) {
let {declarationQuarter, declarationYear} = getDeclarationTime();
let list = await statsEnterpriseTeamCountByNull(declarationYear, declarationQuarter);
let rankList = [];
list.forEach(info => {
rankList.push({name:info.name, count:0, bcos:"填报为0" });
});
let count = rankList.length;
let dataList = rankList.splice((page-1)*5, page*5);
let pageCount = Math.ceil(count/5);
return {count, pageCount, dataList};
}
async function getTeamAnomalyCount() {
let {declarationQuarter, declarationYear} = getDeclarationTime();
let list = await statsEnterpriseTeamCountByNull(declarationYear, declarationQuarter);
return list.length;
}
function getDeclarationTime() {
let thisYear = new Date().getFullYear();
let thisQuarter = moment().quarter();//当月填报季度
if ( (thisQuarter - 1) < 1 ) {
thisYear = moment().subtract(1, 'years').year();
thisQuarter = 4;
} else thisQuarter = thisQuarter - 1;
return {declarationYear:thisYear, declarationQuarter:thisQuarter};
}
/**
* 数据看板 张江看板 孵化器信息
*/
import moment = require("moment");
import { FUHUAINDUSTRY, FUHUAQILV, INSTITUTIONALNATURE } from "../../../../config/enum";
import { findFuHuaQiList } from "../../../../data/fuHuaQi/fuhuaqi";
import { changeEnumValue } from "../../../../util/verificationEnum";
import { findMonthTableListCount, statsFuHuaQiMonthDataCount } from "../../../../data/fuHuaQi/monthTask/monthTable";
import { findScoreDataByParam } from "../../../../data/fuHuaQi/score";
export async function fuHuaQiBaseData() {
let fuHuaQiList = await findFuHuaQiList({});
let fuHuaQiCount = 0;
let institutionalNatureMap = {};//用户计算机构性质分布
let logonTimeMap = {//用于计算注册时间分布
"未满1年":{key:"未满1年", count:0},
"1年-2年":{key:"1年-2年", count:0},
"2年-3年":{key:"2年-3年", count:0},
"3年-5年":{key:"3年-5年", count:0},
"5年以上":{key:"5年以上", count:0},
};
let lvMap = {};//用于计算级别分布
let industryMap = {};//用于计算孵化领域
let nameMap = {};
fuHuaQiList.forEach( info => {
let { userState, institutionalNature, logonTime, lv, industry, uscc, operationName } = info;
nameMap[uscc] = operationName;
if (!userState) fuHuaQiCount += 1;
let institutionalStr = changeEnumValue( INSTITUTIONALNATURE, institutionalNature);
if (!institutionalNatureMap[institutionalStr]) institutionalNatureMap[institutionalStr] = {count:0, key:institutionalStr};
institutionalNatureMap[institutionalStr].count += 1;
if (logonTime) {
let ago = moment(logonTime).fromNow(true);
if (ago.indexOf('months') > -1) {
logonTimeMap["未满1年"].count += 1;
} else {
if (parseInt(ago) <= 2) logonTimeMap["1年-2年"].count += 1;
else if (parseInt(ago) <= 3)logonTimeMap["2年-3年"].count += 1;
else if (parseInt(ago) <= 5)logonTimeMap["3年-5年"].count += 1;
else logonTimeMap["5年以上"].count += 1;
}
}
if (lv) {
let lvStr = changeEnumValue(FUHUAQILV, lv);
if (!lvMap[lvStr]) lvMap[lvStr] = {key:lvStr, count:0};
lvMap[lvStr].count += 1;
}
if (industry) {
industry.forEach(item => {
let industryStr = changeEnumValue(FUHUAINDUSTRY, item);
if (!industryMap[industryStr]) industryMap[industryStr] = {key:industryStr, count:0};
industryMap[industryStr].count += 1;
});
}
});
let zcsjfb = Object.values(logonTimeMap);//注册时间分布
let jgxzfb = Object.values(institutionalNatureMap); //机构性质分布
let fhqjbfb = Object.values(lvMap);//孵化器级别分布
let fhqlyfb = Object.values(industryMap);//孵化器领域分布
let scoreDataList = await findScoreDataByParam({});
let rankList = [];
scoreDataList.forEach((info) => {
let name = nameMap[info.uscc]
if (!name) return;
let score = Math.ceil(info.startScore+info.myDataScore+info.baseDataScore+info.myEnterpriseScore+info.taskScore);
rankList.push({ name, score });
});
rankList.sort((a, b) => {return a.score - b.socre});
let fhqpfpm = rankList.slice(0, 10);
/**出租率趋势 */
let czlqsInfo = await czlqs();
return {czlqsInfo, fhqpfpm, zcsjfb, jgxzfb, fhqjbfb, fhqlyfb, fuHuaQiCount};
}
async function czlqs() {
let dataList = [];
for (let i = 1; i <= 6; i++) {
let dataMonth = moment().subtract(i, 'months').month() +1
let dataYear = moment().subtract(i, 'months').year();
let ms = moment().subtract(i, 'months').valueOf();
let dataSum = await statsFuHuaQiMonthDataCount(dataYear, dataMonth);
let dataCount = await findMonthTableListCount({year:dataYear, month:dataMonth, draftLock:true});
dataList.push({avg:Math.ceil((dataSum/dataCount) * 100)/100, month:dataMonth, ms });
}
dataList.sort( (a, b) => {return a.ms-b.ms});
let monthList = [];
let czlList = [];
dataList.forEach(item => {
monthList.push(item.month);
czlList.push(item.avg);
});
return {czlList, monthList};
}
\ No newline at end of file
/**
* 管理后台用户逻辑层
* 作者: lxm
* 主要包括有 孵化器账号的登录
* 预留好 重置密码 退出登录 接口
*/
import { ERRORENUM } from "../../config/errorEnum";
import { findGuanWeiHuiUserInfoByLoginId } from "../../data/guanWeiHui/guanweihui";
import { BizError } from "../../util/bizError";
import { getPwdMd5, getToken } from "../../tools/system";
import { findFuHuaQiByUSCC } from "../../data/fuHuaQi/fuhuaqi";
const md5 = require("md5");
/**
* 登录
* 4.0版本更新:加入孵化器角色登录
* @param loginId 信用代码
* @param pwd 密码
* @returns resultUserInfo:{uscc, name} 登录后的信息
*/
export async function login(loginId:string, pwd:string) {
let userInfo = await findGuanWeiHuiUserInfoByLoginId(loginId);
let userIsNull = false;
let isFuHuaQi = false;
if(!userInfo || !userInfo.loginId) {
userInfo = await findFuHuaQiByUSCC(loginId);
if (!userInfo || !userInfo.uscc) userIsNull = true;
isFuHuaQi = true;
pwd = md5(pwd);
}
if (userIsNull) throw new BizError(ERRORENUM.账号不存在, loginId);
let checkPwd = getPwdMd5(loginId, pwd);
if (userInfo.pwd != checkPwd) throw new BizError(ERRORENUM.密码错误);
let token = getToken(loginId);
let resultUserInfo = {
loginId: "",
name: userInfo.name,
token:"",
isFuHuaQi
};
if (isFuHuaQi) {
//孵化器登录管理后台
token = token +'ad'
resultUserInfo.loginId = userInfo.uscc;
resultUserInfo.token = token;
userInfo.adminToken = token;
} else {
//管委会登录管理后台
resultUserInfo.loginId = userInfo.loginId;
resultUserInfo.token = token;
userInfo.token = token;
userInfo.tokenMs = new Date().valueOf();
}
await userInfo.save();
return resultUserInfo;
}
/**
* 采收逻辑
*/
import { TABLENAME } from "../config/dbEnum";
import { CaiShouConfig } from "../config/eccParam";
import { PLANTTYPE, ZHONGYANGTYPE } from "../config/enum";
import * as caishouData from "../data/caishou";
import * as dikuaiData from "../data/dikuai";
import * as zhongzhiData from "../data/zhongzhi";
import { randomId, successResult } from "../tools/system";
import { changeEnumValue, eccEnumValue } from "../util/verificationEnum";
import { eccFormParam } from "../util/verificationParam";
import moment = require("moment");
/**
* 添加采收
* @param reqUser
* @param param
* @returns
*/
export async function addCaiShou(reqUser, param) {
let funName = `添加采收`;
eccFormParam(funName, CaiShouConfig, param );
eccEnumValue(funName, "plantType", PLANTTYPE, param.plantType);
//修改种养
let zhongyangParam = {isEnd:0, plantType:param.plantType, dId:param.dId};
let zhongzhiList = await zhongzhiData.selectToParam(zhongyangParam);
let sizeCount = 0;
for (let i = 0; i < zhongzhiList.length; i++) {
let {dId, size} = zhongzhiList[i];
sizeCount += size;
}
//释放地块
let diKuaiInfo = await dikuaiData.selectOne({dId:param.dId});
diKuaiInfo.nullSize = diKuaiInfo.nullSize + sizeCount;
diKuaiInfo.useSize = diKuaiInfo.useSize - sizeCount;
await diKuaiInfo.save();
let csId = randomId(TABLENAME.采收);
//改变种植面积
await zhongzhiData.updateManyToParam({isEnd:0, plantType:param.plantType}, {isEnd:1, csId});
//添加采收记录
let addInfo = {
csId,
dIdList:param.dIdList,
plantType:param.plantType,
operationTime:param.operationTime,
weight:param.weight,
ct:new Date().valueOf(),
createUser:reqUser.userId
};
await caishouData.addData(addInfo)
return successResult();
}
/**
* 采收列表
* @param selectStr
* @param dId
* @param zhongYangType
* @param plantType
* @param operationTime
* @returns
*/
export async function caiShouList(zhongYangType:number, selectStr:string, dId:string, plantType:number, operationTime:number) {
let funName = "采收列表";
eccEnumValue(funName, "zhongYangType", ZHONGYANGTYPE, zhongYangType);
let param:any = { plantType : {"$gte":zhongYangType, "$lt":zhongYangType+99} };
if (plantType) {
eccEnumValue(funName, "plantType", PLANTTYPE, plantType);
param.plantType = plantType;
}
if (dId) {
param.dIdList = {"$in":dId};
}
if (operationTime) {
let startMs = moment(operationTime).startOf("month").valueOf();
let endMs = moment(operationTime).endOf("month").valueOf();
param.useTime = {"$gt":startMs, "$lt":endMs};
}
let dikuaiList = await dikuaiData.selectToParam({});
let diKuaiMap = {};
dikuaiList.forEach(info => {
let {dId, code} = info;
diKuaiMap[dId] = code;
});
let nongShiList = await caishouData.selectToParam(param);
let dataList = [];
nongShiList.forEach(item => {
let {plantType, dIdList, operationTime, weight } = item;
let dIds = dIdList;
let didStr = "";
dIds.forEach(dId => {
didStr += `${diKuaiMap[dId]} `;
})
dataList.push({
plantType:changeEnumValue(PLANTTYPE, plantType),
dIdList:didStr,
operationTime:moment(operationTime).format("YYYY-MM-DD"),
weight
});
});
return {dataList}
}
\ No newline at end of file
/**
* 数据接口输出
*/
import moment = require("moment");
import { LIANGSHI, NONGZITYPE, PLANTTYPE, PLOTTYPE } from "../config/enum";
import { diKuaiSizeCountByParam } from "../data/dikuai";
import { statisNongZiType, statisNongZiTypeCountByTime } from "../data/nongzi";
import { selectToParam, zhongZhiTongJiCount } from "../data/zhongzhi"
import * as nongshiData from "../data/nongshi"
import * as xiaoshouData from "../data/xiaoshou"
import { changeEnumValue } from "../util/verificationEnum";
import { selectChanLiangOfMonth } from "../data/caishou";
export async function getDataOut() {
let 种植总面积 = 0;
let 粮田面积 = 0;
let 菜田面积 = 0;
let 作物数量 = 0;
let zhongZhiList = await zhongZhiTongJiCount();
let zhongZhiZuoWuList = []; //结果
zhongZhiList.forEach(info => {
let {_id, sizeCount} = info;
种植总面积 += sizeCount;
if (_id == LIANGSHI.水稻 || _id == LIANGSHI.蚕豆) {
粮田面积 += sizeCount;
} else if (_id < 100) {
菜田面积 += sizeCount;
}
if ( !(_id > 100 && _id < 200)) {
作物数量 += 1;
zhongZhiZuoWuList.push({key:changeEnumValue(PLANTTYPE, _id), value:sizeCount});
}
});
let diKuaiInfo = await diKuaiSizeCountByParam({plotType:PLOTTYPE.地块});
let 地块使用率 = 0;
if (diKuaiInfo.totalSize && diKuaiInfo.totalUseSize) {
地块使用率 = Math.round(diKuaiInfo.totalUseSize/diKuaiInfo.totalSize * 100);
}
let zhongZhiTypeList = [
{key:"种植总面积", value:种植总面积},
{key:"菜田面积", value:菜田面积},
{key:"粮田面积", value:粮田面积},
{key:"作物数量", value:作物数量},
{key:"地块使用率", value:地块使用率},
]; //结果
let 农资类型 = await statisNongZiType();
let 农资情况Map = {};
农资情况Map[NONGZITYPE.肥料] = {key:changeEnumValue(NONGZITYPE, NONGZITYPE.肥料), value:0};
农资情况Map[NONGZITYPE.农药] = {key:changeEnumValue(NONGZITYPE, NONGZITYPE.农药), value:0};
农资情况Map[NONGZITYPE.其他] = {key:changeEnumValue(NONGZITYPE, NONGZITYPE.其他), value:0};
农资类型.forEach(info => {
let {_id, count} = info;
if (农资情况Map[_id]) 农资情况Map[_id].value = count;
});
let nongZiList = Object.values(农资情况Map); //结果
let nongZiAllMonthList = await statisNongZiTypeCountByTime();
let nongZiCountInfo = {};//肥料用药情况
nongZiCountInfo[NONGZITYPE.农药] = {};
nongZiCountInfo[NONGZITYPE.肥料] = {};
// nongZiAllMonthList = [
// { "totalWeight" : 15, "year" : 2025, "month" : 1, "nzType" : 2 },
// { "totalWeight" : 23, "year" : 2025, "month" : 2, "nzType" : 1 },
// { "totalWeight" : 10, "year" : 2025, "month" : 3, "nzType" : 1 },
// ]
nongZiAllMonthList.forEach(info => {
let {year, month, nzType, totalWeight} = info;
if (nongZiCountInfo[nzType]) {
nongZiCountInfo[nzType][`${year}-${month}`] = totalWeight;
};
});
let 肥料 = [];
let 用药 = [];
for (let i = 9; i >= 0; i--) {
let key = moment().subtract(i, 'months').format("YYYY-M");
肥料.push({
key,
value:nongZiCountInfo[NONGZITYPE.肥料][key] || 0
});
用药.push({
key,
value:nongZiCountInfo[NONGZITYPE.农药][key] || 0
});
}
let feiliaoyongyaoqingkuang = [ //结果
{name:"肥料", data:肥料},
{name:"用药", data:用药},
];
let nongShiCount = await nongshiData.selectCountByParam({}); //结果
let nongshiTyptList = await nongshiData.statisNongShiType();
let 操作趋势 = {};
let nongShiList = [];//结果
nongshiTyptList.forEach(info => {
let {year, month, count} = info;
操作趋势[`${year}-${month}`] = count;
});
for (let i = 9; i >= 0; i--) {
let key = moment().subtract(i, 'months').format("YYYY-M");
nongShiList.push({
key,
value:操作趋势[key] || 0
});
}
let monthDBList = await selectChanLiangOfMonth();
let 作物产量Map = {};
monthDBList.forEach(info => {
let {year, month, totalWeight} = info;
let key = `${year}-${month}`;
if (!作物产量Map[key]) 作物产量Map[key] = 0;
作物产量Map[key] += totalWeight;
});
let 今年 = [];
let 去年 = [];
let thisYear = new Date().getFullYear();
let lastYear = thisYear - 1;
let 今年产量总数 = 0;
let 去年产量总数 = 0;
for (let i =1; i <=12; i++) {
let thisYearItem = 作物产量Map[`${thisYear}-${i}`] || 0;
let lastYearItem = 作物产量Map[`${lastYear}-${i}`] || 0;
今年.push({key: `${thisYear}-${i}`, value:thisYearItem });
去年.push({key: `${lastYear}-${i}`, value:lastYearItem });
今年产量总数 += thisYearItem;
去年产量总数 += lastYearItem;
}
let chanLiangList = [ //结果
{name:"今年", data:今年},
{name:"去年", data:去年},
];
let 产量年同比 = 0;
if (今年产量总数 && 去年产量总数) {
产量年同比 = Math.round((今年产量总数 - 去年产量总数)/ 去年产量总数*10000)/100
}
let chanLiangStatisList = [//结果
{key:"作物产量", value:今年产量总数},
{key:"同比", value:产量年同比}
];
let xiaoshouStartMs = moment().subtract(1, "months").startOf('month').valueOf();
let xiaoshouEndMs = moment().startOf('month').valueOf();
let xiaoshouDBList = await xiaoshouData.selectToParam({operationTime:{"$gt":xiaoshouStartMs, "$lt":xiaoshouEndMs }});
let lastMonthXiaoShou = 0;
let lastMonthXiaoShouMap = {};
xiaoshouDBList.forEach(info => {
let {operationTime, weight} = info;
lastMonthXiaoShou += weight;
let key = moment(operationTime).format("MM-DD");
let dayKey = moment(operationTime).format("DD");
if (!lastMonthXiaoShouMap[key]) lastMonthXiaoShouMap[key] = {key:dayKey, value:0};
lastMonthXiaoShouMap[key].value += weight;
});
let lastMonthXiaoShouList = Object.values(lastMonthXiaoShouMap);//结果
return {
zhongZhiZuoWuList,
zhongZhiTypeList,
nongZiList,
feiliaoyongyaoqingkuang,
nongShiList,
nongShiCount,
chanLiangList,
chanLiangStatisList,
lastMonthXiaoShou,
lastMonthXiaoShouList
}
}
/**
* 地块
*/
import { TABLENAME } from "../config/dbEnum";
import { DiKuaiConfig, YangZhiChiConfig } from "../config/eccParam";
import { AREARANGE, PLANTTYPE, PLOTTYPE, PURPOSE, ZHONGYANGTYPE } from "../config/enum";
import { ERRORENUM } from "../config/errorEnum";
import * as dikuaiData from "../data/dikuai";
import { randomId, successResult } from "../tools/system";
import { BizError } from "../util/bizError";
import { changeEnumValue, eccEnumValue } from "../util/verificationEnum";
import { eccFormParam } from "../util/verificationParam";
/**
* 添加地块
* @param reqUser
* @param plotType
* @param param
* @returns
*/
export async function addDiKuai(reqUser, plotType, param) {
let funName = `添加地块`;
eccEnumValue(funName, "plottype", PLOTTYPE, plotType);
let purpose = PURPOSE.养殖;
if (plotType == PLOTTYPE.地块) {
eccFormParam(funName+changeEnumValue(PLOTTYPE, plotType), DiKuaiConfig, param);
eccEnumValue(funName, "param=>type", PURPOSE, param.type);
purpose = param.type;
} else {
eccFormParam(funName+changeEnumValue(PLOTTYPE, plotType), YangZhiChiConfig, param);
}
let addInfo = {
dId:randomId(TABLENAME.地块表),
size:param.size,
useSize:0,//使用大小默认0
nullSize:param.size,//初始可使用大小为大小
code:param.code,
name:param.code, //地块名称
plotType,
purpose,//用途 【枚举】 PURPOSE
createUser:reqUser.userId,
ct:new Date().valueOf()
};
await dikuaiData.addData(addInfo);
return successResult();
}
/**
* 地块信息
* @param plotType
* @param selectStr
* @param code
* @param purpose
* @param area
* @returns
*/
export async function diKuaiInfo(dId:String ) {
let funName = "地块信息";
let dikuaiInfo = await dikuaiData.selectOne({dId});
let dataInfo = {
size:dikuaiInfo.size,
dId:dikuaiInfo.dId,
type:dikuaiInfo.purpose,
purpose:changeEnumValue(PURPOSE, dikuaiInfo.purpose),
code:dikuaiInfo.code
};
return {dataInfo}
}
/**
* 地块列表
* @param plotType
* @param selectStr
* @param code
* @param purpose
* @param area
* @returns
*/
export async function diKuaiList(plotType:number, selectStr:string, code:string, purpose:number, area:number ) {
let funName = "地块列表";
eccEnumValue(funName, "plottype", PLOTTYPE, plotType);
let param:any = {plotType};
if (code) {
param.code = { "$regex":code };
}
if (purpose) {
eccEnumValue(funName, "purpose", PURPOSE, purpose);
param.purpose = purpose;
}
if (area) {
eccEnumValue(funName, "area", AREARANGE, area);
param.size = {"$lte": parseInt(AREARANGE[area].replace("<=", "")) };
}
let diKuaiList = await dikuaiData.selectToParam(param);
let dataList = [];
diKuaiList.forEach(item => {
let { size, dId, purpose, code } = item;
dataList.push({size,dId,type:changeEnumValue(PURPOSE, purpose),code});
});
return {dataList}
}
/**
* 修改地块信息
* @param reqUser
* @param plotType
* @param dId
* @param param
* @returns
*/
export async function updateDiKuai(reqUser, plotType, dId, param) {
let funName = `修改地块`;
eccEnumValue(funName, "plottype", PLOTTYPE, plotType);
let purpose = PURPOSE.养殖;
if (plotType == PLOTTYPE.地块) {
eccFormParam(funName+changeEnumValue(PLOTTYPE, plotType), DiKuaiConfig, param);
eccEnumValue(funName, "param=>type", PURPOSE, param.type);
purpose = param.type;
} else {
eccFormParam(funName+changeEnumValue(PLOTTYPE, plotType), YangZhiChiConfig, param);
}
let dInfo = await dikuaiData.selectOne({dId});
if (!dInfo || !dInfo.dId) throw new BizError(ERRORENUM.地块不存在);
dInfo.code = param.code,
dInfo.size = param.size,
dInfo.purpose = purpose;
await dInfo.save();
return successResult();
}
/**
* 当前可种植地块
* @returns
*/
export async function keXuanDiKuaiList(zhongYangType:number) {
let param:any = {};
if (zhongYangType) {
let purpose = 1;
if (zhongYangType == ZHONGYANGTYPE.水产) purpose = PURPOSE.养殖;
else if (zhongYangType == ZHONGYANGTYPE.花卉 ||zhongYangType == ZHONGYANGTYPE.蔬菜 ) purpose = PURPOSE.菜田;
else if (zhongYangType == ZHONGYANGTYPE.粮食) purpose = PURPOSE.粮田;
param.nullSize = {"$gt":0};
param.purpose = purpose;
}
console.log("------>", JSON.stringify(param));
let dbList = await dikuaiData.selectToParam(param);
let dataList = [];
dbList.forEach(info => {
let {code, purpose, dId, size} = info;
dataList.push( {code, purpose:changeEnumValue(PURPOSE, purpose), dId, size});
});
return {dataList};
}
/**
* 当前采收地块列表
* @returns
*/
export async function keCaiShouList(zhongYangType:number) {
let purpose = 1;
if (zhongYangType == ZHONGYANGTYPE.水产) purpose = PURPOSE.养殖;
else if (zhongYangType == ZHONGYANGTYPE.花卉 ||zhongYangType == ZHONGYANGTYPE.蔬菜 ) purpose = PURPOSE.菜田;
else if (zhongYangType == ZHONGYANGTYPE.粮食) purpose = PURPOSE.粮田;
let param = {useSize:{"$gt":0}, purpose:purpose};
let dbList = await dikuaiData.selectToParam(param);
let dataList = [];
dbList.forEach(info => {
let {code, purpose, dId, size} = info;
dataList.push( {code, purpose:changeEnumValue(PURPOSE, purpose), dId, size});
});
return {dataList}
}
/**
* 全部地块列表
* @param plotType
* @param selectStr
* @param code
* @param purpose
* @param area
* @returns
*/
export async function allDiKuaiList(plotType:number ) {
let funName = "地块列表";
eccEnumValue(funName, "plottype", PLOTTYPE, plotType);
let param:any = {plotType};
let diKuaiList = await dikuaiData.selectToParam(param);
let dataList = [];
diKuaiList.forEach(item => {
let { size, dId, purpose, code } = item;
dataList.push({dId, code});
});
return {dataList}
}
\ No newline at end of file
import { getPolicyBGImgId } from "../tools/system";
/**
* 文件上传
*/
const fs = require('fs');
const path = require('path');
/**
* 上传文件
* @param files
* @param type
* @returns
*/
export async function upFile(files, type) {
let pngId = getPolicyBGImgId();
let upUrl = path.join(__dirname.substring(0,__dirname.indexOf("out")), 'files', 'policy');
let stats = fs.existsSync(upUrl);
if (!stats) fs.mkdirSync(upUrl);
let fileName = `${pngId}${type}`;
fs.renameSync(files.file.path, path.join(upUrl, `${fileName}` ));
return {isSuccess:true, url:`/policy/${fileName}`, fileName};
}
\ No newline at end of file
export enum TARGET {
孵化器数量= 1,
孵化器孵化领域分布,
企业融资数量,
行业领域分布,
企业融资金额,
融资最多企业金额和占比,
上市企业数量,
上市企业分布,
融资行业领域占比,
融资事件最多的领域,
孵化器具备投资功能的数量和占比,
孵化器投融资金额,
融资企业的融资轮次分布,
孵化器就业人数,
在孵企业就业人数,
国际一流人才与国内一流人才占比,
布局新模式孵化器占比,
布局海外孵化器基地数量,
国际化合作数量,
搭建专业技术平台的数量,
搭建专业技术平台的占比,
创投基金数量,
创业创新方向各类型占比,
在孵企业营收总金额,
在孵企业营收季度趋势,
在孵企业纳税金额,
在孵企业纳税季度趋势,
在孵企业研发投入金额,
在孵企业研发投入季度趋势,
在孵企业创新方向占比,
孵化器营收总金额,
孵化器营收季度趋势,
孵化器纳税金额,
孵化器纳税季度趋势,
企业资质占比,
企业专利占比,
创业导师数量,
创业导师专业分布,
创业导师领域分布,
企业总数
}
\ No newline at end of file
/**
* ai聊天模块
*/
import { ERRORENUM } from "../../config/errorEnum"
import { BizError } from "../../util/bizError"
import { cozeGet, cozePost, post } from "../../util/request"
const request = require('request')
const AK = "SjRG4fWy8ByvLSmpBX3X7zyl"
const SK = "vA1jj6TbQoY4bXqzgZBEewNoi1eZAFoS"
/**
* 使用 AK,SK 生成鉴权签名(Access Token)
* @return string 鉴权签名信息(Access Token)
*/
function getAccessToken() {
let options = {
'method': 'POST',
'url': 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=' + AK + '&client_secret=' + SK,
}
return new Promise((resolve, reject) => {
request(options, (error, response) => {
if (error) { reject(error) }
else { resolve(JSON.parse(response.body).access_token) }
})
})
}
export async function checkMsg(msg:string, preConditions?) {
if (!preConditions) preConditions = [];
let messages = [];
preConditions.forEach(str => {
messages.push({"role":"user", "content":str});
messages.push({"role":"assistant", "content":"好的"});
});
messages.push({"role":"user", "content":msg});
let access_token = await getAccessToken();
var options = {
'method': 'POST',
'url': 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant?access_token=' + access_token,
'headers': {
'Content-Type': 'application/json'
},
body: JSON.stringify({messages})
};
return new Promise((resolve, reject) => {
request(options, function (error, response) {
if (error) throw new Error(error);
if (error) {
reject(error);
}
else {
resolve(JSON.parse(response.body).result);
}
});
})
}
/**
* 字节智能体
*/
export async function cozeMsg(msg:string, conversationId:string, chatId:string, messageList) {
let additional_messages = [];
//拼接上下文
let i = messageList.length <= 10 ? 0 : (messageList.length - 10)-1;
for (; i < messageList.length; i++) {
let {role, msg} = messageList[i];
let type = role != 'user' ? 'question' : 'answer'
additional_messages.push({
role,
type,
content:msg,
content_type:'text'
});
}
/**请求头 */
const Header = {
Authorization:'Bearer pat_KORy65MIpPSGQ8cx4rLLipsAZhgjkk5neIv0o1IWKb2svC3t2RbECSMpSBHWyDuN',
"Content-Type":"application/json"
};
const botId = '7395108996510089266';
/**创建会话 */
if (!conversationId) {
let creatChartUrl = 'https://api.coze.cn/v1/conversation/create';
let conversationRes:any = await cozePost(creatChartUrl, {}, Header);
conversationId = conversationRes.data.id;
}
/**创建消息 */
let messageBody = {
role:'user',
content:msg,
content_type:"text"
};
let createMessageRes:any = await cozePost(`https://api.coze.cn/v1/conversation/message/create?conversation_id=${conversationId}`, messageBody, Header);
//判断创建情况,如果消息创建失败,后面轮询会报错
if (!createMessageRes.data) {
throw new BizError(ERRORENUM.智能体调用出错请联系管理员, '创建消息失败');
}
/**发起对话 */
let chatUrl = `https://api.coze.cn/v3/chat?conversation_id=${conversationId}`;
let chatBody = {
bot_id :botId,
conversation_id:conversationId,
user_id:"user",
stream:false,
auto_save_history:true,
additional_messages
};
let chatResult:any = await cozePost(chatUrl, chatBody, Header);
//判断创建情况,如果消息创建失败,后面轮询会报错
if (!createMessageRes.data) {
throw new BizError(ERRORENUM.智能体调用出错请联系管理员, '发起对话失败');
}
chatId = chatResult.data.id;
/**查询对话状态 */
let max = 100;
for (let i = 0; i < max; i++) {
await sleep(1000);
let queryInfo = {conversation_id:conversationId, chat_id:chatId};
// let itemUrl =`https://api.coze.cn/v3/chat/retrieve?conversation_id=${conversation_id}&chat_id=${chat_id}`;
let itemUrl =`https://api.coze.cn/v3/chat/retrieve`;
let itemRes:any = await cozeGet(itemUrl, queryInfo, Header);
console.log(`第${i+1}次等待`);
if (!itemRes.data || !itemRes.data.status || itemRes.data.status == "failed") {
throw new BizError(ERRORENUM.智能体调用出错请联系管理员, '轮询对话状态失败');
}
if (["completed","required_action","canceled","failed"].indexOf( itemRes.data.status) != -1) {
break;
}
}
/**查看消息列表 */
let allres:any = await cozeGet('https://api.coze.cn/v3/chat/message/list', {conversation_id:conversationId, chat_id:chatId}, Header);
if (!allres.data) throw new BizError(ERRORENUM.智能体调用出错请联系管理员, '查看消息列表失败');
let msgList = allres.data;
let resMsg = msgList[msgList.length -1 ].content;
console.log(`提问:${msg}`, `回答:${resMsg}`);
return {answer:resMsg, conversationId, chatId};
}
function sleep(time) {
return new Promise((resolve, reject) => {
setTimeout(()=> {
resolve({});
}, time);
});
}
/**
* 用于报告生成
*/
import { ERRORENUM } from "../../config/errorEnum";
import { findFuHuaQiList } from "../../data/fuHuaQi/fuhuaqi";
import { createChatInfo, selectChatInfo } from "../../data/guanWeiHui/chart";
import { BizError } from "../../util/bizError";
import { TARGET } from "./enum";
import { checkMsg, cozeMsg } from "./gpt";
import { getIndicationRate, getIndicationValueStr, getIndicationValue } from "./indicatorPool";
const officegen = require('officegen');
const fs = require('fs');
const path = require('path');
/**提问大纲 */
let outline = [];
export function initOutline() {
outline = [
{ title:'概述', msg:"写一段话,概述孵化器的作用与意义来表达孵化器的重要性", removeParagraph:true },
{ title:'孵化器分析', msg:"请根据已知条件,从经济学的角度分析孵化器的运行情况,要求2000个字。", context:[fuHuaQiCombinationMessage()]},
{ title:'企业分析', msg:"请根据已知条件,从经济学的角度分析企业的运行情况, 要求2000个字。", context:[enterpriseCombinationMessage()]},
{ title:'改进与规划', msg:"请根据已知条件,从经济学的角度提出孵化器的不足和改进方向。", context:[fuHuaQiCombinationMessage(), enterpriseCombinationMessage()]}
];
}
/**
* 生成报告
* @param token
*/
export async function generateReport() {
// return {fileName:"2023年采集数据分析.docx", size:'17kb', url:'/doc/2023年采集数据分析.docx'};
let docx = officegen('docx');
let pObj = docx.createP();
/**绑定事件 */
docx.on('finalize', function(written) {
console.log(
'报告已生成'
)
});
docx.on('error', function(err) {
console.log(err)
});
/**生成大标题 */
pObj.addText(`${new Date().getFullYear()}孵化器运行分析报告\n`,{ font_size:18, bold:true });
let index = 1;
for (let key in outline) {
let {title, msg, context, removeParagraph} = outline[key];
/**组合小标题 */
pObj.addText(`${index}${title}\n`, { font_size:16, bold:true });
context = context || [];
let chartStr:any = await checkMsg(msg, context);
if (removeParagraph && chartStr) {
let rmvList = chartStr.split('\n');
let rmvStr = ``;
rmvList.forEach(itemStr => {rmvStr += itemStr});
chartStr = rmvStr;
}
pObj.addText(' '+chartStr+`\n`, { font_size:14 });
index ++;
}
let out = fs.createWriteStream( path.join(__dirname.substring(0,__dirname.indexOf("out")), "res", 'test.docx' ));
docx.generate(out);
return {isSuccess:true};
}
export async function zjAiChart(token:string) {
let str = fuHuaQiCombinationMessage();
let enterpriseStr = enterpriseCombinationMessage();
let preConditions = [];
preConditions.push(str);
preConditions.push(enterpriseStr);
let resultMsg:any = await checkMsg(token, preConditions);
return {message:resultMsg};
}
export async function aiChart(userId:string, token:string, messageList) {
if (!token) throw new BizError(ERRORENUM.请输入聊天内容);
let chatInfo = await selectChatInfo(userId);
if (!chatInfo || !chatInfo.userId) {
await createChatInfo(userId);
chatInfo = await selectChatInfo(userId);
}
let contextList = JSON.parse(chatInfo.additionalMessages);
let {answer, chatId, conversationId} = await cozeMsg(token, chatInfo.conversationId, chatInfo.chatId, contextList);
/**更新对话记录 */
let newContextList = [];
if (contextList.length >= 10) {
for (let i = 2; i < contextList.length; i++) {
newContextList.push(contextList[i]);
}
}
newContextList.push({ role:'user', msg:token});
newContextList.push({ role:'bot', msg:answer});
chatInfo.additionalMessages = JSON.stringify(newContextList);
/**更新参数 */
chatInfo.chatId = chatId;
chatInfo.conversationId = conversationId;
chatInfo.conversationMs = new Date().valueOf();
return {message:answer};
}
/**
* 组合数据前置条件
* 孵化器
*/
function fuHuaQiCombinationMessage() {
const Unit = "家";
let fhqCount = getIndicationValueStr(TARGET.孵化器数量, Unit);
let str = `已知:上海张江共计${fhqCount}孵化器,`;
str += `其中${getIndicationValueStr(TARGET.孵化器孵化领域分布, Unit)}${fhqCount}孵化器中${getIndicationRate(TARGET.布局新模式孵化器占比)}。`;
str += `共计${getIndicationValueStr(TARGET.创投基金数量, Unit)}孵化器成立创投基金。`;
let rate = Math.ceil(getIndicationValue(TARGET.孵化器具备投资功能的数量和占比)/getIndicationValue(TARGET.孵化器数量)*10000)/100;
str +=`${getIndicationValueStr(TARGET.孵化器具备投资功能的数量和占比, Unit)}孵化器具备投资功能,占比${rate}%,共计投融资${getIndicationValueStr(TARGET.孵化器投融资金额, "万元")}。`
str +=`${getIndicationValueStr(TARGET.搭建专业技术平台的数量, Unit)}孵化器搭建专业技术平台,占比${getIndicationValueStr(TARGET.搭建专业技术平台的占比)}。`;
str += `${fhqCount}家孵化器中,共有${getIndicationValue(TARGET.国际化合作数量)}个国际化合作。`;
str += `${getIndicationValue(TARGET.创业导师数量)}个创业导师,在这${getIndicationValue(TARGET.创业导师数量)}个创业导师中,${getIndicationValueStr(TARGET.创业导师专业分布, "个")}。`
str += `所有孵化器从业人员中:${getIndicationRate(TARGET.国际一流人才与国内一流人才占比)}。`;
str +=`本年度孵化器总营收${getIndicationValue(TARGET.孵化器营收总金额)}元,其中${getIndicationValueStr(TARGET.孵化器营收季度趋势, "元")}。`;
str +=`本年度孵化器纳税共计${getIndicationValue(TARGET.孵化器纳税金额)}元,其中${getIndicationValueStr(TARGET.孵化器纳税季度趋势, "元")}。`;
return str;
}
function enterpriseCombinationMessage() {
let str = `已知:孵化器已采集的${getIndicationValue(TARGET.企业总数)}家企业数据情况如下,行业领域分布:${getIndicationRate(TARGET.行业领域分布)}。`;
str += `创业创新方向各类型分布:${getIndicationRate(TARGET.创业创新方向各类型占比)}。`;
str += `在统计范围之内共有${getIndicationValueStr(TARGET.企业融资数量, '次')}融资行为,共计融资${getIndicationValueStr(TARGET.企业融资金额, '万元')},`;
str += `其中融资轮次分布情况:${getIndicationRate(TARGET.融资企业的融资轮次分布)},`;
let maxIn = getIndicationValue(TARGET.融资事件最多的领域);
str += `融资行业领域占比${getIndicationRate(TARGET.融资行业领域占比)},其中${maxIn["领域"]}领域融资事件最多,有${maxIn["次数"]}次。`;
str += `其中融资最多企业金额和占比${getIndicationValue(TARGET.融资最多企业金额和占比)}。`;
str += `在统计范围内共有上市企业${getIndicationValue(TARGET.上市企业数量)}家。`;
str += `在统计范围内在孵企业的营收总额${getIndicationValue(TARGET.在孵企业营收总金额)}元,其中${getIndicationValueStr(TARGET.在孵企业营收季度趋势, "元")},`;
str += `在孵企业纳税总额${getIndicationValue(TARGET.在孵企业纳税金额)}元,其中${getIndicationValueStr(TARGET.在孵企业纳税季度趋势, "元")},`;
str += `在孵企业纳税总额${getIndicationValue(TARGET.在孵企业研发投入金额)}元,其中${getIndicationValueStr(TARGET.在孵企业研发投入季度趋势, "元")}。`;
str += `在统计范围内企业资质情况${getIndicationRate(TARGET.企业资质占比)}。`;
str += `在统计范围内企业专利情况${getIndicationRate(TARGET.企业专利占比)}。`;
return str;
}
export async function test() {
let chartStr:any = await checkMsg("分析当前所有再孵企业的行业优势", [enterpriseCombinationMessage()]);
let str = "";
if ( chartStr) {
let rmvList = chartStr.split('\n');
let rmvStr = ``;
rmvList.forEach(itemStr => {rmvStr += itemStr});
str = rmvStr;
}
console.log(str);
console.log();
}
\ No newline at end of file
/**
* 小程序端 企业用户的 企业基础信息
* 作者:lxm
*/
import moment = require("moment");
import { EnterpriseUpdateBaseDataConfig } from "../../../config/eccParam/enterprise";
import { CYCSRBJ, CYCXFX, INDUSTRY, STATEENUM } from "../../../config/enum";
import { ERRORENUM } from "../../../config/errorEnum";
import { EnterpriseBaseConfig } from "../../../config/splitResultConfig";
import * as enterpriseData from "../../../data/enterprise/enterprise";
import { selectEnterpriseTwoYeasFinancing } from "../../../data/enterprise/financingInfo";
import { findEnterpriseNewTeamData } from "../../../data/enterprise/quarterTask/team";
import { BizError } from "../../../util/bizError";
import { checkChange, checkDataHaveNull, extractData } from "../../../util/piecemeal";
import { eccEnumValue } from "../../../util/verificationEnum";
import { eccFormParam } from "../../../util/verificationParam";
import { findBusinessDataByYear } from "../../../data/enterprise/quarterTask/businessdata";
import { findReplenishBusinessDataByYear } from "../../../data/enterprise/replenish";
import { addEnterprisePoint } from "../../point";
import { ENTERPRISENODEENUM, POINTTYPEENUM } from "../../../config/pointConfig";
/**
* 获取首页基础信(首页顶端数据)
* 知识产权,融资情况,企业资质 第一次进来会红,点开之后红点提示 会永久消失 2023-05-08
* @param uscc 企业统一信用代码
* @returns
*/
export async function getHomePageHeaderData(uscc:string) {
let enterpriseInfo = await enterpriseData.findEnterpriseByUscc(uscc);
//企业名称
let name = enterpriseInfo.name;
//团队总数
let newTeamInfo = await findEnterpriseNewTeamData(uscc);
let teamInfo = Object.keys(newTeamInfo).length > 0 ? newTeamInfo : {doctor:0, master:0, undergraduate:0, juniorCollege:0, other:0 };
let memberCount = teamInfo.doctor + teamInfo.master+ teamInfo.undergraduate+ teamInfo.juniorCollege+ teamInfo.other;
let initialTeam = enterpriseInfo.haveFirstClassTalent == STATEENUM.未选 || !enterpriseInfo.haveFirstClassTalent;//创始团队缺失 true=缺失
let qualification = !enterpriseInfo.tipsQualification; //企业资质缺失 true=缺失 需要标红
let intellectualProperty = !enterpriseInfo.tipsIntellectualProperty;//知识产权缺失 true=缺失 需要标红
let financing = !enterpriseInfo.tipsFinancingInfo; //融资情况缺失 true=缺失 需要标红
let checkEnterpriseInfo = extractData(EnterpriseBaseConfig, enterpriseInfo, false);
let baseInfo = checkDataHaveNull(checkEnterpriseInfo, true);
/** 更新拟毕业情况 ps:拟毕业状态是不可逆的*/
if ( !enterpriseInfo.qualification ) {
let isGraduation = false;
let qualification = enterpriseInfo.qualification || {};
if (qualification.isHighTech || qualification.isZjtx || qualification.isBeOnTheMarket) {
isGraduation = true;
}
/*两年融资累计500万*/
let startYear = new Date(moment().subtract(2, 'year').year() + '-01-01 00:00:00').valueOf();
let endYear = new Date(moment().year() + '-01-01 00:00:00').valueOf();
let financingCount = await selectEnterpriseTwoYeasFinancing(uscc, startYear, endYear);
if (financingCount>=500) isGraduation = true;
/*两年营收累计1000万*/
let BICount = await findBusinessDataByYear(uscc, new Date(startYear).getFullYear(), new Date(startYear).getFullYear()+1 );
let replenishBI = await findReplenishBusinessDataByYear(uscc, new Date(startYear).getFullYear(), new Date(startYear).getFullYear()+1);
if (BICount + replenishBI >=10000000) isGraduation = true;
if (isGraduation) {
enterpriseInfo.graduation = true;
await enterpriseInfo.save();
}
}
return {
name,
memberCount,
hiatus:{
initialTeam,
qualification,
financing,
intellectualProperty,
baseInfo
}
}
}
/**
* 获取企业基本信息
* 回显
* @param uscc
*/
export async function enterpriseBaseInfo(uscc:string) {
let enterpriseInfo = await enterpriseData.findEnterpriseByUscc(uscc);
let updateInfo = extractData(EnterpriseBaseConfig, enterpriseInfo, false);
return updateInfo;
}
/**
* 修改我的企业信息
* @param uscc 企业统一信用代码
* @param param 表单
* @returns
*/
export async function updateEnterpriseBaseInfo(uscc:string, param) {
eccFormParam("企业修改我的信息", EnterpriseUpdateBaseDataConfig, param );
eccEnumValue('企业修改我的信息', 'industry', INDUSTRY, param.industry);
let enterpriseInfo = await enterpriseData.findEnterpriseByUscc(uscc);
addEnterprisePoint( uscc, ENTERPRISENODEENUM.基本信息_经营地址, enterpriseInfo.operatingAddress, param.operatingAddress, enterpriseInfo.fuHuaQiUscc);
addEnterprisePoint( uscc, ENTERPRISENODEENUM.基本信息_行业领域, enterpriseInfo.industry, param.industry, enterpriseInfo.fuHuaQiUscc);
/**修改字段 */
let changeList = checkChange(param, enterpriseInfo);
if ( !changeList.length ) throw new BizError(ERRORENUM.数据无更新, `${param.uscc}数据无更新`);
changeList.forEach(key => {
if (key != "uscc" && key != "name") {
enterpriseInfo[key] = param[key];
}
});
await enterpriseInfo.save();
return {isSuccess:true};
}
/**
* 修改创业创新方向
* @param uscc
* @param cycxfx
*/
export async function updateCYCXFX(uscc:string, cycxfx) {
eccEnumValue('修改创业创新方向', 'cycxfx', CYCXFX, cycxfx);
let enterpriseInfo = await enterpriseData.findEnterpriseByUscc(uscc);
enterpriseInfo.cycxfx = cycxfx;
await enterpriseInfo.save();
return {isSuccess:true};
}
/**
* 创业创新方向回显
* @param uscc
*/
export async function selectCYCXFX(uscc:string) {
let enterpriseInfo = await enterpriseData.findEnterpriseByUscc(uscc);
return {cycxfx:enterpriseInfo.cycxfx || []};
}
/**
* 修改创业创始人背景
* @param uscc
* @param cycxfx
*/
export async function updateCYCSRBJ(uscc:string, cycsrbj) {
eccEnumValue('修改创业创始人背景', 'cycsrbj', CYCSRBJ, cycsrbj);
let enterpriseInfo = await enterpriseData.findEnterpriseByUscc(uscc);
enterpriseInfo.cycsrbj = cycsrbj;
await enterpriseInfo.save();
return {isSuccess:true};
}
/**
* 创业创始人背景回显
* @param uscc
*/
export async function selectCYCSRBJ(uscc:string) {
let enterpriseInfo = await enterpriseData.findEnterpriseByUscc(uscc);
return {cycsrbj:enterpriseInfo.cycsrbj || []};
}
/**
* 创始团队主要逻辑
* 作者:lxm
*/
import { InitialTeamUpdateConfig } from "../../../config/eccParam/enterprise";
import { ENTERPRISETEAM, STATEENUM } from "../../../config/enum";
import { ERRORENUM } from "../../../config/errorEnum";
import { ENTERPRISENODEENUM, POINTTYPEENUM } from "../../../config/pointConfig";
import { EnterpriseInitialTeamConfig } from "../../../config/splitResultConfig";
import * as enterpriseData from "../../../data/enterprise/enterprise";
import * as initialTeamData from "../../../data/enterprise/initialTeam";
import { getInitialTeamMemberId } from "../../../tools/system";
import { BizError } from "../../../util/bizError";
import { checkChange, extractData } from "../../../util/piecemeal";
import { eccEnumValue } from "../../../util/verificationEnum";
import { eccFormParam } from "../../../util/verificationParam";
import { addEnterprisePoint } from "../../point";
/**
* 修改创始团队信息
* 修改 删除 添加 为一个接口 根据数据情况与老数据情况做匹配
* @param uscc 企业统一信用代码
* @param firstClassTalent 是否拥有国际一流人才
* @param teams 创始团队信息
* @returns isSuccess
*/
export async function updateInitialTeamInfo(uscc:string, firstClassTalent:number, teams) {
eccEnumValue("修改创始团队信息", "firstClassTalent", STATEENUM, firstClassTalent);
if (firstClassTalent==STATEENUM.未选) throw new BizError(ERRORENUM.请先选择是否拥有, '修改创始团队信息 没有选是和否');
/**校验参数 */
if ( (firstClassTalent==STATEENUM. && !Array.isArray(teams)) || (firstClassTalent==STATEENUM. && !teams.length) ) {
throw new BizError(ERRORENUM.参数错误, "修改创始团队信息", "缺少参数 teams");
}
if (!firstClassTalent) teams = [];
teams.forEach((info, index) => {
eccFormParam(`修改创始团队信息 下标:${index}`, InitialTeamUpdateConfig, info);
eccEnumValue('修改创始团队信息', 'type', ENTERPRISETEAM, info.type);
if (info.des.length > 200) throw new BizError(ERRORENUM.字数超过200限制, `修改创始团队信息 下标:${index}`);
});
//是否拥有国际人才这个字段在 企业表中 需要单独做更改
let enterpriseInfo = await enterpriseData.findEnterpriseByUscc(uscc);
let oldHaveFirstClassTalent = enterpriseInfo.haveFirstClassTalent;
enterpriseInfo.haveFirstClassTalent = firstClassTalent;
await enterpriseInfo.save();
let enterpriseInitialTeamList = await initialTeamData.findEnterpriseInitialTeam(uscc);
/**匹配数据操作逻辑 */
let newTeamIdList = [];//用于匹配新数据,老数据不在新数据中 判定为被删除
teams.forEach(info => {
if (info.id && info.id != "newdata") newTeamIdList.push(info.id);//todo
});
let deleteList = [];
//老数据将出现在这个map里 用于与新数据id匹配,匹配id不在老数据中判定为添加操作
let dataBaseTeamMap = {};
enterpriseInitialTeamList.forEach(info => {
dataBaseTeamMap[info.id] = info;
if (newTeamIdList.indexOf(info.id) == -1 ) {
deleteList.push(info);
}
});
let addList = [];
let updateList = [];
teams.forEach(info => {
let {id} = info;
let dataBaseInfo = dataBaseTeamMap[id];
if (!dataBaseInfo) {//不存在老的id 判定为添加操作
info.id = getInitialTeamMemberId(uscc, info.name);
info.uscc = uscc;
info.name = enterpriseInfo.name;
addList.push(info);
} else {
//比对新老数据判断数据需不需要修改
let changeList = checkChange(info, Object.assign({name:enterpriseInfo.name, uscc}, dataBaseInfo));
if (changeList.length) updateList.push(info);
}
});
/**修改数据 */
if (addList.length) await initialTeamData.addMoneyEnterpriseInitialTeam(addList);
if (updateList.length) await initialTeamData.updateManyEnterpriseInitialTeam(updateList);
if (deleteList.length) await initialTeamData.deleteManyEnterpriseInitialTeam(deleteList);
/**添加埋点 */
let oldPointData = {haveFirstClassTalent:oldHaveFirstClassTalent, teams:enterpriseInitialTeamList || [] };
let newPointData = {haveFirstClassTalent:firstClassTalent, teams};
addEnterprisePoint( uscc, ENTERPRISENODEENUM.创始团队, oldPointData, newPointData);
return {isSuccess:true};
}
/**
* 获取创始团队信息
* 回显
* @param uscc 企业统一信用代码
* @returns initialTeam 团队列表 firstClassTalent 是否拥有国际一流人才
*/
export async function selectInitialTeamInfo(uscc:string) {
let enterpriseInfo = await enterpriseData.findEnterpriseByUscc(uscc);
let firstClassTalent = enterpriseInfo.haveFirstClassTalent || STATEENUM.未选;
let initialTeamList = await initialTeamData.findEnterpriseInitialTeam(uscc);
let initialTeam = [];
initialTeamList.forEach(info => {
let changeData = extractData(EnterpriseInitialTeamConfig, info, false);
initialTeam.push(changeData);
});
return { initialTeam, firstClassTalent };
}
\ No newline at end of file
/**
* 知识产权主要逻辑
* 作者:lxm
*/
import { ENTERPRISENODEENUM, POINTTYPEENUM } from "../../../config/pointConfig";
import * as enterpriseData from "../../../data/enterprise/enterprise";
import { addEnterprisePoint } from "../../point";
/**
* 校验参数是否为空
* @param param 参数
* @returns true就是空
*/
function paramIsNull(param) {
if (!param) return true;
let isNull = false;
if (typeof param == "object") {
if (Array.isArray(param) ) isNull = param.length == 0;
else isNull = Object.keys(param).length == 0;
}
else isNull = !param;
return isNull;
}
/**
* 修改企业知识产权信息
* @param uscc 企业统一信用代码
* @param alienPatent 海外专利个数
* @param classIPatent 一类专利个数
* @param secondClassPatent 二类专利个数
* @returns isSuccess
*/
export async function updateIntellectualProperty(uscc:string, alienPatent:number, classIPatent:number, secondClassPatent:number) {
let enterpriseInfo = await enterpriseData.findEnterpriseByUscc(uscc);
if (enterpriseInfo.alienPatent != alienPatent) {
addEnterprisePoint( uscc, ENTERPRISENODEENUM.知识产权_海外专利, enterpriseInfo.alienPatent || 0, alienPatent);
}
if (enterpriseInfo.classIPatent != classIPatent) {
addEnterprisePoint( uscc, ENTERPRISENODEENUM.知识产权_一类专利, enterpriseInfo.classIPatent || 0, classIPatent);
}
if (enterpriseInfo.secondClassPatent != secondClassPatent) {
addEnterprisePoint( uscc, ENTERPRISENODEENUM.知识产权_二类专利, enterpriseInfo.secondClassPatent || 0, secondClassPatent);
}
enterpriseInfo.intellectualProperty = {alienPatent, classIPatent, secondClassPatent};
/**红框提示 */
if (!enterpriseInfo.tipsIntellectualProperty ) {
enterpriseInfo.tipsIntellectualProperty = true;
}
await enterpriseInfo.save();
return {isSuccess:true}
}
/**
* 查询企业专利信息
* 回显
* @param uscc 企业统一信用代码
* @returns
*/
export async function selectIntellectualProperty(uscc:string) {
let enterpriseInfo = await enterpriseData.findEnterpriseByUscc(uscc);
let intellectualProperty = {alienPatent:0, classIPatent:0, secondClassPatent:0};
if (!paramIsNull(enterpriseInfo.intellectualProperty)) {
intellectualProperty = enterpriseInfo.intellectualProperty;
}
return intellectualProperty;
}
/**
* 企业资质 相关逻辑
* 作者:lxm
*/
import { EnterpriseQualificationUpdateConfig } from "../../../config//eccParam/enterprise";
import { LISTINGSITUATION } from "../../../config/enum";
import { ERRORENUM } from "../../../config/errorEnum";
import { BizError } from "../../../util/bizError";
import { eccEnumValue } from "../../../util/verificationEnum";
import { eccFormParam } from "../../../util/verificationParam";
import * as enterpriseData from "../../../data/enterprise/enterprise";
import { addEnterprisePoint } from "../../point";
import { ENTERPRISENODEENUM } from "../../../config/pointConfig";
import { enterpriseLabelEvent } from "../../label";
import { LABELEVENT } from "../../../config/enum/labelEnum";
/**
* 获取企业资质信息
* @param uscc 企业统一信用代码
* @returns
*/
export async function selectQualification(uscc:string) {
let enterpriseInfo = await enterpriseData.findEnterpriseByUscc(uscc);
let defaultQualification = {
isHighTech:false,//是否是高新技术企业
highTechMs:0,//高新技术认证时间戳
isZjtx:false,//是否专精特新企业
zjtxMs:0,//专精特新认证时间戳
isXjrpy:false,//是否小巨人培育企业
xjrpyMs:0,//小巨人培育企业时间戳
isXjr:false,//是否是小巨人企业
xjrMs:0,//小巨人企业认证时间
beOnTheMarket:[],//上市情况
isBeOnTheMarket:false
};
return enterpriseInfo.qualification || defaultQualification;
}
/**
* 修改企业资质
* @param uscc 企业统一信用代码
* @returns
*/
export async function updateQualification(uscc:string, param) {
eccFormParam("修改企业资质", EnterpriseQualificationUpdateConfig, param);
if (param.isBeOnTheMarket) {
if (!param.beOnTheMarket.length) throw new BizError(ERRORENUM.参数错误, '修改企业资质', '缺失 beOnTheMarket ')
eccEnumValue("修改企业资质", "beOnTheMarket", LISTINGSITUATION, param.beOnTheMarket );
} else param.beOnTheMarket = [];
let enterpriseInfo = await enterpriseData.findEnterpriseByUscc(uscc);
/**埋点 */
let oldQualification = enterpriseInfo.qualification || {};
let oldHighTechData = {highTechMs:oldQualification.highTechMs, isHighTech:oldQualification.isHighTech};
let newHighTechData = {highTechMs:param.highTechMs, isHighTech:param.isHighTech};
addEnterprisePoint( uscc, ENTERPRISENODEENUM.企业资质_高新技术,oldHighTechData, newHighTechData );
let oldIsZjtxData = {isZjtx:oldQualification.isZjtx, zjtxMs:oldQualification.zjtxMs};
let newIsZjtxData = {isZjtx:param.isZjtx, zjtxMs:param.zjtxMs};
addEnterprisePoint( uscc, ENTERPRISENODEENUM.企业资质_专精特新,oldIsZjtxData, newIsZjtxData );
let oldIsXjrpyData = {isXjrpy:oldQualification.isXjrpy, xjrpyMs:oldQualification.xjrpyMs};
let newIsXjrpyData = {isXjrpy:param.isXjrpy, xjrpyMs:param.xjrpyMs};
addEnterprisePoint( uscc, ENTERPRISENODEENUM.企业资质_小巨人培育,oldIsXjrpyData, newIsXjrpyData );
let oldIsXjrData = {isXjr:oldQualification.isXjr, xjrMs:oldQualification.xjrMs};
let newIsXjrData = {isXjr:param.isXjr, xjrMs:param.xjrMs};
addEnterprisePoint( uscc, ENTERPRISENODEENUM.企业资质_小巨人,oldIsXjrData, newIsXjrData );
let oldMarketData = {
beOnTheMarket:oldQualification.beOnTheMarket ? JSON.stringify(oldQualification.beOnTheMarket) : '[]',
isBeOnTheMarket:oldQualification.isBeOnTheMarket
};
let newMarketData = {
beOnTheMarket:param.beOnTheMarket ? JSON.stringify(param.beOnTheMarket) : '[]',
isBeOnTheMarket:param.isBeOnTheMarket
};
addEnterprisePoint(uscc, ENTERPRISENODEENUM.企业资质_上市情况,oldMarketData, newMarketData );
enterpriseInfo.qualification = JSON.parse(JSON.stringify(param) );
/**标签 */
await enterpriseLabelEvent(enterpriseInfo, LABELEVENT.资质更新, '企业登记');
/**修改了之后去掉 红框提示 */
if (!enterpriseInfo.tipsQualification ) {
enterpriseInfo.tipsQualification = true;
}
await enterpriseInfo.save();
return {isSuccess:true};
}
/**
* 企业融资情况
* 作者:lxm
*/
import * as eccFormParamConfig from "../../config/eccParam/enterprise";
import { FINANCINGROUNDS, FUHUAQILNVESTMENTSTYLE } from "../../config/enum";
import { LABELEVENT } from "../../config/enum/labelEnum";
import { ERRORENUM } from "../../config/errorEnum";
import { EnterpriseFinancingListDataConfig } from "../../config/splitResultConfig";
import { findEnterpriseByUscc } from "../../data/enterprise/enterprise";
import * as enterpriseFinancingData from "../../data/enterprise/financingInfo";
import { getFinancingId } from "../../tools/system";
import { BizError } from "../../util/bizError";
import { checkChange, extractData } from "../../util/piecemeal";
import { changeEnumValue, eccEnumValue } from "../../util/verificationEnum";
import { eccFormParam } from "../../util/verificationParam";
import { enterpriseLabelEvent } from "../label";
/**
* 获取企业融资情况信息列表
* @param uscc 企业统一信用代码
*/
export async function getEnterpriseFinancingList(uscc:string) {
let financingList = await enterpriseFinancingData.selectFinancingListByUscc(uscc);
let resultList = [];
financingList.forEach(info => {
let updateInfo = extractData(EnterpriseFinancingListDataConfig, info, false);
resultList.push(updateInfo);
});
let enterpriseInfo = await findEnterpriseByUscc(uscc);
if (!enterpriseInfo.tipsFinancingInfo ) {
enterpriseInfo.tipsFinancingInfo = true;
await enterpriseInfo.save();
}
return { dataList:resultList };
}
/**
* 添加融资信息
* @param uscc 企业统一信用代码
* @param form 表单
* @returns
*/
export async function addEnterpriseFinancing(uscc:string, form) {
eccFormParam("企业录入企业融资信息", eccFormParamConfig.EnterpriseCreateFinancingDataConfig, form);
eccEnumValue( "录入企业融资信息", "financingRounds", FINANCINGROUNDS, form.financingRounds);
if (form.fuHuaQiInvestment) {
/**如果当孵化器是否投资填了true 则校验 fuHuaQiInvestmentAmount, fuHuaQiInvestmentStyle 两个字段 */
let subCheckName = "录入企业融资信息_孵化器是否参与";
let subCheckData = {
fuHuaQiInvestmentAmount:form.fuHuaQiInvestmentAmount,
fuHuaQiInvestmentStyle:form.fuHuaQiInvestmentStyle,
};
eccFormParam(subCheckName, eccFormParamConfig.EnterpriseCreateFinancingParamSubConfig, subCheckData);
/**校验投资方式是否符合枚举规则 */
eccEnumValue("添加企业融资信息", "fuHuaQiInvestmentStyle", FUHUAQILNVESTMENTSTYLE, form.fuHuaQiInvestmentStyle);
} else {
/**如果 没有填这里给默认数据*/
form.fuHuaQiInvestmentAmount = 0;
form.fuHuaQiInvestmentStyle = 0;
}
let enterpriseInfo = await findEnterpriseByUscc(uscc);
let addInfo:any = {
id:getFinancingId(uscc), uscc, name:enterpriseInfo.name, createTime:new Date().valueOf(), type:2
};
await enterpriseFinancingData.addFinancingInfo(Object.assign(addInfo, form));
//添加标签
let financingRoundsStr = changeEnumValue(FINANCINGROUNDS, form.financingRounds);
await enterpriseLabelEvent(enterpriseInfo, LABELEVENT.融资, financingRoundsStr, form.financingAmount);
await enterpriseInfo.save();
return {isSuccess:true};
}
/**
* 获取 企业融资情况
* 回显
* @param uscc 企业统一信用代码
* @param id 融资数据标识
*/
export async function getEnterpriseFinancingInfo(uscc:string, id:string) {
let financingInfo = await enterpriseFinancingData.getFinancingById(id);
if (!financingInfo) throw new BizError(ERRORENUM.参数错误, `获取企业融资情况 id在库里找不到`);
if ( financingInfo.uscc != uscc ) throw new BizError(ERRORENUM.只能修改本企业信息, `${uscc} 想修改 ${id}`);
let updateInfo = extractData(EnterpriseFinancingListDataConfig, financingInfo, false);
return updateInfo;
}
/**
* 修改企业融资数据
* @param uscc 企业统一信用代码
* @param form 表单
* @returns
*/
export async function updateEnterpriseFinancingInfo(uscc:string, form) {
eccFormParam("企业修改企业融资信息", eccFormParamConfig.EnterpriseUpdateFinancingDataConfig, form);
eccEnumValue( "录入企业融资信息", "financingRounds", FINANCINGROUNDS, form.financingRounds);
if (form.fuHuaQiInvestment) {
/**如果当孵化器是否投资填了true 则校验 fuHuaQiInvestmentAmount, fuHuaQiInvestmentStyle 两个字段 */
let subCheckName = "录入企业融资信息_孵化器是否参与";
let subCheckData = {
fuHuaQiInvestmentAmount:form.fuHuaQiInvestmentAmount,
fuHuaQiInvestmentStyle:form.fuHuaQiInvestmentStyle,
};
eccFormParam(subCheckName, eccFormParamConfig.EnterpriseCreateFinancingParamSubConfig, subCheckData);
/**校验投资方式是否符合枚举规则 */
eccEnumValue("添加企业融资信息", "fuHuaQiInvestmentStyle", FUHUAQILNVESTMENTSTYLE, form.fuHuaQiInvestmentStyle);
} else {
/**如果 没有填这里给默认数据*/
form.fuHuaQiInvestmentAmount = 0;
form.fuHuaQiInvestmentStyle = 0;
}
let financingInfo = await enterpriseFinancingData.getFinancingById(form.id);
if (!financingInfo) throw new BizError(ERRORENUM.参数错误, `修改企业信息的时候 id在库里找不到`);
if ( financingInfo.uscc != uscc ) throw new BizError(ERRORENUM.只能修改本企业信息, `${uscc} 想修改 ${form.id}`);
let changeList = checkChange(form, financingInfo);
if ( !changeList.length ) throw new BizError(ERRORENUM.数据无更新, `企业更新融资数据`, `${form.id}数据无更新`);
changeList.forEach(key => {
if (key != "id") {
financingInfo[key] = form[key];
}
});
await financingInfo.save();
return {isSuccess:true};
}
/**
* 删除企业融资数据
* @param uscc 企业统一信用代码
* @param id 唯一标识
* @returns
*/
export async function deleteEnterpriseFinancingInfo(uscc:string, id:string) {
let financingInfo = await enterpriseFinancingData.getFinancingById(id);
if (!financingInfo) throw new BizError(ERRORENUM.参数错误, `获取企业融资情况 id在库里找不到`);
if ( financingInfo.uscc != uscc ) throw new BizError(ERRORENUM.只能删除本企业信息, `${uscc} 想修改 ${id}`);
await enterpriseFinancingData.deleteFinancingById(id);
return {isSuccess:true};
}
\ No newline at end of file
/**
* 政策速递 企业端
*/
import moment = require("moment");
import * as informationDat from "../../data/guanWeiHui/information";
import { addEnterprisePoint } from "../point";
import { ENTERPRISENODEENUM } from "../../config/pointConfig";
/**
* 获取资讯列表
*
* @param uscc 预留好 后期做推荐的参数
* @param selectTitle
* @param page 分页
* @returns
*/
export async function getInformationList(uscc:string, selectTitle:string, page:number) {
let selectParam = {state:true, "$or":[{closeTimeMs: {"$gt":new Date().valueOf()} }, {isPermanent:true}] };
if (selectTitle) {
selectParam["title"] = {"$regex":`${selectTitle}`};
}
let informationList = await informationDat.selectInformationByParamToPage(selectParam, (page-1) * 10 );
let count = await informationDat.selectInformationByParamCount(selectParam);
let pageCount = count ? Math.ceil(count/10) : 0;
let dataList = [];
informationList.forEach((info) => {
let { id, title,createTimeMs, source, coverImg } = info;
dataList.push({title, id, createTime:moment(createTimeMs).format("MM/DD"),source, url:`/policy/${coverImg}`});
});
return {dataList, count, pageCount};
}
/**
* 获取过期资讯列表
*
* @param uscc 预留好 后期做推荐的参数
* @param selectTitle 模糊查询标题
* @param page 分页
* @returns
*/
export async function getOutOfDateInformationList(uscc:string, selectTitle:string, page:number) {
let selectParam = {"$or":[{closeTimeMs: {"$lt":new Date().valueOf()} }, {state:false}] };
if (selectTitle) {
selectParam["title"] = {"$regex":`${selectTitle}`};
}
let informationList = await informationDat.selectInformationByParamToPage(selectParam, (page-1) * 10 );
let count = await informationDat.selectInformationByParamCount(selectParam);
let pageCount = count ? Math.ceil(count/10) : 0;
let dataList = [];
informationList.forEach((info) => {
let { id, title,createTimeMs, source, coverImg } = info;
dataList.push({title, id, createTime:moment(createTimeMs).format("MM/DD"), source, url:`/policy/${coverImg}`});
});
return {dataList, count, pageCount};
}
/**
* 获取资讯详情
* @param uscc
* @param id 标识
*/
export async function getOnceinformation(uscc:string, id:string) {
let dateBaseData = await informationDat.selectInformationDataById(id );
let reuslt = {
title:dateBaseData.title,
desc:dateBaseData.desc,
source:dateBaseData.source,
createTime:moment(dateBaseData.createTimeMs).format("MM/DD")
};
addEnterprisePoint( uscc, ENTERPRISENODEENUM.政策速递, id);
return {infomation:reuslt};
}
/**
* 企业资讯列表 (首页)
* @returns
*/
export async function getInformationTitleList() {
let selectParam = {state:true, "$or":[{closeTimeMs: {"$gt":new Date().valueOf()} }, {isPermanent:true}] };
let informationData = await informationDat.selectOnceInformationByParamToParam(selectParam) || {title:""};;
return {title:informationData.title};
}
\ No newline at end of file
/**
* 企业经营数据相关
* 作者:lxm
* 说明: 首页经营数据 经营数据补充
* 备注: 填报的经营数据在 填报逻辑 里
*/
import moment = require("moment");
import { findBusinessDataByUsccAndYear } from "../../../data/enterprise/quarterTask/businessdata";
import { eccEnumValue } from "../../../util/verificationEnum";
import { BUSINESSDATATYPE } from "../../../config/enum";
import * as replenishData from "../../../data/enterprise/replenish";
import { addEnterprisePoint } from "../../point";
import { ENTERPRISENODEENUM, POINTTYPEENUM } from "../../../config/pointConfig";
/**
* 获取经营数据
* @param uscc 企业统一信用代码
*/
export async function getBusinessData(uscc:string) {
let lastYear = moment().subtract(1, 'years').year();
let thisYear = new Date().getFullYear();
let thisYearData = await findBusinessDataByUsccAndYear(uscc, thisYear);
let thisBusinessData = {RD:0, BI:0, TXP:0};
thisYearData.forEach(info => {
for (let key in thisBusinessData) {
thisBusinessData[key] += info[key] || 0;
}
});
let result = {};
for (let key in thisBusinessData) {
let {unit, count} = countUnitData(thisBusinessData[key]);
result[`this${key}`] = {unit, count }
}
/**找缺失 要求是:缺一个季度就要爆红 只要提交了,就算是0也不算是缺失的数据 */
let deletionMap = {RD:0, BI:0, TXP:0};
let lastYearData = await findBusinessDataByUsccAndYear(uscc, lastYear);
let lastBusinessData = {RD:0, BI:0, TXP:0};
lastYearData.forEach(info => {
for (let key in lastBusinessData) {
lastBusinessData[key] += info[key] || 0;
deletionMap[key] += 1;
}
});
let lastYearRepleishData = await replenishData.selectRepleishData(uscc, lastYear);
lastYearRepleishData.forEach(info => {
if (info.type == BUSINESSDATATYPE.研发投入) {
lastBusinessData.RD += info.value;
deletionMap["RD"] += 1;
}
if (info.type == BUSINESSDATATYPE.纳税) {
lastBusinessData.TXP += info.value;
deletionMap["TXP"] += 1;
}
if (info.type == BUSINESSDATATYPE.营业收入) {
lastBusinessData.BI += info.value;
deletionMap["BI"] += 1;
}
});
for (let key in lastBusinessData) {
let {unit, count} = countUnitData(lastBusinessData[key]);
let deletion = deletionMap[key] <4;
result[`last${key}`] = {unit, count, deletion}
}
return result;
}
/**
* 获取格式 将金额数据转换为金额加单位
* 单位为:元 万元 根据长度自动转换
* 超过千万 单位为万 否则单位为元
* @param data
* @returns
*/
function countUnitData(data:number) {
if (!data) return {unit:"元", count:0};
if (data/10000000 < 10) {
return {
unit:"元",
count:Math.floor(data)
}
}
return {
unit:"万元",
count:Math.floor(data/10000)
}
}
/**
* 补录经营数据
* @param uscc 统一信用代码
* @param quarter 补录季度
* @param type 补录类型
* @param value 值
*/
export async function replenishBusinessData(uscc:string, type:number, data) {
eccEnumValue("补录经营数据", "type", BUSINESSDATATYPE, type);
let lastYear = parseInt( moment().subtract(1, 'year').format("YYYY") );
/**获取去年正常填报数据 */
let resultData = [0,0,0,0];
let lastYearData = await findBusinessDataByUsccAndYear(uscc, lastYear);
lastYearData.forEach(info => {
let addIndex = info.quarter - 1;
if (type == BUSINESSDATATYPE.研发投入) resultData[addIndex] += info.RD;
if (type == BUSINESSDATATYPE.纳税) resultData[addIndex] += info.TXP;
if (type == BUSINESSDATATYPE.营业收入) resultData[addIndex] += info.BI;
});
/**获取上一年度补录 */
let lastYearReplenishData = await replenishData.findRepleishDataByTypeAndYear(uscc, type, lastYear);
lastYearReplenishData.forEach(info => {
let addIndex = info.quarter - 1;
resultData[addIndex] += info.value;
});
let checkMap = {};
data.forEach((val, index) => {
if (index >= 4) return;
if (resultData[index] == 0) {
checkMap[index+1] = val;
}
});
for (let key in checkMap) {
let quarter = parseInt(key);
let value = checkMap[key];
await replenishData.replenishData(uscc, lastYear, quarter, type, value);
}
/**加入埋点 */
if (Object.keys(checkMap).length ) {
let pointId;
if (type == BUSINESSDATATYPE.研发投入) pointId = ENTERPRISENODEENUM.经营数据补录_研发投入;
if (type == BUSINESSDATATYPE.纳税) pointId = ENTERPRISENODEENUM.经营数据补录_纳税;
if (type == BUSINESSDATATYPE.营业收入) pointId = ENTERPRISENODEENUM.经营数据补录_营业收入;
addEnterprisePoint( uscc, pointId, checkMap);
}
return {isSuccess:true};
}
/**
* 根据类型上一年度经营数据
* @param uscc 统一信用代码
*/
export async function lastYearBusinessData(uscc:string, type:number) {
eccEnumValue("补录经营数据", "type", BUSINESSDATATYPE, type);
let lastYear = parseInt( moment().subtract(1, 'year').format("YYYY") );
let lastYearData = await findBusinessDataByUsccAndYear(uscc, lastYear);
let resultData = [0,0,0,0];
lastYearData.forEach(info => {
let addIndex = info.quarter - 1;
if (type == BUSINESSDATATYPE.研发投入) resultData[addIndex] += info.RD;
if (type == BUSINESSDATATYPE.纳税) resultData[addIndex] += info.TXP;
if (type == BUSINESSDATATYPE.营业收入) resultData[addIndex] += info.BI;
});
/**获取上一年度补录 */
let lastYearReplenishData = await replenishData.findRepleishDataByTypeAndYear(uscc, type, lastYear);
lastYearReplenishData.forEach(info => {
let addIndex = info.quarter - 1;
resultData[addIndex] += info.value;
});
return {dataList:resultData};
}
\ No newline at end of file
/**
* 小程序端 企业角色用户 逻辑
* 作者:lxm
* 3.0更新功能
*/
import { ERRORENUM } from "../../config/errorEnum";
import * as sysTools from "../../tools/system";
import { BizError } from "../../util/bizError";
import * as enterpriseData from "../../data/enterprise/enterprise";
import moment = require("moment");
import * as codeData from "../../data/fuHuaQi/code";
import { sendChangePwdCode } from "../sms";
import { CODETYPE } from "../../config/enum";
/**
* 企业登录
* @param uscc 企业统一信用代码
* @param pwd
*/
export async function enterpriseLogin(uscc:string, pwd:string) {
if (!sysTools.eccUscc(uscc)) throw new BizError(ERRORENUM.统一社会信用代码不合法, '孵化器登录时');
let enterpriseInfo = await enterpriseData.findEnterpriseByUscc(uscc);
if (!enterpriseInfo) throw new BizError(ERRORENUM.账号不存在);
if ( moment(enterpriseInfo.createTime).format("YYYY-MM") == moment().format("YYYY-MM") ) {
throw new BizError(ERRORENUM.企业审批中请下个自然月登录);
}
let checkPwd = sysTools.getPwdMd5(enterpriseInfo.uscc, pwd);
if (enterpriseInfo.pwd != checkPwd) throw new BizError(ERRORENUM.密码错误);
const Token = sysTools.getToken(uscc);
let userInfo = {
uscc: enterpriseInfo.uscc,
// name: fuhuaqiInfo.name,
firstLogin : !enterpriseInfo.firstLoginIsChangePwd,
token:Token
};
enterpriseInfo.token = Token;
enterpriseInfo.tokenMs = new Date().valueOf();
await enterpriseInfo.save();
return userInfo;
}
/**
* 首次登录修改密码
* @param uscc 企业统一信用代码
* @param pwd 密码
* @param confirmPwd 确认密码
*/
export async function firstChangePwd(uscc:string, pwd:string, confirmPwd:string) {
if (pwd != confirmPwd) throw new BizError(ERRORENUM.密码不一致);
if (pwd.search(/^[A-Za-z0-9]{6,18}$/) < 0) throw new BizError(ERRORENUM.密码只能由618位字符和数字组成);
let dataBaseInfo = await enterpriseData.findEnterpriseByUscc(uscc);
if (dataBaseInfo.firstLoginIsChangePwd) throw new BizError(ERRORENUM.不能重复修改密码, `企业端 重复调用了首次登录之后的修改密码接口${uscc}`);
dataBaseInfo.pwd = sysTools.getPwdMd5(uscc, sysTools.md5PwdStr(pwd));
dataBaseInfo.firstLoginIsChangePwd = true;
await dataBaseInfo.save();
return {isSuccess:true};
}
/**
* 找回密码
* @param phone 负责人电话号码 如果和库里的对不上 就要报错
* @param uscc 企业统一信用代码
* @param code 验证码
* @param pwd 密码
* @param confirmPwd 确认密码
*/
export async function resettingPwd(phone:string, uscc:string, code:string, pwd:string, confirmPwd:string) {
if (!sysTools.eccUscc(uscc)) throw new BizError(ERRORENUM.统一社会信用代码不合法, '重置密码时');
let enterpriseInfo = await enterpriseData.findEnterpriseByUscc(uscc);
if (!enterpriseInfo) throw new BizError(ERRORENUM.账号不存在, `重置密码时 uscc:${uscc}`);
if (!enterpriseInfo.securePhon) throw new BizError(ERRORENUM.未填安全手机号无法修改密码, '企业-修改密码发验证码时-没有安全手机号');
if ( phone != enterpriseInfo.securePhon) throw new BizError(ERRORENUM.号码与主体不一致, '企业-修改密码发验证码时');
if (pwd != confirmPwd) throw new BizError(ERRORENUM.密码不一致);
if (pwd.search(/^[A-Za-z0-9]{6,18}$/) < 0) throw new BizError(ERRORENUM.密码只能由618位字符和数字组成);
let todayMs = sysTools.getTodayMs();
let codeList = await codeData.findTodayCodeByUscc(uscc, todayMs);
let now = new Date().valueOf();
let codeId = '';
let msg = ERRORENUM.验证码错误;
codeList.forEach(info => {
if (info.code == code) {
if (info.isUse) msg = ERRORENUM.验证码失效;
else if ( (now - info.sendMs) > (30 * 60 * 1000) ) msg = ERRORENUM.验证码过期
else codeId = info.id;
}
});
if (!codeId) throw new BizError(msg, `uscc:${uscc}重置密码的code:${code}`);
await codeData.updateCodeState(codeId);
enterpriseInfo.pwd = sysTools.getPwdMd5(uscc, sysTools.md5PwdStr(pwd));
await enterpriseInfo.save();
return {isSuccess:true};
}
/**
* 发送修改密码的短信验证码
* @param uscc 企业统一信用代码
*/
export async function changePwdSendCode(uscc:string, phone:string) {
if (!sysTools.eccUscc(uscc)) throw new BizError(ERRORENUM.统一社会信用代码不合法, '重置密码时');
let enterpriseInfo = await enterpriseData.findEnterpriseByUscc(uscc);
if (!enterpriseInfo) throw new BizError(ERRORENUM.账号不存在, `企业-发送验证码时 uscc:${uscc}`);
if (!enterpriseInfo.securePhon) throw new BizError(ERRORENUM.未填安全手机号无法修改密码, '企业-修改密码发验证码时-没有安全手机号');
if ( phone != enterpriseInfo.securePhon) throw new BizError(ERRORENUM.号码与主体不一致, '企业-修改密码发验证码时');
let todayMs = sysTools.getTodayMs();
let todayCodeList = await codeData.findTodayCodeByUscc(uscc, todayMs);
if (todayCodeList.length >= 4) throw new BizError(ERRORENUM.发送验证码次数超限制, `${uscc} 修改密码发送验证码次数超限制4`);
let sendMs = todayMs;
todayCodeList.forEach(info => {
sendMs = Math.max(sendMs, info.sendMs);
});
let now = new Date().valueOf();
if ((now - sendMs) <= (60 * 1000) ) throw new BizError(ERRORENUM.发送验证码频率过快, `${uscc}`);
let codeId = sysTools.getSMSCodeId(uscc, todayCodeList.length);
let code = sysTools.getSMSCode();
await sendChangePwdCode(phone, code);
now = new Date().valueOf();
await codeData.createCode(uscc, codeId, code, CODETYPE.修改密码, now);
return {
isSuccess:true,
sendMs:now
};
}
export async function getFirstUpdatePwdState(uscc:string) {
let enterpriseInfo = await enterpriseData.findEnterpriseByUscc(uscc);
return {firstLogin : !enterpriseInfo.firstLoginIsChangePwd,};
}
\ No newline at end of file
/**
* 小程序端 孵化器入口 企业融资相关逻辑
* 作者: lxm
* 包括新融资信息的增删改查
*
*/
import * as eccFormParamConfig from "../../../config/eccParam/fuHuaQi";
import { ERRORENUM } from "../../../config/errorEnum";
import * as financingData from "../../../data/fuHuaQi/monthTask/financing";
import * as splitResultConfig from "../../../config/splitResultConfig";
import { BizError } from "../../../util/bizError";
import * as taskTool from "../../../tools/taskTool";
import * as enterpriseData from "../../../data/enterprise/enterprise";
import * as configEnum from "../../../config/enum";
import { eccFormParam } from "../../../util/verificationParam";
import { eccEnumValue } from "../../../util/verificationEnum";
import { checkChange, extractData } from "../../../util/piecemeal";
/**
* 添加企业融资信息
* 小程序端
* @param uscc 孵化器统一信用代码
* @param param 表单配置
* @returns {isSuccess:true/false}
*/
export async function createFinancingInfo(uscc:string, param) {
/**校验表单参数*/
eccFormParam("录入企业融资信息", eccFormParamConfig.FinancingParamConfig, param);
eccEnumValue( "录入企业融资信息", "financingRounds", configEnum.FINANCINGROUNDS, param.financingRounds);
if (param.fuHuaQiInvestment) {
/**如果当孵化器是否投资填了true 则校验 fuHuaQiInvestmentAmount, fuHuaQiInvestmentStyle 两个字段 */
let subCheckName = "录入企业融资信息_孵化器是否参与";
let subCheckData = {
fuHuaQiInvestmentAmount:param.fuHuaQiInvestmentAmount,
fuHuaQiInvestmentStyle:param.fuHuaQiInvestmentStyle,
};
eccFormParam(subCheckName, eccFormParamConfig.FinancingParamSubConfig, subCheckData);
/**校验投资方式是否符合枚举规则 */
eccEnumValue("添加企业融资信息", "fuHuaQiInvestmentStyle", configEnum.FUHUAQILNVESTMENTSTYLE, param.fuHuaQiInvestmentStyle);
} else {
/**如果 没有填这里给默认数据*/
param.fuHuaQiInvestmentAmount = 0;
param.fuHuaQiInvestmentStyle = 0;
}
/**校验企业是否存在 */
let enterpriseInfo = await enterpriseData.findEnterpriseInfoByName(param.name);
if (!enterpriseInfo) throw new BizError(ERRORENUM.该企业不存在, uscc, param.name);
/** 前端无需传入企业的uscc 库中需要企业的uscc*/
param.uscc = enterpriseInfo.uscc;//
const TaskId = taskTool.getTaskId(uscc);
/**一个企业一个月只能填报一次融资信息 */
let dataBaseInfo = await financingData.findFinancingInfoByTaskIdAndSucc(TaskId, param.uscc);
if ( dataBaseInfo&& dataBaseInfo.uscc) throw new BizError(ERRORENUM.该企业当月数据已存在, `${param.uscc}的融资信息已经存在`);
await financingData.createFinancing(uscc, TaskId, enterpriseInfo.uscc, enterpriseInfo.logonTime,enterpriseInfo.industry || [], param);
return {isSuccess:true};
}
/**
* 更新企业融资信息
* 小程序端
* 只能更新本月未提交的并且已经创建的企业融资信息
* @param uscc 孵化器统一信用代码
* @param param 表单配置
* @returns {isSuccess:true/false}
*/
export async function updateFinancingInfo(uscc:string, param) {
/**校验表单参数 */
eccFormParam( "更新融资企业信息", eccFormParamConfig.FinancingParamUpdateConfig, param );
if (param.fuHuaQiInvestment) {
/**如果当孵化器是否投资填了true 则校验 fuHuaQiInvestmentAmount, fuHuaQiInvestmentStyle 两个字段 */
let subCheckName = "录入企业融资信息_孵化器是否参与";
let subCheckData = {
fuHuaQiInvestmentAmount:param.fuHuaQiInvestmentAmount,
fuHuaQiInvestmentStyle:param.fuHuaQiInvestmentStyle,
};
eccFormParam(subCheckName, eccFormParamConfig.FinancingParamSubConfig, subCheckData);
/**校验投资方式是否符合枚举规则 */
eccEnumValue("修改企业融资信息", "fuHuaQiInvestmentStyle", configEnum.FUHUAQILNVESTMENTSTYLE, param.fuHuaQiInvestmentStyle);
} else {
/**如果 没有填这里给默认数据*/
param.fuHuaQiInvestmentAmount = 0;
param.fuHuaQiInvestmentStyle = 0;
}
/**找到该企业的本月融资数据 */
const TaskId = taskTool.getTaskId(uscc);
let dataBaseInfo = await financingData.findFinancingInfoByTaskIdAndSucc(TaskId, param.uscc);
if (!dataBaseInfo || !dataBaseInfo.uscc) throw new BizError(ERRORENUM.未找到数据, `库中不存在${TaskId}的任务`);
/**匹配修改 */
let changeList = checkChange(param, dataBaseInfo);
if ( !changeList.length ) throw new BizError(ERRORENUM.数据无更新, `${param.uscc}数据无更新`);
changeList.forEach(key => {
dataBaseInfo[key] = param[key];
});
await dataBaseInfo.save();
return {isSuccess:true};
}
/**
* 查询本月提交的企业融资信息
* 小程序端 回显
* @param fuHuaQiUscc 孵化器统一信用代码
* @param uscc 企业统一信用代码
* @returns {data:{}} 表单
*/
export async function getEnterpriseFinancingByUscc(fuHuaQiUscc:string, uscc:string) {
/**找到该企业的本月融资数据 */
const TaskId = taskTool.getTaskId(fuHuaQiUscc);
let dataBaseInfo = await financingData.findFinancingInfoByTaskIdAndSucc(TaskId, uscc);
if (!dataBaseInfo || !dataBaseInfo.uscc) throw new BizError(ERRORENUM.未找到数据, `库中不存在${uscc}这个企业的本次融资数据`);
/**截取返回字段 */
let data = extractData(splitResultConfig.EnterpriseFinancingInfoConfig, dataBaseInfo, false);
return {data};
}
/**
* 根据企业id删除草稿企业
* 小程序端
* @param fuHuaQiUscc 孵化器统一信用代码
* @param uscc 企业统一信用代码
* @returns {isSuccess:true/false}
*/
export async function deleteEnterpriseFinancingByUscc(fuHuaQiUscc:string, uscc:string) {
/**找到该企业的本月融资数据 */
const TaskId = taskTool.getTaskId(fuHuaQiUscc);
let dataBaseInfo = await financingData.findFinancingInfoByTaskIdAndSucc(TaskId, uscc);
if (!dataBaseInfo || !dataBaseInfo.uscc) throw new BizError(ERRORENUM.未找到数据, `库中不存在${uscc}这个企业`);
/**删除限制 */
if (dataBaseInfo.draftLock) throw new BizError(ERRORENUM.已入库的数据不能删除, uscc);
await financingData.deleteEnterpriseFinancing(uscc, TaskId);
return {isSuccess:true};
}
/**
* 获取本孵化器下的所有企业信息
* 小程序端 用于下拉框使用
* @param uscc 孵化器统一信用代码
* @returns [] name:企业名称, logonAdd:注册地址, operatingAdd:经营地址
*/
export async function getFuHuaQiEnterpriseForSelect(uscc:string) {
/**找到该孵化器下已经提交入库的企业列表 */
let enterpriseList = await enterpriseData.findSubmittedEnterpriseListByFuHuaQiUscc(uscc);
/**拼接返回 */
let dataList = [];
enterpriseList.forEach( info => {
if (info.state != configEnum.FUHUASTATE.迁出) {
dataList.push({
name:info.name,
logonAddress:info.logonAddress,
operatingAddress:info.operatingAddress
});
}
});
return dataList;
}
/**
* 小程序端 孵化器入口 审核相关
* 作者: lxm
*
*/
import * as businessData from "../../../data/enterprise/quarterTask/businessdata";
import { ENTERPRISEDECLARATIONTYPE } from "../../../config/enum";
import * as teamData from "../../../data/enterprise/quarterTask/team";
import { eccEnumValue } from "../../../util/verificationEnum";
import { eccFormParam } from "../../../util/verificationParam";
import * as eccFormParamConfig from "../../../config/eccParam/fuHuaQi";
import { BizError } from "../../../util/bizError";
import { ERRORENUM } from "../../../config/errorEnum";
function getCycle(cycleNumber:number) {
if (!cycleNumber) return "-";
let nameList = ["一", "二", "三", "四"];
return `第${nameList[cycleNumber-1]}季度`;
}
/**
* 待审核列表
* @param uscc 孵化器统一信用代码
*/
export async function unauditedList(uscc:string, state:number, type:number ) {
let query:any = {fhqIsSubmit:false, fuHuaQiUscc:uscc};
if (state == 2) { //已填报
query.isSubmit = true;
} else if (state == 3) { //未填报
query.isSubmit = false;
}
let dataNumberLists = [
{
"key":1,//枚举值
"value":`全部(0)`//按钮文本
},
{
"key":2,//枚举值
"value":`已填报(0)`//按钮文本
},
{
"key":3,//枚举值
"value":`未填报(0)`//按钮文本
},
];
return {dataNumberList:dataNumberLists, dataList:[]};
let businessDataList = [];
let teamDataList = [];
if (type == 2) {
businessDataList = await businessData.findBusinessDataByParams(query);
} else if (type == 3) {
teamDataList = await teamData.findTeamDataByParams(query);
} else {
businessDataList = await businessData.findBusinessDataByParams(query);
teamDataList = await teamData.findTeamDataByParams(query);
}
let dataList = [];
businessDataList.forEach(info => {
let { name, quarter, isSubmit, year, isUpdate } = info;
dataList.push({
name,
uscc:info.uscc,
typeStr:"经营状况",
type:ENTERPRISEDECLARATIONTYPE.经营状况,
cycle:getCycle(quarter),
quarter,
year,
enterpriseSubmit:isSubmit ? "是" : "否",
isUpdate:isUpdate
});
});
teamDataList.forEach(info => {
let { name, quarter, isSubmit, year, isUpdate } = info;
dataList.push({
name,
uscc:info.uscc,
typeStr:"团队信息",
type:ENTERPRISEDECLARATIONTYPE.团队信息,
cycle:getCycle(quarter),
quarter,
year,
enterpriseSubmit:isSubmit ? "是" : "否",
isUpdate:isUpdate
});
});
/**组合dataNumberList */
let businessSubmitCount = await businessData.findBusinessDataCountByParams({fhqIsSubmit:false, fuHuaQiUscc:uscc, isSubmit:true});
let businessNotSubmitCount = await businessData.findBusinessDataCountByParams({fhqIsSubmit:false, fuHuaQiUscc:uscc, isSubmit:false});
let teamSubmitCount = await teamData.findTeamDataCountByParams({fhqIsSubmit:false, fuHuaQiUscc:uscc, isSubmit:true});
let teamNotSubmitCount = await teamData.findTeamDataCountByParams({fhqIsSubmit:false, fuHuaQiUscc:uscc, isSubmit:false});
let dataNumberList = [
{
"key":1,//枚举值
"value":`全部(${businessSubmitCount + businessNotSubmitCount + teamSubmitCount + teamNotSubmitCount})`//按钮文本
},
{
"key":2,//枚举值
"value":`已填报(${businessSubmitCount + teamSubmitCount})`//按钮文本
},
{
"key":3,//枚举值
"value":`未填报(${businessNotSubmitCount + teamNotSubmitCount})`//按钮文本
},
];
return { dataList, dataNumberList };
}
/**
* 已审核列表
* @param uscc 孵化器统一信用代码
* @param year 年度
* @param quarter 季度
*/
export async function auditCompletedList(uscc:string, year:number, quarter:number) {
let query = {fhqIsSubmit:true, fuHuaQiUscc:uscc, year:year, quarter:quarter};
let businessDataList = await businessData.findBusinessDataByParams(query);
let dataList = [];
businessDataList.forEach(info => {
let { name, quarter } = info;
dataList.push({
name,
typeStr:"经营状况",
cycle:getCycle(quarter),
});
});
let teamDataList = await teamData.findTeamDataByParams(query);
teamDataList.forEach(info => {
let { name, quarter } = info;
dataList.push({
name,
typeStr:"团队信息",
cycle:getCycle(quarter),
});
});
return { dataList };
}
/**
* 孵化器补充企业数据
* @param fuHuaQiUscc 孵化器统一信用代码
* @param uscc 企业统一信用代码
* @param type 类型
* @param form 数据表单
*/
export async function fuHuaQiReplenishEnterpriseDataDeclaration(fuHuaQiUscc:string, uscc:string, type:number, year:number, quarter:number, form ) {
eccEnumValue("孵化器补充企业数据", "type", ENTERPRISEDECLARATIONTYPE, type);
if (type == ENTERPRISEDECLARATIONTYPE.团队信息) {
eccFormParam("孵化器补充企业数据-团队信息", eccFormParamConfig.FuHuaQiReplenishEnterpriseTeamDataConfig, form);
let teamInfo = await teamData.findTeamByUsccAndTime(uscc, year, quarter);
if (teamInfo.fuHuaQiUscc != fuHuaQiUscc) {}
for (let key in eccFormParamConfig.FuHuaQiReplenishEnterpriseTeamDataConfig) {
teamInfo[key] = form[key];
}
teamInfo.isUpdate = true;
await teamInfo.save();
} else {
eccFormParam("孵化器补充企业数据-经营状况", eccFormParamConfig.FuHuaQiReplenishEnterpriseBusinessDataConfig, form);
let businessInfo = await businessData.findBusinessDataByTimeAndUscc(uscc, year, quarter);
if (businessInfo.fuHuaQiUscc != fuHuaQiUscc) {}
for (let key in eccFormParamConfig.FuHuaQiReplenishEnterpriseBusinessDataConfig) {
businessInfo[key] = form[key];
}
businessInfo.isUpdate = true;
await businessInfo.save();
}
return { isSuccess:true };
}
/**
* 通过校验
* @param fuHuaQiUscc 孵化器统一信用代码
* @param uscc 企业统一信用代码
* @param type 类型 ENTERPRISEDECLARATIONTYPE
* @param year 年度
* @param quarter 季度
* @returns
*/
export async function fuHuaQiPass(fuHuaQiUscc:string, uscc:string, type:number, year:number, quarter:number ) {
eccEnumValue("孵化器补充企业数据", "type", ENTERPRISEDECLARATIONTYPE, type);
let dataInfo:any = {};
if (type == ENTERPRISEDECLARATIONTYPE.团队信息) {
dataInfo = await teamData.findTeamByUsccAndTime(uscc, year, quarter);
} else {
dataInfo = await businessData.findBusinessDataByTimeAndUscc(uscc, year, quarter);
}
if (dataInfo.fhqIsSubmit) throw new BizError(ERRORENUM.重复通过填报数据, `${fuHuaQiUscc} 企业审核 重复通过`);
dataInfo.fhqIsSubmit = true;
await dataInfo.save();
return { isSuccess:true };
}
/**
* 孵化器 回显 企业填报的团队信息 数据
* @param fuHuaQiUscc 孵化器统一信用代码
* @param uscc 企业统一信用代码
* @param year 年度
* @param quarter 季度
* @returns
*/
export async function selectFuHuaQiReplenishEnterpriseTeamData(fuHuaQiUscc:string, uscc:string, year:number, quarter:number) {
let teamInfo = await teamData.findTeamByUsccAndTime(uscc, year, quarter);
let result = {
doctor:teamInfo.doctor,//博士
master:teamInfo.master,//硕士
undergraduate:teamInfo.undergraduate,//本科
juniorCollege:teamInfo.juniorCollege,//专科
other:teamInfo.other,//其他
studyAbroad:teamInfo.studyAbroad,//留学人数
graduates:teamInfo.graduates,//应届毕业生
}
return result;
}
/**
* 孵化器 回显 企业填报的经营 数据
* @param fuHuaQiUscc 孵化器统一信用代码
* @param uscc 企业统一信用代码
* @param year 年度
* @param quarter 季度
* @returns
*/
export async function selectFuHuaQiReplenishEnterpriseBusinessData(fuHuaQiUscc:string, uscc:string, year:number, quarter:number) {
let businessInfo = await businessData.findBusinessDataByTimeAndUscc(uscc, year, quarter);
let result = {
BI:businessInfo.BI,//营业收入
RD:businessInfo.RD,//研发投入
TXP:businessInfo.TXP,//纳税
}
return result;
}
/**
* 党建任务
*/
import * as eccParamConfig from "../../../config/eccParam/fuHuaQi";
import * as splitResultConfig from "../../../config/splitResultConfig";
import { STATEENUM } from "../../../config/enum";
import { NOTZHIBUTYPEENUM, SZZCFHJGSFCLDZBENUM, ZHIBUTYPEENUM } from "../../../config/enum/dangJianEnum";
import { ERRORENUM } from "../../../config/errorEnum";
import { findDangJianTaskListByTaskId } from "../../../data/fuHuaQi/monthTask/dangJian";
import { BizError } from "../../../util/bizError";
import { checkChange, extractData } from "../../../util/piecemeal";
import { eccEnumValue } from "../../../util/verificationEnum";
import { eccFormParam } from "../../../util/verificationParam";
/**
* 党建任务-众创孵化信息采集
* @param uscc
*/
export async function replenishZhongChuang(uscc:string, param) {
const FunName = '补充众创孵化信息采集';
/**校验表单参数 */
eccFormParam(FunName, eccParamConfig.DangJianZhongChuangConfig, param);
/**校验枚举 */
eccEnumValue(FunName, '董事长是党员', STATEENUM, param.zcdszdy);
eccEnumValue(FunName, '众创孵化机构是否建设党建园地', STATEENUM, param.zcfhjgsfjsdjyd);
eccEnumValue(FunName, '众创孵化机构是否成立党支部', STATEENUM, param.zcjgsfcldzs);
eccEnumValue(FunName, '众创孵化机构党支部类型', SZZCFHJGSFCLDZBENUM, param.zcjgsfcldzslx);
if (param.zcjgsfcldzs == STATEENUM.) {
eccEnumValue(FunName, '存在支部时众创孵化机构党支部类型', ZHIBUTYPEENUM, param.zcjgsfcldzslx);
if (!param.zbmc) throw new BizError(ERRORENUM.参数错误, '缺少支部名称');
if (param.dzbsfkzshyk) {
if (param.hdcs == undefined || param.hdcs == null || param.cyrs == undefined || param.cyrs == null) {
throw new BizError(ERRORENUM.参数错误, '活动人数或参与人数');
}
} else {
param.hdcs = 0;//活动次数
param.cyrs = 0;//参与人数
}
} else if (param.zcjgsfcldzs == STATEENUM.) {
eccEnumValue(FunName, '不存在支部时众创孵化机构党支部类型', NOTZHIBUTYPEENUM, param.zcjgsfcldzslx);
param.zbmc = '';//支部名称
param.dzbsfkzshyk = false;//党支部是否开展三会一课
param.hdcs = 0;//活动次数
param.cyrs = 0;//参与人数
}
const TaskId = `${uscc}${new Date().getFullYear()}`;
let dangJianTaskInfo = await findDangJianTaskListByTaskId(TaskId);
/**修改值 */
let changeList = checkChange(param, dangJianTaskInfo);
if ( !changeList.length ) throw new BizError(ERRORENUM.数据无更新, `${param.uscc}数据无更新`);
changeList.forEach(key => {
dangJianTaskInfo[key] = param[key];
});
await dangJianTaskInfo.save();
return {isSuccess:true};
}
/**
* 众创孵化信息采集 回显
* @param uscc
*/
export async function zhongChuangInfo(uscc:string) {
const TaskId = `${uscc}${new Date().getFullYear()}`;
let dangJianTaskInfo = await findDangJianTaskListByTaskId(TaskId);
if (!dangJianTaskInfo || !dangJianTaskInfo.taskId) throw new BizError(ERRORENUM.未找到数据, `库中不存在uscc=${uscc}这个年度任务`);
let dataInfo = extractData(splitResultConfig.DangJianZhongChuangConfig, dangJianTaskInfo, false);
return {dataInfo};
}
/**
* 党建任务-在孵企业信息采集
* @param uscc
*/
export async function replenishZaiFu(uscc:string, param) {
const FunName = '补充在孵企业信息采集';
/**校验表单参数 */
eccFormParam(FunName, eccParamConfig.DangJianZaiFuConfig, param);
/**校验枚举 */
eccEnumValue(FunName, '在孵企业党建', STATEENUM, param.zfqydj);
if ((param.dy70h+param.dy80h+param.dy90h) > param.zfqydysl) throw new BizError(ERRORENUM.党员年龄分布总和大于总数);
if (param.zfqydj == STATEENUM.) {
if (!param.zfqydzbdjList.length) throw new BizError(ERRORENUM.参数错误, '缺少党支部信息');
let itemConfig = {
name:{type:"String"},//支部名称
type:{type:"Number"},//支部类型
count:{type:"Number"},//党员数量
dzbsfkzshyk:{type:"Boolean"},//党支部是否开展三会一课
hdcs:{type:"Number", notMustHave:true},//活动次数
cyrs:{type:"Number", notMustHave:true},//参与人数
};
for (let i in param.zfqydzbdjList) {
let item = param.zfqydzbdjList[i];
eccFormParam(FunName+'党支部登记', itemConfig, item);
eccEnumValue(FunName+'党支部登记', '支部类型', ZHIBUTYPEENUM, item.type);
if (item.dzbsfkzshyk) {
if (item.hdcs == undefined || item.hdcs == null || item.cyrs == undefined || item.cyrs == null) {
throw new BizError(ERRORENUM.参数错误, '活动人数或参与人数');
}
} else {
item.hdcs = 0;//活动次数
item.cyrs = 0;//参与人数
}
}
} else {
param.zfqydzbdjList = [];
}
const TaskId = `${uscc}${new Date().getFullYear()}`;
let dangJianTaskInfo = await findDangJianTaskListByTaskId(TaskId);
/**修改值 */
let changeList = checkChange(param, dangJianTaskInfo);
if ( !changeList.length ) throw new BizError(ERRORENUM.数据无更新, `${param.uscc}数据无更新`);
changeList.forEach(key => {
dangJianTaskInfo[key] = param[key];
});
await dangJianTaskInfo.save();
return {isSuccess:true};
}
/**
* 党建任务-在孵企业信息采集回显
* @param uscc
*/
export async function zaiFuInfo(uscc:string) {
const TaskId = `${uscc}${new Date().getFullYear()}`;
let dangJianTaskInfo = await findDangJianTaskListByTaskId(TaskId);
if (!dangJianTaskInfo || !dangJianTaskInfo.taskId) throw new BizError(ERRORENUM.未找到数据, `库中不存在uscc=${uscc}这个年度任务`);
let dataInfo = extractData(splitResultConfig.DangJianZaiFuConfig, dangJianTaskInfo, false);
return {dataInfo};
}
/**
* 孵化器经营数据填报
*
*/
import moment = require("moment");
import * as eccFormParamConfig from "../../../config/eccParam/fuHuaQi";
import { ERRORENUM } from "../../../config/errorEnum";
import { FuHuaQiBusinessDataInfoConfig } from "../../../config/splitResultConfig";
import { findBusinessByTaskId } from "../../../data/fuHuaQi/quarterTask/businessData";
import * as taskTool from "../../../tools/taskTool";
import { BizError } from "../../../util/bizError";
import { extractData } from "../../../util/piecemeal";
import { eccFormParam } from "../../../util/verificationParam";
/**
* 新添加孵化器经营数据填报
* 小程序端
* 逻辑是 将填报编辑状态修改为true 当库里=true时
* @param uscc 孵化器的统一信用代码
* @param param
* @returns {isSuccess:true/false}
*/
export async function createBusiness(uscc:string, param) {
const TaskId = taskTool.getQuarterTaskId(uscc);
eccFormParam("新添加孵化器季度填报", eccFormParamConfig.FuHuaQiBusinessDataConfig, param);
let businessInfo = await findBusinessByTaskId(TaskId);
/**不可以重复创建 */
if ( businessInfo.isUpdate ) throw new BizError(ERRORENUM.该孵化器经营数据填报已存在, `孵化器 ${uscc}重复提交了经营数据`);
/**更新状态和数据 */
businessInfo.isUpdate = true;
for (let key in param) {
businessInfo[key] = param[key];
}
await businessInfo.save();
return {isSuccess:true};
}
/**
* 删除孵化器经营数据
* @param uscc 孵化器统一
* @returns
*/
export async function deleteBusiness(uscc:string) {
const TaskId = taskTool.getQuarterTaskId(uscc);
let businessInfo = await findBusinessByTaskId(TaskId);
/**删除校验 */
if ( !businessInfo.isUpdate ) throw new BizError(ERRORENUM.未填报数据不能删除, `孵化器 ${uscc}删除经营数据时经营数据不存在`);
if ( businessInfo.draftLock ) throw new BizError(ERRORENUM.已提交的数据不能进行操作, `孵化器 ${uscc}尝试 删除 已经提交的经营数据`);
/**更新状态和数据 */
businessInfo.isUpdate = false;
for (let key in eccFormParamConfig.FuHuaQiBusinessDataConfig) {
businessInfo[key] = 0;
}
await businessInfo.save();
return {isSuccess:true};
}
/**
* 查询单个经营数据
* @param uscc 孵化器统一信用代码
* @returns
*/
export async function selectBusiness(uscc:string) {
const TaskId = taskTool.getQuarterTaskId(uscc);
let businessInfo = await findBusinessByTaskId(TaskId);
/**不可以重复创建 */
if ( !businessInfo.isUpdate ) throw new BizError(ERRORENUM.请先填报数据, `孵化器 ${uscc}调用回显接口时经营数据不存在`);
let {declarationQuarter, declarationYear} = getDeclarationTime();
if ( businessInfo.quarter != declarationQuarter || businessInfo.year != declarationYear ) throw new BizError(ERRORENUM.已提交的数据不能进行操作, `孵化器 ${uscc}尝试 回显 已经提交的经营数据`);
// if ( businessInfo.draftLock ) throw new BizError(ERRORENUM.已提交的数据不能进行操作, `孵化器 ${uscc}尝试 回显 已经提交的经营数据`);
let businessData = extractData(FuHuaQiBusinessDataInfoConfig, businessInfo, false);
return {businessData};
}
/**
* 获取当前时间的 填报年度 和 填报季度
* 即:获取上一个季度
* @returns declarationYear:数据填报年 declarationQuarter:数据填报季度
*/
function getDeclarationTime() {
let thisYear = new Date().getFullYear();
let thisQuarter = moment().quarter();//当月填报季度
if ( (thisQuarter - 1) < 1 ) {
thisYear = moment().subtract(1, 'years').year();
thisQuarter = 4;
} else thisQuarter = thisQuarter - 1;
return {declarationYear:thisYear, declarationQuarter:thisQuarter};
}
/**
* 孵化器修改经营数据
* @param uscc 孵化器统一信用代码
* @param param 参数
* @returns
*/
export async function updateBusiness(uscc:string, param) {
const TaskId = taskTool.getQuarterTaskId(uscc);
eccFormParam("修改孵化器季度填报", eccFormParamConfig.FuHuaQiBusinessDataConfig, param);
let businessInfo = await findBusinessByTaskId(TaskId);
/**不可以重复创建 */
if ( !businessInfo.isUpdate ) throw new BizError(ERRORENUM.请先填报数据, `孵化器 ${uscc}调用修改接口时经营数据不存在`);
let {declarationQuarter, declarationYear} = getDeclarationTime();
if ( businessInfo.quarter != declarationQuarter || businessInfo.year != declarationYear ) throw new BizError(ERRORENUM.已提交的数据不能进行操作, `孵化器 ${uscc}尝试 修改 已经提交的经营数据`);
/**更新状态和数据 */
for (let key in param) {
businessInfo[key] = param[key];
}
await businessInfo.save();
return {isSuccess:true};
}
/**
* 我的数据中展示填报的经营数据
* @param uscc 孵化器统一信用代码
* @param year 年度
* @param quarter 季度
* @returns
*/
export async function showBusinessData(uscc:string, year:number, quarter:number) {
let taskId = taskTool.getQuarterTaskIdByYearAndQuarter(uscc, year, quarter);
let businessInfo = await findBusinessByTaskId(taskId);
if (!businessInfo) {
businessInfo = {
TR:0, ROR:0, RR:0,
FS:0, MIS:0, NP:0, TP:0
}
}
let businessData = extractData(FuHuaQiBusinessDataInfoConfig, businessInfo, false);
return {businessData};
}
\ No newline at end of file
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
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