SSM实现排课管理系统

1.技术介绍
java+sprinMVC+spring+mysql+mybatis+JSP
开发工具:eclipse或IDEA
2.主要功能说明:
注册、登录、课程管理、排课表、教师管理、教师管理、班级管理、课程教师、学生管理、排课统计
角色管理、菜单管理、用户管理
3.部分代码展示
课程管理控制器

package com.ian.media.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.ian.media.dao.jiaoshiMapper;
import com.ian.media.dao.jiaoshiguanliMapper;
import com.ian.media.model.jiaoshi;
import com.ian.media.model.jiaoshiguanli;
import com.ian.media.util.RandomUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ian.media.dao.kechengMapper;
import com.ian.media.dao.paikebiaoMapper;

import com.ian.media.model.kecheng;
import com.ian.media.model.paikebiao;

import java.util.Random;
import java.util.HashSet;


@Controller("kecheng")
@Scope("prototype")
@RequestMapping("kecheng.action")
public class kechengController extends BaseController<kecheng> {

    public kechengMapper kechengMapper;

    public paikebiaoMapper paikebiaoMapper;

	public jiaoshiMapper jiaoshiMapper;

    public jiaoshiguanliMapper jiaoshiguanliMapper;

    @Autowired
    public void setPlansMapperDao(kechengMapper kechengMapper, paikebiaoMapper paikebiaoMapper,jiaoshiMapper jiaoshiMapper,jiaoshiguanliMapper jiaoshiguanliMapper) {
        this.kechengMapper = kechengMapper;

        this.paikebiaoMapper = paikebiaoMapper;
        this.jiaoshiMapper = jiaoshiMapper;
        this.jiaoshiguanliMapper = jiaoshiguanliMapper;
    }

    @PostConstruct
    public void setBaseDao() {
        super.setBaseDao(kechengMapper);
    }


    @RequestMapping(params = "add")
    @ResponseBody
    public Map<Object, Object> add(HttpSession session, HttpServletRequest request, kecheng params) {

        System.out.println("你好");
        Map<Object, Object> map = new HashMap<Object, Object>();

        System.out.print("你好" + params);
        kecheng ss = new kecheng();

        String a1 = request.getParameter("a1");
        String a2 = request.getParameter("a2");
        String a3 = request.getParameter("a3");
        String a4 = request.getParameter("a4");
        String a5 = request.getParameter("a5");
        String a6 = request.getParameter("a6");
        System.out.println("a1:" + a1 + " a2:" + a2 + " a3: " + a3 + " a4: " + a4);
        ss.setA1(a1);
        ss.setA2(a2);
        ss.setA3(a3);
        ss.setA4(a4);
        ss.setA5(a5);
        ss.setA6(a6);

        try {
            kechengMapper.insertSelective(ss);
            map.put("msg", "添加 成功");
            map.put("success", true);
        } catch (Exception e) {
            e.printStackTrace();
            map.put("success", false);
            map.put("msg", "添加失败");
        }
        return map;
    }

    @RequestMapping(params = "update")
    @ResponseBody
    public Map<Object, Object> update(HttpSession session, HttpServletRequest request, kecheng params) {
        Map<Object, Object> map = new HashMap<Object, Object>();
        try {
            kechengMapper.updateByPrimaryKeySelective(params);
            map.put("success", true);
            map.put("msg", "修改 成功");

        } catch (Exception e) {
            e.printStackTrace();
            map.put("success", false);
            map.put("msg", "修改失败");
        }
        return map;
    }

    @RequestMapping(params = "jieshu")
    @ResponseBody
    public Map<Object, Object> jieshu(String id) {
        Map<Object, Object> map = new HashMap<Object, Object>();
        System.out.println("Hello World1111111111111111.                            ");

        System.out.println("ID:::::::::::::::::::::.                            " + id);
        try {
            Map<Object, Object> queryMap = new HashMap<Object, Object>();
            queryMap.put("id", id);
            List<kecheng> list = dao.get(queryMap);


            for (kecheng str : list) {
                System.out.println(str);

                int countold = Integer.parseInt(str.getA4());
                System.out.println(" countold::::::::::::::: ." + countold + " id:::::::::::" + str.getId());
                int countnew = countold >= 1 ? countold - 1 : 0;

                str.setA4(String.valueOf(countnew));
                System.out.println("new count::::::::::::::: ." + countnew);
                kechengMapper.updatejieshu(str);


                kecheng _huanshu = new kecheng();
                _huanshu.setA1(str.getA1());
                _huanshu.setA2(str.getA2());
                _huanshu.setA3(str.getA3());
                _huanshu.setA4("1");//借书数量,默认一次借1本书
                _huanshu.setA5(str.getId().toString());//这里是图书的主键存到a5字段里面

                kechengMapper.insertSelectivehuanshu(_huanshu);


                map.put("success", true);
                map.put("msg", "借书成功");
            }

        } catch (Exception e) {
            e.printStackTrace();
            map.put("success", false);
            map.put("msg", "借书失败");
        }
        return map;
    }


    @RequestMapping(params = "paike")
    @ResponseBody
    public Map<Object, Object> paike(String id, String banji) {
        Map<Object, Object> map = new HashMap<Object, Object>();

        System.out.println("班级:::::::::::::::::::::.                            " + banji);
        System.out.println("ID:::::::::::::::::::::.                            " + id);

        //
        paikebiaoMapper.deletepaikeall(banji);


        int jieshu = 20;
        try {
            Map<Object, Object> queryMap = new HashMap<Object, Object>();
            queryMap.put("a5", banji);

            List<kecheng> list = dao.get(queryMap);

            //获取教室list
            List<jiaoshi> listClassroom = jiaoshiMapper.get(null);
            //获取教师list
           // List<jiaoshiguanli> listTeacher = jiaoshiguanliMapper.get(null);

            String a1total = "";
            kecheng ransznew[] = new kecheng[jieshu];
            Integer[] ransz = new Integer[jieshu];
            kecheng rankc[] = new kecheng[jieshu];
            int indexstart = 0;
            for (kecheng str : list) {

                int m = Integer.parseInt(str.getA4());

                String s2 = "";

                int icountindex = 0;
                for (int k = indexstart; k < jieshu; k++) {
                    if (icountindex < m) {

                        rankc[k] = str;

                        System.out.println(" k::::::::::::::: ." + k);
                        System.out.println(" indexstart::::::::::::::: ." + indexstart);

                    } else {
                        break;
                    }
                    icountindex++;
                    indexstart++;
                }

                System.out.println(" 次数::::::::::::::: .");
                map.put("success", true);
                map.put("msg", "排课成功");
            }


            Random r = new Random();
            List<Integer> listaa = new ArrayList<Integer>();
            int i;
            while (listaa.size() < jieshu) {
                i = r.nextInt(jieshu);
                if (!listaa.contains(i)) {
                    listaa.add(i);
                }
            }

            ransz = listaa.toArray(new Integer[]{});


            for (int p = 0; p < ransz.length; p++) {
                ransznew[p] = rankc[ransz[p]];


                System.out.println(" ransznew::::::::::::::: ." + ransznew[p]);
            }
            for (int p = 0; p < ransznew.length; p++) {


                paikebiao ss = new paikebiao();

                String a1 = ransznew[p].getA1();
                String a2 = ransznew[p].getA6();
                String a3 = RandomUtil.randomEle(listClassroom).getA1();
                String a4 = p + "";
                String a5 = banji;
                System.out.println("a1:" + a1 + " a2:" + a2 + " a3: " + a3 + " a4: " + a4);
                ss.setA1(a1);
                ss.setA2(a2);
                ss.setA3(a3);
                ss.setA4(a4);
                ss.setA5(a5);

                try {
                    paikebiaoMapper.insertSelective(ss);
                    map.put("msg", "添加 成功");
                    map.put("success", true);
                } catch (Exception e) {
                    e.printStackTrace();
                    map.put("success", false);
                    map.put("msg", "添加失败");
                }

            }


            System.out.println("a1total::::::::::::::: ." + a1total);


        } catch (Exception e) {
            e.printStackTrace();
            map.put("success", false);
            map.put("msg", "排课失败");
        }
        return map;
    }


   

4.系统演示地址:
链接:https://pan.baidu.com/s/1Mg-gNkJ9_Ymofi9mYZEvbg
提取码:n09n

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值