فهرست منبع

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

wangzhinan 6 سال پیش
والد
کامیت
1c78150dfc

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

@ -636,7 +636,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){
@ -1496,16 +1506,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]);
                        }
                    }
                }
            }
@ -1663,6 +1675,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());

+ 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);
}

+ 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);
	}

+ 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 {

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

@ -295,7 +295,7 @@ public class SynergyManagerController extends BaseController{
     * @param time
     * @return
     */
    @RequestMapping(value = "/sendMessage", method = RequestMethod.GET)
    @RequestMapping(value = "/sendMessage", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("发送消息")
    public String sendMessage(@ApiParam(name = "message",value = "消息对象(如:{'sender':'','receiver':'','relationCode':'','type':19})",required = true)