Commit 9a7db531 by lixinming

no message

parent b5792850
......@@ -16,15 +16,14 @@ import moment = require("moment");
* @returns {isSuccess:true/false}
*/
export async function createReport(uscc:string, occupancyRate:number) {
//不允许有重复的
const TaskId = getTaskId(uscc);
let dataBaseInfo = await monthData.findmonthTableListByTaskId(TaskId);
let dataBaseInfo = await monthData.findmonthTableByTaskId(TaskId);
if (!dataBaseInfo || !dataBaseInfo.taskId) throw new BizError(ERRORENUM.该孵化器月度填报已存在, `${uscc}重复提交了月度填报值为${occupancyRate}`);
if (dataBaseInfo) throw new BizError(ERRORENUM.该孵化器月度填报已存在, `${uscc}重复提交了月度填报值为${occupancyRate}`);
const MonthNumber = moment().subtract(1, 'months').month() + 1;
const MonthTableName = `${MonthNumber}月孵化器月度填报`;
await monthData.addOnceReport(MonthTableName, uscc, occupancyRate);
await monthData.addOnceReport(TaskId, MonthTableName, uscc, occupancyRate);
return {isSuccess:true};
}
......@@ -37,8 +36,8 @@ export async function createReport(uscc:string, occupancyRate:number) {
*/
export async function updateReport(uscc:string, occupancyRate:number) {
const TaskId = getTaskId(uscc);
let dataBaseInfo = await monthData.findmonthTableListByTaskId(TaskId);
if (dataBaseInfo || dataBaseInfo.taskId) throw new BizError(ERRORENUM.未找到数据, `未找到${uscc}的月度报表` );
let dataBaseInfo = await monthData.findmonthTableByTaskId(TaskId);
if (!dataBaseInfo || !dataBaseInfo.taskId) throw new BizError(ERRORENUM.未找到数据, `未找到${uscc}的月度报表` );
dataBaseInfo.occupancyRate = occupancyRate;
await dataBaseInfo.save();
......@@ -53,10 +52,10 @@ export async function updateReport(uscc:string, occupancyRate:number) {
*/
export async function deleteReport(uscc:string) {
const TaskId = getTaskId(uscc);
let dataBaseInfo = await monthData.findmonthTableListByTaskId(TaskId);
if (dataBaseInfo || dataBaseInfo.taskId) throw new BizError(ERRORENUM.未找到数据);
let dataBaseInfo = await monthData.findmonthTableByTaskId(TaskId);
if (!dataBaseInfo || !dataBaseInfo.taskId) throw new BizError(ERRORENUM.未找到数据);
await monthData.deleteReport(uscc);
await monthData.deleteReport(uscc, dataBaseInfo.name);
return {isSuccess:true};
}
\ No newline at end of file
......@@ -61,21 +61,23 @@ export async function findmonthTableByTaskId(taskId:string) {
/**
* 孵化器月度填报 新增报表
* @param taskId 任务Id
* @param name 任务名称 系统生成
* @param uscc 孵化器统一信用代码
* @param occupancyRate 出租率
* @param createTime 创建时间
*
*/
export async function addOnceReport(name:string, uscc:string, occupancyRate:number) {
let monthInfo = {name, fuHuaQiUscc:uscc, occupancyRate, createTime:new Date().valueOf()}
export async function addOnceReport(taskId:string, name:string, uscc:string, occupancyRate:number) {
let monthInfo = {taskId, name, fuHuaQiUscc:uscc, occupancyRate, createTime:new Date().valueOf()}
await monthTableModel.create(monthInfo);
}
/**
* 孵化器月度填报 删除报表
* @param uscc 孵化器统一信用代码
* @param name 表名称
*/
export async function deleteReport(uscc:string) {
return await monthTableModel.remove({fuHuaQiUscc:uscc}).exec();
export async function deleteReport(uscc:string, name:string) {
return await monthTableModel.deleteOne({fuHuaQiUscc:uscc, name}).exec();
}
\ No newline at end of file
......@@ -7,10 +7,10 @@ import { FUHUAQILV, INSTITUTIONALNATURE, FUHUAINDUSTRY, INDUSTRY } from '../conf
import { checkFuHuaQiToken } from '../middleware/user';
export function setRouter(httpServer) {
httpServer.post('/public/fuhuaqilv', checkFuHuaQiToken, asyncHandler(getFuHuaQiLv));
httpServer.post('/public/institutionalnature', checkFuHuaQiToken, asyncHandler(getInstitutionalNature));
httpServer.post('/public/fuhuaqiindustry', checkFuHuaQiToken, asyncHandler(getFuHuaQiIndustry));
httpServer.post('/public/industry', checkFuHuaQiToken, asyncHandler(getIndustry));
httpServer.post('/public/fuhuaqilv', asyncHandler(getFuHuaQiLv));
httpServer.post('/public/institutionalnature', asyncHandler(getInstitutionalNature));
httpServer.post('/public/fuhuaqiindustry', asyncHandler(getFuHuaQiIndustry));
httpServer.post('/public/industry', asyncHandler(getIndustry));
}
/**
......
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