Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
house-type-server
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
xingyuji
house-type-server
Commits
e79aef25
Commit
e79aef25
authored
Aug 12, 2020
by
姜鹏鹏
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master' into jiangpengpeng
parents
bae09a0b
1438ae60
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
621 additions
and
65 deletions
+621
-65
BnsProjectController.java
.../business/bnsproject/controller/BnsProjectController.java
+34
-15
ExportBnsProductDto.java
...ft/tenio/business/bnsproject/dto/ExportBnsProductDto.java
+0
-10
ExportBnsProjectDto.java
...ft/tenio/business/bnsproject/dto/ExportBnsProjectDto.java
+1
-17
BnsSaleController.java
.../tenio/business/bnssale/controller/BnsSaleController.java
+243
-6
ExportSaleProjectDTO.java
...soft/tenio/business/bnssale/dto/ExportSaleProjectDTO.java
+87
-0
BnsSaleServiceImpl.java
...nio/business/bnssale/service/impl/BnsSaleServiceImpl.java
+23
-12
ExcelPatternMsg.java
...ain/java/com/isoft/tenio/utils/excel/ExcelPatternMsg.java
+4
-5
ExportSaleProjectHander.java
...va/com/isoft/tenio/utils/poi/ExportSaleProjectHander.java
+229
-0
No files found.
src/main/java/com/isoft/tenio/business/bnsproject/controller/BnsProjectController.java
View file @
e79aef25
...
...
@@ -188,7 +188,8 @@ public class BnsProjectController {
exportBnsProductDto
.
setShortName
(
projectListDto
.
getShortName
());
exportBnsProductDto
.
setLongitude
(
String
.
valueOf
(
projectListDto
.
getLongitude
()
==
null
?
""
:
projectListDto
.
getLongitude
()));
exportBnsProductDto
.
setLatitude
(
String
.
valueOf
(
projectListDto
.
getLatitude
()
==
null
?
""
:
projectListDto
.
getLatitude
()));
exportBnsProductDto
.
setSaleStatus
(
String
.
valueOf
(
projectListDto
.
getSaleStatus
()));
exportBnsProductDto
.
setSaleStatus
(
String
.
valueOf
(
projectListDto
.
getSaleStatus
()
==
null
?
""
:
projectListDto
.
getSaleStatus
()));
exportBnsProductDto
.
setIsTy
(
String
.
valueOf
(
projectListDto
.
getIsTy
()
==
null
?
""
:
projectListDto
.
getIsTy
()));
exportBnsProductDto
.
setPrice
(
projectListDto
.
getPrice
());
exportBnsProductDto
.
setOpenTime
(
projectListDto
.
getOpenTime
());
exportBnsProductDto
.
setLandArea
(
String
.
valueOf
(
projectListDto
.
getLandArea
()
==
null
?
""
:
projectListDto
.
getLandArea
()));
...
...
@@ -239,7 +240,8 @@ public class BnsProjectController {
exportBnsProductDto
.
setShortName
(
projectListDto
.
getShortName
());
exportBnsProductDto
.
setLongitude
(
String
.
valueOf
(
projectListDto
.
getLongitude
()
==
null
?
""
:
projectListDto
.
getLongitude
()));
exportBnsProductDto
.
setLatitude
(
String
.
valueOf
(
projectListDto
.
getLatitude
()
==
null
?
""
:
projectListDto
.
getLatitude
()));
exportBnsProductDto
.
setSaleStatus
(
String
.
valueOf
(
projectListDto
.
getSaleStatus
()));
exportBnsProductDto
.
setSaleStatus
(
String
.
valueOf
(
projectListDto
.
getSaleStatus
()
==
null
?
""
:
projectListDto
.
getSaleStatus
()));
exportBnsProductDto
.
setIsTy
(
String
.
valueOf
(
projectListDto
.
getIsTy
()
==
null
?
""
:
projectListDto
.
getIsTy
()));
exportBnsProductDto
.
setPrice
(
projectListDto
.
getPrice
());
exportBnsProductDto
.
setOpenTime
(
projectListDto
.
getOpenTime
());
exportBnsProductDto
.
setLandArea
(
String
.
valueOf
(
projectListDto
.
getLandArea
()
==
null
?
""
:
projectListDto
.
getLandArea
()));
...
...
@@ -704,12 +706,16 @@ public class BnsProjectController {
AtomicInteger
indexInt
=
new
AtomicInteger
(
1
);
regionProductMapSuplyOrderByDESC
.
forEach
((
key
,
value
)
->
{
DetilRegionProductImgDto
detilRegionProductImgDto
=
new
DetilRegionProductImgDto
();
List
<
String
>
productIdS
=
new
ArrayLis
t
<>();
Set
<
String
>
productSetIds
=
new
HashSe
t
<>();
for
(
RegionProductResultDto
regionProductResultDto
:
value
)
{
List
<
String
>
list
=
splitStrProductToList
(
regionProductResultDto
.
getProductId
());
for
(
String
s
:
list
)
{
productIdS
.
add
(
s
);
}
}
productSetIds
.
add
(
s
);
}
}
List
<
String
>
productIdS
=
new
ArrayList
<>(
productSetIds
);
int
index
=
indexInt
.
getAndIncrement
();
List
<
ProductQueryDto
>
productQueryDtoList
=
new
ArrayList
<
ProductQueryDto
>();
...
...
@@ -848,7 +854,7 @@ public class BnsProjectController {
AtomicInteger
indexInt
=
new
AtomicInteger
(
1
);
regionProductMapSuplyOrderByDESC
.
forEach
((
key
,
value
)
->
{
List
<
String
>
productIdS
=
new
ArrayLis
t
<>();
Set
<
String
>
productSetIds
=
new
HashSe
t
<>();
PieDetilProductDto
pieDetilProductDto
=
new
PieDetilProductDto
();
BarProductDto
barDetilDto
=
new
BarProductDto
();
int
suplyNumberADD
=
0
;
...
...
@@ -858,10 +864,12 @@ public class BnsProjectController {
for
(
RegionProductResultDto
regionProductResultDto
:
value
)
{
List
<
String
>
list
=
splitStrProductToList
(
regionProductResultDto
.
getProductId
());
for
(
String
s
:
list
)
{
product
IdS
.
add
(
s
);
product
SetIds
.
add
(
s
);
}
}
List
<
String
>
productIdS
=
new
ArrayList
<>(
productSetIds
);
int
index
=
indexInt
.
getAndIncrement
();
pieDetilProductDto
.
setProductionPie
(
"产品"
+
index
);
pieDetilProductDto
.
setSupplication
(
suplyNumberADD
);
...
...
@@ -1615,9 +1623,14 @@ public class BnsProjectController {
bnsProject
.
setPrice
(
exportBnsProjectDto
.
getPrice
());
}
if
(
exportBnsProjectDto
.
getIsTy
()
!=
null
){
bnsProject
.
setIsTy
(
Integer
.
valueOf
(
exportBnsProjectDto
.
getIsTy
().
trim
()));
}
if
(
exportBnsProjectDto
.
getSaleStatus
()
!=
null
){
bnsProject
.
setSaleStatus
(
Integer
.
valueOf
(
exportBnsProjectDto
.
getSaleStatus
().
trim
()));
}
if
(
exportBnsProjectDto
.
getLandArea
()
!=
null
){
bnsProject
.
setLandArea
(
Float
.
valueOf
(
exportBnsProjectDto
.
getLandArea
().
trim
()));
}
...
...
@@ -1645,6 +1658,14 @@ public class BnsProjectController {
if
(
parentTpyeStr
.
equals
(
"1"
)){
// 全删全入 隶属关联 1
BnsBuildingProduct
bnsBuildingProductDel
=
new
BnsBuildingProduct
();
QueryWrapper
wrapperQueryVerifyDel
=
new
QueryWrapper
();
bnsBuildingProductDel
.
setProjectId
(
byProdectId
);
bnsBuildingProductDel
.
setType
(
1
);
wrapperQueryVerifyDel
.
setEntity
(
bnsBuildingProductDel
);
iBnsProjectParentService
.
remove
(
wrapperQueryVerifyDel
);
QueryWrapper
<
BnsRegion
>
wrapper
=
new
QueryWrapper
();
BnsRegion
bnsRegion
=
new
BnsRegion
();
bnsRegion
.
setDelFlag
(
"0"
);
...
...
@@ -1680,6 +1701,7 @@ public class BnsProjectController {
}
if
(
parentTpyeStr
.
equals
(
"0"
)){
QueryWrapper
<
BnsLand
>
wrapper
=
new
QueryWrapper
();
BnsLand
bnsLand
=
new
BnsLand
();
bnsLand
.
setDelFlag
(
"0"
);
...
...
@@ -1994,13 +2016,8 @@ public class BnsProjectController {
}
List
<
ProductQueryDto
>
productQueryDtoList
=
new
ArrayList
<
ProductQueryDto
>();
QueryWrapper
<
BnsProduct
>
queryWrapperProduct
=
new
QueryWrapper
<
BnsProduct
>();
BnsProduct
bnsProduct
=
new
BnsProduct
();
bnsProduct
.
setDelFlag
(
"0"
);
bnsProduct
.
setProjectId
(
businessId
);
queryWrapperProduct
.
orderByAsc
(
"PRODUCT_TYPE"
,
"UNIT_AREA"
);
queryWrapperProduct
.
setEntity
(
bnsProduct
);
bnsProductList
=
iBnsProductService
.
list
(
queryWrapperProduct
);
bnsProductList
=
iBnsProductService
.
getProductList
(
businessId
);
StringBuffer
sBuffer
=
new
StringBuffer
();
int
i
=
0
;
...
...
@@ -2536,7 +2553,9 @@ public class BnsProjectController {
iBnsProjectService
.
updateById
(
bnsProject
);
UpdateWrapper
wrapper
=
new
UpdateWrapper
();
wrapper
.
set
(
"PROJECT_ID"
,
businessId
);
BnsProduct
bnsProduct
=
new
BnsProduct
();
bnsProduct
.
setProjectId
(
businessId
);
wrapper
.
setEntity
(
bnsProduct
);
wrapper
.
set
(
"DEL_FLAG"
,
DelStatus
.
DELETED
.
getStatus
());
iBnsProductService
.
update
(
wrapper
);
...
...
src/main/java/com/isoft/tenio/business/bnsproject/dto/ExportBnsProductDto.java
View file @
e79aef25
...
...
@@ -54,14 +54,12 @@ public class ExportBnsProductDto extends CommonEntity {
*/
@Excel
(
name
=
"产品类型*"
,
height
=
20
,
width
=
30
)
@NotEmpty
(
message
=
"不能为空"
)
@Length
(
max
=
64
)
private
String
productType
;
/**
* 居室数
*/
@Excel
(
name
=
"居室数"
,
height
=
20
,
width
=
30
)
@Length
(
max
=
4
)
private
String
roomNumber
;
/**
...
...
@@ -69,42 +67,36 @@ public class ExportBnsProductDto extends CommonEntity {
*/
@Excel
(
name
=
"户型面积*"
,
height
=
20
,
width
=
30
)
@NotEmpty
(
message
=
"不能为空"
)
@Length
(
max
=
13
)
private
String
unitArea
;
/**
* 南向面宽
*/
@Excel
(
name
=
"南向面宽"
,
height
=
20
,
width
=
30
)
@Length
(
max
=
13
)
private
String
southWidth
;
/**
* 起居室面宽
*/
@Excel
(
name
=
"起居室面宽"
,
height
=
20
,
width
=
30
)
@Length
(
max
=
13
)
private
String
liveRoomWidth
;
/**
* 主卧面宽
*/
@Excel
(
name
=
"主卧面宽"
,
height
=
20
,
width
=
30
)
@Length
(
max
=
13
)
private
String
masterRoomWidth
;
/**
* 客卧面宽
*/
@Excel
(
name
=
"客卧面宽"
,
height
=
20
,
width
=
30
)
@Length
(
max
=
13
)
private
String
guestRoomWidth
;
/**
* 厅数
*/
@Excel
(
name
=
"厅数"
,
height
=
20
,
width
=
30
)
@Length
(
max
=
4
)
private
String
hallNumber
;
/**
...
...
@@ -116,14 +108,12 @@ public class ExportBnsProductDto extends CommonEntity {
* 卫生间数
*/
@Excel
(
name
=
"卫生间数"
,
height
=
20
,
width
=
30
)
@Length
(
max
=
9
)
private
String
toiletNumber
;
/**
* 开间数
*/
@Excel
(
name
=
"开间数"
,
height
=
20
,
width
=
30
)
@Length
(
max
=
8
)
private
String
bayNumber
;
/**
...
...
src/main/java/com/isoft/tenio/business/bnsproject/dto/ExportBnsProjectDto.java
View file @
e79aef25
...
...
@@ -36,7 +36,6 @@ public class ExportBnsProjectDto extends CommonEntity {
*/
@Excel
(
name
=
"楼盘编码*"
,
height
=
20
,
width
=
30
)
@NotEmpty
(
message
=
"不能为空"
)
@Length
(
max
=
20
)
private
String
code
;
/**
...
...
@@ -44,14 +43,12 @@ public class ExportBnsProjectDto extends CommonEntity {
*/
@Excel
(
name
=
"楼盘名称*"
,
height
=
20
,
width
=
30
)
@NotEmpty
(
message
=
"不能为空"
)
@Length
(
max
=
50
)
private
String
name
;
/**
* 楼盘简称(最大30个字符)
*/
@Excel
(
name
=
"其他名称"
,
height
=
20
,
width
=
30
)
@Length
(
max
=
30
)
private
String
shortName
;
/**
...
...
@@ -59,7 +56,6 @@ public class ExportBnsProjectDto extends CommonEntity {
*/
@Excel
(
name
=
"隶属(0:土拍;1:板块)*"
,
height
=
20
,
width
=
30
)
@NotEmpty
(
message
=
"类型不能为空"
)
@Length
(
max
=
10
)
private
String
parentTpye
;
/**
...
...
@@ -67,21 +63,18 @@ public class ExportBnsProjectDto extends CommonEntity {
*/
@Excel
(
name
=
"隶属板块(土拍)*"
,
height
=
20
,
width
=
30
)
@NotEmpty
(
message
=
"不能为空"
)
@Length
(
max
=
30
)
private
String
parentName
;
/**
* 经度
*/
@Excel
(
name
=
"经度"
,
height
=
20
,
width
=
30
)
@Length
(
max
=
17
)
private
String
longitude
;
/**
* 纬度
*/
@Excel
(
name
=
"纬度"
,
height
=
20
,
width
=
30
)
@Length
(
max
=
17
)
private
String
latitude
;
/**
...
...
@@ -89,7 +82,6 @@ public class ExportBnsProjectDto extends CommonEntity {
*/
@Excel
(
name
=
"销售状态(0:售罄;1:在售)*"
,
height
=
20
,
width
=
30
)
@NotEmpty
(
message
=
"不能为空"
)
@Length
(
max
=
2
)
private
String
saleStatus
;
/**
...
...
@@ -97,14 +89,12 @@ public class ExportBnsProjectDto extends CommonEntity {
*/
@Excel
(
name
=
"是否天友设计(0:否;1:是)*"
,
height
=
20
,
width
=
30
)
@NotEmpty
(
message
=
"不能为空"
)
@Length
(
max
=
2
)
private
String
isTenio
;
private
String
isTy
;
/**
* 价格
*/
@Excel
(
name
=
"价格"
,
height
=
20
,
width
=
30
)
@Length
(
max
=
32
)
private
String
price
;
/**
...
...
@@ -119,42 +109,36 @@ public class ExportBnsProjectDto extends CommonEntity {
* 用地面积
*/
@Excel
(
name
=
"用地面积"
,
height
=
20
,
width
=
30
)
@Length
(
max
=
19
)
private
String
landArea
;
/**
* 总建筑面积
*/
@Excel
(
name
=
"总建筑面积"
,
height
=
20
,
width
=
30
)
@Length
(
max
=
19
)
private
String
totalArea
;
/**
* 容积率
*/
@Excel
(
name
=
"容积率"
,
height
=
20
,
width
=
30
)
@Length
(
max
=
32
)
private
String
plotRatio
;
/**
* 总户数
*/
@Excel
(
name
=
"总户数"
,
height
=
20
,
width
=
30
)
@Length
(
max
=
9
)
private
String
totalHousehold
;
/**
* 开发商
*/
@Excel
(
name
=
"开发商"
,
height
=
20
,
width
=
30
)
@Length
(
max
=
64
)
private
String
developer
;
/**
* 物业管理
*/
@Excel
(
name
=
"物业管理"
,
height
=
20
,
width
=
30
)
@Length
(
max
=
64
)
private
String
estateManage
;
...
...
src/main/java/com/isoft/tenio/business/bnssale/controller/BnsSaleController.java
View file @
e79aef25
This diff is collapsed.
Click to expand it.
src/main/java/com/isoft/tenio/business/bnssale/dto/ExportSaleProjectDTO.java
0 → 100644
View file @
e79aef25
package
com
.
isoft
.
tenio
.
business
.
bnssale
.
dto
;
import
cn.afterturn.easypoi.excel.annotation.Excel
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.isoft.tenio.utils.entity.CommonEntity
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
javax.validation.constraints.NotNull
;
import
java.util.Date
;
/**
* @Author: HaoChangXi
* @Date: 2020/6/30 13:30
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
ExportSaleProjectDTO
extends
CommonEntity
{
/**
* 时间(月) -- 销售月份
* */
@Excel
(
name
=
"时间(月)"
,
height
=
20
,
width
=
30
)
@NotNull
(
message
=
"不能为空"
)
private
String
saleMonth
;
/**
* 成交数量
*/
@Excel
(
name
=
"成交套数(套)"
,
height
=
20
,
width
=
30
)
private
Integer
dealNumber
;
/**
* 供应套数
*/
@Excel
(
name
=
"供应套数(套)"
,
height
=
20
,
width
=
30
)
private
Integer
suplyNumber
;
@Excel
(
name
=
"区域"
,
height
=
20
,
width
=
30
)
private
String
quYu
;
@Excel
(
name
=
"板块"
,
height
=
20
,
width
=
30
)
private
String
banKai
;
@Excel
(
name
=
"开发商"
,
height
=
20
,
width
=
30
)
private
String
kaiFaS
;
@Excel
(
name
=
"供应面积(㎡)"
,
height
=
20
,
width
=
30
)
private
String
gongQiuM
;
@Excel
(
name
=
"成交面积(㎡)"
,
height
=
20
,
width
=
30
)
private
String
chenJiaM
;
@Excel
(
name
=
"成交均价(元/㎡)"
,
height
=
20
,
width
=
30
)
private
String
chenJiaJ
;
@Excel
(
name
=
"套均价(元/套)"
,
height
=
20
,
width
=
30
)
private
String
taoJunJ
;
@Excel
(
name
=
"成交金额(元)"
,
height
=
20
,
width
=
30
)
private
String
chenJiaJE
;
@Excel
(
name
=
"供求比"
,
height
=
20
,
width
=
30
)
private
String
gongQiuBi
;
/**
* 最小面积
*/
private
String
minArea
;
/**
* 楼盘名称
*/
private
String
projectName
;
/**
* 最大面积
*/
private
String
maxArea
;
private
String
areaInterval
;
private
String
productTypeName
;
}
src/main/java/com/isoft/tenio/business/bnssale/service/impl/BnsSaleServiceImpl.java
View file @
e79aef25
...
...
@@ -194,11 +194,11 @@ public class BnsSaleServiceImpl extends ServiceImpl<BnsSaleMapper, BnsSale> impl
}
if
(
s2
.
equals
(
o
)
||
(
o_minArea
<=
s2_minArea
&&
o_maxArea
>=
s2_maxArea
))
{
if
(
map
.
get
(
s2
)
!=
null
)
{
SaleDto
saleDto1
=
map
.
get
(
s2
);
saleDto1
.
setDealNumber
(
map
.
get
(
s2
).
getDealNumber
()
+
saleDto
.
getDealNumber
());
saleDto1
.
setSuplyNumber
(
map
.
get
(
s2
).
getSuplyNumber
()
+
saleDto
.
getSuplyNumber
());
map
.
put
(
s2
,
saleDto1
);
if
(
map
.
get
(
o
)
!=
null
)
{
SaleDto
saleDto1
=
map
.
get
(
o
);
saleDto1
.
setDealNumber
(
map
.
get
(
o
).
getDealNumber
()
+
saleDto
.
getDealNumber
());
saleDto1
.
setSuplyNumber
(
map
.
get
(
o
).
getSuplyNumber
()
+
saleDto
.
getSuplyNumber
());
map
.
put
(
o
,
saleDto1
);
}
else
{
SaleDto
saleDto2
=
new
SaleDto
();
saleDto2
.
setDealNumber
(
saleDto
.
getDealNumber
());
...
...
@@ -251,21 +251,32 @@ public class BnsSaleServiceImpl extends ServiceImpl<BnsSaleMapper, BnsSale> impl
for
(
SaleDto
saleDto
:
saleDtos
)
{
String
s2
=
new
DecimalFormat
(
"#.00"
).
format
(
saleDto
.
getAreaMin
())
+
"-"
+
new
DecimalFormat
(
"#.00"
).
format
(
saleDto
.
getAreaMax
());
float
s2_minArea
=
Float
.
valueOf
(
new
DecimalFormat
(
"#.00"
).
format
(
saleDto
.
getAreaMin
()));
float
s2_maxArea
=
Float
.
valueOf
(
new
DecimalFormat
(
"#.00"
).
format
(
saleDto
.
getAreaMax
()));
dealTotal
=
dealTotal
+
saleDto
.
getDealNumber
();
suplyTotal
=
suplyTotal
+
saleDto
.
getSuplyNumber
();
for
(
Object
o
:
map
.
keySet
())
{
if
(
s2
.
equals
(
o
))
{
if
(
map
.
get
(
s2
)
!=
null
)
{
SaleDto
saleDto1
=
map
.
get
(
s2
);
saleDto1
.
setDealNumber
(
map
.
get
(
s2
).
getDealNumber
()
+
saleDto
.
getDealNumber
());
saleDto1
.
setSuplyNumber
(
map
.
get
(
s2
).
getSuplyNumber
()
+
saleDto
.
getSuplyNumber
());
map
.
put
(
s2
,
saleDto1
);
float
o_minArea
=
0
;
float
o_maxArea
=
0
;
if
(
o
.
toString
().
contains
(
"-"
)){
String
[]
o_Arr
=
o
.
toString
().
split
(
"-"
);
o_minArea
=
Float
.
valueOf
(
o_Arr
[
0
]);
o_maxArea
=
Float
.
valueOf
(
o_Arr
[
1
]);
}
if
(
s2
.
equals
(
o
)
||
(
o_minArea
<=
s2_minArea
&&
o_maxArea
>=
s2_maxArea
))
{
if
(
map
.
get
(
o
)
!=
null
)
{
SaleDto
saleDto1
=
map
.
get
(
o
);
saleDto1
.
setDealNumber
(
map
.
get
(
o
).
getDealNumber
()
+
saleDto
.
getDealNumber
());
saleDto1
.
setSuplyNumber
(
map
.
get
(
o
).
getSuplyNumber
()
+
saleDto
.
getSuplyNumber
());
map
.
put
(
o
,
saleDto1
);
}
else
{
SaleDto
saleDto2
=
new
SaleDto
();
saleDto2
.
setDealNumber
(
saleDto
.
getDealNumber
());
saleDto2
.
setSuplyNumber
(
saleDto
.
getSuplyNumber
());
map
.
put
(
s2
,
saleDto2
);
map
.
put
(
o
,
saleDto2
);
}
}
}
...
...
src/main/java/com/isoft/tenio/utils/excel/ExcelPatternMsg.java
View file @
e79aef25
...
...
@@ -30,6 +30,9 @@ public class ExcelPatternMsg {
public
static
final
String
DATEMonth
=
"^(([1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2})\\/(0[1-9]|[12][0-9]|3[01]))$"
;
public
static
final
String
DATEMonth_MSG
=
"输入正确的日期格式:yyyy/MM"
;
public
static
final
String
DATEMonthC
=
"^(([1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2})年(0[1-9]|[12][0-9]|3[01])月)$"
;
public
static
final
String
DATEMonthC_MSG
=
"输入正确的日期格式:yyyy年MM月"
;
//日期格式 yyyy/MM/dd
public
static
final
String
DATE1
=
"(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})\\/(((0[13578]|1[02])\\/(0[1-9]|[12][0-9]|3[01]))|"
+
...
...
@@ -95,10 +98,6 @@ public class ExcelPatternMsg {
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
Pattern
.
matches
(
DECIMALAreaInterval
,
"90/100"
));
String
[]
s
=
"ssss-ssss.xlsx"
.
split
(
"\\."
);
System
.
out
.
println
(
s
[
0
]);
System
.
out
.
println
(
s
[
1
]);
System
.
out
.
println
(
Pattern
.
matches
(
DATEMonthC
,
"2019年06月"
));
}
}
\ No newline at end of file
src/main/java/com/isoft/tenio/utils/poi/ExportSaleProjectHander.java
0 → 100644
View file @
e79aef25
package
com
.
isoft
.
tenio
.
utils
.
poi
;
import
cn.afterturn.easypoi.excel.entity.result.ExcelVerifyHandlerResult
;
import
cn.afterturn.easypoi.handler.inter.IExcelVerifyHandler
;
import
com.alibaba.fastjson.JSONObject
;
import
com.isoft.tenio.business.bnsproject.entity.BnsProject
;
import
com.isoft.tenio.business.bnsproject.service.IBnsProjectService
;
import
com.isoft.tenio.business.bnssale.dto.ExportSaleProjectDTO
;
import
com.isoft.tenio.business.bnssale.service.IBnsSaleService
;
import
com.isoft.tenio.business.bnssale.utils.SaleProductType
;
import
com.isoft.tenio.utils.Utils
;
import
com.isoft.tenio.utils.excel.ExcelPatternMsg
;
import
lombok.SneakyThrows
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.util.IOUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.mock.web.MockMultipartFile
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Function
;
import
java.util.regex.Pattern
;
import
java.util.stream.Collectors
;
/**
* 自定义校验 官方api
*
* @author :jiangpengpeng
* @date:2020/6/24 11:17
*/
@Component
public
class
ExportSaleProjectHander
implements
IExcelVerifyHandler
<
ExportSaleProjectDTO
>
{
@Value
(
"${file.dir.sale}"
)
private
String
sale
;
/**
* 文件的目录
*/
@Value
(
"${file.realFile}"
)
private
String
realFile
;
@Autowired
private
IBnsSaleService
iBnsSaleService
;
@Autowired
private
IBnsProjectService
iBnsProjectService
;
/**
* 更新销售按行验证
* @author Super_liu
* @param ExportSaleProjectDTO
* @return
*/
@SneakyThrows
@Override
public
ExcelVerifyHandlerResult
verifyHandler
(
ExportSaleProjectDTO
exportSaleProjectDTO
)
{
ExcelVerifyHandlerResult
result
=
new
ExcelVerifyHandlerResult
(
true
,
""
);
List
<
String
>
list
=
new
ArrayList
<>();
String
projectName
=
""
;
String
minArea
=
""
;
String
maxArea
=
""
;
String
saleTime
=
""
;
String
filePath
=
realFile
+
"/"
+
sale
+
"/saleProject.txt"
;
JSONObject
jsonObject
=
null
;
if
(
Utils
.
verifyFile
(
filePath
))
{
jsonObject
=
JSONObject
.
parseObject
(
Utils
.
readFile
(
filePath
));
}
if
(
jsonObject
!=
null
&&
jsonObject
.
get
(
"areaInterval"
)
!=
null
&&
jsonObject
.
get
(
"areaInterval"
).
toString
()!=
""
){
String
[]
str
=
jsonObject
.
get
(
"areaInterval"
).
toString
().
split
(
"-"
);
minArea
=
str
[
0
];
boolean
matchesMin
=
Pattern
.
matches
(
ExcelPatternMsg
.
Decimal
,
minArea
.
toString
());
maxArea
=
str
[
1
];
boolean
matchesMax
=
Pattern
.
matches
(
ExcelPatternMsg
.
Decimal
,
maxArea
.
toString
());
if
(!
matchesMax
&&
!
matchesMin
){
list
.
add
(
"面积区间不合法"
+
ExcelPatternMsg
.
DECIMALAreaInterval_MSG
);
}
else
if
(!
matchesMax
&&
matchesMin
){
list
.
add
(
"面积区间最大面积不合法"
+
ExcelPatternMsg
.
DECIMALAreaInterval_MSG
);
}
else
if
(
matchesMax
&&
!
matchesMin
){
list
.
add
(
"面积区间最小面积不合法"
+
ExcelPatternMsg
.
DECIMALAreaInterval_MSG
);
}
}
if
(
exportSaleProjectDTO
.
getSaleMonth
()
!=
null
&&
exportSaleProjectDTO
.
getSaleMonth
().
toString
()!=
""
){
boolean
matches
=
Pattern
.
matches
(
ExcelPatternMsg
.
DATEMonthC
,
exportSaleProjectDTO
.
getSaleMonth
().
toString
());
if
(!
matches
){
list
.
add
(
"销售时间不合法"
+
ExcelPatternMsg
.
DATEMonthC_MSG
);
}
else
{
saleTime
=
exportSaleProjectDTO
.
getSaleMonth
().
toString
();
}
}
if
(
jsonObject
!=
null
&&
jsonObject
.
get
(
"projectName"
)
!=
null
&&
jsonObject
.
get
(
"projectName"
).
toString
()!=
""
){
projectName
=
jsonObject
.
get
(
"projectName"
).
toString
();
BnsProject
bnsProject
=
iBnsProjectService
.
getVerifyNameOne
(
projectName
);
if
(
bnsProject
==
null
)
{
list
.
add
(
"楼盘不存在"
);
}
else
if
((
minArea
!=
null
&&
!
minArea
.
equals
(
""
))
&&
(
maxArea
!=
null
&&
!
maxArea
.
equals
(
""
))){
String
projectId
=
bnsProject
.
getBusinessId
();
String
jsonTypeName
=
jsonObject
.
get
(
"productTypeName"
).
toString
();
String
productTypeName
=
SaleProductType
.
getSelectProductType
(
jsonTypeName
);
String
[]
tName
=
null
;
if
(
jsonTypeName
.
equals
(
"别墅"
)){
tName
=
productTypeName
.
split
(
"-"
);
}
List
<
String
>
listProductTypes
=
new
ArrayList
<>();
if
(
tName
!=
null
){
List
<
String
>
listProductTypes1
=
iBnsSaleService
.
selectProductTypes
(
projectId
,
tName
[
0
],
minArea
,
maxArea
);
List
<
String
>
listProductTypes2
=
iBnsSaleService
.
selectProductTypes
(
projectId
,
tName
[
1
],
minArea
,
maxArea
);
if
(
listProductTypes1
.
size
()
==
1
&&
listProductTypes2
.
size
()
==
1
){
list
.
add
(
"该产品下的("
+
tName
[
0
]+
"-"
+
tName
[
1
]+
")面积区间("
+
minArea
+
"-"
+
maxArea
+
")产品类型各存在一个(俩种类型只可存在一个)"
);
}
else
if
(
listProductTypes1
.
size
()
>=
1
&&
listProductTypes2
.
size
()
==
0
){
listProductTypes
=
listProductTypes1
;
}
else
if
(
listProductTypes2
.
size
()
>=
1
&&
listProductTypes1
.
size
()
==
0
){
listProductTypes
=
listProductTypes2
;
}
}
else
{
listProductTypes
=
iBnsSaleService
.
selectProductTypes
(
projectId
,
productTypeName
,
minArea
,
maxArea
);
}
if
(
minArea
.
equals
(
maxArea
)){
list
.
add
(
"面积区间面积相等(请修改最大面积)"
);
}
else
if
(
listProductTypes
==
null
||
listProductTypes
.
size
()
==
0
){
list
.
add
(
"楼盘产品类型不存在(请在楼盘管理设置当前楼盘产品类型)"
);
}
else
if
(
listProductTypes
.
size
()
>
1
){
list
.
add
(
"该楼盘("
+
projectName
+
")产品类型下的面积区间("
+
minArea
+
"-"
+
maxArea
+
"㎡)含多个产品(需缩短面积区间、精确定位产品)"
);
}
else
{
String
productType
=
listProductTypes
.
get
(
0
);
if
(
saleTime
!=
null
&&
!
saleTime
.
equals
(
""
)){
String
min
=
""
;
String
max
=
""
;
if
(
Float
.
valueOf
(
maxArea
)
<=
70
){
min
=
"0"
;
max
=
"70"
;
}
else
if
(
Float
.
valueOf
(
maxArea
)
>
200
){
min
=
"200"
;
max
=
"20000"
;
}
else
{
min
=
minArea
;
max
=
maxArea
;
}
saleTime
=
new
SimpleDateFormat
(
"yyyy-mm-dd"
).
format
(
new
SimpleDateFormat
(
"yyyy年mm月"
).
parse
(
saleTime
));
int
count
=
iBnsSaleService
.
productTypeCount
(
projectId
,
productType
,
min
,
max
,
saleTime
);
if
(
count
==
1
){
list
.
add
(
"销售信息已存在"
);
}
else
if
(
count
>
1
){
list
.
add
(
"销售信息重复存在多条"
);
}
}
}
}
}
// 验证每行在EXCEL中 是否出现重复数据 并 按行提示 ---Start---
String
filePathE
=
realFile
+
"/"
+
sale
+
"/saleProject.xls"
;
File
fileE
=
new
File
(
filePathE
);
FileInputStream
inputStream
=
new
FileInputStream
(
fileE
);
MultipartFile
multipartFile
=
new
MockMultipartFile
(
"file"
,
fileE
.
getName
(),
"text/plain"
,
IOUtils
.
toByteArray
(
inputStream
));
List
<
ExportSaleProjectDTO
>
saleDTOList
=
Utils
.
importExcel
(
multipartFile
,
1
,
1
,
ExportSaleProjectDTO
.
class
);
if
(
saleDTOList
==
null
){
saleDTOList
=
Utils
.
importExcel
(
multipartFile
,
2
,
1
,
ExportSaleProjectDTO
.
class
);
}
if
(
saleDTOList
!=
null
&&
saleDTOList
.
size
()
>
0
){
if
(
saleDTOList
.
get
(
0
).
getSaleMonth
()
==
null
){
saleDTOList
=
Utils
.
importExcel
(
multipartFile
,
2
,
1
,
ExportSaleProjectDTO
.
class
);
}
Map
<
ExportSaleProjectDTO
,
Long
>
collect
=
saleDTOList
.
stream
().
collect
(
Collectors
.
groupingBy
(
Function
.
identity
(),
Collectors
.
counting
()));
if
(
collect
.
get
(
exportSaleProjectDTO
)
!=
null
){
if
(
collect
.
get
(
exportSaleProjectDTO
)
>
1
){
list
.
add
(
"Excel中销售信息重复"
);
}
}
}
// 验证每行在EXCEL中 是否出现重复数据 并 按行提示 ---End---
if
(
list
.
size
()
>
0
){
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
if
(
i
==
0
){
sb
.
append
(
list
.
get
(
i
));
}
else
{
sb
.
append
(
","
+
list
.
get
(
i
));
}
}
result
.
setMsg
(
sb
.
toString
());
result
.
setSuccess
(
false
);
return
result
;
}
return
result
;
}
}
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