Commit d22b8055 authored by sherlock's avatar sherlock

merge

parents cb875628 7894635f
...@@ -26,8 +26,7 @@ import pwc.taxtech.atms.common.config.FileServiceConfig; ...@@ -26,8 +26,7 @@ import pwc.taxtech.atms.common.config.FileServiceConfig;
import pwc.taxtech.atms.dto.ApiResultDto; import pwc.taxtech.atms.dto.ApiResultDto;
import pwc.taxtech.atms.exception.ServiceException; import pwc.taxtech.atms.exception.ServiceException;
import java.io.IOException; import java.io.*;
import java.io.InputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -43,24 +42,32 @@ public class HttpFileService extends BaseService { ...@@ -43,24 +42,32 @@ public class HttpFileService extends BaseService {
* 上传模板 * 上传模板
* *
* @param fileName 文件名 * @param fileName 文件名
* @param file MultipartFile * @param fileBytes 文件字节
* @return Boolean * @return Boolean
*/ */
public String uploadTemplate(String fileName, MultipartFile file) throws ServiceException { public String uploadTemplateWithBytes(String fileName, byte[] fileBytes) throws ServiceException {
if (StringUtils.isBlank(fileName) || null == file) { if (StringUtils.isBlank(fileName) || null == fileBytes) {
throw new IllegalArgumentException("上传参数为空"); throw new IllegalArgumentException("上传参数为空");
} }
CloseableHttpClient httpClient = null; CloseableHttpClient httpClient = null;
String fullPath = USER_TEMPLATE_PATH + fileName; String fullPath = USER_TEMPLATE_PATH + fileName;
try { try {
httpClient = HttpClients.createDefault(); httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(config.getServerUrl() + config.getUploadUrl()); HttpPost httpPost = new HttpPost(config.getServerUrl() + config.getUploadUrl());
httpPost.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType()); httpPost.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType());
FileOutputStream out = new FileOutputStream(fullPath);
out.write(fileBytes);
FileInputStream fis = new FileInputStream(fullPath);
byte[] byt = new byte[fis.available()];
fis.read(byt);
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
param.put("path", fullPath); param.put("path", fullPath);
param.put("file", file.getBytes()); param.put("file", byt);
fis.close();
out.close();
HttpEntity httpEntity = new StringEntity(param.toJSONString(), ContentType.APPLICATION_JSON); HttpEntity httpEntity = new StringEntity(param.toJSONString(), ContentType.APPLICATION_JSON);
httpPost.setEntity(httpEntity); httpPost.setEntity(httpEntity);
...@@ -83,6 +90,25 @@ public class HttpFileService extends BaseService { ...@@ -83,6 +90,25 @@ public class HttpFileService extends BaseService {
throw new ServiceException("uploadTemplate error."); throw new ServiceException("uploadTemplate error.");
} }
/**
* 上传模板
*
* @param fileName 文件名
* @param file MultipartFile
* @return Boolean
*/
public String uploadTemplate(String fileName, MultipartFile file) throws ServiceException {
if (StringUtils.isBlank(fileName) || null == file) {
throw new IllegalArgumentException("上传参数为空");
}
try {
return uploadTemplateWithBytes(fileName, file.getBytes());
} catch (IOException e) {
logger.error("close httpClient error.", e);
}
throw new ServiceException("uploadTemplate error.");
}
/** /**
* 下载模板 * 下载模板
* *
......
...@@ -41,9 +41,7 @@ import pwc.taxtech.atms.vat.dao.PeriodDataSourceMapper; ...@@ -41,9 +41,7 @@ import pwc.taxtech.atms.vat.dao.PeriodDataSourceMapper;
import pwc.taxtech.atms.vat.entity.PeriodCellData; import pwc.taxtech.atms.vat.entity.PeriodCellData;
import pwc.taxtech.atms.vat.entity.PeriodDataSource; import pwc.taxtech.atms.vat.entity.PeriodDataSource;
import java.io.ByteArrayInputStream; import java.io.*;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -223,7 +221,7 @@ public class TemplateGroupServiceImpl extends AbstractService { ...@@ -223,7 +221,7 @@ public class TemplateGroupServiceImpl extends AbstractService {
} }
ByteArrayOutputStream bos = new ByteArrayOutputStream(); ByteArrayOutputStream bos = new ByteArrayOutputStream();
optional.get().write(bos); optional.get().write(bos);
String tmpPath = httpFileService.uploadTemplate(newName, file); String tmpPath = httpFileService.uploadTemplateWithBytes(newName, bos.toByteArray());
String[] arr = sheetName.split("_"); String[] arr = sheetName.split("_");
String name = arr.length >= 2 ? arr[1] : arr[0]; String name = arr.length >= 2 ? arr[1] : arr[0];
Template template = new Template(); Template template = new Template();
...@@ -370,7 +368,7 @@ public class TemplateGroupServiceImpl extends AbstractService { ...@@ -370,7 +368,7 @@ public class TemplateGroupServiceImpl extends AbstractService {
} }
} }
wtemp.write(bos); wtemp.write(bos);
String tmpPath = httpFileService.uploadTemplate(newName, file); String tmpPath = httpFileService.uploadTemplateWithBytes(newName, bos.toByteArray());
String[] arr = sheetName.split("_"); String[] arr = sheetName.split("_");
String name = arr.length >= 2 ? arr[1] : arr[0]; String name = arr.length >= 2 ? arr[1] : arr[0];
Template template = new Template(); Template template = new Template();
......
...@@ -875,9 +875,6 @@ public class ReportServiceImpl { ...@@ -875,9 +875,6 @@ public class ReportServiceImpl {
public OperationResultDto addCellManualDataSource(ManualDataSourceDto data, String projectId) { public OperationResultDto addCellManualDataSource(ManualDataSourceDto data, String projectId) {
OperationResultDto operationResultDto = new OperationResultDto(); OperationResultDto operationResultDto = new OperationResultDto();
String status = periodApprovalMapper.getStatusByProjectIdAndPeriod(projectId, data.getPeriod());
MyAsserts.assertTrue(status == null || status.equals(Constant.APPROVAL_DISAGREED), Exceptions.REPORT_IN_PROCESS_OR_AGREED_EXCEPTION);
try { try {
if (data.getCellId() == null) { if (data.getCellId() == null) {
//todo: insert celldata for manual datasource //todo: insert celldata for manual datasource
...@@ -900,12 +897,14 @@ public class ReportServiceImpl { ...@@ -900,12 +897,14 @@ public class ReportServiceImpl {
PeriodCellData cellData = periodCellDataMapper.selectByPrimaryKey(data.getCellId()); PeriodCellData cellData = periodCellDataMapper.selectByPrimaryKey(data.getCellId());
if(StringUtils.isNotBlank(data.getKeyinData())){ if(StringUtils.isNotBlank(data.getKeyinData())){
cellData.setKeyinData(data.getKeyinData()); cellData.setKeyinData(data.getKeyinData());
periodCellDataMapper.updateByPrimaryKeySelective(cellData);
}else if (data.getAmount() != null && cellData.getData() != data.getAmount().toString()) { }else if (data.getAmount() != null && cellData.getData() != data.getAmount().toString()) {
cellData.setData(data.getAmount().toString()); cellData.setData(data.getAmount().toString());
if (StringUtils.isEmpty(cellData.getFormulaExp())) if (StringUtils.isEmpty(cellData.getFormulaExp()))
cellData.setFormulaExp(data.getAmount().toString()); cellData.setFormulaExp(data.getAmount().toString());
periodCellDataMapper.updateByPrimaryKeySelective(cellData);
} }
periodCellDataMapper.updateByPrimaryKeySelective(cellData);
} }
List<DataSourceExtendDto> dataSourceExtendDtos = periodDataSourceMapper.getManualDataSource(data.getCellId()); List<DataSourceExtendDto> dataSourceExtendDtos = periodDataSourceMapper.getManualDataSource(data.getCellId());
...@@ -1206,7 +1205,7 @@ public class ReportServiceImpl { ...@@ -1206,7 +1205,7 @@ public class ReportServiceImpl {
PeriodCellData cellData = periodCellDataMapper.selectByPrimaryKey(cellDataId); PeriodCellData cellData = periodCellDataMapper.selectByPrimaryKey(cellDataId);
BigDecimal cellVal = new BigDecimal("0"); BigDecimal cellVal = new BigDecimal("0");
try { try {
if (cellData != null && !Pattern.compile("[\\D,^\\.]").matcher(cellData.getData()).find()) { if (cellData != null && StringUtils.isEmpty(cellData.getKeyinData())) {
cellVal = new BigDecimal(cellData.getData()); cellVal = new BigDecimal(cellData.getData());
Integer cellDataType = periodCellTemplateMapper Integer cellDataType = periodCellTemplateMapper
.getDataType(cellData.getCellTemplateId() .getDataType(cellData.getCellTemplateId()
...@@ -1219,10 +1218,6 @@ public class ReportServiceImpl { ...@@ -1219,10 +1218,6 @@ public class ReportServiceImpl {
} }
} }
public static void main(String[] args) {
String s= "122.3";
System.out.println(Pattern.compile("[\\D,^\\.]"));
}
private void updateCellValueForDataSourceChange(PeriodDataSource dataSourceEntity, BigDecimal amount) { private void updateCellValueForDataSourceChange(PeriodDataSource dataSourceEntity, BigDecimal amount) {
BigDecimal originalAmount = dataSourceEntity.getAmount(); BigDecimal originalAmount = dataSourceEntity.getAmount();
dataSourceEntity.setAmount(amount); dataSourceEntity.setAmount(amount);
......
...@@ -319,4 +319,6 @@ public abstract class CommonIT { ...@@ -319,4 +319,6 @@ public abstract class CommonIT {
MenuExample example = new MenuExample(); MenuExample example = new MenuExample();
menuMapper.deleteByExample(example); menuMapper.deleteByExample(example);
} }
} }
\ No newline at end of file
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
$scope.voucherFileName = ""; $scope.voucherFileName = "";
$scope.voucherFileID = ""; $scope.voucherFileID = "";
$scope.manualSpread = {}; $scope.manualSpread = {};
$scope.file = null;
//Notice: ************************************ //Notice: ************************************
//$scope.templateCode, $scope.reportId, $scope.initRow, $scope.initCol等都是外部传递进来的数据。 //$scope.templateCode, $scope.reportId, $scope.initRow, $scope.initCol等都是外部传递进来的数据。
...@@ -32,6 +33,7 @@ ...@@ -32,6 +33,7 @@
var webHost = apiTokenObj.api_host; var webHost = apiTokenObj.api_host;
var chunkSize = 100000; var chunkSize = 100000;
var resumable = true; var resumable = true;
var hasManualLoad = false;
// File: Voucher Upload Declarations ENDED: // File: Voucher Upload Declarations ENDED:
//*************************************************************************************** //***************************************************************************************
...@@ -986,6 +988,7 @@ ...@@ -986,6 +988,7 @@
$q.all(promiss).then(function () { $q.all(promiss).then(function () {
//重新排序报表 //重新排序报表
$('#busy-indicator-container').show();
exportReportData = _.sortBy(exportReportData, function (item) { exportReportData = _.sortBy(exportReportData, function (item) {
return item.orderIndex; return item.orderIndex;
}); });
...@@ -1019,6 +1022,7 @@ ...@@ -1019,6 +1022,7 @@
function exportSpread(exportReportData) { function exportSpread(exportReportData) {
$scope.exportReportData = exportReportData; $scope.exportReportData = exportReportData;
$timeout(function () { $timeout(function () {
$('#busy-indicator-container').show();
var mainSpread = new GC.Spread.Sheets.Workbook(document.getElementById("export"), {sheetCount: 1}); var mainSpread = new GC.Spread.Sheets.Workbook(document.getElementById("export"), {sheetCount: 1});
mainSpread.isPaintSuspended(true); mainSpread.isPaintSuspended(true);
mainSpread.sheets.pop(); mainSpread.sheets.pop();
...@@ -1036,12 +1040,15 @@ ...@@ -1036,12 +1040,15 @@
mainSpread.sheets.push(currentSheet); mainSpread.sheets.push(currentSheet);
} }
var excelIo = new GC.Spread.Excel.IO(); var excelIo = new GC.Spread.Excel.IO();
// here is excel IO API // here is excel IO API
excelIo.save(mainSpread.toJSON(), function (blob) { excelIo.save(mainSpread.toJSON(), function (blob) {
saveAs(blob, vatSessionService.project.name+'-'+vatSessionService.month+'-纳税申报.xlsx'); saveAs(blob, vatSessionService.project.name+'-'+vatSessionService.month+'-纳税申报.xlsx');
$('#busy-indicator-container').hide();
}, function (e) { }, function (e) {
alert(e); alert(e);
$('#busy-indicator-container').hide();
}); });
// vatExportService.exportReport(content).success(function (data) { // vatExportService.exportReport(content).success(function (data) {
...@@ -1494,17 +1501,21 @@ ...@@ -1494,17 +1501,21 @@
//单元格详细信息点击确定时执行 //单元格详细信息点击确定时执行
$scope.confirm = function () { $scope.confirm = function () {
$scope.handInputModel.name = $scope.taxCellDetail.inputMemo; vatApproveService.approvalStatus(vatSessionService.project.id,vatSessionService.project.period).success(function(result){
var r = /^(-[1-9]\d*|[1-9]\d*|[0]{1,1})$/; if(result&&result=='committed'){
if ($scope.taxCellDetail.keyinData) { SweetAlert.error('报表提审中!');
$scope.handInputModel.keyinData = $scope.taxCellDetail.keyinData; }else{
}else { $scope.handInputModel.name = $scope.taxCellDetail.inputMemo;
$scope.handInputModel.amount = $scope.taxCellDetail.inputValue; var r = /^(-[1-9]\d*|[1-9]\d*|[0]{1,1})$/;
} if ($scope.taxCellDetail.keyinData) {
$scope.handInputModel.description = $scope.taxCellDetail.inputMemo; $scope.handInputModel.keyinData = $scope.taxCellDetail.keyinData;
$scope.handInputModel.projectID = vatSessionService.project.id; }else {
$scope.handInputModel.serviceTypeID = vatSessionService.project.serviceTypeID; $scope.handInputModel.amount = $scope.taxCellDetail.inputValue;
$scope.handInputModel.period = vatSessionService.month; }
$scope.handInputModel.description = $scope.taxCellDetail.inputMemo;
$scope.handInputModel.projectID = vatSessionService.project.id;
$scope.handInputModel.serviceTypeID = vatSessionService.project.serviceTypeID;
$scope.handInputModel.period = vatSessionService.month;
if ($scope.handInputModel.amount || $scope.handInputModel.name || $scope.handInputModel.keyinData) { if ($scope.handInputModel.amount || $scope.handInputModel.name || $scope.handInputModel.keyinData) {
//日志对象 //日志对象
...@@ -1518,16 +1529,19 @@ ...@@ -1518,16 +1529,19 @@
+ ", Cell Template ID:" + $scope.handInputModel.cellTemplateID + ")"; + ", Cell Template ID:" + $scope.handInputModel.cellTemplateID + ")";
logDto.OperationType = enums.vatLogOperationTypeEnum.RV_ManualInput; logDto.OperationType = enums.vatLogOperationTypeEnum.RV_ManualInput;
// 前端保存数据 // 前端保存数据
return vatReportService.addCellManualData($scope.handInputModel, logDto).then(function (manualData) { return vatReportService.addCellManualData($scope.handInputModel, logDto).then(function (manualData) {
var obj = manualData.data.data; var obj = manualData.data.data;
obj.dataSourceType = manualData.dataSourceType; obj.dataSourceType = manualData.dataSourceType;
$scope.updateCellByManualChange(obj); $scope.updateCellByManualChange(obj);
return $q.when(); return $q.when();
}); });
} }
return $q.reject();
}
});
return $q.reject();
}; };
......
...@@ -194,7 +194,7 @@ ...@@ -194,7 +194,7 @@
<div class="modal-dialog" style="width:850px;height:500px" role="document" > <div class="modal-dialog" style="width:850px;height:500px" role="document" >
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<span class="close" data-dismiss="modal" aria-hidden="true" ng-click="closeModal()">×</span> <span class="close" data-dismiss="modal" aria-hidden="true" ng-click="closeManualModal()">×</span>
<span>批量录入手工数据</span> <span>批量录入手工数据</span>
</div> </div>
...@@ -204,14 +204,30 @@ ...@@ -204,14 +204,30 @@
</div> </div>
<div class="row" style="margin-left:12px; margin-right:12px;"> <div class="row" style="margin-left:12px; margin-right:12px;">
<div class="col-lg-12 col-md-12 col-sm-12"> <div class="col-sm-4">
<div class="inputContainer"> <div class="form-control" type="text" name="fileName" readonly placeholder=""
<input type="file" id="fileDemo" class="btn btn-sm" name="选择文件"> ng-required="isAdd" title="{{file ? file.name : ''}}">
<input type="button" id="loadExcel" value="加载文件" class="btn btn-sm" ng-click="loadMyExcel()"> {{file ? file.name : '' | limitString :25}}
<button class="btn btn-sm" ng-click="multiWrite()">批量录入</button>
<button class="btn btn-sm" ng-click="cleanManual()">清空</button>
</div> </div>
</div> </div>
<div class="col-sm-2">
<button type="button" type="file" ngf-select ng-model="file" accept=".xls,.xlsx"
class="btn browse">选择文件
</button>
</div>
<div class="col-sm-2">
<button type="button" class="btn browse" ng-click="loadMyExcel()">加载文件
</button>
</div>
<div class="col-sm-2">
<button type="button" class="btn browse" ng-click="multiWrite()">批量录入
</button>
</div>
<div class="col-sm-2">
<button type="button" class="btn browse" ng-click="cleanManual()"> 清空
</button>
</div>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -96,13 +96,9 @@ ...@@ -96,13 +96,9 @@
data.dataSourceType = enums.cellDataSourceType.KeyIn; data.dataSourceType = enums.cellDataSourceType.KeyIn;
return $q.when(data); return $q.when(data);
},function (data) { },function (data) {
if(data.status==412){ logInfo.UpdateState = $translate.instant('ManualInputFail');
SweetAlert.error('报表提审中或审核已通过!'); SweetAlert.error($translate.instant('PleaseContactAdministrator'));
}else{ return vatOperationLogService.addOperationLog(logInfo);
logInfo.UpdateState = $translate.instant('ManualInputFail');
SweetAlert.error($translate.instant('PleaseContactAdministrator'));
return vatOperationLogService.addOperationLog(logInfo);
}
}); });
}, },
deleteCellVoucher: function (voucherId, datasourceId) { deleteCellVoucher: function (voucherId, datasourceId) {
......
...@@ -93,7 +93,7 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt ...@@ -93,7 +93,7 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
excelIo.open(blob, function (json) { excelIo.open(blob, function (json) {
deferred.resolve(json); deferred.resolve(json);
}, function (e) { }, function (e) {
console.error(e.errormessage); // console.error(e.errorMessage);
//alert(e.errorMessage); //alert(e.errorMessage);
deferred.reject(e.errorMessage); deferred.reject(e.errorMessage);
}, {}); }, {});
......
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