832813bd4552fe1c9ba8dcbf564752cfd0dc90a1.svn-base 65.7 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 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745
/**

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

import java.io.File;
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
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.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
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.service.ServiceException;
import com.thinkgem.jeesite.common.utils.DateUtils;
import com.thinkgem.jeesite.common.utils.JsonUtil;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.modules.reg.bus.entity.RegBusBtqlr;
import com.thinkgem.jeesite.modules.reg.bus.service.RegBusBtqlrService;
import com.thinkgem.jeesite.modules.reg.dao.bus.RegBusQlrRelationYwhDao;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseH;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBasePerson;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseZdjbxx;
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.RegBusFdcq2;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusQlr;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusQlrRelationYwh;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusSlsq;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusYgdj;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseHService;
import com.thinkgem.jeesite.modules.reg.service.base.RegBasePersonService;
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.RegBusDyaqService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusFdcq2Service;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusQlrService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusSlsqService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusYgdjService;
import com.thinkgem.jeesite.modules.reg.utils.RegUtils;
import com.thinkgem.jeesite.modules.sys.entity.RegBusInterHis;
import com.thinkgem.jeesite.modules.sys.entity.User;
import com.thinkgem.jeesite.modules.sys.service.InterSiService;
import com.thinkgem.jeesite.modules.sys.utils.DictUtils;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;

/**
 * 权利人信息维护Controller
 * 
 * @author xuyg
 * @version 2015-10-15
 */
@Controller
@RequestMapping(value = "${adminPath}/reg/nf/regBusQlr")
public class RegBusNfQlrController extends BaseController {
	@Autowired
	private RegBusQlrService regBusQlrService;
	@Autowired
	private RegBusDyaqService regBusDyaqService;
	@Autowired
	private RegBusQlrRelationYwhDao regBusQlrRelationYwhDao;
	@Autowired
	private RegBusBdcqzsdjxxService regBusBdcqzsdjxxService;
	@Autowired
	private RegBusYgdjService regBusYgdjService;
	@Autowired
	private RegBusFdcq2Service regBusFdcq2Service;
	@Autowired
	private RegBusSlsqService regBusSlsqService;
	@Autowired
	private RegBasePersonService regBasePersonService;
	@Autowired
	private RegBaseZdjbxxService regBaseZdjbxxService;
	@Autowired
	private RegBusBtqlrService regBusBtqlrService;
	@Autowired
	private RegBaseHService regBaseHService;
	@Autowired
	private InterSiService siService;

	@ModelAttribute
	public RegBusQlr get(@RequestParam(required = false) String id) {
		RegBusQlr entity = null;
		if (StringUtils.isNotBlank(id)) {
			entity = regBusQlrService.get(id);
		}
		if (entity == null) {
			entity = new RegBusQlr();
		}
		return entity;
	}

	@RequiresPermissions("reg:bus:regBusQlr:view")
	@RequestMapping(value = { "list", "" })
	public String list(RegBusQlr regBusQlr, HttpServletRequest request, HttpServletResponse response, Model model) {
		regBusQlr.setYwh("LZ");
		Page<RegBusQlr> page = regBusQlrService.findPage_nf(new Page<RegBusQlr>(request, response), regBusQlr);
		model.addAttribute("page", page);
		return "modules/reg/nf/regBusQlrList";
	}

	@RequiresPermissions("reg:bus:regBusQlr:view")
	@RequestMapping(value = "yrform")
	public String yrform(RegBusQlr regBusQlr, Model model, HttpServletRequest request) {
		Map<String, String> map = new HashMap<String, String>();
		if (StringUtils.isNotBlank(request.getParameter("ywh"))) {
			model.addAttribute("ywh", request.getParameter("ywh"));
			regBusQlr.setYwh(request.getParameter("ywh"));
		}
		if (StringUtils.isNotBlank(request.getParameter("SXH"))) {
			model.addAttribute("SXH", request.getParameter("SXH"));
		}
		String ids = request.getParameter("ids");
		RegBasePerson person = new RegBasePerson();
		person = regBasePersonService.get(ids);
		regBusQlr.setZjzl(person.getZjzl());
		regBusQlr.setSshy(DictUtils.getDictLabel(person.getSshy(), "reg_bus_sshy", ""));
		regBusQlr.setZjh(person.getZjh());
		regBusQlr.setHjszss(person.getHjszss());
		regBusQlr.setXb(person.getXb());
		regBusQlr.setDh(person.getDh());
		regBusQlr.setYb(person.getYb());
		regBusQlr.setGzdw(person.getGzdw());
		regBusQlr.setDzyj(person.getDzyj());
		regBusQlr.setDlrmc(person.getDlrymc());
		regBusQlr.setDljgmc(person.getDljg());
		regBusQlr.setDlrdh(person.getDlrydh());
		regBusQlr.setBz(person.getBz()+" 补充");
		regBusQlr.setQlrlx(person.getRylx());
		regBusQlr.setHjszss(person.getHjszss());
		regBusQlr.setPcode(person.getPcode());
		regBusQlr.setSczt(person.getSczt());
		regBusQlr.setVeritysczt(person.getVeritysczt());
		regBusQlr.setFzjg(person.getFzjg());
		regBusQlr.setSfczr(DictUtils.getDictValue("是", "yes_no", ""));
		regBusQlr.setId("");
		if (StringUtils.isNotBlank(request.getParameter("XG")) && StringUtils.isNotBlank(request.getParameter("qlrid"))
				&& StringUtils.isNotBlank(request.getParameter("ryxz"))) {
			model.addAttribute("opty", "1");
			model.addAttribute("ryxz", "1");
		}
		if (StringUtils.isNotBlank(person.getRymc())) {
			map.put("QLR", person.getRymc());
		}
		if (StringUtils.isNotBlank(person.getDz())) {
			map.put("ZL", person.getDz());
		}
		model.addAttribute("pcode", person.getPcode());
		model.addAttribute("maps", map);
		String qxdm = DictUtils.getDictLabel(Global.getAreaCode(), "reg_bus_xq", "");
		RegBusInterHis his = null;
		System.out.println(request.getParameter("DJLX"));
		model.addAttribute("regBusQlr", regBusQlr);
		
			return "modules/reg/nf/regBusQlrForm";
		
	}

	@RequiresPermissions("reg:bus:regBusQlr:view")
	@RequestMapping(value = "hishouseyrform")
	public String hishouseyrform(RegBusQlr regBusQlr, Model model, HttpServletRequest request) {
		Map<String, String> map = new HashMap<String, String>();
		if (StringUtils.isNotBlank(request.getParameter("YWH"))) {
			model.addAttribute("YWH", request.getParameter("YWH"));
		}
		// 变更类型时,控制宗地基本信息页面上的显示情况
		if (StringUtils.isNotBlank(request.getParameter("SXBGLX"))) {
			model.addAttribute("SXBGLX", request.getParameter("SXBGLX"));
		}
		String qlrxxxz = request.getParameter("QLRXXXZ");
		if (StringUtils.isNotBlank(qlrxxxz)) {
			model.addAttribute("SXBGLX", qlrxxxz);
		}
		if (StringUtils.isNotBlank(request.getParameter("DJLX"))) {
			model.addAttribute("DJLX", request.getParameter("DJLX"));
		}
		// 计算当前顺序号【注意:只有新增时才需要这个值】
		if (StringUtils.isBlank(request.getParameter("optype"))) {
			model.addAttribute("SXH", getQlrmcOrderNumber(request.getParameter("YWH")));
		}
		String ids = request.getParameter("ids");
		RegBasePerson person = new RegBasePerson();
		person = regBasePersonService.get(ids);
		regBusQlr.setZjzl(DictUtils.getDictLabel(person.getZjzl(), "reg_bus_zjlx", ""));
		regBusQlr.setZjh(person.getZjh());
		regBusQlr.setHjszss(person.getHjszss());
		regBusQlr.setXb(person.getXb());
		regBusQlr.setDh(person.getDh());
		regBusQlr.setYb(person.getYb());
		regBusQlr.setGzdw(person.getGzdw());
		regBusQlr.setDzyj(person.getDzyj());
		regBusQlr.setDlrmc(person.getDlrymc());
		regBusQlr.setDljgmc(person.getDljg());
		regBusQlr.setDlrdh(person.getDlrydh());
		regBusQlr.setBz(person.getBz());
		regBusQlr.setQlrlx(person.getRylx());
		regBusQlr.setFzjg(person.getFzjg());
		regBusQlr.setHjszss(person.getHjszss());
		regBusQlr.setSfczr(DictUtils.getDictValue("是", "yes_no", ""));
		regBusQlr.setId("");
		if (StringUtils.isNotBlank(person.getRymc())) {
			map.put("QLR", person.getRymc());
		}
		if (StringUtils.isNotBlank(person.getDz())) {
			map.put("ZL", person.getDz());
		}
		model.addAttribute("maps", map);
		model.addAttribute("regBusQlr", regBusQlr);
		return "modules/reg/bus/regBusHisHouseQlrForm";
	}

	@RequiresPermissions("reg:bus:regBusQlr:view")
	@RequestMapping(value = "form")
	public String form(RegBusQlr regBusQlr, Model model, HttpServletRequest request) {
		   if(StringUtils.isNotBlank(request.getParameter("ywh"))) {
		    model.addAttribute("SXH", getQlrmcOrderNumber(request.getParameter("ywh")));
		    model.addAttribute("ywh", request.getParameter("ywh"));
		    regBusQlr.setBz("补充");
		   }else {
			model.addAttribute("SXH", regBusQlr.getSxh());
		   }
		   model.addAttribute("regBusQlr", regBusQlr);
			return "modules/reg/nf/regBusQlrForm";
	}

	@RequiresPermissions("reg:bus:regBusQlr:view")
	@RequestMapping(value = "hishouseForm")
	public String hishouseForm(RegBusQlr regBusQlr, Model model, HttpServletRequest request) {
		model.addAttribute("regBusQlr", regBusQlr);
		// 业务号
		if (StringUtils.isNotBlank(request.getParameter("YWH"))) {
			model.addAttribute("YWH", request.getParameter("YWH"));
		}
		// 传递要素代码
		if (StringUtils.isNotBlank(request.getParameter("YSDM"))) {
			model.addAttribute("YSDM", request.getParameter("YSDM"));
		}
		// 计算当前顺序号【注意:只有新增时才需要这个值】
		if (StringUtils.isBlank(regBusQlr.getId())) {
			model.addAttribute("SXH", getQlrmcOrderNumber(request.getParameter("YWH")));
		}

		// 查看标示
		if (StringUtils.isNotBlank(request.getParameter("VIEWS"))) {
			model.addAttribute("VIEWS", request.getParameter("VIEWS"));
		}
		Map<String, String> map = new HashMap<String, String>();
		if (StringUtils.isNotBlank(request.getParameter("QLR"))) {
			map.put("QLR", request.getParameter("QLR"));
		}
		if (StringUtils.isNotBlank(request.getParameter("ZL"))) {
			map.put("ZL", request.getParameter("ZL"));
		}
		model.addAttribute("maps", map);
		return "modules/reg/bus/regBusHisHouseQlrForm";
	}

	@RequiresPermissions("reg:bus:regBusQlr:view")
	@RequestMapping(value = { "selectedList" })
	public String selectedList(RegBusQlr regBusQlr, HttpServletRequest request, HttpServletResponse response,
			Model model) {
		Page<RegBusQlr> page = regBusQlrService.findPage(new Page<RegBusQlr>(request, response), regBusQlr);
		model.addAttribute("page", page);
		// QLRXXXZ
		if (StringUtils.isNotBlank(request.getParameter("QLRXXXZ"))) {
			model.addAttribute("QLRXXXZ", "1");
		}
		// 初审以后的环节只能查看不能修改删除
		if (StringUtils.isNotBlank(request.getParameter("LISTVIEWS"))) {
			model.addAttribute("LISTVIEWS", "1");
		}
		if (StringUtils.isNotBlank(request.getParameter("ywh"))) {
			model.addAttribute("YWH", request.getParameter("ywh"));
		}
		if (StringUtils.isNotBlank(request.getParameter("YSDM"))) {
			model.addAttribute("YSDM", request.getParameter("YSDM"));
		}
		if (StringUtils.isNotBlank(request.getParameter("QLR"))) {
			model.addAttribute("QLR", request.getParameter("QLR"));
		}
		if (StringUtils.isNotBlank(request.getParameter("ZL"))) {
			model.addAttribute("ZL", request.getParameter("ZL"));
		}
		if (StringUtils.isNotBlank(request.getParameter("QLRDH"))) {
			model.addAttribute("QLRDH", request.getParameter("QLRDH"));
		}
		if (StringUtils.isNotBlank(request.getParameter("QLRYJ"))) {
			model.addAttribute("QLRYJ", request.getParameter("QLRYJ"));
		}
		// 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");
		}
		return "modules/reg/bus/regBusQlrList";
	}

	@RequiresPermissions("reg:bus:regBusQlr:view")
	@RequestMapping(value = "queryinfo")
	@ResponseBody
	public ModelMap queryinfo(HttpServletRequest request) {
		ModelMap modelmap = new ModelMap();
		modelmap.put("success", "");
		RegBusQlr qlr = regBusQlrService.get(request.getParameter("id"));
		RegBusQlr regBusQlr = new RegBusQlr();
		regBusQlr.setQlrmc(qlr.getQlrmc());
		regBusQlr.setZjh(qlr.getZjh());
		List<RegBusQlr> list = regBusQlrService.findList_1(regBusQlr);
		if(list.size()>1) {
			if(StringUtils.isNotBlank(request.getParameter("flag"))) {
			modelmap.put("success", "1");
			}else {
				if(qlr.getGyfs().equals("0")) {//入库时单独所有就不能添加
					modelmap.put("success", "2");
					RegBusBdcqzsdjxx djxx = new RegBusBdcqzsdjxx();
					djxx.setBdcdyh(qlr.getBdcdyh().substring(0, 19)+"F");
					List<RegBusBdcqzsdjxx> djxxlist = regBusBdcqzsdjxxService.findList(djxx);
					/*if(djxxlist.size()>0) {
						modelmap.put("success", "3");//房屋已引用,无法添加
					}*/
				}
			}
		}
		
		return modelmap;
	}

	
	@RequiresPermissions("reg:bus:regBusQlr:edit")
	@RequestMapping(value = "save")
	public String save(RegBusQlr regBusQlr, Model model, HttpServletRequest request,
			RedirectAttributes redirectAttributes) throws IOException {
		//bz为空,则为入库数据,只能修改证件号
		if(StringUtils.isBlank(regBusQlr.getBz())) {
			RegBasePerson person = new RegBasePerson();
			person.setPcode(regBusQlr.getPcode());
			person.setRymc(regBusQlr.getQlrmc());
			List<RegBasePerson> personlist = regBasePersonService.findList(person);
			if(personlist.size()>0) {
				person = personlist.get(0);
				person.setZjh(regBusQlr.getZjh());
				regBasePersonService.save(person);
			}
		}else {
		List<RegBusQlr> qlrlist = regBusQlrService.findByYwh(regBusQlr.getYwh());
		regBusQlr.setQllx(qlrlist.get(0).getQllx());
		regBusQlr.setBdcdyh(qlrlist.get(0).getBdcdyh());
		regBusQlr.setGyfs(qlrlist.get(0).getGyfs());
		regBusQlr.setGyfs(DictUtils.getDictLabel(qlrlist.get(0).getGyfs(), "reg_bus_gyfs", ""));
		}
		regBusQlrService.save(regBusQlr);
		return "redirect:" + Global.getAdminPath() + "/reg/nf/regBusQlr/list";
	}

	/**
	 * 根据当前权利人查询配偶信息并且进行保存或者删除
	 * 
	 * @param regBusQlr
	 * @param flag
	 * @throws JsonParseException
	 * @throws JsonMappingException
	 * @throws IOException
	 * @throws ServiceException
	 */
	private void updateMZQlr(RegBusQlr regBusQlr, String flag)
			throws JsonParseException, JsonMappingException, IOException, ServiceException {
		String str = "{" + "\"" + "cert_num" + "\"" + ":" + "\"" + regBusQlr.getZjh() + "\"" + "," + "\"" + "name"
				+ "\"" + ":" + "\"" + regBusQlr.getQlrmc() + "\"" + "}";
		String si_code = "in/MZ01";
		RegBusInterHis interhis = new RegBusInterHis();
		RegBasePerson person = new RegBasePerson();
		person.setRymc(regBusQlr.getQlrmc());
		person.setZjzl("1");
		person.setZjh(regBusQlr.getZjh());
		List<RegBasePerson> personlst = regBasePersonService.findListqy(person);
		if (personlst.size() > 0) {
			person = personlst.get(0);
		}
		 interhis.setChyw("权利人保存");
		 interhis.setJklx(si_code);
		 interhis.setJkmc("婚姻状态");
		 interhis.setRymc(regBusQlr.getQlrmc() );
		 interhis.setZjhm(regBusQlr.getZjh());
		 interhis.setPersonid(person.getId());
		 interhis.setPcode(regBusQlr.getPcode());
		 interhis.setInparam(str);
		 interhis.setYwh(regBusQlr.getYwh()); 
		 interhis.setQlrid(regBusQlr.getId());
		
		if ("1".equals(regBusQlr.getZjzl()) && "1".equals(regBusQlr.getQlrlx())) {
			Map resmap = siService.si_post1(str,interhis, si_code); 
			
			if (resmap.containsKey("data")) {
				Map data = (Map) resmap.get("data");
				interhis.setVeritydatazt("1");
				if (data.containsKey("op_type")) { 
					
					String op_type = (String) data.get("op_type");
					
					if ("IA".equals(op_type) || "IC".equals(op_type) || "ICA".equals(op_type)) {
						
						if ("0".equals(regBusQlr.getGyfs())) {
							regBusQlr.setGyfs("1");
							regBusQlr.setGyqk(DictUtils.getDictLabel(regBusQlr.getGyfs(), "reg_bus_gyfs", ""));
							regBusQlr.setQlbl("");
							regBusQlrService.save(regBusQlr);
							
							
							RegBusBdcqzsdjxx regBusBdcqzsdjxxtmp = new RegBusBdcqzsdjxx();
							regBusBdcqzsdjxxtmp.setYwh(regBusQlr.getYwh());
							List<RegBusBdcqzsdjxx> findList = regBusBdcqzsdjxxService.findList(regBusBdcqzsdjxxtmp);
							if (findList.size() > 0) {
								for (int i = 0; i < findList.size(); i++) {
									regBusBdcqzsdjxxtmp = findList.get(i); 
									regBusBdcqzsdjxxtmp.setGyqk(
											DictUtils.getDictLabel(regBusQlr.getGyfs(), "reg_bus_gyfs", ""));// 共有情况
									regBusBdcqzsdjxxService.save(regBusBdcqzsdjxxtmp);
								}
							}
						} 
						
						RegBusQlr regBusQlr1 = new RegBusQlr();
						RegBusQlr regBusQlr2 = new RegBusQlr();
						regBusQlr1.setQlrmc((String) data.get("name_man"));
						regBusQlr1.setZjh((String) data.get("cert_num_man"));
						regBusQlr1.setYwh(regBusQlr.getYwh());
						regBusQlr2.setQlrmc((String) data.get("name_woman"));
						regBusQlr2.setZjh((String) data.get("cert_num_woman"));
						regBusQlr2.setYwh(regBusQlr.getYwh());
						
						Map map = Maps.newHashMap();
						map.put("男姓名", regBusQlr1.getQlrmc());
						map.put("男证件号码", regBusQlr1.getZjh());
						map.put("女姓名", regBusQlr2.getQlrmc());
						map.put("女证件号码", regBusQlr2.getZjh());
						map.put("状态", "结婚");
						interhis.setVeritydatamsg("数据核查通过 数据内容:"+JsonUtil.toJsonString(map));
						
						if ("save".equals(flag)) {
							if (!regBusQlr.getQlrmc().equals(regBusQlr1.getQlrmc())
									&& !regBusQlr.getZjh().equals(regBusQlr1.getZjh())) {
								
								List list  = regBusQlrService.findList_1(regBusQlr1);
								if(list != null && list.size() >=0) {
									logger.info("配偶 姓名:"+regBusQlr1.getQlrmc()+" 证件号码:"+regBusQlr1.getZjh()+"在权利人中已存在");
								}
								
								RegBasePerson regBasePerson = new RegBasePerson();
								regBasePerson.setRymc((String) data.get("name_man"));
								regBasePerson.setZjzl("1");
								regBasePerson.setZjh((String) data.get("cert_num_man"));
								List<RegBasePerson> findListqy = regBasePersonService.findListqy(regBasePerson);
								if (findListqy.size() > 0) {
									regBasePerson = findListqy.get(0);
									regBusQlr1.setHjszss(regBasePerson.getHjszss());
									regBusQlr1.setDz(regBasePerson.getDz());
									regBusQlr1.setDh(regBasePerson.getDh());
									regBusQlr1.setGzdw(regBasePerson.getGzdw());
									regBusQlr1.setDzyj(regBasePerson.getDzyj());
									regBusQlr1.setDlrmc(regBasePerson.getDlrymc());
									regBusQlr1.setDlrdh(regBasePerson.getDlrydh());
								} else {
									String pCode = "1000000";
									pCode = RegUtils.getHMaxFwbm(regBasePersonService.getHMaxPCode());// 没有的时候返回100000,然后+1最为第一笔
									regBasePerson.setPcode(pCode);
									regBasePerson.setGj(person.getGj());
									regBasePerson.setDz(person.getDz());
									regBasePerson.setRylx(person.getRylx());
									regBasePerson.setBz("民政婚姻接口带入-基础信息插入");
									regBasePerson.setIsaudit(person.getIsaudit());
									regBasePerson.setVeritydatazt(person.getVeritydatazt());
									regBusQlr1.setHjszss(regBusQlr.getHjszss());
									regBusQlr1.setDz(regBusQlr.getDz());
									regBusQlr1.setDh(regBusQlr.getDh());
									regBusQlr1.setGzdw(regBusQlr.getGzdw());
									regBusQlr1.setDzyj(regBusQlr.getDzyj());
									regBusQlr1.setDlrmc(regBusQlr.getDlrmc());
									regBusQlr1.setDlrdh(regBusQlr.getDlrdh());
								}
								regBusQlr1.setPcode(regBasePerson.getPcode());
								regBusQlr1.setZjzl("1");
								regBusQlr1.setGj("142");
								regBusQlr1.setXb("1");
								regBusQlr1.setSfczr(regBusQlr.getSfczr());
								regBusQlr1.setFzjg(regBusQlr.getFzjg());
								regBusQlr1.setYsdm(regBusQlr.getYsdm());
								regBusQlr1.setQllx(regBusQlr.getQllx());
								regBusQlr1.setQszt(regBusQlr.getQszt());
								regBusQlr1.setQlrlx(regBusQlr.getQlrlx());
								regBusQlr1.setGyfs(regBusQlr.getGyfs());
								regBusQlr1.setGyqk(regBusQlr.getGyqk());
								regBusQlr1.setBz("民政婚姻接口带入-权利人");
								regBasePersonService.save(regBasePerson);
								regBusQlr1.setSxh(getQlrmcOrderNumber(regBusQlr.getYwh()));
								regBusQlrService.save(regBusQlr1);
							} else if (!regBusQlr.getQlrmc().equals(regBusQlr2.getQlrmc())
									&& !regBusQlr.getZjh().equals(regBusQlr2.getZjh())) {
								
								List list  = regBusQlrService.findList_1(regBusQlr1);
								if(list != null && list.size() >=0) {
									logger.info("配偶 姓名:"+regBusQlr1.getQlrmc()+" 证件号码:"+regBusQlr1.getZjh()+"在权利人中已存在");
								}
								
								RegBasePerson regBasePerson = new RegBasePerson();
								regBasePerson.setRymc((String) data.get("name_woman"));
								regBasePerson.setZjzl("1");
								regBasePerson.setZjh((String) data.get("cert_num_woman"));
								List<RegBasePerson> findListqy = regBasePersonService.findListqy(regBasePerson);
								if (findListqy.size() > 0) {
									regBasePerson = findListqy.get(0);
									regBusQlr2.setHjszss(regBasePerson.getHjszss());
									regBusQlr2.setDz(regBasePerson.getDz());
									regBusQlr2.setDh(regBasePerson.getDh());
									regBusQlr2.setGzdw(regBasePerson.getGzdw());
									regBusQlr2.setDzyj(regBasePerson.getDzyj());
									regBusQlr2.setDlrmc(regBasePerson.getDlrymc());
									regBusQlr2.setDlrdh(regBasePerson.getDlrydh());
								} else {
									String pCode = "1000000";
									pCode = RegUtils.getHMaxFwbm(regBasePersonService.getHMaxPCode());// 没有的时候返回100000,然后+1最为第一笔
									regBasePerson.setPcode(pCode);
									regBasePerson.setGj(person.getGj());
									regBasePerson.setDz(person.getDz());
									regBasePerson.setRylx(person.getRylx());
									regBasePerson.setBz("民政婚姻接口带入-基础信息插入");
									regBasePerson.setIsaudit(person.getIsaudit());
									regBasePerson.setVeritydatazt(person.getVeritydatazt());
									regBusQlr2.setHjszss(regBusQlr.getHjszss());
									regBusQlr2.setDz(regBusQlr.getDz());
									regBusQlr2.setDh(regBusQlr.getDh());
									regBusQlr2.setGzdw(regBusQlr.getGzdw());
									regBusQlr2.setDzyj(regBusQlr.getDzyj());
									regBusQlr2.setDlrmc(regBusQlr.getDlrmc());
									regBusQlr2.setDlrdh(regBusQlr.getDlrdh());
								}
								regBusQlr2.setZjzl("1");
								regBusQlr2.setGj("142");
								regBusQlr2.setXb("2");
								regBusQlr2.setPcode(regBasePerson.getPcode());
								regBusQlr2.setSfczr(regBusQlr.getSfczr());
								regBusQlr2.setFzjg(regBusQlr.getFzjg());
								regBusQlr2.setYsdm(regBusQlr.getYsdm());
								regBusQlr2.setQllx(regBusQlr.getQllx());
								regBusQlr2.setQszt(regBusQlr.getQszt());
								regBusQlr2.setQlrlx(regBusQlr.getQlrlx());
								regBusQlr2.setGyfs(regBusQlr.getGyfs());
								regBusQlr2.setGyqk(regBusQlr.getGyqk());
								regBusQlr2.setSxh(getQlrmcOrderNumber(regBusQlr.getYwh()));
								regBusQlr2.setBz("民政婚姻接口带入-权利人");
								regBasePersonService.save(regBasePerson);
								regBusQlrService.save(regBusQlr2);
							}
						}
					}else {
						Map map = Maps.newHashMap();
						map.put("男姓名", data.get("name_man"));
						map.put("男证件号码",  data.get("cert_num_man"));
						map.put("女姓名",  data.get("name_woman"));
						map.put("女证件号码", data.get("cert_num_woman"));
						map.put("状态", "离婚");
						interhis.setVeritydatamsg("数据核查通过 数据内容:"+JsonUtil.toJsonString(map));
					}
				}else {
					interhis.setVeritydatamsg("数据内容:配偶信息为空");
				}
			}else {
				interhis.setVeritydatamsg("数据核查未通过 未接收到返回信息");
				interhis.setVeritydatazt("2");
			}
			User user = UserUtils.getUser();
			interhis.setCreateby(user.getId());
			interhis.setCreateuser(user.getLoginName());
			interhis.setCreateDate(new Date());
			siService.save(interhis);
		}
	}

	@RequiresPermissions("reg:bus:regBusQlr:edit")
	@RequestMapping(value = "delete")
	public String delete(RegBusQlr regBusQlr, RedirectAttributes redirectAttributes, HttpServletRequest request)
			throws JsonParseException, JsonMappingException, IOException, ServiceException {
		Map<String, String> map = new HashMap<String, String>();
		String ywhStr = request.getParameter("YWH");
	   if(StringUtils.isBlank(regBusQlr.getBz())) {
		   addMessage(redirectAttributes, "入库权利人只能修改,无法删除!");
	   }else {
		if (StringUtils.isNotBlank(ywhStr)) {
			RegBusQlr regBusQlr1 = new RegBusQlr();
			regBusQlr1.setYwh(ywhStr);
			List<RegBusQlr> regBusQlrlist = regBusQlrService.findListSxh(regBusQlr1);
			regBusQlr = regBusQlrService.get(regBusQlr.getId());
			if (regBusQlrlist.size() > 0) {
				regBusQlr1 = regBusQlrlist.get(regBusQlrlist.size() - 1);
				if (regBusQlr1.getSxh() > regBusQlr.getSxh()) {// 判断当前顺序号是否是最大顺序号
					addMessage(redirectAttributes, "请先删除最大顺序号权利人!");
				} else {
					if(StringUtils.isNotBlank(regBusQlr.getPic())) {
						String picpath = Global.getPictures();
						  String realpath = picpath + regBusQlr.getPic();
						  File file =new File(realpath);
						  if(file.exists()){
							  file.delete();
						  }
					}
					regBusQlrService.delete(regBusQlr);
					map.put("ywh", ywhStr);
					map.put("qlrid", regBusQlr.getId());
					regBusQlrService.updateRelationYwhIsuse(map);
					addMessage(redirectAttributes, "删除权利人信息成功");
				}
			} else {
				addMessage(redirectAttributes, "删除权利人信息失败!");
			}
		} else {
			addMessage(redirectAttributes, "删除权利人信息失败!");
		}
	   }
		return "redirect:" + Global.getAdminPath() + "/reg/nf/regBusQlr/list";
	}

	@RequiresPermissions("reg:bus:regBusQlr:edit")
	@RequestMapping(value = "deletegmqlr")
	public String deletegmqlr(RegBusQlr regBusQlr, RedirectAttributes redirectAttributes, HttpServletRequest request) {
		if (StringUtils.isNotBlank(regBusQlr.getId())) {
			regBusQlrService.delete(regBusQlr);
			addMessage(redirectAttributes, "删除权利人信息成功!");
		}
		return "redirect:" + Global.getAdminPath() + "/reg/bus/regBusQlr/fwgmdjlist?ts=1&ywh="
				+ request.getParameter("YWH");
	}

	/**
	 * 房屋预告更名删除
	 * 
	 * @param regBusQlr
	 * @param redirectAttributes
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusQlr:edit")
	@RequestMapping(value = "deleteyggmqlr")
	public String deleteyggmqlr(RegBusQlr regBusQlr, RedirectAttributes redirectAttributes,
			HttpServletRequest request) {
		if (StringUtils.isNotBlank(regBusQlr.getId())) {
			regBusQlrService.delete(regBusQlr);
			addMessage(redirectAttributes, "删除权利人信息成功!");
		}
		return "redirect:" + Global.getAdminPath() + "/reg/bus/regBusQlr/fwgmdjlist?ywh=" + request.getParameter("YWH")
				+ "&gm=" + request.getParameter("gm") + "&bj=" + request.getParameter("bj");
	}

	/***
	 * @Title: getQlrmcByYwh @Description: 通过业务号获取权利人名称 @param @param
	 * ywhStr @param @return 设定文件 @return String 返回类型 @throws
	 */
	public String getQlrmcByYwh(String ywhStr) {
		String qlrmc = "";
		if (StringUtils.isBlank(ywhStr)) {
			return qlrmc;
		}
		// 首先获取权利人 ID
		List<String> qlrIDList = new ArrayList<String>();
		RegBusQlrRelationYwh regBusQlrRelationYwh = new RegBusQlrRelationYwh();
		regBusQlrRelationYwh.setYwh(ywhStr);
		List<RegBusQlrRelationYwh> regBusQlrRelationYwhList = regBusQlrRelationYwhDao.findList(regBusQlrRelationYwh);
		if (regBusQlrRelationYwhList.size() > 0) {
			for (int i = 0; i < regBusQlrRelationYwhList.size(); i++) {
				qlrIDList.add(regBusQlrRelationYwhList.get(i).getQlrid());
			}
		}

		// 通过权利人ID获取权利人实体list
		List<RegBusQlr> regBusQlrList = new ArrayList<RegBusQlr>();
		if (qlrIDList.size() > 0) {
			for (int j = 0; j < qlrIDList.size(); j++) {
				regBusQlrList.add(regBusQlrService.get(qlrIDList.get(j)));
			}
		}
		// 开始构造权利人姓名字符串
		if (regBusQlrList.size() > 0) {
			for (int k = 0; k < regBusQlrList.size(); k++) {
				qlrmc += regBusQlrList.get(k).getQlrmc() + "  ";
			}
		}
		return qlrmc;
	}

	/***
	 * @Title: getQlrmcByYwh @Description: 通过业务号获取权利人名称 @param @param
	 * ywhStr @param @return 设定文件 @return String 返回类型 @throws
	 */
	public Map<String, String> getQlrmcAndGyqkByYwh(String ywhStr) {
		Map<String, String> map = new HashMap<String, String>();
		if (StringUtils.isBlank(ywhStr)) {
			return null;
		}
		String qlrmc = "";
		String qlgyqk = "";
		// 首先获取权利人 ID
		List<String> qlrIDList = new ArrayList<String>();
		RegBusQlrRelationYwh regBusQlrRelationYwh = new RegBusQlrRelationYwh();
		regBusQlrRelationYwh.setYwh(ywhStr);
		List<RegBusQlrRelationYwh> regBusQlrRelationYwhList = regBusQlrRelationYwhDao.findList(regBusQlrRelationYwh);
		if (regBusQlrRelationYwhList.size() > 0) {
			for (int i = 0; i < regBusQlrRelationYwhList.size(); i++) {
				qlrIDList.add(regBusQlrRelationYwhList.get(i).getQlrid());
			}
		}

		// 通过权利人ID获取权利人实体list
		List<RegBusQlr> regBusQlrList = new ArrayList<RegBusQlr>();
		if (qlrIDList.size() > 0) {
			for (int j = 0; j < qlrIDList.size(); j++) {
				regBusQlrList.add(regBusQlrService.get(qlrIDList.get(j)));
			}
		}
		// 开始构造权利人姓名字符串
		if (regBusQlrList.size() > 0) {
			for (int k = 0; k < regBusQlrList.size(); k++) {
				qlrmc += regBusQlrList.get(k).getQlrmc() + "  ";
				if (StringUtils.isNotBlank(regBusQlrList.get(k).getGyfs())) {
					qlgyqk = DictUtils.getDictLabel(regBusQlrList.get(k).getGyfs(), "reg_bus_gyfs", "");// 这里用共有方式【代码转化到文本】
				}
			}
			map.put("qlrmc", qlrmc);
			map.put("qlgyqk", qlgyqk);
		}
		return map;
	}

	/***
	 * @Title: getQlrmcOrderNumber @Description: 通过业务号获取当前权利人在此业务中的顺序号 @param @param
	 * ywhStr @param @return 设定文件 @return String 返回类型 @throws
	 */
	public int getQlrmcOrderNumber(String ywhStr) {
		int qlrmcOrderNumber = 1;// 默认为001
		if (StringUtils.isBlank(ywhStr)) {
			return qlrmcOrderNumber;
		}
		// 首先获取权利人 ID个数
		RegBusQlr qlr = new RegBusQlr();
		qlr.setYwh(ywhStr);
		List<RegBusQlr> qlrlist = regBusQlrService.findList_1(qlr);
		int count = qlrlist.size();
		if (count > 0) {
			qlrmcOrderNumber = qlrlist.size() + 1;
		}
		return qlrmcOrderNumber;
	}

	/**
	 * 所有权使用权更正判断是否已有抵押数据存在
	 * 
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusBdcqzsdjxx:view")
	@RequestMapping(value = "isFlagDy")
	@ResponseBody
	public ModelMap isFlagDy(HttpServletRequest request) {
		ModelMap modelMap = new ModelMap();
		String ywh = request.getParameter("ywh");
		RegBusBdcqzsdjxx regBusBdcqzsdjxx = new RegBusBdcqzsdjxx();
		regBusBdcqzsdjxx.setYwh(ywh);
		List<RegBusBdcqzsdjxx> findList = regBusBdcqzsdjxxService.findList(regBusBdcqzsdjxx);
		if (findList.size() > 0) {
			RegBusBdcqzsdjxx regBusBdcqzsdjxxtmp = new RegBusBdcqzsdjxx();
			for (int i = 0; i < findList.size(); i++) {
				regBusBdcqzsdjxx = findList.get(i);
				regBusBdcqzsdjxxtmp.setBdcdyh(regBusBdcqzsdjxx.getBdcdyh());
				regBusBdcqzsdjxxtmp.setIslogout("0");
				regBusBdcqzsdjxxtmp.setDbsj("NOTNULL");
				regBusBdcqzsdjxxtmp.setRights("25");
				List<RegBusBdcqzsdjxx> findList2 = regBusBdcqzsdjxxService.findList(regBusBdcqzsdjxxtmp);
				if (findList2.size() > 0) {
					modelMap.put("success", 0);
					modelMap.put("msg", "不动产单元号:" + regBusBdcqzsdjxx.getBdcdyh() + "已存在抵押业务数据,不能更换权利人!");
					break;
				} else {
					modelMap.put("success", 1);
				}
			}
		} else {
			modelMap.put("success", 0);
			modelMap.put("msg", "当前业务数据不存在,不能更换权利人!");
		}
		return modelMap;
	}

	/**
	 * 判断是否已有第一笔为共同共有的权利人
	 * 
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusQlr:view")
	@RequestMapping(value = "isFlagGyqk")
	@ResponseBody
	public ModelMap isFlagGyqk(HttpServletRequest request) {
		ModelMap modelMap = new ModelMap();
		String ywh = request.getParameter("YWH");
		RegBusQlr regBusQlr = new RegBusQlr();
		regBusQlr.setYwh(ywh);
		List<RegBusQlr> findList = regBusQlrService.findListSxh(regBusQlr);
		if (findList.size() > 0) {
			regBusQlr = findList.get(0);
			if (regBusQlr.getGyfs().equals("0")) {// 单独所有
				modelMap.put("success", 0);
				modelMap.put("msg", "第一权利人为单独所有,不能继续添加权利人!");
			} else {
				modelMap.put("success", 1);
			}
			modelMap.put("gyfs", regBusQlr.getGyfs());
		} else {
			modelMap.put("success", 1);
			modelMap.put("gyfs", "");
		}
		return modelMap;
	}

	/**
	 * 柜台受理提交判断共同共有的权利人
	 * 
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusQlr:view")
	@RequestMapping(value = "isFlagSubmit")
	@ResponseBody
	public ModelMap isFlagSubmit(HttpServletRequest request) {
		ModelMap modelMap = new ModelMap();
		modelMap.put("success", 1);
		String ywh = request.getParameter("ywh");
		RegBusQlr regBusQlr = new RegBusQlr();
		regBusQlr.setYwh(ywh);
		List<RegBusQlr> findList = regBusQlrService.findListSxh(regBusQlr);
		if (findList.size() == 1) {
			regBusQlr = findList.get(0);
			if (!regBusQlr.getGyfs().equals("0")) {
				modelMap.put("success", 0);
				modelMap.put("msg", "存在不合理的权利人共有情况,不能提交受理!");
			}
		} else {
			regBusQlr = findList.get(0);
			if (regBusQlr.getGyfs().equals("2")) {
				Double qlbl = 0.0;
				boolean n = true;
				for (RegBusQlr qlr : findList) {
					try {
						qlbl += Double.valueOf(qlr.getQlbl());
					} catch (Exception e) {
						modelMap.put("success", 0);
						modelMap.put("msg", "权利比例(" + qlr.getQlrmc() + ")存在非法字符,不能提交受理!");
						n = false;
						break;
					}
				}
				// 小数点转换
				DecimalFormat dFormat = new DecimalFormat("#.00");
				String yearString = dFormat.format(qlbl);
				qlbl = Double.valueOf(yearString);
				if (n && qlbl != 100.0) {
					modelMap.put("success", 0);
					modelMap.put("msg", "按份共有权利比例总和不等于100%,不能提交受理!");
				}

			}

		}
		return modelMap;
	}

	/**
	 * 房屋更名权利人信息查询
	 * 
	 * @param regBusBdcqzsdjxx
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusQlr:view")
	@RequestMapping(value = "fwgmdjlist")
	public String fwgmdjlist(RegBusQlr regBusQlr, HttpServletRequest request, HttpServletResponse response,
			Model model) {
		String ywh = request.getParameter("ywh");
		String listView = request.getParameter("LISTVIEWS");
		if (StringUtils.isNotBlank(ywh)) {
			regBusQlr.setYwh(ywh);
			model.addAttribute("YWH", ywh);
		}
		if (StringUtils.isNotBlank(request.getParameter("ts"))) {
			model.addAttribute("ts", "1");
		}
		if (StringUtils.isNotBlank(request.getParameter("slhj"))) {
			model.addAttribute("slhj", "1");
		}
		if (StringUtils.isNotBlank(request.getParameter("gm"))) {
			RegBusQlr Qlr = new RegBusQlr();
			Qlr.setYwh(ywh);// 用新业务号去查
			// 当前业务号有数据就在list中显示当前的没有就显示选择已登记信息的
			List<RegBusQlr> qlrList = regBusQlrService.findList_1(Qlr);
			if (qlrList.size() > 0) {
				regBusQlr.setYwh(ywh);
			} else {
				RegBusBdcqzsdjxx djxx = new RegBusBdcqzsdjxx();
				djxx.setYwh(ywh);
				djxx.setBdcdyh(regBusQlr.getBdcdyh());
				djxx.setIslogout("0");
				List<RegBusBdcqzsdjxx> djxxList = regBusBdcqzsdjxxService.findList(djxx);
				if (djxxList.size() > 0) {
					djxx = djxxList.get(0);
					RegBusBdcqzsdjxx djxxold = regBusBdcqzsdjxxService.get(djxx.getOldid());
					regBusQlr.setYwh(djxxold.getYwh());
				}
			}
			model.addAttribute("gm", "1");
		} else {
			regBusQlr.setYwh(ywh);
		}
		if (StringUtils.isNotBlank(listView)) {
			model.addAttribute("LISTVIEWS", listView);
		}
		Page<RegBusQlr> page = regBusQlrService.findPage_1(new Page<RegBusQlr>(request, response), regBusQlr);
		model.addAttribute("page", page);
		return "modules/reg/bus/regBusfwgmdjList";
	}

	@RequiresPermissions("reg:bus:regBusQlr:view")
	@RequestMapping(value = "qlrgmform")
	public String qlrgmform(RegBusQlr regBusQlr, Model model, HttpServletRequest request) {
		String ids = request.getParameter("id");
		model.addAttribute("oldid", ids);
		model.addAttribute("regBusQlr", regBusQlr);
		// 计算当前顺序号【注意:只有新增时才需要这个值】
		if (StringUtils.isBlank(regBusQlr.getId())) {
			model.addAttribute("SXH", getQlrmcOrderNumber(request.getParameter("YWH")));
		}
		// 查看标示
		if (StringUtils.isNotBlank(request.getParameter("VIEWS"))) {
			model.addAttribute("VIEWS", request.getParameter("VIEWS"));
		}
		if (StringUtils.isNotBlank(request.getParameter("djlx"))) {
			model.addAttribute("djlx", request.getParameter("djlx"));
		}
		// 是否预告更名表示
		if (StringUtils.isNotBlank(request.getParameter("bj"))) {
			model.addAttribute("bj", "1");
		}
		// 业务号
		if (StringUtils.isNotBlank(request.getParameter("YWH"))) {
			model.addAttribute("YWH", request.getParameter("YWH"));
			model.addAttribute("BDCDYH", request.getParameter("BDCDYH"));
		}
		// 修改
		if (StringUtils.isNotBlank(request.getParameter("XG"))) {
			model.addAttribute("XG", "1");
		}
		return "modules/reg/bus/regBusQlrgmForm";
	}

	@RequiresPermissions("reg:bus:regBusQlr:view")
	@RequestMapping(value = "qlrtdgmform")
	public String qlrtdgmform(RegBusQlr regBusQlr, Model model, HttpServletRequest request) {
		// 已经是当前业务号的权利人id
		String ids = request.getParameter("id");
		model.addAttribute("oldid", ids);
		model.addAttribute("regBusQlr", regBusQlr);
		// 计算当前顺序号【注意:只有新增时才需要这个值】
		if (StringUtils.isBlank(regBusQlr.getId())) {
			model.addAttribute("SXH", getQlrmcOrderNumber(request.getParameter("YWH")));
		}
		// 查看标示
		if (StringUtils.isNotBlank(request.getParameter("VIEWS"))) {
			model.addAttribute("VIEWS", request.getParameter("VIEWS"));
		}
		if (StringUtils.isNotBlank(request.getParameter("DJLX"))) {
			model.addAttribute("djlx", request.getParameter("DJLX"));
		}
		// 是否预告更名表示
		if (StringUtils.isNotBlank(request.getParameter("bj"))) {
			model.addAttribute("bj", "1");
		}
		// 业务号
		if (StringUtils.isNotBlank(request.getParameter("YWH"))) {
			model.addAttribute("YWH", request.getParameter("YWH"));
			model.addAttribute("BDCDYH", request.getParameter("BDCDYH"));
		}
		// 修改
		if (StringUtils.isNotBlank(request.getParameter("XG"))) {
			model.addAttribute("XG", "1");
		}
		return "modules/reg/bus/regBusQlrTdgmForm";
	}

	@RequiresPermissions("reg:bus:regBusQlr:view")
	@RequestMapping(value = "gmyrform")
	public String gmyrform(RegBusQlr regBusQlr, Model model, HttpServletRequest request) {
		Map<String, String> map = new HashMap<String, String>();
		if (StringUtils.isNotBlank(request.getParameter("YWH"))) {
			model.addAttribute("YWH", request.getParameter("YWH"));
			model.addAttribute("BDCDYH", request.getParameter("BDCDYH"));
		}
		if (StringUtils.isNotBlank(request.getParameter("oldid"))) {
			model.addAttribute("oldid", request.getParameter("oldid"));
		}
		if (StringUtils.isNotBlank(request.getParameter("XG"))) {
			model.addAttribute("XG", "1");
		}
		if (StringUtils.isNotBlank(request.getParameter("qllx"))) {
			model.addAttribute("qllx", request.getParameter("qllx"));
			regBusQlr.setQllx(request.getParameter("qllx"));
		}
		// 是否预告更名表示
		if (StringUtils.isNotBlank(request.getParameter("bj"))) {
			model.addAttribute("bj", "1");
		}
		// 计算当前顺序号【注意:只有新增时才需要这个值】
		System.out.println(request.getParameter("YWH"));// 当前业务号
//		if(StringUtils.isBlank(request.getParameter("optype"))){
//			model.addAttribute("SXH", getQlrmcOrderNumber(request.getParameter("YWH")));
//		}
		String ids = request.getParameter("ids");
		RegBasePerson person = new RegBasePerson();
		person = regBasePersonService.get(ids);
//		//首先获取权利人 ID个数
//		RegBusQlr qlr2 = new RegBusQlr();
//		qlr2.setYwh(request.getParameter("YWH"));
//		qlr2.setPcode(person.getPcode());
//		List<RegBusQlr> qlrlist = regBusQlrService.findList_1(qlr2);
//		int count = qlrlist.size();
//		if(count > 0){
//			model.addAttribute("SXH",qlrlist.get(0).getSxh());
//		}
		regBusQlr.setZjzl(person.getZjzl());
		regBusQlr.setZjh(person.getZjh());
		regBusQlr.setHjszss(person.getHjszss());
		regBusQlr.setXb(person.getXb());
		regBusQlr.setDh(person.getDh());
		regBusQlr.setYb(person.getYb());
		regBusQlr.setGzdw(person.getGzdw());
		regBusQlr.setDzyj(person.getDzyj());
		regBusQlr.setDlrmc(person.getDlrymc());
		regBusQlr.setDljgmc(person.getDljg());
		regBusQlr.setDlrdh(person.getDlrydh());
		regBusQlr.setBz(person.getBz());
		regBusQlr.setQlrlx(person.getRylx());
		regBusQlr.setHjszss(person.getHjszss());
		regBusQlr.setPcode(person.getPcode());
		regBusQlr.setSfczr(DictUtils.getDictValue("是", "yes_no", ""));
		regBusQlr.setId("");
		if (StringUtils.isNotBlank(person.getRymc())) {
			map.put("QLR", person.getRymc());
			regBusQlr.setQlrmc(person.getRymc());
		}
		if (StringUtils.isNotBlank(person.getDz())) {
			map.put("ZL", person.getDz());
			regBusQlr.setDz(person.getDz());
		}
		model.addAttribute("pcode", person.getPcode());
		model.addAttribute("maps", map);
		if (StringUtils.isNotBlank(request.getParameter("djlx"))) {
			model.addAttribute("djlx", request.getParameter("djlx"));
		}
		model.addAttribute("regBusQlr", regBusQlr);
		return "modules/reg/bus/regBusQlrgmForm";
	}

	/**
	 * 权利人更名保存
	 * 
	 * @param regBusQlr
	 * @param model
	 * @param request
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusQlr:edit")
	@RequestMapping(value = "gmsave")
	@ResponseBody
	public ModelMap gmsave(RegBusQlr regBusQlr, Model model, HttpServletRequest request,
			RedirectAttributes redirectAttributes) {
		ModelMap modelMap = new ModelMap();
		modelMap.put("success", 1);
		String ywhStr = request.getParameter("YWH");// 当前业务号
		// 获取单元号
		String dyh = request.getParameter("BDCDYH");
		regBusQlr.setYwh(ywhStr);
		// 业务号跟权利人关联
		Map<String, String> map = new HashMap<String, String>();
		Object djxl = request.getParameter("DJLX");
		String pcode = request.getParameter("pcode");
		if (StringUtils.isNotBlank(pcode)) {
			regBusQlr.setPcode(pcode);
		}
		System.out.println(request.getParameter("oldid"));
		// 获取要更名的业务数据
		RegBusQlr qlrshow = regBusQlrService.get(request.getParameter("oldid"));
		String oldid = request.getParameter("oldid");
		String rybm = qlrshow.getPcode();
		int sxh = qlrshow.getSxh();
		String ysdm = qlrshow.getYsdm();

		// 获取要更名的登记信息
		String djxlqllx = "";
		RegBusBdcqzsdjxx djxxgm = new RegBusBdcqzsdjxx();
		djxxgm.setYwh(qlrshow.getYwh());
		List<RegBusBdcqzsdjxx> djxxgmlist = regBusBdcqzsdjxxService.findList(djxxgm);
		if (djxxgmlist.size() > 0) {
			djxxgm = djxxgmlist.get(0);
			djxlqllx = djxxgm.getDjlx();
		}
		// 此处添加权利人权利类型,根据得及小类判断
		// 抵押权利类型为24抵押权
		if ("213".equals(djxlqllx) || "214".equals(djxlqllx) || "215".equals(djxlqllx) || "422".equals(djxlqllx)
				|| "317".equals(djxlqllx) || "318".equals(djxlqllx) || "316".equals(djxlqllx) || "209".equals(djxlqllx)
				|| "315".equals(djxlqllx) || djxlqllx.equals("605") || djxlqllx.equals("606") || djxlqllx.equals("608")
				|| djxlqllx.equals("217")) {
			regBusQlr.setQllx("24");
		}
		// 预告权利类型为27预告登记
		if ("803".equals(djxlqllx) || "818".equals(djxlqllx) || "806".equals(djxlqllx) || "811".equals(djxlqllx)
				|| "812".equals(djxlqllx) || "810".equals(djxlqllx) || "609".equals(djxlqllx) || "809".equals(djxlqllx)
				|| "819".equals(djxlqllx) || "804".equals(djxlqllx) || "807".equals(djxlqllx)
				|| "607".equals(djxlqllx)) {
			regBusQlr.setQllx("27");
		}
		// 所有权利类型为4所有权
		if ("207".equals(djxlqllx) || "416".equals(djxlqllx) || "302".equals(djxlqllx)) {
			regBusQlr.setQllx("4");
		}
		// 集体土地所有权1
		if ("202".equals(djxlqllx) || "301".equals(djxlqllx)) {
			regBusQlr.setQllx("1");
		}
		// 使用权利类型为3,5,7使用权国有
		if ("201".equals(djxlqllx) || "305".equals(djxlqllx)) {
			regBusQlr.setQllx("3");
		}
		// 使用权利类型为3,5,7使用权集体
		if ("203".equals(djxlqllx) || "306".equals(djxlqllx)) {
			regBusQlr.setQllx("7");
		}
		// 使用权利类型为3,5,7使用权宅基地
		if ("204".equals(djxlqllx) || "307".equals(djxlqllx)) {
			regBusQlr.setQllx("5");
		}
//		定义权利人个数
//		int  qlrsizeold = 0;
//		int  qlrsizenew = 0;	
//		//查询旧的权利人的个数
//		RegBusQlr qlrold = new RegBusQlr();
//		qlrold.setYwh(qlrshow.getYwh());
//		List<RegBusQlr>  qllistold = regBusQlrService.findList_1(qlrold);
//		qlrsizeold = qllistold.size();
//		查询新的权利人的个数
//		RegBusQlr qlrnew = new RegBusQlr();
//		qlrnew.setYwh(ywhStr);
//		List<RegBusQlr>  qllistnew = regBusQlrService.findList_1(qlrnew);
//		qlrsizenew = qllistnew.size();
		if (sxh == 1) {
			RegBusBdcqzsdjxx regBusBdcqzsdjxxtmp = new RegBusBdcqzsdjxx();
			if (StringUtils.isNotBlank(ywhStr)) {
				regBusBdcqzsdjxxtmp.setYwh(ywhStr);
				List<RegBusBdcqzsdjxx> findList = regBusBdcqzsdjxxService.findList(regBusBdcqzsdjxxtmp);
				if (findList.size() > 0) {
					dyh = findList.get(0).getBdcdyh();
					// 同步更新已登记信息权利人
					for (int i = 0; i < findList.size(); i++) {
						regBusBdcqzsdjxxtmp = findList.get(i);
						regBusBdcqzsdjxxtmp.setQlrmc(regBusQlr.getQlrmc());
						regBusBdcqzsdjxxtmp.setGyqk(DictUtils.getDictLabel(regBusQlr.getGyfs(), "reg_bus_gyfs", ""));
						regBusBdcqzsdjxxService.save(regBusBdcqzsdjxxtmp);
					}
				}
			}
		}

		if (rybm.equals(regBusQlr.getPcode())) {
			// 查询本次更换的权利人是否有增加过
			RegBusQlr qlrybm = new RegBusQlr();
			qlrybm.setSxh(sxh);
			qlrybm.setYwh(regBusQlr.getYwh());
			List<RegBusQlr> qlrybmlist = regBusQlrService.findList_1(qlrybm);
			if (qlrybmlist.size() > 0) {
				RegBusQlr delqlr = new RegBusQlr();
				delqlr.setYwh(regBusQlr.getYwh());
				delqlr.setSxh(sxh);
				regBusQlrService.deleteqlr(delqlr);
			}
			RegBasePerson person = new RegBasePerson();
			person.setZjh(regBusQlr.getZjh());
			person.setZjzl(regBusQlr.getZjzl());
			List<RegBasePerson> personllist = regBasePersonService.findList(person);
			if (personllist.size() > 0) {
				if (regBusQlr.getPcode().equals(personllist.get(0).getPcode())) {
					// 通过oldid要更名的业务数据是否与当前业务号一样,一样就直接更新此条数据,不一样说明还未对以前的权利人进行更名则直接新增
					if (!qlrshow.getYwh().equals(ywhStr)) {
						RegBusQlr ql = new RegBusQlr();
						ql.setPcode(regBusQlr.getPcode());
						ql.setYwh(regBusQlr.getYwh());
						List<RegBusQlr> qllist = regBusQlrService.findList_1(ql);
						if (qllist.size() <= 0) {
							// 首先获取权利人 ID个数
							// int qlrmcOrderNumber = 0;
							// RegBusQlr qlr2 = new RegBusQlr();
							// qlr2.setYwh(regBusQlr.getYwh());
							// List<RegBusQlr> qlrlist = regBusQlrService.findList_1(qlr2);
							// int count = qlrlist.size();
							// if(count > 0){
							// qlrmcOrderNumber = qlrlist.size() + 1;
							// }else{
							// qlrmcOrderNumber = 1;
							// }
							regBusQlr.setSxh(sxh);
							regBusQlr.setYsdm("6003000000");
							regBusQlr.setGmrid(oldid);
							regBusQlr.setQszt("0");
							regBusQlrService.saveqlr(regBusQlr);
							addMessage(redirectAttributes, "保存权利人信息成功");
							modelMap.put("success", 0);
						} else {
							if (qllist.size() > 0) {
								regBusQlr.setId(qllist.get(0).getId());
								regBusQlr.setBdcdyh(dyh);
								regBusQlr.setSxh(qllist.get(0).getSxh());
								regBusQlr.setGyqk(request.getParameter("gyfs"));
								regBusQlr.setGmrid(oldid);
								regBusQlrService.saveqlr(regBusQlr);
								addMessage(redirectAttributes, "保存权利人信息成功");
								modelMap.put("success", 0);
							}
						}
						// 修改人员信息的状态为已引用
						if (StringUtils.isNotBlank(regBusQlr.getZjh())) {
							RegBasePerson regBasePerson = new RegBasePerson();
							regBasePerson.setZjh(regBusQlr.getZjh());
							regBasePerson.setZjzl(regBusQlr.getZjzl());
							List<RegBasePerson> findPersonList = regBasePersonService.findList(regBasePerson);
							if (findPersonList.size() > 0) {
								regBasePerson = findPersonList.get(0);
								regBasePerson.setIsaudit("2");
								regBasePersonService.save(regBasePerson);
								modelMap.put("success", 0);
							}

						}
					} else {
						qlrshow = regBusQlr;
						qlrshow.setSxh(sxh);
						qlrshow.setYsdm(ysdm);
						qlrshow.setBdcdyh(dyh);
						qlrshow.setId(request.getParameter("oldid"));
						regBusQlrService.save(qlrshow);
						modelMap.put("success", 0);
					}
				} else {
					modelMap.put("success", 1);
				}
			} else {
				// 通过oldid要更名的业务数据是否与当前业务号一样,一样就直接更新此条数据,不一样说明还未对以前的权利人进行更名则直接新增
				if (!qlrshow.getYwh().equals(ywhStr)) {
					RegBusQlr ql = new RegBusQlr();
					ql.setPcode(regBusQlr.getPcode());
					ql.setYwh(regBusQlr.getYwh());
					List<RegBusQlr> qllist = regBusQlrService.findList_1(ql);
					if (qllist.size() <= 0) {
						// 首先获取权利人 ID个数
//							int qlrmcOrderNumber = 0;
//							RegBusQlr qlr2 = new RegBusQlr();
//							qlr2.setYwh(regBusQlr.getYwh());
//							List<RegBusQlr> qlrlist = regBusQlrService.findList_1(qlr2);
//							int count = qlrlist.size();
//							if(count > 0){
//								qlrmcOrderNumber = qlrlist.size() + 1;
//							}else{
//								 qlrmcOrderNumber = 1;
//							}
						regBusQlr.setSxh(sxh);
						regBusQlr.setYsdm("6003000000");
						regBusQlr.setQszt("0");
						regBusQlr.setGmrid(oldid);
						regBusQlr.setBdcdyh(null);
						regBusQlrService.saveqlr(regBusQlr);
						addMessage(redirectAttributes, "保存权利人信息成功");
						modelMap.put("success", 0);
					} else {
						if (qllist.size() > 0) {
							regBusQlr.setId(qllist.get(0).getId());
							regBusQlr.setBdcdyh(dyh);
							regBusQlr.setSxh(qllist.get(0).getSxh());
							regBusQlr.setGyqk(request.getParameter("gyfs"));
							regBusQlr.setGmrid(oldid);
							regBusQlrService.saveqlr(regBusQlr);
							addMessage(redirectAttributes, "保存权利人信息成功");
							modelMap.put("success", 0);
						}
					}
					// 修改人员信息的状态为已引用
					if (StringUtils.isNotBlank(regBusQlr.getZjh())) {
						RegBasePerson regBasePerson = new RegBasePerson();
						regBasePerson.setZjh(regBusQlr.getZjh());
						regBasePerson.setZjzl(regBusQlr.getZjzl());
						List<RegBasePerson> findPersonList = regBasePersonService.findList(regBasePerson);
						if (findPersonList.size() > 0) {
							regBasePerson = findPersonList.get(0);
							regBasePerson.setIsaudit("2");
							regBasePersonService.save(regBasePerson);
							modelMap.put("success", 0);
						}

					}
				} else {
					qlrshow = regBusQlr;
					qlrshow.setSxh(sxh);
					qlrshow.setYsdm(ysdm);
					qlrshow.setBdcdyh(dyh);
					qlrshow.setId(request.getParameter("oldid"));
					regBusQlrService.save(qlrshow);
					modelMap.put("success", 0);
				}
			}
		}

		if (!rybm.equals(regBusQlr.getPcode())) {
			// 查询本次更换的权利人是否有增加过
			RegBusQlr qlrybm = new RegBusQlr();
			qlrybm.setSxh(sxh);
			qlrybm.setYwh(regBusQlr.getYwh());
			List<RegBusQlr> qlrybmlist = regBusQlrService.findList_1(qlrybm);
			if (qlrybmlist.size() > 0) {
				RegBusQlr delqlr = new RegBusQlr();
				delqlr.setYwh(regBusQlr.getYwh());
				delqlr.setSxh(sxh);
				regBusQlrService.deleteqlr(delqlr);
			}
			RegBasePerson person = new RegBasePerson();
			person.setZjh(regBusQlr.getZjh());
			person.setZjzl(regBusQlr.getZjzl());
			List<RegBasePerson> personllist = regBasePersonService.findList(person);
			if (personllist.size() > 0) {
				if (regBusQlr.getPcode().equals(personllist.get(0).getPcode())) {
					// 通过oldid要更名的业务数据是否与当前业务号一样,一样就直接更新此条数据,不一样说明还未对以前的权利人进行更名则直接新增
					if (!qlrshow.getYwh().equals(ywhStr)) {
						RegBusQlr ql = new RegBusQlr();
						ql.setPcode(regBusQlr.getPcode());
						ql.setYwh(regBusQlr.getYwh());
						List<RegBusQlr> qllist = regBusQlrService.findList_1(ql);
						if (qllist.size() <= 0) {
							// 首先获取权利人 ID个数
							int qlrmcOrderNumber = 0;
							RegBusQlr qlr2 = new RegBusQlr();
							qlr2.setYwh(regBusQlr.getYwh());
							List<RegBusQlr> qlrlist = regBusQlrService.findList_1(qlr2);
							int count = qlrlist.size();
							if (count > 0) {
								qlrmcOrderNumber = qlrlist.size() + 1;
							} else {
								qlrmcOrderNumber = 1;
							}
							regBusQlr.setSxh(sxh);
							regBusQlr.setQszt("0");
							regBusQlr.setYsdm("6003000000");
							regBusQlr.setGmrid(oldid);
							regBusQlr.setBdcdyh(null);
							regBusQlrService.saveqlr(regBusQlr);
							addMessage(redirectAttributes, "保存权利人信息成功");
							modelMap.put("success", 0);
						} else {
							if (qllist.size() > 0) {
								regBusQlr.setId(qllist.get(0).getId());
								regBusQlr.setBdcdyh(dyh);
								regBusQlr.setSxh(qllist.get(0).getSxh());
								regBusQlr.setGyqk(request.getParameter("gyfs"));
								regBusQlr.setGmrid(oldid);
								regBusQlrService.saveqlr(regBusQlr);
								addMessage(redirectAttributes, "保存权利人信息成功");
								modelMap.put("success", 0);
							}
						}
						// 修改人员信息的状态为已引用
						if (StringUtils.isNotBlank(regBusQlr.getZjh())) {
							RegBasePerson regBasePerson = new RegBasePerson();
							regBasePerson.setZjh(regBusQlr.getZjh());
							regBasePerson.setZjzl(regBusQlr.getZjzl());
							List<RegBasePerson> findPersonList = regBasePersonService.findList(regBasePerson);
							if (findPersonList.size() > 0) {
								regBasePerson = findPersonList.get(0);
								regBasePerson.setIsaudit("2");
								regBasePersonService.save(regBasePerson);
								modelMap.put("success", 0);
							}

						}
					} else {
						qlrshow = regBusQlr;
						qlrshow.setSxh(sxh);
						qlrshow.setYsdm(ysdm);
						qlrshow.setBdcdyh(dyh);
						qlrshow.setId(request.getParameter("oldid"));
						regBusQlrService.save(qlrshow);
						modelMap.put("success", 0);
					}
				} else {
					modelMap.put("success", 1);
				}
			} else {
				// 通过oldid要更名的业务数据是否与当前业务号一样,一样就直接更新此条数据,不一样说明还未对以前的权利人进行更名则直接新增
				if (!qlrshow.getYwh().equals(ywhStr)) {
					RegBusQlr ql = new RegBusQlr();
					ql.setPcode(regBusQlr.getPcode());
					ql.setYwh(regBusQlr.getYwh());
					List<RegBusQlr> qllist = regBusQlrService.findList_1(ql);
					if (qllist.size() <= 0) {
						// 首先获取权利人 ID个数
						int qlrmcOrderNumber = 0;
						RegBusQlr qlr2 = new RegBusQlr();
						qlr2.setYwh(regBusQlr.getYwh());
						List<RegBusQlr> qlrlist = regBusQlrService.findList_1(qlr2);
						int count = qlrlist.size();
						if (count > 0) {
							qlrmcOrderNumber = qlrlist.size() + 1;
						} else {
							qlrmcOrderNumber = 1;
						}
						regBusQlr.setSxh(sxh);
						regBusQlr.setYsdm("6003000000");
						regBusQlr.setGmrid(oldid);
						regBusQlr.setQszt("0");
						regBusQlrService.saveqlr(regBusQlr);
						regBusQlr.setBdcdyh(null);
						addMessage(redirectAttributes, "保存权利人信息成功");
						modelMap.put("success", 0);
					} else {
						if (qllist.size() > 0) {
							regBusQlr.setId(qllist.get(0).getId());
							regBusQlr.setBdcdyh(dyh);
							regBusQlr.setSxh(qllist.get(0).getSxh());
							regBusQlr.setGyqk(request.getParameter("gyfs"));
							regBusQlr.setGmrid(oldid);
							regBusQlrService.saveqlr(regBusQlr);
							addMessage(redirectAttributes, "保存权利人信息成功");
							modelMap.put("success", 0);
						}
					}
					// 修改人员信息的状态为已引用
					if (StringUtils.isNotBlank(regBusQlr.getZjh())) {
						RegBasePerson regBasePerson = new RegBasePerson();
						regBasePerson.setZjh(regBusQlr.getZjh());
						regBasePerson.setZjzl(regBusQlr.getZjzl());
						List<RegBasePerson> findPersonList = regBasePersonService.findList(regBasePerson);
						if (findPersonList.size() > 0) {
							regBasePerson = findPersonList.get(0);
							regBasePerson.setIsaudit("2");
							regBasePersonService.save(regBasePerson);
							modelMap.put("success", 0);
						}

					}
				} else {
					qlrshow = regBusQlr;
					qlrshow.setSxh(sxh);
					qlrshow.setYsdm(ysdm);
					qlrshow.setBdcdyh(dyh);
					qlrshow.setId(request.getParameter("oldid"));
					regBusQlrService.save(qlrshow);
					modelMap.put("success", 0);
				}
			}
		}
		return modelMap;
	}

	/**
	 * @Title: tdgmsave @Description:土地更名 @param @param regBusQlr @param @param
	 * model @param @param request @param @param redirectAttributes @param @return
	 * 设定文件 @return ModelMap 返回类型 @throws
	 */
	@RequiresPermissions("reg:bus:regBusQlr:edit")
	@RequestMapping(value = "tdgmsave")
	@ResponseBody
	public ModelMap tdgmsave(RegBusQlr regBusQlr, Model model, HttpServletRequest request,
			RedirectAttributes redirectAttributes) {
		ModelMap modelMap = new ModelMap();
		// 判断当前业务号和人员编码下已经有权利人信息了,有了就直接修改,没有就新增
		String ywh = request.getParameter("YWH");
		String bdcdyh = request.getParameter("BDCDYH");
		String pcode = request.getParameter("pcode");

		RegBusQlr regBusQlrT = new RegBusQlr();
		regBusQlrT.setYwh(ywh);
		regBusQlrT.setPcode(pcode);
		List<RegBusQlr> findList_1 = regBusQlrService.findList_1(regBusQlrT);
		// 已经存在
		if (findList_1 != null && findList_1.size() > 0) {
			regBusQlrT = findList_1.get(0);
			regBusQlrT.setQlrmc(regBusQlr.getQlrmc());
			regBusQlrT.setZjzl(regBusQlr.getZjzl());
			regBusQlrT.setZjh(regBusQlr.getZjh());
			regBusQlrService.save(regBusQlrT);
		} else {
			// 不存在的话,就直接新增
			regBusQlr.setYwh(ywh);
			regBusQlr.setBdcdyh(bdcdyh);
			regBusQlr.setYsdm("6003000000");
			regBusQlrService.save(regBusQlr);
		}
		modelMap.put("success", 1);
		return modelMap;
	}

	/**
	 * 判断多宗地或者多房屋的权利人是否一致
	 * 
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusBdcqzsdjxx:view")
	@RequestMapping(value = "isFlag")
	@ResponseBody
	public String isFlag(HttpServletRequest request, String ywhs, String dyxxdjId) {
		String id = "";
		if (dyxxdjId.equals("")) {
			id = request.getParameter("ids");
		} else {
			id = dyxxdjId;
		}
		String[] ids = id.split(";");
		String success = "";
		for (int i = 0; i < ids.length; i++) {
			String qlr1size = "";
			String qlrsize = "";
			RegBusBdcqzsdjxx regBusBdcqzsdjxx = new RegBusBdcqzsdjxx();
			regBusBdcqzsdjxx = regBusBdcqzsdjxxService.get(ids[i]);
			RegBusQlr regBusQlr = new RegBusQlr();
			RegBusQlr regBusQlr1 = new RegBusQlr();
			if (regBusBdcqzsdjxx != null) {
				if (!ywhs.equals("")) {// 后续继续添加
					regBusQlr.setYwh(ywhs);
					List<RegBusQlr> listregBusQlr = regBusQlrService.findListSxh(regBusQlr);
					qlrsize = listregBusQlr.size() + "";
					regBusBdcqzsdjxx = regBusBdcqzsdjxxService.get(ids[i]);
					regBusQlr1.setYwh(regBusBdcqzsdjxx.getYwh());
					List<RegBusQlr> listregBusQlr1 = regBusQlrService.findListSxh(regBusQlr1);
					String flag = "";
					qlr1size = listregBusQlr1.size() + "";

					if (listregBusQlr1.size() > 0) {
						for (int j = 0; j < listregBusQlr1.size(); j++) {
							regBusQlr1 = listregBusQlr1.get(j);
							regBusQlr.setPcode(regBusQlr1.getPcode());
							List<RegBusQlr> listregBusQlrtmp = regBusQlrService.findListSxh(regBusQlr);
							if (listregBusQlrtmp.size() == 0) {
								flag = "1";
								break;
							}
						}
					}

					if (qlrsize.equals("0") || !qlrsize.equals(qlr1size) || flag.equals("1")) {
						success = "0";
						break;
					} else {
						success = "1";
					}
				} else {// 第一次添加
					regBusQlr.setYwh(regBusBdcqzsdjxx.getYwh());
					List<RegBusQlr> listregBusQlr = regBusQlrService.findListSxh(regBusQlr);
					qlrsize = listregBusQlr.size() + "";
					if (i > 0) {
						regBusBdcqzsdjxx = regBusBdcqzsdjxxService.get(ids[i - 1]);
						regBusQlr1.setYwh(regBusBdcqzsdjxx.getYwh());
						List<RegBusQlr> listregBusQlr1 = regBusQlrService.findListSxh(regBusQlr1);
						String flag = "";
						qlr1size = listregBusQlr1.size() + "";
						if (listregBusQlr1.size() > 0) {
							for (int j = 0; j < listregBusQlr1.size(); j++) {
								regBusQlr1 = listregBusQlr1.get(j);
								regBusQlr.setPcode(regBusQlr1.getPcode());
								List<RegBusQlr> listregBusQlrtmp = regBusQlrService.findListSxh(regBusQlr);
								if (listregBusQlrtmp.size() == 0) {
									flag = "1";
									break;
								}
							}
						}
						if (qlrsize.equals("0") || !qlrsize.equals(qlr1size) || flag.equals("1")) {
							success = "0";
							break;
						} else {
							success = "1";
						}
					}
				}
			}
		}
		return success;
	}

	/**
	 * 必特权利人查询保存
	 * 
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusBdcqzsdjxx:view")
	@RequestMapping(value = "BTQueryQlr")
	@ResponseBody
	public void BTQueryQlr(String bdcdyh, String djxl, String ywh) {
		// 保存权利人
		RegBaseH regbaseh = regBaseHService.getdy(bdcdyh);
		if (StringUtils.isNotBlank(regbaseh.getBtfwbm())) {
			RegBusBtqlr btQlr = new RegBusBtqlr();
			btQlr.setFwbm(regbaseh.getBtfwbm());
			btQlr.setDjxl(djxl);
			List<RegBusBtqlr> listregBusQlr = regBusBtqlrService.findList(btQlr);
			if (listregBusQlr.size() > 0) {
				for (int i = 0; i < listregBusQlr.size(); i++) {
					btQlr = listregBusQlr.get(i);
					// 获取权利人编码
					String pcode = RegUtils.getHMaxFwbm(regBasePersonService.getHMaxPCode());
					RegBusQlr Qlr_1 = new RegBusQlr();
					org.springframework.beans.BeanUtils.copyProperties(btQlr, Qlr_1);
					Qlr_1.setYwh(ywh);
					Qlr_1.setId("");
					Qlr_1.setQllx("4");
					Qlr_1.setSxh(i + 1);
					Qlr_1.setZjzl(btQlr.getQlrzjzl());
					Qlr_1.setZjh(btQlr.getQlrzjh());
					Qlr_1.setHjszss(btQlr.getQlrhjszss());
					Qlr_1.setXb(btQlr.getQlrxb());
					Qlr_1.setDh(btQlr.getQlrdh());
					Qlr_1.setBz(btQlr.getQlrbz());
					Qlr_1.setQlrlx(btQlr.getQlrlx());
					Qlr_1.setGyfs(btQlr.getQlrgyfs());
					Qlr_1.setGyfs(btQlr.getQlrgyfs());
					Qlr_1.setQlbl(btQlr.getQlrqlbl());
					Qlr_1.setGyqk(DictUtils.getDictLabel(btQlr.getQlrgyfs(), "reg_bus_gyfs", ""));
					Qlr_1.setSfczr(DictUtils.getDictValue("是", "yes_no", ""));
					Qlr_1.setPcode(pcode);
					Qlr_1.setQszt("0");
					regBusQlrService.save(Qlr_1);
				}
			}
		}
	}
	
	
	
	
	//人像比对界面
	@RequestMapping(value = "rxbdForm")
	public String rxbdForm(RegBusQlr regBusQlr, HttpServletRequest request, HttpServletResponse response, Model model) {
		String ywh="";
		if(StringUtils.isNotBlank(request.getParameter("ywh"))) {
		ywh = request.getParameter("ywh");	
		List<RegBusQlr> list = regBusQlrService.findByYwh(ywh);
		model.addAttribute("list", list);
		}
		return "modules/reg/bus/regBusQlrrxbdForm";
	}
	
	//人像比对过程
	@RequestMapping(value = "interSi/{si_type}/{si_code}", method = RequestMethod.POST)
	public void interSi(HttpServletRequest request,@PathVariable String si_code,@PathVariable String si_type, HttpServletResponse response, Model model) {
		Map resmap = Maps.newHashMap(); 
		try{
			String data = request.getParameter("data");
			String interdata = request.getParameter("interdata");
			String ywh = request.getParameter("ywh");
			String sxh = request.getParameter("sxh");
			resmap =  regBusQlrService.interSi(data, interdata,si_type+"/"+si_code,ywh,sxh);
			resmap.put("success", "0");
		}catch(Exception e){
			e.printStackTrace();
			resmap.put("success", "1");
			resmap.put("error_msg", e.getMessage());
		} 
		renderString(response, resmap);
	}
	
	@RequestMapping(value="test")
	public String test(ModelMap model,HttpServletRequest request,HttpServletResponse response) {
		  
		return  "modules/wxinterface/test";
	}
	
	
	//--------------------------------------个人登记信息查询-----------------------------------------------//
	@RequestMapping(value="readCard")
	public String readCard(ModelMap model,HttpServletRequest request,HttpServletResponse response) {
		  
		return  "modules/reg/print/ReadCard";
	}
	
	@RequestMapping(value="DjxxSelect")
	public String DjxxSelect(ModelMap model,HttpServletRequest request,HttpServletResponse response) {
		String qlrmc = request.getParameter("qlrmc");
		String zjh = request.getParameter("zjh");
		String zjzl = request.getParameter("zjzl");
		RegBusQlr qlr = new RegBusQlr();
		qlr.setQlrmc(qlrmc);
		qlr.setZjh(zjh);
		qlr.setZjzl(zjzl);
		List<Map> list = regBusQlrService.DjxxSelect(qlr);
		
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		model.addAttribute("date", sdf.format(new Date()));
		model.addAttribute("list", list);
		model.addAttribute("qlrmc", qlrmc);
		model.addAttribute("zjh", zjh);
		
		return  "modules/reg/print/djxxPrint";
	}
}