Browse Source

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

chenweida 7 years ago
parent
commit
d5876a3b0f

+ 5 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/jkedu/repository/JkeduStatisticsArticleDao.java

@ -5,17 +5,17 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
public interface JkeduStatisticsArticleDao
		extends PagingAndSortingRepository<NewArticleStatisticsModel, Long>, JpaSpecificationExecutor<NewArticleStatisticsModel> {
	@Modifying
    @Modifying
	@Query("update NewArticleStatisticsModel s set s.shareNumber=?2,s.collectionNumber=?3," +
			"s.pushNumber=?4,s.browseNumber=?5 where s.articleId=?1")
	int modifyStatics(String articleId, int shareNumber,int collectionNumber,int pushNumber,int browseNumber);
	@Query("select s from NewArticleStatisticsModel s where s.articleId=?1")
	NewArticleStatisticsModel findByArticleId(String articleId);
}

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/archives/PatientArchiveInfoService.java

@ -42,7 +42,7 @@ public class PatientArchiveInfoService {
    /**
     * 查询建档记录列表
     * 查询建档记录列表.
     * @param doctorCode
     * @param signStatus
     * @param startTime
@ -66,7 +66,7 @@ public class PatientArchiveInfoService {
                " FROM " +
                " wlyy_archive a " +
                " LEFT JOIN dm_country c ON a.jw_zone_code = c.jw_code " +
                " LEFT JOIN wlyy_sign_family f ON a.identity_card_no = f.idcard"+
                " LEFT JOIN wlyy_sign_family f ON a.identity_card_no = f.idcard AND f.status >0 "+
                " WHERE " +
                " a.doctor_code ='"+doctorCode+"'";
        if (StringUtils.isNotBlank(signStatus)){

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

@ -18,6 +18,7 @@ import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorRoleDao;
import com.yihu.wlyy.repository.education.HealthEduArticleDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.common.account.RoleService;
import com.yihu.wlyy.service.third.jkEduArticle.ThirdJkEduArticleService;
import com.yihu.wlyy.util.DateUtil;
@ -42,7 +43,7 @@ import org.springframework.hateoas.alps.Doc;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.util.CollectionUtils;
import java.util.*;
@ -52,7 +53,7 @@ import java.util.stream.Collectors;
 * Created by zhangdan on 2017/12/25.
 */
@Service
@Transactional(rollbackFor = Exception.class)
@org.springframework.transaction.annotation.Transactional(transactionManager="jkehuTransactionManager")
public class EduArticleService {
    private Logger logger = LoggerFactory.getLogger(EduArticleService.class);
@ -1307,7 +1308,6 @@ public class EduArticleService {
                        push = Double.valueOf(String.valueOf(emap.get("sendCount"))).intValue();
                    }
                }
                //执行更新.
                int a = jkeduStatisticsArticleDao.modifyStatics(String.valueOf(map.get("code")),share,collection,push,share);
                result += a;
@ -1323,4 +1323,54 @@ public class EduArticleService {
        return  flag;
    }
    public boolean getArticleStatics2(){
        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);
            for (Map<String,Object> map : articleList){
                String articleId =String.valueOf(map.get("code"));
                NewArticleStatisticsModel newArticleStatisticsModel = jkeduStatisticsArticleDao.findByArticleId(articleId);
                //循环收藏人数
                for (Map<String,Object> cmap : collectList){
                    if (articleId.equals(cmap.get("article").toString())){
                        newArticleStatisticsModel.setCollectionNumber(Integer.valueOf(String.valueOf(cmap.get("collectNumber"))));
                    }
                }
                //循环1.阅读3.转发
                for (Map<String,Object> omap : opList){
                    if (articleId.equals(omap.get("code").toString())){
                        if ("3".equals(omap.get("status").toString())){
                            newArticleStatisticsModel.setShareNumber(Integer.valueOf(String.valueOf(omap.get("statusCount"))));
                            newArticleStatisticsModel.setBrowseNumber(Integer.valueOf(String.valueOf(omap.get("statusCount"))));
                        }
                    }
                }
                //循环发送数目
                for (Map<String,Object> emap : esList){
                    if (articleId.equals(emap.get("articleId").toString())){
                        newArticleStatisticsModel.setPushNumber(Double.valueOf(String.valueOf(emap.get("sendCount"))).intValue());
                    }
                }
                //执行更新.
                jkeduStatisticsArticleDao.save(newArticleStatisticsModel);
            }
        }catch (Exception e){
            e.printStackTrace();
            flag = false;
        }
        return  flag;
    }
}