Commit 0740d75a by caojingji

修改插入轨迹时使用多线程方法中的bug

parent d2d48682
...@@ -80,7 +80,7 @@ public class IphoneTrackServiceImpl implements IphoneTrackService { ...@@ -80,7 +80,7 @@ public class IphoneTrackServiceImpl implements IphoneTrackService {
List<String> sjhmTypes = Arrays.asList("20","4394","3996","6003"); //手机号码类别 List<String> sjhmTypes = Arrays.asList("20","4394","3996","6003"); //手机号码类别
String url = relationGetAll_url + "&objectValue="+obj; String url = relationGetAll_url + "&objectValue="+obj;
String result = HttpUtil.getWaData(url); String result = HttpUtil.getWaData(url);
//String result = "{children:[{children:[{children:[{children:[],objType:4315,objTypeName:\"IMEI\",objValue:\"865437021068398\"},{children:[],objType:4315,objTypeName:\"IMEI\",objValue:\"865437021068390\"}],objType:4314,objTypeName:\"IMSI\",objValue:\"460023869043189\"}],objType:20,objTypeName:\"联系方式\",objValue:\"15023614997\"},{children:[],objType:7888,objTypeName:\"摩托车黄色号牌\",objValue:\"渝B69914\"},{children:[],objType:7888,objTypeName:\"摩托车黄色号牌\",objValue:\"渝BY7803\"},{children:[{children:[{children:[],objType:4315,objTypeName:\"IMEI\",objValue:\"865437021068398\"},{children:[],objType:4315,objTypeName:\"IMEI\",objValue:\"865437021068390\"}],objType:4314,objTypeName:\"IMSI\",objValue:\"460023869043189\"}],objType:3996,objTypeName:\"手机号码\",objValue:\"15023614997\"},{children:[],objType:4394,objTypeName:\"电话号码\",objValue:\"1106265\"},{children:[{children:[{children:[],objType:4315,objTypeName:\"IMEI\",objValue:\"861150031416796\"},{children:[],objType:4315,objTypeName:\"IMEI\",objValue:\"863093030461690\"},{children:[],objType:4615,objTypeName:\"微信ID\",objValue:\"77545929\"},{children:[],objType:4315,objTypeName:\"IMEI\",objValue:\"863093030461694\"}],objType:4314,objTypeName:\"IMSI\",objValue:\"460003714894770\"}],objType:4394,objTypeName:\"电话号码\",objValue:\"13883114146\"},{children:[],objType:437,objTypeName:\"号牌号码\",objValue:\"渝BY7803\"},{children:[],objType:7888,objTypeName:\"摩托车黄色号牌\",objValue:\"渝BEN020\"},{children:[],objType:20,objTypeName:\"联系方式\",objValue:\"1106265\"},{children:[],objType:20,objTypeName:\"联系方式\",objValue:\"1388311416\"},{children:[],objType:437,objTypeName:\"号牌号码\",objValue:\"渝BEN020\"},{children:[{children:[{children:[],objType:4315,objTypeName:\"IMEI\",objValue:\"865437021068398\"},{children:[],objType:4315,objTypeName:\"IMEI\",objValue:\"865437021068390\"}],objType:4314,objTypeName:\"IMSI\",objValue:\"460023869043189\"}],objType:4394,objTypeName:\"电话号码\",objValue:\"15023614997\"},{children:[{children:[{children:[],objType:4315,objTypeName:\"IMEI\",objValue:\"861150031416796\"},{children:[],objType:4315,objTypeName:\"IMEI\",objValue:\"863093030461690\"},{children:[],objType:4615,objTypeName:\"微信ID\",objValue:\"77545929\"},{children:[],objType:4315,objTypeName:\"IMEI\",objValue:\"863093030461694\"}],objType:4314,objTypeName:\"IMSI\",objValue:\"460003714894770\"}],objType:3996,objTypeName:\"手机号码\",objValue:\"13883114146\"},{children:[],objType:437,objTypeName:\"号牌号码\",objValue:\"渝B69914\"}],objType:1,objTypeName:\"身份证号码\",objValue:\"510224197106221113\"}"; //String result = "{children:[{children:[{children:[],objType:4315,objTypeName:\"IMEI\",objValue:\"861150031416796\"},{children:[],objType:4315,objTypeName:\"IMEI\",objValue:\"863093030461690\"},{children:[],objType:4615,objTypeName:\"微信ID\",objValue:\"77545929\"},{children:[],objType:4315,objTypeName:\"IMEI\",objValue:\"863093030461694\"}],objType:4314,objTypeName:\"IMSI\",objValue:\"460003714894770\"}],objType:4394,objTypeName:\"电话号码\",objValue:\"13883114146\"}";
if(null != result && result.startsWith("{")){ if(null != result && result.startsWith("{")){
jsonObejct = JSONObject.parseObject(result); jsonObejct = JSONObject.parseObject(result);
} }
...@@ -151,15 +151,37 @@ public class IphoneTrackServiceImpl implements IphoneTrackService { ...@@ -151,15 +151,37 @@ public class IphoneTrackServiceImpl implements IphoneTrackService {
List<JSONObject> qqhms = new ArrayList<JSONObject>(); List<JSONObject> qqhms = new ArrayList<JSONObject>();
List<JSONObject> imeis = new ArrayList<JSONObject>(); List<JSONObject> imeis = new ArrayList<JSONObject>();
List<JSONObject> imsis = new ArrayList<JSONObject>(); List<JSONObject> imsis = new ArrayList<JSONObject>();
if(array != null && !array.isEmpty()){
//1.这里多线程处理 chent //1.这里多线程处理 chent
int limit = 120;//批处理量 for(int i = 0;i < array.size(); i++){
int size = array.size(); JSONObject o2 = array.getJSONObject(i);
long threadNum = size / limit; if(o2 != null){
for (int i = 0; i < threadNum + 1; i++) { if("4314".equals(o2.getString("objType"))){
HandleThreadSjhmsList thread = new HandleThreadSjhmsList(array, i * limit, ((i + 1) * limit),object); JSONArray a = o2.getJSONArray("children");
thread.start(); if(a != null && !a.isEmpty()){
for (int j = 0;j < a.size(); j++){
JSONObject o1 = a.getJSONObject(j);
o1.remove("children"); //删除o1对象中的children子项
if(o1.getString("objType").equals("4615")){ //梳理添加微信号码
wxhms.add(o1);
}else if(o1.getString("objType").equals("558")){ //梳理添加QQ号码
qqhms.add(o1);
}else if(o1.getString("objType").equals("4315")){ //梳理添加IMEI号码
imeis.add(o1);
}
} }
} }
o2.remove("children");
imsis.add(o2);
}
}
}
}
object.put("wxhms",removeJSonObject(wxhms));
object.put("qqhms",removeJSonObject(qqhms));
object.put("imeis",removeJSonObject(imeis));
object.put("imsis",removeJSonObject(imsis));
}
return object; return object;
} }
/** /**
...@@ -263,69 +285,6 @@ public class IphoneTrackServiceImpl implements IphoneTrackService { ...@@ -263,69 +285,6 @@ public class IphoneTrackServiceImpl implements IphoneTrackService {
} }
} }
/**
* 多线程批处理(getSjhmsList)
* by changchao
*/
class HandleThreadSjhmsList extends Thread {
private JSONArray data;
private int start;
private int end;
private JSONObject object;
public HandleThreadSjhmsList(JSONArray data, int start, int end, JSONObject object) {
this.data = data;
this.start = start;
this.end = end;
this.object=object;
}
public void run() {
if (start > data.size()) {
return;
}
if (end > data.size()) {
end = data.size();
}
//begin
JSONArray array = subArray(data, start, end);
List<JSONObject> wxhms = new ArrayList<JSONObject>();
List<JSONObject> qqhms = new ArrayList<JSONObject>();
List<JSONObject> imeis = new ArrayList<JSONObject>();
List<JSONObject> imsis = new ArrayList<JSONObject>();
if(array != null && !array.isEmpty()){
//1.这里多线程处理 chent
for(int i = 0;i < array.size(); i++){
JSONObject o2 = array.getJSONObject(i);
if(o2 != null){
if("4314".equals(o2.getString("objType"))){
JSONArray a = o2.getJSONArray("children");
if(a != null && !a.isEmpty()){
for (int j = 0;j < a.size(); j++){
JSONObject o1 = a.getJSONObject(j);
o1.remove("children"); //删除o1对象中的children子项
if(o1.getString("objType").equals("4615")){ //梳理添加微信号码
wxhms.add(o1);
}else if(o1.getString("objType").equals("558")){ //梳理添加QQ号码
qqhms.add(o1);
}else if(o1.getString("objType").equals("4315")){ //梳理添加IMEI号码
imeis.add(o1);
}
}
}
o2.remove("children");
imsis.add(o2);
}
}
}
}
object.put("wxhms",removeJSonObject(wxhms));
object.put("qqhms",removeJSonObject(qqhms));
object.put("imeis",removeJSonObject(imeis));
object.put("imsis",removeJSonObject(imsis));
// end
}
}
//JSONArray 实现截取 //JSONArray 实现截取
private static JSONArray subArray(JSONArray array, int start, int end){ private static JSONArray subArray(JSONArray array, int start, int end){
...@@ -339,7 +298,6 @@ public class IphoneTrackServiceImpl implements IphoneTrackService { ...@@ -339,7 +298,6 @@ public class IphoneTrackServiceImpl implements IphoneTrackService {
return result; return result;
} }
/** /**
* 多线程批处理(saveObjectRelationLocal) * 多线程批处理(saveObjectRelationLocal)
* by changchao * by changchao
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment