text:
<repo_name>huangweicong/ACSS<file_sep>/ACSS/src/main/java/com/zsc/net11/vo/Cell.java
package com.zsc.net11.vo;

import java.io.Serializable;

/**
 * 单元格
 *
 * @author 黄伟枞
 */
public class Cell implements Serializable{

	private static final long serialVersionUID = 7172113663898740243L;

	private int timeIndex;

	private int roomIndex;

	public Cell() {
	}

	/**
	 *
	 * @param timeIndex 时间索引
	 *
	 * @param roomIndex 教室索引
	 */
	public Cell(int timeIndex, int roomIndex) {
		super();
		this.timeIndex = timeIndex;
		this.roomIndex = roomIndex;
	}

	/**
	 * 获取时间索引
	 *
	 * @return 时间索引
	 */
	public int getTimeIndex() {
		return timeIndex;
	}

	/**
	 * 设置时间索引
	 *
	 * @param timeIndex 时间索引
	 */
	public void setTimeIndex(int timeIndex) {
		this.timeIndex = timeIndex;
	}

	/**
	 * 获取教室索引
	 *
	 * @return 教室索引
	 */
	public int getRoomIndex() {
		return roomIndex;
	}

	/**
	 * 设置教室索引
	 *
	 * @param roomIndex 教室索引
	 */
	public void setRoomIndex(int roomIndex) {
		this.roomIndex = roomIndex;
	}

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/service/impl/CannotSetCurriculumServiceImpl.java
package com.zsc.net11.service.impl;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zsc.net11.dao.CannotSetCurriculumDao;
import com.zsc.net11.entity.CannotSetCurriculum;
import com.zsc.net11.service.CannotSetCurriculumService;

/**
 * 不排课时间操作相关 Service 接口的实现
 *
 * @author 黄伟枞
 */
@Service("cannotSetCurriculumService")
public class CannotSetCurriculumServiceImpl implements
		CannotSetCurriculumService {

	@Resource
	private CannotSetCurriculumDao cannotSetCurriculumDao;

	@Override
	public Integer save(CannotSetCurriculum cannotSetCurriculum) {

		CannotSetCurriculum entity = getByTimeIndex(cannotSetCurriculum.getTimeIndex());

		if (entity != null) {

			entity.setType(cannotSetCurriculum.getType());
			cannotSetCurriculumDao.update(entity);
			return entity.getId();

		}

		return (Integer) cannotSetCurriculumDao.save(cannotSetCurriculum);

	}

	@Override
	public boolean delete(int id) {

		cannotSetCurriculumDao.delete(id);
		return true;

	}

	@Override
	public boolean update(CannotSetCurriculum cannotSetCurriculum) {

		CannotSetCurriculum entity = cannotSetCurriculumDao.get(cannotSetCurriculum.getId());

		if (entity != null) {

			entity.setType(cannotSetCurriculum.getType());
			cannotSetCurriculumDao.update(entity);
			return true;

		}

		return false;

	}

	@Override
	public CannotSetCurriculum getById(int id) {
		return cannotSetCurriculumDao.get(id);
	}

	@Override
	public CannotSetCurriculum getByTimeIndex(int timeIndex) {
		return (CannotSetCurriculum) cannotSetCurriculumDao.createQuery(" from CannotSetCurriculum cannotSetCurriculum "
				+ " where cannotSetCurriculum.timeIndex = :timeIndex ")
				.setInteger("timeIndex", timeIndex)
				.uniqueResult();
	}

	@Override
	public List<CannotSetCurriculum> getAll() {
		return cannotSetCurriculumDao.list("from CannotSetCurriculum cannotSetCurriculum"
				+ " order by cannotSetCurriculum.timeIndex asc, "
				+ " cannotSetCurriculum.type asc ");
	}

	@SuppressWarnings("unchecked")
	@Override
	public Set<Integer> getAllSetByType(Integer Type) {

		Set<Integer> set = new HashSet<Integer>();
		List<CannotSetCurriculum> list = cannotSetCurriculumDao.createQuery("from CannotSetCurriculum cannotSetCurriculum "
				+ " where cannotSetCurriculum.type = :type ")
				.setInteger("type", Type)
				.list();

		for (CannotSetCurriculum cannotSetCurriculum : list) {
			set.add(cannotSetCurriculum.getTimeIndex());
		}

		return set;

	}

}
<file_sep>/ACSS/src/main/webapp/WEB-INF/content/room/get_all_classroom.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="s" uri="/struts-tags"%>

查看系别信息

		 			教学楼
		 			教室号
		 			类型
		 			容量
		 			修改
		 			删除

		 		<s:iterator id="classroom" value="#request.classroomList">

		 				<s:property value="#classroom.building.name" />
		 				<s:property value="#classroom.identifie" />

		 					<s:if test="#classroom.type == 0">
		 						理论课教室
		 					</s:if>
		 					<s:else>
		 						实验课教室
		 					</s:else>

		 				<s:property value="#classroom.capacity" />

		 					<a href='javascript:void(0)'
		 						onclick='loadHTML("room/update_classroom", {classroom_id:<s:property value="#classroom.id"/>})'>
		 						修改

							<a href='javascript:void(0)'
								onclick='delClassroomResult(<s:property value="#classroom.id"/>)'>
								删除

		 		</s:iterator>

<file_sep>/ACSS/src/main/webapp/WEB-INF/content/properties/change_password.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="s" uri="/struts-tags"%>

修改密码

		<form id="form" class="form-horizontal col-xs-offset-2 margin-top"
			method="post" action="changePasswordResult()"
			data-bv-feedbackicons-valid="glyphicon glyphicon-ok"
			data-bv-feedbackicons-invalid="glyphicon glyphicon-remove"
			data-bv-feedbackicons-validating="glyphicon glyphicon-refresh" >

					旧密码

					<input type="password" class="form-control" id="input_old_password"
						name="oldPassword" placeholder="旧密码"
						required data-bv-trigger="blur" data-bv-notempty-message="密码不能为空" />

					新密码

					<input type="password" class="form-control" id="input_new_password1"
						name="newPassword1" placeholder="新密码"
						required data-bv-trigger="blur" data-bv-notempty-message="密码不能为空" />

					确认密码

					<input type="password" class="form-control" id="input_new_password2"
						name="newPassword2" placeholder="<PASSWORD>"
						required data-bv-trigger="blur" data-bv-notempty-message="密码不能为空"
						data-bv-identical="true" data-bv-identical-field="newPassword1" data-bv-identical-message="密码不一致" />

				<button id="defaultEnterSubmit" type="submit"
					class="btn btn-primary col-xs-offset-3 col-xs-2" >
					修改
				</button>

		</form>

<file_sep>/ACSS/src/main/java/com/zsc/net11/entity/Course.java
package com.zsc.net11.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Version;

/**
 * 课程表实体类
 *
 * @author 黄伟枞
 */
@Entity
@Table(name = "TB_COURSE")
public class Course implements Serializable {

	// //////////////////////////////////////////////////begin 课程性质

	/** 选修课 */
	public static final int PROPERTY_SELECTED = -1;

	/** 限选课 */
	public static final int PROPERTY_LIMITED = 0;

	/** 必修课 */
	public static final int PROPERTY_REQUIRED = 1;

	// //////////////////////////////////////////////////end 课程性质

	// //////////////////////////////////////////////////begin 课程类别

	/** 基础课 */
	public static final int CATEGORY_BASIC = -1;

	/** 实践课 */
	public static final int CATEGORY_PRACTICE = 0;

	/** 专业课 */
	public static final int CATEGORY_PROFESSIONAL = 1;

	// //////////////////////////////////////////////////end 课程类别

	private static final long serialVersionUID = 3279580119080161006L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="PK_COLLEGE_ID")
	private Integer id;

	/** 课程名 */
	@Column(name = "F_NAME", length = 30)
	private String name;

	/** 课程代码 */
	@Column(name = "F_IDENTIFIE", length = 30)
	private String identifie;

	/** 课程性质（选修， 限选， 必修） */
	@Column(name = "F_PROPERTY")
	private Integer property;

	/** 课程类别（基础课， 实践课， 专业课） */
	@Column(name = "F_CATEGORY")
	private Integer category;

	@Version
	@Column(name = "F_VERSION")
	private Integer version;

	@Column(name = "F_DELETE")
	private Boolean del = false;

	// //////////////////////////////////////////////////Begin Constructor

	public Course() {
	}

	/**
	 * @param name 课程名
	 *
	 * @param teacherID 授课老师ID
	 *
	 * @param year 课程开设年份
	 *
	 * @param semester 课程开设学期，true为上学期， false为下学期
	 *
	 */
	public Course(String name) {
		this.name = name;
	}

	// //////////////////////////////////////////////End Constructor

	// //////////////////////////////////////////////Begin Getter Setter

	public Integer getId() {
		return id;
	}

	public Course setId(Integer id) {
		this.id = id;
		return this;
	}

	/**
	 * 获取课程名
	 *
	 * @return 课程名
	 */
	public String getName() {
		return name;
	}

	/**
	 * 设置课程名
	 *
	 * @param name 课程名
	 */
	public Course setName(String name) {
		this.name = name;
		return this;
	}

	/**
	 * 获取课程代码
	 *
	 * @return 课程代码
	 */
	public String getIdentifie() {
		return identifie;
	}

	/**
	 * 设置课程代码
	 *
	 * @param identifie 课程代码
	 */
	public Course setIdentifie(String identifie) {
		this.identifie = identifie;
		return this;
	}

	/**
	 * 获取课程性质
	 *
	 * @return 课程性质（选修， 限选， 必修）
	 */
	public Integer getProperty() {
		return property;
	}

	/**
	 * 设置课程性质
	 *
	 * @param property 课程性质（选修， 限选， 必修）
	 */
	public Course setProperty(Integer property) {
		this.property = property;
		return this;
	}

	/**
	 * 获取课程类别
	 *
	 * @return 课程类别（基础课， 实践课， 专业课）
	 */
	public Integer getCategory() {
		return category;
	}

	/**
	 * 设置课程类别
	 *
	 * @param category 课程类别（基础课， 实践课， 专业课）
	 */
	public Course setCategory(Integer category) {
		this.category = category;
		return this;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	public Boolean getDel() {
		return del;
	}

	public Course setDel(Boolean del) {
		this.del = del;
		return this;
	}

	// //////////////////////////////////////////////End Getter Setter

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/dao/CourseDao.java
package com.zsc.net11.dao;

import com.zsc.net11.base.BaseDao;
import com.zsc.net11.entity.Course;

/**
 * 课程表 Dao
 *
 * @author 黄伟枞
 */
public interface CourseDao extends BaseDao<Course> {

}
<file_sep>/ACSS/src/main/webapp/WEB-INF/content/room/update_classroom.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="s" uri="/struts-tags"%>

		返回
		修改教室信息

		<form id="form" class="form-horizontal col-xs-offset-2 margin-top"
			method="post" action="updateClassroomResult()"
			data-bv-feedbackicons-valid="glyphicon glyphicon-ok"
			data-bv-feedbackicons-invalid="glyphicon glyphicon-remove"
			data-bv-feedbackicons-validating="glyphicon glyphicon-refresh">
			<input name="id" value="<s:property value='#request.classroom.id'/>" hidden="hidden">

					教学楼

					<select class="form-control" id="select_building_name" name="building_id">
						<s:iterator id="building" value="#request.buildingList">
							<s:if test="#building.id == #request.classroom.building.id">
								<option selected="selected" value='<s:property value="#building.id"/>'>
									<s:property value="#building.name" />
								</option>
							</s:if>
							<s:else>
								<option value='<s:property value="#building.id"/>'>
									<s:property value="#building.name" />
								</option>
							</s:else>
						</s:iterator>
					</select>

					教室号

					<input type="text" class="form-control" id="input_classroom_identifie"
						name="name" placeholder="教室号"
						value='<s:property value="#request.classroom.identifie"/>' disabled
						required data-bv-trigger="blur" data-bv-notempty-message="教室号不能为空" />

					容量

					<input type="number" class="form-control" id="input_classroom_capacity"
						name="capacity" min="0" value='<s:property value="#request.classroom.capacity"/>'
						data-bv-greaterthan-inclusive="true" data-bv-greaterthan-message="容量必须大于0"  />

					教室类型

					<select class="form-control" id="select_classroom_type" name="type">
						<s:if test="#request.classroom.type == 0">
							<option value="0" selected="selected">理论课教室</option>
							<option value="1">实验课教室</option>
						</s:if>
						<s:else>
							<option value="0">理论课教室</option>
							<option value="1" selected="selected">实验课教室</option>
						</s:else>
					</select>

				<button id="defaultEnterSubmit" type="submit"
					class="btn btn-primary col-xs-offset-3 col-xs-2" >
					修改
				</button>

		</form>

<file_sep>/ACSS/src/main/java/com/zsc/net11/dao/impl/CannotSetCurriculumDaoImpl.java
package com.zsc.net11.dao.impl;

import org.springframework.stereotype.Repository;

import com.zsc.net11.base.BaseDaoImpl;
import com.zsc.net11.dao.CannotSetCurriculumDao;
import com.zsc.net11.entity.CannotSetCurriculum;

/**
 * 不排课时间表 Dao 的实现
 *
 * @author 黄伟枞
 */
@Repository("cannotSetCurriculumDao")
public class CannotSetCurriculumDaoImpl extends
		BaseDaoImpl<CannotSetCurriculum> implements CannotSetCurriculumDao {

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/util/algorithm/Search.java
package com.zsc.net11.util.algorithm;

import java.util.LinkedList;

import com.zsc.net11.algorithm.Gene;
import com.zsc.net11.util.Constant;
import com.zsc.net11.vo.Cell;

/**
 * 搜索
 *
 * @author 黄伟枞
 */
public class Search {

	/**
	 * 填充队列
	 *
	 * @param cells 四个顶点
	 *
	 * @param cellQueue 搜索队列
	 *
	 * @param table 课表
	 *
	 * @return true 表示能继续搜索； false 表示不能继续搜索
	 */
	public static boolean setQueue(Cell[] cells, LinkedList<Cell> cellQueue, Gene[][] table) {

		if (cells[0].getRoomIndex() >= 0) {

			int timeIndexBegin = cells[0].getTimeIndex() >= 0 ? cells[0].getTimeIndex() : 0;
			int timeIndexEnd = cells[1].getTimeIndex() < Constant.TIME_AMOUNT ? cells[1].getTimeIndex() : Constant.TIME_AMOUNT - 1;
			int iRoomIndex = cells[0].getRoomIndex();

			while (timeIndexBegin <= timeIndexEnd) {

				cellQueue.addLast(new Cell(timeIndexBegin, iRoomIndex));
				++timeIndexBegin;

			}

		}

		if (cells[1].getTimeIndex() < Constant.TIME_AMOUNT) {

			int roomIndexBegin = cells[1].getRoomIndex() >= 0 ? cells[1].getRoomIndex() : 0;
			int roomIndexEnd = cells[2].getRoomIndex() < table[0].length ? cells[2].getRoomIndex() : table[0].length - 1;
			int iTimeIndex = cells[1].getTimeIndex();

			while (roomIndexBegin <= roomIndexEnd) {

				cellQueue.addLast(new Cell(iTimeIndex, roomIndexBegin));
				++roomIndexBegin;

			}

		}

		if (cells[2].getRoomIndex() < table[0].length) {

			int timeIndexBegin = cells[2].getTimeIndex() < Constant.TIME_AMOUNT ? cells[2].getTimeIndex() : Constant.TIME_AMOUNT - 1;
			int timeIndexEnd = cells[3].getTimeIndex() >= 0 ? cells[3].getTimeIndex() : 0;
			int iRoomIndex = cells[2].getRoomIndex();

			while(timeIndexBegin >= timeIndexEnd) {

				cellQueue.addLast(new Cell(timeIndexBegin, iRoomIndex));
				--timeIndexBegin;

			}

		}

		if (cells[3].getTimeIndex() >= 0) {

			int roomIndexBegin = cells[3].getRoomIndex()
= 0 ? cells[0].getRoomIndex() : 0;
			int iTimeIndex = cells[3].getTimeIndex();

			while (roomIndexBegin >= roomIndexEnd) {

				cellQueue.addLast(new Cell(iTimeIndex, roomIndexBegin));
				--roomIndexBegin;

			}

		}

		return !cellQueue.isEmpty();
	}
}
<file_sep>/ACSS/src/main/webapp/WEB-INF/conf/oracle.properties
jdbc.driverClass=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc\:oracle\:thin\:@192.168.117.250\:1521\:ACSS
jdbc.username=scott
jdbc.password=<PASSWORD>
c3p0.maxPoolSize=40
c3p0.minPoolSize=1
c3p0.initialPoolSize=1
c3p0.maxIdleTime=30
<file_sep>/ACSS/src/main/java/com/zsc/net11/entity/CannotSetCurriculum.java
package com.zsc.net11.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Version;

/**
 * 不排课时间表实体类
 *
 * @author 黄伟枞
 */
@Entity
@Table(name = "TB_CANNOT_SET_CURRICULUM")
public class CannotSetCurriculum implements Serializable{

	private static final long serialVersionUID = -5064322649267810144L;

	/** 全部 */
	public static final int ALL = 0;

	/** 理论课 */
	public static final int THEORY = 1;

	/** 实验课 */
	public static final int EXPERIMENT = 2;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="PK_CANNOT_SET_CURRICULUM_ID")
	private Integer id;

	/** 时间索引 */
	@Column(name="F_TIME_INDEX")
	private Integer timeIndex;

	/** 类型：全部、理论课、实验课 */
	@Column(name="F_TYPE")
	private Integer type;

	@Version
	@Column(name = "F_VERSION")
	private Integer version;

	// //////////////////////////////////////////////////Begin Constructor

	public CannotSetCurriculum() {
	}

	public CannotSetCurriculum(Integer timeIndex, Integer type) {
		super();
		this.timeIndex = timeIndex;
		this.type = type;
	}

	// //////////////////////////////////////////////////End Constructor

	// //////////////////////////////////////////////////Begin Getter Setter

	public Integer getId() {
		return id;
	}

	public CannotSetCurriculum setId(Integer id) {
		this.id = id;
		return this;
	}

	/**
	 * 获取时间索引
	 *
	 * @return 时间索引
	 */
	public Integer getTimeIndex() {
		return timeIndex;
	}

	/**
	 * 设置时间索引
	 *
	 * @param timeIndex 时间索引
	 */
	public CannotSetCurriculum setTimeIndex(Integer timeIndex) {
		this.timeIndex = timeIndex;
		return this;
	}

	/**
	 * 获取类型
	 *
	 * @return 类型
	 */
	public Integer getType() {
		return type;
	}

	/**
	 * 设置类型
	 *
	 * @param type 类型
	 */
	public CannotSetCurriculum setType(Integer type) {
		this.type = type;
		return this;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	// //////////////////////////////////////////////////End Getter Setter

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/base/BaseDao.java
package com.zsc.net11.base;

import java.io.Serializable;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.SQLQuery;

/**
 * 数据访问对象基本接口，定义了增删改查
 *
 * @param <T> 实体类
 *
 * @author 黄伟枞
 */
public interface BaseDao<T> {

	/**
	 * 获取实体类
	 *
	 * @return 实体类
	 */
	@SuppressWarnings("rawtypes")
	public Class getEntityClass();

	/**
	 * 持久化实例
	 *
	 * @param entity 需要被持久化的实例
	 *
	 * @return 返回被持久化实例的 ID
	 */
	public Serializable save(T entity);

	/**
	 * 根据Id删除实例
	 *
	 * @param id 需要被删除的实例的 ID
	 */
	public void delete(Integer id);

	/**
	 * 删除指定的实例
	 *
	 * @param entity 需要被删除的实例
	 */
	public void delete(T entity);

	/**
	 * 修改指定的实例
	 *
	 * @param entity 需要被修改的实例
	 */
	public void update(T entity);

	/**
	 * 根据Id来查找实例
	 *
	 * @param id ID
	 *
	 * @return 查找的实例
	 */
	public T get(Integer id);

	/**
	 * 在数据库中保存实例
	 *
	 * @param entity 要保存到数据库中的实例
	 */
	public void create(T entity);

	/**
	 * 创建查询对象
	 *
	 * @param hql HQL语句
	 *
	 * @return 查询对象实例
	 */
	public Query createQuery(String hql);

	/**
	 * 创建查询对象
	 *
	 * @param sql SQL语句
	 *
	 * @return 查询对象实例
	 */
	public SQLQuery createSqlQuery(String sql);

	/**
	 * 根据HQL语句获取表记录总数
	 *
	 * @param hql HQL语句
	 *
	 * @param params HQL语句参数
	 *
	 * @return 总数
	 */
	public Integer getTotalCount(String hql, Object... params);

	/**
	 * 获取此实体类数据库的所有实例
	 *
	 * @param clazz 实体类
	 *
	 * @return 此实体类数据库的所有实例
	 */
	@SuppressWarnings("rawtypes")
	public List<T> list(Class clazz);

	/**
	 * 根据hql查询
	 *
	 * @param hql HQL语句
	 *
	 * @return 查询的结果
	 */
	public List<T> list(String hql);

	/**
	 * 分页
	 *
	 * @param hql HQL语句
	 *
	 * @param firstResult 从这条记录开始
	 *
	 * @param maxSize 获取最多记录数
	 *
	 * @param params HQL参数
	 *
	 * @return 记录集合
	 */
	public List<T> list(String hql, int firstResult, int maxSize,
			Object... params);

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/algorithm/Species.java
package com.zsc.net11.algorithm;

import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import com.zsc.net11.util.Variable;
import com.zsc.net11.util.algorithm.Init;
import com.zsc.net11.util.algorithm.Release;

/**
 * 物种(伪单实例)
 *
 * @author 黄伟枞
 */
public class Species extends Thread {

	/** 是否运行 */
	private boolean run = false;

	/** 线程池 */
	private ExecutorService executorService;

	/** 种群集合 */
	private List<Population> populationList;

	private static class SingletonHolder {

		private static Species instance = new Species();

		private static Species renew() {
			instance = new Species();
			return instance;
		}

	}

	private Species() {
		populationList = new LinkedList<Population>();
	}

	/**
	 * 获取种群集合
	 *
	 * @return 种群集合
	 */
	public List<Population> getPopulationList() {
		return populationList;
	}

	/** 获取实例
	 *
	 * @return 物种
	 */
	public static final Species getInstance() {
		return SingletonHolder.instance;
	}

	/**
	 * 重新构造物种对象
	 *
	 * @return 物种
	 */
	public static final Species renew() {
		return SingletonHolder.renew();
	}

	@Override
	public void run() {

		if (!run) {

			executorService = Executors.newCachedThreadPool();

			run = true;
			// 初始化设置
			Variable.finish = false;
			Variable.setBestChromosome(null);
			Variable.resetTheradRunNumber();
			Variable.resetSatisfactionList();

			Init.init();

			populationList.clear();
			for (int i = 0; i < Variable.populationAmount; ++ i) {
				populationList.add(new Population());
			}

			for (Population population : populationList) {
				executorService.execute(population);
			}

		}

	}

	/** 重置 */
	public void reset() {

		if (executorService != null
				&& !executorService.isShutdown()) {
			executorService.shutdownNow();
		}

		Variable.finish = false;
		Variable.resetTheradRunNumber();
		populationList.clear();
		Release.release();
		run = false;

	}

	/**
	 * 判断是否在运行
	 *
	 * @return true 表示正在运行； false 表示没在运行
	 */
	public boolean isRun() {
		return run;
	}

	/**
	 * 停止运行
	 */
	public void stopRun() {

		if (executorService != null
				&& !executorService.isShutdown()) {
			executorService.shutdownNow();
		}

		run = false;
	}

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/util/algorithm/collections/ExperimentMap.java
package com.zsc.net11.util.algorithm.collections;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 黄伟枞
 */
public abstract class ExperimentMap {

	/** 实验课课程名:班级名 - 实验室索引 关联，实验课对应的实验室 */
	private static Map<String, Integer> experimentAndRoomMap;

	/**
	 * 初始化实验课与教室关联
	 */
	public static void init() {
		experimentAndRoomMap = new HashMap<String, Integer>();
	}

	/**
	 * 初始化实验课与教室关联
	 *
	 * @param amount 数量
	 */
	public static void init(int amount) {
		experimentAndRoomMap = new HashMap<String, Integer>((int) (amount / 0.7));
	}

	/**
	 * 添加实验课与教室关联
	 *
	 * @param courseClazz 实验课课程名:班级名
	 *
	 * @param roomIndex 实验室教室索引
	 */
	public static void put(String courseClazz, int roomIndex) {
		experimentAndRoomMap.put(courseClazz, roomIndex);
	}

	/**
	 * 根据课程名称获取实验室教室索引
	 *
	 * @param courseClazz 实验课课程名:班级名
	 *
	 * @return 实验室教室索引
	 */
	public static Integer get(String courseClazz) {
		return experimentAndRoomMap.get(courseClazz);
	}

	/**
	 * 移除映射
	 *
	 * @param courseClazz 实验课课程名:班级名
	 */
	public static void remove(String courseClazz) {
		experimentAndRoomMap.remove(courseClazz);
	}

	/**
	 * 清空 roomMap
	 */
	public static void clear() {
		experimentAndRoomMap.clear();
	}

	/**
	 * 释放 roomMap 占用的空间
	 */
	public static void release() {
		experimentAndRoomMap = null;
	}

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/actions/teach/CourseAction.java
package com.zsc.net11.actions.teach;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import com.zsc.net11.base.BaseActionFormSupport;
import com.zsc.net11.entity.Course;
import com.zsc.net11.service.CourseService;

/**
 * 课程相关 Action
 *
 * @author 黄伟枞
 */
@ParentPackage("base")
public class CourseAction extends BaseActionFormSupport<Course> {

	private static final long serialVersionUID = 3127811229436424664L;

	@Resource
	private CourseService courseService;

	/**
	 * 添加课程信息
	 */
	@Action(value = "add_course", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/teach/add_course.jsp") })
	public String addCourse() throws Exception {
		return SUCCESS;
	}

	/**
	 * 添加课程信息结果
	 */
	@Action(value = "add_course_result", results = { @Result(name = SUCCESS, type="json", params = {"root", "result"}) })
	public String addCourseResult() throws Exception {

		Integer courseId = courseService.save(getModel());

		if (courseId == null) {
			result = false;
		} else {
			result = true;
		}

		return SUCCESS;
	}

	/**
	 * 查看课程信息
	 */
	@Action(value = "get_all_course", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/teach/get_all_course.jsp") })
	public String getAllCourse() throws Exception {

		List<Course> courseList = courseService.getAll();
		request.setAttribute("courseList", courseList);
		return SUCCESS;

	}

	/**
	 * 更新课程信息
	 */
	@Action(value = "update_course", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/teach/update_course.jsp") })
	public String updateCourse() throws Exception {

		Integer courseId = Integer.valueOf(request.getParameter("course_id"));
		Course course = courseService.getById(courseId);

		if (course != null) {

			request.setAttribute("course", course);
			return SUCCESS;

		}

		return ERROR;
	}

	/**
	 * 更新课程信息结果
	 */
	@Action(value = "update_course_result", results = { @Result(name = SUCCESS, type="json", params = {"root", "result"}) })
	public String updateCourseResult() throws Exception {

		result = courseService.update(getModel());

		return SUCCESS;

	}

	/**
	 * 删除课程信息结果
	 */
	@Action(value = "del_course_result", results = { @Result(name = SUCCESS, type="json", params = {"root", "result"}) })
	public String delCourseResult() throws Exception {

		Integer courseId = Integer.valueOf(request.getParameter("course_id"));

		result = courseService.delete(courseId);

		return SUCCESS;

	}

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/dao/BuildingSatisfactionDao.java
package com.zsc.net11.dao;

import com.zsc.net11.base.BaseDao;
import com.zsc.net11.entity.BuildingSatisfaction;

/**
 * 教学楼与教学楼之间的满意度表 Dao
 *
 * @author 黄伟枞
 */
public interface BuildingSatisfactionDao extends BaseDao<BuildingSatisfaction> {

}
<file_sep>/ACSS/src/main/webapp/WEB-INF/content/room/get_all_building_satisfaction.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="s" uri="/struts-tags"%>

查看教学楼距离

		 			教学楼名
		 			教学楼名
		 			距离
		 			修改

		 		<s:iterator id="buildingSatisfaction" value="#request.buildingSatisfactionList">

		 				<s:property value="#buildingSatisfaction.frontBuilding.name" />
		 				<s:property value="#buildingSatisfaction.nextBuilding.name" />

			 				<s:if test="#buildingSatisfaction.satisfaction > 0.5" >
			 					近
			 				</s:if>
			 				<s:elseif test="#buildingSatisfaction.satisfaction > 0.2" >
			 					中
			 				</s:elseif>
			 				<s:else>
			 					远
			 				</s:else>

		 					<a href='javascript:void(0)'
		 						onclick='loadHTML("room/update_building_satisfaction", {buildingSatisfaction_id:<s:property value="#buildingSatisfaction.id"/>})'>
		 						修改

		 		</s:iterator>

<file_sep>/ACSS/src/main/java/com/zsc/net11/entity/Teacher.java
package com.zsc.net11.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Version;

/**
 * 教师表实体类
 *
 * @author 黄伟枞
 */
@Entity
@Table(name = "TB_TEACHER")
public class Teacher implements Serializable {

	private static final long serialVersionUID = 1235240087364658404L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="PK_TEACHER_ID")
	private Integer id;

	/** 教师姓名 */
	@Column(name = "F_NAME", length = 10)
	private String name;

	/** 教师编号 */
	@Column(name = "F_IDENTIFIE", length = 30)
	private String identifie;

	/** 系别 */
	@OneToOne
    @JoinColumn(name="FK_DEPARTMENT_ID")
	private Department department;

	@Version
	@Column(name = "F_VERSION")
	private Integer version;

	@Column(name = "F_DELETE")
	public Boolean del = false;

	// //////////////////////////////////////////////////Begin Constructor

	public Teacher() {
	}

	/**
	 * @param name 教师姓名
	 */
	public Teacher(String name) {
		this.name = name;
	}

	/**
	 * @param name 教师姓名
	 *
	 * @param identifie 教师编号
	 */
	public Teacher(String name, String identifie) {
		this.name = name;
		this.identifie = identifie;
	}

	// //////////////////////////////////////////////////End Constructor

	// //////////////////////////////////////////////////Begin Getter Setter

	public Integer getId() {
		return id;
	}

	public Teacher setId(Integer id) {
		this.id = id;
		return this;
	}

	/**
	 * 获取教师姓名
	 *
	 * @return 教师姓名
	 */
	public String getName() {
		return name;
	}

	/**
	 * 设置教师姓名
	 *
	 * @param name 教师姓名
	 */
	public Teacher setName(String name) {
		this.name = name;
		return this;
	}

	/**
	 * 获取教师编号
	 *
	 * @return 教师编号
	 */
	public String getIdentifie() {
		return identifie;
	}

	/**
	 * 设置教师编号
	 * @param identifie 教师编号
	 */
	public Teacher setIdentifie(String identifie) {
		this.identifie = identifie;
		return this;
	}

	/**
	 * 获取系别
	 *
	 * @return 系别
	 */
	public Department getDepartment() {
		return department;
	}

	/**
	 * 设置系别
	 *
	 * @param department 系别
	 */
	public Teacher setDepartment(Department department) {
		this.department = department;
		return this;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	public Boolean getDel() {
		return del;
	}

	public Teacher setDel(Boolean del) {
		this.del = del;
		return this;
	}

	// //////////////////////////////////////////////////End Getter Setter

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/dao/impl/CollegeDaoImpl.java
package com.zsc.net11.dao.impl;

import org.springframework.stereotype.Repository;

import com.zsc.net11.base.BaseDaoImpl;
import com.zsc.net11.dao.CollegeDao;
import com.zsc.net11.entity.College;

/**
 * 学院表 Dao 的实现
 *
 * @author 黄伟枞
 */
@Repository("collegeDao")
public class CollegeDaoImpl extends BaseDaoImpl<College> implements CollegeDao {

}
<file_sep>/ACSS/src/main/webapp/WEB-INF/conf/mysql.properties
jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.url=jdbc\:mysql\://192.168.117.11\:3306/ACSS?createDatabaseIfNotExist\=true&characterEncoding\=UTF-8
jdbc.username=root
jdbc.password=<PASSWORD>
c3p0.maxPoolSize=40
c3p0.minPoolSize=1
c3p0.initialPoolSize=1
c3p0.maxIdleTime=30
<file_sep>/ACSS/src/main/java/com/zsc/net11/service/impl/BuildingSatisfactionServiceImpl.java
package com.zsc.net11.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zsc.net11.dao.BuildingSatisfactionDao;
import com.zsc.net11.entity.BuildingSatisfaction;
import com.zsc.net11.service.BuildingSatisfactionService;

/**
 * @author 黄伟枞
 */
@Service("buildingSatisfactionService")
public class BuildingSatisfactionServiceImpl implements
		BuildingSatisfactionService {

	@Resource
	private BuildingSatisfactionDao buildingSatisfactionDao;

	@Override
	public boolean update(BuildingSatisfaction buildingSatifaction) {

		BuildingSatisfaction entity = buildingSatisfactionDao.get(buildingSatifaction.getId());

		if (entity != null) {

			buildingSatisfactionDao.update(entity);

			entity = getByTwoBuildingId(buildingSatifaction.getFrontBuilding().getId(),
					buildingSatifaction.getNextBuilding().getId());

			if (entity != null) {

				entity.setSatisfaction(buildingSatifaction.getSatisfaction());
				buildingSatisfactionDao.update(entity);

				entity = getByTwoBuildingId(buildingSatifaction.getNextBuilding().getId(),
						buildingSatifaction.getFrontBuilding().getId());

				if (entity != null) {
					entity.setSatisfaction(buildingSatifaction.getSatisfaction());
					buildingSatisfactionDao.update(entity);
				}

				return true;

			}

		}

		return false;
	}

	@Override
	public BuildingSatisfaction getById(int id) {
		return buildingSatisfactionDao.get(id);
	}

	@Override
	public BuildingSatisfaction getByTwoBuildingId(int frontId, int nexId) {
		return (BuildingSatisfaction) buildingSatisfactionDao.createQuery("from BuildingSatisfaction buildingSatisfaction "
				+ " where buildingSatisfaction.frontBuilding.id = :frontId "
				+ " and buildingSatisfaction.nextBuilding.id = :nextId")
				.setInteger("frontId", frontId)
				.setInteger("nextId", nexId)
				.uniqueResult();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<BuildingSatisfaction> getByBuildingId(int frontId) {
		return buildingSatisfactionDao.createQuery("from BuildingSatisfaction buildingSatisfaction "
				+ " where buildingSatisfaction.frontBuilding.id = :frontId "
				+ " order by convert(buildingSatisfaction.nextBuilding.name) asc ")
				.setInteger("frontId", frontId)
				.list();
	}

	@Override
	public List<BuildingSatisfaction> getAll() {
		return buildingSatisfactionDao.list("from BuildingSatisfaction buildingSatisfaction "
				+ " order by convert(buildingSatisfaction.frontBuilding.name) asc, "
				+ " convert(buildingSatisfaction.nextBuilding.name) asc");
	}

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/service/impl/TeacherServiceImpl.java
package com.zsc.net11.service.impl;

import java.util.LinkedList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zsc.net11.dao.TeacherDao;
import com.zsc.net11.entity.Teacher;
import com.zsc.net11.json.TeacherJson;
import com.zsc.net11.service.TeacherService;

/**
 * 教师操作相关 Service 接口的实现
 *
 * @author 黄伟枞
 */
@Service("teacherService")
public class TeacherServiceImpl implements TeacherService {

	@Resource
	private TeacherDao teacherDao;

	@Override
	public Integer save(Teacher teacher) {

		Teacher entity = getByIdentifie(teacher.getIdentifie());

		if (entity != null) {
			// 存在相同编号的
			if (entity.getDel()) {
				// 已删除，恢复
				entity.setDel(false)
					.setName(teacher.getName())
					.setDepartment(teacher.getDepartment());
				teacherDao.update(entity);
				return entity.getId();

			}
			// 没删除，编号冲突
			return null;
		}

		return (Integer) teacherDao.save(teacher);

	}

	@Override
	public boolean delete(int id) {

		Teacher entity = getById(id);

		if (entity != null) {

			entity.setDel(true);
			teacherDao.update(entity);
			return true;

		}

		return false;
	}

	@Override
	public boolean update(Teacher teacher) {

		Teacher entity = getById(teacher.getId());

		if (entity != null) {

			entity.setDepartment(teacher.getDepartment());
			teacherDao.update(entity);
			return true;

		}

		return false;
	}

	@Override
	public Teacher getByIdentifie(String identifie) {
		return (Teacher) teacherDao.createQuery("from Teacher teacher where teacher.identifie = :identifie")
				.setString("identifie", identifie)
				.uniqueResult();

	}

	@Override
	public Teacher getById(int id) {
		return teacherDao.get(id);
	}

	@Override
	public List<Teacher> getAll() {
		return teacherDao.list("from Teacher teacher "
				+ " where teacher.del = false "
				+ " order by convert(teacher.department.college.name) asc, "
				+ " convert(teacher.department.name) asc, "
				+ " convert(teacher.name) asc");
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Teacher> getAllByCollegeId(int collegeId) {
		return teacherDao.createQuery("from Teacher teacher "
				+ " where teacher.del = false "
				+ " and teacher.department.college.id = :collegeId "
				+ " order by convert(teacher.department.name) asc, "
				+ " convert(teacher.name) asc")
				.setInteger("collegeId", collegeId)
				.list();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Teacher> getAllByDepartmentId(int departmentId) {
		return teacherDao.createQuery("from Teacher teacher "
				+ " where teacher.del = false "
				+ " and teacher.department.id = :departmentId "
				+ " order by convert(teacher.name) asc")
				.setInteger("departmentId", departmentId)
				.list();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<TeacherJson> getAllJsonByDeparimentId(int departmentId) {

		String sql = " select PK_TEACHER_ID, F_NAME, F_IDENTIFIE from TB_TEACHER "
				+ " where F_DELETE = 0 "
				+ " and FK_DEPARTMENT_ID = :departmentId "
				+ " order by convert(F_NAME using gbk) asc";

		List<Object[]> list = teacherDao.createSqlQuery(sql)
										.setInteger("departmentId", departmentId)
										.list();

		List<TeacherJson> teacherJsonList = new LinkedList<TeacherJson>();

		for (Object[] objects : list) {
			teacherJsonList.add(new TeacherJson((Integer)objects[0], (String)objects[1], (String)objects[2]));
		}

		return teacherJsonList;

	}

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/util/algorithm/CaculateSatisfaction.java
package com.zsc.net11.util.algorithm;

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

import com.zsc.net11.algorithm.vo.CurriculumUnitVO;
import com.zsc.net11.algorithm.vo.CurriculumVO;
import com.zsc.net11.entity.Course;
import com.zsc.net11.util.Constant;
import com.zsc.net11.util.algorithm.collections.BuildingSatisfactionMap;
import com.zsc.net11.util.algorithm.collections.ExperimentRoomCollection;
import com.zsc.net11.util.algorithm.collections.StoreySatisfaction;
import com.zsc.net11.util.algorithm.collections.TheoryRoomCollection;

/**
 * 计算时间、空间满意度
 *
 * @author 黄伟枞
 */
public abstract class CaculateSatisfaction {

	/** 时间间距满意度 */
	private static final double[] TIME_SATISFACTION = new double[]{
		1,
		0, 0, 0, 0, 0, 0,
		0.1, 0.1, 0.1, 0.1,
		0.6, 0.6,
		0.8, 0.8, 0.8, 0.8,
		0.6, 0.6, 0.6, 0.6,
		0.2, 0.2, 0.2, 0.2,
		0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
		0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
		0.1, 0.1, 0.1, 0.1, 0.1, 0.1
	};

	/** 基础课 */
	private static final double[] BASE_SATISFACTION = {0.4, 0.4, 0.6, 0.6, 0.2, 0.2};

	/** 实践课/实验课 */
	private static final double[] PRACTICE_SATISFACTION = {0.4, 0.4, 0.6, 0.6, 0.2, 0.2};

	/** 专业课 */
	private static final double[] PROFESSIONAL_SATISFACTION = {0.6, 0.6, 0.4, 0.4, 0.2, 0.2};

	/**
	 * 计算时间满意度
	 *
	 * @return 时间满意度
	 */
	public static double caculateTimeSatisfaction(List<CurriculumUnitVO> curriculumUnitVOList)
	{
		int size = curriculumUnitVOList.size();

		if (size <= 1) { // 只有一个，时间满意度为 1
			return 1;
		} else {

			Iterator<CurriculumUnitVO> iterator =  curriculumUnitVOList.iterator();
			CurriculumUnitVO front = iterator.next();
			CurriculumUnitVO next = null;
			double statisfaction = 0.0;
			int timeDiffer = 0;

			while (iterator.hasNext()) {
				next = iterator.next();
				timeDiffer = next.getTimeIndex() - front.getTimeIndex();
				statisfaction += TIME_SATISFACTION[timeDiffer];
				front = next;
			}

			return statisfaction / (size - 1);
		}
	}

	/**
	 * 计算空间满意度
	 *
	 * @return 空间满意度
	 */
	public static double caculateSpaceSatisfaction(List<CurriculumUnitVO> curriculumUnitVOList)
	{
		double spaceSatisfaction = 0.0; // 空间满意度

		if (curriculumUnitVOList.isEmpty()) {
			return 0;
		}

		int size = curriculumUnitVOList.size();

		if (size <= 1) {
			return 1;
		} else {
			Iterator<CurriculumUnitVO> iterator = curriculumUnitVOList.iterator();
			CurriculumUnitVO front = iterator.next();
			CurriculumUnitVO next = null;

			int frontRoomIndex = 0; // 前一个教学楼索引
			int nextRoomIndex = 0; // 后一个教学楼索引

			int frontBuildingId = 0; // 前一个教学楼 ID
			int nextBuildingId = 0; // 后一个教学楼 ID

			int frontTimeIndex = front.getTimeIndex(); // 前一个课程的时间
			int nextTimeIndex = -1; // 后一个课程的时间

			int frontTimeDay = frontTimeIndex / 6; // 第几天（一周中，第一天为星期一）
			int nextTimeDay = -1; //

			int frontStorey = 0; // 前一个课程教室所在楼层数
			int nextStorey = 0; // 后一个课程教室所在楼层数

			double buildingSatisfaction = 0.0; // 楼满意度
			double storeySatisfaction = 0.0; // 层满意度

			while (iterator.hasNext()) {

				next = iterator.next();
				nextTimeIndex = next.getTimeIndex();
				nextTimeDay = nextTimeIndex / 6;

				frontTimeIndex %= 6;
				nextTimeIndex %= 6;

				// 连课才计算，不连课满意度为1
				if (frontTimeDay == nextTimeDay
						&& nextTimeIndex - frontTimeIndex == 1
						&& frontTimeIndex % 2 == 0) {

					// 计算教学楼与教学楼之间的满意度
					frontRoomIndex = front.getRoomIndex();

					// 获取楼层
					if (front.getCurriculumType()) {
					if (frontRoomIndex < 0) {
//						System.out
//								.println("CaculateSatisfaction.caculateSpaceSatisfaction()");
//						System.out.println(frontRoomIndex);
					}
						frontStorey = TheoryRoomCollection.get(frontRoomIndex).getStorey();
						frontBuildingId = TheoryRoomCollection.get(frontRoomIndex).getBuildingId();

					} else {

						frontStorey = ExperimentRoomCollection.get(frontRoomIndex).getStorey();
						frontBuildingId = ExperimentRoomCollection.get(frontRoomIndex).getBuildingId();

					}

					nextRoomIndex = next.getRoomIndex();
					if (next.getCurriculumType()) {

						nextStorey = TheoryRoomCollection.get(nextRoomIndex).getStorey();
						nextBuildingId = TheoryRoomCollection.get(nextRoomIndex).getBuildingId();

					} else {

						nextStorey = ExperimentRoomCollection.get(nextRoomIndex).getStorey();
						nextBuildingId = ExperimentRoomCollection.get(nextRoomIndex).getBuildingId();

					}

					if (frontBuildingId == nextBuildingId) {
						// 同一栋楼

						buildingSatisfaction = 1;
						storeySatisfaction = StoreySatisfaction.get(Math.abs(frontStorey - nextStorey));

					} else {

						Map<Integer, Double> map = BuildingSatisfactionMap.get(frontBuildingId);

						if (map != null) {

							buildingSatisfaction = map.get(nextBuildingId);
							storeySatisfaction = StoreySatisfaction.get(frontStorey + nextStorey);

						} else {

							buildingSatisfaction = 0;
							storeySatisfaction = 0;

						}

					}

				} else {

					buildingSatisfaction = 1;
					storeySatisfaction = 1;

				}

				spaceSatisfaction += buildingSatisfaction * storeySatisfaction;

				front = next;

				frontTimeIndex = front.getTimeIndex();
				frontTimeDay = frontTimeIndex / 6;
			}

		}

		return spaceSatisfaction / (size - 1) ;

	}

	/**
	 * 计算课程的时间满意度
	 *
	 * @param curriculumUnitVO 排课单元 VO
	 *
	 * @param timeIndex 时间索引
	 *
	 * @return 课程时间满意度
	 */
	public static double caculateCurriculumTimeSatisfaction(CurriculumUnitVO curriculumUnitVO, int timeIndex) {

		if (!curriculumUnitVO.getCurriculumType()) {
			return PRACTICE_SATISFACTION[timeIndex % Constant.TIMT_DAY];
		}

		Course course = curriculumUnitVO.getCurriculumUnit().getCourse();

		if (course.getCategory() == Course.CATEGORY_BASIC) {
			return BASE_SATISFACTION[timeIndex % Constant.TIMT_DAY];
		}

		if (course.getCategory() == Course.CATEGORY_PRACTICE) {
			return PRACTICE_SATISFACTION[timeIndex % Constant.TIMT_DAY];
		}

		if (course.getCategory() == Course.CATEGORY_PROFESSIONAL) {
			return PROFESSIONAL_SATISFACTION[timeIndex % Constant.TIMT_DAY];
		}

		return 0;

	}

	public static double caculateCurriculumSpaceSatisfaction(List<CurriculumVO> curriculumVOList) {

		int amount = 0;
		double satisfaction = 0.0;

		for (CurriculumVO cu : curriculumVOList) {

			++amount;

			Map<Integer, Integer> map = new HashMap<Integer, Integer>();

			for (CurriculumUnitVO cuVO : cu.getCurriculumUnitVOList()) {

				if (cuVO.getCurriculumType()) {

					int roomIndex = cuVO.getRoomIndex();
					Integer num = map.get(roomIndex);

					// 统计教室次数
					if (num == null) {
						map.put(roomIndex, 1);
					} else {
						map.put(roomIndex, num + 1);
					}

				}

			}

			if (!map.isEmpty()) {

				Iterator<Integer> iterator = map.values().iterator();
				int oneNum = 0;
				int total = 0;

				while (iterator.hasNext()) {

					int num = iterator.next();
					total += num;

					if (num == 1) {
						++oneNum;
					}

				}

				if (total != 0) {
					double temp = 1 - (double)oneNum / total;
					temp = temp <= 0 ? 1 : temp;
					satisfaction += temp;
				}

			}

		}

		if (amount != 0) {
			return satisfaction /= amount;
		}

		return 0.0;

	}

}
<file_sep>/ACSS/src/main/webapp/WEB-INF/content/teacher/get_all_teacher.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="s" uri="/struts-tags"%>

查看教师信息

				<select class="form-control" id="select_college_name"
					onchange="getAllTeacherByCollege()">
					<option value='0'>全部</option>
					<s:iterator id="college" value="#request.collegeList">
						<option value='<s:property value="#college.id"/>'>
							<s:property value="#college.name" />
						</option>
					</s:iterator>
				</select>

				<select class="form-control" id="select_department_name" onchange="getAllTeacherByDepartment()">
					<option value='0'>全部</option>
					<s:iterator id="department" value="#request.departmentList">
						<option value='<s:property value="#department.id"/>'>
							<s:property value="#department.name" />
						</option>
					</s:iterator>
				</select>

				<s:include value="get_all_teacher_by.jsp"></s:include>

<file_sep>/ACSS/src/main/webapp/js/main.js
/**
 * 主界面相关的 js 操作
 */

$(document).ready(function () {

	$(document).keyup(function (event) {
		if (event.keyCode == '13') {
			$("#defaultEnterSubmit").click();
		}
	});

});

function alertInfo(info, type) {
	$("#alertInfo").append('
'
			+ '<button type="button" class="close" data-dismiss="alert" aria-label="Close">×</button>'
			+ info
			+ '
');

	setTimeout(function() {
		$("#alertInfo").children().remove();
	}, 2000);

}

function loadHTML(action, parament, id) {
	if (id == undefined) {
		id = "#content";
	}
	$(id).load(action, parament, function() {
		var $form = $("#form");
		if($form.length > 0) {
			$("#form").bootstrapValidator().on('success.form.bv', function(e) {
		        e.preventDefault();
		        var $form = $(e.target);
		        var bv = $form.data('bootstrapValidator');
		        var fun = $form.attr("action");
		        eval(fun);
		    });
		}
	});
	return false;
}

function addCollegeResult() {
	$.post("teacher/add_college_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("添加成功", "success");
				} else {
					alertInfo("添加失败，已存在同名学院", "danger");
				}
	});
}

function updateCollegeResult() {
	$.post("teacher/update_college_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("修改成功", "success");
					loadHTML("teacher/get_all_college");
				} else {
					alertInfo("修改失败，已存在同名学院", "danger");
				}
	});
}

function delCollegeResult(id) {
	if (confirm("确定删除学院")) {
		$.post("teacher/del_college_result",
				{
					college_id : id
				},
				function(data, status) {
					if (data == true) {
						alertInfo("删除成功", "success");
						loadHTML("teacher/get_all_college");
					} else {
						alertInfo("删除失败", "danger");
					}
		});
	}
}

function addDepartmentResult() {
	$.post("teacher/add_department_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("添加成功", "success");
				} else {
					alertInfo("添加失败，已存在同名系别", "danger");
				}
	});
}

function updateDepartmentResult() {
	$.post("teacher/update_department_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("修改成功", "success");
					loadHTML("teacher/get_all_department");
				} else {
					alertInfo("修改失败，已存在同名系别", "danger");
				}
	});
}

function delDepartmentResult(id) {
	if (confirm("确定删除系别")) {
		$.post("teacher/del_department_result",
				{
					department_id : id
				},
				function(data, status) {
					if (data == true) {
						alertInfo("删除成功", "success");
						loadHTML("teacher/get_all_department");
					} else {
						alertInfo("删除失败", "danger");
					}
		});
	}
}

function getDepartmentJsonByCollege() {

	var collegeId = $("#select_college_name option:selected").val();

	$.post("teacher/get_all_department_json_by_college",
			{
				college_id : collegeId
			},
			function(data, status) {

				var $departmentSelect = $("#select_department_name");
				$departmentSelect.children().remove(); // 清空孩子节点

				for(var i = 0; i < data.length; ++i) {
					$departmentSelect.append("<option value=" + data[i].id + ">" + data[i].name + "</option>")
				}
			});
}

function getAllDepartmentByCollege() {

	var collegeId = $("#select_college_name option:selected").val();
	$.post("teacher/get_all_department_by_college",
			{
				college_id : collegeId
			},
			function(data, status) {
				$("#departmentTable").children().remove();
				$("#departmentTable").append(data);
			});

}

function getJsonByDepartment(isTeacherTable) {

	var departmentId = $("#select_department_name option:selected").val();

	if (isTeacherTable) {

		$.post("teacher/get_all_teacher_json_by_department",
				{
					department_id : departmentId
				},
				function(data, status) {

					var $teacherSelect = $("#select_teacher_name");
					$teacherSelect.children().remove(); // 清空孩子节点

					for(var i = 0; i < data.length; ++i) {
						$teacherSelect.append("<option value=" + data[i].id + ">" + data[i].name +"(" + data[i].identifie + ")</option>")
					}

				});

	} else {

		$.post("clazz/get_all_clazz_json_by_department",
				{
					department_id : departmentId
				},
				function(data, status) {

					var $clazzSelect = $("#select_clazz_name");
					$clazzSelect.children().remove(); // 清空孩子节点

					for(var i = 0; i < data.length; ++i) {
						$clazzSelect.append("<option value=" + data[i].id + ">" + data[i].name + "</option>")
					}

				});

	}

}

function addTeacherResult() {
	$.post("teacher/add_teacher_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("添加成功", "success");
				} else {
					alertInfo("添加失败，已存在相同教师编号", "danger");
				}
	});
}

function updateTeacherResult() {
	$.post("teacher/update_teacher_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("修改成功", "success");
					loadHTML("teacher/get_all_teacher");
				} else {
					alertInfo("修改失败", "danger");
				}
	});
}

function delTeacherResult(id) {
	if (confirm("确定删除教师")) {
		$.post("teacher/del_teacher_result",
				{
					teacher_id : id
				},
				function(data, status) {
					if (data == true) {
						alertInfo("删除成功", "success");
						loadHTML("teacher/get_all_teacher");
					} else {
						alertInfo("删除失败", "danger");
					}
		});
	}
}

function getAllTeacherByCollege() {

	var collegeId = $("#select_college_name option:selected").val();
	$.post("teacher/get_all_teacher_by_college",
			{
				college_id : collegeId
			},
			function(data, status) {
				$("#teacherTable").children().remove();
				$("#teacherTable").append(data);
			});
	$.post("teacher/get_all_department_json_by_college",
			{
				college_id : collegeId
			},
			function(data, status) {

				var $departmentSelect = $("#select_department_name");
				$departmentSelect.children().remove(); // 清空孩子节点

				$departmentSelect.append("<option value='0'>全部</option>");

				for(var i = 0; i < data.length; ++i) {
					$departmentSelect.append("<option value=" + data[i].id + ">" + data[i].name + "</option>");
				}
			});

}

function getAllTeacherByDepartment() {

	var departmentId = $("#select_department_name option:selected").val();
	var collegeId = $("#select_college_name option:selected").val();
	$.post("teacher/get_all_teacher_by_department",
			{
				college_id : collegeId,
				department_id : departmentId
			},
			function(data, status) {
				$("#teacherTable").children().remove();
				$("#teacherTable").append(data);
			});

}

function addBuildingResult() {
	$.post("room/add_building_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("添加成功", "success");
				} else {
					alertInfo("添加失败，已存在相同教学楼名", "danger");
				}
	});
}

function updateBuildingResult() {
	$.post("room/update_building_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("修改成功", "success");
					loadHTML("room/get_all_building");
				} else {
					alertInfo("修改失败", "danger");
				}
	});
}

function delBuildingResult(id) {
	if (confirm("确定删除教学楼")) {
		$.post("room/del_building_result",
				{
					building_id : id
				},
				function(data, status) {
					if (data == true) {
						alertInfo("删除成功", "success");
						loadHTML("room/get_all_building");
					} else {
						alertInfo("删除失败", "danger");
					}
		});
	}
}

function updateBuildingSatisfactionResult() {
	$.post("room/update_building_satisfaction_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("修改成功", "success");
					loadHTML("room/get_all_building_satisfaction");
				} else {
					alertInfo("修改失败", "danger");
				}
	});
}

function addClassroomResult() {
	$.post("room/add_classroom_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("添加成功", "success");
				} else {
					alertInfo("添加失败，已存在相同教室号", "danger");
				}
	});
}

function updateClassroomResult() {
	$.post("room/update_classroom_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("修改成功", "success");
					loadHTML("room/get_all_classroom");
				} else {
					alertInfo("修改失败，已存在相同教室号", "danger");
				}
	});
}

function delClassroomResult(id) {
	if (confirm("确定删除教室")) {
		$.post("room/del_classroom_result",
				{
					classroom_id : id
				},
				function(data, status) {
					if (data == true) {
						alertInfo("删除成功", "success");
						loadHTML("room/get_all_classroom");
					} else {
						alertInfo("删除失败", "danger");
					}
		});
	}
}

var clazzMergingIndex = -1;
var clazzMergingList;

function initClazzMerging() {
	$.ajax({
		type : 'POST',
		url : "clazz/get_all_clazz_by_json",
		success : function(data) {
			clazzMergingList = data;
		}
	});
}

function addClazzMerging() {
	var $clazzMerging = $("#clazz_merging");
	var clazzMergingHtml = '
'
						+		'合班班级'
						+		'
'
						+			'<select class="form-control" id="select_clazz_merging_' + clazzMergingIndex + '" name="clazz_ids">'
						;

	for (var i = 0; i < clazzMergingList.length; ++i) {
		clazzMergingHtml += '<option value="' + clazzMergingList[i].id + '">' + clazzMergingList[i].name + '</option>';
	}

	clazzMergingHtml	+=			'</select>'
						+		'
'
						+		'删除'
						+	'
'
						;
	$clazzMerging.append(clazzMergingHtml);
	--clazzMergingIndex;
}

function deleteClazzMerging(index) {
	var $clazzMerging = $("#clazz_merging_" + index);
	$clazzMerging.remove();
}

function addClazzResult() {
	$.post("clazz/add_clazz_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("添加成功", "success");
				} else {
					alertInfo("添加失败，已存在相同班级名称", "danger");
				}
	});
}

function updateClazzResult() {
	$.post("clazz/update_clazz_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("修改成功", "success");
					loadHTML("clazz/get_all_clazz");
				} else {
					alertInfo("修改失败，已存在相同班级名称", "danger");
				}
	});
}

function delClazzResult(id) {
	if (confirm("确定删除班级")) {
		$.post("clazz/del_clazz_result",
				{
					clazz_id : id
				},
				function(data, status) {
					if (data == true) {
						alertInfo("删除成功", "success");
						loadHTML("clazz/get_all_clazz");
					} else {
						alertInfo("删除失败", "danger");
					}
		});
	}
}

function addCourseResult() {
	$.post("teach/add_course_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("添加成功", "success");
				} else {
					alertInfo("添加失败，已存在相同名称或代码", "danger");
				}
	});
}

function updateCourseResult() {
	$.post("teach/update_course_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("修改成功", "success");
					loadHTML("teach/get_all_course");
				} else {
					alertInfo("修改失败，已存在相同名称或代码", "danger");
				}
	});
}

function delCourseResult(id) {
	if (confirm("确定删除课程")) {
		$.post("teach/del_course_result",
				{
					course_id : id
				},
				function(data, status) {
					if (data == true) {
						alertInfo("删除成功", "success");
						loadHTML("teach/get_all_course");
					} else {
						alertInfo("删除失败", "danger");
					}
		});
	}
}

function addCurriculumUnitResult() {
	$.post("teach/add_curriculum_unit_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("添加成功", "success");
				} else {
					alertInfo("添加失败，已存在相同任课代码", "danger");
				}
	});
}

function updateCurriculumUnitResult() {
	$.post("teach/update_curriculum_unit_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("修改成功", "success");
					loadHTML("teach/get_all_curriculum_unit");
				} else {
					alertInfo("修改失败，已存在相同任课代码", "danger");
				}
	});
}

function delCurriculumUnitResult(id) {
	if (confirm("确定删除任课")) {
		$.post("teach/del_curriculum_unit_result",
				{
					curriculum_unit_id : id
				},
				function(data, status) {
					if (data == true) {
						alertInfo("删除成功", "success");
						loadHTML("teach/get_all_curriculum_unit");
					} else {
						alertInfo("删除失败", "danger");
					}
		});
	}
}

function changePasswordResult() {
	$.post("properties/change_password_result",
			{
				oldPassword : $.md5($("#input_old_password").val()),
				newPassword1 : $.md5($("#input_new_password1").val()),
				newPassword2 : $.md5($("#input_new_password2").val())
			},
			function(data, status) {
				if (data == true) {
					alertInfo("修改密码成功", "success");
				} else {
					alertInfo("修改密码失败，请检查旧密码是否正确", "danger");
				}
	});
}

function changePropertiesResult() {
	$.post("properties/change_properties_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("修改成功", "success");
					loadHTML("properties/change_properties");
				} else {
					alertInfo("修改失败", "danger");
				}
	});
}

function addExperimentAndRoomResult() {
	$.post("scheduling/add_experiment_and_room_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("添加成功", "success");
				} else {
					alertInfo("添加失败，已存在相同任课代码", "danger");
				}
	});
}

function updateExperimentAndRoomResult() {
	$.post("scheduling/update_experiment_and_room_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("修改成功", "success");
					loadHTML("scheduling/get_all_experiment_and_room");
				} else {
					alertInfo("修改失败，已存在相同任课代码", "danger");
				}
	});
}

function delExperimentAndRoomResult(id) {
	if (confirm("确定删除任课")) {
		$.post("scheduling/del_experiment_and_room_result",
				{
					experiment_and_room_id : id
				},
				function(data, status) {
					if (data == true) {
						alertInfo("删除成功", "success");
						loadHTML("scheduling/get_all_experiment_and_room");
					} else {
						alertInfo("删除失败", "danger");
					}
		});
	}
}

function addManualTimetableResult() {
	$.post("scheduling/add_manual_timetable_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("添加成功", "success");
				} else {
					alertInfo("添加失败，有冲突", "danger");
				}
	});
}

function updateManualTimetableResult() {
	$.post("scheduling/update_manual_timetable_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("修改成功", "success");
					loadHTML("scheduling/get_all_manual_timetable");
				} else {
					alertInfo("修改失败，有冲突", "danger");
				}
	});
}

function delManualTimetableResult(id) {
	if (confirm("确定删除手动排课信息")) {
		$.post("scheduling/del_manual_timetable_result",
				{
					manual_timetable_id : id
				},
				function(data, status) {
					if (data) {
						alertInfo("删除成功", "success");
						loadHTML("scheduling/get_all_manual_timetable");
					} else {
						alertInfo("删除失败", "danger");
					}
		});
	}
}

function addCannotSetCurriculumResult() {
	$.post("scheduling/add_cannot_set_curriculum_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("添加成功", "success");
				} else {
					alertInfo("添加失败", "danger");
				}
			});
}

function updateCannotSetCurriculumResult() {
	$.post("scheduling/update_cannot_set_curriculum_result",
			$('#form').serialize(),
			function(data, status) {
				if (data == true) {
					alertInfo("修改成功", "success");
					loadHTML("scheduling/get_all_cannot_set_curriculum");
				} else {
					alertInfo("修改失败", "danger");
				}
			});
}

function delCannotSetCurriculumResult(id) {
	if (confirm("确定删除不排课时间")) {
		$.post("scheduling/del_cannot_set_curriculum_result",
				{
					cannot_set_curriculum_id : id
				},
				function(data, status) {
					if (data) {
						alertInfo("删除成功", "success");
						loadHTML("scheduling/get_all_cannot_set_curriculum");
					} else {
						alertInfo("删除失败", "danger");
					}
				});
	}
}

function doAutoScheduling() {

	$.post("scheduling/do_auto_scheduling",
			$('#form').serialize(),
			function(data, status) {
				setTimeout(function() {
					loadHTML("scheduling/get_auto_scheduling");
				}, 2000);
			});
}

function getTermByYear() {

	var year = $("#select_year option:selected").val();

	$.post("scheduling/get_term_by_year",
			{
				year : year
			},
			function(data, status) {

				var $termSelect = $("#select_term");
				$termSelect.children().remove(); // 清空孩子节点

				for(var i = 0; i < data.length; ++i) {
					$termSelect.append("<option value=" + data[i] + ">" + data[i] + "</option>");
				}

			});

}

function getTableBy(isTeacherTable) {

	if (isTeacherTable) {

		$.post("scheduling/get_teacher_table_by",
				$('#form').serialize(),
				function(data, status) {

					var $timetable = $("#timetable");
					$timetable.children().remove(); // 清空孩子节点

					$timetable.append(data);

				});

	} else {

		$.post("scheduling/get_clazz_table_by",
				$('#form').serialize(),
				function(data, status) {

					var $timetable = $("#timetable");
					$timetable.children().remove(); // 清空孩子节点

					$timetable.append(data);

				});

	}

}

function getChartData() {

	$.post("scheduling/get_chart_data",
			null,
			function(data, status) {

				var $chart = $("#chart");
				$chart.children().remove(); // 清空孩子节点

				var ctx;
				for (var i = 0; i < data.length; ++i) {

					$chart.append('
'
							+			'
'
							+ 				'<canvas class="col-xs-12" id="chart' + i + '"' + ' height="150"></canvas>'
							+			'
'
							+		'
'
							+		'
'
							+			'
'
							+				'
种群'+ (i + 1) + '
'
							+			'
'
							+		'
'
							+		'
');

					var array = new Array();
					var multiple = data[i].length / 10;
					var multiplier = 0;
					var length = data[i].length - 1;
					for (var j = 0; j < length; ++j) {
						if (j == multiplier * multiple) {
							array.push(j);
							++multiplier;
						} else {
							array.push("");
						}
					}
					array.push(data[i].length);
					var lineChartData = {
							labels : array,
							datasets : [
								{
									fillColor : "rgba(151,187,205,0.5)",
									strokeColor : "rgba(151,187,205,1)",
									pointColor : "rgba(151,187,205,1)",
									pointStrokeColor : "#fff",
									data : data[i]
								}
							]

						}

					var myLine = new Chart(document.getElementById("chart" + i).getContext("2d")).Line(lineChartData,{
						scaleStartValue : 0,
						scaleShowGridLines : false,
						pointDot : false,
						bezierCurve : false,
						animation : false
					});

				}

			});

}

function loadScheduiling() {
	var $scheduing = $("#scheduing");
	if($scheduing.length > 0) {
		loadHTML("scheduling/get_auto_scheduling");
	}
}

<file_sep>/ACSS/src/main/java/com/zsc/net11/actions/MainAction.java
package com.zsc.net11.actions;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import com.zsc.net11.base.BaseActionSupport;

/**
 * @author 黄伟枞
 */
@ParentPackage("base")
public class MainAction extends BaseActionSupport {

	private static final long serialVersionUID = 2110472044590332972L;

	@Action(value = "main", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/main.jsp") })
	public String doMain() throws Exception {
		return SUCCESS;
	}

}
<file_sep>/ACSS/src/main/webapp/WEB-INF/content/clazz/update_clazz.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="s" uri="/struts-tags"%>

		返回
		修改班级信息

		<form id="form" class="form-horizontal col-xs-offset-2 margin-top">
			<input name="id" value="<s:property value='#request.clazz.id'/>" hidden="hidden">

					学院名称

					<select class="form-control" id="select_college_name" name="college_id"
						onchange='getDepartmentJsonByCollege()'>
						<s:iterator id="college" value="#request.collegeList">
							<s:if test="#college.id == #request.clazz.department.college.id">
								<option selected="selected" value='<s:property value="#college.id"/>'>
									<s:property value="#college.name" />
								</option>
							</s:if>
							<s:else>
								<option value='<s:property value="#college.id"/>'>
									<s:property value="#college.name" />
								</option>
							</s:else>
						</s:iterator>
					</select>

					系别名称

					<select class="form-control" id="select_department_name" name="department_id"
						required data-bv-trigger="blur" data-bv-notempty-message="系别不能为空" >
						<s:iterator id="department" value="#request.departmentList">
							<s:if test="#department.id == #request.clazz.department.id">
								<option selected="selected" value='<s:property value="#department.id"/>'>
									<s:property value="#department.name" />
								</option>
							</s:if>
							<s:else>
								<option value='<s:property value="#department.id"/>'>
									<s:property value="#department.name" />
								</option>
							</s:else>
						</s:iterator>
					</select>

					班级名称

					<input type="text" class="form-control" id="input_clazz_name"
						name="name" placeholder="班级名称" value='<s:property value="#request.clazz.name"/>'
						disabled="disabled" />

					人数

					<input type="number" class="form-control" id="input_clazz_population"
						name="population" min="0"  value='<s:property value="#request.clazz.population"/>'
						data-bv-greaterthan-inclusive="false" data-bv-greaterthan-message="必须大于0" />

					添加合班班级

				<s:iterator id="clazzMerging" value="#request.clazz.clazzList" status="calzzIndex">
					<div class="form-group" id='clazz_merging_<s:property value="#calzzIndex.index" />'>
						<label for='select_clazz_merging_<s:property value="#calzzIndex.index" />'class="col-xs-3 control-label">
							合班班级

							<select class="form-control" id='select_clazz_merging_<s:property value="#calzzIndex.index" />'
								name="clazz_ids">
								<s:iterator id="clazz" value="#request.clazzJsonList">
									<s:if test="#clazz.id == #clazzMerging.id">
										<option selected="selected" value='<s:property value="#clazz.id"/>'>
											<s:property value="#clazz.name" />
										</option>
									</s:if>
									<s:else>
										<option value='<s:property value="#clazz.id"/>'>
											<s:property value="#clazz.name" />
										</option>
									</s:else>
								</s:iterator>
							</select>

						<a href="javascript:void(0)"
							onclick="deleteClazzMerging(<s:property value="#calzzIndex.index" />)">
							删除

				</s:iterator>

				<button id="defaultEnterSubmit" type="button"
					class="btn btn-primary col-xs-offset-3 col-xs-2"
					onclick="updateClazzResult()">
					修改
				</button>

		</form>

<file_sep>/ACSS/src/main/java/com/zsc/net11/algorithm/vo/ClazzVO.java
package com.zsc.net11.algorithm.vo;

import java.io.Serializable;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

import com.zsc.net11.entity.Clazz;
import com.zsc.net11.util.algorithm.CaculateSatisfaction;

/**
 * 班级，用于算法计算的值对象
 *
 * @author 黄伟枞
 */
public class ClazzVO implements Serializable{

	private static final long serialVersionUID = -508424685777096632L;

	/** 排课单元值对象 */
	private List<CurriculumUnitVO> curriculumUnitVOList;

	/** 合班的班级 */
	private List<ClazzVO> clazzVOList;

	/** 班级 */
	private Clazz clazz;

	/** 时间满意度 */
	private double timeSatisfaction;

	/** 空间满意度 */
	private double spaceSatisfaction;

	// //////////////////////////////////////////////////Begin Constructor

	public ClazzVO() {
		curriculumUnitVOList = new LinkedList<CurriculumUnitVO>();
		clazzVOList = new LinkedList<ClazzVO>();
	}

	/**
	 * @param curriculumUnitVO
	 *            排课单元值对象
	 * @param clazz
	 *            班级
	 */
	public ClazzVO(Clazz clazz) {
		curriculumUnitVOList = new LinkedList<CurriculumUnitVO>();
		clazzVOList = new LinkedList<ClazzVO>();
		this.clazz = clazz;
	}

	// //////////////////////////////////////////////////End Constructor

	// //////////////////////////////////////////////////Begin Getter Setter

	/**
	 * 获取班级
	 *
	 * @return 班级
	 */
	public Clazz getClazz() {
		return clazz;
	}

	/**
	 * 获取时间满意度
	 *
	 * @return 时间满意度
	 */
	public double getTimeSatisfaction() {
		return timeSatisfaction;
	}

	/**
	 * 获取空间满意度
	 *
	 * @return 空间满意度
	 */
	public double getSpaceSatisfaction() {
		return spaceSatisfaction;
	}

	/**
	 * 获取此班级的排课单元
	 *
	 * @return 此班级的排课单元
	 */
	public List<CurriculumUnitVO> getCurriculumUnitVOList() {
		return this.curriculumUnitVOList;
	}

	/**
	 * 获取合班的详细班级
	 *
	 * @return 合班班级列表，不是合班的为空列表
	 */
	public List<ClazzVO> getClazzVOList() {
		return clazzVOList;
	}

	// //////////////////////////////////////////////////End Getter Setter

	/**
	 * 添加排课单元值对象
	 *
	 * @param curriculumUnitVO
	 *            排课单元值对象
	 */
	public ClazzVO addCurriculumUnitVO(CurriculumUnitVO curriculumUnitVO) {
		curriculumUnitVOList.add(curriculumUnitVO);
		return this;
	}

	/**
	 * 添加合班的组成班级
	 *
	 * @param clazzVO 合班的组成班级
	 *
	 * @return 班级
	 */
	public ClazzVO addClazzVO(ClazzVO clazzVO) {
		this.clazzVOList.add(clazzVO);
		return this;
	}

//	/**
//	 * 判断上课时间是否冲突
//	 *
//	 * @param timeIndex
//	 *            时间索引
//	 *
//	 * @return 冲突则返回true

//	 *         不冲突则返回false
//	 */
//	public boolean isTimeConflict(byte timeIndex) {
//		for (CurriculumUnitVO curriculumUnitVO : curriculumUnitVOList) {
//			if (curriculumUnitVO.getTimeIndex() == timeIndex) {
//				return true;
//			}
//		}
//		return false;
//	}

	/**
	 * 计算时间满意度、空间满意度
	 */
	public ClazzVO calculate() {

		Collections.sort(this.curriculumUnitVOList);
		this.timeSatisfaction = CaculateSatisfaction.caculateTimeSatisfaction(this.curriculumUnitVOList);
		this.spaceSatisfaction = CaculateSatisfaction.caculateSpaceSatisfaction(this.curriculumUnitVOList);

		return this;
	}

}
<file_sep>/ACSS/src/main/webapp/WEB-INF/content/teach/get_all_course.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="s" uri="/struts-tags"%>

查看课程信息

		 			课程代码
		 			课程名
		 			课程性质
		 			课程类别
		 			修改
		 			删除

		 		<s:iterator id="course" value="#request.courseList">

		 				<s:property value="#course.identifie" />
		 				<s:property value="#course.name" />

		 					<s:if test="#request.course.property > 0">
								必修
							</s:if>
							<s:elseif test="#request.course.property < 0">
								选修
							</s:elseif>
							<s:else >
								限选
							</s:else>

		 					<s:if test="#request.course.category > 0">
								专业课
							</s:if>
							<s:elseif test="#request.course.category < 0">
								基础课
							</s:elseif>
							<s:else>
								实践课
							</s:else>

		 					<a href='javascript:void(0)'
		 						onclick='loadHTML("teach/update_course", {course_id:<s:property value="#course.id"/>})'>
		 						修改

							<a href='javascript:void(0)'
								onclick='delCourseResult(<s:property value="#course.id"/>)'>
								删除

		 		</s:iterator>

<file_sep>/ACSS/src/main/java/com/zsc/net11/service/impl/CourseServiceImpl.java
package com.zsc.net11.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zsc.net11.dao.CourseDao;
import com.zsc.net11.entity.Course;
import com.zsc.net11.service.CourseService;

/**
 * 课程操作相关 Service 接口的实现
 *
 * @author 黄伟枞
 */
@Service("courseService")
public class CourseServiceImpl implements CourseService {

	@Resource
	private CourseDao courseDao;

	@Override
	public Integer save(Course course) {

		Course nameCourse = getByName(course.getName());
		Course identifieEntity = getByIdentifie(course.getIdentifie());

		if (nameCourse != null
				&& identifieEntity != null
				&& nameCourse.getId().equals(identifieEntity.getId())) {
			// 存在相同代码和名称，并且是同一个
			if (nameCourse.getDel()) {

				nameCourse.setDel(false)
						.setProperty(course.getProperty())
						.setCategory(course.getCategory());
				courseDao.update(nameCourse);
				return nameCourse.getId();

			}

		} else if (nameCourse == null && identifieEntity == null) {
			return (Integer) courseDao.save(course);
		}

		return null;
	}

	@Override
	public boolean delete(int id) {

		Course entity = getById(id);

		if (entity != null) {

			entity.setDel(true);
			courseDao.update(entity);
			return true;

		}

		return false;

	}

	@Override
	public boolean update(Course course) {

		Course entity = getById(course.getId());

		if (entity != null) {

			entity.setProperty(course.getProperty())
				.setCategory(course.getCategory());
			courseDao.update(entity);
			return true;

		}

		return false;
	}

	@Override
	public Course getByName(String name) {
		return (Course) courseDao.createQuery("from Course course where course.name = :name")
				.setString("name", name)
				.uniqueResult();
	}

	@Override
	public Course getByIdentifie(String identifie) {
		return (Course) courseDao.createQuery("from Course course where course.identifie = :identifie")
				.setString("identifie", identifie)
				.uniqueResult();
	}

	@Override
	public Course getById(int id) {
		return courseDao.get(id);
	}

	@Override
	public List<Course> getAll() {
		return courseDao.list("from Course course "
				+ " where course.del = false "
				+ " order by convert(course.name) asc ");
	}

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/base/BaseActionFormSupport.java
package com.zsc.net11.base;

import java.lang.reflect.ParameterizedType;

import com.opensymphony.xwork2.ModelDriven;

/**
 * Action表单 基类，封装了泛型参数get、set 方法；

 * 注入spring applicationContext 对象

 *
 * @author 黄伟枞
 */
public class BaseActionFormSupport<T> extends BaseActionSupport implements
		ModelDriven<T> {

	private static final long serialVersionUID = 2403169344807729109L;

	/** 声明的参数类 */
	protected T model;

	/** 构造参数对象 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public BaseActionFormSupport() {
		try {
			// 得到entity的类型信息
			ParameterizedType pt = (ParameterizedType) this.getClass()
					.getGenericSuperclass();
			Class clazz = (Class) pt.getActualTypeArguments()[0];

			// 通过反射生成entity的实例
			model = (T) clazz.newInstance();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 设置表单对象
	 *
	 * @param model
	 *            表单对象
	 */
	public void setModel(T model) {
		this.model = model;
	}

	/**
	 *  将泛型参数类映射为Struts的默认参数包装对象
	 *  @return 封装的表单对象
	 */
	@Override
	public T getModel() {
		return model;
	}

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/service/CourseService.java
package com.zsc.net11.service;

import java.util.List;

import com.zsc.net11.entity.Course;

/**
 * 课程操作相关 Service 接口
 *
 * @author 黄伟枞
 */
public interface CourseService {

	/**
	 * 保存课程信息
	 *
	 * @param course 课程实体类
	 *
	 * @return 课程 ID; null 表示存在相同课程代码；
	 */
	public Integer save(Course course);

	/**
	 * 根据课程 ID 删除课程记录
	 *
	 * @param id 课程 ID
	 *
	 * @return true 表示删除成功； false 表示删除失败
	 */
	public boolean delete(int id);

	/**
	 * 更新课程信息
	 *
	 * @param course 课程实体类
	 *
	 * @return true 表示更新成功； false 表示更新失败
	 */
	public boolean update(Course course);

	/**
	 * 根据课程名称获取课程信息
	 *
	 * @param name 课程名称
	 *
	 * @return 课程信息
	 */
	public Course getByName(String name);

	/**
	 * 根据课程代码获取课程信息
	 *
	 * @param identifie 课程代码
	 *
	 * @return 课程实体类
	 */
	public Course getByIdentifie(String identifie);

	/**
	 * 根据课程 ID 获取课程信息
	 *
	 * @param id 课程 ID
	 *
	 * @return 课程信息
	 */
	public Course getById(int id);

	/**
	 * 获取所有的课程信息
	 *
	 * @return 所有的课程记录，除了被删除的
	 */
	public List<Course> getAll();

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/actions/room/ClassroomAction.java
package com.zsc.net11.actions.room;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import com.zsc.net11.base.BaseActionFormSupport;
import com.zsc.net11.entity.Building;
import com.zsc.net11.entity.Classroom;
import com.zsc.net11.service.BuildingService;
import com.zsc.net11.service.ClassroomService;

/**
 * 教室相关 Action
 *
 * @author 黄伟枞
 */
@ParentPackage("base")
public class ClassroomAction extends BaseActionFormSupport<Classroom> {

	private static final long serialVersionUID = -1993034188692081888L;

	@Resource
	private ClassroomService classroomService;

	@Resource
	private BuildingService buildingService;

	/**
	 * 添加教室信息
	 */
	@Action(value = "add_classroom", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/room/add_classroom.jsp") })
	public String addClassroom() throws Exception {

		List<Building> buildingList = buildingService.getAll();
		request.setAttribute("buildingList", buildingList);

		return SUCCESS;

	}

	/**
	 * 添加教室信息结果
	 */
	@Action(value = "add_classroom_result", results = { @Result(name = SUCCESS, type="json", params = {"root", "result"}) })
	public String addClassroomResult() throws Exception {

		Integer buildingId = Integer.parseInt(request.getParameter("building_id"));
		Building building = buildingService.getById(buildingId);

		if (building != null) {

			getModel().setBuilding(building);
			Integer classroomId = classroomService.save(getModel());

			if (classroomId != null) {
				result = true;
			}

			return SUCCESS;

		}

		result = false;
		return SUCCESS;

	}

	/**
	 * 查看教室信息
	 */
	@Action(value = "get_all_classroom", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/room/get_all_classroom.jsp") })
	public String getAllClassroom() throws Exception {

		List<Classroom> classroomList = classroomService.getAll();
		request.setAttribute("classroomList", classroomList);
		return SUCCESS;

	}

	/**
	 * 更新教室信息
	 */
	@Action(value = "update_classroom", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/room/update_classroom.jsp") })
	public String updateClassroom() throws Exception {

		Integer classroomId = Integer.valueOf(request.getParameter("classroom_id"));
		Classroom classroom = classroomService.getById(classroomId);

		if (classroom != null) {

			List<Building> buildingList = buildingService.getAll();

			request.setAttribute("classroom", classroom);
			request.setAttribute("buildingList", buildingList);
			return SUCCESS;

		}

		return ERROR;
	}

	/**
	 * 更新教室信息结果
	 */
	@Action(value = "update_classroom_result", results = { @Result(name = SUCCESS, type="json", params = {"root", "result"}) })
	public String updateClassroomResult() throws Exception {

		Integer buildingId = Integer.valueOf(request.getParameter("building_id"));
		Building building = buildingService.getById(buildingId);

		if (building != null) {

			getModel().setBuilding(building);
			result = classroomService.update(getModel());

			return SUCCESS;

		}

		result = false;
		return SUCCESS;

	}

	/**
	 * 删除教室信息结果
	 */
	@Action(value = "del_classroom_result", results = { @Result(name = SUCCESS, type="json", params = {"root", "result"}) })
	public String delClassroomResult() throws Exception {

		Integer classroomId = Integer.valueOf(request.getParameter("classroom_id"));

		result = classroomService.delete(classroomId);

		return SUCCESS;

	}

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/dao/BuildingDao.java
package com.zsc.net11.dao;

import com.zsc.net11.base.BaseDao;
import com.zsc.net11.entity.Building;

/**
 * 建筑物表 Dao
 *
 * @author 黄伟枞
 */
public interface BuildingDao extends BaseDao<Building> {

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/actions/scheduling/TimetableAction.java
package com.zsc.net11.actions.scheduling;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import com.zsc.net11.algorithm.Population;
import com.zsc.net11.algorithm.Species;
import com.zsc.net11.base.BaseActionSupport;
import com.zsc.net11.entity.College;
import com.zsc.net11.entity.Timetable;
import com.zsc.net11.json.ClazzJson;
import com.zsc.net11.json.DepartmentJson;
import com.zsc.net11.json.TeacherJson;
import com.zsc.net11.service.BuildingSatisfactionService;
import com.zsc.net11.service.CannotSetCurriculumService;
import com.zsc.net11.service.ClassroomService;
import com.zsc.net11.service.ClazzService;
import com.zsc.net11.service.CollegeService;
import com.zsc.net11.service.CurriculumUnitService;
import com.zsc.net11.service.DepartmentService;
import com.zsc.net11.service.ExperimentAndRoomService;
import com.zsc.net11.service.ManualTimetableService;
import com.zsc.net11.service.PropertiesService;
import com.zsc.net11.service.TeacherService;
import com.zsc.net11.service.TimetableService;
import com.zsc.net11.util.Variable;
import com.zsc.net11.util.algorithm.Init;

/**
 * 自动排课 Action
 *
 * @author 黄伟枞
 */
@ParentPackage("base")
public class TimetableAction extends BaseActionSupport {

	private static final long serialVersionUID = 7048046802171694999L;

	@Resource
	private PropertiesService propertiesService;

	@Resource
	private BuildingSatisfactionService buildingSatisfactionService;

	@Resource
	private ClazzService clazzService;

	@Resource
	private ClassroomService classroomService;

	@Resource
	private ExperimentAndRoomService experimentAndRoomService;

	@Resource
	private CurriculumUnitService curriculumUnitService;

	@Resource
	private TeacherService teacherService;

	@Resource
	private CannotSetCurriculumService cannotSetCurriculumService;

	@Resource
	private ManualTimetableService manualTimetableService;

	@Resource
	private TimetableService timetableService;

	@Resource
	private CollegeService collegeService;

	@Resource
	private DepartmentService departmentService;

	/**
	 * 学期列表
	 */
	private List<Integer> termList;

	/**
	 * 历代最优满意度
	 */
	private List<List<Double>> satisfactionList;

	public List<Integer> getTermList() {
		return termList;
	}

	public void setTermList(List<Integer> termList) {
		this.termList = termList;
	}

	public List<List<Double>> getSatisfactionList() {
		return satisfactionList;
	}

	public void setSatisfactionList(List<List<Double>> satisfactionList) {
		this.satisfactionList = satisfactionList;
	}

	/**
	 * 获取自动排课页面
	 */
	@Action(value = "get_auto_scheduling", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/scheduling/get_auto_scheduling.jsp") })
	public String getAutoScheduling() throws Exception {

		int status = 0;
		if (Variable.getTheradRunNumber() > 0) {
			// 正在排课中

			List<Population> populationList = Species.getInstance().getPopulationList();
			request.setAttribute("populationList", populationList);

			status = 1;
		} else if (Variable.finish) {
			status = 2;
		}
		else {
			// 没在排课

			List<Integer> yearList = curriculumUnitService.getYear();
			request.setAttribute("yearList", yearList);

			if (!yearList.isEmpty()) {

				List<Integer> termList = curriculumUnitService.getTerm(yearList.get(yearList.size() - 1));
				request.setAttribute("termList", termList);

			}
			status = 0;
		}
		request.setAttribute("status", status);
		return SUCCESS;

	}

	/**
	 * 开始自动排课
	 */
	@Action(value = "do_auto_scheduling", results = { @Result(name = SUCCESS, type="json", params={"root", "result" }) })
	public String doAutoScheduling() throws Exception {

		result = false;

		if (!Species.getInstance().isRun()) {

			// 设置排课时间
			Integer year = Integer.parseInt(request.getParameter("year"));

			Integer term = Integer.parseInt(request.getParameter("term"));

			if (term != null) {
				Variable.term = term;
			} else {
				Variable.term = 0;
			}

			// 注入service
			Init.propertiesService = propertiesService;
			Init.buildingSatisfactionService = buildingSatisfactionService;
			Init.clazzService = clazzService;
			Init.classroomService = classroomService;
			Init.experimentAndRoomService = experimentAndRoomService;
			Init.curriculumUnitService = curriculumUnitService;
			Init.teacherService = teacherService;
			Init.cannotSetCurriculumService = cannotSetCurriculumService;
			Init.manualTimetableService = manualTimetableService;

			Variable.timetableService = timetableService;

			Variable.year = year;
			Variable.term = term;

			timetableService.deleteByYearAndTerm(year, term);

			Species.renew().start();

			result = true;
		}

		return SUCCESS;

	}

	/**
	 * 停止自动排课
	 */
	@Action(value = "stop_auto_scheduling", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/scheduling/get_auto_scheduling.jsp") })
	public String stopAutoScheduling() throws Exception {

		Species.getInstance().reset();

		List<Integer> yearList = curriculumUnitService.getYear();
		request.setAttribute("yearList", yearList);

		if (!yearList.isEmpty()) {

			List<Integer> termList = curriculumUnitService.getTerm(yearList.get(yearList.size() - 1));
			request.setAttribute("termList", termList);

		}

		request.setAttribute("status", 0);
		return SUCCESS;

	}

	/**
	 * 确认自动排课完成
	 */
	@Action(value = "confirm_auto_scheduling", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/scheduling/get_auto_scheduling.jsp") })
	public String confirmAutoScheduling() throws Exception {

		Variable.finish = false;

		List<Integer> yearList = curriculumUnitService.getYear();
		request.setAttribute("yearList", yearList);

		if (!yearList.isEmpty()) {

			List<Integer> termList = curriculumUnitService.getTerm(yearList.get(yearList.size() - 1));
			request.setAttribute("termList", termList);

		}

		request.setAttribute("status", 0);
		return SUCCESS;

	}

	/**
	 * 获取教师课表
	 */
	@Action(value = "get_teacher_table", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/scheduling/get_table.jsp") })
	public String getTeacherTable() throws Exception {

		Integer teacherId = 0;
		Integer year = 0;
		Integer term = 0;

		List<College> collegeList = collegeService.getAll();

		if (!collegeList.isEmpty()) {

			List<DepartmentJson> departmentJsonList = departmentService
					.getAllJsonByCollegeId(collegeList.get(0).getId());
			request.setAttribute("departmentJsonList", departmentJsonList);

			if (!departmentJsonList.isEmpty()) {

				List<TeacherJson> teacherJsonList = teacherService
						.getAllJsonByDeparimentId(departmentJsonList.get(0).getId());

				request.setAttribute("teacherJsonList", teacherJsonList);

				if (!teacherJsonList.isEmpty()) {
					teacherId = teacherJsonList.get(0).getId();
				}

			}

		}

		List<Integer> yearList = timetableService.getYear();

		if (!yearList.isEmpty()) {

			year = yearList.get(yearList.size() - 1);

			List<Integer> termList = timetableService.getTerm(year);
			request.setAttribute("termList", termList);

			if (!termList.isEmpty()) {
				term = termList.get(termList.size() - 1);
			}

		}

		List<Timetable> timeTableList = timetableService.getAllByTeacher(teacherId, year, term);
		request.setAttribute("timeTableList", timeTableList);

		request.setAttribute("collegeList", collegeList);
		request.setAttribute("yearList", yearList);
		request.setAttribute("isTeacherTable", true);

		return SUCCESS;

	}

	/**
	 * 获取教师某学年某学期课表
	 */
	@Action(value = "get_teacher_table_by", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/scheduling/get_table_by.jsp") })
	public String getTeacherTableBy() throws Exception {

		Integer teacherId = Integer.parseInt(request.getParameter("teacher_id"));
		Integer year = Integer.parseInt(request.getParameter("year"));
		Integer term = Integer.parseInt(request.getParameter("term"));

		List<Timetable> timeTableList = timetableService.getAllByTeacher(teacherId, year, term);
		request.setAttribute("timeTableList", timeTableList);

		return SUCCESS;

	}

	/**
	 * 获取班级课表
	 */
	@Action(value = "get_clazz_table", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/scheduling/get_table.jsp") })
	public String getClazzTable() throws Exception {

		Integer clazzId = 0;
		Integer year = 0;
		Integer term = 0;

		List<College> collegeList = collegeService.getAll();

		if (!collegeList.isEmpty()) {

			List<DepartmentJson> departmentJsonList = departmentService
					.getAllJsonByCollegeId(collegeList.get(0).getId());
			request.setAttribute("departmentJsonList", departmentJsonList);

			if (!departmentJsonList.isEmpty()) {

				List<ClazzJson> clazzJsonList = clazzService
						.getAllJsonSingleByDeparment(departmentJsonList.get(0).getId());

				request.setAttribute("clazzJsonList", clazzJsonList);

				if (!clazzJsonList.isEmpty()) {
					clazzId = clazzJsonList.get(0).getId();
				}

			}

		}

		List<Integer> yearList = timetableService.getYear();

		if (!yearList.isEmpty()) {

			year = yearList.get(yearList.size() - 1);

			List<Integer> termList = timetableService.getTerm(year);
			request.setAttribute("termList", termList);

			if (!termList.isEmpty()) {
				term = termList.get(termList.size() - 1);
			}

		}

		List<Timetable> timeTableList = timetableService.getAllByClazz(clazzId, year, term);
		request.setAttribute("timeTableList", timeTableList);

		request.setAttribute("collegeList", collegeList);
		request.setAttribute("yearList", yearList);
		request.setAttribute("isTeacherTable", false);

		return SUCCESS;

	}

	/**
	 * 获取班级某学年某学期课表
	 */
	@Action(value = "get_clazz_table_by", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/scheduling/get_table_by.jsp") })
	public String getClazzTableBy() throws Exception {

		Integer clazzId = Integer.parseInt(request.getParameter("clazz_id"));
		Integer year = Integer.parseInt(request.getParameter("year"));
		Integer term = Integer.parseInt(request.getParameter("term"));

		List<Timetable> timeTableList = timetableService.getAllByClazz(clazzId, year, term);
		request.setAttribute("timeTableList", timeTableList);

		return SUCCESS;

	}

	/**
	 * 根据学年获取学期列表
	 */
	@Action(value = "get_term_by_year", results = { @Result(name = SUCCESS, type = "json", params = {"root", "termList"}) })
	public String getTermByYear() throws Exception {

		Integer year = Integer.parseInt(request.getParameter("year"));

		termList = timetableService.getTerm(year);

		return SUCCESS;

	}

	/**
	 * 获取历代最优满意度列表
	 */
	@Action(value = "get_chart_data", results = { @Result(name = SUCCESS, type = "json", params = {"root", "satisfactionList"}) })
	public String getChartData() throws Exception {

		satisfactionList = Variable.getSatisfactionList();

		return SUCCESS;

	}

}
<file_sep>/ACSS/src/main/webapp/WEB-INF/content/teacher/add_department.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="s" uri="/struts-tags"%>

添加系别信息

		<form id="form" class="form-horizontal col-xs-offset-2 margin-top"
			method="post" action="addDepartmentResult()"
			data-bv-feedbackicons-valid="glyphicon glyphicon-ok"
			data-bv-feedbackicons-invalid="glyphicon glyphicon-remove"
			data-bv-feedbackicons-validating="glyphicon glyphicon-refresh">

					学院名称

					<select class="form-control" id="select_college_name" name="college_id">
						<s:iterator id="college" value="#request.collegeList">
							<option value='<s:property value="#college.id"/>'>
								<s:property value="#college.name" />
							</option>
						</s:iterator>
					</select>

					系别名称

					<input type="text" class="form-control" id="input_department_name"
						name="name" placeholder="系别名称"
						required data-bv-trigger="blur" data-bv-notempty-message="系别名称不能为空"  />

				<button id="defaultEnterSubmit" type="submit"
					class="btn btn-primary col-xs-offset-3 col-xs-2" >
					添加
				</button>

		</form>

<file_sep>/ACSS/src/main/java/com/zsc/net11/dao/PropertiesDao.java
package com.zsc.net11.dao;

import com.zsc.net11.base.BaseDao;
import com.zsc.net11.entity.Properties;

/**
 * 属性表 Dao
 *
 * @author 黄伟枞
 */
public interface PropertiesDao extends BaseDao<Properties> {

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/dao/impl/ClassroomDaoImpl.java
package com.zsc.net11.dao.impl;

import org.springframework.stereotype.Repository;

import com.zsc.net11.base.BaseDaoImpl;
import com.zsc.net11.dao.ClassroomDao;
import com.zsc.net11.entity.Classroom;

/**
 * 教室表 Dao 的实现
 *
 * @author 黄伟枞
 */
@Repository("classroomDao")
public class ClassroomDaoImpl extends BaseDaoImpl<Classroom> implements
		ClassroomDao {

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/actions/teacher/CollegeAction.java
package com.zsc.net11.actions.teacher;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import com.zsc.net11.base.BaseActionFormSupport;
import com.zsc.net11.entity.College;
import com.zsc.net11.service.CollegeService;

/**
 * 学院相关 Action
 *
 * @author 黄伟枞
 */
@ParentPackage("base")
public class CollegeAction extends BaseActionFormSupport<College> {

	private static final long serialVersionUID = -2740456319929920330L;

	@Resource
	private CollegeService collegeService;

	/**
	 * 添加学院信息
	 */
	@Action(value = "add_college", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/teacher/add_college.jsp") })
	public String addCollege() throws Exception {
		return SUCCESS;
	}

	/**
	 * 添加学院信息结果
	 */
	@Action(value = "add_college_result", results = { @Result(name = SUCCESS, type="json", params = {"root", "result"}) })
	public String addCollegeResult() throws Exception {

		Integer collegeId = collegeService.save(getModel());

		if (collegeId == null) {
			result = false;
		} else {
			result = true;
		}

		return SUCCESS;
	}

	/**
	 * 查看学院信息
	 */
	@Action(value = "get_all_college", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/teacher/get_all_college.jsp") })
	public String getAllCollege() throws Exception {

		List<College> collegeList = collegeService.getAll();
		request.setAttribute("collegeList", collegeList);
		return SUCCESS;

	}

	/**
	 * 更新学院信息
	 */
	@Action(value = "update_college", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/teacher/update_college.jsp") })
	public String updateCollege() throws Exception {

		Integer collegeId = Integer.valueOf(request.getParameter("college_id"));
		College college = collegeService.getById(collegeId);

		if (college != null) {

			request.setAttribute("college", college);
			return SUCCESS;

		}

		return ERROR;
	}

	/**
	 * 更新学院信息结果
	 */
	@Action(value = "update_college_result", results = { @Result(name = SUCCESS, type="json", params = {"root", "result"}) })
	public String updateCollegeResult() throws Exception {

		result = collegeService.update(getModel());

		return SUCCESS;

	}

	/**
	 * 删除学院信息结果
	 */
	@Action(value = "del_college_result", results = { @Result(name = SUCCESS, type="json", params = {"root", "result"}) })
	public String delCollegeResult() throws Exception {

		Integer collegeId = Integer.valueOf(request.getParameter("college_id"));

		result = collegeService.delete(collegeId);

		return SUCCESS;

	}

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/interceptor/AuthorityInterceptor.java
package com.zsc.net11.interceptor;

import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

/**
 * @author 黄伟枞
 */
public class AuthorityInterceptor extends AbstractInterceptor {

	private static final long serialVersionUID = -1367505789471693704L;

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		ActionContext context = invocation.getInvocationContext();
		Map<String, Object> session = context.getSession();
		if (session.get("username") != null) {
			return invocation.invoke();
		}
		return "login";
	}

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/service/BuildingService.java
package com.zsc.net11.service;

import java.util.List;

import com.zsc.net11.entity.Building;

/**
 * 教学楼操作相关 Service 接口
 *
 * @author 黄伟枞
 */
public interface BuildingService {

	/**
	 * 保存教学楼信息
	 *
	 * @param building 教学楼实体类
	 *
	 * @return 教学楼 ID; null 表示存在同名；
	 */
	public Integer save(Building building);

	/**
	 * 根据教学楼 ID 删除教学楼记录
	 *
	 * @param id 教学楼 ID
	 *
	 * @return true 表示删除成功； false 表示删除失败
	 */
	public boolean delete(int id);

	/**
	 * 更新教学楼信息
	 *
	 * @param building 教学楼实体类
	 *
	 * @return true 表示更新成功； false 表示更新失败
	 */
	public boolean update(Building building);

	/**
	 * 根据教学楼名获取学院信息
	 *
	 * @param name 教学楼名
	 *
	 * @return 教学楼实体类
	 */
	public Building getByName(String name);

	/**
	 * 根据教学楼 ID 获取教学楼信息
	 *
	 * @param id 教学楼 ID
	 *
	 * @return 教学楼信息
	 */
	public Building getById(int id);

	/**
	 * 获取所有的教学楼信息
	 *
	 * @return 所有的教学楼记录，除了被删除的
	 */
	public List<Building> getAll();

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/service/impl/TimetableServiceImpl.java
package com.zsc.net11.service.impl;

import java.util.LinkedList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zsc.net11.dao.TimetableDao;
import com.zsc.net11.entity.Timetable;
import com.zsc.net11.service.TimetableService;

/**
 * 课表操作相关 Service 接口的实现
 *
 * @author 黄伟枞
 */
@Service("timetableService")
public class TimetableServiceImpl implements TimetableService {

	@Resource
	private TimetableDao timetableDao;

	@Override
	public Integer save(Timetable timetable) {
		return (Integer) timetableDao.save(timetable);
	}

	@Override
	public boolean deleteByYearAndTerm(Integer year, Integer term) {

		int number = timetableDao.createQuery("delete Timetable timetable "
				+ " where timetable.year = :year "
				+ " and timetable.term = :term ")
				.setInteger("year", year)
				.setInteger("term", term)
				.executeUpdate();

		if (number != 0) {
			return true;
		}

		return false;

	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Timetable> getAllByTeacher(Integer teacherId, Integer year,
			Integer term) {
		return timetableDao.createQuery("from Timetable timetable "
				+ " where timetable.teacher.id = :teacherId "
				+ " and timetable.year = :year "
				+ " and timetable.term = :term "
				+ " order by timetable.timeIndex asc, "
				+ " timetable.beginWeek asc ")
				.setInteger("teacherId", teacherId)
				.setInteger("year", year)
				.setInteger("term", term)
				.list();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Timetable> getAllByClazz(Integer clazzId, Integer year,
			Integer term) {
		return timetableDao.createQuery("from Timetable timetable "
				+ " where timetable.clazz.id = :clazzId "
				+ " and timetable.year = :year "
				+ " and timetable.term = :term "
				+ " order by timetable.timeIndex asc, "
				+ " timetable.beginWeek asc ")
				.setInteger("clazzId", clazzId)
				.setInteger("year", year)
				.setInteger("term", term)
				.list();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Integer> getYear() {

		List<Object> list = timetableDao.createSqlQuery("select F_YEAR from TB_TIMETABLE "
				+ " group by F_YEAR "
				+ " order by F_YEAR ")
				.list();

		List<Integer> yearList = new LinkedList<Integer>();

		for (Object object : list) {
			yearList.add((Integer)object);
		}

		return yearList;

	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Integer> getTerm(Integer year) {

		List<Object> list = timetableDao.createSqlQuery("select F_TERM from TB_TIMETABLE "
				+ " where F_YEAR = :year "
				+ " group by F_TERM "
				+ " order by F_TERM asc")
				.setInteger("year", year)
				.list();

		List<Integer> termList = new LinkedList<Integer>();

		for (Object object : list) {
			termList.add((Integer)object);
		}

		return termList;

	}

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/dao/DepartmentDao.java
package com.zsc.net11.dao;

import com.zsc.net11.base.BaseDao;
import com.zsc.net11.entity.Department;

/**
 * 系别表 Dao
 *
 * @author 黄伟枞
 */
public interface DepartmentDao extends BaseDao<Department> {

}
<file_sep>/ACSS/src/main/webapp/WEB-INF/content/main.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>

<base href="<%=basePath%>">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>排课系统</title>

<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrapValidator.min.css">
<link rel="stylesheet" href="css/main.css">

		              	教师管理

添加学院信息

查看学院信息

添加系别信息

查看系别信息

添加教师信息

查看教师信息

|

		              	教室管理

添加教学楼信息

查看教学楼信息

查看教学楼距离

添加教室信息

查看教室信息

|

		              	班级管理

添加班级信息

查看班级信息

|

		              	任课安排

添加课程信息

查看课程信息

添加任课信息

查看任课信息

|

		              	课表查询

教师课表

班级课表

|

		              	排课管理

指定实验课教室

查看指定实验课教室

添加手动排课信息

查看手动排课信息

添加不排课时间

查看不排课时间

自动排课

|

		              	高级

修改密码

修改排课参数

<file_sep>/ACSS/src/main/java/com/zsc/net11/actions/scheduling/ManualTimetableAction.java
package com.zsc.net11.actions.scheduling;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import com.zsc.net11.base.BaseActionFormSupport;
import com.zsc.net11.entity.Classroom;
import com.zsc.net11.entity.CurriculumUnit;
import com.zsc.net11.entity.ManualTimetable;
import com.zsc.net11.service.ClassroomService;
import com.zsc.net11.service.CurriculumUnitService;
import com.zsc.net11.service.ManualTimetableService;
import com.zsc.net11.util.SubTimeTransform;

/**
 * 手动排课 Action
 *
 * @author 黄伟枞
 */
@ParentPackage("base")
public class ManualTimetableAction extends
		BaseActionFormSupport<ManualTimetable> {

	private static final long serialVersionUID = -5009067581546293299L;

	@Resource
	private CurriculumUnitService curriculumUnitService;

	@Resource
	private ClassroomService classroomService;

	@Resource
	private ManualTimetableService manualTimetableService;

	/**
	 * 添加手动排课信息
	 */
	@Action(value = "add_manual_timetable", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/scheduling/add_manual_timetable.jsp") })
	public String addExperimentAndRoom() throws Exception {

		List<CurriculumUnit> curriculumUnitList = curriculumUnitService.getAll();
		List<Classroom> classroomList = classroomService.getAll();

		request.setAttribute("curriculumUnitList", curriculumUnitList);
		request.setAttribute("classroomList", classroomList);
		request.setAttribute("timeList", SubTimeTransform.SUB_TIME);

		return SUCCESS;

	}

	/**
	 * 添加手动排课信息结果
	 */
	@Action(value = "add_manual_timetable_result", results = { @Result(name = SUCCESS, type="json", params = {"root", "result"}) })
	public String addExperimentAndRoomResult() throws Exception {

		Integer curriculumUnitId = Integer.valueOf(request.getParameter("curriculum_unit_id"));
		Integer classroomId = Integer.valueOf(request.getParameter("classroom_id"));

		CurriculumUnit curriculumUnit = curriculumUnitService.getById(curriculumUnitId);

		if (curriculumUnit != null) {

			Classroom classroom = classroomService.getById(classroomId);

			if (classroom != null) {

				getModel().setCurriculumUnit(curriculumUnit)
						.setClassroom(classroom);
				Integer manualTimetableId = manualTimetableService.save(getModel());

				if (manualTimetableId != null) {

					curriculumUnit.setAuto(false);
					curriculumUnitService.update(curriculumUnit);

					result = true;
					return SUCCESS;

				}

			}
		}

		result = false;
		return SUCCESS;

	}

	/**
	 * 查看手动排课信息
	 */
	@Action(value = "get_all_manual_timetable", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/scheduling/get_all_manual_timetable.jsp") })
	public String getAllExperimentAndRoom() throws Exception {

		List<ManualTimetable> manualTimetableList = manualTimetableService.getAll();
		request.setAttribute("manualTimetableList", manualTimetableList);
		request.setAttribute("timeList", SubTimeTransform.SUB_TIME);
		return SUCCESS;

	}

	/**
	 * 更新手动排课信息
	 */
	@Action(value = "update_manual_timetable", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/scheduling/update_manual_timetable.jsp") })
	public String updateExperimentAndRoom() throws Exception {

		Integer manualTimetableId = Integer.valueOf(request.getParameter("manual_timetable_id"));
		ManualTimetable manualTimetable = manualTimetableService.getById(manualTimetableId);

		if (manualTimetable != null) {

			List<CurriculumUnit> curriculumUnitList = curriculumUnitService.getAll();
			List<Classroom> classroomList = classroomService.getAll();

			request.setAttribute("curriculumUnitList", curriculumUnitList);
			request.setAttribute("classroomList", classroomList);
			request.setAttribute("manualTimetable", manualTimetable);
			request.setAttribute("timeList", SubTimeTransform.SUB_TIME);

			return SUCCESS;

		}

		return ERROR;
	}

	/**
	 * 更新手动排课信息结果
	 */
	@Action(value = "update_manual_timetable_result", results = { @Result(name = SUCCESS, type="json", params = {"root", "result"}) })
	public String updateExperimentAndRoomResult() throws Exception {

		Integer classroomId = Integer.valueOf(request.getParameter("classroom_id"));
		Classroom classroom = classroomService.getById(classroomId);

		if (classroom != null) {

			getModel().setClassroom(classroom);

			result = manualTimetableService.update(getModel());
			return SUCCESS;

		}

		result = false;
		return SUCCESS;

	}

	/**
	 * 删除手动排课信息结果
	 */
	@Action(value = "del_manual_timetable_result", results = { @Result(name = SUCCESS, type="json", params = {"root", "result"}) })
	public String delExperimentAndRoomResult() throws Exception {

		Integer manualTimetableId = Integer.valueOf(request.getParameter("manual_timetable_id"));

		ManualTimetable manualTimetable = manualTimetableService.getById(manualTimetableId);
		CurriculumUnit curriculumUnit = manualTimetable.getCurriculumUnit();
		result = manualTimetableService.delete(manualTimetableId);

		Integer manualTimetableNum = manualTimetableService.getNumByCurriculumUnitId(curriculumUnit.getId());

		if (manualTimetableNum == 0) {
			// 没有手动排课，转为自动排课

			curriculumUnit.setAuto(true);
			curriculumUnitService.update(curriculumUnit);

		}

		return SUCCESS;

	}

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/service/TimetableService.java
package com.zsc.net11.service;

import java.util.List;

import com.zsc.net11.entity.Timetable;

/**
 * 课表操作相关 Service 接口
 *
 * @author 黄伟枞
 */
public interface TimetableService {

	/**
	 * 保存课表单元
	 *
	 * @param timetable 课表单元
	 *
	 * @return 课表单元 ID
	 */
	public Integer save(Timetable timetable);

	/**
	 * 删除指定学年学期的课表
	 *
	 * @param year 学年
	 *
	 * @param term 学期
	 *
	 * @return true 表示删除成功； false 表示删除失败
	 */
	public boolean deleteByYearAndTerm(Integer year, Integer term);

	/**
	 * 获取教师的课表
	 *
	 * @param teacherId 教师 ID
	 *
	 * @param year 学年
	 *
	 * @param term 学期
	 *
	 * @return 教师的某学年学期的课表
	 */
	public List<Timetable> getAllByTeacher(Integer teacherId, Integer year, Integer term);

	/**
	 * 获取班级的课表
	 *
	 * @param clazzId 班级 ID
	 *
	 * @param year 学年
	 *
	 * @param term 学期
	 *
	 * @return 班级的某学年学期的课表
	 */
	public List<Timetable> getAllByClazz(Integer clazzId, Integer year, Integer term);

	/**
	 * 获取有课表的学年集合
	 *
	 * @return 有课表的学年集合
	 */
	public List<Integer> getYear();

	/**
	 * 根据学年获取有课表的学期
	 *
	 * @param year 学年
	 *
	 * @return 有课表的学期
	 */
	public List<Integer> getTerm(Integer year);

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/actions/scheduling/ExperimentAndRoomAction.java
package com.zsc.net11.actions.scheduling;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import com.zsc.net11.base.BaseActionFormSupport;
import com.zsc.net11.entity.Classroom;
import com.zsc.net11.entity.Clazz;
import com.zsc.net11.entity.Course;
import com.zsc.net11.entity.ExperimentAndRoom;
import com.zsc.net11.service.ClassroomService;
import com.zsc.net11.service.ClazzService;
import com.zsc.net11.service.CourseService;
import com.zsc.net11.service.ExperimentAndRoomService;

/**
 * 指定实验课实验室 Action
 *
 * @author 黄伟枞
 */
@ParentPackage("base")
public class ExperimentAndRoomAction extends
		BaseActionFormSupport<ExperimentAndRoom> {

	private static final long serialVersionUID = -955083950442850168L;

	@Resource
	private CourseService courseService;

	@Resource
	private ClazzService clazzService;

	@Resource
	private ClassroomService classroomService;

	@Resource
	private ExperimentAndRoomService experimentAndRoomService;

	/**
	 * 添加指定实验课实验室信息
	 */
	@Action(value = "add_experiment_and_room", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/scheduling/add_experiment_and_room.jsp") })
	public String addExperimentAndRoom() throws Exception {

		List<Course> courseList = courseService.getAll();
		List<Clazz> clazzList = clazzService.getAll();
		List<Classroom> classroomList = classroomService.getAllByType(Classroom.EXPERIMENT);

		request.setAttribute("courseList", courseList);
		request.setAttribute("clazzList", clazzList);
		request.setAttribute("classroomList", classroomList);

		return SUCCESS;

	}

	/**
	 * 添加指定实验课实验室信息结果
	 */
	@Action(value = "add_experiment_and_room_result", results = { @Result(name = SUCCESS, type="json", params = {"root", "result"}) })
	public String addExperimentAndRoomResult() throws Exception {

		Integer courseId = Integer.valueOf(request.getParameter("course_id"));
		Integer clazzId = Integer.valueOf(request.getParameter("clazz_id"));
		Integer classroomId = Integer.valueOf(request.getParameter("classroom_id"));

		Course course = courseService.getById(courseId);

		if (course != null) {

			Clazz clazz = clazzService.getById(clazzId);

			if (clazz != null) {

				Classroom classroom = classroomService.getById(classroomId);

				if (classroom != null) {

					getModel().setCourse(course)
							.setClazz(clazz)
							.setClassroom(classroom);

					Integer experimentAndRoomId = experimentAndRoomService.save(getModel());

					if (experimentAndRoomId != null) {

						result = true;
						return SUCCESS;

					}

				}

			}
		}

		result = false;

		return SUCCESS;

	}

	/**
	 * 查看指定实验课实验室信息
	 */
	@Action(value = "get_all_experiment_and_room", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/scheduling/get_all_experiment_and_room.jsp") })
	public String getAllExperimentAndRoom() throws Exception {

		List<ExperimentAndRoom> experimentAndRoomList = experimentAndRoomService.getAll();
		request.setAttribute("experimentAndRoomList", experimentAndRoomList);
		return SUCCESS;

	}

	/**
	 * 更新指定实验课实验室信息
	 */
	@Action(value = "update_experiment_and_room", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/scheduling/update_experiment_and_room.jsp") })
	public String updateExperimentAndRoom() throws Exception {

		Integer experimentAndRoomId = Integer.valueOf(request.getParameter("experiment_and_room_id"));
		ExperimentAndRoom experimentAndRoom = experimentAndRoomService.getById(experimentAndRoomId);

		if (experimentAndRoom != null) {

			List<Classroom> classroomList = classroomService.getAllByType(Classroom.EXPERIMENT);

			request.setAttribute("classroomList", classroomList);
			request.setAttribute("experimentAndRoom", experimentAndRoom);

			return SUCCESS;

		}

		return ERROR;
	}

	/**
	 * 更新指定实验课实验室信息结果
	 */
	@Action(value = "update_experiment_and_room_result", results = { @Result(name = SUCCESS, type="json", params = {"root", "result"}) })
	public String updateExperimentAndRoomResult() throws Exception {

		Integer classroomId = Integer.valueOf(request.getParameter("classroom_id"));

		Classroom classroom = classroomService.getById(classroomId);

		if (classroom != null) {

			getModel().setClassroom(classroom);

			result = experimentAndRoomService.update(getModel());
			return SUCCESS;

		}

		result = false;
		return SUCCESS;

	}

	/**
	 * 删除指定实验课实验室信息结果
	 */
	@Action(value = "del_experiment_and_room_result", results = { @Result(name = SUCCESS, type="json", params = {"root", "result"}) })
	public String delExperimentAndRoomResult() throws Exception {

		Integer experimentAndRoomId = Integer.valueOf(request.getParameter("experiment_and_room_id"));

		result = experimentAndRoomService.delete(experimentAndRoomId);

		return SUCCESS;

	}

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/dao/impl/PropertiesDaoImpl.java
package com.zsc.net11.dao.impl;

import org.springframework.stereotype.Repository;

import com.zsc.net11.base.BaseDaoImpl;
import com.zsc.net11.dao.PropertiesDao;
import com.zsc.net11.entity.Properties;

/**
 * 属性表 Dao 的实现
 *
 * @author 黄伟枞
 */
@Repository("propertiesDao")
public class PropertiesDaoImpl extends BaseDaoImpl<Properties> implements
		PropertiesDao {

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/service/impl/CollegeServiceImpl.java
package com.zsc.net11.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zsc.net11.dao.CollegeDao;
import com.zsc.net11.entity.College;
import com.zsc.net11.service.CollegeService;

/**
 * 学院操作相关 Service 接口的实现
 *
 * @author 黄伟枞
 */
@Service("collegeService")
public class CollegeServiceImpl implements CollegeService {

	@Resource
	private CollegeDao collegeDao;

	@Override
	public Integer save(College college) {

		College entity = getByName(college.getName());

		if (entity != null) {
			// 已存在同名的
			if(entity.getDel()) {
				// 已删除，恢复
				entity.setDel(false);
				update(entity);
				return entity.getId();

			}
			// 没删除，名字冲突
			return null;
		} else {
			return  (Integer) collegeDao.save(college);
		}

	}

	@Override
	public boolean delete(int id) {

		College entity = collegeDao.get(id);

		if (entity != null) {

			entity.setDel(true);
			collegeDao.update(entity);

			collegeDao.createSqlQuery(" update TB_DEPARTMENT set F_DELETE = 1 where PK_COLLEGE_ID = :collegeId")
					.setInteger("collegeId", id)
					.executeUpdate();

			return true;

		}

		return false;
	}

	@Override
	public boolean update(College college) {

		College entity = getById(college.getId());

		if (entity != null) {

			College temp = getByName(college.getName());

			if (temp == null) {

				entity.setName(college.getName());
				collegeDao.update(entity);
				return true;

			}

		}

		return false;

	}

	@Override
	public College getByName(String name) {

		return (College) collegeDao.createQuery("from College college "
				+ " where college.name = :name ")
				.setString("name", name)
				.uniqueResult();
	}

	@Override
	public College getById(int id) {
		return collegeDao.get(id);
	}

	@Override
	public List<College> getAll() {
		return collegeDao.list("from College college "
				+ " where college.del = false "
				+ " order by convert(college.name) asc");
	}

}
<file_sep>/ACSS/src/main/webapp/WEB-INF/content/scheduling/get_auto_scheduling.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="s" uri="/struts-tags"%>

自动排课

		<form id="form" class="form-horizontal col-xs-offset-2 margin-top">
			<s:if test="#request.status == 0">

						学年

						<select class="form-control" id="select_year" name="year">
							<s:iterator id="year" value="#request.yearList" status="yearIndex">
								<s:if test="#yearIndex.last">
									<option value='<s:property value="#year"/>' selected="selected">
										<s:property value="#year"/> - <s:property value="#year + 1"/>
									</option>
								</s:if>
								<s:else>
									<option value='<s:property value="#year"/>'>
										<s:property value="#year"/> - <s:property value="#year + 1"/>
									</option>
								</s:else>
							</s:iterator>
						</select>

						学期

						<select class="form-control" id="select_term" name="term">
							<s:iterator id="term" value="#request.termList" status="termIndex">
								<s:if test="#termIndex.last">
									<option value='<s:property value="#term"/>' selected="selected">
										<s:property value="#term"/>
									</option>
								</s:if>
								<s:else>
									<option value='<s:property value="#term"/>'>
										<s:property value="#term"/>
									</option>
								</s:else>
							</s:iterator>
						</select>

					<button type="button"
						class="btn btn-primary col-xs-offset-3 col-xs-2"
						onclick='doAutoScheduling()'>
						开始自动排课
					</button>

			</s:if>
			<s:elseif test="#request.status == 1">

					<s:set name="type" value="{'success', 'info', 'warning', 'danger'}" scope="request"></s:set>
					<s:iterator id="population" value="#request.populationList" status="index">

								种群<s:property value="#index.index + 1"/>

									<s:if test="#population.nowGenerations == 0">
										初始化中
									</s:if>
									<s:else>
										<div class="progress-bar progress-bar-<s:property value="#request.type[#index.index]" /> progress-bar-striped" role="progressbar"
											aria-valuenow='<s:property value="#population.nowGenerations" />'
											aria-valuemin="0"
											aria-valuemax='<s:property value="#population.generations" />'
											style='width: <s:property value="#population.nowGenerations / #population.generations * 100" />%'>

										  		<s:property value="#population.nowGenerations / #population.generations * 100" />%

									</s:else>

					</s:iterator>

						<button type="button"
							class="btn btn-primary col-xs-offset-2 col-xs-2"
							onclick='loadHTML("scheduling/get_auto_scheduling")'>
							刷新
						</button>
						<button type="button"
							class="btn btn-primary col-xs-offset-1 col-xs-2"
							onclick='loadHTML("scheduling/stop_auto_scheduling")'>
							停止自动排课
						</button>

			</s:elseif>
			<s:elseif test="#request.status == 2">

排课完成

					<button type="button"
						class="btn btn-primary col-xs-offset-3 col-xs-2"
						onclick='loadHTML("scheduling/confirm_auto_scheduling")'>
						确定
					</button>

			</s:elseif>
		</form>

<file_sep>/ACSS/src/main/java/com/zsc/net11/service/ClazzService.java
package com.zsc.net11.service;

import java.util.List;

import com.zsc.net11.entity.Clazz;
import com.zsc.net11.json.ClazzJson;

/**
 * 班级操作相关 Service 接口
 *
 * @author 黄伟枞
 */
public interface ClazzService {

	/**
	 * 保存班级信息
	 *
	 * @param clazz 班级实体类
	 *
	 * @return 班级 ID; null 表示存在相同班级名；
	 */
	public Integer save(Clazz clazz);

	/**
	 * 根据班级 ID 删除班级记录
	 *
	 * @param id 班级 ID
	 *
	 * @return true 表示删除成功； false 表示删除失败
	 */
	public boolean delete(int id);

	/**
	 * 更新班级信息
	 *
	 * @param clazz 班级实体类
	 *
	 * @return true 表示更新成功； false 表示更新失败
	 */
	public boolean update(Clazz clazz);

	/**
	 * 根据班级名称获取班级信息
	 *
	 * @param name 班级名称
	 *
	 * @return 班级实体类
	 */
	public Clazz getByName(String name);

	/**
	 * 根据班级 ID 获取班级信息
	 *
	 * @param id 班级 ID
	 *
	 * @return 班级信息
	 */
	public Clazz getById(int id);

	/**
	 * 获取所有的班级信息
	 *
	 * @return 所有的班级记录，除了被删除的
	 */
	public List<Clazz> getAll();

	/**
	 * 根据合班班级 ID 集合获取合班班级实体类集合
	 *
	 * @param clazzIdList 合班的各班级id，用';'分割
	 *
	 * @return 合班班级实体类集合
	 */
	public List<Clazz> getClazzList(String clazzIdList);

	/**
	 * 获取所有不是合班的班级 ID 和名称（JSON）
	 *
	 * @return 所有的班级 ID 和名称集合
	 */
	public List<ClazzJson> getAllJsonSingle();

	/**
	 * 获取所有不是合班的班级 ID 和名称（JSON）
	 *
	 * @param departmentId 系别 ID
	 *
	 * @return 所有的班级 ID 和名称集合
	 */
	public List<ClazzJson> getAllJsonSingleByDeparment(Integer departmentId);

}
<file_sep>/ACSS/src/main/webapp/WEB-INF/content/scheduling/get_all_cannot_set_curriculum.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="s" uri="/struts-tags"%>

查看不排课时间

		 			时间
		 			类型
		 			修改
		 			删除

		 		<s:iterator id="cannotSetCurriculum" value="#request.cannotSetCurriculumList">

		 				<s:property value="#request.timeList[#cannotSetCurriculum.timeIndex]" />

		 					<s:if test="#cannotSetCurriculum.type == 1">
		 						理论课
		 					</s:if>
		 					<s:elseif test="#cannotSetCurriculum.type == 2">
		 						实验课
		 					</s:elseif>
		 					<s:else>
		 						全部
		 					</s:else>

		 					<a href='javascript:void(0)'
		 						onclick='loadHTML("scheduling/update_cannot_set_curriculum", {cannot_set_curriculum_id:<s:property value="#cannotSetCurriculum.id"/>})'>
		 						修改

							<a href='javascript:void(0)'
								onclick='delCannotSetCurriculumResult(<s:property value="#cannotSetCurriculum.id"/>)'>
								删除

		 		</s:iterator>

<file_sep>/ACSS/src/main/java/com/zsc/net11/service/CannotSetCurriculumService.java
package com.zsc.net11.service;

import java.util.List;
import java.util.Set;

import com.zsc.net11.entity.CannotSetCurriculum;

/**
 * 不排课时间操作相关 Service 接口
 *
 * @author 黄伟枞
 */
public interface CannotSetCurriculumService {

	/**
	 * 保存不排课时间信息
	 *
	 * @param cannotSetCurriculum 不排课时间实体类
	 *
	 * @return 不排课时间 ID; null 表示存在同名；
	 */
	public Integer save(CannotSetCurriculum cannotSetCurriculum);

	/**
	 * 根据不排课时间 ID 删除不排课时间记录
	 *
	 * @param id 不排课时间 ID
	 *
	 * @return true 表示删除成功； false 表示删除失败
	 */
	public boolean delete(int id);

	/**
	 * 更新不排课时间信息
	 *
	 * @param cannotSetCurriculum 不排课时间实体类
	 *
	 * @return true 表示更新成功； false 表示更新失败
	 */
	public boolean update(CannotSetCurriculum cannotSetCurriculum);

	/**
	 * 根据不排课时间 ID 获取不排课时间信息
	 *
	 * @param id 不排课时间 ID
	 *
	 * @return 不排课时间信息
	 */
	public CannotSetCurriculum getById(int id);

	/**
	 * 根据不排课时间索引获取不排课时间信息
	 *
	 * @param timeIndex 不排课时间索引
	 *
	 * @return 不排课时间信息
	 */
	public CannotSetCurriculum getByTimeIndex(int timeIndex);

	/**
	 * 获取所有的不排课时间信息
	 *
	 * @return 所有的不排课时间记录
	 */
	public List<CannotSetCurriculum> getAll();

	/**
	 * 根据不排课类型获取不排课时间索引集合
	 *
	 * @param Type 不排课类型
	 *
	 * @return 不排课时间索引集合
	 */
	public Set<Integer> getAllSetByType(Integer Type);

}
<file_sep>/ACSS/src/main/webapp/WEB-INF/content/scheduling/add_manual_timetable.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="s" uri="/struts-tags"%>

添加手动排课

		<form id="form" class="form-horizontal col-xs-offset-2 margin-top">

					任课选择

					<select class="form-control" id="select_manual_timetable_curriculum_unit" name="curriculum_unit_id">
						<s:iterator id="curriculumUnit" value="#request.curriculumUnitList">
							<option value='<s:property value="#curriculumUnit.id"/>'>
								<s:property value="#curriculumUnit.course.name" />
								(<s:property value="#curriculumUnit.identifie" />)
							</option>
						</s:iterator>
					</select>

					时间

					<select class="form-control" id="select_manual_timetable_time_index" name="timeIndex">
						<s:iterator id="time" value="#request.timeList" status="timeIndex">
							<option value='<s:property value="#timeIndex.index"/>'>
								<s:property value="#time"/>
							</option>
						</s:iterator>
					</select>

					教室

					<select class="form-control" id="select_manual_timetable_classroom" name="classroom_id">
						<s:iterator id="classroom" value="#request.classroomList">
							<option value='<s:property value="#classroom.id"/>'>
								<s:property value="#classroom.building.name" />-<s:property value="#classroom.identifie" />
							</option>
						</s:iterator>
					</select>

					上课类型

					<select class="form-control" id="select_manual_timetable_full" name="full">
						<option value="true">连续</option>
						<option value="false">单双周</option>
					</select>

				<button id="defaultEnterSubmit" type="button"
					class="btn btn-primary col-xs-offset-3 col-xs-2"
					onclick="addManualTimetableResult()">
					添加
				</button>

		</form>

<file_sep>/ACSS/src/main/java/com/zsc/net11/dao/impl/CurriculumUnitDaoImpl.java
package com.zsc.net11.dao.impl;

import org.springframework.stereotype.Repository;

import com.zsc.net11.base.BaseDaoImpl;
import com.zsc.net11.dao.CurriculumUnitDao;
import com.zsc.net11.entity.CurriculumUnit;

/**
 * 排课单元表 Dao 的实现
 *
 * @author 黄伟枞
 */
@Repository("curriculumUnitDao")
public class CurriculumUnitDaoImpl extends BaseDaoImpl<CurriculumUnit>
		implements CurriculumUnitDao {

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/service/impl/CurriculumUnitServiceImpl.java
package com.zsc.net11.service.impl;

import java.util.LinkedList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zsc.net11.dao.CurriculumUnitDao;
import com.zsc.net11.entity.CurriculumUnit;
import com.zsc.net11.service.CurriculumUnitService;

/**
 * 任课操作相关 Service 接口的实现
 *
 * @author 黄伟枞
 */
@Service("curriculumUnitService")
public class CurriculumUnitServiceImpl implements CurriculumUnitService {

	@Resource
	private CurriculumUnitDao curriculumUnitDao;

	@Override
	public Integer save(CurriculumUnit curriculumUnit) {

		CurriculumUnit entity = getByIdentifie(curriculumUnit.getIdentifie());

		if (entity != null) {
			// 存在相同任课代码
			return null;
		}

		return (Integer) curriculumUnitDao.save(curriculumUnit);

	}

	@Override
	public boolean delete(int id) {

		curriculumUnitDao.delete(id);
		return true;

	}

	@Override
	public boolean update(CurriculumUnit curriculumUnit) {

		CurriculumUnit entity = getById(curriculumUnit.getId());

		if (entity != null) {

			entity.setTeacher(curriculumUnit.getTeacher())
				.setClazz(curriculumUnit.getClazz())
				.setCourse(curriculumUnit.getCourse())
				.setTotalPeriod(curriculumUnit.getTotalPeriod())
				.setTeachWeek(curriculumUnit.getTeachWeek())
				.setExperimentWeek(curriculumUnit.getExperimentWeek())
				.setTeachPeriod(curriculumUnit.getTeachPeriod())
				.setExperimentPeriod(curriculumUnit.getExperimentPeriod())
				.setBeginWeek(curriculumUnit.getBeginWeek())
				.setEndWeek(curriculumUnit.getEndWeek())
				.setGrouping(curriculumUnit.getGrouping())
				.setAuto(curriculumUnit.getAuto())
				.setYear(curriculumUnit.getYear())
				.setTerm(curriculumUnit.getTerm());

			curriculumUnitDao.update(entity);
			return true;

		}

		return false;

	}

	@Override
	public CurriculumUnit getByIdentifie(String identifie) {
		return (CurriculumUnit) curriculumUnitDao.createQuery("from CurriculumUnit curriculumUnit where curriculumUnit.identifie = :identifie")
				.setString("identifie", identifie)
				.uniqueResult();
	}

	@Override
	public CurriculumUnit getById(int id) {
		return curriculumUnitDao.get(id);
	}

	@Override
	public List<CurriculumUnit> getAll() {
		return curriculumUnitDao.list("from CurriculumUnit curriculumUnit "
				+ " order by convert(curriculumUnit.identifie) asc ");
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<CurriculumUnit> getAllByYearAndTerm(int year, int term) {
		return curriculumUnitDao.createQuery("from CurriculumUnit curriculumUnit "
				+ " where curriculumUnit.year = :year "
				+ " and curriculumUnit.term = :term "
				+ " order by convert(curriculumUnit.identifie) asc ")
				.setInteger("year", year)
				.setInteger("term", term)
				.list();
	}

	@Override
	public List<CurriculumUnit> getAllAuto() {
		return curriculumUnitDao.list("from CurriculumUnit curriculumUnit "
				+ " where curriculumUnit.auto = true "
				+ " order by convert(curriculumUnit.identifie) asc ");
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<CurriculumUnit> getAllAutoByYearAndTerm(int year, int term) {
		return curriculumUnitDao.createQuery("from CurriculumUnit curriculumUnit "
				+ " where curriculumUnit.auto = true "
				+ " and curriculumUnit.year = :year "
				+ " and curriculumUnit.term = :term "
				+ " order by convert(curriculumUnit.identifie) asc ")
				.setInteger("year", year)
				.setInteger("term", term)
				.list();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Integer> getYear() {

		List<Object> list = curriculumUnitDao.createSqlQuery("select F_YEAR from TB_CURRICULUM_UNIT "
				+ " group by F_YEAR "
				+ " order by F_YEAR ")
				.list();

		List<Integer> yearList = new LinkedList<Integer>();

		for (Object object : list) {
			yearList.add((Integer)object);
		}

		return yearList;

	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Integer> getTerm(Integer year) {

		List<Object> list = curriculumUnitDao.createSqlQuery("select F_TERM from TB_CURRICULUM_UNIT "
				+ " where F_YEAR = :year "
				+ " group by F_TERM "
				+ " order by F_TERM asc")
				.setInteger("year", year)
				.list();

		List<Integer> termList = new LinkedList<Integer>();

		for (Object object : list) {
			termList.add((Integer)object);
		}

		return termList;

	}

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/service/impl/ExperimentAndRoomServiceImpl.java
package com.zsc.net11.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zsc.net11.dao.ExperimentAndRoomDao;
import com.zsc.net11.entity.ExperimentAndRoom;
import com.zsc.net11.service.ExperimentAndRoomService;

/**
 * 实验课对应实验室操作相关 Service 接口的实现
 *
 * @author 黄伟枞
 */
@Service("experimentAndRoomService")
public class ExperimentAndRoomServiceImpl implements ExperimentAndRoomService {

	@Resource
	private ExperimentAndRoomDao experimentAndRoomDao;

	@Override
	public Integer save(ExperimentAndRoom experimentAndRoom) {

		ExperimentAndRoom entity = (ExperimentAndRoom) experimentAndRoomDao.createQuery(" from ExperimentAndRoom experimentAndRoom "
				+ " where experimentAndRoom.course.id = :courseId "
				+ " and experimentAndRoom.clazz.id = :clazzId ")
				.setInteger("courseId", experimentAndRoom.getCourse().getId())
				.setInteger("clazzId", experimentAndRoom.getClazz().getId())
				.uniqueResult();

		if (entity != null) {
			// 有冲突
			return null;
		}

		return (Integer) experimentAndRoomDao.save(experimentAndRoom);
	}

	@Override
	public boolean delete(int id) {

		experimentAndRoomDao.delete(id);;
		return true;

	}

	@Override
	public boolean update(ExperimentAndRoom experimentAndRoom) {

		ExperimentAndRoom entity = getById(experimentAndRoom.getId());

		if (entity != null) {
			entity.setClassroom(experimentAndRoom.getClassroom());
			experimentAndRoomDao.update(entity);
			return true;
		}

		return false;
	}

	@Override
	public ExperimentAndRoom getById(int id) {
		return experimentAndRoomDao.get(id);
	}

	@Override
	public List<ExperimentAndRoom> getAll() {
		return experimentAndRoomDao.list("from ExperimentAndRoom experimentAndRoom "
				+ " order by convert(experimentAndRoom.course.name) asc, "
				+ " convert(experimentAndRoom.clazz.name) asc ");
	}

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/util/algorithm/collections/ExperimentRoomCollection.java
package com.zsc.net11.util.algorithm.collections;

import java.util.HashMap;
import java.util.Map;

import com.zsc.net11.vo.ClassroomVO;

/**
 * 实验课教室

 * index 实验课教室的索引 ，Value 实验课教室实体类

 * key 实验课教室名(教学楼+教室编号)
 *
 * @author 黄伟枞
 */
public abstract class ExperimentRoomCollection {

	/** 实验课教室数组，index 实验课教室的索引 ，Value 实验课教室实体类 */
	private static ClassroomVO[] roomArray;

	/** 实验课教室映射，key 实验室教室名(教学楼+教室编号)，value 实验课教室索引 */
	private static Map<String, Integer> roomMap;

	/**
	 * 初始化 roomMap
	 *
	 * @param roomAmount 实验课教室数量
	 */
	public static void init(int roomAmount) {
		roomArray = new ClassroomVO[roomAmount];
		roomMap = new HashMap<String, Integer>((int) (roomAmount / 0.7));
	}

	/**
	 * 获取实验课教室实体类
	 *
	 * @param index 实验课教室的索引
	 *
	 * @return 实验课教室实体类
	 */
	public static ClassroomVO get(Integer index) {
		return roomArray[index];
	}

	/**
	 * 获取实验课教室的索引
	 *
	 * @param roomName 实验室教室名(教学楼+教室编号)
	 *
	 * @return 实验课教室的索引
	 */
	public static Integer get(String roomName) {
		return roomMap.get(roomName);
	}

	/**
	 * 添加映射
	 *
	 * @param index 实验课教室的索引
	 *
	 * @param room 实验课教室实体类
	 */
	public static void put(Integer index, ClassroomVO room) {
		roomArray[index] =  room;
	}

	/**
	 * 添加映射
	 *
	 * @param roomName 实验室教室名(教学楼+教室编号)
	 *
	 * @param index 实验课教室的索引
	 */
	public static void put(String roomName, Integer index) {
		roomMap.put(roomName, index);
	}

	/**
	 * 移除映射
	 *
	 * @param index 实验课教室的索引
	 */
	public static void remove(Integer index) {
		roomArray[index] = null;
	}

	/**
	 * 移除映射
	 *
	 * @param roomName 实验室教室名(教学楼+教室编号)
	 */
	public static void remove(String roomName) {
		roomMap.remove(roomName);
	}

	/**
	 * 释放 roomMap 占用的空间
	 */
	public static void release() {
		roomArray = null;
		roomMap = null;
	}

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/service/PropertiesService.java
package com.zsc.net11.service;

import com.zsc.net11.entity.Properties;

/**
 * 属性操作相关 Service 接口
 *
 * @author 黄伟枞
 */
public interface PropertiesService {

	/**
	 * 获取属性
	 *
	 * @return 属性对象
	 */
	public Properties getProperties();

	/**
	 * 修改密码
	 *
	 * @param properties 属性实体类
	 *
	 * @return true 表示修改成功； false 表示修改失败
	 */
	public boolean updatePassword(Properties properties);

	/**
	 * 修改属性
	 *
	 * @param properties 属性实体类
	 *
	 * @return true 表示修改成功； false 表示修改失败
	 */
	public boolean updateProperties(Properties properties);

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/actions/teacher/TeacherAction.java
package com.zsc.net11.actions.teacher;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import com.zsc.net11.base.BaseActionFormSupport;
import com.zsc.net11.entity.College;
import com.zsc.net11.entity.Department;
import com.zsc.net11.entity.Teacher;
import com.zsc.net11.json.DepartmentJson;
import com.zsc.net11.json.TeacherJson;
import com.zsc.net11.service.CollegeService;
import com.zsc.net11.service.DepartmentService;
import com.zsc.net11.service.TeacherService;

/**
 * 教师相关 Action
 *
 * @author 黄伟枞
 */
@ParentPackage("base")
public class TeacherAction extends BaseActionFormSupport<Teacher> {

	private static final long serialVersionUID = 4881696692787334442L;

	@Resource
	private CollegeService collegeService;

	@Resource
	private DepartmentService departmentService;

	@Resource
	private TeacherService teacherService;

	private List<TeacherJson> teacherJsonList;

	public List<TeacherJson> getTeacherJsonList() {
		return teacherJsonList;
	}

	public void setTeacherJsonList(List<TeacherJson> teacherJsonList) {
		this.teacherJsonList = teacherJsonList;
	}

	/**
	 * 添加教师信息
	 */
	@Action(value = "add_teacher", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/teacher/add_teacher.jsp") })
	public String addTeacher() throws Exception {

		List<College> collegeList = collegeService.getAll();
		request.setAttribute("collegeList", collegeList);

		return SUCCESS;

	}

	/**
	 * 添加教师信息结果
	 */
	@Action(value = "add_teacher_result", results = { @Result(name = SUCCESS, type="json", params = {"root", "result"}) })
	public String addTeacherResult() throws Exception {

		Integer departmentId = Integer.valueOf(request.getParameter("department_id"));

		Department department = departmentService.getById(departmentId);

		if (department != null) {

			getModel().setDepartment(department);

			Integer teacherId = teacherService.save(getModel());

			if (teacherId != null) {

				result = true;
				return SUCCESS;

			}

		}

		result = false;

		return SUCCESS;

	}

	/**
	 * 查看教师信息
	 */
	@Action(value = "get_all_teacher", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/teacher/get_all_teacher.jsp") })
	public String getAllTeacher() throws Exception {

		List<Teacher> teacherList = teacherService.getAll();
		List<College> collegeList = collegeService.getAll();

		request.setAttribute("teacherList", teacherList);
		request.setAttribute("collegeList", collegeList);
		return SUCCESS;

	}

	/**
	 * 更新教师信息
	 */
	@Action(value = "update_teacher", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/teacher/update_teacher.jsp") })
	public String updateTeacher() throws Exception {

		Integer teacherId = Integer.valueOf(request.getParameter("teacher_id"));
		Teacher teacher = teacherService.getById(teacherId);

		if (teacher != null) {

			List<College> collegeList = collegeService.getAll();
			List<DepartmentJson> departmentList = departmentService.getAllJsonByCollegeId(teacher.getDepartment().getCollege().getId());

			request.setAttribute("teacher", teacher);
			request.setAttribute("collegeList", collegeList);
			request.setAttribute("departmentList", departmentList);

			return SUCCESS;

		}

		return ERROR;
	}

	/**
	 * 更新教师信息结果
	 */
	@Action(value = "update_teacher_result", results = { @Result(name = SUCCESS, type="json", params = {"root", "result"}) })
	public String updateTeacherResult() throws Exception {

		Integer collegeId = Integer.valueOf(request.getParameter("college_id"));
		Integer departmentId = Integer.valueOf(request.getParameter("department_id"));

		College college = collegeService.getById(collegeId);

		if (college != null) {

			Department department = departmentService.getById(departmentId);

			if (department != null) {

				getModel().setDepartment(department);
				result = teacherService.update(getModel());

				return SUCCESS;

			}
		}

		result = false;
		return SUCCESS;

	}

	/**
	 * 删除教师信息结果
	 */
	@Action(value = "del_teacher_result", results = { @Result(name = SUCCESS, type="json", params = {"root", "result"}) })
	public String delTeacherResult() throws Exception {

		Integer teacherId = Integer.valueOf(request.getParameter("teacher_id"));

		result = teacherService.delete(teacherId);

		return SUCCESS;

	}

	/**
	 * 根据学院查看教师信息
	 */
	@Action(value = "get_all_teacher_by_college", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/teacher/get_all_teacher_by.jsp") })
	public String getAllTeacherByCollege() throws Exception {

		Integer collegeId = Integer.parseInt(request.getParameter("college_id"));
		List<Teacher> teacherList;

		if (collegeId == null
				|| collegeId <= 0) {
			teacherList = teacherService.getAll();
		} else {
			teacherList = teacherService.getAllByCollegeId(collegeId);
		}

		request.setAttribute("teacherList", teacherList);
		return SUCCESS;

	}

	/**
	 * 根据系别查看教师信息
	 */
	@Action(value = "get_all_teacher_by_department", results = { @Result(name = SUCCESS, location = "/WEB-INF/content/teacher/get_all_teacher_by.jsp") })
	public String getAllTeacherByDepartment() throws Exception {

		Integer departmentId = Integer.parseInt(request.getParameter("department_id"));
		List<Teacher> teacherList;

		if (departmentId == null
				|| departmentId <= 0) {

			Integer collegeId = Integer.parseInt(request.getParameter("college_id"));

			if (collegeId == null
					|| collegeId <= 0) {
				teacherList = teacherService.getAll();
			} else {
				teacherList = teacherService.getAllByCollegeId(collegeId);
			}

		} else {

			teacherList = teacherService.getAllByDepartmentId(departmentId);
		}

		request.setAttribute("teacherList", teacherList);
		return SUCCESS;

	}

	/**
	 * 根据系别查看教师信息
	 */
	@Action(value = "get_all_teacher_json_by_department", results = { @Result(name = SUCCESS, type = "json", params = {"root", "teacherJsonList"}) })
	public String getAllTeacherJsonByDepartment() throws Exception {

		Integer departmentId = Integer.parseInt(request.getParameter("department_id"));

		if (departmentId != null) {

				teacherJsonList = teacherService.getAllJsonByDeparimentId(departmentId);
				request.setAttribute("teacherList", teacherJsonList);

		}

		return SUCCESS;

	}

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/entity/Clazz.java
package com.zsc.net11.entity;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.Version;

/**
 * 班级表实体类
 *
 * @author 黄伟枞
 */
@Entity
@Table(name = "TB_CLASS")
public class Clazz implements Serializable {

	private static final long serialVersionUID = 8059602045922008574L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="PK_CLASS_ID")
	private Integer id;

	/** 班级名称 */
	@Column(name = "F_NAME", length = 30)
	private String name;

	/** 人数 */
	@Column(name = "F_POPULATION")
	private Integer population;

	/** 合班的各班级id，用';'分割 */
	@Column(name = "F_CLASS_LIST", length = 250)
	private String clazzIds;

	/** 合班的班级（不保存进数据库） */
	@Transient
	private List<Clazz> clazzList;

	/** 系别 */
	@OneToOne
    @JoinColumn(name="FK_DEPARTMENT_ID")
	private Department department;

	@Version
	@Column(name = "F_VERSION")
	private Integer version;

	@Column(name = "F_DELETE")
	private Boolean del = false;

	// //////////////////////////////////////////////////Begin Constructor

	public Clazz() {
		this.clazzList = new LinkedList<Clazz>();
	}

	// //////////////////////////////////////////////////End Constructor

	// //////////////////////////////////////////////////Begin Getter Setter

	public Integer getId() {
		return id;
	}

	public Clazz setId(Integer id) {
		this.id = id;
		return this;
	}

	/**
	 * 获取班级名称
	 *
	 * @return 班级名称
	 */
	public String getName() {
		return name;
	}

	/**
	 * 设置班级名称
	 *
	 * @param name 班级名称
	 */
	public Clazz setName(String name) {
		this.name = name;
		return this;
	}

	/**
	 * 获取人数
	 *
	 * @return 人数
	 */
	public Integer getPopulation() {
		return population;
	}

	/**
	 * 设置人数
	 *
	 * @param population
	 *            人数
	 */
	public Clazz setPopulation(Integer population) {
		this.population = population;
		return this;
	}

	/**
	 * 获取合班的各班级id，用';'分割
	 *
	 * @return 合班的各班级id，用';'分割
	 */
	public String getClazzIds() {
		return clazzIds;
	}

	/**
	 * 设置合班的各班级id，用';'分割
	 *
	 * @param clazzIds 合班的各班级id，用';'分割
	 */
	public Clazz setClazzIds(String clazzIds) {
		this.clazzIds = clazzIds;
		return this;
	}

	/**
	 * 获取合班的班级列表
	 *
	 * @return 合班的班级列表
	 */
	public List<Clazz> getClazzList() {
		return clazzList;
	}

	/**
	 * 设置合班的班级列表
	 *
	 * @param clazzVOList 合班的班级列表
	 */
	public Clazz setClazzList(List<Clazz> clazzList) {
		this.clazzList = clazzList;
		return this;
	}

	/**
	 * 获取系别
	 *
	 * @return 系别
	 */
	public Department getDepartment() {
		return department;
	}

	/**
	 * 设置系别
	 *
	 * @param department 系别
	 */
	public Clazz setDepartment(Department department) {
		this.department = department;
		return this;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	public Boolean getDel() {
		return del;
	}

	public Clazz setDel(Boolean del) {
		this.del = del;
		return this;
	}

	// //////////////////////////////////////////////////End Getter Setter

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/dao/impl/TimetableDaoImpl.java
package com.zsc.net11.dao.impl;

import org.springframework.stereotype.Repository;

import com.zsc.net11.base.BaseDaoImpl;
import com.zsc.net11.dao.TimetableDao;
import com.zsc.net11.entity.Timetable;

/**
 * 课表 Dao 的实现
 *
 * @author 黄伟枞
 */
@Repository("timetabelDao")
public class TimetableDaoImpl extends BaseDaoImpl<Timetable> implements
		TimetableDao {

}
<file_sep>/ACSS/src/main/java/com/zsc/net11/algorithm/vo/CurriculumUnitVO.java
package com.zsc.net11.algorithm.vo;

import java.io.Serializable;

import com.zsc.net11.entity.CurriculumUnit;
import com.zsc.net11.util.algorithm.collections.ExperimentRoomCollection;
import com.zsc.net11.util.algorithm.collections.TheoryRoomCollection;
import com.zsc.net11.vo.ClassroomVO;

/**
 * 排课单元，用于算法计算的值对象
 *
 * @author 黄伟枞
 */
public class CurriculumUnitVO implements Comparable<CurriculumUnitVO>, Serializable{

	private static final long serialVersionUID = 7717792544259326666L;

	/** 排课单元 */
	private CurriculumUnit curriculumUnit;

	/** 教师值对象 */
	private TeacherVO teacherVO;

	/** 班级值对象 */
	private ClazzVO clazzVO;

	/** 时间索引 */
	private int timeIndex = -1;

	/** 教室索引 */
	private int roomIndex = -1;

	/** 教室利用率 */
	private double roomUtilizationRatio;

	/** 课程类型 true 表示理论课； false 表示实验课 */
	private boolean curriculumType;

	/** 是否是单双周 true 表示单双周； false 表示连续 */
	private boolean single = false;

	/** 相同课程汇集 */
	private CurriculumVO curriculumVO;

	/** 是否分组 true 为有分组； false 为无分组 */
	private boolean group = false;

	// //////////////////////////////////////////////////Begin Constructor

	public CurriculumUnitVO() {
	}

	/**
	 * @param curriculumUnit
	 *            排课单元
	 * @param teacherVO
	 *            教师值对象
	 * @param clazzVO
	 *            班级值对象
	 */
	public CurriculumUnitVO(CurriculumUnit curriculumUnit, TeacherVO teacherVO,
			ClazzVO clazzVO) {
		this.curriculumUnit = curriculumUnit;
		this.teacherVO = teacherVO;
		this.clazzVO = clazzVO;
	}

	// //////////////////////////////////////////////////End Constructor

	// //////////////////////////////////////////////////Begin Getter Setter

	/**
	 * 获取排课单元
	 *
	 * @return 排课单元
	 */
	public CurriculumUnit getCurriculumUnit() {
		return curriculumUnit;
	}

	/**
	 * 设置排课单元
	 *
	 * @param curriculumUnit 排课单元
	 */
	public CurriculumUnitVO setCurriculumUnit(CurriculumUnit curriculumUnit) {
		this.curriculumUnit = curriculumUnit;
		return this;
	}

	/**
	 * 获取教师值对象
	 *
	 * @return 教师值对象
	 */
	public TeacherVO getTeacherVO() {
		return teacherVO;
	}

	/**
	 * 设置教师值对象
	 *
	 * @param teacherVO 教师值对象
	 */
	public CurriculumUnitVO setTeacherVO(TeacherVO teacherVO) {
		this.teacherVO = teacherVO;
		return this;
	}

	/**
	 * 获取班级值对象
	 *
	 * @return 班级值对象
	 */
	public ClazzVO getClazzVO() {
		return clazzVO;
	}

	/**
	 * 设置班级值对象
	 *
	 * @param clazzVO 班级值对象
	 */
	public CurriculumUnitVO setClazzVO(ClazzVO clazzVO) {
		this.clazzVO = clazzVO;
		return this;
	}

	/**
	 * 获取时间索引
	 *
	 * @return 时间索引
	 */
	public int getTimeIndex() {
		return timeIndex;
	}

	/**
	 * 设置时间索引
	 *
	 * @param timeIndex
	 *            时间索引
	 */
	public CurriculumUnitVO setTimeIndex(int timeIndex) {
		if (timeIndex < 0) {
//			System.out.println("CurriculumUnitVO.setTimeIndex()");
//			System.out.println("timeIndex < 0");
		}
		this.timeIndex = timeIndex;
		return this;
	}

	/**
	 * 获取教室索引
	 *
	 * @return 教室索引
	 */
	public int getRoomIndex() {
		return roomIndex;
	}

	/**
	 * 设置教室索引
	 *
	 * @param roomIndex
	 *            教室索引
	 */
	public CurriculumUnitVO setRoomIndex(int roomIndex) {
		if (roomIndex < 0) {
//			System.out.println("CurriculumUnitVO.setRoomIndex()");
//			System.out.println("roomIndex < 0");
		}
		this.roomIndex = roomIndex;
		return this;
	}

	/**
	 * 获取教室利用率
	 *
	 * @return 教室利用率
	 */
	public double getRoomUtilizationRatio() {
		return roomUtilizationRatio;
	}

	/**
	 * 设置教室利用率
	 *
	 * @param roomUtilizationRatio 教室利用率
	 */
	public CurriculumUnitVO setRoomUtilizationRatio(double roomUtilizationRatio) {
		this.roomUtilizationRatio = roomUtilizationRatio;
		return this;
	}

	/**
	 * 判断课程类型
	 *
	 * @return true 表示理论课； false 表示实验课
	 */
	public boolean getCurriculumType() {
		return curriculumType;
	}

	/**
	 * 设置课程类型
	 *
	 * @param curriculumType
	 *            true 表示理论课； false 表示实验课
	 */
	public CurriculumUnitVO setCurriculumType(boolean curriculumType) {
		this.curriculumType = curriculumType;
		return this;
	}

	/**
	 * 判断是否是单双周
	 *
	 * @return true 表示单双周； false 表示连续
	 */
	public boolean isSingle() {
		return single;
	}

	/**
	 * 设置是否是单双周
	 *
	 * @param single true 表示单双周； false 表示连续
	 */
	public CurriculumUnitVO setSingle(boolean single) {
		this.single = single;
		return this;
	}

	/**
	 * 获取同一课程汇集
	 *
	 * @return 同一课程汇集
	 */
	public CurriculumVO getCurriculumVO() {
		return curriculumVO;
	}

	/**
	 * 设置同一课程汇集
	 *
	 * @param curriculumVO 同一课程汇集
	 */
	public CurriculumUnitVO setCurriculumVO(CurriculumVO curriculumVO) {
		this.curriculumVO = curriculumVO;
		return this;
	}

	/**
	 * 判断是否分组
	 *
	 * @return true 为有分组； false 为无分组
	 */
	public boolean isGroup() {
		return group;
	}

	/**
	 * 设置是否分组
	 *
	 * @param group true 为有分组； false 为无分组
	 */
	public CurriculumUnitVO setGroup(boolean group) {
		this.group = group;
		return this;
	}

	// //////////////////////////////////////////////////End Getter Setter

	/**
	 * 计算教室利用率
	 *
	 * @return 教室利用率
	 */
	public double calculate() {

		if (this.curriculumType) {
			ClassroomVO theoryClassroom = TheoryRoomCollection.get(this.roomIndex);
			if (theoryClassroom != null) {
				this.roomUtilizationRatio = this.curriculumUnit.getClazz().getPopulation() / theoryClassroom.getCapacity();
			}

		} else {
			ClassroomVO experimentClassroom = ExperimentRoomCollection.get(this.roomIndex);
			if (experimentClassroom != null) {
				this.roomUtilizationRatio = this.curriculumUnit.getClazz().getPopulation() / experimentClassroom.getCapacity();
			}
		}
		return this.roomUtilizationRatio;
	}

	@Override
	public int compareTo(CurriculumUnitVO cu) {
		return this.timeIndex -  cu.timeIndex;
	}

}
<file_sep>/ACSS/src/main/webapp/WEB-INF/content/login.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML>

<base href="<%=basePath%>">

<title>登录</title>

<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrapValidator.min.css">
<link rel="stylesheet" href="css/login.css">

					排课系统

					<form id="form" class="form-horizontal"  method="post" action="login()"
						data-bv-feedbackicons-valid="glyphicon glyphicon-ok"
						data-bv-feedbackicons-invalid="glyphicon glyphicon-remove"
						data-bv-feedbackicons-validating="glyphicon glyphicon-refresh">

							用户名:

								<input type="text" name="username" class="form-control"
									id="inputUsername"  placeholder="用户名" required data-bv-trigger="blur" data-bv-notempty-message="用户名不能为空" />

							密码:

								<input type="<PASSWORD>" name="password" class="form-control"
									id="inputPassword" placeholder="密码" required data-bv-trigger="blur" data-bv-notempty-message="密码不能为空" />

							<button id="defaultSubmit" type="submit"
								class="btn btn-primary col-xs-offset-4 col-xs-5" >
								登 录
							</button>

					</form>

<file_sep>/ACSS/src/main/java/com/zsc/net11/util/Constant.java
package com.zsc.net11.util;

/**
 * 公共常量类
 *
 * @author 黄伟枞
 */
public abstract class Constant {

	/** 上课时间数量（一周） */
	public static final int TIME_AMOUNT = 42;

	/** 一天上课时间数 */
	public static final int TIMT_DAY = 6;
}

languages:
Java
INI
JavaScript
Java Server Pages

repo_language: Java

repo_name: huangweicong/ACSS