const TaskBase = require("../../task.base");
const settings = require("../../../../config/settings");
var excel = require('exceljs');
var archiver = require('archiver');
var xlsx = require('node-xlsx');
const system = require("../../../system");
const fs = require('fs');
const COS = require('cos-nodejs-sdk-v5');
const request = require('request');
var child_process = require('child_process');

var resultinfo = {
  "status": 0,
  "msg": "操作成功",
  "data": [
    {
      "id": 63,
      "type": "EDI",
      //   --------    注册认证   ----------
      "registeredAddressData": {
        //   --------    实名认证   ----------
        "authentication": {
          "personType": "法人122222222222222111111",
          "companyType": "GFKBM11222222222222222221111BM", // 企业或机构类型
          "enterpriseCode": "GSGK1122222222222222221111111KL",// 统一社会信用代码
          "name": "LFKLG呃呃呃呃呃呃啦22222222222222222211111111啦啦啦啦啦",// 统一社会信用代码
          "legalTypes": "事业单位1111111111111法人",// 法人企业或机构名称
          "legalName": "111112222222444",// 企业法定代表人姓名
          "legalCertificateId": "D",// 企业法定代表人姓名
          "legalCertificateType": "身份证",// 企业法定代表人证件类型
          "contactAddress": "D"// 联系地址
        },
        "files": [
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_483515925309822962020199432296.jpeg",
              "name": "564A34E8-3D06-41BC-8BE8-E8C20B8EBCC0_4_5005_c.jpeg"
            },
            "title": "营业执照"
          },
          {
            "title": "法定代表人身份证件",
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_13151591685846571202091457265719592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg",
              "name": "9592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg"
            }
          }
        ]
      },
      //   --------    发展和实施计划   ----------
      "implementationPlanData": {
        //   --------    网站或APP信息   ----------
        "webApp": [
          {
            "name": "X111X",
            "type": "APP",
            "domain": "XX11Z",
            "appStoreName": "AA11",
            "serverAddress": "Z111Z"
          },
          {
            "name": "X222ZX",
            "type": "网站",
            "domain": "XZ22X",
            "appStoreName": "QQ222",
            "serverAddress": "ZXZ222X"
          }
        ],
        "files": [
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_238515925309868272020199436827.jpeg",
              "name": "564A34E8-3D06-41BC-8BE8-E8C20B8EBCC0_4_5005_c.jpeg"
            },
            "title": "域名证书"
          },
          {
            "title": "交易处理业务",
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_21051591783811377202010181011377开篇词-面试，这样做会功到自然成.pdf",
              "name": "开篇词-面试，这样做会功到自然成.pdf"
            }
          }
        ],
        //   --------    发展和实施计划  ICP 或 EDI ----------
        "EDI": {
          "electronicExchange": "行政事务数据结构化/自动处理和交换服务,贸易事务数据结构化/自动处理和交换服务",
          "transactionProcessing": "",
          "dataProcessing": "",
          "targetUser": "个人,企业",
          "profitableWay": "混合收费"
        }
        // "ICP": {
        //   "releaseAndDelivery": "fff,应用商店",
        //   "community": "论坛,社交平台,fsfsdfsf",
        //   "protectiveProcessing": "防病毒平台",
        //   "interactive": "即时通信",
        //   "search": "ff,搜索引擎",
        //   "targetUser": "企业,个人,政府/事业单位",
        //   "profitableWay": "前向用户收费,后向平台服务收费"
        // }
      },
      //   --------    增值 电信 申请表 ----------
      "licenceData": {
        //   --------    增值 电信 业务 ----------
        "licence": {
          "companyName": "LFKLG呃呃呃呃呃呃啦啦啦啦啦啦",//公司名称
          "enterpriseCode": "GSGKKL",//企业统一社会信用代码
          "registeredCapital": 100000,//注册资本（万元）
          "registerAddress": "KDKFKD",//注册地址
          "fixedTelephone": "KKKDKD",//公司固定电话
          "workAddress": "DMQWW",//主要办公地址
          "zipCode": "WM,D",//主要办公地址邮编
          "comapnyNature": "国有控股",//公司性质
          "ifListed": "是"//是否上市（含新三板）
        },
        "files": [
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_483515925309822962020199432296.jpeg",
              "name": "564A34E8-3D06-41BC-8BE8-E8C20B8EBCC0_4_5005_c.jpeg"
            },
            "title": "营业执照"
          }
        ]
      },
      //   --------    公司及人员情况 ----------
      "companyPersonnelData": {
        "personnelInfo": [
          {
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_13151591685846571202091457265719592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg",
              "name": "9592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg"
            },
            "name": "111112222222444",
            "email": "EE",
            "phone": "DF",
            "title": "法定代表人",
            "certificateId": "D",
            "certificateType": "身份证"
          },
          {
            "file": {},
            "name": "44433C ",
            "email": "CX",
            "phone": "VCV",
            "title": "客服负责人",
            "certificateId": "C",
            "certificateType": "身份证"
          },
          {
            "file": {},
            "name": "WLLJJJ",
            "email": "SD",
            "phone": "EE",
            "title": "安全负责人",
            "certificateId": "D",
            "certificateType": "台湾居民往来内地同行证或台湾身份证"
          },
          {
            "file": {},
            "name": "C",
            "email": "XCC",
            "phone": "XCX",
            "title": "许可证负责人",
            "certificateId": "C",
            "certificateType": "台湾居民往来内地同行证或台湾身份证"
          }
        ],
        "companyInfo": {
          "bussinessDirection": "电力、热力、燃气及水生产和供应业",
          "staffSize": "大于等于10人,且小于100人",
          "businessScale": "无营收收入"
        },
        "files": [
          {
            "title": "法定代表人身份证",
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_13151591685846571202091457265719592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg",
              "name": "9592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg"
            }
          },
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_2405159253102215720201994342157.jpeg",
              "name": "47245E5D-C49F-4CBD-AD34-6E31048B6DE3.jpeg"
            },
            "title": "社保证明文件"
          }
        ]
      },
      //   --------    网络与信息安全 ----------
      "safetyData": {
        "safety": {
          "qualification": "XZXZ灌灌灌灌",//网络与信息安全管理组织机构设置及工作职责
          "responsibility": "ZXZX" //网络与信息安全管理人员配备情况及其相应资质
        },
        "files": []
      },
      //   --------    股东信息  ----------
      "shareholdersData": {
        "shareholdes": [
          {
            "name": "DD",//股东姓名
            "type": "境内机自然人",//股东性质
            "address": "SDSD",//证件号
            "idNumber": "XC",//证件号
            "companyCode": "EW",//上市公司代码
            "currencyType": "人民币",//出资方式
            "declareCompany": "DSD",//申报企业
            "holdProportion": 330,//持股比例（%）
            "waysInvestment": "货币",//出资方式
            "investmentAmount": 222022,//出资金额
            "superiorIdNumber": "SDS",//上级股东证件号
            "superiorShareholder": "SDS"//上级股东
          }, {
            "name": "111DD",//股东姓名
            "type": "111境内机自然人",//股东性质
            "address": "1111SDSD",//证件号
            "idNumber": "111XC",//证件号
            "companyCode": "111EW",//上市公司代码
            "currencyType": "人民币",//出资方式
            "declareCompany": "11DSD",//申报企业
            "holdProportion": 330,//持股比例（%）
            "waysInvestment": "货币",//出资方式
            "investmentAmount": 111222022,//出资金额
            "superiorIdNumber": "111SDS",//上级股东证件号
            "superiorShareholder": "111SDS"//上级股东
          }, {
            "name": "222DD",//股东姓名
            "type": "222境内机自然人",//股东性质
            "address": "222SDSD",//证件号
            "idNumber": "222XC",//证件号
            "companyCode": "222EW",//上市公司代码
            "currencyType": "222人民币",//出资方式
            "declareCompany": "222DSD",//申报企业
            "holdProportion": 330,//持股比例（%）
            "waysInvestment": "货币",//出资方式
            "investmentAmount": 333222022,//出资金额
            "superiorIdNumber": "S22DS",//上级股东证件号
            "superiorShareholder": "22SDS"//上级股东
          }, {
            "name": "222DD",//股东姓名
            "type": "222境内机自然人",//股东性质
            "address": "222SDSD",//证件号
            "idNumber": "222XC",//证件号
            "companyCode": "222EW",//上市公司代码
            "currencyType": "222人民币",//出资方式
            "declareCompany": "222DSD",//申报企业
            "holdProportion": 330,//持股比例（%）
            "waysInvestment": "货币",//出资方式
            "investmentAmount": 333222022,//出资金额
            "superiorIdNumber": "S22DS",//上级股东证件号
            "superiorShareholder": "22SDS"//上级股东
          }

        ],
        "files": [
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_1105159253099127720201994311277.jpeg",
              "name": "564A34E8-3D06-41BC-8BE8-E8C20B8EBCC0_4_5005_c.jpeg"
            },
            "title": "申请者国家企业信用信息公示系统截图"
          },
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_1065159253099988820201994319888.jpeg",
              "name": "564A34E8-3D06-41BC-8BE8-E8C20B8EBCC0_4_5005_c.jpeg"
            },
            "title": "股东追溯承诺书"
          },
          {
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_4415159168589478720209145814787公司宝logo（透明背景）.png",
              "name": "公司宝logo（透明背景）.png"
            },
            "title": "DD身份证"
          }
        ]
      },
      //   --------    电信业务承诺书  ----------
      "telecommunicationServiceData": {
        "files": [
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_1465159253100654120201994326541.jpeg",
              "name": "47245E5D-C49F-4CBD-AD34-6E31048B6DE3.jpeg"
            },
            "title": "依法经营电信业务承诺书"
          }
        ]
      },
      //   --------    其他材料  ----------
      "otherMaterialsData": {
        "files": [
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_4985159253101295020201994332950.jpeg",
              "name": "47245E5D-C49F-4CBD-AD34-6E31048B6DE3.jpeg"
            },
            "title": "服务器托管协议"
          },
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_3225159262160702520202010532725.jpeg",
              "name": "47245E5D-C49F-4CBD-AD34-6E31048B6DE3.jpeg"
            },
            "title": "收费方案"
          }
        ]
      }
    },
    {
      "id": 64,
      "type": "ICP",
      "registeredAddressData": {
        "authentication": {
          "companyType": "rwrwr",
          "enterpriseCode": "ddjdjdjjd不会后悔或多对多",
          "name": "woowoowo",
          "legalTypes": "企业法人",
          "legalName": "1",
          "legalCertificateId": "1",
          "legalCertificateType": "身份证",
          "contactAddress": "123"
        },
        "files": [
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_483515925309822962020199432296.jpeg",
              "name": "564A34E8-3D06-41BC-8BE8-E8C20B8EBCC0_4_5005_c.jpeg"
            },
            "title": "营业执照"
          },
          {
            "title": "法定代表人身份证件",
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_42451591683819189202091423391899592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg",
              "name": "9592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg"
            }
          }
        ]
      },
      "implementationPlanData": {
        "webApp": [
          {
            "name": "bnnn",
            "type": "网站",
            "domain": "kjjks",
            "appStoreName": "sss",
            "serverAddress": "sss"
          }
        ],
        "files": [
          {
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_42251591791734647202010202214647开篇词-面试，这样做会功到自然成.pdf",
              "name": "开篇词-面试，这样做会功到自然成.pdf"
            },
            "title": "专项审批项-新闻"
          },
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_238515925309868272020199436827.jpeg",
              "name": "564A34E8-3D06-41BC-8BE8-E8C20B8EBCC0_4_5005_c.jpeg"
            },
            "title": "域名证书"
          }
        ],
        "ICP": {
          "releaseAndDelivery": "fff,应用商店",
          "community": "论坛,社交平台,fsfsdfsf",
          "protectiveProcessing": "防病毒平台",
          "interactive": "即时通信",
          "search": "ff,搜索引擎",
          "targetUser": "企业,个人,政府/事业单位",
          "profitableWay": "前向用户收费,后向平台服务收费"
        }
      },
      "licenceData": {
        "licence": {
          "companyName": "woowoowo",
          "enterpriseCode": "ddjdjdjjd不会后悔或多对多",
          "registeredCapital": 5666666,
          "registerAddress": "dfgfdhd",
          "fixedTelephone": "3993939",
          "workAddress": "288282",
          "zipCode": "994994",
          "comapnyNature": "民营控股",
          "ifListed": "是"
        },
        "files": [
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_483515925309822962020199432296.jpeg",
              "name": "564A34E8-3D06-41BC-8BE8-E8C20B8EBCC0_4_5005_c.jpeg"
            },
            "title": "营业执照"
          }
        ]
      },
      "companyPersonnelData": {
        "personnelInfo": [
          {
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_42451591683819189202091423391899592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg",
              "name": "9592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg"
            },
            "name": "1",
            "email": "3",
            "phone": "2",
            "title": "法定代表人",
            "certificateId": "1",
            "certificateType": "身份证"
          },
          {
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_1135159168383773920209142357739公司宝logo（黑色背景）.jpg",
              "name": "公司宝logo（黑色背景）.jpg"
            },
            "name": "2",
            "email": "3",
            "phone": "2",
            "title": "客服负责人",
            "certificateId": "1",
            "certificateType": "身份证"
          },
          {
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_785159168404690720209142726907公司宝logo（透明背景）.png",
              "name": "公司宝logo（透明背景）.png"
            },
            "name": "34",
            "email": "4",
            "phone": "2",
            "title": "安全负责人",
            "certificateId": "1",
            "certificateType": "台湾居民往来内地同行证或台湾身份证"
          },
          {
            "file": {},
            "name": "4",
            "email": "3",
            "phone": "2",
            "title": "许可证负责人",
            "certificateId": "1",
            "certificateType": "台湾居民往来内地同行证或台湾身份证"
          }
        ],
        "companyInfo": {
          "bussinessDirection": "电力、热力、燃气及水生产和供应业",
          "staffSize": "小于10人",
          "businessScale": "无营收收入"
        },
        "files": [
          {
            "title": "法定代表人身份证",
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_42451591683819189202091423391899592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg",
              "name": "9592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg"
            }
          },
          {
            "title": "客服负责人身份证",
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_1135159168383773920209142357739公司宝logo（黑色背景）.jpg",
              "name": "公司宝logo（黑色背景）.jpg"
            }
          },
          {
            "title": "安全负责人身份证",
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_785159168404690720209142726907公司宝logo（透明背景）.png",
              "name": "公司宝logo（透明背景）.png"
            }
          },
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_2405159253102215720201994342157.jpeg",
              "name": "47245E5D-C49F-4CBD-AD34-6E31048B6DE3.jpeg"
            },
            "title": "社保证明文件"
          }
        ]
      },
      "safetyData": {
        "safety": {
          "qualification": "dwe3333",
          "responsibility": "jdjfsjkgjksd"
        },
        "files": []
      },
      "shareholdersData": {
        "shareholdes": [
          {
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_1435159168555660620209145236606开篇词-面试，这样做会功到自然成.pdf",
              "name": "开篇词-面试，这样做会功到自然成.pdf"
            },
            "name": "123",
            "type": "境外自然人",
            "address": "1313",
            "idNumber": "1111",
            "companyCode": "333",
            "currencyType": "美元",
            "declareCompany": "2232",
            "holdProportion": 20,
            "waysInvestment": "货币",
            "investmentAmount": 303033,
            "superiorIdNumber": "112",
            "superiorShareholder": "111"
          }
        ],
        "files": [
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_1105159253099127720201994311277.jpeg",
              "name": "564A34E8-3D06-41BC-8BE8-E8C20B8EBCC0_4_5005_c.jpeg"
            },
            "title": "申请者国家企业信用信息公示系统截图"
          },
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_1065159253099988820201994319888.jpeg",
              "name": "564A34E8-3D06-41BC-8BE8-E8C20B8EBCC0_4_5005_c.jpeg"
            },
            "title": "股东追溯承诺书"
          },
          {
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_1435159168555660620209145236606开篇词-面试，这样做会功到自然成.pdf",
              "name": "开篇词-面试，这样做会功到自然成.pdf"
            },
            "title": "123身份证"
          }
        ]
      },
      "telecommunicationServiceData": {
        "files": [
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_1465159253100654120201994326541.jpeg",
              "name": "47245E5D-C49F-4CBD-AD34-6E31048B6DE3.jpeg"
            },
            "title": "依法经营电信业务承诺书"
          }
        ]
      },
      "otherMaterialsData": {
        "files": [
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_4985159253101295020201994332950.jpeg",
              "name": "47245E5D-C49F-4CBD-AD34-6E31048B6DE3.jpeg"
            },
            "title": "服务器托管协议"
          },
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_3225159262160702520202010532725.jpeg",
              "name": "47245E5D-C49F-4CBD-AD34-6E31048B6DE3.jpeg"
            },
            "title": "收费方案"
          }
        ]
      }
    },
    {
      "id": 65,
      "type": "ICP",
      "registeredAddressData": {
        "authentication": {
          "companyType": "rwrwr",
          "enterpriseCode": "ddjdjdjjd不会后悔或多对多",
          "name": "woowoowo",
          "legalTypes": "企业法人",
          "legalName": "1",
          "legalCertificateId": "1",
          "legalCertificateType": "身份证",
          "contactAddress": "123"
        },
        "files": [
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_483515925309822962020199432296.jpeg",
              "name": "564A34E8-3D06-41BC-8BE8-E8C20B8EBCC0_4_5005_c.jpeg"
            },
            "title": "营业执照"
          },
          {
            "title": "法定代表人身份证件",
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_42451591683819189202091423391899592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg",
              "name": "9592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg"
            }
          }
        ]
      },
      "implementationPlanData": {
        "webApp": [
          {
            "name": "bnnn",
            "type": "网站",
            "domain": "kjjks",
            "appStoreName": "sss",
            "serverAddress": "sss"
          }
        ],
        "files": [
          {
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_42251591791734647202010202214647开篇词-面试，这样做会功到自然成.pdf",
              "name": "开篇词-面试，这样做会功到自然成.pdf"
            },
            "title": "专项审批项-新闻"
          },
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_238515925309868272020199436827.jpeg",
              "name": "564A34E8-3D06-41BC-8BE8-E8C20B8EBCC0_4_5005_c.jpeg"
            },
            "title": "域名证书"
          }
        ],
        "ICP": {
          "releaseAndDelivery": "fff,应用商店",
          "community": "论坛,社交平台,fsfsdfsf",
          "protectiveProcessing": "防病毒平台",
          "interactive": "即时通信",
          "search": "ff,搜索引擎",
          "targetUser": "企业,个人,政府/事业单位",
          "profitableWay": "前向用户收费,后向平台服务收费"
        }
      },
      "licenceData": {
        "licence": {
          "companyName": "woowoowo",
          "enterpriseCode": "ddjdjdjjd不会后悔或多对多",
          "registeredCapital": 5666666,
          "registerAddress": "dfgfdhd",
          "fixedTelephone": "3993939",
          "workAddress": "288282",
          "zipCode": "994994",
          "comapnyNature": "民营控股",
          "ifListed": "是"
        },
        "files": [
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_483515925309822962020199432296.jpeg",
              "name": "564A34E8-3D06-41BC-8BE8-E8C20B8EBCC0_4_5005_c.jpeg"
            },
            "title": "营业执照"
          }
        ]
      },
      "companyPersonnelData": {
        "personnelInfo": [
          {
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_42451591683819189202091423391899592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg",
              "name": "9592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg"
            },
            "name": "1",
            "email": "3",
            "phone": "2",
            "title": "法定代表人",
            "certificateId": "1",
            "certificateType": "身份证"
          },
          {
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_1135159168383773920209142357739公司宝logo（黑色背景）.jpg",
              "name": "公司宝logo（黑色背景）.jpg"
            },
            "name": "2",
            "email": "3",
            "phone": "2",
            "title": "客服负责人",
            "certificateId": "1",
            "certificateType": "身份证"
          },
          {
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_785159168404690720209142726907公司宝logo（透明背景）.png",
              "name": "公司宝logo（透明背景）.png"
            },
            "name": "34",
            "email": "4",
            "phone": "2",
            "title": "安全负责人",
            "certificateId": "1",
            "certificateType": "台湾居民往来内地同行证或台湾身份证"
          },
          {
            "file": {},
            "name": "4",
            "email": "3",
            "phone": "2",
            "title": "许可证负责人",
            "certificateId": "1",
            "certificateType": "台湾居民往来内地同行证或台湾身份证"
          }
        ],
        "companyInfo": {
          "bussinessDirection": "电力、热力、燃气及水生产和供应业",
          "staffSize": "小于10人",
          "businessScale": "无营收收入"
        },
        "files": [
          {
            "title": "法定代表人身份证",
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_42451591683819189202091423391899592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg",
              "name": "9592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg"
            }
          },
          {
            "title": "客服负责人身份证",
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_1135159168383773920209142357739公司宝logo（黑色背景）.jpg",
              "name": "公司宝logo（黑色背景）.jpg"
            }
          },
          {
            "title": "安全负责人身份证",
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_785159168404690720209142726907公司宝logo（透明背景）.png",
              "name": "公司宝logo（透明背景）.png"
            }
          },
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_2405159253102215720201994342157.jpeg",
              "name": "47245E5D-C49F-4CBD-AD34-6E31048B6DE3.jpeg"
            },
            "title": "社保证明文件"
          }
        ]
      },
      "safetyData": {
        "safety": {
          "qualification": "dwe3333",
          "responsibility": "jdjfsjkgjksd"
        },
        "files": []
      },
      "shareholdersData": {
        "shareholdes": [
          {
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_1435159168555660620209145236606开篇词-面试，这样做会功到自然成.pdf",
              "name": "开篇词-面试，这样做会功到自然成.pdf"
            },
            "name": "123",
            "type": "境外自然人",
            "address": "1313",
            "idNumber": "1111",
            "companyCode": "333",
            "currencyType": "美元",
            "declareCompany": "2232",
            "holdProportion": 20,
            "waysInvestment": "货币",
            "investmentAmount": 303033,
            "superiorIdNumber": "112",
            "superiorShareholder": "111"
          }
        ],
        "files": [
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_1105159253099127720201994311277.jpeg",
              "name": "564A34E8-3D06-41BC-8BE8-E8C20B8EBCC0_4_5005_c.jpeg"
            },
            "title": "申请者国家企业信用信息公示系统截图"
          },
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_1065159253099988820201994319888.jpeg",
              "name": "564A34E8-3D06-41BC-8BE8-E8C20B8EBCC0_4_5005_c.jpeg"
            },
            "title": "股东追溯承诺书"
          },
          {
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_1435159168555660620209145236606开篇词-面试，这样做会功到自然成.pdf",
              "name": "开篇词-面试，这样做会功到自然成.pdf"
            },
            "title": "123身份证"
          }
        ]
      },
      "telecommunicationServiceData": {
        "files": [
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_1465159253100654120201994326541.jpeg",
              "name": "47245E5D-C49F-4CBD-AD34-6E31048B6DE3.jpeg"
            },
            "title": "依法经营电信业务承诺书"
          }
        ]
      },
      "otherMaterialsData": {
        "files": [
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_4985159253101295020201994332950.jpeg",
              "name": "47245E5D-C49F-4CBD-AD34-6E31048B6DE3.jpeg"
            },
            "title": "服务器托管协议"
          },
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_3225159262160702520202010532725.jpeg",
              "name": "47245E5D-C49F-4CBD-AD34-6E31048B6DE3.jpeg"
            },
            "title": "收费方案"
          }
        ]
      }
    },
    {
      "id": 66,
      "type": "ICP",
      "registeredAddressData": {
        "authentication": {
          "companyType": "rwrwr",
          "enterpriseCode": "ddjdjdjjd不会后悔或多对多",
          "name": "woowoowo",
          "legalTypes": "企业法人",
          "legalName": "1",
          "legalCertificateId": "1",
          "legalCertificateType": "身份证",
          "contactAddress": "123"
        },
        "files": [
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_483515925309822962020199432296.jpeg",
              "name": "564A34E8-3D06-41BC-8BE8-E8C20B8EBCC0_4_5005_c.jpeg"
            },
            "title": "营业执照"
          },
          {
            "title": "法定代表人身份证件",
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_42451591683819189202091423391899592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg",
              "name": "9592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg"
            }
          }
        ]
      },
      "implementationPlanData": {
        "webApp": [
          {
            "name": "bnnn",
            "type": "网站",
            "domain": "kjjks",
            "appStoreName": "sss",
            "serverAddress": "sss"
          }
        ],
        "files": [
          {
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_42251591791734647202010202214647开篇词-面试，这样做会功到自然成.pdf",
              "name": "开篇词-面试，这样做会功到自然成.pdf"
            },
            "title": "专项审批项-新闻"
          },
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_238515925309868272020199436827.jpeg",
              "name": "564A34E8-3D06-41BC-8BE8-E8C20B8EBCC0_4_5005_c.jpeg"
            },
            "title": "域名证书"
          }
        ],
        "ICP": {
          "releaseAndDelivery": "fff,应用商店",
          "community": "论坛,社交平台,fsfsdfsf",
          "protectiveProcessing": "防病毒平台",
          "interactive": "即时通信",
          "search": "ff,搜索引擎",
          "targetUser": "企业,个人,政府/事业单位",
          "profitableWay": "前向用户收费,后向平台服务收费"
        }
      },
      "licenceData": {
        "licence": {
          "companyName": "woowoowo",
          "enterpriseCode": "ddjdjdjjd不会后悔或多对多",
          "registeredCapital": 5666666,
          "registerAddress": "dfgfdhd",
          "fixedTelephone": "3993939",
          "workAddress": "288282",
          "zipCode": "994994",
          "comapnyNature": "民营控股",
          "ifListed": "是"
        },
        "files": [
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_483515925309822962020199432296.jpeg",
              "name": "564A34E8-3D06-41BC-8BE8-E8C20B8EBCC0_4_5005_c.jpeg"
            },
            "title": "营业执照"
          }
        ]
      },
      "companyPersonnelData": {
        "personnelInfo": [
          {
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_42451591683819189202091423391899592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg",
              "name": "9592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg"
            },
            "name": "1",
            "email": "3",
            "phone": "2",
            "title": "法定代表人",
            "certificateId": "1",
            "certificateType": "身份证"
          },
          {
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_1135159168383773920209142357739公司宝logo（黑色背景）.jpg",
              "name": "公司宝logo（黑色背景）.jpg"
            },
            "name": "2",
            "email": "3",
            "phone": "2",
            "title": "客服负责人",
            "certificateId": "1",
            "certificateType": "身份证"
          },
          {
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_785159168404690720209142726907公司宝logo（透明背景）.png",
              "name": "公司宝logo（透明背景）.png"
            },
            "name": "34",
            "email": "4",
            "phone": "2",
            "title": "安全负责人",
            "certificateId": "1",
            "certificateType": "台湾居民往来内地同行证或台湾身份证"
          },
          {
            "file": {},
            "name": "4",
            "email": "3",
            "phone": "2",
            "title": "许可证负责人",
            "certificateId": "1",
            "certificateType": "台湾居民往来内地同行证或台湾身份证"
          }
        ],
        "companyInfo": {
          "bussinessDirection": "电力、热力、燃气及水生产和供应业",
          "staffSize": "小于10人",
          "businessScale": "无营收收入"
        },
        "files": [
          {
            "title": "法定代表人身份证",
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_42451591683819189202091423391899592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg",
              "name": "9592BBA6-5CA0-4536-83B7-7E8BAD85CCFE.jpeg"
            }
          },
          {
            "title": "客服负责人身份证",
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_1135159168383773920209142357739公司宝logo（黑色背景）.jpg",
              "name": "公司宝logo（黑色背景）.jpg"
            }
          },
          {
            "title": "安全负责人身份证",
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_785159168404690720209142726907公司宝logo（透明背景）.png",
              "name": "公司宝logo（透明背景）.png"
            }
          },
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_2405159253102215720201994342157.jpeg",
              "name": "47245E5D-C49F-4CBD-AD34-6E31048B6DE3.jpeg"
            },
            "title": "社保证明文件"
          }
        ]
      },
      "safetyData": {
        "safety": {
          "qualification": "dwe3333",
          "responsibility": "jdjfsjkgjksd"
        },
        "files": []
      },
      "shareholdersData": {
        "shareholdes": [
          {
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_1435159168555660620209145236606开篇词-面试，这样做会功到自然成.pdf",
              "name": "开篇词-面试，这样做会功到自然成.pdf"
            },
            "name": "123",
            "type": "境外自然人",
            "address": "1313",
            "idNumber": "1111",
            "companyCode": "333",
            "currencyType": "美元",
            "declareCompany": "2232",
            "holdProportion": 20,
            "waysInvestment": "货币",
            "investmentAmount": 303033,
            "superiorIdNumber": "112",
            "superiorShareholder": "111"
          }
        ],
        "files": [
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_1105159253099127720201994311277.jpeg",
              "name": "564A34E8-3D06-41BC-8BE8-E8C20B8EBCC0_4_5005_c.jpeg"
            },
            "title": "申请者国家企业信用信息公示系统截图"
          },
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_1065159253099988820201994319888.jpeg",
              "name": "564A34E8-3D06-41BC-8BE8-E8C20B8EBCC0_4_5005_c.jpeg"
            },
            "title": "股东追溯承诺书"
          },
          {
            "file": {
              "url": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_1435159168555660620209145236606开篇词-面试，这样做会功到自然成.pdf",
              "name": "开篇词-面试，这样做会功到自然成.pdf"
            },
            "title": "123身份证"
          }
        ]
      },
      "telecommunicationServiceData": {
        "files": [
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_1465159253100654120201994326541.jpeg",
              "name": "47245E5D-C49F-4CBD-AD34-6E31048B6DE3.jpeg"
            },
            "title": "依法经营电信业务承诺书"
          }
        ]
      },
      "otherMaterialsData": {
        "files": [
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_4985159253101295020201994332950.jpeg",
              "name": "47245E5D-C49F-4CBD-AD34-6E31048B6DE3.jpeg"
            },
            "title": "服务器托管协议"
          },
          {
            "file": {
              "url": "http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/zc_3225159262160702520202010532725.jpeg",
              "name": "47245E5D-C49F-4CBD-AD34-6E31048B6DE3.jpeg"
            },
            "title": "收费方案"
          }
        ]
      }
    }
  ],
  "bizmsg": "empty"
};

class TestTask extends TaskBase {
  constructor() {
    super(TaskBase.getServiceName(TestTask));

  }


  async subBeforeTask(params) {

    // console.log("----++++++++++++++++++++-----------前置操作......", this.serviceName);
    // var cos = new COS({
    //   SecretId: "AKIDnPWjiUFatAHahwtsV8KJ2jDONAA4KG6k",
    //   SecretKey: "xJmXncXcbAW9YEeITUWr192t6sQiEYBU",
    //   // SecretId: "AKIDEEuMglVIlESr3ZQx2jBO5YQ2zsVUpo55",
    //   // SecretKey: "sTR7jRt0UIsEJGzhCQN7aoEQN2RD5g4C",
    // });

    //创建目录,判断文件目录是否存在，不存在就创建  
    if (!fs.existsSync('upload')) {
      fs.mkdirSync('upload');
    }
    var reslist = [];
    //遍历数据
    var datalist = resultinfo.data;
    for (var j = 0; j < datalist.length; j++) {
      var exceldata = datalist[j];
      //编号id
      var Id = exceldata.id;
      var type = exceldata.type;
      var id_dir = 'upload/' + Id;
      var registeredAddress_dir = id_dir + '/01-注册认证';
      var implementationPlan_dir = id_dir + '/02-发展和实施计划';
      var licence_dir = id_dir + '/03-增值电信申请表';
      var companyPersonnel_dir = id_dir + '/04-公司及人员情况';
      var safety_dir = id_dir + '/05-网络与信息安全';
      var shareholders_dir = id_dir + '/06-股东信息';
      var telecommunication_dir = id_dir + '/07-电信业务承诺书';
      var rotherMaterials_dir = id_dir + '/08-其他材料';
      if (!fs.existsSync(id_dir)) {
        fs.mkdirSync(id_dir);
      }
      //复制文件夹及文件
      child_process.spawn('cp', ['-r', 'template/01-注册认证', id_dir]);
      child_process.spawn('cp', ['-r', 'template/02-发展和实施计划', id_dir]);
      child_process.spawn('cp', ['-r', 'template/03-增值电信申请表', id_dir]);
      child_process.spawn('cp', ['-r', 'template/04-公司及人员情况', id_dir]);
      child_process.spawn('cp', ['-r', 'template/05-网络与信息安全', id_dir]);
      child_process.spawn('cp', ['-r', 'template/06-股东信息', id_dir]);
      child_process.spawn('cp', ['-r', 'template/07-电信业务承诺书', id_dir]);
      child_process.spawn('cp', ['-r', 'template/08-其他材料', id_dir]);
      // child_process.spawn('cp', ['template/材料清单.xlsx', id_dir]);
      //------------------------创建  01-注册认证 ------------------------
      if (fs.existsSync(registeredAddress_dir)) {
        var registeredAddressData = exceldata.registeredAddressData;
        var workbook = new excel.Workbook();
        await workbook.xlsx.readFile(registeredAddress_dir + "/实名认证.xlsx").then(function () {
          var worksheet = workbook.getWorksheet("实名认证"); //获取第一个worksheet
          // console.log("-------------------", workbook.worksheets);
          worksheet.eachRow(function (row, rowNumber) {
            // console.log('Row ' + rowNumber + ' = ' + JSON.stringify(row.values));
            // console.log(row.values);
            if (rowNumber == 2) {
              row.eachCell(function (cell, colNumber) {
                // if (cell.type == 6) {
                //   var value = cell.result;
                // } else {
                //   var value = cell.value;
                // }
                if (colNumber == 2) {
                  // console.log('Cell ' + colNumber + ' = ' + cell.type + " " + value);
                  cell.value = registeredAddressData.authentication.personType;
                }

              });
            }
            if (rowNumber == 3) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 2) {
                  cell.value = registeredAddressData.authentication.companyType;
                }

              });
            }
            if (rowNumber == 4) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 2) {
                  cell.value = registeredAddressData.authentication.enterpriseCode;
                }

              });
            }
            if (rowNumber == 5) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 2) {
                  cell.value = registeredAddressData.authentication.name;
                }

              });
            }
            if (rowNumber == 6) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 2) {
                  cell.value = registeredAddressData.authentication.legalTypes;
                }

              });
            }
            if (rowNumber == 7) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 2) {
                  cell.value = registeredAddressData.authentication.legalName;
                }

              });
            }
            if (rowNumber == 8) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 2) {
                  cell.value = registeredAddressData.authentication.legalCertificateId;
                }

              });
            }
            if (rowNumber == 9) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 2) {
                  cell.value = registeredAddressData.authentication.legalCertificateType;
                }

              });
            }
            if (rowNumber == 10) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 2) {
                  cell.value = registeredAddressData.authentication.contactAddress;
                }

              });
            }

          });
          workbook.xlsx.writeFile(registeredAddress_dir + "/实名认证.xlsx");
        });
        //下载文件
        var files = registeredAddressData.files;
        await this.downFile(files, registeredAddress_dir);
      }
      //------------------------02-发展和实施计划 ------------------------
      if (fs.existsSync(implementationPlan_dir)) {
        var implementationPlanData = exceldata.implementationPlanData;
        if (type == "EDI") {
          fs.unlinkSync(implementationPlan_dir + "/发展和实施计划-ICP.xlsx");
          var implementationPlan_workbook = new excel.Workbook();
          await implementationPlan_workbook.xlsx.readFile(implementationPlan_dir + "/发展和实施计划-EDI.xlsx").then(function () {
            var worksheet = implementationPlan_workbook.getWorksheet("发展和实施计划-EDI"); //获取第一个worksheet
            // console.log("---------------------",workbook.worksheets);
            worksheet.eachRow(function (row, rowNumber) {
              // console.log('Row ' + rowNumber + ' = ' + JSON.stringify(row.values));
              // console.log(row.values);
              if (rowNumber == 3) {
                row.eachCell(function (cell, colNumber) {
                  if (colNumber == 2) {
                    cell.value = implementationPlanData.EDI.electronicExchange;
                  }

                });
              }
              if (rowNumber == 4) {
                row.eachCell(function (cell, colNumber) {
                  if (colNumber == 2) {
                    cell.value = implementationPlanData.EDI.transactionProcessing;
                  }

                });
              }
              if (rowNumber == 5) {
                row.eachCell(function (cell, colNumber) {
                  if (colNumber == 2) {
                    cell.value = implementationPlanData.EDI.dataProcessing;
                  }

                });
              }
              if (rowNumber == 6) {
                row.eachCell(function (cell, colNumber) {
                  if (colNumber == 2) {
                    cell.value = implementationPlanData.EDI.targetUser;
                  }

                });
              }
              if (rowNumber == 7) {
                row.eachCell(function (cell, colNumber) {
                  if (colNumber == 2) {
                    cell.value = implementationPlanData.EDI.profitableWay;
                  }
                });
              }

            });
            implementationPlan_workbook.xlsx.writeFile(implementationPlan_dir + "/发展和实施计划-EDI.xlsx").then(function () { });;
          });
        } else if (type == "ICP") {
          fs.unlinkSync(implementationPlan_dir + "/发展和实施计划-EDI.xlsx");
          var icp_workbook = new excel.Workbook();
          await icp_workbook.xlsx.readFile(implementationPlan_dir + "/发展和实施计划-ICP.xlsx").then(function () {
            var worksheet = icp_workbook.getWorksheet("发展和实施计划-ICP"); //获取第一个worksheet
            // console.log(workbook.worksheets);
            worksheet.eachRow(function (row, rowNumber) {
              // console.log('Row ' + rowNumber + ' = ' + JSON.stringify(row.values));
              // console.log(row.values);
              if (rowNumber == 3) {
                row.eachCell(function (cell, colNumber) {
                  if (colNumber == 2) {
                    cell.value = implementationPlanData.ICP.releaseAndDelivery;
                  }

                });
              }
              if (rowNumber == 4) {
                row.eachCell(function (cell, colNumber) {
                  if (colNumber == 2) {
                    cell.value = implementationPlanData.ICP.community;
                  }

                });
              }
              if (rowNumber == 5) {
                row.eachCell(function (cell, colNumber) {
                  if (colNumber == 2) {
                    cell.value = implementationPlanData.ICP.protectiveProcessing;
                  }

                });
              }
              if (rowNumber == 6) {
                row.eachCell(function (cell, colNumber) {
                  if (colNumber == 2) {
                    cell.value = implementationPlanData.ICP.interactive;
                  }

                });
              }
              if (rowNumber == 7) {
                row.eachCell(function (cell, colNumber) {
                  if (colNumber == 2) {
                    cell.value = implementationPlanData.ICP.search;
                  }
                });
              }
              if (rowNumber == 8) {
                row.eachCell(function (cell, colNumber) {
                  if (colNumber == 2) {
                    cell.value = implementationPlanData.ICP.targetUser;
                  }
                });
              }
              if (rowNumber == 9) {
                row.eachCell(function (cell, colNumber) {
                  if (colNumber == 2) {
                    cell.value = implementationPlanData.ICP.profitableWay;
                  }
                });
              }

            });
            icp_workbook.xlsx.writeFile(implementationPlan_dir + "/发展和实施计划-ICP.xlsx").then(function () { });;
          });
        }
        //网站或APP信息
        var webappdata = implementationPlanData.webApp;
        var webapp_workbook = new excel.Workbook();
        await webapp_workbook.xlsx.readFile(implementationPlan_dir + "/网站或APP信息.xlsx").then(function () {
          var worksheet = webapp_workbook.getWorksheet("网站或APP信息"); //获取第一个worksheet
          for (var i = 0; i < webappdata.length; i++) {
            var wd = webappdata[i];
            var rw = worksheet.addRow([wd.name, wd.type, wd.domain, wd.appStoreName, wd.serverAddress]);
            rw.eachCell(function (cell) {
              // cell.fill = {
              //   type: 'pattern',
              //   pattern: 'solid',
              //   fgColor: { argb: 'deeded' }
              // };
              // cell.font = { name: 'Arial', size: 14 };
              cell.alignment = { horizontal: 'center' };
              cell.border = {
                top: { style: "thin" },
                left: { style: "thin" },
                bottom: { style: "thin" },
                right: { style: "thin" }
              };

            });
          }
          webapp_workbook.xlsx.writeFile(implementationPlan_dir + "/网站或APP信息.xlsx").then(function () { });
        });
        //下载文件
        var files = implementationPlanData.files;
        await this.downFile(files, implementationPlan_dir);

      }
      //------------------------03-增值电信申请表 ------------------------
      if (fs.existsSync(licence_dir)) {
        var licenceData = exceldata.licenceData;
        var licence_workbook = new excel.Workbook();
        await licence_workbook.xlsx.readFile(licence_dir + "/增值电信业务经营许可证申请表.xlsx").then(function () {
          var worksheet = licence_workbook.getWorksheet("增值电信业务经营许可证申请表.xlsx"); //获取第一个worksheet
          // console.log("-------------------", workbook.worksheets);
          worksheet.eachRow(function (row, rowNumber) {
            if (rowNumber == 2) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 2) {
                  // console.log('Cell ' + colNumber + ' = ' + cell.type + " " + value);
                  cell.value = licenceData.licence.companyName;
                }
              });
            }
            if (rowNumber == 3) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 2) {
                  cell.value = licenceData.licence.enterpriseCode;
                }
              });
            }
            if (rowNumber == 4) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 2) {
                  cell.value = licenceData.licence.registeredCapital;
                }
              });
            }
            if (rowNumber == 5) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 2) {
                  cell.value = licenceData.licence.registerAddress;
                }
              });
            }
            if (rowNumber == 6) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 2) {
                  cell.value = licenceData.licence.fixedTelephone;
                }
              });
            }
            if (rowNumber == 7) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 2) {
                  cell.value = licenceData.licence.workAddress;
                }
              });
            }
            if (rowNumber == 8) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 2) {
                  cell.value = licenceData.licence.zipCode;
                }

              });
            }
            if (rowNumber == 9) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 2) {
                  cell.value = licenceData.licence.comapnyNature;
                }
              });
            }
            if (rowNumber == 10) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 2) {
                  cell.value = licenceData.licence.ifListed;
                }
              });
            }

          });
          licence_workbook.xlsx.writeFile(licence_dir + "/增值电信业务经营许可证申请表.xlsx").then(function () { });
        });
        //下载文件
        var files = licenceData.files;
        await this.downFile(files, licence_dir);

      }
      //------------------------04-公司及人员情况 ------------------------
      if (fs.existsSync(companyPersonnel_dir)) {
        var companyPersonnelData = exceldata.companyPersonnelData;
        var companyPersonnel_workbook = new excel.Workbook();
        await companyPersonnel_workbook.xlsx.readFile(companyPersonnel_dir + "/公司人员情况.xlsx").then(function () {
          var worksheet = companyPersonnel_workbook.getWorksheet("公司及人员情况"); //获取第一个worksheet
          // console.log("-------------------", workbook.worksheets);
          worksheet.eachRow(function (row, rowNumber) {
            if (rowNumber == 3) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 1) {
                  // console.log('Cell ' + colNumber + ' = ' + cell.value);
                  cell.value = companyPersonnelData.personnelInfo[0].title;
                }
                if (colNumber == 2) {
                  cell.value = companyPersonnelData.personnelInfo[0].name;
                }
                if (colNumber == 3) {
                  cell.value = companyPersonnelData.personnelInfo[0].certificateType;
                }
                if (colNumber == 4) {
                  cell.value = companyPersonnelData.personnelInfo[0].certificateId;
                }
                if (colNumber == 5) {
                  cell.value = companyPersonnelData.personnelInfo[0].phone;
                }
                if (colNumber == 6) {
                  cell.value = companyPersonnelData.personnelInfo[0].email;
                }
              });
            }
            if (rowNumber == 4) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 1) {
                  cell.value = companyPersonnelData.personnelInfo[1].title;
                }
                if (colNumber == 2) {
                  cell.value = companyPersonnelData.personnelInfo[1].name;
                }
                if (colNumber == 3) {
                  cell.value = companyPersonnelData.personnelInfo[1].certificateType;
                }
                if (colNumber == 4) {
                  cell.value = companyPersonnelData.personnelInfo[1].certificateId;
                }
                if (colNumber == 5) {
                  cell.value = companyPersonnelData.personnelInfo[1].phone;
                }
                if (colNumber == 6) {
                  cell.value = companyPersonnelData.personnelInfo[1].email;
                }
              });
            }
            if (rowNumber == 5) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 1) {
                  cell.value = companyPersonnelData.personnelInfo[2].title;
                }
                if (colNumber == 2) {
                  cell.value = companyPersonnelData.personnelInfo[2].name;
                }
                if (colNumber == 3) {
                  cell.value = companyPersonnelData.personnelInfo[2].certificateType;
                }
                if (colNumber == 4) {
                  cell.value = companyPersonnelData.personnelInfo[2].certificateId;
                }
                if (colNumber == 5) {
                  cell.value = companyPersonnelData.personnelInfo[2].phone;
                }
                if (colNumber == 6) {
                  cell.value = companyPersonnelData.personnelInfo[2].email;
                }
              });
            }
            if (rowNumber == 6) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 1) {
                  cell.value = companyPersonnelData.personnelInfo[3].title;
                }
                if (colNumber == 2) {
                  cell.value = companyPersonnelData.personnelInfo[3].name;
                }
                if (colNumber == 3) {
                  cell.value = companyPersonnelData.personnelInfo[3].certificateType;
                }
                if (colNumber == 4) {
                  cell.value = companyPersonnelData.personnelInfo[3].certificateId;
                }
                if (colNumber == 5) {
                  cell.value = companyPersonnelData.personnelInfo[3].phone;
                }
                if (colNumber == 6) {
                  cell.value = companyPersonnelData.personnelInfo[3].email;
                }
              });
            }

            if (rowNumber == 8) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 2) {
                  cell.value = companyPersonnelData.companyInfo.bussinessDirection;
                }
              });
            }
            if (rowNumber == 9) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 2) {
                  cell.value = companyPersonnelData.companyInfo.staffSize;
                }
              });
            }
            if (rowNumber == 10) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 2) {
                  cell.value = companyPersonnelData.companyInfo.businessScale;
                }
              });
            }

          });
          companyPersonnel_workbook.xlsx.writeFile(companyPersonnel_dir + "/公司人员情况.xlsx").then(function () { });
        });
        //下载文件
        var files = companyPersonnelData.files;
        await this.downFile(files, companyPersonnel_dir);

      }
      //------------------------05-网络与信息安全 ------------------------
      if (fs.existsSync(safety_dir)) {
        var safetyData = exceldata.safetyData;
        var safety_workbook = new excel.Workbook();
        await safety_workbook.xlsx.readFile(safety_dir + "/网络与信息安全保障措施.xlsx").then(function () {
          var worksheet = safety_workbook.getWorksheet("网络与信息安全保障措施"); //获取第一个worksheet
          // console.log("-------------------", workbook.worksheets);
          worksheet.eachRow(function (row, rowNumber) {
            if (rowNumber == 2) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 2) {
                  // console.log('Cell ' + colNumber + ' = ' + cell.type + " " + value);
                  cell.value = safetyData.safety.qualification;
                }
              });
            }
            if (rowNumber == 3) {
              row.eachCell(function (cell, colNumber) {
                if (colNumber == 2) {
                  cell.value = safetyData.safety.responsibility;
                }
              });
            }
          });
          safety_workbook.xlsx.writeFile(safety_dir + "/网络与信息安全保障措施.xlsx").then(function () { });
        });
        //下载文件
        var files = safetyData.files;
        await this.downFile(files, safety_dir);
      }
      //------------------------06-股东信息 ------------------------
      if (fs.existsSync(shareholders_dir)) {
        var shareholdersData = exceldata.shareholdersData;
        var shareholders_workbook = new excel.Workbook();
        await shareholders_workbook.xlsx.readFile(shareholders_dir + "/股东信息.xlsx").then(function () {
          var worksheet = shareholders_workbook.getWorksheet("股权信息"); //获取第一个worksheet
          for (var i = 0; i < shareholdersData.shareholdes.length; i++) {
            // console.log(shareholdersData.shareholdes[i]);
            var shareholde = shareholdersData.shareholdes[i];
            var rw = worksheet.addRow([shareholde.name, shareholde.type, shareholde.idNumber, shareholde.holdProportion, shareholde.superiorShareholder, shareholde.superiorIdNumber, shareholde.companyCode, shareholde.declareCompany, shareholde.waysInvestment, shareholde.investmentAmount, shareholde.currencyType, shareholde.address]);
            rw.eachCell(function (cell) {
              // cell.fill = {
              //   type: 'pattern',
              //   pattern: 'solid',
              //   fgColor: { argb: 'deeded' }
              // };
              // cell.font = { name: 'Arial', size: 14 };
              cell.alignment = { horizontal: 'center' };
              cell.border = {
                top: { style: "thin" },
                left: { style: "thin" },
                bottom: { style: "thin" },
                right: { style: "thin" }
              };

            });
          }
          shareholders_workbook.xlsx.writeFile(shareholders_dir + "/股东信息.xlsx").then(function () { });
        });

        //下载文件
        var files = shareholdersData.files;
        await this.downFile(files, shareholders_dir);
      }
      //------------------------07-电信业务承诺书 ------------------------
      if (fs.existsSync(telecommunication_dir)) {
        //下载文件
        var files = exceldata.telecommunicationServiceData.files;
        await this.downFile(files, telecommunication_dir);
      }
      //------------------------08-其他材料 ------------------------
      if (fs.existsSync(rotherMaterials_dir)) {
        //下载文件
        var files = exceldata.otherMaterialsData.files;
        await this.downFile(files, rotherMaterials_dir);
      }

      //打包压缩
      var zipdir = id_dir + '.zip';
      var output = fs.createWriteStream(zipdir);
      var archive = archiver('zip');
      archive.on('error', function (err) {
        throw err;
      });
      archive.pipe(output);
      archive.directory(id_dir, false);
      await archive.finalize();

      var result = {
        "id": Id,
        "id_url": ""
      }
      //把打包文件上传到cos
      // var cos1 = new COS({
      //   SecretId: "AKIDnPWjiUFatAHahwtsV8KJ2jDONAA4KG6k",
      //   SecretKey: "xJmXncXcbAW9YEeITUWr192t6sQiEYBU",
      //   // SecretId: "AKIDEEuMglVIlESr3ZQx2jBO5YQ2zsVUpo55",
      //   // SecretKey: "sTR7jRt0UIsEJGzhCQN7aoEQN2RD5g4C",
      // });
      var bucket = 'test-1258715722'; /* 必须 */
      var begion = 'ap-beijing';   /* 必须 */
      var cos = new COS({
        getAuthorization: function (options, callback) {
          // console.log("-------------------------------");
          // 异步获取临时密钥
          request({
            url: 'http://192.168.1.128:4018/api/uploadAction/txCos/getCosInfo',
            data: {
              // 可从 options 取需要的参数
              // Bucket: "brg-1257943044",
              // Region: "ap-nanjing",
              // Bucket: 'test-1258715722', /* 必须 */
              // Region: 'ap-beijing',    /* 必须 */
            }
          }, function (err, response, body) {
            try {
              var resultdata = JSON.parse(body);
              if (resultdata.status == 1) {
                var data = resultdata.data;
                // console.log('-----------------', data);
                var credentials = data.credentials;
                Bucket = credentials.tmpBucket;
                Region = credentials.tmpRegion;
              }
            } catch (e) { }
            if (!data || !credentials) return console.error('credentials invalid');
            callback({
              TmpSecretId: credentials.tmpSecretId,        // 临时密钥的 tmpSecretId
              TmpSecretKey: credentials.tmpSecretKey,      // 临时密钥的 tmpSecretKey
              XCosSecurityToken: credentials.sessionToken, // 临时密钥的 sessionToken
              ExpiredTime: data.expiredTime,               // 临时密钥失效时间戳，是申请临时密钥时，时间戳加 durationSeconds
            });
          });
        }
      });
      try {
        var getParam = await new Promise(function (resv, rej) {
          cos.putObject({
            Bucket: bucket, /* 必须 */
            Region: begion,    /* 必须 */
            // Bucket: "brg-1257943044",
            // Region: "ap-nanjing",
            Key: zipdir,              /* 必须 */
            // StorageClass: 'STANDARD',
            Body: fs.createReadStream(zipdir),
          }, function (err, data) {
            if (err) {
              rej(false);
            } else {
              if (data.statusCode == 200) {
                resv(data.Location);
              } else {
                resv(false);
              }
            }
          });
        });
      } catch (error) {
        console.log(error);
      }
      if (getParam) {
        result.id_url = 'http://' + getParam;
      }
      console.log(result);
      // reslist.push(result);
    }
    // 删除文件夹
    for (var j = 0; j < datalist.length; j++) {
      var exceldata = datalist[j];
      //编号id
      var Id = exceldata.id;
      //文件夹
      var id_dir = 'upload/' + Id;
      //压缩包
      var id_zip = id_dir + '.zip';
      if (fs.existsSync(id_dir)) {
        // delete
        child_process.spawn('rm', ['-r', id_dir]);

      }
      if (fs.existsSync(id_zip)) {
        child_process.spawn('rm', [id_zip]);
      }
    }

  }
  //下载文件函数
  async downFile(data, dir) {
    // console.log(data, dir);
    //下载文件
    var bucket = 'test-1258715722'; /* 必须 */
    var region = 'ap-beijing';   /* 必须 */
    var cos = new COS({
      getAuthorization: function (options, callback) {
        // 异步获取临时密钥
        request({
          url: 'http://192.168.1.128:4018/api/uploadAction/txCos/getCosInfo',
          data: {
            // 可从 options 取需要的参数
            // Bucket: "brg-1257943044",
            // Region: "ap-nanjing",
            // Bucket: 'test-1258715722', /* 必须 */
            // Region: 'ap-beijing',    /* 必须 */
          }
        }, function (err, response, body) {
          try {
            var resultdata = JSON.parse(body);
            if (resultdata.status == 1) {
              var data = resultdata.data;
              // console.log('-----------------', data);
              var credentials = data.credentials;
              Bucket = credentials.tmpBucket;
              Region = credentials.tmpRegion;
            }
          } catch (e) { }
          if (!data || !credentials) return console.error('credentials invalid');
          callback({
            TmpSecretId: credentials.tmpSecretId,        // 临时密钥的 tmpSecretId
            TmpSecretKey: credentials.tmpSecretKey,      // 临时密钥的 tmpSecretKey
            XCosSecurityToken: credentials.sessionToken, // 临时密钥的 sessionToken
            ExpiredTime: data.expiredTime,               // 临时密钥失效时间戳，是申请临时密钥时，时间戳加 durationSeconds
          });
        });
      }
    });
    var downfiles = data;
    for (var i = 0; i < downfiles.length; i++) {
      var filedata = downfiles[i];
      var file_url = filedata.file.url;
      var arr = file_url.split("myqcloud.com/")
      if (arr.length > 1) {
        var key = arr[arr.length - 1];
        var key_arr = key.split(".")
        var key_type = key_arr[key_arr.length - 1];
        var title = filedata.title;
        if (title) {
          var titlename = title + '.' + key_type;
          var output = dir + '/' + titlename;
          // await cos.getObject({
          //   Bucket: 'test-1258715722', /* 必须 */
          //   Region: 'ap-beijing',    /* 必须 */
          //   Key: key,
          //   Output: output,
          // }, function (err, data) {
          //   console.log(err || data);
          // });
          await this.downLoadFile(bucket, region, cos, key, output);

        }
      }
    }
  }
  downLoadFile(bucket, region, cos, key, output) {
    return new Promise((resolve, reject) => {
      cos.getObject({
        Bucket: bucket, /* 必须 */
        Region: region,    /* 必须 */
        Key: key,
        Output: output,
      }, function (err, data) {
        // console.log(err || data);
        if (err) {
          reject(false);
        } else {
          resolve(true);
        }
      });
    })
  }

  async subDoTask(params) {
    console.log(params);
    console.log("TestTask1.....");
  }
}
module.exports = TestTask;