...
|
...
|
@@ -2,6 +2,7 @@ package com.yoho.rfid.controller; |
|
|
|
|
|
import JW.UHF.JWReader;
|
|
|
import com.yoho.rfid.model.RfidClient;
|
|
|
import com.yoho.rfid.model.SkuResult;
|
|
|
import com.yoho.rfid.service.RfidConfig;
|
|
|
import com.yoho.rfid.service.RfidInit;
|
|
|
import com.yoho.rfid.util.SocketConstant;
|
...
|
...
|
@@ -16,10 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping; |
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* RFID读写器接口
|
...
|
...
|
@@ -48,18 +46,29 @@ public class RfidController { |
|
|
if(null==skuMap){
|
|
|
return new ApiResponse.ApiResponseBuilder().code(200).message("query leave sku").data(null).build();
|
|
|
}
|
|
|
|
|
|
List<String> skuList = new ArrayList<String>();
|
|
|
for(Map.Entry<String, Long> entry : skuMap.entrySet()){
|
|
|
// sku离开时间 >1.5s <30min
|
|
|
if(System.currentTimeMillis()-entry.getValue() > SocketConstant.SKU_INVALID_TIMEOUT
|
|
|
&& System.currentTimeMillis()-entry.getValue() < SocketConstant.SKU_NOTBELONG_TIMEOUT){
|
|
|
skuList.add(entry.getKey());
|
|
|
long currentTime = System.currentTimeMillis();
|
|
|
// List<String> skuList = new ArrayList<String>();
|
|
|
// for(Map.Entry<String, Long> entry : skuMap.entrySet()){
|
|
|
// // sku离开时间 >1.5s <30min
|
|
|
// if(System.currentTimeMillis()-entry.getValue() < SocketConstant.SKU_NOTBELONG_TIMEOUT){
|
|
|
// skuList.add(entry.getKey());
|
|
|
// skuNewMap.put()
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
Iterator<Map.Entry<String, Long>> it = skuMap.entrySet().iterator();
|
|
|
while(it.hasNext()){
|
|
|
Map.Entry<String, Long> skuEntry=it.next();
|
|
|
if(currentTime-skuEntry.getValue() > SocketConstant.SKU_NOTBELONG_TIMEOUT){
|
|
|
it.remove();
|
|
|
}
|
|
|
}
|
|
|
logger.info("out RfidController.queryLeaveSku. ip is: {}, skuList is: {}, currentTime is:{}", ip, skuList, System.currentTimeMillis());
|
|
|
|
|
|
SkuResult skuResult = new SkuResult();
|
|
|
skuResult.setSkuMap(skuMap);
|
|
|
logger.info("out RfidController.queryLeaveSku. ip is: {}, skuResult is: {}, count is:{}", ip, skuResult, skuMap.size());
|
|
|
//组织返回
|
|
|
return new ApiResponse.ApiResponseBuilder().code(200).message("query leave sku").data(skuList).build();
|
|
|
return new ApiResponse.ApiResponseBuilder().code(200).message("query leave sku").data(skuResult).build();
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
|