Commit ab1c88df by lixinming

no message

parent 7b445b32
......@@ -11,6 +11,7 @@ import moment = require("moment");
import { findAllFuHuaQiOperationNameMap } from "../../data/fuHuaQi/fuhuaqi";
import { MonthListConfig } from "../../config/ojbectResultKeyConfig";
import { TASKTYPEENUM } from "../../config/enum";
import { findTaskListByType } from "../../data/fuHuaQi/task";
/**
* 新添加孵化器月度填报
......@@ -77,7 +78,7 @@ export async function monthTableList(state:number, year:number, month:number, pa
if (year) selectParam.year = year;
if (month) selectParam.month = month;
// findTaskListByType(TASKTYPEENUM.孵化器月度填报);
let taskList = findTaskListByType(TASKTYPEENUM.孵化器月度填报);
let dataBaseList = await monthData.findMonthTableList(selectParam, (page-1)*10 );
let count = await monthData.findMonthTableListCount(selectParam);
......
......@@ -116,6 +116,7 @@ export async function provideTask() {
let fuHuaQiList = await findAllFuHuaQi();
const Month = new Date().getMonth() + 1;
let addList = [];
fuHuaQiList.forEach(info => {
let { uscc } = info;
......
......@@ -4,7 +4,7 @@
*/
import {Schema} from 'mongoose';
import { baseDB } from '../../db/dbInit';
import { baseDB } from '../../db/mongo/dbInit';
const enterpriseSchema = new Schema({
name: {type:String, index: true},//企业名称
......
......@@ -5,7 +5,7 @@
*/
import {Schema} from 'mongoose';
import { baseDB } from '../../db/dbInit';
import { baseDB } from '../../db/mongo/dbInit';
const financingSchema = new Schema({
uscc:{type:String, index:true},//融资企业统一信用代码 冗余字段
......
......@@ -8,7 +8,7 @@
*/
import {Schema} from 'mongoose';
import { baseDB } from '../../db/dbInit';
import { baseDB } from '../../db/mongo/dbInit';
const hatchingGroundSchema = new Schema({
personInChargeAdd:String,//孵化场地地址
......
......@@ -7,7 +7,7 @@
*/
import {Schema} from 'mongoose';
import { baseDB } from '../../db/dbInit';
import { baseDB } from '../../db/mongo/dbInit';
const monthTableSchema = new Schema({
taskId:{type:String, index:true},//任务id
......
......@@ -8,10 +8,10 @@
* type 依赖枚举
*/
import {Schema} from 'mongoose';
import { baseDB } from '../../db/dbInit';
import { baseDB } from '../../db/mongo/dbInit';
const fuHuaQiTaskSchema = new Schema({
key:{type:String, index:true},//任务标识 格式为:YYYYM
key:{type:Number, index:true},//任务标识 格式为:YYYYMM
type: {type:Number,index: true},//任务类型
taskId:String,//任务id
fuHuaQiUscc:String,//任务所属孵化器id
......@@ -78,8 +78,8 @@ export async function createTaskToList(taskList:object) {
await fuHuaQiTaskModel.insertMany(taskList);
}
export async function findTaskListByType(taskType:number ) {
let taskList = await fuHuaQiTaskModel.find({taskType});
export async function findTaskListByType(param) {
let taskList = await fuHuaQiTaskModel.find(param);
let map = {};
taskList.forEach(info => {
map[info.taskId] = info.isSubmit
......
......@@ -4,7 +4,7 @@
*/
import {Schema} from 'mongoose';
import { baseDB } from '../../db/dbInit';
import { baseDB } from '../../db/mongo/dbInit';
const guanWeiHuiSchema = new Schema({
name:String,//名称
......
import { systemConfig } from "../config/serverConfig";
import { BizError } from "../util/bizError";
import { systemConfig } from "../../config/serverConfig";
import { BizError } from "../../util/bizError";
import { createDbConnect } from "./dbConnect";
import { initTable } from "./tableInit";
var baseDB;
......
import * as taskinModel from "../data/fuHuaQi/task";
import * as fuhuaqiinModel from "../data/fuHuaQi/fuhuaqi";
import * as enterpriseinModel from "../data/enterprise/enterprise";
import * as financinginModel from "../data/enterprise/financing";
import * as monthTableModel from "../data/fuHuaQi/monthTable";
import * as taskinModel from "../../data/fuHuaQi/task";
import * as fuhuaqiinModel from "../../data/fuHuaQi/fuhuaqi";
import * as enterpriseinModel from "../../data/enterprise/enterprise";
import * as financinginModel from "../../data/enterprise/financing";
import * as monthTableModel from "../../data/fuHuaQi/monthTable";
export async function initTable() {
taskinModel.initModel();
......
export class mySqlTableClass {
file;
/**表方法 */
tableName;//表名
sql;
moreTableSql;
constructor(tableName:string, sqlEnum, moreSqlEnum) {
this.tableName = tableName;
this.sql = sqlEnum;
this.moreTableSql = moreSqlEnum;
}
/**
* 查询单表
* @param param 条件参数
* @param res 指定返回
*/
find(param, res?) {
let sqlStr = 'select ';
if (!res) sqlStr += '* ';
else {
res.forEach((itemStr, index) => {
sqlStr += itemStr;
if (index == res.length - 1) sqlStr += ' ';
else sqlStr += ', ';
});
}
sqlStr += `from ${this.tableName} `;
const KeyLength = Object.keys(param).length;
let valueList = [];
if ( KeyLength > 0) {
sqlStr += 'where ';
let index = 0;
for (let key in param) {
sqlStr += `${key} = ?`;
valueList.push(param[key]);
if (index < KeyLength - 1) sqlStr += ', ';
else sqlStr += ' ';
index += 1;
}
}
}
}
\ No newline at end of file
import * as mysql from 'mysql'
export function createMySqlConnect(host:string, port:number, user:string, password:string, database:string) {
return mysql.createConnection({ host, port, user, password, database });
}
export function createLocatMySql() {
return mysql.createConnection({ host:'127.0.0.1', port:3306, user:'root', password:'root', database:'projectDB', insecureAuth:true });
}
\ No newline at end of file
import { systemConfig } from "../../config/serverConfig";
import { BizError } from "../../util/bizError";
import { createMySqlConnect } from "./mysqlConnect";
let mysqlDB;
export function initMysqlDB() {
// mysqlDB = createMySqlConnect(dbConfig.mysqlHost, dbConfig.mysqlPort, dbConfig.mysqlUser, dbConfig.mysqlPwd, dbConfig.dataBase);
mysqlDB.connect(handleError);
mysqlDB.on('error', handleError);
//自定义方法
bindSqlFunc();
console.log("mysqlDB init success");
}
//断线重连
function handleError(err) {
if (err) {
if (err.code === 'PROTOCOL_CONNECTION_LOST') {
initMysqlDB();
} else {
console.error(err.stack || err);
}
}
}
//绑定方法
function bindSqlFunc() {
mysqlDB.selectData = function(sql, ...param) {
let _this = this;
let paramList = [];
param.forEach(thisStr => {
paramList.push(thisStr);
});
return new Promise( (resolve, reject) => {
_this.query(sql, paramList, (err, results, fields) => {
if (err) throw new BizError(err); //todo要把数据库异常捕捉,并且输出: 逻辑错误
else resolve(results);
});
});
};
mysqlDB.createData = function(table:string, param:object) {
let _this = this;
let sql = `insert into ${table} SET ?`;
return new Promise( (resolve, reject) => {
_this.query(sql, param, (err, results, fields) => {
if (err) throw new BizError(err); //todo要把数据库异常捕捉,并且输出: 逻辑错误
else resolve(results);
});
});
}
mysqlDB.updateData = function(table:string, param:object, contition:object) {
let _this = this;
let sql = `update ${table} set `;
let valueList = [];
let index = 1;
let length = Object.keys(param).length;
for (let key in param) {
sql += ` ${key} = ? `;
if ( index < length ) sql += `,`;
index += 1;
valueList.push(param[key]);
}
length = Object.keys(contition).length;
if (length) {
sql += ` where `;
index = 1;
for (let key in contition) {
sql += ` ${key} = ? `;
if ( index < length ) sql += `and`;
index += 1;
valueList.push(contition[key]);
}
}
return new Promise( (resolve, reject) => {
_this.query(sql, valueList, (err, results, fields) => {
if (err) throw new BizError(err); //todo要把数据库异常捕捉,并且输出: 逻辑错误
else resolve(results);
});
});
}
mysqlDB.findOne = function(sql, ...param) {
let _this = this;
let paramList = [];
param.forEach(thisStr => {
paramList.push(thisStr);
});
return new Promise( (resolve, reject) => {
_this.query(sql, paramList, (err, results, fields) => {
if (err) throw new BizError(err); //todo要把数据库异常捕捉,并且输出: 逻辑错误
else resolve(results[0]);
});
});
};
mysqlDB.deleteData = function(tableName, paramaterInfo) {
let _this = this;
let sql = `DELETE FROM ${tableName} WHERE `;
let index = 1;
let paramList = [];
let length = Object.keys(paramaterInfo).length;
for (let key in paramaterInfo) {
sql += ` ${key} = ? `;
if ( index < length ) sql += `,`;
index += 1;
paramList.push(paramaterInfo[key]);
}
return new Promise( (resolve, reject) => {
_this.query(sql, paramList, (err, results, fields) => {
if (err) throw new BizError(err); //todo要把数据库异常捕捉,并且输出: 逻辑错误
else resolve(results[0]);
});
});
};
}
export {mysqlDB}
\ No newline at end of file
import { fuHuaQiTaskList } from "./biz/fuHuqQi/task";
import { initSystemTask } from "./biz/systemTask";
import { initConfig, systemConfig} from "./config/serverConfig";
import { initDB } from "./db/dbInit";
import { initDB } from "./db/mongo/dbInit";
import { httpServer } from "./net/http_server";
async function lanuch() {
......
......@@ -25,7 +25,7 @@ export async function checkFuHuaQiToken(req, res, next) {
// if (userInfo.token != reqToken || (new Date().valueOf() - userInfo.tokenMs) > (3600*100*24*7) ) return next(new BizError(ERRORENUM.身份验证过期, `userId:${userId} token:${reqToken}`));
if (userInfo.token != reqToken ) return next(new BizError(ERRORENUM.身份验证过期, `userId:${userId} token:${reqToken}`));
req.headers.uscc = userInfo.uscc;
req.headers.uscc = req.headers.userid;
next();
}
......@@ -54,7 +54,7 @@ export async function checkGuanWeiHuiToken(req, res, next) {
if (userInfo.token != reqToken ) return next(new BizError(ERRORENUM.身份验证过期, `userId:${userId} token:${reqToken}`));
req.headers.userid = userInfo.userid;
req.headers.uscc = req.headers.userid;
next();
}
\ No newline at end of file
import { mysqlDB } from "../../db/mysql/mysqlInit";
//指派表
class enterpriseClass {
name:string//企业名称
taskId:string//绑定的任务id
uscc:string//统一信用代码
fuHuaQiUscc:string//孵化器统一信用代码
industry:string//领域 逗号隔开
logonTime:number//注册时间
firstIncubationTime:number//首次入孵时间
timeOfImmigration:number//迁入时间
isNaturalPersonHolding:boolean//是否自然人控股企业
oldLogonAdd:string//迁入前注册地址
logonAdd:string//注册地址
operatingAdd:string//经营地址
// isPhysicalPresence:boolean//是否实地孵化 暂时弃用
leasedArea:number//租赁面积(平方米)
draftLock:boolean//草稿锁,true为提交之后,false为草稿 默认=false
createTime:number//录入时间
/**表方法 */
tableName;
sql;
moreTableSql;
constructor(tableName:string) {
this.tableName = tableName;
/**单表查询语句 */
enum sqlEnum {
获取任务id相关的企业列表=``,
}
/**多表联查语句 */
enum moreSqlEnum {
}
this.sql = sqlEnum;
this.moreTableSql = moreSqlEnum;
}
}
let appointModel = new enterpriseClass("enterprise");
// /**
// * 通过taskId 获取此次任务添加的企业列表
// * @param taskId 任务id 格式遵循tool中getTaskId
// * @returns [{}]
// */
// export async function findEnterpriseListByTaskId(taskId:string) {
// mysqlDB.selectData();
// return await enterpriseModel.find({taskId});
// }
// /**
// * 将taskId的所有数据的draftLock字段为true
// * @param taskId 任务id 格式遵循tool中getTaskId
// */
// export async function updateEnterpriseDraftLock(taskId:string) {
// return await enterpriseModel.update({taskId}, {$set:{draftLock:true}}, {upsert:true});
// }
// /**
// * 通过企业统一信用代码获取企业信息
// * 支持.save方法保存对象修改
// * @param uscc 企业统一信用代码
// * @returns {}
// */
// export async function findEnterpriseByUscc(uscc:string) {
// return await enterpriseModel.selectOnceData({uscc});
// }
// /**
// * 创建新的企业数据
// * @param fuHuaQiUscc 企业所属孵化器的统一信用代码
// * @param taskId 任务id 格式遵循tool中getTaskId
// * @param param 添加的字段对象
// */
// export async function createEnterprise(fuHuaQiUscc:string, taskId:string, param) {
// let addInfo = Object.assign({fuHuaQiUscc, taskId, createTime:new Date().valueOf()}, param);
// await enterpriseModel.create(addInfo);
// }
// /**
// * 查找孵化器所拥有的企业数量
// * @param fuHuaQiUscc 孵化器统一信用代码
// * @returns
// */
// export async function findEnterpriseCountByFuHuaQiUscc(fuHuaQiUscc:string) {
// return await enterpriseModel.count({fuHuaQiUscc}).exec();
// }
// /**
// * 聚合查询 孵化器所拥有的企业数量
// * @returns {} key=孵化器统一信用 value=企业数量
// */
// export async function groupFindEnterprise() {
// let match = {draftLock:true};//前置条件
// let dataList = await enterpriseModel.aggregate([{$match:match},{$group:{_id:"$fuHuaQiUscc",count:{$sum:1}}}]).exec();
// let result = {};
// dataList.forEach(info => {
// let {_id, count} = info;
// result[_id] = count;
// });
// return result;
// }
// /**
// * 删除创建企业的草稿报表
// * @param uscc 企业统一信用代码
// */
// export async function deleteEnterprise(uscc:string) {
// return await enterpriseModel.deleteOne({uscc:uscc}).exec();
// }
// /**
// * 获取所有孵化器
// * @param selectParam 查询参数
// * @param skipCount 跳过数量
// * @returns [] 孵化器列表
// */
// export async function findEnterpriseList(selectParam, skipCount) {
// return await enterpriseModel.find(selectParam).skip(skipCount).limit(10);
// }
// /**
// * 获取所有孵化器
// * @param selectParam 查询参数
// * @returns number 数据数量
// */
// export async function findEnterpriseCount(selectParam) {
// return await enterpriseModel.find(selectParam).count();
// }
// /**
// * 通过企业名称获取企业信息
// * @param selectParam 查询参数
// * @returns number 数据数量
// */
// export async function findEnterpriseInfoByName(name:string) {
// return await enterpriseModel.findOne({name});
// }
// /**
// * todo 注释后加
// * @param selectParam 查询参数
// * @returns number 数据数量
// */
// export async function findEnterpriseListByFuHuaQiUsccName(fuHuaQiUscc:string) {
// return await enterpriseModel.find({fuHuaQiUscc});
// }
import { mysqlDB } from "../../db/mysql/mysqlInit";
//指派表
class enterpriseClass {
name:string//企业名称
taskId:string//绑定的任务id
uscc:string//统一信用代码
fuHuaQiUscc:string//孵化器统一信用代码
industry:string//领域 逗号隔开
logonTime:number//注册时间
firstIncubationTime:number//首次入孵时间
timeOfImmigration:number//迁入时间
isNaturalPersonHolding:boolean//是否自然人控股企业
oldLogonAdd:string//迁入前注册地址
logonAdd:string//注册地址
operatingAdd:string//经营地址
// isPhysicalPresence:boolean//是否实地孵化 暂时弃用
leasedArea:number//租赁面积(平方米)
draftLock:boolean//草稿锁,true为提交之后,false为草稿 默认=false
createTime:number//录入时间
/**表方法 */
tableName;
sql;
moreTableSql;
constructor(tableName:string) {
this.tableName = tableName;
/**单表查询语句 */
enum sqlEnum {
获取任务id相关的企业列表=``,
}
/**多表联查语句 */
enum moreSqlEnum {
}
this.sql = sqlEnum;
this.moreTableSql = moreSqlEnum;
}
}
let appointModel = new enterpriseClass("enterprise");
\ No newline at end of file
......@@ -18,7 +18,7 @@ export function setRouter(httpServer) {
/**基础数据 */
httpServer.post('/fuhuaqi/base', checkFuHuaQiToken, asyncHandler(baseInfo));
httpServer.post('/fuhuaqi/mydata', checkFuHuaQiToken, asyncHandler(myDataInfo));
httpServer.post('/fuhuaqi/base/update', asyncHandler(updateMyDataInfo));
httpServer.post('/fuhuaqi/base/update', checkFuHuaQiToken, asyncHandler(updateMyDataInfo));
/**任务 */
httpServer.post('/fuhuaqi/task/list', checkFuHuaQiToken, asyncHandler(taskList));
httpServer.post('/fuhuaqi/task/submit', checkFuHuaQiToken, asyncHandler(submitTask));
......@@ -32,8 +32,8 @@ export function setRouter(httpServer) {
/**融资企业填报 */
httpServer.post('/fuhuaqi/financing/create', checkFuHuaQiToken, asyncHandler(createFinancingInfo));
httpServer.post('/fuhuaqi/financing/update', checkFuHuaQiToken, asyncHandler(updateFinancingInfo));
httpServer.post('/fuhuaqi/financing/select', checkFuHuaQiToken, asyncHandler(selectFinancingInfo));
httpServer.post('/fuhuaqi/financing/delete', checkFuHuaQiToken, asyncHandler(delFinancingInfo));
httpServer.post('/fuhuaqi/financing/select', checkFuHuaQiToken, asyncHandler(selectEnterpriseFinancingInfo));
httpServer.post('/fuhuaqi/financing/delete', checkFuHuaQiToken, asyncHandler(delEnterpriseFinancingInfo));
httpServer.post('/admin/financing/namelist', asyncHandler(getFinancingInfoByName));
/**新注册或迁入企业 */
......@@ -41,8 +41,8 @@ export function setRouter(httpServer) {
httpServer.post('/fuhuaqi/enterprise/updateregister', checkFuHuaQiToken, asyncHandler(updateRegisterEnterprise));
httpServer.post('/fuhuaqi/enterprise/move', checkFuHuaQiToken, asyncHandler(moveInEnterprise));
httpServer.post('/fuhuaqi/enterprise/updatemove', checkFuHuaQiToken, asyncHandler(updateMoveInEnterprise));
httpServer.post('/fuhuaqi/enterprise/select', checkFuHuaQiToken, asyncHandler(selectEnterpriseFinancingInfo));
httpServer.post('/fuhuaqi/enterprise/delete', checkFuHuaQiToken, asyncHandler(delEnterpriseFinancingInfo));
httpServer.post('/fuhuaqi/enterprise/select', checkFuHuaQiToken, asyncHandler(selectEnterpriseInfo));
httpServer.post('/fuhuaqi/enterprise/delete', checkFuHuaQiToken, asyncHandler(delEnterpriseInfo));
}
......@@ -125,7 +125,7 @@ async function updateRegisterEnterprise(req, res) {
* @param req
* @param res
*/
async function selectFinancingInfo(req, res) {
async function selectEnterpriseInfo(req, res) {
let reqConf = {uscc: 'String' };
let { uscc } = checkReqParam(reqConf, req.body);
......@@ -154,7 +154,7 @@ async function selectEnterpriseFinancingInfo(req, res) {
* @param req
* @param res
*/
async function delFinancingInfo(req, res) {
async function delEnterpriseInfo(req, res) {
let reqConf = {uscc: 'String' };
let { uscc } = checkReqParam(reqConf, req.body);
......
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