df0d38409f6f33ccaba7d5cf05e4313b4392e76e.svn-base 16.2 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
/**
 * Copyright © 2015-2018 ODM All rights reserved.
 */
package com.thinkgem.jeesite.modules.reg.service.bus.change;

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

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

import com.google.common.collect.Maps;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.act.service.ActTaskService;
import com.thinkgem.jeesite.modules.act.utils.ActUtils;
import com.thinkgem.jeesite.modules.reg.dao.bus.RegBusSlsqDao;
import com.thinkgem.jeesite.modules.reg.dao.bus.change.RegBusCSlsqDao;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusBdcqzsdjxx;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusFz;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusQlr;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusSf;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusSlsq;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusYwr;
import com.thinkgem.jeesite.modules.reg.entity.bus.YcslSlsq;
import com.thinkgem.jeesite.modules.reg.entity.bus.change.RegBusCSlsq;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusBdcqzsdjxxService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusFzService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusQlrService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusSfService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusYwrService;
import com.thinkgem.jeesite.modules.reg.service.bus.YcslSlsqService;
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.entity.xttj.YcslXttj;
import com.thinkgem.jeesite.modules.ycsl.service.xttj.YcslXttjService;

/**
 * 变更登记受理申请表单处理Service
 * @author xuyg
 * @version 2015-10-16
 */
@Service
@Transactional(readOnly = true)
public class RegBusCSlsqService extends CrudService<RegBusCSlsqDao, RegBusCSlsq> {
	
	@Autowired
	private ActTaskService actTaskService;
	@Autowired
	private RegBusSfService regBusSfService;
	@Autowired
	private RegBusFzService regBusFzService;
	@Autowired
	private RegBusQlrService regBusQlrService;
	@Autowired
	private RegBusYwrService regBusYwrService;
	@Autowired
	private YcslSlsqService ycslSlsqService;
	@Autowired
	private RegBusBdcqzsdjxxService regBusBdcqzsdjxxService;
	@Autowired
	private YcslXttjService ycslXttjService;
	
	public RegBusCSlsq getByProcInsId(String procInsId) {
		return dao.getByProcInsId(procInsId);
	}

	public RegBusCSlsq get(String id) {
		return super.get(id);
	}
	
	public List<RegBusCSlsq> findList(RegBusCSlsq regBusSlsq) {
		return super.findList(regBusSlsq);
	}
	
	public Page<RegBusCSlsq> findPage(Page<RegBusCSlsq> page, RegBusCSlsq regBusSlsq) {
		regBusSlsq.setPage(page);
		page.setList(dao.findList(regBusSlsq));
		return page;
	}
	
	/**
	* @Title: findMaxYwh 
	* @Description: 获取当前最大的业务号,用于生成下一个业务号使用
	* @param @return    设定文件 
	* @return String    返回类型 
	* @throws
	 */
	public String findMaxYwh(){
		return dao.findMaxYwh();
	}
	
	 
	@Transactional(readOnly = false)
	public void save(RegBusCSlsq regBusSlsq) {
		User user = UserUtils.getUser();
		// 受理申请发起
		if (StringUtils.isBlank(regBusSlsq.getId())){
			regBusSlsq.preInsert();
			dao.insert(regBusSlsq);
			//给Act的ywh set值
			regBusSlsq.getAct().setYwh(regBusSlsq.getYwh());
			regBusSlsq.getAct().setSqr(regBusSlsq.getTzrxm());
			regBusSlsq.getAct().setDjlx(regBusSlsq.getDjdl());
			regBusSlsq.getAct().setSlr(user.getLoginName());//只是流程发起的时候才用到
			//转移登记进行一窗受理业务号显示 20190114GL
			if ("302".equals(regBusSlsq.getDjxl())) {
				regBusSlsq.getAct().setProid(regBusSlsq.getProid());
			}
			
			Map<String, Object> vars = Maps.newHashMap();
			//增加业务号查询变量参数【这样后查询时按照先存在 vars 里面的ywh;然后再通过给 Act加一个 ywh的属性 ;
						//最后是通过 act.ywh 跟 vars 里面的 ywh 进行比对实现查询】
			vars.put("ywh", regBusSlsq.getYwh());
			vars.put("sqr", regBusSlsq.getTzrxm());
			vars.put("djlx", regBusSlsq.getDjdl());
			vars.put("slr", user.getLoginName()); //只是流程发起的时候才用到
			//转移登记进行一窗受理业务号显示z
			if ("302".equals(regBusSlsq.getDjxl())) {
				vars.put("proid", regBusSlsq.getProid());
			}
			// 启动流程
			actTaskService.startProcess(ActUtils.PD_CREG_AUDIT[0], ActUtils.PD_CREG_AUDIT[1], 
					regBusSlsq.getId(), 
					DictUtils.getDictLabel(regBusSlsq.getDjxl(), "reg_bus_djxl", "不动产登记业务受理"), vars);
		}
		
		// 重新编辑申请
		else{
			regBusSlsq.preUpdate();
			dao.update(regBusSlsq);
			/*
			regBusSlsq.getAct().setComment(("yes".equals(regBusSlsq.getAct().getFlag())?"[重申] ":"[销毁] ")+
						regBusSlsq.getAct().getComment());
			*/
			regBusSlsq.getAct().setComment(DictUtils.getDictLabel(regBusSlsq.getDjxl(), "reg_bus_djxl", "")+"-同意受理");
			//完成流程任务
			Map<String, Object> vars = Maps.newHashMap();
			vars.put("pass", "yes".equals(regBusSlsq.getAct().getFlag())? "1" : "0");
			//申请人更新 
			vars.put("sqr", regBusSlsq.getTzrxm());//在没有权利人的业务当中就写入通知人(申请人)
			//增加公示环节
			if("gsyes".equals(regBusSlsq.getAct().getFlag())){
				vars.put("pass", "2");
			}
			actTaskService.complete(regBusSlsq.getAct().getTaskId(), regBusSlsq.getAct().getProcInsId(), 
						regBusSlsq.getAct().getComment(), 
						DictUtils.getDictLabel(regBusSlsq.getDjxl(), "reg_bus_djxl", "不动产登记业务受理") , vars);
		}
	}
	
	@Transactional(readOnly = false)
	public void regssave(RegBusCSlsq regBusCSlsq) {
		if (StringUtils.isBlank(regBusCSlsq.getId())){
			regBusCSlsq.preInsert();
			dao.insert(regBusCSlsq);
		}else{
			regBusCSlsq.preUpdate();
			dao.update(regBusCSlsq);
		}
	}
	
	/**
	* @Title: zsave 
	* @Description: 受理申请单暂存
	* @param @param regBusCSlsq    设定文件 
	* @return void    返回类型 
	* @throws
	 */
	@Transactional(readOnly = false)
	public void zsave(RegBusCSlsq regBusCSlsq) {
		// 受理申请发起
		if (StringUtils.isNotBlank(regBusCSlsq.getId())){
			dao.update(regBusCSlsq);
		}
	}
	
	/**
	 * 审核审批保存
	 * @param testAudit
	 */
	@Transactional(readOnly = false)
	public void auditSave(RegBusCSlsq regBusCSlsq) {
		//获取县区代码
		String areaCode = Global.getAreaCode();
		// 设置意见
		//regBusCSlsq.getAct().setComment(("yes".equals(regBusCSlsq.getAct().getFlag())?"[同意] ":"[驳回] ")+regBusCSlsq.getAct().getComment());
		regBusCSlsq.getAct().setComment(regBusCSlsq.getAct().getComment());
		regBusCSlsq.preUpdate();
		
		// 对不同环节的业务逻辑进行操作
		String taskDefKey = regBusCSlsq.getAct().getTaskDefKey();
		logger.info("******(期转现楼盘变更记录)环节名称:"+taskDefKey+"********"+",变量值:"+regBusCSlsq.getAct().getFlag()+",业务号:"+regBusCSlsq.getYwh()+",登记小类"+regBusCSlsq.getDjxl());
		//【没有公示情况】从初审环节进来 - 提交流程后到了复审,环节修改
		if ("reg_audit".equals(taskDefKey)){
			if("610702".equals(areaCode) || "610725".equals(areaCode) || "610721".equals(areaCode) || "610727".equals(areaCode) || "610728".equals(areaCode) || "610724".equals(areaCode)){
				if(!regBusCSlsq.getYwh().contains("X")){
					regBusCSlsq.setTaskdefkey("reg_audit3");
				}else{
					regBusCSlsq.setTaskdefkey("reg_audit2");
				}
			}else{
				regBusCSlsq.setTaskdefkey("reg_audit2");
			}
		}
		//从复审环节进来 - 提交流程后到了核定,环节修改
		else if("reg_audit2".equals(taskDefKey) && !"610702".equals(areaCode) && !"610725".equals(areaCode) && !"610721".equals(areaCode) && !"610727".equals(areaCode) && !"610728".equals(areaCode)&& !"610724".equals(areaCode)){
			if ("reg_audit2".equals(taskDefKey)){
				regBusCSlsq.setTaskdefkey("reg_audit3");
			}
		}
		else if("reg_audit2".equals(taskDefKey) && !"610725".equals(areaCode) && !"610721".equals(areaCode) && !"610727".equals(areaCode)){
			if ("610702".equals(areaCode) && regBusCSlsq.getYwh().contains("X")){
				regBusCSlsq.setTaskdefkey("reg_audit3");
			}else if("610722".equals(areaCode) || "610723".equals(areaCode) || "610724".equals(areaCode) || "610726".equals(areaCode) || "610729".equals(areaCode) || "610730".equals(areaCode)){
				regBusCSlsq.setTaskdefkey("reg_audit3");
			}
		}
		//从核定环节进来 - 提交流程后到了登簿
		else if ("reg_audit3".equals(taskDefKey)){
			if("429".equals(regBusCSlsq.getDjxl())){
				regBusCSlsq.setTaskdefkey("reg_end");//楼盘变更到归档
			}else{
				regBusCSlsq.setTaskdefkey("reg_audit4");
			}
		}
		//从登簿进来 - 提交流程后到了缮证
		else if ("reg_audit4".equals(taskDefKey)){
			if("400".equals(regBusCSlsq.getDjdl()) || "800".equals(regBusCSlsq.getDjdl())){
				regBusCSlsq.setTaskdefkey("reg_end");
			}else{
				regBusCSlsq.setTaskdefkey("reg_audit5");
			}
			//regBusCSlsq.getAct().setComment("[登簿]"+ regBusCSlsq.getAct().getComment());
			regBusCSlsq.getAct().setComment(regBusCSlsq.getAct().getComment());
		}
		//从缮证进来 - 提交流程后到了发证
		else if ("reg_audit5".equals(taskDefKey)){
			if("yes".equals(regBusCSlsq.getAct().getFlag())){
				//到收费
				regBusCSlsq.setTaskdefkey("reg_audit56");
			}else{
				//到发证
				regBusCSlsq.setTaskdefkey("reg_audit6");
			}
			//重新更新一次流程说明,为no时不是驳回,而是【到发证】
			// 设置意见
			//regBusCSlsq.getAct().setComment(("yes".equals(regBusCSlsq.getAct().getFlag())?"[缮证->收费] ":"[缮证->发证] ") + regBusCSlsq.getAct().getComment());
			regBusCSlsq.getAct().setComment(regBusCSlsq.getAct().getComment());
			regBusCSlsq.preUpdate();
		}
		//从收费进来 - 提交流程后到了发证
		else if ("reg_audit56".equals(taskDefKey)){
			regBusCSlsq.setTaskdefkey("reg_audit6");
			//regBusCSlsq.getAct().setComment("[收费]"+ regBusCSlsq.getAct().getComment());
			regBusCSlsq.getAct().setComment(regBusCSlsq.getAct().getComment());
		}
		//从发证进来 - 提交流程后到了归档
		else if ("reg_audit6".equals(taskDefKey)){
			regBusCSlsq.setTaskdefkey("reg_end");
			//regBusCSlsq.getAct().setComment("[发证]"+ regBusCSlsq.getAct().getComment());
			regBusCSlsq.getAct().setComment(regBusCSlsq.getAct().getComment());
		}
		//从归档进来 - 提交流程后还是归档
		else if ("reg_end".equals(taskDefKey)){
			//不做处理
			//regBusCSlsq.getAct().setComment("[归档]"+ regBusCSlsq.getAct().getComment());
			regBusCSlsq.getAct().setComment(regBusCSlsq.getAct().getComment());
		}
		//未知环节,直接返回
		else{
			return;
		}
		
		// 提交流程任务
		Map<String, Object> vars = Maps.newHashMap();
		if("yes".equals(regBusCSlsq.getAct().getFlag())){
			vars.put("pass", "1");
		}else if("cfyyzx".equals(regBusCSlsq.getAct().getFlag())){
			vars.put("pass", "99");//查封异议注销直接走归档
		}else if("no_sf_sz".equals(regBusCSlsq.getAct().getFlag())){
			//发证环节驳回:判断当前业务是从缮证[0]走过来的还是收费[10]
			if("400".equals(regBusCSlsq.getDjdl()) || "800".equals(regBusCSlsq.getDjdl()) || "300".equals(regBusCSlsq.getDjdl()) || "500".equals(regBusCSlsq.getDjdl())){
				//回退到缮证
				vars.put("pass", "0");
				regBusCSlsq.setTaskdefkey("reg_audit5");
			}else{
				//回退到收费
				vars.put("pass", "10");
				regBusCSlsq.setTaskdefkey("reg_audit56");
			}
			//清理发证信息
			RegBusFz regBusFz = new RegBusFz();
			regBusFz.setYwh(regBusCSlsq.getYwh());
			List<RegBusFz> findFzList = regBusFzService.findList(regBusFz);
			if(findFzList.size() > 0){
				regBusFz = findFzList.get(0);
				regBusFzService.delete(regBusFz);
			}
			
			RegBusBdcqzsdjxx regBusBdcqzsdjxxTemp = new RegBusBdcqzsdjxx();
			regBusBdcqzsdjxxTemp.setYwh(regBusCSlsq.getYwh());
			List<RegBusBdcqzsdjxx> regBusBdcqzsdjxxTempList = regBusBdcqzsdjxxService
					.findList(regBusBdcqzsdjxxTemp);

			if (regBusBdcqzsdjxxTempList != null && regBusBdcqzsdjxxTempList.size() > 0) {
				RegBusBdcqzsdjxx djxx = regBusBdcqzsdjxxTempList.get(0);

				YcslXttj xttj = new YcslXttj();
				xttj.setYwh(regBusCSlsq.getYwh());
				 
				if("20".equals(regBusCSlsq.getSllx())) {
					YcslSlsq ycslSlsq = new YcslSlsq();
					ycslSlsq.setYwh(regBusCSlsq.getProid());
					List<YcslSlsq> slsqList = ycslSlsqService.findList(ycslSlsq);
					if(slsqList == null || slsqList.size() <= 0) {
						xttj.setProid(regBusCSlsq.getProid());
					}else {
						YcslSlsq y_slsq = slsqList.get(0);
						xttj.setProid(y_slsq.getWwywh());
					}
				
				}else {
					xttj.setProid(regBusCSlsq.getProid());
				}

				
				xttj.setCzbz("1");
				xttj.setBdcdyh(djxx.getBdcdyh());
				xttj.setTjywzt(taskDefKey);
				xttj.setYj(regBusCSlsq.getAct().getComment());
				ycslXttjService.save(xttj);

 
			}
		}else if("guid".equals(regBusCSlsq.getAct().getFlag())){
			vars.put("pass", "2");//走向楼盘变更
		}else{
			vars.put("pass", "0");
			//初审驳回
			if ("reg_audit".equals(taskDefKey)){
				regBusCSlsq.setTaskdefkey("reg_start");
			} 
			//从复审驳回
//			else if ("reg_audit2".equals(taskDefKey)){
//				regBusCSlsq.setTaskdefkey("reg_start");
//			}
			//从核定驳回
			else if ("reg_audit3".equals(taskDefKey)){
				regBusCSlsq.setTaskdefkey("reg_start");
			}
			//从登簿进来 - 提交流程后到了缮证
			else if ("reg_audit4".equals(taskDefKey)){
				regBusCSlsq.setTaskdefkey("reg_start");
			}
			
			// 从缮证进来 - 提交流程后 yes到了收费 no到发证
			if (!"reg_audit5".equals(taskDefKey)) {
				RegBusBdcqzsdjxx regBusBdcqzsdjxxTemp = new RegBusBdcqzsdjxx();
				regBusBdcqzsdjxxTemp.setYwh(regBusCSlsq.getYwh());
				List<RegBusBdcqzsdjxx> regBusBdcqzsdjxxTempList = regBusBdcqzsdjxxService
						.findList(regBusBdcqzsdjxxTemp);

				if (regBusBdcqzsdjxxTempList != null && regBusBdcqzsdjxxTempList.size() > 0) {
					RegBusBdcqzsdjxx djxx = regBusBdcqzsdjxxTempList.get(0);

					YcslXttj xttj = new YcslXttj();
					xttj.setYwh(regBusCSlsq.getYwh());
					if("20".equals(regBusCSlsq.getSllx())) {
						YcslSlsq ycslSlsq = new YcslSlsq();
						ycslSlsq.setYwh(regBusCSlsq.getProid());
						List<YcslSlsq> slsqList = ycslSlsqService.findList(ycslSlsq);
						if(slsqList == null || slsqList.size() <= 0) {
							xttj.setProid(regBusCSlsq.getProid());
						}else {
							YcslSlsq y_slsq = slsqList.get(0);
							xttj.setProid(y_slsq.getWwywh());
						}
					
					}else {
						xttj.setProid(regBusCSlsq.getProid());
					}
					xttj.setCzbz("1");
					xttj.setBdcdyh(djxx.getBdcdyh());
					xttj.setTjywzt(taskDefKey);
					xttj.setYj(regBusCSlsq.getAct().getComment());
					ycslXttjService.save(xttj);
 
				}
			}
		}
		
		//收费环节驳回:
		if("no".equals(regBusCSlsq.getAct().getFlag()) && "reg_audit56".equals(taskDefKey)){
			//System.out.println("##############################C1");
			//清理收费信息
			RegBusSf regBusSf = new RegBusSf();
			regBusSf.setYwh(regBusCSlsq.getYwh());
			List<RegBusSf> findSfList = regBusSfService.findList(regBusSf);
			if(findSfList.size() > 0){
				regBusSf = findSfList.get(0);
				regBusSfService.delete(regBusSf);
			}
			regBusCSlsq.setTaskdefkey("reg_audit5");
		}
		
		dao.updateTaskDefKey(regBusCSlsq);
		
		//增加公示环节
		if("gsyes".equals(regBusCSlsq.getAct().getFlag())){
			vars.put("pass", "2");
		}
		logger.info("******(方法走完后,数据更新了)环节名称:"+regBusCSlsq.getTaskdefkey()+"********"+",变量值:"+regBusCSlsq.getAct().getFlag()+",业务号:"+regBusCSlsq.getYwh());
		//System.out.println("流程提交complete参数:"+regBusCSlsq.getAct().getTaskId()+";"+regBusCSlsq.getAct().getProcInsId());
		actTaskService.complete(regBusCSlsq.getAct().getTaskId(), regBusCSlsq.getAct().getProcInsId(), regBusCSlsq.getAct().getComment(), vars);
		
	}
	
	@Transactional(readOnly = false)
	public void delete(RegBusCSlsq regBusSlsq) {
		super.delete(regBusSlsq);
	}
	
	/**
	 * 自动启流程保存
	 */
	@Transactional(readOnly = false)
	public void savecslsq(RegBusCSlsq regBusCSlsq) {
		super.save(regBusCSlsq);
	}
	
}