271d1c7e51f5fb29011f4877c66e6a74d0c01b62.svn-base 34.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863
package com.thinkgem.jeesite.modules.reg.web.base;

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.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
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.servlet.mvc.support.RedirectAttributes;
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.RegBaseH;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseHbhqk;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseSllm;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseSllmbhqk;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseXm;
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.bus.RegBusBdcqzsdjxx;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusLq;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusQlr;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusJsydsyq;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusRights;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusYwr;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusTdsyq;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseSllmService;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseSllmbhqkService;
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.bus.RegBusBdcqzsdjxxService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusLqService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusQlrService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusYwrService;
import com.thinkgem.jeesite.modules.reg.utils.RegUtils;
import com.thinkgem.jeesite.modules.sys.entity.User;
import com.thinkgem.jeesite.modules.sys.service.SystemService;
import com.thinkgem.jeesite.modules.sys.utils.DictUtils;

@Controller
@RequestMapping(value = "${adminPath}/reg/base/regBaseSllm")
public class RegBaseSllmController extends BaseController {

	@Autowired
	private RegBaseSllmService regBaseSllmService;
	@Autowired
	private SystemService systemService;
	@Autowired
	private RegBusBdcqzsdjxxService regBusBdcqzsdjxxService;
	@Autowired
	private RegBaseSllmbhqkService regBaseSllmbhqkService;
	@Autowired
	private RegBusYwrService regBusYwrService;
	@Autowired
	private RegBusQlrService regBusQlrService;
	@Autowired
	private RegBusLqService regBusLqService;
	@Autowired
	private RegBaseZdjbxxService regBaseZdjbxxService;
	
	
	@ModelAttribute
	public RegBaseSllm get(@RequestParam(required=false) String id) {
		RegBaseSllm entity = null;
		if (StringUtils.isNotBlank(id)){
			entity = regBaseSllmService.get(id);
		}
		if (entity == null){
			entity = new RegBaseSllm();
		}
		return entity;
	}
	
	@RequiresPermissions("reg:base:regBaseSllm:view")
	@RequestMapping(value = {"list", ""})
	public String list(RegBaseSllm regBaseSllm, HttpServletRequest request, HttpServletResponse response, Model model) {
		Page<RegBaseSllm> page = regBaseSllmService.findPage(new Page<RegBaseSllm>(request, response), regBaseSllm);
		//regBaseSllm.setIsaudit("99");
		//regBaseSllm.setIslogout("3");
		List<RegBaseSllm> sllmList = page.getList();
		for(int i=0;i<sllmList.size();i++){
			RegBaseSllm sllmTem = sllmList.get(i);
			User creater = systemService.getUser(sllmTem.getCreateBy().getId());
			User updater = systemService.getUser(sllmTem.getUpdateBy().getId());
			sllmTem.setCreater(creater.getName());
			sllmTem.setUpdater(updater.getName());
		}
		page.setList(sllmList);
		model.addAttribute("page", page);
		if(StringUtils.isNotBlank(request.getParameter("YWH"))){
			model.addAttribute("YWH", request.getParameter("YWH"));
		}
		if(StringUtils.isNotBlank(request.getParameter("BCDYH"))){
			model.addAttribute("BCDYH", request.getParameter("BCDYH"));
		}
		if(StringUtils.isNotBlank(request.getParameter("flag"))){
			model.addAttribute("flag", request.getParameter("flag"));
		}
		return "modules/reg/base/regBaseSllmList";
	}
	
	@RequiresPermissions("reg:base:regBaseSllm:view")
	@RequestMapping(value = "alllist")
	public String alllist(RegBaseSllm regBaseSllm, HttpServletRequest request, HttpServletResponse response, Model model) {
		Page<RegBaseSllm> page = new Page<RegBaseSllm>();
		page = regBaseSllmService.findPage(new Page<RegBaseSllm>(request, response), regBaseSllm);
		model.addAttribute("page", page);
		return "modules/reg/base/regBaseSllmAllList";
	}
	
	/**
	 * 森林、林木分割合并选择页面
	 * @param regBaseZdjbxx
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequiresPermissions("reg:base:regBaseSllm:view")
	@RequestMapping(value = "lqList")
	public String lqList(RegBaseSllm regBaseSllm, HttpServletRequest request, HttpServletResponse response, Model model) {
		Page<RegBaseSllm> page = new Page<RegBaseSllm>();
		regBaseSllm.setIsaudit("1");
		regBaseSllm.setIslogout("0");
		page = regBaseSllmService.findPage(new Page<RegBaseSllm>(request, response), regBaseSllm);
		model.addAttribute("page", page);
		return "modules/reg/base/regBaseSllmLqList";
	}
	
	@RequiresPermissions("reg:base:regBaseSllm:view")
	@RequestMapping(value = "oneOfAllForm")
	public String oneOfAllForm(RegBaseSllm regBaseSllm, Model model, HttpServletRequest request) {
		model.addAttribute("regBaseSllm", regBaseSllm);
		if(StringUtils.isNotBlank(request.getParameter("VIEWS"))){
			model.addAttribute("VIEWS", request.getParameter("VIEWS"));
		}
		if(StringUtils.isNotBlank(request.getParameter("qjcx"))){
			model.addAttribute("qjcx", request.getParameter("qjcx"));
		}
		return "modules/reg/base/regBaseSllmOneOfAllForm";
	}
	
	@RequiresPermissions("reg:base:regBaseSllm:view")
	@RequestMapping(value = "form")
	public String form(RegBaseSllm regBaseSllm,Model model,HttpServletRequest request) {
		//编码生成规则:6位数,从100000开始
		if(StringUtils.isBlank(regBaseSllm.getId())){
			model.addAttribute("LMBM", RegUtils.getLmMaxFwbm(regBaseSllmService.getLmbmStr()));
		}
		if(StringUtils.isNotBlank(request.getParameter("view"))){
			model.addAttribute("views", request.getParameter("view"));
		}
		model.addAttribute("regBaseSllm", regBaseSllm);
		return "modules/reg/base/regBaseSllmForm";
	}
	
	/**
	 * 林权变更物理登记form页面
	 * @param regBusLq
	 * @param model
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:base:regBaseSllm:view")
	@RequestMapping(value = "sllmForm")
	public String sllmForm(RegBaseSllm regBaseSllm, Model model, HttpServletRequest request) {
		String jid = "";
		//获取当前业务号
		String ywh = request.getParameter("YWH");
		String djlx = request.getParameter("djlx");
		String xg = request.getParameter("xg");
		model.addAttribute("ywh", ywh);
		model.addAttribute("djlx", djlx);
		model.addAttribute("xg", xg);
		String optype = request.getParameter("optype");
		if(StringUtils.isNotBlank(optype)){
			jid = request.getParameter("ids");
			RegBusLq lqxx = regBusLqService.get(jid);
			RegBaseSllm Sllm = new RegBaseSllm();
			Sllm.setBdcdyh(lqxx.getBdcdyh());
			if(lqxx.getDjsj() != null){
				Sllm.setIslogout("0");
			}else{
				Sllm.setIslogout("3");
			}
			List<RegBaseSllm> sllmlist = regBaseSllmService.findList(Sllm);
			if(sllmlist.size() > 0){
				Sllm = sllmlist.get(0);
			}
			model.addAttribute("optype", optype);
			model.addAttribute("regBaseSllm", Sllm);
		}else{
			jid = request.getParameter("jid");
			RegBusBdcqzsdjxx djxx = regBusBdcqzsdjxxService.get(jid);
			RegBaseSllm Sllm = new RegBaseSllm();
			Sllm.setBdcdyh(djxx.getBdcdyh());
			Sllm.setIslogout("0");
			List<RegBaseSllm> sllmlist = regBaseSllmService.findList(Sllm);
			if(sllmlist.size() > 0){
				Sllm = sllmlist.get(0);
			}
			model.addAttribute("oldsllmid", Sllm.getId());
			model.addAttribute("regBaseSllm", Sllm);
		}
		model.addAttribute("jid", jid);
		return "modules/reg/base/regBaseSllmbgForm";
	}
	
	@RequiresPermissions("reg:base:regBaseSllm:edit")
	@RequestMapping(value = "save")
	public synchronized String save(RegBaseSllm regBaseSllm, Model model, RedirectAttributes redirectAttributes, HttpServletRequest request) {
		if (!beanValidator(model, regBaseSllm)){
			return form(regBaseSllm, model, request);
		}
		if(StringUtils.isBlank(regBaseSllm.getId())){
				//生成不动产单元号:zddm + L + 00000001(一林地即为一宗地)
			if(StringUtils.isNotBlank(regBaseSllm.getZddm())){
				//根据地籍子区sllm不动产单元号最后顺序增加
				String maxLmsxh = regBaseSllmService.getMaxLmbdcdyh(regBaseSllm.getZddm().substring(0, 12));
				String nextLmbdcdyh = getNextLmbdcdyh(maxLmsxh);
				regBaseSllm.setBdcdyh(regBaseSllm.getZddm()+"L"+nextLmbdcdyh);
			}
			String lmbm = RegUtils.getLmMaxFwbm(regBaseSllmService.getLmbmStr());//没有的时候返回1000000,然后+1最为第一笔
			regBaseSllm.setLmbm(lmbm);
		}
		RegBaseZdjbxx regBaseZdjbxx = regBaseZdjbxxService.get(regBaseSllm.getZdid());
		regBaseZdjbxx.setIsaudit("2");
		regBaseZdjbxx.setIslogout("0");
		regBaseZdjbxxService.save(regBaseZdjbxx);
		regBaseSllm.setIsaudit("0");
		regBaseSllm.setIsdiya("0");
		regBaseSllm.setIschafeng("0");
		regBaseSllm.setIsyiyi("0");
		regBaseSllm.setIslogout("0");
		regBaseSllmService.save(regBaseSllm);
		addMessage(redirectAttributes, "保存森林、林木信息成功");
		return "redirect:"+Global.getAdminPath()+"/reg/base/regBaseSllm/list?repage";
	}
	//生成下一个不动产单元号
	private String getNextLmbdcdyh(String maxLmsxh) {
		String nextLmsxh = "00000001";
		if(StringUtils.isNotBlank(maxLmsxh)){
			int num = Integer.parseInt(maxLmsxh)+1;
			nextLmsxh = String.format("%08d", num);
		}
		return nextLmsxh;
	}

	/**
	 * 森林林木变更保存
	 * @param regBaseSllm
	 * @param model
	 * @param redirectAttributes
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:base:regBaseSllm:edit")
	@RequestMapping(value = "sllmbgsave")
	public synchronized String sllmbgsave(RegBaseSllm regBaseSllm, Model model, RedirectAttributes redirectAttributes, HttpServletRequest request) {
		if (!beanValidator(model, regBaseSllm)){
			return form(regBaseSllm, model, request);
		}
		String ywh = request.getParameter("ywh");
		String djlx = request.getParameter("djlx");
		String jid = request.getParameter("jid");
		String oldid = regBaseSllm.getId();
		String optype = request.getParameter("optype");
		String oldsllmid = request.getParameter("oldsllmid");
		model.addAttribute("optype", optype);
		String xg = request.getParameter("xg");
		model.addAttribute("xg", xg);
		//删除新增森林林木信息
		if(StringUtils.isNotBlank(ywh)){
			if(StringUtils.isBlank(optype)){
				RegBusBdcqzsdjxx Bdcqzsdjxx = new RegBusBdcqzsdjxx();
				Bdcqzsdjxx.setYwh(ywh);
				regBusBdcqzsdjxxService.deletezyyg(Bdcqzsdjxx);
				regBusLqService.deleteLq(ywh);
				
				RegBusYwr ywr1 = new RegBusYwr();
				ywr1.setYwh(ywh);
				regBusYwrService.deleteywr(ywr1);
				
				RegBusQlr qlr_1 = new RegBusQlr();
				qlr_1.setYwh(ywh);
				List<RegBusQlr> qlrList_1 =regBusQlrService.findList_1(qlr_1);
				if(qlrList_1.size() > 0){
					for(int i=0;i<qlrList_1.size();i++){
						qlr_1 = qlrList_1.get(i);
						regBusQlrService.delete(qlr_1);
					}
				}
				RegBaseSllmbhqk sllmbhqk = new RegBaseSllmbhqk();
				sllmbhqk.setYwh(ywh);
				sllmbhqk.setBdcdyh(regBaseSllm.getBdcdyh());
				List<RegBaseSllmbhqk> listbh =  regBaseSllmbhqkService.findList(sllmbhqk);
				if(listbh.size() > 0 ){
					sllmbhqk = listbh.get(0);
					RegBaseSllm sllmnew  = new RegBaseSllm();
					sllmnew = regBaseSllmService.get(sllmbhqk.getSllmid());
					RegBaseSllmbhqk sllmbhqkdel = new RegBaseSllmbhqk();
					sllmbhqkdel.setYwh(ywh);
					regBaseSllmbhqkService.deleteSllmbhqk(sllmbhqkdel);
					regBaseSllmService.delete(sllmnew);
				}
			}
		}
		String bdcdyh = "";
		if(StringUtils.isBlank(optype)){
			RegBaseSllm sllm = new RegBaseSllm();
			sllm = regBaseSllm;
			RegBaseSllm sllmold = new RegBaseSllm();
			sllmold.setBdcdyh(regBaseSllm.getBdcdyh());
			sllmold.setIslogout("0");
			List<RegBaseSllm> sllmoldlist = regBaseSllmService.findList(sllmold);
			if(sllmoldlist.size() > 0){
				sllmold = sllmoldlist.get(0);
				sllm.setZdid(sllmold.getZdid());
			}
			sllm.setId("");
			sllm.setIslogout("3");
			regBaseSllmService.save(sllm);
			addMessage(redirectAttributes, "保存森林、林木信息成功");
			//保存森林林木变化情况表
			RegBaseSllmbhqk slbhqk = new RegBaseSllmbhqk();
			slbhqk.setYwh(ywh);
			slbhqk.setBdcdyh(sllm.getBdcdyh());
			slbhqk.setSllmid(sllm.getId());
			slbhqk.setOldsllmid(oldsllmid);
			regBaseSllmbhqkService.save(slbhqk);
			bdcdyh = sllm.getBdcdyh();
		}else{
			regBaseSllmService.save(regBaseSllm);
			//保存森林林木变化情况表
			RegBaseSllmbhqk slbhqknew = new RegBaseSllmbhqk();
			slbhqknew.setYwh(ywh);
			slbhqknew.setBdcdyh(regBaseSllm.getBdcdyh());
			List<RegBaseSllmbhqk> listbhqk = regBaseSllmbhqkService.findList(slbhqknew);
			if(listbhqk.size() > 0){
				slbhqknew = listbhqk.get(0);
				slbhqknew.setYwh(ywh);
				slbhqknew.setBdcdyh(regBaseSllm.getBdcdyh());
				slbhqknew.setSllmid(regBaseSllm.getId());
//				slbhqknew.setOldsllmid(oldsllmid);
				regBaseSllmbhqkService.save(slbhqknew);
			}
			bdcdyh = regBaseSllm.getBdcdyh();
		}
		return "redirect:"+Global.getAdminPath()+"/reg/bus/regBusLq/sllmbgdjForm?ywh="+ywh+"&YSDM=2001010000&djlx="+djlx+"&jid="+jid+"&old="+oldid+"&xg="+xg+"&optype="+optype+"&bdcdyh="+bdcdyh;
	}
	
	@RequiresPermissions("reg:base:regBaseSllm:edit")
	@RequestMapping(value = "audit")
	@Transactional
	public String audit(RegBaseSllm regBaseSllm,HttpServletRequest request, RedirectAttributes redirectAttributes) {
		String lmId = "";
		if(StringUtils.isNotBlank(request.getParameter("id"))){
			lmId = request.getParameter("id");
		}
		regBaseSllm = regBaseSllmService.get(lmId);
		//设置该数据已经被审核
		regBaseSllm.setIsaudit("1");
		regBaseSllmService.save(regBaseSllm);
		addMessage(redirectAttributes, "林木信息审核成功!");
		return "redirect:"+Global.getAdminPath()+"/reg/base/regBaseSllm/";
	}
	
	@RequiresPermissions("reg:base:regBaseSllm:edit")
	@RequestMapping(value = "unaudit")
	@Transactional
	public String unaudit(RegBaseSllm regBaseSllm, RedirectAttributes redirectAttributes, HttpServletRequest request) {
		String qjcx = request.getParameter("qjcx");
		regBaseSllm = regBaseSllmService.get(regBaseSllm.getId());
		//设置该数据已经被审核
		regBaseSllm.setIsaudit("0");
		regBaseSllmService.save(regBaseSllm);
		addMessage(redirectAttributes, "林木信息反审核成功!");
		if(StringUtils.isNoneBlank(qjcx)){
			return "redirect:"+Global.getAdminPath()+"/reg/base/regBaseSllm/alllist";
		}else{
			return "redirect:"+Global.getAdminPath()+"/reg/base/regBaseSllm/";
		}
	}
	
	@RequiresPermissions("reg:base:regBaseSllm:edit")
	@RequestMapping(value = "delete")
	public String delete(RegBaseSllm regBaseSllm, RedirectAttributes redirectAttributes, HttpServletRequest request) {
		String qjcx = request.getParameter("qjcx");
		if(StringUtils.isNotBlank(regBaseSllm.getId())){
			regBaseSllm = regBaseSllmService.get(regBaseSllm.getId());
			RegBaseZdjbxx regBaseZdjbxx = new RegBaseZdjbxx();
			regBaseZdjbxx.setZddm(regBaseSllm.getZddm());
			regBaseZdjbxx.setIslogout("13");
			List<RegBaseZdjbxx> findListzd = regBaseZdjbxxService.findList(regBaseZdjbxx);
			if(findListzd.size() > 0){
				regBaseZdjbxx = findListzd.get(0);
				regBaseZdjbxx.setIsaudit("1");
				regBaseZdjbxxService.save(regBaseZdjbxx);
			}
			regBaseSllmService.delete(regBaseSllm);
		}
		addMessage(redirectAttributes, "删除林木信息成功");
		if(StringUtils.isNoneBlank(qjcx)){
			return "redirect:"+Global.getAdminPath()+"/reg/base/regBaseSllm/alllist";
		}else{
			return "redirect:"+Global.getAdminPath()+"/reg/base/regBaseSllm/";
		}
	}
	
	/**
	 * 森林、林木添加向导
	 * @param regBaseXm
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "guideList")
	public String guideList(RegBaseSllm regBaseSllm, HttpServletRequest request, HttpServletResponse response, Model model) {
		RegBusRights regBusRights = new RegBusRights();
		regBusRights.setStxq(null);
		String djxl = request.getParameter("DJXL");
		String lsbj = request.getParameter("lsbj");
		if(StringUtils.isNotBlank(lsbj)){
			model.addAttribute("lsbj", lsbj);
		}
		if(StringUtils.isNotBlank(djxl)){
			regBaseSllm.setIsaudit("1");
			regBaseSllm.setIslogout("0");
			Page<RegBaseSllm> page = regBaseSllmService.findPage(new Page<RegBaseSllm>(request, response), regBaseSllm); 
			model.addAttribute("page", page);
			model.addAttribute("DJXL", djxl);
		}else {
			Page<RegBaseSllm> page = regBaseSllmService.findPage(new Page<RegBaseSllm>(request, response), regBaseSllm); 
			model.addAttribute("page", page);
		}
		if(StringUtils.isNotBlank(request.getParameter("YWH"))){
			model.addAttribute("ywh", request.getParameter("YWH"));
		}
		//request.getSession().removeAttribute(request.getParameter("YWH")+"_selectedIDs");
		return "modules/reg/bus/dialog/ForestGuide";
	}

	/**
	 * 森林、林木所有权分割
	 * @param regBaseZdjbxx
	 * @param model
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:base:regBaseZdjbxx:view")
	@RequestMapping(value = "lqDivisionform")
	public String lqDivisionform(RegBaseSllm regBaseSllm, Model model, HttpServletRequest request) {
		//根据宗地代码查看一条宗地信息,只能是VIEWS时查看【要不然save时没有验证通过返回FORM时就会根据已选的宗地代码查出宗地信息】
		if(StringUtils.isNotBlank(regBaseSllm.getZddm()) && StringUtils.isNotBlank(request.getParameter("VIEWS"))){
			regBaseSllm.setIslogout("13");
			List<RegBaseSllm> findList = regBaseSllmService.findList(regBaseSllm);
			for(int i=0;i<findList.size();i++){
				regBaseSllm = findList.get(0);
			}
		}
		
		String ywh = request.getParameter("YWH");
		String oldywid = request.getParameter("oldywid");
		String sllmId = request.getParameter("sllmId");
		String optype = request.getParameter("optype");
		if(StringUtils.isNotBlank(request.getParameter("YSDM"))){
			model.addAttribute("YSDM",request.getParameter("YSDM"));
		}
		if(StringUtils.isNotBlank(ywh)){
			model.addAttribute("YWH",ywh);
		}
		if(StringUtils.isNotBlank(request.getParameter("VIEWS"))){
			model.addAttribute("VIEWS", request.getParameter("VIEWS"));
		}
		RegBusBdcqzsdjxx entity = new RegBusBdcqzsdjxx();
		if(StringUtils.isNotBlank(optype)){
			RegBusBdcqzsdjxx regBusBdcqzsdjxx = new RegBusBdcqzsdjxx();
			RegBaseSllmbhqk regBaseSllmbhqk = new RegBaseSllmbhqk();
			RegBusLq regBusLq = new RegBusLq();
			regBusLq = regBusLqService.get(oldywid);
			
			regBaseSllmbhqk.setYwh(ywh);
			regBaseSllmbhqk.setBdcdyh(regBusLq.getBdcdyh());
			List<RegBaseSllmbhqk> listregBaseSllmbhqk = regBaseSllmbhqkService.findList(regBaseSllmbhqk);
			if(listregBaseSllmbhqk.size() == 1){
				regBaseSllmbhqk = listregBaseSllmbhqk.get(0);
				regBaseSllm = regBaseSllmService.get(regBaseSllmbhqk.getSllmid());
			}
			regBusBdcqzsdjxx.setYwh(ywh);
			regBusBdcqzsdjxx.setBdcdyh(regBusLq.getBdcdyh());
			List<RegBusBdcqzsdjxx> listRegBusBdcqzsdjxx = regBusBdcqzsdjxxService.findList(regBusBdcqzsdjxx);
			if(listRegBusBdcqzsdjxx.size() == 1){
				regBusBdcqzsdjxx = listRegBusBdcqzsdjxx.get(0);
				oldywid = regBusBdcqzsdjxx.getOldid();
			}
			model.addAttribute("OldSllmId", regBaseSllmbhqk.getSllmid());
			model.addAttribute("optype", optype);
		}else {
			RegBaseSllm regBaseSllmTemp = new RegBaseSllm();
			if(StringUtils.isNotBlank(oldywid)){
				entity = regBusBdcqzsdjxxService.get(oldywid);
				regBaseSllmTemp = regBaseSllmService.getBdcdyh(entity.getBdcdyh());
				if(regBaseSllmTemp != null){
					if(StringUtils.isNotBlank(sllmId)){
						regBaseSllm = regBaseSllmService.get(sllmId);
						model.addAttribute("views", "1");
					} else {
						BeanUtils.copyProperties(regBaseSllmTemp, regBaseSllm);
						regBaseSllm.setBdcdyh(null);
						regBaseSllm.setId(null);
					}
				}
				model.addAttribute("OldSllmId", regBaseSllmTemp.getId());
			}
		}
		model.addAttribute("oldywid", oldywid);
		RegBusQlr regBusQlr = new RegBusQlr();
		if(StringUtils.isNotBlank(optype)){
			regBusQlr.setYwh(ywh);
		}else {
			regBusQlr.setYwh(entity.getYwh());
		}
		
		if(StringUtils.isNotBlank(request.getParameter("djlx"))){
			model.addAttribute("DJLX", request.getParameter("djlx"));
		}
		
		model.addAttribute("regBaseSllm", regBaseSllm);
		
		return "modules/reg/base/regBaseSllmDivisionForm";
	}
	
	/**
	 * 森林、林木分割
	 * @param regBaseZdjbxx
	 * @param model
	 * @param redirectAttributes
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:base:regBaseZdjbxx:edit")
	@RequestMapping(value = "sllmDivisionSave")
	public synchronized String sllmDivisionSave(RegBaseSllm regBaseSllm, Model model, RedirectAttributes redirectAttributes, HttpServletRequest request) {
		if (!beanValidator(model, regBaseSllm)){
			return lqDivisionform(regBaseSllm, model, request);
		}
		String ywhStr = request.getParameter("YWH");
		String oldywid = request.getParameter("oldywid");
		String djlx = request.getParameter("DJLX");
		String OldSllmId = request.getParameter("OldSllmId");
		String optype = request.getParameter("optype");
		String retur = request.getParameter("retur");
		List<RegBaseSllm> findListSllm = regBaseSllmService.findList(regBaseSllm);
		RegBaseSllm regBaseSllmtemp = new RegBaseSllm();
		if(findListSllm.size() > 0){
			regBaseSllmtemp = findListSllm.get(0);
			regBaseSllmtemp.setIsaudit("2");
			regBaseSllmService.save(regBaseSllmtemp);
		}
		RegBusBdcqzsdjxx regBusBdcqzsdjxx = new RegBusBdcqzsdjxx();
		regBusBdcqzsdjxx.setYwh(ywhStr);
		List<RegBusBdcqzsdjxx> findListDjxx = regBusBdcqzsdjxxService.findList(regBusBdcqzsdjxx);
		if(StringUtils.isNotBlank(retur)){
			regBusBdcqzsdjxx = findListDjxx.get(0);
		}
		regBusBdcqzsdjxx.setBdcdyh(regBaseSllm.getBdcdyh());
		
		if(StringUtils.isBlank(optype)) {
			RegBusQlr regBusQlr = new RegBusQlr();
			regBusQlr.setYwh(ywhStr);
			List<RegBusQlr> findListSxh = regBusQlrService.findListSxh(regBusQlr);
			if(findListSxh.size() > 0){
				regBusBdcqzsdjxx.setQlrmc(findListSxh.get(0).getQlrmc());
			}
			regBusBdcqzsdjxx.setZl(regBaseSllm.getZl());
			regBusBdcqzsdjxx.setMj(regBaseSllm.getSyqmj()+"");
			regBusBdcqzsdjxx.setZddm(regBaseSllm.getZddm());
			RegBusBdcqzsdjxx old = regBusBdcqzsdjxxService.get(oldywid);
			regBusBdcqzsdjxx.setQllx(old.getQllx());
			regBusBdcqzsdjxx.setQlxz(old.getQlxz());
			regBusBdcqzsdjxx.setYt(old.getYt());
			regBusBdcqzsdjxx.setBdcqzh(old.getBdcqzh());
			regBusBdcqzsdjxx.setBdcqzbh(old.getBdcqzbh());
			regBusBdcqzsdjxx.setYsxlh(old.getYsxlh());
			regBusBdcqzsdjxx.setOldid(old.getId());
			regBusBdcqzsdjxx.setGyqk(old.getGyqk());
			regBusBdcqzsdjxx.setDjlx(djlx);
			regBusBdcqzsdjxx.setStatus(old.getStatus());
			regBusBdcqzsdjxx.setIsfdsj(Integer.valueOf("0"));
			regBusBdcqzsdjxx.setIshistory(old.getIshistory());
			regBusBdcqzsdjxx.setIslogout("0");
			regBusBdcqzsdjxx.setIsprint("0");
			regBusBdcqzsdjxx.setRights(old.getRights());
			regBusBdcqzsdjxxService.save(regBusBdcqzsdjxx);
			RegBaseSllm regBaseSllmtmp = regBaseSllmService.getBdcdyh(old.getBdcdyh());
			if(regBaseSllmtmp != null){
				regBaseSllm.setIsdiya(regBaseSllmtmp.getIsdiya());
				regBaseSllm.setIschafeng(regBaseSllmtmp.getIschafeng());
				regBaseSllm.setIsyiyi(regBaseSllmtmp.getIsyiyi());
			}
		}
		regBaseSllm.setId(null);
		regBaseSllm.setStatus("1");
		regBaseSllm.setIsaudit("2");
		regBaseSllm.setIslogout("3");//先不生效,登簙时生效,同时注销之前的宗地基本信息,可以通过宗地情况变化表里的OLDID
		regBaseSllm.setZdid(regBaseSllmtemp.getZdid());
		regBaseSllmService.save(regBaseSllm);
		
		//森林、林木情况变化表-把已经选择出来的基本信息保存起来 
		RegBaseSllmbhqk regBaseSllmbhqk = new RegBaseSllmbhqk();
		//如果没已有对象,那就新增
		regBaseSllmbhqk.setYwh(ywhStr);
		regBaseSllmbhqk.setId(null);
		regBaseSllmbhqk.setBdcdyh(regBaseSllm.getBdcdyh());
		regBaseSllmbhqk.setSllmid(regBaseSllm.getId());
		regBaseSllmbhqk.setOldsllmid(OldSllmId);
		regBaseSllmbhqkService.save(regBaseSllmbhqk);
		
		return "redirect:"+Global.getAdminPath()+"/reg/bus/regBusLq/fghbchangeform?ywh="+ywhStr+"&djxl="+djlx
				+"&ids="+oldywid+"&optype="+optype+"&sllmId="+regBaseSllm.getId();
	}
	
	/***
	* @Title: nextMerger 
	* @Description: 森林、林木合并基本信息添加页面
	* @param @param regBaseSllm
	* @param @param request
	* @param @param response
	* @param @param model
	* @param @return    设定文件 
	* @return String    返回类型 
	* @throws
	 */
	@RequiresPermissions("reg:base:regBaseZdjbxx:view")
	@RequestMapping(value = {"lqMergerfrom"})
	public String lqMergerfrom(RegBaseSllm regBaseSllm,HttpServletRequest request, Model model) {
		//根据宗地代码查看一条宗地信息,只能是VIEWS时查看【要不然save时没有验证通过返回FORM时就会根据已选的宗地代码查出宗地信息】
		if(StringUtils.isNotBlank(regBaseSllm.getZddm()) && StringUtils.isNotBlank(request.getParameter("VIEWS"))){
			regBaseSllm.setIslogout("13");
			List<RegBaseSllm> findList = regBaseSllmService.findList(regBaseSllm);
			for(int i=0;i<findList.size();i++){
				regBaseSllm = findList.get(0);
			}
		}
		
		String ywh = request.getParameter("YWH");
		String ids = request.getParameter("ids");
		String sllmId = request.getParameter("sllmId");
		String djlx = request.getParameter("djlx");
		String optype = request.getParameter("optype");
		String idList[] = ids.split(";");
		if(StringUtils.isNotBlank(request.getParameter("YSDM"))){
			model.addAttribute("YSDM",request.getParameter("YSDM"));
		}
		if(StringUtils.isNotBlank(ywh)){
			model.addAttribute("YWH",ywh);
		}
		if(StringUtils.isNotBlank(request.getParameter("VIEWS"))){
			model.addAttribute("VIEWS", request.getParameter("VIEWS"));
		}
		RegBusBdcqzsdjxx regBusBdcqzsdjxx = new RegBusBdcqzsdjxx();
		RegBusBdcqzsdjxx entity = new RegBusBdcqzsdjxx();
		if(StringUtils.isNotBlank(optype)){
			RegBaseSllmbhqk regBaseSllmbhqk = new RegBaseSllmbhqk();
			RegBusLq regBusLq = new RegBusLq();
			regBusLq = regBusLqService.get(ids);
			regBaseSllmbhqk.setBdcdyh(regBusLq.getBdcdyh());
			regBusBdcqzsdjxx.setBdcdyh(regBusLq.getBdcdyh());
			regBaseSllmbhqk.setYwh(ywh);
			List<RegBaseSllmbhqk> listRegBaseZdbhqk = regBaseSllmbhqkService.findList(regBaseSllmbhqk);
			if(listRegBaseZdbhqk.size() == 1){
				regBaseSllmbhqk = listRegBaseZdbhqk.get(0);
				regBaseSllm = regBaseSllmService.get(regBaseSllmbhqk.getSllmid());
			}
			regBusBdcqzsdjxx.setYwh(ywh);
			List<RegBusBdcqzsdjxx> listRegBusBdcqzsdjxx = regBusBdcqzsdjxxService.findList(regBusBdcqzsdjxx);
			if(listRegBusBdcqzsdjxx.size() == 1){
				regBusBdcqzsdjxx = listRegBusBdcqzsdjxx.get(0);
				ids = regBusBdcqzsdjxx.getOldid();
			}
			model.addAttribute("optype", optype);
		}else {
			if(StringUtils.isNotBlank(sllmId)){
				regBaseSllm = regBaseSllmService.get(sllmId);
				model.addAttribute("views", "1");
			}else{
				regBusBdcqzsdjxx.setYwh(ywh);
				List<RegBusBdcqzsdjxx> listRegBusBdcqzsdjxx = regBusBdcqzsdjxxService.findList(regBusBdcqzsdjxx);
				if(listRegBusBdcqzsdjxx.size() == 1){
					regBusBdcqzsdjxx = listRegBusBdcqzsdjxx.get(0);
					RegBaseSllmbhqk regBaseSllmbhqk = new RegBaseSllmbhqk();
					regBaseSllmbhqk.setYwh(ywh);
					List<RegBaseSllmbhqk> listregBaseSllmbhqk = regBaseSllmbhqkService.findList(regBaseSllmbhqk);
					for(int i=0;i<listregBaseSllmbhqk.size();i++){
						RegBaseSllmbhqk regBaseSllmbhqkT = listregBaseSllmbhqk.get(i);
						RegBaseSllm regBaseSllmtmp = new RegBaseSllm();
						regBaseSllmtmp = regBaseSllmService.get(regBaseSllmbhqkT.getSllmid());
						RegBaseZdjbxx regBaseZdjbxx = new RegBaseZdjbxx();
						regBaseZdjbxx.setZddm(regBaseSllmtmp.getZddm());
						regBaseZdjbxx.setIslogout("13");
						List<RegBaseZdjbxx> findListZdjbxx = regBaseZdjbxxService.findList(regBaseZdjbxx);
						if(findListZdjbxx.size() > 0){
							regBaseZdjbxx = findListZdjbxx.get(0);
							regBaseZdjbxx.setIsaudit("1");//已审核
							regBaseZdjbxxService.save(regBaseZdjbxx);
						}
						regBaseSllmService.delete(regBaseSllmtmp);
					}
					regBaseSllmbhqkService.deleteSllmbhqk(regBaseSllmbhqk);
					regBusQlrService.deleteywh(ywh);
					regBusLqService.deleteLq(ywh);
					regBusBdcqzsdjxxService.deletezyyg(regBusBdcqzsdjxx);
				}
				entity = regBusBdcqzsdjxxService.get(idList[0]);
				RegBaseSllm regBaseSllmTemp = new RegBaseSllm();
				regBaseSllmTemp.setBdcdyh(entity.getBdcdyh());
				regBaseSllmTemp.setIslogout("0");//获取当前宗地基本信息中此宗地代码唯一一条有效数据
				List<RegBaseSllm> listJbxx = regBaseSllmService.findList(regBaseSllmTemp);
				if(listJbxx != null && listJbxx.size()>0){
					regBaseSllmTemp = listJbxx.get(0);
					BeanUtils.copyProperties(regBaseSllmTemp, regBaseSllm);
					regBaseSllm.setBdcdyh(null);
				}
			}
		}
		
		if(StringUtils.isNotBlank(djlx)){
			model.addAttribute("DJLX", djlx);
		}
		if(StringUtils.isNotBlank(ids)){
			model.addAttribute("ids", ids);
		}
		model.addAttribute("regBaseSllm", regBaseSllm);
		
		return "modules/reg/base/regBaseSllmMergerForm";
	}
	
	/***
	* @Title: mergerSave 
	* @Description: 土地合并宗地基本信息保存
	* @param @param regBaseZdjbxx
	* @param @param model
	* @param @param redirectAttributes
	* @param @param request
	* @param @return    设定文件 
	* @return String    返回类型 
	* @throws
	 */
	@RequiresPermissions("reg:base:regBaseSllm:edit")
	@RequestMapping(value = "lqMergerSave")
	public synchronized String lqMergerSave(RegBaseSllm regBaseSllm, Model model, RedirectAttributes redirectAttributes, HttpServletRequest request) {
		if (!beanValidator(model, regBaseSllm)){
			return lqMergerfrom(regBaseSllm, request, model);
		}
		String ywhStr = request.getParameter("YWH");
		String djlx = request.getParameter("DJLX");
		String ids = request.getParameter("ids");
		String isList[] = ids.split(";");
		String optype = request.getParameter("optype");
		List<RegBaseSllm> findListSllm = regBaseSllmService.findList(regBaseSllm);
		RegBaseSllm regBaseSllmtemp = new RegBaseSllm();
		if(findListSllm.size() > 0){
			regBaseSllmtemp = findListSllm.get(0);
			regBaseSllmtemp.setIsaudit("2");
			regBaseSllmService.save(regBaseSllmtemp);
		}
		RegBusBdcqzsdjxx regBusBdcqzsdjxx = new RegBusBdcqzsdjxx();
		regBusBdcqzsdjxx.setYwh(ywhStr);
		List<RegBusBdcqzsdjxx> findListDjxx = regBusBdcqzsdjxxService.findList(regBusBdcqzsdjxx);
		if(findListDjxx.size() > 0){
			regBusBdcqzsdjxx = findListDjxx.get(0);
		}
		regBusBdcqzsdjxx.setBdcdyh(regBaseSllm.getBdcdyh());
		regBusBdcqzsdjxx.setZl(regBaseSllm.getZl());
		//然后把宗地代码先填入到不动产单元号里面,作为不动产单元号生成的备用信息,直到初审通过的那一刻才真正生成不动产单元号
		regBusBdcqzsdjxx.setMj(regBaseSllm.getSyqmj()+"");
		regBusBdcqzsdjxx.setZddm(regBaseSllm.getZddm());
		String oldywh = "";
		if(StringUtils.isBlank(optype)){//首次保存,新增宗地数据
			RegBusBdcqzsdjxx old = regBusBdcqzsdjxxService.get(isList[0]);
			oldywh = old.getYwh();
			regBusBdcqzsdjxx.setQllx(old.getQllx());
			regBusBdcqzsdjxx.setQlxz(old.getQlxz());
			regBusBdcqzsdjxx.setYt(old.getYt());
			regBusBdcqzsdjxx.setQlrmc(old.getQlrmc());
			regBusBdcqzsdjxx.setOldid(ids);
			regBusBdcqzsdjxx.setGyqk(old.getGyqk());
			regBusBdcqzsdjxx.setDjlx(djlx);
			regBusBdcqzsdjxx.setStatus(old.getStatus());
			regBusBdcqzsdjxx.setIsfdsj(Integer.valueOf("0"));
			regBusBdcqzsdjxx.setIshistory(old.getIshistory());
			regBusBdcqzsdjxx.setIslogout("0");
			regBusBdcqzsdjxx.setIsprint("0");
			regBusBdcqzsdjxx.setRights(old.getRights());
			regBusBdcqzsdjxxService.save(regBusBdcqzsdjxx);
			
			regBaseSllm.setStatus("1");
			regBaseSllm.setIsaudit("2");
			regBaseSllm.setIslogout("3");//先不生效,登簙时生效,同时注销之前的宗地基本信息,可以通过宗地情况变化表里的OLDID
			regBaseSllm.setZdid(regBaseSllmtemp.getZdid());
			RegBaseSllm regBaseSllmtmp = regBaseSllmService.getBdcdyh(old.getBdcdyh());
			if(regBaseSllmtmp != null){
				regBaseSllm.setIsdiya(regBaseSllmtmp.getIsdiya());
				regBaseSllm.setIschafeng(regBaseSllmtmp.getIschafeng());
				regBaseSllm.setIsyiyi(regBaseSllmtmp.getIsyiyi());
			}
			regBaseSllmService.save(regBaseSllm);
//			RegBaseZdjbxx regBaseZdjbxx = new RegBaseZdjbxx();
//			regBaseZdjbxx.setZddm(regBaseSllm.getZddm());
//			regBaseZdjbxx.setIslogout("13");
//			List<RegBaseZdjbxx> findListZdjbxx = regBaseZdjbxxService.findList(regBaseZdjbxx);
//			if(findListZdjbxx.size() > 0){
//				regBaseZdjbxx = findListZdjbxx.get(0);
//				regBaseZdjbxx.setIsaudit("2");//已引用
//				regBaseZdjbxxService.save(regBaseZdjbxx);
//			}
			
			RegBusQlr regBusOldQlr = new RegBusQlr();
			regBusOldQlr.setYwh(oldywh);//旧业务号
			List<RegBusQlr> findList_1 = regBusQlrService.findListSxh(regBusOldQlr);
			for(int i=0; i<findList_1.size(); i++){
				regBusOldQlr = findList_1.get(i);
				regBusOldQlr.setYwh(ywhStr);
				regBusOldQlr.setId(null);
				regBusOldQlr.setQszt("0");
				regBusQlrService.save(regBusOldQlr);
			}
		}
		
		//森林、林木情况变化表-把已经选择出来的旧森林、林木基本信息保存起来 
		RegBaseSllmbhqk regBaseSllmbhqk = new RegBaseSllmbhqk();
		regBaseSllmbhqk.setYwh(ywhStr);
		List<RegBaseSllmbhqk> findList = regBaseSllmbhqkService.findList(regBaseSllmbhqk);
		if(findList.size()>0){
			//当前业务号已经有值,更新就好了	
			regBaseSllmbhqk = findList.get(0);
		}else{
			//如果没已有对象,那就新增
			regBaseSllmbhqk.setYwh(ywhStr);
			regBaseSllmbhqk.setId(null);
		}
		regBaseSllmbhqk.setBdcdyh(regBaseSllm.getBdcdyh());
		regBaseSllmbhqk.setSllmid(regBaseSllm.getId());
		regBaseSllmbhqk.setOldsllmid(regBaseSllmtemp.getId());
		regBaseSllmbhqkService.save(regBaseSllmbhqk);
		return "redirect:"+Global.getAdminPath()+"/reg/bus/regBusLq/fghbchangeform?ywh="+ywhStr+"&djxl="+djlx
				+"&ids="+ids+"&optype="+optype+"&sllmId="+regBaseSllm.getId();
	}
	
	
	
}