Commit d22b8055 authored by sherlock's avatar sherlock

merge

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