1a61e83a1c39d214484e23fa66b35e12cea7f29e.svn-base 10.5 KB
/**
 * Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.reg.web.bus;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
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.servlet.mvc.support.RedirectAttributes;

import com.google.common.collect.Lists;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.utils.DateUtils;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusBdcqzsdjxx;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusDyaq;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusSjchild;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusSjmain;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusBdcqzsdjxxService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusDyaqService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusSjmainService;
import com.thinkgem.jeesite.modules.sys.entity.Office;
import com.thinkgem.jeesite.modules.sys.entity.User;
import com.thinkgem.jeesite.modules.sys.service.OfficeService;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;

/**
 * 收件信息(主子表)维护Controller
 * @author xuyg
 * @version 2015-11-24
 */
@Controller
@RequestMapping(value = "${adminPath}/reg/bus/regBusSjmain")
public class RegBusSjmainController extends BaseController {

	@Autowired
	private RegBusSjmainService regBusSjmainService;
	@Autowired
	private RegBusBdcqzsdjxxService regBusBdcqzsdjxxService;
	@Autowired
	private RegBusQlrController regBusQlrController;
	@Autowired
	private RegBusDyaqService regBusDyaqService;
	@Autowired
	private OfficeService officeService;
	
	
	@ModelAttribute
	public RegBusSjmain get(@RequestParam(required=false) String id) {
		RegBusSjmain entity = null;
		if (StringUtils.isNotBlank(id)){
			entity = regBusSjmainService.get(id);
		}
		if (entity == null){
			entity = new RegBusSjmain();
		}
		return entity;
	}
	
	@RequiresPermissions("reg:bus:regBusSjmain:view")
	@RequestMapping(value = {"list", ""})
	public String list(RegBusSjmain regBusSjmain, HttpServletRequest request, HttpServletResponse response, Model model) {
		Page<RegBusSjmain> page = regBusSjmainService.findPage(new Page<RegBusSjmain>(request, response), regBusSjmain); 
		model.addAttribute("page", page);
		//初审以后的环节只能查看不能修改删除
		if(StringUtils.isNotBlank(request.getParameter("LISTVIEWS"))){
			model.addAttribute("LISTVIEWS", "1");
		}
		//WinOpen标示
		if(StringUtils.isNotBlank(request.getParameter("WO"))){
			model.addAttribute("WO", "1");
			model.addAttribute("LISTVIEWS", "1");
		}
		//页面操作类型【新增还是更新】
		if(StringUtils.isNotBlank(request.getParameter("optype"))){
			model.addAttribute("optype", "update");
		}
		if(StringUtils.isNotBlank(request.getParameter("DJLX"))){
			model.addAttribute("DJLX", request.getParameter("DJLX"));
		}
		
		return "modules/reg/bus/regBusSjmainList";
	}
	
	@RequiresPermissions("reg:bus:regBusSjmain:view")
	@RequestMapping(value = "CXlist")
	public String CXlist(RegBusSjmain regBusSjmain, HttpServletRequest request, HttpServletResponse response, Model model) {
		Page<RegBusSjmain> page = regBusSjmainService.findPage(new Page<RegBusSjmain>(request, response), regBusSjmain); 
		model.addAttribute("page", page);
		
		return "modules/reg/bus/regBusSjmainCXList";
	}
	
	@RequiresPermissions("reg:bus:regBusSjmain:view")
	@RequestMapping(value = "listView")
	public String listView(RegBusSjmain regBusSjmain, HttpServletRequest request, HttpServletResponse response, Model model) {
		User user = UserUtils.getUser();
		List<RegBusSjmain> sjMainList = regBusSjmainService.findList(regBusSjmain);
		List<RegBusSjchild> sjList = Lists.newArrayList();
		String id = "";
		for(int a = 0; a < sjMainList.size(); a++){
			id = sjMainList.get(a).getId();
		}
		regBusSjmain = get(id);
		sjList = regBusSjmain.getRegBusSjchildList();
		int yjsl = 0;
		String ywhStr = request.getParameter("ywh"); 
		//String djlx = request.getParameter("djlx"); 
		String bdcqzsdjxxID =  request.getParameter("BdcqzsdjxxID"); 
		if(StringUtils.isNotBlank(ywhStr)){
			model.addAttribute("YWH", ywhStr); //业务号
		
			//获取坐落-从不动产权证书信息表
			String zl = "";
			RegBusBdcqzsdjxx regBusBdcqzsdjxx = regBusBdcqzsdjxxService.get(bdcqzsdjxxID);
			if(regBusBdcqzsdjxx != null){
				zl = regBusBdcqzsdjxx.getZl();
			}
			
			model.addAttribute("ZL", zl); //坐落 改到从宗地信息取
			model.addAttribute("SLSJ", request.getParameter("slsj")); //受理时间
			model.addAttribute("SJSL", sjList.size()); //收件总数量
			model.addAttribute("TZRXM", request.getParameter("tzrxm")); //申请人[受托人]姓名 
			model.addAttribute("STR", request.getParameter("str")); //[受托人]姓名 
			model.addAttribute("TZRYDDH", request.getParameter("tzryddh")); //申请人移动电话
			for(int i=0; i< sjList.size(); i++){
				if("1".equals(sjList.get(i).getSjlx())){
					yjsl++;
				}
			}
			String sqrmc = "";
			// 获取权利人名称【根据列表可能是多个】抵押人与抵押共有人
			RegBusDyaq temp = new RegBusDyaq();
			temp.setYwh(ywhStr);
			List<RegBusDyaq> tempList = regBusDyaqService.findList(temp);
			if(tempList.size()>0){
				temp = tempList.get(0);
				sqrmc = "抵押人:" + temp.getDyr();
				if (StringUtils.isNotBlank(temp.getDygyr())) {
					sqrmc += " 抵押人共有人" + temp.getDygyr();
				}
			}else{
				sqrmc = regBusQlrController.getQlrmcByYwh(ywhStr);
			}
		
			model.addAttribute("QLRMC", sqrmc);
			model.addAttribute("YJSL", yjsl); //原件数量
		}
		model.addAttribute("SLRMC", user.getName());
		model.addAttribute("regBusSjlist", sjList);
		return "modules/reg/bus/regBusSjView";
	}
	
	@RequiresPermissions("reg:bus:regBusSjmain:view")
	@RequestMapping(value = "form")
	public String form(RegBusSjmain regBusSjmain, Model model, HttpServletRequest request) {
		model.addAttribute("regBusSjmain", regBusSjmain);
		if(StringUtils.isNotBlank(request.getParameter("ywh"))){
			model.addAttribute("YWH", request.getParameter("ywh"));
		}
		//查看标示
		if(StringUtils.isNotBlank(request.getParameter("VIEWS"))){
			model.addAttribute("VIEWS", request.getParameter("VIEWS"));
		}
		System.out.println(request.getParameter("DJLX"));
		if(StringUtils.isNotBlank(request.getParameter("DJLX"))){
			model.addAttribute("DJLX", request.getParameter("DJLX"));
		}
		User user = UserUtils.getUser();
		Office office = officeService.get(user.getCurrentUser().getOffice().getId());
		String officeCode = office.getCode();
		if ("S00001001001004".equals(officeCode)) {
			model.addAttribute("officeCode", "S00001001001004");
		}
		model.addAttribute("YEAR", DateUtils.getYear());
		model.addAttribute("MONTH", DateUtils.getMonth());
		return "modules/reg/bus/regBusSjmainForm";
	}

	//用于附件下载、打印
	@RequiresPermissions("reg:bus:regBusSjmain:view")
	@RequestMapping(value = "CXform")
	public String CXform(RegBusSjmain regBusSjmain, Model model, HttpServletRequest request) {
		
		model.addAttribute("regBusSjmain", regBusSjmain);
		if(StringUtils.isNotBlank(request.getParameter("ywh"))){
			model.addAttribute("YWH", request.getParameter("ywh"));
		}
		
		if(StringUtils.isNotBlank(request.getParameter("DJLX"))){
			model.addAttribute("DJLX", request.getParameter("DJLX"));
		}
		model.addAttribute("YEAR", DateUtils.getYear());
		model.addAttribute("MONTH", DateUtils.getMonth());
		return "modules/reg/bus/regBusSjmainCXForm";
	}

	/***
	* @Title: issjed 
	* @Description: 判断是否已经收件
	* @param @param request
	* @param @return    设定文件 
	* @return ModelMap    返回类型 
	* @throws
	 */
	@RequiresPermissions("reg:bus:regBusSjmain:edit")
	@RequestMapping(value = "issjed")
	@ResponseBody
	public ModelMap issjed(HttpServletRequest request) {
		String ywh = request.getParameter("YWH");
		RegBusSjmain regBusSjmainTemp = new RegBusSjmain();
		regBusSjmainTemp.setYwh(ywh);
		List<RegBusSjmain> findList = regBusSjmainService.findList(regBusSjmainTemp);
		ModelMap modelMap = new ModelMap();
		if(findList.size()>0){
			modelMap.put("data", "1");//已经有收件信息记录
		}else{
			modelMap.put("data", "0");
		}
        return modelMap;
	}
	
	/***
	* @Title: issjsubed 
	* @Description: 判断是否已经收件,子表
	* @param @param request
	* @param @return    设定文件 
	* @return ModelMap    返回类型 
	* @throws
	 */
	@RequiresPermissions("reg:bus:regBusSjmain:edit")
	@RequestMapping(value = "issjsubed")
	@ResponseBody
	public ModelMap issjsubed(HttpServletRequest request) {
		String id = request.getParameter("id");
		RegBusSjmain regBusSjmain = regBusSjmainService.get(id);
		List<RegBusSjchild> regBusSjchildList = regBusSjmain.getRegBusSjchildList();
		ModelMap modelMap = new ModelMap();
		if(regBusSjchildList.size()>0){
			modelMap.put("data", "1");//已经有收件子表信息记录
		}else{
			modelMap.put("data", "0");
		}
        return modelMap;
	}

	
	@RequiresPermissions("reg:bus:regBusSjmain:edit")
	@RequestMapping(value = "save")
	public String save(RegBusSjmain regBusSjmain, Model model, RedirectAttributes redirectAttributes, HttpServletRequest request) {
		if (!beanValidator(model, regBusSjmain)){
			return form(regBusSjmain, model, request);
		}
		
		regBusSjmainService.save(regBusSjmain);
		addMessage(redirectAttributes, "保存收件信息成功");
		return "redirect:"+Global.getAdminPath()+"/reg/bus/regBusSjmain/?repage&&WO=1&ywh="+request.getParameter("YWH") +"&optype="+request.getParameter("optype");
	}
	
	@RequiresPermissions("reg:bus:regBusSjmain:edit")
	@RequestMapping(value = "delete")
	public String delete(RegBusSjmain regBusSjmain, RedirectAttributes redirectAttributes, HttpServletRequest request) {
		regBusSjmainService.delete(regBusSjmain);
		addMessage(redirectAttributes, "删除收件信息成功");
		return "redirect:"+Global.getAdminPath()+"/reg/bus/regBusSjmain/?repage&ywh="+ request.getParameter("ywh");
	}

}