|
@@ -11,6 +11,7 @@ import com.github.pagehelper.PageInfo;
|
|
import com.thinkgem.jeesite.common.config.Global;
|
|
import com.thinkgem.jeesite.common.config.Global;
|
|
import com.thinkgem.jeesite.common.persistence.Page;
|
|
import com.thinkgem.jeesite.common.persistence.Page;
|
|
import com.thinkgem.jeesite.common.utils.DateUtils;
|
|
import com.thinkgem.jeesite.common.utils.DateUtils;
|
|
|
|
+import com.thinkgem.jeesite.common.utils.StringUtils;
|
|
import com.thinkgem.jeesite.common.utils.excel.ImportExcel;
|
|
import com.thinkgem.jeesite.common.utils.excel.ImportExcel;
|
|
import com.thinkgem.jeesite.common.web.BaseController;
|
|
import com.thinkgem.jeesite.common.web.BaseController;
|
|
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
|
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
|
@@ -131,6 +132,22 @@ public class KeywordFrequencyController extends BaseController {
|
|
return "0";
|
|
return "0";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 验证关键词库是该否存在关键词
|
|
|
|
+ * @param keywords
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping("/verificationKewords")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public String verificationKewords(String keywords,Model model){
|
|
|
|
+ boolean b = keywordFrequencyService.verificationKewords(keywords);
|
|
|
|
+ if(b){
|
|
|
|
+ return "-1";
|
|
|
|
+ }else{
|
|
|
|
+ return "0";
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
* 删除关键词
|
|
* 删除关键词
|
|
@@ -272,6 +289,10 @@ public class KeywordFrequencyController extends BaseController {
|
|
addMessage(redirectAttributes,"请选择需要导入的关键词文件");
|
|
addMessage(redirectAttributes,"请选择需要导入的关键词文件");
|
|
return "redirect:"+Global.getAdminPath()+"/product/keywordFrequency/getKeywordThesaurusInfo";
|
|
return "redirect:"+Global.getAdminPath()+"/product/keywordFrequency/getKeywordThesaurusInfo";
|
|
}
|
|
}
|
|
|
|
+ int sum=0;//总数量
|
|
|
|
+ int falseNum=0;//已存在数量
|
|
|
|
+ int successNum=0;
|
|
|
|
+ String falseKeys="";//已存在关键词
|
|
try {
|
|
try {
|
|
//根据路径获取这个操作excel的实例
|
|
//根据路径获取这个操作excel的实例
|
|
HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
|
|
HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
|
|
@@ -280,23 +301,44 @@ public class KeywordFrequencyController extends BaseController {
|
|
HSSFRow row = null;
|
|
HSSFRow row = null;
|
|
//循环sesheet页中数据从第二行开始,第一行是标题
|
|
//循环sesheet页中数据从第二行开始,第一行是标题
|
|
List<SearchFrequency> searchFrequencyList=new ArrayList<>();
|
|
List<SearchFrequency> searchFrequencyList=new ArrayList<>();
|
|
- for(int i=1;i<sheet.getPhysicalNumberOfRows()-1;i++){
|
|
|
|
|
|
+ sum=sheet.getPhysicalNumberOfRows()-1;
|
|
|
|
+ for(int i=1;i<=sheet.getPhysicalNumberOfRows()-1;i++){
|
|
row = sheet.getRow(i);
|
|
row = sheet.getRow(i);
|
|
SearchFrequency searchFrequency=new SearchFrequency();
|
|
SearchFrequency searchFrequency=new SearchFrequency();
|
|
|
|
+ //关键词
|
|
if(null !=row.getCell(1)){
|
|
if(null !=row.getCell(1)){
|
|
searchFrequency.setKeyword(row.getCell(1).toString());
|
|
searchFrequency.setKeyword(row.getCell(1).toString());
|
|
|
|
+ boolean b = keywordFrequencyService.verificationKeword(row.getCell(1).toString());
|
|
|
|
+ if(b){//判断关键词是否已存在
|
|
|
|
+ falseNum+=1;
|
|
|
|
+ if(StringUtils.isNotEmpty(falseKeys)){
|
|
|
|
+ falseKeys=falseKeys+","+row.getCell(1).toString();
|
|
|
|
+ }else{
|
|
|
|
+ falseKeys+=row.getCell(1).toString();
|
|
|
|
+ }
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
}else{
|
|
}else{
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- if(null != row.getCell(2)){
|
|
|
|
- if("首页搜索".equals(row.getCell(2).toString())){
|
|
|
|
- searchFrequency.setFromSearch(1);
|
|
|
|
- }else if("信息中心搜索".equals(row.getCell(2).toString())){
|
|
|
|
- searchFrequency.setFromSearch(2);
|
|
|
|
- }else if("管理员添加".equals(row.getCell(2).toString())){
|
|
|
|
- searchFrequency.setFromSearch(6);
|
|
|
|
- }
|
|
|
|
|
|
+ //联动次数
|
|
|
|
+ if(null !=row.getCell(2)){
|
|
|
|
+ String linkageFrequency= row.getCell(2).toString();
|
|
|
|
+ if(linkageFrequency.indexOf(".")>0){
|
|
|
|
+ linkageFrequency=linkageFrequency.replace(".","");
|
|
|
|
+ }
|
|
|
|
+ searchFrequency.setLinkageFrequency(Integer.valueOf(linkageFrequency));
|
|
}
|
|
}
|
|
|
|
+// if(null != row.getCell(2)){
|
|
|
|
+// if("首页搜索".equals(row.getCell(2).toString())){
|
|
|
|
+// searchFrequency.setFromSearch(1);
|
|
|
|
+// }else if("信息中心搜索".equals(row.getCell(2).toString())){
|
|
|
|
+// searchFrequency.setFromSearch(2);
|
|
|
|
+// }else if("管理员添加".equals(row.getCell(2).toString())){
|
|
|
|
+// searchFrequency.setFromSearch(6);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+ //添加时间
|
|
if(null != row.getCell(3)){
|
|
if(null != row.getCell(3)){
|
|
searchFrequency.setSearchTime(new java.sql.Timestamp(row.getCell(3).getDateCellValue().getTime()));
|
|
searchFrequency.setSearchTime(new java.sql.Timestamp(row.getCell(3).getDateCellValue().getTime()));
|
|
}
|
|
}
|
|
@@ -304,6 +346,7 @@ public class KeywordFrequencyController extends BaseController {
|
|
searchFrequency.setTrueStatus(1);
|
|
searchFrequency.setTrueStatus(1);
|
|
searchFrequencyList.add(searchFrequency);
|
|
searchFrequencyList.add(searchFrequency);
|
|
}
|
|
}
|
|
|
|
+ successNum=sum-falseNum;
|
|
//保存文件数据
|
|
//保存文件数据
|
|
keywordFrequencyService.importKeyword(searchFrequencyList);
|
|
keywordFrequencyService.importKeyword(searchFrequencyList);
|
|
//保存后重置关键词redis缓存
|
|
//保存后重置关键词redis缓存
|
|
@@ -312,7 +355,7 @@ public class KeywordFrequencyController extends BaseController {
|
|
} catch (IOException e) {//| ParseException
|
|
} catch (IOException e) {//| ParseException
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
- addMessage(redirectAttributes,"导入的关键词成功");
|
|
|
|
|
|
+ addMessage(redirectAttributes,"导入关键词成功:总数: "+sum+" 条 其中成功 " +successNum+" 条"+"; 关键词库已存在: "+falseNum+" 条( "+falseKeys+" )");
|
|
return "redirect:"+Global.getAdminPath()+"/product/keywordFrequency/getKeywordThesaurusInfo";
|
|
return "redirect:"+Global.getAdminPath()+"/product/keywordFrequency/getKeywordThesaurusInfo";
|
|
}
|
|
}
|
|
}
|
|
}
|