Commit fe67d18c by Java - 段鹏举

通话记录同步过滤重复

parent 95104e86
......@@ -3,24 +3,6 @@
*/
package com.foc.sound.service;
import java.io.File;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.apache.commons.lang3.StringUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
......@@ -30,13 +12,19 @@ import com.foc.sound.entity.CallPhoneInfoListEntity;
import com.foc.sound.entity.CallRecordsEntity;
import com.foc.sound.entity.SoundRecordingEntity;
import com.foc.sound.entity.UserInfo;
import com.foc.util.DBHandler;
import com.foc.util.DBHelper;
import com.foc.util.IdWorker;
import com.foc.util.MapCounter;
import com.foc.util.Util;
import com.foc.util.PathFormatUtils;
import com.foc.util.WavToMp3;
import com.foc.util.*;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
*
......@@ -204,9 +192,9 @@ public class SoundService {
*
* @author zhanglg
* @time 2017年2月24日
* @param callNo
* @param acceptNo
* @param beginTime
* @param start
* @param end
* @param flag
* @return
*/
......@@ -409,9 +397,10 @@ public class SoundService {
*
* @author zhanglg
* @time 2017年2月27日
* @param result
* @param list
* @param end
* @param start
* @param flag
*/
public void insertData(List<SoundRecordingEntity> list, String start, String end, String flag) {
......@@ -545,6 +534,36 @@ public class SoundService {
String recordId = IdWorker.getNextId();
insertCallRECORDS(entity, callUser, recordId, flag);
insertCallPHONE(entity, acceptUser, recordId, flag, callUser.getName());
// 查询是否有重复记录(create_name,username,start_time)
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("SELECT id,\n" +
"\t create_by,\n" +
"\t create_name,\n" +
"\t create_phone,\n" +
"\t call_type,\n" +
"\t end_status,\n" +
"\t user_count,\n" +
"\t start_time,\n" +
"\t end_time\n");
String tableName = Constants.FOC_CALL_RECORDS;
if (GConstants.NO.equals(flag)) {
tableName = Constants.FOC_SOUND_RECORDS;
}
stringBuilder.append("FROM ").append(tableName).append("\n")
.append("WHERE end_status != 'INIT'\n")
.append("AND create_name = '").append(callUser.getName()).append("'\n")
.append("AND start_time <= '").append(entity.getEndTime()).append("'\n")
.append("AND id != '").append(recordId).append("'\n")
.append("ORDER BY start_time DESC");
List<Map<String, Object>> soundRecordsList = DBHelper.fetch("foc", stringBuilder.toString());
// 过滤掉了id,所以查出的数据就是重复的
if (soundRecordsList != null && soundRecordsList.size() > 0) {
for (Map<String, Object> map : soundRecordsList) {
// 将重复数据复制到备份表,并将原表数据删除
}
}
}
public UserInfo GetIdByPhone(String phone) {
......@@ -552,8 +571,9 @@ public class SoundService {
contents.put("phoneNumer", phone);
List<CallPhoneInfoListEntity> list = Util.arrayApi("/api/call/findPhoneInfo", contents, CallPhoneInfoListEntity.class);
if(list == null || list.size() == 0)
if (list == null || list.size() == 0) {
return null;
}
CallPhoneInfoListEntity info = list.get(0);
if(info != null && StringUtils.isNotEmpty(info.getName())){
if(StringUtils.isEmpty(info.getUserId())){
......@@ -680,16 +700,26 @@ public class SoundService {
}
private String getPhoneType(String phone) {
if (StringUtils.isEmpty(phone))// 未知
// 未知
if (StringUtils.isEmpty(phone)) {
return "UNKNOWN";
if (phone.startsWith("1") && phone.length() == 11)// 手机号
}
// 手机号
if (phone.startsWith("1") && phone.length() == 11) {
return "MOBILE";
if (phone.startsWith("01") && phone.length() == 12)// 手机号
}
// 手机号
if (phone.startsWith("01") && phone.length() == 12) {
return "MOBILE";
if (phone.startsWith("001") && phone.length() == 13)// 手机号
}
// 手机号
if (phone.startsWith("001") && phone.length() == 13) {
return "MOBILE";
if (phone.startsWith("6") && phone.length() == 4)// 华为短号
}
// 华为短号
if (phone.startsWith("6") && phone.length() == 4) {
return "HWNUBMER";
}
return "PHONE";// 座机
}
private String targetPath(String downloadUrl){
......
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