123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- 'use strict';
- const { CrudService } = require('naf-framework-mongoose-free/lib/service');
- const { BusinessError, ErrorCode } = require('naf-core').Error;
- const Path = require('path');
- const _ = require('lodash');
- const moment = require('moment');
- const assert = require('assert');
- const { ObjectId } = require('mongoose').Types;
- const Excel = require('exceljs');
- const { sep } = require('path');
- const fs = require('fs');
- // 专利申请表-审批单
- class PatentapplyService extends CrudService {
- constructor(ctx) {
- super(ctx, 'patentapply');
- this.model = this.ctx.model.Patent.Patentapply;
- this.notice = this.ctx.model.Patent.Patentexamine;
- }
- /**
- * 交底书审核
- * @param {body} body 参数
- * @property id 数据id
- * @property status 交底书要改变成的状态
- * @property info 其他数据,当做多个备注,记录使用
- */
- async check({ id, remark, ...data }) {
- // const data = { status, admin_id, admin_name };
- await this.model.updateOne({ _id: ObjectId(id) }, data);
- // 换成对应的状态码,record在下面
- return await this.record({ id, method: data.status, remark });
- }
- async record({ id, method, remark }) {
- let word = '';
- switch (`${method}`) {
- case 'create':
- word = '已申请';
- break;
- case 'update':
- word = '修改';
- break;
- case '1':
- word = '企业/学校审批通过';
- break;
- case '-1':
- word = '企业/学校审未通过';
- break;
- case '2':
- word = '科企代理';
- break;
- case '3':
- word = '代理机构代理';
- break;
- case '4':
- word = '代理机构受理通过';
- break;
- case '-4':
- word = '代理机构受理拒绝';
- break;
- case '5':
- word = '科企代理';
- break;
- case '-5':
- word = '代理机构自行代理';
- break;
- case '6':
- word = '接收申请文件通过';
- break;
- case '-6':
- word = '接收申请文件未通过';
- break;
- case '7':
- word = '已上报国知局';
- break;
- default:
- word = '未知状态';
- break;
- }
- const data = await this.model.findById(id);
- if (!data) {
- throw new BusinessError(
- ErrorCode.DATA_NOT_EXIST,
- '添加记录----未找到数据'
- );
- }
- const obj = {
- time: moment().format('YYYY-MM-DD HH:mm:ss'),
- word,
- remark,
- };
- data.record.push(obj);
- const res = await data.save();
- this.toNotice(id, method);
- return res;
- }
- async toNotice(id, code) {
- const data = await this.model.findById(id);
- if (!data) return;
- const {
- user_id,
- mech_id,
- admin_id,
- agentmech_id,
- name,
- apply_name,
- status,
- } = data;
- const arr = [];
- let content = '';
- let to = '';
- switch (code) {
- case 'create':
- content = `${apply_name}提交了专利申请书【${name}】的申报,及时前往专利申请管理进行处理`;
- if (status === '0') {
- to = mech_id;
- }
- break;
- case 'update':
- content = `${apply_name}重新提交了专利申请书【${name}】的申报,请及时前往专利申请管理进行处理`;
- if (status === '0') {
- to = mech_id;
- } else if (status === '2') {
- to = admin_id;
- } else if (status === '3') {
- to = agentmech_id;
- }
- break;
- case '1':
- content = `您的专利申请书【${name}】通过机构的审批,请您及时选择机构,并上传申请文件进行专利CPC系统申报`;
- to = user_id;
- break;
- case '-1':
- content = `您的专利申请书【${name}】未通过机构的审批,请您及时修改,重新申请`;
- to = user_id;
- break;
- case '4':
- content = `您的专利申请书【${name}】已通过代理机构受理,请等待代理机构进行对申请文件查看`;
- to = user_id;
- break;
- case '-4':
- content = `您的专利申请书【${name}】未通过代理机构的受理,请及时查看审核结果,并重新选择代理机构`;
- to = user_id;
- break;
- case '5':
- arr.push({
- content: `您的专利申请书【${name}】已由代理机构推行给科企机构,请等待科企机构进行受理`,
- to: user_id,
- });
- arr.push({
- content: `${apply_name}的专利申请书【${name}】已由代理机构推送给科企机构,请您尽快对其进行受理`,
- to: admin_id,
- });
- break;
- case '-5':
- content = `您的专利申请书【${name}】已由代理机构自行上报国知局系统`;
- to = user_id;
- break;
- case '6':
- content = `您的专利申请书【${name}】通过科企机构的受理,请耐心等待科企机构上报国知局`;
- to = user_id;
- break;
- case '-6':
- content = `您的专利申请书【${name}】未通过科企机构的受理,请及时查看审核结果,并重新选择代理机构`;
- to = user_id;
- break;
- case '7':
- content = `您的专利申请书【${name}】已上传到国知局,请耐心等待国知局反馈信息`;
- to = user_id;
- break;
- default:
- break;
- }
- if (arr.length > 0) {
- await this.notice.insertMany(arr);
- } else {
- const obj = { to, content };
- await this.notice.create(obj);
- }
- }
- }
- module.exports = PatentapplyService;
|