2c07f208de41d17c86c1967f76e1acee5865c245.svn-base 10.9 KB
/**
 * Copyright &copy; 2015-2018 <a href="#">J-Site</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.ycsl.web;

import java.io.IOException;
import java.util.List;
import java.util.Map;

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

import org.apache.http.client.ClientProtocolException;
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.Maps;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseH;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseZdjbxx;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseZrz;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusBdcqzsdjxx;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusQlr;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusRights;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseHService;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseZdjbxxService;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseZrzService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusBdcqzsdjxxService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusQlrService;
import com.thinkgem.jeesite.modules.sys.utils.DictUtils;
import com.thinkgem.jeesite.modules.ycsl.entity.YcslGxr;
import com.thinkgem.jeesite.modules.ycsl.entity.YcslJbxx;
import com.thinkgem.jeesite.modules.ycsl.service.YcslGxrService;
import com.thinkgem.jeesite.modules.ycsl.service.YcslJbxxService;

/**
 * 一窗受理-基本信息Controller
 * @author lzj
 * @version 2020-12-24
 */
@Controller
@RequestMapping(value = "${frontPath}/ycsl/ycslJbxx")
public class YcslJbxxController extends BaseController {

	@Autowired
	private YcslJbxxService ycslJbxxService;
	@Autowired
	private RegBusBdcqzsdjxxService regBusBdcqzsdjxxService; 
	@Autowired
	private RegBaseZdjbxxService regBaseZdjbxxService;
	@Autowired
    private RegBaseZrzService regBaseZrzService;
	
	@ModelAttribute
	public YcslJbxx get(@RequestParam(required=false) String id) {
		YcslJbxx entity = null;
		if (StringUtils.isNotBlank(id)){
			entity = ycslJbxxService.get(id);
		}
		if (entity == null){
			entity = new YcslJbxx();
		}
		return entity;
	}
	
	@RequiresPermissions("ycsl:ycslJbxx:view")
	@RequestMapping(value = {"list", ""})
	public String list(YcslJbxx ycslJbxx, HttpServletRequest request, HttpServletResponse response, Model model) {
		Page<YcslJbxx> page = ycslJbxxService.findPage(new Page<YcslJbxx>(request, response), ycslJbxx); 
		model.addAttribute("page", page);
		return "modules/ycsl/ycslList";
	}

	@RequiresPermissions("ycsl:ycslJbxx:view")
	@RequestMapping(value = "form")
	public String form(YcslJbxx ycslJbxx, Model model,HttpServletRequest request) {
		if(StringUtils.isNotBlank(request.getParameter("view"))) {
			model.addAttribute("view", request.getParameter("view"));
		}
		model.addAttribute("ycslJbxx", ycslJbxx);
		return "modules/ycsl/ycslForm";
	}

	@RequiresPermissions("ycsl:ycslJbxx:edit")
	@RequestMapping(value = "save")
	public String save(YcslJbxx ycslJbxx, Model model, RedirectAttributes redirectAttributes) {
		ycslJbxxService.saveJbxx(ycslJbxx);
		ycslJbxxService.delEmpty();
		addMessage(redirectAttributes, "保存一窗受理-基本信息成功");
		return "redirect:"+Global.getAdminPath()+"/ycsl/ycslJbxx/?repage";
	}
	
	@RequiresPermissions("ycsl:ycslJbxx:edit")
	@RequestMapping(value = "delete")
	public String delete(YcslJbxx ycslJbxx, RedirectAttributes redirectAttributes) {
		
		ycslJbxxService.deleteJbxx(ycslJbxx);
		addMessage(redirectAttributes, "删除一窗受理-基本信息成功");
		return "redirect:"+Global.getAdminPath()+"/ycsl/ycslJbxx/?repage";
	}
	
	/**
	 *  一窗选房屋页面
	 * @param regBusBdcqzsdjxx
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "zydjGuide")
	public String zydjformalMortgageGuidesc(RegBusBdcqzsdjxx regBusBdcqzsdjxx, HttpServletRequest request, HttpServletResponse response, Model model) {
		String isHouse = request.getParameter("IsHouse");//是否房屋
		if(StringUtils.isNotBlank(isHouse)){
			model.addAttribute("IsHouse", isHouse);
		}
		//房屋的 过滤掉土地的, 土地的过滤掉房屋的
		if(StringUtils.isNotBlank(isHouse)){
			regBusBdcqzsdjxx.setBdcdyh(regBusBdcqzsdjxx.getBdcdyh());//房屋
		}else{
			regBusBdcqzsdjxx.setBdcdyh("W");//土地
		}
		regBusBdcqzsdjxx.setIslogout("0");//未注销
		regBusBdcqzsdjxx.setDbsj("NOTNULL");//已登簿
		// 转移预告登记806  和 转移登记302
		if(StringUtils.isBlank(regBusBdcqzsdjxx.getDjlx()) || regBusBdcqzsdjxx.getDjlx().equals("207")){
			regBusBdcqzsdjxx.setRights("1");
			regBusBdcqzsdjxx.setDjlx("207");
			Page<RegBusBdcqzsdjxx> page = regBusBdcqzsdjxxService.findfwzyqqPage(new Page<RegBusBdcqzsdjxx>(request, response), regBusBdcqzsdjxx);
			model.addAttribute("page", page);
		}else if(StringUtils.isNotBlank(regBusBdcqzsdjxx.getDjlx()) && regBusBdcqzsdjxx.getDjlx().equals("806")){
			regBusBdcqzsdjxx.setRights("4");
			Page<RegBusBdcqzsdjxx> page = regBusBdcqzsdjxxService.findfwzyqqPage(new Page<RegBusBdcqzsdjxx>(request, response), regBusBdcqzsdjxx); 
			model.addAttribute("page", page);
		}
		return "modules/ycsl/zydjfwDialog";
	}
	
	
	/**
	 * 获取信息
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusBdcqzsdjxx:view")
	@RequestMapping(value = "selectjbxx")
	@ResponseBody
	public ModelMap selectjbxx(HttpServletRequest request) {
		ModelMap modelmap = new ModelMap();
		try {
			modelmap = ycslJbxxService.selectjbxx(request);
		} catch (Exception e) {
			e.printStackTrace();
			modelmap.put("success", "1");
			modelmap.put("msg", e.getMessage());
		}
		
		return modelmap;
	}
	
	
	/**
	 * 业务占用控制(公用方法,谨慎修改)
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "isTransaction")
	@ResponseBody
	public ModelMap IsTransaction(HttpServletRequest request) {
		String id = request.getParameter("id");
		ModelMap modelMap = new ModelMap();
		modelMap.put("success", 1);
		String bdcdyh ="";
				RegBusBdcqzsdjxx entity = null;
				if (StringUtils.isNotBlank(id)){
					entity = regBusBdcqzsdjxxService.get(id);
				}
				bdcdyh =  entity.getBdcdyh();
				
			RegBusBdcqzsdjxx RegBusBdcqzsdjxxNewtemp = new RegBusBdcqzsdjxx();
			RegBusBdcqzsdjxxNewtemp.setOldid(id);
			RegBusBdcqzsdjxxNewtemp.setFzsj("ISNULL");
			RegBusBdcqzsdjxxNewtemp.setIslogout("02");
			List<RegBusBdcqzsdjxx> listNewtemp = regBusBdcqzsdjxxService.findSelectedList(RegBusBdcqzsdjxxNewtemp);
			
			RegBusBdcqzsdjxx temp = new RegBusBdcqzsdjxx();
			temp.setBdcdyh(bdcdyh);
			temp.setFzsj("ISNULL");
			temp.setIslogout("02");
			List<RegBusBdcqzsdjxx> lists = regBusBdcqzsdjxxService.findSelectedList(temp);
			if(listNewtemp != null && listNewtemp.size()>0){
				temp = listNewtemp.get(0);
					String djxl = DictUtils.getDictLabel(listNewtemp.get(0).getDjlx(),"reg_bus_djxl", "");
					modelMap.put("success", 0);
					if(StringUtils.isNotBlank(temp.getStatus())){
						if(temp.getStatus().equals("99") || temp.getStatus().equals("98")){
							modelMap.put("msg", "业务号为:"+temp.getYwh()+"的不动产登记信息正在办理:("+djxl+temp.getFj()+")业务,不能继续办理,请您稍后!");
						}else {
							modelMap.put("msg", "业务号为:"+temp.getYwh()+"的不动产登记信息正在办理:("+djxl+")业务,不能继续办理,请您稍后!");
						}
					}else {
						modelMap.put("msg", "业务号为:"+temp.getYwh()+"的不动产登记信息正在办理:("+djxl+")业务,不能继续办理,请您稍后!");
					}
			}else {
				if(lists != null && lists.size()>0){
					temp = lists.get(0);
						String djxl = DictUtils.getDictLabel(lists.get(0).getDjlx(),"reg_bus_djxl", "");
						modelMap.put("success", 0);
						if(StringUtils.isNotBlank(temp.getStatus())){
							if(temp.getStatus().equals("99") || temp.getStatus().equals("98")){
								modelMap.put("msg", "业务号为:"+temp.getYwh()+"的不动产登记信息正在办理:("+djxl+temp.getFj()+")业务,不能继续办理,请您稍后!");
							}else {
								modelMap.put("msg", "业务号为:"+temp.getYwh()+"的不动产登记信息正在办理:("+djxl+")业务,不能继续办理,请您稍后!");
							}
						}else {
							modelMap.put("msg", "业务号为:"+temp.getYwh()+"的不动产登记信息正在办理:("+djxl+")业务,不能继续办理,请您稍后!");
						}
				}else {
					modelMap.put("success", 1);
					modelMap.put("msg", "可以选择");
				}
			}
			
			//判断一窗受理信息是否采集
				YcslJbxx jbxx = new YcslJbxx();
				jbxx.setBdcdyh(bdcdyh);
				jbxx.setZt("1");
				List<YcslJbxx> jbxxlist = ycslJbxxService.findList(jbxx);
				if(jbxxlist.size()==1) {
					modelMap.put("success", 3);
					modelMap.put("msg", "不动产单元号为:"+bdcdyh+"的不动产登记信息 已存在合同签约 信息,请直接修改!");
				}
				
			//独有宗地上的房屋抵押了,土地打上抵押标记,地上其他房屋不能转移,要在转移登记向导里做控制。
				RegBusBdcqzsdjxx djxxtd =  regBusBdcqzsdjxxService.get(id);
				RegBaseZrz zrz = new RegBaseZrz();
				zrz.setZddm(djxxtd.getZddm());
				List<RegBaseZrz> zrzlists = regBaseZrzService.findList(zrz);
				if(zrzlists.size() > 0){
					zrz = zrzlists.get(0);
					if ("2".equals(zrz.getZdftfs())) {//独用宗地
						RegBaseZdjbxx  zdjbxx = new RegBaseZdjbxx();
						zdjbxx.setZddm(djxxtd.getZddm());
						zdjbxx.setIslogout("0");
						List<RegBaseZdjbxx> zdjbxxlist =  regBaseZdjbxxService.findList(zdjbxx);
						if(zdjbxxlist.size() > 0){
							zdjbxx = zdjbxxlist.get(0);
							if("1".equals(zdjbxx.getIsdiya())){
								modelMap.put("success",3);
								modelMap.put("msg", "宗地代码为:"+djxxtd.getZddm()+"的不动产登记信息为独用宗地且已打上了抵押标记,不能继续办理!");
							}
						}
					}
				}
			
		return modelMap;
	}
	

	/**
	 * 测试
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "ceshi")
	@ResponseBody
	public ModelMap ceshi(HttpServletRequest request) {
		ModelMap modelmap = new ModelMap();
		try {
			 ycslJbxxService.downDeal(request);
		} catch (Exception e) {
			e.printStackTrace();
			modelmap.put("success", "1");
			modelmap.put("msg", e.getMessage());
		}
		
		return modelmap;
	}
}