lxw
2023-05-25 f3c27fb78447449a950ba73c5e72ceda64ad8a12
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
package com.whyc.service;
 
import com.whyc.constant.EnumWorksheetType;
import com.whyc.dto.Response;
import com.whyc.mapper.WorksheetMainMapper;
import com.whyc.pojo.UserInf;
import com.whyc.pojo.WorksheetAlarm;
import com.whyc.pojo.WorksheetLink;
import com.whyc.pojo.WorksheetMain;
import com.whyc.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import javax.annotation.Resource;
import java.util.Date;
 
/**
 * @author perryhsu
 * @date 2022/12/17 22:18
 */
@Service
public class WorksheetMainService {
 
    @Resource
    private WorksheetMainMapper mapper;
 
    @Autowired
    private WorksheetLinkService linkService;
 
    @Autowired
    private WorksheetAlarmService alarmService;
 
    @Transactional
    public Response alarmFlowSubmit(WorksheetMain main, UserInf user) {
        WorksheetAlarm worksheetAlarm = main.getWorksheetAlarm();
        //存入主表信息,子表信息,附表告警信息
        Date date = new Date();
        String formatDate = DateUtil.YYYY_MM_DD_HH_MM_SS_UNION.format(date);
        main.setTitle("告警派工单-"+user.getUName()+"-"+formatDate);
        main.setCreateUserId(user.getUId());
        main.setBeginTime(date);
        main.setStatus(1);
        main.setType(EnumWorksheetType.ProductBom.getType());
        mapper.insert(main);
        //子表
        Long nextUser = main.getNextUser();
        WorksheetLink link = new WorksheetLink();
        link.setMainId(main.getId());
        link.setParentId(0);
        link.setDealUserId(nextUser);
        link.setDealDesc(main.getDescription());
        link.setLinkStatus(0);
        link.setCreateTime(date);
        linkService.add(link);
        //附表告警表
        worksheetAlarm.setMainId(main.getId());
        worksheetAlarm.setCreateTime(date);
        alarmService.insert(worksheetAlarm);
 
        return new Response().setII(1,"提交完成");
    }
}