Forráskód Böngészése

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

yeshijie 7 éve
szülő
commit
8b5ceac3a9
17 módosított fájl, 593 hozzáadás és 169 törlés
  1. 37 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/gateway/GcHttpLog.java
  2. 13 24
      common/common-entity/src/main/java/com/yihu/wlyy/entity/gateway/GcToken.java
  3. 85 79
      common/common-entity/src/main/java/com/yihu/wlyy/entity/gateway/GcTokenLog.java
  4. 88 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/GateWayInterceptor.java
  5. 3 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/gateway/GcClientDetailsDao.java
  6. 21 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/gateway/GcTokenDao.java
  7. 4 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  8. 5 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/gateway/GcClientDetailsService.java
  9. 69 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/gateway/GcTokenService.java
  10. 148 44
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/pc/prescription/PrescriptionExpressagePCService.java
  11. 7 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescriptionPC/PrescriptionExpressagePCController.java
  12. 45 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/controller/GcTokenController.java
  13. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/vo/DoctorModel.java
  14. 43 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/vo/GcTokenModel.java
  15. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/vo/HospitalModel.java
  16. 2 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/vo/PatientModel.java
  17. 21 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/vo/base/BaseResultModel.java

+ 37 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/gateway/GcHttpLog.java

@ -28,6 +28,8 @@ public class GcHttpLog extends IdEntity implements java.io.Serializable {
    private String input;
    private String output;
    private Date createTime;
    private Integer flag = 1;
    private String message;
    // Constructors
@ -106,4 +108,39 @@ public class GcHttpLog extends IdEntity implements java.io.Serializable {
        this.createTime = createTime;
    }
    public Integer getFlag() {
        return flag;
    }
    public void setFlag(Integer flag) {
        this.flag = flag;
    }
    public String getMessage() {
        return message;
    }
    public void setMessage(String message) {
        this.message = message;
    }
    public enum flagEm {
        success(1),
        error(1)
        ;
        flagEm(Integer code) {
            this.code = code;
        }
        private Integer code;
        public Integer getCode() {
            return code;
        }
        public void setCode(Integer code) {
            this.code = code;
        }
    }
}

+ 13 - 24
common/common-entity/src/main/java/com/yihu/wlyy/entity/gateway/GcToken.java

@ -1,27 +1,28 @@
package com.yihu.wlyy.entity.gateway;
import java.sql.Timestamp;
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;
/**
 * GtToken entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "gt_token")
public class GcToken implements java.io.Serializable {
@Table(name = "gc_token")
public class GcToken extends IdEntity implements java.io.Serializable {
	// Fields
	private Integer id;
	private String appid;
	private String token;
	private Timestamp createTime;
	private Timestamp outTime;
	private Date createTime;
	private Date outTime;
	private Integer del;
	// Constructors
@ -31,8 +32,8 @@ public class GcToken implements java.io.Serializable {
	}
	/** full constructor */
	public GcToken(String appid, String token, Timestamp createTime,
			Timestamp outTime, Integer del) {
	public GcToken(String appid, String token, Date createTime,
			Date outTime, Integer del) {
		this.appid = appid;
		this.token = token;
		this.createTime = createTime;
@ -40,18 +41,6 @@ public class GcToken implements java.io.Serializable {
		this.del = del;
	}
	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "appid", length = 200)
	public String getAppid() {
		return this.appid;
@ -71,20 +60,20 @@ public class GcToken implements java.io.Serializable {
	}
	@Column(name = "create_time", length = 0)
	public Timestamp getCreateTime() {
	public Date getCreateTime() {
		return this.createTime;
	}
	public void setCreateTime(Timestamp createTime) {
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	@Column(name = "out_time", length = 0)
	public Timestamp getOutTime() {
	public Date getOutTime() {
		return this.outTime;
	}
	public void setOutTime(Timestamp outTime) {
	public void setOutTime(Date outTime) {
		this.outTime = outTime;
	}

+ 85 - 79
common/common-entity/src/main/java/com/yihu/wlyy/entity/gateway/GcTokenLog.java

@ -7,7 +7,9 @@ import java.util.Date;
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;
@ -18,84 +20,88 @@ import javax.persistence.Table;
@Table(name = "gc_token_log")
public class GcTokenLog extends IdEntity implements java.io.Serializable {
	// Fields
	private String ip;
	private String appIp;
	private Integer tokenId;
	private Integer flag;
	private String message;
	private Date createTime;
	// Constructors
	/** default constructor */
	public GcTokenLog() {
	}
	/** full constructor */
	public GcTokenLog(String ip, String appIp, Integer tokenId, Integer flag,
			String message, Timestamp createTime) {
		this.ip = ip;
		this.appIp = appIp;
		this.tokenId = tokenId;
		this.flag = flag;
		this.message = message;
		this.createTime = createTime;
	}
	@Column(name = "ip")
	public String getIp() {
		return this.ip;
	}
	public void setIp(String ip) {
		this.ip = ip;
	}
	@Column(name = "app_ip")
	public String getAppIp() {
		return this.appIp;
	}
	public void setAppIp(String appIp) {
		this.appIp = appIp;
	}
	@Column(name = "token_id")
	public Integer getTokenId() {
		return this.tokenId;
	}
	public void setTokenId(Integer tokenId) {
		this.tokenId = tokenId;
	}
	@Column(name = "flag")
	public Integer getFlag() {
		return this.flag;
	}
	public void setFlag(Integer flag) {
		this.flag = flag;
	}
	@Column(name = "message", length = 2000)
	public String getMessage() {
		return this.message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	@Column(name = "create_time", length = 0)
	public Date getCreateTime() {
		return this.createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
    // Fields
    private String ip;
    private String appIp;
    private String token;
    private Integer flag; //获取1 成功 0失败
    private String message;
    private Date createTime;
    // Constructors
    /**
     * default constructor
     */
    public GcTokenLog() {
    }
    /**
     * full constructor
     */
    public GcTokenLog(String ip, String appIp, String tokenId, Integer flag,
                      String message, Timestamp createTime) {
        this.ip = ip;
        this.appIp = appIp;
        this.flag = flag;
        this.message = message;
        this.createTime = createTime;
    }
    @Column(name = "ip")
    public String getIp() {
        return this.ip;
    }
    public void setIp(String ip) {
        this.ip = ip;
    }
    @Column(name = "app_ip")
    public String getAppIp() {
        return this.appIp;
    }
    public void setAppIp(String appIp) {
        this.appIp = appIp;
    }
    @Column(name = "token")
    public String getToken() {
        return token;
    }
    public void setToken(String token) {
        this.token = token;
    }
    @Column(name = "flag")
    public Integer getFlag() {
        return this.flag;
    }
    public void setFlag(Integer flag) {
        this.flag = flag;
    }
    @Column(name = "message", length = 2000)
    public String getMessage() {
        return this.message;
    }
    public void setMessage(String message) {
        this.message = message;
    }
    @Column(name = "create_time", length = 0)
    public Date getCreateTime() {
        return this.createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

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

@ -4,16 +4,25 @@ package com.yihu.wlyy.interceptors;
 * Created by chenweida on 2017/8/17.
 */
import com.yihu.wlyy.entity.gateway.GcHttpLog;
import com.yihu.wlyy.entity.gateway.GcToken;
import com.yihu.wlyy.repository.gateway.GcHttpLogDao;
import com.yihu.wlyy.repository.gateway.GcTokenDao;
import com.yihu.wlyy.util.NetworkUtil;
import com.yihu.wlyy.web.gateway.vo.base.BaseResultModel;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
/**
 * 对外的请求拦截
@ -24,20 +33,96 @@ public class GateWayInterceptor extends BaseInterceptor {
    private Logger logger = LoggerFactory.getLogger(GateWayInterceptor.class);
    @Autowired
    private GcHttpLogDao httpLogDao;
    @Autowired
    private GcTokenDao tokenDao;
    /**
     * preHandle:预处理回调方法
     *
     * @param request
     * @param response
     * @param handler
     * @return
     * @throws Exception
     */
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        return false;
        String token = request.getParameter("token");
        String ip = NetworkUtil.getIpAddress(request);
        try {
            GcToken gcToken = tokenDao.findByToken(token);
            if (gcToken == null) {
                saveHttpLog(ip, JSONObject.fromObject(request.getParameterMap()).toString(), null, token, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), BaseResultModel.codeEm.token_no_power.getMessage());
                //没权限
                BaseResultModel baseResultModel = new BaseResultModel(BaseResultModel.codeEm.token_no_power.getCode(), BaseResultModel.codeEm.token_no_power.getMessage());
                response.getOutputStream().write(JSONObject.fromObject(baseResultModel).toString().getBytes());
            }
            if (gcToken.getDel() == null || gcToken.getDel() == 0) {
                saveHttpLog(ip, JSONObject.fromObject(request.getParameterMap()).toString(), null, token, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), BaseResultModel.codeEm.token_out_effect.getMessage());
                //token无效
                BaseResultModel baseResultModel = new BaseResultModel(BaseResultModel.codeEm.token_out_effect.getCode(), BaseResultModel.codeEm.token_out_effect.getMessage());
                response.getOutputStream().write(JSONObject.fromObject(baseResultModel).toString().getBytes());
            }
            if (System.currentTimeMillis() > gcToken.getOutTime().getTime()) {
                saveHttpLog(ip, JSONObject.fromObject(request.getParameterMap()).toString(), null, token, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), BaseResultModel.codeEm.token_out_time.getMessage());
                //token过期
                BaseResultModel baseResultModel = new BaseResultModel(BaseResultModel.codeEm.token_out_time.getCode(), BaseResultModel.codeEm.token_out_time.getMessage());
                response.getOutputStream().write(JSONObject.fromObject(baseResultModel).toString().getBytes());
            }
        } catch (Exception e) {
            saveHttpLog(ip, JSONObject.fromObject(request.getParameterMap()).toString(), null, token, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), e.getMessage());
            return false;
        }
        return true;
    }
    /**
     * 后处理回调方法
     *
     * @param request
     * @param response
     * @param handler
     * @param modelAndView
     * @throws Exception
     */
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        HandlerMethod handlerMethod = (HandlerMethod) handler;
        //保存成功之后的日志
        String token = request.getParameter("token");
        String ip = NetworkUtil.getIpAddress(request);
        saveHttpLog(ip,
                JSONObject.fromObject(request.getParameterMap()).toString(),
                JSONObject.fromObject(modelAndView.getModelMap()).toString(),
                token,
                request.getRequestURI(),
                GcHttpLog.flagEm.success.getCode(),
                null);
    }
    /**
     * 整个请求处理完毕回调方法
     *
     * @param request
     * @param response
     * @param handler
     * @param ex
     * @throws Exception
     */
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
    }
    @Transactional
    public void saveHttpLog(String ip, String input, String output, String token, String method, Integer flag, String message) {
        GcHttpLog gcHttpLog = new GcHttpLog();
        gcHttpLog.setCreateTime(new Date());
        gcHttpLog.setIp(ip);
        gcHttpLog.setInput(input);
        gcHttpLog.setOutput(output);
        gcHttpLog.setToken(token);
        gcHttpLog.setMethod(method);
        gcHttpLog.setFlag(flag);
        httpLogDao.save(gcHttpLog);
    }
}

+ 3 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/gateway/GcClientDetailsDao.java

@ -2,10 +2,13 @@ package com.yihu.wlyy.repository.gateway;
import com.yihu.wlyy.entity.gateway.GcClientDetails;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/8/17.
 */
public interface GcClientDetailsDao extends PagingAndSortingRepository<GcClientDetails, Long>, JpaSpecificationExecutor<GcClientDetails> {
    @Query("from GcClientDetails where appId=?1 and del=1")
    GcClientDetails findByAppid(String appid);
}

+ 21 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/gateway/GcTokenDao.java

@ -0,0 +1,21 @@
package com.yihu.wlyy.repository.gateway;
import com.yihu.wlyy.entity.gateway.GcClientDetails;
import com.yihu.wlyy.entity.gateway.GcToken;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/8/17.
 */
public interface GcTokenDao extends PagingAndSortingRepository<GcToken, Long>, JpaSpecificationExecutor<GcToken> {
    @Query("update GcToken g set g.del=0 where g.appid=?1 and g.del=1")
    @Modifying
    void updateDel(String appid);
    @Query("from GcToken where token=?1")
    GcToken findByToken(String token);
}

+ 4 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -393,7 +393,7 @@ public class PrescriptionInfoService extends BaseService {
                prescriptionDao.save(p);
                //审核通过模板消息
                sendRMess(code, 1);
                sendRMess(p.getCode(), 1);
                //修改系统的续方消息的审核状态
                messageDao.updatePreScriptionMessage(p.getConsult(), "1", 6);
@ -407,7 +407,7 @@ public class PrescriptionInfoService extends BaseService {
                p.setPrescribeTime(new Date());
                prescriptionDao.save(p);
                //审核不通过模板消息
                sendRMess(code, 0);
                sendRMess(p.getCode(), 0);
                return 0;
            }
        }
@ -1171,8 +1171,8 @@ public class PrescriptionInfoService extends BaseService {
    }
    public JSONArray getPhysicMinDose(String code) {
        StringBuffer sql = new StringBuffer("SELECT t.min_dose AS minDose,t.physicCode FROM zy_iv_physic_dict t WHERE t.physic_code = ?");
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql.toString());
        StringBuffer sql = new StringBuffer("SELECT t.min_dose AS minDose,t.physic_code AS physicCode FROM zy_iv_physic_dict t WHERE t.physic_code = ?");
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql.toString(),new Object[]{code});
        return new JSONArray(rs);
    }
}

+ 5 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/gateway/GcClientDetailsService.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.service.gateway;
import com.yihu.wlyy.entity.gateway.GcClientDetails;
import com.yihu.wlyy.repository.gateway.GcClientDetailsDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -11,4 +12,8 @@ import org.springframework.stereotype.Service;
public class GcClientDetailsService {
    @Autowired
    private GcClientDetailsDao gtClientDetailsDao;
    public GcClientDetails findByAppId(String appid) {
        return gtClientDetailsDao.findByAppid(appid);
    }
}

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

@ -1,8 +1,16 @@
package com.yihu.wlyy.service.gateway;
import com.yihu.wlyy.entity.gateway.GcToken;
import com.yihu.wlyy.entity.gateway.GcTokenLog;
import com.yihu.wlyy.repository.gateway.GcTokenDao;
import com.yihu.wlyy.repository.gateway.GcTokenLogDao;
import com.yihu.wlyy.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.UUID;
/**
 * Created by chenweida on 2017/8/17.
@ -11,4 +19,65 @@ import org.springframework.stereotype.Service;
public class GcTokenService {
    @Autowired
    private GcTokenLogDao tokenLogDao;
    @Autowired
    private GcTokenDao tokenDao;
    /**
     * 根据appid生成token
     *
     * @param appid
     * @param appSecret
     * @return
     */
    @Transactional
    public GcToken createToken(String appid, String appSecret, String ip) {
        try {
            //把该用户之前有效的token设置为无效
            tokenDao.updateDel(appid);
            //创新新的appId
            Date date = new Date();
            String token = UUID.randomUUID().toString();
            GcToken gc = new GcToken();
            gc.setAppid(appid);
            gc.setCreateTime(date);
            //2小时过期
            gc.setOutTime(DateUtil.getNextMin(date, 120));
            gc.setToken(token);
            gc.setDel(1);
            tokenDao.save(gc);
            //保存日志
            GcTokenLog gcTokenLog = new GcTokenLog();
            gcTokenLog.setAppIp(appid);
            gcTokenLog.setCreateTime(new Date());
            gcTokenLog.setAppIp(ip);
            gcTokenLog.setMessage("创建token");
            gcTokenLog.setToken(token);
            gcTokenLog.setFlag(1);
            tokenLogDao.save(gcTokenLog);
            return gc;
        } catch (Exception e) {
            //保存失败日志
            GcTokenLog gcTokenLog = new GcTokenLog();
            gcTokenLog.setAppIp(appid);
            gcTokenLog.setCreateTime(new Date());
            gcTokenLog.setAppIp(ip);
            gcTokenLog.setMessage("创建token");
            gcTokenLog.setFlag(0);
            tokenLogDao.save(gcTokenLog);
        }
        return null;
    }
    /**
     * 根据token获取GcToken对象
     * @param token
     * @return
     */
    public GcToken getToken(String token) {
        return tokenDao.findByToken(token);
    }
}

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

@ -11,8 +11,10 @@ import com.yihu.wlyy.repository.prescription.*;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.prescription.PrescriptionExpressageService;
import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
import com.yihu.wlyy.service.app.prescription.PrescriptionNoticesService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.RoleService;
import com.yihu.wlyy.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@ -49,13 +51,12 @@ public class PrescriptionExpressagePCService extends BaseService {
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private PrescriptionExpressageService prescriptionExpressageService;
    private PrescriptionNoticesService prescriptionNoticesService;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private DoctorDao doctorDao;
    @Transactional
    public JSONObject getMedicine(String code,String userCode) throws Exception{
        JSONObject jsonObject = new JSONObject();
@ -155,6 +156,7 @@ public class PrescriptionExpressagePCService extends BaseService {
                        break;
                    }
                    default:{
                        jsonObject.put("status",-3);
                        PrescriptionLog prescriptionLog = new PrescriptionLog();
                        prescriptionLog.setCode(UUID.randomUUID().toString());
                        prescriptionLog.setPrescriptionCode(result.get("prescriptionCode").toString());
@ -183,6 +185,7 @@ public class PrescriptionExpressagePCService extends BaseService {
                prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
                prescriptionLog.setRemark("PC端取药码输入错误!");
                prescriptionLogDao.save(prescriptionLog);
            }
            return jsonObject;
@ -196,57 +199,158 @@ public class PrescriptionExpressagePCService extends BaseService {
        //更新二维码(isUse)
        PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeDao.finByCode(code);
        prescriptionDispensaryCode.setIsUse(1);
        prescriptionDispensaryCodeDao.save(prescriptionDispensaryCode);
        //更新处方状态
        //判断二维码是居民取药码还是健管师取药码
//        prescriptionDispensaryCode.setIsUse(1);
//        prescriptionDispensaryCodeDao.save(prescriptionDispensaryCode);
//        //更新处方状态
//        //判断二维码是居民取药码还是健管师取药码
        Prescription prescription =  prescriptionDao.findByCode(prescriptionDispensaryCode.getPrescriptionCode());
        if(prescriptionDispensaryCode.getType()==1){//居民取药码
//        if(prescriptionDispensaryCode.getType()==1){//居民取药码
//
//            prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
//        }else if(prescriptionDispensaryCode.getType()==2){
//            prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
//        }
//        prescriptionDao.save(prescription);
//
//        //处方日志
//        PrescriptionLog prescriptionLog = new PrescriptionLog();
//        prescriptionLog.setCode(UUID.randomUUID().toString());
//        prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
//        prescriptionLog.setCreateTime(new Date());
//        PrescriptionExpressage prescriptionExpressage = prescriptionExpressageDao.findByPrescriptionCode("e707487f063540e1b6d581b16bb8fb12");
//        if(prescriptionDispensaryCode.getType()==1){//居民取药码
//
//            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
//            prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.finish.getValue());
//            prescriptionLog.setUserCode(prescription.getPatient());
//            prescriptionLog.setUserName(prescription.getPatientName());
//            prescriptionLog.setUserType(1);
//        }else if(prescriptionDispensaryCode.getType()==2){
//            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
//            prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
//            prescriptionLog.setUserCode(prescriptionExpressage.getExpressageCode());
//            prescriptionLog.setUserName(prescriptionExpressage.getExpressageName());
//            prescriptionLog.setUserType(2);
//            //发送模板消息通知患者药品开始配送
//
//        }
//        prescriptionLog.setFlag(1);
//        prescriptionLog.setHospital(prescriptionExpressage.getHospitalCode());
//        prescriptionLog.setHospitalName(prescriptionExpressage.getHospitalName());
//        prescriptionLogDao.save(prescriptionLog);
////        prescriptionLog.setType();
////        prescriptionLogDao
//        if(prescriptionDispensaryCode.getType()==2){
//            Patient patient = patientDao.findByCode(prescription.getPatient());
//            String url="prescription/html/order_tracking.html?openid=" + patient.getOpenid() + "" +
//                    "&code=" + prescriptionDispensaryCode.getPrescriptionCode() + "&toUser=" + patient.getCode() + "&toName=" + patient.getName() ;
//        }
//        prescriptionExpressage.setExpressageTime(new Date());
//        Doctor doctor = doctorDao.findByCode(userCode);
//        prescriptionExpressage.setHospitalDoctorCode(userCode);
//        prescriptionExpressage.setHospitalDoctor(doctor.getName());
//        prescriptionExpressage.setFetchingMedicineTime(new Date());
//        prescriptionExpressageDao.save(prescriptionExpressage);
            prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
        }else if(prescriptionDispensaryCode.getType()==2){
            prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
        switch (prescriptionDispensaryCode.getType()) {
            case 1: {
                //判断是1 居民取药码
                dispensaryCode_1(userCode, prescriptionDispensaryCode);
                break;
            }
            case 2: {
                //判断是2 配送员(健管师)取药码
                dispensaryCode_2(userCode,prescription.getPatient(), prescriptionDispensaryCode);
                break;
            }
            default: {
                PrescriptionLog prescriptionLog = new PrescriptionLog();
                prescriptionLog.setCode(UUID.randomUUID().toString());
                prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
                prescriptionLog.setCreateTime(new Date());
                prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
                prescriptionLog.setFlag(1);
                prescriptionLog.setUserCode(userCode);
                prescriptionLog.setUserType(2);
                prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
                prescriptionLog.setRemark("编码类型错误");
                prescriptionLogDao.save(prescriptionLog);
            }
        }
        prescriptionDao.save(prescription);
    }
        //处方日志
    /**
     * 1 居民取药码 业务
     *
     * @param userCode
     * @param prescriptionDispensaryCode
     * @return
     */
    public void dispensaryCode_1(String userCode, PrescriptionDispensaryCode prescriptionDispensaryCode) {
        //修改处方状态为完成
        prescriptionDao.updateStatus(prescriptionDispensaryCode.getPrescriptionCode(), PrescriptionLog.PrescriptionLogStatus.finish.getValue());
        //保存配送成功的日志
        PrescriptionLog prescriptionLog = new PrescriptionLog();
        prescriptionLog.setCode(UUID.randomUUID().toString());
        prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
        prescriptionLog.setCode(UUID.randomUUID().toString());
        prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.finish.getValue());
        prescriptionLog.setCreateTime(new Date());
        PrescriptionExpressage prescriptionExpressage = prescriptionExpressageDao.findByPrescriptionCode("e707487f063540e1b6d581b16bb8fb12");
        if(prescriptionDispensaryCode.getType()==1){//居民取药码
            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
            prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.finish.getValue());
            prescriptionLog.setUserCode(prescription.getPatient());
            prescriptionLog.setUserName(prescription.getPatientName());
            prescriptionLog.setUserType(1);
        }else if(prescriptionDispensaryCode.getType()==2){
            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
            prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
            prescriptionLog.setUserCode(prescriptionExpressage.getExpressageCode());
            prescriptionLog.setUserName(prescriptionExpressage.getExpressageName());
            prescriptionLog.setUserType(2);
            //发送模板消息通知患者药品开始配送
        }
        prescriptionLog.setFlag(1);
        prescriptionLog.setHospital(prescriptionExpressage.getHospitalCode());
        prescriptionLog.setHospitalName(prescriptionExpressage.getHospitalName());
        prescriptionLog.setUserCode(userCode);
        prescriptionLog.setUserType(2);
        prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
        prescriptionLogDao.save(prescriptionLog);
//        prescriptionLog.setType();
//        prescriptionLogDao
        if(prescriptionDispensaryCode.getType()==2){
            Patient patient = patientDao.findByCode(prescription.getPatient());
            String url="prescription/html/order_tracking.html?openid=" + patient.getOpenid() + "" +
                    "&code=" + prescriptionDispensaryCode.getPrescriptionCode() + "&toUser=" + patient.getCode() + "&toName=" + patient.getName() ;
        }
        prescriptionExpressage.setExpressageTime(new Date());
        //修改取药码code为已经使用
        prescriptionDispensaryCode.setIsUse(1);
    }
    /**
     * 配送员(健管师)取药码 业务
     *
     * @param userCode
     * @param prescriptionDispensaryCode
     * @return
     */
    public void dispensaryCode_2(String userCode,String patientCode, PrescriptionDispensaryCode prescriptionDispensaryCode) throws Exception {
        //获取配送的医生信息
        Doctor doctor = doctorDao.findByCode(userCode);
        prescriptionExpressage.setHospitalDoctorCode(userCode);
        prescriptionExpressage.setHospitalDoctor(doctor.getName());
        prescriptionExpressage.setFetchingMedicineTime(new Date());
        prescriptionExpressageDao.save(prescriptionExpressage);
        //修改处方状态为配送中
        Prescription prescription = prescriptionDao.findByCode(prescriptionDispensaryCode.getPrescriptionCode());
        Date expressageing = new Date();
        prescription.setExpressageTime(expressageing);
        prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
        //得到patient
        Patient patient = patientDao.findByCode(prescription.getPatient());
        //保存配送成功的日志
        PrescriptionLog prescriptionLog = new PrescriptionLog();
        prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
        prescriptionLog.setCode(UUID.randomUUID().toString());
        prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
        prescriptionLog.setCreateTime(new Date());
        prescriptionLog.setFlag(1);
        prescriptionLog.setUserCode(userCode);
        prescriptionLog.setUserName(doctor.getName());
        prescriptionLog.setUserType(2);
        prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
        prescriptionLogDao.save(prescriptionLog);
        //修改取药码code为已经使用
        prescriptionDispensaryCode.setIsUse(1);
        //发送模板消息通知患者药品开始配送
        String url = "prescription/html/order_tracking.html?openid=" + patient.getOpenid() + "" +
                "&code=" + prescriptionDispensaryCode.getPrescriptionCode() + "&toUser=" + patient.getCode() + "&toName=" + patient.getName();
        prescriptionNoticesService.sendMessages(patientCode, doctor.getName(), DateUtil.dateToStrLong(expressageing), 3, 0, url);
    }
}

+ 7 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescriptionPC/PrescriptionExpressagePCController.java

@ -29,6 +29,10 @@ public class PrescriptionExpressagePCController extends BaseController {
        try{
            JSONObject jSONObject = prescriptionExpressagePCService.getMedicine(code,getUID());
//            jSONObject.toString().replace("\\","");
            Integer status = jSONObject.getInteger("status");
            if(status==-3||status==-100){
                return error(-1, "获取信息失败!");
            }
            return write(200, "获取信息成功!", "data", jSONObject);
        }catch (Exception e) {
            error(e);
@ -41,11 +45,11 @@ public class PrescriptionExpressagePCController extends BaseController {
    public String fetchingMedicine(
            @ApiParam(required = true, name = "code", value = "二维码(居民取药码、健管师取药码)") @RequestParam(value = "code", required = true) String code){
        try {
            prescriptionExpressagePCService.fetchingMedicine(code, getUID());
            return write(200, "更改成功!");
            prescriptionExpressagePCService.fetchingMedicine(code, getUID());//xh1D2017031503333
            return write(200, "操作成功!");
        }catch (Exception e) {
            error(e);
            return error(-1, "更改失败!");
            return error(-1, "操作失败!");
        }
    }
}

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

@ -1,14 +1,27 @@
package com.yihu.wlyy.web.gateway.controller;
import com.fasterxml.jackson.databind.deser.Deserializers;
import com.yihu.wlyy.entity.gateway.GcClientDetails;
import com.yihu.wlyy.entity.gateway.GcToken;
import com.yihu.wlyy.service.gateway.GcClientDetailsService;
import com.yihu.wlyy.service.gateway.GcTokenService;
import com.yihu.wlyy.util.NetworkUtil;
import com.yihu.wlyy.web.gateway.vo.GcTokenModel;
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.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
/**
 * Created by chenweida on 2017/8/17.
 * 对外的网关
@ -17,13 +30,41 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/wlyygc")
@Api(description = "token相关服务")
public class GcTokenController {
    @Autowired
    private GcTokenService tokenService;
    @Autowired
    private GcClientDetailsService clientDetailsService;
    @ApiOperation("获取token")
    @RequestMapping(value = "token", method = RequestMethod.GET)
    public ResultOneModel getToken(
    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) {
        return null;
            @ApiParam(name = "appSecret", value = "appSecret", required = true) @RequestParam(required = true, value = "appSecret") String appSecret,
            HttpServletRequest request) {
        //得到用户
        GcClientDetails clientDetails = clientDetailsService.findByAppId(appid);
        if (clientDetails == null) {
            ResultOneModel resultOneModel = new ResultOneModel(null);
            resultOneModel.setCode(BaseResultModel.codeEm.error_Appid.getCode());
            resultOneModel.setMessage(BaseResultModel.codeEm.error_Appid.getMessage());
            return resultOneModel;
        }
        //判断appSecret
        if (appSecret.equals(clientDetails.getAppSecret())) {
            ResultOneModel resultOneModel = new ResultOneModel(null);
            resultOneModel.setCode(BaseResultModel.codeEm.error_AppSecret.getCode());
            resultOneModel.setMessage(BaseResultModel.codeEm.error_AppSecret.getMessage());
            return resultOneModel;
        }
        //生成token
        GcToken gcToken = null;
        try {
            gcToken = tokenService.createToken(appid, appSecret, NetworkUtil.getIpAddress(request));
        } catch (IOException e) {
            e.printStackTrace();
        }
        GcTokenModel gcTokenModel = new GcTokenModel();
        BeanUtils.copyProperties(gcToken, gcTokenModel);
        return new ResultOneModel(gcTokenModel);
    }
}

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

@ -9,7 +9,7 @@ import java.util.Date;
/**
 * Created by chenweida on 2017/8/17.
 */
@ApiModel("医生实体")
@ApiModel(description ="医生实体")
public class DoctorModel {
    @ApiModelProperty(value = "主键", required = false, access = "response")

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

@ -0,0 +1,43 @@
package com.yihu.wlyy.web.gateway.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * Created by chenweida on 2017/8/17.
 */
@ApiModel(description = "")
public class GcTokenModel {
    @ApiModelProperty(value = "请求凭证", required = false, access = "response")
    private String token;
    @ApiModelProperty(value = "创建时间", required = false, access = "response")
    private Date createTime;
    @ApiModelProperty(value = "过期时间", required = false, access = "response")
    private Date outTime;
    public String getToken() {
        return token;
    }
    public void setToken(String token) {
        this.token = token;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getOutTime() {
        return outTime;
    }
    public void setOutTime(Date outTime) {
        this.outTime = outTime;
    }
}

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

@ -6,7 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
/**
 * Created by chenweida on 2017/8/17.
 */
@ApiModel("医生实体")
@ApiModel(description ="医生实体")
public class HospitalModel {
    @ApiModelProperty(value = "医院編碼", required = false, access = "response")

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

@ -1,6 +1,7 @@
package com.yihu.wlyy.web.gateway.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
@ -8,6 +9,7 @@ import java.util.Date;
/**
 * Created by chenweida on 2017/8/17.
 */
@ApiModel(description ="患者实体")
public class PatientModel {
    // 业务主键
    @ApiModelProperty(value = "业务主键", required = false, access = "response")

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

@ -30,18 +30,23 @@ public class BaseResultModel {
    }
    public enum codeEm {
        success(10000),//请求成功
        error_params(-10000),//请求失败 参数错误
        error_no_ip(-10010),//请求失败,获取IP失败
        token_outEffect(997),//token无效  包括过期
        token_no_power(999)// 没权限 包括未授权 或者uri错误
        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无效
        ;
        codeEm(Integer code) {
        codeEm(Integer code, String message) {
            this.code = code;
            this.message = message;
        }
        private Integer code;
        private String message;
        public Integer getCode() {
            return code;
@ -50,6 +55,14 @@ public class BaseResultModel {
        public void setCode(Integer code) {
            this.code = code;
        }
        public String getMessage() {
            return message;
        }
        public void setMessage(String message) {
            this.message = message;
        }
    }
    public BaseResultModel() {
@ -63,4 +76,6 @@ public class BaseResultModel {
        this.code = code;
        this.message = message;
    }
}