Переглянути джерело

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

wangzhinan 4 роки тому
батько
коміт
e365a0f2a1

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

@ -4411,7 +4411,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("眼科微信消息模板推送 处方支付提醒开始");
@ -10725,6 +10725,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");
@ -10743,7 +10745,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");
@ -10812,9 +10813,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");

+ 72 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java

@ -86,6 +86,8 @@ public class YkyyEntranceService {
    private final static String orgName ="厦门大学附属厦门眼科中心";
    private final static String saveJdxxUrl="http://192.168.20.55:10023/ykyy/saveJdxx";
    @Autowired
    private DictHospitalDeptDao hospitalDeptDao;
@ -3095,4 +3097,74 @@ public class YkyyEntranceService {
        String content = response.getContent();
        return content;
    }
    //判断居民是否建过档,没有就建档
    public JSONObject patientJDKH(String patientId, String idcard, String name,String phoneNum, String medicare) throws Exception {
        JSONObject res = new JSONObject();
        //查询是否建档
        String brid = "";
        String bridSql = "SELECT brid \"brid\" from portal_his.V_ZKSG_BRCX@xec_link where jzkh = '" +medicare + " ' ";
        Map<String, Object> params = new HashedMap();
        params.put("sql", bridSql);
        logger.info("bridSql:" + bridSql);
        HttpResponse response = HttpUtils.doGet(url, params);
        String content = response.getContent();
        logger.info("response:" + content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if (status==200){
            JSONArray array = rs.getJSONArray("detailModelList");
            int size = array.size();
            if(size == 1){
                brid = ((JSONObject)array.get(0)).getString("BRID");
            }else if (size > 1){
                res.put("status", -1);
                res.put("message", "该居民存在多条建档信息!");
                return res;
            }
        }
        //先通过身份证查询是否有这个病人id 如果有直接返回 如果没有则新建
        if (StringUtil.isBlank(brid)) {
            Map<String, Object> params1 = new HashedMap();
            params1.put("brxm", name);
            params1.put("csny", IdCardUtil.getBirthdayForIdcardStr(idcard));
            params1.put("brxb", IdCardUtil.getSexForIdcard_new(idcard));
            params1.put("czgh", "1996");
            params1.put("sfzh", idcard);
            params1.put("sjhm", phoneNum);
            params1.put("ybkh", medicare);
            params1.put("lxdz", null);
            params1.put("zy", 0);
            HttpResponse response1 = HttpUtils.doGet(saveJdxxUrl, params);
            String content1 = response1.getContent();
            JSONObject rs1 = JSON.parseObject(content1);
            if (rs.getInteger("status") != 200)
            {
                res.put("status", -1);
                res.put("message", "操作失败,失败原因:" + rs1.getString("message"));
                return res;
            } else {
                //获取病人id
                response = HttpUtils.doGet(url, params);
                content = response.getContent();
                logger.info("response:" + content);
                rs = JSON.parseObject(content);
                status = rs.getInteger("status");
                if (status==200){
                    JSONArray array = rs.getJSONArray("detailModelList");
                    int size = array.size();
                    if(size == 1){
                        brid = ((JSONObject)array.get(0)).getString("BRID");
                    }else if (size > 1){
                        res.put("status", -1);
                        res.put("message", "该居民存在多条建档信息!");
                        return res;
                    }
                }
            }
        }
        res.put("status", 200);
        res.put("message", brid);
        return res;
    }
}

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

+ 9 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/hospital/WlyyFamilyMemberController.java

@ -357,7 +357,15 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
                if (null != jsonObject.get("id")) {
                    id = jsonObject.get("id").toString();
                }
                mixEnvelop = wlyyFamilyMemberService.addFamily(id, patientId, familyName, dictId, cardType, idCard, username, false,medicareType,medicare,clinicId);
                //获取建档信息
                JSONObject jdObject = ykyyEntranceService.patientJDKH(patientId, idCard,familyName,username,medicare);
                if(jdObject.getInteger("status") == 200) {
                    mixEnvelop = wlyyFamilyMemberService.addFamily(id, patientId, familyName, dictId, cardType, idCard, username, false, medicareType, medicare, clinicId);
                }else {
                    mixEnvelop.setStatus(408);
                    mixEnvelop.setMessage(jdObject.getString("message"));
                    return mixEnvelop;
                }
            } else {
                mixEnvelop.setStatus(408);
                mixEnvelop.setMessage("验证码不正确");