Commit c9e60f8f authored by frank.xa.zhang's avatar frank.xa.zhang

fixed report display issue

parent ed7a17d0
......@@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import pwc.taxtech.atms.dto.CellTemplateConfigDto;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.service.CellTemplateService;
import java.util.Collections;
......@@ -21,17 +22,35 @@ public class CellTemplateController {
@RequestMapping(value = "configList/{templateID}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
List<CellTemplateConfigDto> GetConfigList(@PathVariable String templateID) {
if(StringUtils.isEmpty(templateID)){
return Collections.emptyList();
OperationResultDto<List<CellTemplateConfigDto>> GetConfigList(@PathVariable String templateID) {
OperationResultDto<List<CellTemplateConfigDto>> result = new OperationResultDto<>();
if (StringUtils.isEmpty(templateID)) {
result.setData(Collections.emptyList());
}
try {
return cellTemplateService.getCellConfigList(templateID);
} catch (Exception e) {
logger.error("CellTemplateController.GetCellConfigList", e);
}
return result;
}
@RequestMapping(value = "config/{cellTemplateID}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
OperationResultDto<CellTemplateConfigDto> GetConfig(@PathVariable String cellTemplateID) {
if (StringUtils.isEmpty(cellTemplateID)) {
return new OperationResultDto<>();
}
try {
return cellTemplateService.GetCellConfigList(templateID);
return cellTemplateService.getCellConfig(cellTemplateID);
} catch (Exception e) {
logger.error("GetCellConfigList",e);
logger.error("CellTemplateController.GetConfig", e);
}
return Collections.emptyList();
return new OperationResultDto<>();
}
}
package pwc.taxtech.atms.service;
import pwc.taxtech.atms.dto.CellTemplateConfigDto;
import pwc.taxtech.atms.dto.OperationResultDto;
import java.util.List;
public interface CellTemplateService {
List<CellTemplateConfigDto> GetCellConfigList(String templateID);
OperationResultDto<List<CellTemplateConfigDto>> getCellConfigList(String templateID);
OperationResultDto<CellTemplateConfigDto> getCellConfig(String cellTemplateID);
}
......@@ -43,7 +43,7 @@ public final class CellConfigTranslater {
cellTemplateConfigDto.setFormulaDescription(description);
Optional<CellTemplateConfig> formulaItem = configList.stream().filter(a -> a.getDataSourceType().equals(CellDataSourceType.valueOf("Formula"))).findFirst();
if (formulaItem != null) {
if (formulaItem.isPresent()) {
cellTemplateConfigDto.setHasFormula(true);
cellTemplateConfigDto.setFormula(formulaItem.get().getFormula());
if (StringUtils.isEmpty(cellTemplateConfigDto.getFormulaDescription())
......@@ -55,7 +55,7 @@ public final class CellConfigTranslater {
}
Optional<CellTemplateConfig> voucherItem = configList.stream().filter(x -> x.getDataSourceType().equals(CellDataSourceType.valueOf("Voucher"))).findFirst();
if (voucherItem != null) {
if (voucherItem.isPresent()) {
cellTemplateConfigDto.setHasVoucher(true);
cellTemplateConfigDto.setVoucherKeyword(voucherItem.get().getVoucherKeyword() == null ? "" : voucherItem.get().getVoucherKeyword());
if (!StringUtils.isEmpty(voucherItem.get().getAccountCodes())) {
......@@ -64,7 +64,7 @@ public final class CellConfigTranslater {
}
Optional<CellTemplateConfig> invoiceItem = configList.stream().filter(x -> x.getDataSourceType().equals(CellDataSourceType.valueOf("OutputInvoice")) || x.getDataSourceType().equals(CellDataSourceType.valueOf("InputInvoice")) || x.getDataSourceType().equals(CellDataSourceType.valueOf("CustomInvoice"))).findFirst();
if (invoiceItem != null) {
if (invoiceItem.isPresent()) {
cellTemplateConfigDto.setHasInvoice(true);
cellTemplateConfigDto.setInvoiceType(invoiceItem.get().getInvoiceType());
cellTemplateConfigDto.setInvoiceAmountType(invoiceItem.get().getInvoiceAmountType());
......@@ -85,18 +85,18 @@ public final class CellConfigTranslater {
}
Optional<CellTemplateConfig> keyInItem = configList.stream().filter(x -> x.getDataSourceType().equals(CellDataSourceType.valueOf("KeyIn"))).findFirst();
if (keyInItem != null) {
if (keyInItem.isPresent()) {
cellTemplateConfigDto.setHasKeyIn(true);
}
Optional<CellTemplateConfig> modelItem = configList.stream().filter(x -> x.getDataSourceType().equals(CellDataSourceType.valueOf("RelatedModel"))).findFirst();
if (modelItem != null) {
if (modelItem.isPresent()) {
cellTemplateConfigDto.setHasModel(true);
cellTemplateConfigDto.setModelIDs(GetList(modelItem.get().getModelIDs()));
}
Optional<CellTemplateConfig> validationItem = configList.stream().filter(x -> x.getDataSourceType().equals(CellDataSourceType.valueOf("Validation"))).findFirst();
if (validationItem != null) {
if (validationItem.isPresent()) {
cellTemplateConfigDto.setHasValidation(true);
cellTemplateConfigDto.setValidation(validationItem.get().getValidation());
cellTemplateConfigDto.setValidationDescription(validationItem.get().getValidationDescription());
......
package pwc.taxtech.atms.service.impl;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dao.CellTemplateMapper;
import pwc.taxtech.atms.dto.CellTemplateConfigDto;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.entitiy.CellTemplate;
import pwc.taxtech.atms.entitiy.CellTemplateConfig;
import pwc.taxtech.atms.entitiy.CellTemplateConfigExample;
import pwc.taxtech.atms.entitiy.CellTemplateExample;
import pwc.taxtech.atms.service.CellTemplateService;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
......@@ -15,19 +19,56 @@ import java.util.stream.Collectors;
public class CellTemplateServiceImpl extends AbstractService implements CellTemplateService {
@Override
public List<CellTemplateConfigDto> GetCellConfigList(String templateID) {
List<CellTemplateConfigDto> result = new ArrayList<>();
public OperationResultDto<List<CellTemplateConfigDto>> getCellConfigList(String templateID) {
OperationResultDto<List<CellTemplateConfigDto>> result = new OperationResultDto<>();
CellTemplateExample example = new CellTemplateExample();
example.createCriteria().andReportTemplateIDEqualTo(templateID);
List<CellTemplate> cellTemplateList = cellTemplateMapper.selectByExample(example);
List<CellTemplateConfig> configList = cellTemplateConfigMapper.getCellTemplateConfigByTemplateID(templateID);
if (cellTemplateList.isEmpty()) {
result.setData(Collections.emptyList());
return result;
}
List<CellTemplateConfigDto> rData = new ArrayList<>();
for (CellTemplate x : cellTemplateList) {
result.add(GetConfigDto(x, configList.stream().filter(a -> a.getCellTemplateID().equalsIgnoreCase(x.getID())).collect(Collectors.toList())));
rData.add(GetConfigDto(x, configList.stream().filter(a -> a.getCellTemplateID().equalsIgnoreCase(x.getID())).collect(Collectors.toList())));
}
if (rData.size() > 0) {
result.setResult(true);
result.setData(rData);
} else {
result.setData(Collections.emptyList());
}
return result;
}
@Override
public OperationResultDto<CellTemplateConfigDto> getCellConfig(String cellTemplateID) {
OperationResultDto<CellTemplateConfigDto> result = new OperationResultDto<>();
CellTemplate config = cellTemplateMapper.selectByPrimaryKey(cellTemplateID);
if (config.equals(null)) {
result.setResultMsg("NoData");
return result;
}
CellTemplateConfigExample example = new CellTemplateConfigExample();
example.createCriteria().andCellTemplateIDEqualTo(cellTemplateID);
List<CellTemplateConfig> configList = cellTemplateConfigMapper.selectByExample(example);
result.setData(GetConfigDto(config, configList));
if (result.getData().equals(null)) {
result.setResultMsg("NoData");
return result;
}
result.setResult(true);
return result;
}
......
......@@ -14,54 +14,54 @@ function ($rootScope, $log, $uibModal, $translate) {
var initialize = function (sheet) {
sheet.isPaintSuspended(true);
sheet.suspendPaint();
hasVoucherImg = new Image();
hasVoucherImg.src = '/app-resources/images/vat/hasVoucher.png';
hasVoucherImg.onload = function () {
sheet.repaint();
}
};
hasInvoiceImg = new Image();
hasInvoiceImg.src = '/app-resources/images/vat/hasInvoice.png';
hasInvoiceImg.onload = function () {
sheet.repaint();
}
};
hasKeyInImg = new Image();
hasKeyInImg.src = '/app-resources/images/vat/hasKeyIn.png';
hasKeyInImg.onload = function () {
sheet.repaint();
}
};
hasModelImg = new Image();
hasModelImg.src = '/app-resources/images/vat/hasModel.png';
hasModelImg.onload = function () {
sheet.repaint();
}
};
hasExceptionImg = new Image();
hasExceptionImg.src = '/app-resources/images/vat/hasException.png';
hasExceptionImg.onload = function () {
sheet.repaint();
}
};
hasValidationImg = new Image();
hasValidationImg.src = '/app-resources/images/vat/hasValidation.png';
hasValidationImg.onload = function () {
sheet.repaint();
}
};
};
var paintSheet = function (sheet) {
sheet.isPaintSuspended(false);
sheet.resumePaint();
};
var setCellTipString = function (cell, tip) {
//cell.cellType(new IconCellType(null, null, 0, null, tip));
cell.cellType(new IconsCellType([], [], tip));
}
};
var setCellTipByCellData = function (cell, cellData) {
var tips = null;
......@@ -100,7 +100,7 @@ function ($rootScope, $log, $uibModal, $translate) {
}
cell.cellType(new IconsCellType(icons, infos, tips));
}
};
var setCellTip = function (cell, config) {
var tips = null;
......@@ -201,7 +201,7 @@ function ($rootScope, $log, $uibModal, $translate) {
this.count = 0;
this.Formula = formula;
}
}
};
//var IconCellType = function (icon1, icon2, count, infos, formula) {
......@@ -217,7 +217,7 @@ function ($rootScope, $log, $uibModal, $translate) {
IconsCellType.prototype = new GC.Spread.Sheets.CellTypes.Base();
IconsCellType.prototype.paint = function (ctx, value, x, y, w, h, style, context) {
GC.Spread.Sheets.CellTypes.Base.prototype.paint.call(this, ctx, value, x, y, w, h, style, context);
GC.Spread.Sheets.CellTypes.Base.paint.call(this, ctx, value, x, y, w, h, style, context);
for (var i = 1; i <= this.count; i++) {
//距离当前单元格左侧距离,距离顶部距离 , ICON宽度,ICON高度
ctx.drawImage(this.Icons[i-1], x + w - (h - 3) * i + (h - 6 - 18) * i, y + 3 + (h / 2 - 3 - 9), 18, 18);
......@@ -232,7 +232,7 @@ function ($rootScope, $log, $uibModal, $translate) {
// ctx.drawImage(this.icon2, x + w - (h - 3) * i + (h - 6 - 18) * i, y + 3 + (h / 2 - 3 - 9), 18, 18);
//}
}
}
};
IconsCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
var index = x - (cellRect.x + cellRect.width - (cellRect.height - 3) * this.count) > 0 ?
Math.floor(this.count - (x - (cellRect.x + cellRect.width - (cellRect.height - 3) * this.count)) / (cellRect.height - 3)) :
......@@ -248,7 +248,7 @@ function ($rootScope, $log, $uibModal, $translate) {
sheetArea: context.sheetArea,
reservedLocationIndex: index
};
}
};
IconsCellType.prototype.processMouseMove = function (hitinfo) {
//console.log(hitinfo);
......
......@@ -93,7 +93,7 @@ webservices.factory('spreadJsService', ['$log', '$q', '$http', 'apiConfig', 'doc
this.minArgs = minArgs;
};
customFunction.prototype = new GC.Spread.Sheets.Calc.Functions.Function();
customFunction.prototype = new GcSpread.Sheets.Calc.Functions.Function();
customFunction.prototype.evaluate = function (args) {
var formulaName = this.name + "(";
......@@ -128,7 +128,7 @@ webservices.factory('spreadJsService', ['$log', '$q', '$http', 'apiConfig', 'doc
var deferred = $q.defer();
var promise = deferred.promise;
var spread = new GC.Spread.Sheets.Spread(document.getElementById(id));
var spread = new GcSpread.Sheets.Spread(document.getElementById(id));
var sheet = spread.getActiveSheet();
spread.showVerticalScrollbar(true);
......@@ -149,16 +149,16 @@ webservices.factory('spreadJsService', ['$log', '$q', '$http', 'apiConfig', 'doc
sheet.setIsProtected(false);
}
spread.bind(GC.Spread.Sheets.Events.CellClick, function (sender, args) {
if (args.sheetArea === GC.Spread.Sheets.SheetArea.colHeader) {
spread.bind(GcSpread.Sheets.Events.CellClick, function (sender, args) {
if (args.sheetArea === GcSpread.Sheets.SheetArea.colHeader) {
$log.debug("The column header was clicked.");
}
if (args.sheetArea === GC.Spread.Sheets.SheetArea.rowHeader) {
if (args.sheetArea === GcSpread.Sheets.SheetArea.rowHeader) {
$log.debug("The row header was clicked.");
}
if (args.sheetArea === GC.Spread.Sheets.SheetArea.corner) {
if (args.sheetArea === GcSpread.Sheets.SheetArea.corner) {
$log.debug("The corner header was clicked.");
}
......@@ -167,7 +167,7 @@ webservices.factory('spreadJsService', ['$log', '$q', '$http', 'apiConfig', 'doc
$log.debug(sheet.getTag(args.row, args.col));
});
spread.bind(GC.Spread.Sheets.Events.EditEnding, function (sender, args) {
spread.bind(GcSpread.Sheets.Events.EditEnding, function (sender, args) {
var sheet = spread.getActiveSheet();
......@@ -212,7 +212,7 @@ webservices.factory('spreadJsService', ['$log', '$q', '$http', 'apiConfig', 'doc
var customfunctions;
//1. 获取自定义函数名及对应的计算值
//1. 获取自定义函数名及对应的计算值
getFormulaValueByDocumentCode(code).then(function (formuladata) {
formulaValues = JSON.parse(formuladata);
$log.debug(formulaValues);
......@@ -234,7 +234,7 @@ webservices.factory('spreadJsService', ['$log', '$q', '$http', 'apiConfig', 'doc
initSpreadCustomFunction(sheet, func.name, 0, func.parameterCount);
}
//5. Get Document Cell
//5. Get Document Cell
getDocumentCellByDocumentId(documentObj.documentID).then(function (celldata) {
renderFormulaCell(sheet, celldata.data);
});
......@@ -281,14 +281,14 @@ webservices.factory('spreadJsService', ['$log', '$q', '$http', 'apiConfig', 'doc
};
var initSpreadCustomFunctionAsync = function (sheet, name) {
var asum = function () { }
//Define a class "ASUM" that extends AsyncFunction
asum.prototype = new GC.Spread.Sheets.Calc.Functions.AsyncFunction(name, 1, 255);
asum.prototype = new GcSpread.Sheets.Calc.Functions.AsyncFunction(name, 1, 255);
//Set default value to "Loading..."
asum.prototype.defaultValue = function () { return "Loading..."; };
//Override the evaluateAsync function
......
......@@ -13,78 +13,37 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
return "";
};
var getTemplateJson = function (templateID) {
//return $http.get('/template/getTemplateJson?templateID=' + templateID, apiConfig.create());
// var result = httpCacheService.get('/template/getTemplateJson?templateID=' + templateID);
// if (result.finishedCache) {
// return result;
// } else {
// var thisConfig = apiConfig.create();
// thisConfig.responseType = "blob";
// return $http.post('/template/getTemplateJson?templateID=' + templateID, {}, apiConfig.create());
// }
var deferred = $q.defer();
var promise = deferred.promise;
// var ajaxUrl = loginContext.apiHost + constant.webapi.prefix + '/template/getTemplateJson?templateID=' + templateID;
// var apiTokenObj = JSON.parse(getCookie('AtmsApiToken'));
// var apiToken = apiTokenObj.access_token;
// var tokenType = apiTokenObj.token_type;
// var ajaxSource = $.ajax({
// url: ajaxUrl,
// type: "POST",
// dataType:"blob",
// beforeSend: function (xhr) {
// xhr.setRequestHeader('Authorization', tokenType + ' ' + apiToken);
// //xhr.setRequestHeader('from', 'aabb@cn.pwc.com');
// //xhr.responseType = "blob";
// },
// success: function(data){
// deferred.resolve(data);
// },
// complete: function(data){
// deferred.resolve(data.responseText);
// }
// });
// ajaxSource.done(function (data) {
// deferred.resolve(data);
// });
return promise;
};
var initSpreadExcel = function (id, ssjsondata) {
var deferred = $q.defer();
var promise = deferred.promise;
var spread = new GC.Spread.Sheets.Workbook(document.getElementById(id));
spread.showVerticalScrollbar(true);
spread.showHorizontalScrollbar(true);
spread.scrollbarMaxAlign(true);
spread.scrollbarShowMax(true);
spread.tabNavigationVisible(true);
spread.newTabVisible(false);
spread.tabEditable(false);
spread.tabStripVisible(false);
spread.newTabVisible(false);
// spread.allowUndo(false);
// spread.allowUserResize(false);
// spread.canUserDragDrop(false);
// spread.canUserDragFill(false);
// spread.canUserEditFormula(false);
//
// spread.isPaintSuspended(true);
// spread.fromJSON(JSON.parse(ssjsondata));
// spread.isPaintSuspended(false);
spread.options.showVerticalScrollbar = true;
spread.options.showHorizontalScrollbar = true;
spread.options.scrollbarMaxAlign = true;
spread.options.scrollbarShowMax = true;
spread.options.tabNavigationVisible = true;
spread.options.newTabVisible = false;
spread.options.tabEditable = false;
spread.options.tabStripVisible = false;
spread.options.newTabVisible = false;
spread.options.allowUndo = false;
spread.options.allowUserResize = false;
spread.options.allowUserDragDrop = false;
spread.options.allowUserDragFill = false;
spread.options.allowUserEditFormula = false;
spread.suspendPaint();
spread.fromJSON(ssjsondata);
spread.resumePaint();
var sheet = spread.getActiveSheet();
if (sheet != null) {
// sheet.setRowHeaderVisible(true);
// sheet.setColumnHeaderVisible(true);
// sheet.setGridlineOptions({
// showVerticalGridline: false, showHorizontalGridline: false
// });
sheet.options.rowHeaderVisible = true;
sheet.options.colHeaderVisible = true;
sheet.options.gridline.showVerticalGridline = false;
sheet.options.gridline.showHorizontalGridline = false;
}
deferred.resolve(spread);
......@@ -96,7 +55,7 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
var promise = deferred.promise;
var spreadSheet;
var url = loginContext.apiHost + constant.webapi.prefix+'/template/getTemplateJson?templateID=' + templateID;
var url = loginContext.apiHost + constant.webapi.prefix + '/template/getTemplateJson?templateID=' + templateID;
var xhr = new XMLHttpRequest();
xhr.open('POST', url, true); // 也可以使用POST方式,根据接口
xhr.responseType = "blob"; // 返回类型blob
......@@ -104,7 +63,6 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
var apiToken = apiTokenObj.access_token;
var tokenType = apiTokenObj.token_type;
xhr.setRequestHeader('Authorization', tokenType + ' ' + apiToken);
// xhr.setRequestHeader("Authorization","bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTUyNzMxNDA4NCwiaWF0IjoxNTI3MTQxMjg0LCJuYmYiOjE1MjcxNDA2ODQsImp0aSI6IjVGM0FGMTBDLTdFMEEtNDVDQy04RDVGLUREMTBFMDRCOUY4NCIsInVzZXJuYW1lIjoiYWRtaW4iLCJkYXRhYmFzZVVzZXJuYW1lIjoiQWRtaW4iLCJ1c2VyaWQiOiI2NjkzM0U3Qi1EQTc1LTRCMkUtQjdENi1BQjY1RENBMjBENTAifQ.M-dyU6W51LAPVQ66HIJZ-KAg6WjPSIt1GqpOc6etQ6XJfXp8KkUPA6A8qPZ8bhydWsKKMqpPlx-KRVhK2o5q0Q")
// 定义请求完成的处理函数,请求前也可以增加加载框/禁用下载按钮逻辑
xhr.onload = function () {
// 请求完成
......@@ -121,39 +79,10 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
// process error
alert(e.errorMessage);
}, {});
// var reader = new FileReader();
// reader.readAsDataURL(blob); // 转换为base64,可以直接放入a表情href
// reader.onload = function (e) {
// // 转换完成,创建一个a标签用于下载
// var a = document.createElement('a');
// a.download = 'data.xlsx';
// a.href = e.target.result;
// $("body").append(a); // 修复firefox中无法触发click
// a.click();
// $(a).remove();
// }
}
};
// 发送ajax请求
xhr.send();
// getTemplateJson(templateID).then(function (result) {
// //var data = new Blob(result, {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"});
// var excelIo = new GC.Spread.Excel.IO();
// excelIo.open(result, function (json) {
// //var workbookObj = json;
// //spread.fromJSON(workbookObj);
// spreadSheet = initSpreadExcel(id, json);
// deferred.resolve(spreadSheet);
// }, function (e) {
// // process error
// alert(e.errorMessage);
// }, {});
// spreadSheet = initSpreadExcel(id, result.data === undefined ? result : result.data);
//
// deferred.resolve(spreadSheet);
// });
return promise;
};
......@@ -162,7 +91,6 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
};
return {
getTemplateJson: getTemplateJson,
renderSpreadExcelSimple: renderSpreadExcelSimple,
initSpreadExcel: initSpreadExcel,
setRowColName: setRowColName
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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