浏览代码

Merge branch 'dev' of zd_123/patient-co-management into dev

chenweida 7 年之前
父节点
当前提交
40deb7be49

+ 5 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandlingController.java

@ -201,12 +201,12 @@ public class DataHandlingController extends BaseController {
    @ResponseBody
    @ApiOperation("将旧数据文章的相关统计数据转移到新数据库")
    public String getArticleStatics(){
        try{
            eduArticleService.getArticleStatics();
        boolean flag = eduArticleService.getArticleStatics();
        if (flag){
            return write(200, "数据更新成功!");
        }catch (Exception e){
            e.printStackTrace();
            return write(200, "数据更新失败!"+e.getMessage());
        }else {
            return write(200, "数据更新失败!");
        }
    }

+ 52 - 37
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkedu/service/EduArticleService.java

@ -1265,50 +1265,65 @@ public class EduArticleService {
        return resultMap;
    }
    public void getArticleStatics()throws Exception{
        thirdJkEduArticleService.insertArticleStatistic();
        String articleSql = "SELECT code FROM wlyy_health_edu_article GROUP BY code";
        String collectSql ="SELECT article,COUNT(*) AS collectNumber FROM wlyy_health_edu_article_doctor GROUP BY article";
        String ophistorySql ="SELECT code,status,COUNT(*) AS statusCount FROM wlyy_health_edu_article_op_history GROUP BY code,status";
        String esSql = "SELECT articleId,count(*) as sendCount FROM "+esIndex+" where userType=1 group by articleId";
        List<Map<String,Object>> articleList = jdbcTemplate.queryForList(articleSql);
        List<Map<String,Object>> collectList = jdbcTemplate.queryForList(collectSql);
        List<Map<String,Object>> opList = jdbcTemplate.queryForList(ophistorySql);
        List<Map<String, Object>> esList = elasticsearchUtil.excuteDataModel(esSql);
        for (Map<String,Object> map : articleList){
            int collection = 0;
            int share = 0;
            int push = 0;
            map.put("collection",0);
            map.put("share",0);
            map.put("push",0);
            //循环收藏人数
            for (Map<String,Object> cmap : collectList){
                if (map.get("code").toString().equals(cmap.get("article").toString())){
                    collection = Integer.valueOf(String.valueOf(cmap.get("collectNumber")));
    public boolean getArticleStatics(){
        int result = 0;
        int articleSize = 0;
        boolean flag = true;
        try {
            thirdJkEduArticleService.insertArticleStatistic();
            String articleSql = "SELECT code FROM wlyy_health_edu_article GROUP BY code";
            String collectSql ="SELECT article,COUNT(*) AS collectNumber FROM wlyy_health_edu_article_doctor GROUP BY article";
            String ophistorySql ="SELECT code,status,COUNT(*) AS statusCount FROM wlyy_health_edu_article_op_history GROUP BY code,status";
            String esSql = "SELECT articleId,count(*) as sendCount FROM "+esIndex+" where userType=1 group by articleId";
            List<Map<String,Object>> articleList = jdbcTemplate.queryForList(articleSql);
            List<Map<String,Object>> collectList = jdbcTemplate.queryForList(collectSql);
            List<Map<String,Object>> opList = jdbcTemplate.queryForList(ophistorySql);
            List<Map<String, Object>> esList = elasticsearchUtil.excuteDataModel(esSql);
            articleSize = articleList.size();
            for (Map<String,Object> map : articleList){
                int collection = 0;
                int share = 0;
                int push = 0;
                map.put("collection",0);
                map.put("share",0);
                map.put("push",0);
                //循环收藏人数
                for (Map<String,Object> cmap : collectList){
                    if (map.get("code").toString().equals(cmap.get("article").toString())){
                        collection = Integer.valueOf(String.valueOf(cmap.get("collectNumber")));
                    }
                }
            }
            //循环1.阅读3.转发
            for (Map<String,Object> omap : opList){
                if (map.get("code").toString().equals(omap.get("code").toString())){
                    if ("3".equals(omap.get("status").toString())){
                        share = Integer.valueOf(String.valueOf(omap.get("statusCount")));
                //循环1.阅读3.转发
                for (Map<String,Object> omap : opList){
                    if (map.get("code").toString().equals(omap.get("code").toString())){
                        if ("3".equals(omap.get("status").toString())){
                            share = Integer.valueOf(String.valueOf(omap.get("statusCount")));
                        }
                    }
                }
            }
            //循环发送数目
            for (Map<String,Object> emap : esList){
                if (map.get("code").toString().equals(emap.get("articleId").toString())){
                    push = Integer.valueOf(String.valueOf(emap.get("sendCount")));
                //循环发送数目
                for (Map<String,Object> emap : esList){
                    if (map.get("code").toString().equals(emap.get("articleId").toString())){
                        push = Double.valueOf(String.valueOf(emap.get("sendCount"))).intValue();
                    }
                }
            }
            //执行更新.
            jkeduStatisticsArticleDao.modifyStatics(String.valueOf(map.get("code")),share,collection,push);
                //执行更新.
                int a = jkeduStatisticsArticleDao.modifyStatics(String.valueOf(map.get("code")),share,collection,push);
                result += a;
            }
        }catch (Exception e){
            e.printStackTrace();
            flag = false;
        }finally {
            if (result<articleSize){
                flag = false;
            }
        }
        return  flag;
    }
}