Explorar o código

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

yeshijie %!s(int64=7) %!d(string=hai) anos
pai
achega
2a9df2eca8
Modificáronse 26 ficheiros con 986 adicións e 132 borrados
  1. 1 1
      common/common-entity/src/main/java/com/yihu/mm/entity/questionnaire/MedicineAnswerLog.java
  2. 9 4
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/controller/WeixinBaseController.java
  3. 37 11
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/controller/medicine/PhysicalExaminationController.java
  4. 4 0
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/repository/mm/exam/MedicineAnswerLogDao.java
  5. 13 0
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/MedicineAnswerLogService.java
  6. 56 12
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/PhysicalExaminationService.java
  7. 4 55
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/util/CommonUtil.java
  8. 208 0
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/util/SystemConf.java
  9. 134 0
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/util/fastdfs/FastDFSClientPool.java
  10. 258 0
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/util/fastdfs/FastDFSUtil.java
  11. 15 0
      patient-co-customization/patient-co-modern-medicine/src/main/resources/config/fdfs_client.conf
  12. 5 0
      patient-co-customization/patient-co-modern-medicine/src/main/resources/system.properties
  13. 1 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/filter/SessionOutTimeFilter.java
  14. 0 5
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/family/FamilyMemberService.java
  15. BIN=BIN
      patient-co/patient-co-wlyy/doc/接口文档/对外接口文档/集美健康教育/集美健康教育对外接口文档.docx
  16. 34 13
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java
  17. 24 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/GateWayAOP.java
  18. 12 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/GateWayInterceptor.java
  19. 15 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/PatientInterceptor.java
  20. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/EvaluateService.java
  21. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/gateway/GcTokenService.java
  22. 24 20
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/pc/prescription/PrescriptionExpressagePCService.java
  23. 87 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/ManagerUtilController.java
  24. 23 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/controller/patient/GcPatientController.java
  25. 10 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/vo/PatientModel.java
  26. 10 2
      patient-co/patient-co-wlyy/src/main/resources/application.yml

+ 1 - 1
common/common-entity/src/main/java/com/yihu/mm/entity/questionnaire/MedicineAnswerLog.java

@ -26,7 +26,7 @@ public class MedicineAnswerLog extends IdEntity {
    private String ctId;//咨询编号
    private String question;//问题描述
    private String opti;//问题选项
    private String type;//选项
    private String type;// 1单选  2多选   3面部   4舌部   5声音
    public String getPatientCode() {
        return patientCode;

+ 9 - 4
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/controller/WeixinBaseController.java

@ -3,6 +3,7 @@ package com.yihu.mm.controller;
import com.yihu.mm.service.AccessTokenService;
import com.yihu.mm.util.CommonUtil;
import com.yihu.mm.util.HttpUtil;
import com.yihu.mm.util.SystemConf;
import com.yihu.wlyy.entity.security.AccessToken;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
@ -26,6 +27,10 @@ public class WeixinBaseController extends BaseController {
	private String appId;
	@Value("${wechat.appSecret}")
	private String appSecret;
	@Autowired
	private CommonUtil CommonUtil;
	@Autowired
	private HttpUtil HttpUtil;
	/**
	 * 获取微信的access_token
@ -47,7 +52,7 @@ public class WeixinBaseController extends BaseController {
			}
			String token_url = "https://api.weixin.qq.com/cgi-bin/token";
			String params = "grant_type=client_credential&appid=" + appId + "&secret=" + appSecret;
			String result = new HttpUtil().sendGet(token_url, params);
			String result = HttpUtil.sendGet(token_url, params);
			JSONObject json = new JSONObject(result);
			if (json.has("access_token")) {
				String token = json.get("access_token").toString();
@ -107,7 +112,7 @@ public class WeixinBaseController extends BaseController {
	 */
	public String saveVoiceToDisk(String mediaId) throws Exception {
		// 文件保存的临时路径
		String tempPath = Class.class.getClass().getResource("/").getPath() + "temp/";
		String tempPath = SystemConf.getInstance().getTempPath() + File.separator;
		// 重命名文件
		String fileBase = UUID.randomUUID().toString();
		String newFileName = fileBase+ ".amr";
@ -130,7 +135,7 @@ public class WeixinBaseController extends BaseController {
			}
			String amrFilePath = tempPath+newFileName;
			String Mp3FilePath = tempPath+mp3FileName;
			new CommonUtil().changeToMp3(amrFilePath,Mp3FilePath);
			CommonUtil.changeToMp3(amrFilePath,Mp3FilePath);
			// 返回保存路径
			return Mp3FilePath;
		} catch (IOException e) {
@ -190,7 +195,7 @@ public class WeixinBaseController extends BaseController {
	public String getOpenId(String code) throws Exception {
		String token_url = "https://api.weixin.qq.com/sns/oauth2/access_token";
		String params = "appid=" + appId+ "&secret=" + appSecret + "&code=" + code + "&grant_type=authorization_code";
		String result = new HttpUtil().sendGet(token_url, params);
		String result = HttpUtil.sendGet(token_url, params);
		JSONObject json = new JSONObject(result);
		if (json.has("openid")) {
			return json.get("openid").toString();

+ 37 - 11
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/controller/medicine/PhysicalExaminationController.java

@ -93,8 +93,7 @@ public class PhysicalExaminationController extends WeixinBaseController {
    @ApiOperation(value = "获取试题")
    @RequestMapping(value = "/findQuestion",produces="application/json;charset=UTF-8")
    @ResponseBody
    public String findQuestion(
                               @ApiParam(name = "pb_id", value = "问卷编号,第一题为0", required = true)@RequestParam(required = true, name = "pb_id") String pb_id,
    public String findQuestion(@ApiParam(name = "pb_id", value = "问卷编号,第一题为0", required = true)@RequestParam(required = true, name = "pb_id") String pb_id,
                               @ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode,
                               @ApiParam(name = "ct_id", value = "咨询编号", required = true)@RequestParam(required = true, name = "ct_id") String ct_id) throws IOException {
@ -186,34 +185,44 @@ public class PhysicalExaminationController extends WeixinBaseController {
    @ApiOperation(value = "获取微信文件,传到越人接口(四象采集,声音文件需要从微信接口获取)")
    @RequestMapping(value = "/dealVoice", produces="application/json;charset=UTF-8")
    @ResponseBody
    public String getFileFromWechat( @ApiParam(name = "mediaId", value = "微信媒体id", required = true)@RequestParam(required = true, name = "mediaId") String mediaId,
    public String getFileFromWechat(@ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode,
                                    @ApiParam(name = "mediaId", value = "微信媒体id", required = true)@RequestParam(required = true, name = "mediaId") String mediaId,
                                   @ApiParam(name = "type", value = "1.脸型  2.舌像  3.声音", required = true)@RequestParam(required = true, name = "type") String type,
                                   @ApiParam(name = "ct_id", value = "咨询编号", required = true)@RequestParam(required = true, name = "ct_id") String ct_id) throws Exception {
        System.out.println("===================================");
        System.out.println(mediaId);
        System.out.println("======================================");
        String voice = saveVoiceToDisk(mediaId);
        String uploadAttachment = physicalExaminationService.uploadAttachment(voice);
        JSONObject uploadResult = new JSONObject(uploadAttachment);
        if(physicalExaminationService.getSuccess(uploadResult)){
            JSONObject recordset = uploadResult.getJSONObject("recordset");
            String at_id =  recordset.get("at_id").toString();
            String at_realname = (String) recordset.get("at_realname");
            String result = physicalExaminationService.dillphoneimgdata(at_id, at_realname, type, ct_id);
            JSONObject resultJson = new JSONObject(result);
            if(physicalExaminationService.getSuccess(resultJson)){
                String type1=Integer.valueOf(type)+2+"";
                MedicineAnswerLog medicineAnswerLog = medicineAnswerLogService.findByTypeAndCtid(type1,ct_id ,patientCode);
                if(medicineAnswerLog==null){
                    medicineAnswerLog = new MedicineAnswerLog();
                    medicineAnswerLog.setCreateTime(new Date());
                    medicineAnswerLog.setType(type1);
                }
                medicineAnswerLog.setPatientCode(patientCode);
                medicineAnswerLog.setTpId(examCode);
                medicineAnswerLog.setAnswer(uploadResult.getString("fileUrl"));
                medicineAnswerLog.setCtId(ct_id);
                medicineAnswerLogService.save(medicineAnswerLog);
            }
            return result;
        }
        return uploadAttachment;
    }
    @ApiOperation(value = "四诊资料采集")
    @RequestMapping(value = "/dillphoneimgdata", method = RequestMethod.POST,produces="application/json;charset=UTF-8")
    @ResponseBody
    public String dillphoneimgdata(@RequestParam MultipartFile file,
                              @ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode,
                              @ApiParam(name = "type", value = "1.脸型  2.舌像  3.声音", required = true)@RequestParam(required = true, name = "type") String type,
                             @ApiParam(name = "ct_id", value = "咨询编号", required = true)@RequestParam(required = true, name = "ct_id") String ct_id){
        String uploadAttachment = physicalExaminationService.uploadAttachment(file);
@ -223,6 +232,23 @@ public class PhysicalExaminationController extends WeixinBaseController {
            String at_id =  recordset.get("at_id").toString();
            String at_realname = (String) recordset.get("at_realname");
            String result = physicalExaminationService.dillphoneimgdata(at_id, at_realname, type, ct_id);
            JSONObject resultJson = new JSONObject(result);
            if(physicalExaminationService.getSuccess(resultJson)){
                String type1=Integer.valueOf(type)+2+"";
                MedicineAnswerLog medicineAnswerLog = medicineAnswerLogService.findByTypeAndCtid(type1,ct_id ,patientCode);
                if(medicineAnswerLog==null){
                    medicineAnswerLog = new MedicineAnswerLog();
                    medicineAnswerLog.setCreateTime(new Date());
                    medicineAnswerLog.setType(type1);
                }
                medicineAnswerLog.setPatientCode(patientCode);
                medicineAnswerLog.setTpId(examCode);
                medicineAnswerLog.setAnswer(uploadResult.getString("fileUrl"));
                medicineAnswerLog.setCtId(ct_id);
                medicineAnswerLogService.save(medicineAnswerLog);
            }
            return result;
        }
        return uploadAttachment;

+ 4 - 0
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/repository/mm/exam/MedicineAnswerLogDao.java

@ -14,4 +14,8 @@ public interface MedicineAnswerLogDao extends PagingAndSortingRepository<Medicin
	@Query("select m from MedicineAnswerLog m where m.patientCode=?1 and m.tpId=?2 and m.pbId=?3 and m.ctId=?4")
    MedicineAnswerLog findAnswer(String patientCode, String tp_id, String pb_id,String ct_id);
	@Query("select m from MedicineAnswerLog m where m.type=?1 and m.ctId=?2 and m.patientCode=?3")
    MedicineAnswerLog findByTypeAndCtid(String type, String ct_id,String patientCode);
}

+ 13 - 0
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/MedicineAnswerLogService.java

@ -33,4 +33,17 @@ public class MedicineAnswerLogService {
    public MedicineAnswerLog findAnswer(String patientCode,String tp_id,String pb_id,String ct_id){
        return  medicineAnswerLogDao.findAnswer(patientCode,tp_id,pb_id,ct_id);
    }
    /**
     * type 为  3,4,5 (3面部   4舌部   5声音)   时,才能返回查询的记录 ,否则返回 null
     * @param type
     * @param ct_id
     * @return
     */
    public MedicineAnswerLog findByTypeAndCtid(String type, String ct_id,String patientCode) {
        if("3".equals(type)||"4".equals(type)||"5".equals(type)){
            return medicineAnswerLogDao.findByTypeAndCtid(type,ct_id,patientCode);
        }
        return null;
    }
}

+ 56 - 12
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/PhysicalExaminationService.java

@ -1,9 +1,13 @@
package com.yihu.mm.service;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.mm.entity.patient.ExamReport;
import com.yihu.mm.entity.yueren.MedicineStroresNo;
import com.yihu.mm.util.CommonUtil;
import com.yihu.mm.util.HttpClientUtil;
import com.yihu.mm.util.fastdfs.FastDFSUtil;
import com.yihu.wlyy.entity.patient.Patient;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -14,8 +18,7 @@ import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
@ -32,6 +35,11 @@ public class PhysicalExaminationService {
    @Autowired
    private ExamReportService examReportService;
    @Autowired
    private CommonUtil CommonUtil;
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastdfs_file_url;
    public boolean getSuccess(JSONObject result ){
@ -211,6 +219,10 @@ public class PhysicalExaminationService {
        }
        try {
            file.transferTo(dest);
            //上传图片到fastDFS
            String fileUrl = uploadToFastDfs(dest);
            RestTemplate rest = new RestTemplate();
            FileSystemResource resource = new FileSystemResource(filePath);
            param.add("file", resource);
@ -218,25 +230,57 @@ public class PhysicalExaminationService {
            if (dest.exists() && dest.isFile()) {
                dest.delete();
            }
            return postStr;
            postStr.replace("exception", "msg");
            JSONObject result = new JSONObject(postStr);
            result.put("fileUrl",fileUrl);
            return result.toString();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "{\"status\":500,\"msg\":\"上传文件出错\"}";
    }
    public String uploadAttachment(String filePath) {
    public String uploadAttachment(String file){
        MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
        File dest = new File(filePath);
        RestTemplate rest = new RestTemplate();
        FileSystemResource resource = new FileSystemResource(filePath);
        param.add("file", resource);
        String postStr = rest.postForObject(yuerenApi+"/uploadattachment" , param, String.class);
        if (dest.exists() && dest.isFile()) {
            dest.delete();
        File dest = new File(file);
        try {
            //上传图片到fastDFS
            String fileUrl = uploadToFastDfs(dest);
            RestTemplate rest = new RestTemplate();
            FileSystemResource resource = new FileSystemResource(file);
            param.add("file", resource);
            String postStr = rest.postForObject(yuerenApi+"/uploadattachment" , param, String.class);
            if (dest.exists() && dest.isFile()) {
                dest.delete();
            }
            postStr.replace("exception", "msg");
            JSONObject result = new JSONObject(postStr);
            result.put("fileUrl",fileUrl);
            return result.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "{\"status\":500,\"msg\":\"上传文件出错\"}";
    }
    private String uploadToFastDfs(File file) throws Exception {
        String fileUrls = "";
        FastDFSUtil fastDFSUtil = new FastDFSUtil();
        String fileName = file.getName();
        InputStream in = new FileInputStream(file);
        ObjectNode result = fastDFSUtil.upload(in, fileName.substring(fileName.lastIndexOf(".") + 1), "");
        in.close();
        if (result != null) {
            fileUrls += (StringUtils.isEmpty(fileUrls) ? "" : ",") + fastdfs_file_url
                    + result.get("groupName").toString().replaceAll("\"", "") + "/"
                    + result.get("remoteFileName").toString().replaceAll("\"", "");
        }
        return postStr.replace("exception", "msg");
        return fileUrls;
    }
}

+ 4 - 55
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/util/CommonUtil.java

@ -1,5 +1,7 @@
package com.yihu.mm.util;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.mm.util.fastdfs.FastDFSUtil;
import it.sauronsoftware.jave.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
@ -96,7 +98,6 @@ public class CommonUtil {
     */
/*
    public String copyTempVoice(String voices) throws  Exception {
        // 文件保存的临时路径
        String serverUrl = fastdfs_file_url;
@ -117,7 +118,6 @@ public class CommonUtil {
        }
        return fileUrls;
    }
*/
    /**
     * double转字符串,在转int
@ -180,7 +180,7 @@ public class CommonUtil {
     * @return
     * @throws Exception
     */
    /*public  String copyTempImage(String files) throws Exception {
    public  String copyTempImage(String files) throws Exception {
        // 文件保存的临时路径
        String tempPath = SystemConf.getInstance().getTempPath() + File.separator;
        String serverUrl = fastdfs_file_url;
@ -209,7 +209,7 @@ public class CommonUtil {
        }
        return fileUrls;
    }*/
    }
    public  void changeToMp3(String sourcePath, String targetPath) {
        File source = new File(sourcePath);
@ -257,16 +257,9 @@ public class CommonUtil {
        File target = new File(targetPath);
        AudioAttributes audio = new AudioAttributes();
        //audio.setCodec("aac");
        audio.setCodec("libvorbis");
       // audio.setBitRate(new Integer(64000));
        //audio.setChannels(new Integer(1));
       // audio.setSamplingRate(new Integer(22050));
        VideoAttributes video = new VideoAttributes();
        //video.setCodec("libxvid");// 转MP4
        video.setCodec("libtheora");//
       // video.setBitRate(new Integer(240000));// 180kb/s比特率
       // video.setFrameRate(new Integer(28));// 1f/s帧频,1是目前测试比较清楚的,越大越模糊
        EncodingAttributes attrs = new EncodingAttributes();
        attrs.setFormat("ogg");// 转MP4
        attrs.setAudioAttributes(audio);
@ -305,48 +298,4 @@ public class CommonUtil {
            return content.substring(min,max);
        }
    }
    /*public  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;
    }*/
}

+ 208 - 0
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/util/SystemConf.java

@ -0,0 +1,208 @@
package com.yihu.mm.util;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
@Component
public class SystemConf {
    // 别处登录
    public static final int LOGIN_OTHER = 999;
    // 登录超时
    public static final int LOGIN_TIMEOUT = 998;
    // 未登录
    public static final int NOT_LOGIN = 997;
    // 文件保存临时路径
    private static final String TEMP_PATH = "upload_temp_path";
    // 血糖餐前最小值
    public static final double HEALTH_STANDARD_ST_MIN_BEFORE = 4;
    // 血糖餐前最大值
    public static final double HEALTH_STANDARD_ST_MAX_BEFORE = 7;
    // 血糖餐后最小值
    public static final double HEALTH_STANDARD_ST_MIN_AFTER = 4;
    // 血糖餐后最大值
    public static final double HEALTH_STANDARD_ST_MAX_AFTER = 11.1;
    // 舒张压最小值
    public static final double HEALTH_STANDARD_SZY_MIN = 60;
    // 舒张压最大值
    public static final double HEALTH_STANDARD_SZY_MAX = 90;
    // 收缩压最小值
    public static final double HEALTH_STANDARD_SSY_MIN = 90;
    // 收缩压最大值
    public static final double HEALTH_STANDARD_SSY_MAX = 140;
    // 同一手机号大最短信数
    public static final int MAX_SMS_MOBILE = 5;
    // 发送短信验证码间隔(分钟)
    public static final int SMS_INTERVAL = 2;
    private static Object lock = new Object();
    // 全局系统配置信息
    private static SystemConf systemConf;
    // 系统配置文件
    private Properties systemProperties;
    //im列表
    private String imListGet;
    public static SystemConf getInstance() {
        if (systemConf == null) {
            synchronized (lock) {
                systemConf = new SystemConf();
            }
        }
        return systemConf;
    }
    /**
     * 加载系统配置文件
     *
     * @return
     */
    public Properties getSystemProperties() {
        if (systemProperties == null) {
            InputStream is = null;
            try {
                is = this.getClass().getResourceAsStream("/system.properties");
                systemProperties = new Properties();
                systemProperties.load(is);
            } catch (IOException e1) {
                e1.printStackTrace();
            } finally {
                if (is != null) {
                    try {
                        is.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        return systemProperties;
    }
    /**
     * 短信接口地址
     */
    public String getSmsUrl() {
        return getSystemProperties().getProperty("yihu_sms_url");
    }
    /**
     * 短信企业编号
     */
    public String getSmsCode() {
        return getSystemProperties().getProperty("yihu_sms_code");
    }
    /**
     * 短信用户名
     */
    public String getSmsName() {
        return getSystemProperties().getProperty("yihu_sms_name");
    }
    /**
     * 短信登录密码
     */
    public String getSmsPassword() {
        return getSystemProperties().getProperty("yihu_sms_password");
    }
    ;
    /**
     * 挂号接口地址
     */
    public String getGuahaoUrl() {
        return getSystemProperties().getProperty("yihu_guahao_url");
    }
    /**
     * 挂号接口对接appid
     */
    public String getGuahaoAppid() {
        return getSystemProperties().getProperty("yihu_guahao_appid");
    }
    /**
     * 挂号接口对接app secret
     */
    public String getGuahaoSecret() {
        return getSystemProperties().getProperty("yihu_guahao_secret");
    }
    /**
     * 获取文件保存的临时路径
     *
     * @return
     */
    public String getTempPath() {
        return getSystemProperties().getProperty(TEMP_PATH);
    }
    /**
     * 获取图片存在地址
     *
     * @return
     */
    /**
     * 获取服务全路径
     *
     * @return
     */
    /******************************** 挂号配置 ********************************************/
    /**
     * 获取厦门预约服务地址
     */
    public String getXMGuahaoUrl() {
        return getSystemProperties().getProperty("guahao_url");
    }
    /**
     * 获取厦门预约服务命名空间
     */
    public String getXMGuahaoNamespace() {
        return getSystemProperties().getProperty("guahao_namespace");
    }
    /****************************************************************************************/
    /********************************* EHR配置 **********************************************/
    /**
     * 是否启用EHR演示
     */
    public Boolean getEhrUsed() {
        return Boolean.valueOf(getSystemProperties().getProperty("ehr_used"));
    }
    /**
     * EHR档案服务地址
     */
    public String getEhrServices() {
        return getSystemProperties().getProperty("ehr_services");
    }
    /**
     * EHR底层地址
     */
    public String getEhrServicesBase() {
        return getSystemProperties().getProperty("ehr_services_base");
    }
    /**************************************************************************************/
    /**************************************************************************************/
}

+ 134 - 0
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/util/fastdfs/FastDFSClientPool.java

@ -0,0 +1,134 @@
package com.yihu.mm.util.fastdfs;
import org.csource.fastdfs.ClientGlobal;
import org.csource.fastdfs.StorageClient;
import org.csource.fastdfs.TrackerClient;
import org.csource.fastdfs.TrackerServer;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
/**
 * Created by szx on 2015/9/19.
 */
public class FastDFSClientPool {
    private static volatile FastDFSClientPool pool;
    private Map<StorageClient, Boolean> map;
    private int maxPoolSize = 20;
    private int waitTime = 500;
    private int initPoolSize = 5;
    static {
        try {
            
            String basePath = FastDFSClientPool.class.getResource("/").getPath();
           
            ClientGlobal.init(FastDFSUtil.class.getResource("/config/fdfs_client.conf").getPath());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    private FastDFSClientPool() {
        init();
    }
    public static FastDFSClientPool getInstance() {
        if (pool == null) {
            synchronized (FastDFSClientPool.class) {
                if(pool == null) {
                    pool = new FastDFSClientPool();
                }
            }
        }
        System.out.println("FastDFSClientPool:"+pool.toString());
        return pool;
    }
    private void init() {
        try {
            map = new HashMap<StorageClient, Boolean>();
            //不做初始缓存
//            for (int i = 0; i < initPoolSize; i++) {
//                map.put(getNewStorageClient(), true);
//            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public TrackerServer getTrackerServer(){
        try {
            TrackerClient tracker = new TrackerClient();
            return tracker.getConnection();
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    private StorageClient getNewStorageClient() {
        try {
            TrackerClient tracker = new TrackerClient();
            TrackerServer trackerServer = tracker.getConnection();
            StorageClient client = new StorageClient(trackerServer, null);
            return client;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    public synchronized StorageClient getStorageClient() {
        StorageClient client = null;
        try {
            for (Entry<StorageClient, Boolean> entry : map.entrySet()) {
                if (entry.getValue()) {
                    client = entry.getKey();
                    System.out.println("从缓存中获得fastdfs client");
                    map.put(client, false);
                    break;
                }
            }
            if (client == null) {
                if(map.size()<maxPoolSize) {
                    System.out.println("创建新fastdfs client:");
                    client = getNewStorageClient();
                    map.put(client, false);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return client;
    }
    public void releaseStorageClient(StorageClient client) {
        if (client == null) {
            return;
        }
        try {
            if(map.containsKey(client)) {
                    map.put(client, true);
            } else {
                client =null;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

+ 258 - 0
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/util/fastdfs/FastDFSUtil.java

@ -0,0 +1,258 @@
package com.yihu.mm.util.fastdfs;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.csource.common.MyException;
import org.csource.common.NameValuePair;
import org.csource.fastdfs.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetSocketAddress;
/**
 * FastDFS 客户端工具.
 *
 * @author szx
 */
public class FastDFSUtil {
    public final static String GroupField = "groupName";
    public final static String RemoteFileField = "remoteFileName";
    public final static String FileIdField = "fid";
    public final static String FileUrlField = "fileUrl";
    final static int BUFFER_SIZE = 4096;
    /**
     * 以输入流的方式上传文件
     * InputStream in = new FileInputStream("C://Desert.jpg");
     * ObjectNode msg = FileUtil.upload(in,"jpg", "沙漠");
     * in.close();
     *
     * @param in                输入流
     * @param fileExtension   文件扩展名,不要带“.”
     * @param description             文件名称(中文)
     * @return 返回值的格式如下:
     * {
     *      "groupName": "healthArchiveGroup",
     *      "remoteFileName": "/M00/00/24/rBFuH1XdQC6AP3CDAAzodQCbVVc052.jpg",
     *      "fid": "group1/M00/00/24/rBFuH1XdQC6AP3CDAAzodQCbVVc052.jpg",
     *      "fileURL": "http://172.19.103.13/healthArchiveGroup/M00/00/24/rBFuH1XdQC6AP3CDAAzodQCbVVc052.jpg"
     * }
     *
     * groupName 及 remoteFileName 可以用于查询在 fastDFS 中文件的信息,如果只是图片显示,可以忽略这两个值。
     * fid 保存了在 fastDFS 上的完整路径,为了避免将来服务器域名发生变更,最好使用本值.服务器的域名另外配置。
     * fileURL 保存了完整的 web 访问路径,为了避免将来服务器域名发生变更,最好不要直接使用本值。
     * 如果需要在下载时,可以显示原始文件名,请在访问file_url时,增加 attname 参数,如:
     *
     * http://host/healthArchiveGroup/M00/00/00/rBFuH1XdIseAUTZZAA1rIuRd3Es062.jpg?attname=a.jpg
     *
     * @throws Exception
     */
    public static ObjectNode upload(InputStream in, String fileExtension,
                                    String description) throws Exception {
        StorageClient client = FastDFSClientPool.getInstance().getStorageClient();
        try {
            NameValuePair[] fileMetaData;
            fileMetaData = new NameValuePair[1];
            fileMetaData[0] = new NameValuePair("description", description == null ? "" : description);
            ObjectMapper objectMapper = new ObjectMapper();
            ObjectNode message = objectMapper.createObjectNode();
            ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
            byte[] buff = new byte[BUFFER_SIZE]; //buff用于存放循环读取的临时数据
            int rc = 0;
            while ((rc = in.read(buff, 0, BUFFER_SIZE)) > 0) {
                swapStream.write(buff, 0, rc);
            }
            byte[] fileBuffer = swapStream.toByteArray(); //in_b为转换之后的结果
            TrackerServer trackerServer = FastDFSClientPool.getInstance().getTrackerServer();
            String[] results = client.upload_file(fileBuffer, fileExtension, fileMetaData);
            if (results != null) {
                String fileId;
                int ts;
                String token;
                String fileURl;
                InetSocketAddress socketAddress;
                String groupName = results[0];
                String remoteFile = results[1];
                message.put(GroupField, groupName);
                message.put(RemoteFileField, remoteFile);
                fileId = groupName + StorageClient1.SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR + remoteFile;
                message.put(FileIdField, fileId);
                socketAddress = trackerServer.getInetSocketAddress();
                fileURl = "http://" + socketAddress.getAddress().getHostAddress();
                if (ClientGlobal.g_tracker_http_port != 80) {
                    fileURl += ":" + ClientGlobal.g_tracker_http_port;
                }
                fileURl += "/" + fileId;
                if (ClientGlobal.g_anti_steal_token) {
                    ts = (int) (System.currentTimeMillis() / 1000);
                    token = ProtoCommon.getToken(fileId, ts, ClientGlobal.g_secret_key);
                    fileURl += "?token=" + token + "&ts=" + ts;
                }
                message.put(FileUrlField, fileURl);
                
                return message;
            } else {
                return null;
            }
        }finally {
            FastDFSClientPool.getInstance().releaseStorageClient(client);
        }
    }
    /**
     * 上传本地文件
     * ObjectNode  a = FileUtil.upload("C://Desert.jpg", "沙漠");
     * System.out.println(a.toString());
     *
     * @param fileName 本地文件的绝对路径,如 C://Desert.jpg
     * @param description    文件备注, 可以为空
     * @return {"groupName":"group1","remoteFileName":"/M00/00/24/rBFuH1XdQC6AP3CDAAzodQCbVVc052.jpg"
     * {
     *      "groupName": "healthArchiveGroup",
     *      "remoteFileName": "/M00/00/24/rBFuH1XdQC6AP3CDAAzodQCbVVc052.jpg",
     *      "fid": "group1/M00/00/24/rBFuH1XdQC6AP3CDAAzodQCbVVc052.jpg",
     *      "fileURL": "http://172.19.103.13/healthArchiveGroup/M00/00/24/rBFuH1XdQC6AP3CDAAzodQCbVVc052.jpg"
     * }
     *
     * groupName 及 remoteFileName 可以用于查询在 fastDFS 中文件的信息,如果只是图片显示,可以忽略这两个值。
     * fid 保存了在 fastDFS 上的完整路径,为了避免将来服务器域名发生变更,最好使用本值.服务器的域名另外配置。
     * fileURL 保存了完整的 web 访问路径,为了避免将来服务器域名发生变更,最好不要直接使用本值。
     * 如果需要在下载时,可以显示原始文件名,请在访问file_url时,增加 attname 参数,如:
     *
     * http://host/healthArchiveGroup/M00/00/00/rBFuH1XdIseAUTZZAA1rIuRd3Es062.jpg?attname=a.jpg
     *
     * @throws Exception
     */
    public static ObjectNode upload(String fileName, String description) throws Exception {
        StorageClient client = FastDFSClientPool.getInstance().getStorageClient();
        try {
            NameValuePair[] meta_list;
            meta_list = new NameValuePair[1];
            meta_list[0] = new NameValuePair("description", description == null ? "" : description);
            ObjectMapper objectMapper = new ObjectMapper();
            ObjectNode message = objectMapper.createObjectNode();
            String fileExtName = "";
            if (fileName.contains(".")) {
                fileExtName = fileName.substring(fileName.lastIndexOf(".") + 1);
            } else {
                throw new RuntimeException("上传失败, 文件缺失扩展名.");
            }
            TrackerServer trackerServer = FastDFSClientPool.getInstance().getTrackerServer();
            String[] results = client.upload_file(fileName, fileExtName, meta_list);
            if (results != null) {
                String fileId;
                int ts;
                String token;
                String fileUrl;
                InetSocketAddress inetSockAddr;
                String groupName = results[0];
                String remoteFileName = results[1];
                message.put(GroupField, groupName);
                message.put(RemoteFileField, remoteFileName);
                fileId = groupName + StorageClient1.SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR + remoteFileName;
                message.put(FileIdField, fileId);
                inetSockAddr = trackerServer.getInetSocketAddress();
                fileUrl = "http://" + inetSockAddr.getAddress().getHostAddress();
                if (ClientGlobal.g_tracker_http_port != 80) {
                    fileUrl += ":" + ClientGlobal.g_tracker_http_port;
                }
                fileUrl += "/" + fileId;
                if (ClientGlobal.g_anti_steal_token) {
                    ts = (int) (System.currentTimeMillis() / 1000);
                    token = ProtoCommon.getToken(fileId, ts, ClientGlobal.g_secret_key);
                    fileUrl += "?token=" + token + "&ts=" + ts;
                }
                message.put(FileUrlField, fileUrl);
                
                return message;
            } else {
                return null;
            }
        }finally {
            FastDFSClientPool.getInstance().releaseStorageClient(client);
        }
    }
    /**
     * 下载文件, 返回文件字节数组.
     *
     * @param groupName      在fastdfs上的卷名
     * @param remoteFileName 在fastdfs上的路径
     * @return 文件的字节码
     * @throws Exception
     */
    public static byte[] download(String groupName, String remoteFileName) throws Exception {
        StorageClient client = FastDFSClientPool.getInstance().getStorageClient();
        try {
            byte[] b = client.download_file(groupName, remoteFileName);
            return b;
        }
        finally {
            FastDFSClientPool.getInstance().releaseStorageClient(client);
        }
    }
    /**
     * 下载文件到本地路径上.
     *
     * @param groupName          在 fastDFS 上的卷名
     * @param remoteFileName    在 fastDFS 上的路径
     * @param localPath          本地路径
     *
     * @return 是否下载成功
     */
    public static String download(String groupName, String remoteFileName, String localPath) throws IOException, MyException {
        StorageClient client = FastDFSClientPool.getInstance().getStorageClient();
        try {
            String localFileName = localPath + "\\" + remoteFileName.replaceAll("/", "_");
            client.download_file(groupName, remoteFileName, 0, 0, localFileName);
            return localFileName;
        }finally {
            FastDFSClientPool.getInstance().releaseStorageClient(client);
        }
    }
    /**
     * 删除文件。
     *
     * @param groupName
     * @param remoteFileName
     */
    public static void delete(String groupName, String remoteFileName) throws IOException, MyException {
        StorageClient client = FastDFSClientPool.getInstance().getStorageClient();
        try {
            client.delete_file(groupName, remoteFileName);
        }finally {
            FastDFSClientPool.getInstance().releaseStorageClient(client);
        }
    }
}

+ 15 - 0
patient-co-customization/patient-co-modern-medicine/src/main/resources/config/fdfs_client.conf

@ -0,0 +1,15 @@
connect_timeout = 2
network_timeout = 30
charset = ISO8859-1
http.tracker_http_port = 80
http.anti_steal_token = no
http.secret_key = FastDFS1234567890
#-------------开发环境---------------#
tracker_server = 172.19.103.54:22122
#-------------测试环境---------------#
#tracker_server = 172.19.103.54:22122
#-------------正式环境---------------#
#tracker_server = 192.168.0.239:22122

+ 5 - 0
patient-co-customization/patient-co-modern-medicine/src/main/resources/system.properties

@ -0,0 +1,5 @@
# \u4E0A\u4F20\u6587\u4EF6\u914D\u7F6E
upload_temp_path=/var/local/temp
image_path=/var/local/upload/images
voice_path=/var/local/upload/voice
chat_file_path=/var/local/upload/chat

+ 1 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/filter/SessionOutTimeFilter.java

@ -34,7 +34,7 @@ public class SessionOutTimeFilter extends OncePerRequestFilter {
        if (isLogin == null || (String) isLogin != "true") {
//            request.setAttribute(FormAuthenticationFilter.DEFAULT_ERROR_KEY_ATTRIBUTE_NAME,"请重新登入");
            if(path.indexOf("customer")>-1){
                httpServletResponse.getOutputStream().write("{\"code\":-200}".getBytes());//-200   客服未登录
                httpServletResponse.getOutputStream().write("{\"status\":-200}".getBytes());//-200   客服未登录
                return ;
            }

+ 0 - 5
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/family/FamilyMemberService.java

@ -118,11 +118,6 @@ public class FamilyMemberService extends BaseService {
                }else {
                    list.add(map1);
                }
                if(family_relation==0){
                    tem.put(map1);
                }else {
                    list.add(map1);
                }
            }
        }
        return list;

BIN=BIN
patient-co/patient-co-wlyy/doc/接口文档/对外接口文档/集美健康教育/集美健康教育对外接口文档.docx


+ 34 - 13
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java

@ -10,6 +10,7 @@ import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.method.HandlerMethod;
@ -31,18 +32,25 @@ public class DoctorInterceptor extends BaseInterceptor {
    private Logger logger = LoggerFactory.getLogger(DoctorInterceptor.class);
    public static String status = "1";
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        boolean flag = true;
        if(Flag.close.equals(status)){
            return true;
        }
        try {
            request.setCharacterEncoding("UTF-8");
            response.setHeader("Content-type", "text/html;charset=UTF-8");
            request.setAttribute("log-start", new Date().getTime());
            response.setCharacterEncoding("UTF-8");
            JSONObject json = getAgent(request);
            if (json == null) {
                // 未登录
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes("UTF-8"));
                return false;
            }
@ -59,11 +67,11 @@ public class DoctorInterceptor extends BaseInterceptor {
            String imei = json.has("imei") ? json.getString("imei") : "";
            String observer = json.has("observer") ? json.getString("observer") : "";
            Integer platform = json.has("platform") ? json.getInt("platform") : 2;
            logger.debug("tokenStr:"+tokenStr);
            logger.debug("uid:"+uid);
            logger.debug("imei:"+imei);
            logger.debug("observer:"+observer);
            logger.debug("platform:"+platform);
            logger.debug("tokenStr:" + tokenStr);
            logger.debug("uid:" + uid);
            logger.debug("imei:" + imei);
            logger.debug("observer:" + observer);
            logger.debug("platform:" + platform);
            //如果是观察者直接返回true
            if (!org.springframework.util.StringUtils.isEmpty(observer) && observer.equals("1")) {
@ -99,7 +107,7 @@ public class DoctorInterceptor extends BaseInterceptor {
                            request.getMethod().toUpperCase().compareTo(cudUrl.getMethod()) != 0) {
                        return true;
                    } else {
                        response.getOutputStream().write(error(403, "该操作没有权限").getBytes());
                        response.getOutputStream().write(error(403, "该操作没有权限").getBytes("UTF-8"));
                        return false;
                    }
                }
@ -107,7 +115,7 @@ public class DoctorInterceptor extends BaseInterceptor {
                return true;
            }
            if (StringUtils.isEmpty(tokenStr) || StringUtils.isEmpty(imei) || StringUtils.isEmpty(uid)) {
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes("UTF-8"));
                return false;
            }
@ -115,7 +123,7 @@ public class DoctorInterceptor extends BaseInterceptor {
            Map<String, Token> tempMap = null;
            if (platform == 2) {
                tempMap = SystemData.doctorTokens;
            }else if(platform == 4){
            } else if (platform == 4) {
                tempMap = SystemData.doctorPCTokens;
            }
            token = tempMap.get(uid);
@ -127,18 +135,18 @@ public class DoctorInterceptor extends BaseInterceptor {
                }
            }
            //  2、医生端app,3、微信公众号wechat,4、医生端pc,或者 PC端取药系统  或者对外系统
            if (token == null || (token.getPlatform() != 2&&token.getPlatform() != 4)) {
            if (token == null || (token.getPlatform() != 2 && token.getPlatform() != 4)) {
                // 未登录
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes("UTF-8"));
                flag = false;
            } else {
                if (token.getTimeout().getTime() < new Date().getTime()) {
                    // 登录超时
                    response.getOutputStream().write(error(SystemConf.LOGIN_TIMEOUT, "登录超时,请重新登录").getBytes());
                    response.getOutputStream().write(error(SystemConf.LOGIN_TIMEOUT, "登录超时,请重新登录").getBytes("UTF-8"));
                    flag = false;
                } else if (!StringUtils.equals(tokenStr, token.getToken()) || !StringUtils.equals(uid, token.getUser()) || !StringUtils.equals(imei, token.getImei())) {
                    // 别处登录
                    response.getOutputStream().write(error(SystemConf.LOGIN_OTHER, "帐号在别处登录,请重新登录").getBytes());
                    response.getOutputStream().write(error(SystemConf.LOGIN_OTHER, "帐号在别处登录,请重新登录").getBytes("UTF-8"));
                    flag = false;
                } else {
                    // 一天只更新一次
@ -158,6 +166,8 @@ public class DoctorInterceptor extends BaseInterceptor {
        return flag;
    }
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        if (null == request.getAttribute("log-start")) {
@ -195,4 +205,15 @@ public class DoctorInterceptor extends BaseInterceptor {
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
    }
    public String getStatus() {
        return status;
    }
    @Value("${interceptor.doctor.status}")
    public void setStatus(String status) {
        DoctorInterceptor.status = status;
    }
}

+ 24 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/GateWayAOP.java

@ -21,7 +21,8 @@ import java.io.PrintWriter;
@Aspect
@Component
public class GateWayAOP {
    private  ThreadLocal entityThreadLocal=new ThreadLocal();
    private ThreadLocal entityThreadLocal = new ThreadLocal();
    //Controller层切点路径
    @Pointcut("execution(* com.yihu.wlyy.web..*.*(..))")
    public void controllerAspect() {
@ -40,10 +41,30 @@ public class GateWayAOP {
        try {
            obj = point.proceed();
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
        }
        request.setAttribute("returnObj",obj);
        request.setAttribute("returnObj", obj);
        return obj;
    }
}
enum Flag {
    close("0"),
    open("1");
    Flag(String value) {
        this.value = value;
    }
    private String value;
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
}

+ 12 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/GateWayInterceptor.java

@ -20,6 +20,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.web.context.HttpRequestResponseHolder;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -48,6 +49,7 @@ public class GateWayInterceptor implements HandlerInterceptor {
    private GcHttpLogDao httpLogDao;
    @Autowired
    private GcTokenDao gcTokenDaoDao;
    public static String status = "1";
    /**
@ -162,4 +164,14 @@ public class GateWayInterceptor implements HandlerInterceptor {
        gcHttpLog.setMessage(message);
        httpLogDao.save(gcHttpLog);
    }
    public String getStatus() {
        return status;
    }
    @Value("${interceptor.accesstoken.status}")
    public void setStatus(String status) {
        DoctorInterceptor.status = status;
    }
}

+ 15 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/PatientInterceptor.java

@ -9,6 +9,7 @@ import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.method.HandlerMethod;
@ -29,11 +30,14 @@ public class PatientInterceptor extends BaseInterceptor {
    private Logger logger = LoggerFactory.getLogger(PatientInterceptor.class);
    public static String status = "1";
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        boolean flag = true;
        try {
            request.setCharacterEncoding("UTF-8");
            response.setHeader("Content-type", "text/html;charset=UTF-8");
            request.setAttribute("log-start", new Date().getTime());
            if (request.getRequestURI().contains("/patient/hosptail/getHositalByTownCode") || request.getRequestURI().contains("/patient/feedback/saveAppeal")) {
                return true;
@ -43,7 +47,7 @@ public class PatientInterceptor extends BaseInterceptor {
            logger.debug("userAgent:" + json);
            if (json == null) {
                // 未登录
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes("UTF-8"));
                return false;
            }
            String tokenStr = json.has("token") ? json.getString("token") : "";
@ -73,12 +77,12 @@ public class PatientInterceptor extends BaseInterceptor {
            }
            if (token == null || StringUtils.isEmpty(tokenStr) || (token.getPlatform() != 1 && token.getPlatform() != 3)) {
                // 未登录
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes("UTF-8"));
                flag = false;
            } else {
                if (!StringUtils.equals(tokenStr, token.getToken()) || !StringUtils.equals(user, token.getUser()) || !StringUtils.equals(imei, token.getImei())) {
                    // 别处登录
                    response.getOutputStream().write(error(SystemConf.LOGIN_OTHER, "帐号在别处登录,请重新登录").getBytes());
                    response.getOutputStream().write(error(SystemConf.LOGIN_OTHER, "帐号在别处登录,请重新登录").getBytes("UTF-8"));
                    flag = false;
                } else {
                    // 一天只更新一次
@ -138,4 +142,12 @@ public class PatientInterceptor extends BaseInterceptor {
    }
    public  String getStatus() {
        return status;
    }
    @Value("${interceptor.patient.status}")
    public  void setStatus(String status) {
        DoctorInterceptor.status = status;
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/EvaluateService.java

@ -206,7 +206,7 @@ public class EvaluateService extends BaseService {
                    evaluateScore.setRemark(remark);
                }else{
                    //如果没有评价信息,根据分数评价内容
                    if(score.compareTo(new BigDecimal(71))==0&&score.compareTo(new BigDecimal(71))==1){
                    if(score.compareTo(new BigDecimal(71))==0||score.compareTo(new BigDecimal(71))==1){
                        evaluateScore.setRemark("好评");
                    }else if(score.compareTo(new BigDecimal(41))==-1){
                        evaluateScore.setRemark("差评");

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/gateway/GcTokenService.java

@ -22,7 +22,7 @@ public class GcTokenService {
    private GcTokenLogDao tokenLogDao;
    @Autowired
    private GcTokenDao tokenDao;
    @Value("${accesstoken.time}")
    @Value("${interceptor.accesstoken.time}")
    private Integer tokenTime;
    /**

+ 24 - 20
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/pc/prescription/PrescriptionExpressagePCService.java

@ -60,15 +60,15 @@ public class PrescriptionExpressagePCService extends BaseService {
    @Transactional
    public JSONObject getMedicine(String code,String userCode) throws Exception{
        JSONObject jsonObject = new JSONObject();
        Doctor doctor = doctorService.findDoctorByCode(userCode);
        String sql = "select a.type,a.prescription_code as prescriptionCode ,c.status,b.hospital_code as hospitalCode, b.hospital_doctor as hospitalDoctor,\n" +
                "b.code as orderCode, b.hospital_name as hospitalName,c.dispensary_type as dispensaryType,b.fetching_medicine_time as fetchingMedicineTime ,\n" +
                "b.expressage_name as expressageName, b.expressage_code as expressageCode,b.expressage_mobile as expressageMobile,d.idcard \n" +
                "b.expressage_code as expressageCode,c.patient \n" +
                "from wlyy_prescription_dispensary_code a \n" +
                "left join wlyy_prescription_expressage b on a.prescription_code = b.prescription_code \n" +
                "left join wlyy_prescription c on a.prescription_code = c.code \n" +
                "left join wlyy_doctor d on b.code=b.expressage_code \n"+
                "where a.is_use=0 and a.code=? and c.status>=50";
//                "left join wlyy_doctor d on b.code=b.expressage_code \n"+
                "where  a.code=? and c.status>=50 order by a.id desc ";
           List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql,code);
@ -79,23 +79,25 @@ public class PrescriptionExpressagePCService extends BaseService {
                switch (type){
                    //居民取药码
                    case 1:{
                        Patient patient = patientDao.findByCode(result.get("patient")+"");
                        if(status==50){
                            jsonObject.put("status",-5);//订单正在配药中,暂时无法出药
                            jsonObject.put("flag",-5);//订单正在配药中,暂时无法出药
                        }else if(status==60){
                            List<PrescriptionInfo> list = prescriptionInfoDao.findByPrescriptionCode(result.get("prescriptionCode").toString());
//                            jsonObject = new JSONObject(result);
//                            jsonObject = JSONObject.fromObject(result);
                            jsonObject.put("prescriptionInfoList",list);
                            jsonObject.put("flag",1);
                            jsonObject.put("prescriptionInfoList",list);
                            jsonObject.put("idcard",result.get("idcard"));
                            jsonObject.put("idcard",patient.getIdcard());
                            jsonObject.put("orderCode",result.get("orderCode"));
                            jsonObject.put("hospitalCode",result.get("hospitalCode"));
                            jsonObject.put("hospitalName",result.get("hospitalName"));
                            jsonObject.put("status",result.get("status"));
                            jsonObject.put("dispensaryType",result.get("dispensaryType"));
                            jsonObject.put("expressageName",result.get("expressageName"));
                            jsonObject.put("expressageMobile",result.get("expressageMobile"));
                            jsonObject.put("expressageName",patient.getName());
                            jsonObject.put("expressageMobile",patient.getMobile());
                            String date = result.get("fetchingMedicineTime")!=null?DateUtil.dateToStr((Date)result.get("fetchingMedicineTime"),"yyyy-MM-dd HH:mm:ss"):"";
                            jsonObject.put("fetchingMedicineTime",date);
                            jsonObject.put("hospitalDoctor",result.get("hospitalDoctor"));
@ -105,14 +107,14 @@ public class PrescriptionExpressagePCService extends BaseService {
//                            jsonObject = new JSONObject(result);
                            jsonObject.put("flag",-6);//”订单已取药,出药人:张三,出药时间:XXXX-XX-XX,无法重新出药
                            jsonObject.put("prescriptionInfoList",list);
                            jsonObject.put("idcard",result.get("idcard"));
                            jsonObject.put("idcard",patient.getIdcard());
                            jsonObject.put("orderCode",result.get("orderCode"));
                            jsonObject.put("hospitalCode",result.get("hospitalCode"));
                            jsonObject.put("hospitalName",result.get("hospitalName"));
                            jsonObject.put("status",result.get("status"));
                            jsonObject.put("dispensaryType",result.get("dispensaryType"));
                            jsonObject.put("expressageName",result.get("expressageName"));
                            jsonObject.put("expressageMobile",result.get("expressageMobile"));
                            jsonObject.put("expressageName",patient.getName());
                            jsonObject.put("expressageMobile",patient.getMobile());
                            String date = result.get("fetchingMedicineTime")!=null?DateUtil.dateToStr((Date)result.get("fetchingMedicineTime"),"yyyy-MM-dd HH:mm:ss"):"";
                            jsonObject.put("fetchingMedicineTime",date);
                            jsonObject.put("hospitalDoctor",result.get("hospitalDoctor"));
@ -123,7 +125,9 @@ public class PrescriptionExpressagePCService extends BaseService {
                    case 2:{
                        //判断出药机构是否与健管师所属机构一致,不一致弹窗提示:“出药机构与您所在机构不一致,无法出药,请重新确认”。一致则进入下一步。
                        if(doctor.getHospital().equals(result.get("hospitalCode")!=null?result.get("hospitalCode")+"":"")){
                        Doctor jgsDoctor = doctorService.findDoctorByCode(userCode);
                        Doctor doctor = doctorService.findDoctorByCode(result.get("expressageCode")+"");
                        if(jgsDoctor.getHospital().equals(result.get("hospitalCode")!=null?result.get("hospitalCode")+"":"")){
                            //20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 , 40配药成功/待配送  41配送失败 42分配健管师 45配送中   49配送到服务站  100配送到患者手中/已完成
                            if(status==50){
                                jsonObject.put("flag",-5);//订单正在配药中,暂时无法出药
@ -133,13 +137,13 @@ public class PrescriptionExpressagePCService extends BaseService {
                                List<PrescriptionInfo> list = prescriptionInfoDao.findByPrescriptionCode(result.get("prescriptionCode").toString());
                                jsonObject.put("prescriptionInfoList",list);
                                jsonObject.put("orderCode",result.get("orderCode"));
                                jsonObject.put("idcard",result.get("idcard"));
                                jsonObject.put("idcard",doctor.getIdcard());
                                jsonObject.put("hospitalCode",result.get("hospitalCode"));
                                jsonObject.put("hospitalName",result.get("hospitalName"));
                                jsonObject.put("status",result.get("status"));
                                jsonObject.put("dispensaryType",result.get("dispensaryType"));
                                jsonObject.put("expressageName",result.get("expressageName"));
                                jsonObject.put("expressageMobile",result.get("expressageMobile"));
                                jsonObject.put("expressageName",doctor.getName());
                                jsonObject.put("expressageMobile",doctor.getMobile());
                                String date = result.get("fetchingMedicineTime")!=null?DateUtil.dateToStr((Date)result.get("fetchingMedicineTime"),"yyyy-MM-dd HH:mm:ss"):"";
                                jsonObject.put("fetchingMedicineTime",date);
                                jsonObject.put("hospitalDoctor",result.get("hospitalDoctor"));
@ -149,13 +153,13 @@ public class PrescriptionExpressagePCService extends BaseService {
                                List<PrescriptionInfo> list = prescriptionInfoDao.findByPrescriptionCode(result.get("prescriptionCode").toString());
                                jsonObject.put("prescriptionInfoList",list);
                                jsonObject.put("orderCode",result.get("orderCode"));
                                jsonObject.put("idcard",result.get("idcard"));
                                jsonObject.put("idcard",doctor.getIdcard());
                                jsonObject.put("hospitalCode",result.get("hospitalCode"));
                                jsonObject.put("hospitalName",result.get("hospitalName"));
                                jsonObject.put("status",result.get("status"));
                                jsonObject.put("dispensaryType",result.get("dispensaryType"));
                                jsonObject.put("expressageName",result.get("expressageName"));
                                jsonObject.put("expressageMobile",result.get("expressageMobile"));
                                jsonObject.put("expressageName",doctor.getName());
                                jsonObject.put("expressageMobile",doctor.getMobile());
                                String date = result.get("fetchingMedicineTime")!=null?DateUtil.dateToStr((Date)result.get("fetchingMedicineTime"),"yyyy-MM-dd HH:mm:ss"):"";
                                jsonObject.put("fetchingMedicineTime",date);
                                jsonObject.put("hospitalDoctor",result.get("hospitalDoctor"));
@ -166,7 +170,7 @@ public class PrescriptionExpressagePCService extends BaseService {
                        break;
                    }
                    default:{
                        jsonObject.put("status",-3);
                        jsonObject.put("flag",-3);
                        PrescriptionLog prescriptionLog = new PrescriptionLog();
                        prescriptionLog.setCode(UUID.randomUUID().toString());
                        prescriptionLog.setPrescriptionCode(result.get("prescriptionCode").toString());
@ -182,7 +186,7 @@ public class PrescriptionExpressagePCService extends BaseService {
                }
            }else{
                jsonObject.put("status",-3);
                jsonObject.put("flag",-3);
                //保存验证二维码的日志
                PrescriptionLog prescriptionLog = new PrescriptionLog();
                prescriptionLog.setCode(UUID.randomUUID().toString());

+ 87 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/ManagerUtilController.java

@ -1,6 +1,9 @@
package com.yihu.wlyy.web.common.util;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.interceptors.DoctorInterceptor;
import com.yihu.wlyy.interceptors.GateWayInterceptor;
import com.yihu.wlyy.interceptors.PatientInterceptor;
import com.yihu.wlyy.repository.consult.ConsultTeamDoctorDao;
import com.yihu.wlyy.service.app.disease.PatientDiseaseService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
@ -263,4 +266,88 @@ public class ManagerUtilController extends BaseController {
        }
    }
    //---------------------------获取在线人数相关 end---------------------------------
    //----------------------------权限相关 start---------------------------------
    @RequestMapping(value = "/closeAll", method = RequestMethod.POST)
    @ApiOperation("关闭全部拦截")
    public String closeAll() {
        try {
            String close = "0";
            DoctorInterceptor.status = close;
            PatientInterceptor.status = close;
            GateWayInterceptor.status = close;
            return write(200, "关闭成功");
        } catch (Exception e) {
            return error(-1, "启动失败");
        }
    }
    @RequestMapping(value = "/openAll", method = RequestMethod.POST)
    @ApiOperation("开启全部拦截")
    public String openAll() {
        try {
            String open = "1";
            DoctorInterceptor.status = open;
            PatientInterceptor.status = open;
            GateWayInterceptor.status = open;
            return write(200, "关闭成功");
        } catch (Exception e) {
            return error(-1, "启动失败");
        }
    }
    @RequestMapping(value = "/closeByType", method = RequestMethod.POST)
    @ApiOperation("根据类型关闭拦截")
    public String closeByType(
            @ApiParam(name = "type", value = "1 患者端 2医生端 3对外", required = true) @RequestParam(value = "type", required = true) String type) {
        try {
            String close = "0";
            switch (type) {
                case "1": {
                    DoctorInterceptor.status = close;
                    break;
                }
                case "2": {
                    PatientInterceptor.status = close;
                    break;
                }
                case "3": {
                    GateWayInterceptor.status = close;
                    break;
                }
            }
            return write(200, "关闭成功");
        } catch (Exception e) {
            return error(-1, "启动失败");
        }
    }
    @RequestMapping(value = "/openByTYpe", method = RequestMethod.POST)
    @ApiOperation("根据类型开启拦截")
    public String openByTYpe(
            @ApiParam(name = "type", value = "1 患者端 2医生端 3对外", required = true) @RequestParam(value = "type", required = true) String type) {
        try {
            String open = "1";
            switch (type) {
                case "1": {
                    DoctorInterceptor.status = open;
                    break;
                }
                case "2": {
                    PatientInterceptor.status = open;
                    break;
                }
                case "3": {
                    GateWayInterceptor.status = open;
                    break;
                }
            }
            return write(200, "开启成功");
        } catch (Exception e) {
            return error(-1, "启动失败");
        }
    }
    //----------------------------权限相关 end---------------------------------
}

+ 23 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/controller/patient/GcPatientController.java

@ -2,6 +2,8 @@ package com.yihu.wlyy.web.gateway.controller.patient;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.web.gateway.vo.DoctorModel;
@ -27,6 +29,8 @@ import org.springframework.web.bind.annotation.*;
public class GcPatientController {
    @Autowired
    private PatientService patientService;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @RequestMapping(value = "/patient", method = RequestMethod.GET)
@ -36,8 +40,27 @@ public class GcPatientController {
    ) {
        Patient patient = patientService.findByCode(code);
        PatientModel patientModel = new PatientModel();
        SignFamily signFamily = signFamilyDao.findSignByPatient(patient.getCode());
        BeanUtils.copyProperties(patient, patientModel);
        if (signFamily != null) {
            patientModel.setIsSign(1);
        } else {
            patientModel.setIsSign(0);
        }
        return new ResultOneModel(patientModel);
    }
    @RequestMapping(value = "/patientHasSign", method = RequestMethod.GET)
    @ApiOperation("判断患者是否签约")
    public ResultOneModel<Integer> patientHasSign(
            @ApiParam(name = "code", value = "患者code", required = true) @RequestParam(value = "code", required = true) String code
    ) {
        Integer isSign = 0;
        SignFamily signFamily = signFamilyDao.findSignByPatient(code);
        if (signFamily != null) {
            isSign = 1;
        }
        return new ResultOneModel(isSign);
    }
}

+ 10 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/vo/PatientModel.java

@ -79,6 +79,8 @@ public class PatientModel {
    @ApiModelProperty(value = "绑定电子社保卡时间", required = false, access = "response")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date sicardTime;
    @ApiModelProperty(value = "是否签约(1是 0否)", required = false, access = "response")
    private Integer isSign;
    public String getCode() {
@ -256,4 +258,12 @@ public class PatientModel {
    public void setSicardTime(Date sicardTime) {
        this.sicardTime = sicardTime;
    }
    public Integer getIsSign() {
        return isSign;
    }
    public void setIsSign(Integer isSign) {
        this.isSign = isSign;
    }
}

+ 10 - 2
patient-co/patient-co-wlyy/src/main/resources/application.yml

@ -80,8 +80,16 @@ security:
    password: jkzlehr
accesstoken:
  time: 2 ##对外接的accesstoken生命周期 2小时
##拦截器开关
interceptor:
  doctor:
    status: 0 ###  1开启 0 关闭
  patient:
    status: 0 ###  1开启 0 关闭
  accesstoken:
    status: 0 ###  1开启 0 关闭
    time: 2 ##对外接的accesstoken生命周期 2小时
---
##测试的配置