Bladeren bron

修改孵化基地

zs 8 maanden geleden
bovenliggende
commit
dbdba4785a

+ 27 - 0
src/controller/users/incubator.controller.ts

@@ -31,6 +31,33 @@ export class IncubatorController implements BaseController {
     return result;
   }
 
+  @Get('/list')
+  @ApiTags('列表查询')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_incubator })
+  async list(@Query() query: object) {
+    const result = await this.service.list(query);
+    return result;
+  }
+
+  @Get('/allList')
+  @ApiTags('列表查询')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_incubator })
+  async allList(@Query() query: object) {
+    const result = await this.service.allList(query);
+    return result;
+  }
+
+  @Get('/statistics')
+  @ApiTags('列表查询')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_incubator })
+  async statistics(@Query() query: object) {
+    const result = await this.service.statistics(query);
+    return result;
+  }
+
   @Get('/:id')
   @ApiTags('单查询')
   @ApiResponse({ type: FVO_incubator })

+ 2 - 0
src/entity/users/incubator.entity.ts

@@ -9,6 +9,8 @@ export class Incubator extends BaseModel {
   tags: Array<any>;
   @Column({ type: 'jsonb', nullable: true, comment: 'logo', default: [] })
   logo: Array<any>;
+  @Column({ type: 'jsonb', nullable: true, comment: '基地风采', default: [] })
+  file: Array<any>;
   @Column({ type: 'character varying', nullable: true, comment: '名称' })
   name: string;
   @Column({ type: 'character varying', nullable: true, comment: '负责人姓名' })

+ 7 - 0
src/interface/users/incubator.interface.ts

@@ -15,6 +15,8 @@ export class FVO_incubator {
   'name': string = undefined;
   @ApiProperty({ description: 'logo' })
   'logo': Array<any> = undefined;
+  @ApiProperty({ description: '基地风采' })
+  'flie': Array<any> = undefined;
   @ApiProperty({ description: '负责人姓名' })
   'person': string = undefined;
   @ApiProperty({ description: '负责人电话' })
@@ -80,6 +82,8 @@ export class QDTO_incubator {
   'name': string = undefined;
   @ApiProperty({ description: 'logo' })
   'logo': Array<any> = undefined;
+  @ApiProperty({ description: '基地风采' })
+  'flie': Array<any> = undefined;
   @ApiProperty({ description: '负责人电话' })
   'person_phone': string = undefined;
 
@@ -148,6 +152,9 @@ export class CDTO_incubator {
   @ApiProperty({ description: 'logo' })
   @Rule(RuleType['array']().empty(''))
   'logo': Array<any> = undefined;
+  @ApiProperty({ description: '基地风采' })
+  @Rule(RuleType['array']().empty(''))
+  'file': Array<any> = undefined;
   @ApiProperty({ description: '负责人姓名' })
   @Rule(RuleType['string']().empty(''))
   'person': string = undefined;

+ 11 - 1
src/public/importMapping.ts

@@ -103,4 +103,14 @@ const company = [
   { index: 25, field: 'brief', zh: '简介' },
 ];
 
-export { achievement, project, demand, supply, company };
+// companyYear
+const companyYear = [
+  { index: 1, field: 'company', zh: '名称', type: 'id' },
+  { index: 2, field: 'year', zh: '年度' },
+  { index: 3, field: 'time', zh: '填报时间' },
+  { index: 4, field: 'esincome_money', zh: '预计营业收入(万元)', type: 'number' },
+  { index: 5, field: 'esprofit_money', zh: '预计利润(万元)', type: 'number' },
+  { index: 6, field: 'estax_money', zh: '预计税金(万元)', type: 'number' },
+  { index: 7, field: 'essearch_money', zh: '预计研发费用(万元)', type: 'number' },
+];
+export { achievement, project, demand, supply, company, companyYear };

+ 7 - 1
src/service/users/cirelation.service.ts

@@ -36,7 +36,13 @@ export class CirelationService extends BaseServiceV2 {
     const { company, incubator } = data;
     // 企业名称
     const companyInfo = await this.companyService.fetch({ id: company });
-    if (companyInfo) data = { ...data, company_name: get(companyInfo, 'name') };
+    if (companyInfo)
+      data = {
+        ...data,
+        company_name: get(companyInfo, 'name'),
+        company_person: get(companyInfo, 'person'),
+        company_industry: get(companyInfo, 'industry'),
+      };
     // 孵化器名称
     const incubatorInfo = await this.incubatorService.fetch({ id: incubator });
     if (incubatorInfo) data = { ...data, incubator_name: get(incubatorInfo, 'name') };

+ 1 - 0
src/service/users/company.service.ts

@@ -15,6 +15,7 @@ export class CompanyService extends BaseServiceV2 {
 
   getQueryColumnsOpera() {
     const obj = {
+      id: this.Opera.In,
       name: this.Opera.Like,
       industry: this.Opera.In,
       pattern: this.Opera.In,

+ 102 - 2
src/service/users/incubator.service.ts

@@ -1,12 +1,26 @@
-import { Provide } from '@midwayjs/core';
+import { Provide, Inject } from '@midwayjs/core';
 import { InjectEntityModel } from '@midwayjs/typeorm';
-import { Repository } from 'typeorm';
+import { Repository, Equal } from 'typeorm';
 import { Incubator } from '../../entity/users/incubator.entity';
 import { BaseServiceV2 } from '../../frame/BaseServiceV2';
+import { get } from 'lodash';
+import { Cirelation } from '../../entity/users/cirelation.entity';
+import { CompanyService } from './company.service';
+import { CompanyYear } from '../../entity/users/companyYear.entity';
 @Provide()
 export class IncubatorService extends BaseServiceV2 {
   @InjectEntityModel(Incubator)
   model: Repository<Incubator>;
+
+  @InjectEntityModel(Cirelation)
+  cModel: Repository<Cirelation>;
+
+  @InjectEntityModel(CompanyYear)
+  cyModel: Repository<CompanyYear>;
+
+  @Inject()
+  companyService: CompanyService;
+
   getQueryColumnsOpera() {
     const obj = {
       name: this.Opera.Like,
@@ -16,4 +30,90 @@ export class IncubatorService extends BaseServiceV2 {
     };
     return obj;
   }
+  // 数据统计
+  async statistics(query) {
+    const info: any = {};
+    const { user, status } = query;
+    const result = await this.model.findOne({ where: { user: Equal(user), status: Equal(status) } });
+    if (result) {
+      // 查询关联企业信息统计总数
+      const companyList = await this.cModel.find({ where: { incubator: Equal(get(result, 'id')), status: Equal(status) } });
+      let person = 0;
+      let tech_num = 0;
+      let new_num = 0;
+      let tech_noum = 0;
+      let new_noum = 0;
+      for (const val of companyList) {
+        const company = await this.companyService.fetch({ id: get(val, 'company') });
+        person = person + parseInt(company.person);
+        if (company.is_tech === '0') tech_num = tech_num + 1;
+        else tech_noum = tech_noum + 1;
+        if (company.is_new === '0') new_num = new_num + 1;
+        else new_noum = new_noum + 1;
+      }
+      info.total_num = companyList.length;
+      info.person = person;
+      info.show = true;
+      info.tech_num = tech_num;
+      info.new_num = new_num;
+      info.tech_noum = tech_noum;
+      info.new_noum = new_noum;
+      // 查询孵化器信息
+      info.name = get(result, 'name');
+      info.id = get(result, 'id');
+      info.file = get(result, 'file');
+      const list = [
+        { num: '0', name: '是否是中试场地', value: 'is_have', type: '0' },
+        { num: 0, name: '运营单位人数', value: 'unit_num' },
+        { num: 0, name: '省级导师数', value: 'teacher_num' },
+        { num: 0, name: '活动人次数', value: 'activity_num' },
+        { num: 0, name: '活动企业数量', value: 'actCompany_num' },
+        { num: 0, name: '市级以上活动数', value: 'actCity_num' },
+        { num: 0, name: '投资机构活动数', value: 'actInstitution_num' },
+        { num: 0, name: '入驻企业数', value: 'company_num' },
+        { num: '0', name: '是否有合作', value: 'cooperate', type: '0' },
+      ];
+      for (const val of list) {
+        if (val.type === '0') {
+          if (get(result, val.value) === '0') val.num = '是';
+          else val.num = '否';
+        } else val.num = get(result, val.value) || 0;
+      }
+      info.list = list;
+    }
+    return info;
+  }
+
+  async allList(query) {
+    const { year, incubator, is_use, status } = query;
+    const builder = await this.cModel.createQueryBuilder('cirelation').select(['cirelation.company']).setFindOptions({ where: { incubator, status } });
+    const data = await builder.getMany();
+    const list1 = [];
+    const list2 = [];
+    const list3 = [];
+    const nameList = [];
+    for (const val of data) {
+      const companyYear = await this.cyModel.findOne({ where: { company: Equal(get(val, 'company')), year: Equal(year), status: Equal(status), is_use: Equal(is_use) } });
+      const company = await this.companyService.fetch({ id: get(val, 'company') });
+      if (company) {
+        nameList.push(get(company, 'name') || '');
+        list1.push(get(companyYear, 'esincome_money') || 0);
+        list2.push(get(companyYear, 'esprofit_money') || 0);
+        list3.push(get(companyYear, 'estax_money') || 0);
+      }
+    }
+    return { nameList, list: [list1, list2, list3] };
+  }
+  // 孵化器专属企业查询
+  async list(query) {
+    const { skip = 0, limit = 0, is_tech, is_new, ...info } = query;
+    const builder = await this.cModel
+      .createQueryBuilder('cirelation')
+      .select(['cirelation.company'])
+      .setFindOptions({ where: { incubator: get(info, 'incubator'), status: get(info, 'status') } });
+    const list = await builder.getMany();
+    const companyids = list.map(i => i.company);
+    const { data, total } = await this.companyService.query({ id: companyids, is_tech, is_new }, { skip, limit });
+    return { data, total };
+  }
 }

+ 47 - 0
src/service/util.service.ts

@@ -17,6 +17,7 @@ import * as Excel from 'exceljs';
 import * as Path from 'path';
 import * as fs from 'fs';
 import { User } from '../entity/system/user.entity';
+import { CompanyYear } from '../entity/users/companyYear.entity';
 /**
  * 工具类服务,为其他地方提供一些通用的函数
  */
@@ -39,6 +40,8 @@ export class UtilService {
   supplyModel: Repository<Supply>;
   @InjectEntityModel(Company)
   companyModel: Repository<Company>;
+  @InjectEntityModel(CompanyYear)
+  yModel: Repository<CompanyYear>;
   @Inject()
   dictDataService: DictDataService;
 
@@ -288,6 +291,41 @@ export class UtilService {
     }
     return { result: result.length, errorList };
   }
+
+  /**
+   * 企业年度
+   * @param {Object} rows excel数据
+   */
+  async companyYear(rows) {
+    const mappingList = mappings.companyYear;
+    const result = await this.dealRows(rows, mappingList);
+    const errorList = [];
+    // 需要查看是否有人,有人更新数据,没人添加数据
+    for (const [index, i] of result.entries()) {
+      const { company, year } = i;
+      const data = await this.yModel.findOne({ where: { company: Equal(company), year: Equal(year) } });
+      if (data && data.id) {
+        try {
+          i.id = data.id;
+          await this.yModel.update({ id: data.id }, i);
+        } catch (error) {
+          errorList.push(`修改第${index + 1}条${name}出现错误!!!`);
+        }
+      } else {
+        try {
+          const companyInfo = await this.companyModel.findOne({ where: { id: Equal(company) } });
+          const userInfo = await this.userService.fetch({ id: companyInfo.user });
+          const id = get(userInfo, 'id');
+          await this.yModel.insert({ ...i, user: id, status: '1', is_use: '0' });
+        } catch (error) {
+          const namek = Object.keys(error.errors)[0];
+          const mapping = mappingList.find(i => i.field === namek);
+          errorList.push(`第${index + 1}条${mapping.zh}列${name}字段出现错误!!!`);
+        }
+      }
+    }
+    return { result: result.length, errorList };
+  }
   /**
    * 处理excel传来的数据
    * @param {Array} rows excel数据,二维数组
@@ -364,6 +402,14 @@ export class UtilService {
       } else {
         if (val) result = parseInt(val) || 0;
       }
+    } else if (type === 'id') {
+      if (val) {
+        const company = await this.companyModel.findOne({ where: { name: Equal(val) } });
+        if (company) result = get(company, 'id');
+        else result = val;
+      } else {
+        result = val;
+      }
     }
     return result;
   }
@@ -375,6 +421,7 @@ export class UtilService {
       需求: 'demand',
       供给: 'supply',
       企业: 'company',
+      企业年度: 'companyYear',
     };
     return get(obj, name);
   }