lrf402788946 4 years ago
parent
commit
313a4e11eb
7 changed files with 1596 additions and 1605 deletions
  1. 303 303
      app/model/car.js
  2. 804 782
      app/service/order/order.js
  3. 10 7
      app/service/order/transport.js
  4. 342 341
      app/service/util/util.js
  5. 82 82
      config/config.default.js
  6. 0 24
      config/config.local.js
  7. 55 66
      package.json

+ 303 - 303
app/model/car.js

@@ -1,303 +1,303 @@
-'use strict';
-const Schema = require('mongoose').Schema;
-const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
-// 车辆表
-const car = {
-  onwer: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: { label: '机动车所有人', filter: true, required: true },
-    row: 1,
-  }, // 机动车所有人
-  car_no: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: { label: '机动车登记编号', required: true, notable: true },
-    row: 2,
-  }, // 机动车登记编号
-  id_number: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: { label: '身份证明代码', required: true },
-    row: 3,
-  }, // 身份证明代码
-  id_name: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: { label: '身份证名称', required: true, notable: true },
-    row: 4,
-  }, // 身份证明名称
-  organ: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: { label: '登记机关', required: true, notable: true },
-    row: 5,
-  }, // 登记机关
-  r_date: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: { label: '登记日期', required: true, notable: true, type: 'date' },
-    row: 6,
-  }, // 登记日期
-  c_type: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: { label: '机动车类别', required: true, notable: true },
-    row: 7,
-  }, // 机动车类别
-  c_doc_no: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: { label: '机动车档案编号', required: true, notable: true },
-    row: 8,
-  }, // 机动车档案编号
-  c_weight: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: { label: '机动车整备质量(自重)', required: true, notable: true },
-    row: 9,
-  }, // 机动车整备质量(自重)
-  c_scrap_date: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: {
-      label: '机动车强制报废日期',
-      required: true,
-      notable: true,
-      type: 'date',
-    },
-    row: 10,
-  }, // 机动车强制报废日期
-  c_examine_date: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: {
-      label: '机动车检验有效期',
-      required: true,
-      notable: true,
-      type: 'date',
-    },
-    row: 11,
-  }, // 机动车检验有效期
-  r_tran_no: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: { label: '道路运输证编号', required: true, notable: true },
-    row: 12,
-  }, // 道路运输证编号
-  r_examine_date: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: {
-      label: '道路检验有效期',
-      required: true,
-      notable: true,
-      type: 'date',
-    },
-    row: 13,
-  }, // 道路检验有效期
-  buy_car_taxes_no: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: { label: '车辆购置税完税证明编号', required: true, notable: true },
-    row: 14,
-  }, // 车辆购置税完税证明编号
-  f_company: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: { label: '强制险责任公司', required: true, notable: true },
-    row: 15,
-  }, // 强制险责任公司
-  f_tel: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: { label: '强制险责任公司服务电话', required: true, notable: true },
-    row: 16,
-  }, // 强制险责任公司服务电话
-  f_no: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: { label: '强制险保险单号', required: true, notable: true },
-    row: 17,
-  }, // 强制险保险单号
-  f_cost: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: { label: '强制险费用合计', required: true, notable: true },
-    row: 18,
-  }, // 强制险费用合计
-  f_start_date: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: {
-      label: '强制险起始时间',
-      type: 'date',
-      required: true,
-      notable: true,
-    },
-    row: 19,
-  }, // 强制险起始时间
-  f_end_date: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: {
-      label: '强制险截止时间',
-      type: 'date',
-      required: true,
-      notable: true,
-    },
-    row: 20,
-  }, // 强制险截止时间
-  f_solve: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: { label: '强制险合同争议解决方式', required: true, notable: true },
-    row: 21,
-  }, // 强制险合同争议解决方式
-  f_car_taxes: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: { label: '强制险代收车船使用税', required: true, notable: true },
-    row: 22,
-  }, // 强制险代收车船使用税
-  f_sign_date: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: {
-      label: '强制险签单日期',
-      type: 'date',
-      required: true,
-      notable: true,
-    },
-    row: 23,
-  }, // 强制险签单日期
-  b_company: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: { label: '商业险责任公司名称', required: true, notable: true },
-    row: 24,
-  }, // 商业险责任公司名称
-  b_tel: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: { label: '商业险责任公司电话', required: true, notable: true },
-    row: 25,
-  }, // 商业险责任公司电话
-  b_no: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: { label: '商业险保险单号', required: true, notable: true },
-    row: 26,
-  }, // 商业险保险单号
-  b_cost: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: { label: '商业险费用合计', required: true, notable: true },
-    row: 27,
-  }, // 商业险费用合计
-  b_start_date: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: {
-      label: '商业险起始日期',
-      required: true,
-      notable: true,
-      type: 'date',
-    },
-    row: 28,
-  }, // 商业险起始日期
-  b_end_date: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: {
-      label: '商业险截止日期',
-      required: true,
-      notable: true,
-      type: 'date',
-    },
-    row: 29,
-  }, // 商业险截止日期
-  b_solve: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: { label: '商业险合同争议解决方式', required: true, notable: true },
-    row: 30,
-  }, // 商业险合同争议解决方式
-  b_sign_date: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: {
-      label: '商业险签约日期',
-      required: true,
-      notable: true,
-      type: 'date',
-    },
-    row: 31,
-  }, // 商业险签约日期
-  remark: {
-    type: String,
-    required: false,
-    maxLength: 200,
-    field: {
-      label: '备注',
-      type: 'textarea',
-      options: { autosize: { minRows: 3, maxRows: 5 } },
-    },
-    row: 32,
-  }, // 备注
-  status: {
-    type: String,
-    maxLength: 200,
-    default: '0',
-    field: {
-      label: '状态',
-      filter: 'select',
-      type: 'radio',
-      format: (i => (i === '0' ? '使用' : '禁用')).toString(),
-      list: [
-        { label: '使用', value: '0' },
-        { label: '禁用', value: '1' },
-      ],
-    },
-  }, // 状态:0=>使用;1禁用
-};
-
-const schema = new Schema(car, { toJSON: { virtuals: true } });
-schema.index({ id: 1 });
-schema.plugin(metaPlugin);
-
-module.exports = app => {
-  const { mongoose } = app;
-  return mongoose.model('Car', schema, 'car');
-};
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+// 车辆表
+const car = {
+  onwer: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '机动车所有人', filter: true, required: true },
+    row: 1,
+  }, // 机动车所有人
+  car_no: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '机动车登记编号', required: true },
+    row: 2,
+  }, // 机动车登记编号
+  id_number: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '身份证明代码', required: true },
+    row: 3,
+  }, // 身份证明代码
+  id_name: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '身份证名称', required: true, notable: true },
+    row: 4,
+  }, // 身份证明名称
+  organ: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '登记机关', required: true, notable: true },
+    row: 5,
+  }, // 登记机关
+  r_date: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '登记日期', required: true, notable: true, type: 'date' },
+    row: 6,
+  }, // 登记日期
+  c_type: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '机动车类别', required: true, notable: true },
+    row: 7,
+  }, // 机动车类别
+  c_doc_no: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '机动车档案编号', required: true, notable: true },
+    row: 8,
+  }, // 机动车档案编号
+  c_weight: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '机动车整备质量(自重)', required: true, notable: true },
+    row: 9,
+  }, // 机动车整备质量(自重)
+  c_scrap_date: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: {
+      label: '机动车强制报废日期',
+      required: true,
+      notable: true,
+      type: 'date',
+    },
+    row: 10,
+  }, // 机动车强制报废日期
+  c_examine_date: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: {
+      label: '机动车检验有效期',
+      required: true,
+      notable: true,
+      type: 'date',
+    },
+    row: 11,
+  }, // 机动车检验有效期
+  r_tran_no: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '道路运输证编号', required: true, notable: true },
+    row: 12,
+  }, // 道路运输证编号
+  r_examine_date: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: {
+      label: '道路检验有效期',
+      required: true,
+      notable: true,
+      type: 'date',
+    },
+    row: 13,
+  }, // 道路检验有效期
+  buy_car_taxes_no: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '车辆购置税完税证明编号', required: true, notable: true },
+    row: 14,
+  }, // 车辆购置税完税证明编号
+  f_company: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '强制险责任公司', required: true, notable: true },
+    row: 15,
+  }, // 强制险责任公司
+  f_tel: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '强制险责任公司服务电话', required: true, notable: true },
+    row: 16,
+  }, // 强制险责任公司服务电话
+  f_no: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '强制险保险单号', required: true, notable: true },
+    row: 17,
+  }, // 强制险保险单号
+  f_cost: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '强制险费用合计', required: true, notable: true },
+    row: 18,
+  }, // 强制险费用合计
+  f_start_date: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: {
+      label: '强制险起始时间',
+      type: 'date',
+      required: true,
+      notable: true,
+    },
+    row: 19,
+  }, // 强制险起始时间
+  f_end_date: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: {
+      label: '强制险截止时间',
+      type: 'date',
+      required: true,
+      notable: true,
+    },
+    row: 20,
+  }, // 强制险截止时间
+  f_solve: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '强制险合同争议解决方式', required: true, notable: true },
+    row: 21,
+  }, // 强制险合同争议解决方式
+  f_car_taxes: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '强制险代收车船使用税', required: true, notable: true },
+    row: 22,
+  }, // 强制险代收车船使用税
+  f_sign_date: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: {
+      label: '强制险签单日期',
+      type: 'date',
+      required: true,
+      notable: true,
+    },
+    row: 23,
+  }, // 强制险签单日期
+  b_company: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '商业险责任公司名称', required: true, notable: true },
+    row: 24,
+  }, // 商业险责任公司名称
+  b_tel: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '商业险责任公司电话', required: true, notable: true },
+    row: 25,
+  }, // 商业险责任公司电话
+  b_no: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '商业险保险单号', required: true, notable: true },
+    row: 26,
+  }, // 商业险保险单号
+  b_cost: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '商业险费用合计', required: true, notable: true },
+    row: 27,
+  }, // 商业险费用合计
+  b_start_date: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: {
+      label: '商业险起始日期',
+      required: true,
+      notable: true,
+      type: 'date',
+    },
+    row: 28,
+  }, // 商业险起始日期
+  b_end_date: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: {
+      label: '商业险截止日期',
+      required: true,
+      notable: true,
+      type: 'date',
+    },
+    row: 29,
+  }, // 商业险截止日期
+  b_solve: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '商业险合同争议解决方式', required: true, notable: true },
+    row: 30,
+  }, // 商业险合同争议解决方式
+  b_sign_date: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: {
+      label: '商业险签约日期',
+      required: true,
+      notable: true,
+      type: 'date',
+    },
+    row: 31,
+  }, // 商业险签约日期
+  remark: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: {
+      label: '备注',
+      type: 'textarea',
+      options: { autosize: { minRows: 3, maxRows: 5 } },
+    },
+    row: 32,
+  }, // 备注
+  status: {
+    type: String,
+    maxLength: 200,
+    default: '0',
+    field: {
+      label: '状态',
+      filter: 'select',
+      type: 'radio',
+      format: (i => (i === '0' ? '使用' : '禁用')).toString(),
+      list: [
+        { label: '使用', value: '0' },
+        { label: '禁用', value: '1' },
+      ],
+    },
+  }, // 状态:0=>使用;1禁用
+};
+
+const schema = new Schema(car, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.plugin(metaPlugin);
+
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Car', schema, 'car');
+};

File diff suppressed because it is too large
+ 804 - 782
app/service/order/order.js


+ 10 - 7
app/service/order/transport.js

@@ -90,15 +90,17 @@ class TransportService extends CrudService {
       'send_time@end': end,
       'send_time@end': end,
       'supplier.car_no': car_no,
       'supplier.car_no': car_no,
     };
     };
-    let tList = await this.query(query);
+    const tquery = this.util.turnFilter(this.util.turnDateRangeQuery(query));
+    let tList = await this.query(tquery);
     if (tList.length > 0) tList = JSON.parse(JSON.stringify(tList));
     if (tList.length > 0) tList = JSON.parse(JSON.stringify(tList));
     const res = {
     const res = {
       inBill: await this.getInBill(tList),
       inBill: await this.getInBill(tList),
       outBill: this.getOutBill(tList),
       outBill: this.getOutBill(tList),
     };
     };
     // 日常维护部分
     // 日常维护部分
-    query = { 'date@start': start, 'date@end': end };
-    const daily = await this.ctx.service.car.daily.query({ car_no, ...query });
+    let dquery = { 'date@start': start, 'date@end': end, car_no };
+    dquery = this.util.turnFilter(this.util.turnDateRangeQuery(dquery));
+    const daily = await this.ctx.service.car.daily.query(dquery);
     res.daily = daily;
     res.daily = daily;
     // 计算合计
     // 计算合计
     const count = {};
     const count = {};
@@ -427,7 +429,6 @@ class TransportService extends CrudService {
    * @property Array ids 订单id集合
    * @property Array ids 订单id集合
    */
    */
   async supplierExport(query) {
   async supplierExport(query) {
-    console.log(query);
     const { ids, outOrderIds, ...params } = query;
     const { ids, outOrderIds, ...params } = query;
     // 查出选择的运输单
     // 查出选择的运输单
     let list = await this.model.find({ _id: ids.map(i => ObjectId(i)) });
     let list = await this.model.find({ _id: ids.map(i => ObjectId(i)) });
@@ -486,9 +487,7 @@ class TransportService extends CrudService {
     lastData.push({ content: header });
     lastData.push({ content: header });
     const alignment = { vertical: 'middle', horizontal: 'center' };
     const alignment = { vertical: 'middle', horizontal: 'center' };
     lastData = lastData.map(i => ({ ...i, alignment }));
     lastData = lastData.map(i => ({ ...i, alignment }));
-    // console.log(lastData);
     const res = await this.ctx.service.util.excel.toExcel({ data: lastData });
     const res = await this.ctx.service.util.excel.toExcel({ data: lastData });
-    console.log(res);
     return res;
     return res;
 
 
   }
   }
@@ -508,6 +507,7 @@ class TransportService extends CrudService {
       if (r) i.supplier.client = r;
       if (r) i.supplier.client = r;
       return i;
       return i;
     });
     });
+    console.log(list);
     rl = await this.dynamicData('treaty', list.map(i => i.treaty));
     rl = await this.dynamicData('treaty', list.map(i => i.treaty));
     list = list.map(i => {
     list = list.map(i => {
       const id = _.get(i, 'treaty');
       const id = _.get(i, 'treaty');
@@ -569,7 +569,10 @@ class TransportService extends CrudService {
    * @param {Array} ids id数组
    * @param {Array} ids id数组
    */
    */
   async dynamicData(type, ids) {
   async dynamicData(type, ids) {
-    let res = await this.ctx.model[`${_.capitalize(type)}`].find({
+    ids = _.compact(ids).filter(f => f !== '');
+    let res = [];
+    if (ids.length <= 0) return res;
+    res = await this.ctx.model[`${_.capitalize(type)}`].find({
       _id: ids,
       _id: ids,
     });
     });
     if (res.length > 0) res = JSON.parse(JSON.stringify(res));
     if (res.length > 0) res = JSON.parse(JSON.stringify(res));

+ 342 - 341
app/service/util/util.js

@@ -1,341 +1,342 @@
-'use strict';
-const _ = require('lodash');
-const moment = require('moment');
-const { CrudService } = require('naf-framework-mongoose/lib/service');
-const fs = require('fs');
-
-class UtilService extends CrudService {
-  constructor(ctx) {
-    super(ctx);
-    this.mq = this.ctx.mq;
-  }
-  async utilMethod(query, body) {
-    const routes = await this.ctx.model.Route.find();
-    const dic = await this.ctx.model.Dictionary.find({ categroy: 'xzqh' });
-    console.log(routes.length);
-    for (const route of routes) {
-      const { s_p, s_c, e_p, e_c } = route;
-      const s_p_o = dic.find(f => f.value == s_p);
-      if (s_p_o) route.s_p = s_p_o._id;
-      const s_c_o = dic.find(f => f.value == s_c);
-      if (s_c_o) route.s_c = s_c_o._id;
-      const e_p_o = dic.find(f => f.value == e_p);
-      if (e_p_o) route.e_p = e_p_o._id;
-      const e_c_o = dic.find(f => f.value == e_c);
-      if (e_c_o) route.e_c = e_c_o._id;
-      route.save();
-    }
-  }
-  /**
-   * 获取字段前置函数
-   * @param {String} param0 {model字段名
-   */
-  async findModel({ model }) {
-    if (model !== 'all') return await this.getModel(model);
-    const modelList = this.ctx.model;
-    const keys = Object.keys(modelList);
-    const arr = [];
-    for (const key of keys) {
-      if (key !== 'Test') {
-        const zh = this.modelToZh(key);
-        if (!zh) continue;
-        arr.push({
-          zh,
-          table: key,
-          value: await this.getModel(key),
-        });
-      }
-    }
-    return arr;
-  }
-
-  /**
-   * 获取字段
-   * @param {String} model 表名
-   */
-  async getModel(model) {
-    const _model = _.capitalize(model);
-    const data = this.ctx.model[_model].prototype.schema.obj;
-    const keys = Object.keys(data);
-    let res = [];
-    for (const k of keys) {
-      const field = _.get(data[k], 'field');
-      if (field && _.get(field, 'label')) {
-        field.model = k;
-        res.push(field);
-      }
-    }
-    res = _.orderBy(res, [ 'row' ], [ 'asc' ]);
-    return res;
-  }
-
-  /**
-   * 表名换成中文
-   * @param {String} model 表名
-   */
-  modelToZh(model) {
-    const obj = {
-      car: '车辆表',
-      client: '客户/供应商表',
-      daily: '车辆日常维修表',
-      dictionary: '字典表',
-      driver: '司机表',
-      item: '项目表',
-      mode: '计费方式表',
-      order: '订单表',
-      route: '路线表',
-      transport: '运输表',
-      treaty: '合同表',
-    };
-    return obj[_.lowerCase(model)];
-  }
-  /**
-   * 将查询条件中模糊查询的标识转换成对应object
-   * @param {Object} filter 查询条件
-   */
-  turnFilter(filter) {
-    const str = /^%\S*%$/;
-    const keys = Object.keys(filter);
-    for (const key of keys) {
-      const res = key.match(str);
-      console.log(res);
-      if (res) {
-        const newKey = key.slice(1, key.length - 1);
-        filter[newKey] = new RegExp(filter[key]);
-        delete filter[key];
-      }
-    }
-    return filter;
-  }
-  /**
-   * 将时间转换成对应查询Object
-   * @param {Object} filter 查询条件
-   */
-  turnDateRangeQuery(filter) {
-    const keys = Object.keys(filter);
-    for (const k of keys) {
-      if (k.includes('@')) {
-        const karr = k.split('@');
-        //  因为是针对处理范围日期,所以必须只有,开始时间和结束时间
-        if (karr.length === 2) {
-          const type = karr[1];
-          if (type === 'start') {
-            filter[karr[0]] = {
-              ..._.get(filter, karr[0], {}),
-              $gte: filter[k],
-            };
-          } else {
-            filter[karr[0]] = {
-              ..._.get(filter, karr[0], {}),
-              $lte: filter[k],
-            };
-          }
-          delete filter[k];
-        }
-      }
-    }
-    return filter;
-  }
-
-  /**
-   * sql的车辆表转换到mongodb
-   */
-  async dataTurnCar() {
-    const file = await fs.readFileSync('C:\\Users\\liuruifeng\\Desktop\\暂存文件夹\\zhwl-turn\\zhwl_car.json');
-    let res = file.toString();
-    res = JSON.parse(res);
-    let arr = res.RECORDS;
-    arr = arr.map(i => {
-      const { car_no } = i;
-      const obj = {
-        car_no,
-        onwer: _.get(i, 'car_onwer'),
-        id_name: _.get(i, 'it'),
-        id_number: _.get(i, 'it_member'),
-        organ: _.get(i, 'ro'),
-        r_date: moment(_.get(i, 'r_time')).format('YYYY-MM-DD'),
-        c_type: _.get(i, 'car_type'),
-        c_doc_no: _.get(i, 'cc_no'),
-        c_weight: _.get(i, 'cc_weight'),
-        c_scrap_date: moment(_.get(i, 'cc_scrap_time')).format('YYYY-MM-DD'),
-        c_examine_date: moment(_.get(i, 'cc_examine_time')).format('YYYY-MM-DD'),
-        r_tran_no: _.get(i, 'rc_no'),
-        r_examine_date: moment(_.get(i, 'rc_examine_time')).format('YYYY-MM-DD'),
-        buy_car_taxes_no: _.get(i, 'bcc_no'),
-        f_company: _.get(i, 'fi_name'),
-        f_tel: _.get(i, 'fi_tel'),
-        f_no: _.get(i, 'fi_no'),
-        f_cost: _.get(i, 'fi_cost'),
-        f_start_date: moment(_.get(i, 'fi_start_time')).format('YYYY-MM-DD'),
-        f_end_date: moment(_.get(i, 'fi_end_time')).format('YYYY-MM-DD'),
-        f_solve: _.get(i, 'fi_dw'),
-        f_car_taxes: _.get(i, 'fi_vt'),
-        f_sign_date: moment(_.get(i, 'fi_sign_time')).format('YYYY-MM-DD'),
-        b_company: _.get(i, 'bi_name'),
-        b_tel: _.get(i, 'bi_tel'),
-        b_no: _.get(i, 'bi_no'),
-        b_start_date: _.get(i, 'bi_start_time') ? moment(_.get(i, 'bi_start_time')).format('YYYY-MM-DD') : undefined,
-        b_end_date: _.get(i, 'bi_start_time') ? moment(_.get(i, 'bi_end_time')).format('YYYY-MM-DD') : undefined,
-        b_solve: _.get(i, 'bi_dw'),
-        b_sign_date: _.get(i, 'bi_start_time') ? moment(_.get(i, 'bi_sign_time')).format('YYYY-MM-DD') : undefined,
-      };
-      return obj;
-    });
-    // await this.ctx.model.Car.insertMany(arr);
-  }
-
-  /**
-   * sql的客户/供应商表初步转换
-   */
-  async dataTurnClientFirst() {
-    const file = await fs.readFileSync(
-      'C:\\Users\\liuruifeng\\Desktop\\暂存文件夹\\zhwl-turn\\zhwl_client.json'
-    );
-    const users = await this.ctx.service.util.httpUtil.cget(
-      '/user',
-      'userAuth',
-      { _tenant: 'zhwl' }
-    );
-    let res = file.toString();
-    res = JSON.parse(res);
-    let arr = res.RECORDS;
-    arr = arr.map(i => {
-      const { name, address, taxes_no, type } = i;
-      const obj = {
-        name,
-        address,
-        taxes_no,
-        type: type === '0' ? '客户' : '供应商',
-        legal: _.get(i, 'legal_person'),
-        mobile: _.get(i, 'tel'),
-        account_bank: _.get(i, 'bank'),
-        account: _.get(i, 'card_account'),
-        id: _.get(i, 'id'),
-      };
-      if (_.get(i, 'login_id')) {
-        let lid = _.get(i, 'login_id');
-        if (lid === 'lsyw') lid = 'liushuang';
-        const user = users.find(f => f.login_id === lid);
-        if (user) {
-          obj.owner = user.id;
-          return obj;
-        }
-      }
-    });
-    await this.ctx.model.IClient.insertMany(_.compact(arr));
-  }
-  /**
-   * sql的合同表初步转换
-   */
-  async dataTurnTreatyFirst() {
-    const file = await fs.readFileSync('C:\\Users\\liuruifeng\\Desktop\\暂存文件夹\\zhwl-turn\\zhwl_client_pact.json');
-    const iclients = await this.ctx.model.IClient.find();
-    let res = file.toString();
-    res = JSON.parse(res);
-    let arr = res.RECORDS;
-    arr = arr.map(i => {
-      const { jf, yf, id, cus_id } = i;
-      const obj = {
-        number: _.get(i, 'pact_no'),
-        period: _.get(i, 'cycle'),
-        settle_up: _.get(i, 'js_type'),
-        settle_up_period: _.get(i, 'js_cycle'),
-        jf, yf, id,
-      };
-      if (cus_id) {
-        const client = iclients.find(f => f.id == cus_id);
-        if (client) {
-          obj.client = client._id;
-          obj.owner = client.owner;
-          return obj;
-        }
-      }
-    });
-    arr = _.compact(arr);
-    await this.ctx.model.ITreaty.insertMany(arr);
-  }
-
-  /**
-   * sql的项目表初步转换
-   */
-  async dataTurnItemFirst() {
-    const file = await fs.readFileSync('C:\\Users\\liuruifeng\\Desktop\\暂存文件夹\\zhwl-turn\\zhwl_client_pact_item.json');
-    let res = file.toString();
-    res = JSON.parse(res);
-    const iitems = res.RECORDS; // 对应itemconst arr = [];
-    const treatys = await this.ctx.model.ITreaty.find();
-    const arr = [];
-    for (const treaty of treatys) {
-      const { _id, id, owner } = treaty;
-      let arritems = iitems.filter(f => f.pact_id == id && f.cess && f.cess !== '');
-      arritems = arritems.map(i => {
-        const obj = {
-          id: _.get(i, 'id'),
-          treaty: _id,
-          name: _.get(i, 'item_name'),
-          taxes: _.get(i, 'cess'),
-          owner,
-        };
-        arr.push(obj);
-      });
-    }
-    await this.ctx.model.IItem.insertMany(arr);
-
-  }
-
-  /**
-   * sql的线路表初步转换
-   */
-  async dataTurnRouteFirst() {
-    const file = await fs.readFileSync('C:\\Users\\liuruifeng\\Desktop\\暂存文件夹\\zhwl-turn\\zhwl_dly_way.json');
-    let res = file.toString();
-    res = JSON.parse(res);
-    const iway = res.RECORDS; // 对应route
-    const iitems = await this.ctx.model.IItem.find();
-    const dic = await this.ctx.model.Dictionary.find({ categroy: 'xzqh' });
-    const arr = [];
-    for (const item of iitems) {
-      const { _id, id, owner } = item;
-      const ways = iway.filter(f => f.item_id == id);
-      for (const way of ways) {
-        const obj = { item: _id, name: way.name, owner, id: way.id, start: way.start_site, end: way.end_site };
-        const s_p_o = dic.find(f => f.label.includes(way.start_province) && f.pid === '5fcb00a6f6ed0b0b70df95cf');
-        const s_c_o = dic.find(f => f.label.includes(way.start_city) && f.pid !== '5fcb00a6f6ed0b0b70df95cf');
-        const e_p_o = dic.find(f => f.label.includes(way.end_province) && f.pid === '5fcb00a6f6ed0b0b70df95cf');
-        const e_c_o = dic.find(f => f.label.includes(way.end_city) && f.pid !== '5fcb00a6f6ed0b0b70df95cf');
-        if (s_p_o) obj.s_p = s_p_o.value;
-        if (s_c_o) obj.s_c = s_c_o.value;
-        if (e_p_o) obj.e_p = e_p_o.value;
-        if (e_c_o) obj.e_c = e_c_o.value;
-        if (obj.s_p && obj.s_c && obj.e_p && obj.e_c) arr.push(obj);
-      }
-
-    }
-    await this.ctx.model.IRoute.insertMany(arr);
-  }
-
-  /**
-   * sql的付费方式表转换(没有初步,直接成型,下面需要做的是将之前的初步转换成成品)
-   */
-  async dataTurnModeFirst() {
-    const file = await fs.readFileSync('C:\\Users\\liuruifeng\\Desktop\\暂存文件夹\\zhwl-turn\\zhwl_client_pact_item_way_type.json');
-    let res = file.toString();
-    res = JSON.parse(res);
-    const itype = res.RECORDS; // 对应rmode
-    const routes = await this.ctx.model.IRoute.find();
-    const arr = [];
-    for (const route of routes) {
-      const { _id, id, owner } = route;
-      const modes = itype.filter(f => f.dly_way_id == id);
-      for (const mode of modes) {
-        const obj = { name: mode.type_name, route: _id, price: mode.price, owner, status: mode.status };
-        if (mode.send_type) obj.send_type = mode.send_type == '1' ? '整车' : '零担';
-        if (mode.count_type) obj.computed_type = mode.count_type == '1' ? '按重量' : '按体积';
-        if (mode.is_lf) obj.is_lf = mode.is_lf == '0';
-        arr.push(obj);
-      }
-    }
-    await this.ctx.model.Mode.insertMany(arr);
-  }
-}
-module.exports = UtilService;
+'use strict';
+const _ = require('lodash');
+const moment = require('moment');
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+const fs = require('fs');
+
+class UtilService extends CrudService {
+  constructor(ctx) {
+    super(ctx);
+    this.mq = this.ctx.mq;
+  }
+  async utilMethod(query, body) {
+    
+    // const routes = await this.ctx.model.Route.find();
+    // const dic = await this.ctx.model.Dictionary.find({ categroy: 'xzqh' });
+    // console.log(routes.length);
+    // for (const route of routes) {
+    //   const { s_p, s_c, e_p, e_c } = route;
+    //   const s_p_o = dic.find(f => f.value == s_p);
+    //   if (s_p_o) route.s_p = s_p_o._id;
+    //   const s_c_o = dic.find(f => f.value == s_c);
+    //   if (s_c_o) route.s_c = s_c_o._id;
+    //   const e_p_o = dic.find(f => f.value == e_p);
+    //   if (e_p_o) route.e_p = e_p_o._id;
+    //   const e_c_o = dic.find(f => f.value == e_c);
+    //   if (e_c_o) route.e_c = e_c_o._id;
+    //   route.save();
+    // }
+  }
+  /**
+   * 获取字段前置函数
+   * @param {String} param0 {model字段名
+   */
+  async findModel({ model }) {
+    if (model !== 'all') return await this.getModel(model);
+    const modelList = this.ctx.model;
+    const keys = Object.keys(modelList);
+    const arr = [];
+    for (const key of keys) {
+      if (key !== 'Test') {
+        const zh = this.modelToZh(key);
+        if (!zh) continue;
+        arr.push({
+          zh,
+          table: key,
+          value: await this.getModel(key),
+        });
+      }
+    }
+    return arr;
+  }
+
+  /**
+   * 获取字段
+   * @param {String} model 表名
+   */
+  async getModel(model) {
+    const _model = _.capitalize(model);
+    const data = this.ctx.model[_model].prototype.schema.obj;
+    const keys = Object.keys(data);
+    let res = [];
+    for (const k of keys) {
+      const field = _.get(data[k], 'field');
+      if (field && _.get(field, 'label')) {
+        field.model = k;
+        res.push(field);
+      }
+    }
+    res = _.orderBy(res, [ 'row' ], [ 'asc' ]);
+    return res;
+  }
+
+  /**
+   * 表名换成中文
+   * @param {String} model 表名
+   */
+  modelToZh(model) {
+    const obj = {
+      car: '车辆表',
+      client: '客户/供应商表',
+      daily: '车辆日常维修表',
+      dictionary: '字典表',
+      driver: '司机表',
+      item: '项目表',
+      mode: '计费方式表',
+      order: '订单表',
+      route: '路线表',
+      transport: '运输表',
+      treaty: '合同表',
+    };
+    return obj[_.lowerCase(model)];
+  }
+  /**
+   * 将查询条件中模糊查询的标识转换成对应object
+   * @param {Object} filter 查询条件
+   */
+  turnFilter(filter) {
+    const str = /^%\S*%$/;
+    const keys = Object.keys(filter);
+    for (const key of keys) {
+      const res = key.match(str);
+      console.log(res);
+      if (res) {
+        const newKey = key.slice(1, key.length - 1);
+        filter[newKey] = new RegExp(filter[key]);
+        delete filter[key];
+      }
+    }
+    return filter;
+  }
+  /**
+   * 将时间转换成对应查询Object
+   * @param {Object} filter 查询条件
+   */
+  turnDateRangeQuery(filter) {
+    const keys = Object.keys(filter);
+    for (const k of keys) {
+      if (k.includes('@')) {
+        const karr = k.split('@');
+        //  因为是针对处理范围日期,所以必须只有,开始时间和结束时间
+        if (karr.length === 2) {
+          const type = karr[1];
+          if (type === 'start') {
+            filter[karr[0]] = {
+              ..._.get(filter, karr[0], {}),
+              $gte: filter[k],
+            };
+          } else {
+            filter[karr[0]] = {
+              ..._.get(filter, karr[0], {}),
+              $lte: filter[k],
+            };
+          }
+          delete filter[k];
+        }
+      }
+    }
+    return filter;
+  }
+
+  /**
+   * sql的车辆表转换到mongodb
+   */
+  async dataTurnCar() {
+    const file = await fs.readFileSync('C:\\Users\\liuruifeng\\Desktop\\暂存文件夹\\zhwl-turn\\zhwl_car.json');
+    let res = file.toString();
+    res = JSON.parse(res);
+    let arr = res.RECORDS;
+    arr = arr.map(i => {
+      const { car_no } = i;
+      const obj = {
+        car_no,
+        onwer: _.get(i, 'car_onwer'),
+        id_name: _.get(i, 'it'),
+        id_number: _.get(i, 'it_member'),
+        organ: _.get(i, 'ro'),
+        r_date: moment(_.get(i, 'r_time')).format('YYYY-MM-DD'),
+        c_type: _.get(i, 'car_type'),
+        c_doc_no: _.get(i, 'cc_no'),
+        c_weight: _.get(i, 'cc_weight'),
+        c_scrap_date: moment(_.get(i, 'cc_scrap_time')).format('YYYY-MM-DD'),
+        c_examine_date: moment(_.get(i, 'cc_examine_time')).format('YYYY-MM-DD'),
+        r_tran_no: _.get(i, 'rc_no'),
+        r_examine_date: moment(_.get(i, 'rc_examine_time')).format('YYYY-MM-DD'),
+        buy_car_taxes_no: _.get(i, 'bcc_no'),
+        f_company: _.get(i, 'fi_name'),
+        f_tel: _.get(i, 'fi_tel'),
+        f_no: _.get(i, 'fi_no'),
+        f_cost: _.get(i, 'fi_cost'),
+        f_start_date: moment(_.get(i, 'fi_start_time')).format('YYYY-MM-DD'),
+        f_end_date: moment(_.get(i, 'fi_end_time')).format('YYYY-MM-DD'),
+        f_solve: _.get(i, 'fi_dw'),
+        f_car_taxes: _.get(i, 'fi_vt'),
+        f_sign_date: moment(_.get(i, 'fi_sign_time')).format('YYYY-MM-DD'),
+        b_company: _.get(i, 'bi_name'),
+        b_tel: _.get(i, 'bi_tel'),
+        b_no: _.get(i, 'bi_no'),
+        b_start_date: _.get(i, 'bi_start_time') ? moment(_.get(i, 'bi_start_time')).format('YYYY-MM-DD') : undefined,
+        b_end_date: _.get(i, 'bi_start_time') ? moment(_.get(i, 'bi_end_time')).format('YYYY-MM-DD') : undefined,
+        b_solve: _.get(i, 'bi_dw'),
+        b_sign_date: _.get(i, 'bi_start_time') ? moment(_.get(i, 'bi_sign_time')).format('YYYY-MM-DD') : undefined,
+      };
+      return obj;
+    });
+    // await this.ctx.model.Car.insertMany(arr);
+  }
+
+  /**
+   * sql的客户/供应商表初步转换
+   */
+  async dataTurnClientFirst() {
+    const file = await fs.readFileSync(
+      'C:\\Users\\liuruifeng\\Desktop\\暂存文件夹\\zhwl-turn\\zhwl_client.json'
+    );
+    const users = await this.ctx.service.util.httpUtil.cget(
+      '/user',
+      'userAuth',
+      { _tenant: 'zhwl' }
+    );
+    let res = file.toString();
+    res = JSON.parse(res);
+    let arr = res.RECORDS;
+    arr = arr.map(i => {
+      const { name, address, taxes_no, type } = i;
+      const obj = {
+        name,
+        address,
+        taxes_no,
+        type: type === '0' ? '客户' : '供应商',
+        legal: _.get(i, 'legal_person'),
+        mobile: _.get(i, 'tel'),
+        account_bank: _.get(i, 'bank'),
+        account: _.get(i, 'card_account'),
+        id: _.get(i, 'id'),
+      };
+      if (_.get(i, 'login_id')) {
+        let lid = _.get(i, 'login_id');
+        if (lid === 'lsyw') lid = 'liushuang';
+        const user = users.find(f => f.login_id === lid);
+        if (user) {
+          obj.owner = user.id;
+          return obj;
+        }
+      }
+    });
+    await this.ctx.model.IClient.insertMany(_.compact(arr));
+  }
+  /**
+   * sql的合同表初步转换
+   */
+  async dataTurnTreatyFirst() {
+    const file = await fs.readFileSync('C:\\Users\\liuruifeng\\Desktop\\暂存文件夹\\zhwl-turn\\zhwl_client_pact.json');
+    const iclients = await this.ctx.model.IClient.find();
+    let res = file.toString();
+    res = JSON.parse(res);
+    let arr = res.RECORDS;
+    arr = arr.map(i => {
+      const { jf, yf, id, cus_id } = i;
+      const obj = {
+        number: _.get(i, 'pact_no'),
+        period: _.get(i, 'cycle'),
+        settle_up: _.get(i, 'js_type'),
+        settle_up_period: _.get(i, 'js_cycle'),
+        jf, yf, id,
+      };
+      if (cus_id) {
+        const client = iclients.find(f => f.id == cus_id);
+        if (client) {
+          obj.client = client._id;
+          obj.owner = client.owner;
+          return obj;
+        }
+      }
+    });
+    arr = _.compact(arr);
+    await this.ctx.model.ITreaty.insertMany(arr);
+  }
+
+  /**
+   * sql的项目表初步转换
+   */
+  async dataTurnItemFirst() {
+    const file = await fs.readFileSync('C:\\Users\\liuruifeng\\Desktop\\暂存文件夹\\zhwl-turn\\zhwl_client_pact_item.json');
+    let res = file.toString();
+    res = JSON.parse(res);
+    const iitems = res.RECORDS; // 对应itemconst arr = [];
+    const treatys = await this.ctx.model.ITreaty.find();
+    const arr = [];
+    for (const treaty of treatys) {
+      const { _id, id, owner } = treaty;
+      let arritems = iitems.filter(f => f.pact_id == id && f.cess && f.cess !== '');
+      arritems = arritems.map(i => {
+        const obj = {
+          id: _.get(i, 'id'),
+          treaty: _id,
+          name: _.get(i, 'item_name'),
+          taxes: _.get(i, 'cess'),
+          owner,
+        };
+        arr.push(obj);
+      });
+    }
+    await this.ctx.model.IItem.insertMany(arr);
+
+  }
+
+  /**
+   * sql的线路表初步转换
+   */
+  async dataTurnRouteFirst() {
+    const file = await fs.readFileSync('C:\\Users\\liuruifeng\\Desktop\\暂存文件夹\\zhwl-turn\\zhwl_dly_way.json');
+    let res = file.toString();
+    res = JSON.parse(res);
+    const iway = res.RECORDS; // 对应route
+    const iitems = await this.ctx.model.IItem.find();
+    const dic = await this.ctx.model.Dictionary.find({ categroy: 'xzqh' });
+    const arr = [];
+    for (const item of iitems) {
+      const { _id, id, owner } = item;
+      const ways = iway.filter(f => f.item_id == id);
+      for (const way of ways) {
+        const obj = { item: _id, name: way.name, owner, id: way.id, start: way.start_site, end: way.end_site };
+        const s_p_o = dic.find(f => f.label.includes(way.start_province) && f.pid === '5fcb00a6f6ed0b0b70df95cf');
+        const s_c_o = dic.find(f => f.label.includes(way.start_city) && f.pid !== '5fcb00a6f6ed0b0b70df95cf');
+        const e_p_o = dic.find(f => f.label.includes(way.end_province) && f.pid === '5fcb00a6f6ed0b0b70df95cf');
+        const e_c_o = dic.find(f => f.label.includes(way.end_city) && f.pid !== '5fcb00a6f6ed0b0b70df95cf');
+        if (s_p_o) obj.s_p = s_p_o.value;
+        if (s_c_o) obj.s_c = s_c_o.value;
+        if (e_p_o) obj.e_p = e_p_o.value;
+        if (e_c_o) obj.e_c = e_c_o.value;
+        if (obj.s_p && obj.s_c && obj.e_p && obj.e_c) arr.push(obj);
+      }
+
+    }
+    await this.ctx.model.IRoute.insertMany(arr);
+  }
+
+  /**
+   * sql的付费方式表转换(没有初步,直接成型,下面需要做的是将之前的初步转换成成品)
+   */
+  async dataTurnModeFirst() {
+    const file = await fs.readFileSync('C:\\Users\\liuruifeng\\Desktop\\暂存文件夹\\zhwl-turn\\zhwl_client_pact_item_way_type.json');
+    let res = file.toString();
+    res = JSON.parse(res);
+    const itype = res.RECORDS; // 对应rmode
+    const routes = await this.ctx.model.IRoute.find();
+    const arr = [];
+    for (const route of routes) {
+      const { _id, id, owner } = route;
+      const modes = itype.filter(f => f.dly_way_id == id);
+      for (const mode of modes) {
+        const obj = { name: mode.type_name, route: _id, price: mode.price, owner, status: mode.status };
+        if (mode.send_type) obj.send_type = mode.send_type == '1' ? '整车' : '零担';
+        if (mode.count_type) obj.computed_type = mode.count_type == '1' ? '按重量' : '按体积';
+        if (mode.is_lf) obj.is_lf = mode.is_lf == '0';
+        arr.push(obj);
+      }
+    }
+    await this.ctx.model.Mode.insertMany(arr);
+  }
+}
+module.exports = UtilService;

+ 82 - 82
config/config.default.js

@@ -1,82 +1,82 @@
-/* eslint valid-jsdoc: "off" */
-
-'use strict';
-const { sep } = require('path');
-const { jwt } = require('./config.secret');
-/**
- * @param {Egg.EggAppInfo} appInfo app info
- */
-module.exports = appInfo => {
-  /**
-   * built-in config
-   * @type {Egg.EggAppConfig}
-   **/
-  const config = (exports = {});
-
-  // use for cookie sign key, should change to your own and keep security
-  config.keys = appInfo.name + '_1579225760252_7743';
-
-  // add your middleware config here
-  config.middleware = [];
-
-  // add your user config here
-  const userConfig = {
-    // myAppName: 'egg',
-  };
-
-  // add your config here
-  config.cluster = {
-    listen: {
-      port: 7009,
-    },
-  };
-  config.mongoose = {
-    url: 'mongodb://localhost:27017/servicezhwl',
-    options: {
-      // user: 'admin',
-      // pass: 'admin',
-      // authSource: 'admin',
-      // useNewUrlParser: true,
-      // useCreateIndex: true,
-    },
-  };
-
-  config.project = {
-    userAuth: 'http://127.0.0.1:7003/api/role/auth',
-    mission: 'http://127.0.0.1:7003/api/mission',
-  };
-
-  config.jwt = {
-    ...jwt,
-    expiresIn: '1d',
-    issuer: 'servicezhwl',
-  };
-  // redis config
-  config.redis = {
-    client: {
-      port: 6379, // Redis port
-      host: '127.0.0.1', // Redis host
-      password: 123456,
-      db: 0,
-    },
-  };
-  // config.amqp = {
-  //   client: {
-  //     hostname: '127.0.0.1',
-  //     username: 'visit',
-  //     password: 'visit',
-  //     vhost: 'visit',
-  //   },
-  //   app: true,
-  //   agent: true,
-  // };
-
-  config.export = {
-    root_path: `${appInfo.baseDir}${sep}`,
-  };
-
-  return {
-    ...config,
-    ...userConfig,
-  };
-};
+/* eslint valid-jsdoc: "off" */
+
+'use strict';
+const { sep } = require('path');
+const { jwt } = require('./config.secret');
+/**
+ * @param {Egg.EggAppInfo} appInfo app info
+ */
+module.exports = appInfo => {
+  /**
+   * built-in config
+   * @type {Egg.EggAppConfig}
+   **/
+  const config = (exports = {});
+
+  // use for cookie sign key, should change to your own and keep security
+  config.keys = appInfo.name + '_1579225760252_7743';
+
+  // add your middleware config here
+  config.middleware = [];
+
+  // add your user config here
+  const userConfig = {
+    // myAppName: 'egg',
+  };
+
+  // add your config here
+  config.cluster = {
+    listen: {
+      port: 7001,
+    },
+  };
+  config.mongoose = {
+    url: 'mongodb://localhost:27017/servicezhwl',
+    options: {
+      // user: 'admin',
+      // pass: 'admin',
+      // authSource: 'admin',
+      // useNewUrlParser: true,
+      // useCreateIndex: true,
+    },
+  };
+
+  config.project = {
+    userAuth: 'http://127.0.0.1:7003/api/role/auth',
+    mission: 'http://127.0.0.1:7003/api/mission',
+  };
+
+  config.jwt = {
+    ...jwt,
+    expiresIn: '1d',
+    issuer: 'servicezhwl',
+  };
+  // redis config
+  config.redis = {
+    client: {
+      port: 6379, // Redis port
+      host: '127.0.0.1', // Redis host
+      password: 123456,
+      db: 0,
+    },
+  };
+  // config.amqp = {
+  //   client: {
+  //     hostname: '127.0.0.1',
+  //     username: 'visit',
+  //     password: 'visit',
+  //     vhost: 'visit',
+  //   },
+  //   app: true,
+  //   agent: true,
+  // };
+
+  config.export = {
+    root_path: `${appInfo.baseDir}${sep}`,
+  };
+
+  return {
+    ...config,
+    ...userConfig,
+  };
+};

+ 0 - 24
config/config.local.js

@@ -1,24 +0,0 @@
-'use strict';
-
-module.exports = () => {
-  const config = (exports = {});
-
-  config.logger = {
-    level: 'DEBUG',
-    consoleLevel: 'DEBUG',
-  };
-
-  config.mongoose = {
-    url: 'mongodb://localhost:27017/servicezhwl',
-    options: {
-      // user: 'demo',
-      // pass: 'demo',
-      // authSource: 'admin',
-      // useNewUrlParser: true,
-      // useCreateIndex: true,
-      // useUnifiedTopology: true,
-    },
-  };
-
-  return config;
-};

+ 55 - 66
package.json

@@ -1,66 +1,55 @@
-{
-  "name": "servicezhwl",
-  "version": "1.0.0",
-  "description": "",
-  "private": true,
-  "egg": {
-    "framework": "naf-framework-mongoose"
-  },
-  "dependencies": {
-    "cheerio": "^1.0.0-rc.3",
-    "egg": "^2.23.0",
-    "egg-naf-amqp": "0.0.13",
-    "egg-redis": "^2.4.0",
-    "egg-scripts": "^2.11.0",
-    "egg-view-nunjucks": "^2.2.0",
-    "exceljs": "^4.2.0",
-    "jsonwebtoken": "^8.5.1",
-    "lodash": "^4.17.15",
-    "moment": "^2.27.0",
-    "naf-framework-mongoose": "^0.6.11",
-    "node-schedule": "^1.3.2",
-    "nodemailer": "^6.4.3",
-    "redis": "^3.0.2",
-    "silly-datetime": "^0.1.2",
-    "string-random": "^0.1.3",
-    "superagent": "^6.1.0",
-    "url-join": "^4.0.1",
-    "uuid": "^3.3.3",
-    "xlsx": "^0.15.1",
-    "xlsx-style": "^0.8.13",
-    "xmlreader": "^0.2.3"
-  },
-  "devDependencies": {
-    "autod": "^3.0.1",
-    "autod-egg": "^1.1.0",
-    "egg-bin": "^4.11.0",
-    "egg-ci": "^1.11.0",
-    "egg-mock": "^3.21.0",
-    "eslint": "^5.13.0",
-    "eslint-config-egg": "^7.1.0"
-  },
-  "engines": {
-    "node": ">=10.0.0"
-  },
-  "scripts": {
-    "start": "egg-scripts start --daemon --title=egg-server-serveci-center",
-    "stop": "egg-scripts stop --title=egg-server-serveci-center",
-    "dev": "egg-bin dev",
-    "debug": "egg-bin debug",
-    "test": "npm run lint -- --fix && npm run test-local",
-    "test-local": "egg-bin test",
-    "cov": "egg-bin cov",
-    "lint": "eslint .",
-    "ci": "npm run lint && npm run cov",
-    "autod": "autod"
-  },
-  "ci": {
-    "version": "10"
-  },
-  "repository": {
-    "type": "git",
-    "url": ""
-  },
-  "author": "",
-  "license": "MIT"
-}
+{
+  "name": "servicezhwl",
+  "version": "1.0.0",
+  "description": "",
+  "private": true,
+  "egg": {
+    "framework": "naf-framework-mongoose"
+  },
+  "dependencies": {
+    "cheerio": "^1.0.0-rc.3",
+    "egg": "^2.15.1",
+    "egg-naf-amqp": "0.0.13",
+    "egg-redis": "^2.4.0",
+    "egg-scripts": "^2.11.0",
+    "exceljs": "^4.2.0",
+    "jsonwebtoken": "^8.5.1",
+    "lodash": "^4.17.15",
+    "moment": "^2.27.0",
+    "naf-framework-mongoose": "^0.6.11",
+    "redis": "^3.0.2"
+  },
+  "devDependencies": {
+    "autod": "^3.0.1",
+    "autod-egg": "^1.1.0",
+    "egg-bin": "^4.11.0",
+    "egg-ci": "^1.11.0",
+    "egg-mock": "^3.21.0",
+    "eslint": "^5.13.0",
+    "eslint-config-egg": "^7.1.0"
+  },
+  "engines": {
+    "node": ">=10.0.0"
+  },
+  "scripts": {
+    "start": "egg-scripts start --daemon --title=egg-server-serveci-center",
+    "stop": "egg-scripts stop --title=egg-server-serveci-center",
+    "dev": "egg-bin dev",
+    "debug": "egg-bin debug",
+    "test": "npm run lint -- --fix && npm run test-local",
+    "test-local": "egg-bin test",
+    "cov": "egg-bin cov",
+    "lint": "eslint .",
+    "ci": "npm run lint && npm run cov",
+    "autod": "autod"
+  },
+  "ci": {
+    "version": "10"
+  },
+  "repository": {
+    "type": "git",
+    "url": ""
+  },
+  "author": "",
+  "license": "MIT"
+}