浏览代码

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

liuwenbin 7 年之前
父节点
当前提交
3dca6c69da

+ 8 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java

@ -378,8 +378,14 @@ public class StatisticsESService {
        }
        Collections.sort(resultList, new Comparator<Map<String, Object>>() {
            public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                long map1value = (long) o1.get("amount");
                long map2value = (long) o2.get("amount");
                long map1value = 0L;
                long map2value = 0L;
                if(o1.get("amount")!=null && o1.get("amount")+""!=""){
                     map1value = Long.valueOf(String.valueOf(o1.get("amount")));
                }
                if(o2.get("amount")!=null && o2.get("amount")+""!=""){
                    map2value = Long.valueOf(String.valueOf(o2.get("amount")));
                }
                if (map1value - map2value > 0) {
                    return sort == 1 ? -1 : 1;

+ 38 - 13
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/FileUploadController.java

@ -541,20 +541,45 @@ public class FileUploadController extends BaseController {
    @ApiOperation("编辑文章上传图片")
    @ResponseBody
    public String pushArticleList(@ApiParam(name = "file", value = "文件", required = true)
                                  @RequestParam(value = "file", required = true) MultipartFile file){
        try {
            InputStream inputStream  = file.getInputStream();
            String fileName = file.getOriginalFilename().substring(0,file.getOriginalFilename().lastIndexOf("."));
            ObjectNode imgNode = FastDFSUtil.upload(inputStream,"png",fileName);
            String fileUrl = imgNode.get("groupName").toString().replaceAll("\"","")
                    + "/" + imgNode.get("remoteFileName").toString().replaceAll("\"","");
            if(!isneiwang){
                fileUrl=fastdfs_file_url+fileUrl;
                                  @RequestParam(value = "file", required = true) MultipartFile file,
                                  HttpServletRequest request, HttpServletResponse response){
        if (isneiwang) {
            // 圖片列表
            List<String> tempPaths = new ArrayList<String>();
            try {
                MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
                Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
                for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
                    // 上传文件
                    MultipartFile mf = entity.getValue();
                    InputStream inputStream  = mf.getInputStream();
                    String fileName = mf.getOriginalFilename().substring(0,mf.getOriginalFilename().lastIndexOf("."));
                    ObjectNode imgNode = FastDFSUtil.upload(inputStream,"png",fileName);
                    com.alibaba.fastjson.JSONObject json = com.alibaba.fastjson.JSONObject.parseObject(imgNode.toString());
                    tempPaths.add(json.getString("fid"));
                }
                String urls = "";
                for (String image : tempPaths) {
                    if (urls.length() == 0) {
                        urls = image;
                    } else {
                        urls += "," + image;
                    }
                }
                JSONObject json = new JSONObject();
                json.put("status", 200);
                json.put("msg", "上传成功");
                json.put("urls", urls);
                logger.info("图片上传:" + json.toString());
                return json.toString();
            } catch (Exception e) {
                error(e);
                return error(-1, "上传失败");
            }
            return write(200,"上传成功!","data",fileUrl);
        }catch (Exception e) {
            e.printStackTrace();
            return error(-1,"失败!");
        } else {
            String result  = CommonUtil.toNeiWang(request, response);
            logger.info("fastDFSImag reslt :" + result);
            return CommonUtil.toNeiWang(request, response);
        }
    }

+ 3 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java

@ -273,12 +273,13 @@ public class EsStatisticsController extends BaseController {
            /**旧版统计代码start**/
            //未回复-22 到达量
            JSONArray jsonArray2 = null;
            if (DateUtil.getYear(endDate, "yyyy-MM-dd").equals(year)) {
            /*if (DateUtil.getYear(endDate, "yyyy-MM-dd").equals(year)) {
                jsonArray2 = statisticsESService.getLowLevelIncrementDetail(endDate, endDate, area, level, indexes[1], sort, lowLevel);
            } else {
                String date = Integer.valueOf(year) + 1 + "-06-30";
                jsonArray2 = statisticsESService.getLowLevelIncrementDetail(date, date, area, level, indexes[1], sort, lowLevel);
            }
            }*/
            jsonArray2 = statisticsESService.getLowLevelIncrementDetail(endDate, endDate, area, level, indexes[1], sort, lowLevel);
            jsonArrays.add(jsonArray2);
            /**旧版统计代码end**/

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

@ -4,6 +4,7 @@ package com.yihu.wlyy.web.third.jkedu.service;
import com.yihu.edu.entity.dataClean.*;
import com.yihu.es.entity.HealthEduArticleES;
import com.yihu.es.entity.HealthEduArticleESResult;
import com.yihu.wlyy.config.es.ElasticFactory;
import com.yihu.wlyy.config.es.ElastricSearchSave;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
@ -21,9 +22,16 @@ import com.yihu.wlyy.util.ElasticsearchUtil;
import com.yihu.wlyy.util.MapListUtils;
import com.yihu.wlyy.util.SpringUtil;
import com.yihu.wlyy.web.third.jkedu.vo.save.SaveEduArticleHelper;
import io.searchbox.client.JestClient;
import io.searchbox.core.*;
import org.apache.axis.utils.Admin;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -41,6 +49,8 @@ import java.util.*;
@Service
@Transactional(rollbackFor = Exception.class)
public class EduArticleService {
    private Logger logger = LoggerFactory.getLogger(EduArticleService.class);
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
@ -59,6 +69,8 @@ public class EduArticleService {
    private JkeduBehaviorArticleDao jkeduBehaviorArticleDao;
    @Autowired
    private ElasticsearchUtil elasticsearchUtil;
    @Autowired
    private ElasticFactory elasticFactory;
    @Value("${es.type.HealthEduArticlePatient}")
    private String esType;
@ -103,7 +115,6 @@ public class EduArticleService {
                            NewArticleModel newArticleModel = new NewArticleModel();
                            //转换数据
                            oldArticleModel = MapListUtils.convertMap2Bean(map,OldArticleModel.class);
                            //@// TODO: 2017/12/25 完善数据
                            BeanUtils.copyProperties(oldArticleModel,newArticleModel);
                            newArticleModel.setArticleOrder(99);
                            newArticleModel.setArticleState(1);
@ -117,8 +128,8 @@ public class EduArticleService {
                            newArticleModel.setAuthenticationId(wjwCode);
                            newArticleModel.setIsAuthentication(1);
                            newArticleModel.setArticleType("2");
                            newArticleModel.setOperatorRoleCode("管理员code");
                            newArticleModel.setOperatorRoleLevel("管理员");
                            newArticleModel.setOperatorRoleCode("350200");
                            newArticleModel.setOperatorRoleLevel("2");
                            newArticleModel.setRoleType(2);
                            newArticleModel.setUserScope(1);
                            newArticleModel.setIsOld(1);
@ -305,7 +316,7 @@ public class EduArticleService {
                    articleMap.put(healthEduArticle.getCode(),healthEduArticle);
                }
            }
            //获取所有的健康教育发送记录数量,分页
            //获取所有的健康教育发送记录数量,分页,userType=1
            String countSql = "SELECT COUNT(id) AS num from wlyy_health_edu_article_patient WHERE admin_team_code IS NOT NULL";
            if (StringUtils.isNotBlank(startTimeForSql)){
                countSql += " AND czrq > '"+startTimeForSql+"'";
@ -323,6 +334,7 @@ public class EduArticleService {
                            " ap.czrq AS createTime, " +
                            " ap.admin_team_code AS adminTeamCode, " +
                            " ap.batch_no AS batchNo, " +
                            " ap.send_type AS sendSource,"+
                            " p.name AS patientName,"+
                            " t.name AS adminTeamName"+
                            " FROM " +
@ -337,7 +349,6 @@ public class EduArticleService {
                        resultSql += " ORDER BY ap.czrq ASC limit ?,?";
                    }
                    for (int i = 1; i <= pageCount; i++) {
                        int start = (i - 1) * (pageSize*20);
                        List<Map<String,Object>> resultList = jdbcTemplate.queryForList(resultSql,new Object[]{start,pageSize*20});
@ -350,10 +361,11 @@ public class EduArticleService {
                            HealthEduArticleES healthEduArticleES = new HealthEduArticleES();
                            //Map转对象
                            healthEduArticleES = MapListUtils.convertMap2Bean(map,HealthEduArticleES.class);
                            healthEduArticleES = setDateToObj(healthEduArticleES,doctorMap,articleMap,wjwCode);
                            healthEduArticleES = setDateToObj(healthEduArticleES,doctorMap,articleMap,wjwCode,1);
                            if (StringUtils.isEmpty(healthEduArticleES.getDoctorName())){
                                healthEduArticleES.setDoctorCode(wjwCode);
                                //healthEduArticleES.setSendCode(wjwCode);
                                //卫计委发送
                                healthEduArticleES.setSendType(2);
                                healthEduArticleES.setSendName("厦门市卫生与计划生育委员会");
                                healthEduArticleES.setDoctorName("厦门市卫生与计划生育委员会");
                            }
@ -364,6 +376,54 @@ public class EduArticleService {
                    }
                }
            }
            //按批次查询文章信息。userType=2
            //要先删除原来的数据。
            String batSql ="SELECT batch_no from wlyy_health_edu_article_patient WHERE admin_team_code IS NOT NULL GROUP BY batch_no ";
            List<Map<String,Object>> batchNoMap = jdbcTemplate.queryForList(batSql);
            if (batchNoMap!=null && batchNoMap.size()>0){
                for (Map<String,Object> map : batchNoMap){
                    deleteData(2,map.get("batch_no")+"");
                }
            }
            String BartchNoSql = "SELECT " +
                    " ap.patient AS patientCode, " +
                    " ap.article AS articleId, " +
                    " ap.doctor AS doctorCode, " +
                    " ap.is_read AS isRead, " +
                    " ap.czrq AS createTime, " +
                    " ap.admin_team_code AS adminTeamCode, " +
                    " ap.batch_no AS batchNo, " +
                    " ap.send_type AS sendSource,"+
                    " p.name AS patientName,"+
                    " t.name AS adminTeamName"+
                    " FROM " +
                    " wlyy_health_edu_article_patient ap " +
                    " LEFT JOIN wlyy_patient p ON ap.patient = p.code " +
                    " LEFT JOIN wlyy_admin_team t ON ap.admin_team_code = t.id" +
                    " WHERE " +
                    " ap.admin_team_code IS NOT NULL GROUP BY ap.batch_no ORDER BY ap.czrq ASC";
            List<Map<String,Object>> batchList = jdbcTemplate.queryForList(BartchNoSql);
            List<HealthEduArticleES> batchEsList = new ArrayList<>();
            if (batchList!=null && batchList.size()>0){
                for (Map<String, Object> map : batchList) {
                    HealthEduArticleES healthEduArticleES = new HealthEduArticleES();
                    healthEduArticleES.setNewArricleFlag(false);
                    //Map转对象
                    healthEduArticleES = MapListUtils.convertMap2Bean(map,HealthEduArticleES.class);
                    healthEduArticleES = setDateToObj(healthEduArticleES,doctorMap,articleMap,wjwCode,2);
                    if (StringUtils.isEmpty(healthEduArticleES.getDoctorName())){
                        healthEduArticleES.setDoctorCode(wjwCode);
                        //卫计委发送
                        healthEduArticleES.setSendType(2);
                        healthEduArticleES.setSendName("厦门市卫生与计划生育委员会");
                        healthEduArticleES.setDoctorName("厦门市卫生与计划生育委员会");
                    }
                    batchEsList.add(healthEduArticleES);
                }
                //保存到Es中
                saveDate(batchEsList);
            }
        }catch (Exception e){
            e.printStackTrace();
            flag= false;
@ -371,7 +431,7 @@ public class EduArticleService {
        return flag;
    }
    public HealthEduArticleES setDateToObj(HealthEduArticleES healthEduArticleES,Map<String,Doctor> doctorMap,Map<String,HealthEduArticle> articleMap,String wjwCode)throws Exception{
    public HealthEduArticleES setDateToObj(HealthEduArticleES healthEduArticleES,Map<String,Doctor> doctorMap,Map<String,HealthEduArticle> articleMap,String wjwCode,int userType)throws Exception{
        //遍历医生
        Set<Map.Entry<String,Doctor>> doctorSet=doctorMap.entrySet();
        for(Map.Entry<String, Doctor> doctorEntry:doctorSet){
@ -380,6 +440,8 @@ public class EduArticleService {
                healthEduArticleES.setDoctorCode(doctor.getCode());
                healthEduArticleES.setDoctorName(doctor.getName());
                //healthEduArticleES.setSendCode(doctor.getCode());
                //医生发送
                healthEduArticleES.setSendType(1);
                healthEduArticleES.setSendName(doctor.getCode());
                healthEduArticleES.setSendPic(doctor.getPhoto());
                healthEduArticleES.setSendSex(doctor.getSex() != null ? String.valueOf(doctor.getSex()) : "");
@ -401,8 +463,7 @@ public class EduArticleService {
                healthEduArticleES.setArticleContent(healthEduArticle.getSummary());
            }
        }
        healthEduArticleES.setSendType(2);
        healthEduArticleES.setUserType(userType);
        healthEduArticleES.setOperatorId(wjwCode);
        healthEduArticleES.setArticleSource("厦门市卫生与计划生育委员会");
        return  healthEduArticleES;
@ -474,6 +535,44 @@ public class EduArticleService {
    private Boolean saveDate(List<HealthEduArticleES> sms)throws Exception {
        return SpringUtil.getBean(SaveEduArticleHelper.class).save(sms);
    }
    /**
     * 删除数据
     */
    private void deleteData(int userType,String batchNo) {
        JestClient jestClient = null;
        try {
            jestClient = elasticFactory.getJestClient();
            //先根据条件查找出来
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            BoolQueryBuilder boolQueryBuilder =  new BoolQueryBuilder();
            boolQueryBuilder.must(QueryBuilders.matchQuery("userType",userType));
            boolQueryBuilder.must(QueryBuilders.matchQuery("batchNo",batchNo));
            searchSourceBuilder.query(boolQueryBuilder).size(100);//一次取10000条
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();
            SearchResult result = jestClient.execute(search);
            List<HealthEduArticleES> saveModels = result.getSourceAsObjectList(HealthEduArticleES.class);
            //根据id批量删除
            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
            for (HealthEduArticleES obj : saveModels) {
                Delete index = new Delete.Builder(obj.getId()).build();
                bulk.addAction(index);
            }
            BulkResult br = jestClient.execute(bulk.build());
            logger.info("delete data count:" + saveModels.size());
            logger.info("delete flag:" + br.isSucceeded());
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
    }
    @Transactional
    public void save(){
        NewArticleModel newArticleModel = new NewArticleModel();