houzhongjian
2024-07-23 a6de490948278991e47952e90671ddba4555e9a2
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
//package com.iailab.module.http.service.impl;
//
//import com.alibaba.fastjson.JSONObject;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.baomidou.mybatisplus.core.toolkit.StringUtils;
//import com.iailab.framework.common.service.impl.BaseServiceImpl;
//import com.iailab.common.utils.HttpsRequest;
//import com.iailab.common.utils.PageUtils;
//import com.iailab.common.utils.Query;
//import com.iailab.module.http.dao.FxjyTagDao;
//import com.iailab.module.http.entity.FxjyTagEntity;
//import com.iailab.module.http.service.HttpApiService;
//import lombok.extern.slf4j.Slf4j;
//import javax.annotation.Resource;
//import org.springframework.stereotype.Service;
//
//import java.lang.reflect.Field;
//import java.math.BigDecimal;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//@Slf4j
//@Service
//public class FxjyTagServiceImpl extends BaseServiceImpl<FxjyTagDao, FxjyTagEntity> implements FxjyTagService {
//
//    @Resource
//    private HttpsRequest httpsRequest;
//
//    @Resource
//    private HttpApiService httpApiService;
//
//    private final String API_CODE = "fxjyHttpTag";
//
//    /**
//     * 分页查询tag
//     *
//     * @param params
//     */
//    @Override
//    public PageUtils queryPage(Map<String, Object> params) {
//        String tagType = (String) params.get("tagType");
//        String tagCode = (String) params.get("tagCode");
//        String tagName = (String) params.get("tagName");
//
//        IPage<FxjyTagEntity> page = baseDao.selectPage(
//                new Query<FxjyTagEntity>().getPage(params),
//                new QueryWrapper<FxjyTagEntity>()
//                        .like(StringUtils.isNotBlank(tagType), "tag_type", tagType)
//                        .like(StringUtils.isNotBlank(tagCode), "tag_code", tagCode)
//                        .like(StringUtils.isNotBlank(tagName), "tag_name", tagName)
//                        .orderByDesc("create_time")
//        );
//        return new PageUtils(page);
//    }
//
//    @Override
//    public Map<String, BigDecimal> getTagsValues(List<FxjyCurrentDto> tags){
//        Map<String, BigDecimal> result = new HashMap<>(tags.size());
//        Map<String, String> params = new HashMap<>(2);
//        String url = httpApiService.getByCode(API_CODE).getUrl();
////        String responseStr = httpsRequest.doGet(url, params,"utf-8", "");
//        String responseStr = "{\n" +
//                "\"flag\":true,\n" +
//                "\"data\":{\n" +
//                "\"ST\":\"2024-01-1616:42:36\",\n" +
//                "\"JYJ1\":{\n" +
//                "\"CURRENT_SPEED\":199.17,\n" +
//                "\"DL\":4.5,\n" +
//                "\"CW\":false,\n" +
//                "\"EN\":true,\n" +
//                "\"FAULT\":false,\n" +
//                "\"GL\":false,\n" +
//                "\"GY\":false,\n" +
//                "\"QY\":false,\n" +
//                "\"RUNING\":true,\n" +
//                "\"SPEED_SET\":200.0\n" +
//                "},\n" +
//                "\"JYJ2\":{\n" +
//                "\"CURRENT_SPEED\":0.0,\n" +
//                "\"DL\":1.8,\n" +
//                "\"CW\":false,\n" +
//                "\"EN\":true,\n" +
//                "\"FAULT\":false,\n" +
//                "\"GL\":false,\n" +
//                "\"GY\":false,\n" +
//                "\"QY\":false,\n" +
//                "\"RUNING\":false,\n" +
//                "\"SPEED_SET\":50.0\n" +
//                "},\n" +
//                "\"JYJ3\":{\n" +
//                "\"CURRENT_SPEED\":199.17,\n" +
//                "\"DL\":4.5,\n" +
//                "\"CW\":false,\n" +
//                "\"EN\":true,\n" +
//                "\"FAULT\":false,\n" +
//                "\"GL\":false,\n" +
//                "\"GY\":false,\n" +
//                "\"QY\":false,\n" +
//                "\"RUNING\":true,\n" +
//                "\"SPEED_SET\":200.0\n" +
//                "},\n" +
//                "\"JYJ4\":{\n" +
//                "\"CURRENT_SPEED\":0.0,\n" +
//                "\"DL\":1.8,\n" +
//                "\"CW\":false,\n" +
//                "\"EN\":true,\n" +
//                "\"FAULT\":false,\n" +
//                "\"GL\":false,\n" +
//                "\"GY\":false,\n" +
//                "\"QY\":false,\n" +
//                "\"RUNING\":false,\n" +
//                "\"SPEED_SET\":50.0\n" +
//                "},\n" +
//                "\"FXJY\":{\n" +
//                "\"YW401\":5.49,\n" +
//                "\"YW407\":66.83,\n" +
//                "\"YW408\":19.92,\n" +
//                "\"PumpRun_402A\":true,\n" +
//                "\"PumpRun_402B\":true,\n" +
//                "\"YCLQ_Run_403A\":true,\n" +
//                "\"YCLQ_Run_403B\":true,\n" +
//                "\"Valve1_GDW\":false,\n" +
//                "\"Valve1_KDW\":true,\n" +
//                "\"Valve1_ZZK\":false,\n" +
//                "\"Valve1_ZZG\":false,\n" +
//                "\"Valve2_GDW\":true,\n" +
//                "\"Valve2_KDW\":false,\n" +
//                "\"Valve2_ZZK\":false,\n" +
//                "\"Valve2_ZZG\":false,\n" +
//                "\"Valve3_GDW\":false,\n" +
//                "\"Valve3_KDW\":true,\n" +
//                "\"Valve3_ZZK\":false,\n" +
//                "\"Valve3_ZZG\":false,\n" +
//                "\"Valve4_GDW\":true,\n" +
//                "\"Valve4_KDW\":false,\n" +
//                "  \"Valve4_ZZK\": false,\n" +
//                "\"Valve4_ZZG\": false,\n" +
//                "\"ZLLLJ1_403A\": 19.35,\n" +
//                "\"ZLLLJ2_403A\": 2.73,\n" +
//                "\"ZLLLJ1_403B\": 15.99,\n" +
//                "\"ZLLLJ2_403B\": 5.19,\n" +
//                "\"FXRL_LLJ_403A1\": 983.75,\n" +
//                "\"FXRL_LLJ_403A2\": 583.91,\n" +
//                "\"FXPMHDJC1\": 5.11,\n" +
//                "\"FXPMHDJC2\": 1.95,\n" +
//                "\"LD3_LD1\": 0.0,\n" +
//                "\"LD3_LD2\": 0.0,\n" +
//                "\"LD3_ND\": 0.0\n" +
//                "},\n" +
//                "\"YLXT\": {\n" +
//                "\"YW405A\": 21.98,\n" +
//                "\"YW405B\": 17.04,\n" +
//                "\"YW601\": 33.79,\n" +
//                "\"VF861_Run\": true,\n" +
//                "\"VF862_Run\": true,\n" +
//                "\"VF863_Run\": true,\n" +
//                "\"KM414A_Run\": false,\n" +
//                "\"KM414B_Run\": false,\n" +
//                "\"KM418A_Run\": false,\n" +
//                "\"KM418B_Run\": false,\n" +
//                "\"KM602A_Run\": false,\n" +
//                "\"KM602B_Run\": false,\n" +
//                "\"KM602C_Run\": true,\n" +
//                "\"KM416A_Run\": false,\n" +
//                "\"KM416B_Run\": false,\n" +
//                "\"KM420A_Run\": false,\n" +
//                "\"KM420B_Run\": false,\n" +
//                "\"KM606A_Run\": false,\n" +
//                "\"KM606B_Run\": false,\n" +
//                "\"KM606C_Run\": false\n" +
//                "},\n" +
//                "\"LJL\": {\n" +
//                "\"Timestamp\": \"2024-01-16\",\n" +
//                "\"JYJ1\": 120.53,\n" +
//                "\"JYJ2\": 0.0,\n" +
//                "\"JYJ3\": 117.66,\n" +
//                "\"JYJ4\": 0.0\n" +
//                "},\n" +
//                "\"YCZ\": {\n" +
//                "\"JYJ1\": 249.6,\n" +
//                "\"JYJ2\": 0.0,\n" +
//                "\"JYJ3\": 248.23,\n" +
//                "\"JYJ4\": 0.0\n" +
//                "},\n" +
//                "\"YLCS\": {\n" +
//                "\"YL415A_GLCSXS\": 7,\n" +
//                "\"YL415B_GLCSXS\": 8,\n" +
//                "\"YL419A_GLCSXS\": 7,\n" +
//                "\"YL419B_GLCSXS\": 8,\n" +
//                "\"YL603A_GLCSXS\": 1,\n" +
//                "\"YL603B_GLCSXS\": 0,\n" +
//                "\"YL603C_GLCSXS\": 3\n" +
//                "},\n" +
//                "\"TEMP\": {\n" +
//                "\"FXRLNDJ403A\": 67.12\n" +
//                "}\n" +
//                "},\n" +
//                "\"msg\": \"查询成功\"\n" +
//                "}";
//        if (StringUtils.isNotBlank(responseStr)) {
//            FxjyJsonDto fxjyJsonDto = parseDto(responseStr);
//            fxjyJsonDto.getData().getLJL().getJYJ1();
//            tags.stream().forEach(
//                    item->{
//                        Class<?> fxjyClass= fxjyJsonDto.getData().getClass();
//                        try {
//                            Class<?> fxjyTypeClass = fxjyClass.getDeclaredField(item.getTagType()).getClass();
//                            Field field = fxjyTypeClass.getDeclaredField(item.getTagCode());
//                            field.setAccessible(true);
//                            BigDecimal value = new BigDecimal((String)field.get(fxjyJsonDto.getData()));
//                            result.put(item.getTagType()+"_"+item.getTagCode(), value);
//                        }catch (NoSuchFieldException e){
//                            log.info("没有找到tag"+item.getTagType()+";"+item.getTagCode());
//                        }catch(IllegalAccessException e){
//                            log.info("没有反射权限");
//                        }
//                    }
//            );
//        }
//        return result;
//    }
//
//    @Override
//    public List<FxjyTagEntity> selectList() {
//        return baseDao.selectList(new QueryWrapper<FxjyTagEntity>().orderByDesc("create_time"));
//    }
//
//    private FxjyJsonDto parseDto(String responseStr) {
//        FxjyJsonDto result = new FxjyJsonDto();
//        if (!org.apache.commons.lang.StringUtils.isEmpty(responseStr)) {
//            JSONObject items = JSONObject.parseObject(responseStr);
//            result = items.toJavaObject(FxjyJsonDto.class);
//        }
//        return result;
//    }
//}