Commit 4d3e6821 by 宋毅

Merge branch 'center-order' of gitlab.gongsibao.com:jiangyong/zhichan into center-order

parents f018ded6 ed75666b
const system = require("../../../system"); const system = require("../../../system");
const ServiceBase = require("../../sve.base"); const ServiceBase = require("../../sve.base");
var xl = require('xlsx');
var fs = require('fs');
class PolicyinfoService extends ServiceBase { class PolicyinfoService extends ServiceBase {
constructor() { constructor() {
super("dbpolicy", ServiceBase.getDaoName(PolicyinfoService)); super("dbpolicy", ServiceBase.getDaoName(PolicyinfoService));
...@@ -40,5 +42,42 @@ class PolicyinfoService extends ServiceBase { ...@@ -40,5 +42,42 @@ class PolicyinfoService extends ServiceBase {
where:paramObj,raw:true,attributes:attributes where:paramObj,raw:true,attributes:attributes
}); });
} }
async addPolicyByExcel(){
var workbook = xl.readFile("policy.xlsx")
const sheetNames = workbook.SheetNames; // 返回 ['sheet1', 'sheet2']
const worksheet = workbook.Sheets[sheetNames[0]];
var dataa =xl.utils.sheet_to_json(worksheet);
var arr = [];
var that=this;
await this.db.transaction(async function (t) {
for(var i=0;i<dataa.length;i++){
var data = dataa[i];
var pobj = {
uapp_id:26,policyNo:data['政策编号'],policyName:data['政策名称'],
policySource:data['政策出处'],policyLinkUrl:data['政策链接'],
policyProvince:data['所属省份'],policyCity:data['所属城市'],
policyTypeName:data['政策类型']};
if(data['政策类型']){
var policy_type ={'租金减免':'fzbt','金融贷款':'jrdk','扶持措施':'zdfc','税收优惠':'ssjm','人力资源':'rlzy'};
var typename = data['政策类型'];
if(policy_type[typename]){
pobj["policyType"]=policy_type[typename];
}
}
if(pobj.policyNo){
var a = await that.dao.create(pobj,t);
arr.push(a);
}
}
})
console.log(arr.length,"###################################");
}
} }
module.exports = PolicyinfoService; module.exports = PolicyinfoService;
// var task = new PolicyinfoService();
// task.addPolicyByExcel().then(d=>{
// console.log("----------end-------------------------");
// })
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