Forráskód Böngészése

Merge branch 'dev' of wangjun/wlyy2.0 into dev

wangzhinan 4 éve
szülő
commit
2d48abb22b

+ 84 - 2
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -4404,7 +4404,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                newConfig.setKeyword1( "处方支付");
                newConfig.setKeyword2(outpatientDO.getHospitalName());
                newConfig.setKeyword3( outpatientDO.getDoctorName());
                newConfig.setKeyword3(outpatientDO.getDoctorName());
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                logger.info("眼科微信消息模板推送 处方支付提醒开始");
@ -10711,6 +10711,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            //同步眼科医院
            logger.info("开始同步眼科医院");
            ykyyEntranceService.saveKsjc(baseNatAppointmentDO,demoFlag);
            //预约成功后发送支付模板消息
            sendYktemplateMessage(baseNatAppointmentDO.getId(),false);
            logger.info("结束同步眼科医院");
            returnMap.put("msg","预约成功");
            returnMap.put("status","200");
@ -10729,7 +10731,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        if (!StringUtils.isNoneBlank(baseNatAppointmentDO.getRealOrder())){
            throw new Exception("核酸项目不存在");
        }
        logger.info("模板消息推送标识pushFlag"+pushFlag);
        if (!StringUtils.isNoneBlank(pushFlag)){
            String recipeTime = DateUtil.dateToStr(new Date(), "yyyyMMddHHmmss");
@ -10798,9 +10799,90 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                logger.info("支付宝模板消息"+reponse);
            }
         }
         return "发送成功!";
    }
    public String sendYktemplateMessage(Integer id,boolean isPayed)  {
        BaseNatAppointmentDO baseNatAppointmentDO = baseNatAppointmentDao.findOne(id);
        if (baseNatAppointmentDO==null){
            return "核酸项目不存在,发送失败";
        }
        List<BasePatientWechatDo> ps = new ArrayList<BasePatientWechatDo>();
        BasePatientDO patientDO = basePatientDao.findById(baseNatAppointmentDO.getPatientId());
        String userName = "";
        if (patientDO != null) {
            userName = patientDO.getName();
        }
        if (StringUtils.isNotEmpty(baseNatAppointmentDO.getPatientId())){
            ps = basePatientWechatDao.findByWechatIdAndPatientId(wechatId, baseNatAppointmentDO.getPatientId());
        }
        if (ps.isEmpty()) {
            logger.info("该用户没有openid,无法推送模版消息,用户ID:" + baseNatAppointmentDO.getPatientId() + "wechatId:" + wechatId);
        }
        Map<String,Object> map = ykyyEntranceService.findYkDoctor(baseNatAppointmentDO.getHospitalFlag());
        WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
        for (BasePatientWechatDo one : ps) {
            try {
                if (isPayed){
                    //眼科预约成功后消息提醒
                    WxTemplateConfigDO newConfig = new WxTemplateConfigDO();
                    String scene = "hsyycgtx";
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_hsyycg_notice", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    newConfig.setFirst(config.getFirst().replace("key1",userName));
                    newConfig.setKeyword1("核酸检测预约单支付");
                    newConfig.setKeyword3(map.get("doctorName")==null?"":map.get("doctorName").toString());
                    newConfig.setKeyword4(userName);
                    newConfig.setKeyword5(DateUtil.dateToStrLong(baseNatAppointmentDO.getAppointmentTime()));
                    newConfig.setRemark(config.getRemark().replace("key1",userName).replace("key2",DateUtil.dateToStrLong(baseNatAppointmentDO.getAppointmentTime())));
                    newConfig.setUrl(newConfig.getUrl()+baseNatAppointmentDO.getId());
                    logger.info("=======setUrlhsyycgtx========" + newConfig.getUrl());
                    logger.info("发送的消息="+ com.alibaba.fastjson.JSONObject.toJSONString(newConfig));
                    logger.info("调用眼科微信模板消息接口的入参:AccessToken="+wxAccessTokenDO.getAccessToken()+"---Openid="+one.getOpenid());
                    weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(), one.getOpenid(), newConfig);
                    //保存发送模板记录,
                    WxPushLogDO wxPushLogDO = new WxPushLogDO();
                    wxPushLogDO.setCreateTime(new Date());
                    wxPushLogDO.setOpenid(one.getOpenid());
                    wxPushLogDO.setReceiver(baseNatAppointmentDO.getPatientId());
                    wxPushLogDO.setWechatId(wechatId);
                    wxPushLogDO.setScene(scene);
                    wxPushLogDao.save(wxPushLogDO);
                }else {
                    WxTemplateConfigDO newPayNotice = new WxTemplateConfigDO();
                    String scenePayNotice= "hszftx";
                    //眼科核酸预约成功后支付提醒
                    WxTemplateConfigDO configPayNotice = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_hszf_notice", scenePayNotice, 1);
                    BeanUtils.copyProperties(configPayNotice, newPayNotice);
                    newPayNotice.setFirst(configPayNotice.getFirst().replace("key1",userName));
                    newPayNotice.setKeyword1("核酸检测预约单支付");
                    newPayNotice.setKeyword3(map.get("doctorName")==null?"":map.get("doctorName").toString());
                    newPayNotice.setRemark(configPayNotice.getRemark());
                    newPayNotice.setUrl(configPayNotice.getUrl()+baseNatAppointmentDO.getId());
                    logger.info("=======setUrlhszftx========" + newPayNotice.getUrl());
                    logger.info("发送的消息="+ com.alibaba.fastjson.JSONObject.toJSONString(newPayNotice));
                    logger.info("发送核酸预约模板消息成功");
                    logger.info("调用眼科微信模板消息支付提醒接口的入参:AccessToken="+wxAccessTokenDO.getAccessToken()+"---Openid="+one.getOpenid());
                    weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(), one.getOpenid(), newPayNotice);
                    //保存发送模板记录,
                    WxPushLogDO wxPushLogDO = new WxPushLogDO();
                    wxPushLogDO.setCreateTime(new Date());
                    wxPushLogDO.setOpenid(one.getOpenid());
                    wxPushLogDO.setReceiver(baseNatAppointmentDO.getPatientId());
                    wxPushLogDO.setWechatId(wechatId);
                    wxPushLogDO.setScene(scenePayNotice);
                    wxPushLogDao.save(wxPushLogDO);
                    logger.info("发送核酸预约模板消息支付提醒成功");
                }
            } catch (Exception e) {
                e.printStackTrace();
                logger.info("发送核酸预约模板消息失败,error="+e.getMessage());
            }
        }
        return "发送成功!";
    }
    public MixEnvelop getNatRecords(String patientId,String id,String payStatus,String appointmentTime, String isSuccess,Integer page ,Integer pageSize){
        String sql = "select t.name as \"name\"," +
                "t.card_no as \"cardNo\"," +

+ 57 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/YkyyPrescriptionService.java

@ -66,6 +66,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -919,7 +920,63 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
        return array;
    }
    public String findYxVideoList(){
        WlyyHospitalSysDictDO sysDictDO = hospitalSysDictDao.findById("YXAPPKEY");
        WlyyHospitalSysDictDO hospitalSysDictDO =  hospitalSysDictDao.findById("YXAPPSECRET");
        if (sysDictDO==null){
            return  "找不到对应的key";
        }
        Long endTime = new Date().getTime();
        Long startTime = new Date().getTime()-24*60*60*1000;
        List vids = new ArrayList();
        String appKey = sysDictDO.getDictValue();
        String appSecret = hospitalSysDictDO.getDictValue();
        String nonce =  randomInt(10);
        String curTime = String.valueOf((new Date()).getTime() / 1000L);
        String checkSum = CheckSumBuilder.getCheckSum(appSecret, nonce ,curTime);//参考 计算CheckSum的java代码
        String url = "https://vcloud.163.com/app/vod/video/get";
        Map<String,Object> httpPost = new HashedMap();
        // 设置请求的header
        httpPost.put("AppKey", appKey);
        httpPost.put("Nonce", nonce);
        httpPost.put("CurTime", curTime);
        httpPost.put("CheckSum", checkSum);
        httpPost.put("Content-Type", "application/json");
        JSONObject object = new JSONObject();
        object.put("currentPage",500);
        object.put("pageSize",1);
        object.put("status",40);
        object.put("beginTime",startTime);
        object.put("endTime",endTime);
        logger.info("入参"+object.toJSONString());
        String response = httpClientUtil.postBodyHead(url,object,httpPost);
        logger.info("返回日志"+response);
        if(StringUtils.isNoneBlank(response)){
            com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(response);
            if (jsonObject.getString("code").equalsIgnoreCase("200")){
                JSONObject object1 = jsonObject.getJSONObject("ret");
                if (object1!=null){
                    Integer total = object1.getInteger("totalRecords");
                    JSONArray jsonArray = object1.getJSONArray("list");
                    if (jsonArray!=null&&jsonArray.size()>0){
                        for (int i=0;i<jsonArray.size();i++){
                            JSONObject object2 = jsonArray.getJSONObject(i);
                            if (object2!=null){
                                String vedioUrl =object1.getString("origUrl");
                                String vedioName = object1.getString("videoName");
                                String filePath = "/Projects/Video/"+DateUtil.getStringDate("yyyyMMdd");
                                logger.info("filePath:"+filePath);
                                logger.info("vedioUrl"+vedioUrl);
                                FileUtil.saveUrlAs(vedioUrl,filePath,"GET",vedioName);
                            }
                        }
                    }
                }
            }
        }
        return null;
    }
    public String saveVideoFile(String vip){
        WlyyHospitalSysDictDO sysDictDO = hospitalSysDictDao.findById("YXAPPKEY");

+ 3 - 0
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -921,12 +921,15 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
                    BaseNatAppointmentDO baseNatAppointmentDO = baseNatAppointmentDao.findOne(Integer.parseInt(businessOrderDO.getRelationCode()));
                    baseNatAppointmentDO.setPayStatus("1");
                    baseNatAppointmentDao.save(baseNatAppointmentDO);
                    String updatesql = "update V_MS_YJ01 t set t.HLWJF=1 where t.yjxh='"+baseNatAppointmentDO.getRealOrder()+"'";
                    try {
                        ykyyEntranceService.updateHisStatus(updatesql);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    //发送核酸支付成功提醒
                    prescriptionService.sendYktemplateMessage(baseNatAppointmentDO.getId(),true);
                }
            }
            if (businessOrderDO!=null&&!businessOrderDO.getOrderCategory().equalsIgnoreCase("5")&&businessOrderDO.getStatus()!=1){

+ 47 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/util/DownLoadYxJob.java

@ -0,0 +1,47 @@
package com.yihu.jw.util;
import com.yihu.jw.hospital.prescription.service.YkyyPrescriptionService;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.Trigger;
import org.springframework.scheduling.TriggerContext;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.support.CronTrigger;
import java.util.Date;
public class DownLoadYxJob implements SchedulingConfigurer {
    private static final Logger logger = LoggerFactory.getLogger(DownLoadYxJob.class);
    private static String cron = "0 0 0 * * ?";//"0 0 0 * * ?";0 */5 * * * ?
    @Autowired
    private YkyyPrescriptionService ykyyPrescriptionService;
    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
        taskRegistrar.addTriggerTask(new Runnable() {
            @Override
            public void run() {
                logger.info("START========OverdueJob========");
                try {
                    ykyyPrescriptionService.findYxVideoList();
                    logger.info("END========OverdueJob========");
                } catch (Exception e) {
                    e.printStackTrace();
                    logger.error("END===ERROE===OverdueJob,message:"+e.getMessage());
                }
            }
        }, new Trigger() {
            @Override
            public Date nextExecutionTime(TriggerContext triggerContext) {
                // 任务触发,可修改任务的执行周期
                CronTrigger trigger = new CronTrigger(cron);
                System.out.println("OverdueJob任务触发,可修改任务的执行周期"+cron);
                Date nextExec = trigger.nextExecutionTime(triggerContext);
                return nextExec;
            }
        });
    }
}