911623491444f143023f1a7f92122a4ffab00868.svn-base 5.08 KB
/**
 * Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.reg.service.bus;

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.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.common.service.ServiceException;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusBdcqzsdjxx;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusHisHouseBdcqzsdjxx;
import com.thinkgem.jeesite.modules.reg.dao.bus.RegBusBdcqzsdjxxDao;
import com.thinkgem.jeesite.modules.reg.dao.bus.RegBusHisHouseBdcqzsdjxxDao;

/**
 * 房屋历史登记数据录入Service
 * @author wb
 * @version 2016-03-22
 */
@Service
@Transactional(readOnly = true)
public class RegBusHisHouseBdcqzsdjxxService extends CrudService<RegBusHisHouseBdcqzsdjxxDao, RegBusHisHouseBdcqzsdjxx> {

	@Autowired
	private RegBusHisHouseBdcqzsdjxxDao regBusHisHouseBdcqzsdjxxDao;
	@Autowired
	private RegBusBdcqzsdjxxDao regBusBdcqzsdjxxDao;
	
	public RegBusHisHouseBdcqzsdjxx get(String id) {
		RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx = super.get(id);
		return regBusHisHouseBdcqzsdjxx;
	}

	public void unaudit(RegBusHisHouseBdcqzsdjxx hisdjxx) {
		RegBusHisHouseBdcqzsdjxx lsdjxx = new RegBusHisHouseBdcqzsdjxx();
		lsdjxx.setBdcdyh(hisdjxx.getBdcdyh());
		lsdjxx.setYwh(hisdjxx.getYwh());
		lsdjxx.setHisok("fsh");
		List<RegBusHisHouseBdcqzsdjxx> djxxlist = findList(lsdjxx);
		
		if(djxxlist.size() > 0 ){
			RegBusHisHouseBdcqzsdjxx djxx = djxxlist.get(0);
			if(!"0".equals(djxx.getFshok()) ||  !"0".equals(djxx.getHisok())) { 
				throw new ServiceException("不动产单元号"+djxx.getBdcdyh()+"已被多个业务引用不能进行反审核");
			}
		}  
		hisdjxx.setIsaudit("0");
		save(hisdjxx); 
	}
	
	
	public List<RegBusHisHouseBdcqzsdjxx> findList(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx) {
		return super.findList(regBusHisHouseBdcqzsdjxx);
	}
	
	public Page<RegBusHisHouseBdcqzsdjxx> findPage(Page<RegBusHisHouseBdcqzsdjxx> page, RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx) {
		return super.findPage(page, regBusHisHouseBdcqzsdjxx);
	}
	@Transactional(readOnly = false)
	public void save(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx) {
		super.save(regBusHisHouseBdcqzsdjxx);
	}

	@Transactional(readOnly = false)
	public void delete(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx) {
		super.delete(regBusHisHouseBdcqzsdjxx);
	}
	@Transactional(readOnly = false)
	public RegBusHisHouseBdcqzsdjxx gethouse(String id) {
		return regBusHisHouseBdcqzsdjxxDao.gethouse(id);
	}

	@Transactional(readOnly = false)
	public Map<Object,Object> getBsst(Map<String,Object> map) {
		return regBusHisHouseBdcqzsdjxxDao.getBsst(map);
	}
	@Transactional(readOnly = false)
	public List<RegBusHisHouseBdcqzsdjxx> getBsst1(Map<String,Object> map) {
		if("oracle".equals(Global.getDbName())){
			return regBusHisHouseBdcqzsdjxxDao.oracleGetBsst1(map);
		}else {
			return regBusHisHouseBdcqzsdjxxDao.getBsst1(map);
		}
	}
	
	public List<RegBusHisHouseBdcqzsdjxx> finddbzbList(RegBusHisHouseBdcqzsdjxx regBusHisHouseBdcqzsdjxx) {
		return regBusHisHouseBdcqzsdjxxDao.finddbzbList(regBusHisHouseBdcqzsdjxx);
	}

	public void unauditDY(RegBusHisHouseBdcqzsdjxx hisdjxx) {
		RegBusHisHouseBdcqzsdjxx lsdjxx = new RegBusHisHouseBdcqzsdjxx();
		lsdjxx.setBdcdyh(hisdjxx.getBdcdyh());
		lsdjxx.setYwh(hisdjxx.getYwh());
		lsdjxx.setHisdyok("fsh");
		List<RegBusHisHouseBdcqzsdjxx> djxxlist = findList(lsdjxx);
		
		if(djxxlist.size() > 0 ){
			RegBusHisHouseBdcqzsdjxx djxx = djxxlist.get(0);
			if("0".equals(djxx.getHisdyok()) && !"0".equals(djxx.getHisok())) { 
				throw new ServiceException("不动产单元号"+djxx.getBdcdyh()+"不能进行反审核");
			}
		}  
		hisdjxx.setIsaudit("0");
		save(hisdjxx); 
	}
	
	public void unauditZY(RegBusHisHouseBdcqzsdjxx hisdjxx) {
		RegBusBdcqzsdjxx lsdjxx = new RegBusBdcqzsdjxx();
		lsdjxx.setBdcdyh(hisdjxx.getBdcdyh());
		RegBusBdcqzsdjxx djxx = findObject(lsdjxx);
			if(!djxx.getYwh().equals(hisdjxx.getYwh())) {
				throw new ServiceException("不动产单元号"+djxx.getBdcdyh()+"有后续业务,不能进行反审核");
			}else {
				RegBusHisHouseBdcqzsdjxx djxx1 = new RegBusHisHouseBdcqzsdjxx();
				djxx1.setBdcdyh(hisdjxx.getBdcdyh());
				RegBusHisHouseBdcqzsdjxx djxx2 = findObjectls(lsdjxx);
				if(!djxx2.getId().equals(hisdjxx.getId())){
					throw new ServiceException("不动产单元号"+djxx.getBdcdyh()+"有历史后续业务,不能进行反审核");
				}
			}
		hisdjxx.setIsaudit("0");
		save(hisdjxx); 
	}

	private RegBusHisHouseBdcqzsdjxx findObjectls(RegBusBdcqzsdjxx lsdjxx) {
		// TODO Auto-generated method stub
		return regBusHisHouseBdcqzsdjxxDao.findObjectls(lsdjxx);
	}

	private RegBusBdcqzsdjxx findObject(RegBusBdcqzsdjxx lsdjxx) {
		// TODO Auto-generated method stub
		return regBusBdcqzsdjxxDao.findObject(lsdjxx);
	}

	
}