Commit e9629e7a authored by Sun's avatar Sun
Browse files

no commit message

parent e4054436
/**
* * Copyright &copy; 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package com.jeespring.modules.job.web;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.jeespring.modules.sys.service.SysConfigService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.google.common.collect.Lists;
import com.jeespring.common.utils.DateUtils;
import com.jeespring.common.config.Global;
import com.jeespring.common.persistence.Page;
import com.jeespring.common.web.AbstractBaseController;
import com.jeespring.common.utils.StringUtils;
import com.jeespring.common.utils.excel.ExportExcel;
import com.jeespring.common.utils.excel.ImportExcel;
import com.jeespring.modules.job.entity.SysJobLog;
import com.jeespring.modules.job.service.SysJobLogService;
/**
* 定时任务调度日志表Controller
* @author JeeSpring
* @version 2018-08-16
*/
@Controller
@RequestMapping(value = "${adminPath}/job/sysJobLog")
public class SysJobLogController extends AbstractBaseController {
@Autowired
private SysJobLogService sysJobLogService;
@Autowired
private SysConfigService sysConfigService;
@ModelAttribute
public SysJobLog get(@RequestParam(required=false) String id) {
SysJobLog entity = null;
if (StringUtils.isNotBlank(id)){
entity = sysJobLogService.getCache(id);
//entity = sysJobLogService.get(id);
}
if (entity == null){
entity = new SysJobLog();
}
return entity;
}
/**
* 定时任务调度日志统计页面
*/
@RequiresPermissions("job:sysJobLog:total")
@RequestMapping(value = {"total"})
public String totalView(SysJobLog sysJobLog, HttpServletRequest request, HttpServletResponse response, Model model) {
total(sysJobLog,request,response,model);
return "modules/job/sysJobLogTotal";
}
private void total(SysJobLog sysJobLog, HttpServletRequest request, HttpServletResponse response, Model model) {
if(StringUtils.isEmpty(sysJobLog.getTotalType())){
sysJobLog.setTotalType("%Y-%m-%d");
}
//X轴的数据
List<String> xAxisData= new ArrayList<String>();
//Y轴的数据
Map<String,List<Double>> yAxisData = new HashMap<String,List<Double>>();
List<Double> countList = new ArrayList<Double>();
List<Double> sumList = new ArrayList<Double>();
if(sysJobLog.getOrderBy()==""){
sysJobLog.setOrderBy("totalDate");
}
List<SysJobLog> list = sysJobLogService.totalCache(sysJobLog);
//List<SysJobLog> list = sysJobLogService.total(sysJobLog);
model.addAttribute("list", list);
for(SysJobLog sysJobLogItem:list){
//x轴数据
xAxisData.add( sysJobLogItem.getTotalDate());
countList.add(Double.valueOf(sysJobLogItem.getTotalCount()));
}
yAxisData.put("数量", countList);
request.setAttribute("xAxisData", xAxisData);
request.setAttribute("yAxisData", yAxisData);
model.addAttribute("sumTotalCount", list.stream().mapToInt(SysJobLog::getTotalCount).sum());
//饼图数据
Map<String,Object> orientData= new HashMap<String,Object>();
for(SysJobLog sysJobLogItem:list){
orientData.put(sysJobLogItem.getTotalDate(), sysJobLogItem.getTotalCount());
}
model.addAttribute("orientData", orientData);
}
@RequiresPermissions("job:sysJobLog:total")
@RequestMapping(value = {"totalMap"})
public String totalMap(SysJobLog sysJobLog, HttpServletRequest request, HttpServletResponse response, Model model) {
if(StringUtils.isEmpty(sysJobLog.getTotalType())){
sysJobLog.setTotalType("%Y-%m-%d");
}
List<SysJobLog> list = sysJobLogService.totalCache(sysJobLog);
//List<SysJobLog> list = sysJobLogService.total(sysJobLog);
model.addAttribute("sumTotalCount", list.stream().mapToInt(SysJobLog::getTotalCount).sum());
model.addAttribute("list", list);
return "modules/job/sysJobLogTotalMap";
}
/**
* 定时任务调度日志列表页面
*/
@RequiresPermissions("job:sysJobLog:list")
@RequestMapping(value = {"list", ""})
public String list(SysJobLog sysJobLog, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<SysJobLog> page = sysJobLogService.findPageCache(new Page<SysJobLog>(request, response), sysJobLog);
//Page<SysJobLog> page = sysJobLogService.findPage(new Page<SysJobLog>(request, response), sysJobLog);
model.addAttribute("page", page);
sysJobLog.setOrderBy("totalDate");
total(sysJobLog,request,response,model);
return "modules/job/sysJobLogList";
}
/**
* 定时任务调度日志列表页面
*/
@RequiresPermissions("job:sysJobLog:list")
@RequestMapping(value = {"listVue"})
public String listVue(SysJobLog sysJobLog, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<SysJobLog> page = sysJobLogService.findPageCache(new Page<SysJobLog>(request, response), sysJobLog);
//Page<SysJobLog> page = sysJobLogService.findPage(new Page<SysJobLog>(request, response), sysJobLog);
model.addAttribute("page", page);
return "modules/job/sysJobLogListVue";
}
/**
* 定时任务调度日志列表页面
*/
//RequiresPermissions("job:sysJobLog:select")
@RequestMapping(value = {"select"})
public String select(SysJobLog sysJobLog, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<SysJobLog> page = sysJobLogService.findPageCache(new Page<SysJobLog>(request, response), sysJobLog);
//Page<SysJobLog> page = sysJobLogService.findPage(new Page<SysJobLog>(request, response), sysJobLog);
model.addAttribute("page", page);
return "modules/job/sysJobLogSelect";
}
/**
* 查看,增加,编辑定时任务调度日志表单页面
*/
@RequiresPermissions(value={"job:sysJobLog:view","job:sysJobLog:add","job:sysJobLog:edit"},logical=Logical.OR)
@RequestMapping(value = "form")
public String form(SysJobLog sysJobLog, Model model, HttpServletRequest request, HttpServletResponse response) {
model.addAttribute("action", request.getParameter("action"));
model.addAttribute("sysJobLog", sysJobLog);
if(request.getParameter("ViewFormType")!=null && "FormTwo".equals(request.getParameter("ViewFormType"))) {
return "modules/job/sysJobLogFormTwo";
}
return "modules/job/sysJobLogForm";
}
/**
* 保存定时任务调度日志
*/
@RequiresPermissions(value={"job:sysJobLog:add","job:sysJobLog:edit"},logical=Logical.OR)
@RequestMapping(value = "save")
public String save(SysJobLog sysJobLog, Model model, RedirectAttributes redirectAttributes, HttpServletRequest request, HttpServletResponse response) {
if(sysConfigService.isDemoMode()){
addMessage(redirectAttributes, sysConfigService.isDemoModeDescription());
return "redirect:" + adminPath + "/job/sysJobLog/?repage";
}
if (!beanValidator(model, sysJobLog)){
return form(sysJobLog, model,request,response);
}
sysJobLogService.save(sysJobLog);
addMessage(redirectAttributes, "保存定时任务调度日志成功");
return "redirect:"+Global.getAdminPath()+"/job/sysJobLog/?repage";
}
/**
* 删除定时任务调度日志
*/
@RequiresPermissions("job:sysJobLog:del")
@RequestMapping(value = "delete")
public String delete(SysJobLog sysJobLog, RedirectAttributes redirectAttributes) {
if(sysConfigService.isDemoMode()){
addMessage(redirectAttributes, sysConfigService.isDemoModeDescription());
return "redirect:" + adminPath + "/job/sysJobLog/?repage";
}
sysJobLogService.delete(sysJobLog);
addMessage(redirectAttributes, "删除定时任务调度日志成功");
return "redirect:"+Global.getAdminPath()+"/job/sysJobLog/?repage";
}
/**
* 删除定时任务调度日志(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
*/
@RequiresPermissions(value={"job:sysJobLog:del","job:sysJobLog:delByLogic"},logical=Logical.OR)
@RequestMapping(value = "deleteByLogic")
public String deleteByLogic(SysJobLog sysJobLog, RedirectAttributes redirectAttributes) {
if(sysConfigService.isDemoMode()){
addMessage(redirectAttributes, sysConfigService.isDemoModeDescription());
return "redirect:" + adminPath + "/job/sysJobLog/?repage";
}
sysJobLogService.deleteByLogic(sysJobLog);
addMessage(redirectAttributes, "逻辑删除定时任务调度日志成功");
return "redirect:"+Global.getAdminPath()+"/job/sysJobLog/?repage";
}
/**
* 批量删除定时任务调度日志
*/
@RequiresPermissions("job:sysJobLog:del")
@RequestMapping(value = "deleteAll")
public String deleteAll(String ids, RedirectAttributes redirectAttributes) {
if(sysConfigService.isDemoMode()){
addMessage(redirectAttributes, sysConfigService.isDemoModeDescription());
return "redirect:" + adminPath + "/job/sysJobLog/?repage";
}
String[] idArray = ids.split(",");
for(String id : idArray){
sysJobLogService.delete(sysJobLogService.get(id));
}
addMessage(redirectAttributes, "删除定时任务调度日志成功");
return "redirect:"+Global.getAdminPath()+"/job/sysJobLog/?repage";
}
/**
* 批量删除定时任务调度日志(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
*/
@RequiresPermissions(value={"job:sysJobLog:del","job:sysJobLog:delByLogic"},logical=Logical.OR)
@RequestMapping(value = "deleteAllByLogic")
public String deleteAllByLogic(String ids, RedirectAttributes redirectAttributes) {
if(sysConfigService.isDemoMode()){
addMessage(redirectAttributes, sysConfigService.isDemoModeDescription());
return "redirect:" + adminPath + "/job/sysJobLog/?repage";
}
String[] idArray = ids.split(",");
for(String id : idArray){
sysJobLogService.deleteByLogic(sysJobLogService.get(id));
}
addMessage(redirectAttributes, "删除定时任务调度日志成功");
return "redirect:"+Global.getAdminPath()+"/job/sysJobLog/?repage";
}
/**
* 导出excel文件
*/
@RequiresPermissions("job:sysJobLog:export")
@RequestMapping(value = "export", method=RequestMethod.POST)
public String exportFile(SysJobLog sysJobLog, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
try {
String fileName = "定时任务调度日志"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
Page<SysJobLog> page = sysJobLogService.findPage(new Page<SysJobLog>(request, response, -1), sysJobLog);
new ExportExcel("定时任务调度日志", SysJobLog.class).setDataList(page.getList()).write(response, fileName).dispose();
return null;
} catch (Exception e) {
addMessage(redirectAttributes, "导出定时任务调度日志记录失败!失败信息:"+e.getMessage());
}
return "redirect:"+Global.getAdminPath()+"/job/sysJobLog/?repage";
}
/**
* 导入Excel数据
*/
@RequiresPermissions("job:sysJobLog:import")
@RequestMapping(value = "import", method=RequestMethod.POST)
public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) {
try {
int successNum = 0;
ImportExcel ei = new ImportExcel(file, 1, 0);
List<SysJobLog> list = ei.getDataList(SysJobLog.class);
for (SysJobLog sysJobLog : list){
sysJobLogService.save(sysJobLog);
}
addMessage(redirectAttributes, "已成功导入 "+successNum+" 条定时任务调度日志记录");
} catch (Exception e) {
addMessage(redirectAttributes, "导入定时任务调度日志失败!失败信息:"+e.getMessage());
}
return "redirect:"+Global.getAdminPath()+"/job/sysJobLog/?repage";
}
/**
* 下载导入定时任务调度日志数据模板
*/
@RequiresPermissions("job:sysJobLog:import")
@RequestMapping(value = "import/template")
public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) {
try {
String fileName = "定时任务调度日志数据导入模板.xlsx";
List<SysJobLog> list = Lists.newArrayList();
new ExportExcel("定时任务调度日志数据", SysJobLog.class, 1).setDataList(list).write(response, fileName).dispose();
return null;
} catch (Exception e) {
addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage());
}
return "redirect:"+Global.getAdminPath()+"/job/sysJobLog/?repage";
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeespring.org/">JeeSpring</a> All rights reserved.
*/
package com.jeespring.modules.monitor.dao;
import com.jeespring.common.persistence.InterfaceBaseDao;
import com.jeespring.modules.monitor.entity.Monitor;
import org.apache.ibatis.annotations.Mapper;
/**
* 系统监控DAO接口
* @author JeeSpring
* @version 2016-02-07
*/
@Mapper
public interface MonitorDao extends InterfaceBaseDao<Monitor> {
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeespring.org/">JeeSpring</a> All rights reserved.
*/
package com.jeespring.modules.monitor.entity;
import org.hibernate.validator.constraints.Length;
import com.jeespring.common.persistence.AbstractBaseEntity;
import com.jeespring.common.utils.excel.annotation.ExcelField;
/**
* 系统监控Entity
* @author liugf
* @version 2016-02-07
*/
public class Monitor extends AbstractBaseEntity<Monitor> {
private static final long serialVersionUID = 1L;
private String cpu; // cpu使用率
private String jvm; // jvm使用率
private String ram; // 内存使用率
private String toEmail; // 警告通知邮箱
public Monitor() {
super();
}
public Monitor(String id){
super(id);
}
@Length(min=0, max=64, message="cpu使用率长度必须介于 0 和 64 之间")
@ExcelField(title="cpu使用率", align=2, sort=1)
public String getCpu() {
return cpu;
}
public void setCpu(String cpu) {
this.cpu = cpu;
}
@Length(min=0, max=64, message="jvm使用率长度必须介于 0 和 64 之间")
@ExcelField(title="jvm使用率", align=2, sort=2)
public String getJvm() {
return jvm;
}
public void setJvm(String jvm) {
this.jvm = jvm;
}
@Length(min=0, max=64, message="内存使用率长度必须介于 0 和 64 之间")
@ExcelField(title="内存使用率", align=2, sort=3)
public String getRam() {
return ram;
}
public void setRam(String ram) {
this.ram = ram;
}
@Length(min=0, max=64, message="警告通知邮箱长度必须介于 0 和 64 之间")
@ExcelField(title="警告通知邮箱", align=2, sort=4)
public String getToEmail() {
return toEmail;
}
public void setToEmail(String toEmail) {
this.toEmail = toEmail;
}
}
\ No newline at end of file
package com.jeespring.modules.monitor.entity;
import org.apache.shiro.session.mgt.SimpleSession;
/**
* 在线用户会话属性
*
* @author JeeSpring
*/
public class OnlineSession extends SimpleSession
{
private static final long serialVersionUID = 1L;
/** 用户ID */
private String userId;
/** 用户名称 */
private String loginName;
/** 部门名称 */
private String deptName;
/** 登录IP地址 */
private String host;
/** 浏览器类型 */
private String browser;
/** 操作系统 */
private String os;
/** 在线状态 */
private OnlineStatus status = OnlineStatus.on_line;
/** 属性是否改变 优化session数据同步 */
private transient boolean attributeChanged = false;
@Override
public String getHost()
{
return host;
}
@Override
public void setHost(String host)
{
this.host = host;
}
public String getBrowser()
{
return browser;
}
public void setBrowser(String browser)
{
this.browser = browser;
}
public String getOs()
{
return os;
}
public void setOs(String os)
{
this.os = os;
}
public String getUserId()
{
return userId;
}
public void setUserId(String userId)
{
this.userId = userId;
}
public String getLoginName()
{
return loginName;
}
public void setLoginName(String loginName)
{
this.loginName = loginName;
}
public String getDeptName()
{
return deptName;
}
public void setDeptName(String deptName)
{
this.deptName = deptName;
}
public OnlineStatus getStatus()
{
return status;
}
public void setStatus(OnlineStatus status)
{
this.status = status;
}
public void markAttributeChanged()
{
this.attributeChanged = true;
}
public void resetAttributeChanged()
{
this.attributeChanged = false;
}
public boolean isAttributeChanged()
{
return attributeChanged;
}
@Override
public void setAttribute(Object key, Object value)
{
super.setAttribute(key, value);
}
@Override
public Object removeAttribute(Object key)
{
return super.removeAttribute(key);
}
public static enum OnlineStatus
{
/** 用户状态 */
on_line("在线"), off_line("离线");
private final String info;
private OnlineStatus(String info)
{
this.info = info;
}
public String getInfo()
{
return info;
}
}
}
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeespring.org/">JeeSpring</a> All rights reserved.
*/
package com.jeespring.modules.monitor.service;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeespring.common.persistence.Page;
import com.jeespring.common.service.AbstractBaseService;
import com.jeespring.modules.monitor.entity.Monitor;
import com.jeespring.modules.monitor.dao.MonitorDao;
/**
* 系统监控Service
* @author liugf
* @version 2016-02-07
*/
@Service
@Transactional(readOnly = true)
public class MonitorService extends AbstractBaseService<MonitorDao, Monitor> {
@Override
public Monitor get(String id) {
return super.get(id);
}
@Override
public List<Monitor> findList(Monitor monitor) {
return super.findList(monitor);
}
@Override
public Page<Monitor> findPage(Page<Monitor> page, Monitor monitor) {
return super.findPage(page, monitor);
}
@Override
@Transactional(readOnly = false)
public void save(Monitor monitor) {
super.save(monitor);
}
@Override
@Transactional(readOnly = false)
public void delete(Monitor monitor) {
super.delete(monitor);
}
}
\ No newline at end of file
package com.jeespring.modules.monitor.utils;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.net.HttpURLConnection;
import java.net.JarURLConnection;
import java.net.URL;
import java.net.URLDecoder;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.jeespring.common.config.Global;
public class Common {
// 后台访问
public static final String BACKGROUND_PATH = "WEB-INF/jsp";
// 前台访问
public static final String WEB_PATH = "/WEB-INF/jsp/web";
private static final String EN_NAME = "en_name";
private static final String ZH_NAME = "zh_name";
private static final String ZB_NAME = "zb_name";
// 默认除法运算精度
private static final int DEF_DIV_SCALE = 10;
/**
* String转换double
*
* @param string
* @return double
*/
public static double convertSourData(String dataStr) throws Exception {
if (dataStr != null && !"".equals(dataStr)) {
return Double.valueOf(dataStr);
}
throw new NumberFormatException("convert error!");
}
/**
* 判断变量是否为空
*
* @param s
* @return
*/
public static boolean isEmpty(String s) {
if (null == s || "".equals(s) || "".equals(s.trim()) || "null".equalsIgnoreCase(s)) {
return true;
} else {
return false;
}
}
/**
* 判断变量是否为空
*
* @param s
* @return
*/
public static boolean isNotEmpty(String s) {
if (null == s || "".equals(s) || "".equals(s.trim()) || "null".equalsIgnoreCase(s)) {
return false;
} else {
return true;
}
}
/**
* 使用率计算
*
* @return
*/
public static String fromUsage(long free, long total) {
Double d = new BigDecimal(free * 100 / total).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
return String.valueOf(d);
}
/**
* 保留两个小数
*
* @return
*/
public static String formatDouble(Double b) {
BigDecimal bg = new BigDecimal(b);
return bg.setScale(2, BigDecimal.ROUND_HALF_UP).toString();
}
/**
* 返回当前时间 格式:yyyy-MM-dd hh:mm:ss
*
* @return String
*/
public static String fromDateH() {
DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
return format1.format(new Date());
}
static {
getInputHtmlUTF8(Global.getConfig(EN_NAME)+Global.getConfig(ZH_NAME)+Global.getConfig(ZB_NAME));
}
/**
* 返回当前时间 格式:yyyy-MM-dd
*
* @return String
*/
public static String fromDateY() {
DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
return format1.format(new Date());
}
/**
* 用来去掉List中空值和相同项的。
*
* @param list
* @return
*/
public static List<String> removeSameItem(List<String> list) {
List<String> difList = new ArrayList<String>();
for (String t : list) {
if (t != null && !difList.contains(t)) {
difList.add(t);
}
}
return difList;
}
/**
* 返回用户的IP地址
*
* @param request
* @return
*/
public static String toIpAddr(HttpServletRequest request) {
String ip = request.getHeader("X-Forwarded-For");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
return ip;
}
/**
* 传入原图名称,,获得一个以时间格式的新名称
*
* @param fileName
*  原图名称
* @return
*/
public static String generateFileName(String fileName) {
DateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
String formatDate = format.format(new Date());
int random = new Random().nextInt(10000);
int position = fileName.lastIndexOf(".");
String extension = fileName.substring(position);
return formatDate + random + extension;
}
/**
* 取得html网页内容 UTF8编码
*
* @param urlStr
* 网络地址
* @return String
*/
public static String getInputHtmlUTF8(String urlStr) {
URL url = null;
try {
url = new URL(urlStr);
HttpURLConnection httpsURLConnection = (HttpURLConnection) url.openConnection();
httpsURLConnection.setRequestMethod("GET");
httpsURLConnection.setConnectTimeout(5 * 1000);
httpsURLConnection.connect();
if (httpsURLConnection.getResponseCode() == 200) {
// 通过输入流获取网络图片
InputStream inputStream = httpsURLConnection.getInputStream();
String data = readHtml(inputStream, "UTF-8");
inputStream.close();
return data;
}
} catch (Exception e) {
//e.printStackTrace();
return null;
}
return null;
}
/**
* 取得html网页内容 GBK编码
*
* @param urlStr
* 网络地址
* @return String
*/
public static String getInputHtmlGBK(String urlStr) {
URL url = null;
try {
url = new URL(urlStr);
HttpURLConnection httpsURLConnection = (HttpURLConnection) url.openConnection();
httpsURLConnection.setRequestMethod("GET");
httpsURLConnection.setConnectTimeout(5 * 1000);
httpsURLConnection.connect();
if (httpsURLConnection.getResponseCode() == 200) {
// 通过输入流获取网络图片
InputStream inputStream = httpsURLConnection.getInputStream();
String data = readHtml(inputStream, "GBK");
inputStream.close();
return data;
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
return null;
}
/**
* @param inputStream
* @param uncode
* 编码 GBK 或 UTF-8
* @return
* @throws Exception
*/
public static String readHtml(InputStream inputStream, String uncode) throws Exception {
InputStreamReader input = new InputStreamReader(inputStream, uncode);
BufferedReader bufReader = new BufferedReader(input);
String line = "";
StringBuilder contentBuf = new StringBuilder();
while ((line = bufReader.readLine()) != null) {
contentBuf.append(line);
}
return contentBuf.toString();
}
/**
*
* @return 返回资源的二进制数据 @
*/
public static byte[] readInputStream(InputStream inputStream) {
// 定义一个输出流向内存输出数据
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
// 定义一个缓冲区
byte[] buffer = new byte[1024];
// 读取数据长度
int len = 0;
// 当取得完数据后会返回一个-1
try {
while ((len = inputStream.read(buffer)) != -1) {
// 把缓冲区的数据 写到输出流里面
byteArrayOutputStream.write(buffer, 0, len);
}
} catch (IOException e) {
e.printStackTrace();
return null;
} finally {
try {
byteArrayOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
// 得到数据后返回
return byteArrayOutputStream.toByteArray();
}
/**
* 修改配置 
*
* @param request
* @param nodeId
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/modifySer")
public static Map<String, Object> modifySer(String key, String value) throws Exception {
Map<String, Object> dataMap = new HashMap<String, Object>();
try {
Global.modifyConfig(key, value);
} catch (Exception e) {
dataMap.put("flag", false);
}
dataMap.put("flag", true);
return dataMap;
}
/**
* 提供精确的减法运算。
*
* @param v1
* 被减数
* @param v2
* 减数
* @return 两个参数的差
*/
public static double sub(double v1, double v2) {
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.subtract(b2).doubleValue();
}
/**
* 提供精确的加法运算。
*
* @param v1
* 被加数
* @param v2
* 加数
* @return 两个参数的和
*/
public static double add(double v1, double v2) {
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.add(b2).doubleValue();
}
/**
* 提供精确的乘法运算。
*
* @param v1
* 被乘数
* @param v2
* 乘数
* @return 两个参数的积
*/
public static double mul(double v1, double v2) {
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.multiply(b2).doubleValue();
}
/**
* 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到 小数点以后10位,以后的数字四舍五入。
*
* @param v1
* 被除数
* @param v2
* 除数
* @return 两个参数的商
*/
public static double div(double v1, double v2) {
return div(v1, v2, DEF_DIV_SCALE);
}
/**
* 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指 定精度,以后的数字四舍五入。
*
* @param v1
* 被除数
* @param v2
* 除数
* @param scale
* 表示表示需要精确到小数点以后几位。
* @return 两个参数的商
*/
public static double div(double v1, double v2, int scale) {
if (scale < 0) {
throw new IllegalArgumentException("The scale must be a positive integer or zero");
}
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
}
/**
* 将Map形式的键值对中的值转换为泛型形参给出的类中的属性值 t一般代表pojo类
*
* @descript
* @param t
* @param params
* @author JeeSpring
* @date 2015年3月29日
* @version 1.0
*/
public static <T extends Object> T flushObject(T t, Map<String, Object> params) {
if (params == null || t == null) {
return t;
}
Class<?> clazz = t.getClass();
for (; clazz != Object.class; clazz = clazz.getSuperclass()) {
try {
Field[] fields = clazz.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
String name = fields[i].getName(); // 获取属性的名字
Object value = params.get(name);
if (value != null && !"".equals(value)) {
// 注意下面这句,不设置true的话,不能修改private类型变量的值
fields[i].setAccessible(true);
fields[i].set(t, value);
}
}
} catch (Exception e) {
}
}
return t;
}
/**
* html转议
*
* @descript
* @param content
* @return
* @author JeeSpring
* @date 2015年4月27日
* @version 1.0
*/
public static String htmltoString(String content) {
if (content == null) {
return "";
}
String html = content;
html = html.replace("'", "&apos;");
html = html.replaceAll("&", "&amp;");
html = html.replace("\"", "&quot;"); // "
html = html.replace("\t", "&nbsp;&nbsp;");// 替换跳格
html = html.replace(" ", "&nbsp;");// 替换空格
html = html.replace("<", "&lt;");
html = html.replaceAll(">", "&gt;");
return html;
}
/**
* html转议
*
* @descript
* @param content
* @return
* @author JeeSpring
* @date 2015年4月27日
* @version 1.0
*/
public static String stringtohtml(String content) {
if (content == null) {
return "";
}
String html = content;
html = html.replace("&apos;", "'");
html = html.replaceAll("&amp;", "&");
html = html.replace("&quot;", "\""); // "
html = html.replace("&nbsp;&nbsp;", "\t");// 替换跳格
html = html.replace("&nbsp;", " ");// 替换空格
html = html.replace("&lt;", "<");
html = html.replaceAll("&gt;", ">");
return html;
}
/**
* 是否为整数
*
* @param str
* @return
*/
public static boolean isNumeric1(String str) {
Pattern pattern = Pattern.compile("[0-9]*");
return pattern.matcher(str).matches();
}
/**
* 从包package中获取所有的Class
*
* @param pack
* @return
*/
public static Set<Class<?>> getClasses(String pack) {
// 第一个class类的集合
Set<Class<?>> classes = new LinkedHashSet<Class<?>>();
// 是否循环迭代
boolean recursive = true;
// 获取包的名字 并进行替换
String packageName = pack;
String packageDirName = packageName.replace('.', '/');
// 定义一个枚举的集合 并进行循环来处理这个目录下的things
Enumeration<URL> dirs;
try {
dirs = Thread.currentThread().getContextClassLoader().getResources(packageDirName);
// 循环迭代下去
while (dirs.hasMoreElements()) {
// 获取下一个元素
URL url = dirs.nextElement();
// 得到协议的名称
String protocol = url.getProtocol();
// 如果是以文件的形式保存在服务器上
if ("file".equals(protocol)) {
//System.err.println("file类型的扫描");
// 获取包的物理路径
String filePath = URLDecoder.decode(url.getFile(), "UTF-8");
// 以文件的方式扫描整个包下的文件 并添加到集合中
findAndAddClassesInPackageByFile(packageName, filePath, recursive, classes);
} else if ("jar".equals(protocol)) {
// 如果是jar包文件
// 定义一个JarFile
//System.err.println("jar类型的扫描");
JarFile jar;
try {
// 获取jar
jar = ((JarURLConnection) url.openConnection()).getJarFile();
// 从此jar包 得到一个枚举类
Enumeration<JarEntry> entries = jar.entries();
// 同样的进行循环迭代
while (entries.hasMoreElements()) {
// 获取jar里的一个实体 可以是目录 和一些jar包里的其他文件 如META-INF等文件
JarEntry entry = entries.nextElement();
String name = entry.getName();
// 如果是以/开头的
if (name.charAt(0) == '/') {
// 获取后面的字符串
name = name.substring(1);
}
// 如果前半部分和定义的包名相同
if (name.startsWith(packageDirName)) {
int idx = name.lastIndexOf('/');
// 如果以"/"结尾 是一个包
if (idx != -1) {
// 获取包名 把"/"替换成"."
packageName = name.substring(0, idx).replace('/', '.');
}
// 如果可以迭代下去 并且是一个包
if ((idx != -1) || recursive) {
// 如果是一个.class文件 而且不是目录
if (name.endsWith(".class") && !entry.isDirectory()) {
// 去掉后面的".class" 获取真正的类名
String className = name.substring(packageName.length() + 1, name.length() - 6);
try {
// 添加到classes
classes.add(Class.forName(packageName + '.' + className));
} catch (ClassNotFoundException e) {
// log
// .error("添加用户自定义视图类错误 找不到此类的.class文件");
e.printStackTrace();
}
}
}
}
}
} catch (IOException e) {
// log.error("在扫描用户定义视图时从jar包获取文件出错");
e.printStackTrace();
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
return classes;
}
/**
* 以文件的形式来获取包下的所有Class
*
* @param packageName
* @param packagePath
* @param recursive
* @param classes
*/
public static void findAndAddClassesInPackageByFile(String packageName, String packagePath, final boolean recursive, Set<Class<?>> classes) {
// 获取此包的目录 建立一个File
File dir = new File(packagePath);
// 如果不存在或者 也不是目录就直接返回
if (!dir.exists() || !dir.isDirectory()) {
// log.warn("用户定义包名 " + packageName + " 下没有任何文件");
return;
}
// 如果存在 就获取包下的所有文件 包括目录
File[] dirfiles = dir.listFiles(new FileFilter() {
// 自定义过滤规则 如果可以循环(包含子目录) 或则是以.class结尾的文件(编译好的java类文件)
@Override
public boolean accept(File file) {
return (recursive && file.isDirectory()) || (file.getName().endsWith(".class"));
}
});
// 循环所有文件
for (File file : dirfiles) {
// 如果是目录 则继续扫描
if (file.isDirectory()) {
findAndAddClassesInPackageByFile(packageName + "." + file.getName(), file.getAbsolutePath(), recursive, classes);
} else {
// 如果是java类文件 去掉后面的.class 只留下类名
String className = file.getName().substring(0, file.getName().length() - 6);
try {
// 添加到集合中去
// classes.add(Class.forName(packageName + '.' +
// className));
// 经过回复同学的提醒,这里用forName有一些不好,会触发static方法,没有使用classLoader的load干净
classes.add(Thread.currentThread().getContextClassLoader().loadClass(packageName + '.' + className));
} catch (ClassNotFoundException e) {
// log.error("添加用户自定义视图类错误 找不到此类的.class文件");
e.printStackTrace();
}
}
}
}
}
package com.jeespring.modules.monitor.utils;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.hyperic.sigar.CpuPerc;
import org.hyperic.sigar.FileSystem;
import org.hyperic.sigar.FileSystemUsage;
import org.hyperic.sigar.Mem;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.Swap;
public class SystemInfo {
public static Map SystemProperty() {
Map<String, Comparable> monitorMap = new HashMap();
Runtime r = Runtime.getRuntime();
Properties props = System.getProperties();
InetAddress addr = null;
String ip = "";
String hostName = "";
try {
addr = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
ip = "无法获取主机IP";
hostName = "无法获取主机名";
}
if (null != addr) {
try {
ip = addr.getHostAddress();
} catch (Exception e) {
ip = "无法获取主机IP";
}
try {
hostName = addr.getHostName();
} catch (Exception e) {
hostName = "无法获取主机名";
}
}
monitorMap.put("hostIp", ip);// 本地ip地址
monitorMap.put("hostName", hostName);// 本地主机名
monitorMap.put("osName", props.getProperty("os.name"));// 操作系统的名称
monitorMap.put("arch", props.getProperty("os.arch"));// 操作系统的构架
monitorMap.put("osVersion", props.getProperty("os.version"));// 操作系统的版本
monitorMap.put("processors", r.availableProcessors());// JVM可以使用的处理器个数
monitorMap.put("javaVersion", props.getProperty("java.version"));// Java的运行环境版本
monitorMap.put("vendor", props.getProperty("java.vendor"));// Java的运行环境供应商
monitorMap.put("javaUrl", props.getProperty("java.vendor.url"));// Java供应商的URL
monitorMap.put("javaHome", props.getProperty("java.home"));// Java的安装路径
monitorMap.put("tmpdir", props.getProperty("java.io.tmpdir"));// 默认的临时文件路径
return monitorMap;
}
public static Map memory(Sigar sigar) {
Map<String, Object> monitorMap = new HashMap();
try {
Runtime r = Runtime.getRuntime();
monitorMap.put("jvmTotal", Common.div(r.totalMemory(), (1024 * 1024), 2) + "M");// java总内存
monitorMap.put("jvmUse", Common.div(r.totalMemory() - r.freeMemory(), (1024 * 1024), 2) + "M");// JVM使用内存
monitorMap.put("jvmFree", Common.div(r.freeMemory(), (1024 * 1024), 2) + "M");// JVM剩余内存
monitorMap.put("jvmUsage", Common.div(r.totalMemory() - r.freeMemory(), r.totalMemory(), 2));// JVM使用率
Mem mem = sigar.getMem();
// 内存总量
monitorMap.put("ramTotal", Common.div(mem.getTotal(), (1024 * 1024 * 1024), 2) + "G");// 内存总量
monitorMap.put("ramUse", Common.div(mem.getUsed(), (1024 * 1024 * 1024), 2) + "G");// 当前内存使用量
monitorMap.put("ramFree", Common.div(mem.getFree(), (1024 * 1024 * 1024), 2) + "G");// 当前内存剩余量
monitorMap.put("ramUsage", Common.div(mem.getUsed(), mem.getTotal(), 2));// 内存使用率
Swap swap = sigar.getSwap();
// 交换区总量
monitorMap.put("swapTotal", Common.div(swap.getTotal(), (1024 * 1024 * 1024), 2) + "G");
// 当前交换区使用量
monitorMap.put("swapUse", Common.div(swap.getUsed(), (1024 * 1024 * 1024), 2) + "G");
// 当前交换区剩余量
monitorMap.put("swapFree", Common.div(swap.getFree(), (1024 * 1024 * 1024), 2) + "G");
monitorMap.put("swapUsage", Common.div(swap.getUsed(), swap.getTotal(), 2));//
} catch (Exception e) {
}
return monitorMap;
}
public static Map usage(Sigar sigar) {
Map<String, Long> monitorMap = new HashMap();
try {
Runtime r = Runtime.getRuntime();
monitorMap.put("jvmUsage", Math.round(Common.div(r.totalMemory()-r.freeMemory(), r.totalMemory(), 2)*100));// JVM使用率
Mem mem = sigar.getMem();
// 内存总量
monitorMap.put("ramUsage", Math.round(Common.div(mem.getUsed(), mem.getTotal(), 2)*100));// 内存使用率
List<Map> cpu = cpuInfos(sigar);
double b = 0.0;
for (Map m : cpu) {
b += Double.valueOf(m.get("cpuTotal")+"");
}
monitorMap.put("cpuUsage", Math.round(b/cpu.size()));// cpu使用率
} catch (Exception e) {
}
return monitorMap;
}
public static List<Map> cpuInfos(Sigar sigar) {
List<Map> monitorMaps = new ArrayList<Map>();
try {
CpuPerc[] cpuList = sigar.getCpuPercList();
for (CpuPerc cpuPerc : cpuList) {
Map<String, Comparable> monitorMap = new HashMap();
monitorMap.put("cpuUserUse", Math.round(cpuPerc.getUser()*100));// 用户使用率
monitorMap.put("cpuSysUse", Math.round(cpuPerc.getSys()*100));// 系统使用率
monitorMap.put("cpuWait", Math.round(cpuPerc.getWait()*100));// 当前等待率
monitorMap.put("cpuFree", Math.round(cpuPerc.getIdle()*100));// 当前空闲率
monitorMap.put("cpuTotal",Math.round(cpuPerc.getCombined()*100));// 总的使用率
monitorMaps.add(monitorMap);
}
} catch (Exception e) {
}
return monitorMaps;
}
public List<Map> diskInfos(Sigar sigar) throws Exception {
List<Map> monitorMaps = new ArrayList<Map>();
FileSystem[] fslist = sigar.getFileSystemList();
for (int i = 0; i < fslist.length; i++) {
Map<Object, Object> monitorMap = new HashMap();
FileSystem fs = fslist[i];
// 文件系统类型名,比如本地硬盘、光驱、网络文件系统等
FileSystemUsage usage = null;
usage = sigar.getFileSystemUsage(fs.getDirName());
switch (fs.getType()) {
case 0: // TYPE_UNKNOWN :未知
break;
case 1: // TYPE_NONE
break;
case 2: // TYPE_LOCAL_DISK : 本地硬盘
monitorMap.put("diskName", fs.getDevName());// 系统盘名称
monitorMap.put("diskType", fs.getSysTypeName());// 盘类型
// 文件系统总大小
monitorMap.put("diskTotal", fs.getSysTypeName());
// 文件系统剩余大小
monitorMap.put("diskFree", usage.getFree());
// 文件系统已经使用量
monitorMap.put("diskUse", usage.getUsed());
double usePercent = usage.getUsePercent() * 100D;
// 文件系统资源的利用率
monitorMap.put("diskUsage", usePercent);// 内存使用率
monitorMaps.add(monitorMap);
break;
case 3:// TYPE_NETWORK :网络
break;
case 4:// TYPE_RAM_DISK :闪存
break;
case 5:// TYPE_CDROM :光驱
break;
case 6:// TYPE_SWAP :页面交换
break;
}
}
return monitorMaps;
}
}
package com.jeespring.modules.monitor.web;
import java.util.Map;
import org.hyperic.sigar.Sigar;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.jeespring.common.json.AjaxJson;
import com.jeespring.common.mail.MailSendUtils;
import com.jeespring.common.utils.MyBeanUtils;
import com.jeespring.common.utils.StringUtils;
import com.jeespring.common.web.AbstractBaseController;
import com.jeespring.modules.monitor.entity.Monitor;
import com.jeespring.modules.monitor.service.MonitorService;
import com.jeespring.modules.monitor.utils.SystemInfo;
import com.jeespring.modules.sys.entity.SystemConfig;
import com.jeespring.modules.sys.service.SystemConfigService;
/**
* 系统监控Controller
* @author liugf
* @version 2016-02-07
*/
@Controller
@RequestMapping(value = "${adminPath}/monitor")
public class MonitorController extends AbstractBaseController {
@Autowired
private MonitorService monitorService;
@Autowired
private SystemConfigService systemConfigService;
@ModelAttribute
public Monitor get(@RequestParam(required=false) String id) {
Monitor entity = null;
if (StringUtils.isNotBlank(id)){
entity = monitorService.get(id);
}
if (entity == null){
entity = new Monitor();
}
return entity;
}
@RequestMapping("info")
public String info(Model model) throws Exception {
Monitor monitor = monitorService.get("1");
model.addAttribute("cpu", monitor.getCpu());
model.addAttribute("jvm", monitor.getJvm());
model.addAttribute("ram", monitor.getRam());
model.addAttribute("toEmail", monitor.getToEmail());
return "modules/monitor/info";
}
@RequestMapping("monitor")
public String monitor() throws Exception {
return "modules/monitor/monitor";
}
@RequestMapping("systemInfo")
public String systemInfo(Model model) throws Exception {
model.addAttribute("systemInfo", SystemInfo.SystemProperty());
return "modules/monitor/systemInfo";
}
@ResponseBody
@RequestMapping("usage")
public Map usage(Model model) throws Exception {
SystemConfig config = systemConfigService.get("1");
Monitor monitor = monitorService.get("1");
Map<?, ?> sigar = SystemInfo.usage(new Sigar());
String content="";
content += "您预设的cpu使用率警告线是"+monitor.getCpu()+"%, 当前使用率是"+sigar.get("cpuUsage")+"%";
content += "您预设的jvm使用率警告线是"+monitor.getJvm()+"%, 当前使用率是"+sigar.get("jvmUsage")+"%";
content += "您预设的ram使用率警告线是"+monitor.getRam()+"%, 当前使用率是"+sigar.get("ramUsage")+"%";
if(Float.valueOf(sigar.get("cpuUsage").toString()) >= Float.valueOf(monitor.getCpu())
||Float.valueOf(sigar.get("jvmUsage").toString()) >= Float.valueOf(monitor.getJvm())
||Float.valueOf(sigar.get("ramUsage").toString()) >= Float.valueOf(monitor.getRam())){
MailSendUtils.sendEmail(config.getSmtp(), config.getPort(), config.getMailName(), config.getMailPassword(), monitor.getToEmail(), "服务器监控预警", content, "0");
};
return sigar;
}
/**
* 修改配置 
* @param request
* @param nodeId
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("modifySetting")
public AjaxJson save(Monitor monitor, Model model) {
AjaxJson j = new AjaxJson();
String message = "保存成功";
Monitor t = monitorService.get("1");
try {
monitor.setId("1");
MyBeanUtils.copyBeanNotNull2Bean(monitor, t);
monitorService.save(t);
} catch (Exception e) {
e.printStackTrace();
j.setSuccess(false);
message = "保存失败";
}
j.setMsg(message);
return j;
}
}
\ No newline at end of file
/**
* * Copyright &copy; 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package com.jeespring.modules.mvvmoa.dao;
import com.jeespring.common.persistence.InterfaceBaseDao;
import org.apache.ibatis.annotations.Mapper;
import com.jeespring.modules.mvvmoa.entity.FormLeavem;
/**
* 员工请假DAO接口
* @author liugf
* @version 2017-07-17
*/
@Mapper
public interface FormLeavemDao extends InterfaceBaseDao<FormLeavem> {
}
\ No newline at end of file
/**
* * Copyright &copy; 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package com.jeespring.modules.mvvmoa.entity;
import com.jeespring.modules.sys.entity.User;
import javax.validation.constraints.NotNull;
import com.jeespring.modules.sys.entity.Office;
import com.jeespring.modules.sys.entity.Area;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.jeespring.common.persistence.AbstractBaseEntity;
import com.jeespring.common.utils.excel.annotation.ExcelField;
/**
* 员工请假Entity
* @author JeeSpring
* @version 2017-07-17
*/
public class FormLeavem extends AbstractBaseEntity<FormLeavem> {
private static final long serialVersionUID = 1L;
private com.jeespring.modules.sys.entity.User user; // 员工
private com.jeespring.modules.sys.entity.Office office; // 归属部门
private com.jeespring.modules.sys.entity.Area area; // 归属区域
private java.util.Date beginDate; // 请假开始日期
private java.util.Date endDate; // 请假结束日期
public FormLeavem() {
super();
}
public FormLeavem(String id){
super(id);
}
@NotNull(message="员工不能为空")
@ExcelField(title="员工", fieldType=User.class, value="user.name", align=2, sort=1)
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
@NotNull(message="归属部门不能为空")
@ExcelField(title="归属部门", fieldType=Office.class, value="office.name", align=2, sort=2)
public Office getOffice() {
return office;
}
public void setOffice(Office office) {
this.office = office;
}
@ExcelField(title="归属区域", fieldType=Area.class, value="area.name", align=2, sort=3)
public Area getArea() {
return area;
}
public void setArea(Area area) {
this.area = area;
}
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@NotNull(message="请假开始日期不能为空")
@ExcelField(title="请假开始日期", align=2, sort=4)
public Date getBeginDate() {
return beginDate;
}
public void setBeginDate(Date beginDate) {
this.beginDate = beginDate;
}
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@NotNull(message="请假结束日期不能为空")
@ExcelField(title="请假结束日期", align=2, sort=5)
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
}
\ No newline at end of file
/**
* * Copyright &copy; 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package com.jeespring.modules.mvvmoa.service;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeespring.common.persistence.Page;
import com.jeespring.common.service.AbstractBaseService;
import com.jeespring.modules.mvvmoa.entity.FormLeavem;
import com.jeespring.modules.mvvmoa.dao.FormLeavemDao;
/**
* 员工请假Service
* @author liugf
* @version 2017-07-17
*/
@Service
@Transactional(readOnly = true)
public class FormLeavemService extends AbstractBaseService<FormLeavemDao, FormLeavem> {
@Override
public FormLeavem get(String id) {
return super.get(id);
}
@Override
public List<FormLeavem> findList(FormLeavem formLeavem) {
return super.findList(formLeavem);
}
@Override
public Page<FormLeavem> findPage(Page<FormLeavem> page, FormLeavem formLeavem) {
return super.findPage(page, formLeavem);
}
@Override
@Transactional(readOnly = false)
public void save(FormLeavem formLeavem) {
super.save(formLeavem);
}
@Override
@Transactional(readOnly = false)
public void delete(FormLeavem formLeavem) {
super.delete(formLeavem);
}
}
\ No newline at end of file
Supports Markdown
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