Commit 684fb70a authored by gary's avatar gary

1、分析模块导入不限定文件名称

2、fixbug
parent 765fc576
......@@ -94,6 +94,24 @@ public class AnalysisController extends BaseController {
}
}
@ResponseBody
@RequestMapping(value = "InternationalExcelFile", method = RequestMethod.POST)
public OperationResultDto importDomesitcExcelFile(@RequestParam MultipartFile file, @RequestParam String period,
@RequestParam Integer type,@RequestParam String companyName,@RequestParam String country) {
try {
String valMsg = valParameter(file,period,type);
if(StringUtils.isNotEmpty(valMsg)){
return OperationResultDto.error(valMsg);
}
return analysisServiceImpl.importInterNationalExcelFile(file,period, type,companyName,country);
} catch (ServiceException e) {
return OperationResultDto.error(e.getMessage());
} catch (Exception e) {
logger.error("importDomesitcExcelFile error.", e);
return OperationResultDto.error(ErrorMessage.SystemError);
}
}
private String valParameter(MultipartFile file,String periodDate,Integer type){
if (null == file) {
return ErrorMessage.NoFile;
......
......@@ -201,11 +201,20 @@ public class AnalysisServiceImpl extends BaseService {
case 4:
importAnalysisDriverNumExcelFile(file,periodDate);
break;
default:
break;
}
return OperationResultDto.success();
}
public OperationResultDto importInterNationalExcelFile(MultipartFile file, String periodDate, Integer type,
String companyName,String country) {
switch (type){
case 100:
importAnalysisInterBuDataExcelFile(file,periodDate);
importAnalysisInterBuDataExcelFile(file,periodDate,companyName,country);
break;
case 101:
importAnalysisInterTaxDataExcelFile(file,periodDate);
importAnalysisInterTaxDataExcelFile(file,periodDate,companyName,country);
break;
default:
break;
......@@ -221,12 +230,7 @@ public class AnalysisServiceImpl extends BaseService {
throw new ServiceException(ErrorMessageCN.DoNotSelectPeriod);
}
// 文件上的期间
String filePeriod = file.getOriginalFilename().split("_")[1];
Integer filePer = DateUtils.strToPeriod2(filePeriod);
Integer selectedPer = DateUtils.strToPeriod(periodDate);
if (!filePer.equals(selectedPer)) {
throw new ServiceException(ErrorMessageCN.ExistDataPeriodsError);
}
for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
Sheet sheet = workbook.getSheetAt(i);
if (isSheetEmpty(sheet)) continue;
......@@ -275,13 +279,7 @@ public class AnalysisServiceImpl extends BaseService {
if (StringUtils.isBlank(periodDate) || "null".equals(periodDate)) {
throw new ServiceException(ErrorMessageCN.DoNotSelectPeriod);
}
// 文件上的期间
String filePeriod = file.getOriginalFilename().split("_")[1];
Integer filePer = DateUtils.strToPeriod2(filePeriod);
Integer selectedPer = DateUtils.strToPeriod(periodDate);
if (!filePer.equals(selectedPer)) {
throw new ServiceException(ErrorMessageCN.ExistDataPeriodsError);
}
for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
Sheet sheet = workbook.getSheetAt(i);
if (isSheetEmpty(sheet)) continue;
......@@ -330,13 +328,7 @@ public class AnalysisServiceImpl extends BaseService {
if (StringUtils.isBlank(periodDate) || "null".equals(periodDate)) {
throw new ServiceException(ErrorMessageCN.DoNotSelectPeriod);
}
// 文件上的期间
String filePeriod = file.getOriginalFilename().split("_")[1];
Integer filePer = DateUtils.strToPeriod2(filePeriod);
Integer selectedPer = DateUtils.strToPeriod(periodDate);
if(!filePer.equals(selectedPer)){
throw new ServiceException(ErrorMessageCN.ExistDataPeriodsError);
}
for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
Sheet sheet = workbook.getSheetAt(i);
if (isSheetEmpty(sheet)) continue;
......@@ -381,13 +373,7 @@ public class AnalysisServiceImpl extends BaseService {
if (StringUtils.isBlank(periodDate) || "null".equals(periodDate)) {
throw new ServiceException(ErrorMessageCN.DoNotSelectPeriod);
}
// 文件上的期间
String filePeriod = file.getOriginalFilename().split("_")[1];
Integer filePer = DateUtils.strToPeriod2(filePeriod);
Integer selectedPer = DateUtils.strToPeriod(periodDate);
if(!filePer.equals(selectedPer)){
throw new ServiceException(ErrorMessageCN.ExistDataPeriodsError);
}
for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
Sheet sheet = workbook.getSheetAt(i);
if (isSheetEmpty(sheet)) continue;
......@@ -432,13 +418,7 @@ public class AnalysisServiceImpl extends BaseService {
if (StringUtils.isBlank(periodDate) || "null".equals(periodDate)) {
throw new ServiceException(ErrorMessageCN.DoNotSelectPeriod);
}
// 文件上的期间
String filePeriod = file.getOriginalFilename().split("_")[1];
Integer filePer = DateUtils.strToPeriod2(filePeriod);
Integer selectedPer = DateUtils.strToPeriod(periodDate);
if(!filePer.equals(selectedPer)){
throw new ServiceException(ErrorMessageCN.ExistDataPeriodsError);
}
for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
Sheet sheet = workbook.getSheetAt(i);
if (isSheetEmpty(sheet)) continue;
......@@ -475,7 +455,8 @@ public class AnalysisServiceImpl extends BaseService {
}
}
private void importAnalysisInterTaxDataExcelFile(MultipartFile file, String periodDate) {
private void importAnalysisInterTaxDataExcelFile(MultipartFile file, String periodDate,
String companyName,String country) {
try{
InputStream inputStream = file.getInputStream();
Workbook workbook = WorkbookFactory.create(inputStream);
......@@ -483,14 +464,7 @@ public class AnalysisServiceImpl extends BaseService {
throw new ServiceException(ErrorMessageCN.DoNotSelectPeriod);
}
// 文件上的期间
String fileCountry = file.getOriginalFilename().split("_")[1];
String fileCompany = file.getOriginalFilename().split("_")[2];
String filePeriod = file.getOriginalFilename().split("_")[3];
Integer filePer = DateUtils.strToPeriod2(filePeriod);
Integer selectedPer = DateUtils.strToPeriod(periodDate);
if(!filePer.equals(selectedPer)){
throw new ServiceException(ErrorMessageCN.ExistDataPeriodsError);
}
for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
Sheet sheet = workbook.getSheetAt(i);
if (isSheetEmpty(sheet)) continue;
......@@ -503,8 +477,8 @@ public class AnalysisServiceImpl extends BaseService {
AnalysisInternationalTaxData model = new AnalysisInternationalTaxData();
model.setId(idService.nextId());
model.setPeriod(selectedPer);
model.setCompanyName(fileCompany);
model.setCountry(fileCountry);
model.setCompanyName(companyName);
model.setCountry(country);
model.setTaxCategory(getCellStringValue(sheet.getRow(j).getCell(0)));
model.setTaxType(getCellStringValue(sheet.getRow(j).getCell(1)));
model.setTaxAmount(getCellBigDecimalValue(sheet.getRow(j).getCell(2)));
......@@ -526,7 +500,8 @@ public class AnalysisServiceImpl extends BaseService {
}
}
private void importAnalysisInterBuDataExcelFile(MultipartFile file, String periodDate) {
private void importAnalysisInterBuDataExcelFile(MultipartFile file, String periodDate,
String companyName,String country) {
try{
InputStream inputStream = file.getInputStream();
Workbook workbook = WorkbookFactory.create(inputStream);
......@@ -534,14 +509,7 @@ public class AnalysisServiceImpl extends BaseService {
throw new ServiceException(ErrorMessageCN.DoNotSelectPeriod);
}
// 文件上的期间
String fileCountry = file.getOriginalFilename().split("_")[1];
String fileCompany = file.getOriginalFilename().split("_")[2];
String filePeriod = file.getOriginalFilename().split("_")[3];
Integer filePer = DateUtils.strToPeriod2(filePeriod);
Integer selectedPer = DateUtils.strToPeriod(periodDate);
if(!filePer.equals(selectedPer)){
throw new ServiceException(ErrorMessageCN.ExistDataPeriodsError);
}
for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
Sheet sheet = workbook.getSheetAt(i);
if (isSheetEmpty(sheet)) continue;
......@@ -550,8 +518,8 @@ public class AnalysisServiceImpl extends BaseService {
AnalysisInternationalBusinessData model = new AnalysisInternationalBusinessData();
model.setId(idService.nextId());
model.setPeriod(selectedPer);
model.setCompanyName(fileCompany);
model.setCountry(fileCountry);
model.setCompanyName(companyName);
model.setCountry(country);
Cell cell1 = sheet.getRow(j).getCell(0);
if (null == cell1 || StringUtils.isEmpty(getCellStringValue(cell1))) {
continue;
......
......@@ -30,11 +30,11 @@
$scope.showTotalSecondRow = false;
$scope.importExcelFileUrlList = {
taxData : apiInterceptor.webApiHostUrl + '/Analysis/DomesitcExcelFile',
returnTax : apiInterceptor.webApiHostUrl + '/Analysis/DomesitcExcelFile',
gmvSubsidy : apiInterceptor.webApiHostUrl + '/Analysis/DomesitcExcelFile',
employeeNum : apiInterceptor.webApiHostUrl + '/Analysis/DomesitcExcelFile',
driverNum : apiInterceptor.webApiHostUrl + '/Analysis/DomesitcExcelFile'
taxData : apiInterceptor.webApiHostUrl + '/Analysis/InternationalExcelFile',
returnTax : apiInterceptor.webApiHostUrl + '/Analysis/InternationalExcelFile',
gmvSubsidy : apiInterceptor.webApiHostUrl + '/Analysis/InternationalExcelFile',
employeeNum : apiInterceptor.webApiHostUrl + '/Analysis/InternationalExcelFile',
driverNum : apiInterceptor.webApiHostUrl + '/Analysis/InternationalExcelFile'
};
$scope.maxTitleLength = constant.maxButtonTitleLength;
......@@ -205,6 +205,8 @@
Upload.upload({
url: url,
data: {
companyName :$scope.selectCompany,
country : $scope.selectCountry,
period: period,
type: $scope.importType
},
......
......@@ -113,8 +113,8 @@ webservices.factory('dataImportService', ['$http', 'apiConfig', function ($http,
/***************************************cit services end**************************************************************/
/***************************************call ApiServices start**************************************************************/
callExtractFinancialData: function (orgIds, period,dataTypes) {
return $http.post('/DataImport/callExtractFinancialData',{ orgIds: orgIds, period: period,dataTypes:dataTypes }, apiConfig.create());
callExtractFinancialData: function (param) {
return $http.post('/DataImport/callExtractFinancialData',param, apiConfig.create());
},
callExtractInvoiceData: function (orgIds, period,dataTypes) {
return $http.post('/DataImport/callExtractInvoiceData', { orgIds: orgIds, period: period,dataTypes:dataTypes }, apiConfig.create());
......
......@@ -107,7 +107,13 @@
//导入事件
var callFinancialApi = function () {
var periodStr = $scope.UploadPeriodTime;
dataImportService.callExtractFinancialData($scope.checkedCompanyCodeList,periodStr,$scope.checkedFileCodeList).success(function (data) {
var param = {
orgIds: $scope.checkedCompanyCodeList,
period: periodStr,
dataTypes: $scope.checkedFileCodeList
};
dataImportService.callExtractFinancialData(param).success(function (data) {
if (data) {
getFinancialDataStatus();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment