f6d1cc9c45d33d8b0335e3ea0ac3d8be5e72e70a.svn-base 8.13 KB
/**
 * Copyright © 2015-2018 ODM All rights reserved.
 */
package com.thinkgem.jeesite.modules.reg.service.base;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
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.utils.DateUtils;
import com.thinkgem.jeesite.common.utils.JsonUtil;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.reg.dao.base.RegBaseZdjbxxDao;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseChxx11;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseZdjbxx;
import com.thinkgem.jeesite.modules.sys.utils.DictUtils;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
import com.thinkgem.jeesite.modules.title.buss.RemoteBuss;
import com.thinkgem.jeesite.modules.title.po.ZdjbxxDto;

/**
 * 宗地基本信息表单维护Service
 * @author xuyg
 * @version 2015-10-12
 */
@Service
@Transactional(readOnly = true)
public class RegBaseZdjbxxService extends CrudService<RegBaseZdjbxxDao, RegBaseZdjbxx> {
	
	@Autowired
	private RemoteBuss buss;
	@Autowired
	private RegBaseChxx11Service regBaseChxxService;
	
	public RegBaseZdjbxx get(String id) {
		return super.get(id);
	}
	
	public List<RegBaseZdjbxx> findList(RegBaseZdjbxx regBaseZdjbxx) {
		return super.findList(regBaseZdjbxx);
	}
	
	
	public List<RegBaseZdjbxx> findListdyhcf(RegBaseZdjbxx regBaseZdjbxx) {
		return dao.findListdyhcf(regBaseZdjbxx);
	}
	
	/***
	* @Title: findChoicePage 
	* @Description: 返回已登记已登簿宗地代码集合的宗地信息  
	* @param @param page
	* @param @param regBaseZdjbxx
	* @param @param zddms
	* @param @return    设定文件 
	* @return Page<RegBaseZdjbxx>    返回类型 
	* @throws
	 */
	public Page<RegBaseZdjbxx> findChoicePage(Page<RegBaseZdjbxx> page, RegBaseZdjbxx regBaseZdjbxx, List<String> zddmList) {
		regBaseZdjbxx.setPage(page);
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("DEL_FLAG_NORMAL", regBaseZdjbxx.getDelFlag());
		paramMap.put("dbName", regBaseZdjbxx.getDbName());
		paramMap.put("zddm", regBaseZdjbxx.getZddm());
		paramMap.put("bdcdyh", regBaseZdjbxx.getBdcdyh());
		paramMap.put("status", regBaseZdjbxx.getStatus());
		paramMap.put("islogout", regBaseZdjbxx.getIslogout());
		paramMap.put("zddmList", zddmList);
		page.setList(dao.findChoiceList(paramMap));
		return page;
	}
	
	
	public Page<RegBaseZdjbxx> findPage(Page<RegBaseZdjbxx> page, RegBaseZdjbxx regBaseZdjbxx) {
		return super.findPage(page, regBaseZdjbxx);
	}
	
	public Page<RegBaseZdjbxx> findFwlinkPage(Page<RegBaseZdjbxx> page, RegBaseZdjbxx regBaseZdjbxx) {
		return super.findFwlinkPage(page, regBaseZdjbxx);
	}
	
	/**
	* @Title: findMaxZddm 
	* @Description: 查询当前数据库里最大的宗地代码
	* @param @return    设定文件 
	* @return String    返回类型 
	* @throws
	 */
	public String findMaxZddm(){
		return dao.findMaxZddm();
	}
	
	/***
	* @Title: findMaxZddmByDistrict 
	* @Description: 获取最大宗地代码顺序号,依据地籍子区累计,用于宗地代码生成  
	* @param @return    设定文件 
	* @return String    返回类型 
	* @throws
	 */
	public synchronized String findMaxZddmByDistrict(String district){
		if("oracle".equals(Global.getDbName())){
			return dao.findMaxZddmByDistrictOfOracle(district);
		}else{
			return dao.findMaxZddmByDistrict(district);
		}
	}
	
	@Transactional(readOnly = false)
	public void save(RegBaseZdjbxx regBaseZdjbxx) {
		super.save(regBaseZdjbxx);
		//切面实现:测绘信息被引用点
		/*if(StringUtils.isNotBlank(regBaseZdjbxx.getChid())){
			RegBaseChxx regBaseChxx = regBaseChxxService.get(regBaseZdjbxx.getChid());
			regBaseChxx.setIsaudit("2");
			regBaseChxxService.save(regBaseChxx);
		}*/
	}
	
	@Transactional(readOnly = false)
	public void delete(RegBaseZdjbxx regBaseZdjbxx) {
		Logger logger = LoggerFactory.getLogger(getClass());
		logger.info("********************开始调用宗地删除********************");
		logger.info("当前时间:{}", DateUtils.getDate("yyyy-MM-dd HH:mm:ss"));
		logger.info("当前用户:{}", UserUtils.getUser().getLoginName());
		logger.info("********************结束调用宗地删除********************");
		/*if(StringUtils.isNotBlank(regBaseZdjbxx.getChid())){
			RegBaseChxx regBaseChxx = regBaseChxxService.get(regBaseZdjbxx.getChid());
			regBaseChxx.setIsaudit("1");
			regBaseChxxService.save(regBaseChxx);
		}*/
		super.delete(regBaseZdjbxx);
	}
	
	@Transactional(readOnly = false)
	public void update(RegBaseZdjbxx regBaseZdjbxx) {
		super.save(regBaseZdjbxx);
		/*if(StringUtils.isNotBlank(regBaseZdjbxx.getChid())){
			RegBaseChxx regBaseChxx = regBaseChxxService.get(regBaseZdjbxx.getChid());
//			regBaseChxx.setIsaudit("1");
			regBaseChxxService.save(regBaseChxx);
		}*/
	}
	
	@Transactional(readOnly = false)
	public void deleteRegBaseZdjbxx(RegBaseZdjbxx regBaseZdjbxx) {
		super.delete(regBaseZdjbxx);
	}
	
	
	/**
	* @Title: getNextZddm 
	* @Description: 获取下一个宗地代码
	* @param @param maxZddm
	* @param @param ruleCode
	* @param @return    设定文件 
	* @return String    返回类型 
	* @throws
	 */
	public synchronized String getNextZddm(String maxZddm, String ruleCode) {
		String nextZddm = ruleCode + "00001";
		//如果数据里的最大宗地代码不为空,就取出来进行处理;否则直接默认值
		if(StringUtils.isNotBlank(maxZddm)){
			int nextSerNum = Integer.parseInt(maxZddm) + 1;
			if (nextSerNum < 10) {
				nextZddm = ruleCode + "0000" + nextSerNum;
			}else if (nextSerNum < 100) {
				nextZddm = ruleCode + "000" + nextSerNum;
			}else if (nextSerNum < 1000) {
				nextZddm = ruleCode + "00" + nextSerNum;
			}else if (nextSerNum < 10000) {
				nextZddm = ruleCode + "0" + nextSerNum;
			}else {
				nextZddm = ruleCode + nextSerNum;
			}
		}
		return nextZddm;
	}
	
	//楼栋找地
	public RegBaseZdjbxx zrzgetdy(String bdcdyh){
		return super.zrzgetdy(bdcdyh);
	}

	public RegBaseZdjbxx getQlrByDy(String ybdcdyh) {
		// TODO Auto-generated method stub
		return dao.getQlrByDy(ybdcdyh);
	}
	
	
	
	/**
	 * 权籍系统传送数据更新
	 * @param regBaseZdjbxx
	 */
	
	@Transactional(readOnly = false)
	public void saveObject(RegBaseZdjbxx regBaseZdjbxx) {
		super.save(regBaseZdjbxx);
		
	}

	public void postData(RegBaseZdjbxx regBaseZdjbxxNew) {
		if(Global.isTitle()) {
		ZdjbxxDto zdjbxx = new ZdjbxxDto();
		BeanUtils.copyProperties(regBaseZdjbxxNew, zdjbxx);
		zdjbxx.setYt(DictUtils.getDictValue(regBaseZdjbxxNew.getYt(), "reg_bus_tdyt", ""));
		String url = Global.getTitleUrl() + "/inte/post/zdxxdata";
		Map params = JsonUtil.ObjectoMap(zdjbxx);
		 
		String content = "";
		try {
			content = buss.posturl(params, url);
		} catch (IOException e) {
			e.printStackTrace();
		}
		}
	}

	public List<RegBaseZdjbxx> findListqj(RegBaseZdjbxx zdjbxx) {
		// TODO Auto-generated method stub
		return dao.findListqj(zdjbxx);
	}

	public void deleteqj(RegBaseZdjbxx zdjbxx) {
		
          dao.deleteqj(zdjbxx);
		
	}

	public RegBaseZdjbxx getdyqj(String zddm) {
		// TODO Auto-generated method stub
		return dao.getdyqj(zddm);
	}

	public void saveZb(RegBaseZdjbxx zdjbxx) {
		// TODO Auto-generated method stub
		dao.saveZb(zdjbxx);
	}
	
	
	@Transactional(readOnly = false)
	public void deleteNf(RegBaseZdjbxx regBaseZdjbxx) {
		Logger logger = LoggerFactory.getLogger(getClass());
		logger.info("********************开始调用宗地删除********************");
		logger.info("当前时间:{}", DateUtils.getDate("yyyy-MM-dd HH:mm:ss"));
		logger.info("当前用户:{}", UserUtils.getUser().getLoginName());
		logger.info("********************结束调用宗地删除********************");
		if(StringUtils.isNotBlank(regBaseZdjbxx.getChid())){
			RegBaseChxx11 regBaseChxx = regBaseChxxService.get(regBaseZdjbxx.getChid());
			regBaseChxxService.delete(regBaseChxx);
		}
		super.delete(regBaseZdjbxx);
	}
}