Procházet zdrojové kódy

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

yeshijie před 7 roky
rodič
revize
09698f0fea
32 změnil soubory, kde provedl 867 přidání a 636 odebrání
  1. 39 10
      common/common-entity/src/main/java/com/yihu/mm/entity/questionnaire/MedicineAnswerLog.java
  2. 75 68
      common/common-entity/src/main/java/com/yihu/wlyy/entity/gateway/GcToken.java
  3. 7 6
      common/common-entity/src/main/java/com/yihu/wlyy/entity/gateway/GcTokenLog.java
  4. 5 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/Prescription.java
  5. 5 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionLog.java
  6. 23 16
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/controller/medicine/PhysicalExaminationController.java
  7. 3 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/Doctor.java
  8. 8 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/Patient.java
  9. 5 1
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/user/user_list_js.jsp
  10. 20 0
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/user/user_modify.jsp
  11. 31 8
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/user/user_modify_js.jsp
  12. 2 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/MvcConfig.java
  13. 19 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/SwaggerConfig.java
  14. 2 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java
  15. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/GateWayInterceptor.java
  16. 0 141
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/UserInterceptor.java
  17. 7 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/TokenService.java
  18. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/gateway/GcTokenService.java
  19. 0 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SystemData.java
  20. 83 67
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java
  21. 219 219
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/PCLoginController.java
  22. 39 40
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/device/DeviceController.java
  23. 2 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionLogController.java
  24. 112 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/controller/GcTokenController.java
  25. 28 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/controller/GcUserController.java
  26. 21 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/vo/DoctorLoginModel.java
  27. 5 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/vo/GcTokenModel.java
  28. 73 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/vo/LoginModel.java
  29. 13 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/vo/base/BaseResultModel.java
  30. 14 14
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/vo/base/ResultBatchModel.java
  31. 3 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/vo/base/ResultOneModel.java
  32. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionLogController.java

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

@ -9,6 +9,8 @@ import java.util.Date;
/**
 * Created by Administrator on 2017/8/9.
 * 越人api文档都是给string类型....但是真正返回的是number....注意了..
 * 可能有很多字段,越人接口有返回,但是对单个接口不容易取值,暂时没有存储
 */
@Entity
@Table(name = "wlyy_medicine_anwser_log")
@ -17,11 +19,14 @@ public class MedicineAnswerLog extends IdEntity {
    private String patientCode; //客户code
    private String tpId;    //试卷编号
    private String tpName; //试卷名称
    private Date createTime;    //创建时间
    private String pbType;  //问卷类型
    private String answer;    //居民答案
    private String pbId;//试题编号
    private Date createTime;    //创建时间
    private String problems;    //问题的集合
    private String ctId;//咨询编号
    private String question;//问题描述
    private String opti;//问题选项
    private String type;//选项
    public String getPatientCode() {
        return patientCode;
@ -56,14 +61,6 @@ public class MedicineAnswerLog extends IdEntity {
        this.createTime = createTime;
    }
    public String getProblems() {
        return problems;
    }
    public void setProblems(String problems) {
        this.problems = problems;
    }
    public String getPbType() {
        return pbType;
    }
@ -87,4 +84,36 @@ public class MedicineAnswerLog extends IdEntity {
    public void setCtId(String ctId) {
        this.ctId = ctId;
    }
    public String getAnswer() {
        return answer;
    }
    public void setAnswer(String answer) {
        this.answer = answer;
    }
    public String getQuestion() {
        return question;
    }
    public void setQuestion(String question) {
        this.question = question;
    }
    public String getOpti() {
        return opti;
    }
    public void setOpti(String opti) {
        this.opti = opti;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
}

+ 75 - 68
common/common-entity/src/main/java/com/yihu/wlyy/entity/gateway/GcToken.java

@ -5,7 +5,9 @@ import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
@ -17,73 +19,78 @@ import java.util.Date;
@Table(name = "gc_token")
public class GcToken extends IdEntity implements java.io.Serializable {
	// Fields
	private String appid;
	private String token;
	private Date createTime;
	private Date outTime;
	private Integer del;
	// Constructors
	/** default constructor */
	public GcToken() {
	}
	/** full constructor */
	public GcToken(String appid, String token, Date createTime,
			Date outTime, Integer del) {
		this.appid = appid;
		this.token = token;
		this.createTime = createTime;
		this.outTime = outTime;
		this.del = del;
	}
	@Column(name = "appid", length = 200)
	public String getAppid() {
		return this.appid;
	}
	public void setAppid(String appid) {
		this.appid = appid;
	}
	@Column(name = "token")
	public String getToken() {
		return this.token;
	}
	public void setToken(String token) {
		this.token = token;
	}
	@Column(name = "create_time", length = 0)
	public Date getCreateTime() {
		return this.createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	@Column(name = "out_time", length = 0)
	public Date getOutTime() {
		return this.outTime;
	}
	public void setOutTime(Date outTime) {
		this.outTime = outTime;
	}
	@Column(name = "del")
	public Integer getDel() {
		return this.del;
	}
	public void setDel(Integer del) {
		this.del = del;
	}
    // Fields
    private String appid;
    private String accesstoken;
    private Date createTime;
    private Date outTime;
    private Integer del;
    // Constructors
    /**
     * default constructor
     */
    public GcToken() {
    }
    /**
     * full constructor
     */
    public GcToken(String appid, String accesstoken, Date createTime,
                   Date outTime, Integer del) {
        this.appid = appid;
        this.accesstoken = accesstoken;
        this.createTime = createTime;
        this.outTime = outTime;
        this.del = del;
    }
    @Column(name = "appid", length = 200)
    public String getAppid() {
        return this.appid;
    }
    public void setAppid(String appid) {
        this.appid = appid;
    }
    @Column(name = "accesstoken")
    public String getAccesstoken() {
        return accesstoken;
    }
    public void setAccesstoken(String accesstoken) {
        this.accesstoken = accesstoken;
    }
    @Column(name = "create_time", length = 0)
    public Date getCreateTime() {
        return this.createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "out_time", length = 0)
    public Date getOutTime() {
        return this.outTime;
    }
    public void setOutTime(Date outTime) {
        this.outTime = outTime;
    }
    @Column(name = "del")
    public Integer getDel() {
        return this.del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 7 - 6
common/common-entity/src/main/java/com/yihu/wlyy/entity/gateway/GcTokenLog.java

@ -24,7 +24,7 @@ public class GcTokenLog extends IdEntity implements java.io.Serializable {
    private String ip;
    private String appIp;
    private String token;
    private String accesstoken;
    private Integer flag; //获取1 成功 0失败
    private String message;
    private Date createTime;
@ -67,13 +67,14 @@ public class GcTokenLog extends IdEntity implements java.io.Serializable {
        this.appIp = appIp;
    }
    @Column(name = "token")
    public String getToken() {
        return token;
    @Column(name = "accesstoken")
    public String getAccesstoken() {
        return accesstoken;
    }
    public void setToken(String token) {
        this.token = token;
    public void setAccesstoken(String accesstoken) {
        this.accesstoken = accesstoken;
    }

+ 5 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/Prescription.java

@ -37,7 +37,11 @@ public class Prescription extends IdEntity {
    private String patientName;             //患者名称
    private String ssc;//社保卡号
    private Integer type;                    //1 处方 2 续方
    private Integer status;                  //状态 (-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中 3.调整完成 4.调整失败 10 审核通过/开方中  , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 , 40配药成功/待配送  41配送失败  42配送中   43配送到服务站  100配送到患者手中/已完成)
    private Integer status;                  //(-3 支付过期 -2 患者自己取消 )续方取消,-1 审核不通过 ,
                                                // (0 待审核, 2调整中,3调整成功, 4调整失败 ,10 医生审核(CA)通过)审核中,
                                                // 20药师审核中,21.药师审核失败,30 开方中/药师审核成功,31.开方失败/预结算失败,
                                                // (40开方完成/待支付 ,41 支付失败 )待支付,  50 支付成功/待配药,(60配药成功/待配送)等待领药,
                                                // (61配送失败62分配健管师 65配送中,69配送到服务站)配送中,(100配送到患者手中/已完成)已完成',
    private String doctor;                   //开处方的医生code 关联 wlyy_doctor
    private String doctorName;               //医生名称
    private Long adminTeamId;             //患者签约的行政团队

+ 5 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionLog.java

@ -124,7 +124,11 @@ public class PrescriptionLog extends IdEntity {
    private String code;                    //业务流程
    private String prescriptionCode;      //处方code 关联表wlyy_prescription code
    private Date createTime;               //处方创建时间
    private Integer status;                 //状态 (-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中 10 审核通过/开方中  , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 , 40配药成功/待配送  41配送失败 42分配健管师 45配送中   49配送到服务站  100配送到患者手中/已完成)
    private Integer status;                 //状态 (-3 支付过期 -2 患者自己取消 )续方取消,-1 审核不通过 ,
                                               // (0 待审核, 2调整中,3调整成功, 4调整失败 ,10 医生审核(CA)通过)审核中,
                                            // 20药师审核中,21.药师审核失败,30 开方中/药师审核成功,31.开方失败/预结算失败,
                                            // (40开方完成/待支付 ,41 支付失败 )待支付,  50 支付成功/待配药,(60配药成功/待配送)等待领药,
                                            // (61配送失败62分配健管师 65配送中,69配送到服务站)配送中,(100配送到患者手中/已完成)已完成',
    private Integer type;                   //类型: 1智业对接 2易联众对接  3创建处方 4 审核  5付款 6 配送 7完成
    private String userCode;                  //医生或者患者code

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

@ -103,12 +103,28 @@ public class PhysicalExaminationController extends BaseController {
        String _pb_id = recordset.get("pb_id").toString();//越人api问题,  我们数据库保存的居民答案的pb_id是这边返回下一题的pb_id
        //查找居民是否已经答过该试题
        MedicineAnswerLog answer = medicineAnswerLogService.findAnswer(patientCode, examCode, _pb_id,ct_id);
        String answerStr="";
        if(answer!=null){
            answerStr = answer.getProblems().replace("\"","\\\"");
        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());
        }
        jsonQuestion.put("answer",answerStr);
        //获取题目 ,选项, 题目类型 ,并重新保存    --->>防止题目选择不同的答案,下个问题也跟着不一样
        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();
    }
@ -127,17 +143,8 @@ public class PhysicalExaminationController extends BaseController {
        //将答案保存/更新到自己数据库
        MedicineAnswerLog answer = medicineAnswerLogService.findAnswer(patientCode, examCode, pb_id, ct_id);
        if(answer==null){//新增
            answer = new MedicineAnswerLog();
            answer.setCreateTime(new Date());
            answer.setPatientCode(patientCode);
            answer.setPbId(pb_id);
            answer.setTpId(examCode);
            answer.setTpName(tpName);
            answer.setCtId(ct_id);
        }
        answer.setPbType(String.valueOf(type));
        answer.setProblems(dc_answer);
        answer.setType(String.valueOf(type));
        answer.setAnswer(dc_answer);
        medicineAnswerLogService.save(answer);
        return result;
    }

+ 3 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/Doctor.java

@ -362,6 +362,9 @@ public class Doctor extends IdEntity {
    @Transient
    public String getLevelName() {
    	if(null==level){
			return "";
		}
		// 类型:1专科医生,2全科医生,3健康管理师
		if(1==level){
			levelName = "专科医生";

+ 8 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/Patient.java

@ -327,6 +327,10 @@ public class Patient extends IdEntity implements Serializable {
    @Transient
	public String getDiseaseName() {//0健康,1高血压,2糖尿病,3高血压+糖尿病
		if(disease==null){
			this.diseaseName = "";
			return diseaseName;
		}
		if(0==disease) {
			this.diseaseName = "健康";
		}else if(1==disease) {
@ -347,6 +351,10 @@ public class Patient extends IdEntity implements Serializable {
	@Transient
	public String getDiseaseConditionName() {
		if(null==diseaseCondition){
			this.diseaseConditionName = "";
			return diseaseConditionName;
		}
		if(0==diseaseCondition) {
			this.diseaseConditionName = "绿标";
		}else if(1==diseaseCondition) {

+ 5 - 1
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/user/user_list_js.jsp

@ -75,7 +75,11 @@
										return "管理员";
									} else if (Util.isStrEquals(row.type, "2")) {
										return "医生";
									}
									}else if (Util.isStrEquals(row.type, "3")) {
                                        return "客服管理员";
                                    }else if (Util.isStrEquals(row.type, "4")) {
                                        return "普通客服";
                                    }
									return "其他";
								}
							},

+ 20 - 0
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/user/user_modify.jsp

@ -40,6 +40,26 @@
			<input type="text"  id="inp_type" class="required useTitle f-w240 validate-special-char" required-title="用户类型不能为空"  data-attr-scan="type"/>
		</div>
	</div>
	<div id="customer" style="display: none">
		<div class="m-form-group">
			<label class="label_title" style="width:120px">工号</label>
			<div class="l-text-wrapper m-form-control essential">
				<input type="text"  id="inp_jobNo" class="required useTitle f-w240 validate-special-char" required-title="工号不能为空"  data-attr-scan="jobNo"/>
			</div>
		</div>
		<div class="m-form-group">
			<label class="label_title" style="width:120px">座席</label>
			<div class="l-text-wrapper m-form-control essential">
				<input type="text"  id="inp_seat" class="required useTitle f-w240 validate-special-char" required-title="座席不能为空"  data-attr-scan="seat"/>
			</div>
		</div>
		<div class="m-form-group">
			<label class="label_title" style="width:120px">号码</label>
			<div class="l-text-wrapper m-form-control essential">
				<input type="text"  id="inp_phone" class="required useTitle f-w240 validate-special-char" required-title="号码不能为空"  data-attr-scan="phone"/>
			</div>
		</div>
	</div>
	<%--<div class="m-form-group">--%>
		<%--<label class="label_title" style="width:120px">所属角色组</label>--%>
		<%--<div class="l-text-wrapper m-form-control">--%>

+ 31 - 8
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/user/user_modify_js.jsp

@ -23,6 +23,9 @@
				$name: $('#inp_name'),
				$mobile: $('#inp_mobile'),
				$type: $("#inp_type"),
                $jobNo:$("#inp_jobNo"),
                $seat:$("#inp_seat"),
                $phone:$("#inp_phone"),
				//$roles:$("#inp_roles"),
				$organization: $("#inp_organizationId"),
				init: function () {
@ -35,15 +38,21 @@
						data: [
							{text: '管理员', typeId: '1'},
							{text: '医生', typeId: '2'},
                            {text: '客服管理员', typeId: '3'},
                            {text: '普通客服', typeId: '4'},
							{text: '其他', typeId: '0'}
						],
						initIsTriggerEvent: false,
						valueField: 'typeId',
					});
                    this.$jobNo.ligerTextBox({width: 240});
                    this.$seat.ligerTextBox({width: 240});
                    this.$phone.ligerTextBox({width: 240});
				},
				initForm: function () {
					_this = this;
                    this.bindEvents();
					//修改、查看
					if (isNoEmpty(id) && id != 0) {
						$.ajax({
@ -65,6 +74,9 @@
										code: data.code,
										name: data.name,
										mobile: data.mobile,
                                        jobNo:data.jobNo,
                                        seat:data.seat,
                                        phone:data.phone
									});
									_this.typeBox.selectValue(data.type);
								} else {
@ -89,7 +101,6 @@
						$("#btn_save_close").css("display", "block");
					}
					this.$form.show();
					this.bindEvents();
				},
				//绑定事件
@ -153,13 +164,25 @@
					var self = this;
					$("#btn_save").click(function () {
						var values = self.$form.Fields.getValues();
						if (!validator.validate()) {
							return;
						}
						values.type = self.typeBox.getValue();
						update(values);
					});
                        var values = self.$form.Fields.getValues();
                        if (!validator.validate()) {
                            return;
                        }
                        values.type = self.typeBox.getValue();
                        update(values);
                    });
                    $("#inp_type").change(function () {
                        var val = self.typeBox.getValue();
                        if(val==3||val==4){
                            $("#customer").show();
                        }else{
                            $("#customer").hide();
                        }
                        debugger
                    });
					function update(values) {
						var dataModel = $.DataModel.init();
						var url = "update";

+ 2 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/MvcConfig.java

@ -3,7 +3,6 @@ package com.yihu.wlyy.config;
import com.yihu.wlyy.interceptors.DoctorInterceptor;
import com.yihu.wlyy.interceptors.GateWayInterceptor;
import com.yihu.wlyy.interceptors.PatientInterceptor;
import com.yihu.wlyy.interceptors.UserInterceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -25,8 +24,6 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
    @Autowired
    private PatientInterceptor patientInterceptor;
    @Autowired
    private UserInterceptor userInterceptor;
    @Autowired
    private GateWayInterceptor gateWayInterceptor;
    @Override
@ -34,10 +31,9 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
        // 多个拦截器组成一个拦截器链
        // addPathPatterns 用于添加拦截规则
        // excludePathPatterns 用户排除拦截
        registry.addInterceptor(doctorInterceptor).addPathPatterns("/doctor/**", "/statistics/province/**", "/statistics/**");
        registry.addInterceptor(patientInterceptor).addPathPatterns("/patient/**");
        registry.addInterceptor(userInterceptor).addPathPatterns("/user/**");
        registry.addInterceptor(gateWayInterceptor).addPathPatterns("/wlyygc/**");
        registry.addInterceptor(doctorInterceptor).addPathPatterns("/doctor/**", "/statistics/province/**", "/statistics/**", "/wlyygc/**");
        registry.addInterceptor(patientInterceptor).addPathPatterns("/patient/**");
        super.addInterceptors(registry);
        logger.info("init doctorInterceptor,patientInterceptor");

+ 19 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/SwaggerConfig.java

@ -27,10 +27,12 @@ public class SwaggerConfig {
    private static final String Other_API = "other";
    private static final String GateWay_API = "gateway";
     final String userAgent="{\"id\":用户id,\"uid\":\"用户code\",\"openid\":\"openid\",\"token\":\"token表\",\"lastUid\":\"\",\"platform\":\"1患者APP,2医生APP,3患者微信公众号\"}";
    final String userAgentJson="{\"id\":int,\"uid\":string,\"openid\":string,\"token\":string,\"lastUid\":string,\"platform\":int}";
    final String userAgent = "{\"id\":用户id,\"uid\":\"用户code\",\"openid\":\"openid\",\"token\":\"token表\",\"lastUid\":\"\",\"platform\":\"1患者APP,2医生APP,3患者微信公众号\"}";
    final String userAgentJson = "{\"id\":int,\"uid\":string,\"openid\":string,\"token\":string,\"lastUid\":string,\"platform\":int}";
    @Bean
    public Docket gatewayAPI() {
        List<Parameter> pars = addToken();
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName(GateWay_API)
                .genericModelSubstitutes(DeferredResult.class)
@ -38,8 +40,12 @@ public class SwaggerConfig {
                .forCodeGeneration(true)
                .pathMapping("/")
                .select()
                .paths(or(regex("/wlyygc/.*")))
                .paths(or(
                        regex("/wlyygc/.*"),
                        regex("/gc/.*")
                ))
                .build()
                .globalOperationParameters(pars)
                .apiInfo(gatewayApiInfo());
    }
@ -55,6 +61,16 @@ public class SwaggerConfig {
        return apiInfo;
    }
    private List<Parameter> addToken() {
        ParameterBuilder tokenPar = new ParameterBuilder();
        List<Parameter> pars = new ArrayList<Parameter>();
        tokenPar.name("accesstoken").description("accesstoken").modelRef(new ModelRef("string")).parameterType("header").required(false).defaultValue("").build();
        pars.add(tokenPar.build());
        return pars;
    }
    @Bean
    public Docket publicAPI() {
        List<Parameter> pars = addUseragent();

+ 2 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java

@ -115,8 +115,6 @@ public class DoctorInterceptor extends BaseInterceptor {
            Map<String, Token> tempMap = null;
            if (platform == 2) {
                tempMap = SystemData.doctorTokens;
            }else if (platform == 5) {
                tempMap = SystemData.prescriptionPCTokens;
            }else {
                tempMap = SystemData.doctorPCTokens;
            }
@ -128,8 +126,8 @@ public class DoctorInterceptor extends BaseInterceptor {
                    tempMap.put(uid, token);
                }
            }
            //1、患者端,2、医生端app,3、微信公众号wechat,4、医生端pc,5、PC端取药系统
            if (token == null || (token.getPlatform() != 2&&token.getPlatform() != 4&&token.getPlatform() != 5)) {
            //1、患者端,2、医生端app,3、微信公众号wechat,4、医生端pc,或者 PC端取药系统  或者对外系统
            if (token == null || (token.getPlatform() != 2&&token.getPlatform() != 4)) {
                // 未登录
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
                flag = false;

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

@ -47,7 +47,7 @@ public class GateWayInterceptor extends BaseInterceptor {
     */
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String token = request.getParameter("token");
        String token = request.getParameter("accesstoken");
        String ip = NetworkUtil.getIpAddress(request);
        try {
            GcToken gcToken = tokenDao.findByToken(token);

+ 0 - 141
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/UserInterceptor.java

@ -1,141 +0,0 @@
package com.yihu.wlyy.interceptors;
import java.lang.reflect.Method;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.yihu.wlyy.logs.InterfaceCallLogs;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.ModelAndView;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.util.SystemData;
/**
 * 公共方法,权限简单校验
 * @author George
 *
 */
@Component
public class UserInterceptor extends BaseInterceptor {
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		try {
			request.setCharacterEncoding("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());
				return false;
			}
			// 获取用户token
			String tokenStr = json.has("token") ? json.getString("token") : "";
			String uid = json.has("uid") ? json.getString("uid") : "";
			String imei = json.has("imei") ? json.getString("imei") : "";
			String openid = json.has("openid") ? json.getString("openid") : "";
			if (StringUtils.isEmpty(imei)) {
				imei = openid;
			}
			Token token = null;
			if (SystemData.doctorTokens.containsKey(uid)) {
				token = SystemData.doctorTokens.get(uid);
			} else if (SystemData.patientTokens.containsKey(uid)) {
				token = SystemData.patientTokens.get(uid);
			} else if (SystemData.wxPatientTokens.containsKey(uid)) {
				token = SystemData.wxPatientTokens.get(uid);
			}
			if (token == null) {
				token = tokenDao.findByToken(tokenStr);
				if (token != null) {
					switch (token.getPlatform()) {
					case 1:
						SystemData.patientTokens.put(uid, token);
						break;
					case 2:
						SystemData.doctorTokens.put(uid, token);
						break;
					case 3:
						SystemData.wxPatientTokens.put(uid, token);
						break;
					}
				}
			}
			if (token == null) {
				// 未登录
				response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
				return false;
			} else {
				if (token.getTimeout().getTime() < new Date().getTime()) {
					// 登录超时
					response.getOutputStream().write(error(SystemConf.LOGIN_TIMEOUT, "登录超时,请重新登录").getBytes());
					return 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());
					return false;
				} else {
					// 一天只更新一次
					if (DateUtil.getDays(token.getCzrq(), DateUtil.getNowDateShort()) != 0) {
						// 今天未更新,则更新缓存
						token.setCzrq(new Date());
						// 更新内存
						SystemData.doctorTokens.put(uid, token);
						// 更新数据库
						tokenDao.save(token);
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return true;
	}
	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
		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());
	}
	@Override
	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
	}
}

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

@ -64,8 +64,6 @@ public class TokenService extends BaseService {
			SystemData.wxPatientTokens.put(user, token);
		}else if(platform == 4){
			SystemData.doctorPCTokens.put(user,token);
		}else if(platform == 5){
			SystemData.prescriptionPCTokens.put(user,token);
		}
		return token;
	}
@ -125,5 +123,11 @@ public class TokenService extends BaseService {
	public Token findWxToken(String patient) {
		return tokenDao.findByPatient(patient, 3);
	}
	/**
	 * 查询doctor的微信token标识
	 * @param user
	 */
	public Token findDoctorToken(String user) {
		return tokenDao.findByPatient(user, 4);
	}
}

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

@ -45,7 +45,7 @@ public class GcTokenService {
            gc.setCreateTime(date);
            //2小时过期
            gc.setOutTime(DateUtil.getNextMin(date, 120));
            gc.setToken(token);
            gc.setAccesstoken(token);
            gc.setDel(1);
            tokenDao.save(gc);
@ -55,7 +55,7 @@ public class GcTokenService {
            gcTokenLog.setCreateTime(new Date());
            gcTokenLog.setAppIp(ip);
            gcTokenLog.setMessage("创建token");
            gcTokenLog.setToken(token);
            gcTokenLog.setAccesstoken(token);
            gcTokenLog.setFlag(1);
            tokenLogDao.save(gcTokenLog);
            return gc;

+ 0 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SystemData.java

@ -15,6 +15,4 @@ public class SystemData {
	public static Map<String, Token> patientTokens = new HashMap<String, Token>();
	// 患者公众号验证信息
	public static Map<String, Token> wxPatientTokens = new HashMap<String, Token>();
	// PC端取药系统验证信息
	public static Map<String, Token> prescriptionPCTokens = new HashMap<String, Token>();
}

+ 83 - 67
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java

@ -17,6 +17,7 @@ import com.yihu.wlyy.util.RSAUtils;
import com.yihu.wlyy.util.SystemData;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.patchca.color.SingleColorFactory;
@ -74,7 +75,7 @@ public class LoginController extends BaseController {
     *
     * @return
     */
    @RequestMapping(value = "public_key",method = {RequestMethod.POST,RequestMethod.GET})
    @RequestMapping(value = "public_key", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public String publicKey() {
        try {
@ -96,22 +97,20 @@ public class LoginController extends BaseController {
    /**
     * 医生登录接口
     *
     *  @param mobile  手机号
     * @param captcha 短信验证码
     * @param idcard  身份证号
     * @param platform  // 1患者端,2医生端app,3微信公众号wechat,4IM医生端pc,5PC端取药系统
     * @param mobile   手机号
     * @param captcha  短信验证码
     * @param platform // 1患者端,2医生端app,3微信公众号wechat,4 IM医生端pc, PC端取药系统
     * @param password 密码
     * @return
     */
    @RequestMapping(value = "doctor",method = RequestMethod.POST)
    @RequestMapping(value = "doctor", method = RequestMethod.POST)
    @ResponseBody
    public String doctor(@RequestParam(required = false) String mobile,
                         @RequestParam(required = false) String captcha,
                         @RequestParam(required = false) String idcard,
                         @RequestParam(required = false) Integer platform,
                         @RequestParam(required = false) String password) {
    public String doctor(@ApiParam(required = false, name = "mobile", value = "手机号") @RequestParam(required = false, value = "mobile") String mobile,
                         @ApiParam(required = false, name = "captcha", value = "短信验证码") @RequestParam(required = false) String captcha,
                         @ApiParam(required = false, name = "platform", value = "医生端pc,取药系统 或者对外系统") @RequestParam(required = false) Integer platform,
                         @ApiParam(required = false, name = "password", value = "密码") @RequestParam(required = false) String password) {
        String errorMessage;
        LoginLog loginLog=new LoginLog();
        LoginLog loginLog = new LoginLog();
        loginLog.setCreateTime(new Date());
        loginLog.setPhone(mobile);
        loginLog.setType("2");
@ -119,31 +118,38 @@ public class LoginController extends BaseController {
        loginLog.setAppVersion(super.getAppVersion());
        try {
            if (StringUtils.isEmpty(getIMEI())) {
                errorMessage="获取手机IMEI码失败!";
                errorMessage = "获取手机IMEI码失败!";
                loginLog.setErrorMessage(errorMessage);
                loginLogService.saveLog(loginLog);
                return error(-1, errorMessage);
            }
            if(platform==null){
            if (platform == null) {
                platform = 2;//默认为医生app端
            }
            //身份证登录
            if(StringUtils.isNoneEmpty(mobile)&&StringUtils.isNoneEmpty(password)){
            if (StringUtils.isNoneEmpty(mobile) && StringUtils.isNoneEmpty(password)) {
                password = RSAUtils.getInstance(doctorService).decryptString(password);
                password=StringUtils.reverse(password);
                Doctor doctor=doctorService.findDoctorByMobile(mobile);
                password = StringUtils.reverse(password);
                Doctor doctor = doctorService.findDoctorByMobile(mobile);
                loginLog.setLoginType("2");
                if(doctor==null){
                    errorMessage="该号码未注册!";
                if (doctor == null) {
                    errorMessage = "该号码未注册!";
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1,errorMessage);
                    return error(-1, errorMessage);
                }
                loginLog.setUserCode(doctor.getCode());
                String loginPassword= MD5.GetMD5Code(password+doctor.getSalt());
                if(loginPassword.equals(doctor.getPassword())){
                    // 用户校验通过,生成token
                    Token token = tokenService.newToken(doctor.getCode(), getIMEI(), platform);
                String loginPassword = MD5.GetMD5Code(password + doctor.getSalt());
                if (loginPassword.equals(doctor.getPassword())) {
                    Token token = tokenService.findDoctorToken(doctor.getCode());
                    if (token != null && platform == 4) {
                        //pc版本要做单点登陆 所以如果platform =4 并且 token存在直接返回之前的token
                    } else {
                        // 用户校验通过,生成token
                        token = tokenService.newToken(doctor.getCode(), getIMEI(), platform);
                    }
                    loginLog.setTokenId(token.getId());
                    loginLog.setType("1");
                    Map<String, Object> map = new HashMap<>();
@ -158,52 +164,62 @@ public class LoginController extends BaseController {
                    //获取医生角色和区域权限
                    List<Map<String, String>> roleMap = roleService.getUserRoleAndArea(doctor.getCode());
                    map.put("userRole", roleMap);
                    if("10".equals(doctor.getLevel())&&roleMap.size()==0){
                        errorMessage="改用户没有管理员权限";
                    if ("10" .equals(doctor.getLevel()) && roleMap.size() == 0) {
                        errorMessage = "改用户没有管理员权限";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);
                    }
                    loginLogService.saveLog(loginLog);
                    return write(200, "登录成功", "data", map);
                }else{
                    errorMessage="密码错误,登录失败";
                } else {
                    errorMessage = "密码错误,登录失败";
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);
                }
            }
            if(StringUtils.isNoneEmpty(mobile)&&StringUtils.isNoneEmpty(captcha)){
            if (StringUtils.isNoneEmpty(mobile) && StringUtils.isNoneEmpty(captcha)) {
                // 对验证码进行校验
                int res = smsService.check(mobile, 5, captcha);
                switch (res) {
                    case -2:{
                        errorMessage="验证码已过期!";
                    case -2: {
                        errorMessage = "验证码已过期!";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);}
                    case -1:{
                        errorMessage="请输入正确的验证码!";
                        return error(-1, errorMessage);
                    }
                    case -1: {
                        errorMessage = "请输入正确的验证码!";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);}
                    case 0:{
                        errorMessage="验证码无效!";
                        return error(-1, errorMessage);
                    }
                    case 0: {
                        errorMessage = "验证码无效!";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);}
                        return error(-1, errorMessage);
                    }
                }
                Doctor doctor = doctorService.findDoctorByMobile(mobile);
                loginLog.setLoginType("1");
                if (doctor == null) {
                     errorMessage="该手机号未注册,请确认!";
                    errorMessage = "该手机号未注册,请确认!";
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);
                } else {
                    loginLog.setUserCode(doctor.getCode());
                    // 用户校验通过,生成token
                    Token token = tokenService.newToken(doctor.getCode(), getIMEI(), platform);
                    Token token = tokenService.findDoctorToken(doctor.getCode());
                    if (token != null && platform == 4) {
                        //pc版本要做单点登陆 所以如果platform =4 并且 token存在直接返回之前的token
                    } else {
                        // 用户校验通过,生成token
                        token = tokenService.newToken(doctor.getCode(), getIMEI(), platform);
                    }
                    loginLog.setTokenId(token.getId());
                    loginLog.setType("1");
                    Map<String, Object> map = new HashMap<>();
@ -218,8 +234,8 @@ public class LoginController extends BaseController {
                    //获取医生角色和区域权限
                    List<Map<String, String>> roleMap = roleService.getUserRoleAndArea(doctor.getCode());
                    map.put("userRole", roleMap);
                    if("10".equals(doctor.getLevel())&&roleMap.size()==0){
                        errorMessage="改用户没有管理员权限";
                    if ("10" .equals(doctor.getLevel()) && roleMap.size() == 0) {
                        errorMessage = "改用户没有管理员权限";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);
@ -228,10 +244,10 @@ public class LoginController extends BaseController {
                    return write(200, "登录成功", "data", map);
                }
            }
            errorMessage="登录信息不完整,请重新输入!";
            errorMessage = "登录信息不完整,请重新输入!";
            loginLog.setErrorMessage(errorMessage);
            loginLogService.saveLog(loginLog);
            return error(-1,errorMessage);
            return error(-1, errorMessage);
        } catch (Exception e) {
            loginLog.setErrorMessage(e.getMessage());
            loginLogService.saveLog(loginLog);
@ -250,14 +266,14 @@ public class LoginController extends BaseController {
     * @param newpwd  新密码
     * @return
     */
    @RequestMapping(value = "forgetpwd",method = RequestMethod.POST)
    @RequestMapping(value = "forgetpwd", method = RequestMethod.POST)
    @ResponseBody
    public String forgetpwd(int type,
                            @RequestParam(required = false) String idcard,
                            @RequestParam(required = false) String mobile,
                            @RequestParam(required = false) String captchaToken,
                            @RequestParam(required = false)String captcha,
                            @RequestParam(required = false)String patient,
                            @RequestParam(required = false) String captcha,
                            @RequestParam(required = false) String patient,
                            String newpwd) {
        try {
            //String ct = request.getSession().getAttribute("captchaToken").toString();
@ -278,13 +294,13 @@ public class LoginController extends BaseController {
            if (type == 2) {
                // 医生端
                    Doctor doctor = doctorService.findDoctorByMobile(mobile);
                    String password = RSAUtils.getInstance(doctorService).decryptString(newpwd);
                    password=StringUtils.reverse(password);
                    password=MD5.GetMD5Code(password+doctor.getSalt());
                    doctor.setPassword(password);
                    doctorService.updateDoctorPwd(doctor);
                    return success("操作成功!");
                Doctor doctor = doctorService.findDoctorByMobile(mobile);
                String password = RSAUtils.getInstance(doctorService).decryptString(newpwd);
                password = StringUtils.reverse(password);
                password = MD5.GetMD5Code(password + doctor.getSalt());
                doctor.setPassword(password);
                doctorService.updateDoctorPwd(doctor);
                return success("操作成功!");
            } else {
                // 患者端
                Patient patientTemp = patientService.findByIdcard(idcard);
@ -292,8 +308,8 @@ public class LoginController extends BaseController {
                    return error(-1, "操作失败:此用户未注册");
                } else {
                    String password = RSAUtils.getInstance(doctorService).decryptString(newpwd);
                    password=StringUtils.reverse(password);
                    password=MD5.GetMD5Code(password+patientTemp.getSalt());
                    password = StringUtils.reverse(password);
                    password = MD5.GetMD5Code(password + patientTemp.getSalt());
                    patientTemp.setPassword(password);
                    patientService.updatePatientPwd(patientTemp);
                    return success("操作成功!");
@ -311,7 +327,7 @@ public class LoginController extends BaseController {
     * @param type 1患者,2医生,3微信公众号
     * @return
     */
    @RequestMapping(value = "exit",method = {RequestMethod.POST,RequestMethod.GET})
    @RequestMapping(value = "exit", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public String logout(int type) {
        try {
@ -323,7 +339,7 @@ public class LoginController extends BaseController {
        }
    }
    @RequestMapping(value = "/third/login",method = {RequestMethod.POST,RequestMethod.GET})
    @RequestMapping(value = "/third/login", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public String thirdLogin(
            @RequestParam(value = "id") int id,
@ -385,7 +401,7 @@ public class LoginController extends BaseController {
     * @param response
     * @throws IOException
     */
    @RequestMapping(value="pcrimg",method = {RequestMethod.POST,RequestMethod.GET})
    @RequestMapping(value = "pcrimg", method = {RequestMethod.POST, RequestMethod.GET})
    public void crimg(HttpServletRequest request, HttpServletResponse response) throws IOException {
        ConfigurableCaptchaService cs = new ConfigurableCaptchaService();
        cs.setColorFactory(new SingleColorFactory(new Color(25, 60, 170)));
@ -432,25 +448,25 @@ public class LoginController extends BaseController {
     * @param mobile 登录手机号
     * @return
     */
    @RequestMapping(value = "checkmobile",method = RequestMethod.POST)
    @RequestMapping(value = "checkmobile", method = RequestMethod.POST)
    @ResponseBody
    public String checkmobile(@RequestParam(required = true,value = "mobile",defaultValue = "0")String mobile,
                              @RequestParam(required = true,value = "type",defaultValue = "0") int type) {
    public String checkmobile(@RequestParam(required = true, value = "mobile", defaultValue = "0") String mobile,
                              @RequestParam(required = true, value = "type", defaultValue = "0") int type) {
        try {
            if(type==0){//患者端
            if (type == 0) {//患者端
                List<Patient> temp = patientService.findByMobile(mobile);
                if (temp != null&&temp.size()>0) {
                if (temp != null && temp.size() > 0) {
                    // 设置身份证号
                    return write(200, "手机号码已经被注册!");
                }
                return error(-1, "该手机号未被注册!");
            }else if(type==1){
            } else if (type == 1) {
                Doctor doctor = doctorService.findDoctorByMobile(mobile);
                if(doctor!=null){
                if (doctor != null) {
                    return write(200, "手机号码已经被注册!");
                }
                return error(-1, "该手机号未被注册!");
            }else{
            } else {
                return error(1, "错误的请求类型!");
            }
        } catch (Exception e) {

+ 219 - 219
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/PCLoginController.java

@ -1,228 +1,228 @@
package com.yihu.wlyy.web.common.account;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.login.LoginLog;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.repository.security.TokenDao;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.common.account.RoleService;
import com.yihu.wlyy.service.common.account.TokenService;
import com.yihu.wlyy.service.common.login.LoginLogService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.util.RSAUtils;
import com.yihu.wlyy.util.SystemData;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.patchca.color.SingleColorFactory;
import org.patchca.filter.predefined.*;
import org.patchca.service.ConfigurableCaptchaService;
import org.patchca.utils.encoder.EncoderHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.*;
import java.io.IOException;
import java.util.*;
import java.util.List;
//package com.yihu.wlyy.web.common.account;
//
//import com.yihu.wlyy.entity.doctor.profile.Doctor;
//import com.yihu.wlyy.entity.login.LoginLog;
//import com.yihu.wlyy.entity.patient.Patient;
//import com.yihu.wlyy.entity.security.Token;
//import com.yihu.wlyy.repository.security.TokenDao;
//import com.yihu.wlyy.service.common.SMSService;
//import com.yihu.wlyy.service.common.account.DoctorService;
//import com.yihu.wlyy.service.common.account.PatientService;
//import com.yihu.wlyy.service.common.account.RoleService;
//import com.yihu.wlyy.service.common.account.TokenService;
//import com.yihu.wlyy.service.common.login.LoginLogService;
//import com.yihu.wlyy.util.DateUtil;
//import com.yihu.wlyy.util.MD5;
//import com.yihu.wlyy.util.RSAUtils;
//import com.yihu.wlyy.util.SystemData;
//import com.yihu.wlyy.web.BaseController;
//import io.swagger.annotations.Api;
/**
 * @author calvin
 */
@Controller
@RequestMapping(value = "/loginPC", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "健康师登录取药系统")
public class PCLoginController extends BaseController {
    @Autowired
    private DoctorService doctorService;
    @Autowired
    private TokenService tokenService;
    @Autowired
    private SMSService smsService;
    @Autowired
    public TokenDao tokenDao;
    @Autowired
    private RoleService roleService;
    @Autowired
    private LoginLogService loginLogService;
    /**
     *
     * @param mobile 手机号
     * @param captcha 短信验证码
     * @param platform  1、患者端,2、医生端app,3、微信公众号wechat,4、医生端pc,5PC端取药系统
     * @param password 密码
     * @return
     */
    @RequestMapping(value = "doctor",method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public String doctor(@ApiParam(required = false, name = "mobile", value = "手机号") @RequestParam(required = false,value = "mobile") String mobile,
                         @ApiParam(required = false, name = "captcha", value = "短信验证码") @RequestParam(required = false) String captcha,
                         @ApiParam(required = false, name = "platform", value = "医生端pc") @RequestParam(required = false,defaultValue = "5") Integer platform,
                         @ApiParam(required = false, name = "password", value = "密码") @RequestParam(required = false) String password) {
        String errorMessage;
        LoginLog loginLog=new LoginLog();
        loginLog.setCreateTime(new Date());
        loginLog.setPhone(mobile);
        loginLog.setType("2");
        loginLog.setUserType("2");
        loginLog.setAppVersion(super.getAppVersion());
        try {
            if(platform==null){
                platform = 5;//默认为医生app端
            }
            //身份证登录
            if(StringUtils.isNoneEmpty(mobile)&&StringUtils.isNoneEmpty(password)){
                password = RSAUtils.getInstance(doctorService).decryptString(password);
                password=StringUtils.reverse(password);
                Doctor doctor=doctorService.findDoctorByMobile(mobile);
                loginLog.setLoginType("2");
                if(doctor==null){
                    errorMessage="该号码未注册!";
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1,errorMessage);
                }
                loginLog.setUserCode(doctor.getCode());
                String loginPassword= MD5.GetMD5Code(password+doctor.getSalt());
                if(loginPassword.equals(doctor.getPassword())){
                    //使用i健康系统账号体系,只有健康师有权限登录取药系统
                    if(doctor.getLevel()!=3){
                        loginLog.setType("2");
                        errorMessage="该用户角色没有登录权限!";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);
                    }
                    // 用户校验通过,生成token
                    Token token = tokenService.newToken(doctor.getCode(), "pc", platform);
                    loginLog.setTokenId(token.getId());
                    loginLog.setType("1");
                    Map<String, Object> map = new HashMap<>();
                    map.put("id", doctor.getId());
                    map.put("uid", doctor.getCode());
                    map.put("token", token.getToken());
                    map.put("name", doctor.getName());
                    map.put("hospital", doctor.getHospital());
                    map.put("photo", doctor.getPhoto());
                    // 设置医生类型:1专科医生,2全科医生,3健康管理师
                    map.put("doctorType", doctor.getLevel());
                    //获取医生角色和区域权限
//                    List<Map<String, String>> roleMap = roleService.getUserRoleAndArea(doctor.getCode());
//                    map.put("userRole", roleMap);
//                    if("10".equals(doctor.getLevel())&&roleMap.size()==0){
//                        errorMessage="该用户没有管理员权限";
//import io.swagger.annotations.ApiParam;
//import org.apache.commons.lang3.StringUtils;
//import org.json.JSONObject;
//import org.patchca.color.SingleColorFactory;
//import org.patchca.filter.predefined.*;
//import org.patchca.service.ConfigurableCaptchaService;
//import org.patchca.utils.encoder.EncoderHelper;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.MediaType;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.awt.*;
//import java.io.IOException;
//import java.util.*;
//import java.util.List;
//
////import io.swagger.annotations.Api;
//
///**
// * @author calvin
// */
//@Controller
//@RequestMapping(value = "/loginPC", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
//@Api(description = "健康师登录取药系统")
//public class PCLoginController extends BaseController {
//
//    @Autowired
//    private DoctorService doctorService;
//
//    @Autowired
//    private TokenService tokenService;
//
//    @Autowired
//    private SMSService smsService;
//
//    @Autowired
//    public TokenDao tokenDao;
//
//    @Autowired
//    private RoleService roleService;
//    @Autowired
//    private LoginLogService loginLogService;
//
//    /**
//     *
//     * @param mobile 手机号
//     * @param captcha 短信验证码
//     * @param platform  1、患者端,2、医生端app,3、微信公众号wechat,4、医生端pc,5PC端取药系统
//     * @param password 密码
//     * @return
//     */
//    @RequestMapping(value = "doctor",method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ResponseBody
//    public String doctor(@ApiParam(required = false, name = "mobile", value = "手机号") @RequestParam(required = false,value = "mobile") String mobile,
//                         @ApiParam(required = false, name = "captcha", value = "短信验证码") @RequestParam(required = false) String captcha,
//                         @ApiParam(required = false, name = "platform", value = "医生端pc") @RequestParam(required = false,defaultValue = "4") Integer platform,
//                         @ApiParam(required = false, name = "password", value = "密码") @RequestParam(required = false) String password) {
//
//        String errorMessage;
//        LoginLog loginLog=new LoginLog();
//        loginLog.setCreateTime(new Date());
//        loginLog.setPhone(mobile);
//        loginLog.setType("2");
//        loginLog.setUserType("2");
//        loginLog.setAppVersion(super.getAppVersion());
//        try {
//            if(platform==null){
//                platform = 4;//默认为医生app端
//            }
//            //身份证登录
//            if(StringUtils.isNoneEmpty(mobile)&&StringUtils.isNoneEmpty(password)){
//                password = RSAUtils.getInstance(doctorService).decryptString(password);
//                password=StringUtils.reverse(password);
//                Doctor doctor=doctorService.findDoctorByMobile(mobile);
//                loginLog.setLoginType("2");
//                if(doctor==null){
//                    errorMessage="该号码未注册!";
//                    loginLog.setErrorMessage(errorMessage);
//                    loginLogService.saveLog(loginLog);
//                    return error(-1,errorMessage);
//                }
//                loginLog.setUserCode(doctor.getCode());
//                String loginPassword= MD5.GetMD5Code(password+doctor.getSalt());
//                if(loginPassword.equals(doctor.getPassword())){
//                    //使用i健康系统账号体系,只有健康师有权限登录取药系统
//                    if(doctor.getLevel()!=3){
//                        loginLog.setType("2");
//                        errorMessage="该用户角色没有登录权限!";
//                        loginLog.setErrorMessage(errorMessage);
//                        loginLogService.saveLog(loginLog);
//                        return error(-1, errorMessage);
//                    }
                    loginLogService.saveLog(loginLog);
                    return write(200, "登录成功", "data", map);
                }else{
                    errorMessage="密码错误,登录失败";
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);
                }
            }
            if(StringUtils.isNoneEmpty(mobile)&&StringUtils.isNoneEmpty(captcha)){
                // 对验证码进行校验
                int res = smsService.check(mobile, 5, captcha);
                switch (res) {
                    case -2:{
                        errorMessage="验证码已过期!";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);}
                    case -1:{
                        errorMessage="请输入正确的验证码!";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);}
                    case 0:{
                        errorMessage="验证码无效!";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);}
                }
                Doctor doctor = doctorService.findDoctorByMobile(mobile);
                loginLog.setLoginType("1");
                if (doctor == null) {
                    errorMessage="该手机号未注册,请确认!";
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);
                } else {
                    loginLog.setUserCode(doctor.getCode());
                    //使用i健康系统账号体系,只有健康师有权限登录取药系统
                    if(doctor.getLevel()!=3){
                        loginLog.setType("2");
                        errorMessage="该用户角色没有登录权限!";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);
                    }
                    // 用户校验通过,生成token
                    Token token = tokenService.newToken(doctor.getCode(), "pc", platform);
                    loginLog.setTokenId(token.getId());
                    loginLog.setType("1");
                    Map<String, Object> map = new HashMap<>();
                    map.put("id", doctor.getId());
                    map.put("uid", doctor.getCode());
                    map.put("token", token.getToken());
                    map.put("name", doctor.getName());
                    map.put("hospital", doctor.getHospital());
                    map.put("photo", doctor.getPhoto());
                    // 设置医生类型:1专科医生,2全科医生,3健康管理师
                    map.put("doctorType", doctor.getLevel());
                    //获取医生角色和区域权限
//                    List<Map<String, String>> roleMap = roleService.getUserRoleAndArea(doctor.getCode());
//                    map.put("userRole", roleMap);
//                    if("10".equals(doctor.getLevel())&&roleMap.size()==0){
//                        errorMessage="改用户没有管理员权限";
//
//
//                    // 用户校验通过,生成token
//                    Token token = tokenService.newToken(doctor.getCode(), "pc", platform);
//                    loginLog.setTokenId(token.getId());
//                    loginLog.setType("1");
//                    Map<String, Object> map = new HashMap<>();
//                    map.put("id", doctor.getId());
//                    map.put("uid", doctor.getCode());
//                    map.put("token", token.getToken());
//                    map.put("name", doctor.getName());
//                    map.put("hospital", doctor.getHospital());
//                    map.put("photo", doctor.getPhoto());
//                    // 设置医生类型:1专科医生,2全科医生,3健康管理师
//                    map.put("doctorType", doctor.getLevel());
//                    //获取医生角色和区域权限
////                    List<Map<String, String>> roleMap = roleService.getUserRoleAndArea(doctor.getCode());
////                    map.put("userRole", roleMap);
////                    if("10".equals(doctor.getLevel())&&roleMap.size()==0){
////                        errorMessage="该用户没有管理员权限";
////                        loginLog.setErrorMessage(errorMessage);
////                        loginLogService.saveLog(loginLog);
////                        return error(-1, errorMessage);
////                    }
//                    loginLogService.saveLog(loginLog);
//                    return write(200, "登录成功", "data", map);
//                }else{
//                    errorMessage="密码错误,登录失败";
//                    loginLog.setErrorMessage(errorMessage);
//                    loginLogService.saveLog(loginLog);
//                    return error(-1, errorMessage);
//                }
//            }
//            if(StringUtils.isNoneEmpty(mobile)&&StringUtils.isNoneEmpty(captcha)){
//                // 对验证码进行校验
//                int res = smsService.check(mobile, 5, captcha);
//                switch (res) {
//                    case -2:{
//                        errorMessage="验证码已过期!";
//                        loginLog.setErrorMessage(errorMessage);
//                        loginLogService.saveLog(loginLog);
//                        return error(-1, errorMessage);}
//                    case -1:{
//                        errorMessage="请输入正确的验证码!";
//                        loginLog.setErrorMessage(errorMessage);
//                        loginLogService.saveLog(loginLog);
//                        return error(-1, errorMessage);}
//                    case 0:{
//                        errorMessage="验证码无效!";
//                        loginLog.setErrorMessage(errorMessage);
//                        loginLogService.saveLog(loginLog);
//                        return error(-1, errorMessage);}
//                }
//                Doctor doctor = doctorService.findDoctorByMobile(mobile);
//                loginLog.setLoginType("1");
//                if (doctor == null) {
//                    errorMessage="该手机号未注册,请确认!";
//                    loginLog.setErrorMessage(errorMessage);
//                    loginLogService.saveLog(loginLog);
//                    return error(-1, errorMessage);
//                } else {
//                    loginLog.setUserCode(doctor.getCode());
//
//                    //使用i健康系统账号体系,只有健康师有权限登录取药系统
//                    if(doctor.getLevel()!=3){
//                        loginLog.setType("2");
//                        errorMessage="该用户角色没有登录权限!";
//                        loginLog.setErrorMessage(errorMessage);
//                        loginLogService.saveLog(loginLog);
//                        return error(-1, errorMessage);
//                    }
                    loginLogService.saveLog(loginLog);
                    return write(200, "登录成功", "data", map);
                }
            }
            errorMessage="登录信息不完整,请重新输入!";
            loginLog.setErrorMessage(errorMessage);
            loginLogService.saveLog(loginLog);
            return error(-1,errorMessage);
        } catch (Exception e) {
            loginLog.setErrorMessage(e.getMessage());
            loginLogService.saveLog(loginLog);
            error(e);
            return error(-1, "系统异常,登录失败");
        }
    }
}
//
//                    // 用户校验通过,生成token
//                    Token token = tokenService.newToken(doctor.getCode(), "pc", platform);
//                    loginLog.setTokenId(token.getId());
//                    loginLog.setType("1");
//                    Map<String, Object> map = new HashMap<>();
//                    map.put("id", doctor.getId());
//                    map.put("uid", doctor.getCode());
//                    map.put("token", token.getToken());
//                    map.put("name", doctor.getName());
//                    map.put("hospital", doctor.getHospital());
//                    map.put("photo", doctor.getPhoto());
//                    // 设置医生类型:1专科医生,2全科医生,3健康管理师
//                    map.put("doctorType", doctor.getLevel());
//                    //获取医生角色和区域权限
////                    List<Map<String, String>> roleMap = roleService.getUserRoleAndArea(doctor.getCode());
////                    map.put("userRole", roleMap);
////                    if("10".equals(doctor.getLevel())&&roleMap.size()==0){
////                        errorMessage="改用户没有管理员权限";
////                        loginLog.setErrorMessage(errorMessage);
////                        loginLogService.saveLog(loginLog);
////                        return error(-1, errorMessage);
////                    }
//                    loginLogService.saveLog(loginLog);
//                    return write(200, "登录成功", "data", map);
//                }
//            }
//            errorMessage="登录信息不完整,请重新输入!";
//            loginLog.setErrorMessage(errorMessage);
//            loginLogService.saveLog(loginLog);
//            return error(-1,errorMessage);
//        } catch (Exception e) {
//            loginLog.setErrorMessage(e.getMessage());
//            loginLogService.saveLog(loginLog);
//            error(e);
//            return error(-1, "系统异常,登录失败");
//        }
//    }
//}

+ 39 - 40
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/device/DeviceController.java

@ -17,50 +17,49 @@ import java.util.List;
@RequestMapping(value = "/common/device", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "设备管理")
public class DeviceController extends BaseController {
	
	@Autowired
	private DeviceService deviceService;
    @Autowired
    private DeviceService deviceService;
	@ApiOperation("获取设备分类")
	@RequestMapping(value = "DeviceCategory",method = RequestMethod.POST)
	@ResponseBody
	public String getDeviceCategory() {
		try {
			List<DeviceCategory> list = deviceService.findAllCategory();
			return write(200,"获取设备分类成功!","data",list);
		} catch (Exception ex) {
			error(ex);
			return invalidUserException(ex, -1, "获取设备分类失败!");
		}
	}
    @ApiOperation("获取设备分类")
    @RequestMapping(value = "DeviceCategory", method = RequestMethod.POST)
    @ResponseBody
    public String getDeviceCategory() {
        try {
            List<DeviceCategory> list = deviceService.findAllCategory();
            return write(200, "获取设备分类成功!", "data", list);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "获取设备分类失败!");
        }
    }
	@ApiOperation("获取设备列表")
	@RequestMapping(value = "DeviceList",method = RequestMethod.POST)
	@ResponseBody
	public String getDeviceList(@ApiParam(name="category_code",value="设备类型代码",defaultValue = "1")
								 @RequestParam(value="category_code",required = true) String categoryCode) {
		try {
			List<Device> list = deviceService.findDeviceByCategory(categoryCode);
			return write(200,"获取设备列表成功!","data",list);
		} catch (Exception ex) {
			error(ex);
			return invalidUserException(ex, -1, "获取设备列表失败!");
		}
	}
    @ApiOperation("获取设备列表")
    @RequestMapping(value = "DeviceList", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public String getDeviceList(@ApiParam(name = "category_code", value = "设备类型代码", defaultValue = "1")
                                @RequestParam(value = "category_code", required = true) String categoryCode) {
        try {
            List<Device> list = deviceService.findDeviceByCategory(categoryCode);
            return write(200, "获取设备列表成功!", "data", list);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "获取设备列表失败!");
        }
    }
	@ApiOperation("获取设备信息")
	@RequestMapping(value = "DeviceInfo",method = RequestMethod.POST)
	@ResponseBody
	public String getDeviceInfo(@ApiParam(name="id",value="设备ID",defaultValue = "19")
									   @RequestParam(value="id",required = true) String id) {
		try {
			Device device = deviceService.findById(id);
    @ApiOperation("获取设备信息")
    @RequestMapping(value = "DeviceInfo", method = RequestMethod.POST)
    @ResponseBody
    public String getDeviceInfo(@ApiParam(name = "id", value = "设备ID", defaultValue = "19")
                                @RequestParam(value = "id", required = true) String id) {
        try {
            Device device = deviceService.findById(id);
			return write(200, "查询成功", "data", device);
		} catch (Exception ex) {
			return invalidUserException(ex, -1, ex.getMessage());
		}
	}
            return write(200, "查询成功", "data", device);
        } catch (Exception ex) {
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
}

+ 2 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionLogController.java

@ -106,7 +106,7 @@ public class PrescriptionLogController extends BaseController {
            }
            //排序
            //排序
            expressageLogs.sort((o1, o2) -> {
            prescriptionLogs.sort((o1, o2) -> {
                long map1value = o1.getCreateTime().getTime();
                long map2value = o2.getCreateTime().getTime();
@ -131,11 +131,7 @@ public class PrescriptionLogController extends BaseController {
            } else {
                return error(-1, "获取失败");
            }
        } catch (
                Exception e
                )
        {
        } catch (Exception e){
            e.printStackTrace();
            return error(-1, "获取失败");
        }

+ 112 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/controller/GcTokenController.java

@ -1,17 +1,27 @@
package com.yihu.wlyy.web.gateway.controller;
import com.fasterxml.jackson.databind.deser.Deserializers;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.gateway.GcClientDetails;
import com.yihu.wlyy.entity.gateway.GcToken;
import com.yihu.wlyy.entity.login.LoginLog;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.TokenService;
import com.yihu.wlyy.service.common.login.LoginLogService;
import com.yihu.wlyy.service.gateway.GcClientDetailsService;
import com.yihu.wlyy.service.gateway.GcTokenService;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.util.NetworkUtil;
import com.yihu.wlyy.util.RSAUtils;
import com.yihu.wlyy.web.gateway.vo.GcTokenModel;
import com.yihu.wlyy.web.gateway.vo.LoginModel;
import com.yihu.wlyy.web.gateway.vo.base.BaseResultModel;
import com.yihu.wlyy.web.gateway.vo.base.ResultOneModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
@ -21,22 +31,30 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Date;
/**
 * Created by chenweida on 2017/8/17.
 * 对外的网关
 */
@RestController
@RequestMapping("/wlyygc")
@RequestMapping("/gc")
@Api(description = "token相关服务")
public class GcTokenController {
    @Autowired
    private GcTokenService tokenService;
    private GcTokenService gcTokenService;
    @Autowired
    private GcClientDetailsService clientDetailsService;
    @ApiOperation("获取token")
    @RequestMapping(value = "token", method = RequestMethod.GET)
    @Autowired
    private DoctorService doctorService;
    @Autowired
    private TokenService tokenService;
    @Autowired
    private LoginLogService loginLogService;
    @ApiOperation("获取accesstoken")
    @RequestMapping(value = "accesstoken", method = RequestMethod.GET)
    public ResultOneModel<GcTokenModel> getToken(
            @ApiParam(name = "appid", value = "appid", required = true) @RequestParam(required = true, value = "appid") String appid,
            @ApiParam(name = "appSecret", value = "appSecret", required = true) @RequestParam(required = true, value = "appSecret") String appSecret,
@ -59,7 +77,7 @@ public class GcTokenController {
        //生成token
        GcToken gcToken = null;
        try {
            gcToken = tokenService.createToken(appid, appSecret, NetworkUtil.getIpAddress(request));
            gcToken = gcTokenService.createToken(appid, appSecret, NetworkUtil.getIpAddress(request));
        } catch (IOException e) {
            e.printStackTrace();
        }
@ -67,4 +85,93 @@ public class GcTokenController {
        BeanUtils.copyProperties(gcToken, gcTokenModel);
        return new ResultOneModel(gcTokenModel);
    }
    /**
     * 医生端要传  userAgent:{"id":4816,"uid":"xh1D2017031503333","token":"5d68d84dbb79996efba31192856139a4","platform":4,"imei":"05948CE4F079E998306CFCCF86A5A77F"}
     * @param imei
     * @param account
     * @param platform
     * @param password
     * @return
     */
    @RequestMapping(value = "/doctor/login", method = RequestMethod.GET)
    @ApiOperation("医生端登陆")
    public ResultOneModel<LoginModel> doctorLogin(
            @ApiParam(required = false, name = "imei", value = "imei号") @RequestParam(required = true, value = "imei") String imei,
            @ApiParam(required = false, name = "account", value = "手机号/身份证") @RequestParam(required = false, value = "account") String account,
            @ApiParam(required = false, name = "platform", value = "医生端pc,取药系统 或者对外系统") @RequestParam(required = false, defaultValue = "4") Integer platform,
            @ApiParam(required = false, name = "password", value = "密码") @RequestParam(required = false) String password) {
        String errorMessage;
        LoginLog loginLog = new LoginLog();
        loginLog.setCreateTime(new Date());
        loginLog.setPhone(account);
        loginLog.setType("2");
        loginLog.setUserType("2");
        try {
            if (StringUtils.isEmpty(imei)) {
                errorMessage = "获取IMEI码失败!";
                loginLog.setErrorMessage(errorMessage);
                loginLogService.saveLog(loginLog);
                return new ResultOneModel<>(BaseResultModel.codeEm.login_IMEI_error.getCode(), BaseResultModel.codeEm.login_IMEI_error.getMessage());
            }
            if (platform == null) {
                platform = 2;//默认为医生app端
            }
            //身份证登录
            if (StringUtils.isNoneEmpty(account) && StringUtils.isNoneEmpty(password)) {
                password = RSAUtils.getInstance(doctorService).decryptString(password);
                password = StringUtils.reverse(password);
                //根据电话号码找
                Doctor doctor = doctorService.findDoctorByMobile(account);
                if (doctor == null) {
                    //如果电话号码找不到 根据身份证找
                    doctor = doctorService.findbyIdCard(account);
                }
                loginLog.setLoginType("2");
                if (doctor == null) {
                    errorMessage = "该号码未注册!";
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return new ResultOneModel<>(BaseResultModel.codeEm.login_account_error.getCode(), BaseResultModel.codeEm.login_account_error.getMessage());
                }
                loginLog.setUserCode(doctor.getCode());
                String loginPassword = MD5.GetMD5Code(password + doctor.getSalt());
                if (loginPassword.equals(doctor.getPassword())) {
                    Token token = tokenService.findDoctorToken(doctor.getCode());
                    if (token != null && platform == 4) {
                        //pc版本要做单点登陆 所以如果platform =4 并且 token存在直接返回之前的token
                    } else {
                        // 用户校验通过,生成token
                        token = tokenService.newToken(doctor.getCode(), imei, platform);
                    }
                    loginLog.setTokenId(token.getId());
                    loginLog.setType("1");
                    LoginModel loginModel = new LoginModel();
                    loginModel.setDoctorCode(doctor.getCode());
                    loginModel.setDoctorName(doctor.getName());
                    loginModel.setToken(token.getToken());
                    loginModel.setDoctorPhoto(doctor.getPhoto());
                    loginModel.setDoctorType(doctor.getLevel());
                    loginLogService.saveLog(loginLog);
                    return new ResultOneModel<>(loginModel);
                } else {
                    errorMessage = "密码错误,登录失败";
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return new ResultOneModel<>(BaseResultModel.codeEm.login_password_error.getCode(), BaseResultModel.codeEm.login_password_error.getMessage());
                }
            }
            return new ResultOneModel<>(BaseResultModel.codeEm.error_params.getCode(), BaseResultModel.codeEm.error_params.getMessage());
        } catch (Exception e) {
            loginLog.setErrorMessage(e.getMessage());
            loginLogService.saveLog(loginLog);
            return new ResultOneModel<>(BaseResultModel.codeEm.login_system_error.getCode(), BaseResultModel.codeEm.login_system_error.getMessage());
        }
    }
}

+ 28 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/controller/GcUserController.java

@ -1,19 +1,42 @@
package com.yihu.wlyy.web.gateway.controller;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.login.LoginLog;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.common.account.RoleService;
import com.yihu.wlyy.service.common.account.TokenService;
import com.yihu.wlyy.service.common.login.LoginLogService;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.util.RSAUtils;
import com.yihu.wlyy.web.common.account.LoginController;
import com.yihu.wlyy.web.gateway.vo.DoctorModel;
import com.yihu.wlyy.web.gateway.vo.LoginModel;
import com.yihu.wlyy.web.gateway.vo.PatientModel;
import com.yihu.wlyy.web.gateway.vo.base.BaseResultModel;
import com.yihu.wlyy.web.gateway.vo.base.ResultOneModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
/**
 * Created by chenweida on 2017/8/17.
 */
@ -25,6 +48,11 @@ public class GcUserController {
    private DoctorService doctorService;
    @Autowired
    private PatientService patientService;
    @Autowired
    private TokenService tokenService;
    @Autowired
    private LoginLogService loginLogService;
    @RequestMapping(value = "/doctor", method = RequestMethod.GET)
    @ApiOperation("根据医生code查询医生信息")
@ -47,6 +75,4 @@ public class GcUserController {
        BeanUtils.copyProperties(patient, patientModel);
        return new ResultOneModel(patientModel);
    }
}

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

@ -0,0 +1,21 @@
package com.yihu.wlyy.web.gateway.vo;
import io.swagger.annotations.ApiModel;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2017/8/17.
 */
@ApiModel(description = "医生登陆model")
public class DoctorLoginModel {
    private Long id;
    private String uid;
    private String token;
    private String name;
    private String hospital;
    private String photo;
    private String doctorType;
    private List<Map<String, String>> roleMap;
}

+ 5 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/vo/GcTokenModel.java

@ -11,18 +11,18 @@ import java.util.Date;
@ApiModel(description = "")
public class GcTokenModel {
    @ApiModelProperty(value = "请求凭证", required = false, access = "response")
    private String token;
    private String accesstoken;
    @ApiModelProperty(value = "创建时间", required = false, access = "response")
    private Date createTime;
    @ApiModelProperty(value = "过期时间", required = false, access = "response")
    private Date outTime;
    public String getToken() {
        return token;
    public String getAccesstoken() {
        return accesstoken;
    }
    public void setToken(String token) {
        this.token = token;
    public void setAccesstoken(String accesstoken) {
        this.accesstoken = accesstoken;
    }
    public Date getCreateTime() {

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

@ -0,0 +1,73 @@
package com.yihu.wlyy.web.gateway.vo;
import com.yihu.wlyy.web.gateway.vo.base.BaseResultModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
 * Created by chenweida on 2017/8/17.
 */
@ApiModel(description = "登陆实体类")
public class LoginModel extends BaseResultModel {
    @ApiModelProperty(value = "医生code", required = false, access = "response")
    private String doctorCode;
    @ApiModelProperty(value = "登陆凭证", required = false, access = "response")
    private String token;
    @ApiModelProperty(value = "医生名称", required = false, access = "response")
    private String doctorName;
    @ApiModelProperty(value = "医院編碼", required = false, access = "response")
    private String hospital;
    @ApiModelProperty(value = "医生头像", required = false, access = "response")
    private String doctorPhoto;
    @ApiModelProperty(value = "医生类型:1专科医生,2全科医生,3健康管理师", required = false, access = "response")
    private Integer doctorType;
    public String getDoctorCode() {
        return doctorCode;
    }
    public void setDoctorCode(String doctorCode) {
        this.doctorCode = doctorCode;
    }
    public String getToken() {
        return token;
    }
    public void setToken(String token) {
        this.token = token;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public String getDoctorPhoto() {
        return doctorPhoto;
    }
    public void setDoctorPhoto(String doctorPhoto) {
        this.doctorPhoto = doctorPhoto;
    }
    public Integer getDoctorType() {
        return doctorType;
    }
    public void setDoctorType(Integer doctorType) {
        this.doctorType = doctorType;
    }
}

+ 13 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/vo/base/BaseResultModel.java

@ -33,11 +33,21 @@ public class BaseResultModel {
        success(10000, "请求成功"),//请求成功
        error_Appid(-9000, "appid不存在"),//appid不存在
        error_AppSecret(-9001, "AppSecret不存在"),//AppSecret不存在
        error_params(-10000, "请求失败 参数错误"),//请求失败 参数错误
        error_no_ip(-10010, "请求失败,获取IP失败"),//请求失败,获取IP失败
        token_out_effect(-9002, "无效的token"),//token无效
        token_no_power(-9003, "用户没权限"),// 没权限 包括未授权 或者uri错误
        token_out_time(-9004, "oken已过期")//token无效
        token_out_time(-9004, "oken已过期"),//token无效
        error_params(-10000, "请求失败 参数错误"),//请求失败 参数错误
        error_no_ip(-10010, "请求失败,获取IP失败"),//请求失败,获取IP失败
        login_system_error(-10020, "系统异常"),
        login_account_error(-20010, "账号不存在"),
        login_password_error(-20020, "密码错误"),
        login_IMEI_error(-20030, "获取imei失败");
        ;
        codeEm(Integer code, String message) {

+ 14 - 14
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/vo/base/ResultBatchModel.java

@ -14,22 +14,22 @@ import java.util.List;
public class ResultBatchModel extends BaseResultModel {
    @ApiModelProperty(value = "成功数目", required = false, access = "response")
    private Integer success = 0;
    private Integer successNum = 0;
    @ApiModelProperty(value = "失败数目", required = false, access = "response")
    private Integer error = 0;
    private Integer errorNum = 0;
    @ApiModelProperty(value = "失败List", required = false, access = "response")
    private List<String> errorList = new ArrayList<>();
    public ResultBatchModel(Integer success, Integer error, List<String> errorList) {
        this.success = success;
        this.error = error;
        this.successNum = success;
        this.errorNum = error;
        this.errorList = errorList;
    }
    public ResultBatchModel(Integer code, String message, Integer success, Integer error, List<String> errorList) {
        super(code, message);
        this.success = success;
        this.error = error;
        this.successNum = success;
        this.errorNum = error;
        this.errorList = errorList;
    }
@ -37,20 +37,20 @@ public class ResultBatchModel extends BaseResultModel {
    }
    public Integer getSuccess() {
        return success;
    public Integer getSuccessNum() {
        return successNum;
    }
    public void setSuccess(Integer success) {
        this.success = success;
    public void setSuccessNum(Integer successNum) {
        this.successNum = successNum;
    }
    public Integer getError() {
        return error;
    public Integer getErrorNum() {
        return errorNum;
    }
    public void setError(Integer error) {
        this.error = error;
    public void setErrorNum(Integer errorNum) {
        this.errorNum = errorNum;
    }
    public List<String> getErrorList() {

+ 3 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/vo/base/ResultOneModel.java

@ -25,5 +25,7 @@ public class ResultOneModel<T> extends BaseResultModel {
        this.result = result;
    }
    public ResultOneModel(Integer code, String message) {
        super(code, message);
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionLogController.java

@ -71,7 +71,7 @@ public class PatientPrescriptionLogController extends BaseController {
                prescriptionLogs.add(prescriptionLog);
            }
            //排序
            expressageLogs.sort((o1, o2) -> {
            prescriptionLogs.sort((o1, o2) -> {
                long map1value = o1.getCreateTime().getTime();
                long map2value = o2.getCreateTime().getTime();