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
bdeeeda7
Commit
bdeeeda7
authored
Feb 22, 2023
by
lixinming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
逻辑优化和注释
parent
b15f8d54
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
156 additions
and
94 deletions
+156
-94
enterprise.ts
src/biz/enterprise/enterprise.ts
+0
-0
financing.ts
src/biz/enterprise/financing.ts
+0
-0
base.ts
src/biz/fuHuqQi/base.ts
+0
-0
task.ts
src/biz/fuHuqQi/task.ts
+57
-62
eccFormParamConfig.ts
src/config/eccFormParamConfig.ts
+34
-1
errorEnum.ts
src/config/errorEnum.ts
+3
-0
enterprise.ts
src/data/enterprise/enterprise.ts
+22
-6
fuhuaqi.ts
src/data/fuHuaQi/fuhuaqi.ts
+8
-11
task.ts
src/data/fuHuaQi/task.ts
+2
-2
enterprise.ts
src/routers/mobileClient/enterprise.ts
+2
-2
system.ts
src/tools/system.ts
+14
-0
verificationEnum.ts
src/util/verificationEnum.ts
+14
-10
No files found.
src/biz/enterprise/enterprise.ts
View file @
bdeeeda7
This diff is collapsed.
Click to expand it.
src/biz/enterprise/financing.ts
View file @
bdeeeda7
This diff is collapsed.
Click to expand it.
src/biz/fuHuqQi/base.ts
View file @
bdeeeda7
This diff is collapsed.
Click to expand it.
src/biz/fuHuqQi/task.ts
View file @
bdeeeda7
/**
* 孵化器任务相关逻辑
* 作者: 李
某
* 作者: 李
欣鸣
* 任务相关逻辑 包括任务的增删改查 管理后台的任务列表逻辑
*
* 需求说明 1.任务一个月只下一次 不填次月失效
* 2.任务提交之后不可以修改
* 3.月度出租率的任务为必填 其他两个可以为空
* 4.完成的任务将不再列表中显示
* 5.每月1日0时0分,将任务下发至孵化器表中未被禁用的孵化器中
* 实现 1.每个月月初系统生成任务列表在task表中 由isSubmit字段控制是否提交
* 2.任务对应的数据存在各表中 当提交任务时 将draftLock 字段置为true
* 3.任务相关的id统一使用 /tools/system 中的 getTaskId() 获取
*/
import
moment
=
require
(
"moment"
);
...
...
@@ -10,7 +17,7 @@ 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
{
findAll
NotDisabled
FuHuaQi
}
from
"../../data/fuHuaQi/fuhuaqi"
;
import
*
as
monthTableData
from
"../../data/fuHuaQi/monthTable"
;
import
*
as
taskData
from
"../../data/fuHuaQi/task"
;
import
{
BizError
}
from
"../../util/bizError"
;
...
...
@@ -19,40 +26,49 @@ import { getTaskId, getTimeKey } from "../../tools/system";
/**
*
获取
孵化器的任务列表
* 孵化器的任务列表
* 小程序端
* @param uscc 孵化器统一信用
* @returns [{type:1, title:'', enterpriseList:[] }]
*/
export
async
function
fuHuaQiTaskList
(
uscc
:
string
)
{
let
result
=
[];
/**得到这个月的任务map taskMap格式为{type:{isSubmit}} */
const
TaskId
=
getTaskId
(
uscc
);
let
taskMap
=
await
taskData
.
findFuHuaQiTaskByTaskId
(
TaskId
);
// let taskTypeMapConf = {}
;
let
result
=
[]
;
for
(
let
key
in
TASKTYPEENUM
)
{
let
k
:
any
=
key
;
if
(
isNaN
(
k
))
{
const
Value
=
k
;
const
KeyStr
=
TASKTYPEENUM
[
key
]
let
keyNumber
=
parseInt
(
KeyStr
);
let
onceObj
=
{
key
:
keyNumber
,
title
:
Value
,
enterpriseList
:[]};
let
onceTaskInfo
=
taskMap
[
KeyStr
];
if
(
!
onceTaskInfo
.
isSubmit
)
{
//没有提交任务
let
anyKey
:
any
=
key
;
/** 当key是枚举的键的时候 进入到逻辑 */
if
(
isNaN
(
anyKey
))
{
const
ValueStr
=
TASKTYPEENUM
[
key
];
//字符型的枚举值 也就是 "1"或者"2"或者"3"
const
ValueNumber
=
parseInt
(
ValueStr
);
//number型的枚举值 也就是 1或者2或者3
let
onceObj
=
{
key
:
ValueNumber
,
title
:
anyKey
,
//标题
enterpriseList
:[]
//相关的列表 这里不应该用这个字段名称 当时不能修改前端 沿用了这个字段名称
};
/**没有提交任务 则获取本月提交的任务相关信息 */
if
(
!
taskMap
[
ValueStr
].
isSubmit
)
{
let
dataList
=
[];
switch
(
keyNumber
)
{
case
TASKTYPEENUM
.
孵化器月度填报
:
dataList
=
await
monthTableData
.
findmonthTableListByTaskId
(
TaskId
);
break
;
case
TASKTYPEENUM
.
新注册或迁入企业登记
:
switch
(
ValueNumber
)
{
case
TASKTYPEENUM
.
孵化器月度填报
:
/** 这里加限制 在月度任务中 isUpdate=true代表已经修改 isUpdate=false表示没有这个任务 详细说明看./month.ts注释*/
dataList
=
await
monthTableData
.
findmonthTableListByTaskId
(
TaskId
);
break
;
case
TASKTYPEENUM
.
新注册或迁入企业登记
:
/**限制 draftLock = false 即草稿数据 这里可以不用这个限制 */
dataList
=
await
findEnterpriseListByTaskId
(
TaskId
);
dataList
.
forEach
(
item
=>
{
item
.
uscc
=
item
.
draftId
;
//这里转换一下,为了不改前端代码 使用uscc这个名称,但是实际是draftId
});
break
;
case
TASKTYPEENUM
.
融资企业填报
:
dataList
=
await
findFinancingListByTaskId
(
TaskId
);
break
;
case
TASKTYPEENUM
.
融资企业填报
:
/**限制 draftLock = false 即草稿数据 这里可以不用这个限制 */
dataList
=
await
findFinancingListByTaskId
(
TaskId
);
break
;
}
dataList
.
forEach
(
info
=>
{
...
...
@@ -78,12 +94,14 @@ export async function fuHuaQiTaskList(uscc:string) {
export
async
function
checkTask
(
uscc
:
string
,
taskType
:
number
)
{
const
TaskId
=
getTaskId
(
uscc
);
let
taskInfo
=
await
taskData
.
findEnterpriseByTaskIdAndType
(
TaskId
,
taskType
);
/**提交限制 */
if
(
!
taskInfo
)
throw
new
BizError
(
ERRORENUM
.
任务不存在
,
uscc
,
TaskId
);
if
(
taskInfo
.
isSubmit
)
throw
new
BizError
(
ERRORENUM
.
不能重复提交任务
,
uscc
,
taskType
);
switch
(
taskType
)
{
case
TASKTYPEENUM
.
孵化器月度填报
:
/**月度报表每个月初和任务数据一起初始化 所以只需要修改状态 */
let
monthTableInfo
=
await
monthTableData
.
findMonthTableByTaskId
(
TaskId
);
if
(
!
monthTableInfo
.
isUpdate
)
throw
new
BizError
(
ERRORENUM
.
该报表需要填写本月内容后提交
,
uscc
,
taskType
);
if
(
monthTableInfo
.
draftLock
)
throw
new
BizError
(
ERRORENUM
.
不能重复提交任务
,
uscc
,
taskType
,
'月度表lock = true'
);
...
...
@@ -92,14 +110,16 @@ export async function checkTask(uscc:string, taskType:number) {
await
monthTableInfo
.
save
();
break
;
case
TASKTYPEENUM
.
新注册或迁入企业登记
:
/**将录入的企业数据 draftLock 改为 true 表示不再是草稿状态 */
await
updateEnterpriseDraftLock
(
TaskId
);
break
;
case
TASKTYPEENUM
.
融资企业填报
:
/**将录入的融资数据 draftLock 改为 true 表示不再是草稿状态 */
await
updateFinancingDraftLock
(
TaskId
);
break
;
}
/
/添加一条任务
/
** 修改任务状态标识 和相关信息 */
taskInfo
.
isSubmit
=
true
;
taskInfo
.
submitTime
=
new
Date
().
valueOf
();
...
...
@@ -112,18 +132,16 @@ export async function checkTask(uscc:string, taskType:number) {
/**
* 发放任务
* 系统自发
* 需求说明:
* 每月1日0时0分,将任务下发至孵化器表中未被禁用的孵化器中
*
* 下发任务的同时初始化月度报表数据
*/
export
async
function
provideTask
()
{
const
TimeKey
=
getTimeKey
();
let
taskCount
=
await
taskData
.
findTaskCountByKey
(
TimeKey
);
if
(
taskCount
)
{}
//todo 重复创建了任务
let
fuHuaQiList
=
await
findAllFuHuaQi
();
if
(
taskCount
)
{
new
BizError
(
ERRORENUM
.
系统错误
,
'重复创建了任务'
);
return
;
}
const
Month
=
new
Date
().
getMonth
()
+
1
;
let
addList
=
[];
//任务列表
let
monthList
=
[];
//月度填报列表
...
...
@@ -131,48 +149,25 @@ export async function provideTask() {
const
YearNumber
=
new
Date
().
getFullYear
();
const
MonthTableName
=
`
${
MonthNumber
}
月孵化器月度填报`
;
let
fuHuaQiList
=
await
findAllNotDisabledFuHuaQi
();
fuHuaQiList
.
forEach
(
info
=>
{
let
{
uscc
}
=
info
;
let
taskId
=
getTaskId
(
uscc
);
addList
.
push
({
key
:
TimeKey
,
type
:
TASKTYPEENUM
.
孵化器月度填报
,
taskId
,
fuHuaQiUscc
:
uscc
,
isSubmit
:
false
},{
key
:
TimeKey
,
type
:
TASKTYPEENUM
.
新注册或迁入企业登记
,
taskId
,
fuHuaQiUscc
:
uscc
,
isSubmit
:
false
},{
key
:
TimeKey
,
type
:
TASKTYPEENUM
.
融资企业填报
,
taskId
,
fuHuaQiUscc
:
uscc
,
isSubmit
:
false
});
monthList
.
push
({
taskId
,
name
:
MonthTableName
,
fuHuaQiUscc
:
uscc
,
month
:
MonthNumber
,
year
:
YearNumber
,
draftLock
:
false
});
addList
.
push
(
{
key
:
TimeKey
,
type
:
TASKTYPEENUM
.
孵化器月度填报
,
taskId
,
fuHuaQiUscc
:
uscc
,
isSubmit
:
false
},
{
key
:
TimeKey
,
type
:
TASKTYPEENUM
.
新注册或迁入企业登记
,
taskId
,
fuHuaQiUscc
:
uscc
,
isSubmit
:
false
},
{
key
:
TimeKey
,
type
:
TASKTYPEENUM
.
融资企业填报
,
taskId
,
fuHuaQiUscc
:
uscc
,
isSubmit
:
false
});
/**任务报表的初始状态为 草稿(draftLock=fals) 未被编辑(isUpdate=false) */
monthList
.
push
({
taskId
,
name
:
MonthTableName
,
fuHuaQiUscc
:
uscc
,
month
:
MonthNumber
,
year
:
YearNumber
,
draftLock
:
false
,
isUpdate
:
false
});
});
try
{
/**初始化 任务 */
await
taskData
.
createTaskToList
(
addList
);
/**添加月度填报表 */
/**初始化 月度填报表 */
await
monthTableData
.
createMonthTableToList
(
monthList
);
logHandle
(
`添加了
${
addList
.
length
}
`
);
}
catch
(
err
)
{
//todo添加异常了
new
BizError
(
ERRORENUM
.
系统错误
,
'添加任务和月度报表的时候 出现了异常 请检查数据库 '
,
err
);
}
}
src/config/eccFormParamConfig.ts
View file @
bdeeeda7
...
...
@@ -19,6 +19,16 @@ export const BaseParamUpdateConfig = {
acreagePersonalUse
:{
type
:
"Number"
,
notMustHave
:
true
},
//孵化器自用面积(㎡)
hatchingGround
:{
type
:
"[Object]"
,
notMustHave
:
true
},
//经备案孵化场地
};
/**
* 使用端: 小程序端【孵化器入口】
* 场景: 验证经备案孵化场地
* 备注: 当填了案孵化场地数据 验证经备案孵化场地
*/
export
const
BaseParamUpdateHatchingGroundConfig
=
{
personInChargeAdd
:{
type
:
"String"
},
//孵化场地地址
siteAcreage
:{
type
:
"Number"
},
//孵化场地面积(㎡)
leasePrice
:{
type
:
"Number"
},
//孵化场地出租单价
};
/**
...
...
@@ -43,6 +53,21 @@ export const OrganizationParamUpdateConfig = {
personInChargePhone
:{
type
:
"String"
,
notMustHave
:
true
},
// {key:"负责人联系电话"},
operationModelDes
:{
type
:
"String"
,
notMustHave
:
true
},
//{key:"运营模式描述"},
};
/**
* 使用端: 小程序端【孵化器入口】
* 场景: 机构信息中的创始团队
* 备注: 更新机构信息时 当选择了创始团队
*/
export
const
OrganizationParamFoundingTeamUpdateConfig
=
{
type
:{
type
:
"Number"
},
//人才类型
memberName
:{
type
:
"String"
},
//成员姓名
memberSex
:{
type
:
"Number"
},
//成员性别
memberAge
:{
type
:
"Number"
},
//成员年龄
memberDEGREE
:{
type
:
"Number"
},
//成员最高学历
memberSchool
:{
type
:
"String"
},
//毕业学校
des
:{
type
:
"String"
},
//履历描述
};
/**
...
...
@@ -164,7 +189,15 @@ export const FinancingParamUpdateConfig = {
fuHuaQiInvestmentStyle
:{
type
:
"Number"
,
notMustHave
:
true
},
//孵化器投资方式
financingRounds
:{
type
:
"Number"
},
//融资轮次
};
/**
* 使用端: 小程序端【孵化器入口】
* 场景: 创建融资企业登记选择了孵化器投资
* 备注:
*/
export
const
FinancingParamSubConfig
=
{
fuHuaQiInvestmentAmount
:{
type
:
"Number"
},
fuHuaQiInvestmentStyle
:{
type
:
"Number"
}
}
/**
* 使用端: 管理后台
...
...
src/config/errorEnum.ts
View file @
bdeeeda7
...
...
@@ -23,6 +23,9 @@ export enum ERRORENUM {
该孵化器账号信息已存在
,
密码不一致
,
密码只能由
6
至
18
位字符和数字组成
,
统一社会信用代码不合法
,
统一社会信用代码重复
,
系统错误
}
export
enum
ERRORCODEENUM
{
...
...
src/data/enterprise/enterprise.ts
View file @
bdeeeda7
...
...
@@ -61,6 +61,7 @@ export async function findEnterpriseByUscc(uscc:string) {
return
await
enterpriseModel
.
selectOnceData
({
uscc
});
}
/**
* 通过草稿箱id获取企业信息
* 支持.save方法保存对象修改
...
...
@@ -73,12 +74,24 @@ export async function findEnterpriseByDraftId(draftId:string) {
/**
* 根据参数查询单个企业信息
* @param param
* @returns
*/
export
async
function
selectOneEnterpriseByParam
(
param
:
object
)
{
return
await
enterpriseModel
.
findOne
(
param
);
}
/**
* 通过taskId 获取此次任务添加的企业列表
* @param taskId 任务id 格式遵循tool中getTaskId
* @returns [{}]
* 限制返回 draftId name isCreate uscc 字段
* @returns [{draftId}]
*/
export
async
function
findEnterpriseListByTaskId
(
taskId
:
string
)
{
return
await
enterpriseModel
.
find
({
taskId
,
draftLock
:
false
});
return
await
enterpriseModel
.
find
({
taskId
,
draftLock
:
false
}
,
'draftId name isCreate uscc'
);
}
...
...
@@ -181,12 +194,15 @@ export async function findEnterpriseInfoByName(name:string) {
/**
* 获取孵化器下的所有企业信息
* 获取孵化器下的所有已经提交的企业信息
* 限制返回 name
logonAdd
operatingAdd
* @param fuHuaQiUscc 孵化器统一信用代码
* @returns []
*/
export
async
function
find
EnterpriseListByFuHuaQiUsccName
(
fuHuaQiUscc
:
string
)
{
return
await
enterpriseModel
.
find
({
fuHuaQiUscc
,
draftLock
:
true
});
export
async
function
find
SubmittedEnterpriseListByFuHuaQiUscc
(
fuHuaQiUscc
:
string
)
{
return
await
enterpriseModel
.
find
({
fuHuaQiUscc
,
draftLock
:
true
}
,
'name logonAdd operatingAdd'
);
}
...
...
@@ -194,7 +210,7 @@ export async function findEnterpriseListByFuHuaQiUsccName(fuHuaQiUscc:string) {
* 查询所有已绑定过的孵化器id
* @returns [孵化器id]
*/
export
async
function
findAllBindFuHuaQi
()
{
export
async
function
findAllBindFuHuaQi
UsccList
()
{
return
await
enterpriseModel
.
distinct
(
'fuHuaQiUscc'
);
}
...
...
src/data/fuHuaQi/fuhuaqi.ts
View file @
bdeeeda7
...
...
@@ -98,15 +98,6 @@ export async function findFuHuaQiByName(name:string) {
return
await
fuHuaQiModel
.
findOne
({
name
});
}
/**
* 通过信用代码获取孵化器信息
* @param uscc 信用代码
* @returns 信用代码为uscc的孵化器信息
*/
export
async
function
findFuHuaQiByUscc
(
uscc
:
string
)
{
return
await
fuHuaQiModel
.
findOne
({
uscc
});
}
/**
* 通过token获取孵化器信息 弃用
...
...
@@ -212,8 +203,14 @@ export async function findAllFuHuaQiOperationUsccMap() {
}
export
async
function
findAllFuHuaQi
()
{
return
await
fuHuaQiModel
.
find
({
userState
:
false
});
/**
* 查询所有非禁用状态下的孵化器
* 限制返回字段 uscc
* operationName
* @returns []
*/
export
async
function
findAllNotDisabledFuHuaQi
()
{
return
await
fuHuaQiModel
.
find
({
userState
:
false
},
'uscc operationName'
);
}
...
...
src/data/fuHuaQi/task.ts
View file @
bdeeeda7
...
...
@@ -44,13 +44,13 @@ export async function save(throwError=false) {
/**
* 通过任务id 查询孵化器任务
* @param taskId 任务id
* @returns {
1:{}, 2:{}
}
* @returns {
} 格式: key=type value={isSubmit
}
*/
export
async
function
findFuHuaQiTaskByTaskId
(
taskId
:
string
)
{
let
findList
=
await
fuHuaQiTaskModel
.
find
({
taskId
}).
exec
()
||
[];
let
taskMap
=
{};
findList
.
forEach
(
item
=>
{
taskMap
[
item
.
type
]
=
item
;
taskMap
[
item
.
type
]
=
{
isSubmit
:
item
.
isSubmit
}
;
});
return
taskMap
;
}
...
...
src/routers/mobileClient/enterprise.ts
View file @
bdeeeda7
...
...
@@ -84,7 +84,7 @@ async function updateMoveInEnterprise(req, res) {
* @param res
*/
async
function
selectEnterpriseInfo
(
req
,
res
)
{
/*这里改成了用DraftId,为了不改前端 依然使用uscc这个参数*/
/*这里改成了用DraftId,为了不改前端 依然使用uscc这个参数
名称
*/
let
reqConf
=
{
uscc
:
'String'
};
let
{
uscc
}
=
eccReqMustHaveParam
(
reqConf
,
req
.
body
);
...
...
@@ -99,7 +99,7 @@ async function updateMoveInEnterprise(req, res) {
* @param res
*/
async
function
delEnterpriseInfo
(
req
,
res
)
{
/*这里改成了用DraftId,为了不改前端 依然使用uscc这个参数*/
/*这里改成了用DraftId,为了不改前端 依然使用uscc这个参数
名称
*/
let
reqConf
=
{
uscc
:
'String'
};
let
{
uscc
}
=
eccReqMustHaveParam
(
reqConf
,
req
.
body
);
...
...
src/tools/system.ts
View file @
bdeeeda7
...
...
@@ -62,4 +62,17 @@ export function md5PwdStr(pwd:string) {
*/
export
function
getToken
(
uscc
:
string
)
{
return
md5
(
`
${
uscc
}${
new
Date
().
valueOf
()}${
Math
.
ceil
(
Math
.
random
()
*
100
)}
`
);
}
/**
* 校验uscc是否合法
* @param uscc
* @returns true/false
*/
export
function
eccUscc
(
uscc
:
string
)
{
let
isSuccess
=
false
;
if
(
uscc
.
search
(
/^
[
A-Za-z0-9
]{16}
$/
)
>
-
1
)
isSuccess
=
true
;
else
if
(
uscc
.
search
(
/^
[
A-Za-z0-9
]{16}
$/
)
>
-
1
)
isSuccess
=
true
;
return
isSuccess
;
}
\ No newline at end of file
src/util/verificationEnum.ts
View file @
bdeeeda7
...
...
@@ -3,23 +3,27 @@
*
*/
import
{
ERRORENUM
}
from
"../config/errorEnum"
;
import
{
BizError
}
from
"./bizError"
;
/**
* 校验value是否符合传入的枚举
* @param enumConf 目标枚举
* @param value 目标值
*
@returns true/false 是否通过校验
*
无返回 有异常直接报错
*/
export
function
checkEnumValue
(
enumConf
,
value
:
any
)
{
if
(
typeof
value
==
'number'
)
{
return
enumConf
[
value
]
?
true
:
false
;
export
function
eccEnumValue
(
name
:
string
,
key
:
string
,
enumConf
,
value
:
any
)
{
let
eccSuccess
=
true
;
if
(
typeof
value
==
'number'
&&
!
enumConf
[
value
]
)
{
eccSuccess
=
false
;
}
else
{
value
.
forEach
(
item
=>
{
if
(
!
enumConf
[
item
]
)
eccSuccess
=
false
;
});
}
let
checkSuccess
=
true
;
value
.
forEach
(
item
=>
{
if
(
!
enumConf
[
item
]
)
checkSuccess
=
false
;
});
return
checkSuccess
;
if
(
!
eccSuccess
)
throw
new
BizError
(
ERRORENUM
.
表单校验失败
,
`
${
name
}
下的
${
key
}
字段值为
${
value
}
不满足枚举范围`
);
}
...
...
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