Commit 97c35e71 by lixinming

no message

parent d4aaf864
/**
* 孵化器基础数据相关逻辑
* 作者: 李某
* 孵化器相关逻辑 包括孵化器的增删改查
*
*/
/**
* 更新孵化器基础数据
* @param uscc 孵化器统一信用代码
*/
export function updateFuHuaQiBaseData(uscc:string, name:string, ) {
}
/**
* 查询孵化器基础数据
* @param uscc 孵化器统一信用代码
*/
export function selectFuHuaQiBaseData(uscc:string) {
}
\ No newline at end of file
...@@ -6,10 +6,13 @@ ...@@ -6,10 +6,13 @@
*/ */
import { TASKTYPEENUM } from "../../config/enum"; import { TASKTYPEENUM } from "../../config/enum";
import { findEnterpriseListByTaskId } from "../../data/enterprise/enterprise"; import { ERRORENUM } from "../../config/errorEnum";
import { findFinancingListByTaskId } from "../../data/enterprise/financing"; import { findEnterpriseListByTaskId, updateEnterpriseDraftLock } from "../../data/enterprise/enterprise";
import { findFuHuaQiTaskByKeyAndUscc } from "../../data/fuHuaQi/task"; import { findFinancingListByTaskId, updateFinancingDraftLock } from "../../data/enterprise/financing";
import { getTaskId } from "../../util/tools"; import { findmonthTableByTaskId, findmonthTableListByTaskId } from "../../data/fuHuaQi/monthTable";
import { createTaskData, findFuHuaQiTaskByKeyAndUscc } from "../../data/fuHuaQi/task";
import { BizError } from "../../util/bizError";
import { getTaskId, getTimeKey } from "../../util/tools";
/** /**
...@@ -19,12 +22,12 @@ import { getTaskId } from "../../util/tools"; ...@@ -19,12 +22,12 @@ import { getTaskId } from "../../util/tools";
*/ */
export async function fuHuaQiTaskList(uscc:string) { export async function fuHuaQiTaskList(uscc:string) {
/** /**
* 返回格式 [{type:, }] * 返回格式 [{type:1, title:'', enterpriseList:[] }]
*/ */
let result = []; let result = [];
const timeKey = `${new Date().getFullYear()}${new Date().getMonth()+1}`; const TimeKey = getTimeKey();
let taskMap = await findFuHuaQiTaskByKeyAndUscc(uscc, timeKey); let taskMap = await findFuHuaQiTaskByKeyAndUscc(uscc, TimeKey);
let taskTypeMapConf = {}; let taskTypeMapConf = {};
for (let key in TASKTYPEENUM) { for (let key in TASKTYPEENUM) {
...@@ -35,17 +38,17 @@ export async function fuHuaQiTaskList(uscc:string) { ...@@ -35,17 +38,17 @@ export async function fuHuaQiTaskList(uscc:string) {
for (let typeStr in taskTypeMapConf) { for (let typeStr in taskTypeMapConf) {
let typeKey = parseInt(typeStr); let typeKey = parseInt(typeStr);
let onceObj = { key:typeStr, enterpriseList:[]}; let onceObj = { key:typeStr, title:taskTypeMapConf[typeStr], enterpriseList:[]};
if (!taskMap[typeStr]) { //没有提交任务 if (!taskMap[typeStr]) { //没有提交任务
if (TASKTYPEENUM.孵化器月度填报 == typeKey ) {
// enterpriseList.push();
continue;
}
let dataList = []; let dataList = [];
if (TASKTYPEENUM.新注册或迁入企业登记 == typeKey ) dataList = await findEnterpriseListByTaskId(TaskId);
if (TASKTYPEENUM.融资企业填报 == typeKey) dataList = await findFinancingListByTaskId(TaskId); switch(typeKey) {
case TASKTYPEENUM.孵化器月度填报: dataList = await findmonthTableListByTaskId(TaskId); break;
case TASKTYPEENUM.新注册或迁入企业登记: dataList = await findEnterpriseListByTaskId(TaskId); break;
case TASKTYPEENUM.融资企业填报: dataList = await findFinancingListByTaskId(TaskId); break;
}
dataList.forEach(info => { dataList.forEach(info => {
onceObj.enterpriseList.push(info.name); onceObj.enterpriseList.push(info.name);
}); });
...@@ -55,3 +58,36 @@ export async function fuHuaQiTaskList(uscc:string) { ...@@ -55,3 +58,36 @@ export async function fuHuaQiTaskList(uscc:string) {
return result; return result;
} }
/**
* 提交任务
* @param uscc 孵化器的信用标识
* @param taskType 任务类型
*/
export async function checkTask(uscc:string, taskType:number) {
const TimeKey = getTimeKey();
const TaskId = getTaskId(uscc);
let taskMap = await findFuHuaQiTaskByKeyAndUscc(uscc, TimeKey);
if ( taskMap[taskType] ) throw new BizError(ERRORENUM.不能重复提交任务, uscc, taskType);
switch (taskType) {
case TASKTYPEENUM.孵化器月度填报:
let tableInfo = await findmonthTableListByTaskId(TaskId);
if (!tableInfo) throw new BizError();//todo 没有做弹框
if (tableInfo.draftLock ) throw new BizError(ERRORENUM.不能重复提交任务, uscc, taskType, 'lock = true');
tableInfo.draftLock = true;
await tableInfo.save();
break;
case TASKTYPEENUM.新注册或迁入企业登记:
await updateFinancingDraftLock(TaskId);
break;
case TASKTYPEENUM.融资企业填报:
await updateEnterpriseDraftLock(TaskId);
break;
}
//添加一条任务
await createTaskData(uscc, TimeKey, TaskId, taskType);
return {isSuccess:true};
}
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
export enum ERRORENUM { export enum ERRORENUM {
未找到数据, 未找到数据,
参数错误, 参数错误,
不能重复提交任务,
} }
let bizErrorMsgMap = {}; let bizErrorMsgMap = {};
......
...@@ -24,10 +24,18 @@ export function initModel(){ ...@@ -24,10 +24,18 @@ export function initModel(){
} }
/** /**
* 通过taskId 获取此次任务提交的企业列表 * 通过taskId 获取此次任务添加的企业列表
* @param taskId * @param taskId
* @returns * @returns
*/ */
export async function findEnterpriseListByTaskId(taskId:string) { export async function findEnterpriseListByTaskId(taskId:string) {
return await enterpriseModel.findOne({taskId}).exec(); return await enterpriseModel.find({taskId}).exec();
}
/**
* 修改特定taskId的锁为true
* @param taskId 任务id
*/
export async function updateEnterpriseDraftLock(taskId:string) {
return await enterpriseModel.update({taskId}, {$set:{draftLock:true}}, {upsert:true});
} }
\ No newline at end of file
...@@ -22,10 +22,18 @@ export function initModel(){ ...@@ -22,10 +22,18 @@ export function initModel(){
} }
/** /**
* 通过taskId 获取此次任务提交的融资列表 * 通过taskId 获取此次任务添加的融资列表
* @param taskId * @param taskId
* @returns * @returns
*/ */
export async function findFinancingListByTaskId(taskId:string) { export async function findFinancingListByTaskId(taskId:string) {
return await financingModel.findOne({taskId}).exec(); return await financingModel.find({taskId}).exec();
}
/**
* 修改特定taskId的锁为true
* @param taskId 任务id
*/
export async function updateFinancingDraftLock(taskId:string) {
return await financingModel.update({taskId}, {$set:{draftLock:true}}, {upsert:true});
} }
\ No newline at end of file
import {Schema} from 'mongoose';
import { baseDB } from '../../db/dbInit';
const monthTableSchema = new Schema({
taskId:String,//任务id
name:String,//任务名称
fuHuaQiUscc:String,//任务所属孵化器id
occupancyRate:Number,//出租率
createTime:Number,//创建时间
draftLock:{type:Boolean, default:false},//草稿锁,true为提交之后,false为草稿
});
var monthTableModel;
export function initModel(){
monthTableModel = baseDB.model('monthTable', monthTableSchema);
monthTableModel.selectOnceData = async function (paramater:object) {
let selectInfo = await monthTableModel.findOne(paramater).exec();
if (selectInfo) {
if (!selectInfo.runSave) {
selectInfo.runSave = selectInfo.save;
selectInfo.save = save.bind(selectInfo)
}
}
return selectInfo;
}
}
export async function save(throwError=false) {
if (!this.isModified()) return;
await this.runSave({validateBeforeSave:false}).catch(err=>{
console.log(err);
});
}
/**
* 通过taskId 获取此次任务添加的月度列表
* @param taskId
* @returns
*/
export async function findmonthTableListByTaskId(taskId:string) {
return await monthTableModel.find({taskId}).exec();
}
/**
* 通过taskId 获取此次月度任务
* @param taskId
* @returns
*/
export async function findmonthTableByTaskId(taskId:string) {
let monthTableInfo = await monthTableModel.selectOnceData({taskId}).exec();
return monthTableInfo;
}
...@@ -7,8 +7,7 @@ const fuHuaQiTaskSchema = new Schema({ ...@@ -7,8 +7,7 @@ const fuHuaQiTaskSchema = new Schema({
taskId:String,//任务id taskId:String,//任务id
fuHuaQiUscc:String,//任务所属孵化器id fuHuaQiUscc:String,//任务所属孵化器id
createTime:Number,//提交时间 createTime:Number,//提交时间
relevanceId:String,//任务关联的表 financing 或 enterprise 的id // relevanceId:String,//任务关联的表 financing 或 enterprise 的id 弃用
occupancyRate:Number//出租率
}); });
var fuHuaQiTaskModel; var fuHuaQiTaskModel;
...@@ -16,6 +15,12 @@ export function initModel(){ ...@@ -16,6 +15,12 @@ export function initModel(){
fuHuaQiTaskModel = baseDB.model('fuHuaQiTask', fuHuaQiTaskSchema); fuHuaQiTaskModel = baseDB.model('fuHuaQiTask', fuHuaQiTaskSchema);
} }
/**
* 通过统一信用代码和任务日期标识 查询孵化器任务
* @param uscc 孵化器代码
* @param key 任务日期标识
* @returns
*/
export async function findFuHuaQiTaskByKeyAndUscc(uscc:string, key:string) { export async function findFuHuaQiTaskByKeyAndUscc(uscc:string, key:string) {
let findList = await fuHuaQiTaskModel.find({uscc, key}).exec() || []; let findList = await fuHuaQiTaskModel.find({uscc, key}).exec() || [];
let taskMap = {}; let taskMap = {};
...@@ -23,4 +28,17 @@ export async function findFuHuaQiTaskByKeyAndUscc(uscc:string, key:string) { ...@@ -23,4 +28,17 @@ export async function findFuHuaQiTaskByKeyAndUscc(uscc:string, key:string) {
taskMap[item.key] = item; taskMap[item.key] = item;
}); });
return taskMap; return taskMap;
} }
\ No newline at end of file
/**
* 归档时添加任务信息
* @param uscc 统一信用代码
* @param key 任务日期标识
* @param taskId 任务id
* @param type 任务类型
*/
export async function createTaskData(uscc:string, key:string, taskId:string, type:number ) {
let addInfo = {key, type, taskId, fuHuaQiUscc:uscc, createTime:new Date().valueOf()};
await fuHuaQiTaskModel.create(addInfo);
}
/**
* 生成任务id
* @param uscc 企业标识
* @returns
*/
export function getTaskId(uscc:string) { export function getTaskId(uscc:string) {
return `${uscc}${new Date().getFullYear()}${new Date().getMonth() + 1 }` return `${uscc}${getTimeKey()}`
}
/**
* 获取当前日期的key
* @returns
*/
export function getTimeKey() {
return `${new Date().getFullYear()}${new Date().getMonth() + 1 }`
} }
\ No newline at end of file
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