Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dsk-cr20g
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
Administrator
dsk-cr20g
Commits
646629fe
Commit
646629fe
authored
Jun 02, 2023
by
lixiaolei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
submit
parent
4ed5004e
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
354 additions
and
29 deletions
+354
-29
BusinessInfoController.java
...m/dsk/web/controller/business/BusinessInfoController.java
+20
-10
BusinessAddDto.java
...m/src/main/java/com/dsk/system/domain/BusinessAddDto.java
+2
-1
BusinessExcelDto.java
...src/main/java/com/dsk/system/domain/BusinessExcelDto.java
+26
-0
BusinessListDto.java
.../src/main/java/com/dsk/system/domain/BusinessListDto.java
+5
-3
BusinessListVo.java
...rc/main/java/com/dsk/system/domain/vo/BusinessListVo.java
+3
-3
IBusinessInfoService.java
...ain/java/com/dsk/system/service/IBusinessInfoService.java
+7
-0
BusinessInfoServiceImpl.java
.../com/dsk/system/service/impl/BusinessInfoServiceImpl.java
+45
-3
ReadBusinessInfoExcel.java
...va/com/dsk/system/service/impl/ReadBusinessInfoExcel.java
+175
-0
BusinessInfoMapper.xml
...src/main/resources/mapper/business/BusinessInfoMapper.xml
+71
-9
No files found.
dsk-admin/src/main/java/com/dsk/web/controller/business/BusinessInfoController.java
View file @
646629fe
...
@@ -17,6 +17,10 @@ import com.dsk.common.core.controller.BaseController;
...
@@ -17,6 +17,10 @@ import com.dsk.common.core.controller.BaseController;
import
com.dsk.common.core.domain.AjaxResult
;
import
com.dsk.common.core.domain.AjaxResult
;
import
com.dsk.common.enums.BusinessType
;
import
com.dsk.common.enums.BusinessType
;
import
com.dsk.common.core.page.TableDataInfo
;
import
com.dsk.common.core.page.TableDataInfo
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
/**
/**
* 项目详情Controller
* 项目详情Controller
...
@@ -31,11 +35,17 @@ public class BusinessInfoController extends BaseController
...
@@ -31,11 +35,17 @@ public class BusinessInfoController extends BaseController
@Autowired
@Autowired
private
IBusinessInfoService
businessInfoService
;
private
IBusinessInfoService
businessInfoService
;
/**
* 项目批量导入
*/
@PostMapping
(
"/upload"
)
public
AjaxResult
batchUpload
(
@RequestParam
(
value
=
"file"
,
required
=
false
)
MultipartFile
file
,
HttpServletRequest
request
,
HttpServletResponse
response
){
return
businessInfoService
.
batchUpload
(
file
,
response
);
}
/**
/**
* 查询所有项目名称(支持模糊查询)
* 查询所有项目名称(支持模糊查询)
*/
*/
// @PreAuthorize("@ss.hasPermi('system:info:list')")
@PostMapping
(
"/query/project"
)
@PostMapping
(
"/query/project"
)
public
AjaxResult
queryprojectName
(
@RequestBody
BusinessListDto
dto
){
public
AjaxResult
queryprojectName
(
@RequestBody
BusinessListDto
dto
){
return
AjaxResult
.
success
(
businessInfoService
.
selectProjectName
(
dto
));
return
AjaxResult
.
success
(
businessInfoService
.
selectProjectName
(
dto
));
...
@@ -44,7 +54,7 @@ public class BusinessInfoController extends BaseController
...
@@ -44,7 +54,7 @@ public class BusinessInfoController extends BaseController
/**
/**
* 查询项目列表
* 查询项目列表
*/
*/
// @PreAuthorize("@ss.hasPermi('system:
info
:list')")
// @PreAuthorize("@ss.hasPermi('system:
business
:list')")
@GetMapping
(
"/list"
)
@GetMapping
(
"/list"
)
public
TableDataInfo
list
(
@RequestBody
BusinessListDto
dto
)
public
TableDataInfo
list
(
@RequestBody
BusinessListDto
dto
)
{
{
...
@@ -56,7 +66,7 @@ public class BusinessInfoController extends BaseController
...
@@ -56,7 +66,7 @@ public class BusinessInfoController extends BaseController
/**
/**
* 查询项目速览
* 查询项目速览
*/
*/
// @PreAuthorize("@ss.hasPermi('system:
info:list
')")
// @PreAuthorize("@ss.hasPermi('system:
business:query
')")
@GetMapping
(
"/browse/{businessId}"
)
@GetMapping
(
"/browse/{businessId}"
)
public
AjaxResult
browse
(
@PathVariable
Integer
id
)
public
AjaxResult
browse
(
@PathVariable
Integer
id
)
{
{
...
@@ -66,7 +76,7 @@ public class BusinessInfoController extends BaseController
...
@@ -66,7 +76,7 @@ public class BusinessInfoController extends BaseController
/**
/**
* 获取项目建设内容
* 获取项目建设内容
*/
*/
// @PreAuthorize("@ss.hasPermi('system:
info
:query')")
// @PreAuthorize("@ss.hasPermi('system:
business
:query')")
@GetMapping
(
value
=
"/construction/{id}"
)
@GetMapping
(
value
=
"/construction/{id}"
)
public
AjaxResult
getConstruction
(
@PathVariable
(
"id"
)
Integer
id
)
public
AjaxResult
getConstruction
(
@PathVariable
(
"id"
)
Integer
id
)
{
{
...
@@ -76,8 +86,8 @@ public class BusinessInfoController extends BaseController
...
@@ -76,8 +86,8 @@ public class BusinessInfoController extends BaseController
/**
/**
* 删除项目列表
* 删除项目列表
*/
*/
// @PreAuthorize("@ss.hasPermi('system:
info
:remove')")
// @PreAuthorize("@ss.hasPermi('system:
business
:remove')")
// @Log(title = "项目详情
", businessType = BusinessType.DELETE)
@Log
(
title
=
"项目管理
"
,
businessType
=
BusinessType
.
DELETE
)
@DeleteMapping
(
"/remove/{ids}"
)
@DeleteMapping
(
"/remove/{ids}"
)
public
AjaxResult
remove
(
@PathVariable
(
value
=
"ids"
,
required
=
false
)
Long
[]
ids
)
public
AjaxResult
remove
(
@PathVariable
(
value
=
"ids"
,
required
=
false
)
Long
[]
ids
)
{
{
...
@@ -87,8 +97,8 @@ public class BusinessInfoController extends BaseController
...
@@ -87,8 +97,8 @@ public class BusinessInfoController extends BaseController
/**
/**
* 新增项目详情
* 新增项目详情
*/
*/
// @PreAuthorize("@ss.hasPermi('system:
info
:add')")
// @PreAuthorize("@ss.hasPermi('system:
business
:add')")
// @Log(title = "项目详情
", businessType = BusinessType.INSERT)
@Log
(
title
=
"项目管理
"
,
businessType
=
BusinessType
.
INSERT
)
@PostMapping
(
"/add"
)
@PostMapping
(
"/add"
)
public
AjaxResult
add
(
@RequestBody
BusinessAddDto
dto
)
public
AjaxResult
add
(
@RequestBody
BusinessAddDto
dto
)
{
{
...
@@ -98,8 +108,8 @@ public class BusinessInfoController extends BaseController
...
@@ -98,8 +108,8 @@ public class BusinessInfoController extends BaseController
/**
/**
* 修改项目详情
* 修改项目详情
*/
*/
// @PreAuthorize("@ss.hasPermi('system:
info
:edit')")
// @PreAuthorize("@ss.hasPermi('system:
business
:edit')")
// @Log(title = "项目详情
", businessType = BusinessType.UPDATE)
@Log
(
title
=
"项目管理
"
,
businessType
=
BusinessType
.
UPDATE
)
@PostMapping
(
"/edit"
)
@PostMapping
(
"/edit"
)
public
AjaxResult
edit
(
@RequestBody
BusinessInfo
businessInfo
)
public
AjaxResult
edit
(
@RequestBody
BusinessInfo
businessInfo
)
{
{
...
...
dsk-system/src/main/java/com/dsk/system/domain/BusinessAddDto.java
View file @
646629fe
package
com
.
dsk
.
system
.
domain
;
package
com
.
dsk
.
system
.
domain
;
import
com.dsk.common.utils.StringUtils
;
import
lombok.Data
;
import
lombok.Data
;
/**
/**
...
@@ -60,6 +61,6 @@ public class BusinessAddDto {
...
@@ -60,6 +61,6 @@ public class BusinessAddDto {
private
String
customerId
;
private
String
customerId
;
public
Double
getInvestmentAmount
()
{
public
Double
getInvestmentAmount
()
{
return
Double
.
parseDouble
(
investmentAmount
);
return
StringUtils
.
isEmpty
(
investmentAmount
)
?
0
:
Double
.
parseDouble
(
investmentAmount
);
}
}
}
}
dsk-system/src/main/java/com/dsk/system/domain/BusinessExcelDto.java
0 → 100644
View file @
646629fe
package
com
.
dsk
.
system
.
domain
;
import
com.dsk.common.utils.StringUtils
;
import
lombok.Data
;
/**
* @author lxl
* @Description:
* @Date 2023/6/1 下午 6:41
**/
@Data
public
class
BusinessExcelDto
{
/**
* 项目名称
*/
private
String
projectName
;
/**
* 投资估算(万元)
*/
private
String
investmentAmount
;
/**
* 业主单位
*/
private
String
ownerCompany
;
}
dsk-system/src/main/java/com/dsk/system/domain/BusinessListDto.java
View file @
646629fe
...
@@ -2,6 +2,8 @@ package com.dsk.system.domain;
...
@@ -2,6 +2,8 @@ package com.dsk.system.domain;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.List
;
/**
/**
* @author lxl
* @author lxl
* @Description:
* @Description:
...
@@ -28,17 +30,17 @@ public class BusinessListDto {
...
@@ -28,17 +30,17 @@ public class BusinessListDto {
/**
/**
* 省id
* 省id
*/
*/
private
Integer
provinceId
;
private
List
<
Integer
>
provinceId
;
/**
/**
* 市id
* 市id
*/
*/
private
Integer
cityId
;
private
List
<
Integer
>
cityId
;
/**
/**
* 区id
* 区id
*/
*/
private
Integer
districtId
;
private
List
<
Integer
>
districtId
;
/**
/**
* 项目类型
* 项目类型
...
...
dsk-system/src/main/java/com/dsk/system/domain/vo/BusinessListVo.java
View file @
646629fe
...
@@ -26,17 +26,17 @@ public class BusinessListVo {
...
@@ -26,17 +26,17 @@ public class BusinessListVo {
/**
/**
* 省
* 省
*/
*/
private
Integer
provinceName
;
private
String
provinceName
;
/**
/**
* 市
* 市
*/
*/
private
Integer
cityName
;
private
String
cityName
;
/**
/**
* 区
* 区
*/
*/
private
Integer
districtName
;
private
String
districtName
;
/**
/**
* 投资估算
* 投资估算
...
...
dsk-system/src/main/java/com/dsk/system/service/IBusinessInfoService.java
View file @
646629fe
...
@@ -8,7 +8,9 @@ import com.dsk.system.domain.customer.dto.CustomerBusinessSearchDto;
...
@@ -8,7 +8,9 @@ import com.dsk.system.domain.customer.dto.CustomerBusinessSearchDto;
import
com.dsk.system.domain.customer.vo.CustomerBusinessListVo
;
import
com.dsk.system.domain.customer.vo.CustomerBusinessListVo
;
import
com.dsk.system.domain.vo.BusinessBrowseVo
;
import
com.dsk.system.domain.vo.BusinessBrowseVo
;
import
com.dsk.system.domain.vo.BusinessListVo
;
import
com.dsk.system.domain.vo.BusinessListVo
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -56,6 +58,11 @@ public interface IBusinessInfoService
...
@@ -56,6 +58,11 @@ public interface IBusinessInfoService
*/
*/
List
<
String
>
selectProjectName
(
BusinessListDto
dto
);
List
<
String
>
selectProjectName
(
BusinessListDto
dto
);
/**
* 项目批量导入
*/
AjaxResult
batchUpload
(
MultipartFile
file
,
HttpServletResponse
response
);
/**
/**
* 新增项目详情
* 新增项目详情
*
*
...
...
dsk-system/src/main/java/com/dsk/system/service/impl/BusinessInfoServiceImpl.java
View file @
646629fe
package
com
.
dsk
.
system
.
service
.
impl
;
package
com
.
dsk
.
system
.
service
.
impl
;
import
java.util.
Arrays
;
import
java.util.
LinkedList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.dsk.common.constant.HttpStatus
;
import
com.dsk.common.core.domain.AjaxResult
;
import
com.dsk.common.core.domain.AjaxResult
;
import
com.dsk.common.core.domain.entity.BusinessInfo
;
import
com.dsk.common.core.domain.entity.BusinessInfo
;
import
com.dsk.common.core.domain.entity.BusinessLabel
;
import
com.dsk.common.core.domain.entity.BusinessLabel
;
import
com.dsk.common.core.domain.entity.BusinessRelateCompany
;
import
com.dsk.common.core.domain.entity.BusinessRelateCompany
;
import
com.dsk.common.core.domain.entity.BusinessUser
;
import
com.dsk.common.core.domain.entity.BusinessUser
;
import
com.dsk.common.dtos.BusinessInfoDto
;
import
com.dsk.common.utils.DateUtils
;
import
com.dsk.common.utils.DateUtils
;
import
com.dsk.common.utils.SecurityUtils
;
import
com.dsk.common.utils.SecurityUtils
;
import
com.dsk.system.domain.BusinessExcelDto
;
import
com.dsk.system.domain.BusinessAddDto
;
import
com.dsk.system.domain.BusinessAddDto
;
import
com.dsk.system.domain.BusinessListDto
;
import
com.dsk.system.domain.BusinessListDto
;
import
com.dsk.system.domain.customer.dto.CustomerBusinessSearchDto
;
import
com.dsk.system.domain.customer.dto.CustomerBusinessSearchDto
;
...
@@ -24,11 +27,13 @@ import com.dsk.system.mapper.BusinessLabelMapper;
...
@@ -24,11 +27,13 @@ import com.dsk.system.mapper.BusinessLabelMapper;
import
com.dsk.system.mapper.BusinessRelateCompanyMapper
;
import
com.dsk.system.mapper.BusinessRelateCompanyMapper
;
import
com.dsk.system.mapper.BusinessUserMapper
;
import
com.dsk.system.mapper.BusinessUserMapper
;
import
com.dsk.system.service.IBusinessInfoService
;
import
com.dsk.system.service.IBusinessInfoService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
/**
/**
* 项目详情Service业务层处理
* 项目详情Service业务层处理
...
@@ -37,6 +42,7 @@ import javax.annotation.Resource;
...
@@ -37,6 +42,7 @@ import javax.annotation.Resource;
* @date 2023-05-17
* @date 2023-05-17
*/
*/
@Service
@Service
@Slf4j
public
class
BusinessInfoServiceImpl
implements
IBusinessInfoService
{
public
class
BusinessInfoServiceImpl
implements
IBusinessInfoService
{
@Resource
@Resource
private
BusinessInfoMapper
businessInfoMapper
;
private
BusinessInfoMapper
businessInfoMapper
;
...
@@ -46,6 +52,8 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
...
@@ -46,6 +52,8 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
private
BusinessRelateCompanyMapper
businessRelateCompanyMapper
;
private
BusinessRelateCompanyMapper
businessRelateCompanyMapper
;
@Resource
@Resource
private
BusinessLabelMapper
businessLabelMapper
;
private
BusinessLabelMapper
businessLabelMapper
;
@Resource
private
ReadBusinessInfoExcel
readBusinessInfoExcel
;
/**
/**
* 查询项目详情
* 查询项目详情
...
@@ -97,6 +105,37 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
...
@@ -97,6 +105,37 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
return
businessInfoMapper
.
selectProjectName
(
dto
);
return
businessInfoMapper
.
selectProjectName
(
dto
);
}
}
@Override
public
AjaxResult
batchUpload
(
MultipartFile
file
,
HttpServletResponse
response
)
{
int
row
=
3
;
//起始行数
int
rowSuccess
=
0
;
//成功条数
Integer
errorCount
=
0
;
//失败条数
List
<
String
>
result
=
new
LinkedList
();
//导入结果汇总
List
<
BusinessExcelDto
>
businessInfoList
=
readBusinessInfoExcel
.
getExcelInfo
(
file
);
for
(
BusinessExcelDto
businessInfo
:
businessInfoList
)
{
//查询已有的项目名称
Integer
count
=
businessInfoMapper
.
selectCount
(
Wrappers
.<
BusinessInfo
>
lambdaQuery
().
eq
(
BusinessInfo:
:
getProjectName
,
businessInfo
.
getProjectName
()));
row
++;
if
(
count
>
0
){
//如果存在,跳过该项目,不保存
result
.
add
(
"第"
+
row
+
"行的"
+
businessInfo
.
getProjectName
()+
"的项目已存在,跳过该项目,保存下一条"
);
errorCount
++;
}
else
{
//保存到数据库
BusinessAddDto
businessAddDto
=
new
BusinessAddDto
();
BeanUtil
.
copyProperties
(
businessInfo
,
businessAddDto
);
//获取当前登录用户id
businessAddDto
.
setUserId
(
SecurityUtils
.
getLoginUser
().
getUserId
().
intValue
());
businessAddDto
.
setCompanyId
(
0
);
AjaxResult
add
=
insertBusinessInfo
(
businessAddDto
);
if
(
add
.
get
(
"code"
).
equals
(
HttpStatus
.
SUCCESS
))
rowSuccess
++;
}
}
result
.
add
(
"导入项目成功条数"
+
rowSuccess
);
result
.
add
(
"导入项目失败条件"
+
errorCount
);
return
errorCount
==
businessInfoList
.
size
()
?
AjaxResult
.
error
(
String
.
join
(
"\n"
,
result
),
response
)
:
AjaxResult
.
success
(
String
.
join
(
"\n"
,
result
),
response
);
}
/**
/**
* 新增项目详情
* 新增项目详情
*
*
...
@@ -106,6 +145,9 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
...
@@ -106,6 +145,9 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
@Override
@Override
@Transactional
@Transactional
public
AjaxResult
insertBusinessInfo
(
BusinessAddDto
dto
)
{
public
AjaxResult
insertBusinessInfo
(
BusinessAddDto
dto
)
{
//新增前查询是否已存在
BusinessInfo
selectOne
=
businessInfoMapper
.
selectOne
(
Wrappers
.<
BusinessInfo
>
lambdaQuery
().
eq
(
BusinessInfo:
:
getProjectName
,
dto
.
getProjectName
()));
if
(
ObjectUtil
.
isNotEmpty
(
selectOne
))
return
AjaxResult
.
error
(
"项目名称已存在"
);
//新增项目主信息
//新增项目主信息
BusinessInfo
businessInfo
=
new
BusinessInfo
();
BusinessInfo
businessInfo
=
new
BusinessInfo
();
BeanUtil
.
copyProperties
(
dto
,
businessInfo
);
BeanUtil
.
copyProperties
(
dto
,
businessInfo
);
...
...
dsk-system/src/main/java/com/dsk/system/service/impl/ReadBusinessInfoExcel.java
0 → 100644
View file @
646629fe
package
com
.
dsk
.
system
.
service
.
impl
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.List
;
import
com.dsk.system.domain.BusinessExcelDto
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.ss.usermodel.*
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
/**
* @author lxl
* @Description:
* @Date 2023/6/1 下午 4:30
**/
@Slf4j
@Service
public
class
ReadBusinessInfoExcel
{
// 总行数
private
int
totalRows
=
0
;
// 总条数
private
int
totalCells
=
0
;
public
int
getTotalRows
()
{
return
totalRows
;
}
public
void
setTotalRows
(
int
totalRows
)
{
this
.
totalRows
=
totalRows
;
}
public
int
getTotalCells
()
{
return
totalCells
;
}
public
void
setTotalCells
(
int
totalCells
)
{
this
.
totalCells
=
totalCells
;
}
/**
* 读EXCEL文件,获取信息集合
*
* @param mFile
* @return
*/
public
List
<
BusinessExcelDto
>
getExcelInfo
(
MultipartFile
mFile
)
{
String
fileName
=
mFile
.
getOriginalFilename
();
// 获取文件名
try
{
// 验证文件名是否合格
if
(!
validateExcel
(
fileName
))
return
null
;
// 根据文件名判断文件是2003版本还是2007版本
boolean
isExcel2003
=
true
;
if
(
isExcel2007
(
fileName
))
isExcel2003
=
false
;
return
createExcel
(
mFile
.
getInputStream
(),
isExcel2003
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
/**
* 根据excel里面的内容读取信息
*
* @param is 输入流
* @param isExcel2003 excel是2003还是2007版本
* @return
*/
public
List
<
BusinessExcelDto
>
createExcel
(
InputStream
is
,
boolean
isExcel2003
)
{
try
{
Workbook
wb
=
null
;
// 当excel是2003时,创建excel2003
if
(
isExcel2003
)
{
wb
=
new
HSSFWorkbook
(
is
);
}
else
{
// 当excel是2007时,创建excel2007
wb
=
new
XSSFWorkbook
(
is
);
}
return
readExcelValue
(
wb
);
// 读取Excel里面客户的信息
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
/**
* 读取Excel内容
*
* @param wb
* @return
*/
private
List
<
BusinessExcelDto
>
readExcelValue
(
Workbook
wb
)
{
//得到第一个shell
Sheet
sheet
=
wb
.
getSheetAt
(
0
);
//得到Excel的行数
this
.
totalRows
=
sheet
.
getPhysicalNumberOfRows
();
//得到Excel的列数(前提是有行数)
if
(
totalRows
>
1
&&
sheet
.
getRow
(
0
)
!=
null
)
{
this
.
totalCells
=
sheet
.
getRow
(
0
).
getPhysicalNumberOfCells
();
}
// List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
ArrayList
<
BusinessExcelDto
>
list
=
new
ArrayList
<>();
//循环Excel行数
for
(
int
r
=
1
;
r
<
totalRows
;
r
++)
{
Row
row
=
sheet
.
getRow
(
r
);
if
(
row
==
null
)
{
continue
;
}
//循环Excel的列
// Map<String, Object> map = new HashMap<String, Object>();
BusinessExcelDto
businessExcelDto
=
new
BusinessExcelDto
();
for
(
int
c
=
3
;
c
<
this
.
totalCells
;
c
++)
{
Cell
cell
=
row
.
getCell
(
c
);
if
(
null
!=
cell
)
{
if
(
c
==
0
)
{
//如果是纯数字,比如你写的是25,cell.getNumericCellValue()获得是25.0,通过截取字符串去掉.0获得25
if
(
cell
.
getCellType
()
==
CellType
.
NUMERIC
)
{
String
name
=
String
.
valueOf
(
cell
.
getNumericCellValue
());
businessExcelDto
.
setProjectName
(
name
.
substring
(
0
,
name
.
length
()
-
2
>
0
?
name
.
length
()
-
2
:
1
));
//项目名称
}
else
{
businessExcelDto
.
setProjectName
(
cell
.
getStringCellValue
());
//名称
}
}
else
if
(
c
==
1
)
{
if
(
cell
.
getCellType
()
==
CellType
.
NUMERIC
)
{
String
company
=
String
.
valueOf
(
cell
.
getNumericCellValue
());
businessExcelDto
.
setOwnerCompany
(
company
.
substring
(
0
,
company
.
length
()
-
2
>
0
?
company
.
length
()
-
2
:
1
));
//业主单位
}
else
{
businessExcelDto
.
setOwnerCompany
(
cell
.
getStringCellValue
());
//性别
}
}
else
if
(
c
==
2
)
{
if
(
cell
.
getCellType
()
==
CellType
.
NUMERIC
)
{
String
amount
=
String
.
valueOf
(
cell
.
getNumericCellValue
());
businessExcelDto
.
setInvestmentAmount
(
amount
.
substring
(
0
,
amount
.
length
()
-
2
>
0
?
amount
.
length
()
-
2
:
1
));
//投资估算(万元)
}
else
{
businessExcelDto
.
setInvestmentAmount
(
cell
.
getStringCellValue
());
}
}
}
}
//添加到list
list
.
add
(
businessExcelDto
);
}
return
list
;
}
/**
* 验证EXCEL文件
* @param filePath
* @return
*/
public
boolean
validateExcel
(
String
filePath
)
{
if
(
filePath
==
null
||
!(
isExcel2003
(
filePath
)
||
isExcel2007
(
filePath
)))
{
log
.
info
(
"文件不是excel格式"
);
return
false
;
}
return
true
;
}
// @描述:是否是2003的excel,返回true是2003
public
static
boolean
isExcel2003
(
String
filePath
)
{
return
filePath
.
matches
(
"^.+\\.(?i)(xls)$"
);
}
// @描述:是否是2007的excel,返回true是2007
public
static
boolean
isExcel2007
(
String
filePath
)
{
return
filePath
.
matches
(
"^.+\\.(?i)(xlsx)$"
);
}
}
dsk-system/src/main/resources/mapper/business/BusinessInfoMapper.xml
View file @
646629fe
...
@@ -80,15 +80,6 @@
...
@@ -80,15 +80,6 @@
LEFT JOIN business_user bu on bu.business_id = i.id
LEFT JOIN business_user bu on bu.business_id = i.id
LEFT JOIN sys_user u on u.user_id = f.user_id
LEFT JOIN sys_user u on u.user_id = f.user_id
<where>
<where>
<if
test=
"provinceId != null"
>
and i.province_id = #{provinceId}
</if>
<if
test=
"cityId != null"
>
and i.city_id = #{cityId}
</if>
<if
test=
"districtId != null"
>
and i.district_id = #{districtId}
</if>
<if
test=
"projectType != null and projectType != ''"
>
<if
test=
"projectType != null and projectType != ''"
>
and i.project_type = #{projectType}
and i.project_type = #{projectType}
</if>
</if>
...
@@ -116,6 +107,77 @@
...
@@ -116,6 +107,77 @@
<if
test=
"deptId != null"
>
<if
test=
"deptId != null"
>
and bu.dept_id = #{deptId} and i.is_private = 1
and bu.dept_id = #{deptId} and i.is_private = 1
</if>
</if>
<if
test=
"provinceId != null and provinceId.size > 0 and cityId == null and districtId == null"
>
and i.province_id in
<foreach
collection=
"provinceId"
item=
"provinceId"
open=
"("
separator=
","
close=
")"
>
#{provinceId}
</foreach>
</if>
<if
test=
"cityId != null and cityId.size > 0 and provinceId == null and districtId == null"
>
and i.city_id in
<foreach
collection=
"cityId"
item=
"cityId"
open=
"("
separator=
","
close=
")"
>
#{cityId}
</foreach>
</if>
<if
test=
"districtId != null and districtId.size > 0 and provinceId == null and cityId == null"
>
and i.district_id in
<foreach
collection=
"districtId"
item=
"districtId"
open=
"("
separator=
","
close=
")"
>
#{districtId}
</foreach>
</if>
<if
test=
"provinceId != null and provinceId.size > 0 and cityId != null and cityId.size > 0 and districtId == null"
>
and (
i.province_id in
<foreach
collection=
"provinceId"
item=
"provinceId"
open=
"("
separator=
","
close=
")"
>
#{provinceId}
</foreach>
or i.city_id in
<foreach
collection=
"cityId"
item=
"cityId"
open=
"("
separator=
","
close=
")"
>
#{cityId}
</foreach>
)
</if>
<if
test=
"provinceId != null and provinceId.size > 0 and districtId != null and districtId.size > 0 and cityId == null"
>
and (
i.province_id in
<foreach
collection=
"provinceId"
item=
"provinceId"
open=
"("
separator=
","
close=
")"
>
#{provinceId}
</foreach>
or i.district_id in
<foreach
collection=
"districtId"
item=
"districtId"
open=
"("
separator=
","
close=
")"
>
#{districtId}
</foreach>
)
</if>
<if
test=
"cityId != null and cityId.size > 0 and districtId != null and districtId.size > 0 and provinceId ==null"
>
and (
i.city_id in
<foreach
collection=
"cityId"
item=
"cityId"
open=
"("
separator=
","
close=
")"
>
#{cityId}
</foreach>
or i.district_id in
<foreach
collection=
"districtId"
item=
"districtId"
open=
"("
separator=
","
close=
")"
>
#{districtId}
</foreach>
)
</if>
<if
test=
"provinceId != null and provinceId.size > 0 and cityId != null and cityId.size > 0 and districtId != null and districtId.size > 0"
>
and (
i.province_id in
<foreach
collection=
"provinceId"
item=
"provinceId"
open=
"("
separator=
","
close=
")"
>
#{provinceId}
</foreach>
or i.city_id in
<foreach
collection=
"cityId"
item=
"cityId"
open=
"("
separator=
","
close=
")"
>
#{cityId}
</foreach>
or i.district_id in
<foreach
collection=
"districtId"
item=
"districtId"
open=
"("
separator=
","
close=
")"
>
#{districtId}
</foreach>
)
</if>
</where>
</where>
GROUP BY i.id
GROUP BY i.id
ORDER BY i.create_time DESC
ORDER BY i.create_time DESC
...
...
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