cd4d9eeccafaa7162343d81c60a986caabb6faa9.svn-base 6.65 KB
/**
 * Copyright &copy; 2015-2018 <a href="#">J-Site</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.reg.web.bus;

import java.util.List;
import java.util.Map;
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.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.bus.RegBusBdcqzsdjxx;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusFcxxquery;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusQlr;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseHService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusBdcqzsdjxxService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusFcxxqueryService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusQlrService;
import com.thinkgem.jeesite.modules.sys.utils.DictUtils;

/**
 * 房屋信息查询Controller
 * @author wb
 * @version 2018-01-18
 */
@Controller
@RequestMapping(value = "${adminPath}/reg/bus/regBusFcxxquery")
public class RegBusFcxxqueryController extends BaseController {

	@Autowired
	private RegBusFcxxqueryService regBusFcxxqueryService;
	@Autowired
	private RegBusBdcqzsdjxxService regBusBdcqzsdjxxService;
	@Autowired
	private RegBaseHService regBaseHService;
	@Autowired
	private RegBusQlrService regBusQlrService;
	
	@ModelAttribute
	public RegBusFcxxquery get(@RequestParam(required=false) String id) {
		RegBusFcxxquery entity = null;
		if (StringUtils.isNotBlank(id)){
			entity = regBusFcxxqueryService.get(id);
		}
		if (entity == null){
			entity = new RegBusFcxxquery();
		}
		return entity;
	}
	
	@RequiresPermissions("reg:bus:regBusFcxxquery:view")
	@RequestMapping(value = {"list", ""})
	public String list(RegBusFcxxquery regBusFcxxquery, HttpServletRequest request, HttpServletResponse response, Model model) {
		Page<RegBusFcxxquery> page = regBusFcxxqueryService.findPage(new Page<RegBusFcxxquery>(request, response), regBusFcxxquery); 
		model.addAttribute("page", page);
		return "modules/reg/bus/regBusFcxxqueryList";
	}

	@RequiresPermissions("reg:bus:regBusFcxxquery:view")
	@RequestMapping(value = "form")
	public String form(RegBusFcxxquery regBusFcxxquery, Model model) {
		model.addAttribute("regBusFcxxquery", regBusFcxxquery);
		return "modules/reg/bus/regBusFcxxqueryForm";
	}

	@RequiresPermissions("reg:bus:regBusFcxxquery:edit")
	@RequestMapping(value = "save")
	public String save(RegBusFcxxquery regBusFcxxquery, Model model, RedirectAttributes redirectAttributes) {
		if (!beanValidator(model, regBusFcxxquery)){
			return form(regBusFcxxquery, model);
		}
		regBusFcxxqueryService.save(regBusFcxxquery);
		addMessage(redirectAttributes, "保存房屋信息查询成功");
		return "redirect:"+Global.getAdminPath()+"/reg/bus/regBusFcxxquery/?repage";
	}
	
	@RequiresPermissions("reg:bus:regBusFcxxquery:edit")
	@RequestMapping(value = "delete")
	public String delete(RegBusFcxxquery regBusFcxxquery, RedirectAttributes redirectAttributes) {
		regBusFcxxqueryService.delete(regBusFcxxquery);
		addMessage(redirectAttributes, "删除房屋信息查询成功");
		return "redirect:"+Global.getAdminPath()+"/reg/bus/regBusFcxxquery/?repage";
	}
	
	
	/**
	 * 查询房屋虚所有和室所有权数据
	 * 2018-01-18
	 * 需求提出人:胡工
	 * @param regBaseChxx
	 * @param model
	 * @param request
	 * @param maps
	 * @return
	 */
	@RequestMapping(value = "fcxxinfoquery")
	@ResponseBody
	public ModelMap fcxxinfoquery(RegBusFcxxquery regBusFcxxquery, Model model, HttpServletRequest request,Map<String,Object> maps) {
		ModelMap modelMap = new ModelMap();
		modelMap.put("success",0);
		RegBusBdcqzsdjxx djxx = new RegBusBdcqzsdjxx();
		djxx.setRights("14");
		djxx.setDbsj("NOTNULL");
		List<RegBusBdcqzsdjxx> djxxlist = regBusBdcqzsdjxxService.findList(djxx);
		if(djxxlist.size() > 0){
			for(int i=0;i<djxxlist.size();i++){
				RegBusFcxxquery regBusFcxx = new RegBusFcxxquery();
				djxx = djxxlist.get(i);
				regBusFcxx.setBdcqzh(djxx.getBdcqzh());
				regBusFcxx.setDbsj(djxx.getDbsj());
				regBusFcxx.setDjxl(djxx.getDjlx());
				if("0".equals(djxx.getIslogout())){
					regBusFcxx.setSjyxzt("有效");
				}else{
					regBusFcxx.setSjyxzt("无效");
				}
				//查询户信息
				RegBaseH h = regBaseHService.getdy(djxx.getBdcdyh());
				if(h != null){
					if(StringUtils.isNotBlank(String.valueOf(h.getScjzmj()))){
						regBusFcxx.setScjzmj(h.getScjzmj());
					}
					regBusFcxx.setZl(h.getZl());
					regBusFcxx.setFwyt1(DictUtils.getDictLabel(h.getFwyt1(),"reg_bus_fwyt", ""));
					if("1".equals(h.getIsdiya())){
						regBusFcxx.setFwxzzt("已抵押,");
					}else{
						regBusFcxx.setFwxzzt("无抵押,");
					}
					if("1".equals(h.getIsyiyi())){
						regBusFcxx.setFwxzzt(regBusFcxx.getFwxzzt()+"已异议,");
					}else{
						regBusFcxx.setFwxzzt(regBusFcxx.getFwxzzt()+"无异议,");
					}
					if("0".equals(h.getIschafeng())){
						regBusFcxx.setFwxzzt(regBusFcxx.getFwxzzt()+"无查封");
					}else{
						regBusFcxx.setFwxzzt(regBusFcxx.getFwxzzt()+"已查封");
					}
				}
				//首先查询权利人
				RegBusQlr regBusQlr = new RegBusQlr();
				String gyqlr = "";
				String gyzjh = "";
				regBusQlr.setYwh(djxx.getYwh());
				List<RegBusQlr> listnew = regBusQlrService.findListSxh(regBusQlr);
				if(listnew.size()>0){
					for(int t=0;t<listnew.size();t++){
						regBusQlr = listnew.get(t);
						if(regBusQlr.getSxh() == 1){
							regBusFcxx.setQlrmc(regBusQlr.getQlrmc());
							regBusFcxx.setZjh(regBusQlr.getZjh());
						}else{
							if(StringUtils.isBlank(gyqlr)){
								gyqlr += regBusQlr.getQlrmc();
								gyzjh += regBusQlr.getZjh();
							}else{
								gyqlr += ","+regBusQlr.getQlrmc();
								gyzjh += ","+regBusQlr.getZjh();
							}
						}
					}
					regBusFcxx.setGyqlrmc(gyqlr);
					regBusFcxx.setGyzjh(gyzjh);
				}
				regBusFcxxqueryService.save(regBusFcxx);
			}
			modelMap.put("success",0);
			modelMap.put("msg","查询数据插入完成!");
		}
		return modelMap;
	}

}