Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
traffic-front
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangxiaoming
traffic-front
Commits
9c6f75c5
Commit
9c6f75c5
authored
Aug 02, 2019
by
frank.xa.zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
batch upload for template download -- frank
parent
369d172a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
160 additions
and
0 deletions
+160
-0
DataImportController.java
...ava/pwc/taxtech/atms/controller/DataImportController.java
+53
-0
TemplateController.java
.../java/pwc/taxtech/atms/controller/TemplateController.java
+59
-0
DataImportService.java
...java/pwc/taxtech/atms/service/impl/DataImportService.java
+48
-0
No files found.
atms-api/src/main/java/pwc/taxtech/atms/controller/DataImportController.java
0 → 100644
View file @
9c6f75c5
package
pwc
.
taxtech
.
atms
.
controller
;
import
com.alibaba.fastjson.JSONArray
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
pwc.taxtech.atms.common.message.ErrorMessage
;
import
pwc.taxtech.atms.dto.OperationResultDto
;
import
pwc.taxtech.atms.exception.ServiceException
;
import
pwc.taxtech.atms.service.impl.DataImportService
;
import
javax.annotation.Resource
;
import
java.util.List
;
@RestController
@RequestMapping
(
"/api/v1/DataImport/"
)
public
class
DataImportController
extends
BaseController
{
@Resource
private
DataImportService
dataImportService
;
@ResponseBody
@RequestMapping
(
value
=
"RLITExcelFile"
,
method
=
RequestMethod
.
POST
)
public
OperationResultDto
importRLITExcelFile
(
@RequestParam
MultipartFile
file
,
@RequestParam
String
orgIds
,
@RequestParam
String
periodDate
,
@RequestParam
Integer
importType
)
{
try
{
List
<
String
>
orgList
=
(
List
<
String
>)
JSONArray
.
parse
(
orgIds
);
String
valMsg
=
valParameter
(
file
,
orgList
,
periodDate
);
if
(
StringUtils
.
isNotEmpty
(
valMsg
)){
return
OperationResultDto
.
error
(
valMsg
);
}
return
dataImportService
.
importRLITExcelFile
(
file
,
orgList
,
periodDate
,
importType
);
}
catch
(
ServiceException
e
)
{
return
OperationResultDto
.
error
(
e
.
getMessage
());
}
catch
(
Exception
e
)
{
logger
.
error
(
"importRLITExcelFile error."
,
e
);
return
OperationResultDto
.
error
(
ErrorMessage
.
SystemError
);
}
}
private
String
valParameter
(
MultipartFile
file
,
List
<
String
>
orgList
,
String
periodDate
){
if
(
null
==
file
)
{
return
ErrorMessage
.
NoFile
;
}
if
(
orgList
.
size
()<
1
){
return
ErrorMessage
.
DidntSelectedCompany
;
}
if
(
StringUtils
.
isEmpty
(
periodDate
)){
return
ErrorMessage
.
DidntSelectedPeriod
;
}
return
null
;
}
}
atms-api/src/main/java/pwc/taxtech/atms/controller/TemplateController.java
0 → 100644
View file @
9c6f75c5
package
pwc
.
taxtech
.
atms
.
controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
pwc.taxtech.atms.common.message.ErrorMessage
;
import
pwc.taxtech.atms.exception.ServiceException
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.InputStream
;
@RestController
@RequestMapping
(
value
=
"api/v1/template/"
)
public
class
TemplateController
extends
BaseController
{
@RequestMapping
(
value
=
"file/downloadTemplate"
,
method
=
RequestMethod
.
GET
)
public
void
fileDownload
(
HttpServletResponse
response
)
{
//获取网站部署路径(通过ServletContext对象),用于确定下载文件位置,从而实现下载
response
.
setContentType
(
"multipart/form-data"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment;fileName=org_import_template.xlsx"
);
ServletOutputStream
out
;
try
{
InputStream
inputStream
=
this
.
getClass
().
getResourceAsStream
(
"/document/DataImport/org_import_template.xlsx"
);
out
=
response
.
getOutputStream
();
int
b
=
0
;
byte
[]
buffer
=
new
byte
[
512
];
while
((
b
=
inputStream
.
read
(
buffer
))
>
0
)
{
out
.
write
(
buffer
,
0
,
b
);
}
inputStream
.
close
();
out
.
close
();
out
.
flush
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
logger
.
error
(
String
.
format
(
"下载批量导入模板异常:%s"
,
e
.
getMessage
()));
throw
new
ServiceException
(
ErrorMessage
.
SystemError
);
}
}
// @ResponseBody
// @RequestMapping(value = "upload", method = RequestMethod.POST)
// public OperationResultDto upload(@RequestParam MultipartFile file, @RequestParam String
// projectId, @RequestParam Integer period) {
// try {
// ReportUpload data = new ReportUpload();
// data.setProjectId(projectId);
// data.setPeriod(period);
// reportUploadService.saveData(file, data);
// return OperationResultDto.success();
// } catch (ServiceException e) {
// return OperationResultDto.error(e.getMessage());
// } catch (Exception e) {
// logger.error("importRLITExcelFile error.", e);
// return OperationResultDto.error(ErrorMessage.SystemError);
// }
// }
}
atms-api/src/main/java/pwc/taxtech/atms/service/impl/DataImportService.java
0 → 100644
View file @
9c6f75c5
package
pwc
.
taxtech
.
atms
.
service
.
impl
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
pwc.taxtech.atms.dto.OperationResultDto
;
import
pwc.taxtech.atms.exception.ServiceException
;
import
java.util.List
;
@Service
public
class
DataImportService
extends
BaseService
{
public
OperationResultDto
importRLITExcelFile
(
MultipartFile
file
,
List
<
String
>
orgIds
,
String
periodDate
,
Integer
importType
)
throws
ServiceException
{
try
{
// OperationResultDto operationResultDto = new OperationResultDto();
// InputStream inputStream = file.getInputStream();
// Workbook workbook = WorkbookFactory.create(inputStream);
// FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
// if (StringUtils.isBlank(periodDate) || "null".equals(periodDate)) {
// throw new ServiceException(ErrorMessageCN.DoNotSelectPeriod);
// }
// Integer tmsPeriod = DateUtils.strToPeriod(periodDate);
// List<DataImportLog> dataImportLogs = Lists.newArrayList();
// for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
// Sheet sheet = workbook.getSheetAt(i);
// if (isSheetEmpty(sheet)) continue;
// List<RedLetterInfoTable> rlits = generalRLITs(sheet, tmsPeriod, evaluator);
// if (rlits.size() < 1) continue;
// // 根据主体分组处理
// Map<String, List<RedLetterInfoTable>> atsGroupRes =
// rlits.stream().collect(Collectors.groupingBy(RedLetterInfoTable::getSubjectNum));
// atsGroupRes.forEach((k, v) -> processRlits(k, v, orgIds, tmsPeriod, importType, dataImportLogs));
// }
// if (dataImportLogs.size() == 0)
// return OperationResultDto.error(ErrorMessage.NoData);
//
// addDataImportLog(dataImportLogs);
// int isSuccess = (int) dataImportLogs.stream().filter(di -> Boolean.TRUE.equals(di.getImportResult())).count();
// if (isSuccess < 1) {
// return OperationResultDto.error(ErrorMessage.ImportNotMatch);
// }
return
operationResultDto
.
success
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
OperationResultDto
.
error
(
e
.
getMessage
());
}
}
}
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