
/**
* 统计输入字符串(”1234“)
* 1 是回帖王1
* 2 是点赞王2
* 3 是跟风王3 根据帖子排序 copy tag1 data 回帖 or tag2 data 点赞
* 4 是潜水王 什么都不干
* 返回点赞数量和回帖数量
* @param inputArticleUserTypeTag
* @return
*/
public static int[] getRetGoodAndReplyStatistic(String inputArticleUserTypeTag) {
if (inputArticleUserTypeTag == null) {
return null
}
if (inputArticleUserTypeTag.isEmpty()) {
return null
}
String trim = inputArticleUserTypeTag.trim()
if (trim.isEmpty()) {
return null
}
String[] split = trim.split("\s")
if (split.length < 1) {
return null
}
int intVal=10
for (int i = 0
intVal*=5
}
if (split.length > intVal) {
return null
}
String testStrTagPattern="1234"
for (int i = 0
if (!testStrTagPattern.contains(split[i])) {
return null
}
}
HashMap<String, Integer> stringStringHashMap = new HashMap<>()
for (int i = 0
String tempArticleTyptTag=split[i].trim()
if (stringStringHashMap.containsKey(tempArticleTyptTag)) {
stringStringHashMap.put(tempArticleTyptTag,stringStringHashMap.get(tempArticleTyptTag)+1)
}else {
stringStringHashMap.put(tempArticleTyptTag,1)
}
}
ArrayList<RetGoodAndReplyStatistic> goodAndReplyStatisticArrayList = new ArrayList<>()
stringStringHashMap.forEach((k,v)->{
RetGoodAndReplyStatistic retGoodAndReplyStatistic = new RetGoodAndReplyStatistic()
retGoodAndReplyStatistic.setId(UUID.randomUUID().toString())
if (k.equals("2")){
retGoodAndReplyStatistic.setName(k+"good1_reply0")
retGoodAndReplyStatistic.setGoodTypeTag(k+"")
retGoodAndReplyStatistic.setReplyTypeTag("-")
retGoodAndReplyStatistic.setGoodTypeTagCount(v)
retGoodAndReplyStatistic.setReplyTypeTagCount(0)
} else if (k.equals("1")) {
retGoodAndReplyStatistic.setName(k+"good0_reply1")
retGoodAndReplyStatistic.setGoodTypeTag("-")
retGoodAndReplyStatistic.setReplyTypeTag(k+"-")
retGoodAndReplyStatistic.setGoodTypeTagCount(0)
retGoodAndReplyStatistic.setReplyTypeTagCount(v)
} else if (k.equals("3")) {
Collections.sort(goodAndReplyStatisticArrayList,new Comparator<RetGoodAndReplyStatistic>() {
@Override
public int compare(RetGoodAndReplyStatistic o1, RetGoodAndReplyStatistic o2) {
if (o1.getGoodTypeTag().equals("2") && o2.getGoodTypeTag().equals("2")) {
if (o1.getGoodTypeTagCount() > o2.getGoodTypeTagCount()) {
return 1
} else if (o1.getGoodTypeTagCount()<o2.getGoodTypeTagCount()) {
return -1
}
return 0
}else if (o1.getGoodTypeTag().equals("1") && o2.getGoodTypeTag().equals("1")) {
if (o1.getReplyTypeTagCount() > o2.getReplyTypeTagCount()) {
return 1
} else if (o1.getReplyTypeTagCount()<o1.getReplyTypeTagCount()) {
return -1
}
return 0
}
return 0
}
})
Collections.sort(goodAndReplyStatisticArrayList,new Comparator<RetGoodAndReplyStatistic>() {
@Override
public int compare(RetGoodAndReplyStatistic o1, RetGoodAndReplyStatistic o2) {
if (o1.getGoodTypeTag().equals("2") && o2.getGoodTypeTag().equals("2")) {
return 1
} else if (o1.getReplyTypeTag().equals(1)&&o2.getReplyTypeTag().equals(1)) {
return -1
}
return 0
}
})
RetGoodAndReplyStatistic retGoodAndReplyStatistic1 = goodAndReplyStatisticArrayList.get(0)
if (retGoodAndReplyStatistic1.getGoodTypeTag().equals("2")) {
retGoodAndReplyStatistic.setName(k+"good1_reply0")
retGoodAndReplyStatistic.setGoodTypeTag(k+"")
retGoodAndReplyStatistic.setReplyTypeTag("-")
retGoodAndReplyStatistic.setGoodTypeTagCount(v+1)
retGoodAndReplyStatistic.setReplyTypeTagCount(0)
}else if (retGoodAndReplyStatistic1.getReplyTypeTag().equals("1")) {
retGoodAndReplyStatistic.setName(k+"good0_reply1")
retGoodAndReplyStatistic.setGoodTypeTag("-")
retGoodAndReplyStatistic.setReplyTypeTag(k+"-")
retGoodAndReplyStatistic.setGoodTypeTagCount(0)
retGoodAndReplyStatistic.setReplyTypeTagCount(v+1)
}
}
})
RetGoodAndReplyStatistic retGoodAndReplyStatisticGood = goodAndReplyStatisticArrayList.get(0)
RetGoodAndReplyStatistic retGoodAndReplyStatisticReply = goodAndReplyStatisticArrayList.get(1)
int[] ints = new int[2]
ints[0] = retGoodAndReplyStatisticGood.getGoodTypeTagCount()
ints[1] = retGoodAndReplyStatisticGood.getReplyTypeTagCount()
return ints
}
class RetGoodAndReplyStatistic{
private String id
private String name
private String goodTypeTag
private String replyTypeTag
private Integer goodTypeTagCount
private Integer replyTypeTagCount
public String getId() {
return id
}
public void setId(String id) {
this.id = id
}
public String getName() {
return name
}
public void setName(String name) {
this.name = name
}
public String getGoodTypeTag() {
return goodTypeTag
}
public void setGoodTypeTag(String goodTypeTag) {
this.goodTypeTag = goodTypeTag
}
public String getReplyTypeTag() {
return replyTypeTag
}
public void setReplyTypeTag(String replyTypeTag) {
this.replyTypeTag = replyTypeTag
}
public Integer getGoodTypeTagCount() {
return goodTypeTagCount
}
public void setGoodTypeTagCount(Integer goodTypeTagCount) {
this.goodTypeTagCount = goodTypeTagCount
}
public Integer getReplyTypeTagCount() {
return replyTypeTagCount
}
public void setReplyTypeTagCount(Integer replyTypeTagCount) {
this.replyTypeTagCount = replyTypeTagCount
}
}