Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bailuntec-cost
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
huluobin
bailuntec-cost
Commits
2ce5e2d9
Commit
2ce5e2d9
authored
Jan 13, 2021
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
# 费用系统 配置 批量导入导出
parent
01dca74b
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
413 additions
and
142 deletions
+413
-142
CostTypeController.java
.../blt/other/module/cost/controller/CostTypeController.java
+2
-3
CostTypeDao.java
.../main/java/com/blt/other/module/cost/dao/CostTypeDao.java
+5
-3
CostTypeExportExcelReq.java
...other/module/cost/dto/request/CostTypeExportExcelReq.java
+3
-1
CostTypeImportExcelItem.java
...ther/module/cost/dto/request/CostTypeImportExcelItem.java
+36
-0
CostTypeImportExcelReq.java
...other/module/cost/dto/request/CostTypeImportExcelReq.java
+10
-0
CostTypeExportExcelItem.java
...her/module/cost/dto/response/CostTypeExportExcelItem.java
+31
-0
CostTypeService.java
...va/com/blt/other/module/cost/service/CostTypeService.java
+4
-2
CostTypeImportExcelItemListener.java
...le/cost/service/impl/CostTypeImportExcelItemListener.java
+97
-0
CostTypeServiceImpl.java
...t/other/module/cost/service/impl/CostTypeServiceImpl.java
+39
-5
SpecDepartmentCheckConfigController.java
...e/sys/controller/SpecDepartmentCheckConfigController.java
+1
-0
SpecDepartmentCheckAddReq.java
...her/module/sys/dto/request/SpecDepartmentCheckAddReq.java
+1
-1
SpecDepartmentCheckBaseQuery.java
.../module/sys/dto/request/SpecDepartmentCheckBaseQuery.java
+1
-1
SpecDepartmentCheckConfigImportExcelItem.java
...dto/request/SpecDepartmentCheckConfigImportExcelItem.java
+29
-0
SpecDepartmentCheckDeleteReq.java
.../module/sys/dto/request/SpecDepartmentCheckDeleteReq.java
+1
-1
SpecDepartmentCheckExportExcelReq.java
...le/sys/dto/request/SpecDepartmentCheckExportExcelReq.java
+1
-1
SpecDepartmentCheckImportExcelReq.java
...le/sys/dto/request/SpecDepartmentCheckImportExcelReq.java
+1
-1
SpecDepartmentCheckModifyReq.java
.../module/sys/dto/request/SpecDepartmentCheckModifyReq.java
+1
-1
SpecDepartmentCheckQueryPageReq.java
...dule/sys/dto/request/SpecDepartmentCheckQueryPageReq.java
+1
-4
SpecDepartmentCheckConfigExportExcelItem.java
...to/response/SpecDepartmentCheckConfigExportExcelItem.java
+30
-0
ISpecDepartmentCheckConfigService.java
...module/sys/service/ISpecDepartmentCheckConfigService.java
+1
-0
SpecDepartmentCheckConfigExcelItemListener.java
...vice/impl/SpecDepartmentCheckConfigExcelItemListener.java
+94
-0
SpecDepartmentCheckConfigServiceImpl.java
...ys/service/impl/SpecDepartmentCheckConfigServiceImpl.java
+10
-114
CostTypeMapper.xml
cost-service/src/main/resources/mapper/CostTypeMapper.xml
+14
-4
No files found.
cost-service/src/main/java/com/blt/other/module/cost/controller/CostTypeController.java
View file @
2ce5e2d9
...
...
@@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.*;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
@Slf4j
@Api
(
tags
=
"类型接口"
)
...
...
@@ -88,7 +87,7 @@ public class CostTypeController {
@ApiOperation
(
"批量导入数据"
)
@PostMapping
(
"/importExcel"
)
public
CostResult
<
Void
>
importExcel
(
@RequestBody
CostTypeImportExcelReq
excel
)
throws
IOException
{
public
CostResult
<
Void
>
importExcel
(
CostTypeImportExcelReq
excel
)
{
costTypeService
.
importExcel
(
excel
);
return
CostResult
.
success
();
}
...
...
@@ -96,7 +95,7 @@ public class CostTypeController {
@ApiOperation
(
"导出excel"
)
@PostMapping
(
"/exportExcel"
)
public
CostResult
<
Void
>
exportExcel
(
HttpServletResponse
response
,
@RequestBody
CostTypeExportExcelReq
req
)
throws
IOException
{
@RequestBody
CostTypeExportExcelReq
req
)
{
costTypeService
.
exportExcel
(
response
,
req
);
return
CostResult
.
success
();
}
...
...
cost-service/src/main/java/com/blt/other/module/cost/dao/CostTypeDao.java
View file @
2ce5e2d9
...
...
@@ -3,14 +3,13 @@ package com.blt.other.module.cost.dao;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.blt.other.database.model.CostTypeDomain
;
import
com.blt.other.module.cost.dto.request.CostType
QueryPag
eReq
;
import
com.blt.other.module.cost.dto.request.CostType
Bas
eReq
;
import
com.blt.other.module.cost.dto.response.CostTypeResult
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
import
java.util.Map
;
@Mapper
@Repository
...
...
@@ -18,7 +17,10 @@ public interface CostTypeDao extends BaseMapper<CostTypeDomain> {
//分页获取费用类型
IPage
<
CostTypeResult
>
queryPage
(
@Param
(
"page"
)
IPage
<
CostTypeResult
>
page
,
@Param
(
"req"
)
CostTypeQueryPageReq
req
);
@Param
(
"req"
)
CostTypeBaseReq
req
);
//获取全部费用类型
List
<
CostTypeResult
>
queryAll
(
@Param
(
"req"
)
CostTypeBaseReq
req
);
//根据编号查
CostTypeDomain
selectByNo
(
String
typeNo
);
...
...
cost-service/src/main/java/com/blt/other/module/cost/dto/request/CostTypeExportExcelReq.java
View file @
2ce5e2d9
package
com
.
blt
.
other
.
module
.
cost
.
dto
.
request
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* <p>
...
...
@@ -10,6 +11,7 @@ import lombok.Data;
* @author robbendev
* @since 2021/1/13 3:04 下午
*/
@EqualsAndHashCode
(
callSuper
=
true
)
@Data
public
class
CostTypeExportExcelReq
{
public
class
CostTypeExportExcelReq
extends
CostTypeBaseReq
{
}
cost-service/src/main/java/com/blt/other/module/cost/dto/request/CostTypeImportExcelItem.java
0 → 100644
View file @
2ce5e2d9
package
com
.
blt
.
other
.
module
.
cost
.
dto
.
request
;
import
com.alibaba.excel.annotation.ExcelIgnore
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2021/1/13 3:30 下午
*/
@Data
public
class
CostTypeImportExcelItem
{
@ExcelProperty
(
"费用类别"
)
private
String
typeName
;
@ExcelProperty
(
"费用类别描述"
)
private
String
typeDesc
;
@ExcelProperty
(
"会计科目"
)
private
String
accountingSubjectName
;
/**
* 形如0b1001 四位二进制
* 高位到低位分别是 付款 收款 借支 借还
*/
@ExcelIgnore
@ApiModelProperty
(
"费用模版类型作用"
)
private
Integer
costTemplateType
;
}
cost-service/src/main/java/com/blt/other/module/cost/dto/request/CostTypeImportExcelReq.java
View file @
2ce5e2d9
package
com
.
blt
.
other
.
module
.
cost
.
dto
.
request
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
org.springframework.web.multipart.MultipartFile
;
/**
* <p>
...
...
@@ -12,4 +14,12 @@ import lombok.Data;
*/
@Data
public
class
CostTypeImportExcelReq
{
@ApiModelProperty
(
"导入excel文件 表头 费用类别-费用类别描述-会计科目 "
)
MultipartFile
excel
;
@ApiModelProperty
(
"1-费用类型 2-收入类型 3-借支类型"
)
Integer
type
;
}
cost-service/src/main/java/com/blt/other/module/cost/dto/response/CostTypeExportExcelItem.java
0 → 100644
View file @
2ce5e2d9
package
com
.
blt
.
other
.
module
.
cost
.
dto
.
response
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2021/1/13 3:30 下午
*/
@Data
public
class
CostTypeExportExcelItem
{
@ExcelProperty
(
"描述"
)
@ApiModelProperty
(
"描述"
)
private
String
description
;
@ExcelProperty
(
"描述"
)
@ApiModelProperty
(
"费用类型标题"
)
private
String
typeName
;
@ExcelProperty
(
"描述"
)
@ApiModelProperty
(
value
=
"会计一级类目名称"
)
private
String
accountingSubjectName
;
}
cost-service/src/main/java/com/blt/other/module/cost/service/CostTypeService.java
View file @
2ce5e2d9
...
...
@@ -9,6 +9,8 @@ import com.blt.other.module.cost.dto.response.GetLogisticsBankResp;
import
com.blt.other.module.cost.dto.response.GetLogisticsCodeResp
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
public
interface
CostTypeService
extends
IService
<
CostTypeDomain
>
{
...
...
@@ -65,8 +67,8 @@ public interface CostTypeService extends IService<CostTypeDomain> {
GetLogisticsBankResp
getLogisticsBank
(
String
subSupplierName
);
//批量导入
void
importExcel
(
CostTypeImportExcelReq
excel
);
void
importExcel
(
CostTypeImportExcelReq
excel
)
throws
IOException
;
//导出
void
exportExcel
(
HttpServletResponse
response
,
CostTypeExportExcelReq
req
);
void
exportExcel
(
HttpServletResponse
response
,
CostTypeExportExcelReq
req
)
throws
IOException
;
}
cost-service/src/main/java/com/blt/other/module/cost/service/impl/CostTypeImportExcelItemListener.java
0 → 100644
View file @
2ce5e2d9
package
com
.
blt
.
other
.
module
.
cost
.
service
.
impl
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.event.AnalysisEventListener
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.IdWorker
;
import
com.blt.other.common.base.SysUser
;
import
com.blt.other.common.util.SessionUtils
;
import
com.blt.other.database.model.CostTypeDomain
;
import
com.blt.other.module.cost.dao.AccountingSubjectMapper
;
import
com.blt.other.module.cost.dao.CostTypeDao
;
import
com.blt.other.module.cost.dto.request.CostTypeImportExcelItem
;
import
com.blt.other.module.cost.model.AccountingSubject
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2021/1/13 3:31 下午
*/
@Slf4j
public
class
CostTypeImportExcelItemListener
extends
AnalysisEventListener
<
CostTypeImportExcelItem
>
{
private
static
final
int
BATCH_COUNT
=
1000
;
List
<
CostTypeImportExcelItem
>
list
=
new
ArrayList
<>();
private
final
Integer
costTemplateType
;
private
final
AccountingSubjectMapper
accountingSubjectMapper
;
private
final
CostTypeDao
costTypeDao
;
public
CostTypeImportExcelItemListener
(
Integer
costTemplateType
,
AccountingSubjectMapper
accountingSubjectMapper
,
CostTypeDao
costTypeDao
)
{
this
.
costTemplateType
=
costTemplateType
;
this
.
accountingSubjectMapper
=
accountingSubjectMapper
;
this
.
costTypeDao
=
costTypeDao
;
}
@Override
public
void
invoke
(
CostTypeImportExcelItem
data
,
AnalysisContext
context
)
{
log
.
info
(
"解析到一条数据:{}"
,
JSON
.
toJSONString
(
data
));
list
.
add
(
data
);
if
(
list
.
size
()
>=
BATCH_COUNT
)
{
syncData
();
list
.
clear
();
}
}
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
context
)
{
syncData
();
log
.
info
(
"所有数据解析完成!"
);
}
private
void
syncData
()
{
SysUser
sysUser
=
SessionUtils
.
getSysUser
();
log
.
info
(
"{}条数据,开始存储数据库!"
,
list
.
size
());
list
.
forEach
(
item
->
{
AccountingSubject
accountingSubject
=
accountingSubjectMapper
.
selectByName
(
item
.
getAccountingSubjectName
());
if
(
accountingSubject
==
null
)
{
accountingSubject
=
new
AccountingSubject
();
accountingSubject
.
setSubjectNo
(
IdWorker
.
getIdStr
());
accountingSubject
.
setName
(
item
.
getAccountingSubjectName
());
accountingSubject
.
setUpdateUserId
(
sysUser
.
getOaUserId
());
accountingSubject
.
setUpdateUser
(
sysUser
.
getUserName
());
accountingSubjectMapper
.
insert
(
accountingSubject
);
log
.
info
(
"新增会计科目"
);
}
CostTypeDomain
costTypeDomain
=
costTypeDao
.
selectOne
(
new
LambdaQueryWrapper
<
CostTypeDomain
>()
.
eq
(
CostTypeDomain:
:
getTypeName
,
item
.
getTypeName
())
.
eq
(
CostTypeDomain:
:
getAccountingSubjectNo
,
accountingSubject
.
getSubjectNo
()));
if
(
costTypeDomain
==
null
)
{
costTypeDomain
=
new
CostTypeDomain
();
costTypeDomain
.
setTypeNo
(
IdWorker
.
getIdStr
());
costTypeDomain
.
setTypeName
(
item
.
getTypeName
());
costTypeDomain
.
setDescription
(
item
.
getTypeDesc
());
costTypeDomain
.
setAccountingSubjectNo
(
accountingSubject
.
getSubjectNo
());
costTypeDomain
.
setCostTemplateType
(
costTemplateType
);
costTypeDomain
.
setUpdateUserId
(
sysUser
.
getOaUserId
());
costTypeDomain
.
setUpdateUser
(
sysUser
.
getUserName
());
costTypeDao
.
insert
(
costTypeDomain
);
log
.
info
(
"新增费用科目"
);
}
});
log
.
info
(
"存储数据库成功!"
);
}
}
cost-service/src/main/java/com/blt/other/module/cost/service/impl/CostTypeServiceImpl.java
View file @
2ce5e2d9
package
com
.
blt
.
other
.
module
.
cost
.
service
.
impl
;
import
com.alibaba.excel.EasyExcel
;
import
com.bailuntec.common.BeanUtils
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.IdWorker
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
...
...
@@ -12,6 +14,7 @@ import com.blt.other.module.auth.model.OaUser;
import
com.blt.other.module.cost.dao.AccountingSubjectMapper
;
import
com.blt.other.module.cost.dao.CostTypeDao
;
import
com.blt.other.module.cost.dto.request.*
;
import
com.blt.other.module.cost.dto.response.CostTypeExportExcelItem
;
import
com.blt.other.module.cost.dto.response.CostTypeResult
;
import
com.blt.other.module.cost.dto.response.GetLogisticsBankResp
;
import
com.blt.other.module.cost.dto.response.GetLogisticsCodeResp
;
...
...
@@ -22,7 +25,11 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.net.URLEncoder
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Service
@Slf4j
...
...
@@ -122,20 +129,47 @@ public class CostTypeServiceImpl extends ServiceImpl<CostTypeDao, CostTypeDomain
return
resp
;
}
@Override
public
void
importExcel
(
CostTypeImportExcelReq
excel
)
{
@Override
public
void
importExcel
(
CostTypeImportExcelReq
req
)
throws
IOException
{
CostTypeImportExcelItemListener
costTypeImportExcelItemListener
=
new
CostTypeImportExcelItemListener
(
this
.
getCostTemplateType
(
req
.
getType
()),
accountingSubjectMapper
,
baseMapper
);
EasyExcel
.
read
(
req
.
getExcel
().
getInputStream
(),
CostTypeImportExcelItem
.
class
,
costTypeImportExcelItemListener
).
sheet
().
doRead
();
}
@Override
public
void
exportExcel
(
HttpServletResponse
response
,
CostTypeExportExcelReq
req
)
{
public
void
exportExcel
(
HttpServletResponse
response
,
CostTypeExportExcelReq
req
)
throws
IOException
{
// 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
response
.
setContentType
(
"application/vnd.ms-excel"
);
response
.
setCharacterEncoding
(
"utf-8"
);
String
fileName
=
URLEncoder
.
encode
(
IdWorker
.
getIdStr
(),
"UTF-8"
);
response
.
setHeader
(
"Content-disposition"
,
"attachment;filename="
+
fileName
+
".xlsx"
);
req
.
setCostTemplateType
(
this
.
getCostTemplateType
(
req
.
getType
()));
List
<
CostTypeExportExcelItem
>
list
=
baseMapper
.
queryAll
(
req
)
.
stream
()
.
map
(
costTypeResult
->
{
CostTypeExportExcelItem
item
=
new
CostTypeExportExcelItem
();
BeanUtils
.
copyProperties
(
costTypeResult
,
item
);
return
item
;
})
.
collect
(
Collectors
.
toList
());
EasyExcel
.
write
(
response
.
getOutputStream
(),
CostTypeExportExcelItem
.
class
)
.
sheet
(
"sheet"
)
.
doWrite
(
list
);
}
/**
* 根据ui类型获取费用类型 对应的费用模版类型
*
* @param type 1-费用类型 2-收入类型
* @param type 1-费用类型 2-收入类型
3-借支类型
* @return res
*/
private
Integer
getCostTemplateType
(
Integer
type
)
{
...
...
cost-service/src/main/java/com/blt/other/module/sys/controller/SpecDepartmentCheckConfigController.java
View file @
2ce5e2d9
...
...
@@ -4,6 +4,7 @@ package com.blt.other.module.sys.controller;
import
com.bailuntec.cost.api.response.CostResult
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.blt.other.module.cost.dto.request.*
;
import
com.blt.other.module.sys.dto.request.*
;
import
com.blt.other.module.sys.model.SpecDepartmentCheckConfig
;
import
com.blt.other.module.sys.service.ISpecDepartmentCheckConfigService
;
import
io.swagger.annotations.Api
;
...
...
cost-service/src/main/java/com/blt/other/module/
cost
/dto/request/SpecDepartmentCheckAddReq.java
→
cost-service/src/main/java/com/blt/other/module/
sys
/dto/request/SpecDepartmentCheckAddReq.java
View file @
2ce5e2d9
package
com
.
blt
.
other
.
module
.
cost
.
dto
.
request
;
package
com
.
blt
.
other
.
module
.
sys
.
dto
.
request
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
...
...
cost-service/src/main/java/com/blt/other/module/
cost
/dto/request/SpecDepartmentCheckBaseQuery.java
→
cost-service/src/main/java/com/blt/other/module/
sys
/dto/request/SpecDepartmentCheckBaseQuery.java
View file @
2ce5e2d9
package
com
.
blt
.
other
.
module
.
cost
.
dto
.
request
;
package
com
.
blt
.
other
.
module
.
sys
.
dto
.
request
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
...
...
cost-service/src/main/java/com/blt/other/module/sys/dto/request/SpecDepartmentCheckConfigImportExcelItem.java
0 → 100644
View file @
2ce5e2d9
package
com
.
blt
.
other
.
module
.
sys
.
dto
.
request
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2021/1/13 3:25 下午
*/
@Data
public
class
SpecDepartmentCheckConfigImportExcelItem
{
@ExcelProperty
(
"付款财务主体"
)
@ApiModelProperty
(
value
=
"付款财务主体"
)
private
String
costCompanyName
;
@ExcelProperty
(
"申请人oa公司"
)
@ApiModelProperty
(
value
=
"申请人oa公司"
)
private
String
oaCompany
;
@ExcelProperty
(
value
=
"特殊审核部门"
)
@ApiModelProperty
(
value
=
"特殊审核部门"
)
private
String
reviewerDepartmentName
;
}
cost-service/src/main/java/com/blt/other/module/
cost
/dto/request/SpecDepartmentCheckDeleteReq.java
→
cost-service/src/main/java/com/blt/other/module/
sys
/dto/request/SpecDepartmentCheckDeleteReq.java
View file @
2ce5e2d9
package
com
.
blt
.
other
.
module
.
cost
.
dto
.
request
;
package
com
.
blt
.
other
.
module
.
sys
.
dto
.
request
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
...
...
cost-service/src/main/java/com/blt/other/module/
cost
/dto/request/SpecDepartmentCheckExportExcelReq.java
→
cost-service/src/main/java/com/blt/other/module/
sys
/dto/request/SpecDepartmentCheckExportExcelReq.java
View file @
2ce5e2d9
package
com
.
blt
.
other
.
module
.
cost
.
dto
.
request
;
package
com
.
blt
.
other
.
module
.
sys
.
dto
.
request
;
/**
* <p>
...
...
cost-service/src/main/java/com/blt/other/module/
cost
/dto/request/SpecDepartmentCheckImportExcelReq.java
→
cost-service/src/main/java/com/blt/other/module/
sys
/dto/request/SpecDepartmentCheckImportExcelReq.java
View file @
2ce5e2d9
package
com
.
blt
.
other
.
module
.
cost
.
dto
.
request
;
package
com
.
blt
.
other
.
module
.
sys
.
dto
.
request
;
import
lombok.Data
;
import
org.springframework.web.multipart.MultipartFile
;
...
...
cost-service/src/main/java/com/blt/other/module/
cost
/dto/request/SpecDepartmentCheckModifyReq.java
→
cost-service/src/main/java/com/blt/other/module/
sys
/dto/request/SpecDepartmentCheckModifyReq.java
View file @
2ce5e2d9
package
com
.
blt
.
other
.
module
.
cost
.
dto
.
request
;
package
com
.
blt
.
other
.
module
.
sys
.
dto
.
request
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
...
...
cost-service/src/main/java/com/blt/other/module/
cost
/dto/request/SpecDepartmentCheckQueryPageReq.java
→
cost-service/src/main/java/com/blt/other/module/
sys
/dto/request/SpecDepartmentCheckQueryPageReq.java
View file @
2ce5e2d9
package
com
.
blt
.
other
.
module
.
cost
.
dto
.
request
;
package
com
.
blt
.
other
.
module
.
sys
.
dto
.
request
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.time.LocalDateTime
;
/**
* <p>
*
...
...
cost-service/src/main/java/com/blt/other/module/sys/dto/response/SpecDepartmentCheckConfigExportExcelItem.java
0 → 100644
View file @
2ce5e2d9
package
com
.
blt
.
other
.
module
.
sys
.
dto
.
response
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2021/1/13 3:27 下午
*/
@Data
public
class
SpecDepartmentCheckConfigExportExcelItem
{
@ExcelProperty
(
"付款财务主体"
)
@ApiModelProperty
(
value
=
"付款财务主体"
)
private
String
costCompanyName
;
@ExcelProperty
(
"申请人oa公司"
)
@ApiModelProperty
(
value
=
"申请人oa公司"
)
private
String
oaCompany
;
@ExcelProperty
(
value
=
"特殊审核部门"
)
@ApiModelProperty
(
value
=
"特殊审核部门"
)
private
String
reviewerDepartmentName
;
}
cost-service/src/main/java/com/blt/other/module/sys/service/ISpecDepartmentCheckConfigService.java
View file @
2ce5e2d9
...
...
@@ -3,6 +3,7 @@ package com.blt.other.module.sys.service;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.blt.other.module.cost.dto.request.*
;
import
com.blt.other.module.sys.dto.request.*
;
import
com.blt.other.module.sys.model.SpecDepartmentCheckConfig
;
import
javax.servlet.http.HttpServletResponse
;
...
...
cost-service/src/main/java/com/blt/other/module/sys/service/impl/SpecDepartmentCheckConfigExcelItemListener.java
0 → 100644
View file @
2ce5e2d9
package
com
.
blt
.
other
.
module
.
sys
.
service
.
impl
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.event.AnalysisEventListener
;
import
com.alibaba.fastjson.JSON
;
import
com.blt.other.module.auth.dao.OaDepartmentMapper
;
import
com.blt.other.module.auth.service.IOaCompanyService
;
import
com.blt.other.module.sys.dto.request.SpecDepartmentCheckConfigImportExcelItem
;
import
com.blt.other.module.cost.service.CostCompanyService
;
import
com.blt.other.module.sys.model.SpecDepartmentCheckConfig
;
import
com.blt.other.module.sys.service.ISpecDepartmentCheckConfigService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2021/1/13 3:27 下午
*/
public
class
SpecDepartmentCheckConfigExcelItemListener
extends
AnalysisEventListener
<
SpecDepartmentCheckConfigImportExcelItem
>
{
private
final
ISpecDepartmentCheckConfigService
specDepartmentCheckConfigService
;
private
final
CostCompanyService
costCompanyService
;
private
final
IOaCompanyService
oaCompanyService
;
private
final
OaDepartmentMapper
oaDepartmentMapper
;
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
SpecDepartmentCheckConfigExcelItemListener
.
class
);
SpecDepartmentCheckConfigExcelItemListener
(
ISpecDepartmentCheckConfigService
specDepartmentCheckConfigService
,
CostCompanyService
costCompanyService
,
IOaCompanyService
oaCompanyService
,
OaDepartmentMapper
oaDepartmentMapper
)
{
this
.
specDepartmentCheckConfigService
=
specDepartmentCheckConfigService
;
this
.
costCompanyService
=
costCompanyService
;
this
.
oaCompanyService
=
oaCompanyService
;
this
.
oaDepartmentMapper
=
oaDepartmentMapper
;
}
private
static
final
int
BATCH_COUNT
=
2000
;
List
<
SpecDepartmentCheckConfigImportExcelItem
>
list
=
new
ArrayList
<>();
@Override
public
void
invoke
(
SpecDepartmentCheckConfigImportExcelItem
data
,
AnalysisContext
context
)
{
LOGGER
.
info
(
"解析到一条数据:{}"
,
JSON
.
toJSONString
(
data
));
list
.
add
(
data
);
if
(
list
.
size
()
>=
BATCH_COUNT
)
{
syncData
();
list
.
clear
();
}
}
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
context
)
{
syncData
();
LOGGER
.
info
(
"所有数据解析完成!"
);
}
private
void
syncData
()
{
LOGGER
.
info
(
"{}条数据,开始存储数据库!"
,
list
.
size
());
List
<
SpecDepartmentCheckConfig
>
specDepartmentCheckConfigList
=
list
.
stream
()
.
map
(
specDepartmentCheckConfigImportExcelItem
->
{
SpecDepartmentCheckConfig
specDepartmentCheckConfig
=
new
SpecDepartmentCheckConfig
();
specDepartmentCheckConfig
.
setCostCompanyName
(
specDepartmentCheckConfigImportExcelItem
.
getCostCompanyName
());
specDepartmentCheckConfig
.
setCostCompanyId
(
costCompanyService
.
costCompanyMap
().
get
(
specDepartmentCheckConfigImportExcelItem
.
getCostCompanyName
()).
getId
());
specDepartmentCheckConfig
.
setOaCompany
(
specDepartmentCheckConfig
.
getOaCompany
());
specDepartmentCheckConfig
.
setOaCompanyId
(
oaCompanyService
.
companyDict
().
get
(
specDepartmentCheckConfigImportExcelItem
.
getOaCompany
()).
getOaCompanyId
());
specDepartmentCheckConfig
.
setReviewerDepartmentId
(
oaDepartmentMapper
.
selectByName
(
specDepartmentCheckConfigImportExcelItem
.
getReviewerDepartmentName
()).
getDepartmentId
());
specDepartmentCheckConfig
.
setReviewerDepartmentName
(
specDepartmentCheckConfigImportExcelItem
.
getReviewerDepartmentName
());
specDepartmentCheckConfig
.
setLastUpdateTime
(
LocalDateTime
.
now
());
return
specDepartmentCheckConfig
;
})
.
filter
(
specDepartmentCheckConfig
->
specDepartmentCheckConfig
.
getCostCompanyId
()
!=
null
)
.
filter
(
specDepartmentCheckConfig
->
specDepartmentCheckConfig
.
getOaCompanyId
()
!=
null
)
.
filter
(
specDepartmentCheckConfig
->
specDepartmentCheckConfig
.
getReviewerDepartmentId
()
!=
null
)
.
collect
(
Collectors
.
toList
());
specDepartmentCheckConfigService
.
saveBatch
(
specDepartmentCheckConfigList
);
LOGGER
.
info
(
"存储数据库成功!"
);
}
}
cost-service/src/main/java/com/blt/other/module/sys/service/impl/SpecDepartmentCheckConfigServiceImpl.java
View file @
2ce5e2d9
package
com
.
blt
.
other
.
module
.
sys
.
service
.
impl
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.event.AnalysisEventListener
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
...
...
@@ -16,13 +13,11 @@ import com.blt.other.module.auth.model.OaUser;
import
com.blt.other.module.auth.service.IOaCompanyService
;
import
com.blt.other.module.cost.dao.SpecDepartmentCheckConfigMapper
;
import
com.blt.other.module.cost.dto.request.*
;
import
com.blt.other.module.sys.dto.request.*
;
import
com.blt.other.module.sys.dto.response.SpecDepartmentCheckConfigExportExcelItem
;
import
com.blt.other.module.cost.service.CostCompanyService
;
import
com.blt.other.module.sys.model.SpecDepartmentCheckConfig
;
import
com.blt.other.module.sys.service.ISpecDepartmentCheckConfigService
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
...
...
@@ -30,7 +25,6 @@ import javax.servlet.http.HttpServletResponse;
import
java.io.IOException
;
import
java.net.URLEncoder
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -131,12 +125,13 @@ public class SpecDepartmentCheckConfigServiceImpl extends ServiceImpl<SpecDepart
@Override
public
void
exportExcel
(
HttpServletResponse
response
,
SpecDepartmentCheckExportExcelReq
req
)
throws
IOException
{
// 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
response
.
setContentType
(
"application/vnd.ms-excel"
);
response
.
setCharacterEncoding
(
"utf-8"
);
//
String
fileName
=
URLEncoder
.
encode
(
"模版"
,
"UTF-8"
);
response
.
setHeader
(
"Content-disposition"
,
"attachment;filename="
+
fileName
+
".xlsx"
);
LongestMatchColumnWidthStyleStrategy
longestMatchColumnWidthStyleStrategy
=
new
LongestMatchColumnWidthStyleStrategy
();
List
<
SpecDepartmentCheckConfigExportExcelItem
>
aiList
=
baseMapper
.
selectList
(
this
.
buildQueryWrapper
(
req
)).
stream
()
.
map
(
specDepartmentCheckConfig
->
{
SpecDepartmentCheckConfigExportExcelItem
item
=
new
SpecDepartmentCheckConfigExportExcelItem
();
...
...
@@ -146,7 +141,10 @@ public class SpecDepartmentCheckConfigServiceImpl extends ServiceImpl<SpecDepart
return
item
;
})
.
collect
(
Collectors
.
toList
());
EasyExcel
.
write
(
response
.
getOutputStream
(),
SpecDepartmentCheckConfigExportExcelItem
.
class
).
sheet
(
"sheet"
).
doWrite
(
aiList
);
EasyExcel
.
write
(
response
.
getOutputStream
(),
SpecDepartmentCheckConfigExportExcelItem
.
class
)
.
sheet
(
"sheet"
)
.
registerWriteHandler
(
longestMatchColumnWidthStyleStrategy
)
.
doWrite
(
aiList
);
}
@Override
...
...
@@ -180,106 +178,4 @@ public class SpecDepartmentCheckConfigServiceImpl extends ServiceImpl<SpecDepart
}
@Data
static
class
SpecDepartmentCheckConfigExportExcelItem
{
@ExcelProperty
(
"付款财务主体"
)
@ApiModelProperty
(
value
=
"付款财务主体"
)
private
String
costCompanyName
;
@ExcelProperty
(
"申请人oa公司"
)
@ApiModelProperty
(
value
=
"申请人oa公司"
)
private
String
oaCompany
;
@ExcelProperty
(
value
=
"特殊审核部门"
)
@ApiModelProperty
(
value
=
"特殊审核部门"
)
private
String
reviewerDepartmentName
;
}
@Data
static
class
SpecDepartmentCheckConfigImportExcelItem
{
@ExcelProperty
(
"付款财务主体"
)
@ApiModelProperty
(
value
=
"付款财务主体"
)
private
String
costCompanyName
;
@ExcelProperty
(
"申请人oa公司"
)
@ApiModelProperty
(
value
=
"申请人oa公司"
)
private
String
oaCompany
;
@ExcelProperty
(
value
=
"特殊审核部门"
)
@ApiModelProperty
(
value
=
"特殊审核部门"
)
private
String
reviewerDepartmentName
;
}
static
class
SpecDepartmentCheckConfigExcelItemListener
extends
AnalysisEventListener
<
SpecDepartmentCheckConfigImportExcelItem
>
{
private
final
ISpecDepartmentCheckConfigService
specDepartmentCheckConfigService
;
private
final
CostCompanyService
costCompanyService
;
private
final
IOaCompanyService
oaCompanyService
;
private
final
OaDepartmentMapper
oaDepartmentMapper
;
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
SpecDepartmentCheckConfigExcelItemListener
.
class
);
SpecDepartmentCheckConfigExcelItemListener
(
ISpecDepartmentCheckConfigService
specDepartmentCheckConfigService
,
CostCompanyService
costCompanyService
,
IOaCompanyService
oaCompanyService
,
OaDepartmentMapper
oaDepartmentMapper
)
{
this
.
specDepartmentCheckConfigService
=
specDepartmentCheckConfigService
;
this
.
costCompanyService
=
costCompanyService
;
this
.
oaCompanyService
=
oaCompanyService
;
this
.
oaDepartmentMapper
=
oaDepartmentMapper
;
}
private
static
final
int
BATCH_COUNT
=
2000
;
List
<
SpecDepartmentCheckConfigImportExcelItem
>
list
=
new
ArrayList
<>();
@Override
public
void
invoke
(
SpecDepartmentCheckConfigImportExcelItem
data
,
AnalysisContext
context
)
{
LOGGER
.
info
(
"解析到一条数据:{}"
,
JSON
.
toJSONString
(
data
));
list
.
add
(
data
);
if
(
list
.
size
()
>=
BATCH_COUNT
)
{
syncData
();
list
.
clear
();
}
}
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
context
)
{
syncData
();
LOGGER
.
info
(
"所有数据解析完成!"
);
}
private
void
syncData
()
{
LOGGER
.
info
(
"{}条数据,开始存储数据库!"
,
list
.
size
());
List
<
SpecDepartmentCheckConfig
>
specDepartmentCheckConfigList
=
list
.
stream
()
.
map
(
specDepartmentCheckConfigImportExcelItem
->
{
SpecDepartmentCheckConfig
specDepartmentCheckConfig
=
new
SpecDepartmentCheckConfig
();
specDepartmentCheckConfig
.
setCostCompanyName
(
specDepartmentCheckConfigImportExcelItem
.
getCostCompanyName
());
specDepartmentCheckConfig
.
setCostCompanyId
(
costCompanyService
.
costCompanyMap
().
get
(
specDepartmentCheckConfigImportExcelItem
.
getCostCompanyName
()).
getId
());
specDepartmentCheckConfig
.
setOaCompany
(
specDepartmentCheckConfig
.
getOaCompany
());
specDepartmentCheckConfig
.
setOaCompanyId
(
oaCompanyService
.
companyDict
().
get
(
specDepartmentCheckConfigImportExcelItem
.
getOaCompany
()).
getOaCompanyId
());
specDepartmentCheckConfig
.
setReviewerDepartmentId
(
oaDepartmentMapper
.
selectByName
(
specDepartmentCheckConfigImportExcelItem
.
getReviewerDepartmentName
()).
getDepartmentId
());
specDepartmentCheckConfig
.
setReviewerDepartmentName
(
specDepartmentCheckConfigImportExcelItem
.
getReviewerDepartmentName
());
specDepartmentCheckConfig
.
setLastUpdateTime
(
LocalDateTime
.
now
());
return
specDepartmentCheckConfig
;
})
.
filter
(
specDepartmentCheckConfig
->
specDepartmentCheckConfig
.
getCostCompanyId
()
!=
null
)
.
filter
(
specDepartmentCheckConfig
->
specDepartmentCheckConfig
.
getOaCompanyId
()
!=
null
)
.
filter
(
specDepartmentCheckConfig
->
specDepartmentCheckConfig
.
getReviewerDepartmentId
()
!=
null
)
.
collect
(
Collectors
.
toList
());
specDepartmentCheckConfigService
.
saveBatch
(
specDepartmentCheckConfigList
);
LOGGER
.
info
(
"存储数据库成功!"
);
}
}
}
cost-service/src/main/resources/mapper/CostTypeMapper.xml
View file @
2ce5e2d9
...
...
@@ -4,6 +4,14 @@
<mapper
namespace=
"com.blt.other.module.cost.dao.CostTypeDao"
>
<select
id=
"queryPage"
resultType=
"com.blt.other.module.cost.dto.response.CostTypeResult"
>
<include
refid=
"query"
/>
</select>
<select
id=
"queryAll"
resultType=
"com.blt.other.module.cost.dto.response.CostTypeResult"
>
<include
refid=
"query"
/>
</select>
<sql
id=
"query"
>
select t1.id,
t1.type_no,
t1.type_name,
...
...
@@ -22,7 +30,7 @@
<if
test=
"req.accountingSubjectNo !=null"
>
and t1.accounting_subject_no = #{req.accountingSubjectNo}
</if>
</s
elect
>
</s
ql
>
<select
id=
"selectByNo"
resultType=
"com.blt.other.database.model.CostTypeDomain"
>
select *
...
...
@@ -73,9 +81,11 @@
</select>
<select
id=
"selectTestType"
resultType=
"com.blt.other.database.model.CostTypeDomain"
>
SELECT t1.* from cost_type t1
LEFT JOIN cost_type t2 on t1.type_name =t2.type_name and t2.cost_template_type = 2
where t1.cost_template_type = 9 and t2.id is null;
SELECT t1.*
from cost_type t1
LEFT JOIN cost_type t2 on t1.type_name = t2.type_name and t2.cost_template_type = 2
where t1.cost_template_type = 9
and t2.id is null;
</select>
...
...
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