02f65568d42c61c9352da04af62c97b3ca60ff82.svn-base 208 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 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185
/**
 * Copyright &copy; 2015-2018 <a href="#">J-Site</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.reg.web.bus;

import java.io.IOException;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

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

import org.apache.http.client.ClientProtocolException;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.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.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.google.common.collect.Lists;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.utils.DateUtils;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseC;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseH;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseHbhqk;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBasePerson;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseXm;
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.RegBusCfdj;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusClhjFw;
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.RegBusHisBdcqzsdjxx;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusHisHouseBdcqzsdjxx;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusHisHouseCfdj;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusHisHouseQlr;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusHisHouseYwr;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusJsydsyq;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusQlr;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusRights;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusYgdj;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusYwr;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseCService;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseHService;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseHbhqkService;
import com.thinkgem.jeesite.modules.reg.service.base.RegBasePersonService;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseXmService;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseZdjbxxService;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseZrzService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusBdcqzsdjxxService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusCfdjService;
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.RegBusHisBdcqzsdjxxService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusHisHouseBdcqzsdjxxService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusHisHouseCfdjService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusHisHouseQlrService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusHisHouseYwrService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusJsydsyqService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusQlrService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusRightsService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusYgdjService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusYwrService;
import com.thinkgem.jeesite.modules.reg.utils.RegUtils;
import com.thinkgem.jeesite.modules.reg.web.bus.change.RegBusCSlsqController;
import com.thinkgem.jeesite.modules.sys.entity.Office;
import com.thinkgem.jeesite.modules.sys.entity.User;
import com.thinkgem.jeesite.modules.sys.service.OfficeService;
import com.thinkgem.jeesite.modules.sys.utils.DictUtils;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
import com.thinkgem.jeesite.modules.ycsl.service.YcslJbxxService;

/**
 * 房屋历史登记数据录入Controller
 * @author wb
 * @version 2016-03-22
 */
@Controller
@RequestMapping(value = "${adminPath}/reg/bus/regBusHisHouseBdcqzsdjxx")
public class RegBusHisHouseBdcqzsdjxxController extends BaseController { 

	@Autowired
	private RegBusHisHouseBdcqzsdjxxService regBusHisHouseBdcqzsdjxxService;  
	@Autowired
	private RegBaseHService regBaseHService; 
	@Autowired
	private RegBaseCService regBaseCService; 
	@Autowired
	private RegBaseZrzService regBaseZrzService; 
	@Autowired
	private RegBaseXmService regBaseXmService;
	
	@Autowired
	private RegBusQlrService regBusQlrService;
	
	@Autowired
	private RegBusBdcqzsdjxxService regBusBdcqzsdjxxService;
	
	@Autowired
	private RegBusFdcq2Service regBusFdcq2Service;
	
	@Autowired
	private RegBusDyaqService regBusDyaqService;
	
	@Autowired
	private RegBusYgdjService regBusYgdjService;
	
	@Autowired
	private RegBaseZdjbxxService regBaseZdjbxxService;
	
	@Autowired
	private RegBusHisHouseQlrService regBusHisHouseQlrService;
	
	@Autowired
	private RegBusYwrService regBusYwrService;
	@Autowired
	private RegBusHisHouseYwrService regBusHisHouseYwrService;
	@Autowired
	private RegBusRightsService regBusRightsService;
	@Autowired
	private RegBasePersonService regBasePersonService;
	@Autowired
	private RegBusJsydsyqService regBusJsydsyqService;
	@Autowired
	private RegBaseHbhqkService regBaseHbhqkService;
	@Autowired
	private OfficeService officeService; 
	@Autowired
	private RegBusCfdjService regBusCfdjService;
	@Autowired
	private RegBusHisHouseCfdjService regBusHisHouseCfdjService;
	
	

	@ModelAttribute
	public RegBusHisHouseBdcqzsdjxx get(@RequestParam(required=false) String id) {
		RegBusHisHouseBdcqzsdjxx entity = null;
		if (StringUtils.isNotBlank(id)){
			entity = regBusHisHouseBdcqzsdjxxService.get(id);
		}
		if (entity == null){
			entity = new RegBusHisHouseBdcqzsdjxx();
		}
		return entity;
	}
	
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = {"list", ""})
	public String list(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx, HttpServletRequest request, HttpServletResponse response, Model model) {
		//WinOpen标示
		if(StringUtils.isNotBlank(request.getParameter("VIEWS"))){
			model.addAttribute("VIEWS", "1");
		}
		//页面操作类型【新增还是更新】
		if(StringUtils.isNotBlank(request.getParameter("optype"))){
			model.addAttribute("optype", "update");
		}
		//WinOpen标示
		if(StringUtils.isNotBlank(request.getParameter("WO"))){
			model.addAttribute("WO", "1");
		}
		model.addAttribute("VIEWS", "1");
		regBusHisHouseBdcqzsdjxx.setDjxl("1");
		Page<RegBusHisHouseBdcqzsdjxx> page = regBusHisHouseBdcqzsdjxxService.findPage(new Page<RegBusHisHouseBdcqzsdjxx>(request, response), regBusHisHouseBdcqzsdjxx); 
		model.addAttribute("page", page);
		return "modules/reg/bus/regBusHisHouseBdcqzsdjxxList";
	}
	
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "listDY")
	public String listDY(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx, HttpServletRequest request, HttpServletResponse response, Model model) {
//		if(StringUtils.isNotBlank(request.getParameter("ywhhz"))){
//			regBusCSlsqController.saveSjhzTable(request.getParameter("ywhhz"));
//		}
		String isbatch = request.getParameter("isbatch");
		model.addAttribute("isbatch", StringUtils.isEmpty(isbatch)?"0":isbatch);
		
		//用户权限分配
		User user = UserUtils.getUser();
		Office office = officeService.get(user.getCurrentUser().getOffice().getId());
		if("S00001001007".equals(office.getCode())){
			model.addAttribute("SH", office.getCode());
		}else{
			model.addAttribute("SH", office.getCode());
		}	
		//重复数据标示
		if(StringUtils.isNotBlank(request.getParameter("cfbz"))){
			if("1".equals(request.getParameter("cfbz"))){
				model.addAttribute("MSG", "提示 :本次审核的数据出现多条重复数据!!!");
			}
		}
		if(StringUtils.isNotBlank(request.getParameter("ysh"))){
			model.addAttribute("ysh", "1");
		}
		//WinOpen标示
		if(StringUtils.isNotBlank(request.getParameter("VIEWS"))){
			model.addAttribute("VIEWS", "1");
		}
		//页面操作类型【新增还是更新】
		if(StringUtils.isNotBlank(request.getParameter("optype"))){
			model.addAttribute("optype", "update");
		}
		//WinOpen标示
		if(StringUtils.isNotBlank(request.getParameter("WO"))){
			model.addAttribute("WO", "1");
		}
		model.addAttribute("VIEWS", "1");
		regBusHisHouseBdcqzsdjxx.setDjxl("2");
		Page<RegBusHisHouseBdcqzsdjxx> page = regBusHisHouseBdcqzsdjxxService.findPage(new Page<RegBusHisHouseBdcqzsdjxx>(request, response), regBusHisHouseBdcqzsdjxx); 
		model.addAttribute("page", page);
		//--------------------------记忆查询20180516
		regBusHisHouseBdcqzsdjxx=new RegBusHisHouseBdcqzsdjxx();
		if(StringUtils.isNotBlank(request.getParameter("ywh"))){
			System.out.println(request.getParameter("ywh"));
			regBusHisHouseBdcqzsdjxx.setYwh(request.getParameter("ywh"));
		}
		if(StringUtils.isNotBlank(request.getParameter("bdcqzh"))){
			System.out.println(request.getParameter("bdcqzh"));
			regBusHisHouseBdcqzsdjxx.setBdcqzh(request.getParameter("bdcqzh"));
		}
		if(StringUtils.isNotBlank(request.getParameter("bdcdyh"))){
			System.out.println(request.getParameter("bdcdyh"));
			regBusHisHouseBdcqzsdjxx.setBdcdyh(request.getParameter("bdcdyh"));
		}
		if(StringUtils.isNotBlank(request.getParameter("fdzl"))){
			System.out.println(request.getParameter("fdzl"));
			regBusHisHouseBdcqzsdjxx.setFdzl(request.getParameter("fdzl"));
		}
		if(StringUtils.isNotBlank(request.getParameter("jzmj"))){
			System.out.println(request.getParameter("jzmj"));
			regBusHisHouseBdcqzsdjxx.setJzmj(Double.parseDouble(request.getParameter("jzmj")));
		}
		model.addAttribute("regBusHisHouseBdcqzsdjxx", regBusHisHouseBdcqzsdjxx);
		//-----------------------------
		return "modules/reg/bus/regBusHisHouseBdcqzsdjxxListDY";
	}
	
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "listYG")
	public String listYG(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx, HttpServletRequest request, HttpServletResponse response, Model model) {
//		if(StringUtils.isNotBlank(request.getParameter("ywhhz"))){
//			regBusCSlsqController.saveSjhzTable(request.getParameter("ywhhz"));
//		}
		String isbatch = request.getParameter("isbatch");
		model.addAttribute("isbatch", StringUtils.isEmpty(isbatch)?"0":isbatch);
		//用户权限分配
		User user = UserUtils.getUser();
		Office office = officeService.get(user.getCurrentUser().getOffice().getId());
		if("S00001001007".equals(office.getCode())){
			model.addAttribute("SH", office.getCode());
		}else{
			model.addAttribute("SH", office.getCode());
		}
		//重复数据标示
		if(StringUtils.isNotBlank(request.getParameter("cfbz"))){
			if("1".equals(request.getParameter("cfbz"))){
				model.addAttribute("MSG", "提示 :本次审核的数据出现多条重复数据!!!");
			}
		}
		//WinOpen标示
		if(StringUtils.isNotBlank(request.getParameter("VIEWS"))){
			model.addAttribute("VIEWS", "1");
		}
		if(StringUtils.isNotBlank(request.getParameter("ysh"))){
			model.addAttribute("ysh", "1");
		}
		//页面操作类型【新增还是更新】
		if(StringUtils.isNotBlank(request.getParameter("optype"))){
			model.addAttribute("optype", "update");
		}
		//WinOpen标示
		if(StringUtils.isNotBlank(request.getParameter("WO"))){
			model.addAttribute("WO", "1");
		}
		model.addAttribute("VIEWS", "1");
		regBusHisHouseBdcqzsdjxx.setDjxl("1");
		Page<RegBusHisHouseBdcqzsdjxx> page = regBusHisHouseBdcqzsdjxxService.findPage(new Page<RegBusHisHouseBdcqzsdjxx>(request, response), regBusHisHouseBdcqzsdjxx); 
		model.addAttribute("page", page);
		//--------------------------记忆查询20180516
		regBusHisHouseBdcqzsdjxx=new RegBusHisHouseBdcqzsdjxx();
		if(StringUtils.isNotBlank(request.getParameter("ywh"))){
			System.out.println(request.getParameter("ywh"));
			regBusHisHouseBdcqzsdjxx.setYwh(request.getParameter("ywh"));
		}
		if(StringUtils.isNotBlank(request.getParameter("bdcqzh"))){
			System.out.println(request.getParameter("bdcqzh"));
			regBusHisHouseBdcqzsdjxx.setBdcqzh(request.getParameter("bdcqzh"));
		}
		if(StringUtils.isNotBlank(request.getParameter("bdcdyh"))){
			System.out.println(request.getParameter("bdcdyh"));
			regBusHisHouseBdcqzsdjxx.setBdcdyh(request.getParameter("bdcdyh"));
		}
		if(StringUtils.isNotBlank(request.getParameter("fdzl"))){
			System.out.println(request.getParameter("fdzl"));
			regBusHisHouseBdcqzsdjxx.setFdzl(request.getParameter("fdzl"));
		}
		if(StringUtils.isNotBlank(request.getParameter("jzmj"))){
			System.out.println(request.getParameter("jzmj"));
			regBusHisHouseBdcqzsdjxx.setJzmj(Double.parseDouble(request.getParameter("jzmj")));
		}
		model.addAttribute("regBusHisHouseBdcqzsdjxx", regBusHisHouseBdcqzsdjxx);
		//-----------------------------
		return "modules/reg/bus/regBusHisHouseBdcqzsdjxxListYG";
	}
	
	/**
	 * 房屋历史首次权属列表
	 * @param regBusHisHouseBdcqzsdjxx
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "hishousefdcqlist")
	public String hishousefdcqlist(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx, HttpServletRequest request, HttpServletResponse response, Model model) {
		//传递业务号和要素代码
		if(StringUtils.isNotBlank(request.getParameter("YWH"))){
			model.addAttribute("YWH", request.getParameter("YWH"));
			model.addAttribute("YSDM",request.getParameter("YSDM"));
			regBusHisHouseBdcqzsdjxx.setYwh(request.getParameter("YWH"));
		}
		//初审以后的环节只能查看不能修改删除
		if(StringUtils.isNotBlank(request.getParameter("LISTVIEWS"))){
			model.addAttribute("LISTVIEWS", "1");
		}
		if(StringUtils.isNotBlank(request.getParameter("delete"))){
			model.addAttribute("delete", "1");
		}
		System.out.println(request.getParameter("WWWO"));
		if(StringUtils.isNotBlank(request.getParameter("xg"))){
			model.addAttribute("xg", "1");
		}
		//WinOpen标示
		if(StringUtils.isNotBlank(request.getParameter("WO"))){
			model.addAttribute("WO", "1");
			model.addAttribute("LISTVIEWS", "1");
		}
		//WinOpen标示
		if(StringUtils.isNotBlank(request.getParameter("WWWO"))){
			model.addAttribute("WWWO", "1");
		}
		if(StringUtils.isNotBlank(request.getParameter("zdqlxz")) || StringUtils.isNotBlank(request.getParameter("fwqlxz"))){
			model.addAttribute("qlxz", DictUtils.getDictLabel(request.getParameter("zdqlxz"), "reg_bus_qlxz", "")+"/"+DictUtils.getDictLabel(request.getParameter("fwqlxz"), "reg_bus_fwxz", ""));
		}
		//页面操作类型【新增还是更新】
		if(StringUtils.isNotBlank(request.getParameter("optype"))){
			model.addAttribute("optype", "update");
		}
		Page<RegBusHisHouseBdcqzsdjxx> page = regBusHisHouseBdcqzsdjxxService.findPage(new Page<RegBusHisHouseBdcqzsdjxx>(request, response), regBusHisHouseBdcqzsdjxx); 
		page.setPageSize(10);
		if(page.getList().size()>0) {
		model.addAttribute("syqx", page.getList().get(0).getSyqx());
		}
		model.addAttribute("page", page);//regBusHisHouseFdcq2SC
		return "modules/reg/bus/regBusHisHouseFdcq2SC";
	}
	
	/**
	 * 房屋历史抵押权属列表
	 * @param regBusHisHouseBdcqzsdjxx
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "hishousedylist")
	public String hishousedylist(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx, HttpServletRequest request, HttpServletResponse response, Model model) {
		//传递业务号和要素代码
		if(StringUtils.isNotBlank(request.getParameter("YWH"))){
			model.addAttribute("YWH", request.getParameter("YWH"));
			model.addAttribute("YSDM",request.getParameter("YSDM"));
			regBusHisHouseBdcqzsdjxx.setYwh(request.getParameter("YWH"));
		}
		//传递业务号和要素代码
		if(StringUtils.isNotBlank(request.getParameter("dymjhj"))){
			model.addAttribute("dymjhj", request.getParameter("dymjhj"));
		}
		//初审以后的环节只能查看不能修改删除
		if(StringUtils.isNotBlank(request.getParameter("LISTVIEWS"))){
			model.addAttribute("LISTVIEWS", "1");
		}
		if(StringUtils.isNotBlank(request.getParameter("delete"))){
			model.addAttribute("delete", "1");
		}
		if(StringUtils.isNotBlank(request.getParameter("zdqlxz")) || StringUtils.isNotBlank(request.getParameter("fwqlxz"))){
			model.addAttribute("qlxz", DictUtils.getDictLabel(request.getParameter("zdqlxz"), "reg_bus_qlxz", "")+"/"+DictUtils.getDictLabel(request.getParameter("fwqlxz"), "reg_bus_fwxz", ""));
		}
		//初审以后的环节只能查看不能修改删除
		if(StringUtils.isNotBlank(request.getParameter("selectedIDs"))){
			model.addAttribute("selectedIDs", request.getParameter("selectedIDs"));
		}
		if(StringUtils.isNotBlank(request.getParameter("xg"))){
			model.addAttribute("xg", "1");
		}
		//WinOpen标示
		if(StringUtils.isNotBlank(request.getParameter("WO"))){
			model.addAttribute("WO", "1");
			model.addAttribute("LISTVIEWS", "1");
		}
		//WinOpen标示
		if(StringUtils.isNotBlank(request.getParameter("WWWO"))){
			model.addAttribute("WWWO", "1");
		}
		//页面操作类型【新增还是更新】
		if(StringUtils.isNotBlank(request.getParameter("optype"))){
			model.addAttribute("optype", "update");
		}
		Page<RegBusHisHouseBdcqzsdjxx> page = regBusHisHouseBdcqzsdjxxService.findPage(new Page<RegBusHisHouseBdcqzsdjxx>(request, response), regBusHisHouseBdcqzsdjxx); 
		page.setPageSize(10);
		model.addAttribute("page", page);
		return "modules/reg/bus/regBusHisHouseDY";
	}
	
	/**
	 * 房屋历史抵押权属列表
	 * @param regBusHisHouseBdcqzsdjxx
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "hishouseyglist")
	public String hishouseyglist(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx, HttpServletRequest request, HttpServletResponse response, Model model) {
		//传递业务号和要素代码
		if(StringUtils.isNotBlank(request.getParameter("YWH"))){
			model.addAttribute("YWH", request.getParameter("YWH"));
			model.addAttribute("YSDM",request.getParameter("YSDM"));
			regBusHisHouseBdcqzsdjxx.setYwh(request.getParameter("YWH"));
		}
		//初审以后的环节只能查看不能修改删除
		if(StringUtils.isNotBlank(request.getParameter("LISTVIEWS"))){
			model.addAttribute("LISTVIEWS", "1");
		}
		if(StringUtils.isNotBlank(request.getParameter("xg"))){
			model.addAttribute("xg", "1");
		}
		if(StringUtils.isNotBlank(request.getParameter("delete"))){
			model.addAttribute("delete", "1");
		}
		if(StringUtils.isNotBlank(request.getParameter("zdqlxz")) || StringUtils.isNotBlank(request.getParameter("fwqlxz"))){
			model.addAttribute("qlxz", DictUtils.getDictLabel(request.getParameter("zdqlxz"), "reg_bus_qlxz", "")+"/"+DictUtils.getDictLabel(request.getParameter("fwqlxz"), "reg_bus_fwxz", ""));
		}
		//WinOpen标示
		if(StringUtils.isNotBlank(request.getParameter("WO"))){
			model.addAttribute("WO", "1");
			model.addAttribute("LISTVIEWS", "1");
		}
		//WinOpen标示
		if(StringUtils.isNotBlank(request.getParameter("WWWO"))){
			model.addAttribute("WWWO", "1");
		}
		//页面操作类型【新增还是更新】
		if(StringUtils.isNotBlank(request.getParameter("optype"))){
			model.addAttribute("optype", "update");
		}
		Page<RegBusHisHouseBdcqzsdjxx> page = regBusHisHouseBdcqzsdjxxService.findPage(new Page<RegBusHisHouseBdcqzsdjxx>(request, response), regBusHisHouseBdcqzsdjxx); 
		page.setPageSize(10);
		model.addAttribute("page", page);
		return "modules/reg/bus/regBusHisHouseYG";
	}
	
	/**
	 * @param房屋所有权转移初始登记Form表单
	 * @param model
	 * @param request
	 * @return
	*/
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "hishouseForm")
	public String hishouseForm(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx, Model model, HttpServletRequest request, HttpServletResponse response) {
		String selectedIDs = request.getParameter("selectedIDs");
		String ywh = request.getParameter("YWH");
		String djxlStr = request.getParameter("djlx");
		String[] idList = selectedIDs.split(";");
		model.addAttribute("ts",idList.length);
		//房屋基本信息
		RegBaseZrz regBaseZrz = new RegBaseZrz();
		RegBaseC regBaseC = new RegBaseC();
		RegBaseH regBaseH = new RegBaseH();
		String bdcdyh = "";
		//房屋信息列表
		Page<RegBaseH> fwpage = new Page<RegBaseH>();
		List<RegBaseH> fwlist = new ArrayList<RegBaseH>();
		Double scjzmj = 0D;//实测建筑面积
		Double fttdmj = 0D;//分摊土地面积
		for(String fwid : idList){
			regBaseH  = regBaseHService.get(fwid);
			regBaseC =  regBaseCService.get(regBaseH.getCid());
			regBaseZrz = regBaseZrzService.get(regBaseC.getZid());
			fwlist.add(regBaseH);
			fwpage.setList(fwlist);
			if(scjzmj == 0){
				scjzmj = regBaseH.getScjzmj();
			}else {
				scjzmj += regBaseH.getScjzmj();
			}if(fttdmj == 0){
				fttdmj = regBaseH.getFttdmj();
			}else {
				fttdmj += regBaseH.getFttdmj();
			}
			model.addAttribute("scjzmj",scjzmj);
			model.addAttribute("fttdmj",fttdmj);
		}
		model.addAttribute("fwpage", fwpage);//返回选择后的房屋列表
		if(StringUtils.isNotBlank(selectedIDs)){
			model.addAttribute("selectedIDs", selectedIDs);
		}
		//首先获取旧的信息
		RegBusHisHouseBdcqzsdjxx hishousefdcq2 = new RegBusHisHouseBdcqzsdjxx();
		//由宗地代码获取宗地信息,确保宗地代码在库里有值时才取宗地信息里的值
		RegBaseZdjbxx regBaseZdjbxx = new RegBaseZdjbxx();
		regBaseZdjbxx.setZddm(regBaseZrz.getZddm());
		regBaseZdjbxx.setIslogout("0");
		List<RegBaseZdjbxx> zdList = regBaseZdjbxxService.findList(regBaseZdjbxx);
		if(zdList.size()>0){
			regBaseZdjbxx = zdList.get(0);
			//权利类型
			if("3".equals(regBaseZdjbxx.getQllx())){
				hishousefdcq2.setQllx("4");
				model.addAttribute("qllxbj","3");
			}else if("7".equals(regBaseZdjbxx.getQllx())){
				hishousefdcq2.setQllx("8");
				model.addAttribute("qllxbj","7");
			}else if("5".equals(regBaseZdjbxx.getQllx())){
				hishousefdcq2.setQllx("6");
				model.addAttribute("qllxbj","5");
			}else if("1".equals(regBaseZdjbxx.getQllx())){
				hishousefdcq2.setQllx("33");
				model.addAttribute("qllxbj","1");
			}else if("23".equals(regBaseZdjbxx.getQllx())){   //20181218GL    农用地使用权23 对应房屋权利为99其他权利
				hishousefdcq2.setQllx("99");
				model.addAttribute("qllxbj","23");
			}
		}

		RegBaseH regBaseHis =  regBaseHService.get(idList[0]);
		if(regBaseHis != null){
			//通过当前办理业务的单元号截取后去登记信息表中查找最后一位登记信
			RegBusBdcqzsdjxx regBusBdcqzsdjxx_1 = new RegBusBdcqzsdjxx();
			String bdcdyh_1 = regBaseH.getBdcdyh().substring(0, 19)+"W";//查找土地最后一笔业务
			regBusBdcqzsdjxx_1.setBdcdyh(bdcdyh_1);
			regBusBdcqzsdjxx_1.setIslogout("0");//未注销
			regBusBdcqzsdjxx_1.setDbsj("NOTNULL");//已登簿
			List<RegBusBdcqzsdjxx> regBusBdcqzsdjxxlist = regBusBdcqzsdjxxService.findList(regBusBdcqzsdjxx_1);
			if(regBusBdcqzsdjxxlist.size() > 0){
				regBusBdcqzsdjxx_1 = regBusBdcqzsdjxxlist.get(0);
				RegBusJsydsyq regBusJsydsyq = new RegBusJsydsyq();
				regBusJsydsyq.setZddm(regBaseZrz.getZddm());
				regBusJsydsyq.setYwh(regBusBdcqzsdjxx_1.getYwh());
				List<RegBusJsydsyq> regBusJsydsyqlist = regBusJsydsyqService.findList(regBusJsydsyq);
				if(regBusJsydsyqlist.size()>0){
					regBusJsydsyq = regBusJsydsyqlist.get(0);
					hishousefdcq2.setTdsyqssj(regBusJsydsyq.getSyqqssj());
					hishousefdcq2.setTdsyjssj(regBusJsydsyq.getSyqjssj());
				}
			}
			if(idList.length <= 1){
				hishousefdcq2.setFdzl(regBaseHis.getZl());
				hishousefdcq2.setJzmj(regBaseHis.getScjzmj());
				hishousefdcq2.setFttdmj(regBaseHis.getScftjzmj());
				hishousefdcq2.setSzc(String.valueOf(regBaseC.getSjc()));
				hishousefdcq2.setFttdmj(regBaseHis.getFttdmj());
				hishousefdcq2.setZyjzmj(regBaseHis.getSctnjzmj());
			}else{
				hishousefdcq2.setFdzl("详见《房屋信息》");
			}
			bdcdyh = regBaseHis.getBdcdyh().substring(0, 24) + "0000";
			//获取自然幢的宗地分摊方式
			RegBaseZrz regBaseZrzzdftfs =regBaseZrzService.getRegBaseZrz(bdcdyh);
			hishousefdcq2.setBdcdyh(bdcdyh);
			hishousefdcq2.setFwxz(regBaseHis.getFwxz());
			hishousefdcq2.setDytdmj(regBaseHis.getDytdmj());
			hishousefdcq2.setZcs(String.valueOf(regBaseHis.getSjcs()));
			hishousefdcq2.setFwjg(regBaseZrz.getFwjg());
			hishousefdcq2.setTdsyqr(regBaseZdjbxx.getQlrxm());
			hishousefdcq2.setGhyt(regBaseH.getFwyt1());
			hishousefdcq2.setJgsj(regBaseZrz.getJgrq());
			hishousefdcq2.setFtjzmj(regBaseHis.getScftjzmj());
			hishousefdcq2.setBdcqzh("");
			hishousefdcq2.setYwh(ywh);
			hishousefdcq2.setDjxl(djxlStr);
			if(StringUtils.isNotBlank(djxlStr)){
				if(djxlStr.startsWith("2")){
					hishousefdcq2.setDjlx("100");//首次登记
					model.addAttribute("DJLX", "100");
				}else if(djxlStr.startsWith("3")){
					hishousefdcq2.setDjlx("200");//转移登记
					model.addAttribute("DJLX", "200");
				}
				if("302".equals(djxlStr)){
					model.addAttribute("DJLX", "300");//页面判断,不需更改
					hishousefdcq2.setZdftfs(regBaseZrzzdftfs.getZdftfs());
					if("1".equals(regBaseZrzzdftfs.getZdftfs())){
						model.addAttribute("ftfs", "1");
					}
				}
			}
			hishousefdcq2.setYsdm("2001010000");
			hishousefdcq2.setQxdm(Global.getAreaCode());
			String qxdm = DictUtils.getDictLabel(Global.getAreaCode(), "reg_bus_xq","");
			regBusHisHouseBdcqzsdjxx.setDjjg(qxdm+"不动产登记局");
			hishousefdcq2.setDjjg(qxdm+"不动产登记局");
			hishousefdcq2.setCqly(DictUtils.getDictValue("新建", "reg_bus_cqly",""));
			model.addAttribute("regBusHisHouseBdcqzsdjxx", hishousefdcq2);
		}
		return "modules/reg/bus/regBusHisHouseFdcq2GuideFormSC";
	}

	/**
	 * 预告历史入口form
	 * @param model
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "hishouseYGForm")
	public String hishouseYGForm(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx,RedirectAttributes redirectAttributes, Model model, HttpServletRequest request, HttpServletResponse response) {
		String selectedIDs = request.getParameter("selectedIDs");
		String ywh = "LS"+getNextYwhs();
		RegBusHisHouseBdcqzsdjxx djxx =new  RegBusHisHouseBdcqzsdjxx();
		djxx.setYwh(ywh);
		List<RegBusHisHouseBdcqzsdjxx> yglist = regBusHisHouseBdcqzsdjxxService.findList(djxx);
		int tz = yglist.size();
		if(tz <= 0){
			String[] idList = selectedIDs.split(";");
			if(StringUtils.isNotBlank(request.getParameter("YWH"))){
				regBusHisHouseBdcqzsdjxx.setYwh(request.getParameter("YWH"));
			}
			String djxlStr = request.getParameter("djlx");
			if(StringUtils.isNotBlank(djxlStr)){
				regBusHisHouseBdcqzsdjxx.setDjxl(djxlStr);
				if(djxlStr.startsWith("8")){
					regBusHisHouseBdcqzsdjxx.setDjlx("700");
				}
			}
			//房屋基本信息
			RegBaseZrz regBaseZrz = new RegBaseZrz();
			RegBaseC regBaseC = new RegBaseC();
			RegBaseH regBaseH = new RegBaseH();
			String bdcdyh = "";
			//房屋信息列表
			Page<RegBaseH> fwpage = new Page<RegBaseH>();
			List<RegBaseH> fwlist = new ArrayList<RegBaseH>();
			model.addAttribute("ts",idList.length);
			for(String fwid : idList){
				regBaseH  = regBaseHService.get(fwid);
				regBaseC =  regBaseCService.get(regBaseH.getCid());
				regBaseZrz = regBaseZrzService.get(regBaseC.getZid());
				fwlist.add(regBaseH);
				fwpage.setList(fwlist);
				
				//由宗地代码获取宗地信息,确保宗地代码在库里有值时才取宗地信息里的值
				RegBaseZdjbxx regBaseZdjbxx = new RegBaseZdjbxx();
				regBaseZdjbxx.setZddm(regBaseZrz.getZddm());
				List<RegBaseZdjbxx> zdList = regBaseZdjbxxService.findList(regBaseZdjbxx);
				if(zdList.size()>0){
					regBaseZdjbxx = zdList.get(0);
				}
				regBusHisHouseBdcqzsdjxx.setTdsyqr(regBaseZdjbxx.getQlrxm());
				regBusHisHouseBdcqzsdjxx.setFdzl(regBaseH.getZl());
				regBusHisHouseBdcqzsdjxx.setFwxz(regBaseH.getFwxz());
				regBusHisHouseBdcqzsdjxx.setSzc(regBaseC.getSjc()+"");
				regBusHisHouseBdcqzsdjxx.setFwjg(regBaseZrz.getFwjg());//房屋结构
				regBusHisHouseBdcqzsdjxx.setZcs(String.valueOf(regBaseZrz.getZcs()));
				regBusHisHouseBdcqzsdjxx.setJzmj(regBaseH.getScjzmj());
				regBusHisHouseBdcqzsdjxx.setGhyt(regBaseH.getFwyt1());
			}
			model.addAttribute("fwpage", fwpage);//返回选择后的房屋列表
			model.addAttribute("selectedIDs", selectedIDs);//返回选择后的房屋列表
			regBusHisHouseBdcqzsdjxx.setQxdm(Global.getAreaCode());
			String qxdm = DictUtils.getDictLabel(Global.getAreaCode(), "reg_bus_xq","");
			regBusHisHouseBdcqzsdjxx.setDjjg(qxdm+"不动产登记局");
			regBusHisHouseBdcqzsdjxx.setYgdjzl(DictUtils.getDictValue("预售商品房买卖预告登记", "reg_bus_ygdjzl",""));
			regBusHisHouseBdcqzsdjxx.setBdcdyh(regBaseH.getBdcdyh());
			regBusHisHouseBdcqzsdjxx.setYsdm("2003000000");
		}
		model.addAttribute("regBusHisHouseBdcqzsdjxx", regBusHisHouseBdcqzsdjxx);//返回选择后的房屋列表 
		return "modules/reg/bus/regBusHisHouseYGGuideFormYG";
	}
	
	/**
	 * 抵押历史入口form
	 * @param model
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "hishouseDYForm")
	public String hishouseDYForm(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx, Model model, HttpServletRequest request, HttpServletResponse response) {
		String selectedIDs = request.getParameter("selectedIDs");
		String ywh = request.getParameter("YWH");
		String djxl = request.getParameter("djxl");
		String[] idList = selectedIDs.split(";");
		if(StringUtils.isNotBlank(request.getParameter("YWH"))){
			regBusHisHouseBdcqzsdjxx.setYwh(ywh);
		}
		//房屋基本信息
		RegBaseZrz regBaseZrz = new RegBaseZrz();
		RegBaseC regBaseC = new RegBaseC();
		RegBaseH regBaseH = new RegBaseH();
		String bdcdyh = "";
		//房屋信息列表
		Page<RegBaseH> fwpage = new Page<RegBaseH>();
		List<RegBaseH> fwlist = new ArrayList<RegBaseH>();
		model.addAttribute("ts",idList.length);
		Double scjzmj = 0D;//实测建筑面积
		Double fttdmj = 0D;//分摊土地面积
		for(String fwid : idList){
			regBaseH  = regBaseHService.get(fwid);
			regBaseC =  regBaseCService.get(regBaseH.getCid());
			regBaseZrz = regBaseZrzService.get(regBaseC.getZid());
			if(scjzmj == 0){
				scjzmj = regBaseH.getScjzmj();
			}else {
				scjzmj += regBaseH.getScjzmj();
			}if(fttdmj == 0){
				fttdmj = regBaseH.getFttdmj();
			}else {
				fttdmj += regBaseH.getFttdmj();
			}
			model.addAttribute("scjzmj",scjzmj);
			model.addAttribute("fttdmj",fttdmj);
			fwlist.add(regBaseH);
			fwpage.setList(fwlist);
		}
		model.addAttribute("djxl", djxl);
		model.addAttribute("fwpage", fwpage);//返回选择后的房屋列表
		model.addAttribute("selectedIDs", selectedIDs);//返回选择后的房屋列表
		bdcdyh = regBaseH.getBdcdyh().substring(0, 24) + "0000";
		regBusHisHouseBdcqzsdjxx.setBdcdyh(bdcdyh);
		regBusHisHouseBdcqzsdjxx.setZjjzwzl("详见房屋信息");
//		regBusHisHouseBdcqzsdjxx.setDjlx(DictUtils.getDictValue("首次登记", "reg_bus_djlx",""));//区县代码
		if("215".equals(regBusHisHouseBdcqzsdjxx.getDjxl())){
			regBusHisHouseBdcqzsdjxx.setDyfs(DictUtils.getDictValue("最高额抵押", "reg_bus_dyfs",""));
		}else{
			regBusHisHouseBdcqzsdjxx.setDyfs(DictUtils.getDictValue("一般抵押", "reg_bus_dyfs",""));
		}
		if("213".equals(regBusHisHouseBdcqzsdjxx.getDjxl())){
			regBusHisHouseBdcqzsdjxx.setDybdclx(DictUtils.getDictValue("土地和在建建筑物", "reg_bus_dybdclx",""));
		}else{
			regBusHisHouseBdcqzsdjxx.setDybdclx(DictUtils.getDictValue("土地和房屋", "reg_bus_dybdclx",""));
		}
		regBusHisHouseBdcqzsdjxx.setQxdm(Global.getAreaCode());
		String qxdm = DictUtils.getDictLabel(Global.getAreaCode(), "reg_bus_xq","");
		regBusHisHouseBdcqzsdjxx.setDjjg(qxdm+"不动产登记局");
		model.addAttribute("regBusHisHouseBdcqzsdjxx", regBusHisHouseBdcqzsdjxx);//返回选择后的房屋列表
		return "modules/reg/bus/regBusHisHouseDYGuideFormDY";
	}
	
	/**
	 * @param房屋所有权,抵押,预告转移初始登记修改Form表单
	 * @param model
	 * @param request
	 * @return
	*/
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "hishouseeditForm")
	public String hishouseeditForm(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx, Model model, HttpServletRequest request, HttpServletResponse response) {
		String ids = request.getParameter("id");
		String[] idList = ids.split(";");
		model.addAttribute("ts",idList.length);
		model.addAttribute("selectedIDs", ids);//返回选择后的房屋列表
		Double scjzmj = 0D;//实测建筑面积
		Double fttdmj = 0D;//分摊土地面积
		//房屋基本信息
		RegBaseZrz regBaseZrz = new RegBaseZrz();
		RegBaseC regBaseC = new RegBaseC();
		RegBaseH regBaseH = new RegBaseH();
		String bdcdyh = regBusHisHouseBdcqzsdjxx.getBdcdyh();
		regBaseH.setBdcdyh(bdcdyh);
		List<RegBaseH> hList =  regBaseHService.findList(regBaseH);
		if(hList.size() > 0){
			//房屋信息列表
			Page<RegBaseH> fwpage = new Page<RegBaseH>();
			List<RegBaseH> fwlist = new ArrayList<RegBaseH>();
			regBaseH = hList.get(0);
			regBaseC =  regBaseCService.get(regBaseH.getCid());
			regBaseZrz = regBaseZrzService.get(regBaseC.getZid());
			if(scjzmj == 0){
				scjzmj = regBaseH.getScjzmj();
			}else {
				scjzmj += regBaseH.getScjzmj();
			}if(fttdmj == 0){
				fttdmj = regBaseH.getFttdmj();
			}else {
				fttdmj += regBaseH.getFttdmj();
			}
			model.addAttribute("scjzmj",scjzmj);
			model.addAttribute("fttdmj",fttdmj);
			fwlist.add(regBaseH);
			fwpage.setList(fwlist);
			model.addAttribute("fwpage", fwpage);//返回选择后的房屋列表
			regBusHisHouseBdcqzsdjxx.setZjjzwzl(regBaseH.getZl());
		}
		String tz= "";
		if(StringUtils.isNotBlank(request.getParameter("H"))){
			tz = request.getParameter("H");
		}
		model.addAttribute("regBusHisHouseBdcqzsdjxx", regBusHisHouseBdcqzsdjxx);
		String views="";
		if(tz.equals("1")){
			model.addAttribute("VIEWS", request.getParameter("VIEWS"));
			views = "modules/reg/bus/regBusHisHouseYGGuideeditFormYG";
		}
		if(tz.equals("2")){
			model.addAttribute("djxl", regBusHisHouseBdcqzsdjxx.getDjxl());
			model.addAttribute("VIEWS", request.getParameter("VIEWS"));
			views = "modules/reg/bus/regBusHisHouseDYGuideeditFormDY";
		}
		if(tz.equals("3")){
			if("302".equals(regBusHisHouseBdcqzsdjxx.getDjxl())){
				model.addAttribute("DJLX", "300");//宗地分摊方式,页面判断不需要更改
				if("1".equals(regBusHisHouseBdcqzsdjxx.getZdftfs())){
					model.addAttribute("ftfs", "1");
				}
			}
			model.addAttribute("VIEWS", request.getParameter("VIEWS"));
			views = "modules/reg/bus/regBusHisHouseFdcq2GuideeditFormSC";
		}
		return views;
	}
	
	
    /**
            * 房屋历史首次列表
     * @param regBusHisHouseBdcqzsdjxx
     * @param request
     * @param response
     * @param model
     * @return
     */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "listSC")
	public String listSC(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx, HttpServletRequest request, HttpServletResponse response, Model model) {
//		if(StringUtils.isNotBlank(request.getParameter("ywhhz"))){
//			regBusCSlsqController.saveSjhzTable(request.getParameter("ywhhz"));
//		}
		String isbatch = request.getParameter("isbatch");
		model.addAttribute("isbatch", StringUtils.isEmpty(isbatch)?"0":isbatch);
		
		//用户权限分配
		User user = UserUtils.getUser();
		Office office = officeService.get(user.getCurrentUser().getOffice().getId());
		if("S00001001007".equals(office.getCode())){
			model.addAttribute("SH", office.getCode());
		}else{
			model.addAttribute("SH", office.getCode());
		}
		//配置管理员删除页面操作权限
		if("root".equals(user.getLoginName())){
			model.addAttribute("rootinfo", user.getLoginName());
		}else{
			model.addAttribute("rootinfo", "");
		}
		//WinOpen标示
		if(StringUtils.isNotBlank(request.getParameter("VIEWS"))){
			model.addAttribute("VIEWS", "1");
		}
		//重复数据标示
		if(StringUtils.isNotBlank(request.getParameter("cfbz"))){
			if("1".equals(request.getParameter("cfbz"))){
				model.addAttribute("MSG", "提示 :本次审核的数据出现多条重复数据!!!");
			}
		}
		if(StringUtils.isNotBlank(request.getParameter("ysh"))){
			model.addAttribute("ysh", "1");
		}
		//页面操作类型【新增还是更新】
		if(StringUtils.isNotBlank(request.getParameter("optype"))){
			model.addAttribute("optype", "update");
		}
		//WinOpen标示
		if(StringUtils.isNotBlank(request.getParameter("WO"))){
			model.addAttribute("WO", "1");
		}
		model.addAttribute("VIEWS", "1");
		regBusHisHouseBdcqzsdjxx.setDjxl("3");
		Page<RegBusHisHouseBdcqzsdjxx> page = regBusHisHouseBdcqzsdjxxService.findPage(new Page<RegBusHisHouseBdcqzsdjxx>(request, response), regBusHisHouseBdcqzsdjxx); 
		model.addAttribute("page", page);
		//--------------------------记忆查询20180516
		regBusHisHouseBdcqzsdjxx=new RegBusHisHouseBdcqzsdjxx();
		if(StringUtils.isNotBlank(request.getParameter("ywh"))){
			System.out.println(request.getParameter("ywh"));
			regBusHisHouseBdcqzsdjxx.setYwh(request.getParameter("ywh"));
		}
		if(StringUtils.isNotBlank(request.getParameter("bdcqzh"))){
			System.out.println(request.getParameter("bdcqzh"));
			regBusHisHouseBdcqzsdjxx.setBdcqzh(request.getParameter("bdcqzh"));
		}
		if(StringUtils.isNotBlank(request.getParameter("bdcdyh"))){
			System.out.println(request.getParameter("bdcdyh"));
			regBusHisHouseBdcqzsdjxx.setBdcdyh(request.getParameter("bdcdyh"));
		}
		if(StringUtils.isNotBlank(request.getParameter("fdzl"))){
			System.out.println(request.getParameter("fdzl"));
			regBusHisHouseBdcqzsdjxx.setFdzl(request.getParameter("fdzl"));
		}
		if(StringUtils.isNotBlank(request.getParameter("jzmj"))){
			System.out.println(request.getParameter("jzmj"));
			regBusHisHouseBdcqzsdjxx.setJzmj(Double.parseDouble(request.getParameter("jzmj")));
		}
		model.addAttribute("regBusHisHouseBdcqzsdjxx", regBusHisHouseBdcqzsdjxx);
		//-----------------------------
		return "modules/reg/bus/regBusHisHouseBdcqzsdjxxListSC";
	}
	
	/**
	 * 房屋历史修改退出列表
	 * @param regBusHisHouseBdcqzsdjxx
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "houselist")
	public String houselist(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx, HttpServletRequest request, HttpServletResponse response, Model model) {
		//WinOpen标示
		if(StringUtils.isNotBlank(request.getParameter("VIEWS"))){
			model.addAttribute("VIEWS", "1");
		}
		//页面操作类型【新增还是更新】
		if(StringUtils.isNotBlank(request.getParameter("optype"))){
			model.addAttribute("optype", "update");
		}
		//WinOpen标示
		if(StringUtils.isNotBlank(request.getParameter("WO"))){
			model.addAttribute("WO", "1");
		}
		String tz = request.getParameter("H");
		String vie = "";
		if(tz.equals("1")){
			//WinOpen标示
			if(StringUtils.isNotBlank(request.getParameter("YWH"))){
				regBusHisHouseBdcqzsdjxx.setYwh(request.getParameter("YWH"));
			}
			regBusHisHouseBdcqzsdjxx.setDjxl("1");
			Page<RegBusHisHouseBdcqzsdjxx> page = regBusHisHouseBdcqzsdjxxService.findPage(new Page<RegBusHisHouseBdcqzsdjxx>(request, response), regBusHisHouseBdcqzsdjxx); 
			model.addAttribute("page", page);
			vie = "modules/reg/bus/regBusHisHouseEditBdcqzsdjxxList";
		}
		if(tz.equals("2")){
			//WinOpen标示
			if(StringUtils.isNotBlank(request.getParameter("YWH"))){
				regBusHisHouseBdcqzsdjxx.setYwh(request.getParameter("YWH"));
			}
			regBusHisHouseBdcqzsdjxx.setDjxl("2");
			Page<RegBusHisHouseBdcqzsdjxx> page = regBusHisHouseBdcqzsdjxxService.findPage(new Page<RegBusHisHouseBdcqzsdjxx>(request, response), regBusHisHouseBdcqzsdjxx); 
			model.addAttribute("page", page);
			vie = "modules/reg/bus/regBusHisHouseEditBdcqzsdjxxList";
		}
		if(tz.equals("3")){
			//WinOpen标示
			if(StringUtils.isNotBlank(request.getParameter("YWH"))){
				regBusHisHouseBdcqzsdjxx.setYwh(request.getParameter("YWH"));
			}
			regBusHisHouseBdcqzsdjxx.setDjxl("3");
			Page<RegBusHisHouseBdcqzsdjxx> page = regBusHisHouseBdcqzsdjxxService.findPage(new Page<RegBusHisHouseBdcqzsdjxx>(request, response), regBusHisHouseBdcqzsdjxx); 
			model.addAttribute("page", page);
			vie = "modules/reg/bus/regBusHisHouseEditBdcqzsdjxxList";
		}
		if(tz.equals("4")){//查封登记
			//WinOpen标示
			if(StringUtils.isNotBlank(request.getParameter("YWH"))){
				regBusHisHouseBdcqzsdjxx.setYwh(request.getParameter("YWH"));
			}
			regBusHisHouseBdcqzsdjxx.setDjxl("9");
			Page<RegBusHisHouseBdcqzsdjxx> page = regBusHisHouseBdcqzsdjxxService.findPage(new Page<RegBusHisHouseBdcqzsdjxx>(request, response), regBusHisHouseBdcqzsdjxx); 
			model.addAttribute("page", page);
			vie = "modules/reg/bus/regBusHisHouseEditBdcqzsdjxxList";
		}
		return vie;
	}
	
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "form")
	public String form(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx, HttpServletRequest request,  Model model) {
		//页面操作类型【新增还是更新】
		String views = "";
		if(StringUtils.isNotBlank(request.getParameter("optype"))){
			model.addAttribute("optype", "update");
			model.addAttribute("LSH",regBusHisHouseBdcqzsdjxx.getYwh());
		}else{
			regBusHisHouseBdcqzsdjxx.setYwh("LS" + getNextYwhs());
			model.addAttribute("LSH", regBusHisHouseBdcqzsdjxx.getYwh());
		}
		if(StringUtils.isNotBlank(request.getParameter("VIEWS"))){
				model.addAttribute("VIEWS", "2");
		}
		if(StringUtils.isNotBlank(request.getParameter("xg"))){
			model.addAttribute("xg", "1");
		}
		if(StringUtils.isNotBlank(request.getParameter("drbj"))){
			model.addAttribute("drbj", "1");
		}
		regBusHisHouseBdcqzsdjxx.setQxdm(Global.getAreaCode());
		String qxdm = DictUtils.getDictLabel(Global.getAreaCode(), "reg_bus_xq","");
		regBusHisHouseBdcqzsdjxx.setDjjg(qxdm+"不动产登记局");
		model.addAttribute("regBusHisHouseBdcqzsdjxx", regBusHisHouseBdcqzsdjxx);
		String tz = request.getParameter("H");
		if(tz.equals("1")){
			if(StringUtils.isBlank(regBusHisHouseBdcqzsdjxx.getQllx())){
				regBusHisHouseBdcqzsdjxx.setQllx(DictUtils.getDictValue("预告登记", "reg_bus_qllx", ""));
				regBusHisHouseBdcqzsdjxx.setYgdjzl(DictUtils.getDictValue("其它不动产买卖预告登记", "reg_bus_ygdjzl", ""));
			}
			model.addAttribute("tz", "1");
			views = "modules/reg/bus/regBusHisHouseBdcqzsdjxxFormYG";
		}else if(tz.equals("2")){
			if(StringUtils.isBlank(regBusHisHouseBdcqzsdjxx.getQllx())){
				regBusHisHouseBdcqzsdjxx.setQllx(DictUtils.getDictValue("抵押权", "reg_bus_qllx", ""));
			}
			model.addAttribute("tz", "2");
			views = "modules/reg/bus/regBusHisHouseBdcqzsdjxxFormDY";
		}else if(tz.equals("3")){
			if("207".equals(regBusHisHouseBdcqzsdjxx.getDjxl())){
				//独有宗地上的房子分批次的做,要把第一次的权利人直接带出来
				RegBaseZrz zrz = new RegBaseZrz();
				zrz.setBdcdyh(regBusHisHouseBdcqzsdjxx.getBdcdyh().substring(0,24)+"0000");
				List<RegBaseZrz> zrzlist = regBaseZrzService.findList(zrz);
				if(zrzlist.size() > 0){
					zrz = zrzlist.get(0);
					//查询独有宗地
					if("2".equals(zrz.getZdftfs())){
						model.addAttribute("xg", "1");
					}
				}		
			}	
			model.addAttribute("tz", "3");
			views = "modules/reg/bus/regBusHisHouseBdcqzsdjxxFormSC";

		}else if(tz.equals("4")){//查封登记
			if(StringUtils.isBlank(regBusHisHouseBdcqzsdjxx.getQllx())){
				regBusHisHouseBdcqzsdjxx.setQllx(DictUtils.getDictValue("查封登记", "reg_bus_qllx", ""));
			}
			String djxl = request.getParameter("djxl");
			regBusHisHouseBdcqzsdjxx.setDjxl(djxl);
			model.addAttribute("tz", "4");
			if(StringUtils.isNotBlank(djxl)&&djxl.equals("907")) {
				model.addAttribute("cfbj", "ycf");
			}
			views = "modules/reg/bus/regBusHisHouseBdcqzsdjxxFormCF";
		}
		return views;
	}
	
	/**
	 * 房屋历史首次权属信息保存
	 * @param regBusHisHouseBdcqzsdjxx
	 * @param request
	 * @param model
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:edit")
	@RequestMapping(value = "hishouseSave")
	@ResponseBody
	public synchronized ModelMap hishouseSave(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx, HttpServletRequest request, Model model, RedirectAttributes redirectAttributes) {
		String selectedIDs = request.getParameter("selectedIDs");
		String[] idList = selectedIDs.split(";");
		String zdqlxz = "";
		String fwqlxz = "";
		String ywh = "LS"+getNextYwhs();
		String bdcdyh = regBusHisHouseBdcqzsdjxx.getBdcdyh();
		ModelMap modelmap = new ModelMap();
		if("207".equals(regBusHisHouseBdcqzsdjxx.getDjxl())){
			//由宗地代码获取宗地信息,确保宗地代码在库里有值时才取宗地信息里的值
			RegBaseZdjbxx regBaseZdjbxx = new RegBaseZdjbxx();
			regBaseZdjbxx.setZddm(bdcdyh.substring(0, 19));
			regBaseZdjbxx.setIslogout("0");
			List<RegBaseZdjbxx> zdList = regBaseZdjbxxService.findList(regBaseZdjbxx);
			if(zdList.size()>0){
				regBaseZdjbxx = zdList.get(0);
			}
			//独有宗地上的房子分批次的做,要把第一次的权利人直接带出来
			RegBaseZrz zrz = new RegBaseZrz();
			zrz.setBdcdyh(bdcdyh);
			List<RegBaseZrz> zrzlist = regBaseZrzService.findList(zrz);
			if(zrzlist.size() > 0){
				zrz = zrzlist.get(0);
				//查询独有宗地
				if("2".equals(zrz.getZdftfs())){
					//一栋楼上有多个房屋,只需要取其中一套房子
					RegBusRights rights = regBusRightsService.getByBdcdyh(bdcdyh.substring(0, 19)+"W00000000");
					if(rights != null){
						//获取首次的权利人并带入
						RegBusQlr qlr = new RegBusQlr();
						if("3".equals(regBaseZdjbxx.getQllx()) || "7".equals(regBaseZdjbxx.getQllx()) || "5".equals(regBaseZdjbxx.getQllx())){
							qlr.setYwh(rights.getSshiyq());
						}else{
							qlr.setYwh(rights.getSsouyq());
						}
						List<RegBusQlr> qlrlist = regBusQlrService.findList_1(qlr);
						if(qlrlist.size() > 0){
							for(int i=0;i<qlrlist.size();i++){
								qlr = qlrlist.get(i);
								RegBusHisHouseQlr qlrnew = new RegBusHisHouseQlr();
								BeanUtils.copyProperties(qlr, qlrnew);
								qlrnew.setId("");
								qlrnew.setBdcdyh(null);
								qlrnew.setSxh(qlr.getSxh().toString());
								qlrnew.setYwh(ywh);
								regBusHisHouseQlrService.save(qlrnew);
							}
							modelmap.put("xg", null);
						}
					}
				}
			}		
		}		
				
		for(int i =0 ;i<idList.length;i++){
			RegBaseH regBaseH = regBaseHService.get(idList[i]);
			RegBaseC regBaseC =  regBaseCService.get(regBaseH.getCid());
			RegBaseZrz regBaseZrz = regBaseZrzService.get(regBaseC.getZid());
			//把楼盘变为已引用
			if("302".equals(regBusHisHouseBdcqzsdjxx.getDjxl())){
				regBaseH.setIszy("1");
			}
			regBaseH.setIsaudit("2");
			regBaseHService.save(regBaseH);
			String zddm = regBaseH.getBdcdyh().substring(0, 19);//查找土地最后一笔业务
//			if("0".equals(regBusHisHouseBdcqzsdjxx.getFwxz())  || "2".equals(regBusHisHouseBdcqzsdjxx.getFwxz()) || "5".equals(regBusHisHouseBdcqzsdjxx.getFwxz()) || "7".equals(regBusHisHouseBdcqzsdjxx.getFwxz())){
//				if(!"7".equals(regBusHisHouseBdcqzsdjxx.getCqly()) && !"8".equals(regBusHisHouseBdcqzsdjxx) && !"9".equals(regBusHisHouseBdcqzsdjxx.getCqly()) && !"15".equals(regBusHisHouseBdcqzsdjxx.getCqly()) && !"19".equals(regBusHisHouseBdcqzsdjxx.getCqly())){
//					regBaseH.setQlxz("102");
//				}
//			}
				
			/*
			//房地产交易价格
			//通过当前办理业务的单元号截取后去登记信息表中查找最后一位登记信
			RegBusBdcqzsdjxx regBusBdcqzsdjxx_1 = new RegBusBdcqzsdjxx();
			String bdcdyh_1 = regBaseH.getBdcdyh().substring(0, 19)+"W";//查找土地最后一笔业务
			regBusBdcqzsdjxx_1.setBdcdyh(bdcdyh_1);
			regBusBdcqzsdjxx_1.setIslogout("0");//未注销
			regBusBdcqzsdjxx_1.setDbsj("NOTNULL");//已登簿
			List<RegBusBdcqzsdjxx> regBusBdcqzsdjxxlist = regBusBdcqzsdjxxService.findList(regBusBdcqzsdjxx_1);
			if(regBusBdcqzsdjxxlist.size() > 0){
				regBusBdcqzsdjxx_1 = regBusBdcqzsdjxxlist.get(0);
				RegBusJsydsyq regBusJsydsyq = new RegBusJsydsyq();
				regBusJsydsyq.setZddm(regBusBdcqzsdjxx_1.getZddm());
				regBusJsydsyq.setYwh(regBusBdcqzsdjxx_1.getYwh());
				List<RegBusJsydsyq> regBusJsydsyqlist = regBusJsydsyqService.findList(regBusJsydsyq);
				if(regBusJsydsyqlist.size()>0){
					regBusJsydsyq = regBusJsydsyqlist.get(0);
					regBusHisHouseBdcqzsdjxx.setFdcjyjg(regBusJsydsyq.getQdjg());
				}
			}*/
			StringBuilder sb = new StringBuilder();
			sb.append("分摊土地使用权面积:").append(RegUtils.replaceNull(regBaseH.getFttdmj())).append(";")
			  .append("房屋结构:").append(RegUtils.replaceNull(DictUtils.getDictLabel(regBaseZrz.getFwjg(), "reg_bus_fwjg", ""))).append(";")
			  .append("专有建筑面积:").append(RegUtils.replaceNull(regBaseH.getSctnjzmj())).append(";")
			  .append("分摊建筑面积:").append(RegUtils.replaceNull(regBaseH.getScftjzmj())).append(";")
			  .append("房屋总层数:").append(RegUtils.replaceNull(regBaseH.getSjcs())).append(";")
			  .append("所在层数:").append(RegUtils.replaceNull(regBaseC.getSjc())).append(";")
			  .append("房屋竣工时间:").append(RegUtils.replaceNull(com.thinkgem.jeesite.common.utils.DateUtils.formatDate(regBusHisHouseBdcqzsdjxx.getJgsj(), "yyyy年MM月dd日"))).append(";");
			if(regBusHisHouseBdcqzsdjxx.getFdcjyjg() != null){
				regBusHisHouseBdcqzsdjxx.setHbjk(Double.toString(regBusHisHouseBdcqzsdjxx.getFdcjyjg()));
			}
			System.out.println(sb.toString());
			if(regBusHisHouseBdcqzsdjxx.getTdsyqssj() != null && regBusHisHouseBdcqzsdjxx.getTdsyjssj() != null){
				regBusHisHouseBdcqzsdjxx.setSyqx(DateUtils.formatDate(regBusHisHouseBdcqzsdjxx.getTdsyqssj(), "yyyy年MM月dd日") + "起" +
						DateUtils.formatDate(regBusHisHouseBdcqzsdjxx.getTdsyjssj(),"yyyy年MM月dd日")+"止;");
				model.addAttribute("syqx", regBusHisHouseBdcqzsdjxx.getSyqx());
			}
			regBusHisHouseBdcqzsdjxx.setGhyt(regBaseH.getFwyt1());
			regBusHisHouseBdcqzsdjxx.setQlqtzk(sb.toString());
			regBusHisHouseBdcqzsdjxx.setFwxz(regBusHisHouseBdcqzsdjxx.getFwxz());
			regBusHisHouseBdcqzsdjxx.setFwjg(regBaseZrz.getFwjg());
			regBusHisHouseBdcqzsdjxx.setBdcdyh(regBaseH.getBdcdyh());
			regBusHisHouseBdcqzsdjxx.setId("");
			regBusHisHouseBdcqzsdjxx.setFdzl(regBaseH.getZl());
			regBusHisHouseBdcqzsdjxx.setJzmj(regBaseH.getScjzmj());
			regBusHisHouseBdcqzsdjxx.setSzc(String.valueOf(regBaseC.getSjc()));
			regBusHisHouseBdcqzsdjxx.setFttdmj(regBaseH.getFttdmj());
			regBusHisHouseBdcqzsdjxx.setZyjzmj(regBaseH.getSctnjzmj());
			regBusHisHouseBdcqzsdjxx.setFtjzmj(regBaseH.getScftjzmj());
			regBusHisHouseBdcqzsdjxx.setQlxz(DictUtils.getDictLabel(regBaseH.getQlxz(), "reg_bus_qlxz", "")+"/"+DictUtils.getDictLabel(regBusHisHouseBdcqzsdjxx.getFwxz(), "reg_bus_fwxz", ""));
			RegBusHisHouseBdcqzsdjxx djxx = new RegBusHisHouseBdcqzsdjxx();
			djxx.setBdcdyh(regBaseH.getBdcdyh());
			djxx.setYwh(ywh);
			List<RegBusHisHouseBdcqzsdjxx> findList = regBusHisHouseBdcqzsdjxxService.findList(djxx);
			if(findList.size() > 0){
				regBusHisHouseBdcqzsdjxx.setId(findList.get(0).getId());
			}
			if("207".equals(regBusHisHouseBdcqzsdjxx.getDjxl())){
				regBusHisHouseBdcqzsdjxx.setZdftfs(null);
			}
			regBusHisHouseBdcqzsdjxx.setYwh(ywh);
			regBusHisHouseBdcqzsdjxx.setBdcqzh(null);
			regBusHisHouseBdcqzsdjxxService.save(regBusHisHouseBdcqzsdjxx);
		}
		if(StringUtils.isNotBlank(regBusHisHouseBdcqzsdjxx.getYwh())){
			modelmap.put("success", 0);
			modelmap.put("qlxz", regBusHisHouseBdcqzsdjxx.getQlxz());
			modelmap.put("YWH", regBusHisHouseBdcqzsdjxx.getYwh());
		}else{
			modelmap.put("success", 1);
		}
		return modelmap;
	}
	
	/**
	 * 房屋历史抵押权属信息保存
	 * @param regBusHisHouseBdcqzsdjxx
	 * @param request
	 * @param model
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:edit")
	@RequestMapping(value = "hishousedySave")
	public String hishousedySave(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx, HttpServletRequest request, Model model, RedirectAttributes redirectAttributes) {
		System.out.println(regBusHisHouseBdcqzsdjxx.getBdcdjzmh());
		String selectedIDs = request.getParameter("selectedIDs");
		String dymjhj = request.getParameter("dymjhj");
		String[] idList = selectedIDs.split(";");
		String zdqlxz = "";
		String fwqlxz = "";
		int t = 0;
		RegBusHisHouseBdcqzsdjxx djxx = new RegBusHisHouseBdcqzsdjxx();
		String ywh = "";
		for(int i =0 ;i<idList.length;i++){
			RegBaseH regBaseH = regBaseHService.get(idList[i]);
			RegBaseC regBaseC =  regBaseCService.get(regBaseH.getCid());
			RegBaseZrz regBaseZrz = regBaseZrzService.get(regBaseC.getZid());
			//把楼盘变为已引用
			regBaseH.setIsaudit("2");
			regBaseHService.save(regBaseH);
//			regBaseC.setIsaudit("2");
//			regBaseCService.save(regBaseC);
//			regBaseZrz.setIsaudit("2");
//			regBaseZrzService.save(regBaseZrz);
			
			String zddm = regBaseH.getBdcdyh().substring(0, 19);//查找土地最后一笔业务
			RegBaseZdjbxx zdxx = new RegBaseZdjbxx();
			zdxx.setZddm(zddm);
			List<RegBaseZdjbxx> zdfindList = regBaseZdjbxxService.findList(zdxx);
			if(zdfindList.size() > 0){
				zdxx = zdfindList.get(0);
				regBusHisHouseBdcqzsdjxx.setQlxz(DictUtils.getDictLabel(regBaseH.getQlxz(), "reg_bus_qlxz", "")+"/"+DictUtils.getDictLabel(regBaseH.getFwxz(), "reg_bus_fwxz", ""));
//				zdqlxz = zdxx.getQlxz();
				zdqlxz = regBaseH.getQlxz();
				fwqlxz = regBaseH.getFwxz();
			}
			if("213".equals(regBusHisHouseBdcqzsdjxx.getDjxl())){
				StringBuilder sb = new StringBuilder();
				sb.append("分摊土地使用权面积:").append(RegUtils.replaceNull(regBaseH.getFttdmj())).append(";")
				  .append("房屋结构:").append(RegUtils.replaceNull(DictUtils.getDictLabel(regBaseZrz.getFwjg(), "reg_bus_fwjg", ""))).append(";")
				  .append("专有建筑面积:").append(RegUtils.replaceNull(regBaseH.getSctnjzmj())).append(";")
				  .append("分摊建筑面积:").append(RegUtils.replaceNull(regBaseH.getScftjzmj())).append(";")
				  .append("房屋总层数:").append(RegUtils.replaceNull(regBaseH.getSjcs())).append(";")
				  .append("所在层数:").append(RegUtils.replaceNull(regBaseC.getSjc())).append(";")
				  .append(";");
				regBusHisHouseBdcqzsdjxx.setQlqtzk(sb.toString());
			}else{
				regBusHisHouseBdcqzsdjxx.setQlqtzk(null);
			}
			
			if(regBusHisHouseBdcqzsdjxx.getZwlxqssj() != null && regBusHisHouseBdcqzsdjxx.getZwlxjssj() != null){
				regBusHisHouseBdcqzsdjxx.setSyqx(DateUtils.formatDate(regBusHisHouseBdcqzsdjxx.getZwlxqssj(), "yyyy年MM月dd日") + "起" +
						DateUtils.formatDate(regBusHisHouseBdcqzsdjxx.getZwlxjssj(),"yyyy年MM月dd日")+"止;");
			}
			regBusHisHouseBdcqzsdjxx.setGhyt(regBaseH.getFwyt1());
			regBusHisHouseBdcqzsdjxx.setBdcdyh(regBaseH.getBdcdyh());
			regBusHisHouseBdcqzsdjxx.setBdcqzh(regBusHisHouseBdcqzsdjxx.getBdcdjzmh());
			regBusHisHouseBdcqzsdjxx.setId(""); 
			regBusHisHouseBdcqzsdjxx.setFdzl(regBaseH.getZl());
			regBusHisHouseBdcqzsdjxx.setZjjzwzl(regBaseH.getZl());
			djxx.setBdcdyh(regBaseH.getBdcdyh());
			if(t == 0){
				ywh =  "LS"+getNextYwhs();
				djxx.setYwh(ywh);
				t  = 1;
			}
			List<RegBusHisHouseBdcqzsdjxx> findList = regBusHisHouseBdcqzsdjxxService.findList(djxx);
			if(findList.size() > 0){
				regBusHisHouseBdcqzsdjxx.setId(findList.get(0).getId());
			}
			regBusHisHouseBdcqzsdjxx.setYwh(ywh);
			regBusHisHouseBdcqzsdjxxService.save(regBusHisHouseBdcqzsdjxx);
			//带抵押人
			RegBusRights rights = new RegBusRights();
			if(regBusHisHouseBdcqzsdjxx.getDjxl().equals("213")) {
				rights.setBdcdyh(regBusHisHouseBdcqzsdjxx.getBdcdyh().substring(0, 19)+"W00000000");
			}else {
			   rights.setBdcdyh(regBusHisHouseBdcqzsdjxx.getBdcdyh());
			}
			List<RegBusRights> rightslist = regBusRightsService.findList(rights);
			if(rightslist.size()>0) {
				rights = rightslist.get(0);
				RegBusQlr qlr = new RegBusQlr();
				String qlrywh = "";
			   if(regBusHisHouseBdcqzsdjxx.getDjxl().equals("804")||regBusHisHouseBdcqzsdjxx.getDjxl().equals("807")) {
				   qlrywh =  rights.getXsouyq();
			   }else if(regBusHisHouseBdcqzsdjxx.getDjxl().equals("214")||regBusHisHouseBdcqzsdjxx.getDjxl().equals("215")) {
				   qlrywh = rights.getSsouyq();
			   }else {
				   qlrywh = rights.getSshiyq();
			   }
				List<RegBusQlr> qlrlist = regBusQlrService.findByYwh(qlrywh);
				if(qlrlist.size()>0) {
					for(int q=0;q<qlrlist.size();q++) {
						qlr = qlrlist.get(q);
						RegBusHisHouseYwr ywr = new RegBusHisHouseYwr();
						BeanUtils.copyProperties(qlr, ywr);
						ywr.setId("");
						ywr.setSxh(qlr.getSxh()+"");
						ywr.setYwh(ywh);
						regBusHisHouseYwrService.save(ywr);
					}
				}
			}
		}
		return  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/hishousedylist?WWWO=1&LISTVIEWS=1&YWH="+regBusHisHouseBdcqzsdjxx.getYwh()+"&selectedIDs="+selectedIDs+"&zdqlxz="+zdqlxz+"&fwqlxz="+fwqlxz+"&dymjhj="+dymjhj;
	}
	
	/**
	 * 房屋历史预告权属信息保存
	 * @param regBusHisHouseBdcqzsdjxx
	 * @param request
	 * @param model
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:edit")
	@RequestMapping(value = "hishouseygSave")
	public String hishouseygSave(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx, HttpServletRequest request, Model model, RedirectAttributes redirectAttributes) {
		String selectedIDs = request.getParameter("selectedIDs");
		String[] idList = selectedIDs.split(";");
		String zdqlxz = "";
		String fwqlxz = "";
		for(int i =0 ;i<idList.length;i++){
			RegBaseH regBaseH = regBaseHService.get(idList[i]);
			RegBaseC regBaseC =  regBaseCService.get(regBaseH.getCid());
			RegBaseZrz regBaseZrz = regBaseZrzService.get(regBaseC.getZid());
			//把楼盘变为已引用
			regBaseH.setIsaudit("2");
			regBaseHService.save(regBaseH);
			regBusHisHouseBdcqzsdjxx.setGhyt(regBaseH.getFwyt1());
			regBusHisHouseBdcqzsdjxx.setBdcdyh(regBaseH.getBdcdyh());
			regBusHisHouseBdcqzsdjxx.setFwxz(regBaseH.getFwxz());
			regBusHisHouseBdcqzsdjxx.setFwjg(regBaseZrz.getFwjg());
			regBusHisHouseBdcqzsdjxx.setFdzl(regBaseH.getZl());
			regBusHisHouseBdcqzsdjxx.setJzmj(regBaseH.getScjzmj());
			regBusHisHouseBdcqzsdjxx.setFtjzmj(regBaseH.getScftjzmj());
			regBusHisHouseBdcqzsdjxx.setSzc(String.valueOf(regBaseC.getSjc()));
			
			if("806".equals(regBusHisHouseBdcqzsdjxx.getDjxl())){
				RegBusHisHouseBdcqzsdjxx hisdjxx = new RegBusHisHouseBdcqzsdjxx();
				hisdjxx.setBdcdyh(regBaseH.getBdcdyh());
				hisdjxx.setDjxl("207");
				hisdjxx.setIsaudit("1");
				List<RegBusHisHouseBdcqzsdjxx> djxxlist = regBusHisHouseBdcqzsdjxxService.findList(hisdjxx);
				if(djxxlist.size() > 0){
					hisdjxx = djxxlist.get(0);
					regBusHisHouseBdcqzsdjxx.setQlqtzk(hisdjxx.getQlqtzk());
				}
			}else{
				regBusHisHouseBdcqzsdjxx.setQlqtzk(null);
			}
			
			regBusHisHouseBdcqzsdjxx.setBdcqzh(regBusHisHouseBdcqzsdjxx.getBdcdjzmh());
			String zddm = regBaseH.getBdcdyh().substring(0, 19);//查找土地最后一笔业务
			RegBaseZdjbxx zdxx = new RegBaseZdjbxx();
			zdxx.setZddm(zddm);
			List<RegBaseZdjbxx> zdfindList = regBaseZdjbxxService.findList(zdxx);
			if(zdfindList.size() > 0){
				zdxx = zdfindList.get(0);
				regBusHisHouseBdcqzsdjxx.setQlxz(DictUtils.getDictLabel(regBaseH.getQlxz(), "reg_bus_qlxz", "")+"/"+DictUtils.getDictLabel(regBaseH.getFwxz(), "reg_bus_fwxz", ""));
//				zdqlxz = zdxx.getQlxz();
				zdqlxz =  regBaseH.getQlxz();
				fwqlxz = regBaseH.getFwxz();
			}
			regBusHisHouseBdcqzsdjxx.setId("");
			String ywh = "LS"+getNextYwhs();
			RegBusHisHouseBdcqzsdjxx djxx = new RegBusHisHouseBdcqzsdjxx();
			djxx.setBdcdyh(regBaseH.getBdcdyh());
			djxx.setYwh(ywh);
			List<RegBusHisHouseBdcqzsdjxx> findList = regBusHisHouseBdcqzsdjxxService.findList(djxx);
			if(findList.size() > 0){
				regBusHisHouseBdcqzsdjxx.setId(findList.get(0).getId());
			}
			regBusHisHouseBdcqzsdjxx.setYwh(ywh);
			regBusHisHouseBdcqzsdjxxService.save(regBusHisHouseBdcqzsdjxx);
			
		}
		
		System.out.println(regBusHisHouseBdcqzsdjxx.getQlxz());
		return  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/hishouseyglist?WWWO=1&LISTVIEWS=1&YWH="+regBusHisHouseBdcqzsdjxx.getYwh()+"&zdqlxz="+zdqlxz+"&fwqlxz="+fwqlxz;
	}
	
	/**
	 * 房屋历史权属修改保存
	 * @param regBusHisHouseBdcqzsdjxx
	 * @param request
	 * @param model
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:edit")
	@RequestMapping(value = "hishouseeditSave")
	public String hishouseeditSave(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx, HttpServletRequest request, Model model, RedirectAttributes redirectAttributes) {
		String tz="";
		if(StringUtils.isNotBlank(request.getParameter("H"))){
			tz = request.getParameter("H");
		}
		if(tz.equals("2")){
			regBusHisHouseBdcqzsdjxx.setBdcqzh(regBusHisHouseBdcqzsdjxx.getBdcdjzmh());
		}
		//此段代码本可以没有,但因业务人员非得修改进去填此处,我也没办法、、、、、、
		if(tz.equals("3")) {
		if(regBusHisHouseBdcqzsdjxx.getTdsyqssj() != null && regBusHisHouseBdcqzsdjxx.getTdsyjssj() != null){
			regBusHisHouseBdcqzsdjxx.setSyqx(DateUtils.formatDate(regBusHisHouseBdcqzsdjxx.getTdsyqssj(), "yyyy年MM月dd日") + "起" +
					DateUtils.formatDate(regBusHisHouseBdcqzsdjxx.getTdsyjssj(),"yyyy年MM月dd日")+"止;");
		}
		List<RegBusHisHouseBdcqzsdjxx> list = regBusHisHouseBdcqzsdjxxService.findByYwh(regBusHisHouseBdcqzsdjxx.getYwh());
		if(list.size()>0) {
			for(int i=0;i<list.size();i++) {
			RegBusHisHouseBdcqzsdjxx djxx = list.get(0);
			djxx.setSyqx(regBusHisHouseBdcqzsdjxx.getSyqx());
			regBusHisHouseBdcqzsdjxxService.save(djxx);
			}
		}
		
		}
		regBusHisHouseBdcqzsdjxxService.save(regBusHisHouseBdcqzsdjxx);
		String views="";
		if(tz.equals("1")){
			views = "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/hishouseyglist?optype=1&WO=1&LISTVIEWS=1&YWH="+regBusHisHouseBdcqzsdjxx.getYwh();
		}
		if(tz.equals("2")){
			views = "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/hishousedylist?optype=1&WO=1&LISTVIEWS=1&YWH="+regBusHisHouseBdcqzsdjxx.getYwh();
		}
		if(tz.equals("3")){
			views = "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/hishousefdcqlist?optype=1&WO=1&LISTVIEWS=1&YWH="+regBusHisHouseBdcqzsdjxx.getYwh();
		}
		return views;
	}
	
	/**
	 * 房屋历史大表(父页面)最终保存
	 * @param regBusHisHouseBdcqzsdjxx
	 * @param request
	 * @param model
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:edit")
	@RequestMapping(value = "save")
	public String save(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx, HttpServletRequest request, Model model, RedirectAttributes redirectAttributes) {
		String	optype = request.getParameter("optype");
		String tz = request.getParameter("H");
		String vie = "";
		RegBusHisHouseBdcqzsdjxx djxxisaudit = new RegBusHisHouseBdcqzsdjxx();
		djxxisaudit.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
		List<RegBusHisHouseBdcqzsdjxx> findList_1 = regBusHisHouseBdcqzsdjxxService.findList(djxxisaudit);
		if(findList_1.size() > 0){
			djxxisaudit = findList_1.get(0);
			if("0".equals(djxxisaudit.getIsaudit()) || StringUtils.isBlank(djxxisaudit.getIsaudit())){
				RegBusHisHouseBdcqzsdjxx djxx = new RegBusHisHouseBdcqzsdjxx();
				djxx.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
				List<RegBusHisHouseBdcqzsdjxx> findList = regBusHisHouseBdcqzsdjxxService.findList(djxx);
				if(findList.size() > 0){
					int t = findList.size();
					for(int i =0;i<t;i++){
						djxx = findList.get(i);
						djxx.setIsaudit("0");
						djxx.setDelFlag("0");
						if(tz.equals("1")){
							djxx.setBdcqzbh(regBusHisHouseBdcqzsdjxx.getBdcqzbh());
							djxx.setBdcqzh(regBusHisHouseBdcqzsdjxx.getBdcqzh());
							djxx.setQllx(regBusHisHouseBdcqzsdjxx.getQllx());
							djxx.setFzsj(regBusHisHouseBdcqzsdjxx.getFzsj());
							djxx.setHbhth(regBusHisHouseBdcqzsdjxx.getHbhth());
							djxx.setHbjk(regBusHisHouseBdcqzsdjxx.getHbjk());
							djxx.setPwh(regBusHisHouseBdcqzsdjxx.getPwh());
							djxx.setRemarks(regBusHisHouseBdcqzsdjxx.getRemarks());
						}
						if(tz.equals("2")){
							RegBaseH h = new RegBaseH();
							if(StringUtils.isNotBlank(regBusHisHouseBdcqzsdjxx.getDjxl())){
								if(regBusHisHouseBdcqzsdjxx.getDjxl().startsWith("8")){
									djxx.setDjlx("700");
								}else if(regBusHisHouseBdcqzsdjxx.getDjxl().startsWith("2")){
									djxx.setDjlx("100");
								}
							}
							djxx.setQllx(regBusHisHouseBdcqzsdjxx.getQllx());
							djxx.setRemarks(regBusHisHouseBdcqzsdjxx.getRemarks());
							djxx.setJzmjhj(regBusHisHouseBdcqzsdjxx.getJzmjhj());
							if("213".equals(regBusHisHouseBdcqzsdjxx.getDjxl())){
								String qlrmc = "";
								String qlgyrmc ="";
								String gyqk="";
								RegBusHisHouseQlr qlrnew = new RegBusHisHouseQlr();
								qlrnew.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
								List<RegBusHisHouseQlr> listqlr = regBusHisHouseQlrService.findList(qlrnew);
								if(listqlr.size() > 0){//获取该笔业务的权利人
									for (int j = 0; j < listqlr.size(); j++) {
										qlrnew = listqlr.get(j);
										if(!"1".equals(qlrnew.getSxh())){
											qlgyrmc +=  qlrnew.getQlrmc()+";";
										}else {
											qlrmc = qlrnew.getQlrmc();
											gyqk = DictUtils.getDictLabel(qlrnew.getGyfs(), "reg_bus_gyfs", "");
										}
									}
								}
								String qlqtzk = djxx.getQlqtzk();
								if(StringUtils.isNotBlank(qlgyrmc)){
									djxx.setQlqtzk(qlqtzk+"共有情况:"+gyqk+";共有人:"+qlgyrmc);
								}else{
									djxx.setQlqtzk(qlqtzk+"共有情况:"+gyqk+";");
								}
							}
						}
						if(tz.equals("3")){
							djxx.setBdcqzbh(regBusHisHouseBdcqzsdjxx.getBdcqzbh());
							djxx.setBdcqzh(regBusHisHouseBdcqzsdjxx.getBdcqzh());
							if(StringUtils.isNotBlank(regBusHisHouseBdcqzsdjxx.getDjxl())){
								if(regBusHisHouseBdcqzsdjxx.getDjxl().startsWith("2")){
									djxx.setDjlx("100");
								}else if(regBusHisHouseBdcqzsdjxx.getDjxl().startsWith("3")){
									djxx.setDjlx("200");
								}
							}
							djxx.setFzsj(regBusHisHouseBdcqzsdjxx.getFzsj());
							djxx.setHbhth(regBusHisHouseBdcqzsdjxx.getHbhth());
							djxx.setHbjk(regBusHisHouseBdcqzsdjxx.getHbjk());
							djxx.setPwh(regBusHisHouseBdcqzsdjxx.getPwh());
							djxx.setRemarks(regBusHisHouseBdcqzsdjxx.getRemarks());
		
							String qlrmc = "";
							String qlgyrmc ="";
							String gyqk="";
							RegBusHisHouseQlr qlrnew = new RegBusHisHouseQlr();
							qlrnew.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
							List<RegBusHisHouseQlr> listqlr = regBusHisHouseQlrService.findList(qlrnew);
							if(listqlr.size() > 0){//获取该笔业务的权利人
								for (int j = 0; j < listqlr.size(); j++) {
									qlrnew = listqlr.get(j);
									if(StringUtils.isNoneBlank(qlrmc) && !"1".equals(qlrnew.getSxh())){
										qlgyrmc += qlrnew.getQlrmc()+";";
									}else {
										qlrmc = qlrnew.getQlrmc();
										gyqk = DictUtils.getDictLabel(qlrnew.getGyfs(), "reg_bus_gyfs", "");
									}
								}
							}
							String qlqtzk = djxx.getQlqtzk();
							if(StringUtils.isNotBlank(qlgyrmc)){
								djxx.setQlqtzk(qlqtzk+"共有情况:"+gyqk+";共有人:"+qlgyrmc);
							}else{
								djxx.setQlqtzk(qlqtzk+"共有情况:"+gyqk+";");
							}
						}
						if(tz.equals("4")){//查封登记
							djxx.setQllx(regBusHisHouseBdcqzsdjxx.getQllx());
							djxx.setFzsj(regBusHisHouseBdcqzsdjxx.getFzsj());
							djxx.setHbhth(regBusHisHouseBdcqzsdjxx.getHbhth());
							djxx.setHbjk(regBusHisHouseBdcqzsdjxx.getHbjk());
							djxx.setPwh(regBusHisHouseBdcqzsdjxx.getPwh());
							djxx.setRemarks(regBusHisHouseBdcqzsdjxx.getRemarks());
							String qlrmc = "";
							String qlgyrmc ="";
							String gyqk="";
							RegBusHisHouseQlr qlrnew = new RegBusHisHouseQlr();
							qlrnew.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
							List<RegBusHisHouseQlr> listqlr = regBusHisHouseQlrService.findList(qlrnew);
							if(listqlr.size() > 0){//获取该笔业务的权利人
								for (int j = 0; j < listqlr.size(); j++) {
									qlrnew = listqlr.get(j);
									if(StringUtils.isNoneBlank(qlrmc) && !"1".equals(qlrnew.getSxh())){
										qlgyrmc += qlrnew.getQlrmc()+";";
									}else {
										qlrmc = qlrnew.getQlrmc();
										gyqk = DictUtils.getDictLabel(qlrnew.getGyfs(), "reg_bus_gyfs", "");
									}
								}
								djxx.setDyr(qlrmc);//暂用抵押人字段存贮查封权利人
							}
							
						
						}
						//通过id首先获取房屋,层,项目信息
						RegBaseH regBaseH = new RegBaseH();
						RegBaseC regBaseC = new RegBaseC();
						RegBaseZrz regBaseZrz = new RegBaseZrz();
						regBaseH.setBdcdyh(djxx.getBdcdyh());
						List<RegBaseH>   hlist = regBaseHService.findList(regBaseH);
						if(hlist.size()>0){
							regBaseH = hlist.get(0);
							regBaseC = regBaseCService.get(regBaseH.getCid());
							djxx.setJzmj(regBaseH.getScjzmj());
							djxx.setFtjzmj(regBaseH.getScftjzmj());
							djxx.setFwxz(regBaseH.getFwxz());
							if(regBaseH.getSjcs() != null){
								djxx.setZcs(String.valueOf(regBaseH.getSjcs()));
							}
						}
						if(regBaseC != null){
							regBaseZrz = regBaseZrzService.get(regBaseC.getZid());
							if(StringUtils.isNotBlank(regBaseC.getSjc())){
								djxx.setSzc(regBaseC.getSjc());//所在层- 取实际层
							}
						}
						if(regBaseZrz != null){
							djxx.setFwjg(regBaseZrz.getFwjg());
							if("207".equals(regBusHisHouseBdcqzsdjxx.getDjxl())){
								djxx.setZdftfs(regBaseZrz.getZdftfs());
							}
						}
						//由宗地代码获取宗地信息,确保宗地代码在库里有值时才取宗地信息里的值
//						RegBaseZdjbxx regBaseZdjbxx = new RegBaseZdjbxx();
//						regBaseZdjbxx.setZddm(regBaseZrz.getZddm());
//						List<RegBaseZdjbxx> zdList = regBaseZdjbxxService.findList(regBaseZdjbxx);
//						if(zdList.size()>0){
//							regBaseZdjbxx = zdList.get(0);
//							djxx.setTdsyqr(regBaseZdjbxx.getQlrxm());
//						}
						String yggyrmc_1 = "";
						RegBusHisHouseQlr ygqlr_2 = new RegBusHisHouseQlr();
						ygqlr_2.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
						List<RegBusHisHouseQlr> ygdjqlrlist_1 = regBusHisHouseQlrService.findList(ygqlr_2);//获取权利人子表数据
						for(int y=0;y<ygdjqlrlist_1.size();y++){
							yggyrmc_1 += ygdjqlrlist_1.get(y).getQlrmc()+"; ";
						}
						djxx.setTdsyqr(yggyrmc_1);
						djxx.setQszt("1");
						djxx.setDjxl(regBusHisHouseBdcqzsdjxx.getDjxl());
						if(regBusHisHouseBdcqzsdjxx.getDjxl().startsWith("2")){
							djxx.setDjlx("100");
						}else if(regBusHisHouseBdcqzsdjxx.getDjxl().startsWith("3")){
							djxx.setDjlx("200");
						}else if(regBusHisHouseBdcqzsdjxx.getDjxl().startsWith("8")){
							djxx.setDjlx("700");
						}else if(regBusHisHouseBdcqzsdjxx.getDjxl().startsWith("9")){
							djxx.setDjlx("800");
						}
						regBusHisHouseBdcqzsdjxxService.save(djxx);
					}
					if(tz.equals("1")){
						if(optype != null && !optype.equals("")){
							if(djxx.getId().trim() != null && !djxx.getId().trim().equals("")){
								addMessage(redirectAttributes, "保存房屋历史登记数据录入成功");
								vie = "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/houselist?YWH="+regBusHisHouseBdcqzsdjxx.getYwh()+"&WO=1&VIEWS=1&H=1";
							}
						}else{
							addMessage(redirectAttributes, "保存房屋历史登记数据录入成功");
							vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listYG?VIEWS=1";
						}
					}
					if(tz.equals("2")){
						if(optype != null && !optype.equals("")){
							if(djxx.getId().trim() != null && !djxx.getId().trim().equals("")){
								addMessage(redirectAttributes, "保存房屋历史登记数据录入成功");
								vie = "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/houselist?YWH="+regBusHisHouseBdcqzsdjxx.getYwh()+"&WO=1&VIEWS=1&H=2";
							}
						}else{
							addMessage(redirectAttributes, "保存房屋历史登记数据录入成功");
							vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listDY?VIEWS=1";
						}
					}
					if(tz.equals("3")){
						if(optype != null && !optype.equals("")){
							if(djxx.getId().trim() != null && !djxx.getId().trim().equals("")){
								addMessage(redirectAttributes, "保存房屋历史登记数据录入成功");
								vie = "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/houselist?YWH="+regBusHisHouseBdcqzsdjxx.getYwh()+"&WO=1&VIEWS=1&H=3";
							}
						}else{
							addMessage(redirectAttributes, "保存房屋历史登记数据录入成功");
							vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listSC?VIEWS=1";
						}
					}
					if(tz.equals("4")){//查封登记
							addMessage(redirectAttributes, "保存房屋历史登记数据录入成功");
							vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listCF?VIEWS=1";
					}
				}
			}else{
				if(tz.equals("1")){
						addMessage(redirectAttributes, "此数据已审核不能保存!");
						vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listYG?VIEWS=1&WO=1&H=1&ysh=1";
				}
				if(tz.equals("2")){
						addMessage(redirectAttributes, "此数据已审核不能保存!");
						vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listDY?VIEWS=1&WO=1&H=2&ysh=1";
				}
				if(tz.equals("3")){
						addMessage(redirectAttributes, "此数据已审核不能保存!");
						vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listSC?VIEWS=1&WO=1&H=3&ysh=1";
				}
				if(tz.equals("4")){//查封登记
					addMessage(redirectAttributes, "此数据已审核不能保存!");
					vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listCF?VIEWS=1&WO=1&H=1&ysh=1";
			}
			}
		}
		return vie;
	}
	
	/**
	 * 房屋历史子页面信息删除
	 * @param regBusHisHouseBdcqzsdjxx
	 * @param redirectAttributes
	 * @param model
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:edit")
	@RequestMapping(value = "hishousedelete")
	public String hishousedelete(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx, RedirectAttributes redirectAttributes, Model model,HttpServletRequest request) {
		String tz = request.getParameter("H");
		String vie = "";
		String delete = "";
		if(StringUtils.isNotBlank(regBusHisHouseBdcqzsdjxx.getYwh())){
			RegBusHisHouseQlr qlr = new RegBusHisHouseQlr();
			qlr.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
			List<RegBusHisHouseQlr> List =  regBusHisHouseQlrService.findList(qlr);
			if(List.size() >0){ 
				for(int i=0;i<List.size();i++){
					qlr = List.get(i);
					regBusHisHouseQlrService.delete(qlr);
				}
			}
			RegBusHisHouseYwr ywr = new RegBusHisHouseYwr();
			ywr.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
			List<RegBusHisHouseYwr> ywrlist = regBusHisHouseYwrService.findList(ywr);//获取权利人子表数据
			if(ywrlist.size()>0){
				for(int t=0;t<ywrlist.size();t++){
					ywr = ywrlist.get(t);
					regBusHisHouseYwrService.delete(ywr);
				}
			}
			delete = "1";
		}
		if(tz.equals("1")){
			if(StringUtils.isNotBlank(regBusHisHouseBdcqzsdjxx.getId())){
				regBusHisHouseBdcqzsdjxxService.delete(regBusHisHouseBdcqzsdjxx);
			}
			addMessage(redirectAttributes, "删除房屋历史登记数据录入成功");
			vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/hishouseyglist?WO=1&optype=1&LISTVIEWS=1&YWH="+regBusHisHouseBdcqzsdjxx.getYwh()+"&delete="+delete;
		}
		if(tz.equals("2")){
			if(StringUtils.isNotBlank(regBusHisHouseBdcqzsdjxx.getId())){
				regBusHisHouseBdcqzsdjxxService.delete(regBusHisHouseBdcqzsdjxx);
			}
			addMessage(redirectAttributes, "删除房屋历史登记数据录入成功");
			vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/hishousedylist?WO=1&optype=1&LISTVIEWS=1&YWH="+regBusHisHouseBdcqzsdjxx.getYwh()+"&delete="+delete;
		}
		if(tz.equals("3")){
			if(StringUtils.isNotBlank(regBusHisHouseBdcqzsdjxx.getId())){
				regBusHisHouseBdcqzsdjxxService.delete(regBusHisHouseBdcqzsdjxx);
			}
			addMessage(redirectAttributes, "删除房屋历史登记数据录入成功");
			vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/hishousefdcqlist?WO=1&optype=1&LISTVIEWS=1&YWH="+regBusHisHouseBdcqzsdjxx.getYwh()+"&delete="+delete;
		}
		return vie;
	}
	
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:edit")
	@RequestMapping(value = "deleteFSH")
	public String deleteFSH(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx, RedirectAttributes redirectAttributes, Model model,HttpServletRequest request) {
		String id = request.getParameter("mainid");
		String tz = request.getParameter("H");
		String vie = "";
		
		//删除权属信息和登记信息
		if(tz.equals("1")){
			vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listYG?VIEWS=1";
		}
		if(tz.equals("2")){
			vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listDY?VIEWS=1";
		}
		if(tz.equals("3")){
			vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listSC?VIEWS=1";
		}
		if(tz.equals("4")){//查封登记
			vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listCF?VIEWS=1";
		}
		
		//更改户信息和删除历史入口信息
		
		RegBusHisHouseBdcqzsdjxx hishouse = new RegBusHisHouseBdcqzsdjxx();
		hishouse.setId(id);
		regBusHisHouseBdcqzsdjxx = regBusHisHouseBdcqzsdjxxService.get(hishouse);
		RegBusBdcqzsdjxx regBusBdcqzsdjxx = new RegBusBdcqzsdjxx();	
		List<RegBusBdcqzsdjxx> busdjxxList = Lists.newArrayList();
		if(tz.equals("3")) {
		if(regBusHisHouseBdcqzsdjxx.getDjxl().equals("207")) {//首次
		regBusBdcqzsdjxx.setBdcdyh(regBusHisHouseBdcqzsdjxx.getBdcdyh());
		busdjxxList = regBusBdcqzsdjxxService.findList(regBusBdcqzsdjxx);
		for (RegBusBdcqzsdjxx busdjxx : busdjxxList) {
			if(!busdjxx.getYwh().equals(regBusHisHouseBdcqzsdjxx.getYwh()) ) {
				addMessage(redirectAttributes, "删除房屋失败,存在已办业务,请联系管理员手工处理");
				logger.error("删除房屋失败,存在已办业务,请联系管理员手工处理");
				return vie;
			}
		}	
		}else {
			regBusBdcqzsdjxx.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
			 busdjxxList = regBusBdcqzsdjxxService.findList(regBusBdcqzsdjxx);
		}
		}else {
		 regBusBdcqzsdjxx.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
		 busdjxxList = regBusBdcqzsdjxxService.findList(regBusBdcqzsdjxx);
		}
		regBusBdcqzsdjxx = busdjxxList.get(0);
		//删除历史表权利/义务人和正式库权利/义务人
		RegBusHisHouseBdcqzsdjxx hishouseqlrywr = new RegBusHisHouseBdcqzsdjxx();
		hishouseqlrywr.setId(id);
		hishouseqlrywr = regBusHisHouseBdcqzsdjxxService.get(hishouseqlrywr);
		if(StringUtils.isNotBlank(regBusBdcqzsdjxx.getBdcdyh())){
			RegBusHisHouseQlr qlr = new RegBusHisHouseQlr(); 
			qlr.setYwh(regBusBdcqzsdjxx.getYwh());
			List<RegBusHisHouseQlr> List =  regBusHisHouseQlrService.findList(qlr);
			if(List.size() >0){
				for(int i=0;i<List.size();i++){
					qlr = List.get(i);
					regBusHisHouseQlrService.delete(qlr);
				}
			}
			RegBusQlr zsqlr = new RegBusQlr();
			zsqlr.setYwh(regBusBdcqzsdjxx.getYwh());
			List<RegBusQlr> zsList =  regBusQlrService.findList(zsqlr);
			if(zsList.size() >0){
				for(int i=0;i<zsList.size();i++){
					zsqlr = zsList.get(i);
					regBusQlrService.delete(zsqlr);
				}
			}

			RegBusHisHouseYwr ywr = new RegBusHisHouseYwr();
			ywr.setYwh(regBusBdcqzsdjxx.getYwh());
			List<RegBusHisHouseYwr> ywrlist = regBusHisHouseYwrService.findList(ywr);//获取权利人子表数据
			if(ywrlist.size()>0){
				for(int t=0;t<List.size();t++){
					ywr = ywrlist.get(t);
					regBusHisHouseYwrService.delete(ywr);
				}
			}
			
			RegBusYwr zsywr = new RegBusYwr();
			zsywr.setYwh(regBusBdcqzsdjxx.getYwh());
			List<RegBusYwr> zsywrList =  regBusYwrService.findList(zsywr);
			if(zsywrList.size() >0){
				for(int i=0;i<zsywrList.size();i++){
					zsywr = zsywrList.get(i);
					regBusYwrService.delete(zsywr);
				}
			}
		
			if(tz.equals("3")) {
		    RegBusFdcq2 fdcq2 = new RegBusFdcq2();
		    fdcq2.setBdcdyh(regBusBdcqzsdjxx.getBdcdyh());
		    fdcq2.setYwh(regBusBdcqzsdjxx.getYwh());
		    List<RegBusFdcq2>  fdcq2lst = regBusFdcq2Service.findList(fdcq2);
		    if(fdcq2lst.size() >0){
				for(int i=0;i<fdcq2lst.size();i++){
					fdcq2 = fdcq2lst.get(i);
					regBusFdcq2Service.delete(fdcq2);
				}
			}
		    
		    RegBaseHbhqk hbhqk = new RegBaseHbhqk();
		    hbhqk.setBdcdyh(regBusBdcqzsdjxx.getBdcdyh());
		    hbhqk.setYwh(regBusBdcqzsdjxx.getYwh());
		    List<RegBaseHbhqk>  hbhqklst = regBaseHbhqkService.findList(hbhqk);
		    if(hbhqklst.size() >0){
				for(int i=0;i<hbhqklst.size();i++){
					hbhqk = hbhqklst.get(i);
					regBaseHbhqkService.delete(hbhqk);
				}
			}
		    
		    RegBusRights rights = new RegBusRights();
		    rights.setBdcdyh(regBusBdcqzsdjxx.getBdcdyh());
		    List<RegBusRights>  rightslst = regBusRightsService.findList(rights);
		    if(rightslst.size() >0){
				for(int i=0;i<rightslst.size();i++){
					rights = rightslst.get(i);
				  if(regBusBdcqzsdjxx.getDjlx().equals("207")) {//首次删除rights
					regBusRightsService.delete(rights);
				   }else {
					  RegBusBdcqzsdjxx djxx1 = regBusBdcqzsdjxxService.get(regBusBdcqzsdjxx.getOldid());
					  djxx1.setIslogout("0");
					  regBusBdcqzsdjxxService.save(djxx1);
					  rights.setSsouyq(djxx1.getYwh());
					  rights.setRemarks(djxx1.getDjlx());
					  regBusRightsService.save(rights);
				}
			} 
			}
			}
			
		    if(tz.equals("2")) {
		    	RegBusDyaq dyaq = new RegBusDyaq();
		    	dyaq.setYwh(regBusBdcqzsdjxx.getYwh());
		    	List<RegBusDyaq> dyaqlst = regBusDyaqService.findList(dyaq);
		    	if(dyaqlst.size()>0) {
		    		for(int i=0;i<dyaqlst.size();i++) {
		    			dyaq = dyaqlst.get(i);
		    			regBusDyaqService.delete(dyaq);
		    		}
		    	}		    	
		    }
			regBusBdcqzsdjxxService.delete(regBusBdcqzsdjxx);
		}

		RegBaseH regBaseH = new RegBaseH();
		regBaseH.setBdcdyh(regBusHisHouseBdcqzsdjxx.getBdcdyh());
		List<RegBaseH> list =  regBaseHService.findList(regBaseH);
		if(list.size() > 0 ){
			regBaseH = list.get(0);
			if("302".equals(regBusHisHouseBdcqzsdjxx.getDjxl())){
				regBaseH.setIszy("0");
			}
			//首次删除时,变更审核状态和登记状态,其他登记小类不变
			if("207".equals(regBusHisHouseBdcqzsdjxx.getDjxl())){
				regBaseH.setIsaudit("1");
				regBaseH.setRights("0");
			}
			//抵押删除
			if(tz.equals("2")) {
			if(!"0".equals(regBaseH.getIsdiya())&&StringUtils.isNotBlank(regBaseH.getIsdiya())) {
				regBaseH.setIsdiya((Integer.parseInt(regBaseH.getIsdiya())-1)+"");
			}
			
			if("0".equals(regBaseH.getIsdiya())) {
				String first = "";
				//首次变为有效
			    if(StringUtils.isNotBlank(regBusBdcqzsdjxx.getOldid())) {
			    RegBusBdcqzsdjxx djxx1 = regBusBdcqzsdjxxService.get(regBusBdcqzsdjxx.getOldid());
			    djxx1.setIslogout("0");
			    first = djxx1.getYwh();
			    regBusBdcqzsdjxxService.save(djxx1);
			}
			    
				RegBusRights rights1 = new RegBusRights();
			    rights1.setBdcdyh(regBusBdcqzsdjxx.getBdcdyh());
			    List<RegBusRights>  rightslst = regBusRightsService.findList(rights1);
			    if(rightslst.size() >0){
					for(int i=0;i<rightslst.size();i++){
						rights1 = rightslst.get(i);
						rights1.setStxq(null);
						rights1.setRemarks(first);
						regBusRightsService.save(rights1);
					}
				} 
			    
			}
			}
			regBaseHService.save(regBaseH);
			
		}
		if(StringUtils.isNotBlank(regBusHisHouseBdcqzsdjxx.getId())){
			regBusHisHouseBdcqzsdjxxService.delete(regBusHisHouseBdcqzsdjxx);
		}
		addMessage(redirectAttributes, "删除房屋历史登记数据录入成功");
		return vie;
	}
	
	
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:edit")
	@RequestMapping(value = "delete")
	public String delete(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx, RedirectAttributes redirectAttributes, Model model,HttpServletRequest request) {
		String id = request.getParameter("mainid");
		String tz = request.getParameter("H");
		String vie = "";

		//删除历史表权利/义务人和正式库权利/义务人
		RegBusHisHouseBdcqzsdjxx hishouseqlrywr = new RegBusHisHouseBdcqzsdjxx();
		hishouseqlrywr.setId(id);
		hishouseqlrywr = regBusHisHouseBdcqzsdjxxService.get(hishouseqlrywr);
		if(StringUtils.isNotBlank(hishouseqlrywr.getYwh())){
			RegBusHisHouseQlr qlr = new RegBusHisHouseQlr();
			qlr.setYwh(hishouseqlrywr.getYwh());
			List<RegBusHisHouseQlr> List =  regBusHisHouseQlrService.findList(qlr);
			if(List.size() >0){
				for(int i=0;i<List.size();i++){
					qlr = List.get(i);
					regBusHisHouseQlrService.delete(qlr);
				}
			}
			RegBusQlr zsqlr = new RegBusQlr();
			zsqlr.setYwh(hishouseqlrywr.getYwh());
			List<RegBusQlr> zsList =  regBusQlrService.findList(zsqlr);
			if(zsList.size() >0){
				for(int i=0;i<zsList.size();i++){
					zsqlr = zsList.get(i);
					regBusQlrService.delete(zsqlr);
				}
			}

			RegBusHisHouseYwr ywr = new RegBusHisHouseYwr();
			ywr.setYwh(hishouseqlrywr.getYwh());
			List<RegBusHisHouseYwr> ywrlist = regBusHisHouseYwrService.findList(ywr);//获取权利人子表数据
			if(ywrlist.size()>0){
				for(int t=0;t<List.size();t++){
					ywr = ywrlist.get(t);
					regBusHisHouseYwrService.delete(ywr);
				}
			}
			
			RegBusYwr zsywr = new RegBusYwr();
			zsywr.setYwh(hishouseqlrywr.getYwh());
			List<RegBusYwr> zsywrList =  regBusYwrService.findList(zsywr);
			if(zsywrList.size() >0){
				for(int i=0;i<zsywrList.size();i++){
					zsywr = zsywrList.get(i);
					regBusYwrService.delete(zsywr);
				}
			}
		}
		
		//删除权属信息和登记信息
		if(tz.equals("1")){
			vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listYG?VIEWS=1";
		}
		if(tz.equals("2")){
			vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listDY?VIEWS=1";
		}
		if(tz.equals("3")){
			vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listSC?VIEWS=1";
		}
		if(tz.equals("4")){//查封登记
			vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listCF?VIEWS=1";
		}
		//更改户信息和删除历史入口信息
		RegBusHisHouseBdcqzsdjxx hishouse = new RegBusHisHouseBdcqzsdjxx();
		hishouse.setId(id);
		regBusHisHouseBdcqzsdjxx = regBusHisHouseBdcqzsdjxxService.get(hishouse);
		RegBaseH regBaseH = new RegBaseH();
		regBaseH.setBdcdyh(regBusHisHouseBdcqzsdjxx.getBdcdyh());
		List<RegBaseH> list =  regBaseHService.findList(regBaseH);
		if(list.size() > 0 ){
			regBaseH = list.get(0);
			regBaseH.setIsaudit("1");
			if("302".equals(regBusHisHouseBdcqzsdjxx.getDjxl())){
				regBaseH.setIszy("0");
				regBaseH.setIsaudit("2");
			}
			if("905".equals(regBusHisHouseBdcqzsdjxx.getDjxl())){
				regBaseH.setIschafeng("0");
				regBaseH.setIsaudit("2");
			}
			regBaseHService.save(regBaseH);
		}
		if(StringUtils.isNotBlank(regBusHisHouseBdcqzsdjxx.getId())){
			regBusHisHouseBdcqzsdjxxService.delete(regBusHisHouseBdcqzsdjxx);
		}
		addMessage(redirectAttributes, "删除房屋历史登记数据录入成功");
		return vie;
	}
	
//	//判断是否存在预购房屋登记权利人信息
//	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
//	@RequestMapping(value = "setinfo")
//	@ResponseBody
//	public ModelMap setinfo(HttpServletRequest request) {
//			ModelMap modelMap = new ModelMap();
//			String HselectedIDs = request.getParameter("selectedIDs");
//			//通过id首先获取房屋,层,项目信息 返回ysdm,bdcdyh,zrzh,ch,hh,zl
//			RegBaseH regBaseH = new RegBaseH();
//			regBaseH.setId(HselectedIDs);
//			regBaseH = regBaseHService.get(regBaseH);
//			if(regBaseH != null){
//				modelMap.put("success", 0);
//				modelMap.put("ysdm",regBaseH.getYsdm());
//				modelMap.put("bdcdyh",regBaseH.getBdcdyh());
//				modelMap.put("hh",regBaseH.getHh());
//				modelMap.put("zl",regBaseH.getZl());
//				modelMap.put("fttdmj",regBaseH.getFttdmj());
//				modelMap.put("scjzmj",regBaseH.getScjzmj());
//				modelMap.put("scftjzmj",regBaseH.getScftjzmj());
//				modelMap.put("sjcs",regBaseH.getSjcs());
//				modelMap.put("fwxz", DictUtils.getDictLabel(regBaseH.getFwxz(), "reg_bus_fwxz", ""));
//			}
//			RegBaseC regBaseC = new RegBaseC();
//			regBaseC = regBaseCService.get(regBaseH.getCid());
//			if(regBaseC != null){
//				modelMap.put("success", 0);
//				modelMap.put("ch",regBaseC.getCh());
//				modelMap.put("zrzh",regBaseC.getZrzh());
//				modelMap.put("sjc",regBaseC.getSjc());
//			}
//			RegBaseZrz regBaseZrz = new RegBaseZrz();
//			regBaseZrz = regBaseZrzService.get(regBaseC.getZid());
//			if(regBaseZrz != null){
//				modelMap.put("success", 0);
//				modelMap.put("fwjg", DictUtils.getDictLabel(regBaseZrz.getFwjg(), "reg_bus_fwjg", ""));
//			}
//			return modelMap;
//	}
	
	/**
	 * 房屋历史审核数据分插
	 * @param regBusHisHouseBdcqzsdjxx
	 * @param request
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:edit")
	@RequestMapping(value = "audit")
	@Transactional
	public synchronized String audit(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx,HttpServletRequest request,  RedirectAttributes redirectAttributes) {
		String djxl = regBusHisHouseBdcqzsdjxx.getDjxl();
		String tz = request.getParameter("H");
		String vie = "";
		RegBusBdcqzsdjxx bdcdjxx = new RegBusBdcqzsdjxx();
		
		int cfbz = 0;
		if(regBusHisHouseBdcqzsdjxx == null || regBusHisHouseBdcqzsdjxx.getYwh() == null  ) {
			addMessage(redirectAttributes, "历史登记数据已审核或已删除,请查看!");
			if(tz.equals("1")){
				vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listYG?VIEWS=1&ywhhz="+regBusHisHouseBdcqzsdjxx.getYwh()+"&isbatch="+request.getParameter("isbatch")+"&cfbz="+cfbz+"&ywh="+request.getParameter("paraywh")+"&bdcqzh="+request.getParameter("parabdcqzh")+"&bdcdyh="+request.getParameter("parabdcdyh")+"&fdzl="+request.getParameter("parafdzl")+"&jzmj="+request.getParameter("parajzmj");
			}
			if(tz.equals("2")){
				vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listDY?VIEWS=1&ywhhz="+regBusHisHouseBdcqzsdjxx.getYwh()+"&isbatch="+request.getParameter("isbatch")+"&cfbz="+cfbz+"&ywh="+request.getParameter("paraywh")+"&bdcqzh="+request.getParameter("parabdcqzh")+"&bdcdyh="+request.getParameter("parabdcdyh")+"&fdzl="+request.getParameter("parafdzl")+"&jzmj="+request.getParameter("parajzmj");
			}
			if(tz.equals("3")){
				vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listSC?VIEWS=1&ywhhz="+regBusHisHouseBdcqzsdjxx.getYwh()+"&isbatch="+request.getParameter("isbatch")+"&cfbz="+cfbz+"&ywh="+request.getParameter("paraywh")+"&bdcqzh="+request.getParameter("parabdcqzh")+"&bdcdyh="+request.getParameter("parabdcdyh")+"&fdzl="+request.getParameter("parafdzl")+"&jzmj="+request.getParameter("parajzmj");
			}
			if(tz.equals("4")){
				vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listCF?VIEWS=1&ywhhz="+regBusHisHouseBdcqzsdjxx.getYwh()+"&isbatch="+request.getParameter("isbatch")+"&cfbz="+cfbz+"&ywh="+request.getParameter("paraywh")+"&bdcqzh="+request.getParameter("parabdcqzh")+"&bdcdyh="+request.getParameter("parabdcdyh")+"&fdzl="+request.getParameter("parafdzl")+"&jzmj="+request.getParameter("parajzmj");
			} 
			return vie; 
		}
		
		
		//删除存在的业务人
		RegBusQlr cqlr = new RegBusQlr();
		cqlr.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
		List<RegBusQlr> cqlrlist = regBusQlrService.findList_1(cqlr);//获取权利人子表数据
		
		System.out.println(cqlrlist.size()+"_____________________________");
		for (RegBusQlr regBusQlr : cqlrlist) { 
			regBusQlr.setDelFlag("1");
			regBusQlrService.save(regBusQlr);
		}
		
		RegBusHisHouseQlr qlr = new RegBusHisHouseQlr();
		qlr.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
		List<RegBusHisHouseQlr> qlrlist = regBusHisHouseQlrService.findList(qlr);//获取权利人子表数据
		String qlrmc = "";
		String gyrmc = "";
		String ywrmc = "";
		String ywrgyrmc = "";
		if(qlrlist.size() > 0 ){
			String gyfs = DictUtils.getDictLabel(qlrlist.get(0).getGyfs(), "reg_bus_gyfs", "");
			bdcdjxx.setGyqk(gyfs);
			for(int qi=0;qi<qlrlist.size();qi++){
				qlr = qlrlist.get(qi);
				qlr.setYsdm("6003000000");
				if(qlrlist.get(qi).getSxh().equals("1")){
					qlrmc = qlrlist.get(qi).getQlrmc();
					bdcdjxx.setQlrmc(qlrmc);
				}else{
					gyrmc += qlrlist.get(qi).getQlrmc()+"; ";
				}
				//首先获取权利人 ID个数
				int qlrmcOrderNumber = 1;
				RegBusQlr qlr_6 = new RegBusQlr();
				qlr_6.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
				List<RegBusQlr> qlrlist_1 = regBusQlrService.findList_1(qlr_6);
				int count = qlrlist_1.size();
				if(count > 0){
					qlrmcOrderNumber = qlrlist_1.size() + 1;
				}
				//预告登记
				if(tz.equals("1")){
					RegBusQlr qlr_1 = new RegBusQlr();
					BeanUtils.copyProperties(qlr, qlr_1);
					qlr_1.setSxh(qlrmcOrderNumber);
					qlr_1.setBdcdyh(regBusHisHouseBdcqzsdjxx.getBdcdyh());
					qlr_1.setId("");
					qlr_1.setQllx("27");
					qlr_1.setQszt("1");
					RegBusQlr qlr_11 = new RegBusQlr();
					qlr_11.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
					qlr_11.setPcode(qlr.getPcode());
					List<RegBusQlr> qlrlist_11 = regBusQlrService.findList_1(qlr_11);
					if(qlrlist_11.size() > 0 ){
						qlr_1.setId(qlrlist_11.get(0).getId());
					}
					regBusQlrService.save(qlr_1);
				}
				//抵押登记
				if(tz.equals("2")){
					RegBusQlr qlr_2 = new RegBusQlr();
					BeanUtils.copyProperties(qlr, qlr_2);
					qlr_2.setSxh(qlrmcOrderNumber);
					qlr_2.setId("");
					RegBusQlr qlr_22 = new RegBusQlr();
					qlr_22.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
					qlr_22.setPcode(qlr.getPcode());
					List<RegBusQlr> qlrlist_22 = regBusQlrService.findList_1(qlr_22);
					if(qlrlist_22.size() > 0 ){
						qlr_2.setId(qlrlist_22.get(0).getId());
					}
					if(djxl.equals("807") || djxl.equals("804")){
						qlr_2.setQllx("27");
					}else{
						qlr_2.setQllx("24");
					}
					qlr_2.setQszt("1");
					regBusQlrService.save(qlr_2);
				}
				//房屋查封登记
				if(tz.equals("4")){
					RegBusQlr qlr_2 = new RegBusQlr();
					BeanUtils.copyProperties(qlr, qlr_2);
					qlr_2.setSxh(qlrmcOrderNumber);
					qlr_2.setId("");
					RegBusQlr qlr_22 = new RegBusQlr();
					qlr_22.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
					qlr_22.setPcode(qlr.getPcode());
					List<RegBusQlr> qlrlist_22 = regBusQlrService.findList_1(qlr_22);
					if(qlrlist_22.size() > 0 ){
						qlr_2.setId(qlrlist_22.get(0).getId());
					}
						qlr_2.setQllx("26");
					qlr_2.setQszt("1");
					regBusQlrService.save(qlr_2);
					
				}
				//首次登记
				if(tz.equals("3")){
					RegBusQlr qlr_3 = new RegBusQlr();
					BeanUtils.copyProperties(qlr, qlr_3);
					qlr_3.setSxh(qlrmcOrderNumber);
					qlr_3.setQszt("1");
					qlr_3.setId("");
					RegBusQlr qlr_33 = new RegBusQlr();
					qlr_33.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
					qlr_33.setPcode(qlr.getPcode());
					qlr_33.setQllx(regBusHisHouseBdcqzsdjxx.getQllx());
					List<RegBusQlr> qlrlist_33 = regBusQlrService.findList_1(qlr_33);
					if(qlrlist_33.size() > 0 ){
						qlr_3.setId(qlrlist_33.get(0).getId());
					}
					qlr_3.setQllx(regBusHisHouseBdcqzsdjxx.getQllx());
					qlr_3.setQszt("1");
					regBusQlrService.save(qlr_3);
				} 
				//修改人员信息的状态为已引用
				if(StringUtils.isNotBlank(qlr.getZjh())){
					RegBasePerson regBasePerson = new RegBasePerson();
					regBasePerson.setZjh(qlr.getZjh());
					regBasePerson.setZjzl(qlr.getZjzl());
					List<RegBasePerson> findPersonList = regBasePersonService.findList(regBasePerson);
					if(findPersonList.size()>0){
						regBasePerson = findPersonList.get(0);
						regBasePerson.setIsaudit("2");
						regBasePersonService.save(regBasePerson);
					}
				}
			}
		}
		
		//分叉数据到义务人表
		RegBusHisHouseYwr ywr = new RegBusHisHouseYwr();
		ywr.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
		List<RegBusHisHouseYwr> ywrlist = regBusHisHouseYwrService.findList(ywr);//获取权利人子表数据
		if(ywrlist.size() > 0 ){
			for(int yi=0;yi<ywrlist.size();yi++){
				ywr = ywrlist.get(yi);
				ywr.setYsdm("2003000000");
				if(ywrlist.get(yi).getSxh().equals("1")){
					ywrmc = ywrlist.get(yi).getQlrmc();
				}else{
					ywrgyrmc += ywrlist.get(yi).getQlrmc()+"; ";
				}
				//首先获取权利人 ID个数
				int ywrmcOrderNumber = 1;
				RegBusYwr ywr2 = new RegBusYwr();
				ywr2.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
				List<RegBusYwr>  ywrlist_1= regBusYwrService.findList(ywr2);
				int count = ywrlist.size();
				if(count > 0){
					ywrmcOrderNumber = ywrlist_1.size() + 1;
				}
				//预告登记
				if(tz.equals("1")){
					RegBusYwr ywr_1 = new RegBusYwr();
					BeanUtils.copyProperties(ywr, ywr_1);
					ywr_1.setSxh(String.valueOf(ywrmcOrderNumber));
					ywr_1.setBdcdyh(regBusHisHouseBdcqzsdjxx.getBdcdyh());
					ywr_1.setQllx("27");
					ywr_1.setQszt("1");
					ywr_1.setId("");
					RegBusYwr ywr_11 = new RegBusYwr();
					ywr_11.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
					ywr_11.setBdcdyh(ywr.getBdcdyh());
					ywr_11.setPcode(ywr.getPcode());
					List<RegBusYwr> ywrlist_11 = regBusYwrService.findList(ywr_11);
					if(ywrlist_11.size() > 0 ){
						ywr_1.setId(ywrlist_11.get(0).getId());
					}
					regBusYwrService.save(ywr_1);
				}
				//抵押登记
				if(tz.equals("2")){
					RegBusYwr ywr_2 = new RegBusYwr();
					BeanUtils.copyProperties(ywr, ywr_2);
					ywr_2.setSxh(String.valueOf(ywrmcOrderNumber));
					ywr_2.setBdcdyh(ywr.getBdcdyh());
					ywr_2.setId("");
					RegBusYwr ywr_22 = new RegBusYwr();
					ywr_22.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
					ywr_22.setBdcdyh(ywr.getBdcdyh());
					ywr_22.setPcode(ywr.getPcode());
					List<RegBusYwr> ywrlist_22 = regBusYwrService.findList(ywr_22);
					if(ywrlist_22.size() > 0 ){
						ywr_2.setId(ywrlist_22.get(0).getId());
					}
					if(djxl.equals("807") || djxl.equals("804")){
						ywr_2.setQllx("27");
					}else{
						ywr_2.setQllx("24");
					}
					ywr_2.setQszt("1");
					regBusYwrService.save(ywr_2);
				}
				//首次登记
				if(tz.equals("3")){
//					RegBusYwr ywr_2 = new RegBusYwr();
//					BeanUtils.copyProperties(ywr, ywr_2);
//					ywr_2.setSxh(String.valueOf(ywrmcOrderNumber));
//					ywr_2.setBdcdyh(ywr.getBdcdyh());
//					ywr_2.setId("");
//					RegBusYwr ywr_22 = new RegBusYwr();
//					ywr_22.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
//					ywr_22.setBdcdyh(ywr.getBdcdyh());
//					ywr_22.setPcode(ywr.getPcode());
//					List<RegBusYwr> ywrlist_22 = regBusYwrService.findList(ywr_22);
//					if(ywrlist_22.size() > 0 ){
//						ywr_2.setId(ywrlist_22.get(0).getId());
//					}
//					regBusYwrService.save(ywr_2);
				} 
				//修改人员信息的状态为已引用
				if(StringUtils.isNotBlank(ywr.getZjh())){
					RegBasePerson regBasePerson = new RegBasePerson();
					regBasePerson.setZjh(ywr.getZjh());
					regBasePerson.setZjzl(ywr.getZjzl());
					List<RegBasePerson> findPersonList = regBasePersonService.findList(regBasePerson);
					if(findPersonList.size()>0){
						regBasePerson = findPersonList.get(0);
						regBasePerson.setIsaudit("2");
						regBasePersonService.save(regBasePerson);
					}
					
				}
			}
		}
		//获取业务号相同的所有数据
		RegBusHisHouseBdcqzsdjxx hishouse_1 = new RegBusHisHouseBdcqzsdjxx();
		hishouse_1.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
		List<RegBusHisHouseBdcqzsdjxx> hislist = regBusHisHouseBdcqzsdjxxService.findList(hishouse_1);
		int t = hislist.size();
		if(t > 0){
			if(StringUtils.isNotBlank(hislist.get(0).getYwh())){
				RegBaseHbhqk regBaseHbhqk = new RegBaseHbhqk();
				regBaseHbhqk.setYwh(hislist.get(0).getYwh());
				regBaseHbhqkService.deletebyywh(regBaseHbhqk);
			}
			for(int i=0;i<t;i++){
				RegBusHisHouseBdcqzsdjxx hishouse = new RegBusHisHouseBdcqzsdjxx();
				hishouse = hislist.get(i);
				//在做历史转移登记的时候,判断系统中是否有所有权有效数据,有的话就注销掉
				if("302".equals(hishouse.getDjxl())){
					RegBusBdcqzsdjxx regBusBdcqzsdjxx = new RegBusBdcqzsdjxx();
					regBusBdcqzsdjxx.setBdcdyh(hishouse.getBdcdyh());
					regBusBdcqzsdjxx.setIslogout("0");
					regBusBdcqzsdjxx.setRights("1");
					regBusBdcqzsdjxx.setYwh("LS");
					List<RegBusBdcqzsdjxx> listRegBusBdcqzsdjxx = regBusBdcqzsdjxxService.findzyList(regBusBdcqzsdjxx);
					if(listRegBusBdcqzsdjxx.size() > 0){
						regBusBdcqzsdjxx = listRegBusBdcqzsdjxx.get(0);
						bdcdjxx.setOldid(regBusBdcqzsdjxx.getId());
						regBusBdcqzsdjxx.setIslogout("1");
						regBusBdcqzsdjxxService.save(regBusBdcqzsdjxx);
						
						RegBusFdcq2 fdcqold = new RegBusFdcq2();
						fdcqold.setYwh(regBusBdcqzsdjxx.getYwh());
						fdcqold.setBdcdyh(regBusBdcqzsdjxx.getBdcdyh());
						List<RegBusFdcq2> listfdcq2 = regBusFdcq2Service.findList(fdcqold);
						if(listfdcq2.size() > 0){
							fdcqold = listfdcq2.get(0);
							fdcqold.setQszt("2");
							regBusFdcq2Service.save(fdcqold);
						}
						RegBusQlr qlrold = new RegBusQlr();
						qlrold.setYwh(regBusBdcqzsdjxx.getYwh());
						List<RegBusQlr> qlroldlist = regBusQlrService.findList_1(qlrold);
						if(qlroldlist.size() > 0 ){
							for(int y=0;y<qlroldlist.size();y++){
								qlrold = qlroldlist.get(y);
								qlrold.setQszt("2");
								regBusQlrService.save(qlrold);
							}
						}
					}
				}
				if(StringUtils.isNotBlank(hishouse.getYwh())){
					RegBaseH regBaseH = new RegBaseH();
					regBaseH.setBdcdyh(hishouse.getBdcdyh());
					List<RegBaseH>   hlist = regBaseHService.findList(regBaseH);
					if(hlist.size() > 0 ){
						regBaseH = hlist.get(0);
						RegBaseHbhqk regBaseHbhqk_1 = new RegBaseHbhqk();
						regBaseHbhqk_1.setYwh(hishouse.getYwh());
						regBaseHbhqk_1.setHid(regBaseH.getId());
						regBaseHbhqk_1.setOldhid(regBaseH.getId());
						regBaseHbhqk_1.setBdcdyh(hishouse.getBdcdyh());
						regBaseHbhqkService.save(regBaseHbhqk_1);
					}
				}
				RegBusYgdj ygdj_1 = new RegBusYgdj();
				RegBusDyaq dyaq_1 = new RegBusDyaq();
				RegBusFdcq2 fdcq2_1 = new RegBusFdcq2();
				String gyr = "";//共有人名称
				//插入已登记信息
				RegBaseH regBaseH = new RegBaseH();
				regBaseH.setBdcdyh(hishouse.getBdcdyh());
				List<RegBaseH> listh  = regBaseHService.findList(regBaseH);
				if(listh.size() > 0 ){
					regBaseH = listh.get(0);
					if(djxl.equals("207") || djxl.equals("302")) {
						if("0".equals(hishouse.getFwxz()) || "1".equals(hishouse.getFwxz()) || "2".equals(hishouse.getFwxz()) || "5".equals(hishouse.getFwxz()) || "7".equals(hishouse.getFwxz())){
							if(!"7".equals(regBusHisHouseBdcqzsdjxx.getCqly()) && !"8".equals(regBusHisHouseBdcqzsdjxx) && !"9".equals(regBusHisHouseBdcqzsdjxx.getCqly()) && !"15".equals(regBusHisHouseBdcqzsdjxx.getCqly()) && !"19".equals(regBusHisHouseBdcqzsdjxx.getCqly())){
								regBaseH.setQlxz("102");
							}
						}
						if(djxl.equals("302")) {
							regBaseH.setIszy("1");
						}
						regBaseH.setFwyt1(hishouse.getGhyt());
						regBaseH.setRights("2");
						regBaseH.setFwxz(hishouse.getFwxz());
					}
					if(djxl.equals("213") || djxl.equals("804") || djxl.equals("214")  || djxl.equals("215") || djxl.equals("807") || djxl.equals("417")){
						if(djxl.equals("214")  || djxl.equals("215") || djxl.equals("807")){
							regBaseH.setRights("2");
						}else{
							regBaseH.setRights("1");
						}
						regBaseH.setIsdiya("1");
					}
					if(djxl.equals("803")){
						regBaseH.setFwyt1(hishouse.getGhyt());
						regBaseH.setRights("1");
					}
					if(djxl.equals("806")){
						regBaseH.setFwyt1(hishouse.getGhyt());
						regBaseH.setRights("2");
					}
					if(djxl.equals("905")){
						int Ischafeng = 0;
						if (StringUtils.isNotBlank(regBaseH.getIschafeng())) {
							Ischafeng = Integer.parseInt(regBaseH.getIschafeng());
						}
						if(Ischafeng >= 100){
							Ischafeng = Ischafeng+1;
						}else{
							if(Ischafeng == 0){
								Ischafeng = 100;
							}
						}
						regBaseH.setIschafeng(String.valueOf(Ischafeng));
					}
					regBaseHService.save(regBaseH);
				}
				RegBaseC regBaseC =  regBaseCService.get(regBaseH.getCid());
				RegBaseZrz regBaseZrz = regBaseZrzService.get(regBaseC.getZid());
				RegBaseZdjbxx regBaseZdjbxx = new RegBaseZdjbxx();
				//由宗地代码获取宗地信息,确保宗地代码在库里有值时才取宗地信息的值
				String yt ="";
				if(StringUtils.isNotBlank(regBaseZrz.getZddm())){
					regBaseZdjbxx.setZddm(regBaseZrz.getZddm());
					List<RegBaseZdjbxx> zdList = regBaseZdjbxxService.findList(regBaseZdjbxx);
					if(zdList.size()>0){
						regBaseZdjbxx = zdList.get(0);
						if("2".equals(regBaseZrz.getZdftfs())){
							if(djxl.equals("804") || djxl.equals("214")  || djxl.equals("215") || djxl.equals("807") || djxl.equals("417")){
								regBaseZdjbxx.setIsdiya("1");
								regBaseZdjbxxService.save(regBaseZdjbxx);
							}
						}
						yt = DictUtils.getDictLabel(hishouse.getGhyt(), "reg_bus_fwyt", "");
						bdcdjxx.setYt(regBaseZdjbxx.getYt()+"/"+yt);
					}
				}
				bdcdjxx.setQlqtzk(hishouse.getQlqtzk());
				bdcdjxx.setYwh(hishouse.getYwh());
				bdcdjxx.setZddm(regBaseZrz.getZddm());
				bdcdjxx.setBdcdyh(hishouse.getBdcdyh());
				bdcdjxx.setBdcqzh(hishouse.getBdcqzh());
				bdcdjxx.setBdcqzbh(hishouse.getBdcqzbh());
				bdcdjxx.setZl(hishouse.getFdzl());
				bdcdjxx.setQlxz(hishouse.getQlxz());
				bdcdjxx.setMj(regBaseH.getScjzmj()+"");
				bdcdjxx.setSyqx(hishouse.getSyqx());
				bdcdjxx.setPwh(hishouse.getPwh());
				bdcdjxx.setHbjk(hishouse.getHbjk());
				bdcdjxx.setHbhth(hishouse.getHbhth());
		
				bdcdjxx.setZzsj(hishouse.getZzsj());
				
				//填写登记时间
				
				bdcdjxx.setFzsj(DateUtils.formatDate(hishouse.getDjsj()));
				bdcdjxx.setDbsj(DateUtils.formatDate(hishouse.getDjsj()));
				
				
				bdcdjxx.setDjlx(hishouse.getDjxl());
				bdcdjxx.setFj(hishouse.getRemarks()+"/"+hishouse.getFj());
				if(djxl.equals("803") || djxl.equals("806")){
					bdcdjxx.setRights("4");
					bdcdjxx.setQllx("27");
					bdcdjxx.setQlqtzk(null);
				}
				if(djxl.equals("207") || djxl.equals("302")) {
					bdcdjxx.setRights("1");
					bdcdjxx.setQllx(hishouse.getQllx());
				}
				if(djxl.equals("214")  || djxl.equals("215")){
					bdcdjxx.setRights("2");
					bdcdjxx.setQllx("24");
				}
				if(djxl.equals("905")){
					bdcdjxx.setRights("2");
					bdcdjxx.setQllx("26");
				}
				if(djxl.equals("804") || djxl.equals("807")){
					bdcdjxx.setRights("5");
					bdcdjxx.setQllx("27");
				}
				if(djxl.equals("213")){
					bdcdjxx.setRights("5");
					bdcdjxx.setQllx("24");
				}
				bdcdjxx.setStatus("2");
				bdcdjxx.setIshistory("0");
				bdcdjxx.setIslogout("0");
				bdcdjxx.setIsprint("0");
				bdcdjxx.setIsfdsj(Integer.valueOf("0"));
				bdcdjxx.setFj(hishouse.getFj());
				
				bdcdjxx.setId("");
				//插入oldid去关联数据
				//查询当前单元号下的确权情况
				RegBusRights rightsdjxx = new RegBusRights();
				rightsdjxx.setBdcdyh(hishouse.getBdcdyh());
				List<RegBusRights> rightslistdjxx = regBusRightsService.findList(rightsdjxx);
				if(rightslistdjxx.size() > 0 ){
					rightsdjxx = rightslistdjxx.get(0);
					//查询当前单元号是否已经存在登记信息
					RegBusBdcqzsdjxx glregBusBdcqzsdjxx = new RegBusBdcqzsdjxx();
					glregBusBdcqzsdjxx.setBdcdyh(hishouse.getBdcdyh());
					//根据不同登记类型查询不同的登记信息
					if("806".equals(djxl)){
						glregBusBdcqzsdjxx.setYwh(rightsdjxx.getSsouyq());
					}
					if("804".equals(djxl) || "807".equals(djxl)){
						glregBusBdcqzsdjxx.setYwh(rightsdjxx.getXsouyq());
					}
					if("214".equals(djxl)){
						if(StringUtils.isNotBlank(rightsdjxx.getXtxq())){
							glregBusBdcqzsdjxx.setYwh(rightsdjxx.getXtxq());
						}else if(StringUtils.isNotBlank(rightsdjxx.getSsouyq()) && StringUtils.isNotBlank(rightsdjxx.getStxq())){
							glregBusBdcqzsdjxx.setYwh(rightsdjxx.getStxq());
						}else if(StringUtils.isNotBlank(rightsdjxx.getSsouyq()) && StringUtils.isBlank(rightsdjxx.getStxq())){
							glregBusBdcqzsdjxx.setYwh(rightsdjxx.getSsouyq());
						}
					}
					if("215".equals(djxl)){
						if(StringUtils.isNotBlank(rightsdjxx.getXtxq())){
							glregBusBdcqzsdjxx.setYwh(rightsdjxx.getXtxq());
						}else if(StringUtils.isNotBlank(rightsdjxx.getSsouyq())){
							glregBusBdcqzsdjxx.setYwh(rightsdjxx.getSsouyq());
						}
					}
					//像本次审核分叉的登记信息数据oldid中插入此单元号下的上笔id
					List<RegBusBdcqzsdjxx> gllistRegBusBdcqzsdjxx = regBusBdcqzsdjxxService.findzyList(glregBusBdcqzsdjxx);
					if(gllistRegBusBdcqzsdjxx.size() > 0){
						glregBusBdcqzsdjxx = gllistRegBusBdcqzsdjxx.get(0);
						bdcdjxx.setOldid(glregBusBdcqzsdjxx.getId());
					}
				}
				RegBusBdcqzsdjxx djxx = new RegBusBdcqzsdjxx();
				djxx.setYwh(hishouse.getYwh());
				djxx.setBdcdyh(hishouse.getBdcdyh());
				List<RegBusBdcqzsdjxx> djxxlist = regBusBdcqzsdjxxService.findList(djxx);
				int tt = djxxlist.size();
				if(tt > 0 ){
					bdcdjxx.setId(djxxlist.get(0).getId());
				}
				regBusBdcqzsdjxxService.save(bdcdjxx);
				//插入确权表
				if(djxl.equals("803")){
					//插入确权表字段
					RegBusRights rights = new RegBusRights();
					rights.setBdcdyh(hishouse.getBdcdyh());
					List<RegBusRights> rightslist = regBusRightsService.findList(rights);
					if(rightslist.size() > 0 ){
						rights = rightslist.get(0);
						rights.setRemarks(djxl);
						rights.setXsouyq(hishouse.getYwh());
					}else{
						rights.setBdcdyh(hishouse.getBdcdyh());
						rights.setRemarks(djxl);
						rights.setXsouyq(hishouse.getYwh());
						//去重验证
						RegBusRights rightsold = new RegBusRights();
						rightsold.setBdcdyh(hishouse.getBdcdyh());
						List<RegBusRights>  rightsList=  regBusRightsService.findList(rightsold);
						if(rightsList.size() > 0){
							rights.setId(rightsList.get(0).getId());
						}
					}
					regBusRightsService.save(rights);
				}
				if(djxl.equals("806")){
					//插入确权表字段
					RegBusRights rights = new RegBusRights();
					rights.setBdcdyh(hishouse.getBdcdyh());
					List<RegBusRights> rightslist = regBusRightsService.findList(rights);
					if(rightslist.size() > 0 ){
						rights = rightslist.get(0);
						rights.setRemarks(djxl);
						rights.setXsouyq(hishouse.getYwh());
					}else{
						rights.setBdcdyh(hishouse.getBdcdyh());
						rights.setRemarks(djxl);
						rights.setXsouyq(hishouse.getYwh());
						//去重验证
						RegBusRights rightsold = new RegBusRights();
						rightsold.setBdcdyh(hishouse.getBdcdyh());
						List<RegBusRights>  rightsList=  regBusRightsService.findList(rightsold);
						if(rightsList.size() > 0){
							rights.setId(rightsList.get(0).getId());
						}
					}
					regBusRightsService.save(rights);
				}
				if(djxl.equals("207")){
					//插入确权表字段
					RegBusRights rights = new RegBusRights();
					rights.setBdcdyh(hishouse.getBdcdyh());
					List<RegBusRights> rightslist = regBusRightsService.findList(rights);
					if(rightslist.size() > 0 ){
						rights = rightslist.get(0);
						rights.setRemarks(djxl);
						rights.setSsouyq(hishouse.getYwh());
					}else{
						rights.setRemarks(djxl);
						rights.setBdcdyh(hishouse.getBdcdyh());
						rights.setSsouyq(hishouse.getYwh());
						//去重验证
						RegBusRights rightsold = new RegBusRights();
						rightsold.setBdcdyh(hishouse.getBdcdyh());
						List<RegBusRights>  rightsList = regBusRightsService.findList(rightsold);
						if(rightsList.size() > 0){
							rights.setId(rightsList.get(0).getId());
						}
					}
					regBusRightsService.save(rights);
				}
				if(djxl.equals("302")) {
					//插入确权表字段
					RegBusRights rights = new RegBusRights();
					rights.setBdcdyh(hishouse.getBdcdyh());
					List<RegBusRights> rightslist = regBusRightsService.findList(rights);
					if(rightslist.size() > 0 ){
						rights = rightslist.get(0);
						rights.setRemarks(djxl);
						rights.setSsouyq(hishouse.getYwh());
					}else{
						rights.setRemarks(djxl);
						rights.setBdcdyh(hishouse.getBdcdyh());
						rights.setSsouyq(hishouse.getYwh());
						//去重验证
						RegBusRights rightsold = new RegBusRights();
						rightsold.setBdcdyh(hishouse.getBdcdyh());
						List<RegBusRights>  rightsList=  regBusRightsService.findList(rightsold);
						if(rightsList.size() > 0){
							rights.setId(rightsList.get(0).getId());
						}
					}
					regBusRightsService.save(rights);
				}
				if(djxl.equals("214")  || djxl.equals("215")){
					//插入确权表字段
					RegBusRights rights = new RegBusRights();
					rights.setBdcdyh(hishouse.getBdcdyh());
					List<RegBusRights> rightslist = regBusRightsService.findList(rights);
					if(rightslist.size() > 0 ){
						rights = rightslist.get(0);
						rights.setRemarks(djxl);
						rights.setStxq(hishouse.getYwh());
					}else{
						rights.setBdcdyh(hishouse.getBdcdyh());
						rights.setRemarks(djxl);
						rights.setStxq(hishouse.getYwh());
						//去重验证
						RegBusRights rightsold = new RegBusRights();
						rightsold.setBdcdyh(hishouse.getBdcdyh());
						List<RegBusRights>  rightsList=  regBusRightsService.findList(rightsold);
						if(rightsList.size() > 0){
							rights.setId(rightsList.get(0).getId());
						}
					}
					regBusRightsService.save(rights);
				}
				if(djxl.equals("213")){
					//插入确权表字段
					RegBusRights rights = new RegBusRights();
					rights.setBdcdyh(hishouse.getBdcdyh());
					List<RegBusRights> rightslist = regBusRightsService.findList(rights);
					if(rightslist.size() > 0 ){
						rights = rightslist.get(0);
						rights.setRemarks(djxl);
						rights.setXtxq(hishouse.getYwh());
					}else{
						rights.setBdcdyh(hishouse.getBdcdyh());
						rights.setRemarks(djxl);
						rights.setXtxq(hishouse.getYwh());
						//去重验证
						RegBusRights rightsold = new RegBusRights();
						rightsold.setBdcdyh(hishouse.getBdcdyh());
						List<RegBusRights>  rightsList=  regBusRightsService.findList(rightsold);
						if(rightsList.size() > 0){
							rights.setId(rightsList.get(0).getId());
						}
					}
					regBusRightsService.save(rights);
				}
				if(djxl.equals("807")){
					//插入确权表字段
					RegBusRights rights = new RegBusRights();
					rights.setBdcdyh(hishouse.getBdcdyh());
					List<RegBusRights> rightslist = regBusRightsService.findList(rights);
					if(rightslist.size() > 0 ){
						rights = rightslist.get(0);
						rights.setRemarks(djxl);
						rights.setXtxq(hishouse.getYwh());
					}else{
						rights.setBdcdyh(hishouse.getBdcdyh());
						rights.setRemarks(djxl);
						rights.setXtxq(hishouse.getYwh());
						//去重验证
						RegBusRights rightsold = new RegBusRights();
						rightsold.setBdcdyh(hishouse.getBdcdyh());
						List<RegBusRights>  rightsList=  regBusRightsService.findList(rightsold);
						if(rightsList.size() > 0){
							rights.setId(rightsList.get(0).getId());
						}
					}
					regBusRightsService.save(rights);
				}
				
				if(djxl.equals("804")){
					//插入确权表字段
					RegBusRights rights = new RegBusRights();
					rights.setBdcdyh(hishouse.getBdcdyh());
					List<RegBusRights> rightslist = regBusRightsService.findList(rights);
					if(rightslist.size() > 0 ){
						rights = rightslist.get(0);
						rights.setRemarks(djxl);
						rights.setXtxq(hishouse.getYwh());
					}else{
						rights.setBdcdyh(hishouse.getBdcdyh());
						rights.setRemarks(djxl);
						rights.setXtxq(hishouse.getYwh());
						//去重验证
						RegBusRights rightsold = new RegBusRights();
						rightsold.setBdcdyh(hishouse.getBdcdyh());
						List<RegBusRights>  rightsList=  regBusRightsService.findList(rightsold);
						if(rightsList.size() > 0){
							rights.setId(rightsList.get(0).getId());
						}
					}
					regBusRightsService.save(rights);
				}
				//开始分插数据
				//首先在每个判断中获取已选择数据的业务号和不动产单元号,通过其去查询对应权属表中的对应数据
				if(djxl.equals("803") || djxl.equals("806")){
					RegBusHisHouseYwr ywrold = new RegBusHisHouseYwr();
					ywrold.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
					List<RegBusHisHouseYwr> ywrlistold = regBusHisHouseYwrService.findList(ywrold);//获取权利人子表数据
					if(ywrlistold.size() > 0 ){
						for(int yi=0;yi<ywrlistold.size();yi++){
							ywrold = ywrlistold.get(yi);
							if("1".equals(ywrold.getSxh())){
								ygdj_1.setYwr(ywrold.getQlrmc());
								ygdj_1.setYwrzjzl(ywrold.getZjzl());
								ygdj_1.setYwrzjh(ywrold.getZjh());
							}
						}
					}
					//获取选择已登记信息的对应的预告权属信息
					ygdj_1.setYsdm(hishouse.getYsdm());
					ygdj_1.setBdcdyh(hishouse.getBdcdyh());
					ygdj_1.setYwh(hishouse.getYwh());
					ygdj_1.setBdczl(hishouse.getFdzl());
					ygdj_1.setYgdjzl(hishouse.getYgdjzl());
					ygdj_1.setDjlx(hishouse.getDjlx());
					ygdj_1.setDjyy(hishouse.getDjyy());
					
					String yggyrmc = "";
					RegBusHisHouseQlr ygqlr = new RegBusHisHouseQlr();
					ygqlr.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
					List<RegBusHisHouseQlr> ygdjqlrlist = regBusHisHouseQlrService.findList(ygqlr);//获取权利人子表数据
					for(int y=0;y<ygdjqlrlist.size();y++){
						yggyrmc += ygdjqlrlist.get(y).getQlrmc()+"; ";
					}
					ygdj_1.setTdsyqr(yggyrmc);
					ygdj_1.setGhyt(hishouse.getGhyt());
					ygdj_1.setFwxz(hishouse.getFwxz());
					ygdj_1.setFwjg(hishouse.getFwjg());
					ygdj_1.setSzc(String.valueOf(hishouse.getSzc()));
					ygdj_1.setZcs(String.valueOf(hishouse.getZcs()));
					ygdj_1.setJzmj(hishouse.getJzmj());
					if(hishouse.getQdjg() != null && !hishouse.getQdjg().equals("")){
						ygdj_1.setQdjg(Double.parseDouble(hishouse.getQdjg().toString()));
					}
					ygdj_1.setBdcdjzmh(hishouse.getBdcqzh());
					ygdj_1.setQxdm(hishouse.getQxdm());
					ygdj_1.setDjjg(hishouse.getDjjg());
					ygdj_1.setDbr(hishouse.getDbr());
					ygdj_1.setDjsj(hishouse.getDjsj());
					ygdj_1.setFj(hishouse.getFj());
					ygdj_1.setQszt("1");
					ygdj_1.setIsfdsj(0);
					ygdj_1.setHtbh(hishouse.getHtbh());
					ygdj_1.setId("");
					ygdj_1.setYtmc(DictUtils.getDictLabel(ygdj_1.getGhyt(), "reg_bus_fwyt", ""));
					ygdj_1.setFwxzmc(DictUtils.getDictLabel(ygdj_1.getFwxz(), "reg_bus_fwxz", ""));
					RegBusYgdj yg = new RegBusYgdj();
					yg.setYwh(hishouse.getYwh());
					yg.setBdcdyh(hishouse.getBdcdyh());
					List<RegBusYgdj> yglist = regBusYgdjService.findList(yg);
					int t1 = yglist.size();
					if(t1 > 0 ){
						ygdj_1.setId(yglist.get(0).getId());
					}
					regBusYgdjService.save(ygdj_1);
				}
				
				if(djxl.equals("213") || djxl.equals("804") || djxl.equals("214")  || djxl.equals("215") || djxl.equals("807") || djxl.equals("417")){
				 //在建工程抵押,房屋抵押预告登记,房屋一般抵押,房屋最高额抵押,房屋抵押预告登记 reg_bus_dyaq 字段抵押权人就是权利人
					RegBusHisHouseQlr qlrdy = new RegBusHisHouseQlr();
					qlrdy.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
					List<RegBusHisHouseQlr> qlrlistdy = regBusHisHouseQlrService.findList(qlrdy);//获取权利人子表数据
					String qlrmcdy = "";
					String gyrmcdy = "";
					if(qlrlist.size() > 0 ){
						for(int qi=0;qi<qlrlist.size();qi++){
							qlrdy = qlrlistdy.get(qi);
							if(qlrlist.get(qi).getSxh().equals("1")){
								qlrmcdy = qlrlist.get(qi).getQlrmc();
								dyaq_1.setDyqr(qlrmcdy);
							}else{
								gyrmcdy += qlrlist.get(qi).getQlrmc()+"; ";
							}
						}
					}
					
					//分叉数据到义务人表
					RegBusHisHouseYwr ywrnew = new RegBusHisHouseYwr();
					ywrnew.setYwh(hishouse.getYwh());
					ywrnew.setBdcdyh(hishouse.getBdcdyh());
					String ywrmcdy="";
					String ywrgyrmcdy="";
					List<RegBusHisHouseYwr> ywrlistnew = regBusHisHouseYwrService.findList(ywrnew);
					if(ywrlistnew.size() > 0 ){
						for(int qi=0;qi<ywrlistnew.size();qi++){
							ywrnew = ywrlistnew.get(qi);
							if(ywrnew.getSxh().equals("1")){
								ywrmcdy = ywrnew.getQlrmc();
							}else{
								ywrgyrmcdy +=ywrnew.getQlrmc()+"; ";
							}
						}
					}
					dyaq_1.setDjlx(hishouse.getDjlx());
					dyaq_1.setDyr(ywrmc);
					dyaq_1.setDygyr(ywrgyrmcdy);
					dyaq_1.setBdcdyh(hishouse.getBdcdyh());
					dyaq_1.setZwr(hishouse.getZwr());
					dyaq_1.setYsdm("6001010000");
					dyaq_1.setPgjz(hishouse.getPgjz());
					dyaq_1.setPgjzhj(hishouse.getPgjzhj());
					dyaq_1.setJzmjhj(hishouse.getJzmjhj());
					dyaq_1.setZwrzjh(hishouse.getZwrzjh());
					dyaq_1.setZwrzjzl(hishouse.getZwrzjzl());
					dyaq_1.setYwh(hishouse.getYwh());
					dyaq_1.setDybdclx(hishouse.getDybdclx());
					dyaq_1.setZjjzwzl(hishouse.getFdzl());
					if(hishouse.getDyfs() != null && !hishouse.getDyfs().equals("")){
						dyaq_1.setDyfs(hishouse.getDyfs());
					}
					if(hishouse.getDbze() != null && !hishouse.getDbze().equals("") && "1".equals(hishouse.getDyfs())){
						dyaq_1.setDbze(hishouse.getDbze());
						if(t > 1){
							dyaq_1.setBdbzzqse(Double.valueOf("0.0"));
						}else{
							dyaq_1.setBdbzzqse(hishouse.getDbze());
						}
					}
					dyaq_1.setDjlx(hishouse.getDjlx());
					if(hishouse.getDjyy() != null && !hishouse.getDjyy().equals("")){
						dyaq_1.setDjyy(hishouse.getDjyy());
					}
					dyaq_1.setZjjzwdyfw(hishouse.getZjjzwdyfw());
					dyaq_1.setZwlxqssj(hishouse.getZwlxqssj());
					dyaq_1.setZwlxjssj(hishouse.getZwlxjssj());
					dyaq_1.setZgzqqdss(hishouse.getZgzqqdss());
					if(hishouse.getZgzqse() != null && !hishouse.getZgzqse().equals("") && "2".equals(hishouse.getDyfs())){
						dyaq_1.setZgzqse(Double.parseDouble(hishouse.getZgzqse().toString()));
					}
					
					dyaq_1.setZxdyywh(hishouse.getZxdyywh());
					dyaq_1.setZxdyyy(hishouse.getZxdyyy());
					dyaq_1.setZxsj(hishouse.getZxsj());
					dyaq_1.setQxdm(hishouse.getQxdm());
					dyaq_1.setDjjg(hishouse.getDjjg());
					dyaq_1.setDbr(hishouse.getDbr());
					dyaq_1.setDjsj(hishouse.getDjsj());
					dyaq_1.setFj(hishouse.getFj());
					dyaq_1.setQszt("1");
					dyaq_1.setTdzh(hishouse.getBdcqzh());
					dyaq_1.setDyqr(qlr.getQlrmc());//抵押权人就是权利人名称
					dyaq_1.setRemarks(hishouse.getRemarks());
					dyaq_1.setDjyy(hishouse.getDjyy());
					dyaq_1.setFj(hishouse.getFj());
					dyaq_1.setZjjzwzl(hishouse.getZjjzwzl());
					dyaq_1.setBdcdjzmh(hishouse.getBdcqzh());
					dyaq_1.setTdzh(hishouse.getTdzh());
					dyaq_1.setIsfdsj(0);
					dyaq_1.setId("");
					RegBusDyaq dy = new RegBusDyaq();
					dy.setYwh(hishouse.getYwh());
					dy.setBdcdyh(hishouse.getBdcdyh());
					List<RegBusDyaq> dylist = regBusDyaqService.findList(dy);
					int t2 = dylist.size();
					if(t2 > 0 ){
						dyaq_1.setId(dylist.get(0).getId());
					}
					regBusDyaqService.save(dyaq_1);
				}
				if(djxl.equals("207") || djxl.equals("302")){
					//获取选择已登记信息的对应的房屋所有权权属信息
					fdcq2_1.setYsdm(hishouse.getYsdm());
					fdcq2_1.setBdcdyh(hishouse.getBdcdyh());
					fdcq2_1.setYwh(hishouse.getYwh());
					fdcq2_1.setQllx(hishouse.getQllx());
					fdcq2_1.setDjlx(hishouse.getDjlx());
					fdcq2_1.setDjyy(hishouse.getDjyy());
					fdcq2_1.setFdzl(hishouse.getFdzl());
					if("302".equals(djxl) || "207".equals(djxl)){
						String yggyrmc = "";
						RegBusHisHouseQlr ygqlr = new RegBusHisHouseQlr();
						ygqlr.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
						List<RegBusHisHouseQlr> ygdjqlrlist = regBusHisHouseQlrService.findList(ygqlr);//获取权利人子表数据
						for(int y=0;y<ygdjqlrlist.size();y++){
							yggyrmc += ygdjqlrlist.get(y).getQlrmc()+"; ";
						}
						fdcq2_1.setTdsyqr(yggyrmc);
					}
					fdcq2_1.setCqly(hishouse.getCqly());
					fdcq2_1.setYwxl(hishouse.getYwxl());
					fdcq2_1.setDytdmj(hishouse.getDytdmj());
					fdcq2_1.setFttdmj(hishouse.getFttdmj());
					fdcq2_1.setTdsyqssj(hishouse.getTdsyqssj());
					fdcq2_1.setTdsyjssj(hishouse.getTdsyjssj());
					fdcq2_1.setFdcjyjg(hishouse.getFdcjyjg());
					fdcq2_1.setGhyt(hishouse.getGhyt());
					fdcq2_1.setFwxz(hishouse.getFwxz());
					fdcq2_1.setFwjg(hishouse.getFwjg());
					if(hishouse.getSzc() != null){
						fdcq2_1.setSzc(hishouse.getSzc());
					}
					if(hishouse.getZcs() != null){
						fdcq2_1.setZcs(Integer.parseInt(String.valueOf(hishouse.getZcs())));
					}
					fdcq2_1.setJzmj(hishouse.getJzmj());
					fdcq2_1.setZyjzmj(hishouse.getZyjzmj());
					fdcq2_1.setFtjzmj(hishouse.getFtjzmj());
					fdcq2_1.setJgsj(DateUtils.formatDate(hishouse.getJgsj(), "yyyy-MM-dd"));
					fdcq2_1.setBdcqzh(hishouse.getBdcqzh());
					if(djxl.equals("207")) {
						fdcq2_1.setYbdcqzh(hishouse.getBdcqzh());
						//反写幢的竣工日期
						RegBaseZrz zrz = new RegBaseZrz();
						String dyh = hishouse.getBdcdyh().substring(0,24);
						zrz.setBdcdyh(dyh);
						List<RegBaseZrz> findZrzList = regBaseZrzService.findList(zrz);
						if(findZrzList.size() > 0 ){
							zrz = findZrzList.get(0);
							zrz.setJgrq(hishouse.getJgsj());
							regBaseZrzService.save(zrz);
						}
					}
					fdcq2_1.setQxdm(hishouse.getQxdm());
					fdcq2_1.setDjjg(hishouse.getDjjg());
					fdcq2_1.setDbr(hishouse.getDbr());
					fdcq2_1.setDjsj(hishouse.getDjsj());
					fdcq2_1.setFj(hishouse.getFj());
					fdcq2_1.setQszt("1");
					fdcq2_1.setRemarks(hishouse.getRemarks());
					fdcq2_1.setDjyy(hishouse.getDjyy());
					fdcq2_1.setFj(hishouse.getFj());
					fdcq2_1.setYtmc(DictUtils.getDictLabel(hishouse.getGhyt(), "reg_bus_fwyt", ""));
					fdcq2_1.setFwxzmc(DictUtils.getDictLabel(hishouse.getFwxz(), "reg_bus_fwxz", ""));
					fdcq2_1.setId("");
					if(djxl.equals("207")){
						fdcq2_1.setZdftfs(regBaseZrz.getZdftfs());
					}
					if(djxl.equals("302")){
						fdcq2_1.setZdftfs(hishouse.getZdftfs());
					}
					RegBusFdcq2 fd = new RegBusFdcq2();
					fd.setYwh(hishouse.getYwh());
					fd.setBdcdyh(hishouse.getBdcdyh());
					List<RegBusFdcq2> fdlist = regBusFdcq2Service.findList(fd);
					int t3 = fdlist.size();
					if(t3 > 0 ){
						fdcq2_1.setId(fdlist.get(0).getId());
					}
					regBusFdcq2Service.save(fdcq2_1);
				}
				//查封登记
				if(djxl.equals("905")){
					//获取选择已登记信息的对应的房屋所有权权属信息
					RegBusHisHouseCfdj regBusHisCfdj = new RegBusHisHouseCfdj();
					regBusHisCfdj.setYwh(hishouse.getYwh());
					regBusHisCfdj.setBdcdyh(hishouse.getBdcdyh());
					List<RegBusHisHouseCfdj> cfdjlist = regBusHisHouseCfdjService.findList(regBusHisCfdj);
					if(cfdjlist.size()>0) {
					regBusHisCfdj = cfdjlist.get(0);
					RegBusCfdj cfdj = new RegBusCfdj();
					cfdj.setBdcdyh(regBusHisCfdj.getBdcdyh());
					cfdj.setBz(regBusHisCfdj.getBz());
					cfdj.setCffw(regBusHisCfdj.getCffw());
					cfdj.setCfjg(regBusHisCfdj.getCfjg());
					cfdj.setCfjssj(regBusHisCfdj.getCfjssj());
					cfdj.setCflx(regBusHisCfdj.getCflx());
					cfdj.setCfqssj(regBusHisCfdj.getCfqssj());
					cfdj.setCfwh(regBusHisCfdj.getCfwh());
					cfdj.setCfwj(regBusHisCfdj.getCfwj());
					cfdj.setDbr(regBusHisCfdj.getDbr());
					cfdj.setDjjg(regBusHisCfdj.getDjjg());
					cfdj.setDjlx(regBusHisCfdj.getDjlx());
					cfdj.setDjsj(regBusHisCfdj.getDjsj());
					cfdj.setFj(regBusHisCfdj.getFj());
					cfdj.setYwh(regBusHisCfdj.getYwh());
					cfdj.setYsdm(regBusHisCfdj.getYsdm());
					cfdj.setQxdm(regBusHisCfdj.getQxdm());
					cfdj.setQszt(regBusHisCfdj.getQszt());
					regBusCfdjService.save(cfdj);
					}
					
				}
				
				//设置该数据已经被审核
				hishouse.setIsaudit("1");
				regBusHisHouseBdcqzsdjxxService.save(hishouse);
			}
			//循环结束
			addMessage(redirectAttributes, "不动产登记历史数据审核成功!");
			//最后再次查重只针对登记信息和确权就可以确定是否有重复数据了
			for(int i=0;i<hislist.size();i++){
				RegBusHisHouseBdcqzsdjxx hishouse = hislist.get(i);
				//确权信息
				RegBusRights rig = new RegBusRights();
				rig.setBdcdyh(hishouse.getBdcdyh());
				List<RegBusRights> riglist = regBusRightsService.findList(rig);
				//登记信息
				RegBusBdcqzsdjxx djxx = new RegBusBdcqzsdjxx();
				djxx.setYwh(hishouse.getYwh());
				djxx.setBdcdyh(hishouse.getBdcdyh());
				List<RegBusBdcqzsdjxx> djxxlist = regBusBdcqzsdjxxService.findList(djxx);
				if(djxxlist.size() >= 2 || riglist.size() >= 2){
					cfbz = 1;
					break;
				}
			}
			if(StringUtils.isNotBlank(request.getParameter("ywh"))){
				System.out.println(request.getParameter("ywh"));
			}
			if(StringUtils.isNotBlank(request.getParameter("bdcqzh"))){
				System.out.println(request.getParameter("bdcqzh"));
			}
			if(StringUtils.isNotBlank(request.getParameter("bdcdyh"))){
				System.out.println(request.getParameter("bdcdyh"));
			}
			if(StringUtils.isNotBlank(request.getParameter("fdzl"))){
				System.out.println(request.getParameter("fdzl"));
			}
			if(StringUtils.isNotBlank(request.getParameter("jzmj"))){
				System.out.println(request.getParameter("jzmj"));
			}
				
			if(tz.equals("1")){
				vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listYG?VIEWS=1&ywhhz="+regBusHisHouseBdcqzsdjxx.getYwh()+"&isbatch="+request.getParameter("isbatch")+"&cfbz="+cfbz+"&ywh="+request.getParameter("paraywh")+"&bdcqzh="+request.getParameter("parabdcqzh")+"&bdcdyh="+request.getParameter("parabdcdyh")+"&fdzl="+request.getParameter("parafdzl")+"&jzmj="+request.getParameter("parajzmj");
			}
			if(tz.equals("2")){
				vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listDY?VIEWS=1&ywhhz="+regBusHisHouseBdcqzsdjxx.getYwh()+"&isbatch="+request.getParameter("isbatch")+"&cfbz="+cfbz+"&ywh="+request.getParameter("paraywh")+"&bdcqzh="+request.getParameter("parabdcqzh")+"&bdcdyh="+request.getParameter("parabdcdyh")+"&fdzl="+request.getParameter("parafdzl")+"&jzmj="+request.getParameter("parajzmj");
			}
			if(tz.equals("3")){
				vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listSC?VIEWS=1&ywhhz="+regBusHisHouseBdcqzsdjxx.getYwh()+"&isbatch="+request.getParameter("isbatch")+"&cfbz="+cfbz+"&ywh="+request.getParameter("paraywh")+"&bdcqzh="+request.getParameter("parabdcqzh")+"&bdcdyh="+request.getParameter("parabdcdyh")+"&fdzl="+request.getParameter("parafdzl")+"&jzmj="+request.getParameter("parajzmj");
			}
			if(tz.equals("4")){
				vie =  "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/listCF?VIEWS=1&ywhhz="+regBusHisHouseBdcqzsdjxx.getYwh()+"&isbatch="+request.getParameter("isbatch")+"&cfbz="+cfbz+"&ywh="+request.getParameter("paraywh")+"&bdcqzh="+request.getParameter("parabdcqzh")+"&bdcdyh="+request.getParameter("parabdcdyh")+"&fdzl="+request.getParameter("parafdzl")+"&jzmj="+request.getParameter("parajzmj");
			}
		}
		return vie;
	}
	
	
	/**
	 * @param regBusHisHouseBdcqzsdjxx
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "hishouseformgageGuide")
	public String hishouseformgageGuide(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx, HttpServletRequest request, HttpServletResponse response, Model model) {
		String ywh = request.getParameter("YWH");
		if(StringUtils.isNotBlank(request.getParameter("YWH"))){
			model.addAttribute("YWH", request.getParameter("YWH"));
		}
		String ifm = request.getParameter("ifm");
		if(StringUtils.isNotBlank(ifm)){//ifm 如果有值		代表是iframe刷新 	父页面不变
			regBusHisHouseBdcqzsdjxx.setYwh(ywh);
			regBusHisHouseBdcqzsdjxx.setDjxl("4");//登记类型为4筛选出未添加抵押人的房屋
			Page<RegBusHisHouseBdcqzsdjxx> page = regBusHisHouseBdcqzsdjxxService.findPage(new Page<RegBusHisHouseBdcqzsdjxx>(request, response), regBusHisHouseBdcqzsdjxx); 
			model.addAttribute("page", page);
			return "modules/reg/bus/dyhishouseformgageGuideifm";
		}else{
			return "modules/reg/bus/dyhishouseformgageGuide";
		}
	}
	/**
	 * 房屋历史登记多条数据添加激发事件
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "dyhishousegetInfoxf")
	@ResponseBody
	public ModelMap dyhishousegetInfoxf(HttpServletRequest request) {
		String ids = request.getParameter("id");
		String[] idList = ids.split(";");
		RegBusHisHouseBdcqzsdjxx entity = null;
		ModelMap modelMap = new ModelMap();
		StringBuilder strBd = new StringBuilder();
		String bdcdyh = "";
		String ywh = "";
		if (StringUtils.isNotBlank(ids)){
			for(String id : idList){
				entity = regBusHisHouseBdcqzsdjxxService.get(id);
				strBd.append("<tr>")
						.append("<td id="+"id "+"style="+"display:none;"+">").append(entity.getId()).append("</td>")
						.append("<td>").append(entity.getYwh()).append("</td>")
						.append("<td>").append(entity.getBdcdyh()).append("</td>")
						.append("<td>").append(entity.getFdzl()).append("</td>")
						.append("</tr>");
				if(StringUtils.isNotBlank(bdcdyh)){
					bdcdyh += ";"+entity.getBdcdyh();
				}else {
					bdcdyh = entity.getBdcdyh();
				}
				if(StringUtils.isNotBlank(ywh)){
					ywh += ";"+entity.getYwh();
				}else {
					ywh = entity.getYwh();
				}
			}
			modelMap.put("data", strBd.toString());
			modelMap.put("bdcdyh", bdcdyh);
			modelMap.put("ywh", ywh);
		}
		return modelMap;
	}
	
	
	/**
	 * 房屋历史入口重复验证
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "infoquery")
	@ResponseBody
	public ModelMap infoquery(HttpServletRequest request) {
		ModelMap modelMap = new ModelMap();
		modelMap.put("success", 0);
		String bz = "0";
		String ids = request.getParameter("selectedIDs");
		String ywh = request.getParameter("YWH");
		String djlx = request.getParameter("djlx");
		//首先获取通过楼盘已选择的房屋信息列表
		//选择的 房屋信息
		String[] idList = ids.split(";");
		RegBaseH regBaseH  =  new RegBaseH();
		for(String fwid : idList){
			regBaseH  = regBaseHService.get(fwid);
			if(!"207".equals(djlx)){
				//查询宗地是否抵押
				if("0".equals(bz)){
					RegBaseZdjbxx  zdjbxx = new RegBaseZdjbxx();
					zdjbxx.setZddm(regBaseH.getBdcdyh().substring(0,19));
					List<RegBaseZdjbxx> zdjbxxlist = regBaseZdjbxxService.findList(zdjbxx);
					if(zdjbxxlist.size() > 0){
						zdjbxx = zdjbxxlist.get(0);
						if("1".equals(zdjbxx.getIsdiya())){
							modelMap.put("success",1);
							modelMap.put("msg", "不动产单元为:"+regBaseH.getBdcdyh()+"所属的宗地为抵押状态,不能继续办理!");
							break;
						}
						bz = "1";
					}
				}
			}
			String success = modelMap.get("success").toString();
			RegBusBdcqzsdjxx regBusBdcqzsdjxx = new RegBusBdcqzsdjxx();
			regBusBdcqzsdjxx.setBdcdyh(regBaseH.getBdcdyh());
			regBusBdcqzsdjxx.setIslogout("0");//未注销
			regBusBdcqzsdjxx.setDelFlag("0");
			regBusBdcqzsdjxx.setFzsj("ISNULL");
			List<RegBusBdcqzsdjxx> regBusBdcqzsdjxxlist = regBusBdcqzsdjxxService.findList(regBusBdcqzsdjxx);
			if(regBusBdcqzsdjxxlist.size() > 0){
				regBusBdcqzsdjxx = regBusBdcqzsdjxxlist.get(0);
				String djxl = DictUtils.getDictLabel(regBusBdcqzsdjxxlist.get(0).getDjlx(),"reg_bus_djxl", "");
				modelMap.put("success", 1);
				modelMap.put("msg", "不动产单元为:"+regBusBdcqzsdjxx.getBdcdyh()+"的不动产登记信息正在办理:("+djxl+")业务,请您办结本次业务或删除后重新办理!");
				break;
			}
			
//			RegBusBdcqzsdjxx regBusBdcqzsdjxx_1 = new RegBusBdcqzsdjxx();
//			regBusBdcqzsdjxx_1.setBdcdyh(regBaseH.getBdcdyh());
//			regBusBdcqzsdjxx_1.setIslogout("0");
//			regBusBdcqzsdjxx_1.setYwh("L");
//			List<RegBusBdcqzsdjxx> regBusBdcqzsdjxxlist_1 = regBusBdcqzsdjxxService.findList(regBusBdcqzsdjxx_1);
//			if(regBusBdcqzsdjxxlist_1.size() > 0){
//				regBusBdcqzsdjxx_1 = regBusBdcqzsdjxxlist_1.get(0);
//				modelMap.put("success", 1);
//				modelMap.put("msg", "不动产单元为:"+regBusBdcqzsdjxx.getBdcdyh()+"的房屋在系统中已存在办理业务,不能进行历史录入!");
//				break;
//			}
			
			if("0".equals(success)){
				RegBusHisHouseBdcqzsdjxx djxx = new RegBusHisHouseBdcqzsdjxx();
				djxx.setDjxl("4");
				djxx.setBdcdyh(regBaseH.getBdcdyh());
				List<RegBusHisHouseBdcqzsdjxx> djxxlist = regBusHisHouseBdcqzsdjxxService.findList(djxx);
				if(djxxlist.size() > 0){
					djxx = djxxlist.get(0);
					String djxl = DictUtils.getDictLabel(djxx.getDjxl(),"reg_bus_djxl", "");
					modelMap.put("success", 1);
					modelMap.put("msg", "不动产单元为:"+djxx.getBdcdyh()+"的不动产登记信息正在办理历史入口:("+djxl+")业务,不能继续办理,请您办结本次业务或删除后重新办理!");
					break;
				}else{
					modelMap.put("success", 0);
				}
			}
		}
        return modelMap;
	}
	
	/***
	* @Title: getNextYwh 
	* @Description: 获取并生成业务号 
	* @param @return    设定文件 
	* @return String    返回类型 
	* @throws
	 */
	public synchronized String getNextYwhs() {
		String maxYwh = regBusBdcqzsdjxxService.findMaxYwhLs();
		if(StringUtils.isNotBlank(maxYwh) && DateUtils.getDate("yyyyMMdd").equals(maxYwh.substring(2, 10))){
			maxYwh = maxYwh.substring(2, 14);
		}else{
			maxYwh =  DateUtils.getDate("yyyyMMdd") + "0000";
		}
		String nextYwh = DateUtils.getDate("yyyyMMdd") + "0001";
		//如果数据里的最大业务号不为空,就取出来进行处理;否则直接默认值
		if(StringUtils.isNotBlank(maxYwh)){
			//如果当前日期字符串等于数据库里最大业务号前面的日期字符串,那只要顺序往上加就好;否则直接默认值
			if(DateUtils.getDate("yyyyMMdd").equals(maxYwh.substring(0, 8))){
				int nextSerNum = Integer.parseInt(maxYwh.substring(8)) + 1;
				if (nextSerNum < 10) {
					nextYwh = DateUtils.getDate("yyyyMMdd") + "000" + nextSerNum;
				}else if (nextSerNum > 9 && nextSerNum < 100) {
					nextYwh = DateUtils.getDate("yyyyMMdd") + "00" + nextSerNum;
				}else if (nextSerNum > 99 && nextSerNum < 1000) {
					nextYwh = DateUtils.getDate("yyyyMMdd") + "0" + nextSerNum;
				}else {
					nextYwh = DateUtils.getDate("yyyyMMdd") + nextSerNum;
				}
			}
		}
		System.out.println(nextYwh);
		return  nextYwh;
	}
	
	
	/**
	 * 限制首次登记是否能够保存业务数据
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusBdcqzsdjxx:view")
	@RequestMapping(value = "scinfoquery")
	@ResponseBody
	public ModelMap scinfoquery(HttpServletRequest request) {
		String bdcdyh = "";
		String djlx = "";
		String id = "";
		if(StringUtils.isNotBlank(request.getParameter("selectedIDs"))){
			id = request.getParameter("selectedIDs");
		}
		if(StringUtils.isNotBlank(request.getParameter("bdcdyh"))){
			bdcdyh = request.getParameter("bdcdyh");
		}
		if(StringUtils.isNotBlank(request.getParameter("djlx"))){
			djlx = request.getParameter("djlx");
		}
		String[] ids = id.split(";");
		ModelMap modelMap = new ModelMap();
		modelMap.put("success", 0);
		if("207".equals(djlx)){
			for(String fwid : ids){
				RegBaseH regBaseH = regBaseHService.get(fwid);
				RegBusHisHouseBdcqzsdjxx hisdjxx = new RegBusHisHouseBdcqzsdjxx();
				hisdjxx.setBdcdyh(regBaseH.getBdcdyh());
				hisdjxx.setDjxl("207");
				List<RegBusHisHouseBdcqzsdjxx> lists = regBusHisHouseBdcqzsdjxxService.findList(hisdjxx);
				if(lists.size() > 0 ){
					modelMap.put("success", 1);
					modelMap.put("bdcdyh", regBaseH.getBdcdyh());
					break;
				}
			}
		}
		return modelMap;
	}
	
	
	/**
	 * 首先保存测绘信息到大表,锁定业务号
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "unaudit")
	@ResponseBody
	public  ModelMap unaudit(HttpServletRequest request,Model model) {
		String ids = request.getParameter("ids");
		ModelMap modelMap = new ModelMap();
		RegBusHisHouseBdcqzsdjxx hisdjxx =  regBusHisHouseBdcqzsdjxxService.get(ids);
		//首次反审核
		if(hisdjxx.getDjxl().equals("207")) {
		try {
			regBusHisHouseBdcqzsdjxxService.unaudit(hisdjxx);
			modelMap.put("success", 0);
		} catch (Exception e) {
			modelMap.put("success", 1);
			modelMap.put("msg", e.getMessage());
		}
		}else if(hisdjxx.getDjxl().equals("302")) {
			try {
				regBusHisHouseBdcqzsdjxxService.unauditZY(hisdjxx);
				modelMap.put("success", 0);
			} catch (Exception e) {
				modelMap.put("success", 1);
				modelMap.put("msg", e.getMessage());
			}
		}
		return modelMap;
	}
	
	/**
	 * 房屋历史审核数据全部审核
	 * @param regBusHisHouseBdcqzsdjxx
	 * @param request
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:edit")
	@RequestMapping(value = "auditall")
	@ResponseBody
	public synchronized ModelMap auditall(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx,HttpServletRequest request,  RedirectAttributes redirectAttributes) {
		String djxl = regBusHisHouseBdcqzsdjxx.getDjxl();
		ModelMap modelmap=new ModelMap();
		modelmap.put("success", "0");
		//获取批量审核下的改小区的所有的户信息
		RegBusHisHouseBdcqzsdjxx djxxhis = new RegBusHisHouseBdcqzsdjxx();
		djxxhis.setIsaudit("0");
		List<RegBusHisHouseBdcqzsdjxx> djxxhislist = regBusHisHouseBdcqzsdjxxService.findList(djxxhis);
		int counthis = djxxhislist.size();
		for(int h=0;h<counthis;h++){
			djxxhis = djxxhislist.get(h);
			regBusHisHouseBdcqzsdjxx.setYwh(djxxhis.getYwh());
			regBusHisHouseBdcqzsdjxx.setQllx(djxxhis.getQllx());
			regBusHisHouseBdcqzsdjxx.setCqly(djxxhis.getCqly());
			djxl = djxxhis.getDjxl();
			RegBusBdcqzsdjxx bdcdjxx = new RegBusBdcqzsdjxx();
			RegBusHisHouseQlr qlr = new RegBusHisHouseQlr();
			qlr.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
			List<RegBusHisHouseQlr> qlrlist = regBusHisHouseQlrService.findList(qlr);//获取权利人子表数据
			String qlrmc = "";
			String gyrmc = "";
			String ywrmc = "";
			String ywrgyrmc = "";
			if(qlrlist.size() > 0 ){
				String gyfs = DictUtils.getDictLabel(qlrlist.get(0).getGyfs(), "reg_bus_gyfs", "");
				bdcdjxx.setGyqk(gyfs);
				for(int qi=0;qi<qlrlist.size();qi++){
					qlr = qlrlist.get(qi);
					qlr.setYsdm("6003000000");
					if(qlrlist.get(qi).getSxh().equals("1")){
						qlrmc = qlrlist.get(qi).getQlrmc();
						bdcdjxx.setQlrmc(qlrmc);
					}else{
						gyrmc += qlrlist.get(qi).getQlrmc()+"; ";
					}
					//首先获取权利人 ID个数
					int qlrmcOrderNumber = 1;
					RegBusQlr qlr_6 = new RegBusQlr();
					qlr_6.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
					List<RegBusQlr> qlrlist_1 = regBusQlrService.findList_1(qlr_6);
					int count = qlrlist_1.size();
					if(count > 0){
						qlrmcOrderNumber = qlrlist_1.size() + 1;
					}
					//首次登记
					RegBusQlr qlr_3 = new RegBusQlr();
					BeanUtils.copyProperties(qlr, qlr_3);
					qlr_3.setSxh(qlrmcOrderNumber);
					qlr_3.setQszt("1");
					qlr_3.setId("");
					RegBusQlr qlr_33 = new RegBusQlr();
					qlr_33.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
					qlr_33.setPcode(qlr.getPcode());
					qlr_33.setQllx(regBusHisHouseBdcqzsdjxx.getQllx());
					List<RegBusQlr> qlrlist_33 = regBusQlrService.findList_1(qlr_33);
					if(qlrlist_33.size() > 0 ){
						qlr_3.setId(qlrlist_33.get(0).getId());
					}
					qlr_3.setQllx(regBusHisHouseBdcqzsdjxx.getQllx());
					qlr_3.setQszt("1");
					regBusQlrService.save(qlr_3);
				}
			}
			//获取业务号相同的所有数据
			RegBusHisHouseBdcqzsdjxx hishouse_1 = new RegBusHisHouseBdcqzsdjxx();
			hishouse_1.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
			List<RegBusHisHouseBdcqzsdjxx> hislist = regBusHisHouseBdcqzsdjxxService.findList(hishouse_1);
			int t = hislist.size();
			if(t > 0){
				if(StringUtils.isNotBlank(hislist.get(0).getYwh())){
					RegBaseHbhqk regBaseHbhqk = new RegBaseHbhqk();
					regBaseHbhqk.setYwh(hislist.get(0).getYwh());
					regBaseHbhqkService.deletebyywh(regBaseHbhqk);
				}
				for(int i=0;i<t;i++){
					RegBusHisHouseBdcqzsdjxx hishouse = new RegBusHisHouseBdcqzsdjxx();
					hishouse = hislist.get(i);
					//在做历史转移登记的时候,判断系统中是否有所有权有效数据,有的话就注销掉
					if("302".equals(hishouse.getDjxl())){
						RegBusBdcqzsdjxx regBusBdcqzsdjxx = new RegBusBdcqzsdjxx();
						regBusBdcqzsdjxx.setBdcdyh(hishouse.getBdcdyh());
						regBusBdcqzsdjxx.setIslogout("0");
						regBusBdcqzsdjxx.setRights("1");
						regBusBdcqzsdjxx.setYwh("LS");
						List<RegBusBdcqzsdjxx> listRegBusBdcqzsdjxx = regBusBdcqzsdjxxService.findzyList(regBusBdcqzsdjxx);
						if(listRegBusBdcqzsdjxx.size() > 0){
							regBusBdcqzsdjxx = listRegBusBdcqzsdjxx.get(0);
							bdcdjxx.setOldid(regBusBdcqzsdjxx.getId());
							regBusBdcqzsdjxx.setIslogout("1");
							regBusBdcqzsdjxxService.save(regBusBdcqzsdjxx);
							
							RegBusFdcq2 fdcqold = new RegBusFdcq2();
							fdcqold.setYwh(regBusBdcqzsdjxx.getYwh());
							fdcqold.setBdcdyh(regBusBdcqzsdjxx.getBdcdyh());
							List<RegBusFdcq2> listfdcq2 = regBusFdcq2Service.findList(fdcqold);
							if(listfdcq2.size() > 0){
								fdcqold = listfdcq2.get(0);
								fdcqold.setQszt("2");
								regBusFdcq2Service.save(fdcqold);
							}
							RegBusQlr qlrold = new RegBusQlr();
							qlrold.setYwh(regBusBdcqzsdjxx.getYwh());
							List<RegBusQlr> qlroldlist = regBusQlrService.findList_1(qlrold);
							if(qlroldlist.size() > 0 ){
								for(int y=0;y<qlroldlist.size();y++){
									qlrold = qlroldlist.get(y);
									qlrold.setQszt("2");
									regBusQlrService.save(qlrold);
								}
							}
						}
					}
					if(StringUtils.isNotBlank(hishouse.getYwh())){
						RegBaseH regBaseH = new RegBaseH();
						regBaseH.setBdcdyh(hishouse.getBdcdyh());
						List<RegBaseH>   hlist = regBaseHService.findList(regBaseH);
						if(hlist.size() > 0 ){
							regBaseH = hlist.get(0);
							RegBaseHbhqk regBaseHbhqk_1 = new RegBaseHbhqk();
							regBaseHbhqk_1.setYwh(hishouse.getYwh());
							regBaseHbhqk_1.setHid(regBaseH.getId());
							regBaseHbhqk_1.setOldhid(regBaseH.getId());
							regBaseHbhqk_1.setBdcdyh(hishouse.getBdcdyh());
							regBaseHbhqkService.save(regBaseHbhqk_1);
						}
					}
					RegBusFdcq2 fdcq2_1 = new RegBusFdcq2();
					String gyr = "";//共有人名称
					//插入已登记信息
					RegBaseH regBaseH = new RegBaseH();
					regBaseH.setBdcdyh(hishouse.getBdcdyh());
					List<RegBaseH> listh  = regBaseHService.findList(regBaseH);
					if(listh.size() > 0 ){
						regBaseH = listh.get(0);
						if(djxl.equals("207") || djxl.equals("302")) {
							if("0".equals(hishouse.getFwxz()) || "1".equals(hishouse.getFwxz()) || "2".equals(hishouse.getFwxz()) || "5".equals(hishouse.getFwxz()) || "7".equals(hishouse.getFwxz())){
								if(!"7".equals(regBusHisHouseBdcqzsdjxx.getCqly()) && !"8".equals(regBusHisHouseBdcqzsdjxx.getCqly()) && !"9".equals(regBusHisHouseBdcqzsdjxx.getCqly()) && !"15".equals(regBusHisHouseBdcqzsdjxx.getCqly()) && !"19".equals(regBusHisHouseBdcqzsdjxx.getCqly())){
									regBaseH.setQlxz("102");
								}
							}
							if(djxl.equals("302")) {
								regBaseH.setIszy("1");
							}
							regBaseH.setFwyt1(hishouse.getGhyt());
							regBaseH.setRights("2");
							regBaseH.setFwxz(hishouse.getFwxz());
						}
						regBaseHService.save(regBaseH);
					}
					RegBaseC regBaseC =  regBaseCService.get(regBaseH.getCid());
					RegBaseZrz regBaseZrz = regBaseZrzService.get(regBaseC.getZid());
					RegBaseZdjbxx regBaseZdjbxx = new RegBaseZdjbxx();
					//由宗地代码获取宗地信息,确保宗地代码在库里有值时才取宗地信息的值
					String yt ="";
					if(StringUtils.isNotBlank(regBaseZrz.getZddm())){
						regBaseZdjbxx.setZddm(regBaseZrz.getZddm());
						List<RegBaseZdjbxx> zdList = regBaseZdjbxxService.findList(regBaseZdjbxx);
						if(zdList.size()>0){
							regBaseZdjbxx = zdList.get(0);
							yt = DictUtils.getDictLabel(hishouse.getGhyt(), "reg_bus_fwyt", "");
							bdcdjxx.setYt(regBaseZdjbxx.getYt()+"/"+yt);
						}
					}
					bdcdjxx.setQlqtzk(hishouse.getQlqtzk());
					bdcdjxx.setYwh(hishouse.getYwh());
					bdcdjxx.setZddm(regBaseZrz.getZddm());
					bdcdjxx.setBdcdyh(hishouse.getBdcdyh());
					bdcdjxx.setBdcqzh(hishouse.getBdcqzh());
					bdcdjxx.setBdcqzbh(hishouse.getBdcqzbh());
					bdcdjxx.setZl(hishouse.getFdzl());
					bdcdjxx.setQlxz(hishouse.getQlxz());
					bdcdjxx.setMj(String.valueOf(regBaseH.getScjzmj()));
					bdcdjxx.setSyqx(hishouse.getSyqx());
					bdcdjxx.setPwh(hishouse.getPwh());
					bdcdjxx.setHbjk(hishouse.getHbjk());
					bdcdjxx.setHbhth(hishouse.getHbhth());
					bdcdjxx.setFzsj(DateUtils.formatDate(new Date(),"yyyy-MM-dd"));
					bdcdjxx.setZzsj(hishouse.getZzsj());
					bdcdjxx.setDjlx(hishouse.getDjxl());
					bdcdjxx.setFj(hishouse.getRemarks()+"/"+hishouse.getFj());
					bdcdjxx.setRights("1");
					bdcdjxx.setQllx(hishouse.getQllx());
					bdcdjxx.setStatus("2");
					bdcdjxx.setIshistory("0");
					bdcdjxx.setIslogout("0");
					bdcdjxx.setIsprint("0");
					bdcdjxx.setIsfdsj(Integer.valueOf("0"));
					bdcdjxx.setFj(hishouse.getFj());
					bdcdjxx.setDbsj(DateUtils.formatDate(new Date(),"yyyy-MM-dd"));
					bdcdjxx.setId("");
					//插入oldid去关联数据
					//查询当前单元号下的确权情况
					RegBusRights rightsdjxx = new RegBusRights();
					rightsdjxx.setBdcdyh(hishouse.getBdcdyh());
					List<RegBusRights> rightslistdjxx = regBusRightsService.findList(rightsdjxx);
					if(rightslistdjxx.size() > 0 ){
						rightsdjxx = rightslistdjxx.get(0);
						//查询当前单元号是否已经存在登记信息
						RegBusBdcqzsdjxx glregBusBdcqzsdjxx = new RegBusBdcqzsdjxx();
						glregBusBdcqzsdjxx.setBdcdyh(hishouse.getBdcdyh());
						//根据不同登记类型查询不同的登记信息
						if("806".equals(djxl)){
							glregBusBdcqzsdjxx.setYwh(rightsdjxx.getSsouyq());
						}
						if("804".equals(djxl) || "807".equals(djxl)){
							glregBusBdcqzsdjxx.setYwh(rightsdjxx.getXsouyq());
						}
						if("214".equals(djxl)){
							if(StringUtils.isNotBlank(rightsdjxx.getXtxq())){
								glregBusBdcqzsdjxx.setYwh(rightsdjxx.getXtxq());
							}else if(StringUtils.isNotBlank(rightsdjxx.getSsouyq()) && StringUtils.isNotBlank(rightsdjxx.getStxq())){
								glregBusBdcqzsdjxx.setYwh(rightsdjxx.getStxq());
							}else if(StringUtils.isNotBlank(rightsdjxx.getSsouyq()) && StringUtils.isBlank(rightsdjxx.getStxq())){
								glregBusBdcqzsdjxx.setYwh(rightsdjxx.getSsouyq());
							}
						}
						if("215".equals(djxl)){
							if(StringUtils.isNotBlank(rightsdjxx.getXtxq())){
								glregBusBdcqzsdjxx.setYwh(rightsdjxx.getXtxq());
							}else if(StringUtils.isNotBlank(rightsdjxx.getSsouyq())){
								glregBusBdcqzsdjxx.setYwh(rightsdjxx.getSsouyq());
							}
						}
						//像本次审核分叉的登记信息数据oldid中插入此单元号下的上笔id
						List<RegBusBdcqzsdjxx> gllistRegBusBdcqzsdjxx = regBusBdcqzsdjxxService.findzyList(glregBusBdcqzsdjxx);
						if(gllistRegBusBdcqzsdjxx.size() > 0){
							glregBusBdcqzsdjxx = gllistRegBusBdcqzsdjxx.get(0);
							bdcdjxx.setOldid(glregBusBdcqzsdjxx.getId());
						}
					}
					RegBusBdcqzsdjxx djxx = new RegBusBdcqzsdjxx();
					djxx.setYwh(hishouse.getYwh());
					djxx.setBdcdyh(hishouse.getBdcdyh());
					List<RegBusBdcqzsdjxx> djxxlist = regBusBdcqzsdjxxService.findList(djxx);
					int tt = djxxlist.size();
					if(tt > 0 ){
						bdcdjxx.setId(djxxlist.get(0).getId());
					}
					regBusBdcqzsdjxxService.save(bdcdjxx);
					//插入确权表
					if(djxl.equals("207")){
						//插入确权表字段
						RegBusRights rights = new RegBusRights();
						rights.setBdcdyh(hishouse.getBdcdyh());
						List<RegBusRights> rightslist = regBusRightsService.findList(rights);
						if(rightslist.size() > 0 ){
							rights = rightslist.get(0);
							rights.setRemarks(djxl);
							rights.setSsouyq(hishouse.getYwh());
						}else{
							rights.setRemarks(djxl);
							rights.setBdcdyh(hishouse.getBdcdyh());
							rights.setSsouyq(hishouse.getYwh());
							//去重验证
							RegBusRights rightsold = new RegBusRights();
							rightsold.setBdcdyh(hishouse.getBdcdyh());
							List<RegBusRights>  rightsList = regBusRightsService.findList(rightsold);
							if(rightsList.size() > 0){
								rights.setId(rightsList.get(0).getId());
							}
						}
						regBusRightsService.save(rights);
					}
					if(djxl.equals("302")) {
						//插入确权表字段
						RegBusRights rights = new RegBusRights();
						rights.setBdcdyh(hishouse.getBdcdyh());
						List<RegBusRights> rightslist = regBusRightsService.findList(rights);
						if(rightslist.size() > 0 ){
							rights = rightslist.get(0);
							rights.setRemarks(djxl);
							rights.setSsouyq(hishouse.getYwh());
						}else{
							rights.setRemarks(djxl);
							rights.setBdcdyh(hishouse.getBdcdyh());
							rights.setSsouyq(hishouse.getYwh());
							//去重验证
							RegBusRights rightsold = new RegBusRights();
							rightsold.setBdcdyh(hishouse.getBdcdyh());
							List<RegBusRights>  rightsList=  regBusRightsService.findList(rightsold);
							if(rightsList.size() > 0){
								rights.setId(rightsList.get(0).getId());
							}
						}
						regBusRightsService.save(rights);
					}
					
					//开始分插数据
					//首先在每个判断中获取已选择数据的业务号和不动产单元号,通过其去查询对应权属表中的对应数据
					if(djxl.equals("207") || djxl.equals("302")){
						//获取选择已登记信息的对应的房屋所有权权属信息
						fdcq2_1.setYsdm(hishouse.getYsdm());
						fdcq2_1.setBdcdyh(hishouse.getBdcdyh());
						fdcq2_1.setYwh(hishouse.getYwh());
						fdcq2_1.setQllx(hishouse.getQllx());
						fdcq2_1.setDjlx(hishouse.getDjlx());
						fdcq2_1.setDjyy(hishouse.getDjyy());
						fdcq2_1.setFdzl(hishouse.getFdzl());
						if("302".equals(djxl) || "207".equals(djxl)){
							String yggyrmc = "";
							RegBusHisHouseQlr ygqlr = new RegBusHisHouseQlr();
							ygqlr.setYwh(regBusHisHouseBdcqzsdjxx.getYwh());
							List<RegBusHisHouseQlr> ygdjqlrlist = regBusHisHouseQlrService.findList(ygqlr);//获取权利人子表数据
							for(int y=0;y<ygdjqlrlist.size();y++){
								yggyrmc += ygdjqlrlist.get(y).getQlrmc()+"; ";
							}
							fdcq2_1.setTdsyqr(yggyrmc);
						}
						fdcq2_1.setCqly(hishouse.getCqly());
						fdcq2_1.setYwxl(hishouse.getYwxl());
						fdcq2_1.setDytdmj(hishouse.getDytdmj());
						fdcq2_1.setFttdmj(hishouse.getFttdmj());
						fdcq2_1.setTdsyqssj(hishouse.getTdsyqssj());
						fdcq2_1.setTdsyjssj(hishouse.getTdsyjssj());
						fdcq2_1.setFdcjyjg(hishouse.getFdcjyjg());
						fdcq2_1.setGhyt(hishouse.getGhyt());
						fdcq2_1.setFwxz(hishouse.getFwxz());
						fdcq2_1.setFwjg(hishouse.getFwjg());
						if(hishouse.getSzc() != null){
							fdcq2_1.setSzc(hishouse.getSzc());
						}
						if(hishouse.getZcs() != null){
							fdcq2_1.setZcs(Integer.parseInt(String.valueOf(hishouse.getZcs())));
						}
						fdcq2_1.setJzmj(hishouse.getJzmj());
						fdcq2_1.setZyjzmj(hishouse.getZyjzmj());
						fdcq2_1.setFtjzmj(hishouse.getFtjzmj());
						fdcq2_1.setJgsj(DateUtils.formatDate(hishouse.getJgsj(), "yyyy-MM-dd"));
						fdcq2_1.setBdcqzh(hishouse.getBdcqzh());
						if(djxl.equals("207")) {
							fdcq2_1.setYbdcqzh(hishouse.getBdcqzh());
							//反写幢的竣工日期
							RegBaseZrz zrz = new RegBaseZrz();
							String dyh = hishouse.getBdcdyh().substring(0,24);
							zrz.setBdcdyh(dyh);
							List<RegBaseZrz> findZrzList = regBaseZrzService.findList(zrz);
							if(findZrzList.size() > 0 ){
								zrz = findZrzList.get(0);
								zrz.setJgrq(hishouse.getJgsj());
								regBaseZrzService.save(zrz);
							}
						}
						fdcq2_1.setQxdm(hishouse.getQxdm());
						fdcq2_1.setDjjg(hishouse.getDjjg());
						fdcq2_1.setDbr(hishouse.getDbr());
						fdcq2_1.setDjsj(hishouse.getDjsj());
						fdcq2_1.setFj(hishouse.getFj());
						fdcq2_1.setQszt("1");
						fdcq2_1.setRemarks(hishouse.getRemarks());
						fdcq2_1.setDjyy(hishouse.getDjyy());
						fdcq2_1.setFj(hishouse.getFj());
						fdcq2_1.setYtmc(DictUtils.getDictLabel(hishouse.getGhyt(), "reg_bus_fwyt", ""));
						fdcq2_1.setFwxzmc(DictUtils.getDictLabel(hishouse.getFwxz(), "reg_bus_fwxz", ""));
						fdcq2_1.setId("");
						if(djxl.equals("207")){
							fdcq2_1.setZdftfs(regBaseZrz.getZdftfs());
						}
						if(djxl.equals("302")){
							fdcq2_1.setZdftfs(hishouse.getZdftfs());
						}
						RegBusFdcq2 fd = new RegBusFdcq2();
						fd.setYwh(hishouse.getYwh());
						fd.setBdcdyh(hishouse.getBdcdyh());
						List<RegBusFdcq2> fdlist = regBusFdcq2Service.findList(fd);
						int t3 = fdlist.size();
						if(t3 > 0 ){
							fdcq2_1.setId(fdlist.get(0).getId());
						}
						regBusFdcq2Service.save(fdcq2_1);
					}
					//设置该数据已经被审核
					hishouse.setIsaudit("1");
					regBusHisHouseBdcqzsdjxxService.save(hishouse);
				}
				//循环结束
				addMessage(redirectAttributes, "不动产登记历史数据审核成功!");
				//最后再次查重只针对登记信息和确权就可以确定是否有重复数据了
				int cfbz = 0;
				for(int i=0;i<hislist.size();i++){
					RegBusHisHouseBdcqzsdjxx hishouse = hislist.get(i);
					//确权信息
					RegBusRights rig = new RegBusRights();
					rig.setBdcdyh(hishouse.getBdcdyh());
					List<RegBusRights> riglist = regBusRightsService.findList(rig);
					//登记信息
					RegBusBdcqzsdjxx djxx = new RegBusBdcqzsdjxx();
					djxx.setYwh(hishouse.getYwh());
					djxx.setBdcdyh(hishouse.getBdcdyh());
					List<RegBusBdcqzsdjxx> djxxlist = regBusBdcqzsdjxxService.findList(djxx);
					if(djxxlist.size() >= 2 || riglist.size() >= 2){
						cfbz = 1;
						break;
					}
				}
			}
		}
		return modelmap;
	}
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "listCF")
	public String listCF(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx, HttpServletRequest request, HttpServletResponse response, Model model) {
//		if(StringUtils.isNotBlank(request.getParameter("ywhhz"))){
//			regBusCSlsqController.saveSjhzTable(request.getParameter("ywhhz"));
//		}
		String isbatch = request.getParameter("isbatch");
		model.addAttribute("isbatch", StringUtils.isEmpty(isbatch)?"0":isbatch);
		
		//用户权限分配
		User user = UserUtils.getUser();
		Office office = officeService.get(user.getCurrentUser().getOffice().getId());
		if("S00001001007".equals(office.getCode())){
			model.addAttribute("SH", office.getCode());
		}else{
			model.addAttribute("SH", office.getCode());
		}	
		//重复数据标示
		if(StringUtils.isNotBlank(request.getParameter("cfbz"))){
			if("1".equals(request.getParameter("cfbz"))){
				model.addAttribute("MSG", "提示 :本次审核的数据出现多条重复数据!!!");
			}
		}
		if(StringUtils.isNotBlank(request.getParameter("ysh"))){
			model.addAttribute("ysh", "1");
		}
		//WinOpen标示
		if(StringUtils.isNotBlank(request.getParameter("VIEWS"))){
			model.addAttribute("VIEWS", "1");
		}
		//页面操作类型【新增还是更新】
		if(StringUtils.isNotBlank(request.getParameter("optype"))){
			model.addAttribute("optype", "update");
		}
		//WinOpFen标示
		if(StringUtils.isNotBlank(request.getParameter("WO"))){
			model.addAttribute("WO", "1");
		}
		model.addAttribute("VIEWS", "1");
		regBusHisHouseBdcqzsdjxx.setDjxl("9");
		Page<RegBusHisHouseBdcqzsdjxx> page = regBusHisHouseBdcqzsdjxxService.findPage(new Page<RegBusHisHouseBdcqzsdjxx>(request, response), regBusHisHouseBdcqzsdjxx); 
		model.addAttribute("page", page);
		//--------------------------记忆查询20180516
		regBusHisHouseBdcqzsdjxx=new RegBusHisHouseBdcqzsdjxx();
		if(StringUtils.isNotBlank(request.getParameter("ywh"))){
			System.out.println(request.getParameter("ywh"));
			regBusHisHouseBdcqzsdjxx.setYwh(request.getParameter("ywh"));
		}
		if(StringUtils.isNotBlank(request.getParameter("bdcqzh"))){
			System.out.println(request.getParameter("bdcqzh"));
			regBusHisHouseBdcqzsdjxx.setBdcqzh(request.getParameter("bdcqzh"));
		}
		if(StringUtils.isNotBlank(request.getParameter("bdcdyh"))){
			System.out.println(request.getParameter("bdcdyh"));
			regBusHisHouseBdcqzsdjxx.setBdcdyh(request.getParameter("bdcdyh"));
		}
		if(StringUtils.isNotBlank(request.getParameter("fdzl"))){
			System.out.println(request.getParameter("fdzl"));
			regBusHisHouseBdcqzsdjxx.setFdzl(request.getParameter("fdzl"));
		}
		if(StringUtils.isNotBlank(request.getParameter("jzmj"))){
			System.out.println(request.getParameter("jzmj"));
			regBusHisHouseBdcqzsdjxx.setJzmj(Double.parseDouble(request.getParameter("jzmj")));
		}
		model.addAttribute("regBusHisHouseBdcqzsdjxx", regBusHisHouseBdcqzsdjxx);
		//-----------------------------
		return "modules/reg/bus/regBusHisHouseBdcqzsdjxxListCF";
	}
	
	//
	/**
	 * 房屋实查封列表
	 * @param regBusCfdj
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "fwcflist")
	public String fwcflist(RegBusHisHouseCfdj regBusCfdj, HttpServletRequest request, HttpServletResponse response, Model model) {
		String ywh = request.getParameter("ywh");
			if (StringUtils.isNotBlank(ywh)) {
				regBusCfdj.setYwh(ywh);
			}
		// 传递要素代码
		if (StringUtils.isNotBlank(ywh)) {
			model.addAttribute("LSH", ywh);
			model.addAttribute("YSDM", request.getParameter("YSDM"));
		}
		// 审核只能查看不能修改删除
		if (StringUtils.isNotBlank(request.getParameter("LISTVIEWS"))) {
			model.addAttribute("LISTVIEWS", "1");
		}
		//WinOpen标示
		if(StringUtils.isNotBlank(request.getParameter("VIEWS"))){
			model.addAttribute("VIEWS", "1");
		}
		//WinOpen标示
				if(StringUtils.isNotBlank(request.getParameter("WO"))){
					model.addAttribute("WO", "1");
					model.addAttribute("LISTVIEWS", "1");
				}
		//WinOpen标示
		if(StringUtils.isNotBlank(request.getParameter("WWO"))){
			model.addAttribute("WWO", "1");
			model.addAttribute("LISTVIEWS", "1");
		}
		//页面操作类型【新增还是更新】
		if(StringUtils.isNotBlank(request.getParameter("optype"))){
			model.addAttribute("optype", "update");
		}
		Page<RegBusHisHouseCfdj> page = regBusHisHouseCfdjService.findPage(new Page<RegBusHisHouseCfdj>(request, response), regBusCfdj); 
		model.addAttribute("page", page);
		String cfbj = request.getParameter("cfbj");
		if(StringUtils.isBlank(cfbj)) {
		return "modules/reg/bus/regBusHisfwCfdjList";
		}else {
			return "modules/reg/bus/regBusHisfwYcfdjList";
		}
	}
	/**
	 * 房屋历史查封权属列表
	 * @param regBusHisHouseBdcqzsdjxx
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "hishousecflist")
	public String hishousecflist(RegBaseXm regBaseXm, HttpServletRequest request, HttpServletResponse response, Model model) {
		RegBusRights regBusRights = new RegBusRights();
		regBusRights.setStxq(null);
		String djlx = request.getParameter("DJLX");
		if(StringUtils.isNotBlank(djlx)){
//			if(djlx.equals("213") || djlx.equals("207") || djlx.equals("803")){//此处过滤土地是抵押状态的宗地
//				Page<RegBaseXm> page = regBaseXmService.findTdPage(new Page<RegBaseXm>(request, response), regBaseXm); 
//				model.addAttribute("page", page);
//			}else {
			Page<RegBaseXm> page = regBaseXmService.findPage(new Page<RegBaseXm>(request, response), regBaseXm); 
			model.addAttribute("page", page);
//			}
			model.addAttribute("DJLX", djlx);
		}else {
			Page<RegBaseXm> page = regBaseXmService.findPage(new Page<RegBaseXm>(request, response), regBaseXm); 
			model.addAttribute("page", page);
		}
		if(StringUtils.isNotBlank(request.getParameter("YWH"))){
			model.addAttribute("ywh", request.getParameter("YWH"));
		}
		if(StringUtils.isNotBlank(request.getParameter("tz"))){
			model.addAttribute("tz", request.getParameter("tz"));
		}
		request.getSession().removeAttribute(request.getParameter("YWH")+"_selectedIDs");
	
		return "modules/reg/bus/regBusHisHouseCF";
	}
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "guideListView")
	public String guideListView(RegBaseZrz regBaseZrz, HttpServletRequest request, HttpServletResponse response,
			Model model) {
		RegBaseXm regBaseXm = null;
		String xmid = request.getParameter("XMID");
		if (StringUtils.isNotBlank(xmid)) {
			model.addAttribute("XMID", xmid);
			regBaseZrz.setXmid(xmid);
			regBaseXm = regBaseXmService.get(xmid);
			model.addAttribute("regBaseXmmc", regBaseXm.getXmmc());
		}

		String ywh = request.getParameter("ywh");
		if (StringUtils.isNotBlank(ywh)) {
			model.addAttribute("ywh", ywh);
		}
		String tz = request.getParameter("tz");
		if (StringUtils.isNotBlank(tz)) {
			model.addAttribute("tz", tz);
		}

		String djlx = request.getParameter("djlx");
		if (StringUtils.isNotBlank(djlx)) {
			model.addAttribute("DJLX", djlx);
		}
		Page<RegBaseZrz> page = regBaseZrzService.findPage(new Page<RegBaseZrz>(request, response), regBaseZrz);
		model.addAttribute("page", page);
		model.addAttribute("zCount", page.getList().size());

		return "modules/reg/bus/regBusHisZrzGuideListView";
	}
	
	/***
	* @Title: zchGuideListView 
	* @Description: 楼盘信息表 
	* @param @param regBaseC
	* @param @param request
	* @param @param response
	* @param @param model
	* @param @return    设定文件 
	* @return String    返回类型 
	* @throws 
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "zchGuideListView")
	public String zchGuideListView(RegBaseC regBaseC, RegBaseH regBaseH, HttpServletRequest request, HttpServletResponse response, Model model) {
		RegBaseZrz regBaseZrz = null;
		if(StringUtils.isNotBlank(request.getParameter("ZID"))){
			model.addAttribute("ZID", request.getParameter("ZID"));
			model.addAttribute("XMMC", request.getParameter("XMMC"));
			regBaseC.setZid(request.getParameter("ZID"));
			regBaseZrz = regBaseZrzService.get(request.getParameter("ZID"));
			model.addAttribute("ZH", regBaseZrz.getZrzh());
			model.addAttribute("JZWMC", regBaseZrz.getGzwmc());
			//model.addAttribute("ZSCJZMJ", regBaseZrz.getScjzmj());
		}
		if(StringUtils.isNotBlank(request.getParameter("ywh"))){
			model.addAttribute("ywh", request.getParameter("ywh"));
		}
		String djlx = "";
		if(StringUtils.isNotBlank(request.getParameter("djlx"))){
			djlx = request.getParameter("djlx");
			model.addAttribute("DJLX", djlx);
		}
		String tz = request.getParameter("tz");
		if(StringUtils.isNotBlank(tz)){
			model.addAttribute("tz", tz);
		}
		//构建自己的层户列表数据结构
		//获取幢包含的层列表
		regBaseC.setZid(request.getParameter("ZID"));
		List<RegBaseC> regBaseCList = regBaseCService.findList(regBaseC);
		model.addAttribute("regBaseCList", regBaseCList);
		model.addAttribute("cCount", regBaseCList.size());
		//获取层包含的户列表
		List<RegBaseH> regBaseHList = new ArrayList<RegBaseH>();
		List<RegBaseH> regBaseAllHList = new ArrayList<RegBaseH>();
		//幢包含所有的户数
		int hCount = 0;
		int tmpMaxCount = 0;
		Double zchmjs = 0.0;
		RegBusRights regBusRights = new RegBusRights();
		for(int i=0; i<regBaseCList.size(); i++){
			//设置获取户列表的层ID
			regBaseH.setCid(regBaseCList.get(i).getId());
			regBaseHList = regBaseHService.findList(regBaseH);
			//添加页面户需要的model
			//计算幢包含的所有户数
			hCount += regBaseHList.size();
			//获取最大的层中户数算法
			int maxNumbers = getMaxColNumber(regBaseHList);
			if(tmpMaxCount < maxNumbers){
				tmpMaxCount = maxNumbers;
			}
			//计算本层所有户的实测面积
			Double chmjs = 0.0;
				for(int a=0; a<regBaseHList.size(); a++){
					RegBaseH regBaseHT = regBaseHList.get(a);
					chmjs += regBaseHT.getScjzmj();
				}
			regBaseAllHList.addAll(regBaseHList);
			RegBaseC regBaseCT = new RegBaseC();
			regBaseCT = regBaseCList.get(i);
			regBaseCT.setChjzmj(chmjs);
			zchmjs += chmjs;
		}
		BigDecimal b = new BigDecimal(zchmjs);
		model.addAttribute("ZSCJZMJ", b.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
		model.addAttribute("regBaseAllHList", regBaseAllHList);
		
		//添加页面层需要的model
		/*
		//获取层包含的户列表
		List<RegBaseH> regBaseHList = null;
		//幢包含所有的户数
		int hCount = 0;
		int tmpMaxCount = 0;
		for(int i=0; i<regBaseCList.size(); i++){
			//设置获取户列表的层ID
			regBaseH.setCid(regBaseCList.get(i).getId());
			regBaseHList = regBaseHService.findList(regBaseH);
			//添加页面户需要的model
			model.addAttribute("option" + i, regBaseHList);
			//计算幢包含的所有户数
			hCount += regBaseHList.size();
			//获取最大的层中户数算法
			if(tmpMaxCount < regBaseHList.size()){
				tmpMaxCount = regBaseHList.size();
			}
		}
		*/
		model.addAttribute("hCount", hCount);
		//再构造一个表头
		List<Integer> intS = new ArrayList<Integer>();
		//表头个数 【用最大的层中户数】
		for(int j=0; j<tmpMaxCount; j++){
			intS.add(j+1);
		}
		model.addAttribute("intS", intS);
		model.addAttribute("ZID", request.getParameter("ZID"));
		String views="";
		
			 if(djlx.equals("905") || djlx.equals("907")){//房屋查封和预查封
				views = "modules/reg/bus/regBaseFwcfZCHGuideListView";
			 }else if(djlx.equals("910")){
				//楼盘查封
				views="modules/reg/bus/regBaseLpcfZCHGuideListView";
			}
			model.addAttribute("DJLX", djlx);
		
		return views;
	}
	/**
	* @Title: getMaxColNumber 
	* @Description: 获取户信息列表里xy中的y的最大值
	* @param @param regBaseHList
	* @param @return    设定文件 
	* @return int    返回类型 
	* @throws
	 */
	public int getMaxColNumber(List<RegBaseH> regBaseHList){
		int retStr = regBaseHList.size();//默认返回这一层的户数,作为本层的最大户数【常规楼盘建立够用了】
		int[] colNumbers = new int[retStr];
		if(retStr > 0){
			RegBaseH regBaseH = new RegBaseH();
			for(int i=0; i<retStr; i++){
				regBaseH = regBaseHList.get(i);
				if(regBaseH.getXyposition().indexOf("-") != -1){
					regBaseH.setXyposition(regBaseH.getXyposition().replaceAll("-", ""));
				}
				//这里的colvalue值需要考虑到100层【10001】以上,1000层以上就不考虑了 
				if(regBaseH.getXyposition().length() >= 6){//100100
					colNumbers[i] = Integer.parseInt(regBaseH.getXyposition().substring(3));
				}else if(regBaseH.getXyposition().length() >= 4){
					if(Integer.parseInt(regBaseH.getEndc()) >= 100){//1001
						colNumbers[i] = Integer.parseInt(regBaseH.getXyposition().substring(3));
					}else{
						if(Integer.valueOf(regBaseH.getHh()) >= 100){//3位户号
							if(Integer.parseInt(regBaseH.getEndc()) >= 10){// 10100 - 99100 
								colNumbers[i] = Integer.parseInt(regBaseH.getXyposition().substring(2));
							}else{//1100 - 9100
								colNumbers[i] = Integer.parseInt(regBaseH.getXyposition().substring(1));
							}
						}else{//2位户号 110(不存在) 1010
							colNumbers[i] = Integer.parseInt(regBaseH.getXyposition().substring(2));
						}
					} 
				}else if(regBaseH.getXyposition().length() >= 3){
					if(Integer.parseInt(regBaseH.getEndc()) >= 100){//1100
						colNumbers[i] = Integer.parseInt(regBaseH.getXyposition().substring(1));
					}else{//101
						colNumbers[i] = Integer.parseInt(regBaseH.getXyposition().substring(1));
					}
				}
			}
		}
		int tempMaxNumbers = 0;
		for(int j=0; j<colNumbers.length; j++){
			if(tempMaxNumbers < colNumbers[j]){
				tempMaxNumbers = colNumbers[j];
			}
		}
		retStr = tempMaxNumbers;
		return retStr;
	}
	
	/**
	 * 房屋实查封from页面
	 * @param regBusCfdj
	 * @param model
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "Fwcfform")
	public String Fwcfform(RegBusHisHouseCfdj regBusCfdj, Model model, HttpServletRequest request) {
		User user = UserUtils.getUser();
		String isLogout = request.getParameter("isLogout");
		String ywh = request.getParameter("YWH");
		String ysdm = request.getParameter("YSDM");
		String djlx = request.getParameter("djlx");
		String wo = request.getParameter("WO");
		String selectedIDs = request.getParameter("selectedIDs");
		String zh = request.getParameter("zh");
		String zid = request.getParameter("ZID");
		String optype = request.getParameter("optype");
		String bj = request.getParameter("bj");
		Page<RegBaseH> fwpage = new Page<RegBaseH>();
		if(StringUtils.isNotEmpty(selectedIDs)){
			model.addAttribute("IDS", selectedIDs);
			String bdcdyh = "";
			String[] idList = selectedIDs.split(";");
			List<RegBaseH> fwlist = new ArrayList<RegBaseH>();
			//权利人信息列表
			Page<RegBusQlr> qlrpage = new Page<RegBusQlr>();
			List<RegBusQlr> qlrlist = new ArrayList<RegBusQlr>();
			for(String fwid : idList){
				RegBaseH regBaseH  = regBaseHService.get(fwid);
				model.addAttribute("BDCDYH", bdcdyh);
				//把选择后的房屋信息填入list中
				fwlist.add(regBaseH);
				//权利人信息
				RegBusRights rightsold_1 = new RegBusRights();
				rightsold_1.setBdcdyh(regBaseH.getBdcdyh());
				//通过业务号和不动产单元获取正在办理的业务数据
				List<RegBusRights> bdclist_1 = regBusRightsService.findList(rightsold_1);
				//有办理的业务数据
				if(bdclist_1.size() > 0){
					//正在办理的业务数据
					rightsold_1 = bdclist_1.get(0);
					regBusCfdj.setBdcdyh(rightsold_1.getBdcdyh().substring(0, 19)+"F00000000");
					RegBusQlr zyqlr = new RegBusQlr();
					zyqlr.setYwh(rightsold_1.getSsouyq());
					List<RegBusQlr> qlrlist_1 =  regBusQlrService.findList_1(zyqlr);
					if(qlrlist_1.size() > 0){
						for(int i=0;i<qlrlist_1.size();i++){
							zyqlr = qlrlist_1.get(i);
							zyqlr.setBdcdyh(rightsold_1.getBdcdyh());
							qlrlist.add(zyqlr);
							qlrpage.setList(qlrlist);
						}
						model.addAttribute("qlrpage", qlrpage);//返回选择后的房屋列表
						model.addAttribute("selectedIDs", zyqlr.getId());
					}
				}
			}
			fwpage.setList(fwlist);
			model.addAttribute("fwpage", fwpage);//返回选择后的房屋列表
		}
		regBusCfdj.setCflx("1");
		regBusCfdj.setQxdm(Global.getAreaCode());
		model.addAttribute("regBusCfdj", regBusCfdj);
		if(StringUtils.isNotBlank(djlx)){
			model.addAttribute("DJLX", djlx);
		}
		if(StringUtils.isNotBlank(selectedIDs)){
			model.addAttribute("selectedIDs", selectedIDs);
		}
		if(StringUtils.isNotBlank(zh)){
			model.addAttribute("zh", zh);
		}
		if(StringUtils.isNotBlank(zid)){
			model.addAttribute("zid", zid);
		}
		// 传递要素代码
		if (StringUtils.isNotBlank(ywh)) {
			model.addAttribute("YWH",ywh);
			model.addAttribute("YSDM",ysdm );
		}
		// 传递要素代码
				if (StringUtils.isNotBlank(wo)) {
					if(bj != null){
						model.addAttribute("WO","2");
					}else{
						model.addAttribute("WO","1");
					}
				}
		if (StringUtils.isNotBlank(optype)) {
			model.addAttribute("optype","2");
		}
		// 查看标示
		String view = request.getParameter("VIEWS");
		if (StringUtils.isNotBlank(view)) {
			model.addAttribute("VIEWS", view);
		}
		return "modules/reg/bus/regBusHisFwCfdjForm";
	}
	
	/**
	 * 房屋查封登记信息保存
	 * @param regBusCfdj
	 * @param model
	 * @param redirectAttributes
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "Fwcfsave")
	@ResponseBody
	public ModelMap Fwcfsave(RegBusHisHouseCfdj regBusCfdj, Model model,HttpServletRequest request, RedirectAttributes redirectAttributes) {
		ModelMap modelmap = new ModelMap();
		String ywh = "LS"+getNextYwhs();
		String ids = request.getParameter("selectedIDs");
		String qllx = RegUtils.getqllx("905");
		String cfjg = request.getParameter("cfjg");
		String cflx = request.getParameter("cflx");
		String cfwj = request.getParameter("cfwj");
		String cfwh = request.getParameter("cfwh");
		String cfqssj = request.getParameter("cfqssj");
		String cfjssj = request.getParameter("cfjssj");
		String cffw = request.getParameter("cffw");
		String qxdm = request.getParameter("qxdm");
		String fj = request.getParameter("fj");
		String dbr =request.getParameter("dbr");
		String djsj = request.getParameter("djsj");
		String djjg = request.getParameter("djjg");
		String ysdm = request.getParameter("ysdm");
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		//首先获取通过楼盘已选择的房屋信息列表
		//选择的 房屋信息
		String[] idList = ids.split(";");
		/*if(StringUtils.isNotBlank(request.getParameter("YWH"))){
			//查询当前ywh是不是在历史登记信息表里已经有数据了,如果有了就删除掉
			RegBusHisHouseBdcqzsdjxx regBusBdcqzsdjxxC = new RegBusHisHouseBdcqzsdjxx();
			regBusBdcqzsdjxxC.setYwh(ywh);
			regBusBdcqzsdjxxC.setDjlx("905");
			List<RegBusHisHouseBdcqzsdjxx> regedList = regBusHisHouseBdcqzsdjxxService.findList(regBusBdcqzsdjxxC);
			if(regedList.size() > 0){
				for(int i=0; i<regedList.size(); i++){
					regBusBdcqzsdjxxC = regedList.get(i);
					if(StringUtils.isNotBlank(regBusBdcqzsdjxxC.getYwh().replace(" ",""))){
						RegBusHisHouseBdcqzsdjxx regBusBdcqzsdjxx_1 = new RegBusHisHouseBdcqzsdjxx();
						regBusBdcqzsdjxx_1.setYwh(regBusBdcqzsdjxxC.getYwh());
						regBusHisHouseBdcqzsdjxxService.delete(regBusBdcqzsdjxx_1);
					}
				}
			}
			regBusHisHouseQlrService.deleteywh(request.getParameter("YWH"));
			RegBusHisHouseCfdj cf = new RegBusHisHouseCfdj();
			cf.setYwh(request.getParameter("YWH"));
			regBusHisHouseCfdjService.deletefwycf(cf);
		}*/
		
		RegBaseH regBaseHold = regBaseHService.get(idList[0]);//房屋基本信息
		RegBaseC regBaseC = regBaseCService.get(regBaseHold.getCid());
		RegBaseZrz regBaseZrz = regBaseZrzService.get(regBaseC.getZid());
		if(regBaseZrz.getZdftfs().equals("2")){
			RegBaseZdjbxx regBaseZdjbxx = new RegBaseZdjbxx();
			String zddmStr = regBaseZrz.getZddm();
			//由宗地代码获取宗地信息,确保宗地代码在库里有值时才取宗地信息里的值
			regBaseZdjbxx.setZddm(zddmStr);
			List<RegBaseZdjbxx> zdList = regBaseZdjbxxService.findList(regBaseZdjbxx);
			if(zdList.size()>0){
				regBaseZdjbxx = zdList.get(0);
				regBaseZdjbxx.setIschafeng("1");
				regBaseZdjbxxService.save(regBaseZdjbxx);
				
				//单另保存土地的查封登记信息,独用宗地查封
				RegBusHisHouseCfdj cfdj = new RegBusHisHouseCfdj();
				cfdj.setCfjg(cfjg);
				cfdj.setCflx(cflx);
				cfdj.setCfwj(cfwj);
				cfdj.setCfwh(cfwh);
				cfdj.setYsdm(ysdm);
				try {
					cfdj.setCfqssj(sdf.parse(cfqssj));
					cfdj.setCfjssj(sdf.parse(cfjssj));
					cfdj.setDjsj(sdf.parse(djsj));
				} catch (ParseException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				cfdj.setCffw(cffw);
				cfdj.setQxdm(qxdm);
				cfdj.setFj(fj);
				cfdj.setDbr(dbr);
				cfdj.setDjjg(djjg);
				cfdj.setDjlx("905");
				cfdj.setCflx("1");
				cfdj.setJfdjsj(null);
				cfdj.setId("");
				cfdj.setYwh(ywh);
				cfdj.setBdcdyh(regBaseZdjbxx.getBdcdyh());
				//防止重复类似发证的提交,需要判断每个业务号,每个单元号只能有一条记录,判断当前业务号已经有记录时就做update
				RegBusHisHouseCfdj cf = new RegBusHisHouseCfdj();
				cf.setYwh(ywh);
				cf.setBdcdyh(regBaseZdjbxx.getBdcdyh());
				List<RegBusHisHouseCfdj> findList_1 = regBusHisHouseCfdjService.findList(cf);
				if(findList_1.size()>0){
					cfdj.setId(findList_1.get(0).getId());
				}
				cfdj.setQszt("0");
				regBusHisHouseCfdjService.save(cfdj);
				addMessage(redirectAttributes, "保存查封登记信息成功");

				//另存一份土地的登记信息和权利人信息
				//该不动产单元号的最后一笔土地有效数据
				/*RegBusBdcqzsdjxx regBusBdcqzsdjxxtd = new RegBusBdcqzsdjxx();
				if(regBaseZdjbxx.getBdcdyh() != null){
					regBusBdcqzsdjxxtd.setBdcdyh(regBaseZdjbxx.getBdcdyh());
					regBusBdcqzsdjxxtd.setIslogout("0");
					List<RegBusBdcqzsdjxx> regBusBdcqzsdjxxlist = regBusBdcqzsdjxxService.findList(regBusBdcqzsdjxxtd);
					if(regBusBdcqzsdjxxlist.size() > 0){
						regBusBdcqzsdjxxtd = regBusBdcqzsdjxxlist.get(0);
						RegBusHisBdcqzsdjxx regBusBdcqzsdjxxtd_1 = new RegBusHisBdcqzsdjxx();
						regBusBdcqzsdjxxtd_1.setBdcdyh(regBusBdcqzsdjxxtd.getBdcdyh());;
						regBusBdcqzsdjxxtd_1.setBdcqzbh(regBusBdcqzsdjxxtd.getBdcqzbh());
						regBusBdcqzsdjxxtd_1.setBdcqzh(regBusBdcqzsdjxxtd.getBdcqzh());
						regBusBdcqzsdjxxtd_1.setBz(regBusBdcqzsdjxxtd.getBjbz());
						regBusBdcqzsdjxxtd_1.setBz(regBusBdcqzsdjxxtd.getBjbz());

						//获取共有方式
						RegBusQlr qlr = new RegBusQlr();
						qlr.setYwh(regBusBdcqzsdjxxtd.getYwh());
						List<RegBusQlr> qlrlist = regBusQlrService.findList(qlr);
						if(qlrlist.size() > 0){
							qlr = qlrlist.get(0);
							regBusBdcqzsdjxxtd_1.setGyqk(DictUtils.getDictLabel(qlr.getGyfs(), "reg_bus_gyfs", ""));
						}
						regBusBdcqzsdjxxtd_1.setFzsj(null);
						regBusBdcqzsdjxxtd_1.setDelFlag("0");
						regBusBdcqzsdjxxtd_1.setId("");
						regBusBdcqzsdjxxtd_1.setDjlx("905");
						regBusBdcqzsdjxxtd_1.setFj(cfdj.getFj());
						regBusBdcqzsdjxxtd_1.setStatus(null);
						regBusBdcqzsdjxxtd_1.setYwh(ywh);
						regBusBdcqzsdjxxtd_1.setQllx(qllx);
						regBusHisBdcqzsdjxxService.save(regBusBdcqzsdjxxtd_1);
					}
				}*/
			}
		}
		
		//通过不动产单元获取正在办理的业务数据,只增加一笔所有权的权利人信息
		RegBusRights regBusRights = new RegBusRights();
		regBusRights.setBdcdyh(regBaseHold.getBdcdyh());
		List<RegBusRights> rightslistold = regBusRightsService.findList(regBusRights);
		if(rightslistold.size() > 0){
			regBusRights = rightslistold.get(0);
			RegBusQlr regBusQlr_1 = new RegBusQlr();
			regBusQlr_1.setYwh(regBusRights.getSsouyq());
			List<RegBusQlr> list_1 = regBusQlrService.findList_1(regBusQlr_1);
			if(list_1 != null && list_1.size()>0){
				for(int i=0;i<list_1.size();i++){
					//已登记信息的权利人
					regBusQlr_1 = list_1.get(i);
					RegBusHisHouseQlr regBusQlr = new RegBusHisHouseQlr();
					regBusQlr.setBdcdyh(regBusQlr_1.getBdcdyh());
					regBusQlr.setBdcqzh(regBusQlr_1.getBdcqzh());
					regBusQlr.setFzjg(regBusQlr_1.getFzjg());
					regBusQlr.setGyfs(regBusQlr_1.getGyfs());
					regBusQlr.setGyqk(regBusQlr_1.getGyqk());
					regBusQlr.setQlrmc(regBusQlr_1.getQlrmc());
					regBusQlr.setPcode(regBusQlr_1.getPcode());
					regBusQlr.setSfczr(regBusQlr_1.getSfczr());
					regBusQlr.setZjzl(regBusQlr_1.getZjzl());
					regBusQlr.setZjh(regBusQlr_1.getZjh());
					regBusQlr.setSshy(regBusQlr_1.getSshy());
					regBusQlr.setGj(regBusQlr_1.getGj());
					regBusQlr.setHjszss(regBusQlr_1.getHjszss());
					regBusQlr.setDz(regBusQlr_1.getDz());
					regBusQlr.setQlrlx(regBusQlr_1.getQlrlx());
					regBusQlr.setQlbl(regBusQlr_1.getQlbl());
					regBusQlr.setSxh(regBusQlr_1.getSxh().toString());
					regBusQlr.setYwh(ywh);
					regBusQlr.setId("");
					regBusHisHouseQlrService.save(regBusQlr);
				}
			}
		}
		
		//再次循环进行新数据的插入
		for(String id_1 : idList){
			RegBaseH regBaseH = regBaseHService.get(id_1);//房屋基本信息
			
			RegBusHisHouseBdcqzsdjxx regBusBdcqzsdjxxold = new RegBusHisHouseBdcqzsdjxx();
			regBusBdcqzsdjxxold.setBdcdyh(regBaseH.getBdcdyh());
			//通过业务号和不动产单元获取正在办理的所有业务数据,历史首次才能历史查封,否则走流程
			List<RegBusHisHouseBdcqzsdjxx> bdclist = regBusHisHouseBdcqzsdjxxService.findList(regBusBdcqzsdjxxold);
			int t = bdclist.size();
			if(t > 0){
				//保存查封登记信息,每套房屋存储一条查封权属信息
				RegBusHisHouseCfdj cfdj = new RegBusHisHouseCfdj();
				cfdj.setCfjg(cfjg);
				cfdj.setCflx(cflx);
				cfdj.setCfwj(cfwj);
				cfdj.setCfwh(cfwh);
				cfdj.setYsdm(ysdm);
				try {
					cfdj.setCfqssj(sdf.parse(cfqssj));
					cfdj.setCfjssj(sdf.parse(cfjssj));
					cfdj.setDjsj(sdf.parse(djsj));
				} catch (ParseException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				cfdj.setCffw(cffw);
				cfdj.setQxdm(qxdm);
				cfdj.setFj(fj);
				cfdj.setDbr(dbr);
				cfdj.setDjjg(djjg);
				
				cfdj.setJfdjsj(null);
				cfdj.setDjlx("905");
				cfdj.setId("");
				cfdj.setQszt("0");
				cfdj.setYwh(ywh);
				cfdj.setBdcdyh(regBaseH.getBdcdyh());
				//防止重复类似发证的提交,需要判断每个业务号,每个单元号只能有一条记录,判断当前业务号已经有记录时就做update
				RegBusHisHouseCfdj cf = new RegBusHisHouseCfdj();
				cf.setYwh(ywh);
				cf.setBdcdyh(regBaseH.getBdcdyh());
				List<RegBusHisHouseCfdj> findList_1 = regBusHisHouseCfdjService.findList(cf);
				if(findList_1.size()>0){
					cfdj.setId(findList_1.get(0).getId());
				}
				regBusHisHouseCfdjService.save(cfdj);
				addMessage(redirectAttributes, "保存查封登记信息成功");
				//此不动产单元号有几条未注销的有效数据就查封注销几条
				
				for(int i=0;i<t;i++){
					//新增一条数据
					RegBusHisHouseBdcqzsdjxx regBusBdcqzsdjxxnew  = new RegBusHisHouseBdcqzsdjxx();
					
					//判断在登记信息表中的islogout字段是否有效
					RegBusBdcqzsdjxx regBusBdcqzsdjxx = new RegBusBdcqzsdjxx();					
					List<RegBusBdcqzsdjxx> djxxlist = regBusBdcqzsdjxxService.findByYwh(bdclist.get(i).getBdcdyh());
					if(djxxlist.size()>0) {
						regBusBdcqzsdjxx = djxxlist.get(0);
					}
					regBusBdcqzsdjxxnew.setBdcqzh(regBusBdcqzsdjxx.getBdcqzh());
					regBusBdcqzsdjxxnew.setBdcdyh(regBusBdcqzsdjxx.getBdcdyh());
					regBusBdcqzsdjxxnew.setBdcqzbh(regBusBdcqzsdjxx.getBdcqzbh());
					regBusBdcqzsdjxxnew.setFdzl(regBusBdcqzsdjxx.getZl());
					regBusBdcqzsdjxxnew.setFzsj(null);
					regBusBdcqzsdjxxnew.setDelFlag("0");
					regBusBdcqzsdjxxnew.setId("");
					regBusBdcqzsdjxxnew.setDjlx("905");
					regBusBdcqzsdjxxnew.setIsaudit("0");
					regBusBdcqzsdjxxnew.setFj(cfdj.getFj());
					regBusBdcqzsdjxxnew.setQllx(qllx);
					regBusBdcqzsdjxxnew.setYwh(ywh);
					regBusBdcqzsdjxxnew.setDjsj(cfdj.getDjsj());
					regBusBdcqzsdjxxnew.setDbr(cfdj.getDbr());
					regBusBdcqzsdjxxnew.setDjjg(cfdj.getDjjg());
					//防止重复类似发证的提交,需要判断每个业务号只能有一条记录,判断当前业务号已经有记录时就做update
					RegBusHisHouseBdcqzsdjxx regBusBdcqzsdjxxtmp = new RegBusHisHouseBdcqzsdjxx();
					regBusBdcqzsdjxxtmp.setYwh(ywh);
					regBusBdcqzsdjxxtmp.setBdcdyh(regBusBdcqzsdjxx.getBdcdyh());
					regBusBdcqzsdjxxtmp.setDjlx(regBusBdcqzsdjxx.getDjlx());
					List<RegBusHisHouseBdcqzsdjxx> findList = regBusHisHouseBdcqzsdjxxService.findList(regBusBdcqzsdjxxtmp);
					if(findList.size()>0){
						regBusBdcqzsdjxxnew.setId(findList.get(0).getId());
					}
					regBusHisHouseBdcqzsdjxxService.save(regBusBdcqzsdjxxnew);
				}
			}
	  }
		modelmap.put("ywh", ywh);
	  return modelmap;
	}
	
	/**
	 * 房屋是查封修改from页面
	 * @param regBusCfdj
	 * @param model
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "Fwcfeditform")
	public String Fwcfeditform(RegBusHisHouseCfdj regBusCfdj, Model model, HttpServletRequest request) {
		String ywh = request.getParameter("ywh");
		String ysdm = request.getParameter("YSDM");
		String bdcdyh = request.getParameter("bdcdyh");
		String djlx = request.getParameter("djlx");
		String wo = request.getParameter("WO");
		String selectedIDs = request.getParameter("selectedIDs");
		String zh = request.getParameter("zh");
		String zid = request.getParameter("ZID");
		String optype = request.getParameter("optype");
		String bj = request.getParameter("bj");
		String tdbj = request.getParameter("tdbj");
		String id = request.getParameter("id");
		String cfbj = request.getParameter("cfbj");
		String cflx = "";
		if(StringUtils.isNotBlank(cfbj)) {
			cflx = "907";
		}else {
			cflx="905";
		}
		if(StringUtils.isNotBlank(id)) {
			regBusCfdj = regBusHisHouseCfdjService.get(id);
		}
		if("1".equals(tdbj)){//表示点击的是土地的权属
			//首先查询出权利人信息,土地的权利人没有添加,则直接获取之前的权利人
			RegBusHisHouseBdcqzsdjxx regBusBdcqzsdjxxold_td = new RegBusHisHouseBdcqzsdjxx();
			regBusBdcqzsdjxxold_td.setBdcdyh(regBusCfdj.getBdcdyh());
			regBusBdcqzsdjxxold_td.setIsaudit("0");;
			regBusBdcqzsdjxxold_td.setDjlx("cflx");
			//通过业务号和不动产单元获取正在办理的业务数据
			List<RegBusHisHouseBdcqzsdjxx> bdclist_td = regBusHisHouseBdcqzsdjxxService.findList(regBusBdcqzsdjxxold_td);
			//有办理的业务数据
			if(bdclist_td.size() > 0){
				//当前为查封类型的土地登记信息
				RegBusHisHouseBdcqzsdjxx regBusBdcqzsdjxxnew_td = bdclist_td.get(0);
				//RegBusHisHouseBdcqzsdjxx regBusBdcqzsdjxxnew_td = regBusHisHouseBdcqzsdjxxService.get(regBusBdcqzsdjxxold_td.getOldid());
				//权利人信息列表
				Page<RegBusQlr> qlrpagenew = new Page<RegBusQlr>();
				List<RegBusQlr> qlrlistnew = new ArrayList<RegBusQlr>();
				RegBusQlr zyqlr = new RegBusQlr();
				zyqlr.setYwh(regBusBdcqzsdjxxnew_td.getYwh());
				List<RegBusQlr> qlrlist_1 =  regBusQlrService.findList_1(zyqlr);
				if(qlrlist_1.size() > 0){
					for(int y=0;y<qlrlist_1.size();y++){
						zyqlr = qlrlist_1.get(y);
						zyqlr.setBdcdyh(regBusBdcqzsdjxxnew_td.getBdcdyh());
						qlrlistnew.add(zyqlr);
						qlrpagenew.setList(qlrlistnew);
					}
					model.addAttribute("qlrpage", qlrpagenew);//返回选择后的房屋列表
				}
				Page<RegBaseZdjbxx> zdpage = new Page<RegBaseZdjbxx>();
				List<RegBaseZdjbxx> zdlist = new ArrayList<RegBaseZdjbxx>();
				RegBaseZdjbxx zdjbxx = new RegBaseZdjbxx();
				zdjbxx.setZddm(regBusBdcqzsdjxxold_td.getBdcdyh().substring(0, 19));
				List<RegBaseZdjbxx> zdxxlist =  regBaseZdjbxxService.findList(zdjbxx);
				if(zdxxlist.size() > 0){
					zdjbxx = zdxxlist.get(0);
					zdlist.add(zdjbxx);
					zdpage.setList(zdlist);
					model.addAttribute("zdpage", zdpage);//返回选择后的房屋列表
				}
			}
			model.addAttribute("tdbj", 1);
		}else{
			//首先通过查封权属的当前业务号去登记信息表中查找此业务号所有登记类型为查封的数据,
			//每个查封的登记信息的oldid存的是被查封的为登薄的数据的id,这样就能找出不动产单元号了
			Page<RegBaseH> fwpage = new Page<RegBaseH>();
			List<RegBaseH> fwlist = new ArrayList<RegBaseH>();
			//权利人信息列表
			Page<RegBusQlr> qlrpage = new Page<RegBusQlr>();
			List<RegBusQlr> qlrlist = new ArrayList<RegBusQlr>();
			RegBaseH regBaseH  = new RegBaseH();
			regBaseH.setBdcdyh(regBusCfdj.getBdcdyh());
			List<RegBaseH> Hlist  = regBaseHService.findList(regBaseH);
			if(Hlist.size() > 0){
				regBaseH = Hlist.get(0);
				//把选择后的房屋信息填入list中
				fwlist.add(regBaseH);
				fwpage.setList(fwlist);
				model.addAttribute("fwpage", fwpage);//返回选择后的房屋列表
				//权利人信息
				RegBusRights rightsold_1 = new RegBusRights();
				rightsold_1.setBdcdyh(regBaseH.getBdcdyh());
				List<RegBusRights> bdclist_1 = regBusRightsService.findList(rightsold_1);
				//有办理的业务数据
				if(bdclist_1.size() > 0){
					//正在办理的业务数据
					rightsold_1 = bdclist_1.get(0);
					RegBusQlr zyqlr = new RegBusQlr();
					zyqlr.setYwh(rightsold_1.getSsouyq());
					List<RegBusQlr> qlrlist_1 =  regBusQlrService.findList_1(zyqlr);
					if(qlrlist_1.size() > 0){
						for(int i=0;i<qlrlist_1.size();i++){
							zyqlr = qlrlist_1.get(i);
							zyqlr.setBdcdyh(rightsold_1.getBdcdyh());
							qlrlist.add(zyqlr);
							qlrpage.setList(qlrlist);
						}
						model.addAttribute("qlrpage", qlrpage);//返回选择后的房屋权利人列表
						model.addAttribute("selectedIDs", zyqlr.getId());
					}
				}
			}
		}
		regBusCfdj.setQxdm(Global.getAreaCode());
		model.addAttribute("regBusCfdj", regBusCfdj);
		if(StringUtils.isNotBlank(djlx)){
			model.addAttribute("DJLX", djlx);
		}
		if(StringUtils.isNotBlank(selectedIDs)){
			model.addAttribute("selectedIDs", selectedIDs);
		}
		if(StringUtils.isNotBlank(zh)){
			model.addAttribute("zh", zh);
		}
		if(StringUtils.isNotBlank(zid)){
			model.addAttribute("zid", zid);
		}
		// 传递要素代码
		if (StringUtils.isNotBlank(ywh)) {
			model.addAttribute("YWH",ywh);
			model.addAttribute("YSDM",ysdm );
		}
		// 传递要素代码
		if (StringUtils.isNotBlank(wo)) {
			if(bj != null){
				model.addAttribute("WO","2");
			}else{
				model.addAttribute("WO","1");
			}
		}
		if (StringUtils.isNotBlank(optype)) {
			model.addAttribute("optype","2");
		}
		// 查看标示
		String view = request.getParameter("VIEWS");
		if (StringUtils.isNotBlank(view)) {
			model.addAttribute("VIEWS", view);
		}
		return "modules/reg/bus/regBusHisFwCfdjeditForm";
	}
	
	//房屋查封修改保存
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
		@RequestMapping(value = "Fwcfeditsave")

		public String Fwcfeditsave(RegBusHisHouseCfdj regBusCfdj, Model model, RedirectAttributes redirectAttributes, HttpServletRequest request) {
		   String ywh = request.getParameter("ywh");
		   String qllx = RegUtils.getqllx("905");
			String cfjg = request.getParameter("cfjg");
			String cflx = request.getParameter("cflx");
			String cfwj = request.getParameter("cfwj");
			String cfwh = request.getParameter("cfwh");
			String cfqssj = request.getParameter("cfqssj");
			String cfjssj = request.getParameter("cfjssj");
			String cffw = request.getParameter("cffw");
			String qxdm = request.getParameter("qxdm");
			String fj = request.getParameter("fj");
			String dbr =request.getParameter("dbr");
			String djsj = request.getParameter("djsj");
			String djjg = request.getParameter("djjg");
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		    RegBusHisHouseCfdj cf = new RegBusHisHouseCfdj();
			cf.setYwh(ywh);
			List<RegBusHisHouseCfdj> findList_1 = regBusHisHouseCfdjService.findList(cf);
			if(findList_1.size()>0){
				for(int i=0;i<findList_1.size();i++){
					cf = findList_1.get(i);
					cf.setCfjg(cfjg);
					cf.setCfwh(cfwh);
					cf.setCfwj(cfwj);
					cf.setCffw(cffw);
					cf.setFj(fj);
					try {
						cf.setCfqssj(sdf.parse(cfqssj));
						cf.setCfjssj(sdf.parse(cfqssj));
					} catch (ParseException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					
					regBusHisHouseCfdjService.save(cf);
				}
			}
			RegBusHisHouseBdcqzsdjxx regBusBdcqzsdjxxNew = new RegBusHisHouseBdcqzsdjxx();
			regBusBdcqzsdjxxNew.setYwh(ywh);
			List<RegBusHisHouseBdcqzsdjxx> fwlist = regBusHisHouseBdcqzsdjxxService.findList(regBusBdcqzsdjxxNew);
			if(fwlist.size() > 0 ){
				for(int t=0;t<fwlist.size();t++){
					regBusBdcqzsdjxxNew = fwlist.get(t);
					regBusBdcqzsdjxxNew.setFj(fj);
					regBusHisHouseBdcqzsdjxxService.save(regBusBdcqzsdjxxNew);
				}
			RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx = fwlist.get(0);
			if(StringUtils.isBlank(regBusHisHouseBdcqzsdjxx.getQllx())){
				regBusHisHouseBdcqzsdjxx.setQllx(DictUtils.getDictValue("查封登记", "reg_bus_qllx", ""));
			}
			model.addAttribute("LSH", regBusHisHouseBdcqzsdjxx.getYwh());
			model.addAttribute("regBusHisHouseBdcqzsdjxx", regBusHisHouseBdcqzsdjxx);
			String djxl = request.getParameter("djxl");
			regBusHisHouseBdcqzsdjxx.setDjxl(djxl);
			model.addAttribute("tz", "4");
			if(StringUtils.isNotBlank(djxl)&&djxl.equals("907")) {
				model.addAttribute("cfbj", "ycf");
			}
			}
	       model.addAttribute("xg", "1");
			 return "modules/reg/bus/regBusHisHouseBdcqzsdjxxFormCF";
		}
	
	/**
	 * 房屋预查封from页面
	 * @param regBusCfdj
	 * @param model
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "Fwycfform")
	public String Fwycfform(RegBusCfdj regBusCfdj, Model model, HttpServletRequest request) {
		String ywh = request.getParameter("YWH");
		String ysdm = request.getParameter("YSDM");
		String djlx = request.getParameter("djlx");
		String wo = request.getParameter("WO");
		String selectedIDs = request.getParameter("selectedIDs");
		String zh = request.getParameter("zh");
		String zid = request.getParameter("ZID");
		String optype = request.getParameter("optype");
		String bj = request.getParameter("bj");
		Page<RegBaseH> fwpage = new Page<RegBaseH>();
		if(StringUtils.isNotEmpty(selectedIDs)){
			model.addAttribute("IDS", selectedIDs);
			String bdcdyh = "";
			String[] idList = selectedIDs.split(";");
			List<RegBaseH> fwlist = new ArrayList<RegBaseH>();
			//权利人信息列表
			Page<RegBusQlr> qlrpage = new Page<RegBusQlr>();
			List<RegBusQlr> qlrlist = new ArrayList<RegBusQlr>();
			for(String fwid : idList){
				RegBaseH regBaseH  = regBaseHService.get(fwid);
				model.addAttribute("BDCDYH", regBaseH.getBdcdyh());
				//把选择后的房屋信息填入list中
				fwlist.add(regBaseH);
				//权利人信息
				RegBusBdcqzsdjxx regBusBdcqzsdjxxold_1 = new RegBusBdcqzsdjxx();
				regBusBdcqzsdjxxold_1.setBdcdyh(regBaseH.getBdcdyh());
				regBusBdcqzsdjxxold_1.setIslogout("907");
				regBusBdcqzsdjxxold_1.setRights("4");
				regBusBdcqzsdjxxold_1.setDjlx("");
				//通过业务号和不动产单元获取正在办理的业务数据
				List<RegBusBdcqzsdjxx> bdclist_1 = regBusBdcqzsdjxxService.findcfList(regBusBdcqzsdjxxold_1);
				//有办理的业务数据
				if(bdclist_1.size() > 0){
					//正在办理的业务数据
					regBusBdcqzsdjxxold_1 = bdclist_1.get(0);
					regBusCfdj.setBdcdyh(regBusBdcqzsdjxxold_1.getBdcdyh().substring(0, 19)+"00000000");
					RegBusQlr zyqlr = new RegBusQlr();
					zyqlr.setYwh(regBusBdcqzsdjxxold_1.getYwh());
					List<RegBusQlr> qlrlist_1 =  regBusQlrService.findList_1(zyqlr);
					if(qlrlist_1.size() > 0){
						for(int i=0;i<qlrlist_1.size();i++){
							zyqlr = qlrlist_1.get(i);
							zyqlr.setBdcdyh(regBusBdcqzsdjxxold_1.getBdcdyh());
							qlrlist.add(zyqlr);
							qlrpage.setList(qlrlist);
						}
						model.addAttribute("qlrpage", qlrpage);//返回选择后的房屋列表
						model.addAttribute("selectedIDs", zyqlr.getId());
					}
				}
			}
			fwpage.setList(fwlist);
			model.addAttribute("fwpage", fwpage);//返回选择后的房屋列表
		}
		regBusCfdj.setCflx("3");
		regBusCfdj.setQxdm(Global.getAreaCode());
		model.addAttribute("regBusCfdj", regBusCfdj);
		if(StringUtils.isNotBlank(djlx)){
			model.addAttribute("DJLX", djlx);
		}
		if(StringUtils.isNotBlank(selectedIDs)){
			model.addAttribute("selectedIDs", selectedIDs);
		}
		if(StringUtils.isNotBlank(zh)){
			model.addAttribute("zh", zh);
		}
		if(StringUtils.isNotBlank(zid)){
			model.addAttribute("zid", zid);
		}
		// 传递要素代码
		if (StringUtils.isNotBlank(ywh)) {
			model.addAttribute("YWH",ywh);
			model.addAttribute("YSDM",ysdm );
		}
		// 传递要素代码
		if (StringUtils.isNotBlank(wo)) {
			if(bj != null){
				model.addAttribute("WO","2");
			}else{
				model.addAttribute("WO","1");
			}
		}
		if (StringUtils.isNotBlank(optype)) {
			model.addAttribute("optype","2");
		}
		// 查看标示
		String view = request.getParameter("VIEWS");
		if (StringUtils.isNotBlank(view)) {
			model.addAttribute("VIEWS", view);
		}
		return "modules/reg/bus/regBusHisFwYcfdjForm";
	}
	
	/**
	 * 房屋预查封登记信息保存
	 * @param regBusCfdj
	 * @param model
	 * @param redirectAttributes
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "Fwycfsave")
	public String Fwycfsave(RegBusCfdj regBusCfdj, Model model, RedirectAttributes redirectAttributes, HttpServletRequest request) {
		
		String ywh = request.getParameter("YWH");
		String ids = request.getParameter("selectedIDs");
		String qllx = RegUtils.getqllx("907");
		//首先获取通过楼盘已选择的房屋信息列表
		//选择的 房屋信息
		String[] idList = ids.split(";");
		if(StringUtils.isNotBlank(request.getParameter("YWH"))){
			//查询当前ywh是不是在已登记信息表里已经有数据了,如果有了就删除掉
			RegBusBdcqzsdjxx regBusBdcqzsdjxxC = new RegBusBdcqzsdjxx();
			regBusBdcqzsdjxxC.setYwh(ywh);
			regBusBdcqzsdjxxC.setDjlx("907");
			List<RegBusBdcqzsdjxx> regedList = regBusBdcqzsdjxxService.findList(regBusBdcqzsdjxxC);
			if(regedList.size() > 0){
				for(int i=0; i<regedList.size(); i++){
					regBusBdcqzsdjxxC = regedList.get(i);
					if(StringUtils.isNotBlank(regBusBdcqzsdjxxC.getYwh().replace(" ",""))){
						RegBusBdcqzsdjxx regBusBdcqzsdjxx_1 = new RegBusBdcqzsdjxx();
						regBusBdcqzsdjxx_1.setYwh(regBusBdcqzsdjxxC.getYwh());
						regBusBdcqzsdjxxService.deletezyyg(regBusBdcqzsdjxx_1);
					}
				}
			}
			//查询当前ywh是不是在历史登记信息表里已经有数据了,如果有了就删除掉
			RegBusHisHouseBdcqzsdjxx hisBdcqzsdjxxC = new RegBusHisHouseBdcqzsdjxx();
			hisBdcqzsdjxxC.setYwh(ywh);
			hisBdcqzsdjxxC.setDjlx("907");
			List<RegBusHisHouseBdcqzsdjxx> reghisedList = regBusHisHouseBdcqzsdjxxService.findList(hisBdcqzsdjxxC);
			if(reghisedList.size() > 0){
				for(int i=0; i<reghisedList.size(); i++){
					hisBdcqzsdjxxC = reghisedList.get(i);
					if(StringUtils.isNotBlank(hisBdcqzsdjxxC.getYwh().replace(" ",""))){
						RegBusHisHouseBdcqzsdjxx regBusBdcqzsdjxx_2 = new RegBusHisHouseBdcqzsdjxx();
						regBusBdcqzsdjxx_2.setYwh(hisBdcqzsdjxxC.getYwh());
						regBusHisHouseBdcqzsdjxxService.delete(regBusBdcqzsdjxx_2);
					}
				}
			}
			regBusQlrService.deleteywh(request.getParameter("YWH"));
			RegBusCfdj cf = new RegBusCfdj();
			cf.setYwh(request.getParameter("YWH"));
			regBusCfdjService.deletefwycf(cf);
		}
		
		RegBaseH regBaseHold = regBaseHService.get(idList[0]);//房屋基本信息
		RegBusBdcqzsdjxx regBusBdcqzsdjxxold_1 = new RegBusBdcqzsdjxx();
		regBusBdcqzsdjxxold_1.setBdcdyh(regBaseHold.getBdcdyh());
		regBusBdcqzsdjxxold_1.setRights("4");
		regBusBdcqzsdjxxold_1.setIslogout("907");
		//通过业务号和不动产单元获取正在办理的业务数据
		List<RegBusBdcqzsdjxx> bdclistold = regBusBdcqzsdjxxService.findcfList(regBusBdcqzsdjxxold_1);
		if(bdclistold.size() > 0){
			regBusBdcqzsdjxxold_1 = bdclistold.get(0);
			RegBusQlr regBusQlr_1 = new RegBusQlr();
			regBusQlr_1.setYwh(regBusBdcqzsdjxxold_1.getYwh());
			List<RegBusQlr> list_1 = regBusQlrService.findList_1(regBusQlr_1);
			if(list_1 != null && list_1.size()>0){
				for(int i=0;i<list_1.size();i++){
					//已登记信息的权利人
					regBusQlr_1 = list_1.get(i);
					RegBusQlr regBusQlr = new RegBusQlr();
					regBusQlr = regBusQlr_1;
					regBusQlr.setYwh(ywh);
					regBusQlr.setId("");
					regBusQlr.setQszt("0");
					regBusQlr.setQllx(qllx);
					regBusQlrService.save(regBusQlr);
					RegBusYwr ywr = new RegBusYwr();
					BeanUtils.copyProperties(regBusQlr, ywr);
					ywr.setId("");
					regBusYwrService.save(ywr);
				}
			}
		}
		//再次循环进行新数据的插入
		for(String id_1 : idList){
			RegBaseH regBaseH = regBaseHService.get(id_1);//房屋基本信息
			//查封楼盘信息
			//查封楼盘信息
			int Ischafeng = 0;
			if (StringUtils.isNotBlank(regBaseH.getIschafeng())) {
				Ischafeng = Integer.parseInt(regBaseH.getIschafeng());
			}
			if(Ischafeng >= 100){
				Ischafeng = Ischafeng+1;
			}else{
				if(Ischafeng == 0){
					Ischafeng = 100;
				}
			}
			regBaseH.setIschafeng(String.valueOf(Ischafeng));
			regBaseHService.save(regBaseH);
			
			RegBusBdcqzsdjxx regBusBdcqzsdjxxold = new RegBusBdcqzsdjxx();
			regBusBdcqzsdjxxold.setBdcdyh(regBaseH.getBdcdyh());
			regBusBdcqzsdjxxold.setIslogout("907");
			regBusBdcqzsdjxxold.setRights("10");//为预查封加条件只查封出虚权的所有数据
			//通过业务号和不动产单元获取正在办理的业务数据
			List<RegBusBdcqzsdjxx> bdclist = regBusBdcqzsdjxxService.findcfList(regBusBdcqzsdjxxold);
			int t = bdclist.size();
			if(t > 0){
				//保存查封登记信息
				RegBusCfdj cfdj = new RegBusCfdj();
				cfdj = regBusCfdj;
				cfdj.setDjlx("907");
				cfdj.setDjsj(null);
				cfdj.setCflx("3");
				cfdj.setDbr(null);
				cfdj.setDjjg(null);
				cfdj.setJfdjsj(null);
				cfdj.setId("");
				cfdj.setYwh(ywh);
				cfdj.setBdcdyh(regBaseH.getBdcdyh());
				//防止重复类似发证的提交,需要判断每个业务号,每个单元号只能有一条记录,判断当前业务号已经有记录时就做update
				RegBusCfdj cf = new RegBusCfdj();
				cf.setYwh(ywh);
				cf.setBdcdyh(regBaseH.getBdcdyh());
				List<RegBusCfdj> findList_1 = regBusCfdjService.findList(cf);
				if(findList_1.size()>0){
					cfdj.setId(findList_1.get(0).getId());
				}
				cfdj.setQszt("0");
				regBusCfdjService.save(cfdj);
				addMessage(redirectAttributes, "保存查封登记信息成功");
				//此不动产单元号有几条未注销的有效数据就查封注销几条
				for(int i=0;i<t;i++){
					//新增一条数据
					RegBusBdcqzsdjxx regBusBdcqzsdjxxnew  = new RegBusBdcqzsdjxx();
					RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx = new RegBusHisHouseBdcqzsdjxx();
					//正在办理的业务数据
					regBusBdcqzsdjxxold = bdclist.get(i);
					regBusBdcqzsdjxxnew = regBusBdcqzsdjxxold;
					//获取共有方式
					RegBusQlr qlr = new RegBusQlr();
					qlr.setYwh(regBusBdcqzsdjxxold.getYwh());
					List<RegBusQlr> qlrlist = regBusQlrService.findList_1(qlr);
					if(qlrlist.size() > 0){
						qlr = qlrlist.get(0);
						regBusBdcqzsdjxxnew.setGyqk(DictUtils.getDictLabel(qlr.getGyfs(), "reg_bus_gyfs", ""));
					}
					//业务登记表
					regBusBdcqzsdjxxnew.setOldid(regBusBdcqzsdjxxold.getId());
					regBusBdcqzsdjxxnew.setDbsj(null);
					regBusBdcqzsdjxxnew.setFzsj(null);
					regBusBdcqzsdjxxnew.setDelFlag("0");
					regBusBdcqzsdjxxnew.setId("");
					regBusBdcqzsdjxxnew.setDjlx("907");
					regBusBdcqzsdjxxnew.setIslogout("0");
					regBusBdcqzsdjxxnew.setFj(regBusCfdj.getFj());
					regBusBdcqzsdjxxnew.setQllx(qllx);
					regBusBdcqzsdjxxnew.setStatus(null);
					regBusBdcqzsdjxxnew.setIsfdsj(Integer.valueOf("0"));
					regBusBdcqzsdjxxnew.setYwh(ywh);
					
					//历史登记表
					regBusHisHouseBdcqzsdjxx.setBdcqzh(regBusBdcqzsdjxxold.getBdcqzh());
					regBusHisHouseBdcqzsdjxx.setBdcdyh(regBusBdcqzsdjxxold.getBdcdyh());
					regBusHisHouseBdcqzsdjxx.setBdcqzbh(regBusBdcqzsdjxxold.getBdcqzbh());
					regBusHisHouseBdcqzsdjxx.setFdzl(regBusBdcqzsdjxxold.getZl());
					regBusHisHouseBdcqzsdjxx.setFzsj(null);
					regBusHisHouseBdcqzsdjxx.setDelFlag("0");
					regBusHisHouseBdcqzsdjxx.setId("");
					regBusHisHouseBdcqzsdjxx.setDjlx("907");
					regBusHisHouseBdcqzsdjxx.setIsaudit("0");
					regBusHisHouseBdcqzsdjxx.setFj(cfdj.getFj());
					regBusHisHouseBdcqzsdjxx.setQllx(qllx);
					regBusHisHouseBdcqzsdjxx.setYwh(ywh);
					//防止重复类似发证的提交,需要判断每个业务号只能有一条记录,判断当前业务号已经有记录时就做update
					RegBusBdcqzsdjxx regBusBdcqzsdjxxtmp = new RegBusBdcqzsdjxx();
					regBusBdcqzsdjxxtmp.setYwh(ywh);
					regBusBdcqzsdjxxtmp.setBdcdyh(regBusBdcqzsdjxxold.getBdcdyh());
					regBusBdcqzsdjxxtmp.setRights(regBusBdcqzsdjxxold.getRights());
					regBusBdcqzsdjxxtmp.setDjlx(regBusBdcqzsdjxxold.getDjlx());
					List<RegBusBdcqzsdjxx> findList = regBusBdcqzsdjxxService.findList(regBusBdcqzsdjxxtmp);
					if(findList.size()>0){
						regBusBdcqzsdjxxnew.setId(findList.get(0).getId());
					}
					regBusBdcqzsdjxxService.save(regBusBdcqzsdjxxnew);
					
					//历史登记表
					RegBusHisHouseBdcqzsdjxx regBusHisBdcqzsdjxxtmp = new RegBusHisHouseBdcqzsdjxx();
					regBusHisBdcqzsdjxxtmp.setYwh(ywh);
					regBusHisBdcqzsdjxxtmp.setBdcdyh(regBusBdcqzsdjxxold.getBdcdyh());
					regBusHisBdcqzsdjxxtmp.setDjlx(regBusBdcqzsdjxxold.getDjlx());
					List<RegBusHisHouseBdcqzsdjxx> findHisList = regBusHisHouseBdcqzsdjxxService.findList(regBusHisBdcqzsdjxxtmp);
					if(findHisList.size()>0){
						regBusHisHouseBdcqzsdjxx.setId(findHisList.get(0).getId());
					}
					regBusHisHouseBdcqzsdjxxService.save(regBusHisHouseBdcqzsdjxx);
				}
			}
	  }
	  return "redirect:"+Global.getAdminPath()+"/reg/bus/regBusHisHouseBdcqzsdjxx/fwcflist?WO=1&ywh="+ywh+"&cfbj=ycf";
	}
	
	
	/**
	 * 房屋查封删除
	 * @param regBusCfdj
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusHisHouseBdcqzsdjxx:view")
	@RequestMapping(value = "fwcfdelete")
	public String fwcfdelete(RegBusHisHouseCfdj regBusCfdj,Model model, HttpServletRequest request,RedirectAttributes redirectAttributes) {
		   RegBusHisHouseCfdj cfdj = new RegBusHisHouseCfdj();
		   RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx = new RegBusHisHouseBdcqzsdjxx();
				   
		if(StringUtils.isNotBlank(request.getParameter("id"))){
			cfdj = regBusHisHouseCfdjService.get(request.getParameter("id"));
			if(cfdj != null) {
			regBusHisHouseQlrService.deleteywh(cfdj.getYwh());
			List<RegBusHisHouseBdcqzsdjxx> djxxlist = regBusHisHouseBdcqzsdjxxService.findByYwh(cfdj.getYwh());
			if(djxxlist.size()>0) {
				regBusHisHouseBdcqzsdjxx = djxxlist.get(0);
			}
			regBusHisHouseBdcqzsdjxxService.deleteywh(cfdj.getYwh());
			
			RegBaseZdjbxx zdjbxx = new RegBaseZdjbxx();
			zdjbxx.setZddm(cfdj.getBdcdyh().substring(0, 19));
			List<RegBaseZdjbxx> findList = regBaseZdjbxxService.findList(zdjbxx);
			if(findList.size()>0){
				zdjbxx = findList.get(0);
				zdjbxx.setIschafeng("0");
				regBaseZdjbxxService.save(zdjbxx);
			}
			regBusHisHouseCfdjService.delete(cfdj);
			addMessage(redirectAttributes, "删除查封历史登记信息成功");
		}
		}
		if(StringUtils.isBlank(regBusHisHouseBdcqzsdjxx.getQllx())){
			regBusHisHouseBdcqzsdjxx.setQllx(DictUtils.getDictValue("查封登记", "reg_bus_qllx", ""));
		}
		model.addAttribute("LSH", regBusHisHouseBdcqzsdjxx.getYwh());
		model.addAttribute("regBusHisHouseBdcqzsdjxx", regBusHisHouseBdcqzsdjxx);
		String djxl = request.getParameter("djxl");
		regBusHisHouseBdcqzsdjxx.setDjxl(djxl);
		model.addAttribute("tz", "4");
		if(StringUtils.isNotBlank(djxl)&&djxl.equals("907")) {
			model.addAttribute("cfbj", "ycf");
		}
		 return "modules/reg/bus/regBusHisHouseBdcqzsdjxxFormCF";
	}
	
	/**
	 * 限制非历史首次登记是否能够保存业务数据
	 * @param request
	 * @return
	 */
	@RequiresPermissions("reg:bus:regBusBdcqzsdjxx:view")
	@RequestMapping(value = "ishistory")
	@ResponseBody
	public ModelMap ishistory(HttpServletRequest request) {
		ModelMap modelmap = new ModelMap();
		String ids = request.getParameter("selectedIDs");
		//首先获取通过楼盘已选择的房屋信息列表
		//选择的 房屋信息
		String[] idList = ids.split(";");
		for(String id : idList){
			RegBaseH h=regBaseHService.get(id);
			String bdcdyh = h.getBdcdyh();
			RegBusHisHouseBdcqzsdjxx regBusBdcqzsdjxxold = new RegBusHisHouseBdcqzsdjxx();
			regBusBdcqzsdjxxold.setBdcdyh(bdcdyh);
			//通过业务号和不动产单元获取正在办理的所有业务数据,历史首次才能历史查封,否则走流程
			List<RegBusHisHouseBdcqzsdjxx> bdclist = regBusHisHouseBdcqzsdjxxService.findList(regBusBdcqzsdjxxold);
		    if(bdclist.size()>0) {
		    	modelmap.put("success", "0");
		    }else {
		    	modelmap.put("success", "1");
				modelmap.put("msg", "未查询到 "+h.getShbw()+" 首次登记信息");
				return modelmap;
		    }
		}
		
		return modelmap;
	}
	
	@RequestMapping(value = "unauditDY")
	@ResponseBody
	public  ModelMap unauditDY(HttpServletRequest request,Model model) {
		String ids = request.getParameter("ids");
		ModelMap modelMap = new ModelMap();
		RegBusHisHouseBdcqzsdjxx hisdjxx =  regBusHisHouseBdcqzsdjxxService.get(ids);
		try {
			regBusHisHouseBdcqzsdjxxService.unauditDY(hisdjxx);
			modelMap.put("success", 0);
		} catch (Exception e) {
			modelMap.put("success", 1);
			modelMap.put("msg", e.getMessage());
		}
		return modelMap;
	}
	
	
	

}