ec6b52c83d21f3e43d72aa5199783e6769b9c25a.svn-base 9.08 KB
/**

 * Copyright © 2015-2018 ODM All rights reserved.
 */
package com.thinkgem.jeesite.modules.reg.web.nf;


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 com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseC;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseH;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseXm;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseZbinfoZrz;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseZdbhqk;
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.base.RegBaseZrzchxx;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusBdcqzsdjxx;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusJsydsyq;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusQlr;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseCService;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseHService;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseXmService;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseZdbhqkService;
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.base.RegBaseZrzchxxService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusBdcqzsdjxxService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusJsydsyqService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusQlrService;


/**
 * 农房入库数据信息维护Controller
 * 
 */
@Controller
@RequestMapping(value = "${adminPath}/reg/nf/regBusNf")
public class RegBusNfController extends BaseController {
	@Autowired
	private RegBusBdcqzsdjxxService regBusBdcqzsdjxxService;
	@Autowired
	private RegBaseZrzService regBaseZrzService;
	@Autowired
	private RegBusJsydsyqService regBusJsydsyqService;
	@Autowired
	private RegBusQlrService regBusQlrService;
	@Autowired
	private RegBaseZdbhqkService regBaseZdbhqkService;
	@Autowired
	private RegBaseZdjbxxService regBaseZdjbxxService;
	@Autowired
	private RegBaseXmService regBaseXmService;
	@Autowired
	private RegBaseCService regBaseCService;
	@Autowired
	private RegBaseHService regBaseHService;
	@Autowired
	private RegBaseZrzchxxService regBaseZrzchxxService;
	
	@ModelAttribute
	public RegBusBdcqzsdjxx get(@RequestParam(required = false) String id) {
		RegBusBdcqzsdjxx entity = null;
		if (StringUtils.isNotBlank(id)) {
			entity = regBusBdcqzsdjxxService.get(id);
		}
		if (entity == null) {
			entity = new RegBusBdcqzsdjxx();
		}
		return entity;
	}
    /*
          * 地
     */
	@RequiresPermissions("reg:bus:regBusNf:view")
	@RequestMapping(value = { "list", "" })
	public String list(RegBusBdcqzsdjxx regBusBdcqzsdjxx, HttpServletRequest request, HttpServletResponse response, Model model) {
		regBusBdcqzsdjxx.setYwh("LZ");
		Page<RegBusBdcqzsdjxx> page = regBusBdcqzsdjxxService.selectNfPage(new Page<RegBusBdcqzsdjxx>(request, response), regBusBdcqzsdjxx);
		model.addAttribute("page", page);
		model.addAttribute("regBusBdcqzsdjxx", regBusBdcqzsdjxx);
		return "modules/reg/nf/regBusBdcqzsdjxxList";
	}

	@RequiresPermissions("reg:bus:regBusNf:view")
	@RequestMapping(value = "delete")
	public String delete(RegBusBdcqzsdjxx regBusBdcqzsdjxx, Model model, HttpServletRequest request) {
		  if(StringUtils.isNotBlank(regBusBdcqzsdjxx.getId())) {
			  RegBusJsydsyq jsydsyq = new RegBusJsydsyq();
			  jsydsyq.setYwh(regBusBdcqzsdjxx.getYwh());
			  jsydsyq.setBdcdyh(regBusBdcqzsdjxx.getBdcdyh());
			  List<RegBusJsydsyq> syqlist = regBusJsydsyqService.findList(jsydsyq);
			  if(syqlist.size()>0) {
				  for(int i=0;i<syqlist.size();i++) {
					  regBusJsydsyqService.delete(syqlist.get(i));
				  }
			  }
			  
			  RegBusQlr qlr = new RegBusQlr();
			  qlr.setYwh(regBusBdcqzsdjxx.getYwh());
			  qlr.setBdcdyh(regBusBdcqzsdjxx.getBdcdyh());
			  List<RegBusQlr> qlrlist = regBusQlrService.findList_1(qlr);
			  if(qlrlist.size()>0) {
				  for(int q=0;q<qlrlist.size();q++) {
					  regBusQlrService.delete(qlrlist.get(q));
				  }
			  }
			  
			  RegBaseZdbhqk zdbhqk = new RegBaseZdbhqk();
			  zdbhqk.setZddm(regBusBdcqzsdjxx.getZddm());
			  List<RegBaseZdbhqk> bhqklist = regBaseZdbhqkService.findList(zdbhqk);
			  if(bhqklist.size()>0) {
				  for(int b=0;b<bhqklist.size();b++) {
					  regBaseZdbhqkService.delete(bhqklist.get(b));
				  }
			  }
			  
			  RegBaseZdjbxx zdjbxx = new RegBaseZdjbxx();
			  zdjbxx.setZddm(regBusBdcqzsdjxx.getZddm());
			  zdjbxx.setBdcdyh(regBusBdcqzsdjxx.getBdcdyh());
			  List<RegBaseZdjbxx> jbxxlist = regBaseZdjbxxService.findList(zdjbxx);
			  if(jbxxlist.size()>0) {
				  for(int d = 0;d<jbxxlist.size();d++) {
					  regBaseZdjbxxService.deleteNf(jbxxlist.get(d));
				  }
			  }
			  
			  regBusBdcqzsdjxxService.delete(regBusBdcqzsdjxx);
		  }
			return "redirect:" + Global.getAdminPath() + "/reg/nf/regBusNf/list?id="+regBusBdcqzsdjxx.getId();
		
	}
   
	
	/*
	 * 房
	 */
	@RequiresPermissions("reg:bus:regBusNf:view")
	@RequestMapping(value = { "zrzlist", "" })
	public String zrzlist(RegBaseZrz regBaseZrz, HttpServletRequest request, HttpServletResponse response, Model model) {
		regBaseZrz.setBdcdyh("JC");
		regBaseZrz.setRemarks("1");
		Page<RegBaseZrz> page = regBaseZrzService.findPage(new Page<RegBaseZrz>(request, response), regBaseZrz);
		model.addAttribute("page", page);
		model.addAttribute("regBaseZrz", regBaseZrz);
		return "modules/reg/nf/regBaseZrzList";
	}

	@RequiresPermissions("reg:bus:regBusNf:view")
	@RequestMapping(value = "fwdelete")
	public String fwdelete(RegBaseZrz regBaseZrz, Model model, HttpServletRequest request) {
		   String zrzid = request.getParameter("zrzid");
		   regBaseZrz = regBaseZrzService.get(zrzid);
		  if(regBaseZrz != null) {
			  RegBaseH h = new RegBaseH();
			  h.setBdcdyh(regBaseZrz.getBdcdyh().substring(0, 24));
			  List<RegBaseH> hlist = regBaseHService.findList(h);
			  if(hlist.size()>0) {
				  for(int i=0;i<hlist.size();i++) {
					  regBaseHService.delete(hlist.get(i));
				  }
			  }
			  
			  RegBaseC c = new RegBaseC();
			  c.setZid(regBaseZrz.getId());
			  
			  List<RegBaseC> clist = regBaseCService.findList(c);
			  if(clist.size()>0) {
				  for(int q=0;q<clist.size();q++) {
					  regBaseCService.delete(clist.get(q));
				  }
			  }
			  
			  
			  RegBaseZrzchxx zrzchxx = new RegBaseZrzchxx();
			 
			  zrzchxx.setBdcdyh(regBaseZrz.getZddm());
			  List<RegBaseZrzchxx> zrzchxxlist = regBaseZrzchxxService.findList(zrzchxx);
			  if(zrzchxxlist.size()>0) {
				  for(int d = 0;d<zrzchxxlist.size();d++) {
					  regBaseZrzchxxService.chdelete(zrzchxxlist.get(d));
				  }
			  }
			  
			  RegBaseXm xm = new RegBaseXm();
			  xm.setId(regBaseZrz.getXmid());
			  xm.setXmmc(regBaseZrz.getXmmc());
			  List<RegBaseXm> xmlist = regBaseXmService.findList(xm);
			  if(xmlist.size()>0) {
				  for(int x=0;x<xmlist.size();x++) {
					  regBaseXmService.delete(xmlist.get(x));
				  }
			  }
			  regBaseZrzService.delete(regBaseZrz);
		  }
			return "redirect:" + Global.getAdminPath() + "/reg/nf/regBusNf/zrzlist?zrzid="+regBaseZrz.getId();
		
	}
	
	
	@RequiresPermissions("reg:bus:regBusNf:view")
	@RequestMapping(value = "isdelete")
	@ResponseBody
	public ModelMap queryinfo(HttpServletRequest request) {
		ModelMap modelmap = new ModelMap();
		String id = request.getParameter("id");
		RegBusBdcqzsdjxx djxx = regBusBdcqzsdjxxService.get(id);
		String zrzid = request.getParameter("zrzid");
		RegBaseZrz zrz = regBaseZrzService.get(zrzid);
		if(StringUtils.isNotBlank(id) && djxx != null) {
			RegBusBdcqzsdjxx djxx1 = new RegBusBdcqzsdjxx();
			djxx1.setBdcdyh(djxx.getZddm()+"F");
			djxx1.setDjlx("220521");
			List<RegBusBdcqzsdjxx> djxxlist = regBusBdcqzsdjxxService.findList(djxx1);
			if(djxxlist.size()>0) {
				modelmap.put("yw", "1");
			}
			RegBaseZrz zrz11 = new RegBaseZrz();
			zrz11.setZddm(djxx.getZddm());
			List<RegBaseZrz> zrzlist = regBaseZrzService.findList(zrz11);
			if(zrzlist.size()>0) {
				modelmap.put("fw", "1");
			}
		}
		
		if(StringUtils.isNotBlank(zrzid) && zrz != null) {
			RegBusBdcqzsdjxx djxx1 = new RegBusBdcqzsdjxx();
			djxx1.setBdcdyh(zrz.getZddm()+"F");
			djxx1.setDjlx("220521");
			List<RegBusBdcqzsdjxx> djxxlist = regBusBdcqzsdjxxService.findList(djxx1);
			if(djxxlist.size()>0) {
				modelmap.put("yw", "1");
			}
		}
		return modelmap;
	}

	
	

	
}