|  | @ -22,6 +22,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
 | 
												
													
														
															|  | import org.springframework.scheduling.annotation.Async;
 |  | import org.springframework.scheduling.annotation.Async;
 | 
												
													
														
															|  | import org.springframework.stereotype.Service;
 |  | import org.springframework.stereotype.Service;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | import java.text.DecimalFormat;
 | 
												
													
														
															|  | import java.util.*;
 |  | import java.util.*;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | /**
 |  | /**
 | 
												
											
												
													
														
															|  | @ -100,7 +101,11 @@ public class OnenetService {
 | 
												
													
														
															|  |                 wlyDateDel(categoryCode,msg);
 |  |                 wlyDateDel(categoryCode,msg);
 | 
												
													
														
															|  |             }else if("2".equals(onenetDevice.getDeviceType())){
 |  |             }else if("2".equals(onenetDevice.getDeviceType())){
 | 
												
													
														
															|  |                 //海康设备
 |  |                 //海康设备
 | 
												
													
														
															|  | 
 |  |                 if("14".equals(onenetDevice.getCategoryCode())){
 | 
												
													
														
															|  | 
 |  |                     hkDeviceQi(onenetDevice,jsonObject);
 | 
												
													
														
															|  | 
 |  |                 }else if("15".equals(onenetDevice.getCategoryCode())){
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |                 }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |             }
 |  |             }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
											
												
													
														
															|  | @ -153,25 +158,78 @@ public class OnenetService {
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     /**
 |  |     /**
 | 
												
													
														
															|  |      * 海康设备解析
 |  | 
 | 
												
													
														
															|  | 
 |  |      * 海康设备解析-气感
 | 
												
													
														
															|  |      */
 |  |      */
 | 
												
													
														
															|  |     public void hkDevice(OnenetDevice onenetDevice,JSONObject jsonObject){
 |  | 
 | 
												
													
														
															|  | 
 |  |     public void hkDeviceQi(OnenetDevice onenetDevice,JSONObject jsonObject){
 | 
												
													
														
															|  |         String value = jsonObject.getString("value");
 |  |         String value = jsonObject.getString("value");
 | 
												
													
														
															|  |         String byMessageId = value.substring(0,2);
 |  |         String byMessageId = value.substring(0,2);
 | 
												
													
														
															|  |         String byDevType = value.substring(4,6);
 |  | 
 | 
												
													
														
															|  | 
 |  | //        String byDevType = value.substring(4,6);
 | 
												
													
														
															|  |         if("01".equals(byMessageId)){
 |  |         if("01".equals(byMessageId)){
 | 
												
													
														
															|  |             //信息上报
 |  |             //信息上报
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |             String valueTmp = value.substring(236);
 | 
												
													
														
															|  | 
 |  |             //0060 0001 0061 0001 0062 0000 0000 0001 0000 79
 | 
												
													
														
															|  | 
 |  |             String wChanRscType = valueTmp.substring(0,4);
 | 
												
													
														
															|  | 
 |  |             String num = valueTmp.substring(4,8);
 | 
												
													
														
															|  | 
 |  |             String wEventType = valueTmp.substring(16,20);
 | 
												
													
														
															|  | 
 |  |             String wParamType = valueTmp.substring(32,36);
 | 
												
													
														
															|  | 
 |  |             String wParamValue = valueTmp.substring(36,40);
 | 
												
													
														
															|  | 
 |  |             if("0062".equals(wEventType)&&"0001".equals(wParamType)){
 | 
												
													
														
															|  | 
 |  |                 String byTime = value.substring(18,26);//时间 秒
 | 
												
													
														
															|  | 
 |  |                 String time = DateUtil.dateToStrLong(DateUtil.secondTransfor(Integer.parseInt(byTime)));
 | 
												
													
														
															|  | 
 |  |                 //气感浓度
 | 
												
													
														
															|  | 
 |  |                 String monitorValue = division(Integer.valueOf(wParamValue),10);
 | 
												
													
														
															|  | 
 |  |                 String resourceSerial = onenetDevice.getSn();
 | 
												
													
														
															|  | 
 |  |                 DeviceHealthIndex index = new DeviceHealthIndex();
 | 
												
													
														
															|  | 
 |  |                 index.setDeviceSn(resourceSerial);
 | 
												
													
														
															|  | 
 |  |                 index.setUnit("%LEL");
 | 
												
													
														
															|  | 
 |  |                 index.setValue(monitorValue);
 | 
												
													
														
															|  | 
 |  |                 index.setRecordTime(time);
 | 
												
													
														
															|  | 
 |  |                 //独立式可燃气体探测器(NB)
 | 
												
													
														
															|  | 
 |  |                 index.setDeviceType("1");
 | 
												
													
														
															|  | 
 |  |                 deviceHealthIndexDao.save(index);
 | 
												
													
														
															|  | 
 |  |                 dataPushLogUtil.savePushLog(resourceSerial,jsonObject.toJSONString(jsonObject,SerializerFeature.WriteMapNullValue),"可燃气体探测器监测信息接收");
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  |             return;
 |  |             return;
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         if("02".equals(byMessageId)){
 |  |         if("02".equals(byMessageId)){
 | 
												
													
														
															|  |             //报警
 |  |             //报警
 | 
												
													
														
															|  | 
 |  | //            String byTime = value.substring(18,26);//时间 秒
 | 
												
													
														
															|  | 
 |  | //            String time = DateUtil.dateToStrLong(DateUtil.secondTransfor(Integer.parseInt(byTime)));
 | 
												
													
														
															|  | 
 |  |             String valueTmp = value.substring(236);
 | 
												
													
														
															|  | 
 |  |             //0060 0001 0061 0001 0064 0000 0002 0001 0087 00
 | 
												
													
														
															|  | 
 |  |             String wChanRscType = valueTmp.substring(0,4);
 | 
												
													
														
															|  | 
 |  |             String num = valueTmp.substring(4,8);
 | 
												
													
														
															|  | 
 |  |             String wEventType = valueTmp.substring(16,20);
 | 
												
													
														
															|  | 
 |  |             String wEventValue = valueTmp.substring(28,32);
 | 
												
													
														
															|  | 
 |  |             String wParamType = valueTmp.substring(32,36);
 | 
												
													
														
															|  | 
 |  |             String wParamValue = valueTmp.substring(36,40);
 | 
												
													
														
															|  | 
 |  |             if("0064".equals(wEventType)&&"0002".equals(wEventValue)){
 | 
												
													
														
															|  | 
 |  |                 //气感报警
 | 
												
													
														
															|  | 
 |  |                 if("0001".equals(wParamType)){
 | 
												
													
														
															|  | 
 |  |                     //气感浓度
 | 
												
													
														
															|  | 
 |  |                     String monitorValue = division(Integer.valueOf(wParamValue),10);
 | 
												
													
														
															|  | 
 |  |                     String resourceSerial = onenetDevice.getSn();
 | 
												
													
														
															|  | 
 |  |                     JSONObject tmp = new JSONObject();
 | 
												
													
														
															|  | 
 |  |                     tmp.put("gas",monitorValue);
 | 
												
													
														
															|  | 
 |  |                     orderUtil.createSecurityOrder(resourceSerial,null,new JSONObject(),null,6,"11","preventGasLeakage",JSON.toJSONString(tmp, SerializerFeature.WriteMapNullValue));
 | 
												
													
														
															|  | 
 |  |                     dataPushLogUtil.savePushLog(resourceSerial,jsonObject.toJSONString(jsonObject,SerializerFeature.WriteMapNullValue),"可燃气体探测器报警信息接收");
 | 
												
													
														
															|  | 
 |  |                 }
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         //其他信息暂时不处理
 |  |         //其他信息暂时不处理
 | 
												
													
														
															|  |         // 03消音 04自检 05故障 06信号查询 07注册 08注销 ...
 |  |         // 03消音 04自检 05故障 06信号查询 07注册 08注销 ...
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     public String division(int a,int b){
 | 
												
													
														
															|  | 
 |  |         String result = "";
 | 
												
													
														
															|  | 
 |  |         float num =(float)a/b;
 | 
												
													
														
															|  | 
 |  |         DecimalFormat df = new DecimalFormat("0.0");
 | 
												
													
														
															|  | 
 |  |         result = df.format(num);
 | 
												
													
														
															|  | 
 |  |         return result;
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     /**
 |  |     /**
 | 
												
													
														
															|  |      * 同步设备
 |  |      * 同步设备
 | 
												
													
														
															|  |      */
 |  |      */
 |