Commit 7c2b2bbc by 孙香冬

no message

parent 8f1cba14
<config> <config>
<port>7088</port> <port>7088</port>
<dbConfig> <dbConfig>
<mysqlHost>192.168.0.105</mysqlHost> <mysqlHost>192.168.0.109</mysqlHost>
<mysqlPort>3306</mysqlPort> <mysqlPort>3306</mysqlPort>
<mysqlUser>root</mysqlUser> <mysqlUser>root</mysqlUser>
<mysqlPwd>123456</mysqlPwd> <mysqlPwd>123456</mysqlPwd>
......
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
import moment = require("moment"); import moment = require("moment");
import { ASKFORLEAVETYPE } from "../config/enum"; import { ASKFORLEAVETYPE } from "../config/enum";
import { addData, selectData } from "../data/admin/askForLeave"; import { addData, selectData } from "../data/admin/askForLeave";
import { changeEnumValue } from "../util/tools"; import * as tools from "../util/tools";
/** /**
...@@ -19,14 +18,26 @@ import { changeEnumValue } from "../util/tools"; ...@@ -19,14 +18,26 @@ import { changeEnumValue } from "../util/tools";
* @param long 时长 * @param long 时长
* @param type 请假类型 * @param type 请假类型
*/ */
export async function askForLeave(userId:string, des:string, startTime:number, endTime:number, type:number, time:number, day:number) {
/**
* 添加请假记录
* @param userId 填报人
* @param desc 描述
* @param startTime 开始请假时间
* @param endTime 结束请假时间
* @param type 请假类型
* @param date 填报时间
* @returns {isSuccess:true, message:"添加成功"}
*/
export async function askForLeave(userId:string, desc:string, startTime:number, endTime:number, type:number, date:string) {
const DateKey = tools.getWorkingDateKey(date);
let st = new Date(startTime); let st = new Date(startTime);
let et = new Date(endTime); let et = new Date(endTime);
await addData(des, st, et, userId, time, type, day); await addData(desc, st, et, userId, type, DateKey);
return {isSuccess:true, message:"添加成功"} return {isSuccess:true, message:"添加成功"};
} }
...@@ -36,7 +47,7 @@ export async function myAskForLeaveList(userId:string) { ...@@ -36,7 +47,7 @@ export async function myAskForLeaveList(userId:string) {
let result = []; let result = [];
dataList.forEach(info => { dataList.forEach(info => {
let { id, des, startTime, endTime, time, type, day } = info; let { id, des, startTime, endTime, time, type, day } = info;
let changeType = changeEnumValue(ASKFORLEAVETYPE, type); let changeType = tools.changeEnumValue(ASKFORLEAVETYPE, type);
let changeStartTime = moment(startTime).format("YYYY/MM/DD HH:mm"); let changeStartTime = moment(startTime).format("YYYY/MM/DD HH:mm");
let changeEndTimee = moment(endTime).format("YYYY/MM/DD HH:mm"); let changeEndTimee = moment(endTime).format("YYYY/MM/DD HH:mm");
let timeStr = `${day}${time}小时`; let timeStr = `${day}${time}小时`;
......
...@@ -16,11 +16,15 @@ import { count } from "console"; ...@@ -16,11 +16,15 @@ import { count } from "console";
/** /**
* 填报工时 * 填报工时
* @param userId * @param userId 填报人
* @param dataList * @param time 工时
* @param projectId 项目号
* @param isOutside 是否外出 true/false
* @param date 填报时间
* @param workLog 工作内容
* @returns {isSuccess:true, message:"添加成功"}
*/ */
export async function addWorking(userId:number, time:number, projectId:string, isOutside:boolean, date:string, workLog:string ) { export async function addWorking(userId:number, time:number, projectId:string, isOutside:boolean, date:string, workLog:string ) {
const DateKey = tools.getWorkingDateKey(date); const DateKey = tools.getWorkingDateKey(date);
let selectKey = moment(date).format("YYYY-MM-DD")+ ' 18:00:00' let selectKey = moment(date).format("YYYY-MM-DD")+ ' 18:00:00'
let timeCount = await workinglogData.findWorkingLogLengthByDateKey(userId, selectKey); let timeCount = await workinglogData.findWorkingLogLengthByDateKey(userId, selectKey);
...@@ -43,8 +47,8 @@ export async function addWorking(userId:number, time:number, projectId:string, i ...@@ -43,8 +47,8 @@ export async function addWorking(userId:number, time:number, projectId:string, i
/** /**
* 查看本周填报的工时 * 查看本周填报的工时
* 本周的规则是:周一到周日 * 本周的规则是:周一到周日
* @param userId * @param userId 填报人
* @returns * @returns { dataList:本周填报的工时信息, 本周工时统计 }
*/ */
export async function workinglogList(userId:number) { export async function workinglogList(userId:number) {
//获取这周开始时间 //获取这周开始时间
...@@ -68,6 +72,16 @@ export async function workinglogList(userId:number) { ...@@ -68,6 +72,16 @@ export async function workinglogList(userId:number) {
} }
/**
* 修改已填报的工时信息
* @param userId 填报人
* @param id 属性的数据类型
* @param time 工时
* @param projectId 项目号
* @param isOutside 是否外出 true/false
* @param workLog 工作内容
* @returns { isSuccess:true, message:"修改成功" }
*/
export async function updateWorkinglog(userId:number, id:string, time:number, projectId:string, isOutside:boolean, workLog:string) { export async function updateWorkinglog(userId:number, id:string, time:number, projectId:string, isOutside:boolean, workLog:string) {
let s = moment().weekday(1).format("YYYY-MM-DD") + ' 00:00:00'; let s = moment().weekday(1).format("YYYY-MM-DD") + ' 00:00:00';
let e = moment().weekday(7).format("YYYY-MM-DD") + ' 23:59:59'; let e = moment().weekday(7).format("YYYY-MM-DD") + ' 23:59:59';
...@@ -96,6 +110,12 @@ export async function updateWorkinglog(userId:number, id:string, time:number, pr ...@@ -96,6 +110,12 @@ export async function updateWorkinglog(userId:number, id:string, time:number, pr
} }
/**
* 根据传入id删除填报工时
* @param userId 填报人
* @param id 属性的数据类型
* @returns { isSuccess:true, message:"删除成功" }
*/
export async function delWorkinglog(userId:number, id:string,) { export async function delWorkinglog(userId:number, id:string,) {
let dataInfo = await workinglogData.findWorkingLogById(id); let dataInfo = await workinglogData.findWorkingLogById(id);
...@@ -109,10 +129,10 @@ export async function delWorkinglog(userId:number, id:string,) { ...@@ -109,10 +129,10 @@ export async function delWorkinglog(userId:number, id:string,) {
/** /**
* 工时管理列表 按时间分 * 工时管理列表 按时间分
* @param page * @param page 页数
* @param startMs * @param startMs 开始时间
* @param endMs * @param endMs 结束时间
* @returns * @returns {dataList:工时管理列表, total:工时列表统计 }
*/ */
export async function adminWorkLogForTime(page:number, startMs:string, endMs:string) { export async function adminWorkLogForTime(page:number, startMs:string, endMs:string) {
let s = null; let s = null;
...@@ -152,10 +172,10 @@ export async function adminWorkLogForTime(page:number, startMs:string, endMs:str ...@@ -152,10 +172,10 @@ export async function adminWorkLogForTime(page:number, startMs:string, endMs:str
/** /**
* 工时管理列表 按项目分 * 工时管理列表 按项目分
* @param page * @param page 页数
* @param startMs * @param startMs 开始时间
* @param endMs * @param endMs 结束时间
* @returns * @returns {dataList:工时管理列表, total:工时列表统计 };
*/ */
export async function adminWorkLogForProject(page:number, startMs:string, endMs:string) { export async function adminWorkLogForProject(page:number, startMs:string, endMs:string) {
let s = null; let s = null;
...@@ -192,9 +212,9 @@ export async function adminWorkLogForProject(page:number, startMs:string, endMs: ...@@ -192,9 +212,9 @@ export async function adminWorkLogForProject(page:number, startMs:string, endMs:
/** /**
* 导出按时间分的工时管理列表 * 导出按时间分的工时管理列表
* @param startMs * @param startMs 开始时间
* @param endMs * @param endMs 结束时间
* @returns * @returns {dataList:工时管理列表, name:`【按时间分工时】.xlsx`}
*/ */
export async function outPutAdminWorkingLogListForTime(startMs:string, endMs:string) { export async function outPutAdminWorkingLogListForTime(startMs:string, endMs:string) {
let s = null; let s = null;
...@@ -238,9 +258,9 @@ export async function outPutAdminWorkingLogListForTime(startMs:string, endMs:str ...@@ -238,9 +258,9 @@ export async function outPutAdminWorkingLogListForTime(startMs:string, endMs:str
/** /**
* 导出按项目分的工时管理列表 * 导出按项目分的工时管理列表
* @param startMs * @param startMs 开始时间
* @param endMs * @param endMs 结束时间
* @returns * @returns {dataList:工时管理列表, name:`【按项目分工时】.xlsx`}
*/ */
export async function outPutAdminWorkingLogListForProject(startMs:string, endMs:string) { export async function outPutAdminWorkingLogListForProject(startMs:string, endMs:string) {
let s = null; let s = null;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
*/ */
import { mySqlTableClass } from "../../db/mysqlClass"; import { mySqlTableClass } from "../../db/mysqlClass";
import { mysqlDB } from "../../db/mysqlInit";
const Sequelize =require('sequelize') const Sequelize =require('sequelize')
const MySequesize = require('../../db/mysqlInit'); //导入创建的sequelize对象 const MySequesize = require('../../db/mysqlInit'); //导入创建的sequelize对象
...@@ -17,14 +18,14 @@ export async function initModel() { ...@@ -17,14 +18,14 @@ export async function initModel() {
allowNull:false, //表示当前列是否允许为空,false表示该列不能为空 allowNull:false, //表示当前列是否允许为空,false表示该列不能为空
unique:true //表示该列的值必须唯一 unique:true //表示该列的值必须唯一
}, },
des:{ type:Sequelize.STRING(100) }, desc:{ type:Sequelize.STRING(100) }, //描述
startTime:{ type:Sequelize.DATE, allowNull:false }, startTime:{ type:Sequelize.DATE, allowNull:false }, //开始请假时间
endTime:{ type:Sequelize.DATE, allowNull:false }, endTime:{ type:Sequelize.DATE, allowNull:false }, //结束请假时间
userId:{ type:Sequelize.INTEGER, allowNull: false },//填报人 userId:{ type:Sequelize.INTEGER, allowNull: false }, //填报人
approval:{ type:Sequelize.INTEGER, allowNull: false },//填报人 approval:{ type:Sequelize.INTEGER, allowNull: false }, //批准
time:{ type:Sequelize.INTEGER, allowNull: false },//填报人 time:{ type:Sequelize.INTEGER, allowNull: false }, //剩余调休时间
day:{ type:Sequelize.INTEGER, allowNull: false },//填报人 day:{ type:Sequelize.INTEGER, allowNull: false }, //年假剩余天数
type:{ type:Sequelize.INTEGER, allowNull: false },//填报人 type:{ type:Sequelize.INTEGER, allowNull: false }, //请假类型 调休/年假/病假/事假
contractId:{ type:Sequelize.STRING(200), },//合同号 contractId:{ type:Sequelize.STRING(200), },//合同号
...@@ -39,13 +40,31 @@ export async function initModel() { ...@@ -39,13 +40,31 @@ export async function initModel() {
} }
export async function addData(des:string, startTime:Date, endTime:Date, userId:string, time:number, type:number, day:number) { /**
await askforleaveModel.create({des, startTime, endTime, userId, time, type, day}); * 添加请假记录
* @param desc
* @param startTime
* @param endTime
* @param userId
* @param time
* @param type
* @param day
*/
export async function addData(des:string, startTime:Date, endTime:Date, userId:string, type:number, dateKey:Date) {
await askforleaveModel.create({des, startTime, endTime, userId, type, dateKey});
} }
export async function selectData(userId:string) {
let dataList = await askforleaveModel.findAll({ /**
where:{userId} * 获取所有请假记录
}); * @param userId
return dataList; * @returns
*/
export async function findAllAskforLeave(userId:string) {
let sql = `select askforleave.startTime, askforleave.endTime, askforleave.userId, askforleave.approval, askforleave.time, askforleave.type, askforleave.desc from askforleave `
if (userId) {
sql += ` where userId = "${userId}"`;
}
let res = await mysqlDB.query(sql, { type: mysqlDB.QueryTypes.SELECT });
return res;
} }
\ No newline at end of file
...@@ -29,7 +29,13 @@ export async function initModel() { ...@@ -29,7 +29,13 @@ export async function initModel() {
workinglogModel = await model.sync({}); workinglogModel = await model.sync({});
} }
//获取今日时长
/**
* 获取今日时长
* @param userId
* @param dateKey
* @returns
*/
export async function findWorkingLogLengthByDateKey(userId:number, dateKey:string) { export async function findWorkingLogLengthByDateKey(userId:number, dateKey:string) {
let count = 0; let count = 0;
...@@ -43,7 +49,13 @@ export async function findWorkingLogLengthByDateKey(userId:number, dateKey:strin ...@@ -43,7 +49,13 @@ export async function findWorkingLogLengthByDateKey(userId:number, dateKey:strin
} }
//获取本周工时记录 /**
* 获取本周工时记录
* @param userId
* @param startTime
* @param endTime
* @returns
*/
export async function findThisWeekWorkingLog(userId:number, startTime:string, endTime:string) { export async function findThisWeekWorkingLog(userId:number, startTime:string, endTime:string) {
let sql = `select workinglog.workLog, workinglog.id as id,workinglog.projectId as projectId, project.name as projectName, workinglog.time, workinglog.dateKey, `; let sql = `select workinglog.workLog, workinglog.id as id,workinglog.projectId as projectId, project.name as projectName, workinglog.time, workinglog.dateKey, `;
sql += `workinglog.isOutside from workinglog INNER JOIN project on project.id = workinglog.projectId where userId = ${userId} and dateKey > "${startTime}" and dateKey < "${endTime}" ` sql += `workinglog.isOutside from workinglog INNER JOIN project on project.id = workinglog.projectId where userId = ${userId} and dateKey > "${startTime}" and dateKey < "${endTime}" `
...@@ -56,8 +68,6 @@ export async function findThisWeekWorkingLog(userId:number, startTime:string, en ...@@ -56,8 +68,6 @@ export async function findThisWeekWorkingLog(userId:number, startTime:string, en
} }
/** /**
* 获取所有工时记录 按时间分 * 获取所有工时记录 按时间分
* 带分页 * 带分页
...@@ -105,10 +115,11 @@ export async function findAllWorkingLog( startTime:string, endTime:string) { ...@@ -105,10 +115,11 @@ export async function findAllWorkingLog( startTime:string, endTime:string) {
return res; return res;
} }
/** /**
* 获取所有工时记录 按项目分 * 获取所有工时记录 按项目分
* @param startTime * @param startTime 开始时间
* @param endTime * @param endTime 结束时间
* @returns * @returns
*/ */
export async function findAllWorkingLogToProject(startTime:string, endTime:string) { export async function findAllWorkingLogToProject(startTime:string, endTime:string) {
...@@ -117,20 +128,48 @@ export async function findAllWorkingLogToProject(startTime:string, endTime:strin ...@@ -117,20 +128,48 @@ export async function findAllWorkingLogToProject(startTime:string, endTime:strin
if (startTime && endTime) { if (startTime && endTime) {
sql += ` where workinglog.dateKey > "${startTime}" and workinglog.dateKey < "${endTime}"`; sql += ` where workinglog.dateKey > "${startTime}" and workinglog.dateKey < "${endTime}"`;
} }
return await mysqlDB.query(sql, { type: mysqlDB.QueryTypes.SELECT } ); let res = await mysqlDB.query(sql, { type: mysqlDB.QueryTypes.SELECT } )
return res;
} }
//添加工时
/**
* 添加工时记录
* @param id 属性的数据类型
* @param projectId 项目号
* @param userId 填报人
* @param time 工时
* @param dateKey 填报时间
* @param isOutside 是否外出 0=否 1=是
* @param workLog 工作内容
*/
export async function addWorkingLog(id:string, projectId:string, userId:number, time:number, dateKey:string, isOutside:number, workLog:string) { export async function addWorkingLog(id:string, projectId:string, userId:number, time:number, dateKey:string, isOutside:number, workLog:string) {
let sql = `INSERT INTO workinglog ( id, projectId, userId, time, dateKey, isOutside, workLog) values `;
sql += `( "${id}", "${projectId}", "${userId}", "${time}", "${dateKey}", "${isOutside}", "${workLog}" )`;
let res = await mysqlDB.insert({})
await workinglogModel.create({id, projectId, userId, time, dateKey, isOutside, workLog}); await workinglogModel.create({id, projectId, userId, time, dateKey, isOutside, workLog});
} }
//修改工时信息
/**
* 修改工时记录
* @param id 属性的数据类型
* @param projectId 项目号
* @param time 工时
* @param isOutside 是否外出 0=否 1=是
* @param workLog 工作内容
*/
export async function updateWorkinglog(id:string, projectId:string, time:number, isOutside:number, workLog:string) { export async function updateWorkinglog(id:string, projectId:string, time:number, isOutside:number, workLog:string) {
let sql = `UPDATE workinglog SET projectId="${projectId}", time="${time}", isOutside="${isOutside}", workLog="${workLog}" where id="${id}"`;
await workinglogModel.update({projectId, time, isOutside, workLog}, {where:{id}}); await workinglogModel.update({projectId, time, isOutside, workLog}, {where:{id}});
} }
/**
* 根据id查询工时记录
* @param id 属性的数据类型
* @returns
*/
export async function findWorkingLogById(id:string) { export async function findWorkingLogById(id:string) {
let dataList = await workinglogModel.findAll({ let dataList = await workinglogModel.findAll({
where:{id} where:{id}
...@@ -139,6 +178,11 @@ export async function findWorkingLogById(id:string) { ...@@ -139,6 +178,11 @@ export async function findWorkingLogById(id:string) {
} }
/**
* 根据id删除工时记录
* @param id 属性的数据类型
* @returns
*/
export async function deleteWorkingLogById(id:string) { export async function deleteWorkingLogById(id:string) {
return await workinglogModel.destroy({where:{id}}); return await workinglogModel.destroy({where:{id}});
} }
\ No newline at end of file
...@@ -57,12 +57,23 @@ async function outPutList(req, res) { ...@@ -57,12 +57,23 @@ async function outPutList(req, res) {
} }
/**
* 工时管理 查询填报的工时
* @param req
* @param res
*/
async function find(req, res) { async function find(req, res) {
let userId = req.headers.userid; let userId = req.headers.userid;
let result = await workingLogBiz.workinglogList(userId); let result = await workingLogBiz.workinglogList(userId);
res.success(result); res.success(result);
} }
/**
*
* @param req 工时管理 添加
* @param res
*/
async function add(req, res) { async function add(req, res) {
let userId = req.headers.userid; let userId = req.headers.userid;
let reqConf = {time: 'Number', projectId: 'String', isOutside: 'Boolean', date:'String', workLog:"String"}; let reqConf = {time: 'Number', projectId: 'String', isOutside: 'Boolean', date:'String', workLog:"String"};
...@@ -73,6 +84,12 @@ async function add(req, res) { ...@@ -73,6 +84,12 @@ async function add(req, res) {
res.success(result); res.success(result);
} }
/**
* 工时管理 删除
* @param req
* @param res
*/
async function del(req, res) { async function del(req, res) {
let userId = req.headers.userid; let userId = req.headers.userid;
let { id } = req.body; let { id } = req.body;
...@@ -80,6 +97,12 @@ async function del(req, res) { ...@@ -80,6 +97,12 @@ async function del(req, res) {
res.success(result); res.success(result);
} }
/**
* 工时管理 修改
* @param req
* @param res
*/
async function update(req, res) { async function update(req, res) {
let userId = req.headers.userid; let userId = req.headers.userid;
let reqConf = {id:"String", time: 'Number', projectId: 'String', isOutside: 'Boolean', workLog:"String"}; let reqConf = {id:"String", time: 'Number', projectId: 'String', isOutside: 'Boolean', workLog:"String"};
......
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