Browse Source

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

trick9191 7 years ago
parent
commit
7660af0c5b
17 changed files with 407 additions and 221 deletions
  1. 5 5
      common/common-entity/src/main/java/com/yihu/mm/entity/patient/PatientExam.java
  2. 78 55
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/controller/medicine/PhysicalExaminationController.java
  3. 8 0
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/PhysicalExaminationService.java
  4. 1 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/common/account/CustomerController.java
  5. 1 1
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/LogService.java
  6. 7 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java
  7. 52 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PrescriptionExecuteSickSettleJob.java
  8. 3 2
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/SFExpressJob.java
  9. 3 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionPayDao.java
  10. 16 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java
  11. 99 27
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java
  12. 106 111
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/PatientInterceptor.java
  13. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  14. 3 7
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/TokenService.java
  15. 3 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SystemData.java
  16. 18 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/ManagerUtilController.java
  17. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java

+ 5 - 5
common/common-entity/src/main/java/com/yihu/mm/entity/patient/PatientExam.java

@ -14,19 +14,19 @@ import java.util.Date;
public class PatientExam extends IdEntity implements Serializable {
    @Column(name="patient")
    private String patient;
    private String patient;//居民code
    @Column(name="tp_id")
    private String tpId;
    private String tpId;//试卷编号
    @Column(name="tp_name")
    private String tpName;
    private String tpName;//试卷名称
    @Column(name="ct_id")
    private String ctId;
    private String ctId;//咨询编号
    @Column(name="is_complete")
    private Integer isComplete;
    private Integer isComplete;//是否完成(0:未完成   1已完成)
    @Column(name="sl_id")
    private String slId;//预约单号

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

@ -70,17 +70,19 @@ public class PhysicalExaminationController extends BaseController {
        if(isSignJM==3){
            String insertslip = physicalExaminationService.insertslip(patient);
            JSONObject jsonQuestion = new JSONObject(insertslip);
            jsonQuestion.put("isSignJM",isSignJM);
            JSONObject recordset = jsonQuestion.getJSONObject("recordset");
            String ct_id = recordset.get("ct_id").toString();
            PatientExam patientExam = new PatientExam();
            patientExam.setCtId(ct_id);
            patientExam.setPatient(patientCode);
            patientExam.setIsComplete(0);
            patientExam.setTpId(examCode);
            patientExam.setCreateTime(new Date());
            patientExamService.save(patientExam);
            if(physicalExaminationService.getSuccess(jsonQuestion)){
                jsonQuestion.put("isSignJM",isSignJM);
                JSONObject recordset = jsonQuestion.getJSONObject("recordset");
                String ct_id = recordset.get("ct_id").toString();
                PatientExam patientExam = new PatientExam();
                patientExam.setCtId(ct_id);
                patientExam.setPatient(patientCode);
                patientExam.setIsComplete(0);
                patientExam.setTpId(examCode);
                patientExam.setCreateTime(new Date());
                patientExamService.save(patientExam);
            }
            return jsonQuestion.toString();
        }else{
            return write(200,"未签约或者签约不在集美","isSignJM",isSignJM);
@ -99,33 +101,35 @@ public class PhysicalExaminationController extends BaseController {
        String question = physicalExaminationService.findQuestion(examCode, pb_id, ct_id);
        JSONObject jsonQuestion = new JSONObject(question);
        JSONObject recordset = jsonQuestion.getJSONObject("recordset");
        String _pb_id = recordset.get("pb_id").toString();//越人api问题,  我们数据库保存的居民答案的pb_id是这边返回下一题的pb_id
        //查找居民是否已经答过该试题
        MedicineAnswerLog medicineAnswerLog = medicineAnswerLogService.findAnswer(patientCode, examCode, _pb_id,ct_id);
        String answer="";
        if(medicineAnswerLog!=null){
            answer = medicineAnswerLog.getAnswer().replace("\"","\\\"");
        }else{
            medicineAnswerLog = new MedicineAnswerLog();
            medicineAnswerLog.setPatientCode(patientCode);
            medicineAnswerLog.setTpId(examCode);
            medicineAnswerLog.setPbId(_pb_id);
            medicineAnswerLog.setCtId(ct_id);
            medicineAnswerLog.setCreateTime(new Date());
        if(physicalExaminationService.getSuccess(jsonQuestion)){
            JSONObject recordset = jsonQuestion.getJSONObject("recordset");
            if(recordset.has("pb_id")){//返回空对象,则为可判断是最后一题
                String _pb_id = recordset.get("pb_id").toString();//越人api问题,  我们数据库保存的居民答案的pb_id是这边返回下一题的pb_id
                //查找居民是否已经答过该试题
                MedicineAnswerLog medicineAnswerLog = medicineAnswerLogService.findAnswer(patientCode, examCode, _pb_id,ct_id);
                String answer="";
                if(medicineAnswerLog!=null){
                    answer = medicineAnswerLog.getAnswer().replace("\"","\\\"");
                }else{
                    medicineAnswerLog = new MedicineAnswerLog();
                    medicineAnswerLog.setPatientCode(patientCode);
                    medicineAnswerLog.setTpId(examCode);
                    medicineAnswerLog.setPbId(_pb_id);
                    medicineAnswerLog.setCtId(ct_id);
                    medicineAnswerLog.setCreateTime(new Date());
                }
                //获取题目 ,选项, 题目类型 ,并重新保存    --->>防止题目选择不同的答案,下个问题也跟着不一样
                String tb_title =  recordset.getString("pb_title");   //题目
                String option = recordset.getString("pb_alternative");//备选答案
                String type = recordset.get("i_multiselect").toString();//单选多选
                medicineAnswerLog.setType(type);
                medicineAnswerLog.setQuestion(tb_title);
                medicineAnswerLog.setOpti(option);
                medicineAnswerLogService.save(medicineAnswerLog);
                jsonQuestion.put("answer",answer);
            }
        }
        //获取题目 ,选项, 题目类型 ,并重新保存    --->>防止题目选择不同的答案,下个问题也跟着不一样
        String tb_title =  recordset.getString("tb_title");   //题目
        String option = recordset.getString("pb_alternative");//备选答案
        String type = recordset.get("i_multiselect").toString();//单选多选
        medicineAnswerLog.setType(type);
        medicineAnswerLog.setQuestion(tb_title);
        medicineAnswerLog.setOpti(option);
        medicineAnswerLogService.save(medicineAnswerLog);
        jsonQuestion.put("answer",answer);
        return jsonQuestion.toString();
    }
@ -137,15 +141,38 @@ public class PhysicalExaminationController extends BaseController {
                                @ApiParam(name = "type", value = "试题类型(0单选 ,1多选)", required = true)@RequestParam(required = true, name = "type") String type,
                               @ApiParam(name = "dc_answer", value = "问题答案", required = true)@RequestParam(required = true, name = "dc_answer") String dc_answer,
                             @ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode){
        PatientExam patientExam = patientExamService.findByPatientAndTpId(patientCode, examCode,ct_id);
        String tpName = patientExam.getTpName();
        //提交答案
        String result = physicalExaminationService.handleExam(examCode, pb_id, dc_answer, ct_id);
        //将答案保存/更新到自己数据库
        MedicineAnswerLog answer = medicineAnswerLogService.findAnswer(patientCode, examCode, pb_id, ct_id);
        answer.setType(String.valueOf(type));
        answer.setAnswer(dc_answer);
        medicineAnswerLogService.save(answer);
        JSONObject resultJson = new JSONObject(result);
        //成功提交答案才做数据的保存等,否则直接返回
        if(physicalExaminationService.getSuccess(resultJson)){
            PatientExam patientExam = patientExamService.findByPatientAndTpId(patientCode, examCode,ct_id);
            if(patientExam==null){
                patientExam = new PatientExam();
                patientExam.setPatient(patientCode);
                patientExam.setTpId(examCode);
                patientExam.setCtId(ct_id);
                patientExam.setCreateTime(new Date());
            }
            //判断是否下一题...
            String question = physicalExaminationService.findQuestion(examCode, pb_id, ct_id);
            JSONObject jsonQuestion = new JSONObject(question);
            if(physicalExaminationService.getSuccess(jsonQuestion)){
                JSONObject recordset = jsonQuestion.getJSONObject("recordset");
                if(recordset.has("pb_id")) {//返回空对象,则为可判断是最后一题
                    patientExam.setIsComplete(0);
                }else{
                    patientExam.setIsComplete(1);
                }
            }
            patientExamService.save(patientExam);
            //将答案保存/更新到自己数据库
            MedicineAnswerLog answer = medicineAnswerLogService.findAnswer(patientCode, examCode, pb_id, ct_id);
            answer.setType(String.valueOf(type));
            answer.setAnswer(dc_answer);
            medicineAnswerLogService.save(answer);
        }
        return result;
    }
@ -156,19 +183,15 @@ public class PhysicalExaminationController extends BaseController {
                              @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);
        String at_id = null;
        String at_realname=null;
        JSONObject uploadResult = new JSONObject(uploadAttachment);
        String status = uploadResult.get("status").toString();
        if("200".equals(status)){
        if(physicalExaminationService.getSuccess(uploadResult)){
            JSONObject recordset = uploadResult.getJSONObject("recordset");
            at_id =  recordset.get("at_id").toString();
            at_realname = (String) recordset.get("at_realname");
        }else{
            return write(500,"提交失败","exception",uploadResult.get("status").toString());
            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);
            return result;
        }
        String result = physicalExaminationService.dillphoneimgdata(at_id, at_realname, type, ct_id);
        return result;
        return uploadAttachment;
    }
    @ApiOperation(value = "查看报告单")

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

@ -31,6 +31,14 @@ public class PhysicalExaminationService {
    @Autowired
    private ExamReportService examReportService;
    public boolean getSuccess(JSONObject result ){
        if("200".equals(result.get("status").toString())){
            return true;
        }
        return false;
    }
    //查找试卷
    public String findExames(String type, String examCode) {
        JSONObject params = new JSONObject();

+ 1 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/common/account/CustomerController.java

@ -47,7 +47,7 @@ public class CustomerController extends BaseController {
    @Autowired
    private WlyyCustomerLogService wlyyCustomerLogService;
    @RequestMapping(value = "/login",produces="application/json;charset=UTF-8")
    @RequestMapping(value = "/login",method = RequestMethod.POST,produces="application/json;charset=UTF-8")
    @ResponseBody
    public String login(@ApiParam(name = "userName", value = "账号", required = true)@RequestParam(required = true, name = "userName") String userName,
                               @ApiParam(name = "password", value = "密码", required = true)@RequestParam(required = true, name = "password") String password,

+ 1 - 1
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/LogService.java

@ -60,7 +60,7 @@ public class LogService {
    }
    /**
     * 保存http调用日志    0开放api  1基卫接口  2市民健康网接口   3易联众接口
     * 保存http调用日志    0开放api  1基卫接口  2市民健康网接口   3易联众接口  4长处方接口
     **/
    public void saveHttpLog(Boolean isSuccess,String url,String content,String method,String header,String params,String response,String error,String type)
    {

+ 7 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java

@ -662,6 +662,9 @@ public class PrescriptionService extends ZysoftBaseService{
        String response = postSecond("getDispUnSettleFeeInfoList","查询处方结算结果列表",params,null,header,false,2);
        //添加日志到wlyy_zy_push_log表
        addZyPushLog(response,"getDispUnSettleFeeInfoList","查询处方结算结果列表",null  ,"POST","","2","");
        return response;
    }
@ -731,6 +734,10 @@ public class PrescriptionService extends ZysoftBaseService{
        String response = postSecond("executeSickSettle","院内结算确认接口",null,json,header,false,2);
        //添加日志到wlyy_zy_push_log表
        addZyPushLog(response,"executeSickSettle","院内结算确认接口",null  ,"POST","","3","");
        return response;
    }

+ 52 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PrescriptionExecuteSickSettleJob.java

@ -0,0 +1,52 @@
package com.yihu.wlyy.job;
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
 * 遍历长处方支付成功但是院内结算失败的记录,重新执行院内结算
 * @author huangwenjie
 * @date 2017/8/17 15:08
 */
public class PrescriptionExecuteSickSettleJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(PrescriptionExecuteSickSettleJob.class);
    @Autowired
    private PrescriptionService prescriptionService;
    @Autowired
    private JwPrescriptionService jwPrescriptionService;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        logger.info("START=====开始执行长处方支付成功,院内结算失败,重新执行院内结算的JOB");
        try {
            //获取支付完成,院内结算失败的 处方CODE 集合
            List<String> prescriptionCodeList = prescriptionService.findCodesByPayStautsAndExecuteSickStatus();
            if(!prescriptionCodeList.isEmpty()){
                for (String code : prescriptionCodeList) {
                    try {
                        jwPrescriptionService.executeSickSettle(code);
                    }catch (Exception e){
                        logger.info("ERROR======重新执行院内结算的JOB,CODE:"+code+",message:" +e.getMessage());
                    }
                }
            }
        logger.info("END========执行长处方支付成功,院内结算失败,重新执行院内结算的JOB");
        }catch (Exception e){
            e.printStackTrace();
            logger.info("END===ERROE===执行长处方支付成功,院内结算失败,重新执行院内结算的JOB,message:"+e.getMessage());
        }
    }
}

+ 3 - 2
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/SFExpressJob.java

@ -20,19 +20,20 @@ import java.text.SimpleDateFormat;
import java.util.*;
/**
 *遍历顺丰快递下单失败的记录,重新下单
 *@author huangwenjie
 *@date 2017/8/12 14:11
 *遍历顺丰快递下单失败的记录,重新下单
 */
public class SFExpressJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(SFExpressJob.class);
    @Autowired
    private PrescriptionExpressageService prescriptionExpressageService;
    @Autowired
    private SFExpressService sfexpressService;
    private static final Logger logger = LoggerFactory.getLogger(SFExpressJob.class);
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {

+ 3 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionPayDao.java

@ -14,4 +14,7 @@ import java.util.List;
public interface PrescriptionPayDao extends PagingAndSortingRepository<PrescriptionPay, Long>, JpaSpecificationExecutor<PrescriptionPay> {
    @Query("from PrescriptionPay p where p.prescriptionCode=?1 ")
    PrescriptionPay findByPrescriptionPay(String prescriptionCode);
    @Query(value = "select p.prescription_code from wlyy_prescription_pay p LEFT JOIN  wlyy_prescription a on a.code = p.prescription_code where p.trade_status = 1 and a.jw_pay_status = 0")
    List<String> findCodesByPayStautsAndExecuteSickStatus();
}

+ 16 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java

@ -2,9 +2,13 @@ package com.yihu.wlyy.service.app.prescription;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.repository.prescription.PrescriptionPayDao;
import com.yihu.wlyy.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * Created by huangwenjie on 2017/8/12.
 */
@ -13,6 +17,9 @@ public class PrescriptionService extends BaseService {
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private PrescriptionPayDao prescriptionPayDao;
    /**
     *  获取处方信息
     * @param prescriptionCode 处方code
@ -22,4 +29,13 @@ public class PrescriptionService extends BaseService {
        return prescriptionDao.findByCode(prescriptionCode);
    }
    /**
     * 获取支付完成,院内结算失败的 处方CODE 集合
     *@author huangwenjie
     *@date 2017/8/17 19:27
     */
    public List<String> findCodesByPayStautsAndExecuteSickStatus() {
        return prescriptionPayDao.findCodesByPayStautsAndExecuteSickStatus();
    }
}

+ 99 - 27
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java

@ -1,14 +1,23 @@
package com.yihu.wlyy.service.third.jw;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.util.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * 基位长处方接口
@ -17,11 +26,16 @@ import java.util.List;
@Service
public class JwPrescriptionService {
    private static final Logger logger = LoggerFactory.getLogger(JwPrescriptionService.class);
    //基卫服务地址
    @Value("${sign.check_upload}")
    private String jwUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PrescriptionDao prescriptionDao;
    /**
     * 获取字典列表
@ -41,18 +55,14 @@ public class JwPrescriptionService {
    /**
     * 获取处方模板
     * @param deptCode 科室编码
     * @param staffCode 人员code
     * @param hospital 医院code
     * @param doctor 医生code
     * @return
     * @throws Exception
     */
    public String getRecipeTemplate(String deptCode,String staffCode, String hospital) throws Exception{
    public String getRecipeTemplate(String doctor) throws Exception{
        String url = jwUrl + "/third/prescription/getRecipeTemplate";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("deptCode", deptCode));
        params.add(new BasicNameValuePair("staffCode", staffCode));
        params.add(new BasicNameValuePair("hospital", hospital));
        params.add(new BasicNameValuePair("doctor", doctor));
        String response = httpClientUtil.post(url, params, "UTF-8");
@ -77,27 +87,57 @@ public class JwPrescriptionService {
        params.add(new BasicNameValuePair("applyTimeFrom", applyTimeFrom));
        params.add(new BasicNameValuePair("applyTimeEnd", applyTimeEnd));
        String response = httpClientUtil.post(url, params, "UTF-8");
//        String response = httpClientUtil.post(url, params, "UTF-8");
        String sql = "SELECT h.response from wlyy_http_log h WHERE h.id = 806287";
        List<Map<String ,Object>> list = jdbcTemplate.queryForList(sql);
        String response = list.get(0).get("response").toString();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("status",200);
        jsonObject.put("data",response);
        response = jsonObject.toString();
        return response;
    }
    /**
     * 处方开方接口
     * @param prescriptionCode 续方code
     * 获取单条历史处方
     * @param recipeNo
     * @param cardNo
     * @return
     * @throws Exception
     */
    public String saveRecipe(String prescriptionCode) throws Exception{
        String url = jwUrl + "/third/prescription/saveRecipe";
    public String getRecipe(String recipeNo,String cardNo){
        String url = jwUrl + "/third/prescription/getRecipe";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("prescriptionCode", prescriptionCode));
        params.add(new BasicNameValuePair("recipeNo", recipeNo));
        params.add(new BasicNameValuePair("cardNo", cardNo));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 处方开方接口
     * @param prescriptionCode 续方code
     * @return
     * @throws Exception
     */
    public String saveRecipe(String prescriptionCode){
        String response = null;
        try {
            String url = jwUrl + "/third/prescription/saveRecipe";
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("prescriptionCode", prescriptionCode));
            response = httpClientUtil.post(url, params, "UTF-8");
            return response;
        }catch (Exception e){
            logger.info("处方开方接口saveRecipe:"+response);
            throw e;
        }
    }
    /**
     * 待结算费用列表接口
     * @param cardNo
@ -116,33 +156,65 @@ public class JwPrescriptionService {
        return response;
    }
    public String executeSickSettle(String dictName) throws Exception{
    /**
     * 院内结算确认接口
     * @param prescriptionCode 处方CODE
     * @return
     * @throws Exception
     */
    public String executeSickSettle(String prescriptionCode) throws Exception{
        String url = jwUrl + "/third/prescription/executeSickSettle";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("dictName", dictName));
        params.add(new BasicNameValuePair("prescriptionCode", prescriptionCode));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 挂号作废处方接口
     * @param visitNo 挂号号
     * @param fadeDept 作废科室编码
     * @param fadeOperator 作废人员编码
     * @param prescriptionCode 续方号码
     * @return
     * @throws Exception
     */
    public String fadeRecipe(String visitNo,String fadeDept,String fadeOperator)throws Exception{
        String url = jwUrl + "/third/prescription/fadeRecipe";
    public String fadeRecipe(String prescriptionCode)throws Exception{
        Prescription prescription = prescriptionDao.findByCode(prescriptionCode);
        if(StringUtils.isNotBlank(prescription.getVisitNo())){
            String url = jwUrl + "/third/prescription/fadeRecipe";
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("visitNo", prescription.getVisitNo()));//挂号号
            params.add(new BasicNameValuePair("fadeDept", prescription.getJwDeptCode()));//作废科室编码
            params.add(new BasicNameValuePair("fadeOperator", prescription.getJwDoctorCode()));//作废人员编码
            String response = httpClientUtil.post(url, params, "UTF-8");
            if(StringUtils.isNotBlank(response)){
                JSONObject reobj =  JSON.parseObject(response);
                Integer status = reobj.getInteger("status");
                String errmsg = reobj.getString("msg");
                if(-1 == status){
                    throw new Exception("基卫接口(挂号作废)请求失败,"+errmsg);
                }
            }else{
                throw new Exception("基卫接口(挂号作废)请求失败,无数据返回!");
            }
            return response;
        }
        return "";
    }
    /**
     * ca认证接口
     * @param code 续方code
     * @return
     */
    public String affirmCARecipe(String code){
        String url = jwUrl + "/third/prescription/affirmCARecipe";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("visitNo", visitNo));//挂号号
        params.add(new BasicNameValuePair("fadeDept", fadeDept));//作废科室编码
        params.add(new BasicNameValuePair("fadeOperator", fadeOperator));//作废人员编码
        params.add(new BasicNameValuePair("code", code));//续方code
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
}

+ 106 - 111
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/PatientInterceptor.java

@ -21,126 +21,121 @@ import java.util.Date;
/**
 * 患者权限校验
 * @author George
 *
 * @author George
 */
@Component
public class PatientInterceptor extends BaseInterceptor {
	private Logger logger = LoggerFactory.getLogger(PatientInterceptor.class);
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		boolean flag = true;
		try {
			request.setCharacterEncoding("UTF-8");
			request.setAttribute("log-start", new Date().getTime());
			if(request.getRequestURI().contains("/patient/hosptail/getHositalByTownCode")||request.getRequestURI().contains("/patient/feedback/saveAppeal")){
				return true;
			}
			response.setCharacterEncoding("UTF-8");
			JSONObject json = getAgent(request);
			logger.debug("userAgent:"+json);
			if (json == null) {
				// 未登录
				response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
				return false;
			}
			String tokenStr = json.has("token") ? json.getString("token") : "";
			String user = json.has("uid") ? json.getString("uid") : "";
			String imei = json.has("imei") ? json.getString("imei") : "";
			String openid = json.has("openid") ? json.getString("openid") : "";
			int platform = json.has("platform") ? json.getInt("platform") : 1;
			logger.debug("tokenStr:"+tokenStr);
			logger.debug("uid:"+user);
			logger.debug("imei:"+imei);
			logger.debug("openid:"+openid);
			logger.debug("platform:"+platform);
			if (StringUtils.isEmpty(imei)) {
				imei = openid;
			}
    private Logger logger = LoggerFactory.getLogger(PatientInterceptor.class);
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        boolean flag = true;
        try {
            request.setCharacterEncoding("UTF-8");
            request.setAttribute("log-start", new Date().getTime());
            if (request.getRequestURI().contains("/patient/hosptail/getHositalByTownCode") || request.getRequestURI().contains("/patient/feedback/saveAppeal")) {
                return true;
            }
            response.setCharacterEncoding("UTF-8");
            JSONObject json = getAgent(request);
            logger.debug("userAgent:" + json);
            if (json == null) {
                // 未登录
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
                return false;
            }
            String tokenStr = json.has("token") ? json.getString("token") : "";
            String user = json.has("uid") ? json.getString("uid") : "";
            String imei = json.has("imei") ? json.getString("imei") : "";
            String openid = json.has("openid") ? json.getString("openid") : "";
            int platform = json.has("platform") ? json.getInt("platform") : 1;
            logger.debug("tokenStr:" + tokenStr);
            logger.debug("uid:" + user);
            logger.debug("imei:" + imei);
            logger.debug("openid:" + openid);
            logger.debug("platform:" + platform);
            if (StringUtils.isEmpty(imei)) {
                imei = openid;
            }
			Token token = null;
			if (platform == 1) {
				token = SystemData.patientTokens.get(user);
			} else if (platform == 3) {
				token = SystemData.wxPatientTokens.get(user);
			}
			if (token == null) {
				token = tokenDao.findByPatient(user, platform);
				// 加入缓存
				if (platform == 1) {
					SystemData.patientTokens.put(user, token);
				} else if (platform == 3) {
					SystemData.wxPatientTokens.put(user, token);
				}
			}
			if (token == null || StringUtils.isEmpty(tokenStr) || (token.getPlatform() != 1 && token.getPlatform() != 3)) {
				// 未登录
				response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
				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());
					flag = false;
				} else {
					// 一天只更新一次
					if (DateUtil.getDays(token.getCzrq(), DateUtil.getNowDateShort()) != 0) {
						// 今天未更新,则更新缓存
						token.setCzrq(new Date());
						// 更新内存
						if (platform == 1) {
							SystemData.patientTokens.put(user, token);
						} else if (platform == 3) {
							SystemData.wxPatientTokens.put(user, token);
						}
						// 更新数据库
						tokenDao.save(token);
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return flag;
	}
            Token token = null;
            if (platform == 1 || platform == 3) {
                token = SystemData.patientTokens.get(user);
            }
            if (token == null) {
                token = tokenDao.findByPatient(user, platform);
                // 加入缓存
                if (platform == 1 || platform == 3) {
                    SystemData.patientTokens.put(user, token);
                }
            }
            if (token == null || StringUtils.isEmpty(tokenStr) || (token.getPlatform() != 1 && token.getPlatform() != 3)) {
                // 未登录
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
                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());
                    flag = false;
                } else {
                    // 一天只更新一次
                    if (DateUtil.getDays(token.getCzrq(), DateUtil.getNowDateShort()) != 0) {
                        // 今天未更新,则更新缓存
                        token.setCzrq(new Date());
                        // 更新内存
                        if (platform == 1||platform == 3) {
                            SystemData.patientTokens.put(user, token);
                        }
                        // 更新数据库
                        tokenDao.save(token);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return flag;
    }
	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
		if(null==request.getAttribute("log-start")){
			return;
		}
		long start = (long) request.getAttribute("log-start");
		long end = new Date().getTime();
		Class cls = ((HandlerMethod) handler).getBeanType();
		RequestMapping clsRm = (RequestMapping) cls.getAnnotation(RequestMapping.class);
		Method method = ((HandlerMethod) handler).getMethod();
		RequestMapping mthRm = method.getAnnotation(RequestMapping.class);
		String url = "";
		String urlCls = "";
		String urlMth = "";
		if (clsRm.value() != null && clsRm.value().length > 0) {
			urlCls = clsRm.value()[0];
		}
		if (mthRm.value() != null && mthRm.value().length > 0) {
			urlMth = mthRm.value()[0];
		}
		if (StringUtils.isNotEmpty(urlCls)) {
			url += urlCls.startsWith("/") ? urlCls : ("/" + urlCls);
		}
		if (StringUtils.isNotEmpty(urlMth)) {
			url += urlMth.startsWith("/") ? urlMth : ("/" + urlMth);
		}
		url = url.replace("\\", "/").replace("//", "/");
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        if (null == request.getAttribute("log-start")) {
            return;
        }
        long start = (long) request.getAttribute("log-start");
        long end = new Date().getTime();
        Class cls = ((HandlerMethod) handler).getBeanType();
        RequestMapping clsRm = (RequestMapping) cls.getAnnotation(RequestMapping.class);
        Method method = ((HandlerMethod) handler).getMethod();
        RequestMapping mthRm = method.getAnnotation(RequestMapping.class);
        String url = "";
        String urlCls = "";
        String urlMth = "";
        if (clsRm.value() != null && clsRm.value().length > 0) {
            urlCls = clsRm.value()[0];
        }
        if (mthRm.value() != null && mthRm.value().length > 0) {
            urlMth = mthRm.value()[0];
        }
        if (StringUtils.isNotEmpty(urlCls)) {
            url += urlCls.startsWith("/") ? urlCls : ("/" + urlCls);
        }
        if (StringUtils.isNotEmpty(urlMth)) {
            url += urlMth.startsWith("/") ? urlMth : ("/" + urlMth);
        }
        url = url.replace("\\", "/").replace("//", "/");
		JSONObject json = getAgent(request);
		String uid = json.has("uid") ? json.getString("uid") : "";
		InterfaceCallLogs.info(end - start, url, uid, new JSONObject(request.getParameterMap()).toString());
	}
        JSONObject json = getAgent(request);
        String uid = json.has("uid") ? json.getString("uid") : "";
        InterfaceCallLogs.info(end - start, url, uid, new JSONObject(request.getParameterMap()).toString());
    }
	@Override
	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
	}
    }
}

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java

@ -127,7 +127,7 @@ public class PatientService extends TokenService {
                Patient p = patientDao.findByCode(token.getUser());
                if (p == null || i <= last) {
                    tokenDao.delete(token);
                    SystemData.wxPatientTokens.remove(token.getUser());
                    SystemData.patientTokens.remove(token.getUser());
                    continue;
                }
//                p.setOpenid("");
@ -135,7 +135,7 @@ public class PatientService extends TokenService {
                signFamilyDao.updateOpenidByPatient("", p.getCode());
                patientDao.save(p);
                tokenDao.delete(token);
                SystemData.wxPatientTokens.remove(p.getCode());
                SystemData.patientTokens.remove(p.getCode());
                break;
            }
        }

+ 3 - 7
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/TokenService.java

@ -56,12 +56,10 @@ public class TokenService extends BaseService {
			throw new Exception("Token生成失败");
		}
		// 更新token缓存
		if (platform == 1) {
		if (platform == 1||platform == 3) {
			SystemData.patientTokens.put(user, token);
		} else if (platform == 2) {
			SystemData.doctorTokens.put(user, token);
		} else if (platform == 3) {
			SystemData.wxPatientTokens.put(user, token);
		}else if(platform == 4){
			SystemData.doctorPCTokens.put(user,token);
		}
@ -90,7 +88,7 @@ public class TokenService extends BaseService {
			throw new Exception("Token生成失败");
		}
		// 更新token缓存
		SystemData.wxPatientTokens.put(user, token);
		SystemData.patientTokens.put(user, token);
		return token;
	}
@ -104,15 +102,13 @@ public class TokenService extends BaseService {
		// 删除老的token
		tokenDao.deleteByUser(uid);
		// 更新token缓存
		if (platform == 1) {
		if (platform == 1||platform == 3) {
			SystemData.patientTokens.remove(uid);
			//删除用户的openId
			//Patient patient=patientDao.findByCode(uid);
			//patient.setOpenid("");
		} else if (platform == 2) {
			SystemData.doctorTokens.remove(uid);
		} else if (platform == 3) {
			SystemData.wxPatientTokens.remove(uid);
		}
	}

+ 3 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SystemData.java

@ -8,11 +8,9 @@ import java.util.Map;
public class SystemData {
	// 医生app验证信息
	public static Map<String, Token> doctorTokens = new HashMap<String, Token>();
	public static Map<String, Token> doctorTokens = new HashMap<String, Token>();  // 2
	// 医生pc端验证信息
	public static Map<String, Token> doctorPCTokens = new HashMap<String, Token>();
	public static Map<String, Token> doctorPCTokens = new HashMap<String, Token>(); // 4
	// 患者验证信息
	public static Map<String, Token> patientTokens = new HashMap<String, Token>();
	// 患者公众号验证信息
	public static Map<String, Token> wxPatientTokens = new HashMap<String, Token>();
	public static Map<String, Token> patientTokens = new HashMap<String, Token>(); //1 3
}

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

@ -1,5 +1,6 @@
package com.yihu.wlyy.web.common.util;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.repository.consult.ConsultTeamDoctorDao;
import com.yihu.wlyy.service.app.disease.PatientDiseaseService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
@ -7,8 +8,10 @@ import com.yihu.wlyy.service.app.statistics.StatisticsService;
import com.yihu.wlyy.service.common.util.ManageUtilService;
import com.yihu.wlyy.service.common.util.SignTeamAndGroupRunnable;
import com.yihu.wlyy.util.SpringUtil;
import com.yihu.wlyy.util.SystemData;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
@ -245,7 +248,19 @@ public class ManagerUtilController extends BaseController {
//    }
    //---------------------------微信标签相关 start---------------------------------
    //---------------------------微信标签相关 end---------------------------------
    //---------------------------获取在线人数相关 start---------------------------------
    @RequestMapping(value = "/online_num", method = RequestMethod.GET)
    @ApiOperation("获取在线人数")
    public String online_num() {
        try {
            JSONObject jo = new JSONObject();
            jo.put("doctor_online", SystemData.doctorTokens.size());
            jo.put("pc_online", SystemData.doctorPCTokens.size());
            jo.put("patient_online", SystemData.patientTokens.size());
            return write(200, "启动成功");
        } catch (Exception e) {
            return error(-1, "启动失败");
        }
    }
    //---------------------------获取在线人数相关 end---------------------------------
}

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java

@ -382,7 +382,7 @@ public class PatientController extends WeixinBaseController {
            } else {
                //patient.setOpenid("");
                //patientInfoService.updateUser(patient);
                Token token = SystemData.wxPatientTokens.get(getUID());
                Token token = SystemData.patientTokens.get(getUID());
                if (token == null) {
                    token = tokenDao.findByPatient(getUID(), 3);
                }
@ -393,7 +393,7 @@ public class PatientController extends WeixinBaseController {
                token.setDel("0");
                tokenDao.save(token);
                SystemData.wxPatientTokens.remove(getUID());
                SystemData.patientTokens.remove(getUID());
                //清空患者的微信标签
                weiXinTagUtil.deleteTagWithOpenid(patient.getOpenid(),patient.getWxtagid());
                patient.setIsWxtag(Patient.isWchatTage.no.getValue());