zrj
2024-06-05 aa295dc3191a4a426a4a1c3b52dba65b09b34278
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
package cn.gistack.sm.hk.service.impl;
 
import cn.gistack.sm.hk.entity.HkEvent;
import cn.gistack.sm.hk.entity.HkStaffGaugeMon;
import cn.gistack.sm.hk.mapper.HkStaffGaugeMonMapper;
import cn.gistack.sm.hk.service.HkStaffGaugeMonService;
import cn.gistack.sm.hk.util.GetCameraUtils;
import cn.gistack.sm.hk.vo.HkStaffGaugeMonVO;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
 
import java.util.Date;
import java.util.Map;
 
import static cn.gistack.sm.hk.constant.HkConstant.waterGaugeURLs;
 
/**
 * 水尺监测服务接口实现层
 * @author zhongrj
 * @date 2024-06-05
 */
@Service
@Slf4j
public class HkStaffGaugeMonServiceImpl extends ServiceImpl<HkStaffGaugeMonMapper, HkStaffGaugeMon> implements HkStaffGaugeMonService {
 
    /**
     * 自定义分页列表查询
     * @param page
     * @param hkStaffGaugeMon
     * @return
     */
    @Override
    public IPage<HkStaffGaugeMonVO> selectHkStaffGaugeMonPage(IPage<HkStaffGaugeMonVO> page, HkStaffGaugeMonVO hkStaffGaugeMon) {
        return page.setRecords(baseMapper.selectHkStaffGaugeMonPage(page,hkStaffGaugeMon));
    }
 
    /**
     * 保存数据
     * @return
     */
    @Override
    public void saveHkStaffGaugeMonInfo() {
        // 解析json
        String result = GetCameraUtils.getStaffGaugeMon(3, waterGaugeURLs);
        // 保存
        saveHkStaffGaugeMonInfo(result);
    }
 
    /**
     * 保存数据
     * @param result
     * @return
     */
    @Override
    public void saveHkStaffGaugeMonInfo(String result) {
        // 解析json
        log.info("水尺监测信息:" + result);
        JSONObject jsonObject = JSONObject.parseObject(result);
        JSONArray jsonArray = jsonObject.getJSONArray("data");
        if (null!= jsonArray && jsonArray.size()>0) {
            for (int i = 0; i < jsonArray.size(); i++) {
                HkStaffGaugeMon hkStaffGaugeMon = new HkStaffGaugeMon();
                hkStaffGaugeMon.setId(jsonArray.getJSONObject(i).getString("id"));
                hkStaffGaugeMon.setWaterGaugeName(jsonArray.getJSONObject(i).getString("waterGaugeName"));
                hkStaffGaugeMon.setWaterGaugeCode(jsonArray.getJSONObject(i).getString("waterGaugeCode"));
                hkStaffGaugeMon.setCameraIndexCode(jsonArray.getJSONObject(i).getString("cameraIndexCode"));
                hkStaffGaugeMon.setCameraName(jsonArray.getJSONObject(i).getString("cameraName"));
                hkStaffGaugeMon.setLocation(jsonArray.getJSONObject(i).getString("location"));
                hkStaffGaugeMon.setMarkPic(jsonArray.getJSONObject(i).getString("markPic"));
                hkStaffGaugeMon.setMarkData(jsonArray.getJSONObject(i).getString("markData"));
                hkStaffGaugeMon.setCreateTime(jsonArray.getJSONObject(i).getDate("createTime"));
                hkStaffGaugeMon.setConfigUpdateTime(jsonArray.getJSONObject(i).getDate("configUpdateTime"));
                hkStaffGaugeMon.setUpdateTime(jsonArray.getJSONObject(i).getDate("updateTime"));
                hkStaffGaugeMon.setDeleteStatus(jsonArray.getJSONObject(i).getInteger("deleteStatus"));
                hkStaffGaugeMon.setCurrentPic(jsonArray.getJSONObject(i).getString("currentPic"));
                hkStaffGaugeMon.setAlarmHeight(jsonArray.getJSONObject(i).getDouble("alarmHeight"));
                hkStaffGaugeMon.setRemark1(jsonArray.getJSONObject(i).getString("remark1"));
                hkStaffGaugeMon.setRemark2(jsonArray.getJSONObject(i).getString("remark2"));
                hkStaffGaugeMon.setRemark3(jsonArray.getJSONObject(i).getString("remark3"));
                hkStaffGaugeMon.setRemark4(jsonArray.getJSONObject(i).getString("remark4"));
                hkStaffGaugeMon.setRemark5(jsonArray.getJSONObject(i).getString("remark5"));
                // 保存
                save(hkStaffGaugeMon);
            }
        }
    }
}