lrf402788946 vor 4 Jahren
Ursprung
Commit
33972d78b9
3 geänderte Dateien mit 104 neuen und 79 gelöschten Zeilen
  1. 70 70
      app/model/product.js
  2. 1 1
      app/service/statistics/index.js
  3. 33 8
      app/service/util/util.js

+ 70 - 70
app/model/product.js

@@ -1,70 +1,70 @@
-'use strict';
-const Schema = require('mongoose').Schema;
-const moment = require('moment');
-const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
-// 产品图片表
-const images = new Schema({
-  url: { type: String, required: true, maxLength: 500 }, // 图片路径
-});
-// 专利信息
-const patents = new Schema({
-  patentinfo: { type: String, required: false, maxLength: 200 }, // 专利信息,
-  patentstatus: { type: String, required: false, maxLength: 200 }, // 专利状态,
-});
-// 产品表
-const product = {
-  name: { type: String, required: false, maxLength: 200 }, // 名称
-  contacts: { type: String, required: false, maxLength: 200 }, // 联系人
-  phone: { type: String, required: false, maxLength: 11 }, // 联系电话
-  qqwx: { type: String, required: false, maxLength: 200 }, // qq&微信
-  email: { type: String, required: false, maxLength: 200 }, // 邮箱
-  type: { type: String, required: false, maxLength: 200 }, // 类型: 0-科技需求;1-技术成果;2-商务服务
-  status: { type: String, required: false, maxLength: 200, default: '0' }, // 状态(0:草稿 1:审核中 2:审核通过 3:审核拒绝)
-  user_id: { type: String, required: false, maxLength: 500 }, // 创建人id
-  // 共同字段
-  field: { type: String, required: false, maxLength: 500 }, // 所属领域
-  cooperation: { type: String, required: false, maxLength: 500 }, // 合作方式
-  company: { type: String, required: false, maxLength: 500 }, // 企业名称
-  condition: { type: String, required: false, maxLength: 500 }, // 合作条件及要求
-  image: { type: [ images ] }, // 图片,产品图片都为此字段
-  expect: { type: String, required: false, maxLength: 500 }, // 预期, 所有的预期都合并为此字段
-  demand: { type: String, required: false, maxLength: 200 }, // 需求程度:技术的需求紧急程度和服务的需求程度改为此字段
-
-  // 技术需求字段
-  budget: { type: String, required: false, maxLength: 300 }, // 投资预算
-  requirementdesc: { type: String, required: false, maxLength: 500 }, // 需求说明
-  present: { type: String, required: false, maxLength: 500 }, // 需求现状
-
-  // 技术成果字段
-  achievestatus: { type: String, required: false, maxLength: 200 }, // 成果状态
-  achieveown: { type: String, required: false, maxLength: 200 }, // 成果权属
-  achievesource: { type: String, required: false, maxLength: 200 }, // 成果来源
-  intentionprice: { type: String, required: false, maxLength: 200 }, // 意向价格
-  patent: { type: [ patents ] },
-  roadshow: { type: String, required: false, maxLength: 200 }, // 项目路演
-  achievebrief: { type: String, required: false, maxLength: 500 }, // 成果简介
-  features: { type: String, required: false, maxLength: 500 }, // 技术特点
-  team: { type: String, required: false, maxLength: 500 }, // 技术团队
-
-  // 商务需求
-  messattribute: { type: String, required: false, maxLength: 200 }, // 信息属性
-  informationdesc: { type: String, required: false, maxLength: 500 }, // 信息描述
-  coreelements: { type: String, required: false, maxLength: 500 }, // 核心要素
-  priceinfo: { type: String, required: false, maxLength: 500 }, // 价格信息
-
-  remark: { type: String, maxLength: 200 },
-  create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
-};
-const schema = new Schema(product, { toJSON: { virtuals: true } });
-schema.index({ id: 1 });
-schema.index({ name: 1 });
-schema.index({ qqwx: 1 });
-schema.index({ type: 1 });
-schema.index({ status: 1 });
-schema.index({ company: 1 });
-schema.index({ 'meta.createdAt': 1 });
-schema.plugin(metaPlugin);
-module.exports = app => {
-  const { mongoose } = app;
-  return mongoose.model('Product', schema, 'product');
-};
+'use strict';
+const Schema = require('mongoose').Schema;
+const moment = require('moment');
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+// 产品图片表
+const images = new Schema({
+  url: { type: String, required: true, maxLength: 500 }, // 图片路径
+});
+// 专利信息
+const patents = new Schema({
+  patentinfo: { type: String, required: false, maxLength: 200 }, // 专利信息,
+  patentstatus: { type: String, required: false, maxLength: 200 }, // 专利状态,
+});
+// 产品表
+const product = {
+  name: { type: String, required: false, maxLength: 200 }, // 名称
+  contacts: { type: String, required: false, maxLength: 200 }, // 联系人
+  phone: { type: String, required: false }, // 联系电话
+  qqwx: { type: String, required: false, maxLength: 200 }, // qq&微信
+  email: { type: String, required: false, maxLength: 200 }, // 邮箱
+  type: { type: String, required: false, maxLength: 200 }, // 类型: 0-科技需求;1-技术成果;2-商务服务
+  status: { type: String, required: false, maxLength: 200, default: '0' }, // 状态(0:草稿 1:审核中 2:审核通过 3:审核拒绝)
+  user_id: { type: String, required: false, maxLength: 500 }, // 创建人id
+  // 共同字段
+  field: { type: String, required: false, maxLength: 500 }, // 所属领域
+  cooperation: { type: String, required: false, maxLength: 500 }, // 合作方式
+  company: { type: String, required: false, maxLength: 500 }, // 企业名称
+  condition: { type: String, required: false, maxLength: 500 }, // 合作条件及要求
+  image: { type: [ images ] }, // 图片,产品图片都为此字段
+  expect: { type: String, required: false, maxLength: 500 }, // 预期, 所有的预期都合并为此字段
+  demand: { type: String, required: false, maxLength: 200 }, // 需求程度:技术的需求紧急程度和服务的需求程度改为此字段
+
+  // 技术需求字段
+  budget: { type: String, required: false, maxLength: 300 }, // 投资预算
+  requirementdesc: { type: String, required: false, maxLength: 500 }, // 需求说明
+  present: { type: String, required: false, maxLength: 500 }, // 需求现状
+
+  // 技术成果字段
+  achievestatus: { type: String, required: false, maxLength: 200 }, // 成果状态
+  achieveown: { type: String, required: false, maxLength: 200 }, // 成果权属
+  achievesource: { type: String, required: false, maxLength: 200 }, // 成果来源
+  intentionprice: { type: String, required: false, maxLength: 200 }, // 意向价格
+  patent: { type: [ patents ] },
+  roadshow: { type: String, required: false, maxLength: 200 }, // 项目路演
+  achievebrief: { type: String, required: false, maxLength: 500 }, // 成果简介
+  features: { type: String, required: false, maxLength: 500 }, // 技术特点
+  team: { type: String, required: false, maxLength: 500 }, // 技术团队
+
+  // 商务需求
+  messattribute: { type: String, required: false, maxLength: 200 }, // 信息属性
+  informationdesc: { type: String, required: false, maxLength: 500 }, // 信息描述
+  coreelements: { type: String, required: false, maxLength: 500 }, // 核心要素
+  priceinfo: { type: String, required: false, maxLength: 500 }, // 价格信息
+
+  remark: { type: String, maxLength: 200 },
+  create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
+};
+const schema = new Schema(product, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ name: 1 });
+schema.index({ qqwx: 1 });
+schema.index({ type: 1 });
+schema.index({ status: 1 });
+schema.index({ company: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Product', schema, 'product');
+};

+ 1 - 1
app/service/statistics/index.js

@@ -19,7 +19,7 @@ class IndexService extends CrudService {
     this.organizationModel = this.ctx.model.Organization;
     this.surveyModel = this.ctx.model.Survey;
     this.dockUser = this.ctx.model.DockUser; // 没改
-    this.tranModel = this.ctx.model.Transaction;// 没改
+    this.tranModel = this.ctx.model.Dock.DockTranscation;// 没改
   }
   /**
    * 首页专利统计

+ 33 - 8
app/service/util/util.js

@@ -10,14 +10,39 @@ class UtilService extends CrudService {
     this.mq = this.ctx.mq;
   }
   async utilMethod(query, body) {
-    const path = 'C:\\Users\\liuruifeng\\Desktop\\temp\\organization.json';
-    let text = await fs.readFileSync(path, { encoding: 'utf-8' });
-    text = JSON.parse(text);
-    for (const i of text) {
-      i.passwd = _.cloneDeep(i.password);
-      delete i.password;
-    }
-    await fs.writeFileSync('C:\\Users\\liuruifeng\\Desktop\\temp\\no.json', JSON.stringify(text));
+    // let products = await this.ctx.model.Product.find();
+    // let personals = await this.ctx.model.Personal.find();
+    // let orgs = await this.ctx.model.Organization.find();
+    // if (_.isArray(products)) products = JSON.parse(JSON.stringify(products));
+    // if (_.isArray(personals)) personals = JSON.parse(JSON.stringify(personals));
+    // if (_.isArray(orgs)) orgs = JSON.parse(JSON.stringify(orgs));
+    // let count = 1;
+    // for (const product of products) {
+    //   const { phone, contacts, _id } = product;
+    //   console.log(`${count}:${product.name}:${phone}-${contacts}`);
+    //   let r = personals.find(f => _.isEqual(f.phone, phone) || _.isEqual(f.name, contacts));
+    //   if (r) {
+    //     product.user_id = r._id;
+    //   } else {
+    //     r = orgs.find(f => _.isEqual(f.phone, phone) || _.isEqual(f.name, contacts));
+    //     if (r) product.user_id = r._id;
+    //   }
+    //   if (r) {
+    //     console.log(`u:${r.phone}-${r.name}:${product.user_id}-${r._id}`);
+    //   } else {
+    //     console.log(`${product.name} 没找到用户`);
+    //   }
+    //   count++;
+    //   await this.ctx.model.Product.updateOne({ _id: ObjectId(_id) }, product);
+    // }
+    // const path = 'C:\\Users\\liuruifeng\\Desktop\\temp\\organization.json';
+    // let text = await fs.readFileSync(path, { encoding: 'utf-8' });
+    // text = JSON.parse(text);
+    // for (const i of text) {
+    //   i.passwd = _.cloneDeep(i.password);
+    //   delete i.password;
+    // }
+    // await fs.writeFileSync('C:\\Users\\liuruifeng\\Desktop\\temp\\no.json', JSON.stringify(text));
 
 
     // const path = 'C:\\Users\\liuruifeng\\Desktop\\temp\\expert.json';