Browse Source

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/web/third/synergy/SynergyManagerController.java
liuwenbin 6 years ago
parent
commit
ba63ec8ac2
18 changed files with 517 additions and 53 deletions
  1. 4 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/Patient.java
  2. 9 5
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/survey/SurveyTemplateDao.java
  3. 26 6
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/patient/AdminPatientService.java
  4. 32 21
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/SynergyManageService.java
  5. 174 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/util/ISqlUtils.java
  6. 9 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java
  7. 28 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/AlertChildImmuneVaccinJob.java
  8. 170 3
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/imm/ChildVaccinImmuneService.java
  9. 2 0
      patient-co/patient-co-wlyy-job/src/main/resources/application-dev.yml
  10. 2 0
      patient-co/patient-co-wlyy-job/src/main/resources/application-devtest.yml
  11. 2 0
      patient-co/patient-co-wlyy-job/src/main/resources/application-test.yml
  12. 3 0
      patient-co/patient-co-wlyy-job/src/main/resources/system.properties
  13. 4 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/imm/ChildImmuneVaccinDao.java
  14. 2 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  15. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/imm/ChildFamilyImmuneService.java
  16. 4 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistEvaluateSevice.java
  17. 2 14
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/imm/DoctorImmController.java
  18. 43 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/synergy/SynergyManagerController.java

+ 4 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/Patient.java

@ -28,23 +28,27 @@ public class Patient extends IdEntity implements Serializable {
    // 业务主键
    private String code;
    // 身份证号
    @Column(name = "idcard")
    private String idcard;
    // 登录密码
    private String password;
    private String salt;
    // 姓名
    @Column(name = "name")
    private String name;
    // 生日
    private Date birthday;
    // 性別,1男,2女
    private Integer sex;
    // 手機號
    @Column(name = "mobile")
    private String mobile;
    // (基卫)手機號
    private String mobileRemarks;
    // 聯繫電話
    private String phone;
    // 社保卡號
    @Column(name = "ssc")
    private String ssc;
    // 頭像HTTP地址
    private String photo;

+ 9 - 5
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/survey/SurveyTemplateDao.java

@ -10,9 +10,13 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 * Created by yeshijie on 2017/3/7.
 */
public interface SurveyTemplateDao extends PagingAndSortingRepository<SurveyTemplate,Long>,JpaSpecificationExecutor<SurveyTemplate> {
        @Query("from SurveyTemplate where title=?1 and del = 1")
        SurveyTemplate findByTitle(String title);
        @Query("update SurveyTemplate set del = 0 where id=?1 and del = 1")
        @Modifying
        void deleteById(Long id);
    @Query("from SurveyTemplate where title=?1 and del = 1")
    SurveyTemplate findByTitle(String title);
    @Query("update SurveyTemplate set del = 0 where id=?1 and del = 1")
    @Modifying
    void deleteById(Long id);
    @Query("select t.diseaseType from SurveyTemplate t where t.code = ?1")
    String findByCode(String code);
}

+ 26 - 6
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/patient/AdminPatientService.java

@ -6,18 +6,23 @@ import com.yihu.wlyy.entity.SocialSecurityInfo;
import com.yihu.wlyy.repository.PatientDao;
import com.yihu.wlyy.repository.SignFamilyDao;
import com.yihu.wlyy.repository.SocialSecurityInfoDao;
import com.yihu.wlyy.util.ISqlUtils;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.util.query.BaseJpaService;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
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.util.StringUtils;
import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
 * Created by yww on 2016/10/8.
@ -31,10 +36,25 @@ public class AdminPatientService extends BaseJpaService<Patient,Long> {
    @Autowired
    private SocialSecurityInfoDao socialSecurityInfoDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public Page<Patient> searchPatientList(String name,String idcard,String ssc,String mobile,Integer openIdStatus,int page,int pageSize) throws Exception{
        if (page <= 0) {
        Patient patient = new Patient();
        patient.setName(name);
        patient.setIdcard(idcard);
        patient.setSsc(ssc);
        patient.setMobile(mobile);
        PageRequest pageRequest = new PageRequest(page - 1, pageSize);
        String sql = ISqlUtils.getSql(patient,page,pageSize,"*",openIdStatus);
        List<Patient> patients = jdbcTemplate.query(sql,new BeanPropertyRowMapper(Patient.class));
        String sqlcount = new ISqlUtils().getSql(patient,0,0,"count",openIdStatus);
        List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sqlcount);
        Long count = 0L;
        if(rstotal!=null&&rstotal.size()>0){
            count = (Long) rstotal.get(0).get("total");
        }
        /*if (page <= 0) {
            page = 1;
        }
        if (pageSize <= 0) {
@ -83,8 +103,8 @@ public class AdminPatientService extends BaseJpaService<Patient,Long> {
        int count = ((Number) queryCount.iterate().next()).intValue();
        queryList.setFirstResult(pageSize * (page - 1));
        queryList.setMaxResults(pageSize);
        List<Patient> list = queryList.list();
        return new PageImpl<Patient>(list,pageRequest,count);
        List<Patient> list = queryList.list();*/
        return new PageImpl<Patient>(patients,pageRequest,count);
    }
    //列表查询-分页

+ 32 - 21
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/SynergyManageService.java

@ -5,12 +5,11 @@ import com.yihu.wlyy.entity.*;
import com.yihu.wlyy.entity.call.CallRecord;
import com.yihu.wlyy.entity.synergy.*;
import com.yihu.wlyy.repository.*;
import com.yihu.wlyy.repository.survey.SurveyTemplateDao;
import com.yihu.wlyy.repository.synergy.*;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
import com.yihu.wlyy.util.http.HttpUtils;
import com.yihu.wlyy.util.query.BaseJpaService;
import jxl.Workbook;
import jxl.write.*;
@ -42,8 +41,6 @@ import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.*;
import static org.springframework.util.ResourceUtils.getFile;
/**
 * Created by 刘文彬 on 2018/9/27.
 */
@ -80,11 +77,7 @@ public class SynergyManageService extends BaseJpaService {
    @Autowired
    private ManageSynergyWorkorderServicerLogDao manageSynergyWorkorderServicerLogDao;
    @Autowired
    private TownDao townDao;
    @Autowired
    private FastDFSUtil fastDFSUtil;
    @Autowired
    private ManageCustomerOnlineRecordDao manageCustomerOnlineRecordDao;
    private SurveyTemplateDao surveyTemplateDao;
    @Autowired
    private ManageSynergyAccessoryDao manageSynergyAccessoryDao;
@ -362,6 +355,7 @@ public class SynergyManageService extends BaseJpaService {
        map.put("serviceTime", s.format(workorderDO.getServiceTime()));
        map.put("status", status);
        map.put("title", workorderDO.getRelationCodeName());
        map.put("relationCode", workorderDO.getRelationCode());
        map.put("remark", workorderDO.getRemark());
        map.put("createTime", sdf.format(workorderDO.getCreateTime()));
        map.put("createUserName", workorderDO.getCreateUserName());
@ -390,6 +384,9 @@ public class SynergyManageService extends BaseJpaService {
            map.put("patientName", workorderServicerDO.get(0).getServicePatientName());
            map.put("idcard", workorderServicerDO.get(0).getIdcard());
            map.put("ssc", workorderServicerDO.get(0).getSsc());
        }else if(workorderDO.getType() == 5) {
            String diseaseType = surveyTemplateDao.findByCode(workorderDO.getRelationCode());
            map.put("diseaseType", diseaseType);
        }
        //超时标签
@ -628,7 +625,7 @@ public class SynergyManageService extends BaseJpaService {
     * @param type
     */
    public void sendMessage(ManageSynergyWorkorderDO workorderDO, User user, Integer type){
        String url = wlyyUrl + "doctor/message/sendMessage";
        String url = wlyyUrl + "third/synergy/sendMessage";
        //组装message内容
        JSONObject message = new JSONObject();
        if(type == 24){
@ -644,7 +641,17 @@ public class SynergyManageService extends BaseJpaService {
        }
        //组装jsonObject内容
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("type", workorderDO.getType());
        Integer servicerType = workorderDO.getType();
        //协同服务类型
        if(servicerType == 1){
            jsonObject.put("type", "健康教育");
        }else if(servicerType == 3){
            jsonObject.put("type", "随访");
        }else if(servicerType == 4){
            jsonObject.put("type", "调查问卷");
        }else if(servicerType == 5){
            jsonObject.put("type", "疾病筛查");
        }
        if(type == 26){
            jsonObject.put("returnedRemark", workorderDO.getReturnedRemark());
        }else if(type == 25){
@ -1518,16 +1525,18 @@ public class SynergyManageService extends BaseJpaService {
        for(CallRecord callRecord : list){
            if (callRecord.getAnswerStatus()==1){
                String talkTime = callRecord.getTalkTime();
                String[] talkTimeStr = talkTime.split(":");
                for (int i=0;i<talkTimeStr.length;i++){
                    if (i==0){
                        hours += Integer.valueOf(talkTimeStr[i]);
                    }
                    if (i==1){
                        minutes += Integer.valueOf(talkTimeStr[i]);
                    }
                    if (i==2){
                        seconds += Integer.valueOf(talkTimeStr[i]);
                if (StringUtils.isNotBlank(talkTime)){
                    String[] talkTimeStr = talkTime.split(":");
                    for (int i=0;i<talkTimeStr.length;i++){
                        if (i==0){
                            hours += Integer.valueOf(talkTimeStr[i]);
                        }
                        if (i==1){
                            minutes += Integer.valueOf(talkTimeStr[i]);
                        }
                        if (i==2){
                            seconds += Integer.valueOf(talkTimeStr[i]);
                        }
                    }
                }
            }
@ -1681,6 +1690,8 @@ public class SynergyManageService extends BaseJpaService {
                " AND r.create_time <= '"+endTime+"'";
        //正在咨询人数
        String consultSql="SELECT COUNT(*) consultNum FROM manage_call_record WHERE answer_status=1 AND (end_time IS NULL or end_time ='')";
        map.put("consultNum",jdbcTemplate.queryForMap(consultSql).get("consultNum"));
        //当前客服人数
        map.put("onlineNowCount",userList.size());

+ 174 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/util/ISqlUtils.java

@ -0,0 +1,174 @@
package com.yihu.wlyy.util;/**
 * Created by nature of king on 2018/4/27.
 */
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import javax.persistence.Column;
import javax.persistence.Table;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
 * @author wangzhinan
 * @create 2018-04-27 12:47
 * @desc sql自定义编辑
 **/
public class ISqlUtils {
    public static String getSql(Object object,Integer page,Integer size,String isFlag,Integer openIdStatus){
        StringBuffer sb = new StringBuffer();
        Class c =object.getClass();
        Table table = (Table)c.getAnnotation(Table.class);
        String tableName = table.name();
        if (isFlag.equalsIgnoreCase("count")){
            sb.append("select count(1) AS total from ").append(tableName).append(" where 1=1");
        }else if(isFlag.equalsIgnoreCase("*")){
            sb.append("select * from ").append(tableName).append(" where 1=1 ");
        }
        JSONObject object1  = (JSONObject) JSONObject.toJSON(object);
        if (object1.getString("id") !=null){
            sb.append(" and id = '" + object1.getString("id")+"' ");
        }
        Field[] fArray= c.getDeclaredFields();
        for(Field f:fArray){
                //拿到字段后与实体类中的属性匹配,并得到其get方法,用来获取他的属性值
                String getMethodName ="";
                boolean isCExist =f.isAnnotationPresent(Column.class);
                if(isCExist){
                    Column mc =f.getAnnotation(Column.class);
                    String columeName =mc.name();  //字段对应数据库名字
                    String name =f.getName();       //字段名字
                    Class a= f.getType();          //字段类型
                    Object value=null;              //字段值
                    getMethodName="get"+name.substring(0,1).toUpperCase()+name.substring(1);//拼接属性的get方法
                    try {
                        Method m =c.getMethod(getMethodName);
                        value =(Object)m.invoke(object);     //拿到属性的值
                        if(value == null || "".equals(value)){  //如果属性没值,不拼接sql
                            continue;
                        }
                        else if(value instanceof String){
                            value ="'%"+value+"%'";
                            sb.append(" and ").append(columeName +" like " ).append(value+"");
                        }else if (value instanceof Integer){
                            value = value;
                            sb.append(" and ").append(columeName +" = " ).append(value+"");
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
        }
        JSONObject jsonObject = (JSONObject) JSONObject.toJSON(object);
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date1 = jsonObject.getDate("startTime");
        Date date2 = jsonObject.getDate("endTime");
        String startTime = null;
        String endTime = null;
        if (date1 != null){
             startTime = sdf.format(date1);
        }
        if (date2 != null) {
            endTime = sdf.format(date2);
        }
        if (StringUtils.isNoneBlank(startTime)&& StringUtils.isNoneBlank(endTime)){
            sb.append(" and start_time >= '"+startTime+"' and end_time <='"+endTime+"'");
        } else if (StringUtils.isNoneBlank(startTime)&&!StringUtils.isNoneBlank(endTime)) {
            sb.append(" and start_time >= '"+startTime+"'");
        }else if (StringUtils.isNoneBlank(endTime)&&!StringUtils.isNoneBlank(startTime)){
            sb.append(" and end_time <= '"+endTime+"'");
        }
        if(openIdStatus != null && openIdStatus== 2){
            sb.append(" and ( openid = '' or  openid is null)");
        }
        if(openIdStatus != null && openIdStatus == 3){
            sb.append(" and (openid != '' and openid is not null) ");
        }
        if(isFlag.equalsIgnoreCase("*")){
            sb.append(" ORDER BY czrq DESC ").append("LIMIT ").append((page-1)*size+",").append(size);
        }
        return sb.toString();
    }
    public static String getAllSql(Object object){
        StringBuffer sb = new StringBuffer();
        Class c =object.getClass();
        Table table = (Table)c.getAnnotation(Table.class);
        String tableName = table.name();
        sb.append("select * from ").append(tableName).append(" where 1=1 ");
        Field[] fArray= c.getDeclaredFields();
        for(Field f:fArray){
            //拿到字段后与实体类中的属性匹配,并得到其get方法,用来获取他的属性值
            String getMethodName ="";
            boolean isCExist =f.isAnnotationPresent(Column.class);
            if(isCExist){
                Column mc =f.getAnnotation(Column.class);
                String columeName =mc.name();  //字段对应数据库名字
                String name =f.getName();       //字段名字
                Object value=null;              //字段值
                getMethodName="get"+name.substring(0,1).toUpperCase()+name.substring(1);//拼接属性的get方法
                try {
                    Method m =c.getMethod(getMethodName);
                    value =(Object)m.invoke(object);     //拿到属性的值
                    if(value == null || "".equals(value) || value.equals(Integer.parseInt("0"))){  //如果属性没值,不拼接sql
                        continue;
                    }
                    else if(value instanceof String){
                        value ="'"+value+"'";
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                sb.append(" and ").append(columeName +"=" ).append(value+"");
            }
        }
        return sb.toString();
    }
    public static  String getUpdateSql(Object object){
        StringBuffer sb = new StringBuffer();
        Class c = object.getClass();
        Table table = (Table)c.getAnnotation(Table.class);
        String tableName = table.name();
        sb.append("update ").append(tableName).append(" set ");
        Field[] fArray = c.getDeclaredFields();
        for (Field f:fArray){
            String getMethoName = "";
            boolean isCExist = f.isAnnotationPresent(Column.class);
            if (isCExist){
                Column mc = f.getAnnotation(Column.class);
                String columeName = mc.name();
                String name = f.getName();
                Class a= f.getType();
                Object value= null;
                getMethoName = "get" + name.substring(0,1).toUpperCase()+name.substring(1);
                try {
                    Method m = c.getMethod(getMethoName);
                    if (Date.class.isAssignableFrom(a)){
                        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        value = sdf.format((Object)m.invoke(object));
                    }else {
                        value = (Object)m.invoke(object);
                    }
                    if (value == null || "".equals(value)){
                        continue;
                    }
                    else if (value instanceof  String){
                        value = "'"+value+"'";
                    }
                }catch (Exception e){
                    e.printStackTrace();
                }
                sb.append(columeName + "=").append(value+"").append(",");
            }
        }
        sb.deleteCharAt(sb.length()-1);
        JSONObject jsonObject = (JSONObject) JSONObject.toJSON(object);
        sb.append(" where ").append("id = ").append("'"+jsonObject.get("id")+"'");
        return sb.toString();
    }
}

+ 9 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java

@ -292,6 +292,15 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
                logger.info("child_immune_vaccin_job  job exist");
            }
            //获取儿童可预约疫苗,每天凌晨1点执行一次
            if (!quartzHelper.isExistJob("alert_child_immune_vaccin_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("alert_child_immune_vaccin_job");
                quartzHelper.addJob(AlertChildImmuneVaccinJob.class, trigger, "alert_child_immune_vaccin_job", new HashMap<String, Object>());
                logger.info("alert_child_immune_vaccin_job  job success");
            } else {
                logger.info("alert_child_immune_vaccin_job  job exist");
            }
        } catch (Exception e) {
            logger.info("sign end job start failed");
        }

+ 28 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/AlertChildImmuneVaccinJob.java

@ -0,0 +1,28 @@
package com.yihu.wlyy.job;
import com.yihu.wlyy.service.imm.ChildVaccinImmuneService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
public class AlertChildImmuneVaccinJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(AlertChildImmuneVaccinJob.class);
    @Autowired
    private ChildVaccinImmuneService childVaccinImmuneService;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        logger.info("START========每天九点提醒居民待接种JOB========");
        try {
            childVaccinImmuneService.alertBefore();
            logger.info("END========每天九点提醒居民待接种JOB========");
        }catch (Exception e){
            e.printStackTrace();
            logger.info("END===ERROE===每天九点提醒居民待接种JOB,message:"+e.getMessage());
        }
    }
}

+ 170 - 3
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/imm/ChildVaccinImmuneService.java

@ -1,16 +1,28 @@
package com.yihu.wlyy.service.imm;
import com.yihu.es.entity.PatientRemindRecordESDO;
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.imm.ChildFamilyImmune;
import com.yihu.wlyy.entity.imm.ChildImmuneVaccin;
import com.yihu.wlyy.entity.imm.ChildInfo;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.imm.ChildImmuneVaccinDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.third.jw.ImmuneService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import io.searchbox.client.JestClient;
import org.apache.commons.lang.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -24,21 +36,38 @@ import java.util.*;
 */
@Service
public class ChildVaccinImmuneService extends BaseService {
	
	private static org.slf4j.Logger logger = LoggerFactory.getLogger(ChildVaccinImmuneService.class);
	@Autowired
	private JdbcTemplate jdbcTemplate;
	@Autowired
	private ChildImmuneVaccinDao childImmuneVaccinDao;
	@Autowired
	private ImmuneService immuneService;
	@Autowired
	private DoctorDao doctorDao;
	@Value("${es.type.patientRemindRecord}")
	private String esType;
	@Value("${es.index.patientRemindRecord}")
	private String esIndex;
	@Autowired
	private WechatTemplateConfigDao templateConfigDao;
	@Autowired
	private PushMsgTask pushMsgTask;
	@Autowired
	private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
	@Autowired
	private ElasticFactory elasticFactory;
	@Autowired
	private ElastricSearchSave elastricSearchSave;
	
	@Transactional(rollbackFor = Exception.class)
	public int getChildImmuneVaccinEveryDay()throws Exception{
		int result = 0;
		try {
			String sql ="SELECT" +
			/*String sql ="SELECT" +
					" DISTINCT ci.`code`," +
					" ci.idcard," +
					" ci.`name`," +
@ -48,7 +77,9 @@ public class ChildVaccinImmuneService extends BaseService {
					" wlyy_child_family_immune fi" +
					" LEFT JOIN wlyy_child_info ci ON fi.child_code = ci.`code`" +
					" WHERE" +
					" fi.del = 0";
					" fi.del = 0";*/
            String sql ="SELECT `code`,`name`,idcard,ssc FROM wlyy_child_info WHERE del=0";
			List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
			for (Map<String,Object> map : list){
				String barcode = String.valueOf(map.get("barcode"));
@ -165,4 +196,140 @@ public class ChildVaccinImmuneService extends BaseService {
		}
		return result;
	}
	public int alertBefore()throws Exception{
		JSONArray jsonArray =  new JSONArray();
		String sql ="SELECT" +
				" v.*, i.birthday" +
				" FROM" +
				" wlyy_child_immune_vaccin v" +
				" LEFT JOIN wlyy_child_info i ON v.child_info_code = i.`code`" +
				" WHERE" +
				" v.del = 0" +
				" AND ymkc = 'true'";
		List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
		String nowDate = DateUtil.dateToStrShort(new Date());
		for (Map<String,Object> map : mapList){
			Calendar calendar=Calendar.getInstance();
			String birthDayStr = String.valueOf(map.get("birthday"));
			if (StringUtils.isNotBlank(birthDayStr)){
				String[] biStr = birthDayStr.split("-");
				int birthdayDate = Integer.valueOf(biStr[biStr.length-1]);
				int nowDayDate = calendar.get(GregorianCalendar.DAY_OF_MONTH);
				int nowMonthDate = calendar.get(GregorianCalendar.MONTH)+1;
				int nowYearDate = calendar.get(GregorianCalendar.YEAR);
				//如果生日在今天的日期之前,则取下个月生日的日期的15天的是否是今天.
				if (birthdayDate<nowDayDate){
					calendar.set(nowYearDate,nowMonthDate+1,birthdayDate);
				}else {
					//如果生日在今天之前后,则看生日的15天之前是否是今天
					calendar.set(nowYearDate,nowMonthDate,birthdayDate);
				}
				String needAlertDate = DateUtil.dateToStrShort(DateUtil.getPreDays(calendar.getTime(),-15));
				if (needAlertDate.equals(nowDate)){
					JSONObject jsonObject = new JSONObject();
					jsonObject.put("vaccinCode",map.get("code"));//待接种疫苗记录code
					jsonObject.put("childName", map.get("name"));//儿童姓名
					jsonObject.put("childCode", map.get("child_info_code"));//儿童code
					jsonObject.put("vaccinName", map.get("ymmc"));//疫苗名称
					jsonArray.put(jsonObject);
				}
			}
		}
		return alertImmVacclinByChildInfoCodes(jsonArray.toString());
	}
	public int alertImmVacclinByChildInfoCodes(String alertDataJsonStr)throws Exception{
		if (StringUtils.isEmpty(alertDataJsonStr)){
			return -1;
		}
		List<PatientRemindRecordESDO> patientRemindRecordESDOList = new ArrayList<>();
		JSONArray jsonArray = new JSONArray(alertDataJsonStr);
		for (int i=0;i<jsonArray.length();i++){
			JSONObject jsonObject = jsonArray.getJSONObject(i);
			String childCode = jsonObject.getString("childCode");
			String childName = jsonObject.getString("childName");
			String vaccinName = jsonObject.getString("vaccinName");
			String vaccinCode = jsonObject.getString("vaccinCode");
			String sql ="SELECT" +
					" cfi.relation," +
					" p.`code`," +
					" p.`name`," +
					" p.openid" +
					" FROM" +
					" wlyy_child_family_immune cfi" +
					" LEFT JOIN wlyy_patient p ON cfi.family_code = p.`code`" +
					" WHERE" +
					" cfi.child_code = '"+childCode+"'" +
					" AND cfi.del = 0 and (p.openid is not null or p.openid !='')";
			List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
			if (list.size()==0){
				return -10000;
			}
			List<String> openIdList = new ArrayList<>();
			for (Map<String,Object> map : list){
				//如果父母亲都在就都发
				if (!openIdList.contains(String.valueOf(map.get("openid")))){
					if (("1".equals(String.valueOf(map.get("relation"))) || "2".equals(String.valueOf(map.get("relation")))) && StringUtils.isNotBlank(String.valueOf(map.get("openid")))){
						boolean flag =true;
						try {
							WechatTemplateConfig temp = templateConfigDao.findByScene("template_deal_with_job", "dsymjztx");
							JSONObject json = new JSONObject();
							json.put("toUser",String.valueOf(map.get("code")));
							json.put("keyword1", temp.getKeyword1().replace("key1",DateUtil.dateToStr(new Date(), "yyyy-MM-dd")));
							json.put("keyword2", temp.getKeyword2().replace("key1", vaccinName));
							json.put("remark", temp.getRemark());
							json.put("first", temp.getFirst().replace("key1", childName));
							logger.info("weiTempJOSN:"+json.toString());
							pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 24,String.valueOf(map.get("openid")) , String.valueOf(map.get("name")), json);
						}catch (Exception e){
							e.printStackTrace();
							flag = false;
						}
						//发送微信消息并且插入一条es提醒数据
						PatientRemindRecordESDO patientRemindRecordESDO =  new PatientRemindRecordESDO();
						patientRemindRecordESDO.setCode(getCode());
						patientRemindRecordESDO.setPatient(String.valueOf(map.get("code")));
						patientRemindRecordESDO.setPatientName(String.valueOf(map.get("name")));
						patientRemindRecordESDO.setDoctor("admin");
						patientRemindRecordESDO.setDoctorName("admin");
						patientRemindRecordESDO.setCreateDate(new Date());
						patientRemindRecordESDO.setRemindType(1);
						if (flag) {
							patientRemindRecordESDO.setStatus(1);
							String update="UPDATE wlyy_child_immune_vaccin SET alert_tag=1,alert_time='"+DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD_HH_MM_SS)+"' where `code`='"+vaccinCode+"'";
							jdbcTemplate.update(update);
						}else {
							patientRemindRecordESDO.setStatus(0);
						}
						patientRemindRecordESDOList.add(patientRemindRecordESDO);
					}
				}
			}
		}
		//保存到es的提醒日志表中
		esSavePatientRemindRecord(patientRemindRecordESDOList);
		return 200;
	}
	public boolean esSavePatientRemindRecord(List<PatientRemindRecordESDO> patientRemindRecordESDOList)throws Exception{
		JestClient jestClient = null;
		boolean flag = true;
		try {
			jestClient = elasticFactory.getJestClient();
			if(patientRemindRecordESDOList != null && patientRemindRecordESDOList.size()>0){
				flag = elastricSearchSave.save(patientRemindRecordESDOList, esIndex, esType);
			}
		}catch (Exception e){
			e.printStackTrace();
			flag = false;
		} finally{
			if (jestClient != null) {
				jestClient.shutdownClient();
			}
		}
		return  flag;
	}
}

+ 2 - 0
patient-co/patient-co-wlyy-job/src/main/resources/application-dev.yml

@ -125,10 +125,12 @@ es:
    HealthEduArticlePatient: health_edu_article_patient_dev
    Statistics: wlyy_quota_test
    FollowUp: wlyy_followup
    patientRemindRecord: wlyy_patient_remind_record
  type:
    HealthEduArticlePatient: health_edu_article_patient_dev
    Statistics: wlyy_quota_test
    FollowUpContent: wlyy_followup_content
    patientRemindRecord: wlyy_patient_remind_record
  host:  http://172.19.103.68:9200
  tHost: 172.19.103.68:9300
  clusterName: jkzl

+ 2 - 0
patient-co/patient-co-wlyy-job/src/main/resources/application-devtest.yml

@ -118,10 +118,12 @@ es:
    HealthEduArticlePatient: wlyy_quota_test
    FollowUp: wlyy_followup
    Statistics: wlyy_quota_test
    patientRemindRecord: wlyy_patient_remind_record
  type:
    HealthEduArticlePatient: wlyy_quota_test
    Statistics: wlyy_quota_test
    FollowUpContent: wlyy_followup_content
    patientRemindRecord: wlyy_patient_remind_record
  host:  http://172.19.103.68:9200
  tHost: 172.19.103.68:9300
  clusterName: jkzl

+ 2 - 0
patient-co/patient-co-wlyy-job/src/main/resources/application-test.yml

@ -124,10 +124,12 @@ es:
    HealthEduArticlePatient: health_edu_article_patient_test
    FollowUp: wlyy_followup
    Statistics: wlyy_quota_test
    patientRemindRecord: wlyy_patient_remind_record
  type:
    HealthEduArticlePatient: health_edu_article_patient_test
    FollowUpContent: wlyy_followup_content
    Statistics: wlyy_quota_test
    patientRemindRecord: wlyy_patient_remind_record
  host:  http://172.19.103.68:9200
  tHost: 172.19.103.68:9300
  clusterName: jkzl

+ 3 - 0
patient-co/patient-co-wlyy-job/src/main/resources/system.properties

@ -140,6 +140,9 @@ patient_medicare_number_job=0 0 6 * * ?
# 获取儿童可预约疫苗,每天凌晨1点执行一次
child_immune_vaccin_job=0 0 1 * * ?
# 提醒具名儿童可预约疫苗,每天9点执行一次
alert_child_immune_vaccin_job=0 0 9 * * ?
#统一支付平台支付成功后页面跳转地址
return_url={server}/wx/html/qygl/html/pay_result.html
#统一支付平台支付接口地址

+ 4 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/imm/ChildImmuneVaccinDao.java

@ -14,7 +14,7 @@ import java.util.List;
 */
public interface ChildImmuneVaccinDao extends PagingAndSortingRepository<ChildImmuneVaccin, Long>,
		JpaSpecificationExecutor<ChildImmuneVaccin> {
	@Query("select p from ChildImmuneVaccin p where p.barcode=?1")
	@Query("select p from ChildImmuneVaccin p where p.barcode=?1 and p.del=0")
	List<ChildImmuneVaccin> getChildImmuneVaccinByBarcode(String barcode);
	List<ChildImmuneVaccin> findByBarcodeAndYmbmAndJzzc(String barcode,String ymbm,String jzzc);
@ -32,4 +32,7 @@ public interface ChildImmuneVaccinDao extends PagingAndSortingRepository<ChildIm
	@Modifying
	@Query("update ChildImmuneVaccin  c set c.alert_tag=?2 where c.code=?1")
	int updateAlertTagByCode(String code,int tag);
	@Query("select p from ChildImmuneVaccin p where p.barcode=?1 and p.del=0 and p.ymsx=1")
	List<ChildImmuneVaccin> getChildImmuneVaccinByBarcodeAndYmsx(String barcode);
}

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

@ -279,6 +279,7 @@ public class MessageService extends BaseService {
            specialistMesJson.put("amount", 0);
        }
        //系统服务
        List<Message> synergyList = new ArrayList<>();
        synergyList = messageDao.getSynergyService(doctor);
        JSONObject synergyMesJson = new JSONObject();
@ -287,7 +288,7 @@ public class MessageService extends BaseService {
            JSONObject  synergyJson = new JSONObject();
            synergyJson.put("title", synergyList.get(0).getTitle());
            synergyJson.put("type", synergyList.get(0).getType());
            synergyJson.put("msg", "您有"+synergyList.size()+"个专科服务消息,请查看!");
            synergyJson.put("msg", "您有"+synergyList.size()+"个协同服务消息,请查看!");
            synergyJson.put("msgTime", DateUtil.dateToStrLong(synergyList.get(0).getCreateTime()));
            synergyMesJson.put("lastMessage", synergyJson);
        }else{

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/imm/ChildFamilyImmuneService.java

@ -190,7 +190,7 @@ public class ChildFamilyImmuneService extends BaseService {
	 * @return
	 */
	public List<ChildImmuneVaccin> getChildImmuneVaccinByBarcode(String barcode){
		return childImmuneVaccinDao.getChildImmuneVaccinByBarcode(barcode);
		return childImmuneVaccinDao.getChildImmuneVaccinByBarcodeAndYmsx(barcode);
	}

+ 4 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistEvaluateSevice.java

@ -193,7 +193,10 @@ public class SpecialistEvaluateSevice extends BaseService {
            if(StringUtils.isNotEmpty(hospitalCode)){
                hospital = hospitalDao.findByCode(hospitalCode);
            }
            Patient patient = patientDao.findByCode(patientCode);
            Patient patient = null;
            if (StringUtils.isNoneBlank(patientCode)){
                patient  = patientDao.findByCode(patientCode);
            }
//            Doctor sendDoctor = doctorDao.findByCode(message.getSender());
            Doctor receiverDoctor = doctorDao.findByCode(message.getReceiver());
            if (message.getType() == 19 ){

+ 2 - 14
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/imm/DoctorImmController.java

@ -143,19 +143,7 @@ public class DoctorImmController extends BaseController {
			return error(-1, "查询失败");
		}
	}
	
	@RequestMapping(value = "/alertImmVacclinByPatient", method = RequestMethod.POST)
	@ApiOperation(value = "医生提醒单个居民疫苗接种")
	public String alertImmVacclinByPatient(@ApiParam(name = "barcode", value = "儿童免疫条码", defaultValue = "")
	                                      @RequestParam(value = "barcode", required = true) String barcode){
		try {
			// TODO: 2018/6/21
			return write(200, "请求成功");
		} catch (Exception e) {
			e.printStackTrace();
			return error(-1, "查询失败");
		}
	}
	@RequestMapping(value = "/alertImmVacclinByChildInfoCodes", method = RequestMethod.POST)
	@ApiOperation(value = "医生提醒居民疫苗接种")
@ -171,7 +159,7 @@ public class DoctorImmController extends BaseController {
	}
	@RequestMapping(value = "/alertImmVacclinByChildInfoCode", method = RequestMethod.POST)
	@ApiOperation(value = "医生提醒居民疫苗接种")
	@ApiOperation(value = "医生提醒居民疫苗接种(作废)")
	public String alertImmVacclinByChildInfoCode(@ApiParam(name = "alertDataJsonStr", value = "{\"childCode\":\"123\",\"childName\":\"张三\",\"vaccinCode\":\"asd123\",\"vaccinName\":\"疫苗名称\"}", defaultValue = "")
												  @RequestParam(value = "alertDataJsonStr", required = true) String alertDataJsonStr){
		try {

+ 43 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/synergy/SynergyManagerController.java

@ -6,9 +6,11 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.yihu.es.entity.FollowupContentESDO;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.service.app.followup.FollowUpService;
import com.yihu.wlyy.service.app.followup.FollowupDrugsService;
import com.yihu.wlyy.service.app.survey.SurveyScreenResultService;
import com.yihu.wlyy.service.specialist.SpecialistEvaluateSevice;
import com.yihu.wlyy.service.survey.ManagerQuestionnaireService;
import com.yihu.wlyy.service.third.jkEduArticle.ThirdJkEduArticleService;
import com.yihu.wlyy.service.third.jw.ZyDictService;
@ -45,6 +47,8 @@ public class SynergyManagerController extends BaseController{
    @Autowired
    private FollowupDrugsService followupDrugsService;
    @Autowired
    private SpecialistEvaluateSevice specialistEvaluateSevice;
    @Autowired
    private ThirdJkEduArticleService thirdJkEduArticleService;
    @ApiOperation("新增临时随访记录(返回ID)")
@ -174,6 +178,7 @@ public class SynergyManagerController extends BaseController{
//            Map<String, String> response = followUpService.getFollowupProjectData(id, followupProject);
            //修改为通过ES查询---2017.11.01--huangwenjie
            Map<String, String> response = followUpService.getFollowup(id);
            Map<String,Object> followupDrugs =  followupDrugsService.getFollowupDrugs(id);
            JSONArray array = JSON.parseArray(followupProject);
            List<FollowupContentESDO> followupContentESDOS = new ArrayList<>();
            for (int i =0;i<array.size();i++){
@ -182,6 +187,7 @@ public class SynergyManagerController extends BaseController{
            }
            JSONObject object = new JSONObject();
            object.put("followup",response);
            object.put("followupDrugs",followupDrugs);
            object.put("followupContent",followupContentESDOS);
            return write(200, "获取随访项目数据成功!", "data", object);
        } catch (Exception e) {
@ -282,6 +288,43 @@ public class SynergyManagerController extends BaseController{
        }
    }
    /**
     * 发送消息 type:19 受理提醒,20 待办工作提醒 21 服务进展提醒-已完成 22 服务进展提醒-未完成
     *  message{sender:"",receiver:"",relationCode:""}
     * @param message
     * @param hospital
     * @param patient
     * @param time
     * @return
     */
    @RequestMapping(value = "/sendMessage", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("发送消息")
    public String sendMessage(@ApiParam(name = "message",value = "消息对象(如:{'sender':'','receiver':'','relationCode':'','type':19})",required = true)
                              @RequestParam(value = "message",required = true)String message,
                              @ApiParam(name = "hospital",value = "医院code",required = false)
                              @RequestParam(value = "hospital",required = false)String hospital,
                              @ApiParam(name = "patient",value = "居民code",required = false)
                              @RequestParam(value = "patient",required = false)String patient,
                              @ApiParam(name = "time",value = "时间",required = false)
                              @RequestParam(value = "time",required = false)Integer time,
                              @ApiParam(name = "jsonObject",value = "参数",required = false)
                              @RequestParam(value = "jsonObject",required = false) String jsonObject){
        try {
            com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(message);
            Message message1 = new Message();
            message1.setSender(object.getString("sender"));
            message1.setType(object.getInteger("type"));
            message1.setReceiver(object.getString("receiver"));
            message1.setRelationCode(object.getString("relationCode"));
            com.alibaba.fastjson.JSONObject jsonObject1 = com.alibaba.fastjson.JSONObject.parseObject(jsonObject);
            return write(200, "获取消息成功!","data",specialistEvaluateSevice.sendMessage(message1,hospital,patient,time,jsonObject1));
        } catch (Exception e) {
            error(e);
            return error(-1, "获取消息失败!");
        }
    }
    @RequestMapping(value = "getArticalById",method = RequestMethod.GET)
    @ApiOperation("获取文章详情")
    public String getArticalById(@ApiParam(name = "articleId", value = "文章id")