Blame view

src/com/fh/controller/sunvote/subject/SubjectController.java 9.45 KB
7db3ebeb   孙向锦   添加一些模块
1
2
3
4
5
6
7
8
9
10
  package com.fh.controller.sunvote.subject;
  
  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;
0e4da37e   孙向锦   学校管理员界面
11
  
7db3ebeb   孙向锦   添加一些模块
12
  import javax.annotation.Resource;
0e4da37e   孙向锦   学校管理员界面
13
  
7db3ebeb   孙向锦   添加一些模块
14
15
16
17
  import org.springframework.beans.propertyeditors.CustomDateEditor;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.WebDataBinder;
  import org.springframework.web.bind.annotation.InitBinder;
837ae11d   孙向锦   添加班長管理
18
  import org.springframework.web.bind.annotation.RequestBody;
7db3ebeb   孙向锦   添加一些模块
19
20
21
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.ResponseBody;
  import org.springframework.web.servlet.ModelAndView;
0e4da37e   孙向锦   学校管理员界面
22
  
7db3ebeb   孙向锦   添加一些模块
23
24
  import com.fh.controller.base.BaseController;
  import com.fh.entity.Page;
837ae11d   孙向锦   添加班長管理
25
26
  import com.fh.service.sunvote.schoolgradesubject.SchoolGradeSubjectManager;
  import com.fh.service.sunvote.subject.SubjectManager;
7db3ebeb   孙向锦   添加一些模块
27
  import com.fh.util.AppUtil;
837ae11d   孙向锦   添加班長管理
28
  import com.fh.util.Jurisdiction;
7db3ebeb   孙向锦   添加一些模块
29
30
  import com.fh.util.ObjectExcelView;
  import com.fh.util.PageData;
837ae11d   孙向锦   添加班長管理
31
  import com.google.gson.Gson;
7db3ebeb   孙向锦   添加一些模块
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  
  /** 
   * 说明:科目
   * 创建人:Elvis
   * 创建时间:2018-04-25
   */
  @Controller
  @RequestMapping(value="/subject")
  public class SubjectController extends BaseController {
  	
  	String menuUrl = "subject/list.do"; //菜单地址(权限用)
  	@Resource(name="subjectService")
  	private SubjectManager subjectService;
  	
0e4da37e   孙向锦   学校管理员界面
46
47
48
  	@Resource(name="schoolgradesubjectService")
  	private SchoolGradeSubjectManager schoolgradesubjectService;
  	
7db3ebeb   孙向锦   添加一些模块
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  	/**保存
  	 * @param
  	 * @throws Exception
  	 */
  	@RequestMapping(value="/save")
  	public ModelAndView save() throws Exception{
  		logBefore(logger, Jurisdiction.getUsername()+"新增Subject");
  		if(!Jurisdiction.buttonJurisdiction(menuUrl, "add")){return null;} //校验权限
  		ModelAndView mv = this.getModelAndView();
  		PageData pd = new PageData();
  		pd = this.getPageData();
  		subjectService.save(pd);
  		mv.addObject("msg","success");
  		mv.setViewName("save_result");
  		return mv;
  	}
  	
0e4da37e   孙向锦   学校管理员界面
66
67
68
69
70
71
72
73
74
75
76
77
78
  	/**保存
  	 * @param
  	 * @throws Exception
  	 */
  	@RequestMapping(value="/save2")
  	public ModelAndView save2() throws Exception{
  		logBefore(logger, Jurisdiction.getUsername()+"新增SchoolGradeSubject");
  		ModelAndView mv = this.getModelAndView();
  		PageData pd = new PageData();
  		pd = this.getPageData();
  		pd.put("SCHOOLGRADESUBJECT_ID", this.get32UUID());	//主键
  		schoolgradesubjectService.save(pd);
  		mv.addObject("msg","success");
837ae11d   孙向锦   添加班長管理
79
  		mv.setViewName("save_result2");
0e4da37e   孙向锦   学校管理员界面
80
81
82
  		return mv;
  	}
  	
7db3ebeb   孙向锦   添加一些模块
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
  	/**删除
  	 * @param out
  	 * @throws Exception
  	 */
  	@RequestMapping(value="/delete")
  	public void delete(PrintWriter out) throws Exception{
  		logBefore(logger, Jurisdiction.getUsername()+"删除Subject");
  		if(!Jurisdiction.buttonJurisdiction(menuUrl, "del")){return;} //校验权限
  		PageData pd = new PageData();
  		pd = this.getPageData();
  		subjectService.delete(pd);
  		out.write("success");
  		out.close();
  	}
  	
  	/**修改
  	 * @param
  	 * @throws Exception
  	 */
  	@RequestMapping(value="/edit")
  	public ModelAndView edit() throws Exception{
  		logBefore(logger, Jurisdiction.getUsername()+"修改Subject");
  		if(!Jurisdiction.buttonJurisdiction(menuUrl, "edit")){return null;} //校验权限
  		ModelAndView mv = this.getModelAndView();
  		PageData pd = new PageData();
  		pd = this.getPageData();
  		subjectService.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()+"列表Subject");
  		//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 = subjectService.list(page);	//列出Subject列表
  		mv.setViewName("sunvote/subject/subject_list");
  		mv.addObject("varList", varList);
6b3a5ad0   孙向锦   添加管理员界面
134
135
136
137
138
139
140
141
142
143
  		mv.addObject("pd", pd);
  		mv.addObject("QX",Jurisdiction.getHC());	//按钮权限
  		return mv;
  	}
  	
  	/**列表
  	 * @param page
  	 * @throws Exception
  	 */
  	@RequestMapping(value="/listcs")
cba5931f   孙向锦   添加翻页
144
  	public ModelAndView listcs(Page page) throws Exception{
6b3a5ad0   孙向锦   添加管理员界面
145
146
147
148
149
  		logBefore(logger, Jurisdiction.getUsername()+"列表Subject");
  		//if(!Jurisdiction.buttonJurisdiction(menuUrl, "cha")){return null;} //校验权限(无权查看时页面会有提示,如果不注释掉这句代码就无法进入列表页面,所以根据情况是否加入本句代码)
  		ModelAndView mv = this.getModelAndView();
  		PageData pd = new PageData();
  		pd = this.getPageData();
cba5931f   孙向锦   添加翻页
150
  		page.setPd(pd);
54a5b6ad   jack   1.英文翻译
151
  		page.setLangIsChina(isChineseLanguageClient());
cba5931f   孙向锦   添加翻页
152
  		List<PageData>	varList = subjectService.listAllSchool(page);	//列出Subject列表
54a5b6ad   jack   1.英文翻译
153
154
155
156
157
  		if(isChineseLanguageClient()){
  			mv.setViewName("sunvote/subject/subject_list2");
  		}else{
  			mv.setViewName("sunvote/subject/en_subject_list2");
  		}
6b3a5ad0   孙向锦   添加管理员界面
158
  		mv.addObject("varList", varList);
7db3ebeb   孙向锦   添加一些模块
159
160
161
162
163
  		mv.addObject("pd", pd);
  		mv.addObject("QX",Jurisdiction.getHC());	//按钮权限
  		return mv;
  	}
  	
837ae11d   孙向锦   添加班長管理
164
165
166
167
168
169
170
171
172
173
174
175
176
177
  	/**列表
  	 * @param page
  	 * @throws Exception
  	 */
  	@RequestMapping(value="/listdata",produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public String listData() throws Exception{
  		PageData pd = new PageData();
  		pd = this.getPageData();
  		List<PageData>	varList = subjectService.listAllSchool(pd);	//列出Subject列表
  		Gson gson = new Gson();
  		return gson.toJson(varList);
  	}
  	
7db3ebeb   孙向锦   添加一些模块
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
  	/**去新增页面
  	 * @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/subject/subject_edit");
  		mv.addObject("msg", "save");
  		mv.addObject("pd", pd);
  		return mv;
  	}	
  	
0e4da37e   孙向锦   学校管理员界面
193
194
195
196
197
198
199
200
201
  	/**去新增页面
  	 * @param
  	 * @throws Exception
  	 */
  	@RequestMapping(value="/goAdd2")
  	public ModelAndView goAdd2()throws Exception{
  		ModelAndView mv = this.getModelAndView();
  		PageData pd = new PageData();
  		pd = this.getPageData();
54a5b6ad   jack   1.英文翻译
202
203
204
205
206
  		if(isChineseLanguageClient()){
  			mv.setViewName("sunvote/subject/subject_edit2");
  		}else{
  			mv.setViewName("sunvote/subject/en_subject_edit2");
  		}
0e4da37e   孙向锦   学校管理员界面
207
208
209
210
211
212
213
  		List<PageData> varList = subjectService.listNotSchoolSubject(pd);
  		mv.addObject("varList", varList);
  		mv.addObject("msg", "save2");
  		mv.addObject("pd", pd);
  		return mv;
  	}	
  	
7db3ebeb   孙向锦   添加一些模块
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
  	 /**去修改页面
  	 * @param
  	 * @throws Exception
  	 */
  	@RequestMapping(value="/goEdit")
  	public ModelAndView goEdit()throws Exception{
  		ModelAndView mv = this.getModelAndView();
  		PageData pd = new PageData();
  		pd = this.getPageData();
  		pd = subjectService.findById(pd);	//根据ID读取
  		mv.setViewName("sunvote/subject/subject_edit");
  		mv.addObject("msg", "edit");
  		mv.addObject("pd", pd);
  		return mv;
  	}	
  	
ed6f550b   孙向锦   添加相应页面
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
  	/**去修改页面
  	 * @param
  	 * @throws Exception
  	 */
  	@RequestMapping(value="/goEdit2")
  	public ModelAndView goEdit2()throws Exception{
  		ModelAndView mv = this.getModelAndView();
  		PageData pd = new PageData();
  		pd = this.getPageData();
  		pd = subjectService.findById(pd);	//根据ID读取
  		mv.setViewName("sunvote/subject/subject_edit2");
  		mv.addObject("msg", "edit");
  		mv.addObject("pd", pd);
  		return mv;
  	}	
  	
7db3ebeb   孙向锦   添加一些模块
246
247
248
249
250
251
252
253
  	 /**批量删除
  	 * @param
  	 * @throws Exception
  	 */
  	@RequestMapping(value="/deleteAll")
  	@ResponseBody
  	public Object deleteAll() throws Exception{
  		logBefore(logger, Jurisdiction.getUsername()+"批量删除Subject");
7db3ebeb   孙向锦   添加一些模块
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
  		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(",");
  			subjectService.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()+"导出Subject到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("英文名称");	//2
  		titles.add("备注");	//3
  		dataMap.put("titles", titles);
  		List<PageData> varOList = subjectService.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).getString("CNAME"));	    //1
  			vpd.put("var2", varOList.get(i).getString("ENAME"));	    //2
  			vpd.put("var3", varOList.get(i).getString("REMARK"));	    //3
  			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));
  	}
  }