Commit e04b93bf by 任晓松

腾讯需求导入

parent 24f432f1
......@@ -77,6 +77,9 @@ class IcAPI extends APIBase {
case "queryExpertApplyCommunicationLogs":// 查询需求沟通记录 2020-10-28 laolan
opResult = await this.needinfoSve2.queryExpertApplyCommunicationLogs(pobj, pobj.actionBody, req);
break;
case "bulkCreateNeeds":
opResult = await this.needinfoSve.bulkCreateNeeds(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
......@@ -26,6 +26,18 @@ class Dao {
});
}
}
async bulkCreate(u,t){
if (t != null && t != 'undefined') {
return this.model.bulkCreate(u, { transaction: t }).then(u => {
return u;
});
} else {
return this.model.bulkCreate(u).then(u => {``
return u;
});
}
}
static getModelName(ClassObj) {
return ClassObj["name"].substring(0, ClassObj["name"].lastIndexOf("Dao")).toLowerCase()
}
......
......@@ -84,7 +84,13 @@ module.exports = {
// 诊断结果
"diagnosis_result": { "tg": "通过", "wtg": "未通过", "rgshz": "人工审核中" },
// 诊断处理状态
"diagnosis_status": { "dcl": "待处理", "gtz": "沟通中", "dqrfa": "待确认方案", "ygb": "已关闭", "ywc": "已完成" }
},
"diagnosis_status": { "dcl": "待处理", "gtz": "沟通中", "dqrfa": "待确认方案", "ygb": "已关闭", "ywc": "已完成" },
//腾讯需求商机状态名称
"tx_need_status_name":{"待处理":"已推送","跟进中":"已跟进","待用户确认":"已跟进","已成交":"已成单","已关闭":"已关闭"},
//腾讯需求商机状态码
"tx_need_status":{"待处理":"yts","跟进中":"ygj","待用户确认":"ygj","已成交":"ycd","已关闭":"ygb"},
//腾讯产品码
"tx_product":{"公司注册":"gszc","跟进中":"kzfu","税务报道":"swbd","税控申请":"sksq","代理记账":"dljz","银行开户":"yhkh","工商变更":"gsbg","工商年报":"gsnb","社保开户":"sbkh","云上园区服务":"ysgszc","icp":"icpsq","edi":"edisq","icp年报":"icpnb","edi年报":"edinb"},
},
}
}
\ No newline at end of file
......@@ -3,6 +3,8 @@ const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
var moment = require('moment')
const uiconfig = require("../../../db/metadata/apps/platform");
class NeedinfoService extends ServiceBase {
constructor() {
super("dbneed", ServiceBase.getDaoName(NeedinfoService));
......@@ -357,6 +359,54 @@ class NeedinfoService extends ServiceBase {
return system.getResult(null, "operationType参数错误");
}
}
/**
* 批量需求导入
* @param pobj
* @returns {Promise<void>}
*/
async bulkCreateNeeds(pobj){
const tx_product = uiconfig.config.pdict.tx_product;
const tx_need_status = uiconfig.config.pdict.tx_need_status;
const tx_need_status_name = uiconfig.config.pdict.tx_need_status_name;
let needsArr = [];
let arr = pobj.actionBody.needsArr;
let uapp_id = pobj.actionBody.uapp_id;
let sql = 'select channelNeedNo from n_need_info where uapp_id = 53';
let ret = await this.customQuery(sql);
let existIds = ret.map(item =>{
return item.channelNeedNo;
})
for(let i=0;i<arr.length;i++){
let item = arr[i];
let typeCode = tx_product[item.productType];
let obj = {
"uapp_id": uapp_id,
"needNo": "",
"channelNeedNo":item.number,
"publishContent": item.companyName,
"publishName": item.personName,
"publishMobile": item.personMobile,
"statusName": tx_need_status_name[item.status],
"STATUS": tx_need_status[item.status],
"typeCode": typeCode,
"typeName": item.productType,
"created_at": item.createdAt
};
if(["icp","edi","icp年报","edi年报"].includes(item.productType)){
obj.province = item.area;
}else{
obj.city = item.area;
}
if(!existIds.includes(item.number)){
needsArr.push(obj);
}
}
let result = await this.dao.bulkCreate(needsArr);
return system.getResult(result);
}
}
module.exports = NeedinfoService;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment