Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
P
precision-effect
Project
Project
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
耿迪迪
precision-effect
Commits
e038652e
Commit
e038652e
authored
Jun 15, 2023
by
王晓倩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
交易项目导入
parent
982bc748
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
213 additions
and
6 deletions
+213
-6
TTransactionProjectController.java
...controller/transaction/TTransactionProjectController.java
+18
-0
TTransactionProject.java
...in/java/com/zehong/system/domain/TTransactionProject.java
+2
-3
TTransactionProjectMapper.java
...a/com/zehong/system/mapper/TTransactionProjectMapper.java
+8
-0
ITTransactionProjectService.java
...om/zehong/system/service/ITTransactionProjectService.java
+10
-0
TTransactionProjectServiceImpl.java
...g/system/service/impl/TTransactionProjectServiceImpl.java
+75
-0
TTransactionProjectMapper.xml
...n/resources/mapper/business/TTransactionProjectMapper.xml
+6
-1
project.js
precision-effect-web/src/api/transaction/project.js
+8
-0
index.vue
precision-effect-web/src/views/transaction/index.vue
+86
-2
No files found.
precision-effect-admin/src/main/java/com/zehong/web/controller/transaction/TTransactionProjectController.java
View file @
e038652e
...
...
@@ -16,6 +16,7 @@ import com.zehong.system.service.ITTransactionProjectService;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.List
;
...
...
@@ -82,6 +83,23 @@ public class TTransactionProjectController extends BaseController
return
util
.
exportExcel
(
list
,
"交易项目数据"
);
}
@Log
(
title
=
"交易项目维护"
,
businessType
=
BusinessType
.
IMPORT
)
@PostMapping
(
"/importData"
)
public
AjaxResult
importData
(
MultipartFile
file
,
boolean
updateSupport
)
throws
Exception
{
ExcelUtil
<
TTransactionProject
>
util
=
new
ExcelUtil
<
TTransactionProject
>(
TTransactionProject
.
class
);
List
<
TTransactionProject
>
transactionList
=
util
.
importExcel
(
file
.
getInputStream
());
String
message
=
tTransactionProjectService
.
importTransaction
(
transactionList
,
updateSupport
);
return
AjaxResult
.
success
(
message
);
}
@GetMapping
(
"/importTemplate"
)
public
AjaxResult
importTemplate
()
{
ExcelUtil
<
TTransactionProject
>
util
=
new
ExcelUtil
<
TTransactionProject
>(
TTransactionProject
.
class
);
return
util
.
importTemplateExcel
(
"交易项目数据"
);
}
/**
* 获取交易项目详细信息
*/
...
...
precision-effect-system/src/main/java/com/zehong/system/domain/TTransactionProject.java
View file @
e038652e
...
...
@@ -32,7 +32,7 @@ public class TTransactionProject extends BaseEntity
private
String
context
;
/** 定价类型:1.单价 2.议价 */
@Excel
(
name
=
"定价类型:1
.单价 2.
议价"
)
@Excel
(
name
=
"定价类型:1
定价 2
议价"
)
private
String
priceType
;
/** 单价 */
...
...
@@ -40,14 +40,13 @@ public class TTransactionProject extends BaseEntity
private
BigDecimal
price
;
/** 部门 */
@Excel
(
name
=
"部门"
)
@Excel
(
name
=
"部门
:103泽宏云研发部,104泽宏云技术部,105泽宏云销售部,200核算部,201综合管理部,202销售服务部
"
)
private
Long
deptId
;
/**部门名称*/
private
String
deptName
;
/** 是否删除:0否,1是 */
@Excel
(
name
=
"是否删除:0否,1是"
)
private
String
isDel
;
public
void
setTransactionProjectId
(
Long
transactionProjectId
)
...
...
precision-effect-system/src/main/java/com/zehong/system/mapper/TTransactionProjectMapper.java
View file @
e038652e
...
...
@@ -19,6 +19,14 @@ public interface TTransactionProjectMapper
*/
public
TTransactionProject
selectTTransactionProjectById
(
Long
transactionProjectId
);
/**
* 查询交易项目
*
* @param transactionProjectName 交易项目名称
* @return 交易项目
*/
public
TTransactionProject
selectTransactionProjectByName
(
String
transactionProjectName
);
/**
* 查询交易项目列表
*
...
...
precision-effect-system/src/main/java/com/zehong/system/service/ITTransactionProjectService.java
View file @
e038652e
...
...
@@ -58,4 +58,14 @@ public interface ITTransactionProjectService
* @return 结果
*/
public
int
deleteTTransactionProjectById
(
Long
transactionProjectId
);
/**
* 导入数据
*
* @param transactionList 数据列表
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
* @return 结果
*/
public
String
importTransaction
(
List
<
TTransactionProject
>
transactionList
,
Boolean
isUpdateSupport
);
}
precision-effect-system/src/main/java/com/zehong/system/service/impl/TTransactionProjectServiceImpl.java
View file @
e038652e
package
com
.
zehong
.
system
.
service
.
impl
;
import
java.util.List
;
import
com.zehong.common.core.domain.entity.SysUser
;
import
com.zehong.common.exception.CustomException
;
import
com.zehong.common.utils.DateUtils
;
import
com.zehong.common.utils.SecurityUtils
;
import
com.zehong.common.utils.StringUtils
;
import
com.zehong.system.service.ISysConfigService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.zehong.system.mapper.TTransactionProjectMapper
;
...
...
@@ -17,9 +25,13 @@ import com.zehong.system.service.ITTransactionProjectService;
@Service
public
class
TTransactionProjectServiceImpl
implements
ITTransactionProjectService
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
TTransactionProjectServiceImpl
.
class
);
@Autowired
private
TTransactionProjectMapper
tTransactionProjectMapper
;
@Autowired
private
ISysConfigService
configService
;
/**
* 查询交易项目
*
...
...
@@ -93,4 +105,67 @@ public class TTransactionProjectServiceImpl implements ITTransactionProjectServi
{
return
tTransactionProjectMapper
.
deleteTTransactionProjectById
(
transactionProjectId
);
}
/**
* 导入数据
*
* @param transactionList 数据列表
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
* @return 结果
*/
@Override
public
String
importTransaction
(
List
<
TTransactionProject
>
transactionList
,
Boolean
isUpdateSupport
)
{
if
(
StringUtils
.
isNull
(
transactionList
)
||
transactionList
.
size
()
==
0
)
{
throw
new
CustomException
(
"导入数据不能为空!"
);
}
int
successNum
=
0
;
int
failureNum
=
0
;
StringBuilder
successMsg
=
new
StringBuilder
();
StringBuilder
failureMsg
=
new
StringBuilder
();
for
(
TTransactionProject
transaction
:
transactionList
)
{
try
{
// 验证是否存在这个用户
TTransactionProject
project
=
tTransactionProjectMapper
.
selectTransactionProjectByName
(
transaction
.
getTransactionProjectName
());
if
(
StringUtils
.
isNull
(
project
))
{
this
.
insertTTransactionProject
(
transaction
);
successNum
++;
successMsg
.
append
(
"<br/>"
+
successNum
+
"、交易项目 "
+
transaction
.
getTransactionProjectName
()
+
" 导入成功"
);
}
else
if
(
isUpdateSupport
)
{
transaction
.
setTransactionProjectId
(
project
.
getTransactionProjectId
());
this
.
updateTTransactionProject
(
transaction
);
successNum
++;
successMsg
.
append
(
"<br/>"
+
successNum
+
"、交易项目 "
+
transaction
.
getTransactionProjectName
()
+
" 更新成功"
);
}
else
{
failureNum
++;
failureMsg
.
append
(
"<br/>"
+
failureNum
+
"、交易项目 "
+
transaction
.
getTransactionProjectName
()
+
" 已存在"
);
}
}
catch
(
Exception
e
)
{
failureNum
++;
String
msg
=
"<br/>"
+
failureNum
+
"、交易项目 "
+
transaction
.
getTransactionProjectName
()
+
" 导入失败:"
;
failureMsg
.
append
(
msg
+
e
.
getMessage
());
log
.
error
(
msg
,
e
);
}
}
if
(
failureNum
>
0
)
{
failureMsg
.
insert
(
0
,
"很抱歉,导入失败!共 "
+
failureNum
+
" 条数据格式不正确,错误如下:"
);
throw
new
CustomException
(
failureMsg
.
toString
());
}
else
{
successMsg
.
insert
(
0
,
"恭喜您,数据已全部导入成功!共 "
+
successNum
+
" 条,数据如下:"
);
}
return
successMsg
.
toString
();
}
}
precision-effect-system/src/main/resources/mapper/business/TTransactionProjectMapper.xml
View file @
e038652e
...
...
@@ -40,6 +40,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include
refid=
"selectTTransactionProjectVo"
/>
where transaction_project_id = #{transactionProjectId}
</select>
<select
id=
"selectTransactionProjectByName"
parameterType=
"String"
resultMap=
"TTransactionProjectResult"
>
<include
refid=
"selectTTransactionProjectVo"
/>
where transaction_project_name = #{transactionProjectName}
</select>
<insert
id=
"insertTTransactionProject"
parameterType=
"TTransactionProject"
useGeneratedKeys=
"true"
keyProperty=
"transactionProjectId"
>
insert into t_transaction_project
...
...
@@ -76,7 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"transactionItemName != null"
>
transaction_item_name = #{transactionItemName},
</if>
<if
test=
"context != null"
>
context = #{context},
</if>
<if
test=
"priceType != null"
>
price_type = #{priceType},
</if>
<if
test=
"price != null"
>
price = #{price},
</if>
price = #{price},
<if
test=
"deptId != null"
>
dept_id = #{deptId},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime},
</if>
...
...
precision-effect-web/src/api/transaction/project.js
View file @
e038652e
...
...
@@ -60,3 +60,11 @@ export function exportProject(query) {
params
:
query
})
}
// 下载导入模板
export
function
importTemplate
()
{
return
request
({
url
:
'/transaction/project/importTemplate'
,
method
:
'get'
})
}
precision-effect-web/src/views/transaction/index.vue
View file @
e038652e
...
...
@@ -56,6 +56,16 @@
v-hasPermi=
"['system:project:remove']"
>
删除
</el-button>
</el-col>
<el-col
:span=
"1.5"
>
<el-button
type=
"info"
plain
icon=
"el-icon-upload2"
size=
"mini"
@
click=
"handleImport"
v-hasPermi=
"['system:user:import']"
>
导入
</el-button>
</el-col>
<el-col
:span=
"1.5"
>
<el-button
type=
"warning"
...
...
@@ -77,7 +87,7 @@
<el-table-column
label=
"交易类型"
align=
"center"
prop=
"priceType"
>
<template
slot-scope=
"scope"
>
<span
v-if=
"scope.row.priceType == '1'"
>
定价
</span>
<span
v-if=
"scope.row.priceType == '2'"
>
仪
价
</span>
<span
v-if=
"scope.row.priceType == '2'"
>
议
价
</span>
</
template
>
</el-table-column>
<el-table-column
label=
"单价"
align=
"center"
prop=
"price"
>
...
...
@@ -154,11 +164,43 @@
<el-button
@
click=
"cancel"
>
取 消
</el-button>
</div>
</el-dialog>
<!-- 导入对话框 -->
<el-dialog
:title=
"upload.title"
:visible
.
sync=
"upload.open"
width=
"400px"
append-to-body
>
<el-upload
ref=
"upload"
:limit=
"1"
accept=
".xlsx, .xls"
:headers=
"upload.headers"
:action=
"upload.url + '?updateSupport=' + upload.updateSupport"
:disabled=
"upload.isUploading"
:on-progress=
"handleFileUploadProgress"
:on-success=
"handleFileSuccess"
:auto-upload=
"false"
drag
>
<i
class=
"el-icon-upload"
></i>
<div
class=
"el-upload__text"
>
将文件拖到此处,或
<em>
点击上传
</em>
</div>
<div
class=
"el-upload__tip"
slot=
"tip"
>
<el-checkbox
v-model=
"upload.updateSupport"
/>
是否更新已经存在的数据
<el-link
type=
"info"
style=
"font-size:12px"
@
click=
"importTemplate"
>
下载模板
</el-link>
</div>
<div
class=
"el-upload__tip"
style=
"color:red"
slot=
"tip"
>
提示:仅允许导入“xls”或“xlsx”格式文件!
</div>
</el-upload>
<div
slot=
"footer"
class=
"dialog-footer"
>
<el-button
type=
"primary"
@
click=
"submitFileForm"
>
确 定
</el-button>
<el-button
@
click=
"upload.open = false"
>
取 消
</el-button>
</div>
</el-dialog>
</div>
</template>
<
script
>
import
{
listProject
,
getProject
,
delProject
,
addProject
,
updateProject
,
exportProject
}
from
"@/api/transaction/project"
;
import
{
listProject
,
getProject
,
delProject
,
addProject
,
updateProject
,
exportProject
,
importTemplate
}
from
"@/api/transaction/project"
;
import
{
getToken
}
from
"@/utils/auth"
;
import
{
treeselect
}
from
"@/api/system/dept"
;
import
Treeselect
from
"@riophae/vue-treeselect"
;
import
"@riophae/vue-treeselect/dist/vue-treeselect.css"
;
...
...
@@ -189,6 +231,21 @@ export default {
title
:
""
,
// 是否显示弹出层
open
:
false
,
// 导入参数
upload
:
{
// 是否显示弹出层(导入)
open
:
false
,
// 弹出层标题(导入)
title
:
""
,
// 是否禁用上传
isUploading
:
false
,
// 是否更新已经存在的数据
updateSupport
:
0
,
// 设置上传的请求头部
headers
:
{
Authorization
:
"Bearer "
+
getToken
()
},
// 上传的地址
url
:
process
.
env
.
VUE_APP_BASE_API
+
"/transaction/project/importData"
},
// 查询参数
queryParams
:
{
pageNum
:
1
,
...
...
@@ -299,6 +356,33 @@ export default {
this
.
open
=
true
;
this
.
title
=
"添加交易项目"
;
},
/** 导入按钮操作 */
handleImport
()
{
this
.
upload
.
title
=
"交易项目导入"
;
this
.
upload
.
open
=
true
;
},
/** 下载模板操作 */
importTemplate
()
{
importTemplate
().
then
(
response
=>
{
this
.
download
(
response
.
msg
);
});
},
// 文件上传中处理
handleFileUploadProgress
(
event
,
file
,
fileList
)
{
this
.
upload
.
isUploading
=
true
;
},
// 文件上传成功处理
handleFileSuccess
(
response
,
file
,
fileList
)
{
this
.
upload
.
open
=
false
;
this
.
upload
.
isUploading
=
false
;
this
.
$refs
.
upload
.
clearFiles
();
this
.
$alert
(
response
.
msg
,
"导入结果"
,
{
dangerouslyUseHTMLString
:
true
});
this
.
getList
();
},
// 提交上传文件
submitFileForm
()
{
this
.
$refs
.
upload
.
submit
();
},
/** 修改按钮操作 */
handleUpdate
(
row
)
{
this
.
reset
();
...
...
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