|
@@ -6,9 +6,12 @@ import { Achievement } from '../../entity/platform/achievement.entity';
|
|
|
import { Demand } from '../../entity/platform/demand.entity';
|
|
|
import { Expert } from '../../entity/users/expert.entity';
|
|
|
import * as Excel from 'exceljs';
|
|
|
+import * as path from 'path';
|
|
|
// 2024-06-11 导入
|
|
|
@Provide()
|
|
|
export class initOneService {
|
|
|
+ // 本次导入公共标签
|
|
|
+ tags = ['240611'];
|
|
|
@InjectEntityModel(Demand)
|
|
|
demandModel: Repository<Demand>;
|
|
|
@InjectEntityModel(Achievement)
|
|
@@ -17,14 +20,26 @@ export class initOneService {
|
|
|
expertModel: Repository<Expert>;
|
|
|
async initData() {
|
|
|
console.log('in initData');
|
|
|
- await this.importRequirementFromExcel();
|
|
|
+ // await this.importRequirementFromExcel();
|
|
|
// await this.importAchieveFromExcel();
|
|
|
// await this.importExpertFromExcel();
|
|
|
}
|
|
|
+
|
|
|
+ async addImportDataTags() {
|
|
|
+ // 查询achievementModel和expertModel的所有数据,并为其添加标签
|
|
|
+ const achieveTags: any = [...this.tags, '成果'];
|
|
|
+ const expertTags: any = [...this.tags, '专家'];
|
|
|
+ await this.achievementModel.update({}, { tags: achieveTags });
|
|
|
+ await this.expertModel.update({}, { tags: expertTags });
|
|
|
+ // 查询demandModel 2024-06-10 至 2024-06-12 (其实就是2024-06-11)的数据,添加标签,之后24号的数据在initTwo中添加
|
|
|
+ const demandTags: any = [...this.tags, '需求'];
|
|
|
+ const list = await this.demandModel.createQueryBuilder().update().set({ tags: demandTags }).where('created_time BETWEEN :start AND :end', { start: '2024-06-10', end: '2024-06-12' }).execute();
|
|
|
+ console.log(list);
|
|
|
+ }
|
|
|
async importRequirementFromExcel() {
|
|
|
- const path = 'C:/document/需求库.xlsx';
|
|
|
+ const p = path.resolve(__dirname, '../../../importData/20240611', '需求库.xlsx');
|
|
|
const wb = new Excel.Workbook();
|
|
|
- await wb.xlsx.readFile(path);
|
|
|
+ await wb.xlsx.readFile(p);
|
|
|
const sheet = wb.getWorksheet(1);
|
|
|
const meta = this.requirementMeta();
|
|
|
const allData = [];
|
|
@@ -170,9 +185,9 @@ export class initOneService {
|
|
|
}
|
|
|
|
|
|
async importAchieveFromExcel() {
|
|
|
- const path = 'C:/document/成果库.xlsx';
|
|
|
+ const p = path.resolve(__dirname, '../../../importData/20240611', '成果库.xlsx');
|
|
|
const wb = new Excel.Workbook();
|
|
|
- await wb.xlsx.readFile(path);
|
|
|
+ await wb.xlsx.readFile(p);
|
|
|
const sheet = wb.getWorksheet(1);
|
|
|
const meta = this.achieveMeta();
|
|
|
const allData = [];
|
|
@@ -203,9 +218,9 @@ export class initOneService {
|
|
|
}
|
|
|
|
|
|
async importExpertFromExcel() {
|
|
|
- const path = 'C:/document/专家库.xlsx';
|
|
|
+ const p = path.resolve(__dirname, '../../../importData/20240611', '专家库.xlsx');
|
|
|
const wb = new Excel.Workbook();
|
|
|
- await wb.xlsx.readFile(path);
|
|
|
+ await wb.xlsx.readFile(p);
|
|
|
const sheet = wb.getWorksheet(1);
|
|
|
const rows = sheet.getRows(3, 200);
|
|
|
const meta = this.exportsMeta();
|