Browse Source

Merge branch 'dev' of linzhuo/patient-co-management into dev

lyr 8 years ago
parent
commit
58201c24d5

+ 11 - 3
patient-co-wlyy/pom.xml

@ -50,18 +50,18 @@
        <maven>3.0.0</maven>
    </prerequisites>
    <!-- 设定插件仓库, 如有Nexus私服, 取消注释并指向正确的服务器地址.
    <!-- 设定插件仓库, 如有Nexus私服, 取消注释并指向正确的服务器地址. -->
    <pluginRepositories>
        <pluginRepository>
            <id>nexus</id>
            <name>Team Nexus Repository</name>
            <url>http://localhost:8081/nexus/content/groups/public</url>
            <url>http://172.19.103.47:8081/nexus/content/groups/public</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
    -->
    <!-- 依赖项定义 -->
    <dependencies>
@ -71,6 +71,14 @@
            <artifactId>springfox-swagger2</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>java-ffmpegjave</artifactId>
            <version>1.0.3</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/consult/ConsultTeamDao.java

@ -289,7 +289,7 @@ public interface ConsultTeamDao extends PagingAndSortingRepository<ConsultTeam,
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and (a.type=6 or a.type=7 ) and a.patient = ?1 and a.status=?2  and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findMyFamousDoctorListByStatus(String uid, int status, Pageable pageRequest);
	@Query("select a from ConsultTeam a where a.patient = ?1 and a.doctor = ?2 and a.del = '1' and a.status = 0 order by id desc ")
	@Query("select a from ConsultTeam a where ((a.patient = ?1 and a.doctor = ?2) or (a.patient = ?2 and a.doctor = ?1))  and a.del = '1' and a.status = 0 order by id desc ")
	List<ConsultTeam> findUnfinishedConsult(String patient,String doctor);
	@Query("select a.doctor from ConsultTeam a where team = ?1  and del = '1' and type=?2 ")

+ 17 - 7
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -139,8 +139,7 @@ public class ConsultTeamService extends ConsultService {
    /**
     * 查詢醫生網絡諮詢列表
     *
     * @param type     咨询类型:1、咨询我的,2、公共的, 3、参与过的,4、已结束的 5 名医咨询 全部  6 名医咨询 进行中 7 名医咨询 已结束 8名医咨询 待处理 9咨询我的三师 + 家庭 + 名医
     * @param type 咨询类型:1、咨询我的,2、公共的, 3、参与过的,4、已结束的 5 名医咨询 全部  6 名医咨询 进行中 7 名医咨询 已结束 8名医咨询 待处理 9咨询我的三师 + 家庭 + 名医
     * @param id
     * @param pagesize 每页显示数,默认为10
     * @return
@ -1473,8 +1472,18 @@ public class ConsultTeamService extends ConsultService {
                    }
                }
            }
            Doctor doctorTemp = doctorDao.findByCode(ct.getDoctor());
            JSONObject qiuzuObj = new JSONObject();
            qiuzuObj.put("session_id",oldConsult.getPatient()+"_consult_"+oldConsult.getType());
            qiuzuObj.put("patient",ct.getPatient());
            qiuzuObj.put("old_consult_code",oldConsultCode);
            qiuzuObj.put("doctor",ct.getDoctor());
            qiuzuObj.put("doctor_name",doctorTemp.getName());
            ImUtill.sendTopicIM(doctor.getCode(),doctor.getName(),oldConsultCode,"5",qiuzuObj.toString());
        }
        ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"), "1", "咨询问题:" + ct.getSymptoms(), "1");
        ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"),"1","咨询问题:"+ ct.getSymptoms(),"1");
        //推送给IM图片
        if (StringUtils.isNotEmpty(ct.getImages())) {
            String[] images = ct.getImages().split(",");
@ -1543,6 +1552,8 @@ public class ConsultTeamService extends ConsultService {
            ct.setTeam(oldConsultCode);
            if (oldConsult != null && isSend == 1) {
                JSONObject messages = ImUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), oldConsult.getSymptoms(), oldConsult.getImages());
            if(oldConsult!=null&&isSend==1){
                JSONObject messages = ImUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), "居民问题:"+oldConsult.getSymptoms(), oldConsult.getImages());
                JSONObject jsonObject = new JSONObject();
                jsonObject.put(ct.getPatient(), 0);
                jsonObject.put(ct.getDoctor(), 0);
@ -1564,8 +1575,7 @@ public class ConsultTeamService extends ConsultService {
            qiuzuObj.put("old_consult_code", oldConsultCode);
            qiuzuObj.put("doctor", ct.getDoctor());
            qiuzuObj.put("doctor_name", doctor.getName());
            ImUtill.sendTopicIM(doctorTemp.getCode(), doctorTemp.getName(), oldConsultCode, "5", qiuzuObj.toString());
        }
            ImUtill.sendTopicIM(doctorTemp.getCode(), doctorTemp.getName(), oldConsultCode, "5", qiuzuObj.toString());}
        consultTeamDao.save(ct);  // 保存医生咨询信息
        consultTeamDoctorDao.save(cd);
        consultDao.save(consult);
@ -1614,8 +1624,8 @@ public class ConsultTeamService extends ConsultService {
    public void famousConsult(ConsultTeam ct, String uid, String type) throws Exception {
        // 设置患者信息
        ct.setPatient(uid);
        String senderId = "";
        String senderName = "";
        String senderId="";
        String senderName="";
        if ("1".equals(type)) {
            // 查询患者信息
            Patient tempPatient = patientDao.findByCode(uid);

+ 6 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -1740,7 +1740,12 @@ public class FamilyContractService extends BaseService {
                    return result;
                }
                try{
                    ImUtill.deleteMucUser(healthDoctor,signFamily.getDoctorHealth(),patient+"_consult_2");
                    if(signFamily.getDoctorHealth().equals(signFamily.getDoctor())){
                        ImUtill.deleteMucUser(healthDoctor,"",patient+"_consult_2");
                    }else{
                        ImUtill.deleteMucUser(healthDoctor,signFamily.getDoctorHealth(),patient+"_consult_2");
                    }
                }catch (Exception e){
                    result.put("status", -1);
                    result.put("msg", e.getMessage());

+ 2 - 13
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/talk/TalkGroupService.java

@ -215,20 +215,9 @@ public class TalkGroupService extends BaseService {
     */
    public JSONArray getCommonDoctors(String doctor) {
        JSONArray result = new JSONArray();
        String sql = "select distinct d.*" +
                " from" +
                " wlyy_talk_group g" +
                " left join" +
                " wlyy_talk_group_member m" +
                " on g.code = m.group_code" +
                " join " +
                " wlyy_doctor d" +
                " on m.member_code = d.code" +
                " where g.creator = ? and g.type = 2 and m.member_code != ? ";
        List<Doctor> doctors = jdbcTemplate.query(sql, new Object[]{doctor, doctor},
        String sql = "select DISTINCT d.* from wlyy_consult_team p LEFT JOIN wlyy_doctor d on p.doctor = d.code where p.patient =?  order by p.czrq DESC ";
        List<Doctor> doctors = jdbcTemplate.query(sql, new Object[]{doctor},
                new BeanPropertyRowMapper(Doctor.class));
        for (Doctor doc : doctors) {
            JSONObject json = new JSONObject(doc);

+ 69 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/CommonUtil.java

@ -1,10 +1,13 @@
package com.yihu.wlyy.util;
import java.io.*;
import java.util.Date;
import java.util.Random;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.wlyy.config.FastDFSConfig;
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
import it.sauronsoftware.jave.*;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
@ -173,11 +176,10 @@ public class CommonUtil {
     */
    public static String copyTempVoice(String voices) throws  Exception {
        // 文件保存的临时路径
        String tempPath = SystemConf.getInstance().getTempPath() + File.separator;
        String serverUrl = SystemConf.getInstance().getSystemProperties().getProperty("fastdfs_file_url");
        FastDFSUtil fastDFSUtil = new FastDFSUtil();
        String fileUrls = "";
        File f = new File(tempPath + voices);
        File f = new File(voices);
        if (f.exists()) {
            String fileName = f.getName();
            InputStream in = new FileInputStream(f);
@ -253,4 +255,69 @@ public class CommonUtil {
        return fileUrls;
    }
    public static void changeToMp3(String sourcePath, String targetPath) {
        File source = new File(sourcePath);
        File target = new File(targetPath);
        AudioAttributes audio = new AudioAttributes();
        Encoder encoder = new Encoder();
        audio.setCodec("libmp3lame");
        EncodingAttributes attrs = new EncodingAttributes();
        attrs.setFormat("mp3");
        attrs.setAudioAttributes(audio);
        try {
            encoder.encode(source, target, attrs);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (InputFormatException e) {
            e.printStackTrace();
        } catch (EncoderException e) {
            e.printStackTrace();
        }
    }
    public static String  saveVoiceToDisk(InputStream inputStream,String newFileName) throws Exception {
        // 文件保存的临时路径
        String tempPath = SystemConf.getInstance().getTempPath() + File.separator;
        // 拼接年月日路径
        String datePath = DateUtil.getStringDate("yyyy") + File.separator + DateUtil.getStringDate("MM") + File.separator + DateUtil.getStringDate("dd") + File.separator;
        // 保存路径
        File uploadFile = new File(tempPath + datePath + newFileName);
        FileOutputStream fileOutputStream = null;
        try {
            if (!uploadFile.getParentFile().exists()) {
                uploadFile.getParentFile().mkdirs();
            }
            byte[] data = new byte[1024];
            int len = 0;
            fileOutputStream = new FileOutputStream(uploadFile);
            while ((len = inputStream.read(data)) != -1) {
                fileOutputStream.write(data, 0, len);
            }
            // 返回保存路径
            return tempPath+datePath + newFileName;
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (fileOutputStream != null) {
                try {
                    fileOutputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return null;
    }
}

+ 7 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/WeixinBaseController.java

@ -19,8 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import com.yihu.wlyy.entity.security.AccessToken;
import com.yihu.wlyy.entity.security.JsApiTicket;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.service.common.account.AccessTokenService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.common.account.TokenService;
@ -420,7 +418,9 @@ public class WeixinBaseController extends BaseController {
		// 拼接年月日路径
		String datePath = DateUtil.getStringDate("yyyy") + File.separator + DateUtil.getStringDate("MM") + File.separator + DateUtil.getStringDate("dd") + File.separator;
		// 重命名文件
		String newFileName = DateUtil.dateToStr(new Date(), DateUtil.YYYYMMDDHHMMSS) + "_" + new Random().nextInt(1000) + ".mp3";
		String fileBase =  DateUtil.dateToStr(new Date(), DateUtil.YYYYMMDDHHMMSS) + "_" + new Random().nextInt(1000);
		String newFileName = fileBase+ ".amr";
		String mp3FileName  = fileBase + ".mp3";
		// 保存路径
		File uploadFile = new File(tempPath + datePath + newFileName);
@ -437,8 +437,11 @@ public class WeixinBaseController extends BaseController {
			while ((len = inputStream.read(data)) != -1) {
				fileOutputStream.write(data, 0, len);
			}
			String amrFilePath = tempPath+datePath+newFileName;
			String Mp3FilePath = tempPath+datePath+mp3FileName;
			CommonUtil.changeToMp3(amrFilePath,Mp3FilePath);
			// 返回保存路径
			return datePath + newFileName;
			return Mp3FilePath;
		} catch (IOException e) {
			e.printStackTrace();
		} finally {

+ 21 - 16
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/FileUploadController.java

@ -13,6 +13,7 @@ import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
@ -174,25 +175,29 @@ public class FileUploadController extends BaseController {
                // 上传文件
                MultipartFile mf = entity.getValue();
                //byte audioData[] = mf.getBytes();
                //AudioFormat af = getAudioFormat();
                //ByteArrayInputStream bais = new ByteArrayInputStream(audioData);
                //AudioInputStream ais = new AudioInputStream(bais,af, audioData.length / af.getFrameSize());
                //File file = new File("temp.wav");
                //InputStream in = new FileInputStream(file);
                //AudioSystem.write(ais, AudioFileFormat.Type.WAVE,file);
                fileName = mf.getOriginalFilename();
                String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
                if("3".equals(type)){
                    fileExt ="mp3";
                    String tempPath  =  CommonUtil.saveVoiceToDisk(mf.getInputStream(),fileName);
                    String map3Path = tempPath.substring(0,tempPath.lastIndexOf("."));
                    CommonUtil.changeToMp3(tempPath,map3Path);
                    File tempFile = new File(tempPath);
                    File mp3File = new File(map3Path);
                    ObjectNode objectNode = fastDFSUtil.upload(new FileInputStream(mp3File),".mp3","");
                    tempPaths.add(fastUrl + objectNode.get("groupName").toString().replaceAll("\"","")
                            + "/" + objectNode.get("remoteFileName").toString().replaceAll("\"",""));
                    if(tempFile!=null){
                        tempFile.delete();
                    }
                    if(mp3File!=null){
                        mp3File.delete();
                    }
                }else{
                    String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
                    ObjectNode objectNode = fastDFSUtil.upload(mf.getInputStream() ,fileExt,"");
                    tempPaths.add(fastUrl + objectNode.get("groupName").toString().replaceAll("\"","")
                            + "/" + objectNode.get("remoteFileName").toString().replaceAll("\"",""));
                }
                ObjectNode objectNode = fastDFSUtil.upload(mf.getInputStream() ,fileExt,"");
                tempPaths.add(fastUrl + objectNode.get("groupName").toString().replaceAll("\"","")
                        + "/" + objectNode.get("remoteFileName").toString().replaceAll("\"",""));
            }
            String urls = String.join(",", tempPaths);
            JSONObject json = new JSONObject();

+ 1 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java

@ -881,6 +881,7 @@ public class DoctorConsultController extends WeixinBaseController {
                json.put("consult", ct.getConsult());
                //是否是医生求助医生
                if(ct.getType()==10){
                    //取出原有咨询求助返回原咨询的患者
                    ConsultTeam consultTeam = consultTeamService.findByConsultCode(ct.getTeam());
                    Patient patient = patientService.findByCode(consultTeam.getPatient());
                    json.put("zxGroupCode",consultTeam.getPatient()+"_consult_"+consultTeam.getType());