中扬CRM客户关系管理系统
#
luxiaotao1123
2022-09-12 c10d897c5d72fe80f271acbd909107e42dccff1c
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
package com.zy.crm.manager.service.impl;
 
import com.zy.crm.manager.mapper.CstmrMapper;
import com.zy.crm.manager.entity.Cstmr;
import com.zy.crm.manager.service.CstmrService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
 
@Service("cstmrService")
public class CstmrServiceImpl extends ServiceImpl<CstmrMapper, Cstmr> implements CstmrService {
 
    @Override
    public Cstmr selectByUuid(Long hostId, String uuid) {
        return this.baseMapper.selectByUuid(hostId, uuid);
    }
 
    @Override
    public String getNextUuid(Long hostId) {
        Cstmr cstmr = this.baseMapper.selectCstmrByNewestUuid(hostId);
        if (cstmr == null) {
            return "0001";
        }
        return zerofill(String.valueOf(Integer.parseInt(cstmr.getUuid()) + 1), 4);
    }
 
 
    public static String zerofill(String msg, Integer count){
        if (msg.length() == count){
            return msg;
        } else if (msg.length() > count){
            return msg.substring(0, 16);
        } else {
            StringBuilder msgBuilder = new StringBuilder(msg);
            for (int i = 0; i<count-msg.length(); i++){
                msgBuilder.insert(0,"0");
            }
            return msgBuilder.toString();
        }
    }
 
}