|  |  | 
 |  |  | package com.moral.api.kafka.consumer; | 
 |  |  |  | 
 |  |  | import com.alibaba.fastjson.JSONObject; | 
 |  |  | import com.moral.api.service.*; | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  | import org.apache.kafka.clients.consumer.ConsumerRecord; | 
 |  |  | 
 |  |  | import org.springframework.stereotype.Component; | 
 |  |  | import org.springframework.util.ObjectUtils; | 
 |  |  |  | 
 |  |  | import java.text.DecimalFormat; | 
 |  |  | import java.text.SimpleDateFormat; | 
 |  |  | import java.util.Date; | 
 |  |  | import java.util.HashMap; | 
 |  |  | import java.util.Iterator; | 
 |  |  | import java.util.Map; | 
 |  |  | 
 |  |  |             //数据过滤 | 
 |  |  | //            data.remove("time"); | 
 |  |  |             data.remove("entryTime"); | 
 |  |  |             Map<String, Object> deviceByMac = deviceService.getDeviceByMac(mac.toString()); | 
 |  |  |             HashMap<String, Object> map = (HashMap<String, Object>) deviceByMac.get("organization"); | 
 |  |  |             String id = map.get("id").toString(); | 
 |  |  |             if (id.equals("71")){ | 
 |  |  |                 log.warn(id, msg); | 
 |  |  |                 ack.acknowledge(); | 
 |  |  |                 return; | 
 |  |  |             } | 
 |  |  | //            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 
 |  |  | //            String format = dateFormat.format(new Date().getTime()); | 
 |  |  | //            //获取年份 | 
 |  |  | //            String substring = format.substring(0, 4); | 
 |  |  | // | 
 |  |  | //            String substring1 = time.toString().substring(0, 4); | 
 |  |  | // | 
 |  |  | //            String replace = time.toString().replace(substring1, substring); | 
 |  |  | // | 
 |  |  | //            data.put("DataTime",replace); | 
 |  |  |  | 
 |  |  |             Iterator<Map.Entry<String, Object>> iterator = data.entrySet().iterator(); | 
 |  |  |             Map<String, Object> newMap = new HashMap<>(); | 
 |  |  |             Map.Entry<String, Object> next; |