package com.home.xining.service; import java.text.DecimalFormat; import java.text.Format; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.product.core.dao.BaseDao; import com.product.core.entity.FieldSetEntity; import com.product.core.service.support.AbstractBaseService; /** * 流程结束前处理器调用,自动给行政处罚相关业务添加字号 * @author 86151 * */ @Component public class FlowEndCreateSerialNumber extends AbstractBaseService{ @Autowired BaseDao baseDao; /** * 自动生成字号 * @param tableName 表名 * @param serviceUUID 业务UUID * @param yearNo 宁房字 */ public synchronized void autoCreateSerialNumber(FieldSetEntity fse, String serviceUUID, String yearNo) { //查询同字数据中最大的号 FieldSetEntity fseMax =baseDao.getFieldSetEntityBySQL("SELECT IFNULL(MAX(no02),0)+1 no02 FROM "+fse.getTableName()+" WHERE no01=?", new Object[] {yearNo}, false); if (fseMax!=null) { Integer maxNo = fseMax.getInteger("no02"); //格式化号 Format format = new DecimalFormat("000"); String finalNo= format.format(maxNo); //修改数据 baseDao.executeUpdate("UPDATE "+ fse.getTableName() +" SET no02 =? WHERE uuid=?", new Object[] {finalNo, serviceUUID}); } } }