8814a961674946042553222a4b71deb373ddc930.svn-base 39.1 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
package com.thinkgem.jeesite.modules.restQydm;

import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

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.DateUtils;
import com.thinkgem.jeesite.common.utils.JsonUtil;
import com.thinkgem.jeesite.common.utils.StringUtils;
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.RegBasePerson;
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.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.RegBusSjchild;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusSjmain;
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.RegBusYwr;
import com.thinkgem.jeesite.modules.reg.entity.bus.YcslSlsq;
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.RegBasePersonService;
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.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.RegBusSjmainService;
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.RegBusYwrService;
import com.thinkgem.jeesite.modules.reg.service.bus.YcslSlsqService;
import com.thinkgem.jeesite.modules.reg.utils.RegUtils;
import com.thinkgem.jeesite.modules.reg.web.httprest.httpRestService.HttpRestToService;
import com.thinkgem.jeesite.modules.reg.web.httprest.utils.DatatypeUtil;
import com.thinkgem.jeesite.modules.reg.web.httprest.utils.FTPUtil;
import com.thinkgem.jeesite.modules.reg.web.httprest.utils.SysUtil;
import com.thinkgem.jeesite.modules.sys.dao.DictDao;
import com.thinkgem.jeesite.modules.sys.entity.Dict;
import com.thinkgem.jeesite.modules.sys.entity.User;
import com.thinkgem.jeesite.modules.sys.utils.DictUtils;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;

@Service
@Transactional(readOnly = true)
public class restQydmInterfaceService {
	private static Logger logger = LoggerFactory.getLogger(restQydmInterfaceService.class);
	@Autowired
	private RegBusBdcqzsdjxxService regBusBdcqzsdjxxService;
	@Autowired
	private YcslSlsqService ycslSlsqService;
	@Autowired
	private RegBusSlsqService regBusSlsqService;
	@Autowired
	private RegBusQlrService regBusQlrService;
	@Autowired
	private RegBasePersonService regBasePersonService;
	@Autowired
	private RegBaseHService regBaseHService;
	@Autowired
	private RegBaseZdjbxxService regBaseZdjbxxService;
	@Autowired
	private RegBaseZrzService regBaseZrzService;
	@Autowired
	private RegBaseCService regBaseCService;
	@Autowired
	private RegBusYwrService regBusYwrService;
	@Autowired
	private RegBusDyaqService regBusDyaqService;
	@Autowired
	private RegBusSjmainService regBusSjmainService;
	@Autowired
	private HttpRestToService httpRestToService;
	@Autowired
	private DictDao dictDao;
	@Autowired
	private RegBusFdcq2Service regBusFdcq2Service;
	@Autowired
	private RegBusYgdjService regBusYgdjService;

	/**
	 * 4.1 不动产权证/证明号验证业务层
	 * 
	 * @param jsonstr
	 * @return
	 * @throws Exception
	 */
	public Map checkBdcqxxByZh(String jsonstr) throws Exception {
		Map resmap = Maps.newHashMap();
		List jsonList = JsonUtil.ObjectToList(jsonstr);
		for (int i = 0; i < jsonList.size(); i++) {
			Map jsonobj = (Map) jsonList.get(i);
			// 流程代码(外网流程代码,需要内网登记系统翻译为内网登记系统流程代码)
			String lcdm = jsonobj.containsKey("lcdm") ? jsonobj.get("lcdm").toString() : "";
			String lcxlmc = jsonobj.containsKey("lcxlmc") ? jsonobj.get("lcxlmc").toString() : "";// 流程小类名称
			String qydm = jsonobj.containsKey("qydm") ? jsonobj.get("qydm").toString() : "";// 区域代码
			String zhlx = jsonobj.containsKey("zhlx") ? jsonobj.get("zhlx").toString() : "";// 证号类型
			String bdclx = jsonobj.containsKey("bdclx") ? jsonobj.get("bdclx").toString() : "";// 不动产类型
			List bdcqzhList = jsonobj.containsKey("bdcqzh") ? (List) jsonobj.get("bdcqzh") : Lists.newArrayList();
			if (StringUtils.isEmpty(bdcqzhList.get(0).toString())) {
				throw new ServiceException("节点bdcqzh参数为空,请补充!");
			}
			if (StringUtils.isEmpty(lcdm)) {
				throw new ServiceException("节点lcdm参数为空,请补充!");
			}
			if (StringUtils.isEmpty(qydm)) {
				throw new ServiceException("节点qydm参数为空,请补充!");
			}
			if (jsonobj.containsKey("bdcdyh")) {// 传入不动产单元号,验证单元号和证号是否相符
				List bdcdyhList = jsonobj.containsKey("bdcdyh") ? (List) jsonobj.get("bdcdyh") : Lists.newArrayList();
				if (StringUtils.isNotEmpty(bdcdyhList.get(0).toString())) {
					String bdcqzhs = jsonobj.get("bdcqzh").toString();// 不动产权证号/抵押证明号/预告证明号
					resmap = ckeckBdcdyh(bdcdyhList, bdcqzhs, lcdm);
					if (!(boolean) resmap.get("data")) {
						return resmap;
					}
				} else {// 不动产单元号为空,验证不动产权证号
					ckeckBdcqzh(bdcqzhList, lcdm);

				}
			} else {// 未传入不动产单元号,拆分不动产权证号验证
				ckeckBdcqzh(bdcqzhList, lcdm);

			}
		}
		return resmap;
	}

	/**
	 * 验证不动产单元号
	 * 
	 * @param bdcdyhList
	 * @param bdcqzhs
	 * @return
	 */
	private Map ckeckBdcdyh(List bdcdyhList, String bdcqzhs, String lcdm) {
		Map resmap = Maps.newHashMap();
		resmap.put("data", true);
		resmap.put("txStatus", "1");
		bdcqzhs = bdcqzhs.toString().replace("[", "");
		bdcqzhs = bdcqzhs.toString().replace("]", "");
		bdcqzhs = bdcqzhs.toString().replace("\"", "");
		for (int j = 0; j < bdcdyhList.size(); j++) {
			RegBusBdcqzsdjxx regBusBdcqzsdjxx = new RegBusBdcqzsdjxx();
			regBusBdcqzsdjxx.setBdcdyh(bdcdyhList.get(j).toString());
			regBusBdcqzsdjxx.setBdcqzh(bdcqzhs);
			regBusBdcqzsdjxx.setFzsj("notnull");
			List<RegBusBdcqzsdjxx> bdcqzsList = regBusBdcqzsdjxxService.findBdcdyhIslogoutFzsj(regBusBdcqzsdjxx);
			if (bdcqzsList.size() == 0) {
				resmap.put("data", false);
				resmap.put("rtnMessage", "不动产单元号:" + bdcdyhList.get(j).toString() + "查询的有效证号与已传输证号不符,请核验!");
				resmap.put("txStatus", "0");
				return resmap;
			} else {
				String success = clerkBusiness(lcdm, regBusBdcqzsdjxx);
				if ("1".equals(success)) {
					resmap.put("data", false);
					resmap.put("rtnMessage", "查询到不动产单元号未办结业务,请核验!");
					resmap.put("txStatus", "0");
					return resmap;
				}
			}
		}
		return resmap;
	}

	/**
	 * 未传入不动产单元号
	 * 
	 * @param bdcqzhList
	 * @param lcdm
	 * @return
	 */
	private Map ckeckBdcqzh(List bdcqzhList, String lcdm) {
		Map resmap = Maps.newHashMap();
		resmap.put("data", true);
		resmap.put("txStatus", "1");
		for (int j = 0; j < bdcqzhList.size(); j++) {
			RegBusBdcqzsdjxx regBusBdcqzsdjxx = new RegBusBdcqzsdjxx();
			regBusBdcqzsdjxx.setBdcqzh(bdcqzhList.get(j).toString());
			regBusBdcqzsdjxx.setFzsj("notnull");
			List<RegBusBdcqzsdjxx> bdcqzsList = regBusBdcqzsdjxxService.findBdcdyhIslogoutFzsj(regBusBdcqzsdjxx);
			if (bdcqzsList.size() == 0) {
				throw new ServiceException("系统未找到证(名)号:" + bdcqzhList.get(j).toString() + "的业务办理信息 ,请核验!");
			} else {
				for (int k = 0; k < bdcqzsList.size(); k++) {
					String bdcdyh = bdcqzsList.get(k).getBdcdyh();
					regBusBdcqzsdjxx.setBdcdyh(bdcdyh);
					String success = clerkBusiness(lcdm, regBusBdcqzsdjxx);
					if ("1".equals(success)) {
						throw new ServiceException("系统查询不动产单元号:" + bdcdyh + "存在未办结业务 ,请核验!");
					}
				}
			}
		}
		return resmap;
	}

	/**
	 * 核验业务是否可以进行
	 * 
	 * @param lcdm
	 * @param regBusBdcqzsdjxx
	 */
	private String clerkBusiness(String lcdm, RegBusBdcqzsdjxx regBusBdcqzsdjxx) {
		String success = "";
		regBusBdcqzsdjxx.setBdcqzh(null);
		regBusBdcqzsdjxx.setFzsj("isnull");
		List<RegBusBdcqzsdjxx> bdcqzsList = null;
		switch (lcdm) {
		case "N100203":// 预售商品房抵押预告登记
			bdcqzsList = regBusBdcqzsdjxxService.findBdcdyhIslogoutFzsj(regBusBdcqzsdjxx);
			if (bdcqzsList.size() > 0) {
				success = "1";
				return success;
			}
			break;
		case "N100301":// 房屋抵押权首次登记
			bdcqzsList = regBusBdcqzsdjxxService.findBdcdyhIslogoutFzsj(regBusBdcqzsdjxx);
			if (bdcqzsList.size() > 0) {
				success = "1";
				return success;
			}
			break;
		default:
			break;
		}
		return success;
	}

	/**
	 * 4.8 申请系统分发申请数据至登记系统业务层
	 * 
	 * @param jsonstr
	 * @return
	 */
	@Transactional(readOnly = false)
	public Map saveApplicationInfo(String jsonstr) throws Exception {
		Map resmap = Maps.newHashMap();
		Map jsonobj1 = JsonUtil.ObjectToMap(jsonstr);
		String content = jsonobj1.containsKey("content") ? jsonobj1.get("content").toString() : "";// content标签
		if (StringUtils.isEmpty(content)) {
			throw new ServiceException("缺少content参数,请补充!");
		}
		Map jsonobj = (Map) jsonobj1.get("content");
		String wwywh = jsonobj.containsKey("wwywh") ? jsonobj.get("wwywh").toString() : "";// 外网业务号
		List ywhList = jsonobj.containsKey("ywh") ? (List) jsonobj.get("ywh") : Lists.newArrayList();// 子业务号
		String lcdm = jsonobj.containsKey("lcdm") ? jsonobj.get("lcdm").toString() : "";// 流程代码
		String ysrmc = jsonobj.containsKey("ysrmc") ? jsonobj.get("ysrmc").toString() : "";
		String lcxlmc = jsonobj.containsKey("lcxlmc") ? jsonobj.get("lcxlmc").toString() : "";// 流程小类名称
		String bdclb = jsonobj.containsKey("bdclb") ? jsonobj.get("bdclb").toString() : "";// 不动产类别
		String djjg = jsonobj.containsKey("djjg") ? jsonobj.get("djjg").toString() : "";// 登记机构代码
		String djjgmc = jsonobj.containsKey("djjgmc") ? jsonobj.get("djjgmc").toString() : "";// 登记机构名称
		String bsdt = jsonobj.containsKey("bsdt") ? jsonobj.get("bsdt").toString() : "";// 办事大厅代码
		String bsdtmc = jsonobj.containsKey("bsdtmc") ? jsonobj.get("bsdtmc").toString() : "";// 办事大厅名称
		String tjsj = jsonobj.containsKey("tjsj") ? jsonobj.get("tjsj").toString() : "";// 提交时间
		String sqryhmc = jsonobj.containsKey("sqryhmc") ? jsonobj.get("sqryhmc").toString() : "";// 申请人用户名称
		String bdcqzh = jsonobj.containsKey("bdcqzh") ? jsonobj.get("bdcqzh").toString() : "";// 原不动产权证号
		List zywxxList = jsonobj.containsKey("zywxx") ? (List) jsonobj.get("zywxx") : Lists.newArrayList();// 子业务信息
		List sjcllist = jsonobj.containsKey("sjcllist") ? (List) jsonobj.get("sjcllist") : Lists.newArrayList();// 收件信息
		if (StringUtils.isEmpty(wwywh)) {
			throw new ServiceException("节点wwywh参数为空,请补充!");
		}
		if (StringUtils.isEmpty(ywhList.get(0).toString())) {
			throw new ServiceException("节点ywh参数为空,请补充!");
		}
		if (StringUtils.isEmpty(lcdm)) {
			throw new ServiceException("节点lcdm参数为空,请补充!");
		}
		if (StringUtils.isEmpty(sjcllist.get(0).toString())) {
			throw new ServiceException("节点sjcllist参数为空,请补充!");
		}
		if (StringUtils.isEmpty(lcxlmc)) {
			throw new ServiceException("节点lcxlmc参数为空,请补充!");
		}
		if (StringUtils.isEmpty(bdclb)) {
			throw new ServiceException("节点bdclb参数为空,请补充!");
		}
		if (StringUtils.isEmpty(djjg)) {
			throw new ServiceException("节点djjg参数为空,请补充!");
		}
		if (StringUtils.isEmpty(bsdt)) {
			throw new ServiceException("节点bsdt参数为空,请补充!");
		}
		if (StringUtils.isEmpty(tjsj)) {
			throw new ServiceException("节点tjsj参数为空,请补充!");
		}
		if (StringUtils.isEmpty(sqryhmc)) {
			throw new ServiceException("节点sqryhmc参数为空,请补充!");
		}
		if (StringUtils.isEmpty(zywxxList.get(0).toString())) {
			throw new ServiceException("节点zywxx参数为空,请补充!");
		}
		if (StringUtils.isEmpty(ysrmc)) {
			throw new ServiceException("节点ysrmc参数为空,请补充!");
		}
		User localUser = UserUtils.getByLoginName("互联网申请人员");
		resmap = slsqxxSave(zywxxList, sjcllist, lcdm, jsonobj.get("ywh").toString(), localUser);
		if ((boolean) resmap.get("data")) {
			SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			ParsePosition pos = new ParsePosition(0);
			Date strtodate = formatter.parse(tjsj, pos);
			for (int i = 0; i < ywhList.size(); i++) {
				YcslSlsq ycslSlsq = new YcslSlsq();
				ycslSlsq.setWwywh(wwywh);
				ycslSlsq.setYwh(ywhList.get(i).toString());
				ycslSlsq.setLcdm(lcdm);
				ycslSlsq.setLcxlmc(lcxlmc);
				ycslSlsq.setBdclb(bdclb);
				ycslSlsq.setDjjg(djjg);
				ycslSlsq.setDjjgmc(djjgmc);
				ycslSlsq.setBsdt(bsdt);
				ycslSlsq.setBsdtmc(bsdtmc);
				ycslSlsq.setTjsj(strtodate);
				ycslSlsq.setSqryhmc(sqryhmc);
				ycslSlsq.setBdcqzh(bdcqzh);
				ycslSlsq.setRemarks("省一窗受理");
				ycslSlsq.setCreateBy(localUser);
				ycslSlsq.setUpdateBy(localUser);
				ycslSlsqService.save(ycslSlsq);
			}
		}
		return resmap;
	}

	/**
	 * 生成登记信息业务
	 * 
	 * @param zywxxList
	 * @throws Exception
	 */
	@Transactional(readOnly = true)
	private Map slsqxxSave(List zywxxList, List sjcllist, String lcdm, String ywhs, User localUser) throws Exception {
		Map resmap = Maps.newHashMap();
		resmap.put("data", true);
		resmap.put("rtnMessage", "返回成功");
		resmap.put("txStatus", "1");
		for (int i = 0; i < zywxxList.size(); i++) {
			Map zywxxi = (Map) zywxxList.get(i);
			String bdcdjzmh = zywxxi.containsKey("bdcdjzmh") ? zywxxi.get("bdcdjzmh").toString() : "";
			String ywh = zywxxi.containsKey("ywh") ? zywxxi.get("ywh").toString() : "";
			List qlrsList = zywxxi.containsKey("qlrs") ? (List) zywxxi.get("qlrs") : Lists.newArrayList();// 权利人信息
			List ywrsList = zywxxi.containsKey("ywrs") ? (List) zywxxi.get("ywrs") : Lists.newArrayList();// 义务人信息
			List tzrsList = zywxxi.containsKey("tzrs") ? (List) zywxxi.get("tzrs") : Lists.newArrayList();// 通知人信息
//			List qlxxExList = zywxxi.containsKey("qlxxEx")?(List)zywxxi.get("qlxxEx") : Lists.newArrayList();//权力信息
			List qlxxExMhsList = zywxxi.containsKey("qlxxExMhs") ? (List) zywxxi.get("qlxxExMhs")
					: Lists.newArrayList();// 权力户信息
			String qlxxExstr = zywxxi.containsKey("qlxxEx") ? zywxxi.get("qlxxEx").toString() : "";
			Map qlxxEx = (Map) zywxxi.get("qlxxEx");
			if (StringUtils.isEmpty(ywh)) {
				throw new ServiceException("子业务信息中的ywh为空,请核验!");
			} else if (StringUtils.isEmpty(qlrsList.get(0).toString())) {
				throw new ServiceException("子业务信息中的qlrs信息为空,请核验!");
			} else if (StringUtils.isEmpty(ywrsList.get(0).toString())) {
				throw new ServiceException("子业务信息中的ywrs信息为空,请核验!");
			} else if (StringUtils.isEmpty(qlxxExstr)) {
				throw new ServiceException("子业务信息中的qlxxEx信息为空,请核验!");
			} else if (StringUtils.isEmpty(qlxxExMhsList.get(0).toString())) {
				throw new ServiceException("子业务信息中的qlxxExMhs信息为空,请核验!");
			} else {
				if (!ywhs.contains(ywh)) {
					throw new ServiceException("子业务信息中的业务号不存在于子业务号集合中,请核验!");
				} else {
					String djxl = "";
					String djdl = "";
					String bdcdjxxrights = "";
					String bdcdjxxqllx = "";
					String dydjxx = "";
					String dybdclx = "";
					switch (lcdm) {
					case "N100203":// 预售商品房抵押预告登记
						djxl = "804";
						djdl = "700";
						bdcdjxxrights = "5";
						bdcdjxxqllx = "24";
						dydjxx = "抵押人:" + ((Map) qlrsList.get(0)).get("qlrmc").toString() + "抵押方式:1" + "抵押范围:全部";
						dybdclx = DictUtils.getDictValue("土地和房屋", "reg_bus_dybdclx", "");
						break;
					case "N100301":// 房屋抵押权首次登记
						djxl = "214";
						djdl = "100";
						bdcdjxxrights = "2";
						bdcdjxxqllx = "24";
						dydjxx = "抵押人:" + ((Map) qlrsList.get(0)).get("qlrmc").toString() + "抵押方式:1" + "抵押范围:全部";
						dybdclx = DictUtils.getDictValue("土地和房屋", "reg_bus_dybdclx", "");
						break;
					case "N100099":// 在建工程抵押
						djxl = "213";
						djdl = "100";
						bdcdjxxrights = "5";
						bdcdjxxqllx = "24";
						dydjxx = "抵押人:" + ((Map) qlrsList.get(0)).get("qlrmc").toString() + "抵押方式:1" + "抵押范围:全部";
						dybdclx = DictUtils.getDictValue("土地和在建建筑物", "reg_bus_dybdclx", "");
						break;
					case "N200104":// 所有权转移登记
						djxl = "302";
						djdl = "200";
						bdcdjxxrights = "1";
						bdcdjxxqllx = "24";
						dydjxx = "抵押人:" + ((Map) qlrsList.get(0)).get("qlrmc").toString() + "抵押方式:1" + "抵押范围:全部";
						dybdclx = DictUtils.getDictValue("土地和在建建筑物", "reg_bus_dybdclx", "");
						break;
					default:
						break;
					}

//					if("N200111".equals(zywxxlcdm) || "N200112".equals(zywxxlcdm) || "N100304".equals(zywxxlcdm)
//							 || "N100302".equals(zywxxlcdm) || "N100303".equals(zywxxlcdm)) {//土地抵押类型代码
//						dybdclx = DictUtils.getDictValue("土地", "reg_bus_dybdclx", "");
//					}
					
					String tzrxm = ""; 
					String tzdh = "";
					for (int s = 0; s < tzrsList.size(); s++) {
						Map tzrs = (Map) tzrsList.get(s);
						String tzr_mc = tzrs.containsKey("tzrmc") ? tzrs.get("tzrmc").toString() : "";
						String tz_dh = tzrs.containsKey("tzdh") ? tzrs.get("tzdh").toString() : "";
						String category = tzrs.containsKey("category") ? tzrs.get("category").toString() : "";

						switch (category) { 
							case "0":
							case "2":
							case "7":
							case "5":
							case "10":
							case "12":
								tzrxm = StringUtils.isEmpty(tzrxm) ? tzr_mc : (tzrxm + " " + tzr_mc);
								tzdh = StringUtils.isEmpty(tzdh) ? tz_dh : (tzdh + " " + tz_dh);
								break;
							default:
								break;
						}
					}
					
					RegBusSlsq regBusSlsq = new RegBusSlsq();
					regBusSlsq.setProid(ywh);
					regBusSlsq.setSllx("20");
					List<RegBusSlsq> findSlsqList = regBusSlsqService.findList(regBusSlsq);
					if (findSlsqList.size() > 0) {
						regBusSlsq = findSlsqList.get(0);
						throw new ServiceException("子业务号为:" + ywh + "的业务已存在登记系统正在审核,请勿重复推送!");
					}
					String maxYwh = regBusSlsqService.findMaxYwh();
					String djywh = RegUtils.getNextYwh(maxYwh);
					regBusSlsq.setYwh(djywh);
					regBusSlsq.setYsdm("2004010000");
					regBusSlsq.setSlsj(new Date());
					
				
					regBusSlsq.setTzrxm(tzrxm);
					regBusSlsq.setTzrdh(tzdh);
					regBusSlsq.setSlry(localUser.getLoginName());
					regBusSlsq.setDjxl(djxl);
					regBusSlsq.setDjdl(djdl);
					regBusSlsq.setSqzsbs(0);
					regBusSlsq.setJssj(new Date());
					regBusSlsq.setSqfbcz(0);
					regBusSlsq.setQxdm(Global.getAreaCode());
					regBusSlsq.setSfwtaj("0");
					regBusSlsq.setProcInsId("");
					regBusSlsq.setTaskdefkey("reg_start");
					regBusSlsq.setIsgs("0");
					regBusSlsq.setIslock("0");
					regBusSlsq.setCreateby(localUser.getId());
					regBusSlsq.setUpdateBy(localUser);
					regBusSlsq.setRemarks("99");
					regBusSlsq.setDelFlag("0");
					regBusSlsq.setSllx("20");
					regBusSlsqService.save(regBusSlsq);
					httpRestToService.commimtslsq(regBusSlsq);// 生成流程
					saveFjFiles(sjcllist, djywh, localUser);// 保存收件信息

					for (int j = 0; j < qlrsList.size(); j++) {
						Map qlrs = (Map) qlrsList.get(i);
						RegBusQlr regBusQlr = new RegBusQlr();
						regBusQlr.setYwh(djywh);
						switch (qlrs.get("gyfs").toString()) {
						case "0":// 单独所有
							regBusQlr.setGyfs(qlrs.get("gyfs").toString());
							regBusQlr.setGyqk("单独所有");
							break;
						case "1":// 共同共有
							regBusQlr.setGyfs(qlrs.get("gyfs").toString());
							regBusQlr.setGyqk("共同共有");
							break;
						case "2":// 按份共有
							regBusQlr.setGyfs(qlrs.get("gyfs").toString());
							regBusQlr.setGyqk("按份共有");
							break;
						default:// 3其他共有
							regBusQlr.setGyfs(qlrs.get("gyfs").toString());
							regBusQlr.setGyqk("其他共有");
							break;
						}
						RegBasePerson regBasePerson = new RegBasePerson();
						regBasePerson.setZjh(qlrs.get("zjh").toString()); 
						regBasePerson.setRymc(qlrs.get("qlrmc").toString());
					
						regBasePerson = checkRegBasePerson(regBasePerson);
						
						regBasePerson.setZjzl(qlrs.get("zjzl").toString());
						regBasePerson.setDh(qlrs.get("dh").toString());
						regBasePerson.setXb(qlrs.get("xb").toString());
						regBasePerson.setCreateBy(localUser);
						regBasePerson.setUpdateBy(localUser);
						regBasePersonService.save(regBasePerson);
						regBusQlr.setPcode(regBasePerson.getPcode());
						if (qlxxExMhsList.size() == 1) {
							regBusQlr.setBdcdyh(((Map) qlxxExMhsList.get(0)).get("bdcdyh").toString());
						}
						regBusQlr.setYsdm("6003000000");
						regBusQlr.setSxh(j + 1);
						regBusQlr.setQlrmc(qlrs.get("qlrmc").toString());
						regBusQlr.setSfczr("0");
						regBusQlr.setZjzl(qlrs.get("zjzl").toString());
						regBusQlr.setZjh(qlrs.get("zjh").toString());
						regBusQlr.setSshy("0");
						regBusQlr.setGj("142");
						regBusQlr.setXb(qlrs.get("xb").toString());
						regBusQlr.setDh(qlrs.get("dh").toString());
						regBusQlr.setQlrlx(qlrs.get("qlrlx").toString());
						regBusQlr.setDlrmc(qlrs.get("dlrmc").toString());
						regBusQlr.setDlrdh(qlrs.get("dljgdh").toString());
						regBusQlr.setDljgmc(qlrs.get("dljg").toString());
						regBusQlr.setQllx(bdcdjxxqllx);
						regBusQlr.setFddbrfzr(qlrs.get("frmc").toString());
						regBusQlr.setFddbrfzrdh(qlrs.get("frdh").toString());
						regBusQlr.setDlrmc(qlrs.get("dlrmc").toString());
						regBusQlr.setDlrdh(qlrs.get("dlrzjh").toString());
						regBusQlr.setRemarks("省一窗受理");
						regBusQlr.setCreateBy(localUser);
						regBusQlr.setUpdateBy(localUser);
						regBusQlr.setDelFlag("0");
						if ("0".equals(regBusQlr.getGyfs())) {
							regBusQlr.setQlbl("100");
						}
						regBusQlrService.save(regBusQlr);
					}
					String dyrxx = "";
					String dygyr = "";

					for (int j = 0; j < ywrsList.size(); j++) {
						Map ywrs = (Map) ywrsList.get(j);
						String category = ywrs.containsKey("category") && ywrs.get("category") != null
								? ywrs.get("category").toString()
								: "100";
						String ywrmc = ywrs.containsKey("ywrmc") && ywrs.get("ywrmc") != null
								? ywrs.get("ywrmc").toString()
								: "";
						String ywrzjzl = ywrs.containsKey("zjzl") && ywrs.get("zjzl") != null
								? ywrs.get("zjzl").toString()
								: "";
						String ywrzjbm = ywrs.containsKey("zjh") && ywrs.get("zjh") != null ? ywrs.get("zjh").toString()
								: "";
						switch (category) {
						case "11":
						case "6":
							saveYwr(djywh, ywrs, bdcdjxxqllx, localUser, j + 1);
							break;
						case "10":
						case "5":
							dyrxx = (dyrxx.equals("") ? ywrmc : dyrxx);
							dygyr = dyrxx.equals("") ? "" : (dygyr.equals("") ? ywrmc : (dygyr + "," + ywrmc));
							break;
						default:
							break;
						}
					}

					for (int j = 0; j < qlxxExMhsList.size(); j++) {
						Map qlxxExMhs = (Map) qlxxExMhsList.get(i);
						String bdcdyh = qlxxExMhs.get("bdcdyh").toString();
						String bdcqzh = qlxxExMhs.get("bdcqzh").toString();

						String fwjyjg = qlxxExMhs.containsKey("fwjyjg") && qlxxExMhs.get("fwjyjg") != null
								? qlxxExMhs.get("fwjyjg").toString()
								: null;

						if (StringUtils.isEmpty(fwjyjg)) {
							RegBusYgdj yg = new RegBusYgdj();
							yg.setBdcdyh(bdcdyh);
							List<RegBusYgdj> ygdjList = regBusYgdjService.findList(yg);
							if (ygdjList != null && ygdjList.size() > 0) {
								RegBusYgdj ygdj = ygdjList.get(0);
								fwjyjg = ygdj.getQdjg() == null ? "0" : ygdj.getQdjg().toString();
							}
							
						}

						RegBusBdcqzsdjxx regBusBdcqzsdjxx = new RegBusBdcqzsdjxx();
						regBusBdcqzsdjxx.setBdcdyh(bdcdyh);
						regBusBdcqzsdjxx.setFzsj("isnull");
						List<RegBusBdcqzsdjxx> bdcqzsList = regBusBdcqzsdjxxService
								.findBdcdyhIslogoutFzsj(regBusBdcqzsdjxx);
						if (bdcqzsList.size() > 0) {
							throw new ServiceException(
									"为:" + qlxxExMhs.get("bdcdyh").toString() + "的不动产单元号已存在正在办理的业务,请核验!");
						}

						// 查询上一笔业务
						RegBusBdcqzsdjxx old_djxx = new RegBusBdcqzsdjxx();
						old_djxx.setBdcdyh(bdcdyh);
						old_djxx.setBdcqzh(bdcqzh);
						List<RegBusBdcqzsdjxx> old_djxx_list = regBusBdcqzsdjxxService.findBdcdyhIslogoutFzsj(old_djxx);
						if (old_djxx_list != null && old_djxx_list.size() > 0) {
							RegBusBdcqzsdjxx oldDjxx = old_djxx_list.get(0);
							regBusBdcqzsdjxx.setOldid(oldDjxx.getId());
						} else {
							throw new ServiceException("系统未找到不动产单元号" + bdcdyh + " 证号 " + bdcqzh + " 请核验!");
						}

						regBusBdcqzsdjxx.setFzsj(null);
						regBusBdcqzsdjxx.setYwh(djywh);
						regBusBdcqzsdjxx.setQlrmc(((Map) qlrsList.get(0)).get("qlrmc").toString());
						switch (((Map) qlrsList.get(0)).get("gyfs").toString()) {
						case "0":// 单独所有
							regBusBdcqzsdjxx.setGyqk("单独所有");
							break;
						case "1":// 共同共有
							regBusBdcqzsdjxx.setGyqk("共同共有");
							break;
						case "2":// 按份共有
							regBusBdcqzsdjxx.setGyqk("按份共有");
							break;
						default:// 3其他共有
							regBusBdcqzsdjxx.setGyqk("其他共有");
							break;
						}
						RegBaseH regBaseH = regBaseHService.getIslogout(regBusBdcqzsdjxx.getBdcdyh());
						if (regBaseH == null) {
							throw new ServiceException("为:" + regBusBdcqzsdjxx.getBdcdyh() + "的不动产单元号不存在于户基础资料中,请核验!");
						}
						RegBaseC regBaseC = regBaseCService.get(regBaseH.getCid());
						RegBaseZrz regBaseZrz = regBaseZrzService.get(regBaseC.getZid());
						RegBaseZdjbxx regBaseZdjbxx = regBaseZdjbxxService.getdy(regBaseZrz.getZddm());
						if (regBaseZdjbxx == null) {
							throw new ServiceException("为:" + regBusBdcqzsdjxx.getBdcdyh() + "的不动产单元号查询不到有效的宗地信息,请核验!");
						}
						regBusBdcqzsdjxx.setZl(regBaseH.getZl());
						regBusBdcqzsdjxx.setZddm(regBaseZrz.getZddm());
						regBusBdcqzsdjxx.setQllx(bdcdjxxqllx);
						String hqlxz = DictUtils.getDictLabel(regBaseH.getQlxz(), "reg_bus_qlxz", "");
						String hfwxz = DictUtils.getDictLabel(regBaseH.getFwxz(), "reg_bus_fwxz", "");
						regBusBdcqzsdjxx.setQlxz(hqlxz + "/" + hfwxz);
						String hfwyt = DictUtils.getDictValue(regBaseH.getFwyt1(), "reg_bus_fwyt", "");
						regBusBdcqzsdjxx.setYt(regBaseZdjbxx.getYt() + "/" + hfwyt);
						regBusBdcqzsdjxx.setMj(regBaseH.getScjzmj() + "");
						String jgrq = "";
						if (regBaseZrz.getJgrq() != null) {
							jgrq = DateUtils.formatDate(regBaseZrz.getJgrq(), "yyyy年MM月dd日");
						}
						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(regBaseZrz.getZcs()))
								.append(";").append("所在层数:").append(RegUtils.replaceNull(regBaseC.getSjc())).append(";")
								.append("房屋竣工时间:").append(RegUtils.replaceNull(jgrq)).append(";").append("共有情况:")
								.append(RegUtils.replaceNull(regBusBdcqzsdjxx.getGyqk())).append(";");
						regBusBdcqzsdjxx.setQlqtzk(sb.toString());
						regBusBdcqzsdjxx.setDydjxx(dydjxx);
						regBusBdcqzsdjxx.setDjlx(djxl);
						regBusBdcqzsdjxx.setStatus("8");
						regBusBdcqzsdjxx.setIshistory("0");
						regBusBdcqzsdjxx.setIslogout("0");
						regBusBdcqzsdjxx.setIsfdsj(0);
						regBusBdcqzsdjxx.setIsprint("0");
						regBusBdcqzsdjxx.setRights(bdcdjxxrights);
						regBusBdcqzsdjxx.setCreater(localUser.getId());
						regBusBdcqzsdjxx.setUpdateBy(localUser);
						regBusBdcqzsdjxx.setRemarks("99");
						regBusBdcqzsdjxx.setDelFlag("0");
						Date syqqssj = new Date();
						Date syqjssj = new Date();
						if ("1".equals(bdcdjxxrights) || "4".equals(bdcdjxxrights)) {// 所有权
							String lsyqqssj = zywxxi.containsKey("syqqssj") ? zywxxi.get("syqqssj").toString() : "";
							String lsyqjssj = zywxxi.containsKey("syqjssj") ? zywxxi.get("syqjssj").toString() : "";
							syqqssj = new Date(Long.parseLong(String.valueOf(lsyqqssj)));
							syqjssj = new Date(Long.parseLong(String.valueOf(lsyqjssj)));
						} else if ("2".equals(bdcdjxxrights) || "5".equals(bdcdjxxrights)) {// 他项权
							RegBusDyaq regBusDyaq = new RegBusDyaq();
							regBusDyaq.setDybdclx(dybdclx);
							regBusDyaq.setTdzh(qlxxExMhs.get("bdcqzh").toString());
							regBusDyaq.setBdcdyh(regBusBdcqzsdjxx.getBdcdyh());
							regBusDyaq.setYwh(djywh);
							RegBusYwr regBusYwr = new RegBusYwr();
							regBusYwr.setYwh(djywh);
							regBusYwr.setBdcdyh(regBusBdcqzsdjxx.getBdcdyh());
							List<RegBusYwr> findYwrList = regBusYwrService.findList(regBusYwr);
							if (findYwrList.size() == 0) {
								throw new ServiceException("为:" + regBusBdcqzsdjxx.getBdcdyh() + "的不动产单元号义务人保存失败,请核验!");
							} else {
								regBusDyaq.setDygyr(dygyr);
								regBusDyaq.setDyr(dyrxx);// 权利人名称
								regBusDyaq.setZwr(findYwrList.get(0).getQlrmc());
								regBusDyaq.setZwrzjh(findYwrList.get(0).getZjh());
								regBusDyaq.setZwrzjzl(DictUtils.getDictLabel(findYwrList.get(0).getZjzl(), "reg_bus_zjlx", "其它") );

							}
							String dyfs = qlxxEx.containsKey("dyfs") ? qlxxEx.get("dyfs").toString() : "1";
							regBusDyaq.setDyfs(dyfs);
							regBusDyaq.setDjlx(djdl);
							regBusDyaq.setDjyy(qlxxEx.get("sqdjyy").toString());
							regBusDyaq.setZjjzwzl(regBaseH.getZl());
							regBusDyaq.setZjjzwdyfw("全部");
							SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
							String zwlxqssj = qlxxEx.containsKey("zwlxqssj") ? qlxxEx.get("zwlxqssj").toString() : "";
							String zwlxjssj = qlxxEx.containsKey("zwlxjssj") ? qlxxEx.get("zwlxjssj").toString() : "";
							regBusDyaq.setZwlxqssj(simpleDateFormat.parse(zwlxqssj));
							regBusDyaq.setZwlxjssj(simpleDateFormat.parse(zwlxjssj));
							regBusDyaq.setJzmjhj(String.valueOf(regBaseH.getScjzmj()));
							regBusDyaq.setQxdm(Global.getAreaCode());
							regBusDyaq.setQszt("0");
							regBusDyaq.setIsfdsj(0);
							regBusDyaq.setPgjz(fwjyjg == null ? null : Double.parseDouble(fwjyjg));

							regBusDyaq.setYsdm(regBaseH.getYsdm());
							regBusDyaq.setDyqr(((Map) qlrsList.get(0)).get("qlrmc").toString());
							if ("1".equals(dyfs)) {
								regBusDyaq.setBdbzzqse(Double.valueOf(qlxxEx.get("bdbzzqse").toString()));
								regBusDyaq.setZgzqse(0D);
							} else {
								regBusDyaq.setBdbzzqse(0D);
								regBusDyaq.setZgzqse(Double.valueOf(qlxxEx.get("bdbzzqse").toString()));
								regBusDyaq.setZgzqqdss(qlxxEx.get("zgzqqdss").toString());
							}
							regBusDyaq.setDbze(Double.valueOf(qlxxEx.get("bdbzzqse").toString()));
							String bdcpgjz = qlxxEx.containsKey("bdcpgjz") ? qlxxEx.get("bdcpgjz").toString() : "";
							if (StringUtils.isNotBlank(bdcpgjz)) {
								regBusDyaq.setPgjz(Double.valueOf(bdcpgjz));
							}
							RegBusBdcqzsdjxx regBusBdcqzsdjxx1 = new RegBusBdcqzsdjxx();
							regBusBdcqzsdjxx1.setBdcdyh(qlxxExMhs.get("bdcdyh").toString());
							regBusBdcqzsdjxx1.setFzsj("notnull");
							regBusBdcqzsdjxx1.setRights("1346");
							List<RegBusBdcqzsdjxx> bdcqzsList1 = regBusBdcqzsdjxxService
									.findBdcdyhIslogoutFzsj(regBusBdcqzsdjxx1);
							regBusDyaq.setTdzh(bdcqzsList1.get(0).getBdcqzh());
							regBusDyaq.setDelFlag("0");
							regBusDyaq.setCreateBy(localUser);
							regBusDyaq.setUpdateBy(localUser);
							regBusDyaq.setBdcdjzmh(bdcdjzmh);
							regBusDyaqService.save(regBusDyaq);
							syqqssj = regBusDyaq.getZwlxqssj();
							syqjssj = regBusDyaq.getZwlxjssj();
						} else if ("3".equals(bdcdjxxrights) || "6".equals(bdcdjxxrights)) {// 使用权

						}
						regBusBdcqzsdjxx.setSyqx(DateUtils.formatDate(syqqssj, "yyyy年MM月dd日") + "起"
								+ DateUtils.formatDate(syqjssj, "yyyy年MM月dd日") + "止;");
						regBusBdcqzsdjxxService.save(regBusBdcqzsdjxx);
					}
				}
			}
		}
		return resmap;
	}

	private void saveYwr(String djywh, Map ywrs, String bdcdjxxqllx, User localUser, int sxh) {
		RegBusYwr regBusYwr = new RegBusYwr();
		regBusYwr.setYsdm("6003000000");
		regBusYwr.setYwh(djywh);
		regBusYwr.setBdcdyh(ywrs.get("bdcdyh") == null ? null : ywrs.get("bdcdyh").toString());
		regBusYwr.setSxh(sxh + "");

		RegBasePerson regBasePerson = new RegBasePerson();
		regBasePerson.setZjh(ywrs.get("zjh").toString()); 
		regBasePerson.setRymc(ywrs.get("ywrmc").toString()); 
		regBasePerson = checkRegBasePerson(regBasePerson);
		 
		regBasePerson.setDh(ywrs.get("dh").toString());
		regBasePerson.setCreateBy(localUser);
		regBasePerson.setUpdateBy(localUser);
		regBasePerson.setZjzl(ywrs.get("zjzl").toString());
		regBasePersonService.save(regBasePerson);

		regBusYwr.setQlrmc(ywrs.get("ywrmc").toString());
		regBusYwr.setPcode(regBasePerson.getPcode());
		regBusYwr.setZjzl(ywrs.get("zjzl").toString());
		regBusYwr.setZjh(ywrs.get("zjh").toString());
		regBusYwr.setSfczr(ywrs.get("sfczr") == null ? null : ywrs.get("sfczr").toString());
		regBusYwr.setQlrlx(ywrs.get("qlrlx").toString());
		regBusYwr.setDh(ywrs.get("dh").toString());
		regBusYwr.setGyfs(ywrs.get("gyfs").toString());
		regBusYwr.setQllx(bdcdjxxqllx);
		regBusYwr.setSshy("0");
		regBusYwr.setGj("142");
		regBusYwr.setDlrmc(ywrs.get("dlrmc").toString());
		regBusYwr.setDljgmc(ywrs.get("dljg").toString());
		regBusYwr.setFddbrfzr(ywrs.get("frmc").toString());
		regBusYwr.setFddbrfzrdh(ywrs.get("frdh").toString());
		regBusYwr.setRemarks("省一窗受理");
		regBusYwrService.save(regBusYwr);
	}

	/**
	 * 生成登记系统,没有相关人员,新增人员信息
	 * 
	 * @param zjh
	 * @param zjzl
	 * @return
	 */
	private RegBasePerson checkRegBasePerson(RegBasePerson regBasePerson) {
		List<RegBasePerson> findPersonList = regBasePersonService.findListqy(regBasePerson);
		if (findPersonList.size() > 0) {
			regBasePerson = findPersonList.get(0);
		} else {
			regBasePerson.setPcode(RegUtils.getHMaxFwbm(regBasePersonService.getHMaxPCode()));
			regBasePerson.setRylx("1");
			regBasePerson.setIsaudit("0");
			regBasePerson.setSshy("0");
			regBasePerson.setGj("142");
			regBasePerson.setVeritydatazt("0");
			regBasePerson.setDelFlag("0"); 
		}
		return regBasePerson;
	}

	public void saveFjFiles(List sjclxxlst, String ywh, User user) {
		// 获取收件信息
		// 插入收件主表
		RegBusSjmain sjmain = new RegBusSjmain();
		int bz = 0;
		
		Map<String,RegBusSjchild> child_map = Maps.newHashMap();
		
		for (int s = 0; s < sjclxxlst.size(); s++) {
			Map sjmap = (Map) sjclxxlst.get(s);
			String cllx = getValueByMap(sjmap, "cllx", "");
			String sxh = getValueByMap(sjmap, "sxh", "");
			String fjlj = getValueByMap(sjmap, "cllj", "");
			String clmc = getValueByMap(sjmap, "clmc", "");
			String local_file = "";

			if (bz == 0) {
				sjmain.setYwh(ywh);
				sjmain.setYsdm("2004020000");
				sjmain.setSjsj(new Date());
				sjmain.setCreateBy(user);
				sjmain.setUpdateBy(user);
				regBusSjmainService.save(sjmain);
				bz = 1;
			}
			RegBusSjchild sjchild = new RegBusSjchild(); 
			Dict dict = new Dict();
			dict.setLabel(cllx);
			List<Dict> dictList = dictDao.findLabelList(dict);
			if (dictList.size() > 0) {
				sjchild.setSjmc(dictList.get(0).getValue());
			}else {
				sjchild.setSjmc("9");
			} 
			// 收件用链接
			String[] fileNameArray = fjlj.split(";");
			String localFilePath = "";

			for (int j = 0; j < fileNameArray.length; j++) {
				String ftpFilePath = fileNameArray[j];
				ftpFilePath = ftpFilePath.replace("store://fileStore1", "/fileCenter/content/");

				String hzname = ftpFilePath.substring(
						ftpFilePath.substring(0, ftpFilePath.length() - 1).lastIndexOf(".") + 1, ftpFilePath.length());
				String fileName = clmc;
				// 方式一 把图片下载到本地 读取本地 缺少用户
				String creater = user.getId();
				String filepath = "/userfiles/" + creater + "/files/reg/bus/regBusSjmain/" + ywh.substring(0, 7) + "/"
						+ ywh.substring(7, 9) + "/" + ywh;
				localFilePath = Global.getUserfilesBaseDir() + filepath;
				// 拼接文件路径
				String fileNamefj = "/" + clmc;
				local_file = "|/ODM" + filepath + fileNamefj;
//				local_file = local_file + "|/ODM/" + filepath + File.separator + fileName;
				// 获取

				FTPUtil ftp = new FTPUtil(SysUtil.IMAGE_FTP_IP, SysUtil.IMAGE_FTP_PORT, SysUtil.IMAGE_FTP_USERNAME,
						SysUtil.IMAGE_FTP_USERPWD, SysUtil.FILE_FTP_DEFAULTDIREECTORY);

				// ftp.getFilesNameByPath("WORK_FLOW_STUFF/2020/08/04/484H4019AQF33001/房屋登记机构所需的其他必要材料");

				logger.info("ftp 地址:{},\nlocal 地址 {},\n文件名称 {}", ftpFilePath, localFilePath, fileName);

				ftp.downFileByPath(ftpFilePath, localFilePath, fileName, true);

			}
			if(child_map.containsKey(sjchild.getSjmc())) {
				sjchild = child_map.get(sjchild.getSjmc());
				sjchild.setSjfj(sjchild.getSjfj()+local_file);
			}else {
				sjchild.setMainid(sjmain.getId());
				sjchild.setSjlx("2");// 正本复印件 
				sjchild.setSjfj(local_file);
				sjchild.setCreateDate(new Date());
				sjchild.setYs(1);
				sjchild.setSjsl(1);
				sjchild.setSort(Integer.valueOf(sxh));
				sjchild.setCreateBy(user);
				sjchild.setUpdateBy(user);
			}
			
			child_map.put(sjchild.getSjmc(), sjchild);
		}
		
		Iterator<String> it =  child_map.keySet().iterator();
		while (it.hasNext()) {
			String sjmc = it.next();
			RegBusSjchild sjchild = child_map.get(sjmc);
			regBusSjmainService.savesjchild(sjchild);
		} 
	}

	private String getValueByMap(Map map, String key, String value) {
		return map.get(key) == null ? value : map.get(key).toString();
	}
}