Commit 1fa3f350 authored by chase's avatar chase

merge档案管理

parent 4f21b81c
...@@ -22,14 +22,16 @@ import pwc.taxtech.atms.vat.entity.FileUpload; ...@@ -22,14 +22,16 @@ import pwc.taxtech.atms.vat.entity.FileUpload;
import pwc.taxtech.atms.vat.entity.ReportFileUpload; import pwc.taxtech.atms.vat.entity.ReportFileUpload;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.*; import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
...@@ -360,12 +362,19 @@ public class TaxDocumentServiceImpl { ...@@ -360,12 +362,19 @@ public class TaxDocumentServiceImpl {
} }
//文件名称(带后缀) //文件名称(带后缀)
String fileName = StringUtils.isBlank(taxDocument.getFileOriginalName()) ? "未知文件(请修改后缀名).xlsx" : taxDocument.getFileOriginalName(); String fileName = StringUtils.isBlank(taxDocument.getFileOriginalName()) ? "未知文件(请修改后缀名).xlsx" : taxDocument.getFileOriginalName();
//设置输出流信息
try {
response.setContentType("multipart/form-data");
response.setHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode(fileName, "UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("单个下载文件名编码时出现错误.", e);
}
//获取需要下载的文件流 //获取需要下载的文件流
InputStream is = null; InputStream is = null;
BufferedInputStream in = null; BufferedInputStream in = null;
byte[] buffer = new byte[1024]; byte[] buffer = new byte[1024];
int len; int len;
ServletOutputStream out = null; OutputStream out = null;
try { try {
URL httpurl = new URL(URLDecoder.decode(urlPath, "UTF-8")); URL httpurl = new URL(URLDecoder.decode(urlPath, "UTF-8"));
HttpURLConnection httpConn = (HttpURLConnection) httpurl.openConnection(); HttpURLConnection httpConn = (HttpURLConnection) httpurl.openConnection();
......
...@@ -84,6 +84,7 @@ ...@@ -84,6 +84,7 @@
"OrganizationParent":"Holding Entity", "OrganizationParent":"Holding Entity",
"OrganizationLevelType":"Entity Level", "OrganizationLevelType":"Entity Level",
"OrganizationLevelTypeRequired":"Entity Level Required", "OrganizationLevelTypeRequired":"Entity Level Required",
"CreateDocFileType":"Create Document File Type",
"ChangeProjectTips":"Only Change/Delete unused service", "ChangeProjectTips":"Only Change/Delete unused service",
"ExistsProjectCannotDisable":"Cannot disable user because of project exists", "ExistsProjectCannotDisable":"Cannot disable user because of project exists",
......
...@@ -109,6 +109,7 @@ ...@@ -109,6 +109,7 @@
"DocumentTypeSets": "税务档案类型设置", "DocumentTypeSets": "税务档案类型设置",
"Explain": "说明", "Explain": "说明",
"RequiredFields": "必填字段", "RequiredFields": "必填字段",
"CreateDocFileType":"新建文档类型",
"State": "状态", "State": "状态",
"PCompany": "所属机构", "PCompany": "所属机构",
"Enable": "启用", "Enable": "启用",
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
SweetAlert.warning("没有数据可以下载"); SweetAlert.warning("没有数据可以下载");
return; return;
} }
$scope.dataGridUpdate(data); $scope.dataGridUpdate(data);
}) })
...@@ -23,6 +24,7 @@ ...@@ -23,6 +24,7 @@
$scope.dataGridUpdate = function (_data) { $scope.dataGridUpdate = function (_data) {
$scope.localData = _data.items; $scope.localData = _data.items;
$scope.queryStatusType($scope.localData);
$scope.pagingOptions = { $scope.pagingOptions = {
totalItems: $scope.localData.length, //总数据 totalItems: $scope.localData.length, //总数据
}; };
...@@ -86,6 +88,7 @@ ...@@ -86,6 +88,7 @@
allowHeaderFiltering: true, allowHeaderFiltering: true,
cellTemplate: function (container, options) { cellTemplate: function (container, options) {
try { try {
$scope.queryStatusType(options.data);
var style = options.data.status == 1 ? '' : 'style="color:#999"'; var style = options.data.status == 1 ? '' : 'style="color:#999"';
if (options.data.id) { if (options.data.id) {
$('<span ' + style + '>').text(options.data.id).appendTo(container); $('<span ' + style + '>').text(options.data.id).appendTo(container);
...@@ -103,6 +106,7 @@ ...@@ -103,6 +106,7 @@
allowHeaderFiltering: true, allowHeaderFiltering: true,
cellTemplate: function (container, options) { cellTemplate: function (container, options) {
try { try {
$scope.queryStatusType(options.data);
var style = options.data.status == 1 ? '' : 'style="color:#999"'; var style = options.data.status == 1 ? '' : 'style="color:#999"';
if (options.data.fileAttr) { if (options.data.fileAttr) {
$('<span ' + style + '>').text(options.data.fileAttr).appendTo(container); $('<span ' + style + '>').text(options.data.fileAttr).appendTo(container);
...@@ -120,6 +124,7 @@ ...@@ -120,6 +124,7 @@
allowHeaderFiltering: true, allowHeaderFiltering: true,
cellTemplate: function (container, options) { cellTemplate: function (container, options) {
try { try {
$scope.queryStatusType(options.data);
var style = options.data.status == 1 ? '' : 'style="color:#999"'; var style = options.data.status == 1 ? '' : 'style="color:#999"';
if (options.data.fileType) { if (options.data.fileType) {
$('<span ' + style + '>').text(options.data.fileType).appendTo(container); $('<span ' + style + '>').text(options.data.fileType).appendTo(container);
...@@ -137,6 +142,7 @@ ...@@ -137,6 +142,7 @@
allowHeaderFiltering: true, allowHeaderFiltering: true,
cellTemplate: function (container, options) { cellTemplate: function (container, options) {
try { try {
$scope.queryStatusType(options.data);
var style = options.data.status == 1 ? '' : 'style="color:#999"'; var style = options.data.status == 1 ? '' : 'style="color:#999"';
if (options.data.description) { if (options.data.description) {
$('<span ' + style + '>').text(options.data.description).appendTo(container); $('<span ' + style + '>').text(options.data.description).appendTo(container);
...@@ -155,6 +161,7 @@ ...@@ -155,6 +161,7 @@
allowHeaderFiltering: true, allowHeaderFiltering: true,
cellTemplate: function (container, options) { cellTemplate: function (container, options) {
try { try {
$scope.queryStatusType(options.data);
var style = options.data.status == 1 ? '' : 'style="color:#999"'; var style = options.data.status == 1 ? '' : 'style="color:#999"';
if (options.data.requiredField) { if (options.data.requiredField) {
$('<span '+style+'>').text(options.data.requiredField.join(",")).appendTo(container); $('<span '+style+'>').text(options.data.requiredField.join(",")).appendTo(container);
...@@ -173,6 +180,7 @@ ...@@ -173,6 +180,7 @@
allowHeaderFiltering: true, allowHeaderFiltering: true,
cellTemplate: function (container, options) { cellTemplate: function (container, options) {
try { try {
$scope.queryStatusType(options.data);
var style = options.data.status == 1 ? '' : 'style="color:#999"'; var style = options.data.status == 1 ? '' : 'style="color:#999"';
if (options.data.creator) { if (options.data.creator) {
$('<span ' + style + '>').text(options.data.creator).appendTo(container); $('<span ' + style + '>').text(options.data.creator).appendTo(container);
...@@ -191,6 +199,7 @@ ...@@ -191,6 +199,7 @@
cellTemplate: function (container, options) { cellTemplate: function (container, options) {
try { try {
$scope.queryStatusType(options.data);
var style = options.data.status == 1 ? '' : 'style="color:#999"'; var style = options.data.status == 1 ? '' : 'style="color:#999"';
if (options.data.updateTime) { if (options.data.updateTime) {
$('<span '+style+'>').text($filter('date')(options.data.updateTime, 'yyyy-MM-dd')).appendTo(container); $('<span '+style+'>').text($filter('date')(options.data.updateTime, 'yyyy-MM-dd')).appendTo(container);
...@@ -208,6 +217,7 @@ ...@@ -208,6 +217,7 @@
allowHeaderFiltering: true, allowHeaderFiltering: true,
cellTemplate: function (container, options) { cellTemplate: function (container, options) {
try { try {
$scope.queryStatusType(options.data);
if (options.data.status == 1) { if (options.data.status == 1) {
options.data.status = $translate.instant('Enabled'); options.data.status = $translate.instant('Enabled');
$('<span>').text(options.data.status).appendTo(container); $('<span>').text(options.data.status).appendTo(container);
...@@ -251,10 +261,12 @@ ...@@ -251,10 +261,12 @@
$scope.localData.forEach(function (item) { $scope.localData.forEach(function (item) {
if (item.id == rowId) { if (item.id == rowId) {
$scope.editModel = angular.copy(item); $scope.editModel = angular.copy(item);
if($scope.editModel.status != 1 || $scope.editModel.status != 0){ // if($scope.editModel.status != 1 || $scope.editModel.status != 0){
// 特殊处理状态值,1 = “已启用”, 0 = “已禁用” // // 特殊处理状态值,1 = “已启用”, 0 = “已禁用”
$scope.editModel.status = item.status == $translate.instant("Enabled") ? 1 : 0; // $scope.editModel.status = item.status == $translate.instant("Enabled") ? 1 : 0;
} // }
$scope.queryStatusType($scope.editModel);
} }
}); });
} }
...@@ -286,6 +298,7 @@ ...@@ -286,6 +298,7 @@
if(uploadModel.status === undefined if(uploadModel.status === undefined
|| uploadModel.status === null) uploadModel.status = 1; || uploadModel.status === null) uploadModel.status = 1;
$scope.queryStatusType(uploadModel);
docManageService.addFileType(uploadModel).then(function (data) { docManageService.addFileType(uploadModel).then(function (data) {
if (data == true) { if (data == true) {
SweetAlert.success($translate.instant('SaveSuccess')); SweetAlert.success($translate.instant('SaveSuccess'));
...@@ -299,6 +312,7 @@ ...@@ -299,6 +312,7 @@
var editDocFileType = function () { var editDocFileType = function () {
var uploadModel = angular.copy($scope.editModel); var uploadModel = angular.copy($scope.editModel);
$scope.queryStatusType(uploadModel);
docManageService.editFileType(uploadModel).then(function (data) { docManageService.editFileType(uploadModel).then(function (data) {
if (data == true) { if (data == true) {
SweetAlert.success($translate.instant('SaveSuccess')); SweetAlert.success($translate.instant('SaveSuccess'));
...@@ -316,19 +330,19 @@ ...@@ -316,19 +330,19 @@
}; };
$scope.editModel = { $scope.editModel = {
"id": 0,//主键id "id": null,//主键id
"fileAttr": "",//档案属性 手写 "fileAttr": null,//档案属性 手写
"fileTypeId": null,//暂无作用 因档案类型手写 "fileTypeId": null,//暂无作用 因档案类型手写
"fileType": "",//档案类型 "fileType": null,//档案类型
"requiredField": [],//必填字段对应id(先写死) 对应关系以前端为主导 "requiredField": [],//必填字段对应id(先写死) 对应关系以前端为主导
"requiredFieldJson": "",//后台转换使用 "requiredFieldJson": null,//后台转换使用
"description": "",//说明 "description": null,//说明
"creatorId": 1,//创建人id "creatorId": null,//创建人id
"creator": "",//创建人名字 "creator": null,//创建人名字
"createTime": "2019-02-27T17:53:58.000+08:00",//创建时间 "createTime": null,//创建时间
"updateTime": null,//更新时间 "updateTime": null,//更新时间
"status": 0,//'状态(0代表停用,1代表启用)' "status": null,//'状态(0代表停用,1代表启用)'
"remarks": ""//备注 "remarks": null//备注
}; };
$scope.editRequiredFieldsMap = { $scope.editRequiredFieldsMap = {
1: "文件生效日期", 1: "文件生效日期",
...@@ -344,6 +358,24 @@ ...@@ -344,6 +358,24 @@
$scope.editModel.requiredFieldJson = JSON.stringify(values); $scope.editModel.requiredFieldJson = JSON.stringify(values);
} }
// 在入口和出口都对数据的status字段进行过滤
$scope.queryStatusType = function(model){
if(Object.prototype.toString.call(model) === "[object Array]"){
model.forEach(function(item){
if(item.status === $translate.instant('Enabled')){
item.status = 1;
}else if(item.status === $translate.instant('Disabled')){
item.status = 0;
}
})
}else{
if(model.status === $translate.instant('Enabled')){
model.status = 1;
}else if(model.status === $translate.instant('Disabled')){
model.status = 0;
}
}
}
//----------------------taxation----basic-end------------------------------- //----------------------taxation----basic-end-------------------------------
;(function initialize() { ;(function initialize() {
......
...@@ -485,6 +485,28 @@ taxDocumentManageModule.controller('taxDocumentListController', ...@@ -485,6 +485,28 @@ taxDocumentManageModule.controller('taxDocumentListController',
$scope.fileTypeOptions = $scope.sortByFirstCode(Object.keys(data)); $scope.fileTypeOptions = $scope.sortByFirstCode(Object.keys(data));
$scope.fileAttrOptions = $scope.sortByFirstCode(Object.values(data)); $scope.fileAttrOptions = $scope.sortByFirstCode(Object.values(data));
// 过滤去重
var temp = $scope.fileTypeOptions;
$scope.fileTypeOptions = (function(){
var result = [];
temp.forEach(function(typeItem){
if(result.indexOf(typeItem) === -1){
result.push(typeItem);
}
});
return result;
})();
temp = $scope.fileAttrOptions;
$scope.fileAttrOptions = (function(){
var result = [];
temp.forEach(function(attrItem){
if(result.indexOf(attrItem) === -1){
result.push(attrItem);
}
});
return result;
})();
} }
}); });
...@@ -1245,8 +1267,10 @@ taxDocumentManageModule.directive('watchGroup', function () { ...@@ -1245,8 +1267,10 @@ taxDocumentManageModule.directive('watchGroup', function () {
$scope.autoMatchAttrAndType = function (fileName, fieldModel) { $scope.autoMatchAttrAndType = function (fileName, fieldModel) {
fileName = fileName ? fileName : ""; fileName = fileName ? fileName : "";
var fieldsAttrs = fileName.split("_"); var fieldsAttrs = fileName.split("_");
fieldModel.fileName = fieldsAttrs[0]; if(fieldsAttrs.length){
fieldModel.fileType = fieldsAttrs[1]; fieldModel.companyName = fieldsAttrs[0];
fieldModel.fileType = fieldsAttrs[1];
}
// 根据Type来匹配Attr; // 根据Type来匹配Attr;
Object.keys($scope.typeAndAttrMap).forEach(function (key) { Object.keys($scope.typeAndAttrMap).forEach(function (key) {
...@@ -1437,4 +1461,129 @@ taxDocumentManageModule.directive('downLoadModule', function () { ...@@ -1437,4 +1461,129 @@ taxDocumentManageModule.directive('downLoadModule', function () {
}; };
}] }]
} }
});
taxDocumentManageModule.directive('exportPlugin',function(){
return{
restrict:"EA",
controller:['$scope','SweetAlert','$translate',function($scope,SweetAlert,$translate){
$scope.exportOrgList = function ()
{
var exportData = {
"type" : "orgList",
"jsonData" : JSON.stringify($scope.DataGridSource)
};
orgService.downloadOrgListData(exportData).success(function (data, status, headers) {
if(status===204){
SweetAlert.warning("没有数据可以下载");
return;
}
exportToExcel(data, status, headers, 'taxDocument.xls');
}).error(function () {
SweetAlert.error($translate.instant('PleaseContactAdministrator'));
});
};
//下载服务器上的xls文件
var exportToExcel = function (data, status, headers, defaultFileName) {
$('#busy-indicator-container').show();
var defer = $q.defer();
var octetStreamMime = 'application/vnd.ms-excel';
var success = false;
// Get the headers
headers = headers();
// Get the filename from the x-filename header or default to "download.bin"
var filename = decodeURI(headers['x-file-name']) + defaultFileName;
// Determine the content type from the header or default to "application/octet-stream"
var contentType = headers['content-type'] || octetStreamMime;
try {
// Try using msSaveBlob if supported
//console.log("Trying saveBlob method ...");
var blob = new Blob([data], { type: contentType });
if (navigator.msSaveBlob)
navigator.msSaveBlob(blob, filename);
else {
// Try using other saveBlob implementations, if available
var saveBlob = navigator.webkitSaveBlob || navigator.mozSaveBlob || navigator.saveBlob;
if (saveBlob === undefined) throw "Not supported";
saveBlob(blob, filename);
}
//console.log("saveBlob succeeded");
success = true;
} catch (ex) {
$log.debug("saveBlob method failed with the following exception:");
$log.debug(ex);
}
if (!success) {
// Get the blob url creator
var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;
if (urlCreator) {
// Try to use a download link
var link = document.createElement('a');
if ('download' in link) {
// Try to simulate a click
try {
// Prepare a blob URL
//console.log("Trying download link method with simulated click ...");
var blobdownload = new Blob([data], { type: contentType });
var urldownload = urlCreator.createObjectURL(blobdownload);
link.setAttribute('href', urldownload);
// Set the download attribute (Supported in Chrome 14+ / Firefox 20+)
link.setAttribute("download", filename);
// Simulate clicking the download link
var event = document.createEvent('MouseEvents');
event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
link.dispatchEvent(event);
//console.log("Download link method with simulated click succeeded");
success = true;
} catch (ex) {
$log.debug("Download link method with simulated click failed with the following exception:");
$log.debug(ex);
$q.reject();
}
}
if (!success) {
// Fallback to window.location method
try {
// Prepare a blob URL
// Use application/octet-stream when using window.location to force download
//console.log("Trying download link method with window.location ...");
var blobsuccess = new Blob([data], { type: octetStreamMime });
var urlsuccess = urlCreator.createObjectURL(blobsuccess);
window.location = urlsuccess;
//console.log("Download link method with window.location succeeded");
success = true;
} catch (ex) {
//console.log("Download link method with window.location failed with the following exception:");
$log.debug(ex);
$q.reject();
}
}
}
}
if (!success) {
// Fallback to window.open method
$log.debug("No methods worked for saving the arraybuffer, using last resort window.open");
window.open(httpPath, '_blank', '');
}
//Delete the file
// deleteFile(encodeURI(filename));
defer.resolve('success');
$('#busy-indicator-container').hide();
return defer.promise;
};
}]
}
}); });
\ No newline at end of file
...@@ -498,7 +498,7 @@ ...@@ -498,7 +498,7 @@
<span translate="EntityIndex"></span> <span translate="EntityIndex"></span>
</div> </div>
<div class="TDL-query-val"> <div class="TDL-query-val">
<input type="number" class="form-control radius3" <input type="text" class="form-control radius3"
ng-model="queryFieldModel.physicalIndexNumber"/> ng-model="queryFieldModel.physicalIndexNumber"/>
</div> </div>
</div> </div>
...@@ -818,7 +818,7 @@ ...@@ -818,7 +818,7 @@
</label> </label>
<div class="col-sm-11" style="width:61.67%"> <div class="col-sm-11" style="width:61.67%">
<input class="form-control" <input class="form-control"
type="number" type="text"
placeholder="{{'PleaseType' | translate}}" placeholder="{{'PleaseType' | translate}}"
ng-required="isRequired('EntityIndex')" ng-required="isRequired('EntityIndex')"
ng-model="editFieldModel.physicalIndexNumber" ng-model="editFieldModel.physicalIndexNumber"
...@@ -1055,7 +1055,7 @@ ...@@ -1055,7 +1055,7 @@
</label> </label>
<div class="col-sm-11" style="width:61.67%"> <div class="col-sm-11" style="width:61.67%">
<input class="form-control" <input class="form-control"
type="number" type="text"
placeholder="{{'PleaseType' | translate}}" placeholder="{{'PleaseType' | translate}}"
ng-model="editFieldItem.physicalIndexNumber" ng-model="editFieldItem.physicalIndexNumber"
ng-required="isRequired('EntityIndex')" ng-required="isRequired('EntityIndex')"
...@@ -1180,7 +1180,7 @@ ...@@ -1180,7 +1180,7 @@
<span class="close" data-dismiss="modal" aria-hidden="true" ng-click="closeImgPop()">×</span> <span class="close" data-dismiss="modal" aria-hidden="true" ng-click="closeImgPop()">×</span>
<div class="modal-title">{{curImgName}}</div> <div class="modal-title">{{curImgName}}</div>
</div> </div>
<div class="modal-body" style="text-align: center;"> <div class="modal-body" style="text-align: center;overflow: auto;">
<img src="{{curImgSrc}}" alt="please try again"> <img src="{{curImgSrc}}" alt="please try again">
</div> </div>
</div> </div>
......
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