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();
|
String id = jsonArray.getJSONObject(i).getString("id");
|
// 查询是否已存在
|
HkStaffGaugeMon staffGaugeMon = getById(id);
|
if (null==staffGaugeMon) {
|
// 设置数据
|
hkStaffGaugeMon.setId(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);
|
}
|
}
|
}
|
}
|
}
|