明树Git Lab
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
J
jt_backend
Project
Project
Details
Activity
Releases
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
zengfanpei
jt_backend
Commits
49f1585a
Commit
49f1585a
authored
Dec 25, 2025
by
zfp1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
f195e92c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
279 additions
and
1 deletion
+279
-1
projectTzController.js
controller/projectTzController.js
+119
-0
tzJsqtzhs.js
db/model/jt/tzJsqtzhs.js
+62
-0
tzJsqtzhszb.js
db/model/jt/tzJsqtzhszb.js
+93
-0
projectRouter.js
router/projectRouter.js
+5
-1
No files found.
controller/projectTzController.js
View file @
49f1585a
...
@@ -433,6 +433,121 @@ async function getZdfxList(req, res, next) {
...
@@ -433,6 +433,121 @@ async function getZdfxList(req, res, next) {
next
(
error
);
next
(
error
);
}
}
}
}
async
function
createJsqtzhs
(
req
,
res
,
next
)
{
try
{
if
(
!
req
.
body
.
projectId
)
{
return
res
.
sendError
(
errorMessage
.
paramsError
);
}
//处理财务指标
let
flattenArr
=
[];
let
jsqtzhss
=
req
.
body
.
jsqtzhss
||
[[]];
//二维数组 多次上报
delete
req
.
body
.
jsqtzhss
;
for
(
let
index
=
0
;
index
<
jsqtzhss
.
length
;
index
++
)
{
const
element
=
jsqtzhss
[
index
];
for
(
let
i
=
0
;
i
<
element
.
length
;
i
++
)
{
let
ei
=
element
[
i
];
ei
.
groupBy
=
index
;
ei
.
projectId
=
req
.
body
.
projectId
;
flattenArr
.
push
(
ei
);
}
}
delete
req
.
body
.
jsqtzhss
;
await
DB
.
TzJsqtzhszb
.
bulkCreate
(
flattenArr
);
let
ret
=
await
DB
.
TzJsqtzhs
.
create
(
req
.
body
);
return
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
}
}
async
function
getJsqtzhsInfo
(
req
,
res
,
next
)
{
try
{
let
search
=
{};
if
(
req
.
body
.
id
)
{
search
.
id
=
req
.
body
.
id
;
}
if
(
req
.
body
.
projectId
)
{
search
.
projectId
=
req
.
body
.
projectId
;
}
if
(
_
.
isEmpty
(
search
))
{
return
res
.
sendError
(
errorMessage
.
paramsError
);
}
let
tzhs
=
await
DB
.
TzJsqtzhs
.
findOne
({
where
:
search
,
raw
:
true
});
if
(
!
(
tzhs
&&
tzhs
.
id
&&
tzhs
.
projectId
))
{
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
}
let
jsqtzhss
=
await
DB
.
TzJsqtzhszb
.
findAll
({
where
:
{
projectId
:
tzhs
.
projectId
},
raw
:
true
});
tzhs
.
jsqtzhss
=
_
.
values
(
_
.
groupBy
(
jsqtzhss
,
'groupBy'
))
||
[[]]
return
res
.
sendData
(
tzhs
);
}
catch
(
error
)
{
next
(
error
);
}
}
async
function
updateJsqtzhs
(
req
,
res
,
next
)
{
try
{
if
(
!
req
.
body
.
projectId
)
{
return
res
.
sendError
(
errorMessage
.
paramsError
);
}
let
jsqtzhss
=
req
.
body
.
jsqtzhss
||
[[]];
//二维数组 多次上报
let
ids3
=
[],
infos3
=
[],
newtjsqtzhss
=
[];
for
(
let
index
=
0
;
index
<
jsqtzhss
.
length
;
index
++
)
{
const
element
=
jsqtzhss
[
index
];
for
(
let
i
=
0
;
i
<
element
.
length
;
i
++
)
{
let
ei
=
element
[
i
];
ei
.
groupBy
=
index
;
ei
.
projectId
=
req
.
body
.
projectId
;
if
(
!
ei
.
id
)
{
if
(
!
_
.
isEmpty
(
ei
))
{
newtjsqtzhss
.
push
(
ei
);
}
}
else
{
ids3
.
push
(
ei
.
id
);
infos3
.
push
(
ei
);
}
}
}
await
DB
.
TzJsqtzhszb
.
destroy
({
where
:
{
projectId
:
req
.
body
.
projectId
,
id
:
{
[
Op
.
notIn
]:
ids3
}
}
});
// 删除id不在传入id数组里面的(用户在界面删除的)
await
DB
.
TzJsqtzhszb
.
bulkCreate
(
newtjsqtzhss
);
//创建新的 没有id的
await
Promise
.
all
(
infos3
.
map
(
item
=>
{
DB
.
TzJsqtzhszb
.
update
(
item
,
{
where
:
{
id
:
item
.
id
}
})
}));
delete
req
.
body
.
jsqtzhss
;
await
DB
.
TzJsqtzhs
.
update
(
req
.
body
,
{
where
:
{
id
:
req
.
body
.
id
}
});
return
res
.
sendData
({});
}
catch
(
error
)
{
next
(
error
);
}
}
async
function
getJsqtzhsList
(
req
,
res
,
next
)
{
try
{
let
page
=
req
.
body
.
page
||
1
;
let
limit
=
req
.
body
.
pagesize
||
req
.
body
.
pageSize
||
10
;
let
offset
=
(
page
-
1
)
*
limit
;
let
search
=
{};
search
.
order
=
[[
'createdAt'
,
'DESC'
]];
search
.
limit
=
limit
;
search
.
offset
=
offset
;
let
where
=
{
del
:
0
};
if
(
req
.
body
.
projectName
)
{
where
=
{
[
Op
.
or
]:
[
{
projectName
:
{
[
Op
.
like
]:
`%
${
req
.
body
.
projectName
}
%`
}
},
],
del
:
0
}
}
search
.
where
=
where
;
if
(
req
.
body
.
attributes
&&
req
.
body
.
attributes
.
length
)
{
search
.
attributes
=
req
.
body
.
attributes
;
}
let
ret
=
await
DB
.
TzJsqtzhs
.
findAndCountAll
(
search
);
return
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
}
}
...
@@ -449,4 +564,8 @@ module.exports = {
...
@@ -449,4 +564,8 @@ module.exports = {
updateZdfx
,
updateZdfx
,
getZdfxList
,
getZdfxList
,
getZdfxInfo
,
getZdfxInfo
,
createJsqtzhs
,
updateJsqtzhs
,
getJsqtzhsList
,
getJsqtzhsInfo
,
}
}
\ No newline at end of file
db/model/jt/tzJsqtzhs.js
0 → 100644
View file @
49f1585a
const
{
DataTypes
}
=
require
(
'sequelize'
);
const
sequelize
=
require
(
'../index'
);
const
moment
=
require
(
'moment'
);
/**
* 投中管理- 建设期投资回收
*/
const
TzJsqtzhs
=
sequelize
.
define
(
'TzJsqtzhs'
,
{
id
:
{
type
:
DataTypes
.
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
},
projectName
:
{
type
:
DataTypes
.
STRING
,
comment
:
"项目名称"
,
},
projectId
:
{
type
:
DataTypes
.
INTEGER
,
comment
:
"所属项目ID"
,
},
del
:
{
type
:
DataTypes
.
INTEGER
,
defaultValue
:
0
,
comment
:
"0 正常 1 删除"
},
createdAt
:
{
type
:
DataTypes
.
DATE
,
defaultValue
:
new
Date
(),
get
()
{
const
rawValue
=
this
.
getDataValue
(
'createdAt'
);
return
rawValue
?
moment
(
rawValue
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
''
;
}
},
updatedAt
:
{
// 同样处理 updatedAt
type
:
DataTypes
.
DATE
,
defaultValue
:
new
Date
(),
get
()
{
const
rawValue
=
this
.
getDataValue
(
'updatedAt'
);
return
rawValue
?
moment
(
rawValue
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
''
;
}
}
},
{
tableName
:
'jt_tz_jsqtzhs'
,
// 指定表名(如果与模型名不同)
timestamps
:
true
,
// 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
TzJsqtzhs
.
sync
({
// force: false,
// force: true ,//会删除已存在表并重新创建
alter
:
true
})
.
then
(()
=>
{
console
.
log
(
'TzJsqtzhs 表同步成功'
);
});
module
.
exports
=
TzJsqtzhs
;
\ No newline at end of file
db/model/jt/tzJsqtzhszb.js
0 → 100644
View file @
49f1585a
const
{
DataTypes
}
=
require
(
'sequelize'
);
const
sequelize
=
require
(
'../index'
);
const
moment
=
require
(
'moment'
);
/**
* 投中管理- 建设期投资回收关联表
*/
const
TzJsqtzhszb
=
sequelize
.
define
(
'TzJsqtzhszb'
,
{
id
:
{
type
:
DataTypes
.
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
},
year
:
{
type
:
DataTypes
.
DATE
,
comment
:
"年份"
,
},
month
:
{
type
:
DataTypes
.
INTEGER
,
comment
:
"月份"
,
},
xh
:
{
type
:
DataTypes
.
STRING
,
comment
:
"序号"
,
},
ndtzhsmb
:
{
type
:
DataTypes
.
DECIMAL
(
20
,
2
),
comment
:
"年度投资回收目标"
},
dyhs
:
{
type
:
DataTypes
.
DECIMAL
(
20
,
2
),
comment
:
"当月回收"
},
dyljhs
:
{
type
:
DataTypes
.
DECIMAL
(
20
,
2
),
comment
:
"当月累计回收"
},
ndjhwcl
:
{
type
:
DataTypes
.
DECIMAL
(
5
,
2
),
comment
:
"年度计划完成率 %"
},
bz
:
{
type
:
DataTypes
.
TEXT
,
comment
:
"备注"
,
},
groupBy
:
{
type
:
DataTypes
.
INTEGER
,
comment
:
"分组"
},
projectId
:
{
type
:
DataTypes
.
INTEGER
,
comment
:
"所属项目ID"
,
},
del
:
{
type
:
DataTypes
.
INTEGER
,
defaultValue
:
0
,
comment
:
"0 正常 1 删除"
},
createdAt
:
{
type
:
DataTypes
.
DATE
,
defaultValue
:
new
Date
(),
get
()
{
const
rawValue
=
this
.
getDataValue
(
'createdAt'
);
return
rawValue
?
moment
(
rawValue
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
''
;
}
},
updatedAt
:
{
// 同样处理 updatedAt
type
:
DataTypes
.
DATE
,
defaultValue
:
new
Date
(),
get
()
{
const
rawValue
=
this
.
getDataValue
(
'updatedAt'
);
return
rawValue
?
moment
(
rawValue
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
''
;
}
}
},
{
tableName
:
'jt_tz_jsqtzhs'
,
// 指定表名(如果与模型名不同)
timestamps
:
true
,
// 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
TzJsqtzhszb
.
sync
({
// force: false,
// force: true ,//会删除已存在表并重新创建
alter
:
true
})
.
then
(()
=>
{
console
.
log
(
'TzJsqtzhszb 表同步成功'
);
});
module
.
exports
=
TzJsqtzhszb
;
\ No newline at end of file
router/projectRouter.js
View file @
49f1585a
...
@@ -67,7 +67,11 @@ router.post('/updateZdfx', projectTzController.updateZdfx);
...
@@ -67,7 +67,11 @@ router.post('/updateZdfx', projectTzController.updateZdfx);
router
.
post
(
'/getZdfxList'
,
projectTzController
.
getZdfxList
);
router
.
post
(
'/getZdfxList'
,
projectTzController
.
getZdfxList
);
router
.
post
(
'/getZdfxInfo'
,
projectTzController
.
getZdfxInfo
);
router
.
post
(
'/getZdfxInfo'
,
projectTzController
.
getZdfxInfo
);
//建设期投资回收
router
.
post
(
'/createJsqtzhs'
,
projectTzController
.
createJsqtzhs
);
router
.
post
(
'/updateJsqtzhs'
,
projectTzController
.
updateJsqtzhs
);
router
.
post
(
'/getJsqtzhsList'
,
projectTzController
.
getJsqtzhsList
);
router
.
post
(
'/getJsqtzhsInfo'
,
projectTzController
.
getJsqtzhsInfo
);
module
.
exports
=
router
;
module
.
exports
=
router
;
\ No newline at end of file
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