c168510ccd4ef164c2270c1c91b60718222a2830.svn-base 31.6 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
/**
 * Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.ycsl.service;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.apache.http.client.ClientProtocolException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.ModelMap;

import com.alibaba.druid.support.json.JSONUtils;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.exception.YcslException;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.common.utils.JsonUtil;
import com.thinkgem.jeesite.modules.ycsl.entity.YcslGxr;
import com.thinkgem.jeesite.modules.ycsl.entity.YcslJbxx;
import com.thinkgem.jeesite.modules.ycsl.entity.YcslSj;
import com.thinkgem.jeesite.modules.ycsl.entity.YcslSjcl;
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.RegBusQlr;
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.RegBasePersonService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusBdcqzsdjxxService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusQlrService;
import com.thinkgem.jeesite.modules.reg.utils.RegUtils;
import com.thinkgem.jeesite.modules.reg.web.httprest.httpRestService.HttpactivityService;
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.entity.User;
import com.thinkgem.jeesite.modules.sys.utils.DictUtils;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
import com.thinkgem.jeesite.modules.ycsl.dao.YcslGxrDao;
import com.thinkgem.jeesite.modules.ycsl.dao.YcslJbxxDao;
import com.thinkgem.jeesite.modules.ycsl.dao.YcslSjclDao;

/**
 * 一窗受理-基本信息Service
 * 
 * @author lzj
 * @version 2020-12-24
 */
@Service
@Transactional(readOnly = true)
public class YcslJbxxService extends CrudService<YcslJbxxDao, YcslJbxx> {

	@Autowired
	private YcslJbxxDao dao;
	@Autowired
	private YcslGxrService ycslGxrService;
	@Autowired
	private YcslSjclService ycslSjclService;
	@Autowired
	private HttpactivityService httpactivityService;
	@Autowired
	private YcslSjService ycslSjService;
	@Autowired
	private RegBasePersonService regBasePersonService;
	@Autowired
	private RegBusBdcqzsdjxxService regBusBdcqzsdjxxService;
	@Autowired
	private RegBaseHService regBaseHService;
	@Autowired
	private RegBaseZdjbxxService regBaseZdjbxxService;
	@Autowired
	private RegBusQlrService regBusQlrService;
	@Autowired
	private RegBaseZrzService regBaseZrzService;

	public YcslJbxx get(String id) {
		return super.get(id);
	}

	public List<YcslJbxx> findList(YcslJbxx ycslJbxx) {
		return super.findList(ycslJbxx);
	}

	public Page<YcslJbxx> findPage(Page<YcslJbxx> page, YcslJbxx ycslJbxx) {
		return super.findPage(page, ycslJbxx);
	}

	@Transactional(readOnly = false)
	public void save(YcslJbxx ycslJbxx) {
		super.save(ycslJbxx);
	}

	@Transactional(readOnly = false)
	public void deleteJbxx(YcslJbxx ycslJbxx) {
		Map map = Maps.newHashMap();
		map.put("proid", ycslJbxx.getProid());
		try {
			Map json = httpactivityService.postRequest(map, "deleteSL");
			ycslJbxx.setZt("true");
			save(ycslJbxx);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			ycslJbxx.setZt("false");
			save(ycslJbxx);
			e.printStackTrace();
		}
		delete(ycslJbxx);
	}

	@Transactional(readOnly = false)
	public void delete(YcslJbxx ycslJbxx) {
		super.delete(ycslJbxx);
	}

	@Transactional(readOnly = false)
	public void delEmpty(YcslJbxx ycslJbxx) {
		List<YcslJbxx> jbxxs = findEmpty();
		if (jbxxs.size() > 0) {
			for (int i = 0; i < jbxxs.size(); i++) {
				String proid = jbxxs.get(i).getProid();
				ycslGxrService.deleteByproid(proid);
				ycslSjclService.deleteByproid(proid);
			}
		}
		dao.delEmpty(ycslJbxx);
	}

	// 查询状态为空的数据
	private List<YcslJbxx> findEmpty() {
		// TODO Auto-generated method stub
		return dao.findEmpty();
	}

	@Transactional(readOnly = false)
	public void saveJbxx(YcslJbxx ycslJbxx) {
		Map map = Maps.newHashMap();
		if (StringUtils.isBlank(ycslJbxx.getZt())) {
			ycslJbxx.setZt("0");
			save(ycslJbxx);
			map = getMap(ycslJbxx);

			// 仅权属转移方式 == 买卖,走一窗
			if (!"4".equals(ycslJbxx.getQszyfs())) {
				ycslJbxx.setZt("true");
				save(ycslJbxx);
				return;
			}
			try {
				Map json = httpactivityService.postRequest(map, "insertSL");
				if (json.containsKey("code") && json.get("code").toString().equals("200")) {
					ycslJbxx.setZt("true");
					save(ycslJbxx);
				} else {
					ycslJbxx.setZt("false");
					save(ycslJbxx);
				}
			} catch (Exception e) {
				ycslJbxx.setZt("false");
				save(ycslJbxx);
				e.printStackTrace();
			}
		} else {
			save(ycslJbxx);
			map = getMap(ycslJbxx);
			// 仅权属转移方式 == 买卖,走一窗
			if (!"4".equals(ycslJbxx.getQszyfs())) {
				ycslJbxx.setZt("true");
				save(ycslJbxx);
				return;
			}
			try {
				Map json = httpactivityService.postRequest(map, "updateSL");
				if (json.containsKey("code") && json.get("code").toString().equals("200")) {
					ycslJbxx.setZt("true");
					save(ycslJbxx);
				} else {
					ycslJbxx.setZt("false");
					save(ycslJbxx);
				}
			} catch (Exception e) {
				ycslJbxx.setZt("false");
				save(ycslJbxx);
				e.printStackTrace();
			}
		}

	}

	public Map getMap(YcslJbxx ycslJbxx) {
		Map map = Maps.newHashMap();
		List list1 = Lists.newArrayList();
		List list2 = Lists.newArrayList();
		map.put("proid", ycslJbxx.getProid());
		map.put("bdcdyh", ycslJbxx.getBdcdyh());
		map.put("fybh", ycslJbxx.getFybh());
		map.put("zl", ycslJbxx.getZl());
		map.put("jzmj", ycslJbxx.getJzmj());
		map.put("tnmj", ycslJbxx.getTnmj());
		map.put("szc", ycslJbxx.getSzc());
		map.put("zcs", ycslJbxx.getZcs());
		map.put("zrzh", ycslJbxx.getZrzh());
		map.put("dyh", ycslJbxx.getDyh());
		map.put("fjh", ycslJbxx.getFjh());
		map.put("fwlx", ycslJbxx.getFwlx());
		map.put("fwjg", ycslJbxx.getFwjg());
		map.put("tdxz", ycslJbxx.getTdxz());
		map.put("tdyt", ycslJbxx.getTdyt());
		map.put("fwyt", ycslJbxx.getFwyt());
		map.put("fwxz", ycslJbxx.getFwxz());
		map.put("cqzh", ycslJbxx.getCqzh());
		map.put("fwdj", ycslJbxx.getFwdj());
		map.put("fwzj", ycslJbxx.getFwzj());
		map.put("qszyfs", ycslJbxx.getQszyfs());
		map.put("xmmc", ycslJbxx.getXmmc());
		map.put("jzwmc", ycslJbxx.getJzwmc());
		map.put("zdzl", ycslJbxx.getZdzl());
		map.put("jgsj", ycslJbxx.getJgsj());
		YcslGxr gxr = new YcslGxr();
		gxr.setProid(ycslJbxx.getProid());
		List<YcslGxr> gxrlist = ycslGxrService.findList(gxr);
		if (gxrlist.size() > 0) {
			for (int i = 0; i < gxrlist.size(); i++) {
				gxr = gxrlist.get(i);
				Map map1 = Maps.newHashMap();
				map1.put("gxrmc", gxr.getGxrmc());
				map1.put("gxrsfzjzl", DictUtils.getDictLabel(gxr.getGxrsfzjzl(), "reg_bus_zjlx", ""));
				map1.put("gxrzjh", gxr.getGxrzjh());
				map1.put("gxrlxdh", gxr.getGxrlxdh());
				map1.put("gxrtxdz", gxr.getGxrtxdz());
				map1.put("gxrlx", gxr.getGxrlx());
				// map1.put("rylx", DictUtils.getDictLabel(gxr.getRylx(), "reg_bus_qlrlx", ""));
				map1.put("qlbl", gxr.getQlbl());
				map1.put("gxrfddbr", gxr.getGxrfddbr());
				map1.put("gxrfddbrzjzl", gxr.getGxrfddbrzjzl());
				map1.put("gxrfddbrzjh", gxr.getGxrfddbrzjh());
				map1.put("gxrdlr", gxr.getGxrdlr());
				map1.put("gxrdlrzjzl", gxr.getGxrdlrzjzl());
				map1.put("gxrdlrzjh", gxr.getGxrdlrzjh());
				map1.put("sxh", gxr.getSxh());
				map1.put("gyqk", gxr.getGyqk());
				map1.put("gyfs", gxr.getGyfs());
				list1.add(map1);
			}
		}

		YcslSjcl sjcl = new YcslSjcl();
		YcslSj sj = ycslSjService.getByProid(ycslJbxx.getProid());
		if (sj != null) {
			sjcl.setSjId(sj);
			sjcl.setProid(sj.getProid());
			List<YcslSjcl> sjcllist = ycslSjclService.findList(sjcl);
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			if (sjcllist.size() > 0) {
				for (int j = 0; j < sjcllist.size(); j++) {
					sjcl = sjcllist.get(j);
					if (StringUtils.isNotBlank(sjcl.getSjcllj())) {
						String[] fjs = sjcl.getSjcllj().split("\\|");
						if (fjs.length > 0) {
							for (int c = 0; c < fjs.length; c++) {
								if (StringUtils.isBlank(fjs[c])) {
									continue;
								}
								Map map2 = Maps.newHashMap();
								map2.put("sjr", sjcl.getSjr());
								map2.put("sjrq", sdf.format(sjcl.getSjrq()));
								map2.put("cllx", DictUtils.getDictLabel(sjcl.getClmc(), "reg_bus_fwsjmc_zy", ""));
								map2.put("clmc", DictUtils.getDictLabel(sjcl.getClmc(), "reg_bus_fwsjmc_zy", ""));
								map2.put("fs", sjcl.getFs());
								map2.put("ys", sjcl.getYs());
								// map2.put("sjcllj", fjs[c].replace("/ODM", Global.getAreaCode()));
								map2.put("sjcllj", fjs[c].replace("/ODM", "/odm_21"));
								list2.add(map2);
							}
						}
					}
				}
			}
		}
		map.put("gxrList", list1);
		map.put("sjclList", list2);

		return map;
	}

	public String getJbxx(String bdcdyh, String dept, String htbh1) throws ClientProtocolException, IOException {
		String htbh = "";
		String proid = "";
		Map map = Maps.newHashMap();
		map.put("bdcdyh", bdcdyh);
		YcslJbxx jbxx = new YcslJbxx();
		if (StringUtils.isNotBlank(dept)) {// 交易先获取,然后保存信息
			Map map2 = Maps.newHashMap();
			map2.put("htbh", htbh1);
			map2.put("bdcdyh", bdcdyh);
			Map json2 = httpactivityService.postRequest(map2, "queryTradeYw");
			logger.debug(JsonUtil.toJsonString(json2));
			if (!json2.get("code").toString().equals("200")) {
				throw new YcslException(json2.get("message").toString());
			}
			if (json2.containsKey("data")
					&& JsonUtil.fromJson(JsonUtil.toJsonString(json2.get("data")), List.class).size() > 0) {
				Map result = (Map) JsonUtil.fromJson(JsonUtil.toJsonString(json2.get("data")), List.class).get(0);
				logger.debug(JsonUtil.toJsonString(result));
				if (htbh1.indexOf("CS") != -1) {
					if (result.get("sfgp").toString().equals("否")) {
						throw new YcslException("该房屋未挂牌");
					}
				}
				YcslJbxx jbxxnew = getByProid(result.get("proid").toString());
				if (jbxxnew == null) {
					jbxxnew = new YcslJbxx();
				}
				proid = result.get("proid").toString();
				jbxxnew.setProid(result.get("proid").toString());
				jbxxnew.setBdcdyh(result.get("bdcdyh").toString());
				jbxxnew.setDept("jy");
				jbxxnew.setDyh(result.get("dyh").toString());
				jbxxnew.setFwdj(result.get("dj").toString());
				jbxxnew.setFwjg(result.get("fwjg").toString());
				jbxxnew.setFwzj(result.get("htje").toString());
				jbxxnew.setZt("true");
				jbxxnew.setQszyfs("4");
				jbxxnew.setHtbh(htbh1);
				Map qyxx = Maps.newHashMap();
				qyxx.put("不动产单元号", result.get("bdcdyh").toString());
				qyxx.put("单价", result.get("dj").toString());
				qyxx.put("合同金额", result.get("htje").toString());
				qyxx.put("合同签约时间", result.get("htqysj").toString());
				qyxx.put("合同编号", result.get("htbh").toString());
				qyxx.put("交易类型", result.get("jylx").toString());
				qyxx.put("proid", result.get("proid").toString());
				jbxxnew.setQyxx(JsonUtil.toJsonString(qyxx));
				save(jbxxnew);
				YcslGxr gxr1 = new YcslGxr();
				gxr1.setProid(jbxxnew.getProid());
				List<YcslGxr> gxrlist = ycslGxrService.findList(gxr1);
				if (gxrlist.size() > 0) {
					ycslGxrService.deleteByproid(jbxxnew.getProid());
				}
				List list1 = (List) result.get("gxrlist");
				if (list1.size() > 0) {
					for (int i = 0; i < list1.size(); i++) {
						Map gxrs = (Map) list1.get(i);
						YcslGxr gxr = new YcslGxr();
						RegBasePerson person = new RegBasePerson();
						gxr.setProid(jbxxnew.getProid());
						gxr.setRylx(DictUtils.getDictValue(gxrs.get("gxrlx").toString(), "reg_bus_qlrlx", ""));
						person.setRylx(DictUtils.getDictValue(gxrs.get("gxrlx").toString(), "reg_bus_qlrlx", ""));
						gxr.setGxrlxdh(gxrs.get("gxrlxdh").toString());
						gxr.setGxrtxdz(gxrs.get("gxrtxdz").toString());
						person.setDz(gxrs.get("gxrtxdz").toString());
						person.setDh(gxrs.get("gxrlxdh").toString());
						gxr.setGxrsfzjzl(DictUtils.getDictValue(gxrs.get("gxrsfzjzl").toString(), "reg_bus_zjlx", ""));
						gxr.setGyfs(DictUtils.getDictValue(gxrs.get("gyfs").toString(), "reg_bus_gyfs", ""));
						gxr.setGyqk(gxrs.get("gyfs").toString());
						gxr.setQlbl(gxrs.containsKey("qlbl") ? gxrs.get("qlbl").toString() : "");
						gxr.setGxrlx("qlr");
						gxr.setGxrmc(gxrs.get("gxrmc").toString());
						gxr.setGxrzjh(gxrs.get("gxrzjh").toString());
						gxr.setSxh(i + 1);
						gxr.setGj("142");
						person.setGj("142");
						person.setRymc(gxrs.get("gxrmc").toString());
						person.setZjzl(DictUtils.getDictValue(gxrs.get("gxrsfzjzl").toString(), "reg_bus_zjlx", ""));
						person.setZjh(gxrs.get("gxrzjh").toString());
						List<RegBasePerson> personlist = regBasePersonService.findList(person);
						if (personlist.size() == 0) {
							person.setPcode(getpcode());
							person.setIsaudit("2");
							regBasePersonService.save(person);
							gxr.setPcode(person.getPcode());
						} else {
							person = personlist.get(0);
							person.setIsaudit("2");
							regBasePersonService.save(person);
							gxr.setPcode(person.getPcode());
						}
						ycslGxrService.save(gxr);
					}
				}
				jbxx = jbxxnew;
				htbh = htbh1;
				// throw new YcslException("交易信息已保存");//测试信息,不让跳入下一页面
			} else {
				// 获取不到时,由业务人员判断
				jbxx.setBdcdyh(bdcdyh);
				jbxx.setDept("jy");
				jbxx.setRemarks("未获取到信息");
				// throw new YcslException("未获取到交易信息");

			}

		} else {
			if (StringUtils.isBlank(jbxx.getHtbh())) {
				jbxx = getByBdcdyh(bdcdyh);
				// 仅权属转移方式 == 买卖,走一窗
				if (!"4".equals(jbxx.getQszyfs())) {
					return null;
				}
				// 办结
				Map json = httpactivityService.postRequest(map, "queryTradeWj");
				logger.debug(JsonUtil.toJsonString(json));
				if (json.containsKey("data")
						&& JsonUtil.fromJson(JsonUtil.toJsonString(json.get("data")), List.class).size() > 0) {
					List data = JsonUtil.fromJson(JsonUtil.toJsonString(json.get("data")), List.class);
					if (data.size() > 0) {
						htbh = ((Map) data.get(0)).get("htbh").toString();
						Map json1 = (Map) data.get(0);
						Map qyxx = Maps.newHashMap();
						proid = json1.get("proid").toString();
						qyxx.put("不动产单元号", json1.get("bdcdyh").toString());
						qyxx.put("单价", json1.get("dj").toString());
						qyxx.put("房源编号", json1.get("fybh").toString());
						qyxx.put("合同编号", json1.get("htbh").toString());
						qyxx.put("合同签约时间", json1.get("htqysj").toString());
						qyxx.put("交易类型", json1.get("jylx").toString());
						qyxx.put("proid", json1.get("proid").toString());
						qyxx.put("权利人", json1.get("qlr").toString());
						jbxx.setQyxx(JsonUtil.toJsonString(qyxx));
						jbxx.setHtbh(htbh);
						save(jbxx);
					}
				} else {
					// 获取不到时,由业务人员判断
					jbxx.setRemarks("未获取到信息");
					save(jbxx);
				}
			} else {
				htbh = jbxx.getHtbh();
			}
		}

		if (!com.thinkgem.jeesite.common.utils.StringUtils.isEmpty(proid)) {
			// 获取交易合同
			Map map2 = Maps.newHashMap();
			map2.put("htbh", htbh);
			Map deals = httpactivityService.postRequest(map2, "downDealFiles");
			List deallist = deals.containsKey("data") ? (List) deals.get("data") : Lists.newArrayList();// 收件信息
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			if (deallist.size() > 0) {
				YcslSj sj = ycslSjService.getByProid(proid);
				if (sj == null) {
					sj = new YcslSj();
					sj.setProid(proid);
					sj.setSjsj(new Date());
					ycslSjService.save(sj);
				}
				for (int j = 0; j < deallist.size(); j++) {
					YcslSjcl sjcl1 = new YcslSjcl();
					sjcl1.setCllx("1");// 原件
					sjcl1.setClmc("3");
					sjcl1.setProid(proid);
					sjcl1.setSjId(sj);
					List<YcslSjcl> sjcllist = ycslSjclService.findList(sjcl1);
					if (sjcllist.size() > 0) {
						sjcl1 = sjcllist.get(0);
					}

					String fjlj = JSONUtils.toJSONString(deallist.get(j));
					sjcl1.setSjrq(new Date());
					sjcl1.setSjcllj(getLj(fjlj, proid, "房产合同.pdf"));
					ycslSjclService.save(sjcl1);
				}
			}
		}
		// 完税
		// if(StringUtils.isBlank(jbxx.getWsbz())|| !jbxx.getWsbz().equals("Y")) {
		// 完税接口从下方开始

		Map map1 = Maps.newHashMap();
		map1.put("ESFMMHTH", htbh);
		map1.put("SFZJHM", "");
		Map json1 = httpactivityService.postRequest(map1, "wsqk");
		if (json1.containsKey("data") && !((Map) json1.get("data")).isEmpty()) {
			logger.debug(JsonUtil.toJsonString(json1));
			Map d = (Map) json1.get("data");
			String wsbz = d.containsKey("Wsbz") ? d.get("Wsbz").toString() : null;
			jbxx.setWsbz(wsbz);
			Map wsxx = Maps.newHashMap();
			wsxx.put("纳税人名称", d.get("Nsrmc").toString());
			wsxx.put("纳税人识别号", d.get("Nsrsbh").toString());
			wsxx.put("土地房屋地址", d.get("Tdfwdz").toString());
			wsxx.put("完税标志", d.get("Wsbz").toString());
			wsxx.put("应补退税额", d.get("Ybtse").toString());
			wsxx.put("应纳税额", d.get("Ynse").toString());
			jbxx.setWsxx(JsonUtil.toJsonString(wsxx));
			save(jbxx);
			if (StringUtils.isBlank(wsbz) || (StringUtils.isNotBlank(wsbz) && wsbz.equals("N"))) {
				throw new IOException("未进行完税");
			}
		} /*
			 * else { throw new IOException("完税接口返回信息出错"); }
			 */

		logger.debug(htbh);
		return htbh;
	}

	private YcslJbxx getByProid(String proid) {
		// TODO Auto-generated method stub
		return dao.getByProid(proid);
	}

	public YcslJbxx getByBdcdyh(String bdcdyh) {
		// TODO Auto-generated method stub
		return dao.getByBdcdyh(bdcdyh);
	}

	/***
	 * @Title: getpcode @Description: 获取并生成人员编码 @param @return 设定文件 @return String
	 *         返回类型 @throws
	 */
	public synchronized String getpcode() {
		String pCode = "1000000";
		pCode = RegUtils.getHMaxFwbm(regBasePersonService.getHMaxPCode());// 没有的时候返回100000,然后+1最为第一笔
		return pCode;
	}

	@Transactional(readOnly = false)
	public ModelMap selectjbxx(HttpServletRequest request) throws ClientProtocolException, IOException {
		ModelMap modelmap = new ModelMap();
		String id = request.getParameter("djxxid");
		RegBusBdcqzsdjxx djxx = regBusBdcqzsdjxxService.get(id);
		if (djxx != null) {

			RegBaseH h = regBaseHService.getdy(djxx.getBdcdyh());
			if (h != null) {
				if (StringUtils.isBlank(h.getFybh())) {
					modelmap.put("success", "1");
					modelmap.put("msg", "请先进行数据挂接");
					return modelmap;
				} else {
					Map map = Maps.newHashMap();
					map.put("bdcdyh", djxx.getBdcdyh());
					map.put("fybh", h.getFybh());
					Map json = httpactivityService.postRequest(map, "findLicenseInfo");
					Map res_map = json.containsKey("data") && json.get("data") != null ? (Map) json.get("data")
							: Maps.newHashMap();
					logger.debug(JsonUtil.toJsonString(res_map));
					if (res_map.size() > 0) {
						// 直接判断,
						/*
						 * if(res_map.containsKey("sfgp")&& res_map.get("sfgp").toString().equals("否"))
						 * {//否挂牌 modelmap.put("success", "1"); modelmap.put("msg", "该房屋未挂牌"); return
						 * modelmap; }
						 */
						if (res_map.containsKey("sfblyw") && res_map.get("sfblyw").toString().equals("否")) {// 否
							modelmap.put("success", "1");
							modelmap.put("msg", res_map.get("note").toString());
							return modelmap;
						}
					} else {

						modelmap.put("success", "1");
						modelmap.put("msg", "系统未获取到房屋交易挂牌信息");
						return modelmap;
					}
				}
				modelmap.put("bdcdyh", h.getBdcdyh());
				modelmap.put("fybh", h.getFybh());
				modelmap.put("zl", h.getZl());
				modelmap.put("jzmj", h.getScjzmj());
				modelmap.put("tnmj", h.getSctnjzmj());
				modelmap.put("szc", h.getBeginc());
				modelmap.put("zcs", h.getSjcs());
				modelmap.put("zrzh", h.getZrzh());
				modelmap.put("dyh", "");
				modelmap.put("fjh", h.getShbw());
				modelmap.put("fwlx", h.getFwlx());
				modelmap.put("fwjg", h.getHxjg());
				modelmap.put("tdxz", h.getQlxz());
				modelmap.put("xmmc", h.getXmmc());
				YcslJbxx jbxx = new YcslJbxx();
				jbxx.setBdcdyh(h.getBdcdyh());
				jbxx.setFybh(h.getFybh());
				jbxx.setZl(h.getZl());
				jbxx.setJzmj(h.getScjzmj());
				jbxx.setTnmj(h.getSctnjzmj());
				jbxx.setSzc(h.getBeginc());
				jbxx.setZcs(h.getSjcs());
				jbxx.setZrzh(h.getZrzh());
				jbxx.setDyh(h.getDyh());
				jbxx.setFjh(h.getShbw());
				jbxx.setXmmc(h.getXmmc());
				jbxx.setFwlx(DictUtils.getDictLabel(h.getFwlx(), "reg_bus_fwlx", ""));
				jbxx.setFwjg(DictUtils.getDictLabel(h.getHxjg(), "reg_bus_hxjg", ""));
				jbxx.setTdxz(DictUtils.getDictLabel(h.getQlxz(), "reg_bus_qlxz", ""));
				RegBaseZdjbxx zdjbxx = regBaseZdjbxxService.getdy(h.getBdcdyh().substring(0, 19));
				if (zdjbxx != null) {
					jbxx.setTdyt(zdjbxx.getYt());
					jbxx.setZdzl(zdjbxx.getZl());
				}
				RegBaseZrz zrz = regBaseZrzService.getByZddmZrzh(h.getZddm(), h.getZrzh());
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
				if (zrz != null) {
					jbxx.setJgsj(sdf.format(zrz.getJgrq()));
					jbxx.setJzwmc(zrz.getGzwmc());
				}
				jbxx.setFwyt(DictUtils.getDictLabel(h.getFwyt1(), "reg_bus_fwyt", ""));
				jbxx.setFwxz(DictUtils.getDictLabel(h.getFwxz(), "reg_bus_fwxz", ""));
				jbxx.setCqzh(djxx.getBdcqzh());
				save(jbxx);
				// 保存后得到id,赋给proid
				jbxx.setProid(jbxx.getId());
				save(jbxx);
				jbxx = get(jbxx.getId());
				modelmap.put("jbxx", jbxx);
				List<RegBusQlr> qlrs = regBusQlrService.findByYwh(djxx.getYwh());
				RegBusQlr qlr = new RegBusQlr();
				if (qlrs.size() > 0) {
					for (int i = 0; i < qlrs.size(); i++) {
						qlr = qlrs.get(i);
						YcslGxr gxr = new YcslGxr();
						gxr.setGxrlx("ywr");
						gxr.setGxrmc(qlr.getQlrmc());
						gxr.setGxrsfzjzl(qlr.getZjzl());
						gxr.setGxrtxdz(qlr.getDz());
						gxr.setGxrzjh(qlr.getZjh());
						gxr.setQlbl(qlr.getQlbl());
						gxr.setSxh(qlr.getSxh());
						gxr.setGyqk(qlr.getGyqk());
						gxr.setGyfs(qlr.getGyfs());
						gxr.setGj(qlr.getGj());
						gxr.setRylx(qlr.getQlrlx());
						gxr.setProid(jbxx.getId());
						gxr.setPcode(qlr.getPcode());
						ycslGxrService.save(gxr);
					}
				}
			}
			modelmap.put("cqzh", djxx.getBdcqzh());
		}
		return modelmap;
	}

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

	public String getLj(String fjlj, String proid, String clmc) {

		String local_file = "";
		String[] fileNameArray = fjlj.split(";");
		for (int j = 0; j < fileNameArray.length; j++) {
			String ftpFilePath = fileNameArray[j];

			ftpFilePath = ftpFilePath.replace("store://fileStore1", "/fileCenter/content/");

			String fileName = ftpFilePath.substring(ftpFilePath.lastIndexOf("/") + 1, ftpFilePath.length() - 1);
			logger.info(fileName);
			// 方式一 把图片下载到本地 读取本地 缺少用户
			User user = UserUtils.getUser();
			String creater = user.getId();
			String filepath = "/userfiles/" + creater + "/" + proid + "/";
			String localFilePath = Global.getUserfilesBaseDir() + filepath;
			// 拼接文件路径
			String fileNamefj = fileName;
			local_file = 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);

		}
		return local_file;
	}

	// 测试的
	public void downDeal(HttpServletRequest request) throws ClientProtocolException, IOException {
		// 获取交易合同
		String proid = request.getParameter("htbh");
		Map map2 = Maps.newHashMap();
		map2.put("htbh", "YS0197792");

		Map deals = httpactivityService.postRequest(map2, "downDealFiles");
		List deallist = deals.containsKey("data") ? (List) deals.get("data") : Lists.newArrayList();// 收件信息

		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		if (deallist.size() > 0) {
			for (int j = 0; j < deallist.size(); j++) {
				logger.info(JSONUtils.toJSONString(deallist.get(j)));
				String fjlj = JSONUtils.toJSONString(deallist.get(j));
				getLj(fjlj, proid, "房产合同.pdf");
			}
		}
	}

	// 期房,现房预告交易接口
	public String getHtbh(String bdcdyh) throws ClientProtocolException, IOException {
		// 是否挂接,能否办理业务
		RegBaseH h = regBaseHService.getdy(bdcdyh);
		if (h != null) {
			if (StringUtils.isBlank(h.getFybh())) {
				throw new YcslException("请先进行数据挂接");
			} else {
				Map map = Maps.newHashMap();
				map.put("bdcdyh", bdcdyh);
				map.put("fybh", h.getFybh());
				Map json = httpactivityService.postRequest(map, "findLicenseInfo");
				Map res_map = json.containsKey("data") && json.get("data") != null ? (Map) json.get("data")
						: Maps.newHashMap();
				logger.debug(JsonUtil.toJsonString(res_map));
				if (res_map.size() > 0) {
					// 直接判断,
					/*
					 * if(res_map.containsKey("sfgp")&& res_map.get("sfgp").toString().equals("否"))
					 * {//否挂牌 modelmap.put("success", "1"); modelmap.put("msg", "该房屋未挂牌"); return
					 * modelmap; }
					 */
					if (res_map.containsKey("sfblyw") && res_map.get("sfblyw").toString().equals("否")) {// 否
						throw new YcslException(res_map.get("note").toString());
					}
				} else {

					throw new YcslException("系统未获取到房屋交易挂牌信息");
				}
			}
		}

		// 交易接口获取合同编号及交易信息
		String htbh = "";
		String proid = "";
		Map map = Maps.newHashMap();
		map.put("bdcdyh", bdcdyh);
		YcslJbxx jbxx = new YcslJbxx();

		Map map2 = Maps.newHashMap();
		map2.put("htbh", "");
		map2.put("bdcdyh", bdcdyh);
		Map json2 = httpactivityService.postRequest(map2, "queryTradeYw");
		logger.debug(JsonUtil.toJsonString(json2));
		if (!json2.get("code").toString().equals("200")) {
			throw new YcslException(json2.get("message").toString());
		}
		if (json2.containsKey("data")
				&& JsonUtil.fromJson(JsonUtil.toJsonString(json2.get("data")), List.class).size() > 0) {
			Map result = (Map) JsonUtil.fromJson(JsonUtil.toJsonString(json2.get("data")), List.class).get(0);
			logger.debug(JsonUtil.toJsonString(result));
			htbh = result.get("htbh").toString();
			proid = result.get("proid").toString();
			YcslJbxx jbxxnew = getByProid(result.get("proid").toString());
			if (jbxxnew == null) {
				jbxxnew = new YcslJbxx();
			}
			jbxxnew.setProid(result.get("proid").toString());
			jbxxnew.setBdcdyh(result.get("bdcdyh").toString());
			jbxxnew.setDept("jy");
			jbxxnew.setDyh(result.get("dyh").toString());
			jbxxnew.setFwdj(result.get("dj").toString());
			jbxxnew.setFwjg(result.get("fwjg").toString());
			jbxxnew.setFwzj(result.get("htje").toString());
			jbxxnew.setZt("true");
			jbxxnew.setQszyfs("4");
			jbxxnew.setHtbh(result.get("htbh").toString());
			Map qyxx = Maps.newHashMap();
			qyxx.put("不动产单元号", result.get("bdcdyh").toString());
			qyxx.put("单价", result.get("dj").toString());
			qyxx.put("合同金额", result.get("htje").toString());
			qyxx.put("合同签约时间", result.get("htqysj").toString());
			qyxx.put("合同编号", result.get("htbh").toString());
			qyxx.put("交易类型", result.get("jylx").toString());
			qyxx.put("proid", result.get("proid").toString());
			jbxxnew.setQyxx(JsonUtil.toJsonString(qyxx));
			save(jbxxnew);
			YcslGxr gxr1 = new YcslGxr();
			gxr1.setProid(jbxxnew.getProid());
			List<YcslGxr> gxrlist = ycslGxrService.findList(gxr1);
			if (gxrlist.size() > 0) {
				ycslGxrService.deleteByproid(jbxxnew.getProid());
			}
			List list1 = (List) result.get("gxrlist");
			if (list1.size() > 0) {
				for (int i = 0; i < list1.size(); i++) {
					Map gxrs = (Map) list1.get(i);
					YcslGxr gxr = new YcslGxr();
					RegBasePerson person = new RegBasePerson();
					gxr.setProid(jbxxnew.getProid());
					gxr.setRylx(gxrs.get("gxrlx").toString());
					person.setRylx(DictUtils.getDictValue(gxrs.get("gxrlx").toString(), "reg_bus_qlrlx", ""));
					gxr.setGxrlxdh(gxrs.get("gxrlxdh").toString());
					gxr.setGxrtxdz(gxrs.get("gxrtxdz").toString());
					person.setDz(gxrs.get("gxrtxdz").toString());
					person.setDh(gxrs.get("gxrlxdh").toString());
					gxr.setGxrsfzjzl(DictUtils.getDictValue(gxrs.get("gxrsfzjzl").toString(), "reg_bus_zjlx", ""));
					gxr.setGyfs(DictUtils.getDictValue(gxrs.get("gyfs").toString(), "reg_bus_gyfs", ""));
					gxr.setGyqk(gxrs.get("gyfs").toString());
					gxr.setQlbl(gxrs.containsKey("qlbl") ? gxrs.get("qlbl").toString() : "");
					gxr.setGxrlx("qlr");
					gxr.setGxrmc(gxrs.get("gxrmc").toString());
					gxr.setGxrzjh(gxrs.get("gxrzjh").toString());
					gxr.setSxh(i + 1);
					gxr.setGj("142");
					person.setGj("142");
					person.setRymc(gxrs.get("gxrmc").toString());
					person.setZjzl(DictUtils.getDictValue(gxrs.get("gxrsfzjzl").toString(), "reg_bus_zjlx", ""));
					person.setZjh(gxrs.get("gxrzjh").toString());
					List<RegBasePerson> personlist = regBasePersonService.findList(person);
					if (personlist.size() == 0) {
						person.setPcode(getpcode());
						person.setIsaudit("2");
						regBasePersonService.save(person);
						gxr.setPcode(person.getPcode());
					} else {
						person = personlist.get(0);
						person.setIsaudit("2");
						regBasePersonService.save(person);
						gxr.setPcode(person.getPcode());
					}
					ycslGxrService.save(gxr);
				}
			}

			if (!com.thinkgem.jeesite.common.utils.StringUtils.isEmpty(proid)) {
				// 合同
				Map map3 = Maps.newHashMap();
				map3.put("htbh", htbh);
				Map deals = httpactivityService.postRequest(map3, "downDealFiles");
				List deallist = deals.containsKey("data") ? (List) deals.get("data") : Lists.newArrayList();// 收件信息
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				if (deallist.size() > 0) {
					YcslSj sj = ycslSjService.getByProid(proid);
					if (sj == null) {
						sj = new YcslSj();
						sj.setProid(proid);
						sj.setSjsj(new Date());
						ycslSjService.save(sj);
					}
					for (int j = 0; j < deallist.size(); j++) {
						YcslSjcl sjcl1 = new YcslSjcl();
						sjcl1.setCllx("1");// 原件
						sjcl1.setClmc("3");
						sjcl1.setProid(proid);
						sjcl1.setSjId(sj);
						List<YcslSjcl> sjcllist = ycslSjclService.findList(sjcl1);
						if (sjcllist.size() > 0) {
							sjcl1 = sjcllist.get(0);
						}
						String fjlj = JSONUtils.toJSONString(deallist.get(j));
						sjcl1.setSjrq(new Date());
						sjcl1.setSjcllj(getLj(fjlj, proid, "房产合同.pdf"));
						ycslSjclService.save(sjcl1);
					}
				}
			}
			jbxx = jbxxnew;
			htbh = jbxx.getHtbh();
			// throw new YcslException("交易信息已保存");//测试信息,不让跳入下一页面
		} else {
			throw new YcslException("未获取到交易信息");
		}
		return htbh;
	}

}