Prechádzať zdrojové kódy

统计整的半拉科技的

于添 6 mesiacov pred
rodič
commit
7c2c7cb9a8

+ 146 - 14
src/api/statisticalAnalysis/statisticalAnalysisResourceLibrary.js

@@ -365,9 +365,48 @@ export const getVisibilityData = async(params = {}) => {
 	// 		resolve(mockData.visibilityData)
 	// 	}, Mock.mock('@integer(200, 500)'))
 	// })
-	let collegeStatistic = await request('resourceStatistic/collegeStatistic', params, 'get')
+	let resourcePublicStatistic = await request('resourceStatistic/resourcePublicStatistic', params, 'get')
+	let visibility = ['非公开','公开']
+	let visibilityCounts = []
+	ForEach(resourcePublicStatistic, (item) => {
+		visibilityCounts.push(item.num)
+	})
+	let hotness = []
+	let hotnessCounts = []
+	let recommended = ['已推荐', '未推荐']
+
+	let hotStatistic = await request('resourceStatistic/hotStatistic', params, 'get')
+	ForEach(hotStatistic, (item) => {
+		//1推荐  2热门  3推荐和热门
+		if(item.type == 1){
+			hotness.push('推荐')
+		}
+		if(item.type == 2){
+			hotness.push('热门')
+		}
+		if(item.type == 3){
+			hotness.push('推荐和热门')
+		}
+		hotnessCounts.push(item.num)
+	})
+
 
+	console.log('接口看看',hotStatistic)
+	let recommendedCounts = [12,13]
 
+
+	let json = {
+		code: 200,
+		data : {
+			visibility,
+			visibilityCounts,
+			hotness,
+			hotnessCounts,
+			recommended,
+			recommendedCounts
+		}
+	}
+	return json
 	// data: {
 	// 	visibility: ['公开', '非公开'],
 	// 		visibilityCounts: [
@@ -392,24 +431,117 @@ export const getVisibilityData = async(params = {}) => {
 	// return request('/resource-library/visibility-analysis', params, 'get')
 }
 
-export const getFormatData = (params = {}) => {
-	return new Promise((resolve) => {
-		setTimeout(() => {
-			const mockData = generateMockData(params)
-			resolve(mockData.formatData)
-		}, Mock.mock('@integer(200, 500)'))
+export const getFormatData = async(params = {}) => {
+	// return new Promise((resolve) => {
+	// 	setTimeout(() => {
+	// 		const mockData = generateMockData(params)
+	// 		resolve(mockData.formatData)
+	// 	}, Mock.mock('@integer(200, 500)'))
+	// })
+	let formatStatistic = await request('resourceStatistic/formatStatistic', params, 'get')
+	let formats = []
+	let formatCounts = []
+	ForEach(formatStatistic, (item) => {
+		formats.push(item.extendName)
+		formatCounts.push(item.num)
 	})
+	let storageStatistic = await request('resourceStatistic/storageStatistic', params, 'get')
+	console.log('内存',storageStatistic)
+	let formatAvgSize = []
+	ForEach(storageStatistic, (item) => {
+		formatAvgSize.push(item.extendName)
+	})
+
+	let json = {
+		code: 200,
+		data : {
+			formats,
+			formatCounts,
+			formatStorage: storageStatistic.map((item) => {
+					let size = (item.FILESIZE) * parseFloat(1).toFixed(2)
+					console.log("asdasd",item.FILESIZE)
+					return `${(item.FILESIZE/1000/1000).toFixed(2)}`
+			}
+			),
+			formatAvgSize: storageStatistic.map((format, index) => {
+			// 根据文件类型设置合理的平均大小
+			const size = format.avgSize
+			// if (size > 1000) return `${(size / 1000).toFixed(1)}MB`
+			return `${(size/1000/1000).toFixed(2)}MB`
+		})
+		}
+	}
+	return json
+
+	// formatData: {
+	// 	code: 200,
+	// 		data: {
+	// 		formats: formats,
+	// 			formatCounts: formatCounts,
+	// 			formatStorage: formatCounts.map((count) =>
+	// 			((count / adjustedTotalResources) * parseFloat(adjustedUsedStorage)).toFixed(2)
+	// 		),
+	// 			formatAvgSize: formats.map((format, index) => {
+	// 			// 根据文件类型设置合理的平均大小
+	// 			const sizeMap = {
+	// 				mp4: Mock.mock('@integer(200, 800)'),
+	// 				avi: Mock.mock('@integer(300, 1000)'),
+	// 				wmv: Mock.mock('@integer(150, 600)'),
+	// 				mkv: Mock.mock('@integer(400, 1200)'),
+	// 				pdf: Mock.mock('@integer(5, 50)'),
+	// 				docx: Mock.mock('@integer(2, 20)'),
+	// 				pptx: Mock.mock('@integer(10, 100)'),
+	// 				xlsx: Mock.mock('@integer(1, 15)'),
+	// 				jpg: Mock.mock('@integer(1, 10)'),
+	// 				other: Mock.mock('@integer(5, 200)')
+	// 			}
+	//
+	// 			const size = sizeMap[format] || Mock.mock('@integer(1, 100)')
+	// 			if (size > 1000) return `${(size / 1000).toFixed(1)}GB`
+	// 			return `${size}MB`
+	// 		})
+	// 	}
+	// },
+
+
+
 	// return request('/resource-library/format-distribution', params, 'get')
 }
 
-export const getEngagementData = (params = {}) => {
-	return new Promise((resolve) => {
-		setTimeout(() => {
-			const mockData = generateMockData(params)
-			resolve(mockData.engagementData)
-		}, Mock.mock('@integer(200, 500)'))
-	})
+export const getEngagementData = async(params = {}) => {
+	// return new Promise((resolve) => {
+	// 	setTimeout(() => {
+	// 		const mockData = generateMockData(params)
+	// 		resolve(mockData.engagementData)
+	// 	}, Mock.mock('@integer(200, 500)'))
+	// })
+	let totalStatistic = await request('resourceStatistic/totalStatistic', params, 'get')
+	console.log('001 ',totalStatistic)
+	let json = {
+		code: 200,
+		data : {
+			engagement: ['观看', '收藏', '分享'],
+						engagementCounts: [
+							//船锚
+					],
+		}
+	}
+	return json
 	// return request('/resource-library/engagement-analysis', params, 'get')
+	// 用户参与度数据
+	// engagementData: {
+	// 	code: 200,
+	// 		data: {
+	// 		engagement: ['观看', '收藏', '分享'],
+	// 			engagementCounts: [
+	// 			adjustedViews,
+	// 			adjustedFavorites,
+	// 			Math.floor(adjustedFavorites * 0.3) // 分享数约为收藏数的30%
+	// 		],
+	// 			typeViewCounts: typeCounts.map((count) => Math.floor(count * (2 + Math.random() * 3))) // 每个资源平均2-5次观看
+	// 	}
+	// },
+
 }
 
 export const getTrendData = (params = {}) => {

+ 3 - 3
src/views/statisticalAnalysis/statisticalAnalysisResourceLibrary/index.vue

@@ -437,14 +437,14 @@
 					},
 					angleAxis: {
 						type: 'category',
-						data: ['热门资源', '推荐资源', '热门且推荐']
+						data: chartData.value.hotness
 					},
 					radiusAxis: {},
 					polar: {},
 					series: [
 						{
 							type: 'bar',
-							data: [chartData.value.hotnessCounts[0], chartData.value.recommendedCounts[0], 89],
+							data: chartData.value.hotnessCounts,
 							coordinateSystem: 'polar',
 							name: '资源数量',
 							itemStyle: {
@@ -515,7 +515,7 @@
 						trigger: 'item',
 						formatter: function (params) {
 							const index = params.dataIndex
-							return `${params.name}: ${params.value} TB<br/>文件数量: ${chartData.value.formatCounts[index]}<br/>平均大小: ${chartData.value.formatAvgSize[index]}`
+							return `${params.name}: ${params.value} MB<br/>文件数量: ${chartData.value.formatCounts[index]}<br/>平均大小: ${chartData.value.formatAvgSize[index]}`
 						}
 					},
 					legend: {