5df2184f02097619afd6b07ac5621b8bb3b1fa2f.svn-base 38.9 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
package com.thinkgem.jeesite.modules.reg.web.httprest.httpRestService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.service.ServiceException;
import com.thinkgem.jeesite.common.utils.xml.JXmlUtils;
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.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.RegBusDyaq;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusFdcq2;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusQlr;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusSlsq;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusYgdj;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusYydj;
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.RegBaseZdjbxxService;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseZrzService;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseZsglbService;
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.RegBusQlrService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusSlsqService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusYgdjService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusYydjService;
import com.thinkgem.jeesite.modules.reg.utils.RegUtils;
import com.thinkgem.jeesite.modules.sys.utils.DictUtils;

@Service
public class DbbwService {

	private final String qxdm = Global.getAreaCode();
	@Autowired
	private RegBusQlrService regBusQlrService;

	@Autowired
	private RegBusBdcqzsdjxxService regBusBdcqzsdjxxService;

	@Autowired
	private RegBaseZrzService regBaseZrzService;

	@Autowired
	private RegBaseHService regBaseHService;

	@Autowired
	private RegBaseCService regBaseCService;

	@Autowired
	private RegBusFdcq2Service regBusFdcq2Service;

	@Autowired
	private RegBusCfdjService regBusCfdjService;

	@Autowired
	private RegBusYydjService regBusYydjService;

	@Autowired
	private RegBusSlsqService regBusSlsqService;

	@Autowired
	private RegBusYgdjService regBusYgdjService;

	@Autowired
	private RegBusDyaqService regBusDyaqService;

	@Autowired
	private RegBaseZdjbxxService regBaseZdjbxxService;

	/**
	 * 首次登记 207 房屋建筑物所有权首次登记
	 */
	public Map createXml207(String ywh, String djxl, String bdcdyh) {
		Map data = Maps.newHashMap();
		List<String> bdcdyhs = Lists.newArrayList();
		List<String> cqzhs = Lists.newArrayList();

		StringBuffer xml = new StringBuffer();
		List<RegBusBdcqzsdjxx> djxxlst = getDjxxByYwh(ywh, bdcdyh, null);
		if (djxxlst == null || djxxlst.size() <= 0) {
			throw new ServiceException("系统未找到业务号[ywh]" + ywh + "不动产单元号[bdcdyh]" + bdcdyh + "对应的不动产权证书登记信息");
		}
		if (djxxlst.size() > 1) {
			throw new ServiceException("系统发现业务号[ywh]" + ywh + "不动产单元号[bdcdyh]" + bdcdyh + "对应的不动产权证书登记信息存在多条数据");
		}
		List<RegBusQlr> qlrlst = getQlrByYwh(ywh);
		if (qlrlst == null || qlrlst.size() <= 0) {
			throw new ServiceException("系统未找到业务号[ywh]对应的权利人登记信息");
		}

		StringBuffer qlrxmls = new StringBuffer();
		StringBuffer hxmls = new StringBuffer();
		StringBuffer cxmls = new StringBuffer();
		StringBuffer zxmls = new StringBuffer();
		StringBuffer fdcqxmls = new StringBuffer();

		List<String> cs = Lists.newArrayList();
		List<String> zs = Lists.newArrayList();

		RegBusBdcqzsdjxx djxx = djxxlst.get(0);
			RegBaseH regbaseh_fybh = regBaseHService.getIslogout(djxx.getBdcdyh());
			if (StringUtils.isBlank(regbaseh_fybh.getBtfwbm())) {
				throw new ServiceException("系统未找到单元号为:" + regbaseh_fybh.getBdcdyh() + "对应的房屋序号");
			}

			if (!bdcdyhs.contains(djxx.getBdcdyh())) {
				bdcdyhs.add(djxx.getBdcdyh());
			}
			if (!cqzhs.contains(djxx.getBdcqzh())) {
				cqzhs.add(djxx.getBdcqzh());
			}

			List<RegBusFdcq2> fdcq2lst = getFdcq2ByYwh(ywh, bdcdyh);
			if (fdcq2lst == null || fdcq2lst.size() <= 0) {
				throw new ServiceException("系统未找到不动产单元号[bdcdyh]对应的房地产权信息");
			}
			RegBusFdcq2 fdcq2 = fdcq2lst.get(0);

			for (int i = 0; i < qlrlst.size(); i++) {
				RegBusQlr qlr = qlrlst.get(i);

				String qlrxml = RegUtils.QlrzhuanStrToycsl(qlr, qxdm, djxx.getBdcdyh(), fdcq2.getBdcqzh(),
						regbaseh_fybh.getBtfwbm());
				qlrxmls.append(qlrxml);
			}
			bdcdyh = djxx.getBdcdyh();

			RegBaseH regbaseh = regBaseHService.getIslogout(bdcdyh);
			if (regbaseh == null || regbaseh.getId() == null) {
				throw new ServiceException("系统未找到不动产单元号[bdcdyh]对应的户基本信息");
			}
			String hxml = RegUtils.HzhuanStrToycsl(regbaseh, qxdm);
			hxmls.append(hxml);

			RegBaseC regBaseC = regBaseCService.get(regbaseh.getCid());
			if (regBaseC == null || regBaseC.getId() == null) {
				throw new ServiceException("系统未找到不动产单元号[bdcdyh]对应的层基本信息");
			}
			if (!cs.contains(regBaseC.getId())) {
				String cxml = RegUtils.CzhuanStr(regBaseC, qxdm);
				cxmls.append(cxml);
				cs.add(regBaseC.getId());
			}

			RegBaseZrz regBaseZrz = regBaseZrzService.get(regBaseC.getZid());
			if (regBaseZrz == null || regBaseZrz.getId() == null) {
				throw new ServiceException("系统未找到不动产单元号[bdcdyh]对应的幢基本信息");
			}
			if (!zs.contains(regBaseZrz.getId())) {
				Map<String, Object> zrzmap = getzrzinfo(regBaseZrz);
				String zrzxml = RegUtils.ZrzzhuanStrToycsl(regBaseZrz, qxdm, zrzmap);
				zxmls.append(zrzxml);
				zs.add(regBaseZrz.getId());
			}

			String fdcqxml = RegUtils.Fdcq2zhuanStrToycsl(fdcq2, regbaseh_fybh.getBtfwbm(),regbaseh);
			fdcqxmls.append(fdcqxml);
		 
		xml.append(qlrxmls).append(hxmls).append(cxmls).append(zxmls).append(fdcqxmls);
		// 拼装报文
		StringBuffer headxml = createXmlhead(djxx);
		StringBuffer xmls = createXml(xml, headxml);
		data.put("bdcdyh", StringUtils.join(bdcdyhs, ","));
		data.put("cqzh", StringUtils.join(cqzhs, ","));
		data.put("xml", xmls.toString());
		return data;
	}

	/**
	 * 查封登记 905 房屋建筑物所有权转移登记
	 * 
	 * @param ywh
	 * @return
	 */
	public Map createXml905(String ywh, String djxl, String bdcdyh) {
		Map data = Maps.newHashMap();
		List<String> bdcdyhs = Lists.newArrayList();
		List<String> cqzhs = Lists.newArrayList();

		StringBuffer xml = new StringBuffer();
		RegBusBdcqzsdjxx regBusBdcqzsdjxx = new RegBusBdcqzsdjxx();
		regBusBdcqzsdjxx.setYwh(ywh);
		regBusBdcqzsdjxx.setDjlx(djxl);
		switch (ywh) {
			case "902":
			case "903":
			case "905":
			case "910":
			case "907":
				regBusBdcqzsdjxx.setIslogout("0");
				break;
			case "906":
			case "908": 
			case "912":
				regBusBdcqzsdjxx.setIslogout("2"); 
				break; 
		default:
			break;
		} 
		
		List<RegBusBdcqzsdjxx> djxxlst = regBusBdcqzsdjxxService.findzyList(regBusBdcqzsdjxx);
		if (djxxlst == null || djxxlst.size() <= 0) {
			throw new ServiceException("系统未找到业务号["+ywh+"]对应的不动产权证书登记信息");
		}
		RegBusBdcqzsdjxx djxx = djxxlst.get(0);
			RegBaseH regbaseh_fybh = regBaseHService.getIslogout(djxx.getBdcdyh());
			if (StringUtils.isBlank(regbaseh_fybh.getBtfwbm() )) {
				throw new ServiceException("系统未找到单元号为:" + regbaseh_fybh.getBdcdyh() + "对应的房屋序号");
			}

			if (!bdcdyhs.contains(djxx.getBdcdyh())) {
				bdcdyhs.add(djxx.getBdcdyh());
			}
			if (!cqzhs.contains(djxx.getBdcqzh())) {
				cqzhs.add(djxx.getBdcqzh());
			}

			bdcdyh = djxx.getBdcdyh();
			// 查找查封业务信息
			RegBusCfdj cfdj = new RegBusCfdj();
			cfdj.setQxdm(Global.getAreaCode());
			cfdj.setBdcdyh(djxx.getBdcdyh());
			if ("905".equals(djxl) || "907".equals(djxl) || "910".equals(djxl)) {
				cfdj.setYwh(djxx.getYwh());
			} else {
				cfdj.setJfywh(djxx.getYwh());
			}
			List<RegBusCfdj> cfdjlist = regBusCfdjService.findList(cfdj);
			if (cfdjlist == null || cfdjlist.size() <= 0) {
				throw new ServiceException("系统未找到不动产单元号[bdcdyh]对应的查封登记信息");
			}
			cfdj = cfdjlist.get(0);
			if (StringUtils.isBlank(cfdj.getBdcdyh())) {
				cfdj.setBdcdyh(djxx.getBdcdyh());
			}
			String cfxml = RegUtils.CCfdjzhuanStrToycsl(cfdj, regbaseh_fybh.getBtfwbm());
			xml.append(cfxml); 
			
			RegBaseH regbaseh = regBaseHService.getIslogout(bdcdyh);
			if (regbaseh != null && regbaseh.getId() != null) {
				String hxml = RegUtils.HzhuanStrToycsl(regbaseh, qxdm);
				xml.append(hxml);
			}
			
			
			
		// 拼装报文
		StringBuffer headxml = createXmlhead(djxx);
		StringBuffer xmls = createXml(xml, headxml);
		data.put("bdcdyh", StringUtils.join(bdcdyhs, ","));
		data.put("cqzh", StringUtils.join(cqzhs, ","));
		data.put("xml", xmls.toString());
		return data;
	}

	/**
	 * 异议登记 905 房屋建筑物所有权异议登记
	 * 
	 * @param ywh
	 * @return
	 */
	public Map createXml703(String ywh, String djxl, String bdcdyh) {
		Map data = Maps.newHashMap();
		List<String> bdcdyhs = Lists.newArrayList();
		List<String> cqzhs = Lists.newArrayList();

		StringBuffer xml = new StringBuffer();
		StringBuffer qlrxmls = new StringBuffer();
		StringBuffer yyxmls = new StringBuffer();
		RegBusBdcqzsdjxx regBusBdcqzsdjxx = new RegBusBdcqzsdjxx();
		regBusBdcqzsdjxx.setYwh(ywh);
		regBusBdcqzsdjxx.setDjlx(djxl);
		regBusBdcqzsdjxx.setIslogout("0");
		List<RegBusBdcqzsdjxx> djxxlst = regBusBdcqzsdjxxService.findzyList(regBusBdcqzsdjxx);
		if (djxxlst == null || djxxlst.size() <= 0) {
			throw new ServiceException("系统未找到业务号[ywh]对应的不动产权证书登记信息");
		}
		List<RegBusQlr> qlrlst = getQlrByYwh(ywh);
		if (qlrlst == null || qlrlst.size() <= 0) {
			throw new ServiceException("系统未找到业务号[ywh]对应的权利人登记信息");
		}

		RegBusBdcqzsdjxx djxx = djxxlst.get(0);
			RegBaseH regbaseh_fybh = regBaseHService.getIslogout(djxx.getBdcdyh());
			if (StringUtils.isBlank(regbaseh_fybh.getBtfwbm() )) {
				throw new ServiceException("系统未找到单元号为:" + regbaseh_fybh.getBdcdyh() + "对应的房屋序号");
			}

			if (!bdcdyhs.contains(djxx.getBdcdyh())) {
				bdcdyhs.add(djxx.getBdcdyh());
			}
			if (!cqzhs.contains(djxx.getBdcqzh())) {
				cqzhs.add(djxx.getBdcqzh());
			}

			bdcdyh = djxx.getBdcdyh();
			for (int i = 0; i < qlrlst.size(); i++) {
				RegBusQlr qlr = qlrlst.get(i);

				String qlrxml = RegUtils.QlrzhuanStrToycsl(qlr, qxdm, djxx.getBdcdyh(), djxx.getBdcqzh(),
						regbaseh_fybh.getBtfwbm()  );
				qlrxmls.append(qlrxml);
			}
			// 查找查封业务信息
			RegBusYydj yydj = new RegBusYydj();
			yydj.setBdcdyh(djxx.getBdcdyh());
			yydj.setYwh(djxx.getYwh());
			List<RegBusYydj> yydjlist = regBusYydjService.findList(yydj);
			if (yydjlist == null || yydjlist.size() <= 0) {
				throw new ServiceException("系统未找到不动产单元号[bdcdyh]对应的异议登记信息");
			}
			yydj = yydjlist.get(0);
			if (StringUtils.isBlank(yydj.getBdcdyh())) {
				yydj.setBdcdyh(djxx.getBdcdyh());
			}
			String yyxml = RegUtils.YydjzhuanStrToycsl(yydj, regbaseh_fybh.getBtfwbm() );
			yyxmls.append(yyxml); 
		xml.append(qlrxmls).append(yyxmls);
		// 拼装报文
		StringBuffer headxml = createXmlhead(djxx);
		StringBuffer xmls = createXml(xml, headxml);
		data.put("bdcdyh", StringUtils.join(bdcdyhs, ","));
		data.put("cqzh", StringUtils.join(cqzhs, ","));
		data.put("xml", xmls.toString());
		return data;
	}

	/**
	 * 更正登记 302 房屋建筑物所有权更正登记
	 * 
	 * @param ywh
	 * @return
	 */
	public Map createXml604(String ywh, String djxl, String bdcdyh) {
		Map data = Maps.newHashMap();
		List<String> bdcdyhs = Lists.newArrayList();
		List<String> cqzhs = Lists.newArrayList();

		StringBuffer xml = new StringBuffer();
		List<RegBusBdcqzsdjxx> djxxlst = getDjxxByYwh(ywh, bdcdyh, null);
		if (djxxlst == null || djxxlst.size() <= 0) {
			throw new ServiceException("系统未找到业务号[ywh]对应的不动产权证书登记信息");
		}
		List<RegBusQlr> qlrlst = getQlrByYwh(ywh);
		if (qlrlst == null || qlrlst.size() <= 0) {
			throw new ServiceException("系统未找到业务号[ywh]对应的权利人登记信息");
		}

		StringBuffer qlrxmls = new StringBuffer();
		StringBuffer hxmls = new StringBuffer();
		StringBuffer cxmls = new StringBuffer();
		StringBuffer zxmls = new StringBuffer();
		StringBuffer fdcqxmls = new StringBuffer();

		List<String> cs = Lists.newArrayList();
		List<String> zs = Lists.newArrayList();

		RegBusBdcqzsdjxx djxx = djxxlst.get(0);
			RegBaseH regbaseh_fybh = regBaseHService.getIslogout(djxx.getBdcdyh());
			if (StringUtils.isBlank(regbaseh_fybh.getBtfwbm() )) {
				throw new ServiceException("系统未找到单元号为:" + regbaseh_fybh.getBdcdyh() + "对应的房屋序号");
			}

			if (!bdcdyhs.contains(djxx.getBdcdyh())) {
				bdcdyhs.add(djxx.getBdcdyh());
			}
			if (!cqzhs.contains(djxx.getBdcqzh())) {
				cqzhs.add(djxx.getBdcqzh());
			}

			for (int i = 0; i < qlrlst.size(); i++) {
				RegBusQlr qlr = qlrlst.get(i);

				String qlrxml = RegUtils.QlrzhuanStrToycsl(qlr, qxdm, djxx.getBdcdyh(), djxx.getBdcqzh(),
						regbaseh_fybh.getBtfwbm());
				qlrxmls.append(qlrxml);
			}
			bdcdyh = djxx.getBdcdyh();

			RegBaseH regbaseh = regBaseHService.getIslogout(bdcdyh);
			if (regbaseh == null || regbaseh.getId() == null) {
				throw new ServiceException("系统未找到不动产单元号[bdcdyh]对应的户基本信息");
			}
			String hxml = RegUtils.HzhuanStrToycsl(regbaseh, qxdm);
			hxmls.append(hxml);

			RegBaseC regBaseC = regBaseCService.get(regbaseh.getCid());
			if (regBaseC == null || regBaseC.getId() == null) {
				throw new ServiceException("系统未找到不动产单元号[bdcdyh]对应的层基本信息");
			}
			if (!cs.contains(regBaseC.getId())) {
				String cxml = RegUtils.CzhuanStr(regBaseC, qxdm);
				cxmls.append(cxml);
				cs.add(regBaseC.getId());
			}

			RegBaseZrz regBaseZrz = regBaseZrzService.get(regBaseC.getZid());
			if (regBaseZrz == null || regBaseZrz.getId() == null) {
				throw new ServiceException("系统未找到不动产单元号[bdcdyh]对应的幢基本信息");
			}
			if (!zs.contains(regBaseZrz.getId())) {
				Map<String, Object> zrzmap = getzrzinfo(regBaseZrz);
				String zrzxml = RegUtils.ZrzzhuanStrToycsl(regBaseZrz, qxdm, zrzmap);
				zxmls.append(zrzxml);
				zs.add(regBaseZrz.getId());
			}

			List<RegBusFdcq2> fdcq2lst = getFdcq2ByYwh(ywh, bdcdyh);
			if (fdcq2lst == null || fdcq2lst.size() <= 0) {
				throw new ServiceException("系统未找到不动产单元号[bdcdyh]对应的房地产权信息");
			}
			RegBusFdcq2 fdcq2 = fdcq2lst.get(0);
			String fdcqxml = RegUtils.Fdcq2zhuanStrToycsl(fdcq2, regbaseh_fybh.getBtfwbm(),regbaseh);
			fdcqxmls.append(fdcqxml);
		 

		xml.append(qlrxmls).append(hxmls).append(cxmls).append(zxmls).append(fdcqxmls);
		// 拼装报文
		StringBuffer headxml = createXmlhead(djxx);
		StringBuffer xmls = createXml(xml, headxml);
		data.put("bdcdyh", StringUtils.join(bdcdyhs, ","));
		data.put("cqzh", StringUtils.join(cqzhs, ","));
		data.put("xml", xmls.toString());
		return data;
	}

	/**
	 * 注销登记 905 房屋建筑物所有权注销登记
	 * 
	 * @param ywh
	 * @return
	 */
	public Map createXml505(String ywh, String djxl, String bdcdyh) {
		Map data = Maps.newHashMap();
		List<String> bdcdyhs = Lists.newArrayList();
		List<String> cqzhs = Lists.newArrayList();

		StringBuffer xml = new StringBuffer();
		StringBuffer qlrxmls = new StringBuffer();
		List<RegBusBdcqzsdjxx> djxxlst = getDjxxByYwh(ywh, bdcdyh, "2");
		if (djxxlst == null || djxxlst.size() <= 0) {
			throw new ServiceException("系统未找到业务号[ywh]对应的不动产权证书登记信息");
		}
		RegBusSlsq slsq = new RegBusSlsq();
		List<RegBusSlsq> slsqlst = getslsqByYwh(ywh);
		if (slsqlst == null || slsqlst.size() <= 0) {
			throw new ServiceException("系统未找到业务号[ywh]对应的受理申请信息");
		}
		slsq = slsqlst.get(0);
		RegBusBdcqzsdjxx djxx = djxxlst.get(0);
			RegBaseH regbaseh_fybh = regBaseHService.getIslogout(djxx.getBdcdyh());
			if (regbaseh_fybh == null) {
				throw new ServiceException("系统未找到单元号为:"+djxx.getBdcdyh()+"对应的房屋H信息");
			}
			if (regbaseh_fybh == null || StringUtils.isBlank(regbaseh_fybh.getBtfwbm())) {
				throw new ServiceException("系统未找到单元号为:" + regbaseh_fybh.getBdcdyh() + "对应的房屋序号");
			}
			if (regbaseh_fybh == null || StringUtils.isBlank(regbaseh_fybh.getBtfwbm())) {
				throw new ServiceException("系统未找到单元号为:" + regbaseh_fybh.getBdcdyh() + "对应的房屋序号");
			}

			if (!bdcdyhs.contains(djxx.getBdcdyh())) {
				bdcdyhs.add(djxx.getBdcdyh());
			}
			if (!cqzhs.contains(djxx.getBdcqzh())) {
				cqzhs.add(djxx.getBdcqzh());
			}

			bdcdyh = djxx.getBdcdyh();
			RegBusFdcq2 regBusFdcq2 = new RegBusFdcq2();
			regBusFdcq2.setYwh(ywh);
			regBusFdcq2.setBdcdyh(bdcdyh);
			List<RegBusFdcq2> fdcq2lst = regBusFdcq2Service.findList(regBusFdcq2);
			if (fdcq2lst == null || fdcq2lst.size() <= 0) {
				throw new ServiceException("系统未找到不动产单元号[bdcdyh]对应的注销登记信息");
			}
			regBusFdcq2 = fdcq2lst.get(0);
			if (StringUtils.isBlank(regBusFdcq2.getBdcdyh())) {
				regBusFdcq2.setBdcdyh(djxx.getBdcdyh());
			}
			String fdcq2xml = RegUtils.zxdjFdcq2zhuanStrToycsl(slsq, djxx, regBusFdcq2, regbaseh_fybh.getBtfwbm());
			xml.append(fdcq2xml); 
		// 拼装报文
		StringBuffer headxml = createXmlhead(djxx);
		StringBuffer xmls = createXml(xml, headxml);
		data.put("bdcdyh", StringUtils.join(bdcdyhs, ","));
		data.put("cqzh", StringUtils.join(cqzhs, ","));
		data.put("xml", xmls.toString());
		return data;
	}

	/**
	 * 预告登记 905 房屋建筑物预告登记
	 * 
	 * @param ywh
	 * @return
	 */
	public Map createXml803(String ywh, String djxl, String bdcdyh) {
		Map data = Maps.newHashMap();
		List<String> bdcdyhs = Lists.newArrayList();
		List<String> cqzhs = Lists.newArrayList();

		StringBuffer xml = new StringBuffer();
		StringBuffer qlrxmls = new StringBuffer();
		StringBuffer dyaqxmls = new StringBuffer();
		StringBuffer ygdjxmls = new StringBuffer();
		List<RegBusBdcqzsdjxx> djxxlst = getDjxxByYwh(ywh, bdcdyh, "2");
		if (djxxlst == null || djxxlst.size() <= 0) {
			throw new ServiceException("系统未找到业务号[ywh]" + ywh + "不动产单元号[bdcdyh]" + bdcdyh + "对应的证书登记信息");
		}
		List<RegBusQlr> qlrlst = getQlrByYwh(ywh);
		if (qlrlst == null || qlrlst.size() <= 0) {
			throw new ServiceException("系统未找到业务号[ywh]" + ywh + "不动产单元号[bdcdyh]" + bdcdyh + "对应的权利人登记信息");
		}

		RegBusBdcqzsdjxx djxx = djxxlst.get(0);
		RegBaseH regbaseh_fybh = regBaseHService.getIslogout(djxx.getBdcdyh());
		if (regbaseh_fybh == null) {
			throw new ServiceException("系统未找到业务号[ywh]" + ywh + "不动产单元号[bdcdyh]" + bdcdyh + "对应的户信息");
		}
		 
		if (regbaseh_fybh == null || regbaseh_fybh.getId() == null) {
			throw new ServiceException("系统未找到不动产单元号[bdcdyh]对应的户基本信息");
		}
		String hxml = RegUtils.HzhuanStrToycsl(regbaseh_fybh, qxdm);
		xml.append(hxml);
		
		if (StringUtils.isBlank(regbaseh_fybh.getBtfwbm())) {
			throw new ServiceException("系统未找到单元号为:" + regbaseh_fybh.getBdcdyh() + "对应的房屋序号");
		}

		if (!bdcdyhs.contains(djxx.getBdcdyh())) {
			bdcdyhs.add(djxx.getBdcdyh());
		}
		if (!cqzhs.contains(djxx.getBdcqzh())) {
			cqzhs.add(djxx.getBdcqzh());
		}

		for (int i = 0; i < qlrlst.size(); i++) {
			RegBusQlr qlr = qlrlst.get(i); 
			String qlrxml = RegUtils.QlrzhuanStrToycsl(qlr, qxdm, djxx.getBdcdyh(), djxx.getBdcqzh(),
					regbaseh_fybh.getBtfwbm());
			qlrxmls.append(qlrxml);
		}
		bdcdyh = djxx.getBdcdyh();

		RegBusDyaq regBusDyaq = new RegBusDyaq();
		RegBusYgdj regBusygdj = new RegBusYgdj();
		if ("510".equals(djxx.getDjlx()) || "513".equals(djxx.getDjlx()) || "607".equals(djxx.getDjlx())
				|| "804".equals(djxx.getDjlx()) || "807".equals(djxx.getDjlx()) || "819".equals(djxx.getDjlx())) {
			List<RegBusDyaq> dyaqlst = getDyaqByYwh(ywh, bdcdyh);
			if (dyaqlst == null || dyaqlst.size() <= 0) {
				throw new ServiceException("系统未找到业务号[ywh]不动产单元号[bdcdyh]对应的抵押权信息");
			}
			regBusDyaq = dyaqlst.get(0);
		} else {
			List<RegBusYgdj> ygdjlst = getygdjYwh(ywh, bdcdyh);
			if (ygdjlst == null || ygdjlst.size() <= 0) {
				throw new ServiceException("系统未找到业务号[ywh]不动产单元号[bdcdyh]对应的预告登记信息");
			}
			regBusygdj = ygdjlst.get(0);
		}

		if ("510".equals(djxx.getDjlx()) || "513".equals(djxx.getDjlx()) || "607".equals(djxx.getDjlx())
				|| "804".equals(djxx.getDjlx()) || "807".equals(djxx.getDjlx()) || "819".equals(djxx.getDjlx())) {
			RegBusBdcqzsdjxx tempDjxx = regBusBdcqzsdjxxService.get(djxx.getOldid());
			if (tempDjxx == null || tempDjxx.getId() == null) {
				throw new ServiceException("系统未找到业务号[ywh]不动产单元号[bdcdyh]对应的上次登记业务信息");
			}
			if (regBusDyaq == null) {
				throw new ServiceException("系统未找到业务号[ywh]不动产单元号[bdcdyh]对应的抵押权信息");
			}
			String dyaqxml = RegUtils.DyaqzhuanStrToycsl(regBusDyaq, tempDjxx.getYwh(), regbaseh_fybh.getBtfwbm());
			dyaqxmls.append(dyaqxml);
			xml.append(qlrxmls).append(dyaqxmls);
		} else {
			if (regBusygdj == null) {
				throw new ServiceException("系统未找到业务号[ywh]不动产单元号[bdcdyh]对应的预告登记信息");
			}
			String ygdjxml = RegUtils.YgdjzhuanStrToycsl(djxx.getYwh(), regBusygdj, regbaseh_fybh.getBtfwbm());
			ygdjxmls.append(ygdjxml);
			xml.append(qlrxmls).append(ygdjxmls);
		}

		// 拼装报文
		StringBuffer headxml = createXmlhead(djxx);
		StringBuffer xmls = createXml(xml, headxml);
		data.put("bdcdyh", StringUtils.join(bdcdyhs, ","));
		data.put("cqzh", StringUtils.join(cqzhs, ","));
		data.put("xml", xmls.toString());
		return data;
	}

	/**
	 * 抵押登记
	 * 
	 * 428 在建工程抵押权合并 431 在建工程抵押权变更登记 213 在建工程抵押权首次登记 214 房屋建筑物一般抵押权 215 房屋建筑物最高额抵押权
	 * 316 在建工程抵押权转移登记 317 房屋建筑物一般抵押权转移登记 318 房屋建筑物最高额抵押权转移登记 433 房屋建筑物抵押权变更登记 509
	 * 在建工程抵押权注销登记 515 房屋建筑物抵押权注销登记 606 在建工程抵押权更正登记 608 房屋建筑物抵押权更正登记 818 房屋预告抵押权转移
	 * 
	 * @param ywh
	 * @return
	 */
	public Map createXml428_431_213_214_215_316_317_318_433_509_515_606_608_818(String ywh, String djxl,
			String bdcdyh) {
		Map data = Maps.newHashMap();
		List<String> bdcdyhs = Lists.newArrayList();
		List<String> cqzhs = Lists.newArrayList();

		StringBuffer xml = new StringBuffer();
		List<RegBusBdcqzsdjxx> djxxlst = getDjxxByYwh(ywh, bdcdyh, "2");
		if (djxxlst == null || djxxlst.size() <= 0) {
			throw new ServiceException("系统未找到业务号[ywh]对应的不动产权证书登记信息");
		}
		List<RegBusQlr> qlrlst = getQlrByYwh(ywh);
		if (qlrlst == null || qlrlst.size() <= 0) {
			throw new ServiceException("系统未找到业务号[ywh]对应的权利人登记信息");
		}

		StringBuffer qlrxmls = new StringBuffer();
		StringBuffer dyaqxmls = new StringBuffer();

		RegBusBdcqzsdjxx djxx = djxxlst.get(0);
		
			RegBaseH regbaseh_fybh = regBaseHService.getIslogout(djxx.getBdcdyh());
			if (StringUtils.isBlank(regbaseh_fybh.getBtfwbm())) {
				throw new ServiceException("系统未找到单元号为:" + regbaseh_fybh.getBdcdyh() + "对应的房屋序号");
			}
			if (!bdcdyhs.contains(djxx.getBdcdyh())) {
				bdcdyhs.add(djxx.getBdcdyh());
			}
			if (!cqzhs.contains(djxx.getBdcqzh())) {
				cqzhs.add(djxx.getBdcqzh());
			}

			for (int i = 0; i < qlrlst.size(); i++) {
				RegBusQlr qlr = qlrlst.get(i);

				String qlrxml = RegUtils.QlrzhuanStrToycsl(qlr, qxdm, djxx.getBdcdyh(), djxx.getBdcqzh(),
						regbaseh_fybh.getBtfwbm());
				qlrxmls.append(qlrxml);
			}

			bdcdyh = djxx.getBdcdyh();
			List<RegBusDyaq> dyaqlst = getDyaqByYwh(ywh, bdcdyh);
			if (dyaqlst == null || dyaqlst.size() <= 0) {
				throw new ServiceException("系统未找到业务号[ywh]不动产单元号[bdcdyh]对应的抵押权信息");
			}
			RegBusDyaq regBusDyaq = dyaqlst.get(0);
			if ("213".equals(djxx.getDjlx()) || "214".equals(djxx.getDjlx()) || "215".equals(djxx.getDjlx())) {
				String dyaqxml = RegUtils.DyaqzhuanStrToycsl(regBusDyaq, "", regbaseh_fybh.getBtfwbm());
				dyaqxmls.append(dyaqxml);
			} else {
				RegBusBdcqzsdjxx tempDjxx = regBusBdcqzsdjxxService.get(djxx.getOldid());
				if (tempDjxx == null || tempDjxx.getId() == null) {
					throw new ServiceException("系统未找到业务号[ywh]不动产单元号[bdcdyh]对应的上次登记业务信息");
				}
				String dyaqxml = RegUtils.DyaqzhuanStrToycsl(regBusDyaq, tempDjxx.getYwh(), regbaseh_fybh.getBtfwbm());
				dyaqxmls.append(dyaqxml);
			} 
		xml.append(qlrxmls).append(dyaqxmls);
		// 拼装报文
		StringBuffer headxml = createXmlhead(djxx);
		StringBuffer xmls = createXml(xml, headxml);
		data.put("bdcdyh", StringUtils.join(bdcdyhs, ","));
		data.put("cqzh", StringUtils.join(cqzhs, ","));
		data.put("xml", xmls.toString());
		return data;
	}

	/**
	 * 变更登记 402 房屋建筑物所有权变更登记 403 房屋建筑物所有权分割登记 404 房屋建筑物所有权合并登记 416 房屋建筑物所有权更名
	 * 
	 * @param ywh
	 * @return
	 */
	public Map createXml402_403_404_416(String ywh, String djxl, String bdcdyh) {
		Map data = Maps.newHashMap();
		List<String> bdcdyhs = Lists.newArrayList();
		List<String> cqzhs = Lists.newArrayList();

		StringBuffer xml = new StringBuffer();
		List<RegBusBdcqzsdjxx> djxxlst = getDjxxByYwh(ywh, bdcdyh, null);
		if (djxxlst == null || djxxlst.size() <= 0) {
			throw new ServiceException("系统未找到业务号[ywh]对应的不动产权证书登记信息");
		}
		List<RegBusQlr> qlrlst = getQlrByYwh(ywh);
		if (qlrlst == null || qlrlst.size() <= 0) {
			throw new ServiceException("系统未找到业务号[ywh]对应的权利人登记信息");
		}

		StringBuffer qlrxmls = new StringBuffer();
		StringBuffer hxmls = new StringBuffer();
		StringBuffer cxmls = new StringBuffer();
		StringBuffer zxmls = new StringBuffer();
		StringBuffer fdcqxmls = new StringBuffer();

		List<String> cs = Lists.newArrayList();
		List<String> zs = Lists.newArrayList();

		RegBusBdcqzsdjxx djxx = djxxlst.get(0);
			RegBaseH regbaseh_fybh = regBaseHService.getIslogout(djxx.getBdcdyh());
			if (StringUtils.isBlank(regbaseh_fybh.getBtfwbm())) {
				throw new ServiceException("系统未找到单元号为:" + regbaseh_fybh.getBdcdyh() + "对应的房屋序号");
			}

			if (!bdcdyhs.contains(djxx.getBdcdyh())) {
				bdcdyhs.add(djxx.getBdcdyh());
			}
			if (!cqzhs.contains(djxx.getBdcqzh())) {
				cqzhs.add(djxx.getBdcqzh());
			}

			for (int i = 0; i < qlrlst.size(); i++) {
				RegBusQlr qlr = qlrlst.get(i);

				String qlrxml = RegUtils.QlrzhuanStrToycsl(qlr, qxdm, djxx.getBdcdyh(), djxx.getBdcqzh(),
						regbaseh_fybh.getBtfwbm());
				qlrxmls.append(qlrxml);
			}

			bdcdyh = djxx.getBdcdyh();

			RegBaseH regbaseh = regBaseHService.getIslogout(bdcdyh);
			if (regbaseh == null || regbaseh.getId() == null) {
				throw new ServiceException("系统未找到不动产单元号[bdcdyh]对应的户基本信息");
			}
			String hxml = RegUtils.HzhuanStrToycsl(regbaseh, qxdm);
			hxmls.append(hxml);

			RegBaseC regBaseC = regBaseCService.get(regbaseh.getCid());
			if (regBaseC == null || regBaseC.getId() == null) {
				throw new ServiceException("系统未找到不动产单元号[bdcdyh]对应的层基本信息");
			}
			if (!cs.contains(regBaseC.getId())) {
				String cxml = RegUtils.CzhuanStr(regBaseC, qxdm);
				cxmls.append(cxml);
				cs.add(regBaseC.getId());
			}

			RegBaseZrz regBaseZrz = regBaseZrzService.get(regBaseC.getZid());
			if (regBaseZrz == null || regBaseZrz.getId() == null) {
				throw new ServiceException("系统未找到不动产单元号[bdcdyh]对应的幢基本信息");
			}
			if (!zs.contains(regBaseZrz.getId())) {
				Map<String, Object> zrzmap = getzrzinfo(regBaseZrz);
				String zrzxml = RegUtils.ZrzzhuanStrToycsl(regBaseZrz, qxdm, zrzmap);
				zxmls.append(zrzxml);
				zs.add(regBaseZrz.getId());
			}

			List<RegBusFdcq2> fdcq2lst = getFdcq2ByYwh(ywh, bdcdyh);
			if (fdcq2lst == null || fdcq2lst.size() <= 0) {
				throw new ServiceException("系统未找到不动产单元号[bdcdyh]对应的房地产权信息");
			}
			RegBusFdcq2 fdcq2 = fdcq2lst.get(0);
			String fdcqxml = RegUtils.Fdcq2zhuanStrToycsl(fdcq2, regbaseh_fybh.getBtfwbm(),regbaseh);
			fdcqxmls.append(fdcqxml);
		 
		xml.append(qlrxmls).append(hxmls).append(cxmls).append(zxmls).append(fdcqxmls);
		// 拼装报文
		StringBuffer headxml = createXmlhead(djxx);
		StringBuffer xmls = createXml(xml, headxml);
		data.put("bdcdyh", StringUtils.join(bdcdyhs, ","));
		data.put("cqzh", StringUtils.join(cqzhs, ","));
		data.put("xml", xmls.toString());
		return data;
	}

	/**
	 * 转移登记 302 房屋建筑物所有权转移登记
	 * 
	 * @param ywh
	 * @return
	 */
	public Map createXml302(String ywh, String djxl, String bdcdyh) {
		Map data = Maps.newHashMap();
		List<String> bdcdyhs = Lists.newArrayList();
		List<String> cqzhs = Lists.newArrayList();

		StringBuffer xml = new StringBuffer();
		List<RegBusBdcqzsdjxx> djxxlst = getDjxxByYwh(ywh, bdcdyh, null);
		if (djxxlst == null || djxxlst.size() <= 0) {
			throw new ServiceException("系统未找到业务号[ywh]对应的不动产权证书登记信息");
		}
		List<RegBusQlr> qlrlst = getQlrByYwh(ywh);
		if (qlrlst == null || qlrlst.size() <= 0) {
			throw new ServiceException("系统未找到业务号[ywh]对应的权利人登记信息");
		}

		StringBuffer qlrxmls = new StringBuffer();
		StringBuffer hxmls = new StringBuffer();
		StringBuffer cxmls = new StringBuffer();
		StringBuffer zxmls = new StringBuffer();
		StringBuffer fdcqxmls = new StringBuffer();

		List<String> cs = Lists.newArrayList();
		List<String> zs = Lists.newArrayList();
		RegBusBdcqzsdjxx djxx = djxxlst.get(0);
			List<RegBusFdcq2> fdcq2lst = getFdcq2ByYwh(ywh, bdcdyh);
			if (fdcq2lst == null || fdcq2lst.size() <= 0) {
				throw new ServiceException("系统未找到不动产单元号[bdcdyh]对应的房地产权信息");
			}
			RegBusFdcq2 fdcq2 = fdcq2lst.get(0);
			RegBaseH regbaseh_fybh = regBaseHService.getIslogout(djxx.getBdcdyh());
			if (StringUtils.isBlank(regbaseh_fybh.getBtfwbm() )) {
				throw new ServiceException("系统未找到单元号为:" + regbaseh_fybh.getBdcdyh() + "对应的房屋序号");
			}

			if (!bdcdyhs.contains(djxx.getBdcdyh())) {
				bdcdyhs.add(djxx.getBdcdyh());
			}
			if (!cqzhs.contains(djxx.getBdcqzh())) {
				cqzhs.add(djxx.getBdcqzh());
			}

			for (int i = 0; i < qlrlst.size(); i++) {
				RegBusQlr qlr = qlrlst.get(i);

				String qlrxml = RegUtils.QlrzhuanStrToycsl(qlr, qxdm, djxx.getBdcdyh(), fdcq2.getBdcqzh(),
						regbaseh_fybh.getBtfwbm());
				qlrxmls.append(qlrxml);
			}
			bdcdyh = djxx.getBdcdyh();

			RegBaseH regbaseh = regBaseHService.getIslogout(bdcdyh);
			if (regbaseh == null || regbaseh.getId() == null) {
				throw new ServiceException("系统未找到不动产单元号[bdcdyh]对应的户基本信息");
			}
			String hxml = RegUtils.HzhuanStrToycsl(regbaseh, qxdm);
			hxmls.append(hxml);

			RegBaseC regBaseC = regBaseCService.get(regbaseh.getCid());
			if (regBaseC == null || regBaseC.getId() == null) {
				throw new ServiceException("系统未找到不动产单元号[bdcdyh]对应的层基本信息");
			}
			if (!cs.contains(regBaseC.getId())) {
				String cxml = RegUtils.CzhuanStr(regBaseC, qxdm);
				cxmls.append(cxml);
				cs.add(regBaseC.getId());
			}

			RegBaseZrz regBaseZrz = regBaseZrzService.get(regBaseC.getZid());
			if (regBaseZrz == null || regBaseZrz.getId() == null) {
				throw new ServiceException("系统未找到不动产单元号[bdcdyh]对应的幢基本信息");
			}
			if (!zs.contains(regBaseZrz.getId())) {
				Map<String, Object> zrzmap = getzrzinfo(regBaseZrz);
				String zrzxml = RegUtils.ZrzzhuanStrToycsl(regBaseZrz, qxdm, zrzmap);
				zxmls.append(zrzxml);
				zs.add(regBaseZrz.getId());
			}

			String fdcqxml = RegUtils.Fdcq2zhuanStrToycsl(fdcq2, regbaseh_fybh.getBtfwbm(),regbaseh);
			fdcqxmls.append(fdcqxml);
		 
		xml.append(qlrxmls).append(hxmls).append(cxmls).append(zxmls).append(fdcqxmls);
		// 拼装报文
		StringBuffer headxml = createXmlhead(djxx);
		StringBuffer xmls = createXml(xml, headxml);
		data.put("bdcdyh", StringUtils.join(bdcdyhs, ","));
		data.put("cqzh", StringUtils.join(cqzhs, ","));
		data.put("xml", xmls.toString());
		return data;
	}

	private StringBuffer createXmlhead(RegBusBdcqzsdjxx djxx) {
		StringBuffer headxmls = new StringBuffer();
		String headstr = "<Head>";
		String djdl =  (Integer.parseInt(djxx.getDjlx().substring(0, 1)) - 1) + "00" ;
		headstr = headstr + "<djdl>" + DictUtils.getDictLabel( djdl , "reg_bus_djlx", "")+ "</djdl>"
				+ "<ywh>"+djxx.getYwh()+"</ywh>"+"<bdcdyh>"+djxx.getBdcdyh()+"</bdcdyh>"
				+ "<djxl>" + DictUtils.getDictLabel( djxx.getDjlx() , "reg_bus_djxl", "") + "</djxl>" + "<dbsj>" + djxx.getDbsj() + "</dbsj>" 
				+ "<bdcqzh>"+djxx.getBdcqzh()+"</bdcqzh>";
	    if(!StringUtils.isBlank(djxx.getOldid())) {
	    	RegBusBdcqzsdjxx oldDjxx = regBusBdcqzsdjxxService.get(djxx.getOldid());
	    	if(oldDjxx != null) {
	    		headstr = headstr +"<ybdcqzh>"+oldDjxx.getBdcqzh()+"</ybdcqzh>";
	    	}else {
	    		headstr = headstr +"<ybdcqzh></ybdcqzh>";
	    	}
	    	
	    }else {
	    	headstr = headstr +"<ybdcqzh></ybdcqzh>";
	    }
		
		if ("302".equals(djxx.getDjlx())) {
			List<RegBusFdcq2> fdcq2lst = getFdcq2ByYwh(djxx.getYwh(), djxx.getBdcdyh());
			if (fdcq2lst.size() > 0) {
				RegBusFdcq2 fdcq2 = fdcq2lst.get(0);
				headstr = headstr + "<htbh>" + fdcq2.getHtbh() + "</htbh></Head>";
			}
		}else if ("803".equals(djxx.getDjlx())) {
			List<RegBusYgdj> ygdjlst = getygdjYwh(djxx.getYwh(), djxx.getBdcdyh());
			if (ygdjlst.size() > 0) {
				RegBusYgdj ygdj = ygdjlst.get(0);
				headstr = headstr + "<htbh>" + ygdj.getHtbh() + "</htbh></Head>";
			}
		} else {
			headstr = headstr + "<htbh></htbh></Head>";
		}

		headxmls.append(headstr);
		return headxmls;
	}

	/**
	 * xml报文
	 * 
	 * @param ywh
	 * @return
	 */
	private StringBuffer createXmlhead(String ywh, String bdcdyh) {
		StringBuffer headxmls = new StringBuffer();
		String headstr = "<Head>";
		RegBusBdcqzsdjxx djxx = new RegBusBdcqzsdjxx();

		List<RegBusFdcq2> fdcqlst = getFdcq2ByYwh(ywh, bdcdyh);

		List<RegBusBdcqzsdjxx> djxxlst = getDjxxByYwh(ywh, bdcdyh, null);
		if (djxxlst.size() > 0) {
			djxx = djxxlst.get(0);
		}

		if (djxxlst.size() > 0) {
			djxx = djxxlst.get(0);
			headstr = headstr + "<djdl>" + (Integer.parseInt(djxx.getDjlx().substring(0, 1)) - 1) + "00" + "</djdl>"
					+ "<ywh>"+djxx.getYwh()+"</ywh>"+"<bdcdyh>"+djxx.getBdcdyh()+"</bdcdyh>"
					+ "<djxl>" +DictUtils.getDictLabel( djxx.getDjlx() , "reg_bus_djxl", "") + "</djxl>" + "<dbsj>" + djxx.getDbsj() + "</dbsj>" + "<bjsj>"
					+ (djxx.getFzsj()==null?"":djxx.getFzsj()) + "</bjsj>";
			if ("302".equals(djxx.getDjlx())) {
				List<RegBusFdcq2> fdcq2lst = getFdcq2ByYwh(ywh, djxx.getBdcdyh());
				if (fdcq2lst.size() > 0) {
					RegBusFdcq2 fdcq2 = fdcq2lst.get(0);
					headstr = headstr + "<htbh>" + fdcq2.getHtbh() + "</htbh></Head>";
				}
			} else if ("803".equals(djxx.getDjlx())) {
				List<RegBusYgdj> ygdjlst = getygdjYwh(djxx.getYwh(), djxx.getBdcdyh());
				if (ygdjlst.size() > 0) {
					RegBusYgdj ygdj = ygdjlst.get(0);
					headstr = headstr + "<htbh>" + ygdj.getHtbh() + "</htbh></Head>";
				}
			}else {
				headstr = headstr + "<htbh></htbh></Head>";
			}

		}
		headxmls.append(headstr);
		return headxmls;
	}

	/**
	 * xml报文拼装
	 * 
	 * @param xmlinfo
	 * @return
	 */
	private StringBuffer createXml(StringBuffer xmldata, StringBuffer xmlhead) {
		StringBuffer xmlstr = new StringBuffer();
		xmlstr = xmlstr.append(JXmlUtils.messageBStr).append(xmlhead).append(JXmlUtils.dataBStr).append(xmldata)
				.append(JXmlUtils.dataEStr).append(JXmlUtils.messageEStr);
		return xmlstr;
	}

	private List<RegBusBdcqzsdjxx> getDjxxByYwh(String ywh, String bdcdyh, String isLogout) {
		RegBusBdcqzsdjxx regBusBdcqzsdjxx = new RegBusBdcqzsdjxx();
		regBusBdcqzsdjxx.setYwh(ywh);
		regBusBdcqzsdjxx.setBdcdyh(bdcdyh);
		regBusBdcqzsdjxx.setIslogout(isLogout == null ? "0" : isLogout);
		List<RegBusBdcqzsdjxx> djxxlst = regBusBdcqzsdjxxService.findList(regBusBdcqzsdjxx);
		return djxxlst;
	}

	private Map getzrzinfo(RegBaseZrz regBaseZrz) {
		Map<String, Object> zrzmap = new HashMap<String, Object>();
		// 查询最大房间数
		String czds = "";
		czds = regBaseZrzService.getczds(regBaseZrz.getBdcdyh().substring(0, 24));
		// 根据幢不动产单元查询宗地坐落
		String zrzzl = "";
		RegBaseZdjbxx regBaseZdjbxx = new RegBaseZdjbxx();
		regBaseZdjbxx.setZddm(regBaseZrz.getZddm());
		regBaseZdjbxx.setIslogout("0");
		List<RegBaseZdjbxx> listJbxx = regBaseZdjbxxService.findList(regBaseZdjbxx);
		if (listJbxx.size() == 1) {
			regBaseZdjbxx = listJbxx.get(0);
			zrzzl = regBaseZdjbxx.getZl() + regBaseZrz.getXmmc() + regBaseZrz.getGzwmc();
		}
		zrzmap.put("zrzzl", zrzzl);
		zrzmap.put("czds", czds);
		return zrzmap;
	}

	public List<RegBusQlr> getQlrByYwh(String ywh) {
		RegBusQlr regBusQlr = new RegBusQlr();
		regBusQlr.setYwh(ywh);
		List<RegBusQlr> qlrlst = regBusQlrService.findList_1(regBusQlr);
		return qlrlst;
	}

	private List<RegBusFdcq2> getFdcq2ByYwh(String ywh, String bdcdyh) {
		RegBusFdcq2 regBusFdcq2 = new RegBusFdcq2();
		regBusFdcq2.setYwh(ywh);
		regBusFdcq2.setQszt("1");
		regBusFdcq2.setBdcdyh(bdcdyh);
		List<RegBusFdcq2> fdcq2lst = regBusFdcq2Service.findList(regBusFdcq2);
		return fdcq2lst;
	}

	private List<RegBusSlsq> getslsqByYwh(String ywh) {
		RegBusSlsq slsq = new RegBusSlsq();
		slsq.setYwh(ywh);
		List<RegBusSlsq> slsqlst = regBusSlsqService.findList(slsq);
		return slsqlst;
	}

	private List<RegBusYgdj> getygdjYwh(String ywh, String bdcdyh) {
		RegBusYgdj ygdj = new RegBusYgdj();
		ygdj.setYwh(ywh);
		ygdj.setBdcdyh(bdcdyh);
		List<RegBusYgdj> ygdjlst = regBusYgdjService.findList(ygdj);
		return ygdjlst;
	}

	private List<RegBusDyaq> getDyaqByYwh(String ywh, String bdcdyh) {
		RegBusDyaq regBusDyaq = new RegBusDyaq();
		regBusDyaq.setYwh(ywh);
		regBusDyaq.setBdcdyh(bdcdyh);
		List<RegBusDyaq> dyaqlst = regBusDyaqService.findList(regBusDyaq);
		return dyaqlst;
	}

}