Commit 684fb70a authored by gary's avatar gary

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

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