zhangherong
2025-07-03 1b5a723592ea63e5eec0bdeef7855b9c40e9df71
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
45
46
47
48
49
50
51
52
53
54
55
56
57
package org.jeecg.modules.system.service.impl;
 
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.modules.system.entity.SysBusinessCodeSeq;
import org.jeecg.modules.system.mapper.SysBusinessCodeSeqMapper;
import org.jeecg.modules.system.service.ISysBusinessCodeSeqService;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
/**
 * @Description: 业务编码生成序列
 * @Author: jeecg-boot
 * @Date:   2025-03-19
 * @Version: V1.0
 */
@Service
public class SysBusinessCodeSeqServiceImpl extends ServiceImpl<SysBusinessCodeSeqMapper, SysBusinessCodeSeq> implements ISysBusinessCodeSeqService {
 
    @Override
    public SysBusinessCodeSeq queryByParams(String ruleId, String prefix, String yearValue, String monthValue, String dayValue) {
        LambdaQueryWrapper<SysBusinessCodeSeq> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(SysBusinessCodeSeq::getRuleId, ruleId);
        queryWrapper.orderByDesc(SysBusinessCodeSeq::getCreateTime);
        if(StringUtils.isNotBlank(prefix)){
            queryWrapper.eq(SysBusinessCodeSeq::getPrefix, prefix);
        }else {
            queryWrapper.isNull(SysBusinessCodeSeq::getPrefix);
        }
 
        if(StringUtils.isNotBlank(yearValue)){
            queryWrapper.eq(SysBusinessCodeSeq::getCurrentYear, yearValue);
        }else {
            queryWrapper.isNull(SysBusinessCodeSeq::getCurrentYear);
        }
 
        if(StringUtils.isNotBlank(monthValue)){
            queryWrapper.eq(SysBusinessCodeSeq::getCurrentMonth, monthValue);
        }else {
            queryWrapper.isNull(SysBusinessCodeSeq::getCurrentMonth);
        }
 
        if(StringUtils.isNotBlank(dayValue)){
            queryWrapper.eq(SysBusinessCodeSeq::getCurrentDay, dayValue);
        }else {
            queryWrapper.isNull(SysBusinessCodeSeq::getCurrentDay);
        }
        List<SysBusinessCodeSeq> list = super.list(queryWrapper);
        if(CollectionUtil.isEmpty(list)){
            return null;
        }
        return list.get(0);
    }
}