jiazx0107@163.com
2023-08-25 73f74cbf665a431b0db474be129a03c655e2338a
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package com.ld.igds.modbus;
 
import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.DataResolver;
import com.bstek.dorado.annotation.Expose;
import com.ld.igds.constant.BizType;
import com.ld.igds.modbus.service.HModbusService;
import com.ld.igds.models.DeviceModbus;
import com.ld.igds.models.GasModbus;
import com.ld.igds.util.ContextUtil;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
 
/**
 * MOOBUS-TCP设备参数配置
 */
@Component
public class GasModbusPR {
 
    @Resource
    private HModbusService modbusService;
 
    /**
     * gasModbusPR#getGasData
     *
     * @return
     */
    @DataProvider
    public DeviceModbus getGasData(String depotId) {
        if (null == depotId) return new DeviceModbus();
 
        String bizType = BizType.GAS.getCode();
 
        String companyId = ContextUtil.getCompanyId();
 
        DeviceModbus result = modbusService.getGasData(companyId, depotId, bizType);
 
        if (null == result) {
            result = new DeviceModbus();
            result.setBizType(bizType);
            result.setDeviceCode(depotId);
            result.setListGas(new ArrayList<>());
        }
 
        return result;
    }
 
    /**
     * gasModbusPR#listGasModBus
     *
     * @param depotId
     * @return
     */
    @DataProvider
    public List<GasModbus> listGasModBus(String depotId) {
        return modbusService.listGasModBus(depotId);
    }
 
 
    /**
     * gasModbusPR#updateData
     * @param data
     */
    @DataResolver
    public void updateData(DeviceModbus data){
        modbusService.updateGasModbus(data);
    }
 
    /**
     * gasModbusPR#flushCache
     *
     * @return
     */
    @Expose
    public void flushCache() {
        String companyId = ContextUtil.getCompanyId();
        modbusService.flushCacheGas(companyId);
    }
 
    /**
     * deviceModbusPR#delData
     *
     * @return
     */
    @Expose
    public String delData(GasModbus data) {
        if (null == data.getId()) return null;
        return modbusService.delDataGas(data);
    }
 
}