随着计算机以及网络的普及,教师与学生对辅助教学方式的要求也越来越高,在教学辅助方式上追求质量及效率。作为教学核心组成之一的作业管理也趋向更加便 捷快速的方式。
经过调查,现阶段高校进行作业管理的方式主要有三种:
情况一:老师与学生的课外教学互动通过公共邮箱,如老师一般把教学资料上传到公共邮箱供生下载,学生把电子版作业上交到公共邮箱。这种方 式的局限性是邮箱的容量有限,对于大容量邮件,服务器只保存有限 的时间而且老师难以统计学生提交作业的情况,也难以批改。
情况二:通过U 盘拷贝教师发布作业以及提交作业,这种方式的成本高,一旦U盘损坏会导致作业丢失。
情况三:部分有该方面技术的教师会建立起个人辅助教学网站,网站开发需花费教师较多的时间和精力,一旦建成,修改要手动编辑源代码,比较麻烦,而且教师的个人教学辅助网站相对分散,其共享性不强,可管理性较差。 针对目前的状况,很有必要开发一个操作简单,功能完备,为教师学生进行作业 管理提供便捷的在线作业管理系统,简化作业管理的步骤,从根本上解决作业提交
步骤复杂的问题。
演示视频:
【java毕业设计】基于ssm作业管理系统源码和论文
每次教授了新的章节或者内容之后,教师都有可能需要布置相应的作业或练习
以保证学生可以牢固掌握相应知识。作为教学的核心之一的作业管理,其传统的实
现方式步骤既繁琐又耗时,还不能很好的保证作业发布的即时性及可控性,即教师
无法在他需要的时候立即发布作业,教师也无法提前预设将要发布的作业,删除,
编辑,批改等操作也不够便捷。这时,作业管理系统的作用就体现出来了。教师可
以在网上发布自己的课程作业,而且还可以选择及时发布还是定时发布,对过期的
作业进行删除,查看学生作业提交的情况,批改学生作业等,既方便快捷也省时高
效。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.3.xsd">
<context:property-placeholder location="classpath:db.properties"/>
<!-- 配置数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource">
<!--数据库驱动 -->
<property name="driverClassName" value="${jdbc.driver}" />
<!--连接数据库的url -->
<property name="url" value="${jdbc.url}" />
<!--连接数据库的用户名 -->
<property name="username" value="${jdbc.username}" />
<!--连接数据库的密码 -->
<property name="password" value="${jdbc.password}" />
<!--最大连接数 -->
<property name="maxTotal" value="${jdbc.maxTotal}" />
<!--最大空闲连接 -->
<property name="maxIdle" value="${jdbc.maxIdle}" />
<!--初始化连接数 -->
<property name="initialSize" value="${jdbc.initialSize}" />
</bean>
<!--事务
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>-->
<!--开启事务
<tx:annotation-driven transaction-manager="transactionManager"/>-->
<!-- 配置工厂 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:mybatis-config.xml" />
</bean>
<!-- 基于mapper的接口 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="bysj.dao"/>
</bean>
<!-- 扫描相应包下的注解 -->
<context:component-scan base-package="bysj.service" />
</beans>
package bysj.controller;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.io.FileUtils;
import org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFHeader;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.xmlbeans.impl.xb.xmlschema.SpaceAttribute;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.zhenzi.sms.ZhenziSmsClient;
import bysj.po.HF;
import bysj.po.JS;
import bysj.po.KC;
import bysj.po.LY;
import bysj.po.XS;
import bysj.po.ZY;
import bysj.po.ZYSJ;
import bysj.service.HF_Service;
import bysj.service.KC_Service;
import bysj.service.LY_Service;
import bysj.service.XS_Service;
import bysj.service.ZYSJ_Service;
import bysj.service.ZY_Service;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@Controller
public class ZYSJ_Controller {
@Autowired
private ZYSJ_Service zysj_Service;
@Autowired
private LY_Service ly_Service;
@Autowired
private KC_Service kc_Service;
@Autowired
private ZY_Service zy_Service;
@Autowired
private HF_Service hf_Service;
@Autowired
private XS_Service xs_Service;
/*
* 针对excel表导出功能需求的作业上交情况查询
*/
@RequestMapping("/ZYSJ_select_all_excel")
private String ZYSJ_select_all_excel(HttpServletRequest request,HttpSession session,int kcid) {
List<JS> jss = (List<JS>)session.getAttribute("jsmsg");
KC kc = new KC();
kc.setKC_ID(kcid);
//根据kcid找课程相关信息,这里包含了excel表头部所需的内容
List<KC> kcs_header = this.kc_Service.KC_select_all(kc);
//根据kcid找zyid作业
ZY zy = new ZY();
zy.setKc(kc);
List<ZY> zys = this.zy_Service.ZY_select_all_byidasc(zy);
ArrayList<ZYSJ> zysj_list = new ArrayList<>();
ArrayList<ArrayList<ZYSJ>> zysjs_list = new ArrayList<>();
for(int i=0;i<zys.size();i++) {
//使用zysj_list前清理上一次循环赋的值
zysj_list = new ArrayList<>();
//根据zyid循环得到当前作业相关的学生成绩列表
ZYSJ zysj = new ZYSJ();
zysj.setZy(zys.get(i));
List<ZYSJ> zysjs = this.zysj_Service.ZYSJ_select_all(zysj);
for(int j=0;j<zysjs.size();j++) {
zysj_list.add(j, zysjs.get(j));
}
zysjs_list.add(i, zysj_list);
}
request.setAttribute("kcs_header", kcs_header);
request.setAttribute("zysjs_list", zysjs_list);
/*System.out.println("zysjs_list:"+zysjs_list.size());
for(int k=0;k<zysjs_list.size();k++) {
System.out.println("zysjs_list.get(j)"+zysjs_list.get(k).size());
for(int z=0;z<zysjs_list.get(k).size();z++) {
System.out.println(zysjs_list.get(k).get(z).getXs().getYh().getYH_ZH()+zysjs_list.get(k).get(z).getZy().getZY_MC()+zysjs_list.get(k).get(z).getZYSJ_CJ());
}
System.out.println("------------------------作业分割线------------------------");
}*/
/*ZY zy = new ZY();
if(zysj!=null) {
if(zysj.getZy()!=null) {
if(zysj.getZy().getZY_ID()>0) {
zy.setZY_ID(zysj.getZy().getZY_ID());
request.setAttribute("ZY_IDselected", zysj.getZy().getZY_ID());
String str = zysj.getZy().getZY_MC().replace("\'", "");
request.setAttribute("ZY_MCselected", str);
}
}
}
zy.setJs(jss.get(0));
zysj.setZy(zy);
List<ZYSJ> zysjsall = this.zysj_Service.ZYSJ_select_all(zysj);
List<ZYSJ> zysjs = new ArrayList<ZYSJ>();
int count=-1;
for(int i=0;i<zysjsall.size();i++) {
if(zysjsall.get(i).getZy().getZY_JSSJ().getTime()<new Date().getTime() && zysjsall.get(i).getZy().getZY_ZT().equals("已发布")状态考虑) {
count++;
zysjs.add(count, zysjsall.get(i));
}
}
request.setAttribute("zysjs", zysjs);*/
return "ZYSJ_select_all_selected_excel";
}
/*
* 作业上交情况查询
*/
@RequestMapping("/ZYSJ_select_all")
private String ZYSJ_select_all(HttpServletRequest request,ZYSJ zysj,HttpSession session) {
int flag = 0;
List<JS> jss = (List<JS>)session.getAttribute("jsmsg");
ZY zy = new ZY();
if(zysj!=null) {
if(zysj.getZy()!=null) {
if(zysj.getZy().getZY_ID()>0) {
zy.setZY_ID(zysj.getZy().getZY_ID());
flag = 1;
request.setAttribute("ZY_IDselected", zysj.getZy().getZY_ID());
String str = zysj.getZy().getZY_MC().replace("\'", "");
request.setAttribute("ZY_MCselected", str);
}
}
}
zy.setJs(jss.get(0));
zysj.setZy(zy);
List<ZYSJ> zysjsall = this.zysj_Service.ZYSJ_select_all(zysj);
List<ZYSJ> zysjs = new ArrayList<ZYSJ>();
int count=-1;
for(int i=0;i<zysjsall.size();i++) {
if(zysjsall.get(i).getZy().getZY_JSSJ().getTime()<new Date().getTime() && zysjsall.get(i).getZy().getZY_ZT().equals("已发布")/*状态考虑*/) {
count++;
zysjs.add(count, zysjsall.get(i));
}
}
request.setAttribute("zysjs", zysjs);
if(flag==0) {
return "ZYSJ_select_all";
}
else {
return "ZYSJ_select_all_selected";
}
}
/*
* 学生上交作业
* 学生上交作业附带发表留言
*/
@RequestMapping(value="/SJZY_update_sjzy",produces="text/html;charset=utf-8")
private String SJZY_update_sjzy(HttpServletRequest request,HttpSession session,int kcid,ZYSJ zysj,@RequestParam("LY_NR") String LY_NR,@RequestParam(value="file",required = false)CommonsMultipartFile partFile,@RequestParam(value="file-fujian",required = false)CommonsMultipartFile partFilefujian) {
/*
* 获取服务器路径,若文件保存在服务器,服务器变动时造成文件丢失
* String path = request.getServletContext().getRealPath("/upload");
*/
/*
* 绝对路径下存储
* String path = "E:\\大学\\毕业设计相关\\saveZY";
*/
/*
* 服务器存储作业
*/
String path = request.getSession().getServletContext().getRealPath("/zuoye");
String filename = partFile.getOriginalFilename();
String pathfujian = request.getSession().getServletContext().getRealPath("/fujian");
String filenamefujian = partFilefujian.getOriginalFilename();
if(filenamefujian!=null && filenamefujian!="") {
zysj.setZYSJ_FJ(filenamefujian);
}
else {
zysj.setZYSJ_FJ(null);
}
zysj.setZYSJ_ZT("已上交");
zysj.setZYSJ_WD(filename);
this.zysj_Service.ZYSJ_update_zysj(zysj);
System.out.println("已修改数据库");
String str = LY_NR.replace("\r\n", "<br/>").replaceAll(" ","").replace("\"", """);
//留言不为空
if(!str.isEmpty()) {
//判断是否已存在当前作业的留言,存在就覆盖(无法控制留言的附加情况,采用删除后重新添加),不存在就添加
LY ly = new LY();
ly.setZysj(zysj);
List<LY> lys = this.ly_Service.LY_select_all(ly);
if(lys.size()==0) {
ly.setLY_NR(str);
ly.setLY_SJ(new Date());
this.ly_Service.LY_insert(ly);
}
else{
this.ly_Service.LY_delete(lys.get(0).getLY_ID());
ly.setLY_NR(str);
ly.setLY_SJ(new Date());
this.ly_Service.LY_insert(ly);
}
}
List<ZYSJ> zysjs = this.zysj_Service.ZYSJ_select_all(zysj);
List<XS> xss = (List<XS>)session.getAttribute("xsmsg");
System.out.println("上传文档路径:"+path+"/"+zysjs.get(0).getZy().getZY_ID()+"/"+xss.get(0).getYh().getYH_ZH());
System.out.println("上传文档名字:"+filename);
System.out.println("上传附件路径:"+pathfujian+"/"+zysjs.get(0).getZy().getZY_ID()+"/"+xss.get(0).getYh().getYH_ZH());
System.out.println("上传附件名字:"+filenamefujian);
if(filename!=null && filename!="") {
try {
File file = new File(path+"/"+zysjs.get(0).getZy().getZY_ID()+"/"+xss.get(0).getYh().getYH_ZH()+"/"+filename);
InputStream inputStream = partFile.getInputStream();
FileUtils.copyInputStreamToFile(inputStream, file);
if(inputStream!=null){
inputStream.close();
System.out.println("已修改文档到指定路径");
}
} catch (Exception e) {
e.printStackTrace();
}
}
if(filenamefujian!=null && filenamefujian!="") {
try {
File filefujian = new File(pathfujian+"/"+zysjs.get(0).getZy().getZY_ID()+"/"+xss.get(0).getYh().getYH_ZH()+"/"+filenamefujian);
InputStream inputStream = partFile.getInputStream();
FileUtils.copyInputStreamToFile(inputStream, filefujian);
if(inputStream!=null){
inputStream.close();
System.out.println("已修改附件到指定路径");
}
} catch (Exception e) {
e.printStackTrace();
}
}
/*
if(filename.length()>=6) {
String docxfile = filename.substring(filename.length()-4);
if(docxfile.equals("docx")) {
String t=Thread.currentThread().getContextClassLoader().getResource("").getPath();
int num=t.indexOf(".metadata");
String path1=t.substring(1,num).replace('/', '\\')+"bysj01\\WebContent\\WEB-INF\\word";
try {
File file = new File(path1+"/"+filename);
file.mkdirs();
InputStream inputStream = partFile.getInputStream();
FileUtils.copyInputStreamToFile(inputStream, file);
if(inputStream!=null){
inputStream.close();
System.out.println("已将word文档特殊上传文件路径到:"+path1);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
*/
int flag = 0;
if(request.getParameter("flag")!=null) {
flag = 1;
}
if(flag == 0) {
return "redirect:XS_myZY";
}
else {
return "redirect:XS_myZY_now?kcid="+kcid;
}
}
/*
* 随机批阅,根据作业编号zyid返回zysj内容
*/
@RequestMapping("/ZYSJ_suijipiyue_neirong")
@ResponseBody
private void ZYSJ_suijipiyue_neirong(HttpServletRequest request,HttpServletResponse response,ZYSJ zysj) {
List<ZYSJ> zysjs = this.zysj_Service.ZYSJ_select_all(zysj);
response.setContentType("text/html;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
PrintWriter out;
try {
out = response.getWriter();
JSONArray jsonArray = new JSONArray();
if(zysjs.size()!=0) {
ArrayList<ZYSJ> zysjsweipingfen = new ArrayList<>();
for(int i=0;i<zysjs.size();i++) {
if(!zysjs.get(i).getZYSJ_ZT().equals("已评分")) {
if(zysjs.get(i).getZy().getZY_ZT().equals("已发布")) {
Date datejssj = zysjs.get(i).getZy().getZY_JSSJ();
Date datenow = new Date();
long datejssjshu = datejssj.getTime();
long datenowshu = datenow.getTime();
if(datejssjshu<=datenowshu) {
zysjsweipingfen.add(zysjs.get(i));
}
}
}
}
System.out.println("一共有:"+zysjsweipingfen.size()+"个未评分作业可以被抽取");
//有作业上交信息
if(zysjsweipingfen.size()!=0) {
double haha = Math.random() * zysjsweipingfen.size();
System.out.println("随机数生成测试:"+haha);
System.out.println((int)Math.ceil(haha));
int suijishuxiabiao = (int) Math.ceil((Math.random() * zysjsweipingfen.size()));
System.out.println("随机抽取到了第"+suijishuxiabiao+"个作业");
LY ly = new LY();
ZYSJ suijishuzysjid = new ZYSJ();
suijishuzysjid.setZYSJ_ID(zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_ID());
ly.setZysj(suijishuzysjid);
List<LY> lys = this.ly_Service.LY_select_all(ly);
//有留言
if(lys.size()!=0) {
//有附件,且文件名长度大于6
if(zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_WD()!=null && zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_WD().length()>=6) {
//是.docx文件
if(zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_WD().substring(zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_WD().length()-4).equals("docx")) {
System.out.println("判断是word文件了,稍后继续做操作");
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 4);
jsonObject.put("zysjid", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_ID());
jsonObject.put("zysjxsyhzh", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getYh().getYH_ZH());
jsonObject.put("zysjxsyhxm", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getXS_MC());
jsonObject.put("zysjzykcmc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_MC());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String strKCXQ = sdf.format(zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_XQ());
String strKCXQXQ = String.valueOf(strKCXQ.charAt(6));
jsonObject.put("zysjzykcxqxq", strKCXQXQ);
int strKCXQXN = Integer.valueOf(strKCXQ.substring(0, 4));
jsonObject.put("zysjzykcxqxn", strKCXQXN);
jsonObject.put("zysjzymc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getZY_MC());
jsonObject.put("lynr", lys.get(0).getLY_NR());
jsonObject.put("zysjfj", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_FJ());
//图片问题
jsonObject.put("zysjzyid", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getZY_ID());
jsonObject.put("zysjwd", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_WD());
jsonArray.add(jsonObject);
}
//不支持文件预览
else {
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 3);
jsonObject.put("zysjid", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_ID());
jsonObject.put("zysjxsyhzh", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getYh().getYH_ZH());
jsonObject.put("zysjxsyhxm", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getXS_MC());
jsonObject.put("zysjzykcmc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_MC());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String strKCXQ = sdf.format(zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_XQ());
String strKCXQXQ = String.valueOf(strKCXQ.charAt(6));
jsonObject.put("zysjzykcxqxq", strKCXQXQ);
int strKCXQXN = Integer.valueOf(strKCXQ.substring(0, 4));
jsonObject.put("zysjzykcxqxn", strKCXQXN);
jsonObject.put("zysjzymc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getZY_MC());
jsonObject.put("lynr", lys.get(0).getLY_NR());
jsonObject.put("zysjfj", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_FJ());
jsonArray.add(jsonObject);
}
}
//不支持文件预览
else {
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 3);
jsonObject.put("zysjid", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_ID());
jsonObject.put("zysjxsyhzh", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getYh().getYH_ZH());
jsonObject.put("zysjxsyhxm", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getXS_MC());
jsonObject.put("zysjzykcmc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_MC());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String strKCXQ = sdf.format(zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_XQ());
String strKCXQXQ = String.valueOf(strKCXQ.charAt(6));
jsonObject.put("zysjzykcxqxq", strKCXQXQ);
int strKCXQXN = Integer.valueOf(strKCXQ.substring(0, 4));
jsonObject.put("zysjzykcxqxn", strKCXQXN);
jsonObject.put("zysjzymc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getZY_MC());
jsonObject.put("lynr", lys.get(0).getLY_NR());
jsonObject.put("zysjfj", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_FJ());
jsonArray.add(jsonObject);
}
}
//没有留言
else {
//有附件,且文件名长度大于6
if(zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_WD()!=null && zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_WD().length()>=6) {
//是.docx文件
if(zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_WD().substring(zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_WD().length()-4).equals("docx")) {
System.out.println("判断是word文件了,稍后继续做操作");
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 2);
jsonObject.put("zysjid", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_ID());
jsonObject.put("zysjxsyhzh", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getYh().getYH_ZH());
jsonObject.put("zysjxsyhxm", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getXS_MC());
jsonObject.put("zysjzykcmc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_MC());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String strKCXQ = sdf.format(zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_XQ());
String strKCXQXQ = String.valueOf(strKCXQ.charAt(6));
jsonObject.put("zysjzykcxqxq", strKCXQXQ);
int strKCXQXN = Integer.valueOf(strKCXQ.substring(0, 4));
jsonObject.put("zysjzykcxqxn", strKCXQXN);
jsonObject.put("zysjzymc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getZY_MC());
jsonObject.put("zysjfj", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_FJ());
//图片问题
jsonObject.put("zysjzyid", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getZY_ID());
jsonObject.put("zysjwd", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_WD());
jsonArray.add(jsonObject);
}
//不支持文件预览
else {
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 1);
jsonObject.put("zysjid", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_ID());
jsonObject.put("zysjxsyhzh", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getYh().getYH_ZH());
jsonObject.put("zysjxsyhxm", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getXS_MC());
jsonObject.put("zysjzykcmc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_MC());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String strKCXQ = sdf.format(zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_XQ());
String strKCXQXQ = String.valueOf(strKCXQ.charAt(6));
jsonObject.put("zysjzykcxqxq", strKCXQXQ);
int strKCXQXN = Integer.valueOf(strKCXQ.substring(0, 4));
jsonObject.put("zysjzykcxqxn", strKCXQXN);
jsonObject.put("zysjzymc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getZY_MC());
jsonObject.put("zysjfj", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_FJ());
jsonArray.add(jsonObject);
}
}
//不支持文件预览
else {
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 1);
jsonObject.put("zysjid", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_ID());
jsonObject.put("zysjxsyhzh", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getYh().getYH_ZH());
jsonObject.put("zysjxsyhxm", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getXS_MC());
jsonObject.put("zysjzykcmc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_MC());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String strKCXQ = sdf.format(zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_XQ());
String strKCXQXQ = String.valueOf(strKCXQ.charAt(6));
jsonObject.put("zysjzykcxqxq", strKCXQXQ);
int strKCXQXN = Integer.valueOf(strKCXQ.substring(0, 4));
jsonObject.put("zysjzykcxqxn", strKCXQXN);
jsonObject.put("zysjzymc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getZY_MC());
jsonObject.put("zysjfj", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_FJ());
jsonArray.add(jsonObject);
}
}
}
//没有作业上交信息
else {
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 0);
jsonArray.add(jsonObject);
}
}
else {
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 0);
jsonArray.add(jsonObject);
}
out.println(jsonArray.toString());
} catch (IOException e) {
e.printStackTrace();
}
}
/*
* 随机批阅-继续批阅
*/
@RequestMapping("/ZYSJ_update_cjpd_jixupiyue")
@ResponseBody
private void ZYSJ_update_cjpd_jixupiyue(HttpServletRequest request,HttpServletResponse response,HttpSession session,int ZYSJ_ID,int ZYSJ_CJ,String lynr_insert,String hfnr_insert,int ZY_IDselected_suijipiyue) {
//成绩评定过程
List<JS> jss = (List<JS>)session.getAttribute("jsmsg");
ZYSJ zysjgetzyid = new ZYSJ();
zysjgetzyid.setZYSJ_ID(ZYSJ_ID);
List<ZYSJ> zysjzyid = this.zysj_Service.ZYSJ_select_all(zysjgetzyid);
//如果回复内容为空,表示此作业无留言 或 教师不回复,只需给定成绩,修改评分状态
if(hfnr_insert.isEmpty()) {
//给定成绩,修改评分状态
ZYSJ zysj = new ZYSJ();
zysj.setZYSJ_ID(ZYSJ_ID);
zysj.setZYSJ_ZT("已评分");
zysj.setZYSJ_CJ(ZYSJ_CJ);
this.zysj_Service.ZYSJ_update(zysj);
}
//回复内容不为空,在给定成绩、修改评分状态的同时对该作业上交的留言进行回复,并修改留言回复状态
else {
//给定成绩,修改评分状态
ZYSJ zysj = new ZYSJ();
zysj.setZYSJ_ID(ZYSJ_ID);
zysj.setZYSJ_ZT("已评分");
zysj.setZYSJ_CJ(ZYSJ_CJ);
this.zysj_Service.ZYSJ_update(zysj);
//留言回复
String str = hfnr_insert.replace("\r\n", "<br/>").replaceAll(" ","").replace("\"", """);
HF hf = new HF();
LY ly = new LY();
ZYSJ zysjtogether = new ZYSJ();
zysjtogether.setZYSJ_ID(ZYSJ_ID);
ly.setZysj(zysjtogether);
List<LY> lys = this.ly_Service.LY_select_all(ly);
hf.setLy(lys.get(0));
hf.setHF_SJ(new Date());
hf.setHF_NR(str);
this.hf_Service.HF_insert(hf);
//修改留言状态
/*List<LY> lystogether = this.ly_Service.LY_select_all(hf.getLy());*/
LY lytogether = lys.get(0);
lytogether.setLY_HFZT("已回复");
/*
* 发送短信,打开即调用
*/
ZhenziSmsClient client = new ZhenziSmsClient("https://sms_developer.zhenzikj.com", "103572", "c3aa61cf-5af3-4e63-bf63-10c0cb7b107a");
try {
client.send(lys.get(0).getZysj().getXs().getXS_LXDH(), "亲爱的"+lys.get(0).getZysj().getXs().getXS_MC()+"同学,您在"+lys.get(0).getZysj().getZy().getKc().getKC_MC()+"课程作业的疑问有新的回复,请及时登录系统查看!");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this.ly_Service.LY_update(lytogether);
}
/*
* 测试一下对该学生的上交作业文档增加页眉,表示已批改过
* 前提对象是.docx文档
*/
/*List<ZYSJ> zysjs = this.zysj_Service.ZYSJ_select_all(zysjgetzyid);*/
if(zysjzyid.get(0).getZYSJ_WD()!=null && zysjzyid.get(0).getZYSJ_WD().length()>=6) {
String docxfile = zysjzyid.get(0).getZYSJ_WD().substring(zysjzyid.get(0).getZYSJ_WD().length()-4);
if(docxfile.equals("docx")) {
System.out.println(zysjzyid.get(0).getZy().getZY_ID());
System.out.println(zysjzyid.get(0).getXs().getYh().getYH_ZH());
System.out.println(zysjzyid.get(0).getZYSJ_WD());
String path = request.getSession().getServletContext().getRealPath("/zuoye");
File is = new File(path+"/"+zysjzyid.get(0).getZy().getZY_ID()+"/"+zysjzyid.get(0).getXs().getYh().getYH_ZH()+"/"+zysjzyid.get(0).getZYSJ_WD());//文件路径
FileInputStream fis;
try {
fis = new FileInputStream(is);
XWPFDocument docx = new XWPFDocument(fis);//文档对象
CTP ctp = CTP.Factory.newInstance();
XWPFParagraph paragraph = new XWPFParagraph(ctp, docx);//段落对象
ctp.addNewR().addNewT().setStringValue(jss.get(0).getJS_MC()+";已批阅;"+(new Date().toString()));//设置页眉参数
ctp.addNewR().addNewT().setSpace(SpaceAttribute.Space.PRESERVE);
CTSectPr sectPr = docx.getDocument().getBody().isSetSectPr() ? docx.getDocument().getBody().getSectPr() : docx.getDocument().getBody().addNewSectPr();
XWPFHeaderFooterPolicy policy = new XWPFHeaderFooterPolicy(docx, sectPr);
XWPFHeader header = policy.createHeader(STHdrFtr.DEFAULT, new XWPFParagraph[] { paragraph });
header.setXWPFDocument(docx);
OutputStream os = new FileOutputStream(path+"/"+zysjzyid.get(0).getZy().getZY_ID()+"/"+zysjzyid.get(0).getXs().getYh().getYH_ZH()+"/"+zysjzyid.get(0).getZYSJ_WD());
docx.write(os);//输出到本地
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/*
* 发送短信,打开即调用
ZhenziSmsClient client = new ZhenziSmsClient("https://sms_developer.zhenzikj.com", "103572", "c3aa61cf-5af3-4e63-bf63-10c0cb7b107a");
try {
client.send(zysjzyid.get(0).getXs().getXS_LXDH(), "亲爱的"+zysjzyid.get(0).getXs().getXS_MC()+"同学,您"+zysjzyid.get(0).getZy().getKc().getKC_MC()+"课程作业:"+zysjzyid.get(0).getZy().getZY_MC()+",已被批阅,请及时登录系统查询!");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/
//返回json数据用于再次打开modal
ZYSJ zysj = new ZYSJ();
ZY zy = new ZY();
zy.setZY_ID(ZY_IDselected_suijipiyue);
zysj.setZy(zy);
List<ZYSJ> zysjs = this.zysj_Service.ZYSJ_select_all(zysj);
response.setContentType("text/html;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
PrintWriter out;
try {
out = response.getWriter();
JSONArray jsonArray = new JSONArray();
if(zysjs.size()!=0) {
ArrayList<ZYSJ> zysjsweipingfen = new ArrayList<>();
for(int i=0;i<zysjs.size();i++) {
if(!zysjs.get(i).getZYSJ_ZT().equals("已评分")) {
if(zysjs.get(i).getZy().getZY_ZT().equals("已发布")) {
Date datejssj = zysjs.get(i).getZy().getZY_JSSJ();
Date datenow = new Date();
long datejssjshu = datejssj.getTime();
long datenowshu = datenow.getTime();
if(datejssjshu<=datenowshu) {
zysjsweipingfen.add(zysjs.get(i));
}
}
}
}
System.out.println("一共有:"+zysjsweipingfen.size()+"个未评分作业可以被抽取");
//有作业上交信息
if(zysjsweipingfen.size()!=0) {
double haha = Math.random() * zysjsweipingfen.size();
System.out.println("随机数生成测试:"+haha);
System.out.println((int)Math.ceil(haha));
int suijishuxiabiao = (int) Math.ceil((Math.random() * zysjsweipingfen.size()));
System.out.println("随机抽取到了第"+suijishuxiabiao+"个作业");
LY ly = new LY();
ZYSJ suijishuzysjid = new ZYSJ();
suijishuzysjid.setZYSJ_ID(zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_ID());
ly.setZysj(suijishuzysjid);
List<LY> lys = this.ly_Service.LY_select_all(ly);
//有留言
if(lys.size()!=0) {
//有附件,且文件名长度大于6
if(zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_WD()!=null && zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_WD().length()>=6) {
//是.docx文件
if(zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_WD().substring(zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_WD().length()-4).equals("docx")) {
System.out.println("判断是word文件了,稍后继续做操作");
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 4);
jsonObject.put("zysjid", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_ID());
jsonObject.put("zysjxsyhzh", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getYh().getYH_ZH());
jsonObject.put("zysjxsyhxm", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getXS_MC());
jsonObject.put("zysjzykcmc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_MC());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String strKCXQ = sdf.format(zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_XQ());
String strKCXQXQ = String.valueOf(strKCXQ.charAt(6));
jsonObject.put("zysjzykcxqxq", strKCXQXQ);
int strKCXQXN = Integer.valueOf(strKCXQ.substring(0, 4));
jsonObject.put("zysjzykcxqxn", strKCXQXN);
jsonObject.put("zysjzymc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getZY_MC());
jsonObject.put("zysjfj", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_FJ());
jsonObject.put("lynr", lys.get(0).getLY_NR());
//图片问题
jsonObject.put("zysjzyid", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getZY_ID());
jsonObject.put("zysjwd", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_WD());
jsonArray.add(jsonObject);
}
//不支持文件预览
else {
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 3);
jsonObject.put("zysjid", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_ID());
jsonObject.put("zysjxsyhzh", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getYh().getYH_ZH());
jsonObject.put("zysjxsyhxm", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getXS_MC());
jsonObject.put("zysjzykcmc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_MC());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String strKCXQ = sdf.format(zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_XQ());
String strKCXQXQ = String.valueOf(strKCXQ.charAt(6));
jsonObject.put("zysjzykcxqxq", strKCXQXQ);
int strKCXQXN = Integer.valueOf(strKCXQ.substring(0, 4));
jsonObject.put("zysjzykcxqxn", strKCXQXN);
jsonObject.put("zysjzymc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getZY_MC());
jsonObject.put("lynr", lys.get(0).getLY_NR());
jsonObject.put("zysjfj", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_FJ());
jsonObject.put("zysjzyid", ZY_IDselected_suijipiyue);
jsonArray.add(jsonObject);
}
}
//不支持文件预览
else {
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 3);
jsonObject.put("zysjid", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_ID());
jsonObject.put("zysjxsyhzh", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getYh().getYH_ZH());
jsonObject.put("zysjxsyhxm", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getXS_MC());
jsonObject.put("zysjzykcmc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_MC());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String strKCXQ = sdf.format(zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_XQ());
String strKCXQXQ = String.valueOf(strKCXQ.charAt(6));
jsonObject.put("zysjzykcxqxq", strKCXQXQ);
int strKCXQXN = Integer.valueOf(strKCXQ.substring(0, 4));
jsonObject.put("zysjzykcxqxn", strKCXQXN);
jsonObject.put("zysjzymc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getZY_MC());
jsonObject.put("zysjfj", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_FJ());
jsonObject.put("lynr", lys.get(0).getLY_NR());
//图片问题
jsonObject.put("zysjzyid", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getZY_ID());
jsonObject.put("zysjwd", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_WD());
jsonArray.add(jsonObject);
}
}
//没有留言
else {
//有附件,且文件名长度大于6
if(zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_WD()!=null && zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_WD().length()>=6) {
//是.docx文件
if(zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_WD().substring(zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_WD().length()-4).equals("docx")) {
System.out.println("判断是word文件了,稍后继续做操作");
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 2);
jsonObject.put("zysjid", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_ID());
jsonObject.put("zysjxsyhzh", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getYh().getYH_ZH());
jsonObject.put("zysjxsyhxm", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getXS_MC());
jsonObject.put("zysjzykcmc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_MC());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String strKCXQ = sdf.format(zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_XQ());
String strKCXQXQ = String.valueOf(strKCXQ.charAt(6));
jsonObject.put("zysjzykcxqxq", strKCXQXQ);
int strKCXQXN = Integer.valueOf(strKCXQ.substring(0, 4));
jsonObject.put("zysjzykcxqxn", strKCXQXN);
jsonObject.put("zysjzymc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getZY_MC());
jsonObject.put("zysjfj", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_FJ());
//图片问题
jsonObject.put("zysjzyid", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getZY_ID());
jsonObject.put("zysjwd", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_WD());
jsonArray.add(jsonObject);
}
//不支持文件预览
else {
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 1);
jsonObject.put("zysjid", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_ID());
jsonObject.put("zysjxsyhzh", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getYh().getYH_ZH());
jsonObject.put("zysjxsyhxm", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getXS_MC());
jsonObject.put("zysjzykcmc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_MC());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String strKCXQ = sdf.format(zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_XQ());
String strKCXQXQ = String.valueOf(strKCXQ.charAt(6));
jsonObject.put("zysjzykcxqxq", strKCXQXQ);
int strKCXQXN = Integer.valueOf(strKCXQ.substring(0, 4));
jsonObject.put("zysjzykcxqxn", strKCXQXN);
jsonObject.put("zysjzymc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getZY_MC());
jsonObject.put("zysjfj", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_FJ());
jsonObject.put("zysjzyid", ZY_IDselected_suijipiyue);
jsonArray.add(jsonObject);
}
}
//不支持文件预览
else {
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 1);
jsonObject.put("zysjid", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_ID());
jsonObject.put("zysjxsyhzh", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getYh().getYH_ZH());
jsonObject.put("zysjxsyhxm", zysjsweipingfen.get(suijishuxiabiao-1).getXs().getXS_MC());
jsonObject.put("zysjzykcmc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_MC());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String strKCXQ = sdf.format(zysjsweipingfen.get(suijishuxiabiao-1).getZy().getKc().getKC_XQ());
String strKCXQXQ = String.valueOf(strKCXQ.charAt(6));
jsonObject.put("zysjzykcxqxq", strKCXQXQ);
int strKCXQXN = Integer.valueOf(strKCXQ.substring(0, 4));
jsonObject.put("zysjzykcxqxn", strKCXQXN);
jsonObject.put("zysjzymc", zysjsweipingfen.get(suijishuxiabiao-1).getZy().getZY_MC());
jsonObject.put("zysjfj", zysjsweipingfen.get(suijishuxiabiao-1).getZYSJ_FJ());
jsonObject.put("zysjzyid", ZY_IDselected_suijipiyue);
jsonArray.add(jsonObject);
}
}
}
//没有作业上交信息
else {
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 0);
jsonArray.add(jsonObject);
}
}
else {
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 0);
jsonArray.add(jsonObject);
}
out.println(jsonArray.toString());
} catch (IOException e) {
e.printStackTrace();
}
}
/*
* 作业成绩评定,根据回复内容情况进行回复数据的更新
*/
@RequestMapping("/ZYSJ_update_cjpd")
private String ZYSJ_update_cjpd(HttpServletRequest request,HttpSession session,int ZYSJ_ID,int ZYSJ_CJ,@RequestParam("flag") int flag,String lynr_insert,String hfnr_insert) {
List<JS> jss = (List<JS>)session.getAttribute("jsmsg");
ZYSJ zysjgetzyid = new ZYSJ();
zysjgetzyid.setZYSJ_ID(ZYSJ_ID);
List<ZYSJ> zysjzyid = this.zysj_Service.ZYSJ_select_all(zysjgetzyid);
//如果回复内容为空,表示此作业无留言 或 教师不回复,只需给定成绩,修改评分状态
if(hfnr_insert.isEmpty()) {
//给定成绩,修改评分状态
ZYSJ zysj = new ZYSJ();
zysj.setZYSJ_ID(ZYSJ_ID);
zysj.setZYSJ_ZT("已评分");
zysj.setZYSJ_CJ(ZYSJ_CJ);
this.zysj_Service.ZYSJ_update(zysj);
}
//回复内容不为空,在给定成绩、修改评分状态的同时对该作业上交的留言进行回复,并修改留言回复状态
else {
//给定成绩,修改评分状态
ZYSJ zysj = new ZYSJ();
zysj.setZYSJ_ID(ZYSJ_ID);
zysj.setZYSJ_ZT("已评分");
zysj.setZYSJ_CJ(ZYSJ_CJ);
this.zysj_Service.ZYSJ_update(zysj);
//留言回复
String str = hfnr_insert.replace("\r\n", "<br/>").replaceAll(" ","").replace("\"", """);
HF hf = new HF();
LY ly = new LY();
ZYSJ zysjtogether = new ZYSJ();
zysjtogether.setZYSJ_ID(ZYSJ_ID);
ly.setZysj(zysjtogether);
List<LY> lys = this.ly_Service.LY_select_all(ly);
hf.setLy(lys.get(0));
hf.setHF_SJ(new Date());
hf.setHF_NR(str);
this.hf_Service.HF_insert(hf);
//修改留言状态
/*List<LY> lystogether = this.ly_Service.LY_select_all(hf.getLy());*/
LY lytogether = lys.get(0);
lytogether.setLY_HFZT("已回复");
/*
* 发送短信,打开即调用
*/
ZhenziSmsClient client = new ZhenziSmsClient("https://sms_developer.zhenzikj.com", "103572", "c3aa61cf-5af3-4e63-bf63-10c0cb7b107a");
try {
client.send(lys.get(0).getZysj().getXs().getXS_LXDH(), "亲爱的"+lys.get(0).getZysj().getXs().getXS_MC()+"同学,您在"+lys.get(0).getZysj().getZy().getKc().getKC_MC()+"课程作业的疑问有新的回复,请及时登录系统查看!");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this.ly_Service.LY_update(lytogether);
}
/*
* 测试一下对该学生的上交作业文档增加页眉,表示已批改过
* 前提对象是.docx文档
*/
/*List<ZYSJ> zysjs = this.zysj_Service.ZYSJ_select_all(zysjgetzyid);*/
if(zysjzyid.get(0).getZYSJ_WD()!=null && zysjzyid.get(0).getZYSJ_WD().length()>=6) {
String docxfile = zysjzyid.get(0).getZYSJ_WD().substring(zysjzyid.get(0).getZYSJ_WD().length()-4);
if(docxfile.equals("docx")) {
System.out.println(zysjzyid.get(0).getZy().getZY_ID());
System.out.println(zysjzyid.get(0).getXs().getYh().getYH_ZH());
System.out.println(zysjzyid.get(0).getZYSJ_WD());
String path = request.getSession().getServletContext().getRealPath("/zuoye");
File is = new File(path+"/"+zysjzyid.get(0).getZy().getZY_ID()+"/"+zysjzyid.get(0).getXs().getYh().getYH_ZH()+"/"+zysjzyid.get(0).getZYSJ_WD());//文件路径
FileInputStream fis;
try {
fis = new FileInputStream(is);
XWPFDocument docx = new XWPFDocument(fis);//文档对象
CTP ctp = CTP.Factory.newInstance();
XWPFParagraph paragraph = new XWPFParagraph(ctp, docx);//段落对象
ctp.addNewR().addNewT().setStringValue(jss.get(0).getJS_MC()+";已批阅;"+(new Date().toString()));//设置页眉参数
ctp.addNewR().addNewT().setSpace(SpaceAttribute.Space.PRESERVE);
CTSectPr sectPr = docx.getDocument().getBody().isSetSectPr() ? docx.getDocument().getBody().getSectPr() : docx.getDocument().getBody().addNewSectPr();
XWPFHeaderFooterPolicy policy = new XWPFHeaderFooterPolicy(docx, sectPr);
XWPFHeader header = policy.createHeader(STHdrFtr.DEFAULT, new XWPFParagraph[] { paragraph });
header.setXWPFDocument(docx);
OutputStream os = new FileOutputStream(path+"/"+zysjzyid.get(0).getZy().getZY_ID()+"/"+zysjzyid.get(0).getXs().getYh().getYH_ZH()+"/"+zysjzyid.get(0).getZYSJ_WD());
docx.write(os);//输出到本地
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/*
* 发送短信,打开即调用
ZhenziSmsClient client = new ZhenziSmsClient("https://sms_developer.zhenzikj.com", "103572", "c3aa61cf-5af3-4e63-bf63-10c0cb7b107a");
try {
client.send(zysjzyid.get(0).getXs().getXS_LXDH(), "亲爱的"+zysjzyid.get(0).getXs().getXS_MC()+"同学,您"+zysjzyid.get(0).getZy().getKc().getKC_MC()+"课程作业:"+zysjzyid.get(0).getZy().getZY_MC()+",已被批阅,请及时登录系统查询!");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/
if(flag==0) {
return "redirect:ZYSJ_select_all";
}
else {
return "redirect:ZYSJ_select_all?zy.ZY_ID="+zysjzyid.get(0).getZy().getZY_ID()+"&zy.ZY_MC="+zysjzyid.get(0).getZy().getZY_MC();
}
}
/*
* 作业成绩评定修改
*/
@RequestMapping("/ZYSJ_update")
private String ZYSJ_update(HttpServletRequest request,HttpSession session,ZYSJ zysj,String lynr_update,String hfnr_update,RedirectAttributes attr) {
zysj.setZYSJ_ZT("已评分");
this.zysj_Service.ZYSJ_update(zysj);
LY lycheck = new LY();
lycheck.setZysj(zysj);
List<LY> lyscheck = this.ly_Service.LY_select_all(lycheck);
/*
* 修改成绩时对是否有留言 是否有回复 进行修改判断
*/
if(lyscheck.size()!=0) {
if(hfnr_update!=null && hfnr_update!="") {
//留言回复
String str = hfnr_update.replace("\r\n", "<br/>").replaceAll(" ","").replace("\"", """);
HF hfcheck = new HF();
hfcheck.setLy(lyscheck.get(0));
List<HF> hfscheck = this.hf_Service.HF_select_all(hfcheck);
LY ly = new LY();
ly.setZysj(zysj);
List<LY> lys = this.ly_Service.LY_select_all(ly);
if(hfscheck.size()!=0) {
hfscheck.get(0).setLy(lys.get(0));
hfscheck.get(0).setHF_SJ(new Date());
hfscheck.get(0).setHF_NR(str);
this.hf_Service.HF_update(hfscheck.get(0));
}
else {
hfcheck.setHF_SJ(new Date());
hfcheck.setHF_NR(str);
this.hf_Service.HF_insert(hfcheck);
}
//修改留言状态
/*List<LY> lystogether = this.ly_Service.LY_select_all(hf.getLy());*/
LY lytogether = lys.get(0);
lytogether.setLY_HFZT("已回复");
/*
* 发送短信,打开即调用
*/
ZhenziSmsClient client = new ZhenziSmsClient("https://sms_developer.zhenzikj.com", "103572", "c3aa61cf-5af3-4e63-bf63-10c0cb7b107a");
try {
client.send(lys.get(0).getZysj().getXs().getXS_LXDH(), "亲爱的"+lys.get(0).getZysj().getXs().getXS_MC()+"同学,您在"+lys.get(0).getZysj().getZy().getKc().getKC_MC()+"课程作业的疑问有新的回复,请及时登录系统查看!");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this.ly_Service.LY_update(lytogether);
}
else {
HF hf = new HF();
hf.setLy(lyscheck.get(0));
List<HF> hfs = this.hf_Service.HF_select_all(hf);
if(hfs.size()!=0) {
this.hf_Service.HF_delete(hfs.get(0).getHF_ID());
}
LY lytogether = lyscheck.get(0);
lytogether.setLY_HFZT("未回复");
this.ly_Service.LY_update(lytogether);
}
}
String ZY_ID = request.getParameter("ZY_IDselected");
String ZY_MC = request.getParameter("ZY_MCselected");
if(ZY_ID!=null && Integer.parseInt(ZY_ID)>0) {
attr.addAttribute("zy.ZY_ID",Integer.parseInt(ZY_ID));
}
if(ZY_MC!=null && ZY_MC!="") {
attr.addAttribute("zy.ZY_MC",ZY_MC);
}
return "redirect:ZYSJ_select_all";
}
/*
* 通过作业信息查询该作业的上交情况
*/
@RequestMapping("/ZYSJ_select_all_byZYID")
@ResponseBody
private void ZYSJ_select_all_byZYID(HttpServletRequest request,HttpServletResponse response,ZYSJ zysj) {
List<ZYSJ> zysjs = this.zysj_Service.ZYSJ_select_all(zysj);
response.setContentType("text/html;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
PrintWriter out;
try {
out = response.getWriter();
JSONArray jsonArray = new JSONArray();
for(int i=0;i<zysjs.size();i++) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("byZYID_zysjid", zysjs.get(i).getZYSJ_ID());
jsonObject.put("byZYID_zyid", zysjs.get(i).getZy().getZY_ID());
jsonObject.put("byZYID_zymc", zysjs.get(i).getZy().getZY_MC());
jsonObject.put("byZYID_zysjwd", zysjs.get(i).getZYSJ_WD());
jsonObject.put("byZYID_zyxsyhzh", zysjs.get(i).getXs().getYh().getYH_ZH());
jsonObject.put("byZYID_zyxsmc", zysjs.get(i).getXs().getXS_MC());
jsonArray.add(jsonObject);
}
out.println(jsonArray.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
2.Java 是面向对象的
Java 是一种面向对象的编程语言。除了简单的类型,如数字和布尔算子之外,
Java 中的大部分都是对象。
正如任何面向对象的语言一样,Java 代码也按类组织。每个类定义一组规定
对象行为的方法。一个类可以继承另一个类的行为。在类的根层次上,通常是类
对象。
3.Java 是静态类型的
在一个 Java 程序中,必须定义所用对象(数字、字符、数组等)的类型。这有
助于编程人员很快发现问题,因为当程序编译时可以检测类型错误。
不过,Java 系统中的对象也有动态类型。要求一个对象为动态类型往往是可
能的,所以编程人员写的程序可以对不同类型的对象做不同的事。
4.Java 是编译型的
当运行 Java 程序时,它首先被编译成字节代码。字节代码非常类似于机器指
令,所以 Java 程序非常高效。然而,字节代码并不专对一种特定的机器,所以 Java
程序无需重新编译便可在众多不同的计算机上执行。
Java 源程序被编译成类文件,它相当于程序的字节代码表现。在一个 Java 类
文件中,所有对方法及实例变量的参照均按名进行,并在第一次执行代码时加以
分辨。这使得代码更通用,更不易受修改的影响,而仍具高效。
5.Java 是体系结构中立的
Java 语言对每种计算机都一样。比如,简单的类型都是不变的:整数总是32
位,长整数总是 64 位。令人奇怪的是,诸如 C 及 C++等时髦的编程语言却不是这
样。由于这些语言定义如此自由,每种编译器及开发环境便各有不同了,这使程
序的移植成为讨厌的问题。Java 程序的移植却很容易,而且不需要进行重新编译。
6.Java 是健全的
Java 程序不可能造成计算机崩溃。Java 系统仔细检测对内存的每次访问,确
认它是合法的,而且不致引起任何问题。
不过,即使 Java 程序也可能有错误。如果出现某种出乎意料之事,程序不会
崩溃,而把该例外抛弃。程序会发现这类例外,并加以处理。