package abacus.springboot.example.config;

import javax.persistence.EntityManager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.abacus.xpos.foundation.pubs.DaoIdGenerator;

/**
 * <p>Title:JcIdGeneratorConfig</p>
   <p>Description: ID生成器</p>
   @author chuanZeng 
   @date 2024年12月5日
 */
@Configuration
public class JcIdGeneratorConfig {

	@Autowired
    private EntityManager entityManager;
	
	@Bean(name="jcBillIdGenerator")
    public DaoIdGenerator jcBillIdGenerator() {
        DaoIdGenerator daoIdGenerator = new DaoIdGenerator();
        daoIdGenerator.setTargetTableName("jc_bill");
        daoIdGenerator.setPrefix("JC");
        daoIdGenerator.setTargetIdColumnName("id");
        daoIdGenerator.setSerialLength(4);
        daoIdGenerator.setUseDAOId(false);
        daoIdGenerator.setUseDateFormat(true);
    	//年月日
    	daoIdGenerator.setDateFormat("yyyyMMdd");
        return daoIdGenerator;
    }
	
	@Bean(name="jcBillHgIdGenerator")
    public DaoIdGenerator jcBillHgIdGenerator() {
        DaoIdGenerator daoIdGenerator = new DaoIdGenerator();
        daoIdGenerator.setTargetTableName("jc_billhg");
        daoIdGenerator.setPrefix("HG");
        daoIdGenerator.setTargetIdColumnName("id");
        daoIdGenerator.setSerialLength(4);
        daoIdGenerator.setUseDAOId(false);
        daoIdGenerator.setUseDateFormat(true);
    	//年月日
    	daoIdGenerator.setDateFormat("yyyyMMdd");
        return daoIdGenerator;
    }
}
