whycxzp
2021-11-04 fd6c1811135d080fff6cb8349f3f251985b11238
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
58
59
60
61
62
63
64
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.whyc.mapper.WorkflowLinkMapper;
import com.whyc.mapper.WorkflowMainMapper;
import com.whyc.pojo.WorkflowAlarm;
import com.whyc.pojo.WorkflowMain;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
 
@Service
public class WorkflowMainService {
 
    @Resource
    private WorkflowMainMapper mapper;
 
    @Resource
    private WorkflowLinkMapper linkMapper;
 
    public String getNextSequence() {
        String nextSequence = "";
        QueryWrapper<WorkflowMain> wrapper = Wrappers.query();
 
        String orderId = "WF-1-";
        String ymd = new SimpleDateFormat("yyyyMMdd").format(new Date());
        orderId = orderId+ymd+"-";
        wrapper.likeRight("order_id",orderId).orderByDesc("order_id").last(" limit 1");
        WorkflowMain workflowMain = mapper.selectOne(wrapper);
        if(workflowMain == null){
            nextSequence="00001";
        }else{
            String maxSequence = workflowMain.getOrderId().split("-")[3];
            int nextSequenceIntValue = Integer.parseInt(maxSequence) + 1;
            nextSequence = String.format("%05d", nextSequenceIntValue);
        }
        return nextSequence;
    }
 
 
 
    public static void main(String[] args) {
        int a = 110;
        System.out.println(String.format("%05d",a));
    }
 
    public void add(List<WorkflowMain> workflowMainList) {
        mapper.insertBatchSomeColumn(workflowMainList);
    }
 
    public List<WorkflowMain> getPendingWorkflowList(Long userId) {
        //获取系统生成,待处理的工单
        List<WorkflowMain> workflowAlarmList = mapper.getWorkflowAlarmList(userId);
        //获取正在工单节点表中待处理的工单
        List<WorkflowMain> workflowList = mapper.getPendingWorkflowList(userId);
 
        workflowList.addAll(workflowAlarmList);
        return workflowList;
    }
}