package nju.software.jxjs.controller;

import java.util.ArrayList;
import java.util.List;

import nju.software.jxjs.model.PubDmb;
import nju.software.jxjs.model.TLog;
import nju.software.jxjs.service.DmbService;
import nju.software.jxjs.service.LogService;
import nju.software.jxjs.service.UserService;

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.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import nju.software.jxjs.util.DateUtil;
import nju.software.jxjs.view.LogView;

@Controller
@RequestMapping("/xtgl")
public class XtglController extends BaseController {
	@Autowired
	private LogService logService;
	@Autowired
	private DmbService dmbService;
	@Autowired
	private UserService userService;
	//日志查询
	@RequestMapping(value = "/rzcx", method = RequestMethod.POST)
	@ResponseBody
	public Object approval(@RequestParam("kssj") String kssj,@RequestParam("jssj") String jssj,
			@RequestParam("type") String type){
		List<LogView> views = new ArrayList<LogView>();
		String logType = null;
		PubDmb dmb = dmbService.getDmbByLbbhAndDmms("JXJS-LOGTYPE", type);
		if(dmb!=null)
			logType = dmb.getDmbh();
		List<TLog> logs = logService.getLogByDateAndType(kssj, jssj, logType);
		for(TLog log:logs){
			LogView vo = new LogView();
			dmb = dmbService.getDmbByLbbhAndDmbh("JXJS-LOGTYPE", log.getType());
			vo.setType(dmb.getDmms());
			vo.setCzsj(DateUtil.format(log.getCzsj(), DateUtil.webFormat));
			vo.setCzip(log.getCzip());
			vo.setBz(log.getBz());
			if(log.getType().equals("6"))//监狱用户只有申请，其余的操作都是法院用户
				vo.setCzr(userService.getUserById(log.getRybh()).getUsername());
			else
				vo.setCzr(userService.getYhbById(log.getRybh()).getYhmc());
			views.add(vo);
		}
		return views;
	}

}

@@ -287,21 +287,106 @@
 ice.
-UserService;%0A
+MenuService;%0Aimport nju.software.jxjs.service.UserService;%0A%0Aimport org.apache.shiro.SecurityUtils;
 %0Aimp
@@ -741,16 +741,69 @@
 nseBody;
+%0Aimport org.springframework.web.servlet.ModelAndView;
 %0A%0Aimport
@@ -874,16 +874,52 @@
 LogView;
+%0Aimport nju.software.jxjs.view.User;
 %0A%0A@Contr
@@ -1006,32 +1006,69 @@
 r %7B%0A%09@Autowired%0A
+%09private MenuService ms;%0A%09@Autowired%0A
 %09private LogServ
@@ -1173,16 +1173,640 @@
 ervice;%0A
+%09/**%0A%09 * %E6%97%A5%E5%BF%97%E7%AE%A1%E7%90%86%0A%09 * %0A%09 * @return%0A%09 */%0A%09@RequestMapping(value = %22/rzgl%22, method = RequestMethod.GET)%0A%09public ModelAndView rzgl()%0A%09%7B%0A%09%09ModelAndView mav = new ModelAndView();%0A%09%09mav.setViewName(%22xtgl-rzgl%22);%0A%09%09List%3CPubDmb%3E dmbList = dmbService.getDmbByLbbh(%22JXJS-LOGTYPE%22);%0A%09%09List%3CString%3E conditionList = new ArrayList%3CString%3E();%0A%09%09for(PubDmb dmb:dmbList)%7B%0A%09%09%09conditionList.add(dmb.getDmms());%0A%09%09%7D%0A%09%09mav.addObject(%22conditionList%22, conditionList);%0A%09%09User user = (User)SecurityUtils.getSubject().getSession().getAttribute(%22currentUser%22);%0A%09%09mav.addObject(%22menuWrapper%22, ms.makeMenu(user.getRole(), %22tjfx%22, %22jccx%22));%0A%09%09return mav;%0A%09%7D%0A
 %09//%E6%97%A5%E5%BF%97%E6%9F%A5%E8%AF%A2%0A

modify by csy