Sfoglia il codice sorgente

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

Conflicts:
	patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
zd_123 7 anni fa
parent
commit
ebd677bf2f
23 ha cambiato i file con 413 aggiunte e 162 eliminazioni
  1. 11 2
      common/common-entity/src/main/java/com/yihu/wlyy/entity/call/CallRecord.java
  2. 1 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/call/CallService.java
  3. 13 2
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/common/account/CustomerController.java
  4. 10 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/call/CallRecord.java
  5. 10 5
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/account/CustomerService.java
  6. 70 4
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/controller/QueryController.java
  7. 6 5
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/PrescriptionStatusConvert.java
  8. 7 10
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/util/Contant.java
  9. 1 1
      patient-co/patient-co-statistics-es/src/main/resources/application.yml
  10. 32 32
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/util/NoticeImUtill.java
  11. 3 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java
  12. 15 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  13. 12 7
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionExpressageService.java
  14. 6 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  15. 20 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/call/CustomerService.java
  16. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ElasticsearchUtil.java
  17. 27 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/call/CallRecordController.java
  18. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java
  19. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java
  20. 3 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcEduArticleController.java
  21. 131 74
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/service/GcEduArticleService.java
  22. 30 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/vo/HealthEduArticlePatientModel.java
  23. 1 1
      patient-co/patient-co-wlyy/src/main/resources/application-prod.yml

+ 11 - 2
common/common-entity/src/main/java/com/yihu/wlyy/entity/call/CallRecord.java

@ -18,7 +18,7 @@ public class CallRecord extends IdEntity {
    private Integer type; //1.呼入,2.呼出
    private Integer type; //1.呼入,2.呼出
    private String  callerNumber; //主叫号码
    private String  callerNumber; //主叫号码
    private String  recipientNumber;//被叫号码
    private String  recipientNumber;//被叫号码
    private Integer  answerStatus;//接听状态: 1.接通,2. 队列中放弃,3.接通
    private Integer  answerStatus;//接听状态: 1.接通,2. 队列中放弃,3.未接通
    private Integer  serviceType; //服务类型:1.医生转接 2.代理咨询
    private Integer  serviceType; //服务类型:1.医生转接 2.代理咨询
    private String  serviceContent; //服务内容
    private String  serviceContent; //服务内容
    private Date createTime; //创建时间
    private Date createTime; //创建时间
@ -34,7 +34,8 @@ public class CallRecord extends IdEntity {
    private String  ssc; //社保卡号
    private String  ssc; //社保卡号
    private String  doctor; //签约医生code
    private String  doctor; //签约医生code
    private String  doctorName; //签约医生姓名
    private String  doctorName; //签约医生姓名
    private Long  adminTeamCode;
    private Long  adminTeamCode; //团队id
    private Integer transferState;//转接状态1.成功 2.失败
    public String getCode() {
    public String getCode() {
        return code;
        return code;
@ -205,4 +206,12 @@ public class CallRecord extends IdEntity {
    public void setAdminTeamCode(Long adminTeamCode) {
    public void setAdminTeamCode(Long adminTeamCode) {
        this.adminTeamCode = adminTeamCode;
        this.adminTeamCode = adminTeamCode;
    }
    }
    public Integer getTransferState() {
        return transferState;
    }
    public void setTransferState(Integer transferState) {
        this.transferState = transferState;
    }
}
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/call/CallService.java

@ -14,7 +14,7 @@ import java.util.Date;
@Table(name = "manage_call_service")
@Table(name = "manage_call_service")
public class CallService extends IdEntity {
public class CallService extends IdEntity {
    private String code; //服务编号
    private String code; //服务编号.
    private String callCode; //关联通话记录
    private String callCode; //关联通话记录
    private String patient; //服务对象(患者code)
    private String patient; //服务对象(患者code)
    private String patientName; // 服务对象名称(患者名称)
    private String patientName; // 服务对象名称(患者名称)

+ 13 - 2
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/common/account/CustomerController.java

@ -231,9 +231,10 @@ public class CustomerController extends BaseController {
    public String  updateCallRecordService(@ApiParam(name="code",value="通话记录code")@RequestParam(required = true)String code,
    public String  updateCallRecordService(@ApiParam(name="code",value="通话记录code")@RequestParam(required = true)String code,
                                           @ApiParam(name="phone",value="服务对象电话号码")@RequestParam(required = true)String phone,
                                           @ApiParam(name="phone",value="服务对象电话号码")@RequestParam(required = true)String phone,
                                           @ApiParam(name="serviceType",value="服务类型:1.医生转接 2.代理咨询")@RequestParam(required = true)Integer serviceType,
                                           @ApiParam(name="serviceType",value="服务类型:1.医生转接 2.代理咨询")@RequestParam(required = true)Integer serviceType,
                                           @ApiParam(name="serviceContent",value="服务内容")@RequestParam(required = false) String serviceContent){
                                           @ApiParam(name="serviceContent",value="服务内容")@RequestParam(required = false) String serviceContent,
                                           @ApiParam(name="transferState",value="1.成功,2.失败")@RequestParam(required = true) Integer transferState){
        try {
        try {
            return write(200,"保存成功","data",customerService.updateCallRecordService(code,phone,serviceType,serviceContent));
            return write(200,"保存成功","data",customerService.updateCallRecordService(code,phone,serviceType,serviceContent,transferState));
        }catch (Exception e){
        }catch (Exception e){
            error(e);
            error(e);
            return error(-1,"保存失败");
            return error(-1,"保存失败");
@ -349,4 +350,14 @@ public class CustomerController extends BaseController {
        }
        }
    }
    }
    @RequestMapping(value = "/delCallService", method = {RequestMethod.GET, RequestMethod.POST})
    @ApiOperation(value = "删除协同服务")
    public String delCallService(@ApiParam(name="code",value="协同服务编号")@RequestParam(required = true)String code){
        try {
            return write(200,"操作成功","data",customerService.delCallService(code));
        }catch (Exception e){
            error(e);
            return error(-1,"操作成功");
        }
    }
}
}

+ 10 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/call/CallRecord.java

@ -34,7 +34,8 @@ public class CallRecord extends IdEntity {
    private String  ssc; //社保卡号
    private String  ssc; //社保卡号
    private String  doctor; //签约医生code
    private String  doctor; //签约医生code
    private String  doctorName; //签约医生姓名
    private String  doctorName; //签约医生姓名
    private Long  adminTeamCode;
    private Long  adminTeamCode; //团队id
    private Integer transferState;//转接状态1.成功 2.失败
    public String getCode() {
    public String getCode() {
        return code;
        return code;
@ -205,4 +206,12 @@ public class CallRecord extends IdEntity {
    public void setAdminTeamCode(Long adminTeamCode) {
    public void setAdminTeamCode(Long adminTeamCode) {
        this.adminTeamCode = adminTeamCode;
        this.adminTeamCode = adminTeamCode;
    }
    }
    public Integer getTransferState() {
        return transferState;
    }
    public void setTransferState(Integer transferState) {
        this.transferState = transferState;
    }
}
}

+ 10 - 5
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/account/CustomerService.java

@ -20,6 +20,7 @@ import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.aspectj.weaver.ast.Call;
import org.json.JSONObject;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
@ -220,7 +221,7 @@ public class CustomerService extends BaseService{
		return "1";
		return "1";
	}
	}
	public Map<String,Object> updateCallRecordService(String code,String phone,Integer serviceType,String serviceContent){
	public Map<String,Object> updateCallRecordService(String code,String phone,Integer serviceType,String serviceContent,Integer transferState){
		CallRecord callRecord = callRecordDao.findByCode(code);
		CallRecord callRecord = callRecordDao.findByCode(code);
		List<Patient> list =  patientDao.findByMobile(phone);
		List<Patient> list =  patientDao.findByMobile(phone);
@ -253,7 +254,7 @@ public class CustomerService extends BaseService{
		callRecord.setServiceType(serviceType);
		callRecord.setServiceType(serviceType);
		callRecord.setServiceContent(serviceContent);
		callRecord.setServiceContent(serviceContent);
		callRecord.setAdminTeamCode(sf.getAdminTeamId());
		callRecord.setAdminTeamCode(sf.getAdminTeamId());
		callRecord.setTransferState(transferState);
		CallRecord call = callRecordDao.save(callRecord);
		CallRecord call = callRecordDao.save(callRecord);
		rs.put("state",1);
		rs.put("state",1);
@ -307,7 +308,7 @@ public class CustomerService extends BaseService{
				" manage_call_record r " +
				" manage_call_record r " +
				" WHERE " +
				" WHERE " +
				" 1 = 1 ";
				" 1 = 1 ";
		sql = setCallRecordSql( sqltotal, callerNumber,recipientNumber, answerStatus, serviceType ,userName,jobNo, startDate, endDate);
		sql = setCallRecordSql( sql, callerNumber,recipientNumber, answerStatus, serviceType ,userName,jobNo, startDate, endDate);
		sql += " ORDER BY r.call_time DESC LIMIT "+(page-1)*size+","+size;
		sql += " ORDER BY r.call_time DESC LIMIT "+(page-1)*size+","+size;
		List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
		List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
@ -496,7 +497,7 @@ public class CustomerService extends BaseService{
				" s.patient_name AS patientName, " +
				" s.patient_name AS patientName, " +
				" s.doctor, " +
				" s.doctor, " +
				" s.doctor_name AS doctorName, " +
				" s.doctor_name AS doctorName, " +
				" s.server_type As serverType, " +
				" s.type As type, " +
				" s.state, " +
				" s.state, " +
				" s.server_content AS serverContent, " +
				" s.server_content AS serverContent, " +
				" s.create_time AS createTime, " +
				" s.create_time AS createTime, " +
@ -567,7 +568,11 @@ public class CustomerService extends BaseService{
		return rs;
		return rs;
	}
	}
	public String delCallService(String code){
		CallService c = callServiceDao.findByCode(code);
		callServiceDao.delete(c);
		return "1";
	}

+ 70 - 4
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/controller/QueryController.java

@ -6,6 +6,7 @@ import com.alibaba.druid.sql.parser.ParserException;
import com.alibaba.druid.sql.parser.SQLExprParser;
import com.alibaba.druid.sql.parser.SQLExprParser;
import com.alibaba.druid.sql.parser.Token;
import com.alibaba.druid.sql.parser.Token;
import com.google.gson.JsonObject;
import com.google.gson.JsonObject;
import com.yihu.wlyy.statistics.etl.cache.Cache;
import com.yihu.wlyy.statistics.etl.save.es.ElasticFactory;
import com.yihu.wlyy.statistics.etl.save.es.ElasticFactory;
import com.yihu.wlyy.statistics.util.DateUtil;
import com.yihu.wlyy.statistics.util.DateUtil;
import com.yihu.wlyy.statistics.util.ElasticsearchUtil;
import com.yihu.wlyy.statistics.util.ElasticsearchUtil;
@ -38,10 +39,9 @@ import org.nlpcn.es4sql.query.AggregationQueryAction;
import org.nlpcn.es4sql.query.DefaultQueryAction;
import org.nlpcn.es4sql.query.DefaultQueryAction;
import org.nlpcn.es4sql.query.SqlElasticSearchRequestBuilder;
import org.nlpcn.es4sql.query.SqlElasticSearchRequestBuilder;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
/**
 * Created by chenweida on 2017/7/1.
 * Created by chenweida on 2017/7/1.
@ -176,6 +176,72 @@ public class QueryController {
        return deleteData(DateUtil.strToDate(date, "yyyy-MM-dd"), null).toString();
        return deleteData(DateUtil.strToDate(date, "yyyy-MM-dd"), null).toString();
    }
    }
    @ApiOperation(value = "删除某一天到某一天的数据")
    @RequestMapping(value = "/deleteQuotaDateToDate", method = RequestMethod.DELETE)
    public String deleteQuotaDateToDate(
            @ApiParam(name = "start", value = "时间(yyyy-MM-dd)", required = true) @RequestParam(value = "start", required = true) String start,
            @ApiParam(name = "end", value = "时间(yyyy-MM-dd)", required = true) @RequestParam(value = "end", required = true) String end) {
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            Date startDate = sdf.parse(start);
            Date endDate = endDate = sdf.parse(end);
            int day = daysBetween(startDate, endDate);
            for (int i = 0; i < day; i++) {
                Cache.cleanCache();//清空缓存
                deleteData(DateUtil.strToDate(getYesterday(i, startDate), "yyyy-MM-dd"), null).toString();
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return "删除成功";
    }
    @ApiOperation(value = "删除某一天到某一天的数据")
    @RequestMapping(value = "/deleteQuotaDateToDateWithId", method = RequestMethod.DELETE)
    public String deleteQuotaDateToDateWithId(
            @ApiParam(name = "id", value = "指标id", required = true) @RequestParam(value = "id", required = true) String id,
            @ApiParam(name = "start", value = "时间(yyyy-MM-dd)", required = true) @RequestParam(value = "start", required = true) String start,
            @ApiParam(name = "end", value = "时间(yyyy-MM-dd)", required = true) @RequestParam(value = "end", required = true) String end) {
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            Date startDate = sdf.parse(start);
            Date endDate = endDate = sdf.parse(end);
            int day = daysBetween(startDate, endDate);
            for (int i = 0; i < day; i++) {
                Cache.cleanCache();//清空缓存
                deleteData(DateUtil.strToDate(getYesterday(i, startDate), "yyyy-MM-dd"), id).toString();
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return "删除成功";
    }
    public static String getYesterday(Integer day, Date startDate) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(startDate);
        cal.add(Calendar.DAY_OF_MONTH, day);
        String yesterday = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime());
        return yesterday;
    }
    public static int daysBetween(Date smdate, Date bdate) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        smdate = sdf.parse(sdf.format(smdate));
        bdate = sdf.parse(sdf.format(bdate));
        Calendar cal = Calendar.getInstance();
        cal.setTime(smdate);
        long time1 = cal.getTimeInMillis();
        cal.setTime(bdate);
        long time2 = cal.getTimeInMillis();
        long between_days = (time2 - time1) / (1000 * 3600 * 24);
        return Integer.parseInt(String.valueOf(between_days));
    }
    /**
    /**
     * 删除 某个指标某一天的某个timelevel的数据
     * 删除 某个指标某一天的某个timelevel的数据
     *
     *

+ 6 - 5
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/PrescriptionStatusConvert.java

@ -19,21 +19,22 @@ import java.util.Map;
 * Created by zhangdan on 2017/10/26.
 * Created by zhangdan on 2017/10/26.
 */
 */
public class PrescriptionStatusConvert implements Convert {
public class PrescriptionStatusConvert implements Convert {
    public List<DataModel> convert(JdbcTemplate jdbcTemplate, List<DataModel> oneList, String slaveLevel, WlyyDimensionQuota temp ) {
        for(DataModel one:oneList){
    public List<DataModel> convert(JdbcTemplate jdbcTemplate, List<DataModel> oneList, String slaveLevel, WlyyDimensionQuota temp) {
        for (DataModel one : oneList) {
            try {
            try {
//                Object value = DataModel.class.getMethod("get" + temp.getKey()).invoke(one);
//                Object value = DataModel.class.getMethod("get" + temp.getKey()).invoke(one);
                //获取到prescriptionCode,求长处方状态
                //获取到prescriptionCode,求长处方状态
                String sql ="SELECT status FROM wlyy_prescription WHERE code=?";
                String sql = "SELECT status FROM wlyy_prescription WHERE code=?";
                //int status = jdbcTemplate.queryForObject(sql, Integer.class);
                //int status = jdbcTemplate.queryForObject(sql, Integer.class);
                Object[] args = {one.getPrescriptionCode()};
                Object[] args = {one.getPrescriptionCode()};
                int status=jdbcTemplate.queryForObject(sql,args,Integer.class);
                int status = jdbcTemplate.queryForObject(sql, args, Integer.class);
                String key = getStatusCode(status);
                String key = getStatusCode(status);
                DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(one, key);
                DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(one, key);
            } catch (Exception e) {
            } catch (Exception e) {
                e.printStackTrace();
                e.printStackTrace();
            }
            }
        };
        }
        ;
        return oneList;
        return oneList;
    }
    }

+ 7 - 10
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/util/Contant.java

@ -141,11 +141,13 @@ public class Contant {
    }
    }
    public static class prescriptionStatus{
    public static class prescriptionStatus{
        public static String status_1="1";
        public static String status_2="2";
        public static String status_3="3";
        public static String status_4="4";
        public static String status_5="5";
        public static String status_1="1";//已完成
        public static String status_2="2";//已取消
        public static String status_3="3";//审核不通过
        public static String status_4="4";//进行中
        public static String status_5="5";//其他原因取消
//        public static String status_6="6";
//        public static String status_6="6";
//        public static String status_7="7";
//        public static String status_7="7";
//        public static String status_8="8";
//        public static String status_8="8";
@ -170,11 +172,6 @@ public class Contant {
//        public static String status_12_name="已完成";
//        public static String status_12_name="已完成";
//        public static String status_13_name="进行中";
//        public static String status_13_name="进行中";
        public static String status_1_name="进行中";//大于0小于100
        public static String status_2_name="已完成";//100
        public static String status_3_name="已取消";//患者取消,-2
        public static String status_4_name="审核不通过";//-1;
        public static String status_5_name="其他原因取消";//支付超时,-3;
    }
    }
}
}

+ 1 - 1
patient-co/patient-co-statistics-es/src/main/resources/application.yml

@ -27,7 +27,7 @@ spring:
    poolPreparedStatements: true # 打开PSCache,并且指定每个连接上PSCache的大小
    poolPreparedStatements: true # 打开PSCache,并且指定每个连接上PSCache的大小
    maxPoolPreparedStatementPerConnectionSize: 50
    maxPoolPreparedStatementPerConnectionSize: 50
    removeAbandoned: true #超过时间限制是否回收
    removeAbandoned: true #超过时间限制是否回收
    removeAbandonedTimeout: 180 #超时时间;单位为秒。180秒=3分钟
    removeAbandonedTimeout: 7200 #超时时间;单位为秒。180秒=3分钟
    logAbandoned: false #关闭abanded连接时输出错误日志
    logAbandoned: false #关闭abanded连接时输出错误日志
    # REDIS
    # REDIS
  redis:
  redis:

+ 32 - 32
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/util/NoticeImUtill.java

@ -150,23 +150,23 @@ public class NoticeImUtill {
        return messages;
        return messages;
    }
    }
    public static JSONObject getTopicMessage(String baseUrl,String topicId,String startMsgId,String endMsgId,int page,int pagesize,String uid){
        String url = baseUrl
                + "api/v2/sessions/topic/"+topicId+"/messages?topic_id="+topicId+"&end="+startMsgId
                +"&start="+(endMsgId==null?"":endMsgId)+"&page="+page+"&pagesize="+pagesize+"&user="+uid;
        try{
            String ret = HttpClientUtil.get(url, "UTF-8");
            JSONObject obj = new JSONObject(ret);
            if(obj.getInt("status")==-1){
                throw new RuntimeException(obj.getString("message"));
            }else{
                return  obj.getJSONObject("data");
            }
        }catch (Exception e){
            return null;
        }
    }
//    public static JSONObject getTopicMessage(String baseUrl,String topicId,String startMsgId,String endMsgId,int page,int pagesize,String uid){
//        String url = baseUrl
//                + "api/v2/sessions/topic/"+topicId+"/messages?topic_id="+topicId+"&end="+startMsgId
//                +"&start="+(endMsgId==null?"":endMsgId)+"&page="+page+"&pagesize="+pagesize+"&user="+uid;
//        try{
//            String ret = HttpClientUtil.get(url, "UTF-8");
//            JSONObject obj = new JSONObject(ret);
//            if(obj.getInt("status")==-1){
//                throw new RuntimeException(obj.getString("message"));
//            }else{
//                return  obj.getJSONObject("data");
//            }
//        }catch (Exception e){
//            return null;
//        }
//
//    }
    /**
    /**
     * 删除对应的成员信息在MUC模式中
     * 删除对应的成员信息在MUC模式中
@ -201,21 +201,21 @@ public class NoticeImUtill {
     * @param topicId
     * @param topicId
     * @return
     * @return
     */
     */
    public static JSONObject getTopic(String baseUrl,String topicId) throws  Exception{
        String url =baseUrl
                + "api/v2/sessions/topics/"+topicId+"?topic_id="+topicId;
        try{
            String ret = HttpClientUtil.get(url,"utf-8");
            JSONObject obj = new JSONObject(ret);
            if(obj.getInt("status")==-1){
                throw new RuntimeException("获取议题失败!");
            }else{
                return obj;
            }
        }catch (Exception e){
            throw new RuntimeException("获取议题失败!");
        }
    }
//    public static JSONObject getTopic(String baseUrl,String topicId) throws  Exception{
//        String url =baseUrl
//                + "api/v2/sessions/topics/"+topicId+"?topic_id="+topicId;
//        try{
//            String ret = HttpClientUtil.get(url,"utf-8");
//            JSONObject obj = new JSONObject(ret);
//            if(obj.getInt("status")==-1){
//                throw new RuntimeException("获取议题失败!");
//            }else{
//                return obj;
//            }
//        }catch (Exception e){
//            throw new RuntimeException("获取议题失败!");
//        }
//    }
}
}

+ 3 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java

@ -100,4 +100,7 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    @Query("from Message a where a.type = 12 and a.state=0 and a.del='1' and a.over='0' and receiver = ?1  ")
    @Query("from Message a where a.type = 12 and a.state=0 and a.del='1' and a.over='0' and receiver = ?1  ")
    List<Message> findByReceiverCallService(String doctor);
    List<Message> findByReceiverCallService(String doctor);
    @Query("select a from Message a where a.receiver = ?1 and a.type=?2 ")
    List<Message> getMessageByType(String doctor, Integer type, Pageable pageRequest);
}
}

+ 15 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java

@ -166,6 +166,20 @@ public class MessageService extends BaseService {
            prescriptionJson.put("amount", 0);
            prescriptionJson.put("amount", 0);
        }
        }
        //协同服务
        List<Message> callServiceMes =  messageDao.findByReceiverCallService(doctor);
        JSONObject callServiceMesJson = new JSONObject();
        if (callServiceMes != null && callServiceMes.size() > 0) {
            callServiceMesJson.put("amount", callServiceMes.size());
            JSONObject callJson = new JSONObject();
            callJson.put("title", callServiceMes.get(0).getTitle());
            callJson.put("type", callServiceMes.get(0).getType());
            callJson.put("msg", callServiceMes.get(0).getContent());
            callJson.put("msgTime", DateUtil.dateToStrLong(callServiceMes.get(0).getCreateTime()));
            callServiceMesJson.put("lastMessage", callJson);
        } else {
            callServiceMesJson.put("amount", 0);
        }
        JSONObject json = new JSONObject();
        JSONObject json = new JSONObject();
        json.put("imMsgCount", getImMsgAmount(doctor));//IM消息数量
        json.put("imMsgCount", getImMsgAmount(doctor));//IM消息数量
@ -173,6 +187,7 @@ public class MessageService extends BaseService {
        json.put("healthIndex", indexJson);//健康指标
        json.put("healthIndex", indexJson);//健康指标
        json.put("system", systemJson);//系统消息
        json.put("system", systemJson);//系统消息
        json.put("prescription", prescriptionJson);//续方消息
        json.put("prescription", prescriptionJson);//续方消息
        json.put("callService", callServiceMesJson);//协同服务消息
        return json;
        return json;
    }
    }

+ 12 - 7
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionExpressageService.java

@ -25,6 +25,7 @@ import java.util.*;
 * 订单物流相关。
 * 订单物流相关。
 */
 */
@Service
@Service
@Transactional
public class PrescriptionExpressageService extends BaseService {
public class PrescriptionExpressageService extends BaseService {
    @Autowired
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    private PrescriptionExpressageDao prescriptionExpressageDao;
@ -560,17 +561,21 @@ public class PrescriptionExpressageService extends BaseService {
            //更新二维码(isUse)
            //更新二维码(isUse)
            PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeDao.finByCode(prescriptionCode);
            PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeDao.finByCode(prescriptionCode);
            //修改取药码code为已经使用
            prescriptionDispensaryCode.setIsUse(1);
            prescriptionDispensaryCodeDao.save(prescriptionDispensaryCode);
            if(prescriptionDispensaryCode!=null){
                //修改取药码code为已经使用
                prescriptionDispensaryCode.setIsUse(1);
                prescriptionDispensaryCodeDao.save(prescriptionDispensaryCode);
            }
            //更新配送信息
            //更新配送信息
            PrescriptionExpressage prescriptionExpressage = prescriptionExpressageDao.findByPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
            PrescriptionExpressage prescriptionExpressage = prescriptionExpressageDao.findByPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
            prescriptionExpressage.setHospitalDoctor(doctor);
            prescriptionExpressage.setHospitalDoctorCode(d.getCode());
            prescriptionExpressage.setFetchingMedicineTime(new Date());
            prescriptionExpressageDao.save(prescriptionExpressage);
            if(prescriptionExpressage!=null){
                prescriptionExpressage.setHospitalDoctor(doctor);
                prescriptionExpressage.setHospitalDoctorCode(d.getCode());
                prescriptionExpressage.setFetchingMedicineTime(new Date());
                prescriptionExpressageDao.save(prescriptionExpressage);
            }
            return "1";
            return "1";
        }
        }
        return "0";
        return "0";

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

@ -521,7 +521,11 @@ public class StatisticsESService {
    public long getWeiJiaoFei(String endDate, String area, int level) throws Exception {
    public long getWeiJiaoFei(String endDate, String area, int level) throws Exception {
        SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel1(endDate, area, level, "16", "2", "0");
        SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel1(endDate, area, level, "16", "2", "0");
        return saveModel.getResult2().longValue();
        if (saveModel != null) {
            return saveModel.getResult2().longValue();
        } else {
            return 0;
        }
    }
    }
@ -2798,7 +2802,7 @@ public class StatisticsESService {
            throw new RuntimeException("未找到团队信息");
            throw new RuntimeException("未找到团队信息");
        }
        }
        Long id = admin.getId();
        Long id = admin.getId();
        List<SaveModel> list = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate,endDate,id+"",Integer.valueOf(SaveModel.teamLevel),"1",SaveModel.timeLevel_ZL,String.valueOf(Integer.valueOf(type)+1));
        List<SaveModel> list = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, id + "", Integer.valueOf(SaveModel.teamLevel), "1", SaveModel.timeLevel_ZL, String.valueOf(Integer.valueOf(type) + 1));
        List<Map<String, Object>> rs = new ArrayList<>();
        List<Map<String, Object>> rs = new ArrayList<>();
        for (SaveModel saveModel : list) {
        for (SaveModel saveModel : list) {

+ 20 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/call/CustomerService.java

@ -11,6 +11,9 @@ import com.yihu.wlyy.service.BaseService;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
@ -92,9 +95,21 @@ public class CustomerService extends BaseService{
		return list;
		return list;
	}
	}
	public List<Message> getCallServiceMes(String doctor){
		List<Message> mes =  messageDao.findByReceiverCallService(doctor);
		return mes;
//	public List<Message> getCallServiceMes(String doctor,Integer page, Integer pagesize){
//		Sort sort = new Sort(Sort.Direction.DESC, "createTime");
//		// 分页信息
//		Pageable pageRequest = new PageRequest(page - 1, pagesize, sort);
//
//		List<Message> mes =  messageDao.findByReceiverCallService(doctor);
//		return mes;
//	}
	public List<Message> getCallServiceMes(String doctor,Integer page, Integer pagesize) throws Exception {
		// 排序
		Sort sort = new Sort(Sort.Direction.DESC, "createTime");
		// 分页信息
		Pageable pageRequest = new PageRequest(page - 1, pagesize, sort);
		return messageDao.getMessageByType(doctor,12, pageRequest);
	}
	}
	public Map<String,Object> getCallServiceInfo(String code){
	public Map<String,Object> getCallServiceInfo(String code){
@ -147,11 +162,12 @@ public class CustomerService extends BaseService{
		//预约失败
		//预约失败
		}else{
		}else{
			cs.setState(2);
			cs.setState(2);
			cs.setDealState(3);
			cs.setDealTime(new Date());
			cs.setDealTime(new Date());
			cs.setDealReason(dealReason);
			cs.setDealReason(dealReason);
			cs.setDealContent(dealContent);
			cs.setDealContent(dealContent);
		}
		}
		callServiceDao.save(cs);
		return "1";
		return "1";
	}
	}
}
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ElasticsearchUtil.java

@ -384,7 +384,7 @@ public class ElasticsearchUtil {
                groupBy.append(",slaveKey1,slaveKey1Name");
                groupBy.append(",slaveKey1,slaveKey1Name");
            }
            }
        } else if (SaveModel.OrgLevel.equals(low_level)) {
        } else if (SaveModel.OrgLevel.equals(low_level)) {
            sql.append("select hospital,hospitalName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2),quotaDate result2 from " + esIndex + " where ");
            sql.append("select hospital,hospitalName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2,quotaDate from " + esIndex + " where ");
            groupBy.append("  group by hospital,hospitalName");
            groupBy.append("  group by hospital,hospitalName");
            if (!org.springframework.util.StringUtils.isEmpty(slaveKey1) || commonParams.equals(slaveKey1)) {
            if (!org.springframework.util.StringUtils.isEmpty(slaveKey1) || commonParams.equals(slaveKey1)) {
                groupBy.append(",slaveKey1,slaveKey1Name");
                groupBy.append(",slaveKey1,slaveKey1Name");

+ 27 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/call/CallRecordController.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.web.doctor.call;
package com.yihu.wlyy.web.doctor.call;
import com.yihu.wlyy.service.call.CustomerService;
import com.yihu.wlyy.service.call.CustomerService;
import com.yihu.wlyy.service.third.jw.JwSmjkService;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
@ -8,10 +9,7 @@ import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
/**
 * Created by Trick on 2017/11/14.
 * Created by Trick on 2017/11/14.
@ -23,6 +21,8 @@ public class CallRecordController extends BaseController {
    @Autowired
    @Autowired
    private CustomerService customerService;
    private CustomerService customerService;
    @Autowired
    private JwSmjkService jwSmjkService;
    @RequestMapping(value = "/getCallServices", method = {RequestMethod.GET, RequestMethod.POST})
    @RequestMapping(value = "/getCallServices", method = {RequestMethod.GET, RequestMethod.POST})
    @ApiOperation(value = "协同服务查询")
    @ApiOperation(value = "协同服务查询")
@ -49,9 +49,10 @@ public class CallRecordController extends BaseController {
    @RequestMapping(value = "/getCallServiceMes", method = {RequestMethod.GET, RequestMethod.POST})
    @RequestMapping(value = "/getCallServiceMes", method = {RequestMethod.GET, RequestMethod.POST})
    @ApiOperation(value = "获取协同服务消息")
    @ApiOperation(value = "获取协同服务消息")
    public String getCallServiceMes(){
    public String getCallServiceMes(@ApiParam(name="page",value="第几页")@RequestParam(required = false)Integer page,
                                    @ApiParam(name="pagesize",value="每页几条记录")@RequestParam(required = false)Integer pagesize){
        try {
        try {
            return write(200,"保存成功","data",customerService.getCallServiceMes(getUID()));
            return write(200,"保存成功","data",customerService.getCallServiceMes(getUID(),page,pagesize));
        }catch (Exception e){
        }catch (Exception e){
            error(e);
            error(e);
            return error(-1,"保存失败");
            return error(-1,"保存失败");
@ -103,4 +104,24 @@ public class CallRecordController extends BaseController {
            return error(-1,"保存失败");
            return error(-1,"保存失败");
        }
        }
    }
    }
    /*************************************** 患者端查询 ******************************************************************/
    @RequestMapping(value = "GetRegList", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("获取患者预约信息列表接口--患者端")
    public String GetRegList(@ApiParam(name = "patient", value = "患者编号", defaultValue = "0cc6e4562de2437ab2dbbf51a9fc3b49")
                             @RequestParam(value = "patient", required = false) String patient) {
        try {
//            SimpleDateFormat sm = new SimpleDateFormat("yyyy-MM-dd");
//            Date nowDate = new Date();
//            Date oneMonthAfter = getMonthBefore(nowDate, -1);
//            Date threeMonthBefore = getMonthBefore(nowDate, 3);        //三个月历史记录
//            List<PatientReservation> list = guahaoXM.GetRegList(patient, sm.format(threeMonthBefore), sm.format(oneMonthAfter), threeMonthBefore, oneMonthAfter);
            String list = jwSmjkService.GetRegList(patient);
            return list;
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
}
}

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

@ -32,7 +32,7 @@ import java.util.TreeMap;
 * Created by chenweida on 2017/10/13.
 * Created by chenweida on 2017/10/13.
 */
 */
@Controller
@Controller
@RequestMapping(value = "/esstatistics", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, method = {RequestMethod.GET, RequestMethod.POST})
@RequestMapping(value = "/statistics", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, method = {RequestMethod.GET, RequestMethod.POST})
@Api(description = "ES统计查询")
@Api(description = "ES统计查询")
public class EsStatisticsController extends BaseController {
public class EsStatisticsController extends BaseController {
@ -1709,7 +1709,7 @@ public class EsStatisticsController extends BaseController {
    public String getPrescriptionTotalHistogram(@ApiParam(name="level", value="级别") @RequestParam(required = true)String level,
    public String getPrescriptionTotalHistogram(@ApiParam(name="level", value="级别") @RequestParam(required = true)String level,
                                                @ApiParam(name="area", value="级别对应编码") @RequestParam(required = true)String area,
                                                @ApiParam(name="area", value="级别对应编码") @RequestParam(required = true)String area,
                                                @ApiParam(name="disease", value="疾病类型") @RequestParam(required = false)String disease,
                                                @ApiParam(name="disease", value="疾病类型") @RequestParam(required = false)String disease,
                                                @ApiParam(name="type", value="类型0.总量,1.进行中,2.已完成,3.居民取消,4.审核不通过,5.其他原因取消") @RequestParam(required = true)String type){
                                                @ApiParam(name="type", value="类型1.总量,2.已完成,3.居民取消,4.审核不通过,5.进行中,6.其他原因取消") @RequestParam(required = true)String type){
        try{
        try{
            return write(200, "查询成功", "data", statisticsESService.getPrescriptionTotalHistogram(elasticsearchUtil.changeLevel(Integer.valueOf(level)),area,disease,type));
            return write(200, "查询成功", "data", statisticsESService.getPrescriptionTotalHistogram(elasticsearchUtil.changeLevel(Integer.valueOf(level)),area,disease,type));
        } catch (Exception e) {
        } catch (Exception e) {

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

@ -29,7 +29,7 @@ import java.util.*;
 * Created by lyr on 2016/08/16.
 * Created by lyr on 2016/08/16.
 */
 */
@Controller
@Controller
@RequestMapping(value = "/statistics", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,method = {RequestMethod.GET,RequestMethod.POST})
@RequestMapping(value = "/oldstatistics", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,method = {RequestMethod.GET,RequestMethod.POST})
@Api(description = "统计")
@Api(description = "统计")
public class StatisticsController extends BaseController {
public class StatisticsController extends BaseController {

+ 3 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcEduArticleController.java

@ -32,7 +32,9 @@ import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.TextMessage;
import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
/**
 * Created by chenweida on 2017/8/30...
 * Created by chenweida on 2017/8/30...

+ 131 - 74
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/service/GcEduArticleService.java

@ -1,5 +1,7 @@
package com.yihu.wlyy.web.third.gateway.service;
package com.yihu.wlyy.web.third.gateway.service;
//import com.yihu.es.entity.ArticleTest;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.yihu.es.entity.HealthEduArticlePatient;
import com.yihu.es.entity.HealthEduArticlePatient;
import com.yihu.wlyy.config.es.ElastricSearchSave;
import com.yihu.wlyy.config.es.ElastricSearchSave;
@ -12,17 +14,19 @@ import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.health.HealthEduArticleOpHistoryService;
import com.yihu.wlyy.service.app.health.HealthEduArticleOpHistoryService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.fzzb.HealthEducationArticleService;
import com.yihu.wlyy.service.third.fzzb.HealthEducationArticleService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ElasticsearchUtil;
import com.yihu.wlyy.util.ElasticsearchUtil;
import com.yihu.wlyy.web.third.gateway.vo.DictModel;
import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel;
import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.util.StringUtils;
import java.text.SimpleDateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.*;
@ -74,17 +78,17 @@ public class GcEduArticleService {
        //1 服务类型  2 健康情况 3 疾病类型 4 自定义标签
        //1 服务类型  2 健康情况 3 疾病类型 4 自定义标签
        if (!org.springframework.util.StringUtils.isEmpty(labelType)) {
        if (!org.springframework.util.StringUtils.isEmpty(labelType)) {
            switch (labelType) {
            switch (labelType) {
                case "1":{
                case "1": {
                    sb.append(" select w.code FROM wlyy_sign_family w  left join wlyy_sign_family_server s on w.code=s.sign_code " +
                    sb.append(" select w.code FROM wlyy_sign_family w  left join wlyy_sign_family_server s on w.code=s.sign_code " +
                            " left join wlyy_patient p on p.code=w.patient "+
                            " left join wlyy_patient p on p.code=w.patient " +
                            "where w.`status` > 0 and s.server_type=? ");
                            "where w.`status` > 0 and s.server_type=? ");
                    params.add(labelCode);
                    params.add(labelCode);
                }
                }
                case "2":
                case "2":
                case "3":
                case "3":
                case "4":{
                case "4": {
                    sb.append(" SELECT w.code FROM wlyy_sign_family w left join wlyy_sign_patient_label_info l on w.patient = l.patient " +
                    sb.append(" SELECT w.code FROM wlyy_sign_family w left join wlyy_sign_patient_label_info l on w.patient = l.patient " +
                            " left join wlyy_patient p on p.code=w.patient "+
                            " left join wlyy_patient p on p.code=w.patient " +
                            "where w.`status` > 0 and l.label_type = ? AND l.label = ? and l.status=1 ");
                            "where w.`status` > 0 and l.label_type = ? AND l.label = ? and l.status=1 ");
                    params.add(labelType);
                    params.add(labelType);
                    params.add(labelCode);
                    params.add(labelCode);
@ -100,7 +104,7 @@ public class GcEduArticleService {
        }
        }
        if (patients != null && patients.length > 0) {
        if (patients != null && patients.length > 0) {
            List<String> arrPatient = java.util.Arrays.asList(patients);
            List<String> arrPatient = java.util.Arrays.asList(patients);
            for(String str:arrPatient){
            for (String str : arrPatient) {
                patientSet.add(str);
                patientSet.add(str);
            }
            }
        }
        }
@ -192,21 +196,21 @@ public class GcEduArticleService {
    /**
    /**
     * 保存发送信息
     * 保存发送信息
     *
     *
     * @param patientSet   患者set集和
     * @param sendCode     发送人code、
     * @param sendName     发送人名称
     * @param sendMessage  发送人携带的信息
     * @param teamId       发送人所属团队
     * @param articleId    文章列表
     * @param patientSet  患者set集和
     * @param sendCode    发送人code、
     * @param sendName    发送人名称
     * @param sendMessage 发送人携带的信息
     * @param teamId      发送人所属团队
     * @param articleId   文章列表
     */
     */
    @Transactional
    @Transactional
    public HealthEduArticlePatient getSaveArticle(Set<String> patientSet,
    public HealthEduArticlePatient getSaveArticle(Set<String> patientSet,
                                                        String sendCode,
                                                        String sendName,
                                                        Integer sendType,
                                                        String sendMessage,
                                                        Long teamId,
                                                        String articleId) throws Exception{
                                                  String sendCode,
                                                  String sendName,
                                                  Integer sendType,
                                                  String sendMessage,
                                                  Long teamId,
                                                  String articleId) throws Exception {
        String batchNo = UUID.randomUUID().toString();
        String batchNo = UUID.randomUUID().toString();
@ -219,13 +223,13 @@ public class GcEduArticleService {
        //1、医生,2、卫计委
        //1、医生,2、卫计委
        //如果是卫计委得区别角色
        //如果是卫计委得区别角色
        Doctor doctor = null;
        Doctor doctor = null;
        if(sendType==2){
        if (sendType == 2) {
            String sql = "select r.code as roleCode from wlyy_user_role u " +
            String sql = "select r.code as roleCode from wlyy_user_role u " +
                    "left join wlyy_role r on r.`code`=u.role where u.user='"+sendCode+"'";
            Map<String,Object> result = jdbcTemplate.queryForMap(sql);
                    "left join wlyy_role r on r.`code`=u.role where u.user='" + sendCode + "'";
            Map<String, Object> result = jdbcTemplate.queryForMap(sql);
            //角色的code值
            //角色的code值
            healthEduArticlePatient.setSendCode(result.get("roleCode")+"");
        }else{
            healthEduArticlePatient.setSendCode(result.get("roleCode") + "");
        } else {
            doctor = doctorDao.findByCode(sendCode);
            doctor = doctorDao.findByCode(sendCode);
            healthEduArticlePatient.setSendCode(sendCode);
            healthEduArticlePatient.setSendCode(sendCode);
        }
        }
@ -237,9 +241,9 @@ public class GcEduArticleService {
            healthEduArticlePatient.setHospitalName(doctor.getHospitalName());
            healthEduArticlePatient.setHospitalName(doctor.getHospitalName());
            healthEduArticlePatient.setTown(doctor.getTown());
            healthEduArticlePatient.setTown(doctor.getTown());
            healthEduArticlePatient.setTownName(doctor.getTownName());
            healthEduArticlePatient.setTownName(doctor.getTownName());
            healthEduArticlePatient.setSendLevel(doctor.getLevel()!=null?String.valueOf(doctor.getLevel()):"");
            healthEduArticlePatient.setSendLevel(doctor.getLevel() != null ? String.valueOf(doctor.getLevel()) : "");
            healthEduArticlePatient.setSendPic(doctor.getPhoto());
            healthEduArticlePatient.setSendPic(doctor.getPhoto());
            healthEduArticlePatient.setSendSex(doctor.getSex()!=null?String.valueOf(doctor.getSex()):"");
            healthEduArticlePatient.setSendSex(doctor.getSex() != null ? String.valueOf(doctor.getSex()) : "");
        }
        }
        healthEduArticlePatient.setBatchNo(batchNo);
        healthEduArticlePatient.setBatchNo(batchNo);
        healthEduArticlePatient.setCreateTime(new Date());
        healthEduArticlePatient.setCreateTime(new Date());
@ -247,15 +251,15 @@ public class GcEduArticleService {
        //通过文章id 获取文章详情
        //通过文章id 获取文章详情
        JSONObject article = healthEducationArticleService.getArticalById(articleId);
        JSONObject article = healthEducationArticleService.getArticalById(articleId);
        healthEduArticlePatient.setArticleId(article.get("articleId")+"");
        healthEduArticlePatient.setAttachedTitle(article.get("articleTitle")+"");
        healthEduArticlePatient.setAttachedPic(article.get("articleCover")+"");
        healthEduArticlePatient.setAttachedContent(article.get("articleContent")+"");
        healthEduArticlePatient.setArticleId(article.get("articleId") + "");
        healthEduArticlePatient.setAttachedTitle(article.get("articleTitle") + "");
        healthEduArticlePatient.setAttachedPic(article.get("articleCover") + "");
        healthEduArticlePatient.setAttachedContent(article.get("articleContent") + "");
        healthEduArticlePatient.setAttachedMessage(sendMessage);
        healthEduArticlePatient.setAttachedMessage(sendMessage);
        healthEduArticlePatient.setArticleType(article.get("articleType")+"");
        healthEduArticlePatient.setLevel(article.get("articlelevel")+"");
        healthEduArticlePatient.setLevel1Type(article.get("firstLevelCategoryId")+"");
        healthEduArticlePatient.setLevel2Type(article.get("secondLevelCategoryId")+"");
        healthEduArticlePatient.setArticleType(article.get("articleType") + "");
        healthEduArticlePatient.setLevel(article.get("articlelevel") + "");
        healthEduArticlePatient.setLevel1Type(article.get("firstLevelCategoryId") + "");
        healthEduArticlePatient.setLevel2Type(article.get("secondLevelCategoryId") + "");
        healthEduArticlePatient.setType("1");//文章
        healthEduArticlePatient.setType("1");//文章
        healthEduArticlePatient.setArticleUrl("");
        healthEduArticlePatient.setArticleUrl("");
        healthEduArticlePatient.setPatients(patientList);
        healthEduArticlePatient.setPatients(patientList);
@ -269,7 +273,7 @@ public class GcEduArticleService {
        pagesize = page * pagesize;
        pagesize = page * pagesize;
        page = (page - 1) * pagesize;
        page = (page - 1) * pagesize;
        StringBuffer sql = new StringBuffer("select *,count(articleId) allCount from   " +esType+
        StringBuffer sql = new StringBuffer("select *,count(articleId) allCount from   " + esType +
                " where  sendCode='" + sendCode + "' ");
                " where  sendCode='" + sendCode + "' ");
        if (!StringUtils.isEmpty(articleType)) {
        if (!StringUtils.isEmpty(articleType)) {
            sql.append(" and  articleType='" + articleType + "'  ");
            sql.append(" and  articleType='" + articleType + "'  ");
@ -309,7 +313,7 @@ public class GcEduArticleService {
    }
    }
    private com.yihu.es.entity.HealthEduArticlePatient findOne(String articleId) {
    private com.yihu.es.entity.HealthEduArticlePatient findOne(String articleId) {
        String sql = "select level,level2Type,level1Type,attachedContent,attachedTitle,articleId,createTime,articleType,sendCode,sendName from "+esType+" where articleId='" + articleId + "' order by createTime desc limit 0,1";
        String sql = "select level,level2Type,level1Type,attachedContent,attachedTitle,articleId,createTime,articleType,sendCode,sendName from " + esType + " where articleId='" + articleId + "' order by createTime desc limit 0,1";
        com.yihu.es.entity.HealthEduArticlePatient esList = (com.yihu.es.entity.HealthEduArticlePatient) elasticsearchUtil.excuteOneObject(sql, com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType);
        com.yihu.es.entity.HealthEduArticlePatient esList = (com.yihu.es.entity.HealthEduArticlePatient) elasticsearchUtil.excuteOneObject(sql, com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType);
        return esList;
        return esList;
    }
    }
@ -382,38 +386,64 @@ public class GcEduArticleService {
//        patientSet.addAll(groupPatient);
//        patientSet.addAll(groupPatient);
//    }
//    }
    public void initPatient(Set<String> patientSet,String labelUnit,String labelSex,String labelServe,String labelDisease,String labelHealth){
    public void initPatient(Set<String> patientSet, String labelUnit, String labelSex, String labelServe, String labelDisease, String labelHealth) {
        //全选的时候前端传0,后台要去数据库再查询一次
        if ("0".equals(labelUnit)) {
            //查找全部的下属单位
            String sql = "select Group_concat(code) code  from dm_hospital  where level=2 and town = '350211'";
            labelUnit = jdbcTemplate.queryForObject(sql, String.class);
        }
        if ("0".equals(labelSex)) {
            //查找全部的性别
            labelSex = "1,2";
        }
        if ("0".equals(labelServe)) {
            //查找全部的服务类型
            String sql = "select Group_concat(s.code) from wlyy_sign_dict s where s.year='2017' order by s.sort asc";
            labelServe = jdbcTemplate.queryForObject(sql, String.class);
        }
        if ("0".equals(labelDisease)) {
            //查找全部的疾病标签
            String sql = "select Group_concat(s.label_code)  from wlyy_sign_patient_label s where s.label_type=3 and status=1";
            labelDisease = jdbcTemplate.queryForObject(sql, String.class);
        }
        if ("0".equals(labelHealth)) {
            //查找全部的健康情况
            String sql = "select Group_concat(s.label_code)  from wlyy_sign_patient_label s where s.label_type=2 and status=1";
            labelHealth = jdbcTemplate.queryForObject(sql, String.class);
        }
        String tableSql = " select p.code from wlyy_sign_family w ";
        String tableSql = " select p.code from wlyy_sign_family w ";
        String whereSql = " where w.status>0 and p.town='350211' ";
        String whereSql = " where w.status>0 and p.town='350211' ";
        if(!StringUtils.isEmpty(labelServe)){
        if (!StringUtils.isEmpty(labelServe)) {
            tableSql += " left join wlyy_sign_family_server s on w.code= s.sign_code ";
            tableSql += " left join wlyy_sign_family_server s on w.code= s.sign_code ";
            whereSql += " and s.server_type in ("+labelServe+" ) ";
            whereSql += " and s.server_type in (" + labelServe + " ) ";
        }
        }
        if(!StringUtils.isEmpty(labelHealth)||!StringUtils.isEmpty(labelDisease)){
        if (!StringUtils.isEmpty(labelHealth) || !StringUtils.isEmpty(labelDisease)) {
            tableSql += " left join wlyy_sign_patient_label_info l on w.patient=l.patient ";
            tableSql += " left join wlyy_sign_patient_label_info l on w.patient=l.patient ";
            whereSql += " and l.status=1 ";
            whereSql += " and l.status=1 ";
            whereSql += " and ( ";
            whereSql += " and ( ";
        }
        }
        if(!StringUtils.isEmpty(labelHealth)){
            whereSql += " (l.label_type = 2 AND l.label in ("+labelHealth+")) ";
        if (!StringUtils.isEmpty(labelHealth)) {
            whereSql += " (l.label_type = 2 AND l.label in (" + labelHealth + ")) ";
        }
        }
        if(!StringUtils.isEmpty(labelDisease)){
            if(!whereSql.endsWith(" and ( ")) {
                whereSql += " or (l.label_type = 3 AND l.label in ("+labelDisease+"))) ";
            }else{
                whereSql += " (l.label_type = 1 AND l.label in ("+labelDisease+"))) ";
        if (!StringUtils.isEmpty(labelDisease)) {
            if (!whereSql.endsWith(" and ( ")) {
                whereSql += " or (l.label_type = 3 AND l.label in (" + labelDisease + "))) ";
            } else {
                whereSql += " (l.label_type = 1 AND l.label in (" + labelDisease + "))) ";
            }
            }
        }
        }
        tableSql += " left join wlyy_patient p on p.code=w.patient ";
        tableSql += " left join wlyy_patient p on p.code=w.patient ";
        if(!StringUtils.isEmpty(labelSex)){
            whereSql += " and p.sex in ("+labelSex+") ";
        if (!StringUtils.isEmpty(labelSex)) {
            whereSql += " and p.sex in (" + labelSex + ") ";
        }
        }
        if(!StringUtils.isEmpty(labelUnit)){
            whereSql += " and w.hospital in ("+labelUnit+") ";
        if (!StringUtils.isEmpty(labelUnit)) {
            whereSql += " and w.hospital in (" + labelUnit + ") ";
        }
        }
        List<String> groupPatient = jdbcTemplate.queryForList(tableSql+whereSql, String.class);
        List<String> groupPatient = jdbcTemplate.queryForList(tableSql + whereSql, String.class);
        patientSet.addAll(groupPatient);
        patientSet.addAll(groupPatient);
    }
    }
@ -457,25 +487,22 @@ public class GcEduArticleService {
//    }
//    }
    public List<HealthEduArticlePatientModel> pushArticleLogs(int page, int pagesize,String sendCode) throws Exception{
    public List<HealthEduArticlePatientModel> pushArticleLogs(int page, int pagesize, String sendCode) throws Exception {
        pagesize = page * pagesize;
        pagesize = page * pagesize;
        page = (page - 1) * pagesize;
        page = (page - 1) * pagesize;
        String sql = "select r.code as roleCode from wlyy_user_role u " +
        String sql = "select r.code as roleCode from wlyy_user_role u " +
                "left join wlyy_role r on r.`code`=u.role where u.user='"+sendCode+"'";
                "left join wlyy_role r on r.`code`=u.role where u.user='" + sendCode + "'";
        Map<String,Object> resultMap = jdbcTemplate.queryForMap(sql);
        Map<String, Object> resultMap = jdbcTemplate.queryForMap(sql);
        sendCode = resultMap.get("roleCode").toString();
        sendCode = resultMap.get("roleCode").toString();
        StringBuffer sql2 = new StringBuffer("select *  from   " +esType+
        StringBuffer sql2 = new StringBuffer("select *  from   " + esType +
                " where  sendCode='" + sendCode + "' ");
                " where  sendCode='" + sendCode + "' ");
        sql2.append("  order by createTime limit " + page + "," + pagesize);
        sql2.append("  order by createTime limit " + page + "," + pagesize);
        List<com.yihu.es.entity.HealthEduArticlePatient> esList = elasticsearchUtil.excute(sql2.toString(), com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType);
        List<com.yihu.es.entity.HealthEduArticlePatient> esList = elasticsearchUtil.excute(sql2.toString(), com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType);
        List<HealthEduArticlePatientModel> returnList = new ArrayList<>();
        Map<String,HealthEduArticlePatientModel> result = new HashMap<>();
        Map<String, HealthEduArticlePatientModel> result = new HashMap<>();
        HealthEduArticlePatientModel heapm = null;
        HealthEduArticlePatientModel heapm = null;
        com.alibaba.fastjson.JSONObject article = null;
        com.alibaba.fastjson.JSONObject article = null;
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXX");
        for(HealthEduArticlePatient one :esList){
        for (HealthEduArticlePatient one : esList) {
            article = healthEducationArticleService.getArticalById(one.getArticleId());
            article = healthEducationArticleService.getArticalById(one.getArticleId());
//            com.yihu.es.entity.HealthEduArticlePatient p = findOne(one.getArticleId());
//            com.yihu.es.entity.HealthEduArticlePatient p = findOne(one.getArticleId());
//            if (p != null) {
//            if (p != null) {
@ -484,10 +511,10 @@ public class GcEduArticleService {
//                BeanUtils.copyProperties(p, heapm);
//                BeanUtils.copyProperties(p, heapm);
//                returnList.add(heapm);
//                returnList.add(heapm);
//            }
//            }
            if(result.get(one.getArticleId())!=null){
            if (result.get(one.getArticleId()) != null) {
                heapm = result.get(one.getArticleId());
                heapm = result.get(one.getArticleId());
            }else{
            } else {
                heapm = new HealthEduArticlePatientModel();
                heapm = new HealthEduArticlePatientModel();
            }
            }
            heapm.setSendName(one.getSendName());
            heapm.setSendName(one.getSendName());
@ -500,34 +527,64 @@ public class GcEduArticleService {
            heapm.setLevel1Type(article.getString("firstLevelCategoryId"));
            heapm.setLevel1Type(article.getString("firstLevelCategoryId"));
            heapm.setLevel2Type(article.getString("secondLevelCategoryId"));
            heapm.setLevel2Type(article.getString("secondLevelCategoryId"));
            heapm.setLevel(article.getString("articlelevel"));
            heapm.setLevel(article.getString("articlelevel"));
            heapm.setAllCount(heapm.getAllCount()+one.getPatients().size());
            heapm.setBrowseNumbere(article.getInteger("browseNumber"));
            heapm.setCommentNumber(article.getInteger("commentNumber"));
            result.put(one.getArticleId(),heapm);
        };
        List< HealthEduArticlePatientModel > resultList = new ArrayList<>();
        for (Map.Entry< String, HealthEduArticlePatientModel > entry : result.entrySet()) {
            heapm.setAllCount(heapm.getAllCount() + one.getPatients().size());
            heapm.setBrowseNumbere(Integer.valueOf(article.getString("browseNumber")));//文章浏览数
            heapm.setCommentNumber(Integer.valueOf(article.getString("commentNumber")));//文章评论数
            heapm.setPointNumber(Integer.valueOf(article.getString("pointNumber")));//文章点赞数
            heapm.setArticleCover(article.getString("articleCover"));//封面
            heapm.setComputeTime(computeTime(article.getString("insertTime")));
            // heapm.setTime();//时间  xx小时前  2017-10-11
            result.put(one.getArticleId(), heapm);
        }
        List<HealthEduArticlePatientModel> resultList = new ArrayList<>();
        for (Map.Entry<String, HealthEduArticlePatientModel> entry : result.entrySet()) {
            resultList.add(entry.getValue());
            resultList.add(entry.getValue());
        }
        }
        return resultList;
        return resultList;
    }
    }
    public static String computeTime(String create) {
        Date createDate = DateUtil.strToDate(create, "yyyy-MM-dd HH:mm:ss.SSS");
        Date nowDate = new Date();
        //计算2个时间差
        Long l = nowDate.getTime() - createDate.getTime();
        long hour = l / (60 * 60 * 1000); //小时
        long min = l / (60 * 1000);//分钟
        long s = l / 1000;//秒
        if(s<60){
            return s+"秒前";
        }
        if(min<60){
            return min+"分钟前";
        }
        if(hour<24){
            return hour+"小时前";
        }
        return DateUtil.dateToStr(createDate,"yyyy-MM-dd");
    }
    public static void main(String[] args) {
        System.out.println(computeTime("2017-11-16 13:32:00.010"));
    }
    public Long pushArticleLogsCount(String sendCode) {
    public Long pushArticleLogsCount(String sendCode) {
        StringBuffer sql = new StringBuffer("select count(distinct articleId) count  from   " +esType+
        StringBuffer sql = new StringBuffer("select count(distinct articleId) count  from   " + esType +
                " where  sendCode='" + sendCode + "' ");
                " where  sendCode='" + sendCode + "' ");
        return elasticsearchUtil.excuteForLong(sql.toString(), esIndex, esType);
        return elasticsearchUtil.excuteForLong(sql.toString(), esIndex, esType);
    }
    }
    public JSONObject pushArticleConfirm(String articleId, String labelUnit,String labelSex,String labelServe,String labelDisease,String labelHealth) throws Exception{
    public JSONObject pushArticleConfirm(String articleId, String labelUnit, String labelSex, String labelServe, String labelDisease, String labelHealth) throws Exception {
        JSONObject article = healthEducationArticleService.getArticalById(articleId);
        JSONObject article = healthEducationArticleService.getArticalById(articleId);
        Set<String> patientSet = new HashSet<>();
        Set<String> patientSet = new HashSet<>();
        initPatient(patientSet,labelUnit,labelSex,labelServe,labelDisease,labelHealth);
        initPatient(patientSet, labelUnit, labelSex, labelServe, labelDisease, labelHealth);
        long num = patientSet.size();
        long num = patientSet.size();
        JSONObject result = new JSONObject();
        JSONObject result = new JSONObject();
        result.put("num",num);
        result.put("articleTitle",article.getString("articleTitle"));
        result.put("num", num);
        result.put("articleTitle", article.getString("articleTitle"));
        return result;
        return result;
    }
    }
}
}

+ 30 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/vo/HealthEduArticlePatientModel.java

@ -41,6 +41,12 @@ public class HealthEduArticlePatientModel {
    private Integer browseNumbere=0;//文章浏览数
    private Integer browseNumbere=0;//文章浏览数
    @ApiModelProperty(value = "文章评论数", required = false, access = "response")
    @ApiModelProperty(value = "文章评论数", required = false, access = "response")
    private Integer commentNumber=0;//文章评论数
    private Integer commentNumber=0;//文章评论数
    @ApiModelProperty(value = "文章点赞数", required = false, access = "response")
    private Integer pointNumber=0;//文章点赞数
    @ApiModelProperty(value = "封面图", required = false, access = "response")
    private String articleCover="";//封面图
    private String computeTime;//时间
    public String getSendCode() {
    public String getSendCode() {
        return sendCode;
        return sendCode;
@ -145,4 +151,28 @@ public class HealthEduArticlePatientModel {
    public void setCommentNumber(Integer commentNumber) {
    public void setCommentNumber(Integer commentNumber) {
        this.commentNumber = commentNumber;
        this.commentNumber = commentNumber;
    }
    }
    public Integer getPointNumber() {
        return pointNumber;
    }
    public void setPointNumber(Integer pointNumber) {
        this.pointNumber = pointNumber;
    }
    public String getArticleCover() {
        return articleCover;
    }
    public void setArticleCover(String articleCover) {
        this.articleCover = articleCover;
    }
    public String getComputeTime() {
        return computeTime;
    }
    public void setComputeTime(String computeTime) {
        this.computeTime = computeTime;
    }
}
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/resources/application-prod.yml

@ -118,5 +118,5 @@ activemq:
##如果是外网项目就是flase 内网是true
##如果是外网项目就是flase 内网是true
neiwang:
neiwang:
  enable: false
  enable: true
  wlyy: http://59.61.92.90:8072/wlyy
  wlyy: http://59.61.92.90:8072/wlyy