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

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
import java.util.Map;

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

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.modules.reg.entity.base.RegBaseH;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseZdjbxx;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusBdcqzsdjxx;
import com.thinkgem.jeesite.modules.reg.entity.bus.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.RegBusYwr;
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.bus.RegBusBdcqzsdjxxService;
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.RegBusYwrService;
import com.thinkgem.jeesite.modules.reg.web.httprest.utils.DatatypeUtil;
import com.thinkgem.jeesite.modules.sys.utils.DictUtils;

@Service
public class HttpSwService {
	protected Logger logger = LoggerFactory.getLogger(getClass());

	@Autowired
	private RegBusFdcq2Service regBusFdcq2Service;
	@Autowired
	private RegBusBdcqzsdjxxService regBusBdcqzsdjxxService;
	@Autowired
	private RegBusYwrService regBusYwrService;
	@Autowired
	private RegBusQlrService regBusQlrService;
	@Autowired
	private RegBaseHService regBaseHService;
	@Autowired
	private RegBusSlsqService regBusSlsqService;
	@Autowired
	private RegBaseZdjbxxService regBaseZdjbxxService;

	public Map getClfcxInfo(List<Map> rows) {
		Map res_map = Maps.newHashMap();
		List res_rows = Lists.newArrayList();
		for (Map row : rows) {
			Map res_row = Maps.newHashMap();
			String htbm = DatatypeUtil.getValueByMap(row, "ESFMMHTH", "");
			String zjh = DatatypeUtil.getValueByMap(row, "SFZJHM", "");
			if (StringUtils.isBlank(htbm)) {
				throw new ServiceException("合同编码[ESFMMHTH]不能为空");
			}
			RegBusFdcq2 fdcq2 = getFdcq2ByHtbm(htbm);
			if (fdcq2 == null) {
				throw new ServiceException("系统未找到合同编码[ESFMMHTH]{" + htbm + "}对应的交易信息");
			}
			List<RegBusBdcqzsdjxx> djxxlist = getDjxxByYwh(fdcq2.getYwh(), fdcq2.getBdcdyh());
			if (djxxlist == null || djxxlist.size() <=0) {
				throw new ServiceException(
						"系统未找到合同编码[ESFMMHTH]{" + htbm + "}不动产单元号{" + fdcq2.getBdcdyh() + "}对应的不动产权证书登记信息");
			}
			RegBusBdcqzsdjxx djxx = djxxlist.get(0);
			if (djxx == null) {
				throw new ServiceException(
						"系统未找到合同编码[ESFMMHTH]{" + htbm + "}不动产单元号{" + fdcq2.getBdcdyh() + "}对应的不动产权证书登记信息");
			}
			if (StringUtils.isBlank(djxx.getOldid())) {
				throw new ServiceException("系统未找到合同编码[ESFMMHTH]{" + htbm + "}不动产单元号{" + fdcq2.getBdcdyh() + "}的交易前信息");
			}
			RegBusSlsq slsq = getSlsqByYwh(djxx.getYwh());
			if (slsq == null) {
				throw new ServiceException(
						"系统未找到合同编码[ESFMMHTH]{" + htbm + "}不动产单元号{" + fdcq2.getBdcdyh() + "}对应的不动产业务申请信息");
			}

			List<RegBusQlr> qlrList = getQlrByYwh(djxx.getYwh(), null);
			List<RegBusYwr> ywrList = getYwrByYwh(djxx.getYwh(), null);
			if (qlrList == null) {
				throw new ServiceException(
						"系统未找到合同编码[ESFMMHTH]{" + htbm + "}不动产单元号{" + fdcq2.getBdcdyh() + "}对应的交易权利人信息");
			}
			if (!StringUtils.isBlank(zjh) && !validateQlr(qlrList, zjh)) {
				throw new ServiceException("系统未找到合同编码[ESFMMHTH]{" + htbm + "}不动产单元号{" + fdcq2.getBdcdyh()
						+ "}中证件号[SFZJHM]{" + zjh + "}对应的交易权利人信息");
			}
			if (ywrList == null) {
				throw new ServiceException(
						"系统未找到合同编码[ESFMMHTH]{" + htbm + "}不动产单元号{" + fdcq2.getBdcdyh() + "}对应的交易义务人信息");
			}

			RegBaseZdjbxx zdxx = getZdjbxxByBdcdyh(djxx.getBdcdyh());
			if (zdxx == null) {
				throw new ServiceException(
						"系统未找到合同编码[ESFMMHTH]{" + htbm + "}不动产单元号{" + fdcq2.getBdcdyh() + "}对应的宗地基本信息");
			}
			// 查询房屋状态
			RegBaseH regbaseh = regBaseHService.getIslogout(djxx.getBdcdyh());

			RegBusBdcqzsdjxx old_djxx = regBusBdcqzsdjxxService.get(djxx.getOldid());
			if (old_djxx == null) {
				throw new ServiceException("系统未找到合同编码[ESFMMHTH]{" + htbm + "}不动产单元号{" + fdcq2.getBdcdyh() + "}的交易前信息");
			}
			RegBusFdcq2 old_fdcq = getFdcq2ByYwh(old_djxx.getYwh(), old_djxx.getBdcdyh());
			if (old_fdcq == null) {
				throw new ServiceException("系统未找到合同编码[ESFMMHTH]{" + htbm + "}不动产单元号{" + fdcq2.getBdcdyh() + "}的交易前业务号{"
						+ old_djxx.getYwh() + "}的产权信息");
			}

			Map jyxx = createJyxx(fdcq2, slsq, zdxx, regbaseh);
			Map fwxx = createFwxx(fdcq2, regbaseh);
			Map sysjyxx = createSysjyxx(old_fdcq, old_djxx,fdcq2);
			Map mmsfxx = createMmsfxx(qlrList, ywrList);

			res_row.put("JYXX", jyxx);
			res_row.put("FWXX", fwxx);
			res_row.put("SYSJYXX", sysjyxx);
			res_row.put("MMSFXX", mmsfxx);

			res_rows.add(res_row);
		}
		res_map.put("Row", res_rows);
		return res_map;
	}

	public Map getTcInfo(List<Map> rows) {
		Map res_map = Maps.newHashMap();
		List res_rows = Lists.newArrayList();

		List<String> bdclst = Lists.newArrayList();
		List<Map<String, String>> bdc_list = Lists.newArrayList();
		for (Map row : rows) {
			String xm = DatatypeUtil.getValueByMap(row, "XM", "");
			String zjh = DatatypeUtil.getValueByMap(row, "SFZJHM", "");
			if (StringUtils.isBlank(xm) || StringUtils.isBlank(zjh)) {
				throw new ServiceException("姓名[XM]、身份证号码[SFZJHM]不能为空");
			}
			Map map = Maps.newHashMap();
			map.put("qlrmc", xm);
			map.put("zjh", zjh); 
			List<Map<String, String>> list = regBusBdcqzsdjxxService.queryBdcDjxxByQlr(map);
			
			for(Map m :list) {
				String bdcdyh = DatatypeUtil.getValueByMap(m, "bdcdyh", "");
				if (bdclst.contains(bdcdyh)) {
					continue;
				}
				logger.info(bdcdyh);
				bdc_list.add(m);
			} 
		}
		
		
		Map row = Maps.newHashMap();
		row.put("CSH", "");
		row.put("SQBH", "");
		row.put("ESFMMHTH", "");
		row.put("ZZTS", transform_fwts(bdc_list.size()));
		row.put("ZZTC", "");
		row.put("MMSFLX", "");

		res_rows.add(row);
		
		 
		res_map.put("Row", res_rows);
		return res_map;
	}
	
	

	public Map getZlfcxInfo(List<Map> rows) {
		Map res_map = Maps.newHashMap();
		List res_rows = Lists.newArrayList();
		for (Map row : rows) {
			Map res_row = Maps.newHashMap();
			String htbm = DatatypeUtil.getValueByMap(row, "ESFMMHTH", "");
			String zjh = DatatypeUtil.getValueByMap(row, "SFZJHM", "");
			if (StringUtils.isBlank(htbm)) {
				throw new ServiceException("合同编码[ESFMMHTH]不能为空");
			}
			RegBusFdcq2 fdcq2 = getFdcq2ByHtbm(htbm);
			if (fdcq2 == null) {
				throw new ServiceException("系统未找到合同编码[ESFMMHTH]{" + htbm + "}对应的交易信息");
			}
			List<RegBusBdcqzsdjxx> djxxlist = getDjxxByYwh(fdcq2.getYwh(), fdcq2.getBdcdyh());
			if (djxxlist == null) {
				throw new ServiceException(
						"系统未找到合同编码[ESFMMHTH]{" + htbm + "}不动产单元号{" + fdcq2.getBdcdyh() + "}对应的不动产权证书登记信息");
			}
			RegBusBdcqzsdjxx djxx = djxxlist.get(0);
			if (djxx == null) {
				throw new ServiceException(
						"系统未找到合同编码[ESFMMHTH]{" + htbm + "}不动产单元号{" + fdcq2.getBdcdyh() + "}对应的不动产权证书登记信息");
			}
			if (StringUtils.isBlank(djxx.getOldid())) {
				throw new ServiceException("系统未找到合同编码[ESFMMHTH]{" + htbm + "}不动产单元号{" + fdcq2.getBdcdyh() + "}的交易前信息");
			}
			RegBusSlsq slsq = getSlsqByYwh(djxx.getYwh());
			if (slsq == null) {
				throw new ServiceException(
						"系统未找到合同编码[ESFMMHTH]{" + htbm + "}不动产单元号{" + fdcq2.getBdcdyh() + "}对应的不动产业务申请信息");
			}

			List<RegBusQlr> qlrList = getQlrByYwh(djxx.getYwh(),null);
			if (qlrList == null) {
				throw new ServiceException(
						"系统未找到合同编码[ESFMMHTH]{" + htbm + "}不动产单元号{" + fdcq2.getBdcdyh() + "}对应的交易权利人信息");
			}
			if (!StringUtils.isBlank(zjh) && !validateQlr(qlrList, zjh)) {
				throw new ServiceException("系统未找到合同编码[ESFMMHTH]{" + htbm + "}不动产单元号{" + fdcq2.getBdcdyh()
						+ "}中证件号[SFZJHM]{" + zjh + "}对应的交易权利人信息");
			}
			List<RegBusYwr> ywrList = getYwrByYwh(djxx.getYwh(), null);
			if (ywrList == null) {
				throw new ServiceException(
						"系统未找到合同编码[ESFMMHTH]{" + htbm + "}不动产单元号{" + fdcq2.getBdcdyh() + "}对应的交易义务人信息");
			}

			RegBaseZdjbxx zdxx = getZdjbxxByBdcdyh(djxx.getBdcdyh());
			if (zdxx == null) {
				throw new ServiceException(
						"系统未找到合同编码[ESFMMHTH]{" + htbm + "}不动产单元号{" + fdcq2.getBdcdyh() + "}对应的宗地基本信息");
			}
			// 查询房屋状态
			RegBaseH regbaseh = regBaseHService.getIslogout(djxx.getBdcdyh());

			RegBusBdcqzsdjxx old_djxx = regBusBdcqzsdjxxService.get(djxx.getOldid());
			if (old_djxx == null) {
				throw new ServiceException("系统未找到合同编码[ESFMMHTH]{" + htbm + "}不动产单元号{" + fdcq2.getBdcdyh() + "}的交易前信息");
			}
			RegBusFdcq2 old_fdcq = getFdcq2ByYwh(old_djxx.getYwh(), old_djxx.getBdcdyh());
			if (old_fdcq == null) {
				throw new ServiceException("系统未找到合同编码[ESFMMHTH]{" + htbm + "}不动产单元号{" + fdcq2.getBdcdyh() + "}的交易前业务号{"
						+ old_djxx.getYwh() + "}的产权信息");
			}

			Map jyxx = createZlfJyxx(fdcq2, slsq, zdxx, regbaseh, djxx, ywrList);
			Map msrxx = createMsrxx(qlrList);

			res_row.put("JYXX", jyxx);
			res_row.put("MSRXX", msrxx);

			res_rows.add(res_row);
		}
		res_map.put("Row", res_rows);
		return res_map;
	}

	private Map createZlfJyxx(RegBusFdcq2 fdcq2, RegBusSlsq slsq, RegBaseZdjbxx zdxx, RegBaseH h, RegBusBdcqzsdjxx djxx,
			List<RegBusYwr> ywrList) {
		Map res_map = Maps.newHashMap();
		Map jyxx_set = Maps.newHashMap();
		List jyxx_rows = Lists.newArrayList();
		Map jyxx_row = Maps.newHashMap();

		String jyjg = fdcq2.getFdcjyjg() == null ? null : fdcq2.getFdcjyjg() * 10000 + "";

		String ywrmc = "";
		String ywrzjhm = "";
		String ywrdh = "";
		for (int i = 0; i < ywrList.size(); i++) {
			RegBusYwr ywr = ywrList.get(0);
			ywrmc += ywr.getQlrmc();
			ywrzjhm += ywr.getZjh();
			if (i < ywrList.size() - 1) {
				ywrmc += ",";
				ywrzjhm += ",";
				ywrdh += ",";
			}
		}

		jyxx_row.put("BDCDYH", fdcq2.getBdcdyh());
		jyxx_row.put("ZRZH", h.getJgzwmc());
		jyxx_row.put("YWRMC", ywrmc);
		jyxx_row.put("KFQYYYZZH", ywrzjhm);
		jyxx_row.put("YWRZJH", ywrzjhm);
		jyxx_row.put("BDCXMBH", "");
		jyxx_row.put("XMMC", h.getXmmc());
		jyxx_row.put("YWRFRDH", ywrdh);
		jyxx_row.put("QXDM", Global.getAreaCode());
		jyxx_row.put("JDXZ", zdxx.getZl());
		jyxx_row.put("FWXZ", transform_fwxz(fdcq2.getFwxz()));
		jyxx_row.put("FWYT1", transform_fwyt(h.getFwyt1()));
		jyxx_row.put("QSQSZYFS", transform_cqly(fdcq2.getCqly()));
		jyxx_row.put("FDZL", fdcq2.getFdzl());

		jyxx_row.put("DY", h.getDyh());
		jyxx_row.put("CH", h.getBeginc());
		jyxx_row.put("HH", h.getHh());
		jyxx_row.put("FWJG", fdcq2.getFwjg());
		jyxx_row.put("CX", h.getCx());
		jyxx_row.put("SCJZMJ", h.getScjzmj());

		jyxx_row.put("HTJZMJ", h.getScjzmj());
		jyxx_row.put("SCTNJZMJ", h.getSctnjzmj());
		jyxx_row.put("HTTNMJ", h.getSctnjzmj());
		jyxx_row.put("DJ", fdcq2.getHtdj());
		jyxx_row.put("FDCJYJG", jyjg);
		jyxx_row.put("FWLX",transform_fwlx(h.getFwlx()));

		jyxx_row.put("HTBASJ", fdcq2.getHtbarq());
		jyxx_row.put("HTBH",fdcq2.getHtbh());
		jyxx_row.put("CSH", StringUtils.isBlank(slsq.getProid()) ? slsq.getYwh() : slsq.getProid());

		jyxx_rows.add(jyxx_row);
		jyxx_set.put("Row", jyxx_rows);
		res_map.put("RecordSet", jyxx_set);
		return res_map;
	}

	private Map createMsrxx(List<RegBusQlr> qlrList) {
		Map res_map = Maps.newHashMap();
		Map set = Maps.newHashMap();
		List rows = Lists.newArrayList();
		for (RegBusQlr qlr : qlrList) {
			
			String qlbl = qlr.getQlbl();
			BigDecimal int_qlbl = null;
			 
			switch (qlr.getGyfs()) {
			case "0":
				int_qlbl = new BigDecimal("1");
				break;
			case "1":
				int_qlbl = null;
				break;
			default: 
				if(!StringUtils.isEmpty(qlbl)) {
					qlbl = qlbl.replaceAll("%", "");
					BigDecimal big_qlbl = new BigDecimal(qlbl); 
					int_qlbl = big_qlbl.divide(new BigDecimal("100")); 
				}
				break;
			}
			
			Map row = Maps.newHashMap();
			row.put("QLRMC", qlr.getQlrmc());
			row.put("QLRZJZL", qlr.getZjzl());
			row.put("QLRZJH", qlr.getZjh());
			row.put("QLRLX", qlr.getQlrlx());
			row.put("GJ", qlr.getGj());
			row.put("DH", qlr.getDh());
			row.put("QLRTXDZ", qlr.getDz());
			row.put("QLBL", int_qlbl);
			row.put("GYFS", qlr.getGyfs());
			rows.add(row);
		}
		set.put("Row", rows);
		res_map.put("RecordSet", set);
		return res_map;
	}

	private Boolean validateQlr(List<RegBusQlr> qlrList, String zjh) {
		for (RegBusQlr qlr : qlrList) {
			if (zjh.equalsIgnoreCase(qlr.getZjh())) {
				return true;
			}
		}
		return false;
	}

	private Map createMmsfxx(List<RegBusQlr> qlrList, List<RegBusYwr> ywrList) {
		Map res_map = Maps.newHashMap();
		Map set = Maps.newHashMap();
		List rows = Lists.newArrayList();
		for (RegBusQlr qlr : qlrList) {
			String qlbl = qlr.getQlbl();
			BigDecimal int_qlbl = null;
			 
			switch (qlr.getGyfs()) {
			case "0":
				int_qlbl = new BigDecimal("1");
				break;
			case "1":
				int_qlbl = null;
				break;
			default: 
				if(!StringUtils.isEmpty(qlbl)) {
					qlbl = qlbl.replaceAll("%", "");
					BigDecimal big_qlbl = new BigDecimal(qlbl); 
					int_qlbl = big_qlbl.divide(new BigDecimal("100")); 
				}
				break;
			}
			
			
			Map row = Maps.newHashMap();
			row.put("QLRMC", qlr.getQlrmc());
			row.put("QLRZJZL", qlr.getZjzl());
			row.put("QLRZJH", qlr.getZjh());
			row.put("QLRLX", qlr.getQlrlx());
			row.put("GJ", qlr.getGj());
			row.put("DH", qlr.getDh());
			row.put("QLRTXDZ", qlr.getDz());
			row.put("MMSFLX", "02");
			row.put("QLBL", int_qlbl); 
			row.put("GYFS", qlr.getGyfs());

			rows.add(row);
		}

		for (RegBusYwr ywr : ywrList) {
			String qlbl = ywr.getQlbl();
			BigDecimal int_qlbl = null;
			 
			switch (ywr.getGyfs()) {
			case "0":
				int_qlbl = new BigDecimal("1");
				break;
			case "1":
				int_qlbl = null;
				break;
			default: 
				if(!StringUtils.isEmpty(qlbl)) {
					qlbl = qlbl.replaceAll("%", "");
					BigDecimal big_qlbl = new BigDecimal(qlbl); 
					int_qlbl = big_qlbl.divide(new BigDecimal("100")); 
				}
				break;
			}
			Map row = Maps.newHashMap();
			row.put("YWRMC", ywr.getQlrmc());
			row.put("YWRZJZL", ywr.getZjzl());
			row.put("YWRZJH", ywr.getZjh());
			row.put("YWRLX", ywr.getQlrlx());
			row.put("GJ", ywr.getGj());
			row.put("DH", ywr.getDh());
			row.put("YWRTXDZ", ywr.getDz());
			row.put("MMSFLX", "01"); 
			row.put("JYBL",  int_qlbl);
			row.put("GYFS", ywr.getGyfs());

			rows.add(row);
		}

		set.put("Row", rows);
		res_map.put("RecordSet", set);
		return res_map;
	}

	private Map createSysjyxx(RegBusFdcq2 ssfdcq2, RegBusBdcqzsdjxx djxx,RegBusFdcq2 fdcq2) {
		Map res_map = Maps.newHashMap();
		Map set = Maps.newHashMap();
		List rows = Lists.newArrayList();
		Map row = Maps.newHashMap();

		String jyjg = ssfdcq2.getFdcjyjg() == null ? null : ssfdcq2.getFdcjyjg() * 10000 + "";
		row.put("YSYQZH", ssfdcq2.getBdcqzh());
		row.put("YFWJZ", jyjg);
		row.put("SCQDFWFS", fdcq2.getScqdfwfs()); 
		row.put("CB", fdcq2.getCb());
		row.put("SCQDFWSJ", djxx.getDbsj());
		row.put("FZSJ", djxx.getFzsj());
		row.put("SSQSJE", fdcq2.getSsqsje());
		row.put("SSQSJNSJ", fdcq2.getSsqsjnsj());

		rows.add(row);
		set.put("Row", rows);
		res_map.put("RecordSet", set);
		return res_map;
	}

	private Map createFwxx(RegBusFdcq2 fdcq2, RegBaseH h) {
		Map res_map = Maps.newHashMap();
		Map set = Maps.newHashMap();
		List rows = Lists.newArrayList();
		Map row = Maps.newHashMap();

		row.put("ZRZH", h.getJgzwmc());
		row.put("DY", h.getDyh());
		row.put("HH", h.getHh());
		row.put("CX", h.getCx());
		row.put("CH", h.getBeginc());
		row.put("XMMC", h.getXmmc());
		row.put("JGRQ", fdcq2.getJgsj());
		row.put("ZCS", fdcq2.getZcs());
		row.put("SCJZMJ", h.getScjzmj());
		row.put("SCTNJZMJ", h.getSctnjzmj());
		row.put("FWYT1", transform_fwyt(h.getFwyt1()));
		row.put("FWXZ", transform_fwxz(fdcq2.getFwxz()));
		row.put("FWJG", fdcq2.getFwjg());
		row.put("CGZK", h.getCgzk());

		rows.add(row);
		set.put("Row", rows);
		res_map.put("RecordSet", set);
		return res_map;
	}

	private Map createJyxx(RegBusFdcq2 fdcq2, RegBusSlsq slsq, RegBaseZdjbxx zdxx, RegBaseH h) {
		Map res_map = Maps.newHashMap();
		Map jyxx_set = Maps.newHashMap();
		List jyxx_rows = Lists.newArrayList();
		Map jyxx_row = Maps.newHashMap();

		String jyjg = fdcq2.getFdcjyjg() == null ? null : fdcq2.getFdcjyjg() * 10000 + "";

		jyxx_row.put("CSH", StringUtils.isBlank(slsq.getProid()) ? slsq.getYwh() : slsq.getProid());
		jyxx_row.put("ESFMMHTH", fdcq2.getHtbh());
		jyxx_row.put("AJBH", "");
		jyxx_row.put("SLDH", "");
		jyxx_row.put("DJLX", fdcq2.getDjlx());
		jyxx_row.put("YSYQZH", fdcq2.getYbdcqzh());
		jyxx_row.put("FDZL", fdcq2.getFdzl());
		jyxx_row.put("BDCQZH", fdcq2.getBdcqzh());
		jyxx_row.put("FDCJYJG", jyjg);
		jyxx_row.put("HTDJRQ", fdcq2.getHtdjrq());
		jyxx_row.put("QXDM", Global.getAreaCode());
		jyxx_row.put("JDXZ", zdxx.getZl());
		jyxx_row.put("FWSZDSWJG", fdcq2.getFwszdswjg());
		jyxx_row.put("FWXZ", transform_fwxz(fdcq2.getFwxz()));
		jyxx_row.put("FWLX", transform_fwlx(h.getFwlx()));

		jyxx_row.put("QSQSZYFS",transform_cqly(fdcq2.getCqly()));  
		jyxx_row.put("BDCDYH", fdcq2.getBdcdyh());
		jyxx_row.put("FYBH", h.getBtfwbm());

		jyxx_rows.add(jyxx_row);
		jyxx_set.put("Row", jyxx_rows);
		res_map.put("RecordSet", jyxx_set);
		return res_map;
	}
	
	public String transform_fwts(int ts) {
		 if(ts == 0) {
			 return "01";
		 }else  if(ts == 1) {
			 return "02";
		 }else  if(ts == 2) {
			 return "03";
		 }else {
			 return "04";
		 }
	}
	
	public String transform_fwtc(int cs) {
		 if(cs == 1) {
			 return "01";
		 }else  if(cs == 2) {
			 return "02";
		 }else {
			 return "03";
		 }
	}
	
	public String transform_cqly(String cqly) {
		switch (cqly) {
			case "4":
				return "21" ;
			case "5":
				return "22" ;
			case "6":
				return "23" ;	
			case "11":
				return "24" ;	
			default:
				return "29" ;
		}
	}

	public String transform_fwyt(String fwyt) {
		switch (fwyt) {
		case "10":
		case "11":
		case "111":
		case "112":
		case "12":
		case "13":
		case "20":
		case "21":
		case "22":
		case "23":
		case "24":
		case "25":
		case "26":
		case "27":
		case "30":
		case "31":
		case "32":
		case "33":
		case "34":
		case "35":
		case "40":
		case "41":
		case "42":
		case "43":
		case "50":
		case "51":
		case "52":
		case "53":
		case "54":
		case "55":
		case "60":
		case "70":
		case "80":
		case "81":
		case "82":
		case "83":
		case "84":
			return fwyt;
		case "801":
		case "802":
		case "803":
		case "804":
		case "805":
		case "85":
			return "80";
		default:
			return "80";
		}
	}

	public String transform_fwlx(String fwlx) {
		switch (fwlx) {
		case "1":
			// 1 住宅
			return "1";
		case "2":
			// 2 商业用房
			return "2";
		case "3":
			// 3 办公用房
			return "3";
		case "4":
			// 4 工业用房
			return "4";
		case "5":
			// 5 仓储用房
			return "5";
		case "6":
			// 6 车库
			return "6";
		default:
			/**
			 * 7 柴房 8 车位 99 其它
			 **/
			return "99";
		}

	}

	public String transform_fwxz(String fwxz) {
		switch (fwxz) {
		case "0":
			/**
			 * 0 市场化商品房
			 */
			return "0";
		case "1":
		case "10":
		case "11":
		case "12":
		case "13":
		case "14":
		case "15":
		case "16":
			/**
			 * 1 动迁房 10 保障性住房 11 房改房 12 自建房 13 解困房 14 安居房 15 移民搬迁安置房 16 成本价售房
			 */
			return "1";
		case "2":
			// 2 配套商品房
			return "2";
		case "3":
			// 3 公共租赁住房
			return "3";
		case "4":
			// 4 廉租住房
			return "4";
		case "5":
			// 5 限价普通商品住房
			return "5";
		case "6":
			// 6 经济适用住房
			return "6";
		case "7":
			// 7 定销商品房
			return "7";
		case "8":
			// 8 集资建房
			return "8";
		case "9":
			// 9 福利房
			return "9";
		default:
			// 99 其它
			return "99";
		}
	}

	public RegBaseZdjbxx getZdjbxxByBdcdyh(String bdcdyh) {
		RegBaseZdjbxx zdjbxx = new RegBaseZdjbxx();
		zdjbxx.setZddm(bdcdyh.substring(0, 19));
		zdjbxx.setIslogout("0");
		List<RegBaseZdjbxx> zdjbxxlst = regBaseZdjbxxService.findList(zdjbxx);
		if (zdjbxxlst == null) {
			return null;
		}
		return zdjbxxlst.get(0);
	}

	public RegBusSlsq getSlsqByYwh(String ywh) {
		RegBusSlsq slsq = new RegBusSlsq();
		slsq.setYwh(ywh);
		List<RegBusSlsq> slsqLst = regBusSlsqService.findList(slsq);
		if (slsqLst == null || slsqLst.size() <= 0) {
			return null;
		}
		return slsqLst.get(0);
	}

	public List<RegBusQlr> getQlrByYwh(String ywh, String bdcdyh) {
		// 查出此权利人对应的业务号
		RegBusQlr qlr = new RegBusQlr();

		qlr.setBdcdyh(bdcdyh);
		qlr.setYwh(ywh);

		List<RegBusQlr> qlrList = regBusQlrService.findListNF(qlr);
		return qlrList;
	}

	public List<RegBusYwr> getYwrByYwh(String ywh, String bdcdyh) {
		// 查出此权利人对应的业务号
		RegBusYwr ywr = new RegBusYwr();

		ywr.setBdcdyh(bdcdyh);
		ywr.setYwh(ywh);

		List<RegBusYwr> ywrList = regBusYwrService.findList(ywr);
		return ywrList;
	}

	public List<RegBusBdcqzsdjxx> getDjxxByYwh(String ywh, String bdcdyh) {
		RegBusBdcqzsdjxx dj = new RegBusBdcqzsdjxx();
		dj.setBdcdyh(bdcdyh);
		dj.setYwh(ywh);
		dj.setIslogout("01");
		dj.setDbsj("NOTNULL");
		dj.setRights("1");
		List<RegBusBdcqzsdjxx> djxxlist = regBusBdcqzsdjxxService.findhttpList(dj);
		return djxxlist;
	}

	public RegBusFdcq2 getFdcq2ByHtbm(String htbm) {
		RegBusFdcq2 regBusFdcq2 = new RegBusFdcq2();
		regBusFdcq2.setHtbh(htbm);
		List<RegBusFdcq2> fdcq2Lst = regBusFdcq2Service.findList(regBusFdcq2);
		if (fdcq2Lst == null || fdcq2Lst.size() <=0) {
			return null;
		}
		if (fdcq2Lst.size() > 1) {
			throw new ServiceException("系统找到多条合同编码[ESFMMHTH]{" + htbm + "}对应的交易信息");
		}

		return fdcq2Lst.get(0);
	}

	public RegBusFdcq2 getFdcq2ByYwh(String ywh, String bdcdyh) {
		RegBusFdcq2 regBusFdcq2 = new RegBusFdcq2();
		regBusFdcq2.setYwh(ywh);
		regBusFdcq2.setBdcdyh(bdcdyh);
		List<RegBusFdcq2> fdcq2Lst = regBusFdcq2Service.findList(regBusFdcq2);
		if (fdcq2Lst == null) {
			return null;
		}
		return fdcq2Lst.get(0);
	}
}