Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zjxcxServer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
node_server
zjxcxServer
Commits
1f834465
Commit
1f834465
authored
Feb 06, 2023
by
lixinming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
69e71289
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
118 additions
and
19 deletions
+118
-19
serverConfig.xml
serverConfig.xml
+8
-1
task.ts
src/biz/fuHuqQi/task.ts
+34
-3
enum.ts
src/config/enum.ts
+4
-3
serverConfig.ts
src/config/serverConfig.ts
+11
-2
enterprise.ts
src/data/enterprise/enterprise.ts
+11
-1
financing.ts
src/data/enterprise/financing.ts
+14
-2
task.ts
src/data/fuHuaQi/task.ts
+8
-2
dbConnect.ts
src/db/dbConnect.ts
+7
-5
dbInit.ts
src/db/dbInit.ts
+2
-0
tableInit.ts
src/db/tableInit.ts
+10
-0
main.ts
src/main.ts
+9
-0
tools.ts
src/util/tools.ts
+0
-0
No files found.
serverConfig.xml
View file @
1f834465
<config>
<config>
<port>
30001
</port>
<port>
30001
</port>
<mongodb>
mongodb://192.168.12.79:27017/adminDB?w=1
&
wtimeoutMS=30000
</mongodb>
<mongodb>
<path>
127.0.0.1
</path>
<port>
27017
</port>
<w>
1
</w>
<dataBase>
baseDB
</dataBase>
<wtimeoutMS>
30000
</wtimeoutMS>
</mongodb>
</config>
</config>
\ No newline at end of file
src/biz/fuHuqQi/task.ts
View file @
1f834465
...
@@ -5,8 +5,11 @@
...
@@ -5,8 +5,11 @@
*
*
*/
*/
import
{
TASKTYPEENUM
}
from
"../../config/enum"
;
import
{
findEnterpriseListByTaskId
}
from
"../../data/enterprise/enterprise"
;
import
{
findFinancingListByTaskId
}
from
"../../data/enterprise/financing"
;
import
{
findFuHuaQiTaskByKeyAndUscc
}
from
"../../data/fuHuaQi/task"
;
import
{
findFuHuaQiTaskByKeyAndUscc
}
from
"../../data/fuHuaQi/task"
;
import
{
getTaskId
}
from
"../../util/tools"
;
/**
/**
...
@@ -15,12 +18,40 @@ import { findFuHuaQiTaskByKeyAndUscc } from "../../data/fuHuaQi/task";
...
@@ -15,12 +18,40 @@ import { findFuHuaQiTaskByKeyAndUscc } from "../../data/fuHuaQi/task";
* @returns
* @returns
*/
*/
export
async
function
fuHuaQiTaskList
(
uscc
:
string
)
{
export
async
function
fuHuaQiTaskList
(
uscc
:
string
)
{
/**
* 返回格式 [{type:, }]
*/
let
result
=
[];
let
result
=
[];
const
timeKey
=
`
${
new
Date
().
getFullYear
()}${
new
Date
().
getMonth
()
+
1
}
`
;
const
timeKey
=
`
${
new
Date
().
getFullYear
()}${
new
Date
().
getMonth
()
+
1
}
`
;
let
taskList
=
await
findFuHuaQiTaskByKeyAndUscc
(
uscc
,
timeKey
);
let
taskMap
=
await
findFuHuaQiTaskByKeyAndUscc
(
uscc
,
timeKey
);
if
(
!
taskList
.
length
)
{
let
taskTypeMapConf
=
{};
for
(
let
key
in
TASKTYPEENUM
)
{
let
k
:
any
=
key
;
if
(
isNaN
(
k
))
taskTypeMapConf
[
TASKTYPEENUM
[
key
]]
=
key
;
}
const
TaskId
=
getTaskId
(
uscc
);
for
(
let
typeStr
in
taskTypeMapConf
)
{
let
typeKey
=
parseInt
(
typeStr
);
let
onceObj
=
{
key
:
typeStr
,
enterpriseList
:[]};
if
(
!
taskMap
[
typeStr
])
{
//没有提交任务
if
(
TASKTYPEENUM
.
孵化器月度填报
==
typeKey
)
{
// enterpriseList.push();
continue
;
}
let
dataList
=
[];
if
(
TASKTYPEENUM
.
新注册或迁入企业登记
==
typeKey
)
dataList
=
await
findEnterpriseListByTaskId
(
TaskId
);
if
(
TASKTYPEENUM
.
融资企业填报
==
typeKey
)
dataList
=
await
findFinancingListByTaskId
(
TaskId
);
dataList
.
forEach
(
info
=>
{
onceObj
.
enterpriseList
.
push
(
info
.
name
);
});
}
result
.
push
(
onceObj
);
}
}
return
result
;
return
result
;
}
}
src/config/enum.ts
View file @
1f834465
export
enum
ERRORENUM
{
export
enum
TASKTYPEENUM
{
未找到数据
,
孵化器月度填报
=
1
,
参数错误
,
融资企业填报
,
新注册或迁入企业登记
}
}
src/config/serverConfig.ts
View file @
1f834465
...
@@ -18,8 +18,13 @@ export async function initConfig() {
...
@@ -18,8 +18,13 @@ export async function initConfig() {
let
{
port
,
mongodb
}
=
configInfo
.
config
;
let
{
port
,
mongodb
}
=
configInfo
.
config
;
systemConfig
.
port
=
parseInt
(
port
[
0
]);
systemConfig
.
port
=
parseInt
(
port
[
0
]);
systemConfig
.
mongodbStr
=
mongodb
[
0
]
const
MongoPath
=
mongodb
[
0
].
path
[
0
];
const
MongoPort
=
mongodb
[
0
].
port
[
0
];
const
MongoW
=
mongodb
[
0
].
w
[
0
];
const
MongoDataBase
=
mongodb
[
0
].
dataBase
[
0
];
const
MongoWtimeoutMS
=
mongodb
[
0
].
wtimeoutMS
[
0
];
systemConfig
.
mongodbStr
=
analysisMongoConnectStr
(
MongoPath
,
MongoPort
,
MongoDataBase
,
MongoW
,
MongoWtimeoutMS
);
}
}
console
.
log
(
"config init success"
);
console
.
log
(
"config init success"
);
...
@@ -28,6 +33,10 @@ export async function initConfig() {
...
@@ -28,6 +33,10 @@ export async function initConfig() {
throw
new
BizError
(
"服务器配置解析错误 请检查根目录下 serverConfig.xml 文件是否正确"
);
throw
new
BizError
(
"服务器配置解析错误 请检查根目录下 serverConfig.xml 文件是否正确"
);
}
}
}
}
function
analysisMongoConnectStr
(
path
,
port
,
dataBase
,
w
,
timeOutMs
)
{
return
`mongodb://
${
path
}
:
${
port
}
/
${
dataBase
}
?w=
${
w
}
&wtimeoutMS=
${
timeOutMs
}
`
}
export
function
getEnum
()
{
export
function
getEnum
()
{
...
...
src/data/enterprise/enterprise.ts
View file @
1f834465
...
@@ -3,7 +3,7 @@ import { baseDB } from '../../db/dbInit';
...
@@ -3,7 +3,7 @@ import { baseDB } from '../../db/dbInit';
const
enterpriseSchema
=
new
Schema
({
const
enterpriseSchema
=
new
Schema
({
name
:
{
type
:
String
,
index
:
true
},
//企业名称
name
:
{
type
:
String
,
index
:
true
},
//企业名称
id
:{
type
:
String
,
index
:
true
},
//唯一标识
taskId
:{
type
:
String
,
index
:
true
},
//任务id
uscc
:{
type
:
String
,
index
:
true
},
//统一信用代码
uscc
:{
type
:
String
,
index
:
true
},
//统一信用代码
logonTime
:
Number
,
//注册时间
logonTime
:
Number
,
//注册时间
logonAdd
:
String
,
//注册地址
logonAdd
:
String
,
//注册地址
...
@@ -22,3 +22,12 @@ var enterpriseModel;
...
@@ -22,3 +22,12 @@ var enterpriseModel;
export
function
initModel
(){
export
function
initModel
(){
enterpriseModel
=
baseDB
.
model
(
'enterprise'
,
enterpriseSchema
);
enterpriseModel
=
baseDB
.
model
(
'enterprise'
,
enterpriseSchema
);
}
}
/**
* 通过taskId 获取此次任务提交的企业列表
* @param taskId
* @returns
*/
export
async
function
findEnterpriseListByTaskId
(
taskId
:
string
)
{
return
await
enterpriseModel
.
findOne
({
taskId
}).
exec
();
}
\ No newline at end of file
src/data/enterprise/financing.ts
View file @
1f834465
...
@@ -2,8 +2,9 @@ import {Schema} from 'mongoose';
...
@@ -2,8 +2,9 @@ import {Schema} from 'mongoose';
import
{
baseDB
}
from
'../../db/dbInit'
;
import
{
baseDB
}
from
'../../db/dbInit'
;
const
financingSchema
=
new
Schema
({
const
financingSchema
=
new
Schema
({
uscc
:{
type
:
String
,
key
:
true
},
//统一信用代码
uscc
:{
type
:
String
,
index
:
true
},
//统一信用代码
id
:{
type
:
String
,
key
:
true
},
//唯一标识
name
:
String
,
//企业名称
taskId
:{
type
:
String
,
index
:
true
},
//任务id
createTime
:
Number
,
//入库时间
createTime
:
Number
,
//入库时间
financingTime
:
Number
,
//获得融资时间
financingTime
:
Number
,
//获得融资时间
financingAmount
:
Number
,
//融资金额(万元)
financingAmount
:
Number
,
//融资金额(万元)
...
@@ -12,9 +13,19 @@ const financingSchema = new Schema({
...
@@ -12,9 +13,19 @@ const financingSchema = new Schema({
fuHuaQiInvestment
:{
type
:
Boolean
,
default
:
false
},
//孵化器是否投资
fuHuaQiInvestment
:{
type
:
Boolean
,
default
:
false
},
//孵化器是否投资
fuHuaQiInvestmentAmount
:
Number
,
//孵化器投资金额(万元)
fuHuaQiInvestmentAmount
:
Number
,
//孵化器投资金额(万元)
fuHuaQiInvestmentStyle
:
Number
,
//孵化器投资方式
fuHuaQiInvestmentStyle
:
Number
,
//孵化器投资方式
draftLock
:{
type
:
Boolean
,
default
:
false
},
//草稿锁,true为提交之后,false为草稿
});
});
var
financingModel
;
var
financingModel
;
export
function
initModel
(){
export
function
initModel
(){
financingModel
=
baseDB
.
model
(
'financing'
,
financingSchema
);
financingModel
=
baseDB
.
model
(
'financing'
,
financingSchema
);
}
}
/**
* 通过taskId 获取此次任务提交的融资列表
* @param taskId
* @returns
*/
export
async
function
findFinancingListByTaskId
(
taskId
:
string
)
{
return
await
financingModel
.
findOne
({
taskId
}).
exec
();
}
\ No newline at end of file
src/data/fuHuaQi/task.ts
View file @
1f834465
...
@@ -4,6 +4,7 @@ import { baseDB } from '../../db/dbInit';
...
@@ -4,6 +4,7 @@ import { baseDB } from '../../db/dbInit';
const
fuHuaQiTaskSchema
=
new
Schema
({
const
fuHuaQiTaskSchema
=
new
Schema
({
key
:{
type
:
String
,
index
:
true
},
//任务标识 格式为:YYYYMM
key
:{
type
:
String
,
index
:
true
},
//任务标识 格式为:YYYYMM
type
:
{
type
:
Number
,
index
:
true
},
//任务类型
type
:
{
type
:
Number
,
index
:
true
},
//任务类型
taskId
:
String
,
//任务id
fuHuaQiUscc
:
String
,
//任务所属孵化器id
fuHuaQiUscc
:
String
,
//任务所属孵化器id
createTime
:
Number
,
//提交时间
createTime
:
Number
,
//提交时间
relevanceId
:
String
,
//任务关联的表 financing 或 enterprise 的id
relevanceId
:
String
,
//任务关联的表 financing 或 enterprise 的id
...
@@ -16,6 +17,10 @@ export function initModel(){
...
@@ -16,6 +17,10 @@ export function initModel(){
}
}
export
async
function
findFuHuaQiTaskByKeyAndUscc
(
uscc
:
string
,
key
:
string
)
{
export
async
function
findFuHuaQiTaskByKeyAndUscc
(
uscc
:
string
,
key
:
string
)
{
let
result
=
await
fuHuaQiTaskModel
.
find
({
uscc
,
key
}).
exec
();
let
findList
=
await
fuHuaQiTaskModel
.
find
({
uscc
,
key
}).
exec
()
||
[];
return
result
;
let
taskMap
=
{};
findList
.
forEach
(
item
=>
{
taskMap
[
item
.
key
]
=
item
;
});
return
taskMap
;
}
}
\ No newline at end of file
src/db/dbConnect.ts
View file @
1f834465
...
@@ -6,14 +6,16 @@ let defaultOptions = {
...
@@ -6,14 +6,16 @@ let defaultOptions = {
// reconnectTries:1000,
// reconnectTries:1000,
// reconnectInterval:3000,
// reconnectInterval:3000,
keepAlive
:
1
,
keepAlive
:
1
,
connectTimeoutMS
:
3000
0
,
connectTimeoutMS
:
3000
,
useCreateIndex
:
true
,
useCreateIndex
:
true
,
useUnifiedTopology
:
true
useUnifiedTopology
:
true
};
};
export
async
function
createDbConnect
(
connectUrl
:
string
,
options
?:
object
)
{
export
async
function
createDbConnect
(
connectUrl
:
string
,
options
?:
object
)
{
if
(
!
connectUrl
)
throw
new
Error
(
`wrong connect url
${
connectUrl
}
`
);
if
(
!
options
)
options
=
defaultOptions
;
if
(
!
options
)
options
=
defaultOptions
;
return
await
mongoose
.
createConnection
(
connectUrl
,
options
).
catch
(
return
await
mongoose
.
createConnection
(
connectUrl
,
options
).
catch
((
err
)
=>
{
throw
err
});
(
err
)
=>
{
throw
err
});
}
}
src/db/dbInit.ts
View file @
1f834465
...
@@ -8,11 +8,13 @@ var baseDB;
...
@@ -8,11 +8,13 @@ var baseDB;
export
async
function
initDB
()
{
export
async
function
initDB
()
{
//如果配置了mongoServerConstVal 才会连接mongo
//如果配置了mongoServerConstVal 才会连接mongo
if
(
systemConfig
.
mongodbStr
)
{
if
(
systemConfig
.
mongodbStr
)
{
console
.
log
(
systemConfig
.
mongodbStr
)
baseDB
=
await
createDbConnect
(
systemConfig
.
mongodbStr
).
catch
(
err
=>
{
baseDB
=
await
createDbConnect
(
systemConfig
.
mongodbStr
).
catch
(
err
=>
{
throw
err
throw
err
});
});
await
initTable
();
await
initTable
();
console
.
log
(
'init mongodb success'
);
}
else
{
}
else
{
throw
new
BizError
(
"xml中未配置mongo连接字符串 无法连接到mongodb"
);
throw
new
BizError
(
"xml中未配置mongo连接字符串 无法连接到mongodb"
);
}
}
...
...
src/db/tableInit.ts
View file @
1f834465
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"
;
export
async
function
initTable
()
{
export
async
function
initTable
()
{
taskinModel
.
initModel
();
fuhuaqiinModel
.
initModel
();
enterpriseinModel
.
initModel
();
financinginModel
.
initModel
();
}
}
\ No newline at end of file
src/main.ts
View file @
1f834465
import
{
fuHuaQiTaskList
}
from
"./biz/fuHuqQi/task"
;
import
{
initConfig
,
systemConfig
}
from
"./config/serverConfig"
;
import
{
initConfig
,
systemConfig
}
from
"./config/serverConfig"
;
import
{
initDB
}
from
"./db/dbInit"
;
import
{
httpServer
}
from
"./net/http_server"
;
import
{
httpServer
}
from
"./net/http_server"
;
async
function
lanuch
()
{
async
function
lanuch
()
{
await
initConfig
();
//初始化配置解析
await
initConfig
();
//初始化配置解析
await
initDB
();
httpServer
.
createServer
(
systemConfig
.
port
);
httpServer
.
createServer
(
systemConfig
.
port
);
console
.
log
(
'This indicates that the server is started successfully.'
);
console
.
log
(
'This indicates that the server is started successfully.'
);
await
t
();
}
async
function
t
()
{
await
fuHuaQiTaskList
(
'111'
);
}
}
lanuch
();
lanuch
();
\ No newline at end of file
src/util/tools.ts
View file @
1f834465
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment