许鹏程
2023-06-07 f22002d5aaa03e54b3a8ffdb2a0e56e4d8ab473b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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});
        }
    }
}