Przeglądaj źródła

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

zdm 5 lat temu
rodzic
commit
218e995333

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

@ -1032,10 +1032,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        String rsCode = res.getString("@RESULT");
        if("0".equals(rsCode)){
            //存储挂号号
            String serialNo = (String)rs.get("serial_no");
            // {"resquest":{"@RESULT":"0","@MSG":"完成","@serial_no":"47770476","@times":"28"}}
            String serialNo = (String)res.get("@serial_no");
            outpatientDO.setRegisterNo(serialNo);
            String conNo = (String)rs.get("@times");
            String conNo = (String)res.get("@times");
            outpatientDO.setConNo(conNo);
            logger.info("挂号流水 @serial_no: " +serialNo+" @times: "+conNo);
            outpatientDao.save(outpatientDO);
        }
            //保存日志
@ -2321,7 +2323,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @return
     * @throws Exception
     */
    public Boolean saveDoctorWorkTimeJson(String type,String codes,String workTimeJson)throws Exception{
    public Boolean saveDoctorWorkTimeJson(String type,String codes,String workTimeJson,String date)throws Exception{
        com.alibaba.fastjson.JSONArray works = JSON.parseArray(workTimeJson);
        List<WlyyDoctorWorkTimeDO> wlyyDoctorWorkTimeDOs = new ArrayList<>();
@ -2348,7 +2350,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    " h.org_code ='"+codes+"'";
            List<Map<String,Object>> doctors = jdbcTemplate.queryForList(sql);
            List<WlyyDoctorWorkTimeDO> workTimeDOs =makeDoctorWorkTimeDOList(doctors,wlyyDoctorWorkTimeDOs);
            saveDoctorWorkTime(workTimeDOs);
            saveDoctorWorkTime(workTimeDOs,date,doctors);
            //科室
        }else if("2".equals(type)){
@ -2367,7 +2369,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    " h.dept_code in ("+sqlCode(codes)+")";
            List<Map<String,Object>> doctors = jdbcTemplate.queryForList(sql);
            List<WlyyDoctorWorkTimeDO> workTimeDOs =makeDoctorWorkTimeDOList(doctors,wlyyDoctorWorkTimeDOs);
            saveDoctorWorkTime(workTimeDOs);
            saveDoctorWorkTime(workTimeDOs,date,doctors);
            //医生批量
        }else if("3".equals(type)){
            String sql ="SELECT " +
@ -2385,7 +2387,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    " d.id in ("+sqlCode(codes)+")";
            List<Map<String,Object>> doctors = jdbcTemplate.queryForList(sql);
            List<WlyyDoctorWorkTimeDO> workTimeDOs =makeDoctorWorkTimeDOList(doctors,wlyyDoctorWorkTimeDOs);
            saveDoctorWorkTime(workTimeDOs);
            saveDoctorWorkTime(workTimeDOs,date,doctors);
        }
        return true;
@ -2407,15 +2409,24 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            //构建医生排班
            for(Map<String,Object> doctor:doctors){
                for(WlyyDoctorWorkTimeDO time:wlyyDoctorWorkTimeDOs){
                    time.setDoctor((String)doctor.get("id"));
                    time.setDoctorName((String)doctor.get("name"));
                    time.setDept((String)doctor.get("dept_code"));
                    time.setDeptName((String)doctor.get("dept_name"));
                    time.setHospital((String)doctor.get("org_code"));
                    time.setHospitalName((String)doctor.get("org_name"));
                    time.setCreateTime(new Date());
                    rs.add(time);
                    WlyyDoctorWorkTimeDO t = new WlyyDoctorWorkTimeDO();
                    t.setDoctor((String)doctor.get("id"));
                    t.setDoctorName((String)doctor.get("name"));
                    t.setDept((String)doctor.get("dept_code"));
                    t.setDeptName((String)doctor.get("dept_name"));
                    t.setHospital((String)doctor.get("org_code"));
                    t.setHospitalName((String)doctor.get("org_name"));
                    t.setCreateTime(new Date());
                    t.setType(time.getType());
                    t.setTimeType(time.getTimeType());
                    t.setStartTime(time.getStartTime());
                    t.setEndTime(time.getEndTime());
                    t.setDate(time.getDate());
                    t.setTimeInterval(time.getTimeInterval());
                    rs.add(t);
                }
                logger.info(rs.size()+"");
            }
        }
        return rs;
@ -2426,7 +2437,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param workTimeDOs
     * @return
     */
    public Boolean saveDoctorWorkTime(List<WlyyDoctorWorkTimeDO> workTimeDOs){
    public Boolean saveDoctorWorkTime(List<WlyyDoctorWorkTimeDO> workTimeDOs,String date,List<Map<String,Object>> doctors){
        if(workTimeDOs!=null&&workTimeDOs.size()>0){
            //按月按医生分组标记排班数据
@ -2434,15 +2445,26 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            for(WlyyDoctorWorkTimeDO time : workTimeDOs){
                //医生工作月份
                String workMonth = time.getDoctor()+","+time.getDate().substring(0,6);
                String workMonth = time.getDoctor()+","+time.getDate().substring(0,7);
                //判断是否是首次插入医生月份数据,如果是首次,则删除该医生当前月份排班数据数据
                if(!workMonths.contains(workMonth)){
                    workMonths.add(workMonth);
                    List<WlyyDoctorWorkTimeDO> oldTimes = doctorWorkTimeDao.findDoctorWorkTimeByMonth(time.getDoctor(),"%"+time.getDate().substring(0,6)+"%");
                    List<WlyyDoctorWorkTimeDO> oldTimes = doctorWorkTimeDao.findDoctorWorkTimeByMonth(time.getDoctor(),"%"+time.getDate().substring(0,7)+"%");
                    doctorWorkTimeDao.delete(oldTimes);
                }
            }
            doctorWorkTimeDao.save(workTimeDOs);
        }else{
            //如果排班数据为空,删除医生月份下排班数据
            if(StringUtils.isNotBlank(date)){
                String d[] = date.split(",");
                for(String dt:d){
                    for(Map<String,Object> doc:doctors){
                        List<WlyyDoctorWorkTimeDO> oldTimes = doctorWorkTimeDao.findDoctorWorkTimeByMonth((String)doc.get("id"),"%"+dt+"%");
                        doctorWorkTimeDao.delete(oldTimes);
                    }
                }
            }
        }
        return true;
    }
@ -2693,15 +2715,20 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param doctor
     */
    public void pickVideoPrescripitonWaitingPeople(String outpatientCode, String doctor) throws Exception{
        BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doctor);
        List<WlyyHospitalWaitingRoomDO> roomDOs =hospitalWaitingRoomDao.findByOutpatientId(outpatientCode);
        if(roomDOs!=null&&roomDOs.size()>0){
            for(WlyyHospitalWaitingRoomDO roomDO:roomDOs){
                    BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doctor);
                    roomDO.setDoctor(doctor);
                    roomDO.setDoctorName(baseDoctorDO.getName());
                    hospitalWaitingRoomDao.save(roomDO);
            }
        }
        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findOne(outpatientCode);
        wlyyOutpatientDO.setDoctor(doctor);
        wlyyOutpatientDO.setDoctorName(baseDoctorDO.getName());
        
        
    }
    
    /**

+ 11 - 0
business/base-service/src/main/java/com/yihu/jw/wlyy/dao/OauthWlyyConfigDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.wlyy.dao;
import com.yihu.jw.entity.wlyyinfo.OauthWlyyConfigDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2019/8/7.
 */
public interface OauthWlyyConfigDao extends PagingAndSortingRepository<OauthWlyyConfigDO, String>, JpaSpecificationExecutor<OauthWlyyConfigDO> {
}

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

@ -0,0 +1,73 @@
package com.yihu.jw.wlyy.wlyyhttp;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.wlyyinfo.OauthWlyyConfigDO;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.wlyy.dao.OauthWlyyConfigDao;
import org.apache.commons.collections.map.HashedMap;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * Created by Trick on 2019/8/19.
 */
@Service
public class WlyyHttpService {
    private static final Logger logger = LoggerFactory.getLogger(WlyyHttpService.class);
    @Autowired
    private OauthWlyyConfigDao oauthWlyyConfigDao;
    @Autowired
    private HttpClientUtil httpClientUtil;
    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");
        if (status == 10000) {
            //设置入参
            List<NameValuePair> p = new ArrayList<>();
            p.add(new BasicNameValuePair("param", param.toJSONString()));
            //设置头部
            token = rsjson.getJSONObject("result").getString("accesstoken");
            Map<String,Object> headerMap = new HashedMap();
            headerMap.put("accesstoken",token);
            String rs = httpClientUtil.headerPost(oauthWlyyConfigDO.getUrl(),p,"UTF-8",headerMap);
            logger.info("sendWlyyMes headerPost :"+rs);
            JSONObject auth = JSONObject.parseObject(rs);
            Integer s = auth.getInteger("status");
            if(s == 200){
                JSONObject data = auth.getJSONObject("data");
                return data;
            }else{
                return null;
            }
        }else{
            return null;
        }
    }
}

+ 33 - 8
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -956,7 +956,13 @@ public class ImService {
			
			//4、创建咨询
			JSONObject users = new JSONObject();//咨询参与者
			users.put(patient, 0);
			
			//协同门诊
			if("2".equals(wlyyOutpatientDO.getOutpatientType())){
				users.put(wlyyOutpatientDO.getGeneralDoctor(),0);
			}else{
				users.put(patient, 0);
			}
			users.put(doctorCode, 0);
			//关联业务code
			ct.setRelationCode(outpatientCode);
@ -992,7 +998,17 @@ public class ImService {
			ct.setConsult(consult.getId());
			
			//推送给IM去创建议题,取得成员消息
			JSONObject messages = imUtil.getCreateTopicMessage(patient, p.getName(), consult.getTitle(), content, consult.getImages(), doctorCode);
			
			JSONObject messages =  new JSONObject();
			//协同门诊
			if("2".equals(wlyyOutpatientDO.getOutpatientType())){
				BaseDoctorDO generalDoctor = baseDoctorDao.findById(wlyyOutpatientDO.getGeneralDoctor());
				messages = imUtil.getCreateTopicMessage(generalDoctor.getId(),generalDoctor.getName(), consult.getTitle(), content, consult.getImages(), doctorCode);
			}else{
				messages = imUtil.getCreateTopicMessage(patient, p.getName(), consult.getTitle(), content, consult.getImages(), doctorCode);
			}
			
			
			//5、(im创建咨询) 续方咨询的sessionid为居民code+就诊code+咨询类型(图文,视频,图文+视频)
			String sessionId = patient + "_" + outpatientCode + "_" + ct.getType();
@ -1312,8 +1328,8 @@ public class ImService {
			
			ConsultDo consultDo = consultDao.findOne(consult);
			
			//如果是复诊咨询,则修改成已评价
			if("9".equals(consultDo.getType())){
			//如果是复诊咨询,或者协同门诊,则修改成已评价
			if(9 == consultDo.getType() || 13 == consultDo.getType() ){
				WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findOne(consultTeamDo.getRelationCode());
				wlyyOutpatientDO.setEvaluateStatus("1");
				outpatientDao.save(wlyyOutpatientDO);
@ -1425,12 +1441,20 @@ public class ImService {
				"b.status AS status," +
				"b.evaluate AS evaluate," +
				"d.name AS patientName," +
				"d.id as patientId," +
				"d.idcard as patientIdcard," +
				"d.sex as patientsex," +
				"op.id as outpatientid," +
				"op.type as consultType," +
				"op.general_doctor as generalDoctor," +
				"op.icd10_name as icd10Name," +
				"d.photo AS patientphoto " +
				"FROM wlyy_consult a," +
				"wlyy_consult_team b," +
				"base_patient d " +
				"base_patient d, " +
				"wlyy_outpatient op " +
				"WHERE a.id=b.consult " +
				"AND b.patient=d.id AND b.doctor='"+doctor+"' ";
				"AND b.patient=d.id AND b.doctor='"+doctor+"' AND a.relation_code = op.id ";
		List<ConsultVO> result = new ArrayList<>();
		
		if(!StringUtils.isEmpty(title)){
@ -1481,9 +1505,10 @@ public class ImService {
				" COUNT(1) AS total " +
				"FROM wlyy_consult a," +
				"wlyy_consult_team b," +
				"base_patient d " +
				"base_patient d," +
				"wlyy_outpatient op " +
				"WHERE a.id=b.consult " +
				"AND b.patient=d.id AND b.doctor='"+doctor+"' ";
				"AND b.patient=d.id AND b.doctor='"+doctor+"' AND a.relation_code = op.id  ";
		List<ConsultVO> result = new ArrayList<>();
		
		if(!StringUtils.isEmpty(title)){

+ 78 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/im/ConsultVO.java

@ -46,6 +46,28 @@ public class ConsultVO extends UuidIdentityVO {
	@ApiModelProperty(value = "患者名称", example = "模块1")
	private String patientName;
	
	@ApiModelProperty(value = "患者ID", example = "模块1")
	private String patientId;
	
	
	@ApiModelProperty(value = "患者身份证", example = "模块1")
	private String patientIdcard;
	
	@ApiModelProperty(value = "患者性别", example = "模块1")
	private String patientsex;
	
	@ApiModelProperty(value = "就诊记录ID", example = "模块1")
	private String outpatientid;
	
	@ApiModelProperty(value = "1图文,2视频", example = "模块1")
	private String consultType;
	
	@ApiModelProperty(value = "全科医生", example = "模块1")
	private String generalDoctor;
	
	@ApiModelProperty(value = "诊断", example = "模块1")
	private String icd10Name;
	
	public Integer getType() {
		return type;
	}
@ -133,4 +155,60 @@ public class ConsultVO extends UuidIdentityVO {
	public void setPatientName(String patientName) {
		this.patientName = patientName;
	}
	
	public String getPatientId() {
		return patientId;
	}
	
	public void setPatientId(String patientId) {
		this.patientId = patientId;
	}
	
	public String getPatientIdcard() {
		return patientIdcard;
	}
	
	public void setPatientIdcard(String patientIdcard) {
		this.patientIdcard = patientIdcard;
	}
	
	public String getPatientsex() {
		return patientsex;
	}
	
	public void setPatientsex(String patientsex) {
		this.patientsex = patientsex;
	}
	
	public String getOutpatientid() {
		return outpatientid;
	}
	
	public void setOutpatientid(String outpatientid) {
		this.outpatientid = outpatientid;
	}
	
	public String getConsultType() {
		return consultType;
	}
	
	public void setConsultType(String consultType) {
		this.consultType = consultType;
	}
	
	public String getGeneralDoctor() {
		return generalDoctor;
	}
	
	public void setGeneralDoctor(String generalDoctor) {
		this.generalDoctor = generalDoctor;
	}
	
	public String getIcd10Name() {
		return icd10Name;
	}
	
	public void setIcd10Name(String icd10Name) {
		this.icd10Name = icd10Name;
	}
}

+ 47 - 0
common/common-util/src/main/java/com/yihu/jw/util/http/HttpClientUtil.java

@ -251,4 +251,51 @@ public class HttpClientUtil {
        restTemplate.put(url, formEntity, String.class);
    }
    /**
     * 发送post请求
     *
     * @param url     请求地址
     * @param params  请求参数
     * @param chatSet 编码格式
     * @param headerMap 请求头
     * @return
     */
    public  String headerPost(String url, List<NameValuePair> params, String chatSet, Map<String,Object> headerMap) {
        // 创建默认的httpClient实例.
        CloseableHttpClient httpclient = HttpClients.createDefault();
        // 创建httppost
        HttpPost httppost = new HttpPost(url);
        UrlEncodedFormEntity uefEntity;
        try {
            uefEntity = new UrlEncodedFormEntity(params, chatSet);
            httppost.setEntity(uefEntity);
            for(String str:headerMap.keySet()){
                httppost.addHeader(str,headerMap.get(str).toString());
            }
            CloseableHttpResponse response = httpclient.execute(httppost);
            try {
                HttpEntity entity = response.getEntity();
                if (entity != null) {
                    return EntityUtils.toString(entity, chatSet);
                }
            } finally {
                response.close();
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e1) {
            e1.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            // 关闭连接,释放资源
            try {
                httpclient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return null;
    }
}

+ 30 - 3
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java

@ -2,6 +2,9 @@ package com.yihu.jw.hospital.endpoint.consult;
import com.alibaba.fastjson.JSONArray;
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.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.im.service.ImService;
@ -9,11 +12,13 @@ import com.yihu.jw.restmodel.im.ConsultVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -38,6 +43,9 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
	@Autowired
	private PrescriptionService prescriptionService;
	
	@Autowired
	private BaseDoctorDao baseDoctorDao;
	
	
	@GetMapping (value = BaseHospitalRequestMapping.DodtorIM.findWaitingRoomOutpatientByDoctor)
	@ApiOperation(value = "医生可接单列表(图文)", notes = "医生可接单列表(图文)")
@ -270,6 +278,7 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
		result.put("zjCount",zjCount);//专家咨询数量
		result.put("imgCount",imgCount);//图文复诊数量
		result.put("videoCount",waitVideoCount+_videoOnlineCount);//视频复诊数量
		result.put("xtCount",0);//协同门诊候诊数量
		
		
		return success("请求成功",result);
@ -305,6 +314,13 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
				json.put("id", consult.getId());
				// 设置咨询类型:1专家咨询,9在线复诊,待扩展,13协同门诊
				json.put("type", consult.getType());
				
				//如果是协同门诊,多返回全科医生的详细信息
				if(13 == consult.getType() && StringUtils.isNoneBlank(consult.getGeneralDoctor())){
					BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(consult.getGeneralDoctor());
					json.put("generalDoctorName", baseDoctorDO.getName());
				}
				
				// 设置显示标题
				json.put("title", consult.getTitle());
				// 设置主诉
@ -315,10 +331,21 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
				json.put("czrq", DateUtil.dateToStrLong(consult.getCzrq()));
				//是否评价
				json.put("evaluate", consult.getEvaluate());
				//患者头像
				json.put("patientPhoto", consult.getPatientphoto());
				//患者名称
				//患者ID
				json.put("patientId", consult.getPatientId());
				//患者性别
				json.put("patientsex", consult.getPatientsex());
				//患者姓名
				json.put("patientName", consult.getPatientName());
				//患者年龄
				json.put("patientAge", DateUtil.getAgeForIdcard(consult.getPatientIdcard()));
				//就诊记录ID
				json.put("outpatientId", consult.getOutpatientid());
				//图文或者视频类型
				json.put("consultType", consult.getConsultType());
				//诊断
				json.put("icd10Name", consult.getIcd10Name());
				
				array.add(json);
			}

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

@ -470,8 +470,10 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                             @ApiParam(name = "codes", value = "1.医院code,2.科室code,‘,’分割,3.医生code,‘,’分割")
                                             @RequestParam(value = "codes", required = true)String codes,
                                             @ApiParam(name = "workTimeJson", value = "排班列表json")
                                             @RequestParam(value = "workTimeJson", required = true)String workTimeJson)throws Exception {
        return success(prescriptionService.saveDoctorWorkTimeJson(type,codes,workTimeJson));
                                             @RequestParam(value = "workTimeJson", required = true)String workTimeJson,
                                             @ApiParam(name = "date", value = "yyyy-MM,支持‘,’分割")
                                             @RequestParam(value = "date", required = true)String date)throws Exception {
        return success(prescriptionService.saveDoctorWorkTimeJson(type,codes,workTimeJson,date));
    }
    @PostMapping(value = "test")