package com.slcf.controller;
|
|
import java.util.List;
|
import java.util.Map;
|
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import com.slcf.pojo.UserBean;
|
import com.slcf.bean.SysLogCondition;
|
import com.slcf.pojo.SysLogBean;
|
import com.slcf.service.RoleService;
|
import com.slcf.service.SysLogService;
|
import com.slcf.util.AuthorityCode;
|
|
/**
|
* 日志管理控制器层
|
* @author admin
|
* @date 2018年11月9日
|
*/
|
@Controller
|
@RequestMapping("/user")
|
public class SysLogController {
|
|
@Resource
|
SysLogService sysLogService;
|
@Autowired
|
RoleService roleService;
|
|
@RequestMapping("/goSysLog.action")
|
public String goSysLogPage(HttpServletRequest request){
|
try {
|
String rid = request.getSession().getAttribute("ROLEID").toString();
|
String authCode = roleService.getAuthListByRoleMenu(Integer.parseInt(rid),
|
AuthorityCode.SysLogCode);
|
request.getSession().setAttribute("AUTHCODE",authCode);
|
// 插入日志
|
UserBean user = (UserBean) request.getSession().getAttribute("USER");
|
SysLogBean sysLog = new SysLogBean();
|
sysLog.setLogin_no(user.getUser_account());
|
sysLog.setMachine_ip(request.getRemoteAddr());
|
sysLog.setForm_no("goSysLog.action");
|
sysLog.setTts_keyname("访问:系统日志");
|
sysLog.setModi_user(user.getUser_account());
|
sysLogService.insertSysLog(sysLog);
|
}catch (Exception e) {
|
System.out.println(e.getMessage());
|
}
|
return "sysLog";
|
}
|
|
// /**
|
// * 添加工作状态
|
// * @param SysLogEntity
|
// * @param request
|
// * @return
|
// */
|
// @ResponseBody
|
// @RequestMapping("/addSysLog.action")
|
// public Integer insertSysLog(SysLogEntity SysLog,HttpServletRequest request){
|
// int result=0;
|
// try {
|
// UserBean user=(UserBean)request.getSession().getAttribute("USER");
|
// int srow = SysLog.getS_row();
|
// int erow = SysLog.getE_row();
|
// int sbay = SysLog.getS_bay();
|
// int ebay = SysLog.getE_bay();
|
// int slev = SysLog.getS_lev();
|
// int elev = SysLog.getE_lev();
|
// int loc_type = SysLog.getLoc_type();
|
//
|
// for(int i=srow; i<=erow; i++) {
|
// for(int j=sbay; j<=ebay; j++) {
|
// for(int k=slev; k<=elev; k++) {
|
// String loc_no = String.format("%02d", i) + String.format("%03d", j) + String.format("%02d", k);
|
// int crn_no = (i+1)/2;
|
// SysLogBean loc = new SysLogBean();
|
// loc.setLoc_no(loc_no);
|
// loc.setLoc_sts("O");
|
// loc.setModi_user(user.getUser_account());
|
// loc.setRow1(i);
|
// loc.setBay1(j);
|
// loc.setLev1(k);
|
// loc.setCrn_no(crn_no);
|
// loc.setLoc_type(loc_type);
|
// sysLogService.insertSysLog(loc);
|
// result++;
|
// }
|
// }
|
// }
|
//// System.out.println(i+"++++++++++++");
|
// }catch(Exception e) {
|
// System.out.println(e.getMessage());
|
// result=0;
|
// }
|
// return result;
|
// }
|
|
/**
|
* 分页查询所有
|
* @param pageNumber
|
* @param pageSize
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/sysLogList.action")
|
public Map<String,Object> querySysLogListByPages(SysLogCondition sysLogCon){
|
Map<String,Object>map=sysLogService.querySysLogList(sysLogCon);
|
return map;
|
}
|
// @ResponseBody
|
// @RequestMapping("/SysLogList.action")
|
// public Map<String,Object> querySysLogListByPages(
|
// @RequestParam(value="pageNumber",defaultValue="1",required=false)int pageNumber,
|
// @RequestParam("pageSize")int pageSize){
|
// Map<String,Object>map=new HashMap<String, Object>();
|
// try {
|
// int count=sysLogService.querySysLogCount();
|
// List<SysLogBean>dlist=sysLogService.querySysLogList((pageNumber-1)*pageSize, pageSize);
|
// map.put("total", count);
|
// map.put("rows", dlist);
|
// }catch(Exception e) {
|
// System.out.println(e.getMessage());
|
// }
|
// return map;
|
// }
|
|
/**
|
* 根据id查询信息
|
* @param id
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/querySysLogById.action")
|
public SysLogBean querySysLogById(@RequestParam("did")int id){
|
try {
|
return sysLogService.querySysLogById(id);
|
}catch(Exception e) {
|
System.out.println(e.getMessage());
|
return null;
|
}
|
}
|
|
// /**
|
// * 验证工作代号是否唯一
|
// * @param did
|
// * @return
|
// */
|
// @ResponseBody
|
// @RequestMapping("/checkSysLog.action")
|
// public Map<String,Object> checkSysLog(@RequestParam("did")int id){
|
// Map<String,Object> map=new HashMap<String, Object>();
|
//// boolean flag=userService.validUserAccount(account, uid);
|
// try {
|
// SysLogBean SysLog = sysLogService.querySysLogById(id);
|
// if(SysLog==null){
|
// map.put("msg", "代号可用");
|
// }else{
|
// map.put("msg", "代号不可用");
|
// }
|
// }catch(Exception e) {
|
// System.out.println(e.getMessage());
|
// }
|
// return map;
|
// }
|
//
|
// /**
|
// * 修改信息
|
// * @param SysLogEntity
|
// * @return
|
// */
|
// @ResponseBody
|
// @RequestMapping("/upSysLog.action")
|
// public Integer upSysLog(SysLogBean SysLog,HttpServletRequest request){
|
// int result = 0;
|
// try {
|
// UserBean user=(UserBean)request.getSession().getAttribute("USER");
|
// SysLog.setModi_user(user.getUser_account());
|
//
|
// result=sysLogService.upSysLog(SysLog);
|
// }catch(Exception e) {
|
// System.out.println(e.getMessage());
|
// }
|
// return result;
|
// }
|
|
/**
|
* 删除信息
|
* @param id
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/delSysLog.action")
|
public int delSysLog(@RequestParam("did")int id,HttpServletRequest request){
|
int result = 0;
|
try {
|
result=sysLogService.delSysLog(id);
|
|
if(result>0) {
|
// 插入日志
|
UserBean user = (UserBean) request.getSession().getAttribute("USER");
|
SysLogBean sysLog = new SysLogBean();
|
sysLog.setLogin_no(user.getUser_account());
|
sysLog.setMachine_ip(request.getRemoteAddr());
|
sysLog.setForm_no("delSysLog.action");
|
sysLog.setTts_keyname("删除系统日志,ID:" + id);
|
sysLog.setModi_user(user.getUser_account());
|
sysLogService.insertSysLog(sysLog);
|
}
|
}catch(Exception e) {
|
System.out.println(e.getMessage());
|
}
|
return result;
|
}
|
|
/**
|
* 查询所有
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/getSysLog.action")
|
public List<SysLogBean> getSysLog(){
|
try {
|
return sysLogService.getSysLogList();
|
}catch(Exception e) {
|
System.out.println(e.getMessage());
|
return null;
|
}
|
}
|
|
/**
|
* 清空
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/resetSysLog.action")
|
public int resetSysLog(HttpServletRequest request){
|
int result = 0;
|
try {
|
result=sysLogService.resetSysLog();
|
|
if(result>0) {
|
// 插入日志
|
UserBean user = (UserBean) request.getSession().getAttribute("USER");
|
SysLogBean sysLog = new SysLogBean();
|
sysLog.setLogin_no(user.getUser_account());
|
sysLog.setMachine_ip(request.getRemoteAddr());
|
sysLog.setForm_no("delSysLog.action");
|
sysLog.setTts_keyname("清空日志");
|
sysLog.setModi_user(user.getUser_account());
|
sysLogService.insertSysLog(sysLog);
|
}
|
}catch(Exception e) {
|
System.out.println(e.getMessage());
|
}
|
return result;
|
}
|
|
/**
|
* 导出所有
|
* @param response
|
*/
|
@RequestMapping("/exportSysLog.action")
|
public void ExportExcel(SysLogCondition sysLogCon, HttpServletResponse response,HttpServletRequest request){
|
try {
|
sysLogService.ExportSysLogList(sysLogCon,response);
|
|
// 插入日志
|
UserBean user = (UserBean) request.getSession().getAttribute("USER");
|
SysLogBean sysLog = new SysLogBean();
|
sysLog.setLogin_no(user.getUser_account());
|
sysLog.setMachine_ip(request.getRemoteAddr());
|
sysLog.setForm_no("exportSysLog.action");
|
sysLog.setTts_keyname("导出系统日志到EXCEL");
|
sysLog.setModi_user(user.getUser_account());
|
sysLogService.insertSysLog(sysLog);
|
}catch (Exception e) {
|
System.out.println(e.getMessage());
|
}
|
}
|
}
|