Commit 6ff8b6a8 authored by 赵建伟's avatar 赵建伟

update codes

parent c638a07c
......@@ -272,7 +272,7 @@ public class CtrPfrRctMysqlSink extends RichSinkFunction<CtrPfrRctBean> {
"second_solutions_pfr_recent3," +
"second_solutions_pfr_recent10," +
"pfr_recent10_queue_info," +
"last_update_time," +
"last_update_time" +
") values ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s'," +
"'%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",
deviceId,
......@@ -316,12 +316,16 @@ public class CtrPfrRctMysqlSink extends RichSinkFunction<CtrPfrRctBean> {
LinkedList<PfrRecentInfo> newQueue = new LinkedList<>();
Map<String,Integer> pfrMap = StringUtil.transString2Map(pfrStr);
for (PfrRecentInfo pfrRecentInfo : oldQueue) {
String pfrName = pfrRecentInfo.getPfrName();
Integer pfrCount = pfrRecentInfo.getPfrCount();
if(pfrMap.keySet().contains(pfrName)){
newQueue.add(new PfrRecentInfo(pfrName,pfrCount + 1 ,timeStr));
}else{
newQueue.add(pfrRecentInfo);
String sevenDaysAgoTimeStr = DateUtil.getSevenDaysAgoTimeStr(new Date());
String lastUpdateTime = pfrRecentInfo.getLastUpdateTime();
if(DateUtil.getTimestampByDateStr(lastUpdateTime) > DateUtil.getTimestampByDateStr(sevenDaysAgoTimeStr)){
String pfrName = pfrRecentInfo.getPfrName();
Integer pfrCount = pfrRecentInfo.getPfrCount();
if(pfrMap.keySet().contains(pfrName)){
newQueue.add(new PfrRecentInfo(pfrName,pfrCount + 1 ,timeStr));
}else{
newQueue.add(pfrRecentInfo);
}
}
}
while(newQueue.size() > queueSize){
......
......@@ -91,9 +91,15 @@ public class DateUtil {
* @return
* @throws ParseException
*/
public static Long getTimestampByDateStr(String dateStr) throws ParseException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_FORMATE_YMDHMS);
return simpleDateFormat.parse(dateStr).getTime();
public static Long getTimestampByDateStr(String dateStr) {
Long rs = 0L;
try{
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_FORMATE_YMDHMS);
rs = simpleDateFormat.parse(dateStr).getTime();
}catch (Exception e){
e.printStackTrace();
}
return rs;
}
/**
......
......@@ -49,7 +49,7 @@ public class StringUtil {
}
public static LinkedList<PfrRecentInfo> transString2PfrRecentInfoList(String str,String timeStr){
LinkedList<PfrRecentInfo> pfrRecentInfoList = null;
LinkedList<PfrRecentInfo> pfrRecentInfoList = new LinkedList<>();
String[] splits = str.split(",");
for (String split : splits) {
if(StringUtils.isNotBlank(split)){
......
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