Commit 01b5ef51 by 高宇强

gyq

parent 123eed9d
var APIBase = require("../../api.base");
var system = require("../../../system");
const crypto = require('crypto');
const xlsx = require('node-xlsx');
class LaoActionApi extends APIBase {
constructor() {
super();
......@@ -14,6 +15,7 @@ class LaoActionApi extends APIBase {
this.smsClient = system.getObject("util.smsClient");
this.vcodePrev = "lwb_vcode_";
this.testPhones = ['13691046554', '13333333333'];
this.restClient = system.getObject("util.restClient");
}
async test(pobj, query) {
......@@ -612,6 +614,179 @@ class LaoActionApi extends APIBase {
}
}
async ParamRecruitExcel(obj){
if (!obj.userId || !obj.ossUrl){
return system.getResult(null, "参数不能为空");
}
var userId = obj.userId;
var ossurl = obj.ossUrl;
var dataList = [];
var filePath = "/tmp/recruit_info_" + userId + ".xlsx";
try {
await this.restClient.execDownload("'" + ossurl + "'", filePath);
var sheets = xlsx.parse(filePath);
var rows = sheets[0].data;
for (var i = 5; i < rows.length; i++) {
var cells = rows[i];
if (cells[0]){
var data = {};
data.recruit_name = "" + cells[1];
data.recruit_type = "" + cells[2];
data.recruit_count = "" + cells[3];
data.pay_name = "" + cells[4];
if (data.pay_name == "月薪"){
data.pay_type = 1;
}
else if (data.pay_name == "日薪"){
data.pay_type = 2;
}
else if (data.pay_name == "时薪"){
data.pay_type = 3;
}
else{
data.pay_type = null;
}
data.pay_unit = null;//少一个薪资单价
var temp = "" + cells[5];
if (temp && temp != "—" && temp != "面议"){
data.basic_salary = Number(temp) * 100;
}
else{
data.basic_salary = null;
}
temp = "" + cells[6];
if (temp && temp != "—" && temp != "面议"){
data.compre_salary = Number(temp) * 100;
}
else{
data.compre_salary = null;
}
temp = "" + cells[7];
if (temp && temp != "—"){
data.work_duration = Number(temp);
}
else{
data.work_duration = null;
}
temp = "" + cells[8];
if (temp == "面议"){
data.rfee_type = 0;
}
else if (temp == "月返"){
data.rfee_type = 1;
}
else if (temp == "日返"){
data.rfee_type = 2;
}
else if (temp == "时返"){
data.rfee_type = 3;
}
else if (temp == "一次返"){
data.rfee_type = 4;
}
else{
data.rfee_type = null;
}
temp = "" + cells[9];
if (temp && temp != "—"){
var arr = temp.split("/");
if (arr.length ==2){
data.rfee_duration = arr[0];
data.rfee_time = arr[1];
}
else{
data.rfee_duration = null;
data.rfee_time = null;
}
}
else{
data.rfee_duration = null;
data.rfee_time = null;
}
temp = "" + cells[10];
if (temp){
data.age_range = temp;
}
else{
data.age_range = null;
}
temp = "" + cells[11];
if (temp){
data.work_address = temp;
}
else{
data.work_address = null;
}
data.publish_date = (new Date()).Format("yyyy-MM-dd");
temp = "" + cells[12];
if (temp){
if (temp == "长期"){
data.end_date = "1970-01-01";
}
else{
data.end_date = temp;
}
}
else{
data.end_date = null;
}
data.pic_path = null;
temp = "" + cells[14];
if (temp){
data.recrui_require = temp;
}
else{
data.recrui_require = null;
}
temp = "" + cells[15];
if (temp){
data.phone_no = temp;
var parm = {
phone_no: temp
}
var user_info = await this.usersSve.findUserInfoByPhone(parm);
if (user_info.status == -1) {
data.user_id = null;
}
else{
data.user_id = user_info.data.id;
}
}
else{
data.phone_no = null;
data.user_id = null;
}
data.counter_mark = null;
data.cur_type = 1;
data.cur_status = "展示中";
dataList.push(data)
}
}
obj.dataList = dataList;
var re = await this.recruitSve.ParamRecruitExcel(obj)
if (re == 1) {
return system.getResult(re);
} else {
return system.getResult(null, "插入数据失败");
}
}
catch (e){
console.log(e);
return system.getResult(null, "接口异常");
}
}
async getOssConfig() {
var policyText = {
"expiration": "2119-12-31T16:00:00.000Z",
......@@ -675,19 +850,19 @@ class LaoActionApi extends APIBase {
}
module.exports = LaoActionApi;
// var tesk = new LaoActionApi();
// var parm = {
// find_type:4,
// find_info:"北京"
// //id:2,
// //cur_status:"已过期"
// //memo_text:"sssssssss"
// //user_name:"高",
// //com_name:"京东"
// };
// tesk.FindRecruitInfo(parm).then(function(result){
// console.log(result);
// console.log(result.data.rows);
// }).catch(function(e){
// console.log(e);
// });
\ No newline at end of file
var tesk = new LaoActionApi();
var parm = {
userId:4,
ossUrl:"https://gsb-zc.oss-cn-beijing.aliyuncs.com/1111.xlsx"
//id:2,
//cur_status:"已过期"
//memo_text:"sssssssss"
//user_name:"高",
//com_name:"京东"
};
tesk.ParamRecruitExcel(parm).then(function(result){
console.log(result);
//console.log(result.data.rows);
}).catch(function(e){
console.log(e);
});
\ No newline at end of file
......@@ -55,6 +55,8 @@ class WorkloadService extends ServiceBase {
}
}
}
module.exports = WorkloadService;
\ No newline at end of file
......@@ -8,6 +8,7 @@ class RecruitService extends ServiceBase {
constructor() {
super("operator", ServiceBase.getDaoName(RecruitService));
this.usersDao = system.getObject("db.operator.usersDao");
//this.restClient = system.getObject("util.restClient");
}
async SaveRecruitInfo(params){//添加或更新招聘信息
......@@ -353,6 +354,19 @@ class RecruitService extends ServiceBase {
}
}
async ParamRecruitExcel(obj) {//批量上传
var resu = obj.dataList;
try {
await this.dao.model.bulkCreate(resu, {fields: ["recruit_name", "recruit_type", "recruit_count", "pay_type", "pay_name",
"pay_unit", "basic_salary", "compre_salary","work_duration","rfee_type","rfee_unit","rfee_duration","rfee_time","age_range",
"work_address","publish_date","end_date","pic_path","recrui_require","phone_no","user_id","counter_mark","cur_type","cur_status"]});
return 1;
} catch (e) {
console.log(e);
return 0;
}
}
}
module.exports = RecruitService;
......
......@@ -38,8 +38,8 @@ class OSSClient{
}
module.exports=OSSClient;
// var oss=new OSSClient();
// var key="netsharp_QSzjD4HdKdTmRR6b5486pEA3AbsW8Pr8.jpg"
// oss.upfile(key,"/usr/devws/OMC/igirl-api/r3.jpg").then(function(result){
// var key="1111.xlsx"
// oss.upfile(key,"/home/gaoyuqiang/taskexecutor/1.xlsx").then(function(result){
// console.log(result);
// });
// oss.downfile(key).then(function(result){
......
......@@ -30,14 +30,14 @@
"express-session": "^1.15.6",
"gm": "^1.23.1",
"method-override": "^2.3.10",
"morgan": "^1.9.0",
"morgan": "^1.9.1",
"multer": "^1.3.0",
"mysql2": "^1.5.3",
"node-cron": "^2.0.1",
"node-uuid": "^1.4.8",
"node-xlsx": "^0.15.0",
"qr-image": "^3.2.0",
"sequelize": "^4.37.8",
"sequelize": "^4.44.3",
"sequelize-cli": "^4.1.1",
"serve-favicon": "^2.4.5",
"sha1": "^1.1.1",
......
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