Blame view

src/com/fh/controller/sunvote/coursemanagement/CourseManagementController.java 7.96 KB
57330ff4   孙向锦   添加一些模块信息
1
2
3
4
5
6
7
8
9
10
  package com.fh.controller.sunvote.coursemanagement;
  
  import java.io.PrintWriter;
  import java.text.DateFormat;
  import java.text.SimpleDateFormat;
  import java.util.ArrayList;
  import java.util.Date;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
8ee66e91   孙向锦   更新链接
11
  
57330ff4   孙向锦   添加一些模块信息
12
  import javax.annotation.Resource;
8ee66e91   孙向锦   更新链接
13
  
57330ff4   孙向锦   添加一些模块信息
14
15
16
17
18
19
20
  import org.springframework.beans.propertyeditors.CustomDateEditor;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.WebDataBinder;
  import org.springframework.web.bind.annotation.InitBinder;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.ResponseBody;
  import org.springframework.web.servlet.ModelAndView;
8ee66e91   孙向锦   更新链接
21
  
57330ff4   孙向锦   添加一些模块信息
22
23
24
25
26
27
28
29
  import com.fh.controller.base.BaseController;
  import com.fh.entity.Page;
  import com.fh.util.AppUtil;
  import com.fh.util.ObjectExcelView;
  import com.fh.util.PageData;
  import com.fh.util.Jurisdiction;
  import com.fh.util.Tools;
  import com.fh.service.sunvote.coursemanagement.CourseManagementManager;
8ee66e91   孙向锦   更新链接
30
31
32
  import com.fh.service.sunvote.sclass.SClassManager;
  import com.fh.service.sunvote.subject.SubjectManager;
  import com.fh.service.sunvote.teacher.TeacherManager;
57330ff4   孙向锦   添加一些模块信息
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  
  /** 
   * 说明:任课管理
   * 创建人:Elvis
   * 创建时间:2018-04-26
   */
  @Controller
  @RequestMapping(value="/coursemanagement")
  public class CourseManagementController extends BaseController {
  	
  	String menuUrl = "coursemanagement/list.do"; //菜单地址(权限用)
  	@Resource(name="coursemanagementService")
  	private CourseManagementManager coursemanagementService;
  	
8ee66e91   孙向锦   更新链接
47
48
49
50
51
52
53
54
55
  	@Resource(name="teacherService")
  	private TeacherManager teacherService;
  	
  	@Resource(name="sclassService")
  	private SClassManager sclassService;
  	
  	@Resource(name="subjectService")
  	private SubjectManager subjectService;
  	
57330ff4   孙向锦   添加一些模块信息
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
  	/**保存
  	 * @param
  	 * @throws Exception
  	 */
  	@RequestMapping(value="/save")
  	public ModelAndView save() throws Exception{
  		logBefore(logger, Jurisdiction.getUsername()+"新增CourseManagement");
  		if(!Jurisdiction.buttonJurisdiction(menuUrl, "add")){return null;} //校验权限
  		ModelAndView mv = this.getModelAndView();
  		PageData pd = new PageData();
  		pd = this.getPageData();
  		coursemanagementService.save(pd);
  		mv.addObject("msg","success");
  		mv.setViewName("save_result");
  		return mv;
  	}
  	
  	/**删除
  	 * @param out
  	 * @throws Exception
  	 */
  	@RequestMapping(value="/delete")
  	public void delete(PrintWriter out) throws Exception{
  		logBefore(logger, Jurisdiction.getUsername()+"删除CourseManagement");
  		if(!Jurisdiction.buttonJurisdiction(menuUrl, "del")){return;} //校验权限
  		PageData pd = new PageData();
  		pd = this.getPageData();
  		coursemanagementService.delete(pd);
  		out.write("success");
  		out.close();
  	}
  	
  	/**修改
  	 * @param
  	 * @throws Exception
  	 */
  	@RequestMapping(value="/edit")
  	public ModelAndView edit() throws Exception{
  		logBefore(logger, Jurisdiction.getUsername()+"修改CourseManagement");
  		if(!Jurisdiction.buttonJurisdiction(menuUrl, "edit")){return null;} //校验权限
  		ModelAndView mv = this.getModelAndView();
  		PageData pd = new PageData();
  		pd = this.getPageData();
  		coursemanagementService.edit(pd);
  		mv.addObject("msg","success");
  		mv.setViewName("save_result");
  		return mv;
  	}
  	
  	/**列表
  	 * @param page
  	 * @throws Exception
  	 */
  	@RequestMapping(value="/list")
  	public ModelAndView list(Page page) throws Exception{
  		logBefore(logger, Jurisdiction.getUsername()+"列表CourseManagement");
  		//if(!Jurisdiction.buttonJurisdiction(menuUrl, "cha")){return null;} //校验权限(无权查看时页面会有提示,如果不注释掉这句代码就无法进入列表页面,所以根据情况是否加入本句代码)
  		ModelAndView mv = this.getModelAndView();
  		PageData pd = new PageData();
  		pd = this.getPageData();
  		String keywords = pd.getString("keywords");				//关键词检索条件
  		if(null != keywords && !"".equals(keywords)){
  			pd.put("keywords", keywords.trim());
  		}
  		page.setPd(pd);
  		List<PageData>	varList = coursemanagementService.list(page);	//列出CourseManagement列表
  		mv.setViewName("sunvote/coursemanagement/coursemanagement_list");
  		mv.addObject("varList", varList);
  		mv.addObject("pd", pd);
  		mv.addObject("QX",Jurisdiction.getHC());	//按钮权限
  		return mv;
  	}
  	
  	/**去新增页面
  	 * @param
  	 * @throws Exception
  	 */
  	@RequestMapping(value="/goAdd")
  	public ModelAndView goAdd()throws Exception{
  		ModelAndView mv = this.getModelAndView();
  		PageData pd = new PageData();
  		pd = this.getPageData();
  		mv.setViewName("sunvote/coursemanagement/coursemanagement_edit");
8ee66e91   孙向锦   更新链接
139
140
141
142
143
144
145
146
  		
  		List<PageData> teachers = teacherService.listAll(pd);
  		mv.addObject("teachers",teachers);
  		List<PageData> classs = sclassService.listAll(pd);
  		mv.addObject("classs",classs);
  		List<PageData> subjects = subjectService.listAll(pd);
  		mv.addObject("subjects", subjects);
  		
57330ff4   孙向锦   添加一些模块信息
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
  		mv.addObject("msg", "save");
  		mv.addObject("pd", pd);
  		return mv;
  	}	
  	
  	 /**去修改页面
  	 * @param
  	 * @throws Exception
  	 */
  	@RequestMapping(value="/goEdit")
  	public ModelAndView goEdit()throws Exception{
  		ModelAndView mv = this.getModelAndView();
  		PageData pd = new PageData();
  		pd = this.getPageData();
  		pd = coursemanagementService.findById(pd);	//根据ID读取
  		mv.setViewName("sunvote/coursemanagement/coursemanagement_edit");
8ee66e91   孙向锦   更新链接
163
164
165
166
167
168
169
  		List<PageData> teachers = teacherService.listAll(pd);
  		mv.addObject("teachers",teachers);
  		List<PageData> classs = sclassService.listAll(pd);
  		mv.addObject("classs",classs);
  		List<PageData> subjects = subjectService.listAll(pd);
  		mv.addObject("subjects", subjects);
  		
57330ff4   孙向锦   添加一些模块信息
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
  		mv.addObject("msg", "edit");
  		mv.addObject("pd", pd);
  		return mv;
  	}	
  	
  	 /**批量删除
  	 * @param
  	 * @throws Exception
  	 */
  	@RequestMapping(value="/deleteAll")
  	@ResponseBody
  	public Object deleteAll() throws Exception{
  		logBefore(logger, Jurisdiction.getUsername()+"批量删除CourseManagement");
  		if(!Jurisdiction.buttonJurisdiction(menuUrl, "del")){return null;} //校验权限
  		PageData pd = new PageData();		
  		Map<String,Object> map = new HashMap<String,Object>();
  		pd = this.getPageData();
  		List<PageData> pdList = new ArrayList<PageData>();
  		String DATA_IDS = pd.getString("DATA_IDS");
  		if(null != DATA_IDS && !"".equals(DATA_IDS)){
  			String ArrayDATA_IDS[] = DATA_IDS.split(",");
  			coursemanagementService.deleteAll(ArrayDATA_IDS);
  			pd.put("msg", "ok");
  		}else{
  			pd.put("msg", "no");
  		}
  		pdList.add(pd);
  		map.put("list", pdList);
  		return AppUtil.returnObject(pd, map);
  	}
  	
  	 /**导出到excel
  	 * @param
  	 * @throws Exception
  	 */
  	@RequestMapping(value="/excel")
  	public ModelAndView exportExcel() throws Exception{
  		logBefore(logger, Jurisdiction.getUsername()+"导出CourseManagement到excel");
  		if(!Jurisdiction.buttonJurisdiction(menuUrl, "cha")){return null;}
  		ModelAndView mv = new ModelAndView();
  		PageData pd = new PageData();
  		pd = this.getPageData();
  		Map<String,Object> dataMap = new HashMap<String,Object>();
  		List<String> titles = new ArrayList<String>();
  		titles.add("老师");	//1
  		titles.add("班级ID");	//2
  		titles.add("科目");	//3
  		titles.add("开始时间");	//4
  		titles.add("结束时间");	//5
  		titles.add("备注");	//6
  		dataMap.put("titles", titles);
  		List<PageData> varOList = coursemanagementService.listAll(pd);
  		List<PageData> varList = new ArrayList<PageData>();
  		for(int i=0;i<varOList.size();i++){
  			PageData vpd = new PageData();
  			vpd.put("var1", varOList.get(i).get("TEACHER_ID").toString());	//1
  			vpd.put("var2", varOList.get(i).getString("CLASS_ID"));	    //2
  			vpd.put("var3", varOList.get(i).getString("SUBJECT_ID"));	    //3
  			vpd.put("var4", varOList.get(i).getString("START_DATE"));	    //4
  			vpd.put("var5", varOList.get(i).getString("END_DATE"));	    //5
  			vpd.put("var6", varOList.get(i).getString("REMARK"));	    //6
  			varList.add(vpd);
  		}
  		dataMap.put("varList", varList);
  		ObjectExcelView erv = new ObjectExcelView();
  		mv = new ModelAndView(erv,dataMap);
  		return mv;
  	}
  	
  	@InitBinder
  	public void initBinder(WebDataBinder binder){
  		DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
  		binder.registerCustomEditor(Date.class, new CustomDateEditor(format,true));
  	}
  }