Pārlūkot izejas kodu

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

wangzhinan 1 gadu atpakaļ
vecāks
revīzija
252c3402a5

+ 0 - 3
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -357,7 +357,6 @@ public class ImService {
        if (rstotal != null && rstotal.size() > 0) {
            consultCode = rstotal.get(0).get("consultCode").toString();
        }
        logger.info("未结束判断语句" + totalSql + "======consultCode" + consultCode);
        return consultCode;
    }
@ -378,7 +377,6 @@ public class ImService {
        if (rstotal != null && rstotal.size() > 0) {
            consultCode = rstotal.get(0).get("consultCode").toString();
        }
        logger.info("未结束判断语句" + totalSql + "======consultCode" + consultCode);
        return consultCode;
    }
@ -406,7 +404,6 @@ public class ImService {
        if (rstotal != null && rstotal.size() > 0) {
            consultCode = rstotal.get(0).get("consultCode").toString();
        }
        logger.info("未结束判断语句" + totalSql + "======consultCode" + consultCode);
        return consultCode;
    }

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServiceItemPlanDO.java

@ -25,7 +25,7 @@ public class ServiceItemPlanDO extends UuidIdentityEntityWithCreateTime {
    private String planDetailId;//康复计划明细id
    private String name;//服务项名称
    private String relationCode;//关联业务id
    private String relationType;//关联业务类型 1电话/短信关怀 2康复咨询 3康复咨询 4上门服务 5康复指导 6康复随访 7康复复诊
    private String relationType;//关联业务类型 1电话/短信关怀 2康复咨询 3健康监测 4上门服务 5康复指导 6康复随访 7康复复诊
    private String content;//服务完成笔记
    private String appendixs;//附件

+ 47 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/RehabilitationDetailDO.java

@ -77,6 +77,12 @@ public class RehabilitationDetailDO extends UuidIdentityEntity implements Serial
    private String completeTime;//上次完成时间
    private String planTime;//计划时间
    private Integer signCount;//监测次数
    private Integer signType;//体征类型 1血糖 2血压
    private String value1;
    private String value2;
    private String value3;
    @Column(name = "reservation_type")
    public Integer getReservationType() {
        return reservationType;
@ -371,4 +377,45 @@ public class RehabilitationDetailDO extends UuidIdentityEntity implements Serial
    public void setName(String name) {
        this.name = name;
    }
    @Transient
    public Integer getSignCount() {
        return signCount;
    }
    public void setSignCount(Integer signCount) {
        this.signCount = signCount;
    }
    @Transient
    public Integer getSignType() {
        return signType;
    }
    public void setSignType(Integer signType) {
        this.signType = signType;
    }
    @Transient
    public String getValue1() {
        return value1;
    }
    public void setValue1(String value1) {
        this.value1 = value1;
    }
    @Transient
    public String getValue2() {
        return value2;
    }
    public void setValue2(String value2) {
        this.value2 = value2;
    }
    @Transient
    public String getValue3() {
        return value3;
    }
    public void setValue3(String value3) {
        this.value3 = value3;
    }
}

+ 29 - 6
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/consult/controller/ConsultController.java

@ -20,6 +20,7 @@ import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.ServiceException;
import com.yihu.jw.util.http.HttpClientUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -28,12 +29,8 @@ import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
@ -50,7 +47,7 @@ import java.util.*;
 * @author George
 */
@RestController
@RequestMapping(value = "/patient/consult", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, method = {RequestMethod.GET, RequestMethod.POST})
@RequestMapping(value = "/patient/consult")
@Api(description = "患者端-患者咨询")
public class ConsultController extends EnvelopRestEndpoint {
@ -98,6 +95,32 @@ public class ConsultController extends EnvelopRestEndpoint {
    @Value("${im.data_base_name}")
    private String im;
    /**
     * 修改状态为1的咨询记录为结束
     *
     * @param code 咨询标识
     * @return
     */
    @PostMapping(value = "finish")
    @ApiOperation("修改状态为1的咨询记录为结束")
    public Envelop finish(@RequestParam(required = true) String code,@RequestParam(required = true) Integer endType) {
        try {
            int row = consultTeamService.finishConsult(code, getRepUID(), endType);
            if (row > 0) {
                return Envelop.getSuccess("操作成功!");
            }else if(row == -2) {
                return Envelop.getError( "续方未审核,不能结束续方咨询!",-1);
            }  else {
                return Envelop.getError("操作失败!",-1);
            }
        } catch (ServiceException se) {
            return Envelop.getError(se.getMessage(),-1);
        } catch (Exception e) {
            error(e);
            return Envelop.getError("操作失败!",-1);
        }
    }
    /**
     * 获取未完成咨询
     *

+ 45 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/consult/service/ConsultTeamService.java

@ -1,6 +1,7 @@
package com.yihu.jw.hospital.module.consult.service;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.im.ConsultTeamLogDo;
@ -18,6 +19,7 @@ import com.yihu.jw.order.dao.ConsultTeamOrderDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.util.entity.ServiceException;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -72,6 +74,49 @@ public class ConsultTeamService extends ConsultService {
    @Autowired
    private ImUtil imUtill;
    public int finishConsult(String consult, String endOperator, int endType) throws Exception {
        ConsultTeamDo consultTeam = consultTeamDao.findByConsult(consult);
        ConsultDo cons = consultDao.findById(consult).orElse(null);
        if (consultTeam.getStatus() == 1) {
            return -1;
        }
        String endName = "";
        String endId = "";
        //结束咨询才发送推送给IM文字消息
        if (endType == 1) {
            BasePatientDO p = patientDao.findById(endOperator).orElse(null);
            endName = p.getName();
            endId = p.getId();
        } else {
            if (endOperator.equals("admin")) {
                endId = "system";
                endName = "咨询超时未回复,系统自动";
            } else {
                BaseDoctorDO d = doctorDao.findByIdAndDel(endOperator);
                endId = d.getId();
                endName = d.getName();
            }
        }
        JSONObject obj = imUtill.endTopics(consultTeam.getPatient(), endId, endName, consultTeam.getConsult());
        if (obj == null) {
            throw new ServiceException("IM消息结束异常!");
        }
        if (obj.getInteger("status") == -1) {
            throw new ServiceException(String.valueOf(obj.get("message")));
        }
        consultTeam.setEndMsgId(obj.getString("id"));
        cons.setEndTime(new Date());
        consultTeam.setEndTime(new Date());
        consultTeam.setStatus(1);
        consultDao.save(cons);
        consultTeamDao.save(consultTeam);
        return 1;
    }
    /**
     * 添加上门服务咨询

+ 17 - 13
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/DeviceDetailService.java

@ -192,21 +192,25 @@ public class DeviceDetailService {
	 * @return
	 */
	public void registerToWlyy(DevicePatientDevice device){
		//判断设备类型
		Device deviceDO = deviceDao.findById(device.getDeviceId()).orElse(null);
		if (StringUtils.isNotBlank(deviceDO.getNeedRegister())){
			// 设备注册至iot后 通过iot将设备数据转发
		try {
			//判断设备类型
			Device deviceDO = deviceDao.findById(device.getDeviceId()).orElse(null);
			if (StringUtils.isNotBlank(deviceDO.getNeedRegister())){
				// 设备注册至iot后 通过iot将设备数据转发
//			String url = "http://www.cityihealth.com:43210/deviceManage/register";
			WlyyHospitalSysDictDO dictDO1 = hospitalSysDictDao.findOneByDictNameAndDictCode("registerToWlyy","pushAddress");
			WlyyHospitalSysDictDO dictDO2 = hospitalSysDictDao.findOneByDictNameAndDictCode("registerToWlyy","url");
			String pushAddress = dictDO1.getDictValue();
			String url = dictDO2.getDictValue();
			List<NameValuePair> params = new ArrayList<>();
			params.add(new BasicNameValuePair("deviceSN", device.getDeviceSn()));
			params.add(new BasicNameValuePair("pushAddress", pushAddress));
			String response = httpClientUtil.post(url, params,"UTF-8");
			System.out.println("注册结果:"+response);
				WlyyHospitalSysDictDO dictDO1 = hospitalSysDictDao.findOneByDictNameAndDictCode("registerToWlyy","pushAddress");
				WlyyHospitalSysDictDO dictDO2 = hospitalSysDictDao.findOneByDictNameAndDictCode("registerToWlyy","url");
				String pushAddress = dictDO1.getDictValue();
				String url = dictDO2.getDictValue();
				List<NameValuePair> params = new ArrayList<>();
				params.add(new BasicNameValuePair("deviceSN", device.getDeviceSn()));
				params.add(new BasicNameValuePair("pushAddress", pushAddress));
				String response = httpClientUtil.post(url, params,"UTF-8");
				System.out.println("注册结果:"+response);
			}
		}catch (Exception e){
			e.printStackTrace();
		}
	}
}

+ 12 - 25
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/PatientHealthIndexService.java

@ -32,12 +32,9 @@ import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@ -377,7 +374,6 @@ public class PatientHealthIndexService {
        com.alibaba.fastjson.JSONObject obj = new com.alibaba.fastjson.JSONObject();
        obj.put("user", patient);
        boolean hadData = false;
        Date date = DateUtil.strToDateShort(dateString);
        /***************** 按时间排序 ***************************/
        
        String sql = "SELECT " +
@ -405,17 +401,15 @@ public class PatientHealthIndexService {
                " order by record_date,id desc ";
        List<Map<String, Object>> list = getPatientXT_JsonIot(sql,patient,dateString);
        SimpleDateFormat dateFormat6 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat dateFormat3 = new SimpleDateFormat("yyyy-MM-dd");
        if (list != null && list.size() > 0) {
            obj.put("type", 1);
            obj.put("czrq", date);
            obj.put("recordDate", date);
            obj.put("sortDate", date);
            obj.put("czrq", dateString);
            obj.put("recordDate", dateString);
            obj.put("sortDate", dateString);
            for (Map<String, Object> item : list) {
                String data = item.get("value1").toString();
                String dataType = item.get("value2").toString();
                String deviceSn = item.get("device_sn") == null ? "" : item.get("device_sn").toString();
                System.out.println(item.get("record_date").toString());
                Date recordDate = dateFormat6.parse(item.get("record_date").toString());
                Long id = Long.parseLong(item.get("id") + "");
                Date createDate = (Date)item.get("createDate");
@ -426,43 +420,43 @@ public class PatientHealthIndexService {
                if (data != null && dataType != null) {
                    if (dataType.equals("1")) {
                        obj.put("value1", data);
                        obj.put("time1", recordDate);
                        obj.put("time1", recordTime);
                        obj.put("id1", id);
                        obj.put("deviceSn1", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("2")) {
                        obj.put("value2", data);
                        obj.put("time2", recordDate);
                        obj.put("time2", recordTime);
                        obj.put("id2", id);
                        obj.put("deviceSn2", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("3")) {
                        obj.put("value3", data);
                        obj.put("time3", recordDate);
                        obj.put("time3", recordTime);
                        obj.put("id3", id);
                        obj.put("deviceSn3", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("4")) {
                        obj.put("value4", data);
                        obj.put("time4", recordDate);
                        obj.put("time4", recordTime);
                        obj.put("id4", id);
                        obj.put("deviceSn4", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("5")) {
                        obj.put("value5", data);
                        obj.put("time5", recordDate);
                        obj.put("time5", recordTime);
                        obj.put("id5", id);
                        obj.put("deviceSn5", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("6")) {
                        obj.put("value6", data);
                        obj.put("time6", recordDate);
                        obj.put("time6", recordTime);
                        obj.put("id6", id);
                        obj.put("deviceSn6", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("7")) {
                        obj.put("value7", data);
                        obj.put("time7", recordDate);
                        obj.put("time7", recordTime);
                        obj.put("id7", id);
                        obj.put("deviceSn7", deviceSn);
                        hadData = true;
@ -781,12 +775,7 @@ public class PatientHealthIndexService {
                " and a.type="+type+" and a.record_date >= '"+DateUtil.dateToStrLong(startDate)+"' and a.record_date <= '"+DateUtil.dateToStrLong(endDate)+"' " +
                "and a.del = '1' group by DATE_FORMAT(a.record_date,'%Y-%m-%d')" +
                " order by DATE_FORMAT(a.record_date,'%Y-%m-%d') desc limit "+page+" ,"+size;
        return jdbcTemplate.query(sql, new RowMapper<String>() {
            @Override
            public String mapRow(ResultSet resultSet, int i) throws SQLException {
                return null;
            }
        });
        return jdbcTemplate.queryForList(sql, String.class);
    }
    
@ -1413,9 +1402,7 @@ public class PatientHealthIndexService {
                json.put("value7", map.get("value7"));
                json.put("deviceSn", map.get("device_sn") == null ? "" : map.get("device_sn"));
                json.put("type", map.get("type"));
                System.out.println(map.get("record_date"));
                SimpleDateFormat dateFormat6 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                SimpleDateFormat dateFormat3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                Date date = dateFormat6.parse(map.get("record_date").toString()) ;
                if (type == 2) {
                    json.put("date", DateUtil.dateToStr(date, DateUtil.YYYY_MM_DD_HH_MM_SS));
@ -1762,7 +1749,7 @@ public class PatientHealthIndexService {
    }
    public DevicePatientHealthIndex findLastData(String patientCode, int type) {
        String sql = "select a.* from wlyy_patient_health_index a where a.user=?1 and a.type=?2 and a.del='1' order by a.record_date desc limit 0,1";
        String sql = "select a.* from wlyy_patient_health_index a where a.user='"+patientCode+"' and a.type="+type+" and a.del='1' order by a.record_date desc limit 0,1";
        List<DevicePatientHealthIndex> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(DevicePatientHealthIndex.class));
        if(list.size()>0){
            return list.get(0);

+ 37 - 1
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationManageService.java

@ -7,6 +7,7 @@ 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.base.servicePackage.ServiceItemPlanDO;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import com.yihu.jw.entity.door.SignFamily;
import com.yihu.jw.entity.followup.Followup;
import com.yihu.jw.entity.specialist.RehabilitationServiceItemDO;
@ -181,7 +182,7 @@ public class RehabilitationManageService {
        String relationType = detailDO.getHospitalServiceItemId();
        Integer plan_start_time_type = detailDO.getTimeType();//计划开始时间类型
        String server_count = detailDO.getServerCount();//服务次数
        if(StringUtils.isBlank(server_count)){
        if(StringUtils.isBlank(server_count)&&!"2".equals(relationType)&&!"3".equals(relationType)){
            return planDOList;
        }
        String planDetailId = detailDO.getId();
@ -1355,9 +1356,12 @@ public class RehabilitationManageService {
        List<RehabilitationServiceItemDO> itemDOList = serviceItemDao.findList();
        Map<String, String> serviceItemMap = itemDOList.stream().collect(Collectors.toMap(RehabilitationServiceItemDO::getCode, RehabilitationServiceItemDO::getName));
        List<ServiceItemPlanDO> planDOList = serviceItemPlanDao.findByPlanId(planId);
        PatientRehabilitationPlanDO patientRehabilitationPlanDO = patientRehabilitationPlanDao.findById(planId).orElse(null);
        String patient = patientRehabilitationPlanDO.getPatient();
        Map<String,List<ServiceItemPlanDO>> planListMap = planDOList.stream().collect(Collectors.groupingBy(ServiceItemPlanDO::getRelationType));
        for (RehabilitationDetailDO detailDO:detailDOList){
            String key = detailDO.getHospitalServiceItemId();
            String doctor = detailDO.getDoctor();
            List<ServiceItemPlanDO> planDOS = planListMap.get(key);
            if(planDOS==null){
                planDOS = new ArrayList<>();
@ -1385,6 +1389,38 @@ public class RehabilitationManageService {
            detailDO.setCompleteTime(completeTime);
            detailDO.setPlanTime(planTime);
            detailDO.setName(serviceItemMap.get(key));
            if("2".equals(key)){
                //康复咨询
                String sqlTotal = "SELECT COUNT(*) from wlyy_consult_team WHERE patient='"+patient+"' and doctor='"+doctor+"' and type = '28' ";
                Integer signCount = jdbcTemplate.queryForObject(sqlTotal,Integer.class);
                detailDO.setFinishNum(signCount);
                if(signCount>0){
                    String sqlTemp = "select DATE_FORMAT(czrq, '%Y-%m-%d %H:%i:%s') czrq from wlyy_consult_team p where p.patient ='" + patient + "' and doctor='"+doctor+"' and " +
                            "type = '28' order by p.czrq desc limit 0,1 ";
                    List<Map<String,Object>> indexList = jdbcTemplate.queryForList(sqlTemp);
                    if(indexList.size()>0){
                        detailDO.setCompleteTime(indexList.get(0).get("")+"czrq");
                    }
                }
            }
            if("3".equals(key)){
                //健康监测
                String sqlTotal = "select count(*) as total from wlyy_patient_health_index p " +
                        "where p.user ='" + patient + "' and p.type IN(1,2) ";//and p.record_date >= '"+createTime+"'
                Integer signCount = jdbcTemplate.queryForObject(sqlTotal,Integer.class);
                detailDO.setSignCount(signCount);
                if(signCount>0){
                    String sqlTemp = "select p.* from wlyy_patient_health_index p where p.user ='" + patient + "' and p.type IN(1,2) order by p.record_date desc limit 0,1 ";
                    List<DevicePatientHealthIndex> indexList = jdbcTemplate.query(sqlTemp,new BeanPropertyRowMapper<>(DevicePatientHealthIndex.class));
                    if(indexList.size()>0){
                        DevicePatientHealthIndex index = indexList.get(0);
                        detailDO.setSignType(index.getType());
                        detailDO.setValue1(index.getValue1());
                        detailDO.setValue2(index.getValue2());
                        detailDO.setValue3(index.getValue3());
                    }
                }
            }
        }
        return detailDOList;
    }