| | |
| | | |
| | | import cn.gistack.nky.entity.AlarmGet; |
| | | import cn.gistack.nky.fegin.INkyClient; |
| | | import cn.gistack.nky.service.IAlarmGetService; |
| | | import cn.gistack.nky.service.IArimaPredictService; |
| | | import cn.gistack.nky.service.IHstPredictService; |
| | | import cn.gistack.nky.service.INkyService; |
| | | import cn.gistack.nky.resultpojo.BaseCd; |
| | | import cn.gistack.nky.resultpojo.NkyBindDetailResult; |
| | | import cn.gistack.nky.resultpojo.ResDamMonitorResult; |
| | | import cn.gistack.nky.service.*; |
| | | import cn.gistack.nky.vo.AlarmGetVO; |
| | | import cn.gistack.nky.vo.PageVO; |
| | | import cn.gistack.sm.patrol.feign.PatrolTaskClient; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import lombok.AllArgsConstructor; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @NonDS |
| | | @ApiIgnore |
| | |
| | | private final IHstPredictService hstPredictService; |
| | | private final IAlarmGetService alarmGetService; |
| | | private final PatrolTaskClient patrolTaskClient; |
| | | private final IZtApiService ztApiService; |
| | | |
| | | |
| | | @Override |
| | |
| | | String taskType = "1641037874390999041"; |
| | | |
| | | //杨树堰水库大坝预警巡查 |
| | | String title = StringUtil.format("{}大坝预警巡查",byId.getReservoirName()); |
| | | String title = StringUtil.format("{}大坝预警巡查", byId.getReservoirName()); |
| | | |
| | | //杨树堰水库在2023-11-29 17:41:19时监测到位移GN1测点,测点值为2.37,预警等级为三级 |
| | | |
| | | String resNm = byId.getReservoirName(); |
| | | String tm = DateUtil.format(byId.getTime(),"MM月dd日HH时mm分"); |
| | | String tm = DateUtil.format(byId.getTime(), "MM月dd日HH时mm分"); |
| | | String typeName = byId.getTypeName(); |
| | | String cdNm = byId.getCdName(); |
| | | String value = byId.getValue(); |
| | | String level =String.valueOf( byId.getLevel()); |
| | | String level = String.valueOf(byId.getLevel()); |
| | | |
| | | String content=StringUtil.format("{}在{}时监测到{}{}测点值为{},预警等级为{}级", |
| | | resNm,tm,typeName,cdNm,value,level); |
| | | String content = StringUtil.format("{}在{}时监测到{}{}测点值为{},预警等级为{}级", |
| | | resNm, tm, typeName, cdNm, value, level); |
| | | String resCd = byId.getDamId(); |
| | | |
| | | //创建巡查任务 |
| | | String taskId = patrolTaskClient.createTask(processDefinitionId,taskType,title,content,resCd); |
| | | String taskId = patrolTaskClient.createTask(processDefinitionId, taskType, title, content, resCd); |
| | | alarmGet.setTaskId(taskId); |
| | | return alarmGetService.updateById(alarmGet); |
| | | } |
| | |
| | | |
| | | AlarmGet alarmGet = alarmGetService.getOne(new QueryWrapper<AlarmGet>().eq("TASK_ID", taskId)); |
| | | |
| | | if (alarmGet != null){ |
| | | if (alarmGet != null) { |
| | | //设置预警为已处理 |
| | | alarmGet.setStatus("1"); |
| | | Boolean aBoolean = updateStatus(alarmGet); |
| | | return aBoolean; |
| | | return aBoolean; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | @PostMapping(INIT_ALGORITHM) |
| | | public void initAlgorithm(List<String> resList) { |
| | | List<ResDamMonitorResult> resDamMonitorResultList = ztApiService.getResDamMonitor(); |
| | | //获取水库之后,根据标识是否有监测站请求测点 |
| | | resDamMonitorResultList.forEach(resDamMonitorResult -> { |
| | | String resGuid = resDamMonitorResult.getCode(); |
| | | if (resDamMonitorResult.getIs_sy().equals("1")){ |
| | | activeAlgorithm(resGuid,"sy","1"); |
| | | } |
| | | if (resDamMonitorResult.getIs_sl().equals("1")){ |
| | | activeAlgorithm(resGuid,"sl","2"); |
| | | } |
| | | if (resDamMonitorResult.getIs_wy().equals("1")){ |
| | | activeAlgorithm(resGuid,"wy","3,4,5"); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private void activeAlgorithm(String resGuid,String type,String nkyType){ |
| | | String taskCategory = "2107"; |
| | | List<BaseCd> cdList = ztApiService.getBaseCd(resGuid,type); |
| | | List<String> nkyTypeList = Arrays.asList(nkyType.split(",")); |
| | | |
| | | |
| | | cdList.forEach(baseCd -> { |
| | | String pointId = baseCd.getCd(); |
| | | |
| | | nkyTypeList.forEach(nkyTypeFlag->{ |
| | | |
| | | //请求测点之后,循环测点,判断算法绑定情况 |
| | | List<NkyBindDetailResult> nkyBindDetailResultList = nkyService.getBindDetail(baseCd.getRes_cd(),baseCd.getCd(),nkyTypeFlag); |
| | | //过滤出 多元线性回归预测模型异常判定 algorithmCategory: 2107 |
| | | List<NkyBindDetailResult> filterCollect = nkyBindDetailResultList.stream().filter(nkyBindDetailResult -> nkyBindDetailResult.getAlgorithmCategory().equals(taskCategory)).collect(Collectors.toList()); |
| | | |
| | | if (filterCollect.size() == 0){ |
| | | //如果是空的,说明没有启用该算法;先启用该算法 |
| | | // JSONObject bindEnableParams = new JSONObject(); |
| | | // |
| | | // bindEnableParams.put("status",1); |
| | | // bindEnableParams.put("taskCategory",taskCategory); |
| | | // bindEnableParams.put("damId",resGuid); |
| | | // bindEnableParams.put("pointId",pointId); |
| | | // bindEnableParams.put("type",nkyTypeFlag); |
| | | // boolean bindEnableRes = nkyService.bindEnable(bindEnableParams); |
| | | // //成功启用,设置值 |
| | | // if (bindEnableRes){ |
| | | // |
| | | // JSONObject bindParamParams = new JSONObject(); |
| | | // |
| | | // bindParamParams.put("damId",resGuid); |
| | | // bindParamParams.put("pointId",pointId); |
| | | // bindParamParams.put("type",nkyTypeFlag); |
| | | // bindParamParams.put("algorithmCategory",taskCategory); |
| | | // bindParamParams.put("reserve1","4,3.3,2.7,2"); |
| | | // |
| | | // boolean bindParamRes = nkyService.bindParam(bindParamParams); |
| | | // } |
| | | |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | } |