Commit 8006d117 by 周王清

考勤模块

parent 8bb2542c
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
<value>classpath:com/jw/app/business/store/user/storeUserDAO.xml</value> <value>classpath:com/jw/app/business/store/user/storeUserDAO.xml</value>
<value>classpath:com/jw/app/business/userchoice/userchoiceDAO.xml</value> <value>classpath:com/jw/app/business/userchoice/userchoiceDAO.xml</value>
<value>classpath:com/jw/app/business/calendar/calendarDAO.xml</value> <value>classpath:com/jw/app/business/calendar/calendarDAO.xml</value>
<value>classpath:com/jw/app/business/attendance/attendanceDAO.xml</value>
</list> </list>
</property> </property>
</bean> </bean>
...@@ -70,6 +71,10 @@ ...@@ -70,6 +71,10 @@
<property name="mapperInterface" value="com.jw.app.business.calendar.calendarDAO"/> <property name="mapperInterface" value="com.jw.app.business.calendar.calendarDAO"/>
<property name="sqlSessionFactory" ref="sqlSessionFactory-apps"/> <property name="sqlSessionFactory" ref="sqlSessionFactory-apps"/>
</bean> </bean>
<bean id="attendanceDAO" class="org.mybatis.spring.mapper.MapperFactoryBean">
<property name="mapperInterface" value="com.jw.app.business.attendance.attendanceDAO"/>
<property name="sqlSessionFactory" ref="sqlSessionFactory-apps"/>
</bean>
<!-- BusinessInterFace --> <!-- BusinessInterFace -->
<bean id="PortletBusiness" <bean id="PortletBusiness"
class="com.jw.app.business.portlet.PortletBusinessImpl"> class="com.jw.app.business.portlet.PortletBusinessImpl">
...@@ -116,6 +121,11 @@ ...@@ -116,6 +121,11 @@
<property name="calendarDAO" ref="calendarDAO"/> <property name="calendarDAO" ref="calendarDAO"/>
</bean> </bean>
<bean id="AttendanceBusiness"
class="com.jw.app.business.attendance.AttendanceBusinessImpl">
<property name="attendanceDAO" ref="attendanceDAO"/>
</bean>
<!-- DAO --> <!-- DAO -->
<bean id="portletDAO" class="org.mybatis.spring.mapper.MapperFactoryBean"> <bean id="portletDAO" class="org.mybatis.spring.mapper.MapperFactoryBean">
<property name="mapperInterface" value="com.jw.app.business.portlet.PortletDAO"/> <property name="mapperInterface" value="com.jw.app.business.portlet.PortletDAO"/>
......
<%@page contentType="text/html; charset=UTF-8"%>
<%@ include file="/gaowj/header-simple-1.0.jsp"%>
<div id="attendanceTab">
<link rel="stylesheet" type="text/css" href="${ctx}/jwapp/common/css/content_body.css" charset="utf-8"></link>
<link rel="stylesheet" type="text/css" href="${ctx}/jwapp/common/css/content_table.css" charset="utf-8"></link>
<link rel="stylesheet" type="text/css" href="${ctx}/jwapp/common/css/content_input.css" charset="utf-8"></link>
</div>
<table id="list" style="width: 100%; height: 100%;"></table>
<div id="tb">
<a href="#" style="align : 'center';" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="javascript:dkRow()">打卡</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="javascript:refreshRow()" >刷新</a>
</div>
<script type="text/javascript" src="${ctx}/jwapp/pages/standard/js/jwStandardModule.js" charset="utf-8"></script>
<script type="text/javascript" src="${ctx}/jwapp/pages/attendance/js/attendanceModule.js" charset="utf-8"></script>
<script type="text/javascript" src="${ctx}/jwapp/pages/attendance/js/attendanceEmployeeTab.js" charset="utf-8"></script>
<%@page contentType="text/html; charset=UTF-8"%>
<%@ include file="/gaowj/header-simple-1.0.jsp"%>
<div id="attendanceTab">
<link rel="stylesheet" type="text/css" href="${ctx}/jwapp/common/css/content_body.css" charset="utf-8"></link>
<link rel="stylesheet" type="text/css" href="${ctx}/jwapp/common/css/content_table.css" charset="utf-8"></link>
<link rel="stylesheet" type="text/css" href="${ctx}/jwapp/common/css/content_input.css" charset="utf-8"></link>
</div>
<table id="list" style="width: 100%; height: 100%;"></table>
<div id="tb">
<form id="attendanceTab_searchForm" style="float:left">
姓名: <input class="easyui-textbox" id="FIELD_USER_NAME" name="FIELD_USER_NAME" style="width:200px"/>&nbsp;&nbsp;
</form>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="javascript:searchRow()">查询</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="javascript:refreshRow()">刷新</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="javascript:dkRow()">打卡</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-clear',plain:true" onclick="javascript:deleteBatchRow()">删除</a>
</div>
<script type="text/javascript" src="${ctx}/jwapp/pages/standard/js/jwStandardModule.js" charset="utf-8"></script>
<script type="text/javascript" src="${ctx}/jwapp/pages/attendance/js/attendanceModule.js" charset="utf-8"></script>
<script type="text/javascript" src="${ctx}/jwapp/pages/attendance/js/attendanceTab.js" charset="utf-8"></script>
/**
* 序号:1
* 功能:定义分页(EasyUI)
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:杰夫兄弟
* 备注:无需更改
**/
var ls_width = $(window).width();
var ls_height = $(window).height();
var local_page=1;
var rows=20;
var listPageSize = [10,20,50,100,500,1000];
var queryData = eval("({'page':'"+local_page+"','rows':'"+rows+"'})");
var tab_n = 0;
//重置分页参数
function resetQueryData(){
queryData = "";
queryData = eval("({'page':'"+local_page+"','rows':'"+rows+"'})");
}
//定义附件关联模块ID(1:一般业务,2:测试信息,3:审批业务,999:其它数据 )
var ls_module_id='2';
//定义当前模块业务类型(YBYW:一般业务,SPGL:审批业务)
var ls_ywlx = 'YBYW';
/****/
/****/
/**
* 序号:2
* 功能:构建主页面列表
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:杰夫兄弟
* 备注:需更改
**/
//定义grid列表
var ls_title="打卡管理&nbsp;&nbsp;";
var is_column = [ [
{field : 'DAY_TEXT',title : '日期',width : 80,align : 'center'},
{field : 'BEGIN_TIME',title : '上班时间',width : 150,align : 'center'},
{field : 'END_TIME',title : '下班时间',width : 80,align : 'center'}
] ];
//列表加载完成回调
function reportrollback(){
}
//设置颜色和每行高度
function rowstyler(index,row){
}
//展示列表
reportgrid("list",ls_title,gaowj.WEB_APP_NAME + "/attendanceData_list2",queryData,is_column);
/****/
/**
* 序号3
* 功能:设置主页面操作列菜单
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:杰夫兄弟
* 备注:需更改
**/
//返回菜单集的菜单个数(需更改)
function getOptionMenuCount(){
var is_menu_count = 1;
return is_menu_count;
}
/****/
//加载打卡子页面
function dkRow(is_entity){
var v_result = attendanceModule.attendanceActAction.insertAttendance(is_entity);
$('#list').datagrid('reload');
$.messager.show({
title:' ',
timeout:500,
msg:'打卡成功',
showType:'show',
style:{
right:'',
top:document.body.scrollTop+document.documentElement.scrollTop,
bottom:''
}
});
return v_result;
}
/****/
/**
* 序号:3
* 功能:刷新
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:杰夫兄弟
* 备注:需更改
**/
function refreshRow(){
$('#list').datagrid('load',{});
$("#attendanceTab_searchForm")[0].reset();
}
/****/
/**
* 序号:8
* 功能:查询
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:杰夫兄弟
* 备注:需更改
**/
function searchRow(){
var v_query = $("#attendanceTab_searchForm").getFormVal();
$('#list').datagrid('load',v_query);
}
/****/
//此乃本模块与后台交互的方法接口部分
var attendanceModule = function(format) {
this.module = "";
this.action = "";
this.format = format;
};
//定义数据交互
attendanceModule.prototype = BusinessObject;
//插入考勤数据
attendanceModule.prototype.insertAttendance = function(){};
//修改考勤数据
attendanceModule.prototype.updateAttendance = function(){};
//删除考勤数据
attendanceModule.prototype.deleteAttendance = function(){};
//考勤数据_分页
attendanceModule.prototype.list = function(){};
//考勤所有数据
attendanceModule.prototype.listAll = function(){};
//创建一个数据操作对象,然后再后续使用
attendanceModule.attendanceActAction = new attendanceModule("json").delegate("attendanceAct");
//创建一个数据获取对象,然后再后续使用
attendanceModule.attendanceDataAction = new attendanceModule("json").delegate("attendanceData");
//说明: 1、所有方法里统一传递josn格式的参数,用于后台交互,如data.listTables(param) ,如没有参数则传'{}',如data.listTables({})
// 2、前后台数据获取传输协议 如:json[{'0':{pageCount':'2','pageNo':'1','pageSize':'20','rowSet':'[{0},{1}....]'}}]
// 3、前后台增删改的返回状态 如:json[{'0':{'rowSet':{'NAME':'-1','VALUE':'保存失败'}}}]
/**
* 序号:1
* 功能:定义分页(EasyUI)
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:杰夫兄弟
* 备注:无需更改
**/
var ls_width = $(window).width();
var ls_height = $(window).height();
var local_page=1;
var rows=20;
var listPageSize = [10,20,50,100,500,1000];
var queryData = eval("({'page':'"+local_page+"','rows':'"+rows+"'})");
var tab_n = 0;
//重置分页参数
function resetQueryData(){
queryData = "";
queryData = eval("({'page':'"+local_page+"','rows':'"+rows+"'})");
}
//定义附件关联模块ID(1:一般业务,2:测试信息,3:审批业务,999:其它数据 )
var ls_module_id='2';
//定义当前模块业务类型(YBYW:一般业务,SPGL:审批业务)
var ls_ywlx = 'YBYW';
/****/
/**
* 序号:2
* 功能:构建下拉框内容
* 参数:
* 说明:方便新增、修改页面里的下拉选项加载数据
* 作者:高伟杰
* 时间:2016-01-22
* 单位:杰夫兄弟
* 备注:需更改
**/
/*//加载部门名称数据
var v_dept_namequery = {};
v_dept_namequery.FIELD_tableName = "DM_ORG_SORT";
var v_dept_namequery_data = standardModel.dataAction.listAllCache(v_dept_namequery);
*/
//加载考勤地址 类型数据
var v_kqdzquery_data = [{CODE_ID:'0',CODE_NAME:'公司'},{CODE_ID:'1',CODE_NAME:'非公司'}];
/****/
/**
* 序号:3
* 功能:构建主页面列表
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:杰夫兄弟
* 备注:需更改
**/
//定义grid列表
var ls_title="打卡管理";
var is_column = [ [
{field : 'USER_NAME',title : '人员姓名',width : 100,align : 'center'},
{field : 'DEPT_NAME',title : '部门名称',width : 80,align : 'center'},
{field : 'ATTENDANCE_TIME',title : '打卡时间',width : 150,align : 'center'},
// {field : 'USER_TYPE',title : '人员类型',width : 80,align : 'center'},
/* {field : 'ATTENDANCE_ADDRESS',title : '考勤地址',width : 300,align : 'center',
formatter : function(value) {
return getCodeName(v_kqdzquery_data, value) ;
}
},
{field : 'ATTENDANCE_ADDRESS_DETAIL',title : '考勤详细地址',width : 300,align : 'center'}, */
{field : 'CREATE_ID',title : '创建人员',width : 100,align : 'center'},
{field : 'CREATE_TIME',title : '创建时间',width : 150,align : 'center'}
] ];
//列表加载完成回调
function dataOnLoadSuccess(){
}
//设置颜色和每行高度
function rowstyler(index,row){
}
//展示列表
datagrid("list",ls_title,gaowj.WEB_APP_NAME + "/attendanceData_list",queryData,is_column,60,80);
/****/
/**
* 序号:4
* 功能:设置主页面操作列菜单
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:杰夫兄弟
* 备注:需更改
**/
//操用列显示更多(一般情况下无需更改)
function formatMenu(value, data,index) {
var returnData="";
return returnData
+ "<span class=\"icon-ext-moremenu\" style=\"padding-left:20px;*width:20px;\"></span>"
+ "<span data-p1="+index+" class=\"easyui-tooltip\" style=\"color:blue;cursor:pointer;\">更多</span>";
}
//上浮横向菜单集里的具体菜单项(需更改)
function getOptionMenu(data,index){
var returnData= " <span class=\"icon-clear\" style=\"padding-left:20px;*width:20px;\"></span><a href=\"javascript:void(0);\" onclick=\"deleteRow('"
+ index + "')\">删除</a> ";
return returnData;
}
//返回菜单集的菜单个数(需更改)
function getOptionMenuCount(){
var is_menu_count = 1;
return is_menu_count;
}
/****/
//加载打卡子页面
function dkRow(is_entity){
var v_result = attendanceModule.attendanceActAction.insertAttendance(is_entity);
$('#list').datagrid('reload');
$.messager.show({
title:' ',
timeout:500,
msg:'打卡成功',
showType:'show',
style:{
right:'',
top:document.body.scrollTop+document.documentElement.scrollTop,
bottom:''
}
});
return v_result;
}
/****/
/**
* 序号:5
* 功能:单个删除
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:杰夫兄弟
* 备注:需更改
**/
function deleteRow(index){
$('#list').datagrid('selectRow',index);
var is_row = $('#list').datagrid('getSelections');
$('#list').datagrid('clearSelections');
var code = is_row[0].UUID;
$.messager.confirm('提示', '确定删除?', function(r) {
if (r) {
var v_query = {};
v_query.FIELD_CODE = code;
var v_result = attendanceModule.attendanceActAction.deleteAttendance(v_query);
$.messager.alert('提示',v_result.VALUE);
$('#list').datagrid('reload');
}
});
}
/****/
/**
* 序号:6
* 功能:批量删除
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:杰夫兄弟
* 备注:需更改
**/
function deleteBatchRow(){
var code="";
var rows = $('#list').datagrid('getSelections');
for(var i=0; i<rows.length; i++){
code = code + rows[i].UUID+",";
}
if(rows == null || rows == ""){
$.messager.alert('提示',"请选择需删除的记录!",'info');
return;
}
if(code.length>0){
code = code.substring(0,code.length - 1);
}
$.messager.confirm('提示', '确定删除?', function(r) {
if (r) {
var v_query = {};
v_query.FIELD_CODE = code;
var v_result = attendanceModule.attendanceActAction.deleteAttendance(v_query);
$.messager.alert('提示',v_result.VALUE);
$('#list').datagrid('reload');
}
});
}
/****/
/**
* 序号:7
* 功能:刷新
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:杰夫兄弟
* 备注:需更改
**/
function refreshRow(){
$('#list').datagrid('load',{});
$("#attendanceTab_searchForm")[0].reset();
}
/****/
/**
* 序号:8
* 功能:查询
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:杰夫兄弟
* 备注:需更改
**/
function searchRow(){
var v_query = $("#attendanceTab_searchForm").getFormVal();
$('#list').datagrid('load',v_query);
}
/****/
...@@ -89,6 +89,24 @@ ...@@ -89,6 +89,24 @@
<action name="userchoiceView_*" class="com.jw.app.userchoice.action.viewAction" method="{1}"> <action name="userchoiceView_*" class="com.jw.app.userchoice.action.viewAction" method="{1}">
<result name="{1}">/jwapp/pages/userchoice/{1}.jsp</result> <result name="{1}">/jwapp/pages/userchoice/{1}.jsp</result>
</action> </action>
<!-- 考勤相关 -->
<action name="attendanceAct_*" class="com.jw.app.attendance.action.actAction"
method="{1}">
<result name="json" type="json">
<param name="root">jsonObject</param>
</result>
</action>
<action name="attendanceData_*" class="com.jw.app.attendance.action.dataAction"
method="{1}">
<result name="json" type="json">
<param name="root">jsonObject</param>
</result>
</action>
<action name="attendanceView_*" class="com.jw.app.attendance.action.viewAction"
method="{1}">
<result name="{1}">/jwapp/pages/attendance/{1}.jsp</result>
</action>
<!-- 日历相关 --> <!-- 日历相关 -->
<action name="calendarAct_*" class="com.jw.app.calendar.action.actAction" <action name="calendarAct_*" class="com.jw.app.calendar.action.actAction"
method="{1}"> method="{1}">
......
package com.jw.app.attendance.action;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONObject;
import com.gaowj.business.SystemOpeBusiness;
import com.gaowj.business.action.BasicAction;
import com.gaowj.business.comp.BusinessManager;
import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.QueryParamUtil;
import com.gaowj.business.util.RequestUtils;
import com.gaowj.business.util.Status;
import com.gaowj.standard.utils.CacheKit;
import com.jw.app.business.AttendanceBusiness;
public class actAction extends BasicAction {
private static final long serialVersionUID = 1407459954477199670L;
/**
*
*/
private JSONObject jsonObject = new JSONObject();
public JSONObject getJsonObject() {
return jsonObject;
}
public void setJsonObject(JSONObject jsonObject) {
this.jsonObject = jsonObject;
}
/**
* 插入
* @param entity
* @throws BusinessException
*/
public String insertAttendance() throws BusinessException {
AttendanceBusiness business = BusinessManager.getBusiness(AttendanceBusiness.class);
Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
jsonObject = new JSONObject();
try {
entity = QueryParamUtil.StringToDate(entity);
//去除不要更新的字段
entity.remove("OPETYPE");
//新增
business.insert_attendance(entity);
// 操作日志
//sysbusiness.insert_logBusiness(具体方法,操作内容,操作描述,操作记录ID,操作记录中文描述,分类)
SystemOpeBusiness sysbusiness = BusinessManager.getBusiness(SystemOpeBusiness.class);
sysbusiness.insert_logBusiness("insertAttendance", "" + entity,
"增加考勤记录", (String) entity.get("UUID"), (String) entity.get("NAME"), "attendancedemo1");
//
jsonObject.putAll(Status.getStatusSuccessMessage("保存成功"));
} catch (Exception e) {
jsonObject.putAll(Status.getStatusErrorMessage("保存失败"));
e.printStackTrace();
}
return "json";
}
/**
* 更新
* @param entity
* @throws BusinessException
*/
public String updateAttendance() throws BusinessException {
AttendanceBusiness business = BusinessManager.getBusiness(AttendanceBusiness.class);
Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
try {
//去除不要更新的字段
entity.remove("OPETYPE");
//修改
entity = QueryParamUtil.StringToDate(entity);
business.update_attendance(entity);
// 操作日志
SystemOpeBusiness sysbusiness = BusinessManager.getBusiness(SystemOpeBusiness.class);
sysbusiness.insert_logBusiness("updateAttendance", "" + entity,
"修改考勤记录",(String) entity.get("UUID"), (String) entity.get("NAME"),"attendancedemo1");
//
jsonObject.putAll(Status.getStatusSuccessMessage("修改成功"));
} catch (Exception e) {
jsonObject.putAll(Status.getStatusErrorMessage("修改失败"));
e.printStackTrace();
}
return "json";
}
/**
* 在软删除基础上删除记录
* @param entity
* @throws BusinessException
*/
public String deleteAttendance() throws BusinessException {
AttendanceBusiness business = BusinessManager.getBusiness(AttendanceBusiness.class);
Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
String deletekey = (String) entity.get("CODE");
List<String> ListKey = QueryParamUtil.StringToList(deletekey);
try {
business.delete_attendance(ListKey);
// 操作日志
SystemOpeBusiness sysbusiness = BusinessManager.getBusiness(SystemOpeBusiness.class);
sysbusiness.insert_logBusiness("deleteAttendance", "" + ListKey,
"删除考勤记录", deletekey, "多个流水号","attendancedemo1");
//
jsonObject.putAll(Status.getStatusSuccessMessage("删除成功"));
} catch (Exception e) {
jsonObject.putAll(Status.getStatusErrorMessage("删除失败"));
e.printStackTrace();
}
return "json";
}
}
package com.jw.app.attendance.action;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONObject;
import com.gaowj.business.action.BasicAction;
import com.gaowj.business.comp.BusinessManager;
import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.Page;
import com.gaowj.business.util.PropUtil;
import com.gaowj.business.util.QueryParamUtil;
import com.gaowj.business.util.RequestUtils;
import com.gaowj.business.util.SessionUtil;
import com.gaowj.business.util.TestMd5;
import com.gaowj.standard.utils.CacheKit;
import com.jw.app.business.AttendanceBusiness;
public class dataAction extends BasicAction{
private static final long serialVersionUID = -5763420688795370601L;
/**
*
*/
private JSONObject jsonObject = new JSONObject();
private int rows = 20;// 每页显示的记录数
private int page = 1;// 当前第几页
public JSONObject getJsonObject() {
return jsonObject;
}
public void setJsonObject(JSONObject jsonObject) {
this.jsonObject = jsonObject;
}
public int getRows() {
return rows;
}
public void setRows(int rows) {
this.rows = rows;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
/**
* 管理员界面分页获取记录
* @param entity
* @throws BusinessException
*/
public String list() throws BusinessException {
AttendanceBusiness business = BusinessManager.getBusiness(AttendanceBusiness.class);
Map<String, Object> query = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
try {
query = QueryParamUtil.StringToDate(query);
Page<Map<String, Object>> pageRows = business.list_attendance(pageNo,pageSize, query);
setPageCount((pageRows.getCount() - 1) / pageSize + 1);
Map<String, Object> data = new HashMap<String, Object>();
data.put("rowSet", QueryParamUtil.DateTimeToString(pageRows.getItems()));
data.put("pageNo", pageNo);
data.put("pageSize", pageSize);
data.put("pageCount", pageCount);
data.put("rows", data.get("rowSet"));
data.put("total", pageRows.getCount());
jsonObject = new JSONObject();
jsonObject.putAll(data);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "json";
}
/**
* 员工考勤界面分页获取记录
* @param entity
* @throws BusinessException
*/
public String list2() throws BusinessException {
AttendanceBusiness business = BusinessManager.getBusiness(AttendanceBusiness.class);
Map<String, Object> query = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
try {
query = QueryParamUtil.StringToDate(query);
Page<Map<String, Object>> pageRows = business.list_attendanceEmployee(pageNo,pageSize, query);
setPageCount((pageRows.getCount() - 1) / pageSize + 1);
Map<String, Object> data = new HashMap<String, Object>();
data.put("rowSet", QueryParamUtil.DateTimeToString(pageRows.getItems()));
data.put("pageNo", pageNo);
data.put("pageSize", pageSize);
data.put("pageCount", pageCount);
data.put("rows", data.get("rowSet"));
data.put("total", pageRows.getCount());
jsonObject = new JSONObject();
jsonObject.putAll(data);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "json";
}
}
package com.jw.app.attendance.action;
import java.util.Map;
import com.gaowj.business.action.BasicAction;
import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.RequestUtils;
public class viewAction extends BasicAction {
/**
*
*/
private static final long serialVersionUID = 2552316251030971461L;
public String attendanceTab() throws BusinessException{
return "attendanceTab";
}
public String attendanceEmployeeTab() throws BusinessException{
return "attendanceEmployeeTab";
}
public String attendanceTabDetail() throws BusinessException{
Map<String,Object> query = RequestUtils.getUpdateFieldMapUtf8(request, RequestUtils.UPDATEDATAFIELDPREFIX);
request.setAttribute("is_row", query);
return "attendanceTabDetail";
}
}
package com.jw.app.business;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.Page;
@Service
public interface AttendanceBusiness {
/**
* 插入
* @param entity
* @throws BusinessException
*/
void insert_attendance(Map<String,Object> entity) throws BusinessException ;
/**
* 更新
* @param entity
* @throws BusinessException
*/
void update_attendance(Map<String,Object> entity) throws BusinessException ;
/**
* 删除记录
* @param entity
* @throws BusinessException
*/
void delete_attendance(List<String> list)throws BusinessException;
/**
* 分页获取记录
* @param entity
* @throws BusinessException
*/
Page<Map<String, Object>> list_attendance(int pageNo, int pageSize, Map<String, Object> query)throws BusinessException ;
/**
* 获取所有记录
* @param entity
* @throws BusinessException
*/
List<Map<String,Object>> list_attendance(Map<String, Object> query) throws BusinessException ;
/**
* 获取所有记录数
* @param entity
* @throws BusinessException
*/
int listCount_attendance(Map<String, Object> query) throws BusinessException ;
//员工考勤
Page<Map<String, Object>> list_attendanceEmployee(int pageNo, int pageSize, Map<String, Object> query)throws BusinessException ;
/**
* 获取所有记录
* @param entity
* @throws BusinessException
*/
List<Map<String,Object>> list_attendanceEmployee(Map<String, Object> query) throws BusinessException ;
/**
* 获取所有记录数
* @param entity
* @throws BusinessException
*/
int listCount_attendanceEmployee(Map<String, Object> query) throws BusinessException ;
}
package com.jw.app.business.attendance;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.ibatis.session.RowBounds;
import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.Page;
import com.gaowj.business.util.SessionUtil;
import com.gaowj.standard.utils.CacheKit;
import com.jw.app.business.AttendanceBusiness;
import oracle.net.aso.f;
public class AttendanceBusinessImpl implements AttendanceBusiness {
private attendanceDAO attendanceDAO;
public attendanceDAO getattendanceDAO() {
return attendanceDAO;
}
public void setattendanceDAO(attendanceDAO attendanceDAO) {
this.attendanceDAO = attendanceDAO;
}
@Override
public void insert_attendance(Map<String, Object> entity) throws BusinessException {
entity.put("UUID", java.util.UUID.randomUUID().toString());
if(entity.get("USER_ID")==null){
entity.put("USER_ID", SessionUtil.getEmid());
}
if(entity.get("USER_NAME")==null){
entity.put("USER_NAME", SessionUtil.getEmname());
}
if(entity.get("DEPT_ID")==null){
entity.put("DEPT_ID", SessionUtil.getEmdepart());
}
if(entity.get("DEPT_NAME")==null){
entity.put("DEPT_NAME", SessionUtil.getEmdepartname());
}
if(entity.get("ATTENDANCE_TIME")==null){
entity.put("ATTENDANCE_TIME", new Date());
}
if(entity.get("ATTENDANCE_ADDRESS")==null){
entity.put("ATTENDANCE_ADDRESS", 0);
}
if(entity.get("CREATE_TIME")==null){
entity.put("CREATE_TIME", new Date());
}
if(entity.get("CREATE_ID")==null){
entity.put("CREATE_ID", SessionUtil.getCode());
}
if(entity.get("UPDATE_ID")==null){
entity.put("UPDATE_ID", SessionUtil.getCode());
}
if(entity.get("UPDATE_TIME")==null){
entity.put("UPDATE_TIME", new Date());
}
//动态传值插入
List<String> infoListKey = new ArrayList<String>();
List<Object> infoList = new ArrayList<Object>();
if(entity.keySet()!=null){
Set<String> key = entity.keySet();
// 将map集合中的key和value 取出来分别放到list集合里
for (String str : key) {
infoList.add(entity.get(str));
infoListKey.add(str);
}
entity.put("infoListKey", infoListKey);
entity.put("infoList", infoList);
// 插入
attendanceDAO.insert_attendance(entity);
}
}
@Override
public void update_attendance(Map<String, Object> entity) throws BusinessException {
if(entity.get("UPDATE_ID")==null){
entity.put("UPDATE_ID", SessionUtil.getCode());
}
if(entity.get("UPDATE_TIME")==null){
entity.put("UPDATE_TIME", new Date());
}
//动态传值修改
List<Map<String, Object>> updateList = new ArrayList<Map<String, Object>>();
if(entity.keySet()!=null){
Set<String> key = entity.keySet();
// 将map集合中的key和value 取出来分别放到list集合里
for (String str : key) {
Map<String, Object> updateMap = new HashMap<String, Object>();
if (StringUtils.equalsIgnoreCase("UUID",str)) continue;
updateMap.put("key", str);
updateMap.put("value", entity.get(str));
updateList.add(updateMap);
}
entity.put("info", updateList);
//
attendanceDAO.update_attendance(entity);
}
}
@Override
public void delete_attendance(List<String> list) throws BusinessException {
attendanceDAO.delete_attendance(list);
}
@Override
public Page<Map<String, Object>> list_attendance(int pageNo, int pageSize,Map<String, Object> query) throws BusinessException {
//计算起始记录
int pageStart = (pageNo - 1) * pageSize;
//获取列表
List<Map<String, Object>> items = attendanceDAO.list_attendance(new RowBounds(pageStart, pageSize), query);
//获取列表个数
int count = listCount_attendance(query);
//创建分页对象
Page<Map<String, Object>> page = new Page<Map<String, Object>>();
page.setStart(pageStart);
page.setLimit(pageSize);
page.setCount(count);
page.setItems(items);
return page;
}
@Override
public List<Map<String, Object>> list_attendance(Map<String, Object> query) throws BusinessException {
List<Map<String, Object>> list_data = CacheKit.get("ehcache10", "attendance"+query);
if(list_data==null || list_data.size()==0){
list_data=attendanceDAO.list_attendance(query);
CacheKit.put("ehcache10", "attendance"+query, list_data);
}
return list_data;
}
@Override
public int listCount_attendance(Map<String, Object> query) throws BusinessException {
return attendanceDAO.listCount_attendance(query);
}
//员工考勤
@Override
public Page<Map<String, Object>> list_attendanceEmployee(int pageNo, int pageSize,Map<String, Object> query) throws BusinessException {
query.put("USER_ID", SessionUtil.getEmid());
//计算起始记录
int pageStart = (pageNo - 1) * pageSize;
//获取列表
List<Map<String, Object>> items = attendanceDAO.list_attendanceEmployee(new RowBounds(pageStart, pageSize), query);
//获取列表个数
int count = listCount_attendanceEmployee(query);
//创建分页对象
Page<Map<String, Object>> page = new Page<Map<String, Object>>();
page.setStart(pageStart);
page.setLimit(pageSize);
page.setCount(count);
page.setItems(items);
return page;
}
@Override
public List<Map<String, Object>> list_attendanceEmployee(Map<String, Object> query) throws BusinessException {
List<Map<String, Object>> list_data = CacheKit.get("ehcache10", "attendanceEmployee"+query);
if(list_data==null || list_data.size()==0){
list_data=attendanceDAO.list_attendanceEmployee(query);
CacheKit.put("ehcache10", "attendanceEmployee"+query, list_data);
}
return list_data;
}
@Override
public int listCount_attendanceEmployee(Map<String, Object> query) throws BusinessException {
return attendanceDAO.listCount_attendanceEmployee(query);
}
}
package com.jw.app.business.attendance;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.session.RowBounds;
import com.gaowj.business.exception.BusinessException;
public interface attendanceDAO {
void insert_attendance(Map<String,Object> entity) throws BusinessException ;
void update_attendance(Map<String,Object> entity) throws BusinessException ;
void delete_attendance(List<String> list) throws BusinessException;
List<Map<String,Object>> list_attendance(RowBounds rowbounds, Map<String, Object> query) throws BusinessException ;
List<Map<String,Object>> list_attendance(Map<String,Object> query) throws BusinessException ;
int listCount_attendance(Map<String, Object> query) throws BusinessException ;
List<Map<String,Object>> list_attendanceEmployee(RowBounds rowbounds, Map<String, Object> query) throws BusinessException ;
List<Map<String,Object>> list_attendanceEmployee(Map<String,Object> query) throws BusinessException ;
int listCount_attendanceEmployee(Map<String, Object> query) throws BusinessException ;
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jw.app.business.attendance.attendanceDAO">
<sql id="WHERE">
<where>
<trim prefixOverrides="and">
<if test="UUID != null and UUID != ''">
and f.UUID = #{UUID}
</if>
<if test="USER_ID != null and USER_ID != ''">
and f.USER_ID = #{USER_ID}
</if>
<if test="USER_NAME != null and USER_NAME != ''">
and f.USER_NAME like '%${USER_NAME}%'
</if>
<if test="DEPT_ID != null and DEPT_ID != ''">
and f.DEPT_ID = #{DEPT_ID}
</if>
<if test="DEPT_NAME != null and DEPT_NAME != ''">
and f.DEPT_NAME = #{DEPT_NAME}
</if>
<if test="START_TIME != null and START_TIME != ''">
and f.ATTENDANCE_TIME &gt;= #{ATTENDANCE_TIME}
</if>
<if test="END_TIME != null and END_TIME != ''">
and f.ATTENDANCE_TIME &lt;= #{ATTENDANCE_TIME}
</if>
<if test="ATTENDANCE_ADDRESS != null and ATTENDANCE_ADDRESS != ''">
and f.ATTENDANCE_ADDRESS = #{ATTENDANCE_ADDRESS}
</if>
<if
test="ATTENDANCE_ADDRESS_DETAIL != null and ATTENDANCE_ADDRESS_DETAIL != ''">
and f.ATTENDANCE_ADDRESS_DETAIL = #{ATTENDANCE_ADDRESS_DETAIL}
</if>
<if test="MAP_PATH != null and MAP_PATH != ''">
and f.MAP_PATH = #{MAP_PATH}
</if>
<if test="USER_TYPE != null and USER_TYPE != ''">
and f.USER_TYPE = #{USER_TYPE}
</if>
<if test="CREATOR_ID != null and CREATOR_ID != ''">
and f.CREATOR_ID = #{CREATOR_ID}
</if>
<if test="CREATE_TIME != null and CREATE_TIME != ''">
and f.CREATE_TIME = #{CREATE_TIME}
</if>
<if test="UPDATE_ID != null and UPDATE_ID != ''">
and f.UPDATE_ID = #{UPDATE_ID}
</if>
<if test="UPDATE_TIME != null and UPDATE_TIME != ''">
and f.UPDATE_TIME = #{UPDATE_TIME}
</if>
</trim>
</where>
</sql>
<!-- 管理人员考勤 -->
<insert id="insert_attendance" parameterType="map">
insert into ATTENDANCE_INFO(
<trim prefix="" suffixOverrides=",">
<foreach collection="infoListKey" item="key">
${key},
</foreach>
</trim>
<![CDATA[ ) values( ]]>
<trim prefix="" suffixOverrides=",">
<foreach collection="infoList" item="value">
#{value},
</foreach>
</trim>
<![CDATA[ ) ]]>
</insert>
<update id="update_attendance" parameterType="map">
<![CDATA[
update ATTENDANCE_INFO set
]]>
<trim prefix="" suffixOverrides=",">
<foreach collection="info" item="info">
${info.key} = #{info.value} ,
</foreach>
</trim>
<where>
<if test="UUID != null and UUID != ''">
and UUID = #{UUID}
</if>
</where>
</update>
<delete id="delete_attendance" parameterType="list">
<![CDATA[
delete from ATTENDANCE_INFO where UUID IN
]]>
<foreach collection="list" item="UUID" open="(" separator=","
close=")">
#{UUID}
</foreach>
</delete>
<select id="list_attendance" parameterType="map" resultType="upperCaseKeyMap">
select f.*
from ATTENDANCE_INFO f
<include refid="WHERE"></include>
order by f.CREATE_TIME DESC
</select>
<select id="listCount_attendance" parameterType="map"
resultType="int">
select count(*) c from ATTENDANCE_INFO f
<include refid="WHERE"></include>
</select>
<!-- 员工考勤 -->
<select id="list_attendanceEmployee" parameterType="map"
resultType="upperCaseKeyMap">
select
a.DEPT_NAME,a.USER_ID,DATE_FORMAT(a.ATTENDANCE_TIME,'%Y-%m-%d') as
day_text,DATE_FORMAT(MIN(a.ATTENDANCE_TIME),'%H:%i:%s') as
BEGIN_TIME,CASE WHEN MIN(a.ATTENDANCE_TIME)=MAX(a.ATTENDANCE_TIME)
THEN '未打卡' ELSE DATE_FORMAT(MAX(a.ATTENDANCE_TIME),'%H:%i:%s') END as
END_TIME from `attendance_info` a GROUP by a.USER_ID,DATE_FORMAT
(a.ATTENDANCE_TIME,'%Y-%m-%d')
having a.USER_ID=#{USER_ID}; </select>
<select id="listCount_attendanceEmployee" parameterType="map"
resultType="int">
select count(b.USER_ID) from (
select a.USER_ID,DATE_FORMAT
(a.ATTENDANCE_TIME,'%Y-%m-%d') from
`attendance_info` a GROUP by
a.USER_ID,DATE_FORMAT
(a.ATTENDANCE_TIME,'%Y-%m-%d')
having
a.USER_ID=#{USER_ID}) b;
</select>
</mapper>
\ No newline at end of file
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