Commit 690ed87f authored by frank's avatar frank

Merge branch 'dev_frank' into 'dev'

fixed issue and merge eddie branch

See merge request root/atms!11
parents 18e37ecc ed7a17d0
...@@ -14,6 +14,7 @@ import pwc.taxtech.atms.service.TemplateService; ...@@ -14,6 +14,7 @@ import pwc.taxtech.atms.service.TemplateService;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
import java.net.URISyntaxException;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
...@@ -34,37 +35,37 @@ public class TemplateController { ...@@ -34,37 +35,37 @@ public class TemplateController {
@RequestMapping(value = "get", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "get", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody public @ResponseBody
List<TemplateDto> get(@RequestParam String templateGroupID, @RequestParam Integer reportType) { List<TemplateDto> get(@RequestParam String templateGroupID, @RequestParam String reportType) {
if (StringUtils.isEmpty(templateGroupID)) { if (StringUtils.isEmpty(templateGroupID)) {
return Collections.emptyList(); return Collections.emptyList();
} }
try { try {
return templateService.get(templateGroupID, reportType); return templateService.get(templateGroupID, (reportType != null && !reportType.equals("null")) ? Integer.parseInt(reportType) : null);
} catch (Exception e) { } catch (Exception e) {
logger.error("GetCellConfigList", e); logger.error("GetCellConfigList", e);
} }
return Collections.emptyList(); return Collections.emptyList();
} }
@RequestMapping(value = "getTemplateJson", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "getTemplateJson", method = RequestMethod.POST, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public @ResponseBody public @ResponseBody
void getTemplateBlob(@RequestParam String templateID, HttpServletResponse response) { void getTemplateBlob(@RequestParam String templateID, HttpServletResponse response) throws URISyntaxException {
String filePath; String filePath;
File templateFile; File templateFile;
InputStream inputStream = null; InputStream inputStream = null;
String templatePath = templateService.getTemplatePath(templateID); String templatePath = templateService.getTemplatePath(templateID);
if(StringUtils.isEmpty(templateID)) if (StringUtils.isEmpty(templateID)) {
{
return; return;
} }
if (templatePath==null||StringUtils.isEmpty(templatePath)){ if (templatePath == null || StringUtils.isEmpty(templatePath)) {
return; return;
} }
filePath = this.getClass().getResource("/").getPath(); filePath = this.getClass().getResource("").toURI().getPath();
templateFile = new File(filePath + templateService.getTemplatePath(templateID)); String tempPath = filePath.substring(0,filePath.indexOf("classes")+"\\classes".length());
templateFile = new File(tempPath + templateService.getTemplatePath(templateID));
try { try {
inputStream = new BufferedInputStream(new FileInputStream(templateFile)); inputStream = new BufferedInputStream(new FileInputStream(templateFile));
...@@ -72,7 +73,14 @@ public class TemplateController { ...@@ -72,7 +73,14 @@ public class TemplateController {
String customFileName = "template_" + DateTime.now().toString("yyyyMMddHHmmss") + ".xlsx"; String customFileName = "template_" + DateTime.now().toString("yyyyMMddHHmmss") + ".xlsx";
response.setHeader("Content-Disposition", String.format("inline; filename=\"" + customFileName + "\"")); response.setHeader("Content-Disposition", String.format("inline; filename=\"" + customFileName + "\""));
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
FileCopyUtils.copy(inputStream, response.getOutputStream()); int len=0;
byte[] buffer = new byte[1024];
OutputStream out = response.getOutputStream();
while ((len=inputStream.read(buffer))>0){
out.write(buffer,0,len);
}
//FileCopyUtils.copy(inputStream, response.getOutputStream());
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} catch (Exception e) { } catch (Exception e) {
......
...@@ -120,20 +120,20 @@ public final class TemplateDto { ...@@ -120,20 +120,20 @@ public final class TemplateDto {
this.code = code; this.code = code;
} }
public boolean isSystemType() { public boolean getIsSystemType() {
return isSystemType; return this.isSystemType;
} }
public void setSystemType(boolean systemType) { public void setIsSystemType(boolean isSystemType) {
isSystemType = systemType; this.isSystemType = isSystemType;
} }
public boolean isActiveAssociation() { public boolean getIsActiveAssociation() {
return isActiveAssociation; return this.isActiveAssociation;
} }
public void setActiveAssociation(boolean activeAssociation) { public void setIsActiveAssociation(boolean isActiveAssociation) {
isActiveAssociation = activeAssociation; this.isActiveAssociation = isActiveAssociation;
} }
public List<CellTemplateDto> getCellTemplateDtos() { public List<CellTemplateDto> getCellTemplateDtos() {
......
...@@ -43,7 +43,7 @@ public class TemplateServiceImpl extends AbstractService implements TemplateServ ...@@ -43,7 +43,7 @@ public class TemplateServiceImpl extends AbstractService implements TemplateServ
if (template != null) { if (template != null) {
if (template.getPath().startsWith("~")) { if (template.getPath().startsWith("~")) {
result = template.getPath().substring(1, template.getPath().length() - 1); result = template.getPath().substring(1, template.getPath().length());
} else { } else {
result = template.getPath(); result = template.getPath();
} }
......
...@@ -7,7 +7,7 @@ mail_jdbc_user=sa ...@@ -7,7 +7,7 @@ mail_jdbc_user=sa
mail_jdbc_password=atmsunittestSQL mail_jdbc_password=atmsunittestSQL
web.url=http://localhost:8080 web.url=http://localhost:8080
#web.url=*
jwt.base64Secret=TXppQjFlZFBSbnJzMHc0Tg== jwt.base64Secret=TXppQjFlZFBSbnJzMHc0Tg==
jwt.powerToken=xxxx jwt.powerToken=xxxx
......
...@@ -274,6 +274,10 @@ grunt.initConfig({ ...@@ -274,6 +274,10 @@ grunt.initConfig({
src: ["Scripts/spreadjs/gc.spread.sheets.all.11.0.0.min.js"], src: ["Scripts/spreadjs/gc.spread.sheets.all.11.0.0.min.js"],
dest: '<%= pkg.bundleDest %>/spread.js' dest: '<%= pkg.bundleDest %>/spread.js'
}, },
spreadiojs: {
src: ["Scripts/spreadjs/interop/gc.spread.excelio.11.0.0.min.js"],
dest: '<%= pkg.bundleDest %>/spreadio.js'
},
ivhTreeview: { ivhTreeview: {
src: ["Scripts/angular-ivh-treeview/ivh-treeview.js", src: ["Scripts/angular-ivh-treeview/ivh-treeview.js",
"Scripts/angular-notify/angular-notify.js", "Scripts/angular-notify/angular-notify.js",
......
...@@ -95,6 +95,7 @@ ...@@ -95,6 +95,7 @@
<script type="text/javascript" src="bundles/spread.js"></script> <script type="text/javascript" src="bundles/spread.js"></script>
<script type="text/javascript" src="bundles/ivh-treeview.js"></script> <script type="text/javascript" src="bundles/ivh-treeview.js"></script>
<script type="text/javascript" src="bundles/ui-select.js"></script> <script type="text/javascript" src="bundles/ui-select.js"></script>
<script type="text/javascript" src="bundles/spreadio.js"></script>
<script type="text/javascript"> <script type="text/javascript">
//window.location.href = '/Home/Admin/#/userDetail/808b7a8c-0265-4497-9adb-6b7a757bd2f2'; //window.location.href = '/Home/Admin/#/userDetail/808b7a8c-0265-4497-9adb-6b7a757bd2f2';
......
// web service proxy for standard account // web service proxy for standard account
webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'httpCacheService', '$timeout', '$rootScope', '$interval', webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'httpCacheService', '$timeout', '$rootScope', '$interval', 'loginContext',
function ($log, $http, $q, apiConfig, httpCacheService, $timeout, $rootScope, $interval) { function ($log, $http, $q, apiConfig, httpCacheService, $timeout, $rootScope, $interval, loginContext) {
'use strict'; 'use strict';
var getCookie = function (cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i].trim();
// if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
if (c.indexOf(name) == 0) return ATMS_EXTRA.decodeCookieValue(c.substring(name.length, c.length));
}
return "";
};
var getTemplateJson = function (templateID) { var getTemplateJson = function (templateID) {
//return $http.get('/template/getTemplateJson?templateID=' + templateID, apiConfig.create()); //return $http.get('/template/getTemplateJson?templateID=' + templateID, apiConfig.create());
// var result = httpCacheService.get('/template/getTemplateJson?templateID=' + templateID); // var result = httpCacheService.get('/template/getTemplateJson?templateID=' + templateID);
// if (result.finishedCache) { // if (result.finishedCache) {
// return result; // return result;
// } else { // } else {
var thisConfig = apiConfig.create(); // var thisConfig = apiConfig.create();
thisConfig.responseType = "arraybuffer"; // thisConfig.responseType = "blob";
$http.post('/template/getTemplateJson?templateID=' + templateID, {}, apiConfig.create()).then(function (response) { // return $http.post('/template/getTemplateJson?templateID=' + templateID, {}, apiConfig.create());
var data = new Blob([response.data], {type: response.headers('Content-Type')});
return data;
});
// } // }
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 initSpreadExcel = function (id, ssjsondata) {
...@@ -22,7 +58,7 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt ...@@ -22,7 +58,7 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
var deferred = $q.defer(); var deferred = $q.defer();
var promise = deferred.promise; var promise = deferred.promise;
var spread = new GC.Spread.Sheets.Spread(document.getElementById(id)); var spread = new GC.Spread.Sheets.Workbook(document.getElementById(id));
spread.showVerticalScrollbar(true); spread.showVerticalScrollbar(true);
spread.showHorizontalScrollbar(true); spread.showHorizontalScrollbar(true);
spread.scrollbarMaxAlign(true); spread.scrollbarMaxAlign(true);
...@@ -32,23 +68,23 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt ...@@ -32,23 +68,23 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
spread.tabEditable(false); spread.tabEditable(false);
spread.tabStripVisible(false); spread.tabStripVisible(false);
spread.newTabVisible(false); spread.newTabVisible(false);
spread.allowUndo(false); // spread.allowUndo(false);
spread.allowUserResize(false); // spread.allowUserResize(false);
spread.canUserDragDrop(false); // spread.canUserDragDrop(false);
spread.canUserDragFill(false); // spread.canUserDragFill(false);
spread.canUserEditFormula(false); // spread.canUserEditFormula(false);
//
spread.isPaintSuspended(true); // spread.isPaintSuspended(true);
spread.fromJSON(JSON.parse(ssjsondata)); // spread.fromJSON(JSON.parse(ssjsondata));
spread.isPaintSuspended(false); // spread.isPaintSuspended(false);
var sheet = spread.getActiveSheet(); var sheet = spread.getActiveSheet();
if (sheet != null) { if (sheet != null) {
sheet.setRowHeaderVisible(true); // sheet.setRowHeaderVisible(true);
sheet.setColumnHeaderVisible(true); // sheet.setColumnHeaderVisible(true);
sheet.setGridlineOptions({ // sheet.setGridlineOptions({
showVerticalGridline: false, showHorizontalGridline: false // showVerticalGridline: false, showHorizontalGridline: false
}); // });
} }
deferred.resolve(spread); deferred.resolve(spread);
...@@ -60,21 +96,63 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt ...@@ -60,21 +96,63 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
var promise = deferred.promise; var promise = deferred.promise;
var spreadSheet; var spreadSheet;
getTemplateJson(templateID).success(function (result) { var url = loginContext.apiHost + constant.webapi.prefix+'/template/getTemplateJson?templateID=' + templateID;
var excelIo = new GC.Spread.Excel.IO(); var xhr = new XMLHttpRequest();
excelIo.open(result, function (json) { xhr.open('POST', url, true); // 也可以使用POST方式,根据接口
var workbookObj = json; xhr.responseType = "blob"; // 返回类型blob
//spread.fromJSON(workbookObj); var apiTokenObj = JSON.parse(getCookie('AtmsApiToken'));
spreadSheet = initSpreadExcel(id, workbookObj); var apiToken = apiTokenObj.access_token;
deferred.resolve(spreadSheet); var tokenType = apiTokenObj.token_type;
}, function (e) { xhr.setRequestHeader('Authorization', tokenType + ' ' + apiToken);
// process error // xhr.setRequestHeader("Authorization","bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTUyNzMxNDA4NCwiaWF0IjoxNTI3MTQxMjg0LCJuYmYiOjE1MjcxNDA2ODQsImp0aSI6IjVGM0FGMTBDLTdFMEEtNDVDQy04RDVGLUREMTBFMDRCOUY4NCIsInVzZXJuYW1lIjoiYWRtaW4iLCJkYXRhYmFzZVVzZXJuYW1lIjoiQWRtaW4iLCJ1c2VyaWQiOiI2NjkzM0U3Qi1EQTc1LTRCMkUtQjdENi1BQjY1RENBMjBENTAifQ.M-dyU6W51LAPVQ66HIJZ-KAg6WjPSIt1GqpOc6etQ6XJfXp8KkUPA6A8qPZ8bhydWsKKMqpPlx-KRVhK2o5q0Q")
alert(e.errorMessage); // 定义请求完成的处理函数,请求前也可以增加加载框/禁用下载按钮逻辑
}, {}); xhr.onload = function () {
// spreadSheet = initSpreadExcel(id, result.data === undefined ? result : result.data); // 请求完成
// if (this.status === 200) {
// deferred.resolve(spreadSheet); // 返回200
}); var blob = this.response;
var excelIo = new GC.Spread.Excel.IO();
excelIo.open(blob, function (json) {
//var workbookObj = json;
//spread.fromJSON(workbookObj);
spreadSheet = initSpreadExcel(id, json);
deferred.resolve(spreadSheet);
}, function (e) {
// 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; return promise;
}; };
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -576,14 +576,14 @@ systemConfigurationModule ...@@ -576,14 +576,14 @@ systemConfigurationModule
setCellFormula(template.id); setCellFormula(template.id);
//给单元格增加双击事件 //给单元格增加双击事件
activeSheet.bind(GcSpread.Sheets.Events.CellDoubleClick, function (sender, args) { activeSheet.bind(GC.Spread.Sheets.Events.CellDoubleClick, function (sender, args) {
var sheet = args.sheet; var sheet = args.sheet;
var cell = sheet.getCell(args.row, args.col); var cell = sheet.getCell(args.row, args.col);
showEditReportFormulaPop(template, args.row, args.col, true); showEditReportFormulaPop(template, args.row, args.col, true);
}); });
//给单元格增加单击事件 //给单元格增加单击事件
activeSheet.bind(GcSpread.Sheets.Events.CellClick, function (sender, args) { activeSheet.bind(GC.Spread.Sheets.Events.CellClick, function (sender, args) {
var sheet = args.sheet; var sheet = args.sheet;
var cell = sheet.getCell(args.row, args.col); var cell = sheet.getCell(args.row, args.col);
showEditReportFormulaPop(template, args.row, args.col, false); showEditReportFormulaPop(template, args.row, args.col, false);
...@@ -604,7 +604,7 @@ systemConfigurationModule ...@@ -604,7 +604,7 @@ systemConfigurationModule
if ($scope.currentTemplate.isSystemType) { if ($scope.currentTemplate.isSystemType) {
isHideContextMenu = true; isHideContextMenu = true;
} }
else if (hitTestType === GcSpread.Sheets.SheetArea.colHeader) { else if (hitTestType === GC.Spread.Sheets.SheetArea.colHeader) {
if (getCellInSelections(selections, row, col) === null) { if (getCellInSelections(selections, row, col) === null) {
sheet.setSelection(-1, col, sheet.getRowCount(), 1); sheet.setSelection(-1, col, sheet.getRowCount(), 1);
} }
...@@ -612,7 +612,7 @@ systemConfigurationModule ...@@ -612,7 +612,7 @@ systemConfigurationModule
$(".context-header").show(); $(".context-header").show();
$(".context-cell").hide(); $(".context-cell").hide();
} }
} else if (hitTestType === GcSpread.Sheets.SheetArea.rowHeader) { } else if (hitTestType === GC.Spread.Sheets.SheetArea.rowHeader) {
if (getCellInSelections(selections, row, col) === null) { if (getCellInSelections(selections, row, col) === null) {
sheet.setSelection(row, -1, 1, sheet.getColumnCount()); sheet.setSelection(row, -1, 1, sheet.getColumnCount());
} }
...@@ -620,7 +620,7 @@ systemConfigurationModule ...@@ -620,7 +620,7 @@ systemConfigurationModule
$(".context-header").show(); $(".context-header").show();
$(".context-cell").hide(); $(".context-cell").hide();
} }
} else if (hitTestType === GcSpread.Sheets.SheetArea.viewport) { } else if (hitTestType === GC.Spread.Sheets.SheetArea.viewport) {
if (getCellInSelections(selections, row, col) === null) { if (getCellInSelections(selections, row, col) === null) {
sheet.clearSelection(); sheet.clearSelection();
sheet.setActiveCell(row, col); sheet.setActiveCell(row, col);
...@@ -631,7 +631,7 @@ systemConfigurationModule ...@@ -631,7 +631,7 @@ systemConfigurationModule
} else { } else {
isHideContextMenu = true; isHideContextMenu = true;
} }
} else if (hitTestType === GcSpread.Sheets.SheetArea.corner) { } else if (hitTestType === GC.Spread.Sheets.SheetArea.corner) {
sheet.setSelection(-1, -1, sheet.getRowCount(), sheet.getColumnCount()); sheet.setSelection(-1, -1, sheet.getRowCount(), sheet.getColumnCount());
if (row !== undefined && col !== undefined) { if (row !== undefined && col !== undefined) {
$(".context-header").hide(); $(".context-header").hide();
......
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