deartibers 2 years ago
parent
commit
1b9e47fde1
  1. 94
      api/app/lib/controllers/member/index.js
  2. 9
      api/app/lib/routes/member/index.js
  3. 20
      api/app/lib/utils/member.js
  4. 51
      web/client/src/sections/humanAffairs/containers/import-members-modal.js
  5. 1
      web/client/src/sections/humanAffairs/containers/personnelFiles.jsx
  6. 1
      web/config.js

94
api/app/lib/controllers/member/index.js

@ -198,12 +198,63 @@ async function nativePlaceList (ctx) {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
const nRes = await models.Member.findAll({ const nRes = await models.Member.findAll({
attributes: [''], attributes: ['nativePlace'],
group: '' group: 'nativePlace',
where: {
nativePlace: { $ne: null }
}
}) })
ctx.status = 200; ctx.status = 200;
ctx.body = [] ctx.body = nRes
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
async function workPlaceList (ctx) {
// 获取已有的工作地列表
try {
const { models } = ctx.fs.dc;
const wRes = await models.Member.findAll({
attributes: ['workPlace'],
group: 'workPlace',
where: {
workPlace: { $ne: null }
}
})
ctx.status = 200;
ctx.body = wRes
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
async function maritalList (ctx) {
// 获取已有的婚育状况列表
try {
const { models } = ctx.fs.dc;
const mRes = await models.Member.findAll({
attributes: ['marital'],
group: 'marital',
where: {
marital: { $ne: null }
}
})
ctx.status = 200;
ctx.body = mRes
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.fs.logger.error(`path: ${ctx.path}, error: error`);
ctx.status = 400; ctx.status = 400;
@ -217,7 +268,10 @@ async function list (ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
const { judgeHoliday, memberList } = ctx.app.fs.utils const { judgeHoliday, memberList } = ctx.app.fs.utils
const { keywordTarget, keyword, limit, page, state } = ctx.query const {
keywordTarget, keyword, limit, page, state,
hiredateStart, hiredateEnd, marital, native, workPlace
} = ctx.query
const curDay = moment().format('YYYY-MM-DD') const curDay = moment().format('YYYY-MM-DD')
const nowTime = moment() const nowTime = moment()
@ -235,7 +289,10 @@ async function list (ctx) {
dayoffTime = true dayoffTime = true
} }
} }
const userRes = await memberList({ keywordTarget, keyword, limit, page, state }) const userRes = await memberList({
keywordTarget, keyword, limit, page, state,
hiredateStart, hiredateEnd, marital, native, workPlace
})
let returnD = [] let returnD = []
userRes.rows.forEach(u => { userRes.rows.forEach(u => {
@ -366,6 +423,12 @@ async function overTimeStatistics (ctx) {
INNER JOIN overtime INNER JOIN overtime
ON overtime.id = overtime_day.overtime_id ON overtime.id = overtime_day.overtime_id
AND overtime.pep_user_id = ${pepUserId} AND overtime.pep_user_id = ${pepUserId}
${startDate ? `
AND overtime_day.day >= '${moment(startDate).format('YYYY-MM-DD')}'
`: ''}
${endDate ? `
AND overtime_day.day <= '${moment(endDate).format('YYYY-MM-DD')}'
` : ''}
GROUP BY overtime_day.day, overtime.compensate GROUP BY overtime_day.day, overtime.compensate
`).toPromise() `).toPromise()
@ -393,10 +456,14 @@ async function vacateStatistics (ctx) {
const { startDate, endDate, pepUserId } = ctx.query const { startDate, endDate, pepUserId } = ctx.query
const timeOption = [] const timeOption = []
if (startDate && endDate) { if (startDate) {
timeOption.push( timeOption.push(
`wpStory.create_at <= '${moment(endDate).format('YYYY-MM-DD HH:mm:ss')}' `wpStory.create_at > '${moment(startDate).format('YYYY-MM-DD HH:mm:ss')}'`
AND wpStory.create_at > '${moment(startDate).format('YYYY-MM-DD HH:mm:ss')}'` )
}
if (endDate) {
timeOption.push(
`wpStory.create_at <= '${moment(endDate).format('YYYY-MM-DD HH:mm:ss')}'`
) )
} }
const dataRes = await clickHouse.hr.query(` const dataRes = await clickHouse.hr.query(`
@ -436,6 +503,12 @@ async function vacateStatistics (ctx) {
INNER JOIN vacate INNER JOIN vacate
ON vacate.id = vacate_day.vacate_id ON vacate.id = vacate_day.vacate_id
AND vacate.pep_user_id = ${pepUserId} AND vacate.pep_user_id = ${pepUserId}
${startDate ? `
AND vacate_day.day >= '${moment(startDate).format('YYYY-MM-DD')}'
`: ''}
${endDate ? `
AND vacate_day.day <= '${moment(endDate).format('YYYY-MM-DD')}'
` : ''}
GROUP BY vacate_day.day GROUP BY vacate_day.day
`).toPromise() `).toPromise()
@ -679,5 +752,8 @@ module.exports = {
overTimeStatistics, overTimeStatistics,
vacateStatistics, vacateStatistics,
exportData, exportData,
addMembersBulk addMembersBulk,
nativePlaceList,
workPlaceList,
maritalList,
} }

9
api/app/lib/routes/member/index.js

@ -15,6 +15,15 @@ module.exports = function (app, router, opts) {
app.fs.api.logAttr['GET/member/search'] = { content: '搜索项企用户', visible: true }; app.fs.api.logAttr['GET/member/search'] = { content: '搜索项企用户', visible: true };
router.get('/member/search', member.searchPepMember); router.get('/member/search', member.searchPepMember);
app.fs.api.logAttr['GET/member/native_place'] = { content: '查询籍贯列表', visible: true };
router.get('/member/native_place', member.nativePlaceList);
app.fs.api.logAttr['GET/member/marital'] = { content: '查询婚育列表', visible: true };
router.get('/member/marital', member.maritalList);
app.fs.api.logAttr['GET/member/work_place'] = { content: '查询工作地列表', visible: true };
router.get('/member/work_place', member.workPlaceList);
app.fs.api.logAttr['GET/member/list'] = { content: '查询人员列表', visible: true }; app.fs.api.logAttr['GET/member/list'] = { content: '查询人员列表', visible: true };
router.get('/member/list', member.list); router.get('/member/list', member.list);

20
api/app/lib/utils/member.js

@ -4,7 +4,10 @@ const request = require('superagent');
module.exports = function (app, opts) { module.exports = function (app, opts) {
async function memberList ({ keywordTarget, keyword, limit, page, state }) { async function memberList ({
keywordTarget, keyword, limit, page, state,
hiredateStart, hiredateEnd, marital, native, workPlace
}) {
const { judgeHoliday } = app.fs.utils const { judgeHoliday } = app.fs.utils
const { clickHouse } = app.fs const { clickHouse } = app.fs
const { database: pepEmis } = clickHouse.pepEmis.opts.config const { database: pepEmis } = clickHouse.pepEmis.opts.config
@ -114,6 +117,21 @@ module.exports = function (app, opts) {
${state == 'dimission' ? `AND member.dimission_date IS NOT null` : ''} ${state == 'dimission' ? `AND member.dimission_date IS NOT null` : ''}
${state == 'onJob' ? `AND member.dimission_date IS null` : ''} ${state == 'onJob' ? `AND member.dimission_date IS null` : ''}
${whereFromSelectOption.length ? `AND ${whereFromSelectOption.join('AND')}` : ''} ${whereFromSelectOption.length ? `AND ${whereFromSelectOption.join('AND')}` : ''}
${hiredateStart ? `
AND member.hiredate >= '${moment(hiredateStart).format('YYYY-MM-DD')}'
`: ''}
${hiredateEnd ? `
AND member.hiredate <= '${moment(hiredateEnd).format('YYYY-MM-DD')}'
` : ''}
${marital ? `
AND member.marital = '${marital}'
`: ''}
${native ? `
AND member.native_place = '${native}'
`: ''}
${workPlace ? `
AND member.work_place = '${workPlace}'
`: ''}
` `
const userRes = await clickHouse.hr.query(` const userRes = await clickHouse.hr.query(`

51
web/client/src/sections/humanAffairs/containers/import-members-modal.js

@ -31,8 +31,24 @@ const ImportMembersModal = props => {
} }
} }
const dldCsvMb = () => {
//表头
let head = "人员编号,姓名,证件号,性别(男/女),出生年月日(例2022/02/01),籍贯,婚育状态(已婚/未婚/已婚已育),政治面貌,联系方式,工作地点,毕业院校,学历,专业,毕业时间,入职时间,转试用期时间,转正时间,离职日期,工作经验(年),历史工作经历与职务\n"
//数据
//let data = 1 + ',' + 2 + ',' + 3 + ',' + 4 + ',' + 5
let templateCsv = "data:text/csv;charset=utf-8,\ufeff" + head;
//创建一个a标签
let link = document.createElement("a");
//为a标签设置属性
link.setAttribute("href", templateCsv);
link.setAttribute("download", "人资系统人员信息导入模板.csv");
//点击a标签
link.click();
}
const download = () => { const download = () => {
dldTemplate(); //dldTemplate();
dldCsvMb();
let str = ""; let str = "";
rule.forEach((v, i) => { rule.forEach((v, i) => {
str += `${v}\r\n` str += `${v}\r\n`
@ -40,21 +56,21 @@ const ImportMembersModal = props => {
dldText("填写说明.txt", str); dldText("填写说明.txt", str);
} }
const dldTemplate = () => { // const dldTemplate = () => {
let dataTable = []; // let dataTable = [];
let option = {}; // let option = {};
option.fileName = '人资系统人员信息导入模板'; // option.fileName = '人资系统人员信息导入模板';
option.datas = [ // option.datas = [
{ // {
sheetData: dataTable, // sheetData: dataTable,
sheetName: '人资系统人员信息导入模板', // sheetName: '人资系统人员信息导入模板',
sheetFilter: ['人员编号', '姓名', '证件号', '性别(男/女)', '出生年月日(例2022/02/01)', '籍贯', '婚育状态(已婚/未婚/已婚已育)', '政治面貌', '联系方式', '工作地点', '毕业院校', '学历', '专业', '毕业时间', '入职时间', '转试用期时间', '转正时间', '离职日期', '工作经验(年)', '历史工作经历与职务'], //excel文件中需显示的列数据 // sheetFilter: ['人员编号', '姓名', '证件号', '性别(男/女)', '出生年月日(例2022/02/01)', '籍贯', '婚育状态(已婚/未婚/已婚已育)', '政治面貌', '联系方式', '工作地点', '毕业院校', '学历', '专业', '毕业时间', '入职时间', '转试用期时间', '转正时间', '离职日期', '工作经验(年)', '历史工作经历与职务'], //excel文件中需显示的列数据
sheetHeader: ['人员编号', '姓名', '证件号', '性别(男/女)', '出生年月日(例2022/02/01)', '籍贯', '婚育状态(已婚/未婚/已婚已育)', '政治面貌', '联系方式', '工作地点', '毕业院校', '学历', '专业', '毕业时间', '入职时间', '转试用期时间', '转正时间', '离职日期', '工作经验(年)', '历史工作经历与职务'], //excel文件中每列的表头名称 // sheetHeader: ['人员编号', '姓名', '证件号', '性别(男/女)', '出生年月日(例2022/02/01)', '籍贯', '婚育状态(已婚/未婚/已婚已育)', '政治面貌', '联系方式', '工作地点', '毕业院校', '学历', '专业', '毕业时间', '入职时间', '转试用期时间', '转正时间', '离职日期', '工作经验(年)', '历史工作经历与职务'], //excel文件中每列的表头名称
} // }
] // ]
let toExcel = new ExportJsonExcel(option); //生成excel文件 // let toExcel = new ExportJsonExcel(option); //生成excel文件
toExcel.saveExcel(); //下载excel文件 // toExcel.saveExcel(); //下载excel文件
} // }
const dldText = (filename, text) => { const dldText = (filename, text) => {
var element = document.createElement('a'); var element = document.createElement('a');
@ -68,7 +84,7 @@ const ImportMembersModal = props => {
document.body.removeChild(element); document.body.removeChild(element);
} }
//const action = '/file/qiniu/upload?type=excel&token=' + user.token; //const action = '/file/qiniu/upload?type=excel&token=' + user.token;
const fileLimit = '.xls,.xlsx,.csv'; const fileLimit = '.csv';
const getFileBlob = (url) => { const getFileBlob = (url) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -88,6 +104,7 @@ const ImportMembersModal = props => {
const workbook = XLSX.read(result, { const workbook = XLSX.read(result, {
type: "binary", type: "binary",
cellDates: true,//设为true,将天数的时间戳转为时间格式 cellDates: true,//设为true,将天数的时间戳转为时间格式
codepage: 936
}); });
let data = []; // 存储获取到的数据 let data = []; // 存储获取到的数据
// 遍历每张工作表进行读取(这里默认只读取第一张表) // 遍历每张工作表进行读取(这里默认只读取第一张表)

1
web/client/src/sections/humanAffairs/containers/personnelFiles.jsx

@ -32,6 +32,7 @@ const Rest = (props) => {
}, [typeChoose]) }, [typeChoose])
function getMemberSearchList () {// function getMemberSearchList () {//
dispatch(humanAffairs.getMemberSearch())
dispatch(humanAffairs.getMemberList({ keywordTarget, keyword, state: typeChoose })).then((res) => {// dispatch(humanAffairs.getMemberList({ keywordTarget, keyword, state: typeChoose })).then((res) => {//
if (res.success) { if (res.success) {
setArchivesList(res.payload?.data?.rows) setArchivesList(res.payload?.data?.rows)

1
web/config.js

@ -34,6 +34,7 @@ const ANXINCLOUD_QINIU_DOMAIN_QNDMN_RESOURCE = process.env.ANXINCLOUD_QINIU_DOMA
if ( if (
!API_URL !API_URL
|| !API_HR_URL
|| !ANXINCLOUD_QINIU_AK || !ANXINCLOUD_QINIU_SK || !ANXINCLOUD_QINIU_BUCKET_RESOURCE || !ANXINCLOUD_QINIU_DOMAIN_QNDMN_RESOURCE || !ANXINCLOUD_QINIU_AK || !ANXINCLOUD_QINIU_SK || !ANXINCLOUD_QINIU_BUCKET_RESOURCE || !ANXINCLOUD_QINIU_DOMAIN_QNDMN_RESOURCE
) { ) {
console.log('缺少启动参数,异常退出'); console.log('缺少启动参数,异常退出');

Loading…
Cancel
Save