Commit 1f403a54 authored by chase's avatar chase

报表文件上传归档功能

parent 506dce2c
......@@ -38,14 +38,15 @@ public class ReportUploadDetailController extends BaseController {
return reportFileUploadService.queryData(param);
}
@ResponseBody
@PostMapping("saveFileUpload")
public OperationResultDto saveFileUpload(@RequestParam MultipartFile file, @RequestParam String reportType,@RequestParam String projectId, @RequestParam Integer period) {
public OperationResultDto saveFileUpload(@RequestParam MultipartFile file, @RequestParam String sourceType,@RequestParam String reportType,@RequestParam String projectId, @RequestParam Integer period) {
try {
ReportFileUpload data = new ReportFileUpload();
data.setPeriod(period);
data.setProjectId(projectId);
data.setReportType(reportType);
data.setSourceType(sourceType);
reportFileUploadService.saveData(file,data);
return OperationResultDto.success();
} catch (ServiceException e) {
......
......@@ -50,41 +50,41 @@ public class ReportFileUploadService extends BaseService {
ReportFileUploadExample example = new ReportFileUploadExample();
example.createCriteria().andProjectIdEqualTo(param.getProjectId()).andPeriodEqualTo(param.getPeriod());
List<ReportFileUpload> dataList = reportFileUploadMapper.selectByExample(example);
List<String> fileUploadUids =dataList.stream()
List<String> fileUploadUids = dataList.stream()
.map(o -> o.getFileUploadId()).collect(Collectors.toList());
Map<String,String> urlMap = new HashMap<>();
if(CollectionUtils.isNotEmpty(fileUploadUids)){
Map<String, String> urlMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(fileUploadUids)) {
DidiFileIUploadParam fileParam = new DidiFileIUploadParam();
fileParam.setUuids(fileUploadUids);
PageInfo<DidiFileUploadDetailResult> uploadDetail = didiFileUploadService.queryPage(fileParam);
if(CollectionUtils.isNotEmpty(uploadDetail.getList())){
if (CollectionUtils.isNotEmpty(uploadDetail.getList())) {
urlMap = uploadDetail.getList().stream().collect(Collectors.toMap(DidiFileUploadDetailResult::getUid, didiFileUploadDetailResult -> didiFileUploadDetailResult.getViewHttpUrl()));
}
}
List<String> reportTypeList = dataList.stream()
.map(o -> o.getReportType()).collect(Collectors.toList());
if(!reportTypeList.contains(ReportFileUploadEnum.ReportType.NORMAL_DECLARATION)){
if (!reportTypeList.contains(ReportFileUploadEnum.ReportType.NORMAL_DECLARATION.getCode())) {
ReportFileUpload upload = new ReportFileUpload();
upload.setReportType(ReportFileUploadEnum.ReportType.NORMAL_DECLARATION.getCode());
dataList.add(upload);
}
if(!reportTypeList.contains(ReportFileUploadEnum.ReportType.CORR_DECLARATION)){
if (!reportTypeList.contains(ReportFileUploadEnum.ReportType.CORR_DECLARATION.getCode())) {
ReportFileUpload upload = new ReportFileUpload();
upload.setReportType(ReportFileUploadEnum.ReportType.CORR_DECLARATION.getCode());
dataList.add(upload);
}
if(!reportTypeList.contains(ReportFileUploadEnum.ReportType.NORMAL_TAX_RECEIPT)){
if (!reportTypeList.contains(ReportFileUploadEnum.ReportType.NORMAL_TAX_RECEIPT.getCode())) {
ReportFileUpload upload = new ReportFileUpload();
upload.setReportType(ReportFileUploadEnum.ReportType.NORMAL_TAX_RECEIPT.getCode());
dataList.add(upload);
}
if(!reportTypeList.contains(ReportFileUploadEnum.ReportType.CORR_TAX_RECEIPT)){
if (!reportTypeList.contains(ReportFileUploadEnum.ReportType.CORR_TAX_RECEIPT.getCode())) {
ReportFileUpload upload = new ReportFileUpload();
upload.setReportType(ReportFileUploadEnum.ReportType.CORR_TAX_RECEIPT.getCode());
dataList.add(upload);
}
List<ReportFileUploadResult> resultList = new ArrayList<ReportFileUploadResult>();
for(ReportFileUpload data:dataList){
for (ReportFileUpload data : dataList) {
ReportFileUploadResult result = beanUtil.copyProperties(data, new ReportFileUploadResult());
result.setFileUrl(urlMap.get(data.getFileUploadId()));
resultList.add(result);
......@@ -93,10 +93,10 @@ public class ReportFileUploadService extends BaseService {
}
public void saveData(MultipartFile file, ReportFileUpload data) {
if(!ReportFileUploadEnum.ReportType.MAPPING.containsKey(data.getReportType())){
if (!ReportFileUploadEnum.ReportType.MAPPING.containsKey(data.getReportType())) {
throw new ServiceException(ErrorMessage.ParamError);
}
if(!ReportFileUploadEnum.SuorceType.MAPPING.containsKey(data.getSourceType())){
if (!ReportFileUploadEnum.SuorceType.MAPPING.containsKey(data.getSourceType())) {
throw new ServiceException(ErrorMessage.ParamError);
}
String uid = authUserHelper.getCurrentUserId();
......@@ -111,8 +111,8 @@ public class ReportFileUploadService extends BaseService {
data.setUid(CommonUtils.getUUID());
data.setCreateTime(new Date());
data.setReportFileName(file.getOriginalFilename());
int updateRow = reportFileUploadMapper.updateByExample(data,example);
if(updateRow==0){
int updateRow = reportFileUploadMapper.updateByExample(data, example);
if (updateRow == 0) {
reportFileUploadMapper.insert(data);
}
}
......
package pwc.taxtech.atms.vat.entity;
import pwc.taxtech.atms.entity.BaseEntity;
import java.io.Serializable;
import java.util.Date;
import pwc.taxtech.atms.entity.BaseEntity;
/**
*
......@@ -87,17 +88,6 @@ public class ReportFileUpload extends BaseEntity implements Serializable {
*/
private String reportFileName;
/**
* Database Column Remarks:
* 版本号
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column report_file_upload.version
*
* @mbg.generated
*/
private Integer version;
/**
* Database Column Remarks:
* 文件上传表id
......@@ -307,30 +297,6 @@ public class ReportFileUpload extends BaseEntity implements Serializable {
this.reportFileName = reportFileName == null ? null : reportFileName.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column report_file_upload.version
*
* @return the value of report_file_upload.version
*
* @mbg.generated
*/
public Integer getVersion() {
return version;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column report_file_upload.version
*
* @param version the value for report_file_upload.version
*
* @mbg.generated
*/
public void setVersion(Integer version) {
this.version = version;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column report_file_upload.file_upload_id
......@@ -422,7 +388,6 @@ public class ReportFileUpload extends BaseEntity implements Serializable {
sb.append(", creator=").append(creator);
sb.append(", createTime=").append(createTime);
sb.append(", reportFileName=").append(reportFileName);
sb.append(", version=").append(version);
sb.append(", fileUploadId=").append(fileUploadId);
sb.append(", reportType=").append(reportType);
sb.append(", sourceType=").append(sourceType);
......
......@@ -665,66 +665,6 @@ public class ReportFileUploadExample {
return (Criteria) this;
}
public Criteria andVersionIsNull() {
addCriterion("version is null");
return (Criteria) this;
}
public Criteria andVersionIsNotNull() {
addCriterion("version is not null");
return (Criteria) this;
}
public Criteria andVersionEqualTo(Integer value) {
addCriterion("version =", value, "version");
return (Criteria) this;
}
public Criteria andVersionNotEqualTo(Integer value) {
addCriterion("version <>", value, "version");
return (Criteria) this;
}
public Criteria andVersionGreaterThan(Integer value) {
addCriterion("version >", value, "version");
return (Criteria) this;
}
public Criteria andVersionGreaterThanOrEqualTo(Integer value) {
addCriterion("version >=", value, "version");
return (Criteria) this;
}
public Criteria andVersionLessThan(Integer value) {
addCriterion("version <", value, "version");
return (Criteria) this;
}
public Criteria andVersionLessThanOrEqualTo(Integer value) {
addCriterion("version <=", value, "version");
return (Criteria) this;
}
public Criteria andVersionIn(List<Integer> values) {
addCriterion("version in", values, "version");
return (Criteria) this;
}
public Criteria andVersionNotIn(List<Integer> values) {
addCriterion("version not in", values, "version");
return (Criteria) this;
}
public Criteria andVersionBetween(Integer value1, Integer value2) {
addCriterion("version between", value1, value2, "version");
return (Criteria) this;
}
public Criteria andVersionNotBetween(Integer value1, Integer value2) {
addCriterion("version not between", value1, value2, "version");
return (Criteria) this;
}
public Criteria andFileUploadIdIsNull() {
addCriterion("file_upload_id is null");
return (Criteria) this;
......
......@@ -13,7 +13,6 @@
<result column="creator" jdbcType="VARCHAR" property="creator" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="report_file_name" jdbcType="VARCHAR" property="reportFileName" />
<result column="version" jdbcType="INTEGER" property="version" />
<result column="file_upload_id" jdbcType="VARCHAR" property="fileUploadId" />
<result column="report_type" jdbcType="VARCHAR" property="reportType" />
<result column="source_type" jdbcType="VARCHAR" property="sourceType" />
......@@ -89,8 +88,8 @@
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
`uid`, org_id, project_id, period, creator, create_time, report_file_name, version,
file_upload_id, report_type, source_type
`uid`, org_id, project_id, period, creator, create_time, report_file_name, file_upload_id,
report_type, source_type
</sql>
<select id="selectByExample" parameterType="pwc.taxtech.atms.vat.entity.ReportFileUploadExample" resultMap="BaseResultMap">
<!--
......@@ -127,12 +126,12 @@
-->
insert into report_file_upload (`uid`, org_id, project_id,
period, creator, create_time,
report_file_name, version, file_upload_id,
report_type, source_type)
report_file_name, file_upload_id, report_type,
source_type)
values (#{uid,jdbcType=VARCHAR}, #{orgId,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR},
#{period,jdbcType=INTEGER}, #{creator,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{reportFileName,jdbcType=VARCHAR}, #{version,jdbcType=INTEGER}, #{fileUploadId,jdbcType=VARCHAR},
#{reportType,jdbcType=VARCHAR}, #{sourceType,jdbcType=VARCHAR})
#{reportFileName,jdbcType=VARCHAR}, #{fileUploadId,jdbcType=VARCHAR}, #{reportType,jdbcType=VARCHAR},
#{sourceType,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="pwc.taxtech.atms.vat.entity.ReportFileUpload">
<!--
......@@ -162,9 +161,6 @@
<if test="reportFileName != null">
report_file_name,
</if>
<if test="version != null">
version,
</if>
<if test="fileUploadId != null">
file_upload_id,
</if>
......@@ -197,9 +193,6 @@
<if test="reportFileName != null">
#{reportFileName,jdbcType=VARCHAR},
</if>
<if test="version != null">
#{version,jdbcType=INTEGER},
</if>
<if test="fileUploadId != null">
#{fileUploadId,jdbcType=VARCHAR},
</if>
......@@ -249,9 +242,6 @@
<if test="record.reportFileName != null">
report_file_name = #{record.reportFileName,jdbcType=VARCHAR},
</if>
<if test="record.version != null">
version = #{record.version,jdbcType=INTEGER},
</if>
<if test="record.fileUploadId != null">
file_upload_id = #{record.fileUploadId,jdbcType=VARCHAR},
</if>
......@@ -279,7 +269,6 @@
creator = #{record.creator,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
report_file_name = #{record.reportFileName,jdbcType=VARCHAR},
version = #{record.version,jdbcType=INTEGER},
file_upload_id = #{record.fileUploadId,jdbcType=VARCHAR},
report_type = #{record.reportType,jdbcType=VARCHAR},
source_type = #{record.sourceType,jdbcType=VARCHAR}
......
commonModule.controller('vatReportUploadDetailController', ['$scope', '$log', '$translate', '$timeout', 'SweetAlert', '$q',
'$interval', 'dxDataGridService', '$http', 'apiConfig', 'vatSessionService','Upload','apiInterceptor',
function ($scope, $log, $translate, $timeout, SweetAlert, $q, $interval, dxDataGridService, $http, apiConfig, vatSessionService,Upload,apiInterceptor) {
'$interval', 'dxDataGridService', '$http', 'apiConfig', 'vatSessionService', 'Upload', 'apiInterceptor',
function ($scope, $log, $translate, $timeout, SweetAlert, $q, $interval, dxDataGridService, $http, apiConfig, vatSessionService, Upload, apiInterceptor) {
'use strict';
$log.debug('vatReportUploadDetailController.ctor()...');
......@@ -36,7 +36,7 @@
allowHeaderFiltering: true
},
{
dataField: 'reportName',
dataField: 'reportFileName',
caption: $translate.instant('RepUploadDtlColFileName'),
fixed: true,
allowHeaderFiltering: true
......@@ -87,7 +87,7 @@
},
{
dataField: 'createTime',
width: '20%',
width: '10%',
caption: $translate.instant('RepUploadDtlColCreateTime'),
fixed: true,
allowHeaderFiltering: true,
......@@ -102,7 +102,7 @@
allowHeaderFiltering: true
},
{
dataField: 'reportName',
dataField: 'reportFileName',
width: '30%',
caption: $translate.instant('RepUploadDtlColFileName'),
fixed: true,
......@@ -111,15 +111,17 @@
{
caption: $translate.instant('RepUploadDtlColUpload'),
fixed: true,
width: '5%',
width: '8%',
allowHeaderFiltering: true,
cellTemplate: function (container, options) {
try {
$("<a href='javascript:void(0)'>上传</a>").on('click', function () {
$scope.handleReportType = options.data.reportType;
$('#uploadBut' + options.rowIndex).click();
}).appendTo(container);
$('<input type="file" ng-model="uploadFileName" id="uploadBut' + options.rowIndex + '" style="display:none;"/>').appendTo(container);
$("<a href='javascript:void(0)'>上传</a>").on('click', function () {
$('#uploadBut' + options.rowIndex).click();
}).appendTo(container);
$('<input type="file" style="display:none;" id="uploadBut' + options.rowIndex + '" />').on('change', function () {
console.log($('#uploadBut' + options.rowIndex)[0].files[0]);
uploadFile($('#uploadBut' + options.rowIndex)[0].files[0], options.data.reportType);
}).appendTo(container);
} catch (e) {
$log.error(e);
}
......@@ -127,12 +129,12 @@
},
{
dataField: 'fileUrl',
width: '5%',
width: '8%',
caption: $translate.instant('RepUploadDtlColDownload'),
fixed: true,
allowHeaderFiltering: true,
cellTemplate: function (container, options) {
if (!options.data.fileUrl && "" != options.data.fileUrl) {
if (options.data.fileUrl && "" != options.data.fileUrl) {
try {
$("<a href='" + options.data.fileUrl + "'>下载</a>")
.appendTo(container);
......@@ -144,7 +146,7 @@
},
{
dataField: 'sourceTypeStr',
width: '5%',
width: '8%',
caption: $translate.instant('RepUploadDtlColSourceType'),
fixed: true,
allowHeaderFiltering: true
......@@ -181,7 +183,7 @@
},
{
dataField: 'createTime',
width: '20%',
width: '10%',
caption: $translate.instant('RepUploadDtlColCreateTime'),
fixed: true,
allowHeaderFiltering: true,
......@@ -196,7 +198,7 @@
allowHeaderFiltering: true
},
{
dataField: 'reportName',
dataField: 'reportFileName',
width: '30%',
caption: $translate.instant('RepUploadDtlColFileName'),
fixed: true,
......@@ -205,12 +207,17 @@
{
caption: $translate.instant('RepUploadDtlColUpload'),
fixed: true,
width: '5%',
width: '8%',
allowHeaderFiltering: true,
cellTemplate: function (container, options) {
try {
$("<a href='javascript:void(0)'>上传</a>")
.appendTo(container);
$("<a href='javascript:void(0)'>上传</a>").on('click', function () {
$('#uploadBut' + options.rowIndex).click();
}).appendTo(container);
$('<input type="file" style="display:none;" id="uploadBut' + options.rowIndex + '" />').on('change', function () {
console.log($('#uploadBut' + options.rowIndex)[0].files[0]);
uploadFile($('#uploadBut' + options.rowIndex)[0].files[0], options.data.reportType);
}).appendTo(container);
} catch (e) {
$log.error(e);
}
......@@ -218,12 +225,12 @@
},
{
dataField: 'fileUrl',
width: '5%',
width: '8%',
caption: $translate.instant('RepUploadDtlColDownload'),
fixed: true,
allowHeaderFiltering: true,
cellTemplate: function (container, options) {
if (!options.data.fileUrl && "" != options.data.fileUrl) {
if (options.data.fileUrl && "" != options.data.fileUrl) {
try {
$("<a href='" + options.data.fileUrl + "'>下载</a>")
.appendTo(container);
......@@ -235,7 +242,7 @@
},
{
dataField: 'sourceTypeStr',
width: '5%',
width: '8%',
caption: $translate.instant('RepUploadDtlColSourceType'),
fixed: true,
allowHeaderFiltering: true
......@@ -246,24 +253,25 @@
}
});
$scope.uploadFile = function () {
var uploadFile = function (file, reportType) {
var month = vatSessionService.month < 10 ? ("0" + vatSessionService.month) : vatSessionService.month;
Upload.upload({
url: apiInterceptor.webApiHostUrl + '/reportUploadDetail/saveFileUpload',
data: {
projectId: vatSessionService.project.id,
period: "" + vatSessionService.year + month
period: "" + vatSessionService.year + month,
reportType: reportType,
sourceType: "VAT"
},
file: $scope.uploadFileName,
file: file,
headers: {
'Access-Control-Allow-Origin': '*',
Authorization: apiInterceptor.tokenType + ' ' + apiInterceptor.apiToken(),
__RequestVerificationToken: token,
withCredentials: true
},
__RequestVerificationToken: token,
withCredentials: true
}).then(function (resp) {
$scope.getReportFileUpload();
}, function (resp) {
}, function (evt) {
......@@ -296,8 +304,7 @@
var month = vatSessionService.month < 10 ? ("0" + vatSessionService.month) : vatSessionService.month;
$http.post('/reportUploadDetail/queryFileUpload', {
projectId: vatSessionService.project.id,
period: "" + vatSessionService.year + month,
reportType: $scope.handleReportType
period: "" + vatSessionService.year + month
}, apiConfig.createVat())
.success(function (res) {
if (res) {
......@@ -311,7 +318,6 @@
$scope.reportThreeDataSource.push(data);
}
});
$scope.pagingOptions.totalItems = res.pageInfo.totalCount;
} else {
SweetAlert.error($translate.instant('SystemError'));
}
......@@ -332,12 +338,6 @@
$scope.searchParam = {};
$scope.uploadFileName = "";
$scope.$watch('uploadFileName', function (newValue, oldValue) {
$scope.uploadFile();
});
$scope.handleReportType;
function init() {
$scope.refreshGrid();
$scope.getReportFileUpload();
......
......@@ -23,7 +23,7 @@
</div>
<div style="height: 40%">
<div class="content-container-other" style="float:left;width:48%;">
<div class="content-container-other" style="float:left;width:49%;">
<div class="body">
......@@ -40,7 +40,7 @@
</div>
<div class="content-container-other" style="float:right;width:48%;">
<div class="content-container-other" style="float:right;width:49%;">
<div class="body">
......
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