zs 4 months ago
parent
commit
0cfc193af4

+ 0 - 0
src/controller/platform/investigate.controller.ts


+ 0 - 0
src/entity/platform/investigate.entity.ts


+ 2 - 0
src/entity/platform/match.entity.ts

@@ -51,4 +51,6 @@ export class Match extends BaseModel {
   order_num: number;
   @Column({ type: 'character varying', nullable: true, comment: '状态', default: '0' })
   status: string;
+  @Column({ type: 'jsonb', nullable: true, comment: '调查问卷', default: [] })
+  investigate: Array<any>;
 }

+ 0 - 0
src/interface/platform/investigate.interface.ts


+ 5 - 0
src/interface/platform/match.interface.ts

@@ -56,6 +56,8 @@ export class FVO_match {
   'order_num': number = undefined;
   @ApiProperty({ description: '状态' })
   'status': string = undefined;
+  @ApiProperty({ description: '调查问卷' })
+  'investigate': Array<any> = undefined;
 }
 
 export class QDTO_match extends SearchBase {
@@ -173,6 +175,9 @@ export class CDTO_match {
   @ApiProperty({ description: '状态' })
   @Rule(RuleType['string']().empty(''))
   'status': string = undefined;
+  @ApiProperty({ description: '调查问卷' })
+  @Rule(RuleType['array']().empty(''))
+  'investigate': Array<any> = undefined;
 }
 
 export class CVO_match extends FVO_match {

+ 8 - 1
src/public/importMapping.ts

@@ -118,4 +118,11 @@ const companyYear = [
   { index: 7, field: 'essearch_money', zh: '预计研发费用(万元)', type: 'number' },
   { index: 8, field: 'tags', zh: '标签' },
 ];
-export { achievement, project, demand, supply, company, companyYear };
+
+// incubate
+const incubate = [
+  { index: 1, field: 'name', zh: '孵化基地名称' },
+  { index: 2, field: 'unit', zh: '运营机构' },
+];
+
+export { achievement, project, demand, supply, company, companyYear, incubate };

+ 0 - 0
src/service/platform/investigate.service.ts


+ 34 - 1
src/service/util.service.ts

@@ -1134,7 +1134,7 @@ export class UtilService {
         }
       } else {
         try {
-          await this.companyModel.insert({ ...i, status: '1', is_show: '1' });
+          await this.companyModel.insert({ ...i, status: '1', is_show: '0' });
         } catch (error) {
           const namek = Object.keys(error.errors)[0];
           const mapping = mappingList.find(i => i.field === namek);
@@ -1179,6 +1179,38 @@ export class UtilService {
     }
     return { result: result.length, errorList };
   }
+
+  /**
+   * 孵化基地
+   * @param {Object} rows excel数据
+   */
+  async incubate(rows) {
+    const mappingList = mappings.incubate;
+    const result = await this.dealRows(rows, mappingList);
+    const errorList = [];
+    // 需要查看是否有人,有人更新数据,没人添加数据
+    for (const [index, i] of result.entries()) {
+      const { name } = i;
+      const data = await this.incubatorModel.findOne({ where: { name: Equal(name) } });
+      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 {
+          await this.incubatorModel.insert({ ...i, status: '1', is_show: '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数据,二维数组
@@ -1286,6 +1318,7 @@ export class UtilService {
       供给: 'supply',
       企业: 'company',
       企业年度: 'companyYear',
+      孵化基地: 'incubate',
     };
     return get(obj, name);
   }