Commit 006cf54e by lixinming

no message

parent bb4cd4fb
......@@ -23,11 +23,15 @@ export async function createReport(uscc:string, occupancyRate:number) {
const TaskId = getTaskId(uscc);
let dataBaseInfo = await monthData.findmonthTableByTaskId(TaskId);
if (dataBaseInfo) throw new BizError(ERRORENUM.该孵化器月度填报已存在, `${uscc}重复提交了月度填报值为${occupancyRate}`);
if (dataBaseInfo.state == 2) throw new BizError(ERRORENUM.该孵化器月度填报已存在, `${uscc}重复提交了月度填报值为${occupancyRate}`);
const MonthNumber = moment().subtract(1, 'months').month() + 1;
const MonthTableName = `${MonthNumber}月孵化器月度填报`;
await monthData.addOnceReport(TaskId, MonthTableName, uscc, occupancyRate);
dataBaseInfo.state = 2;
dataBaseInfo.createTime = new Date().valueOf();
dataBaseInfo.occupancyRate = occupancyRate;
await dataBaseInfo.save();
// const MonthNumber = moment().subtract(1, 'months').month() + 1;
// const MonthTableName = `${MonthNumber}月孵化器月度填报`;
// await monthData.addOnceReport(TaskId, MonthTableName, uscc, occupancyRate);
return {isSuccess:true};
}
......@@ -75,10 +79,10 @@ export async function deleteReport(uscc:string) {
*/
export async function monthTableList(state:number, year:number, month:number, page:number) {
let selectParam:any = {};
if (state) selectParam.state = state;
if (year) selectParam.year = year;
if (month) selectParam.month = month;
let taskList = findTaskListByType(TASKTYPEENUM.孵化器月度填报);
let dataBaseList = await monthData.findMonthTableList(selectParam, (page-1)*10 );
let count = await monthData.findMonthTableListCount(selectParam);
......@@ -96,10 +100,6 @@ export async function monthTableList(state:number, year:number, month:number, pa
dataList.push(onceInfo);
});
//==
return {count, dataList}
}
......
......@@ -5,12 +5,13 @@
*
*/
import moment = require("moment");
import { TASKTYPEENUM } from "../../config/enum";
import { ERRORENUM } from "../../config/errorEnum";
import { findEnterpriseListByTaskId, updateEnterpriseDraftLock } from "../../data/enterprise/enterprise";
import { findFinancingListByTaskId, updateFinancingDraftLock } from "../../data/enterprise/financing";
import { findAllFuHuaQi } from "../../data/fuHuaQi/fuhuaqi";
import { findmonthTableByTaskId, findmonthTableListByTaskId } from "../../data/fuHuaQi/monthTable";
import { createMonthTableToList, findmonthTableByTaskId, findmonthTableListByTaskId } from "../../data/fuHuaQi/monthTable";
import { findEnterpriseByTaskIdAndType, createTaskToList, findFuHuaQiTaskByTaskId, findTaskCountByKey } from "../../data/fuHuaQi/task";
import { BizError } from "../../util/bizError";
import { logConsole, logHandle } from "../../util/log";
......@@ -118,33 +119,53 @@ export async function provideTask() {
let fuHuaQiList = await findAllFuHuaQi();
const Month = new Date().getMonth() + 1;
let addList = [];
let addList = [];//任务列表
let monthList = [];//月度填报列表
const MonthNumber = moment().subtract(1, 'months').month() + 1;
const YearNumber = new Date().getFullYear();
const MonthTableName = `${MonthNumber}月孵化器月度填报`;
fuHuaQiList.forEach(info => {
let { uscc } = info;
let taskId = getTaskId(uscc);
addList.push({
key:TimeKey,
type:TASKTYPEENUM.孵化器月度填报,
taskId:getTaskId(uscc),
taskId,
fuHuaQiUscc:uscc,
isSubmit:false
},{
key:TimeKey,
type:TASKTYPEENUM.新注册或迁入企业登记,
taskId:getTaskId(uscc),
taskId,
fuHuaQiUscc:uscc,
isSubmit:false
},{
key:TimeKey,
type:TASKTYPEENUM.融资企业填报,
taskId:getTaskId(uscc),
taskId,
fuHuaQiUscc:uscc,
isSubmit:false
});
monthList.push({
taskId,
name:MonthTableName,
fuHuaQiUscc:uscc,
month:MonthNumber,
year:YearNumber,
state:1
});
});
try {
await createTaskToList(addList);
logHandle(`添加了${addList.length}`)
/**添加月度填报表 */
await createMonthTableToList(monthList);
logHandle(`添加了${addList.length}`);
} catch (err) {
//todo添加异常了
}
......
......@@ -15,10 +15,11 @@ const monthTableSchema = new Schema({
fuHuaQiUscc:String,//任务所属孵化器id
occupancyRate:Number,//出租率 单位为%
createTime:Number,//创建时间
state:{type:Number, default:1},//状态 初始状态=1 1表示未填报
/**不下发字段 */
draftLock:{type:Boolean, default:false},//草稿锁,true为提交之后,false为草稿
year:{type:Number, index:true},
month:{type:Number, index:true},
year:{type:Number, index:true}
});
var monthTableModel;
......@@ -104,4 +105,9 @@ export async function findMonthTableList(selectParam:object, skipNum:number) {
*/
export async function findMonthTableListCount(selectParam:object) {
return await monthTableModel.find(selectParam).count();
}
\ No newline at end of file
}
export async function createMonthTableToList(tableList:object) {
await monthTableModel.insertMany(tableList);
}
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