zoukankan      html  css  js  c++  java
  • Examlog-大数据日志分析-代码

     jsp:

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ page isELIgnored="false"%>
    <%@ include file="/common.jsp"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
        <title>班级绑定试卷${pageContext.request.contextPath}</title>
        <script type="text/javascript" src="${pageContext.request.contextPath}/script/matchExam.js"></script>
        <script type="text/javascript">
    
            var ctx = '<%=request.getContextPath()%>';
            $(document).ready(function() {
                loadMatchExamInfo(ctx);
            });
        </script>
    </head>
    <body class="easyui-layout layout panel-noscroll easyui-fluid" >
        <input type="hidden" id="page" value="1"value="${page}">
        <input type="hidden" id="rows"value="10" value="${rows}">
    
    
        <%--精确查询--%>
    
        <div class="easyui-panel" style="padding: 20px;  100%;">
            班级:
            <select id="" class="easyui-combobox"  name="className" style="200px;">
                <option value="0">--选择班级--</option>
                <option value="大学英语">大学英语</option>
                <option value="大学数学">大学数学</option>
            </select>
            课程:
            <select id="" class="easyui-combobox"  name="courseName" style="200px;">
                <option value="0">--选择课程--</option>
                <option value="1">大学</option>
                <option value="2">大学数学</option>
            </select>
        </div>
    
        <%--表格--%>
        <div class="easyui-layout" style=" 1243px" style="overflow: hidden ">
           <table id="dtMatchExam" class="easyui-datagrid" toolbar="#toolbar" title="选择试卷" style="743px;height:390px;" data-options="
                    rownumbers:true,
                    autoRowHeight:false,
                    pagination:true,
                    pageSize:10">
           </table>
    
        </div>
    
        <!-- 表格的工具栏-- -->
        <div id="toolbar" width="50">
            <a href="javascript:void(0)" class="easyui-linkbutton"
               iconCls="icon-add" plain="true" onclick="addMatchExamInfoDialog()">添加</a> <a
                href="javascript:void(0)" class="easyui-linkbutton"
                iconCls="icon-remove" plain="true" onclick="deleteMatchExamInfo()">删除</a>
        </div>
    
        <%--弹出框--%>
        <div id="dd" class="easyui-dialog" title="添加试卷信息" style="400px;height:200px;"
             data-options="iconCls:'icon-add',resizable:true,modal:true,closed:true">
    
            <form action="" method="post" id="form">
                    <div>试卷名称:
                        <select id="examPaperName" class="easyui-combobox"  name="examPaperName" style="200px;">
                            <%--<option value="aa"></option>
                           <option>bitem2</option>
                           <option>bitem3</option>
                           <option>ditem4</option>--%>
                            <option value="大学英语">大学英语</option>
                            <option value="大学数学">大学数学</option>
                        </select>
                    </div>
    
                    <div>试卷总分: <input id="totalScore" name="totalScore" class="easyui-validatebox" data-options="required:true,validType:'email'"></div>
                    <div> 期望分值: <input id="expectScore" name="expectScore" class="easyui-validatebox" data-options="required:true,validType:'email'"></div>
                    <div> 发试卷张数: <input id="totalExam" name="totalExam" class="easyui-validatebox" data-options="required:true,validType:'email'"></div>
    
                    <div>是否为抢分卷:
                        <select id="type" class="easyui-combobox"  name="type" style="200px;">
                            <option value="0">是</option>
                            <option value="1">否</option>
                        </select>
                    </div>
                    <div>
                        <a class="easyui-linkbutton" onclick="AddMatchExamInfo()" style="80px">确定</a>
                        <a href="#" class="easyui-linkbutton" onclick="" style="80px">取消</a>
                    </div>
    
            </form>
    
    
        </div>
    
    </body>
    
    
    
    </html>

    js:

    var ctx;
    function loadMatchExamInfo(ctx){
        //清空表格数据
        $("#dtMatchExam").datagrid("loadData",{
            total:0,
            rows  :[]
        });
    
    //加载数据
        var page;
        var rows;
        $('#dtMatchExam').datagrid({
            rownumbers:true,
            fit:true,
            fitColumns: true,
            url :ctx+ "/MatchCourse/MatchCourseData",
            data:{"page":page,
                   "rows":rows},
            onLoadSuccess: function (data) {
                if (data.total == 0) {
                    //添加一个新数据行,第一列的值为你需要的提示信息,然后将其他列合并到第一列来,注意修改colspan参数为你columns配置的总列数
                    //$("#dgTeacher").datagrid("deleteRow",0);
                    $("#dtMatchExam").datagrid('appendRow', { userRealName: '<div style="text-align:center;color:red">没有相关记录!</div>' }).datagrid('mergeCells', { index: 0, field: 'userRealName', colspan: 4 })
                }
    
            },
            pageSize:10,
            pageList: [10, 20, 30],
            columns : [ [
               {
                    field: 'id',
                    checkbox:true,
                    '4%'
                },
                {
                    field : 'examPaperName',
                    title : '试卷名称',
                    width : '16%',
                    align : 'center',
                },
                {
                    field : 'expectScore',
                    title : '期望分值',
                    width : '20%',
                    align : 'center'
                },
                {
                    field : 'awardScore',
                    title : '奖励分值',
                    width : '20%',
                    align : 'center'
                },
                {
                    field : 'totalExam',
                    title : '试卷总数',
                    width : '20%',
                    align : 'center'
                },
                {
                    field : 'surplusExam',
                    title : '剩余试卷',
                    width : '20%',
                    align : 'center'
                }
                ] ]
        });
    
    }
    
    
    function  addMatchExamInfoDialog(){
        $('#dd').dialog({
            title: 'My Dialog',
             400,
            height: 200,
            closed: false,
            cache: false,
            modal: true
        });
    
    }
    
    function  AddMatchExamInfo(){
      //$('#form').submit();
       // var totalScore=$('#totalScore').val();
      //  alert(totalScore);
        $.ajax({
            type:"POST",
            url:ctx+ "/MatchCourse/AddMatchExamInfo",
            dataType:"json",
            async : false,
            data : $('#form').serialize(),
            success : function(data) {
                $('#form').form('clear');
                $('#dd').window('close');
                $.messager.alert('提示', '添加成功!');
                $('#dtMatchExam').datagrid('reload');
            },
            error : function(err) {
                $('#dd').window('close');
                $.messager.alert('提示', '添加成功!');
                $('#dtMatchExam').datagrid('reload');
            }
        })
    
    
    }
    
    function  deleteMatchExamInfo(){
        var row = $('#dtMatchExam').datagrid('getSelections'); // 返回选中多行
        if (row.length == 0) {
            $.messager.alert('提示', '请选择要删除的记录!');
            return false;
        }
        var id ="";
        for (var i = 0; i < row.length; i++) {
            id=id + row[i].id + ",";
        }
    
        $.messager.confirm('提示', '确定要删除所选记录吗?删除之后,将不能恢复!', function(r) {
            if (r) {
                $.ajax({
                    type:"POST",
                    dataType:"json",
                    data:{"id":id},
                    url:ctx+"/MatchCourse/DeleteMatchInfos",
                    success:function(){
                        $.messager.alert('提示', '删除成功!');
                        $('#dtMatchExam').datagrid('reload');
                    },
                    error : function(err) {
                        $.messager.alert('提示', '删除成功!');
                        $('#dtMatchExam').datagrid('reload');
                    }
                });
    
            }
        });
    }

    Controller:

    package com.dmsd.itoo.examlog.controller;
    
    import ch.qos.logback.classic.Logger;
    import com.dmsd.itoo.examlog.entity.MatchExam;
    import com.dmsd.itoo.examlog.service.MatchCourseInfoService;
    import com.dmsd.itoo.tool.pageModel.PageEntity;
    import com.dmsd.itoo.tool.tojson.JacksonJsonUntil;
    import org.slf4j.LoggerFactory;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Controller;
    import org.springframework.ui.ModelMap;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.bind.annotation.ResponseBody;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    /**
     * Created by wm on 2016/8/8.
     */
    
    @RequestMapping("/MatchCourse")
    @Controller
    public class MatchCourseInfoController {
    
        //打印日志
        private static Logger logger=(Logger) LoggerFactory.getLogger(CourseController.class);
    
        @Autowired
        MatchCourseInfoService matchCourseInfoService;
    
    
        @RequestMapping(value={"/MatchCourse"})
        public String QueryAllMatchCourseInfo (String conditions,String page,String rows,HttpServletRequest request, HttpServletResponse response,ModelMap Map){
            request.setAttribute("conditions",conditions);
            if(null==page){
               Map.put("page","1");
            }else{
                Map.put("page",page);
            }
    
            if(null==rows){
                Map.put("rows","10");
            }else{
                Map.put("rows",rows);
    
            }
    
            return"MatchCourseInfo";
        }
    
    
        @RequestMapping(value={"/MatchCourseData"})
        public void QueryAllMatchCourseInfoData(HttpServletRequest request, HttpServletResponse response,String page,String rows){
            String conditions=(String)request.getAttribute("conditions");
            JacksonJsonUntil jackJsonUtil =new JacksonJsonUntil ();
            String dataBaseName = "itoo_examlog";
            try {
                // 获取前台easyui分页工具的属性,page为当前页数,rows为每页显示的行数
                int pageNum=(Integer.parseInt(page)>0)?(Integer.parseInt(page)):1;
                int pageSize=(Integer.parseInt(rows)>0)?(Integer.parseInt(rows)):1;
                //构造分页实体
                PageEntity<MatchExam > pageEntity =new PageEntity();
                pageEntity.setPageNum(pageNum);
                pageEntity.setPageSize(pageSize);
                pageEntity.setDataBaseName(dataBaseName);
    
                PageEntity<MatchExam> list =matchCourseInfoService.QueryAllMatchCourseInfo(pageEntity,conditions);
                jackJsonUtil.beanToJson(response,list);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    
    
        @RequestMapping(value = "AddMatchExamInfo",method = RequestMethod.POST,produces = "application/json;charset=UTF-8")
        @ResponseBody
       public void AddMatchExamInfo (HttpServletRequest request, HttpServletResponse response,MatchExam matchExam){
            matchCourseInfoService.SaveMatchInfo(matchExam);
        }
    
    
        @RequestMapping(value = "DeleteMatchInfos",method = RequestMethod.POST,produces = "application/json;charset=UTF-8")
        @ResponseBody
        public void DeleteMatchInfos(HttpServletRequest request,HttpServletResponse response,String id){
    
            id= id.substring(0, id.length()-1);
            String[] ids=id.split(",");
            try{
                matchCourseInfoService.DeleteMatchInfos(ids);
            }catch(Exception e){
                e.printStackTrace();
            }
    
        }
    }

    serviceImpl:

    package com.dmsd.itoo.examlog.service.impl;
    
    import com.dmsd.itoo.examlog.dao.impl.MatchCourseInfoDaoImpl;
    import com.dmsd.itoo.examlog.entity.MatchExam;
    import com.dmsd.itoo.examlog.service.MatchCourseInfoService;
    import com.dmsd.itoo.tool.pageModel.PageEntity;
    import org.springframework.beans.factory.ObjectFactory;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    import org.springframework.transaction.annotation.Transactional;
    
    import java.util.HashMap;
    import java.util.Map;
    import java.util.List;
    /**
     * 班级绑定试卷
     * Created by wm on 2016/8/8.
     */
    @Service("matchCourseInfoServiceImpl")
    @Transactional
    public class MatchCourseInfoServiceImpl implements MatchCourseInfoService {
    
        @Autowired
        MatchCourseInfoDaoImpl matchCourseInfoDaoImpl;
    
        /**
         * 班级绑定试卷,查询数据   2016年8月10日
         * @param pageEntity 分页实体
         * @param conditions 查询条件
         * @return 分页实体
         */
        @Override
        public PageEntity<MatchExam> QueryAllMatchCourseInfo(PageEntity<MatchExam> pageEntity, String conditions) {
            PageEntity<MatchExam> list=new PageEntity<MatchExam>();
            Map<String,String> map=new HashMap();
            map.put("conditions",conditions);
            list=matchCourseInfoDaoImpl.QueryMatchCourseInfo(pageEntity,map);
            return  list;
        }
    
        /**
         * 保存考试信息
         * @param matchExam
         */
        @Override
        public void  SaveMatchInfo(MatchExam matchExam) {
               matchCourseInfoDaoImpl.save(matchExam);
        }
    
        @Override
        public void DeleteMatchInfos(String[] ids) {
            try{
                matchCourseInfoDaoImpl.delete(ids);
            }catch (Exception e){
                throw e;
            }
    
    
        }
    }

    DaoImpl:

    package com.dmsd.itoo.examlog.dao.impl;
    
    import com.dmsd.itoo.base.dao.hibernate.BaseHibernateDaoSupport;
    import com.dmsd.itoo.examlog.entity.MatchExam;
    import com.dmsd.itoo.tool.pageModel.PageEntity;
    import org.springframework.stereotype.Repository;
    import java.util.Map;
    
    @Repository("matchCourseInfoDaoImpl")
    public class MatchCourseInfoDaoImpl extends BaseHibernateDaoSupport<MatchExam> {
    
            /**
             * 查询匹配试卷信息 wm 2016-8-16
             * @param pageEntity
             * @param map
             * @return
             */
            public PageEntity<MatchExam> QueryMatchCourseInfo(PageEntity<MatchExam> pageEntity, Map<String, String> map) {
                //查询全部
                StringBuffer hql = new StringBuffer();
               // hql.append("select  new MatchExam( m.examPaperName,m.expectScore,m.awardScore,m.totalExam ,m.surplusExam) from  MatchExam m where  m.isDelete=0");
                 hql.append("from MatchExam c where c.isDelete=0");
                pageEntity.setHql(hql.toString());
                PageEntity<MatchExam> listMatchExam= this.queryPageEntityByHql(pageEntity);
                return  listMatchExam;
            }
    
    
    }
  • 相关阅读:
    Failed to parse PID from file /run/nginx.pid: Invalid argument
    Ubuntu16.04环境下bashrc文件位置
    virtualenvwrapper.sh报错: There was a problem running the initialization hooks.解决
    pip安装virtualenvwrapper报错的解决办法
    争鸣|函数性质的综合应用辨析
    总结|静雅斋之2020高考备考回顾总结
    2020年全国卷Ⅱ卷文科数学图片版
    奇怪|说好的求最大值变成了求最小值
    探究|平面向量探究题
    平面向量错误收集
  • 原文地址:https://www.cnblogs.com/wangmei/p/5849479.html
Copyright © 2011-2022 走看看