whycxzp
2023-08-15 b3c541b81dd6212564d605a4f14a89682080289e
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
65
66
67
68
69
70
71
72
73
74
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.whyc.dto.AlarmDaoFactory;
import com.whyc.dto.Response;
import com.whyc.mapper.AlarmManualClearMapper;
import com.whyc.pojo.AlarmManualClear;
import com.whyc.util.ActionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.Date;
 
@Service
public class AlarmManualClearService {
 
    @Resource
    private AlarmManualClearMapper mapper;
 
    @Autowired
    private BattInfService battInfService;
 
    @Autowired
    private PowerInfService powerInfService;
 
    public Response submit(AlarmManualClear clear) {
        int userId = ActionUtil.getUser().getUId().intValue();
        clear.setDealUserId(userId);
        clear.setCreateTime(new Date());
        //插入对应的站点id,用于后期用户相关
        Integer alarmType = clear.getAlarmType();
        String stationId;
        if(alarmType == 1){
            stationId = battInfService.getStationIdByBattGroupId(clear.getBattGroupId());
        } else if (alarmType == 2) {
            stationId = battInfService.getStationIdByDeviceId(clear.getDeviceId());
        }else{
            stationId = powerInfService.getStationIdByPowerDeviceId(clear.getPowerDeviceId());
        }
        clear.setStationId(stationId);
        mapper.insert(clear);
        return new Response().set(1,"提交完成");
    }
 
    public Response getRecordByAlarmInfo(AlarmManualClear clear) {
        QueryWrapper<AlarmManualClear> query = Wrappers.query();
        Integer alarmType = clear.getAlarmType();
        String alarmName;
        if(alarmType == 1) {
            alarmName = AlarmDaoFactory.getAllAlarmName(clear.getAlmSignalId());
            query.eq("batt_group_id",clear.getBattGroupId()).eq("alm_signal_id",clear.getAlmSignalId());
        }else if(alarmType == 2){
            query.eq("device_id",clear.getDeviceId());
            alarmName = AlarmDaoFactory.getAllAlarmName(clear.getAlmId());
        }else{
            query.eq("power_device_id",clear.getPowerDeviceId());
            alarmName = AlarmDaoFactory.getAllAlarmName(clear.getAlmId());
        }
        query.eq("alm_start_time",clear.getAlmStartTime())
                .eq("alm_id",clear.getAlmId()).last(" limit 1");
        AlarmManualClear clearDB = mapper.selectOne(query);
 
        clearDB.setAlarmName(alarmName);
        return new Response().set(1,clearDB);
 
    }
 
    public Response getAll() {
        int userId = ActionUtil.getUser().getUId().intValue();
        return null;
    }
}