Authored by wangshusheng

Merge branch 'dev' of http://git.yoho.cn/yoho30/yohobuy-rfid into dev

... ... @@ -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();
}
/**
... ...
package com.yoho.rfid.model;
import java.util.Map;
public class SkuResult {
private Map<String, Long> skuMap;
private long currentTime;
public Map<String, Long> getSkuMap() {
return skuMap;
}
public void setSkuMap(Map<String, Long> skuMap) {
this.skuMap = skuMap;
}
public long getCurrentTime() {
return currentTime;
}
public void setCurrentTime(long currentTime) {
this.currentTime = currentTime;
}
@Override
public String toString() {
return "SkuResult{" +
"skuMap=" + skuMap +
", currentTime=" + currentTime +
'}';
}
}
... ...
... ... @@ -129,7 +129,7 @@ public class RfidManager {
}
mRfidSetting.GPIO_Config = null;
mRfidSetting.Inventory_Time = 0;
mRfidSetting.Region_List = RegionList.CCC;
mRfidSetting.Region_List = RegionList.FCC;
if (SocketConstant.TYPE_RFID_UNACTIVE == type) {
mRfidSetting.RSSI_Filter = new RSSIFilter();
mRfidSetting.RSSI_Filter.Enable = false;
... ...
... ... @@ -17,7 +17,7 @@ public class SocketConstant {
/**
* 指定时间没有数据上报,则认为已经不属于该货架,不需要给前端返回数据 30分钟
*/
public static final int SKU_NOTBELONG_TIMEOUT = 30 * 60 * 1000;
public static final int SKU_NOTBELONG_TIMEOUT = 2 * 60 * 1000;
/**
* 正在生效的读写器列表
... ...
... ... @@ -4,7 +4,7 @@ is_debug_enable=true
# ******************** client servers ********************
# mac:ip:port:power(1:use, 0:no use, 30:capacity):speedMode(SPEED_FASTEST(0), SPEED_NORMAL(1), SPEED_POWERSAVE(2), SPEED_FULL_POWER(3))
rfid.client.address=00-00-00-00-00-00-00-E0:172.16.6.231:9761:1|0|0|0-30|0|0|0:0
rfid.client.address=00-00-00-00-00-00-00-E0:10.40.5.3:9761:1|1|1|1-30|30|30|30:0
zkAddress=192.168.102.45:2181
# web context
... ...
... ... @@ -4,9 +4,6 @@
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
... ...