LAPTOP-KB9HII50\70708 3 rokov pred
rodič
commit
d1dfd4b017

+ 11 - 1
common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java

@ -1427,6 +1427,16 @@ public class DateUtil {
        return result.toString();
    }
    /**
     * 1970年1月1日来的 秒转化成时间
     * @param seconds
     * @return
     */
    public static Date secondTransfor(int seconds){
        Calendar calendar = Calendar.getInstance();
        calendar.set(1970,Calendar.JANUARY,1,0,0,0);
        calendar.add(Calendar.SECOND,seconds);
        return calendar.getTime();
    }
}

+ 7 - 6
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/HvDeviceService.java

@ -235,7 +235,8 @@ public class HvDeviceService {
    }
    public static void main(String[] args) {
        String value = "01018B00000000000061444C7F0001921900FFBC00000070000000003839383630343334313832313830313337323531383637303730303336313331313231000000000034363030343534343733303732353100000000002235343030302E313030302E33352E30332E31332E30380000000000001300600001006100010062000000000001000079";
//        String value = "01018B00000000000061444C7F0001921900FFBC00000070000000003839383630343334313832313830313337323531383637303730303336313331313231000000000034363030343534343733303732353100000000002235343030302E313030302E33352E30332E31332E30380000000000001300600001006100010062000000000001000079";
        String value = "02018B000000000000614443850001921800FFBA00000070000000013839383630343334313832313830313337323531383637303730303336313331313231000000000034363030343534343733303732353100000000002235343030302E313030302E33352E30332E31332E30380000000000001300600001006100010064000000020001008700";
        String byMessageId = value.substring(0,2);//业务类型
        String byFixedSign = value.substring(2,4);
        String byDevType = value.substring(4,6);//设备类型
@ -252,18 +253,18 @@ public class HvDeviceService {
        String byIMEI20 = value.substring(96,136);
        String byIMSI20 = value.substring(136,176);
        String byNBModuleVersion24 = value.substring(176,224);
        String dwCID = value.substring(224,232);//32 基站码
        String dwLAC = value.substring(232,240);//32
        System.out.println(byTime);
        System.out.println(dwPackageNo);
        System.out.println(byQCCID20);
        System.out.println(byIMEI20);
        System.out.println(byIMSI20);
        System.out.println(byNBModuleVersion24);
        System.out.println(dwCID);
        System.out.println(dwLAC);
        //38 36 37 30 37 30 30 33 36 31 33 31 31 32 31 0000000000
        System.out.println(value.substring(240));
        System.out.println(Integer.parseInt("0087",16));
    }
}

+ 62 - 4
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/OnenetService.java

@ -22,6 +22,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.text.DecimalFormat;
import java.util.*;
/**
@ -100,7 +101,11 @@ public class OnenetService {
                wlyDateDel(categoryCode,msg);
            }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 byMessageId = value.substring(0,2);
        String byDevType = value.substring(4,6);
//        String byDevType = value.substring(4,6);
        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;
        }
        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注销 ...
    }
    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;
    }
    /**
     * 同步设备
     */