lxw
2023-08-11 c626699236a68cf459ade900936799185f0368da
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
package com.whyc.service;
 
import com.whyc.constant.WorkflowEnum;
import com.whyc.dto.Response;
import com.whyc.mapper.Fbs9100SetParamTempMapper;
import com.whyc.pojo.Fbs9100SetParamTemp;
import com.whyc.pojo.UserInf;
import com.whyc.pojo.WorkflowMain;
import com.whyc.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.Date;
 
@Service
public class Fbs9100SetParamTempService {
    @Autowired(required = false)
    private Fbs9100SetParamTempMapper mapper;
 
    @Autowired(required = false)
    private WorkflowMainService mainService;
 
    //该设备放电申请
    public Response searchTemp(int devId) {
        Fbs9100SetParamTemp temp = mapper.searchTemp(devId);
        return new Response().setII(1, temp == null ? false : true, temp, "设备放电申请");
    }
 
    //二次放电发起申请
    @Transactional
    public Response addTmpWorkMain(Fbs9100SetParamTemp tmp, UserInf uinf) {
        //1.提交到单据审批流程
        //查询表单编号
        int id = mainService.getMaxId();
        WorkflowMain main = new WorkflowMain();
        String orderId = mainService.getNextOrderId("ECHR");
        String title = "二次放电审批单-" + DateUtil.YYYY_MM_DD_HH_MM_SS_UNION;
        Integer mainStatus = WorkflowEnum.MAIN_STATUS_DEALING.getValue();
        Integer mainType = WorkflowEnum.MAIN_TYPE_DISCHARGE_DIST.getValue();
        main.setOrderId(orderId);
        main.setTitle(title);
        main.setTaskDesc(tmp.getReason());
        main.setCreateUserId(Integer.parseInt(uinf.getUId().toString()));
        main.setCreateTime(new Date());
        main.setBeginTime(new Date());
        main.setStatus(mainStatus);
        main.setType(mainType);
        main.setId(id);
        mainService.add(main);
        //2.添加二次放电参数
        tmp.setMainId(id);
        mapper.insert(tmp);
        return new Response().set(1, true, "二次放电申请");
    }
}