Commit 43f23e64 by 王昆

gsb

parent 6e2f3668
......@@ -32,14 +32,14 @@ class APIBase extends DocBase {
ispass: isExistInNoAuth || apptocheck
};
}
async doexec(gname, methodname, pobj, query, req) {
async doexec(gname, methodname, pobj, query, req, res) {
try {
//检查访问token
// var isPassResult = await this.checkAcck(gname, methodname, pobj, query, req);
// if (!isPassResult.ispass) {
// return system.getResultFail(system.tokenFail, "访问token失效,请重新获取");
// }
var rtn = await this[methodname](pobj, query);
var rtn = await this[methodname](pobj, query, req, res);
// if(isPassResult.apptocheck){
// var app=isPassResult.apptocheck.app;
// if(methodname && methodname.indexOf("recvNotificationForCacheCount")<0){
......
......@@ -29,6 +29,7 @@ class LaoActionApi extends APIBase {
this.msSve = system.getObject("service.common.msSve");
this.userconfSve = system.getObject("service.operator.userconfSve");
this.excelClient = system.getObject("util.excelClient");
this.applyStatusMap = {
10: "已申请",
......@@ -341,8 +342,6 @@ class LaoActionApi extends APIBase {
return system.getResult(null, "验证码错误,请重新输入");
}
var parm = {
phone_no: phone_no
}
......@@ -629,6 +628,114 @@ class LaoActionApi extends APIBase {
}
}
async exportUserLabourInfo(pobj, query, req, res) {//获取应聘信息
let obj = query.search;
try {
obj = JSON.parse(obj);
} catch (e) {
obj = {};
}
var temp_info = {};
var parm = {};
var isAdmin = obj.isAdmin;
parm.page_size = -1;
if (obj.id) {
parm.id = obj.id;
}
if (obj.user_id) {
parm.user_id = obj.user_id;
}
if (obj.labour_id) {
parm.labour_id = obj.labour_id;
}
if (obj.recruit_id) {
parm.recruit_id = obj.recruit_id;
}
if (obj.labour_user_id) {
parm.labour_user_id = obj.labour_user_id;
}
if (obj.ecid) {
parm.ecid = obj.ecid;
}
if (obj.apply_stauts) {
if (obj.apply_stauts == "已申请") {
parm.apply_stauts = 10;
} else if (obj.apply_stauts == "邀请面试") {
parm.apply_stauts = 20;
} else if (obj.apply_stauts == "面试成功") {
parm.apply_stauts = 30;
} else if (obj.apply_stauts == "面试失败") {
parm.apply_stauts = 40;
} else if (obj.apply_stauts == "待签约") {
parm.apply_stauts = 50;
} else if (obj.apply_stauts == "签约成功") {
parm.apply_stauts = 60;
}
}
temp_info = await this.userlabourSve.finduserlabourByWhere(parm);
if (temp_info && temp_info.status == 0 && temp_info.data.rows.length > 0) {
try {
for (var i = 0; i < temp_info.data.rows.length; i++) {
let row = temp_info.data.rows[i];
row.signType = "薪必果电子签";
if (row.sign_at) {
row.sign_at = moment(row.sign_at).add(-8,"hours").format("YYYY-MM-DD HH:mm:ss");
}
}
var csvobj = {
fileName: "签约信息" + moment().format("YYYYMMDD") + ".csv",
rows: temp_info.data.rows,
opts: {
fields: [
'id', 'name', 'sex', 'age', 'nation',
'marital_status', 'is_children', 'id_no', 'birthday',
'contact_mobile', 'sign_at', 'signType',
'card_no', 'opening_bank',
'education_back', 'graduate_ins', 'place_domicile', 'current_residence',
'urgency_person', 'contact_way',
],
unwind: [],
unwindBlank: true,
excelStrings: true,
},
headers: {
'id': '编号',
'name' : "姓名",
'sex' : "性别",
'age' : "年龄",
'nation' : "民族",
'marital_status' : "婚否",
'is_children' : "子女情况",
'id_no' : "身份证号码",
'birthday' : "生日",
'contact_mobile' : "联系电话",
'sign_at' : "签约时间",
'signType' : "签约类型",
'card_no' : "卡号",
'opening_bank' : "开户行",
'education_back' : "学历",
'graduate_ins' : "毕业院校",
'place_domicile' : "户籍地",
'current_residence' : "现住址",
'urgency_person' : "紧急联系人",
'contact_way' : "联系方式",
},
};
await this.excelClient.exportCsv(req, res, csvobj);
} catch (e) {
console.log(e);
return system.getResult(null, "获取数据失败");
}
} else {
//console.log(e);
if (isAdmin) {
return system.getResultSuccess({count: 0, rows: []});
} else {
return system.getResult(null, "获取数据为空");
}
}
}
// 我的应聘-邀请面试
async inviteInterview(obj) {
let id = Number(obj.id || 0);
......@@ -715,6 +822,7 @@ class LaoActionApi extends APIBase {
userlabour.place_domicile = obj.place_domicile;
userlabour.current_residence= obj.current_residence;
userlabour.urgency_person= obj.urgency_person;
userlabour.contact_mobile= obj.contact_mobile;
userlabour.contact_way= obj.contact_way;
userlabour.name = obj.name;
userlabour.id_no = obj.id_no;
......@@ -722,7 +830,7 @@ class LaoActionApi extends APIBase {
userlabour.sex = obj.sex;
userlabour.age = obj.age;
userlabour.birthday = obj.birthday;
userlabour.save();
await userlabour.save();
}
return system.getResult(userlabour);
}
......
......@@ -257,13 +257,15 @@ class XbgApi extends apiBase {
if(!userInfo) {
return system.getResult(null, "用户信息不存在");
}
if (!userInfo.id_card) {
let id_card = userInfo.id_card || userlabour.id_no;
if (!id_card) {
return system.getResult(null, "用户未实名认证,身份证不存在");
}
let params = {
// idNo: "222403198301071778",
idNo: userInfo.id_card,
idNo: id_card,
// ecid: 495,
ecid: userlabour.ecid,
};
......@@ -272,6 +274,7 @@ class XbgApi extends apiBase {
rs = JSON.parse(rs.stdout);
if (rs.data) {
userlabour.apply_stauts = 60;
userlabour.sign_at = new Date();
userlabour.contract_url = rs.data;
await userlabour.save();
return system.getResultSuccess(true);
......@@ -289,6 +292,18 @@ class XbgApi extends apiBase {
}
}
async syncContractUrl() {
let ids = await this.userlabourSve.findUnSyncIds();
if (!ids || ids.length == 0) {
return system.getResultSuccess("数据已经同步完成");
}
for (let id of ids) {
this.contractUrl({userlabour_id: id});
}
return system.getResultSuccess("数据同步请求提交完成");
}
async contractUrl(qobj) {
let userlabour_id = Number(qobj.userlabour_id || 0);
......@@ -310,13 +325,15 @@ class XbgApi extends apiBase {
if(!userInfo) {
return system.getResult(null, "用户信息不存在");
}
if (!userInfo.id_card) {
let id_card = userInfo.id_card || userlabour.id_no;
if (!id_card) {
return system.getResult(null, "用户未实名认证,身份证不存在");
}
let params = {
// idNo: "222403198301071778",
idNo: userInfo.id_card,
idNo: id_card,
ecid: userlabour.ecid,
};
......
......@@ -6,12 +6,25 @@ class UserlabourDao extends Dao {
super(Dao.getModelName(UserlabourDao));
}
async findUnSyncIds() {
let sql = "SELECT id FROM user_labour WHERE apply_stauts = 60 AND (contract_url IS NULL OR contract_url = '') ";
let list = await this.customQuery(sql);
let ids = [];
if (!list || list.length == 0) {
return ids;
}
for (let item of list) {
ids.push(item.id);
}
return ids;
}
async findLabourIdsByUserId(userId) {
var sql = "select labour_id from user_labour where user_id = :userId";
var list = await this.customQuery(sql, {userId: userId});
var result = [];
if(list) {
if (list) {
for (var item of list) {
result.push(item.labour_id);
}
......@@ -33,7 +46,7 @@ class UserlabourDao extends Dao {
for (var item of list) {
var lst = result[item.id];
if(!lst) {
if (!lst) {
lst = [];
}
lst.push(item.labour_id);
......
......@@ -12,16 +12,18 @@ module.exports = (db, DataTypes) => {
interview_time: DataTypes.DATE,
sign_at: DataTypes.DATE,
contract_url: DataTypes.STRING(300),
nation: DataTypes.INTEGER,
marital_status: DataTypes.INTEGER,
is_children : DataTypes.INTEGER,
opening_bank: DataTypes.INTEGER,
education_back: DataTypes.INTEGER,
graduate_ins: DataTypes.INTEGER,
place_domicile: DataTypes.INTEGER,
current_residence: DataTypes.INTEGER,
urgency_person: DataTypes.INTEGER,
contact_way: DataTypes.INTEGER,
nation: DataTypes.STRING,
marital_status: DataTypes.STRING,
is_children : DataTypes.STRING,
opening_bank: DataTypes.STRING,
education_back: DataTypes.STRING,
graduate_ins: DataTypes.STRING,
place_domicile: DataTypes.STRING,
current_residence: DataTypes.STRING,
urgency_person: DataTypes.STRING,
contact_mobile: DataTypes.STRING,
contact_way: DataTypes.STRING,
name : DataTypes.STRING,
id_no : DataTypes.STRING,
card_no : DataTypes.STRING,
......
......@@ -74,10 +74,12 @@ class UserlabourService extends ServiceBase {
var sqlwhere = {
where: where,
//order: [["publish_date", 'desc']],
limit: pageSize,
offset: (currentPage - 1) * pageSize,
raw: true
};
if (pageSize != -1) {
sqlwhere.limit = pageSize;
sqlwhere.offset = (currentPage - 1) * pageSize;
}
var list = await this.dao.model.findAndCountAll(sqlwhere) || [];
if (list) {
return system.getResult(list);
......@@ -123,6 +125,9 @@ class UserlabourService extends ServiceBase {
return 0;
}
}
async findUnSyncIds() {
return await this.dao.findUnSyncIds();
}
}
module.exports = UserlabourService;
......
var excel = require('exceljs');
const system=require("../system");
const system = require("../system");
const uuidv4 = require('uuid/v4');
const fs=require("fs");
const fs = require("fs");
const xlsx = require('node-xlsx')
const json2csv = require('json2csv');
class ExcelClient {
constructor() {
this.columns = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
this.ossClient=system.getObject("util.ossClient");
this.filedownloadDao = system.getObject("db.filedownloadDao");
}
constructor() {
this.columns = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
this.ossClient = system.getObject("util.ossClient");
this.restClient = system.getObject("util.restClient");
}
async download(params) {
var self = this;
var title = params.title || "";
var code = params.code || uuidv4();
var fileName = params.fileName || code + ".xlsx";
var filePath = params.filePath || "/tmp/" + fileName;
var rows = params.rows || [];
var user = params.user || {};
var wb = new excel.Workbook();
wb.properties.date1904 = true;
var sheet = wb.addWorksheet("sheet1");
var headers = rows[0];
console.log(headers, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2 headers");
if(title) {
sheet.addRow([title]);
sheet.getCell("A1").font = {
    name: '微软雅黑',
    family: 4,
    size: 12,
    bold: true
};
sheet.getCell('A1').alignment = { vertical: 'middle', horizontal: 'center' };
var colkey = 0;
if(headers.length > 0) {
colkey = headers.length - 1;
}
var endColumn = this.columns[colkey] || "A";
sheet.mergeCells("A1:" + endColumn + "1");
async download(params, cb) {
var self = this;
var title = params.title || "";
var code = params.code || uuidv4();
var fileName = params.fileName || code + ".xlsx";
var filePath = params.filePath || "/tmp/" + fileName;
var rows = params.rows || [];
var wb = new excel.Workbook();
wb.properties.date1904 = true;
var sheet = wb.addWorksheet("sheet1");
var headers = rows[0];
console.log(headers, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2 headers");
if (title) {
sheet.addRow([title]);
sheet.getCell("A1").font = {
name: '微软雅黑',
family: 4,
size: 12,
bold: true
};
sheet.getCell('A1').alignment = {
vertical: 'middle',
horizontal: 'center'
};
var colkey = 0;
if (headers.length > 0) {
colkey = headers.length - 1;
}
var endColumn = this.columns[colkey] || "A";
sheet.mergeCells("A1:" + endColumn + "1");
}
for(var r of rows) {
sheet.addRow(r);
for (var r of rows) {
sheet.addRow(r);
}
wb.xlsx.writeFile(filePath).then(async function (d) {
var rtn = await self.ossClient.upfile(fileName, filePath);
fs.unlink(filePath, function (err) {});
if (cb) {
cb(rtn.url);
}
});
}
wb.xlsx.writeFile(filePath).then(async function(d) {
var rtn = await self.ossClient.upfile(fileName, filePath);
fs.unlink(filePath,function(err){});
var obj = {
user_id : user.id || 0,
userName : user.userName || "",
code : code,
fileName : fileName,
filePath : rtn.url || "",
isDownload : false,
}
var obj = await self.filedownloadDao.create(obj);
async readExcel(id, ossurl) {
var result = {
code: 0,
data: [],
};
var names = [];
var filePath = "/tmp/ecompany_contract_" + id + ".xlsx";
try {
await this.restClient.execDownload("'" + ossurl + "'", filePath);
var sheets = xlsx.parse(filePath);
fs.unlink(filePath, e => {
console.log("fail");
});
if (!sheets || sheets.length == 0) {
return result;
}
var sheet = sheets[0];
if (!sheet || !sheet.data || sheet.data.length == 0) {
return result;
}
var rows = sheet.data;
for (var idx in rows) {
if (idx == 0) {
continue;
}
var cells = rows[idx];
if (!cells || cells.length == 0 || !cells[0]) {
continue;
}
var c = cells[0];
if (names.indexOf(c) > -1) {
continue;
}
names.push(c);
}
console.log(sheet);
result.code = 1;
result.data = names;
return result;
} catch (error) {
console.log(error.stack);
return result;
}
}
async exportCsv(req, res, csvobj) {
var userAgent = (req.headers['user-agent'] || '').toLowerCase();
var fileName = csvobj.fileName || new Date().getTime();
if (userAgent.indexOf('msie') >= 0 || userAgent.indexOf('chrome') >= 0) {
await res.setHeader('Content-Disposition', 'attachment; filename=' + encodeURIComponent(fileName));
} else if (userAgent.indexOf('firefox') >= 0) {
await res.setHeader('Content-Disposition', 'attachment; filename*="utf8\'\'' + encodeURIComponent(fileName) + '"');
} else {
await res.setHeader('Content-Disposition', 'attachment; filename=' + new Buffer(fileName).toString('binary'));
}
await res.writeHead(200,{'Content-Type':'application/octet-stream;charset=utf-8'});
let csv = json2csv.parse(csvobj.rows, csvobj.opts);
if(csvobj.headers) {
for(var field of csvobj.opts.fields) {
csv = csv.replace(field, csvobj.headers[field]);
}
}
await res.write("\uFEFF" + csv);
await res.write('\n');
}
}
module.exports = ExcelClient;
module.exports = ExcelClient;
\ No newline at end of file
var url = require("url");
var System = require("../../base/system");
module.exports = function (app) {
app.get('/api/:gname/:qname/:method', function (req, res) {
var classPath = req.params["qname"];
var methodName = req.params["method"];
var gname=req.params["gname"];
classPath=gname+"."+classPath;
var tClientIp = System.get_client_ip(req);
req.clientIp = tClientIp;
req.uagent= req.headers["user-agent"];
req.classname=classPath;
app.get('/api/:gname/:qname/:method', function (req, res) {
var classPath = req.params["qname"];
var methodName = req.params["method"];
var gname = req.params["gname"];
var params = [];
params.push(gname);
params.push(methodName);
params.push(req.body);
params.push(req.query);
params.push(req);
var p = null;
var invokeObj = System.getObject("api." + classPath);
if (invokeObj["doexec"]) {
p = invokeObj["doexec"].apply(invokeObj, params);
}
p.then(r => {
res.end(JSON.stringify(r));
});
});
app.post('/api/:gname/:qname/:method', function (req, res) {
var classPath = req.params["qname"];
var methodName = req.params["method"];
var gname=req.params["gname"];
var params = [];
classPath=gname+"."+classPath;
var tClientIp = System.get_client_ip(req);
classPath = gname + "." + classPath;
var tClientIp = System.get_client_ip(req);
req.clientIp = tClientIp;
req.uagent = req.headers["user-agent"];
req.classname = classPath;
req.clientIp = tClientIp;
req.uagent= req.headers["user-agent"];
req.classname=classPath;
var params = [];
params.push(gname);
params.push(methodName);
params.push(req.body);
params.push(req.query);
params.push(req);
params.push(res);
var p = null;
var invokeObj = System.getObject("api." + classPath);
if (invokeObj["doexec"]) {
p = invokeObj["doexec"].apply(invokeObj, params);
}
p.then(r => {
res.end(JSON.stringify(r));
});
});
app.post('/api/:gname/:qname/:method', function (req, res) {
var classPath = req.params["qname"];
var methodName = req.params["method"];
var gname = req.params["gname"];
var params = [];
classPath = gname + "." + classPath;
var tClientIp = System.get_client_ip(req);
params.push(gname);
params.push(methodName);
params.push(req.body);
params.push(req.query);
params.push(req);
var p = null;
var invokeObj = System.getObject("api." + classPath);
if (invokeObj["doexec"]) {
p = invokeObj["doexec"].apply(invokeObj, params);
}
p.then(r => {
res.end(JSON.stringify(r));
});
});
req.clientIp = tClientIp;
req.uagent = req.headers["user-agent"];
req.classname = classPath;
params.push(gname);
params.push(methodName);
params.push(req.body);
params.push(req.query);
params.push(req);
params.push(res);
var p = null;
var invokeObj = System.getObject("api." + classPath);
if (invokeObj["doexec"]) {
p = invokeObj["doexec"].apply(invokeObj, params);
}
p.then(r => {
res.end(JSON.stringify(r));
});
});
};
......@@ -26,10 +26,12 @@
"element-ui": "^2.4.0",
"engine.io-parser": "^2.1.2",
"errorhandler": "^1.5.0",
"exceljs": "^3.9.0",
"exif-js": "^2.3.0",
"express": "^4.16.2",
"express-session": "^1.15.6",
"gm": "^1.23.1",
"json2csv": "^5.0.0",
"method-override": "^2.3.10",
"morgan": "^1.9.1",
"multer": "^1.3.0",
......
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