Trick 5 gadi atpakaļ
vecāks
revīzija
a3161b9ff9

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

@ -3136,23 +3136,27 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    public Map<String,Object> findGeneralDoctorInfo(String generalDoctor){
        Map<String,Object> rs = new HashedMap();
        Date startTime = DateUtil.strToDate(DateUtil.dateToStr(new Date(),"yyyy-MM-dd")+" 00:00:00","yyyy-MM-dd HH:mm:ss");
        Date endTime = DateUtil.strToDate(DateUtil.dateToStr(new Date(),"yyyy-MM-dd")+" 23:59:59","yyyy-MM-dd HH:mm:ss");
        Calendar endTime = Calendar.getInstance();
        endTime.setTime(new Date());
        endTime.set(endTime.get(Calendar.YEAR),endTime.get(Calendar.MONTH),endTime.get(Calendar.DAY_OF_MONTH),23,59,59);
        //今天协同门诊列表
        List<WlyyOutpatientDO> todayList = outpatientDao.findByGeneralDoctor(generalDoctor,new Date(),endTime.getTime(),"0");
        List<WlyyOutpatientDO> todayList = outpatientDao.findByGeneralDoctor(generalDoctor,startTime,endTime,"0");
        rs.put("todayList",todayList);
        Calendar tomorrowTime = Calendar.getInstance();
        tomorrowTime.setTime(new Date());
        tomorrowTime.set(endTime.get(tomorrowTime.YEAR),endTime.get(tomorrowTime.MONTH),endTime.get(tomorrowTime.DATE),00,00,00);
        List<WlyyOutpatientDO> todayBeginList = outpatientDao.findByGeneralDoctor(generalDoctor,startTime,endTime,"1");
        rs.put("todayBeginList",todayBeginList);
        Calendar tomorrowTime = Calendar.getInstance();
        tomorrowTime.setTime(startTime);
        tomorrowTime.add(Calendar.DATE,1);
        endTime.add(Calendar.DATE,1);
        Calendar tomorrowEndtime = Calendar.getInstance();
        tomorrowEndtime.setTime(endTime);
        tomorrowEndtime.add(Calendar.DATE,1);
        //明天协同门诊列表
        List<WlyyOutpatientDO> tomorrowList = outpatientDao.findByGeneralDoctor(generalDoctor,tomorrowTime.getTime(),endTime.getTime(),"0");
        List<WlyyOutpatientDO> tomorrowList = outpatientDao.findByGeneralDoctor(generalDoctor,tomorrowTime.getTime(),tomorrowEndtime.getTime(),"0");
        rs.put("tomorrowList",tomorrowList);
        //统计科预约医生
@ -3180,7 +3184,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " JOIN base_doctor_role r ON d.id = r.doctor_code " +
                " WHERE " +
                " r.role_code ='specialist' " +
                " AND d.consult_status ='1'";
                " AND d.consult_status ='1' " +
                " AND d.charge_type is not null " +
                " AND d.outpatient_type is not null ";
        List<Map<String, Object>> oltotal = jdbcTemplate.queryForList(onlineSql);
        Long onlineTotal = 0l;

+ 131 - 0
business/base-service/src/main/java/com/yihu/jw/wlyy/service/WlyyBusinessService.java

@ -0,0 +1,131 @@
package com.yihu.jw.wlyy.service;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wlyy.wlyyhttp.WlyyHttpService;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
/**
 * Created by Trick on 2019/8/21.
 */
@Service
@Transactional
public class WlyyBusinessService {
    private static final Logger logger = LoggerFactory.getLogger(WlyyBusinessService.class);
    @Autowired
    private WlyyHttpService wlyyHttpService;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private OutpatientDao outpatientDao;
    @Autowired
    private BasePatientDao basePatientDao;
    /**
     * 推送系统门诊wlyy系统消息
     * @param doctor
     * @param outPatientId
     * @return
     */
    public Boolean sendWlyyOutpatientMes(String doctor,String outPatientId){
        BaseDoctorDO doctorDO = baseDoctorDao.findOne(doctor);
        if(doctorDO!=null&& StringUtils.isNotBlank(doctorDO.getIdcard())){
            WlyyOutpatientDO outpatientDO =outpatientDao.findOne(outPatientId);
            BasePatientDO basePatientDO = basePatientDao.findOne(outpatientDO.getPatient());
            JSONObject param = new JSONObject();
            param.put("idCard",doctorDO.getIdcard());
            param.put("sender","hlwyy");
            param.put("senderName","互联网医院");
            param.put("relationCode",outPatientId);
            String sex = "";
            try {
                String sx = IdCardUtil.getSexForIdcard_new(basePatientDO.getIdcard());
                if("1".equals(sx)){
                    sex = "男";
                }else if("2".equals(sx)){
                    sex = "女";
                }
            }catch (Exception e){
                logger.error("推送wlyy系统消息 身份证转换性别失败!:"+e.toString());
            }
            String age = IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard())==-1?"未知":IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard())+"";
            String content = "您已向"+outpatientDO.getHospitalName()+outpatientDO.getDeptName()+
                    "医师"+doctorDO.getName()+"发起了协同门诊请求。协同门诊患者:"+outpatientDO.getPatientName()+
                    "("+sex+" "+age+"岁),协同门诊时间:"+ DateUtil.dateToStr(outpatientDO.getRegisterDate(),"yyyy-MM-dd HH:mm");
            param.put("content",content);
            param.put("title","协同门诊消息");
            param.put("type",500);
            JSONObject rs = wlyyHttpService.sendWlyyMes("wlyySendMes",param);
            if(rs!=null){
                return true;
            }
        }
        return false;
    }
    public Boolean readWlyyOutpatientMes(String outPatientId){
        Map<String,Object> res = new HashedMap();
        WlyyOutpatientDO outpatientDO =outpatientDao.findOne(outPatientId);
        if(outpatientDO!=null){
            BaseDoctorDO doctorDO = baseDoctorDao.findOne(outpatientDO.getDoctor());
            JSONObject param = new JSONObject();
            param.put("idCard",doctorDO.getIdcard());
            param.put("type",500);
            param.put("relationCode",outPatientId);
            JSONObject rs = wlyyHttpService.sendWlyyMes("wlyyReadMes",param);
            if(rs!=null){
                return true;
            }
        }
        return false;
    }
    /**
     * 验证居民是否签约
     *
     * @param idCard
     * @return
     */
    public Boolean checkSignFamily(String idCard){
        JSONObject param = new JSONObject();
        param.put("idCard",idCard);
        JSONObject rs = wlyyHttpService.sendWlyyMes("wlyyCheckSignFamily",param);
        if(rs!=null){
            return true;
        }
        return false;
    }
}

+ 34 - 28
business/base-service/src/main/java/com/yihu/jw/wlyy/wlyyhttp/WlyyHttpService.java

@ -11,6 +11,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
@ -20,6 +21,7 @@ import java.util.Map;
 * Created by Trick on 2019/8/19.
 */
@Service
@Transactional
public class WlyyHttpService {
    private static final Logger logger = LoggerFactory.getLogger(WlyyHttpService.class);
@ -32,42 +34,46 @@ public class WlyyHttpService {
    public JSONObject sendWlyyMes(String configId,JSONObject param) {
        OauthWlyyConfigDO oauthWlyyConfigDO = oauthWlyyConfigDao.findOne(configId);
        //token获取accesstoken
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("appid", oauthWlyyConfigDO.getAppId()));
        params.add(new BasicNameValuePair("appSecret", oauthWlyyConfigDO.getAppSecret()));
        String res = httpClientUtil.post(oauthWlyyConfigDO.getTokenUrl(), params, "UTF-8");
        String token = null;
        JSONObject rsjson = JSONObject.parseObject(res);
        logger.info("sendWlyyMes token :" + rsjson.toString());
        Integer status = rsjson.getInteger("status");
        try{
        if (status == 10000) {
            //设置入参
            List<NameValuePair> p = new ArrayList<>();
            p.add(new BasicNameValuePair("param", param.toJSONString()));
            OauthWlyyConfigDO oauthWlyyConfigDO = oauthWlyyConfigDao.findOne(configId);
            //token获取accesstoken
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("appid", oauthWlyyConfigDO.getAppId()));
            params.add(new BasicNameValuePair("appSecret", oauthWlyyConfigDO.getAppSecret()));
            String res = httpClientUtil.post(oauthWlyyConfigDO.getTokenUrl(), params, "UTF-8");
            String token = null;
            JSONObject rsjson = JSONObject.parseObject(res);
            logger.info("sendWlyyMes token :" + rsjson.toString());
            Integer status = rsjson.getInteger("status");
            //设置头部
            token = rsjson.getJSONObject("result").getString("accesstoken");
            Map<String,Object> headerMap = new HashedMap();
            headerMap.put("accesstoken",token);
            if (status == 10000) {
                //设置入参
                List<NameValuePair> p = new ArrayList<>();
                p.add(new BasicNameValuePair("param", param.toJSONString()));
            String rs = httpClientUtil.headerPost(oauthWlyyConfigDO.getUrl(),p,"UTF-8",headerMap);
            logger.info("sendWlyyMes headerPost :"+rs);
                //设置头部
                token = rsjson.getJSONObject("result").getString("accesstoken");
                Map<String,Object> headerMap = new HashedMap();
                headerMap.put("accesstoken",token);
            JSONObject auth = JSONObject.parseObject(rs);
            Integer s = auth.getInteger("status");
                String rs = httpClientUtil.headerPost(oauthWlyyConfigDO.getUrl(),p,"UTF-8",headerMap);
                logger.info("sendWlyyMes headerPost :"+rs);
            if(s == 200){
                JSONObject data = auth.getJSONObject("data");
                return data;
                JSONObject re = JSONObject.parseObject(rs);
                Integer s = re.getInteger("status");
                if(s == 200){
                    return re;
                }else{
                    return null;
                }
            }else{
                return null;
            }
        }else{
            return null;
        }catch (Exception e){
            logger.error("sendWlyyMes error:"+e.toString());
        }
        return null;
    }
}

+ 11 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -236,6 +236,17 @@ public class BaseHospitalRequestMapping {
         */
        public static final String findGeneralDoctorInfo = "/findGeneralDoctorInfo";
        /**
         * 发送i健康系统消息
         */
        public static final String sendWlyyOutpatientMes = "/sendWlyyOutpatientMes";
        /**
         * 设置I健康消息已读
         */
        public static final String readWlyyOutpatientMes = "/readWlyyOutpatientMes";
        //=================end=======================================
        /**

+ 21 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -13,6 +13,7 @@ import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.wlyy.service.WlyyBusinessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -38,6 +39,9 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private PrescriptionService prescriptionService;
    @Autowired
    private WlyyBusinessService wlyyBusinessService;
    @Value("${demo.flag}")
    private boolean demoFlag;
@ -472,7 +476,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                             @ApiParam(name = "workTimeJson", value = "排班列表json")
                                             @RequestParam(value = "workTimeJson", required = true)String workTimeJson,
                                             @ApiParam(name = "date", value = "yyyy-MM,支持‘,’分割")
                                             @RequestParam(value = "date", required = true)String date)throws Exception {
                                             @RequestParam(value = "date", required = false)String date)throws Exception {
        return success(prescriptionService.saveDoctorWorkTimeJson(type,codes,workTimeJson,date));
    }
@ -566,6 +570,22 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                            @RequestParam(value = "generalDoctor", required = true)String generalDoctor) {
        return success(prescriptionService.findGeneralDoctorInfo(generalDoctor));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.sendWlyyOutpatientMes)
    @ApiOperation(value = "发送i健康系统消息", notes = "发送i健康系统消息")
    public ObjEnvelop sendWlyyOutpatientMes(@ApiParam(name = "doctor", value = "全科医生Id")
                                            @RequestParam(value = "doctor", required = true)String doctor,
                                            @ApiParam(name = "outPatientId", value = "门诊id")
                                            @RequestParam(value = "outPatientId", required = true)String outPatientId) {
        return success(wlyyBusinessService.sendWlyyOutpatientMes(doctor,outPatientId));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.readWlyyOutpatientMes)
    @ApiOperation(value = "设置I健康消息已读", notes = "设置I健康消息已读")
    public ObjEnvelop readWlyyOutpatientMes(@ApiParam(name = "outPatientId", value = "门诊id")
                                            @RequestParam(value = "outPatientId", required = true)String outPatientId){
        return success(wlyyBusinessService.readWlyyOutpatientMes(outPatientId));
    }
    //===========