Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-store
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
base_platform_enterprise
gic-store
Commits
1516a510
Commit
1516a510
authored
Jul 08, 2019
by
zhiwj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
自定义字段:时间
parent
e82d074b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
33 deletions
+50
-33
StoreImportApiService.java
...ain/java/com/gic/store/service/StoreImportApiService.java
+3
-0
StoreImportApiServiceImpl.java
...om/gic/store/service/outer/StoreImportApiServiceImpl.java
+14
-4
ExcelUtils.java
...store-web/src/main/java/com/gic/store/web/ExcelUtils.java
+17
-10
StoreImportController.java
...a/com/gic/store/web/controller/StoreImportController.java
+16
-19
No files found.
gic-store-api/src/main/java/com/gic/store/service/StoreImportApiService.java
View file @
1516a510
...
...
@@ -5,6 +5,7 @@ import com.gic.api.base.commons.ServiceResponse;
import
com.gic.store.dto.StoreTmpDTO
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author zhiwj
...
...
@@ -44,4 +45,6 @@ public interface StoreImportApiService {
// List<StoreTmpDTO> listStoreTmp(Integer enterpriseId, Boolean isSuccess, Boolean isWait);
ServiceResponse
<
List
<
List
<
String
>>>
listImportTitle
(
Integer
enterpriseId
,
Integer
regionId
);
ServiceResponse
<
Map
<
Integer
,
Boolean
>>
fieldIsDateType
(
Integer
enterpriseId
,
Integer
regionId
);
}
gic-store-service/src/main/java/com/gic/store/service/outer/StoreImportApiServiceImpl.java
View file @
1516a510
...
...
@@ -6,6 +6,7 @@ import com.gic.api.base.commons.Page;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.commons.util.PageHelperUtils
;
import
com.gic.store.constant.StoreFieldTypeEnum
;
import
com.gic.store.dto.StoreExtendDTO
;
import
com.gic.store.dto.StoreTmpDTO
;
import
com.gic.store.entity.TabStoreBrand
;
...
...
@@ -20,10 +21,7 @@ import org.apache.logging.log4j.Logger;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -236,4 +234,16 @@ public class StoreImportApiServiceImpl implements StoreImportApiService {
return
ServiceResponse
.
success
(
list
);
}
@Override
public
ServiceResponse
<
Map
<
Integer
,
Boolean
>>
fieldIsDateType
(
Integer
enterpriseId
,
Integer
regionId
)
{
HashMap
<
Integer
,
Boolean
>
map
=
new
HashMap
<>();
List
<
TabStoreField
>
fields
=
storeFieldService
.
listStoreFieldByRegionId
(
regionId
);
if
(
CollectionUtils
.
isNotEmpty
(
fields
))
{
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
map
.
put
(
14
+
i
,
fields
.
get
(
i
).
getStoreFieldType
()
==
StoreFieldTypeEnum
.
DATE
.
getCode
());
}
}
return
ServiceResponse
.
success
(
map
);
}
}
gic-store-web/src/main/java/com/gic/store/web/ExcelUtils.java
View file @
1516a510
package
com
.
gic
.
store
.
web
;
import
com.gic.store.constant.Constants
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.poi.ss.usermodel.Cell
;
...
...
@@ -9,10 +10,8 @@ import org.apache.poi.xssf.usermodel.*;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
/**
* @author zhiwj
...
...
@@ -268,16 +267,17 @@ public class ExcelUtils {
* @param fileType 文件的后缀 例如:xls xlsx
* @return
*/
public
static
List
<
Map
<
Integer
,
String
>>
readExcel
(
int
row
,
String
fileType
,
XSSFWorkbook
xssfWorkbook
)
{
public
static
List
<
Map
<
Integer
,
String
>>
readExcel
(
int
row
,
String
fileType
,
XSSFWorkbook
xssfWorkbook
,
Map
<
Integer
,
Boolean
>
dateTypeMap
)
{
if
(
fileType
.
equals
(
"xlsx"
))
{
return
readXlsx
(
xssfWorkbook
,
row
);
return
readXlsx
(
xssfWorkbook
,
row
,
dateTypeMap
);
}
else
{
return
null
;
}
}
public
static
List
<
Map
<
Integer
,
String
>>
readXlsx
(
XSSFWorkbook
xssfWorkbook
,
int
row
)
{
public
static
List
<
Map
<
Integer
,
String
>>
readXlsx
(
XSSFWorkbook
xssfWorkbook
,
int
row
,
Map
<
Integer
,
Boolean
>
dateTypeMap
)
{
List
<
Map
<
Integer
,
String
>>
result
=
new
ArrayList
<
Map
<
Integer
,
String
>>();
SimpleDateFormat
format
=
new
SimpleDateFormat
(
Constants
.
dateformat
);
// XSSFWorkbook xssfWorkbook = new XSSFWorkbook(in);
for
(
int
numSheet
=
0
;
numSheet
<
1
;
numSheet
++)
{
XSSFSheet
xssfSheet
=
xssfWorkbook
.
getSheetAt
(
numSheet
);
...
...
@@ -299,10 +299,17 @@ public class ExcelUtils {
if
(
xssfCell
==
null
)
{
map
.
put
(
colix
,
""
);
}
else
{
if
(
xssfCell
.
getCellType
()
!=
Cell
.
CELL_TYPE_STRING
)
{
xssfCell
.
setCellType
(
Cell
.
CELL_TYPE_STRING
);
Boolean
isDate
=
dateTypeMap
.
get
(
colix
);
if
(
isDate
!=
null
&&
isDate
)
{
Date
date
=
xssfCell
.
getDateCellValue
();
map
.
put
(
colix
,
format
.
format
(
date
));
}
else
{
if
(
xssfCell
.
getCellType
()
!=
Cell
.
CELL_TYPE_STRING
)
{
xssfCell
.
setCellType
(
Cell
.
CELL_TYPE_STRING
);
}
map
.
put
(
colix
,
xssfCell
.
getStringCellValue
());
}
map
.
put
(
colix
,
xssfCell
.
getStringCellValue
());
}
}
if
(!
isEmpty
(
map
,
minColix
,
maxColix
))
{
...
...
gic-store-web/src/main/java/com/gic/store/web/controller/StoreImportController.java
View file @
1516a510
...
...
@@ -135,7 +135,8 @@ public class StoreImportController {
if
(
storeRegion
==
null
)
{
return
RestResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"门店域不存在"
);
}
List
<
Map
<
Integer
,
String
>>
data
=
ExcelUtils
.
readExcel
(
6
,
fileName
.
substring
(
fileName
.
lastIndexOf
(
"."
)
+
1
),
workbook
);
ServiceResponse
<
Map
<
Integer
,
Boolean
>>
isDateTypeMap
=
storeImportApiService
.
fieldIsDateType
(
enterpriseId
,
storeRegion
.
getRegionId
());
List
<
Map
<
Integer
,
String
>>
data
=
ExcelUtils
.
readExcel
(
6
,
fileName
.
substring
(
fileName
.
lastIndexOf
(
"."
)
+
1
),
workbook
,
isDateTypeMap
.
getResult
());
ServiceResponse
<
List
<
List
<
String
>>>
titleServiceResponse
=
storeImportApiService
.
listImportTitle
(
enterpriseId
,
storeRegion
.
getRegionId
());
List
<
String
>
titleList
=
titleServiceResponse
.
getResult
().
get
(
0
);
// todo 这里在测试完成后放开
...
...
@@ -388,24 +389,20 @@ public class StoreImportController {
ServiceResponse
<
List
<
ProvinceDTO
>>
provinceResponse
=
provincesApiService
.
selectAllProvince
();
ServiceResponse
<
List
<
CityDTO
>>
cityResponse
=
provincesApiService
.
selectAllCity
();
ServiceResponse
<
List
<
CountyDTO
>>
countyResponse
=
provincesApiService
.
selectAllCounty
();
if
(
provinceResponse
.
isSuccess
()
&&
cityResponse
.
isSuccess
()
&&
countyResponse
.
isSuccess
())
{
List
<
ProvinceDTO
>
provinceDTOList
=
provinceResponse
.
getResult
();
long
provinceCount
=
provinceDTOList
.
stream
().
filter
(
e
->
StringUtils
.
equals
(
e
.
getProvinceName
(),
province
)).
count
();
List
<
CityDTO
>
cityDTOList
=
cityResponse
.
getResult
();
long
cityCount
=
cityDTOList
.
stream
().
filter
(
e
->
StringUtils
.
equals
(
e
.
getCityName
(),
city
)).
count
();
List
<
CountyDTO
>
countyDTOList
=
countyResponse
.
getResult
();
long
countyCount
=
countyDTOList
.
stream
().
filter
(
e
->
StringUtils
.
equals
(
e
.
getCountyName
(),
county
)).
count
();
if
(
countyCount
==
0
)
{
bean
.
setErrorMessage
(
"输入的区县信息有误"
);
}
if
(
cityCount
==
0
)
{
bean
.
setErrorMessage
(
"输入的市信息有误"
);
}
if
(
provinceCount
==
0
)
{
bean
.
setErrorMessage
(
"输入的省信息有误"
);
}
}
else
{
logger
.
warn
(
"省市区调用服务失败"
);
List
<
ProvinceDTO
>
provinceDTOList
=
provinceResponse
.
getResult
();
long
provinceCount
=
provinceDTOList
.
stream
().
filter
(
e
->
StringUtils
.
equals
(
e
.
getProvinceName
(),
province
)).
count
();
List
<
CityDTO
>
cityDTOList
=
cityResponse
.
getResult
();
long
cityCount
=
cityDTOList
.
stream
().
filter
(
e
->
StringUtils
.
equals
(
e
.
getCityName
(),
city
)).
count
();
List
<
CountyDTO
>
countyDTOList
=
countyResponse
.
getResult
();
long
countyCount
=
countyDTOList
.
stream
().
filter
(
e
->
StringUtils
.
equals
(
e
.
getCountyName
(),
county
)).
count
();
if
(
countyCount
==
0
)
{
bean
.
setErrorMessage
(
"输入的区县信息有误"
);
}
if
(
cityCount
==
0
)
{
bean
.
setErrorMessage
(
"输入的市信息有误"
);
}
if
(
provinceCount
==
0
)
{
bean
.
setErrorMessage
(
"输入的省信息有误"
);
}
}
// 验证门店详细地址
...
...
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