| 
					
				 | 
			
			
				@ -1,8 +1,15 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				package com.yihu.jw.care.service.device; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.util.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.zhDevice.dao.ZhAlarmDealSyncDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.zhDevice.dao.ZhDataBatchSyncDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.zhDevice.dao.ZhDeviceSyncDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.zhDevice.entity.ZhAlarmDealSyncDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.zhDevice.entity.ZhDataBatchSyncDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.zhDevice.entity.ZhDeviceSyncDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.care.device.DeviceDataPushLog; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.BeanPropertyRowMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.JdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -18,8 +25,6 @@ import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				public class DeviceSyncService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private JdbcTemplate jdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -126,7 +131,7 @@ public class DeviceSyncService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            zhDeviceSyncDO.setLng(lng);//经 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            zhDeviceSyncDO.setState(1);  //1-新增/修改,-1-删除 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            zhDeviceSyncDO.setStatus(1);//0-离线,1-在线,3-停用(长期离线) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (1!=Integer.parseInt(deviceS.get("contact_status").toString())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (1 != Integer.parseInt(deviceS.get("contact_status").toString())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                zhDeviceSyncDO.setStatus(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                zhDeviceSyncDO.setDisabledType(4); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                zhDeviceSyncDO.setReason("长时间未连接网络获取最新状态!默认判定离线状态"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -143,7 +148,212 @@ public class DeviceSyncService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    ZhDataBatchSyncDao zhDataBatchSyncDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void dataBatchSync() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String date = DateUtil.getStringDateShort(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String startDate = date+" 00:00:00"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String endDate = date+" 23:59:59"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<ZhDataBatchSyncDO> result = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String devicePushLogSql = "select * from device_data_push_log where create_time = '" + startDate + "' and create_time <= '" + endDate + "' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<DeviceDataPushLog> deviceDataPushLogList = jdbcTemplate.query(devicePushLogSql, new BeanPropertyRowMapper<>(DeviceDataPushLog.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (DeviceDataPushLog deviceDataPushLog : deviceDataPushLogList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ZhDataBatchSyncDO zhDataBatchSyncDO =new ZhDataBatchSyncDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String deviceSN = deviceDataPushLog.getDeviceSn(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String, Object>> list = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            switch (Integer.parseInt(deviceDataPushLog.getDeviceCategory())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case 14:  //气感 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sql = "select * from base.base_security_monitoring_order where device_sn = '" + deviceSN + "' and topic_item ='preventGasLeakage' and create_time >= '"+startDate+"' and create_time <= '"+endDate+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setReporttime(deviceDataPushLog.getCreateTime().toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setDevicecode(deviceSN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (list.size()>0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setAlarmCode(list.get(0).get("id").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setMessagetype("2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setAlarmtype("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setAlarmlevel("4"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setName(list.get(0).get("serve_desc").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setMessagetype("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setName(deviceDataPushLog.getApiName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setDataType("2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setUpdateValue(deviceDataPushLog.getData()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    result.add(zhDataBatchSyncDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case 15:  //烟感 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sql = "select * from base.base_security_monitoring_order where device_sn = '" + deviceSN + "' and topic_item ='preventFire' and create_time >= '"+startDate+"' and create_time <= '"+endDate+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (list.size()>0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setAlarmCode(list.get(0).get("id").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setMessagetype("2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setAlarmtype("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setAlarmlevel("3"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setName(list.get(0).get("serve_desc").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setMessagetype("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setName(deviceDataPushLog.getApiName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setDataType("2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setUpdateValue(deviceDataPushLog.getData()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    result.add(zhDataBatchSyncDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case 12: //防跌倒 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sql = "select * from base.base_security_monitoring_order where device_sn = '" + deviceSN + "' and topic_item ='preventFire' and create_time >= '"+startDate+"' and create_time <= '"+endDate+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (list.size()>0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setAlarmCode(list.get(0).get("id").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setMessagetype("2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setAlarmtype("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setAlarmlevel("2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setName(list.get(0).get("serve_desc").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setMessagetype("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setName(deviceDataPushLog.getApiName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setDataType("2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setUpdateValue(deviceDataPushLog.getData()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    result.add(zhDataBatchSyncDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case 2:   //血压 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setMessagetype("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setReporttime(deviceDataPushLog.getCreateTime().toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setDataType("2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setDevicecode(deviceSN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setName("血压监测"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setUpdateValue(deviceDataPushLog.getData()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    result.add(zhDataBatchSyncDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case 1:   //血糖 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setMessagetype("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setReporttime(deviceDataPushLog.getCreateTime().toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setDataType("2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setDevicecode(deviceSN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setName("血糖检测"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setUpdateValue(deviceDataPushLog.getData()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    result.add(zhDataBatchSyncDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case 13:  //睡眠带 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sql = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case 16: //云芯防走失拐杖 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sql = "select * from base_security_monitoring_order where device_sn = '"+deviceSN+"' and topic_item ='preventLost' and create_time >= '"+startDate+"' and create_time ='"+endDate+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setDevicecode(deviceSN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setReporttime(DateUtil.dateToStrLong(deviceDataPushLog.getCreateTime())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (0<list.size()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setAlarmCode(list.get(0).get("id").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        //JSONObject gzObj = JSONObject.parseObject(JSON.toJSONString(list.get(0))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setMessagetype("2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setAlarmtype("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setAlarmlevel("4"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setName(list.get(0).get("serve_desc").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setMessagetype("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setName(deviceDataPushLog.getApiName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setDataType("2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setUpdateValue(deviceDataPushLog.getData()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    result.add(zhDataBatchSyncDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case 4: // 智能手表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setDevicecode(deviceSN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setReporttime(deviceDataPushLog.getCreateTime().toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setAlarmlevel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setMessagetype("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setName(deviceDataPushLog.getApiName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setDataType("2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setUpdateValue(deviceDataPushLog.getData()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    result.add(zhDataBatchSyncDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case 7: //SOS紧急呼叫器 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sql = "select * from base_emergency_assistance_order where device_sn = '"+deviceSN+"' and topic_item ='preventLost' and create_time >= '"+startDate+"' and create_time ='"+endDate+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setDevicecode(deviceSN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhDataBatchSyncDO.setReporttime(deviceDataPushLog.getCreateTime().toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (list.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setAlarmCode(list.get(0).get("id").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setMessagetype("2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setName("紧急呼叫"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setAlarmlevel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setAlarmtype("4"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setDataType("2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setUpdateValue(deviceDataPushLog.getData()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhDataBatchSyncDO.setMessagetype("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    result.add(zhDataBatchSyncDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                default: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        zhDataBatchSyncDao.save(result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    ZhAlarmDealSyncDao zhAlarmDealSyncDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void alarmDealSync() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String date = DateUtil.getStringDateShort(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String startDate = date + " 00:00:00"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String endDate = date + " 23:59:59"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<ZhAlarmDealSyncDO> result = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT id,status,complete_time,doctor_name,'杭州市拱墅区朝晖街道' AS org_name,serve_desc FROM base_security_monitoring_order WHERE create_time >= '"+startDate+"' AND create_time <= '"+endDate+"' AND device_sn IS NOT NULL \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "UNION \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "SELECT id,status,complete_time,doctor_name,org_name,'紧急预警' AS serve_desc FROM base_emergency_assistance_order WHERE create_time >= '"+startDate+"' AND create_time <= '"+endDate+"' AND device_sn IS NOT NULL"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (Map<String, Object> map : list) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ZhAlarmDealSyncDO zhAlarmDealSyncDO = new ZhAlarmDealSyncDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            zhAlarmDealSyncDO.setAlarmcode(map.get("id").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            zhAlarmDealSyncDO.setAlarmname("紧急预警"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            switch (Integer.parseInt(map.get("status").toString())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case 0:  //已完成      2 已完成 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhAlarmDealSyncDO.setAlarmstatus(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhAlarmDealSyncDO.setDealtime(map.get("complete_time").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhAlarmDealSyncDO.setHandler(map.get("doctor_name").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhAlarmDealSyncDO.setDept(map.get("org_name").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case 1:  //预警中      1 处理中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhAlarmDealSyncDO.setAlarmstatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                default:  //3 已关闭 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhAlarmDealSyncDO.setAlarmstatus(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhAlarmDealSyncDO.setHandler(map.get("doctor_name").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhAlarmDealSyncDO.setDealtime(map.get("update_time").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhAlarmDealSyncDO.setDept(map.get("org_name").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhAlarmDealSyncDO.setExplanation("误报警"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.add(zhAlarmDealSyncDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        zhAlarmDealSyncDao.save(result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |