| | |
| | | damAlarmRecord.setResGuid(alarmRecordJSONObject.getString("RS_CODE")); |
| | | damAlarmRecord.setCollecTime(alarmRecordJSONObject.getDate("collecTime")); |
| | | damAlarmRecord.setPointValue(alarmRecordJSONObject.getString("ponitValue")); |
| | | damAlarmRecord.setValue(alarmRecordJSONObject.getString("value")); |
| | | JSONObject generalInfo = alarmRecordJSONObject.getJSONObject("generalInfo"); |
| | | damAlarmRecord.setPointWarnLevel(generalInfo.getInteger("pointWarnLevel")); |
| | | damAlarmRecord.setPointWarnInfo(generalInfo.getString("pointWarnInfo")); |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveDamAlarmRecordDetail(JSONArray detailInfo,DamAlarmRecord damAlarmRecord) { |
| | | boolean flag = false; |
| | | List<DamAlarmRecordDetail> list = new ArrayList<>(); |
| | | for (int i = 0; i < detailInfo.size(); i++) { |
| | | DamAlarmRecordDetail damAlarmRecordDetail = new DamAlarmRecordDetail(); |
| | | JSONObject jsonObject = detailInfo.getJSONObject(i); |
| | | damAlarmRecordDetail.setDamAlarmRecordId(damAlarmRecord.getId()); |
| | | damAlarmRecordDetail.setAlgorithmName(jsonObject.getString("algorithmName")); |
| | | damAlarmRecordDetail.setAlgorithmWarnLevel(jsonObject.getInteger("algorithmWarnLevel")); |
| | | damAlarmRecordDetail.setAlgorithmWarnInfo(jsonObject.getString("algorithmWarnInfo")); |
| | | damAlarmRecordDetail.setAlgorithmWarnExplain(jsonObject.getString("algorithmWarnExplain")); |
| | | damAlarmRecordDetail.setCreateTime(new Date()); |
| | | // 加入集合 |
| | | list.add(damAlarmRecordDetail); |
| | | } |
| | | // 保存 |
| | | if (list.size()>0) { |
| | | flag = damAlarmRecordDetailService.saveBatch(list); |
| | | }else { |
| | | flag = true; |
| | | if (null!=detailInfo) { |
| | | List<DamAlarmRecordDetail> list = new ArrayList<>(); |
| | | for (int i = 0; i < detailInfo.size(); i++) { |
| | | DamAlarmRecordDetail damAlarmRecordDetail = new DamAlarmRecordDetail(); |
| | | JSONObject jsonObject = detailInfo.getJSONObject(i); |
| | | damAlarmRecordDetail.setDamAlarmRecordId(damAlarmRecord.getId()); |
| | | damAlarmRecordDetail.setAlgorithmName(jsonObject.getString("algorithmName")); |
| | | damAlarmRecordDetail.setAlgorithmWarnLevel(jsonObject.getInteger("algorithmWarnLevel")); |
| | | damAlarmRecordDetail.setAlgorithmWarnInfo(jsonObject.getString("algorithmWarnInfo")); |
| | | damAlarmRecordDetail.setAlgorithmWarnExplain(jsonObject.getString("algorithmWarnExplain")); |
| | | damAlarmRecordDetail.setCreateTime(new Date()); |
| | | // 加入集合 |
| | | list.add(damAlarmRecordDetail); |
| | | } |
| | | // 保存 |
| | | if (list.size() > 0) { |
| | | flag = damAlarmRecordDetailService.saveBatch(list); |
| | | } else { |
| | | flag = true; |
| | | } |
| | | } |
| | | return flag; |
| | | } |