citReport.svc.js 14.4 KB
Newer Older
1 2 3 4
webservices.factory('citReportService', ['$q', '$log', '$http', '$translate', 'apiConfig', 'enums', 'SweetAlert', 'vatOperationLogService',
    'vatSessionService',
    function ($q, $log, $http, $translate, apiConfig, enums, SweetAlert, vatOperationLogService, vatSessionService) {
        'use strict';
zhkwei's avatar
zhkwei committed
5
        $log.debug('citReportService.ctor()...');
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
        return {

            // 修改保存机制后,需要添加缓存机制的方法:
            // addCellManualData,并添加了一个日志参数
            // deleteCellVoucher
            // deleteCellInvoice
            // deleteCellDatasource
            // addDataSource
            // addDataSourceItems
            // updateDataSourceAmount
            // 移除了CalculateSingleCellFormula
            // 新增了updateReportCellValue


            // For CIT:
            // 新增了citGenerateByType


            //CIT Remove(可以直接使用vat已有的):
            //    citGetStdAccountByIndustryID: function (industryID)
            //    citGenerate: function (projectId, templateId, param?, generator)
            //    citGetReportData: function (reportId)
            //    citGetCellVoucher: function (cellDataID)
            //    citGetCellInvoice: function (cellDataID, invoiceType)
            //    citAddCellManualData: function (mauanlData)
            //    citAddDataSource: function (dataSource)
            //    citAddDataSourceItems: function (dataSource)
            //    citDeleteCellVoucher: function (voucherId, datasourceId)
            //    citDeleteCellInvoice: function (invoiceId, datasourceId)
            //    citDeleteCellDatasource: function(datasourceID,cellID)
            //    citGetAllDataItems: function (dataSourceType)
            //    citGetCellAccountRange: function (reportTemplateId, period, rowIndex, columnIndex)
            //    citGetCellTemplateConfig: function (reportTemplateId, period, rowIndex, columnIndex)
            //    citUpdateCellAccountRangeAndSummary: function (cellTemplateId, period?, value, operation)
            //    citUpdateDataSourceAmount: function (datasourceId, amount)
            //CIT Update(带问号参数为修改的参数,目前对于申报表可以直接传null,对于BSPL如果调用到这些API需要传period):
            //    citUpdateConfig: function (projectId, period?)
            //    citGetTemplate: function (projectId, period?)

            updateConfig: function (projectId, ifDeleteManualDataSource, period, generator, isMergeManualDataSource) {
46
                return $http.post('/Report/updateConfig/' + projectId + '/' + ifDeleteManualDataSource + '/' + period + '?generator=' + generator + '&mergeManual=' + isMergeManualDataSource, {}, apiConfig.createVat({ignoreLoadingBar: true}));
47 48 49 50 51
            },
            generate: function (projectId, templateId, ifDeleteManualDataSource, period, generator) {
                return $http.post('/Report/generate/' + projectId + '/' + templateId + '/' + ifDeleteManualDataSource + '/' + period + '?generator=' + generator, {}, apiConfig.createVat({ignoreLoadingBar: true}));
            },
            generateAllCitReport: function (projectId, isMergeManualDataSource, generator) {
52
                return $http.post('/citReport/generateByTotal/' + projectId + '/' + isMergeManualDataSource + '?generator=' + generator, {}, apiConfig.createVat({ignoreLoadingBar: true}));
53 54
            },
            getRunningJob: function (projectId, period) {
55 56
                return $http.get('/citReport/getPeriodJob/' + projectId + '/' + period, apiConfig.createVat());
            },
57
            getJobStatus: function (projectId, period, jobId) {
58 59
                return $http.get('/Report/getJobStatus/' + projectId + '/' + period + '/' + jobId, apiConfig.createVat({ignoreLoadingBar: true}));
            },
60
            getReportData: function (reportId) {
kevin's avatar
kevin committed
61
                return $http.get('/citReport/reportData/' + reportId, apiConfig.createVat());
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
            },
            calculateKeyValue: function (projectId, period) {
                return $http.post('/Report/calculateKeyValue/' + projectId + '/' + period, {}, apiConfig.createVat({ignoreLoadingBar: true}));
            },
            //CalculateSingleCellFormula: function (cellId) {
            //    return $http.get('/Report/formulaDataSource/byCell/' + cellId, apiConfig.createVat());
            //},
            updateReportCellValue: function (cellDataList, reportId, generator) {
                return $http.post('/Report/updateReportCellValue/' + reportId + '?generator=' + generator, cellDataList, apiConfig.createVat());
            },
            getCitTemplate: function (projectId, serviceType) {
                return $http.get('/citReport/citTemplate/' + projectId + '/' + serviceType, apiConfig.createVat());
            },
            getFilterTemplate: function (projectId, serviceType, period) {
                if (!_.isNumber(period)) {
                    period = 0;
                }

80
                return $http.get('/citReport/filterTemplate/' + projectId + '/' + serviceType + '/' + period, apiConfig.createVat());
81 82 83 84 85 86 87 88
            },
            getCellVoucher: function (cellDataID) {
                return $http.get('/Report/cellVoucher/' + cellDataID, apiConfig.createVat());
            },
            getCellInvoice: function (cellDataID, invoiceType) {
                return $http.get('/Report/cellInvoice/' + cellDataID + '/' + invoiceType, apiConfig.createVat());
            },
            addCellManualData: function (manualData, logInfo) {
kevin's avatar
kevin committed
89
                return $http.post('/citReport/addCellManualData', manualData, apiConfig.createVat()).then(function (data) {
90 91 92 93
                    logInfo.UpdateState = $translate.instant('ManualInputSuccess');
                    vatOperationLogService.addOperationLog(logInfo);
                    data.dataSourceType = enums.cellDataSourceType.KeyIn;
                    return $q.when(data);
94
                }, function (data) {
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
                    logInfo.UpdateState = $translate.instant('ManualInputFail');
                    SweetAlert.error($translate.instant('PleaseContactAdministrator'));
                    return vatOperationLogService.addOperationLog(logInfo);
                });
            },
            deleteCellVoucher: function (voucherId, datasourceId) {
                return $http.post('/Report/deleteCellVoucher/' + voucherId + '/' + datasourceId, {}, apiConfig.createVat());
            },
            deleteCellInvoice: function (invoiceId, datasourceId) {
                return $http.post('/Report/deleteCellInvoice/' + invoiceId + '/' + datasourceId, {}, apiConfig.createVat());
            },
            deleteCellDatasource: function (datasourceID, cellID) {
                return $http.post('/Report/deleteCellDatasource/' + datasourceID + '/' + cellID, {}, apiConfig.createVat());
            },
            getAllDataItems: function (dataSourceType) {
                return $http.get('/Report/getAllDataItems/' + dataSourceType, apiConfig.createVat())
            },
            addDataSource: function (dataSource) {
                return $http.post('/Report/addDataSource', dataSource, apiConfig.createVat());
            },
            addDataSourceItems: function (dataSource) {
                return $http.post('/Report/addDataSourceItems', dataSource, apiConfig.createVat());
            },
            getCellAccountRange: function (reportTemplateId, period, rowIndex, columnIndex) {
                if (!_.isNumber(period)) {
                    period = 0;
                }

                return $http.get('/Report/getCellAccountRange/' + reportTemplateId + '/' + period + '/' + rowIndex + '/' + columnIndex, apiConfig.createVat());
            },
            getCellTemplateConfig: function (reportTemplateId, period, rowIndex, columnIndex) {
                if (!_.isNumber(period)) {
                    period = 0;
                }

                return $http.get('/Report/getCellTemplateConfig/' + reportTemplateId + '/' + period + '/' + rowIndex + '/' + columnIndex, apiConfig.createVat());
            },
            updateCellAccountRangeAndSummary: function (cellTemplateId, period, value, operation) {
                if (!_.isNumber(period)) {
                    period = 0;
                }

                return $http.post('/Report/updateCellAccountRangeAndSummary/' + cellTemplateId + '/' + period + '/' + value + '/' + operation, {}, apiConfig.createVat());
            },
            updateDataSourceAmount: function (datasourceId, amount) {
                return $http.post('/Report/updateDataSourceAmount/' + datasourceId + '/' + amount, {}, apiConfig.createVat());
            },
            getStdAccountByIndustryID: function (industryID) {
                return $http.get('/Report/getStdAccountByIndustry/' + industryID, apiConfig.createVat());
            },
            getTemplateReferences: function (period) {
                return $http.get('/Report/templateReferences/' + period, apiConfig.createVat());
            },
            citTryGenerateDocList: function (projectId, serviceType, generator) {
                return $http.post('/Report/citTryGenerateDocList/' + projectId + '/' + serviceType + '?generator=' + generator, {}, apiConfig.createVat());
            },
            citUpdateConfig: function (projectId, ifDeleteManualDataSource, period, generator) {
                if (!_.isNumber(period)) {
                    period = 0;
                }

                return $http.post('/Report/citUpdateConfig/' + projectId + '/' + ifDeleteManualDataSource + '/' + period + '?generator=' + generator, {}, apiConfig.createVat({ignoreLoadingBar: true}));
            },
            citGeneratePrepay: function (projectId, ifDeleteManualDataSource, period, generator) {
                return $http.post('/Report/citGenerate/byTotal/' + projectId + '/' + ifDeleteManualDataSource + '/' + 0
                    // 暂时将生成预缴表的period设置为0,等待完成新的预缴表生成逻辑 + period
                    + '/' + enums.reportType.prepay
162
                    + '?generator=' + generator, {}, apiConfig.createVat({ignoreLoadingBar: true}));
163 164 165 166 167 168 169
            },
            citGenerateByType: function (projectId, ifDeleteManualDataSource, reportType, generator) {
                var paramStr = '';
                if (_.isNumber(reportType)) {
                    paramStr = '/' + reportType;
                }

170
                return $http.post('/Report/citGenerate/byTotal/' + projectId + '/' + ifDeleteManualDataSource + '/0' + paramStr + '?generator=' + generator, {}, apiConfig.createVat({ignoreLoadingBar: true}));
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
            },
            citGetTemplate: function (projectId, period) {
                if (!_.isNumber(period)) {
                    period = 0;
                }

                return $http.get('/Report/citTemplate/' + projectId + '/' + period, apiConfig.createVat());
            },
            citGetTemplateTree: function (projectId) {
                return $http.get('/Report/citTemplateTree/' + projectId, apiConfig.createVat());
            },
            vatGetTemplateTree: function (projectId, period, serviceType) {
                return $http.get('/Report/vatTemplateTree/' + projectId + '/' + period + '/' + serviceType, apiConfig.createVat());
            },
            citCalculateKeyValue: function (projectId, reportType) {
                var reportTypeParam = '';
                if (_.isNumber(reportType)) {
                    reportTypeParam = '/' + reportType;
                }

191
                return $http.post('/Report/citCalculateKeyValue/' + projectId + '/0' + reportTypeParam, {}, apiConfig.createVat({ignoreLoadingBar: true}));
192 193 194 195 196 197 198 199 200 201 202 203
            },
            getReportByTemplateId: function (templateId, period) {
                if (!_.isNumber(period)) {
                    period = 0;
                }
                return $http.get('/Report/report/' + templateId + '/' + period, apiConfig.createVat());

            },
            getDataSourceDetailList: function (dataSourceId) {
                return $http.get('/Report/getDataSourceDetailList/' + dataSourceId, apiConfig.createVat());
            },
            hasManualDataSource: function (projectId, period) {
204 205 206 207 208 209 210 211 212 213
                return $http.get('/Report/hasManualDataSource/' + projectId + '/' + period, apiConfig.createVat());
            },
            loadAttachList: function (activeSheet) {
                return $http.post('/Report/loadAttachList', activeSheet, apiConfig.createVat());
            },
            deleteAttach: function (id) {
                var config = {isBusyRequest: true};
                return $http.get('/Report/deleteAttach?id=' + id, apiConfig.create(config));
            },

214 215 216 217 218 219 220
            /**
             生成固定资产及EAM对应的数据
             */
            generateAssetEamMapping : function(citAssetsListDto){
                debugger;
                return $http.post('/citReport/generateAssetEamMapping', citAssetsListDto, apiConfig.create());
            },
221 222 223 224 225
            /**
             获取固定资产及EAM对应的数据
             */
            getAssetEamMappings : function(citAssetsListDto){
                return $http.post('/citReport/getAssetEamMappingsPage', citAssetsListDto, apiConfig.create());
226
            },
227 228 229 230 231 232 233
            /**
             * 导出固定资产及EAM对应的数据
             * @param citAssetsListDto
             * @returns {HttpPromise}
             */
            initExportAEMData: function (citAssetsListDto) {
                return $http.post('/citReport/exportAEMData', citAssetsListDto, apiConfig.create({ responseType: 'arraybuffer' }));
234
            },
zhkwei's avatar
zhkwei committed
235 236 237 238 239 240 241 242 243
            /**
             获取所得税分配表的数据
             */
            getDistributionTables : function(citAssetsListDto){
                return $http.post('/citReport/getDistributionTables', citAssetsListDto, apiConfig.create());
            },
            /**
             生成所得税分配表的
             */
zhkwei's avatar
zhkwei committed
244 245 246 247 248 249 250 251 252 253 254
            generateDistributionTable : function(citAssetsListDto){
                debugger;
                return $http.post('/citReport/generateDistributionTable', citAssetsListDto, apiConfig.create());
            },
            /**
             * 导出生成所得税分配表
             * @param citAssetsListDto
             * @returns {HttpPromise}
             */
            initExportDTData: function (citAssetsListDto) {
                return $http.post('/citReport/exportDTData', citAssetsListDto, apiConfig.create({ responseType: 'arraybuffer' }));
zhkwei's avatar
zhkwei committed
255
            },
256 257 258
        };

    }]);