/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.sysnumberinfo.service;

import java.util.Calendar;
import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeeplus.common.persistence.Page;
import com.jeeplus.common.service.CrudService;
import com.jeeplus.modules.sysnumberinfo.entity.SysNumberInfo;
import com.jeeplus.modules.sysnumberinfo.dao.SysNumberInfoDao;

/**
 * 编码制定Service
 * @author 丁旭
 * @version 2017-03-22
 */
@Service
@Transactional(readOnly = true)
public class SysNumberInfoService extends CrudService<SysNumberInfoDao, SysNumberInfo> {

	public SysNumberInfo get(String id) {
		return super.get(id);
	}
	
	public List<SysNumberInfo> findList(SysNumberInfo sysNumberInfo) {
		return super.findList(sysNumberInfo);
	}
	
	public Page<SysNumberInfo> findPage(Page<SysNumberInfo> page, SysNumberInfo sysNumberInfo) {
		return super.findPage(page, sysNumberInfo);
	}
	
	@Transactional(readOnly = false)
	public void save(SysNumberInfo sysNumberInfo) {
			String s="";
			String first=sysNumberInfo.getFirst();
			String year=sysNumberInfo.getYear();
			String mouth=sysNumberInfo.getMouth();
			String day= sysNumberInfo.getDay();
			String separators =sysNumberInfo.getSeparator();
			String numFirst =sysNumberInfo.getNumFirst();
			String numLength =sysNumberInfo.getNumLength();
			Calendar now = Calendar.getInstance();
			s=s+first+separators;
			if(year!=null&&year.equals("0")){
				
				s=s+now.get(Calendar.YEAR);
			}
			if(mouth!=null&&mouth.equals("0")){
				s=s+(now.get(Calendar.MONTH)+1);
				
			}
			if(day!=null&&day.equals("0")){
				s=s+now.get(Calendar.DAY_OF_MONTH);
			}
			
			sysNumberInfo.setExample(s);
		
	
		super.save(sysNumberInfo);
	}
	
	@Transactional(readOnly = false)
	public void delete(SysNumberInfo sysNumberInfo) {
		super.delete(sysNumberInfo);
	}
	
	
	
	
}