Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

huangwenjie 4 years ago
parent
commit
461b37faa0
33 changed files with 1634 additions and 84 deletions
  1. 126 45
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  2. 2 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/XzzxEntranceService.java
  3. 22 5
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java
  4. 1 0
      business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java
  5. 14 3
      business/base-service/src/main/java/com/yihu/jw/order/pay/ylz/YlzPayService.java
  6. 2 0
      business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java
  7. 160 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/gateway/GcClientDetails.java
  8. 139 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/gateway/GcHttpLog.java
  9. 89 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/gateway/GcToken.java
  10. 101 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/gateway/GcTokenLog.java
  11. 38 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/gateway/IdEntity.java
  12. 10 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/iot/IotRequestMapping.java
  13. 15 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyPrescriptionVO.java
  14. 46 0
      common/common-util/src/main/java/com/yihu/jw/util/common/IpUtil.java
  15. 11 1
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/UnSettledHISPrescriptionService.java
  16. 1 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  17. 9 22
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/YkyyPrescriptionEndpoint.java
  18. 34 0
      svr/svr-iot/src/main/java/com/yihu/iot/config/MvcConfig.java
  19. 139 0
      svr/svr-iot/src/main/java/com/yihu/iot/controller/gateway/GcTokenController.java
  20. 76 0
      svr/svr-iot/src/main/java/com/yihu/iot/controller/third/ThirdDataInputController.java
  21. 14 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/gateway/GcClientDetailsDao.java
  22. 11 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/gateway/GcHttpLogDao.java
  23. 25 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/gateway/GcTokenDao.java
  24. 11 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/gateway/GcTokenLogDao.java
  25. 8 7
      svr/svr-iot/src/main/java/com/yihu/iot/datainput/controller/DataInputController.java
  26. 164 0
      svr/svr-iot/src/main/java/com/yihu/iot/interceptor/GateWayInterceptor.java
  27. 98 0
      svr/svr-iot/src/main/java/com/yihu/iot/model/BaseResultModel.java
  28. 33 0
      svr/svr-iot/src/main/java/com/yihu/iot/model/GcClientDetailsModel.java
  29. 51 0
      svr/svr-iot/src/main/java/com/yihu/iot/model/GcTokenModel.java
  30. 39 0
      svr/svr-iot/src/main/java/com/yihu/iot/model/ResultOneModel.java
  31. 39 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/gateway/GcClientDetailsService.java
  32. 101 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/gateway/GcTokenService.java
  33. 5 0
      svr/svr-iot/src/main/resources/application.yml

+ 126 - 45
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -15,8 +15,7 @@ import com.yihu.jw.entity.base.org.BaseDoctorPatientFollowDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.entity.base.wx.*;
import com.yihu.jw.entity.hospital.consult.WlyyDoctorClinicRoomDO;
import com.yihu.jw.entity.hospital.consult.WlyyDoctorClinicRoomDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO;
@ -72,11 +71,15 @@ import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.common.LatitudeUtils;
import com.yihu.jw.util.common.LatitudeUtils;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.WebserviceUtil;
import com.yihu.jw.utils.WebserviceUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WechatDao;
import com.yihu.jw.wechat.dao.WechatDao;
import com.yihu.jw.wechat.dao.WxPushLogDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import com.yihu.utils.security.MD5;
import com.ylzinfo.ehc.EhcHandler;
import com.ylzinfo.ehc.EhcHandler;
@ -94,6 +97,7 @@ import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.jsoup.select.Elements;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
@ -224,6 +228,16 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    private WechatDao wechatDao;
    private WechatDao wechatDao;
    @Autowired
    @Autowired
    private BasePatientWechatDao patientWechatDao;
    private BasePatientWechatDao patientWechatDao;
    @Autowired
    private WxTemplateConfigDao wxTemplateConfigDao;
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    @Autowired
    private WeixinMessagePushUtils weixinMessagePushUtils;
    @Autowired
    private BasePatientWechatDao basePatientWechatDao;
    @Autowired
    private WxPushLogDao wxPushLogDao;
    @Value("${demo.flag}")
    @Value("${demo.flag}")
@ -431,7 +445,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param outpatientId
     * @param outpatientId
     * @return
     * @return
     */
     */
    public com.alibaba.fastjson.JSONObject findReOutpatientInfo(String outpatientId,String prescriptionId) throws Exception {
    public com.alibaba.fastjson.JSONObject findReOutpatientInfo(String outpatientId,String prescriptionId,String wxId) throws Exception {
        com.alibaba.fastjson.JSONObject rs = new com.alibaba.fastjson.JSONObject();
        com.alibaba.fastjson.JSONObject rs = new com.alibaba.fastjson.JSONObject();
        //复诊信息
        //复诊信息
@ -452,6 +466,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        rs.put("mobile",basePatientDO.getMobile());
        rs.put("mobile",basePatientDO.getMobile());
        rs.put("birthday",DateUtil.dateToStr(basePatientDO.getBirthday(),"yyyy-MM-dd"));
        rs.put("birthday",DateUtil.dateToStr(basePatientDO.getBirthday(),"yyyy-MM-dd"));
        Long time = new Date().getTime()-outpatientDO.getCreateTime().getTime();
        rs.put("time",time);
        //获取处方信息
        //获取处方信息
        List<WlyyPrescriptionDO> prescriptionDOs = null;
        List<WlyyPrescriptionDO> prescriptionDOs = null;
@ -476,9 +492,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                List<WlyyInspectionVO> inspectionVOs = new ArrayList<>();
                List<WlyyInspectionVO> inspectionVOs = new ArrayList<>();
                vo.setInspectionVOs(convertToModels(wlyyInspectionDao.findByPrescriptionId(vo.getId(),1),inspectionVOs,WlyyInspectionVO.class));
                vo.setInspectionVOs(convertToModels(wlyyInspectionDao.findByPrescriptionId(vo.getId(),1),inspectionVOs,WlyyInspectionVO.class));
                WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO = readOutPatientXml(outpatientDO.getOriginRegisterNo());
                //电子病历
                vo.setWlyyPrescriptionEmrDO(wlyyPrescriptionEmrDO);
                if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
                    WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO1 = prescriptionEmrDao.findEmrByPrescriptionId(vo.getId());
                    if (wlyyPrescriptionEmrDO1!=null){
                        vo.setWlyyPrescriptionEmrDO(wlyyPrescriptionEmrDO1);
                    }else {
                        WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO = readOutPatientXml(outpatientDO.getOriginRegisterNo());
                        //电子病历
                        vo.setWlyyPrescriptionEmrDO(wlyyPrescriptionEmrDO);
                    }
                }
            }
            }
        }
        }
        rs.put("prescriptions",prescriptionVOs);
        rs.put("prescriptions",prescriptionVOs);
@ -3257,10 +3281,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())){
                if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())){
                    data.put("type","9");
                    data.put("type","9");
                   msg+=wlyyOutpatientDO.getPatientName()+",您好! 您有一个图文复诊已被医生取消,取消原因:"+cancelValue+"。取消说明:"+cancelRemark+"。";
                   msg+=wlyyOutpatientDO.getPatientName()+",您好! 您有一个图文复诊已被医生取消,取消原因:"+cancelValue+"。取消说明:"+cancelRemark+"。";
//                   sendWxTemplateMsg(wechatId,wlyyOutpatientDO,"9");
                }
                }
                if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())){
                if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())){
                    data.put("type","16");
                    data.put("type","16");
                    msg+=wlyyOutpatientDO.getPatientName()+",您好! 您有一个视频复诊已被医生取消,取消原因:"+cancelValue+"。取消说明:"+cancelRemark+"。";
                    msg+=wlyyOutpatientDO.getPatientName()+",您好! 您有一个视频复诊已被医生取消,取消原因:"+cancelValue+"。取消说明:"+cancelRemark+"。";
//                    sendWxTemplateMsg(wechatId,wlyyOutpatientDO,"16");
                }
                }
                data.put("msg",msg);
                data.put("msg",msg);
                messageDO.setData(data.toString());
                messageDO.setData(data.toString());
@ -3299,6 +3325,53 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        return  rs;
        return  rs;
    }
    }
    /**
     * 发送微信模板消息  本地无法测试消息是否发送成功
     * @param wxId
     * @param outpatientDO
     * @param type
     */
    public void sendWxTemplateMsg(String wxId,WlyyOutpatientDO outpatientDO,String type){
        List<BasePatientWechatDo> ps = basePatientWechatDao.findByWechatIdAndPatientId(wxId, outpatientDO.getPatient());
        if(ps.isEmpty()){
            logger.info("该用户"+outpatientDO.getPatientName()+"没有openid,无法推送模版消息,用户ID:"+outpatientDO.getPatient()+"wechatId:"+wxId);
            return;
        }
        if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
            ps.stream().forEach(one->{
                BaseDoctorDO doctorDO = baseDoctorDao.findById(outpatientDO.getDoctor());
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId,"template_doctor_notice","ysqxjz",1);
                WxTemplateConfigDO newConfig = new WxTemplateConfigDO();
                BeanUtils.copyProperties(config,newConfig);
                newConfig.setFirst(config.getFirst().replace("key1",outpatientDO.getPatientName()));
                if ("9".equals(type)){
                    newConfig.setFirst(newConfig.getFirst().replace("key2","图文复诊"));
                }
                if ("16".equals(type)){
                    newConfig.setFirst(newConfig.getFirst().replace("key2","视频复诊"));
                }
                newConfig.setUrl(config.getUrl()+""+outpatientDO.getId());
                newConfig.setKeyword1(config.getKeyword1()+outpatientDO.getHospitalName());
                newConfig.setKeyword2(config.getKeyword2()+outpatientDO.getDoctorName());
                newConfig.setKeyword3(config.getKeyword3()+doctorDO.getFee());
                WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
                logger.info("=======setUrl========"+newConfig.getUrl());
                weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(),one.getOpenid(),newConfig);
                //保存发送模板记录,
                WxPushLogDO wxPushLogDO = new WxPushLogDO();
                wxPushLogDO.setCreateTime(new Date());
                wxPushLogDO.setOpenid(one.getOpenid());
                wxPushLogDO.setReceiver(outpatientDO.getPatient());
                wxPushLogDO.setWechatId(wechatId);
                wxPushLogDO.setReceiverName(outpatientDO.getPatientName());
                wxPushLogDO.setScene("ysqxjz");
                wxPushLogDao.save(wxPushLogDO);
            });
        }
    }
    public List<WlyyHospitalSysDictDO> findCancelReasonList(){
    public List<WlyyHospitalSysDictDO> findCancelReasonList(){
        return sysDictDao.findByDictName("PatientCancel");
        return sysDictDao.findByDictName("PatientCancel");
    }
    }
@ -4391,6 +4464,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        for (Map<String,Object> map:list){
        for (Map<String,Object> map:list){
            if (!map.get("id").toString().equalsIgnoreCase(outpatientId)){
            if (!map.get("id").toString().equalsIgnoreCase(outpatientId)){
                waitCount+=1;
                waitCount+=1;
            }else{
                break;
            }
            }
        }
        }
        return waitCount.toString();
        return waitCount.toString();
@ -4799,6 +4874,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     */
     */
    public SystemMessageDO sendOutPatientMes(WlyyOutpatientDO outpatient){
    public SystemMessageDO sendOutPatientMes(WlyyOutpatientDO outpatient){
        SystemMessageDO systemMessageDO = new SystemMessageDO();
        SystemMessageDO systemMessageDO = new SystemMessageDO();
        String msg="";
        JSONObject data = new JSONObject();
        try{
        try{
            //1.在线复诊2.协同门诊
            //1.在线复诊2.协同门诊
            if("2".equals(outpatient.getOutpatientType())){
            if("2".equals(outpatient.getOutpatientType())){
@ -4814,27 +4891,26 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    systemMessageDO.setTitle("视频复诊预约成功");
                    systemMessageDO.setTitle("视频复诊预约成功");
                    systemMessageDO.setType("2");
                    systemMessageDO.setType("2");
                    saveInquirySystemMessage(outpatient);
                    saveInquirySystemMessage(outpatient);
                    msg="您的视频复诊已预约成功。\n" +
                            "预计"+outpatient.getDoctorName()+"医生将于"+outpatient.getRegisterDate()+" 与您进行视频咨询。请留意系统消息或微信公众号消息。咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
                    systemMessageDO.setReceiver(outpatient.getDoctor());
                    systemMessageDO.setReceiverName(outpatient.getDoctorName());
                    systemMessageDO.setRelationCode(outpatient.getId());
                    systemMessageDO.setSender(outpatient.getPatient());
                    systemMessageDO.setSenderName(outpatient.getPatientName());
                    systemMessageDO.setRelationCode(outpatient.getId());
                    data.put("name",outpatient.getPatientName());
                    data.put("age",IdCardUtil.getAgeForIdcard(outpatient.getIdcard()));
                    data.put("gender",IdCardUtil.getSexForIdcard_new(outpatient.getIdcard()));
                    data.put("question",outpatient.getDescription());
                    data.put("msg",msg);
                    systemMessageDO.setData(data.toString());
                    systemMessageService.saveMessage(systemMessageDO);
                }
                }
            }
            }
            systemMessageDO.setReceiver(outpatient.getDoctor());
            systemMessageDO.setReceiverName(outpatient.getDoctorName());
            systemMessageDO.setRelationCode(outpatient.getId());
            systemMessageDO.setSender(outpatient.getPatient());
            systemMessageDO.setSenderName(outpatient.getPatientName());
            systemMessageDO.setRelationCode(outpatient.getId());
            JSONObject data = new JSONObject();
            data.put("name",outpatient.getPatientName());
            data.put("age",IdCardUtil.getAgeForIdcard(outpatient.getIdcard()));
            data.put("gender",IdCardUtil.getSexForIdcard_new(outpatient.getIdcard()));
            data.put("question",outpatient.getDescription());
            String msg="您的视频复诊已预约成功。\n" +
                    "预计"+outpatient.getDoctorName()+"医生将于"+outpatient.getRegisterDate()+" 与您进行视频咨询。请留意系统消息或微信公众号消息。咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
            data.put("msg",msg);
            systemMessageDO.setData(data.toString());
            systemMessageService.saveMessage(systemMessageDO);
            BasePatientDO patient = basePatientDao.findById(outpatient.getPatient());
            BasePatientDO patient = basePatientDao.findById(outpatient.getPatient());
            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
@ -5848,7 +5924,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    if (prescriptionEmrDO!=null){
                    if (prescriptionEmrDO!=null){
                        writeOutPatient(outpatientDO.getRegisterNo(),prescriptionEmrDO.getComplaint(),prescriptionEmrDO.getMedicalHistory(),prescriptionEmrDO.getPastHistory(),prescriptionEmrDO.getPhysicalExamination(),prescriptionEmrDO.getAssistExamination());
                        writeOutPatient(outpatientDO.getRegisterNo(),prescriptionEmrDO.getComplaint(),prescriptionEmrDO.getMedicalHistory(),prescriptionEmrDO.getPastHistory(),prescriptionEmrDO.getPhysicalExamination(),prescriptionEmrDO.getAssistExamination());
                    }
                    }
                    if (map.get("code").toString().equalsIgnoreCase("0")){
                    if (map.get("code").toString().equalsIgnoreCase("1")){
                        //  * @param applyDepaName @param applyDoctorName
                        //  * @param applyDepaName @param applyDoctorName
                        WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(prescriptionId);
                        WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(prescriptionId);
                        String patientCode = prescriptionDO.getPatientCode();
                        String patientCode = prescriptionDO.getPatientCode();
@ -5880,11 +5956,13 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                } catch (Exception e) {
                } catch (Exception e) {
                    e.printStackTrace();
                    e.printStackTrace();
                }
                }
            }
            }
            prescriptionLogService.addPrescriptionLog(prescriptionId,20,2,operate,operateName,reason,new Date());
            prescriptionLogService.addPrescriptionLog(prescriptionId,20,2,operate,operateName,reason,new Date());
            wlyyPrescriptionDO.setCheckStatus(2);
            wlyyPrescriptionDO.setCheckStatus(2);
            wlyyPrescriptionDO.setCheckReason(reason);
            wlyyPrescriptionDO.setCheckReason(reason);
            wlyyPrescriptionDO.setStatus(20);
            wlyyPrescriptionDO.setStatus(20);
            wlyyPrescriptionDO.setPrescribeTime(new Date());
            //发送系统消息 处方支付提醒
            //发送系统消息 处方支付提醒
            SystemMessageDO messageDO = new SystemMessageDO();
            SystemMessageDO messageDO = new SystemMessageDO();
@ -6525,40 +6603,43 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     */
     */
    public PageEnvelop findPatientAllPrescription(String keyName,String status,Integer page, Integer size) {
    public PageEnvelop findPatientAllPrescription(String keyName,String status,Integer page, Integer size) {
        String uid = userAgent.getUID();
        String uid = userAgent.getUID();
        StringBuffer sql = new StringBuffer("select a.* from wlyy_prescription a,wlyy_prescription_info b where a.patient_code ='");
        StringBuffer countSql = new StringBuffer("select COUNT(a.id) count from wlyy_prescription a,wlyy_prescription_info b  where a.patient_code ='");
        sql.append(uid).append("' and a.status >= 0 AND a.id = b.prescription_id");
        countSql.append(uid).append("' and a.status >= 0 AND a.id = b.prescription_id ");
        StringBuffer sql = new StringBuffer("SELECT b.*, c.oneself_pickup_flg FROM (SELECT a.* FROM wlyy_prescription a WHERE a.patient_code = '");
        StringBuffer countSql = new StringBuffer("select COUNT(b.id) count FROM (SELECT a.* FROM wlyy_prescription a WHERE a.patient_code = '");
        sql.append(uid).append("') b LEFT JOIN wlyy_prescription_info d ON b.id = d.prescription_id JOIN wlyy_prescription_expressage c ON c.outpatient_id = b.outpatient_id");
        countSql.append(uid).append("') b LEFT JOIN wlyy_prescription_info d ON b.id = d.prescription_id JOIN wlyy_prescription_expressage c ON c.outpatient_id = b.outpatient_id ");
        if (StringUtils.isNotEmpty(keyName)){
        if (StringUtils.isNotEmpty(keyName)){
            sql.append(" AND (" +
            sql.append(" AND (" +
                    " a.doctor_name LIKE '%"+keyName+"%' " +
                    " OR a.dept_name LIKE'%"+keyName+"%' " +
                    " OR a.hospital_name LIKE '%"+keyName+"%' " +
                    " OR b.drug_name LIKE '%"+keyName+"%' " +
                    " OR a.real_order LIKE '%"+keyName+"%' " +
                    " b.doctor_name LIKE '%"+keyName+"%' " +
                    " OR b.dept_name LIKE'%"+keyName+"%' " +
                    " OR b.hospital_name LIKE '%"+keyName+"%' " +
                    " OR d.drug_name LIKE '%"+keyName+"%' " +
                    " OR b.real_order LIKE '%"+keyName+"%' " +
                    ")");
                    ")");
            countSql.append(" AND (" +
            countSql.append(" AND (" +
                    " a.doctor_name LIKE '%"+keyName+"%' " +
                    " OR a.dept_name LIKE'%"+keyName+"%' " +
                    " OR a.hospital_name LIKE '%"+keyName+"%' " +
                    " OR b.drug_name LIKE '%"+keyName+"%' " +
                    " OR a.real_order LIKE '%"+keyName+"%' " +
                    " b.doctor_name LIKE '%"+keyName+"%' " +
                    " OR b.dept_name LIKE'%"+keyName+"%' " +
                    " OR b.hospital_name LIKE '%"+keyName+"%' " +
                    " OR d.drug_name LIKE '%"+keyName+"%' " +
                    " OR b.real_order LIKE '%"+keyName+"%' " +
                    ")");
                    ")");
        }
        }
        if (StringUtils.isNotEmpty(status)){
        if (StringUtils.isNotEmpty(status)){
            status= status.substring(1, status.length() - 1);
            status= status.substring(1, status.length() - 1);
            sql.append(" AND a.status IN(").append(status).append(")");
            countSql.append(" AND a.status IN(").append(status).append(")");
            sql.append(" AND b.status IN(").append(status).append(")");
            countSql.append(" AND b.status IN(").append(status).append(")");
        }else {
            sql.append("  and b.status IN(20,21,30,31,32,100,101)");
            countSql.append(" and b.status IN(20,21,30,31,32,100,101) ");
        }
        }
        sql.append(" order by a.prescribe_time limit ").append((page-1)*size).append(",").append(size);
        List<WlyyPrescriptionDO> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(WlyyPrescriptionDO.class));
        sql.append(" order by b.prescribe_time limit ").append((page-1)*size).append(",").append(size);
        List<WlyyPrescriptionVO> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(WlyyPrescriptionVO.class));
        List<Map<String, Object>> mapList = jdbcTemplate.queryForList(countSql.toString());
        List<Map<String, Object>> mapList = jdbcTemplate.queryForList(countSql.toString());
        long count = Long.parseLong(mapList.get(0).get("count").toString());
        long count = Long.parseLong(mapList.get(0).get("count").toString());
        logger.info("sql="+sql.toString());
        logger.info("sql="+sql.toString());
        logger.info("countSql="+countSql.toString());
        logger.info("countSql="+countSql.toString());
        return PageEnvelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find,list,page,size,count);
        return PageEnvelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find, list,page,size,count);
    }
    }

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/XzzxEntranceService.java

@ -1256,6 +1256,7 @@ public class XzzxEntranceService{
                outpatientVO.setDiseaseImg(isEmty(object.getString("DISEASEIMG")));
                outpatientVO.setDiseaseImg(isEmty(object.getString("DISEASEIMG")));
                outpatientVO.setCreateTime(DateUtil.strToDate(object.getString("CREATETIME")));
                outpatientVO.setCreateTime(DateUtil.strToDate(object.getString("CREATETIME")));
                outpatientVO.setStatus(isEmty(object.getString("STATUS")));
                outpatientVO.setStatus(isEmty(object.getString("STATUS")));
                outpatientVO.setConNo(isEmty(object.getString("VISITNUM")));
                wlyyOutpatientVOList.add(outpatientVO);
                wlyyOutpatientVOList.add(outpatientVO);
            }
            }
        }
        }
@ -1306,6 +1307,7 @@ public class XzzxEntranceService{
                outpatientVO.setDiseaseImg(isEmty(object.getString("DISEASEIMG")));
                outpatientVO.setDiseaseImg(isEmty(object.getString("DISEASEIMG")));
                outpatientVO.setCreateTime(DateUtil.strToDate(object.getString("CREATETIME")));
                outpatientVO.setCreateTime(DateUtil.strToDate(object.getString("CREATETIME")));
                outpatientVO.setStatus(isEmty(object.getString("STATUS")));
                outpatientVO.setStatus(isEmty(object.getString("STATUS")));
                outpatientVO.setConNo(isEmty(object.getString("VISITNUM")));
            }
            }
        }
        }
        return outpatientVO;
        return outpatientVO;

+ 22 - 5
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java

@ -8,7 +8,6 @@ import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.doctor.dao.BaseDoctorRoleDao;
import com.yihu.jw.doctor.dao.BaseDoctorRoleDao;
import com.yihu.jw.entity.base.dict.DictDoctorDutyDO;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.dict.DictIcd10DO;
import com.yihu.jw.entity.base.dict.DictIcd10DO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
@ -47,7 +46,6 @@ import com.yihu.utils.network.HttpUtils;
import com.yihu.utils.security.MD5;
import com.yihu.utils.security.MD5;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.omg.CORBA.OBJ_ADAPTER;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
@ -55,7 +53,6 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.*;
/**
/**
@ -216,12 +213,19 @@ public class YkyyEntranceService {
     * @return
     * @return
     * @throws Exception
     * @throws Exception
     */
     */
    public JSONArray vlisReportMasterlist(String patient,Integer page,Integer size) throws Exception{
    public JSONArray vlisReportMasterlist(String patient,Integer page,Integer size,String startTime,String endTime) throws Exception{
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
        if(patientMappingDO==null){
        if(patientMappingDO==null){
            return new JSONArray();
            return new JSONArray();
        }
        }
        String sql ="select * from VLIS_REPORT_MASTER where PATIENT_ID = '"+patientMappingDO.getMappingCode()+"' order by REPORT_TIME desc";
        String sql ="select * from VLIS_REPORT_MASTER where PATIENT_ID = '"+patientMappingDO.getMappingCode()+"'";
        if(StringUtils.isNoneBlank(startTime)){
            sql+=" and to_char(REPORT_TIME,'yyyy-mm-dd hh24:mi:ss') >= '"+startTime+"' ";
        }
        if(StringUtils.isNoneBlank(endTime)){
            sql+=" and to_char(REPORT_TIME,'yyyy-mm-dd hh24:mi:ss') >= '"+endTime+"' ";
        }
        sql+="  order by REPORT_TIME desc";
        Map<String,Object> params = new HashedMap();
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        params.put("sql",sql);
        params.put("size",size);
        params.put("size",size);
@ -259,6 +263,19 @@ public class YkyyEntranceService {
            res = rs.getJSONArray("detailModelList").getJSONObject(0);
            res = rs.getJSONArray("detailModelList").getJSONObject(0);
        }
        }
        BasePatientDO patientDO = findPatientByMapingCode(res.getString("PATIENT_ID"));
        JSONObject patientJson = new JSONObject();
        if(patientDO==null){
            patientJson.put("name","");
            patientJson.put("sex","");
            patientJson.put("birthday","");
        }else {
            patientJson.put("name",patientDO.getName());
            patientJson.put("sex",patientDO.getSex());
            patientJson.put("birthday",patientDO.getBirthday());
        }
        res.put("patient",patientJson);
        //LIS 常规报告细视图
        //LIS 常规报告细视图
        String detail1 = "select * from VLIS_REPORT_DETAIL where REPORT_ID = '"+REPORT_ID+"'";
        String detail1 = "select * from VLIS_REPORT_DETAIL where REPORT_ID = '"+REPORT_ID+"'";
        Map<String,Object> detailParams1 = new HashedMap();
        Map<String,Object> detailParams1 = new HashedMap();

+ 1 - 0
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -1054,6 +1054,7 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
            Double doctorFee = Double.parseDouble(fee);
            Double doctorFee = Double.parseDouble(fee);
            Double balance = doctorFee-cardFee;
            Double balance = doctorFee-cardFee;
            businessOrderDO.setPayPrice(balance);
            businessOrderDO.setPayPrice(balance);
            businessOrderDO.setPayType(4);
            businessOrderDao.save(businessOrderDO);
            businessOrderDao.save(businessOrderDO);
            List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wechatId,businessOrderDO.getPatient());
            List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wechatId,businessOrderDO.getPatient());
            if (patientWechatDos!=null&&patientWechatDos.size()!=0){
            if (patientWechatDos!=null&&patientWechatDos.size()!=0){

+ 14 - 3
business/base-service/src/main/java/com/yihu/jw/order/pay/ylz/YlzPayService.java

@ -6,8 +6,11 @@ import com.yihu.jw.entity.ylzinfo.OauthYlzConfigDO;
import com.yihu.jw.hospital.prescription.dao.OauthDzqmConfigDao;
import com.yihu.jw.hospital.prescription.dao.OauthDzqmConfigDao;
import com.yihu.jw.hospital.prescription.dao.OauthYlzConfigDao;
import com.yihu.jw.hospital.prescription.dao.OauthYlzConfigDao;
import com.yihu.jw.order.pay.utils.PayLogService;
import com.yihu.jw.order.pay.utils.PayLogService;
import com.yihu.jw.util.common.QrcodeUtil;
import com.yihu.jw.utils.ByteToInputStream;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.StringUtil;
import com.ylzinfo.onepay.sdk.HisOnepayClient;
import com.ylzinfo.onepay.sdk.HisOnepayClient;
import com.ylzinfo.onepay.sdk.OnepayClient;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.domain.ext.*;
import com.ylzinfo.onepay.sdk.domain.ext.*;
import com.ylzinfo.onepay.sdk.utils.DateUtil;
import com.ylzinfo.onepay.sdk.utils.DateUtil;
@ -16,6 +19,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.HashMap;
@ -320,7 +324,7 @@ public class YlzPayService {
        String onepayUrl = oauthYlzConfigDO.getUrl();
        String onepayUrl = oauthYlzConfigDO.getUrl();
        String signType=oauthYlzConfigDO.getSignType();
        String signType=oauthYlzConfigDO.getSignType();
        String encryptType = oauthYlzConfigDO.getEncType();
        String encryptType = oauthYlzConfigDO.getEncType();
        HisOnepayClient onepayClient = new HisOnepayClient(onepayUrl, appId, appSecret, signType, encryptType);
        OnepayClient onepayClient = new OnepayClient(onepayUrl, appId, appSecret, signType, encryptType);
        JSONObject jsonObject = new JSONObject();
        JSONObject jsonObject = new JSONObject();
        try {
        try {
            jsonObject.put("accId", accId);// 第三方应用原始ID微信公众号(支付宝)原始ID市民卡APP商户(医院)Id平安APP商户(医院)Id银联商户(医院)Id如:gh_54ec946bd3cd
            jsonObject.put("accId", accId);// 第三方应用原始ID微信公众号(支付宝)原始ID市民卡APP商户(医院)Id平安APP商户(医院)Id银联商户(医院)Id如:gh_54ec946bd3cd
@ -328,8 +332,15 @@ public class YlzPayService {
            jsonObject.put("cardNo",cardNo);//就诊卡或社保卡
            jsonObject.put("cardNo",cardNo);//就诊卡或社保卡
            jsonObject.put("channel", channel);//WX: 微信 (默认)ALI: 支付宝PA: 平安SMK:市民卡APP
            jsonObject.put("channel", channel);//WX: 微信 (默认)ALI: 支付宝PA: 平安SMK:市民卡APP
            //jsonObject.put("extra")
            //jsonObject.put("extra")
            ResponseParams<JSONObject> response = onepayClient.createSicardUrl(jsonObject);
            ResponseParams<JSONObject> response = onepayClient.createSicardPayUrl(jsonObject);
            if (response.getRespCode().equals("000000")){
            if (response.getRespCode().equals("000000")){
                JSONObject object1 = response.getParam();
                String url = object1.getString("payUrl");
                InputStream qrcode = QrcodeUtil.createQrcode(url,300,"jpg");
                ByteToInputStream byteToInputStream = new ByteToInputStream();
                String QRCodeImg = byteToInputStream.getBase64FromInputStream(qrcode);
                object1.put("qrcodeUrl","data:image/png;base64,"+ QRCodeImg);
                response.setParam(object1);
                object = JSON.toJSONString(response);
                object = JSON.toJSONString(response);
            }else {
            }else {
                isSuccess = false;
                isSuccess = false;
@ -344,7 +355,7 @@ public class YlzPayService {
            e.printStackTrace(pw);
            e.printStackTrace(pw);
            error = sw.toString();
            error = sw.toString();
        }
        }
        logService.saveHttpLog(isSuccess, "hop.mmpay.sicard.url", "互联网医院支付地址", "POST", null,JSON.toJSONString(jsonObject), object, error,logService.pushType);
        logService.saveHttpLog(isSuccess, "hop.mmpay.sicard.pay.url", "互联网医院支付地址", "POST", null,JSON.toJSONString(jsonObject), object, error,logService.pushType);
        return object;
        return object;
    }
    }

+ 2 - 0
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -1501,6 +1501,8 @@ public class ImService {
			ykyyService.pushNotificationToYktPatient(patient.getYktId(),messageDO.getTitle(),data.get("msg").toString());
			ykyyService.pushNotificationToYktPatient(patient.getYktId(),messageDO.getTitle(),data.get("msg").toString());
		}
		}
	}
	}
	
	
	/**
	/**
	 * 根据咨询CODE获取session_id
	 * 根据咨询CODE获取session_id

+ 160 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/gateway/GcClientDetails.java

@ -0,0 +1,160 @@
package com.yihu.jw.entity.iot.gateway;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.sql.Timestamp;
import java.util.Date;
/**
 * GtClientDetails entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "gc_client_details")
public class GcClientDetails extends IdEntity implements java.io.Serializable {
    // Fields
    private String appId;
    private String appSecret;
    private String appUri;
    private Date creatieTime;
    private String creatieUser;
    private String createUserName;
    private Date updateTime;
    private String updateUser;
    private String updateUserName;
    private String remark;
    private Integer del;
    // Constructors
    /**
     * default constructor
     */
    public GcClientDetails() {
    }
    /**
     * full constructor
     */
    public GcClientDetails(String appId, String appSecret, String appUri,
                           Timestamp creatieTime, String creatieUser, String createUserName,
                           Timestamp updateTime, String updateUser, String updateUserName,
                           String remark, Integer del) {
        this.appId = appId;
        this.appSecret = appSecret;
        this.appUri = appUri;
        this.creatieTime = creatieTime;
        this.creatieUser = creatieUser;
        this.createUserName = createUserName;
        this.updateTime = updateTime;
        this.updateUser = updateUser;
        this.updateUserName = updateUserName;
        this.remark = remark;
        this.del = del;
    }
    @Column(name = "app_id", length = 100)
    public String getAppId() {
        return this.appId;
    }
    public void setAppId(String appId) {
        this.appId = appId;
    }
    @Column(name = "app_secret", length = 100)
    public String getAppSecret() {
        return this.appSecret;
    }
    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }
    @Column(name = "app_uri", length = 256)
    public String getAppUri() {
        return this.appUri;
    }
    public void setAppUri(String appUri) {
        this.appUri = appUri;
    }
    @Column(name = "creatie_time", length = 0)
    public Date getCreatieTime() {
        return this.creatieTime;
    }
    public void setCreatieTime(Date creatieTime) {
        this.creatieTime = creatieTime;
    }
    @Column(name = "creatie_user", length = 100)
    public String getCreatieUser() {
        return this.creatieUser;
    }
    public void setCreatieUser(String creatieUser) {
        this.creatieUser = creatieUser;
    }
    @Column(name = "create_user_name", length = 20)
    public String getCreateUserName() {
        return this.createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    @Column(name = "update_time", length = 0)
    public Date getUpdateTime() {
        return this.updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    @Column(name = "update_user")
    public String getUpdateUser() {
        return this.updateUser;
    }
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }
    @Column(name = "update_user_name", length = 100)
    public String getUpdateUserName() {
        return this.updateUserName;
    }
    public void setUpdateUserName(String updateUserName) {
        this.updateUserName = updateUserName;
    }
    @Column(name = "remark", length = 20)
    public String getRemark() {
        return this.remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    @Column(name = "del")
    public Integer getDel() {
        return this.del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 139 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/gateway/GcHttpLog.java

@ -0,0 +1,139 @@
package com.yihu.jw.entity.iot.gateway;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.sql.Timestamp;
import java.util.Date;
/**
 * GcHttpLog entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "gc_http_log")
public class GcHttpLog extends IdEntity implements java.io.Serializable {
    // Fields
    private String token;
    private String ip;
    private String method;
    private String input;
    private String output;
    private Date createTime;
    private Integer flag = 1;
    private String message;
    // Constructors
    /**
     * default constructor
     */
    public GcHttpLog() {
    }
    /**
     * full constructor
     */
    public GcHttpLog(String token, String ip, String method, String input,
                     String output, Timestamp createTime) {
        this.token = token;
        this.ip = ip;
        this.method = method;
        this.input = input;
        this.output = output;
        this.createTime = createTime;
    }
    @Column(name = "token")
    public String getToken() {
        return this.token;
    }
    public void setToken(String token) {
        this.token = token;
    }
    @Column(name = "ip", length = 100)
    public String getIp() {
        return this.ip;
    }
    public void setIp(String ip) {
        this.ip = ip;
    }
    @Column(name = "method")
    public String getMethod() {
        return this.method;
    }
    public void setMethod(String method) {
        this.method = method;
    }
    @Column(name = "input")
    public String getInput() {
        return this.input;
    }
    public void setInput(String input) {
        this.input = input;
    }
    @Column(name = "output")
    public String getOutput() {
        return this.output;
    }
    public void setOutput(String output) {
        this.output = output;
    }
    @Column(name = "create_time")
    public Date getCreateTime() {
        return this.createTime;
    }
    public void setCreateTime(Date createTime) {
        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;
        }
    }
}

+ 89 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/gateway/GcToken.java

@ -0,0 +1,89 @@
package com.yihu.jw.entity.iot.gateway;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * GtToken entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "gc_token")
public class GcToken extends IdEntity implements java.io.Serializable {
    // 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;
    }
}

+ 101 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/gateway/GcTokenLog.java

@ -0,0 +1,101 @@
package com.yihu.jw.entity.iot.gateway;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.sql.Timestamp;
import java.util.Date;
/**
 * GcTokenLog entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "gc_token_log")
public class GcTokenLog extends IdEntity implements java.io.Serializable {
    // Fields
    private String ip;
    private String appIp;
    private String accesstoken;
    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 = "accesstoken")
    public String getAccesstoken() {
        return accesstoken;
    }
    public void setAccesstoken(String accesstoken) {
        this.accesstoken = accesstoken;
    }
    @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;
    }
}

+ 38 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/gateway/IdEntity.java

@ -0,0 +1,38 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.jw.entity.iot.gateway;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;
/**
 * 统一定义id的entity基类.
 * 
 * 基类统一定义id的属性名称、数据类型、列名映射及生成策略.
 * Oracle需要每个Entity独立定义id的SEQUCENCE时,不继承于本类而改为实现一个Idable的接口。
 * 
 * @author calvin
 */
// JPA 基类的标识
@MappedSuperclass
public abstract class IdEntity implements Serializable {
	private static final long serialVersionUID = 3673803562328635206L;
	protected Long id;  // 非业务主键
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
}

+ 10 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/iot/IotRequestMapping.java

@ -29,6 +29,7 @@ public class IotRequestMapping {
        public static final String interfaceAudit = api_iot_common + "/interfaceAudit";
        public static final String interfaceAudit = api_iot_common + "/interfaceAudit";
        public static final String monitorPlatform = api_iot_common + "/open/monitorPlatform";//免登录加上open
        public static final String monitorPlatform = api_iot_common + "/open/monitorPlatform";//免登录加上open
        public static final String sim = api_iot_common + "/sim";
        public static final String sim = api_iot_common + "/sim";
        public static final String openThird = api_iot_common + "/open/gc"; //第三方调用 需要accesstoken
        public static final String message_success_update = "update success";
        public static final String message_success_update = "update success";
@ -54,6 +55,15 @@ public class IotRequestMapping {
        public static final String findByDictName = "findByDictName";
        public static final String findByDictName = "findByDictName";
    }
    }
    /**
     * 第三方调用物联网接口 需要accesstoken
     */
    public static class ThirdOpen{
        public static final String bindUser = "bindUser";
        public static final String inputWeRunData = "inputWeRunData";
        public static final String uploadData = "uploadData";
    }
    /**
    /**
     * 文件上传模块常量
     * 文件上传模块常量
     */
     */

+ 15 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyPrescriptionVO.java

@ -374,6 +374,21 @@ public class WlyyPrescriptionVO extends UuidIdentityVOWithOperator {
    @ApiModelProperty(value = "电子病历", example = "模块1")
    @ApiModelProperty(value = "电子病历", example = "模块1")
    private WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO;
    private WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO;
    /**
     * 是否自取 1是 0否
     */
    @ApiModelProperty(value = "取货方式", example = "模块1")
    private Integer oneselfPickupFlg;
    public Integer getOneselfPickupFlg() {
        return oneselfPickupFlg;
    }
    public void setOneselfPickupFlg(Integer oneselfPickupFlg) {
        this.oneselfPickupFlg = oneselfPickupFlg;
    }
    public String getOutpatientId() {
    public String getOutpatientId() {
        return outpatientId;
        return outpatientId;
    }
    }

+ 46 - 0
common/common-util/src/main/java/com/yihu/jw/util/common/IpUtil.java

@ -5,6 +5,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.NetworkInterface;
import java.net.UnknownHostException;
import java.net.UnknownHostException;
@ -138,4 +139,49 @@ public class IpUtil {
        return ipsStr;
        return ipsStr;
    }
    }
    /**
     * 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址;
     *
     * @param request
     * @return
     * @throws IOException
     */
    public final static String getIpAddress(HttpServletRequest request) throws IOException {
        // 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址
        String ip = request.getHeader("X-Forwarded-For");
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
                ip = request.getHeader("Proxy-Client-IP");
            }
            if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
                ip = request.getHeader("WL-Proxy-Client-IP");
            }
            if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
                ip = request.getHeader("HTTP_CLIENT_IP");
            }
            if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
                ip = request.getHeader("HTTP_X_FORWARDED_FOR");
            }
            if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
                ip = request.getRemoteAddr();
            }
        } else if (ip.length() > 15) {
            String[] ips = ip.split(",");
            for (int index = 0; index < ips.length; index++) {
                String strIp = (String) ips[index];
                if (!("unknown".equalsIgnoreCase(strIp))) {
                    ip = strIp;
                    break;
                }
            }
        }
        return ip;
    }
}
}

+ 11 - 1
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/UnSettledHISPrescriptionService.java

@ -182,13 +182,23 @@ public class UnSettledHISPrescriptionService {
                    JSONObject json = jsonArray.getJSONObject(i);
                    JSONObject json = jsonArray.getJSONObject(i);
                    String cfsb = json.getString("CFSB");
                    String cfsb = json.getString("CFSB");
                    //查找对应的处方
                    //查找对应的处方
                    String sql = "SELECT w.OUTPATIENT_ID,w.ID,w.DOCTOR_NAME from WLYY_PRESCRIPTION w WHERE REAL_ORDER = '"+cfsb+"' ORDER BY w.CREATE_TIME desc";
                    String sql = "SELECT w.OUTPATIENT_ID,w.ID,w.DOCTOR,w.DOCTOR_NAME from WLYY_PRESCRIPTION w WHERE REAL_ORDER = '"+cfsb+"' and status <> 11 ORDER BY w.CREATE_TIME desc";
                    List<Map<String, Object>> pre = hibenateUtils.createSQLQuery(sql);
                    List<Map<String, Object>> pre = hibenateUtils.createSQLQuery(sql);
                    if(pre!=null && pre.size()>0){
                    if(pre!=null && pre.size()>0){
                        String prescriptionId = pre.get(0).get("ID").toString();
                        String prescriptionId = pre.get(0).get("ID").toString();
                        String outpatientId=pre.get(0).get("OUTPATIENT_ID").toString();
                        String doctor = pre.get(0).get("DOCTOR").toString();
                        String doctorName = pre.get(0).get("DOCTOR_NAME").toString();
                        //修改处方状态
                        //修改处方状态
                        String updateSql = "update WLYY_PRESCRIPTION set status = 11 where id = '"+prescriptionId+"'";
                        String updateSql = "update WLYY_PRESCRIPTION set status = 11 where id = '"+prescriptionId+"'";
                        hibenateUtils.updateBySql(updateSql);
                        hibenateUtils.updateBySql(updateSql);
                        com.alibaba.fastjson.JSONObject msgObj = new com.alibaba.fastjson.JSONObject();
                        msgObj.put("outpatientid",outpatientId);
                        msgObj.put("prescriptionId",prescriptionId);
                        msgObj.put("reason","处方驳回");
                        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId);
                        String immsg = imService.pushPrescriptionBackMsg(msgObj,doctor,doctorName,outpatientId,wlyyOutpatientDO.getPatient(),wlyyOutpatientDO.getOutpatientType());
                        System.out.println("发送诊断消息成功:"+immsg);
                    }
                    }
                }
                }
            }
            }

+ 1 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -206,7 +206,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                           @RequestParam(value = "outpatientId", required = true) String outpatientId,
                                           @RequestParam(value = "outpatientId", required = true) String outpatientId,
                                           @ApiParam(name = "prescriptionId", value = "处方ID")
                                           @ApiParam(name = "prescriptionId", value = "处方ID")
                                           @RequestParam(value = "prescriptionId", required = false) String prescriptionId)throws Exception{
                                           @RequestParam(value = "prescriptionId", required = false) String prescriptionId)throws Exception{
        com.alibaba.fastjson.JSONObject obj =  prescriptionService.findReOutpatientInfo(outpatientId,prescriptionId);
        com.alibaba.fastjson.JSONObject obj =  prescriptionService.findReOutpatientInfo(outpatientId,prescriptionId,wxId);
        return success(obj);
        return success(obj);
    }
    }
    
    

+ 9 - 22
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/YkyyPrescriptionEndpoint.java

@ -1,39 +1,22 @@
package com.yihu.jw.hospital.endpoint.prescription;
package com.yihu.jw.hospital.endpoint.prescription;
import com.yihu.jw.doctor.service.excel.DoctorWorkTimeExcelReader;
import com.yihu.jw.doctor.service.excel.DoctorWorkTimeMainExcelDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDiagnosisDO;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.service.*;
import com.yihu.jw.hospital.prescription.service.entrance.DoctorPreSignService;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.hospital.prescription.service.YkyyPrescriptionService;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.hospital.service.SystemMessage.HospitalSystemMessageService;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.restmodel.hospital.prescription.WlyyOutpatientVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyOutpatientVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.im.ConsultVO;
import com.yihu.jw.restmodel.web.*;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wlyy.service.WlyyBusinessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.util.List;
import java.util.List;
import java.util.Map;
/**
/**
 * Created by Trick on 2019/5/16
 * Created by Trick on 2019/5/16
@ -61,14 +44,18 @@ public class YkyyPrescriptionEndpoint extends EnvelopRestEndpoint {
                                          @ApiParam(name = "page", value = "第几页")
                                          @ApiParam(name = "page", value = "第几页")
                                          @RequestParam(value = "page",required = false) Integer page,
                                          @RequestParam(value = "page",required = false) Integer page,
                                          @ApiParam(name = "size", value = "页面大小")
                                          @ApiParam(name = "size", value = "页面大小")
                                          @RequestParam(value = "size",required = false) Integer size) throws Exception{
                                          @RequestParam(value = "size",required = false) Integer size,
                                          @ApiParam(name = "startTime", value = "开始时间")
                                          @RequestParam(value = "startTime",required = false) String startTime,
                                          @ApiParam(name = "endTime", value = "结束时间")
                                          @RequestParam(value = "endTime",required = false) String endTime) throws Exception{
        if(page==null){
        if(page==null){
            page = 1;
            page = 1;
        }
        }
        if(size==null){
        if(size==null){
            size = 10;
            size = 10;
        }
        }
        return success(ykyyEntranceService.vlisReportMasterlist(patient, page, size));
        return success(ykyyEntranceService.vlisReportMasterlist(patient, page, size,startTime,endTime));
    }
    }
    @GetMapping(value = "vlisReportMasterDetail")
    @GetMapping(value = "vlisReportMasterDetail")

+ 34 - 0
svr/svr-iot/src/main/java/com/yihu/iot/config/MvcConfig.java

@ -0,0 +1,34 @@
package com.yihu.iot.config;
import com.yihu.iot.interceptor.GateWayInterceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
/**
 * Created by chenweida on 2017/4/6.
 */
@Configuration
public class MvcConfig extends WebMvcConfigurerAdapter {
    private Logger logger = LoggerFactory.getLogger(MvcConfig.class);
    @Autowired
    private GateWayInterceptor gateWayInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 多个拦截器组成一个拦截器链
        // addPathPatterns 用于添加拦截规则
//         excludePathPatterns 用户排除拦截 ,/third/juye/kit/**
        registry.addInterceptor(gateWayInterceptor).addPathPatterns("/svr-iot/open/gc/**").excludePathPatterns(
                "/svr-iot/open/gc/accesstoken",
                "/svr-iot/open/gc/createGcClientDetails");
        super.addInterceptors(registry);
        logger.info("init gateWayInterceptor");
    }
}

+ 139 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/gateway/GcTokenController.java

@ -0,0 +1,139 @@
package com.yihu.iot.controller.gateway;
import com.yihu.iot.dao.gateway.GcHttpLogDao;
import com.yihu.iot.model.BaseResultModel;
import com.yihu.iot.model.GcClientDetailsModel;
import com.yihu.iot.model.GcTokenModel;
import com.yihu.iot.model.ResultOneModel;
import com.yihu.iot.service.gateway.GcClientDetailsService;
import com.yihu.iot.service.gateway.GcTokenService;
import com.yihu.jw.entity.iot.gateway.GcClientDetails;
import com.yihu.jw.entity.iot.gateway.GcHttpLog;
import com.yihu.jw.entity.iot.gateway.GcToken;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.util.common.IpUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
import org.springframework.beans.BeanUtils;
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 java.io.IOException;
import java.util.Date;
import java.util.List;
/**
 * Created by chenweida on 2017/8/17.
 * 对外的网关
 */
@Controller
@RequestMapping(value = IotRequestMapping.Common.openThird, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
@Api(description = "token相关服务")
public class GcTokenController {
    @Autowired
    private GcTokenService gcTokenService;
    @Autowired
    private GcClientDetailsService clientDetailsService;
    @Autowired
    private GcHttpLogDao httpLogDao;
    @ApiOperation("获取accesstoken")
    @RequestMapping(value = "accesstoken", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    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,
            @ApiParam(name = "过期时间 yyyy-MM-dd", value = "overTime", required = false) @RequestParam(required = false, value = "overTime") String overTime,
            HttpServletRequest request) {
        String ip = "";
        try {
            ip = IpUtil.getIpAddress(request);
            //查询appId 的token是否过期
            GcToken gcToken = new GcToken();
            List<GcToken> gcTokenList = gcTokenService.findByAppId(appid);
            if(gcTokenList == null || gcTokenList.size() == 0){
                //得到用户
                GcClientDetails clientDetails = clientDetailsService.findByAppId(appid);
                if (clientDetails == null) {
                    ResultOneModel resultOneModel = new ResultOneModel(null);
                    resultOneModel.setStatus(BaseResultModel.statusEm.error_Appid.getCode());
                    resultOneModel.setMessage(BaseResultModel.statusEm.error_Appid.getMessage());
                    saveHttpLog(ip, new JSONObject(request.getParameterMap()).toString(), "", "", request.getRequestURI(), 0, BaseResultModel.statusEm.error_Appid.getMessage());
                    return resultOneModel;
                }
                //判断appSecret
                if (!appSecret.equals(clientDetails.getAppSecret())) {
                    ResultOneModel resultOneModel = new ResultOneModel(null);
                    resultOneModel.setStatus(BaseResultModel.statusEm.error_AppSecret.getCode());
                    resultOneModel.setMessage(BaseResultModel.statusEm.error_AppSecret.getMessage());
                    saveHttpLog(ip, new JSONObject(request.getParameterMap()).toString(), "", "", request.getRequestURI(), 0, BaseResultModel.statusEm.error_Appid.getMessage());
                    return resultOneModel;
                }
                //生成token
                try {
                    gcToken = gcTokenService.createToken(appid, appSecret, IpUtil.getIpAddress(request),overTime);
                    saveHttpLog(ip, new JSONObject(request.getParameterMap()).toString(), new JSONObject(gcToken).toString(), gcToken.getAccesstoken(), request.getRequestURI(), 1, "成功");
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }else {
                gcToken = gcTokenList.get(0);
            }
            GcTokenModel gcTokenModel = new GcTokenModel();
            BeanUtils.copyProperties(gcToken, gcTokenModel);
            gcTokenModel.setOutTime(gcToken.getOutTime().getTime());
            return new ResultOneModel(gcTokenModel);
        } catch (Exception e) {
            saveHttpLog(ip, new JSONObject(request.getParameterMap()).toString(), "", "", request.getRequestURI(), 0, BaseResultModel.statusEm.login_system_error.getMessage());
            return new ResultOneModel(BaseResultModel.statusEm.login_system_error.getCode(), BaseResultModel.statusEm.login_system_error.getMessage());
        }
    }
    @ApiOperation("生成appId,appSecret")
    @RequestMapping(value = "createGcClientDetails", method = RequestMethod.POST)
    public ResultOneModel<GcClientDetailsModel> createClientDetails(
            @ApiParam(name = "appUri", value = "appUri", required = false) @RequestParam(required = false, value = "appUri") String appUri,
            @ApiParam(name = "createUserName", value = "createUserName", required = false) @RequestParam(required = false, value = "createUserName") String createUserName,
            @ApiParam(name = "creatieUser", value = "creatieUser", required = false) @RequestParam(required = false, value = "creatieUser") String creatieUser,
            @ApiParam(name = "remark", value = "remark", required = false) @RequestParam(required = false, value = "remark") String remark
    ){
        try {
            GcClientDetails gcClientDetails = clientDetailsService.createClientDetails(appUri,createUserName,creatieUser,remark);
            if(gcClientDetails==null){
                return new ResultOneModel(BaseResultModel.statusEm.login_system_error.getCode(), BaseResultModel.statusEm.login_system_error.getMessage());
            }
            GcClientDetailsModel gcClientDetailsModel = new GcClientDetailsModel();
            BeanUtils.copyProperties(gcClientDetails, gcClientDetailsModel);
            return new ResultOneModel(gcClientDetailsModel);
        }catch (Exception e) {
            return new ResultOneModel(BaseResultModel.statusEm.login_system_error.getCode(), BaseResultModel.statusEm.login_system_error.getMessage());
        }
    }
    private 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);
        if(output.length() > 3000) {
            output = output.substring(0, 3000);
        }
        gcHttpLog.setOutput(output);
        gcHttpLog.setToken(token);
        gcHttpLog.setMethod(method);
        gcHttpLog.setFlag(flag);
        gcHttpLog.setMessage(message);
        httpLogDao.save(gcHttpLog);
    }
}

+ 76 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/third/ThirdDataInputController.java

@ -0,0 +1,76 @@
package com.yihu.iot.controller.third;
import com.alibaba.fastjson.JSONObject;
import com.yihu.iot.aop.IntefaceLogRequired;
import com.yihu.iot.datainput.service.DataInputService;
import com.yihu.iot.datainput.util.ConstantUtils;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.iot.DataRequestMapping;
import com.yihu.jw.rm.iot.IotRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
@RestController
@RequestMapping(IotRequestMapping.Common.openThird)
@Api(tags = "开放接口-数据上传操作", description = "开放接口-数据上传操作")
public class ThirdDataInputController {
    @Autowired
    private DataInputService dataInputService;
    @PostMapping(value = IotRequestMapping.ThirdOpen.bindUser)
    @ApiOperation(value = "设备注册绑定", notes = "设备注册并绑定用户")
    public MixEnvelop bindUser(@ApiParam(name = "jsonData", value = "", defaultValue = "") @RequestParam String jsonData){
        try{
            return MixEnvelop.getSuccess(DataRequestMapping.DataInput.message_success,dataInputService.bindUser(jsonData));
        } catch (ApiException e){
            return MixEnvelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PostMapping(value = IotRequestMapping.ThirdOpen.uploadData)
    @ApiOperation(value = "体征数据上传", notes = "数据上传入库")
    @IntefaceLogRequired
    public MixEnvelop uploadData(
            @ApiParam(name = "jsonData", value = "", defaultValue = "")
            @RequestParam String jsonData) throws IOException  {
        JSONObject result = null;
        try {
          String str = dataInputService.inputBodySignsData(jsonData);
            result = JSONObject.parseObject(str);
            if (StringUtils.endsWithIgnoreCase(ConstantUtils.FAIL,result.getString("response"))) {
                return MixEnvelop.getError(result.getString("msg"));
            }
        } catch (ApiException e) {
            return MixEnvelop.getError(e.getMessage(), e.getErrorCode());
        }
        return MixEnvelop.getSuccess(DataRequestMapping.DataInput.message_success, result);
    }
    @PostMapping(value = IotRequestMapping.ThirdOpen.inputWeRunData)
    @ApiOperation(value = "微信运动数据上传", notes = "微信运动数据上传入库")
    public MixEnvelop inputWeRunData(@ApiParam(name = "jsonData", value = "", defaultValue = "") @RequestParam String jsonData) {
        JSONObject result = null;
        try {
            String str = dataInputService.inputWeRunData(jsonData);
            result = JSONObject.parseObject(str);
            if (StringUtils.endsWithIgnoreCase(ConstantUtils.FAIL,result.getString("response"))) {
                return MixEnvelop.getError(result.getString("msg"));
            }
        } catch (ApiException e) {
            return MixEnvelop.getError(e.getMessage(), e.getErrorCode());
        }
        return MixEnvelop.getSuccess(DataRequestMapping.DataInput.message_success, result.getString("msg"));
    }
}

+ 14 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/gateway/GcClientDetailsDao.java

@ -0,0 +1,14 @@
package com.yihu.iot.dao.gateway;
import com.yihu.jw.entity.iot.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);
}

+ 11 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/gateway/GcHttpLogDao.java

@ -0,0 +1,11 @@
package com.yihu.iot.dao.gateway;
import com.yihu.jw.entity.iot.gateway.GcHttpLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/8/17.
 */
public interface GcHttpLogDao extends PagingAndSortingRepository<GcHttpLog, Long>, JpaSpecificationExecutor<GcHttpLog> {
}

+ 25 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/gateway/GcTokenDao.java

@ -0,0 +1,25 @@
package com.yihu.iot.dao.gateway;
import com.yihu.jw.entity.iot.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;
import java.util.List;
/**
 * 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 accesstoken=?1")
    GcToken findByToken(String token);
    @Query("from GcToken where appid=?1 and outTime >= now()")
    List<GcToken> findByAppId(String token);
}

+ 11 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/gateway/GcTokenLogDao.java

@ -0,0 +1,11 @@
package com.yihu.iot.dao.gateway;
import com.yihu.jw.entity.iot.gateway.GcTokenLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/8/17.
 */
public interface GcTokenLogDao extends PagingAndSortingRepository<GcTokenLog, Long>, JpaSpecificationExecutor<GcTokenLog> {
}

+ 8 - 7
svr/svr-iot/src/main/java/com/yihu/iot/datainput/controller/DataInputController.java

@ -1,7 +1,6 @@
package com.yihu.iot.datainput.controller;
package com.yihu.iot.datainput.controller;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.yihu.iot.aop.IntefaceLogRequired;
import com.yihu.iot.datainput.service.DataInputService;
import com.yihu.iot.datainput.service.DataInputService;
import com.yihu.iot.datainput.util.ConstantUtils;
import com.yihu.iot.datainput.util.ConstantUtils;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.ApiException;
@ -13,7 +12,10 @@ import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.io.IOException;
@ -27,7 +29,7 @@ public class DataInputController {
    @PostMapping(value = DataRequestMapping.DataInput.api_user_bind, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = DataRequestMapping.DataInput.api_user_bind, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "设备注册绑定", notes = "设备注册并绑定用户")
    @ApiOperation(value = "设备注册绑定", notes = "设备注册并绑定用户")
    public MixEnvelop bindUser(@ApiParam(name = "jsonData", value = "", defaultValue = "") @RequestParam String jsonData){
    public MixEnvelop bindUser(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
        try{
        try{
            return MixEnvelop.getSuccess(DataRequestMapping.DataInput.message_success,dataInputService.bindUser(jsonData));
            return MixEnvelop.getSuccess(DataRequestMapping.DataInput.message_success,dataInputService.bindUser(jsonData));
        } catch (ApiException e){
        } catch (ApiException e){
@ -37,10 +39,9 @@ public class DataInputController {
    @PostMapping(value = DataRequestMapping.DataInput.api_data_input, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = DataRequestMapping.DataInput.api_data_input, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "体征数据上传", notes = "数据上传入库")
    @ApiOperation(value = "体征数据上传", notes = "数据上传入库")
    @IntefaceLogRequired
    public MixEnvelop uploadData(
    public MixEnvelop uploadData(
            @ApiParam(name = "jsonData", value = "", defaultValue = "")
            @RequestParam String jsonData) throws IOException  {
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws IOException  {
        JSONObject result = null;
        JSONObject result = null;
        try {
        try {
          String str = dataInputService.inputBodySignsData(jsonData);
          String str = dataInputService.inputBodySignsData(jsonData);
@ -56,7 +57,7 @@ public class DataInputController {
    @PostMapping(value = DataRequestMapping.DataInput.api_weRunData_input, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = DataRequestMapping.DataInput.api_weRunData_input, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "微信运动数据上传", notes = "微信运动数据上传入库")
    @ApiOperation(value = "微信运动数据上传", notes = "微信运动数据上传入库")
    public MixEnvelop uploadWeRunData(@ApiParam(name = "jsonData", value = "", defaultValue = "") @RequestParam String jsonData) {
    public MixEnvelop uploadWeRunData(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData) {
        JSONObject result = null;
        JSONObject result = null;
        try {
        try {
            String str = dataInputService.inputWeRunData(jsonData);
            String str = dataInputService.inputWeRunData(jsonData);

+ 164 - 0
svr/svr-iot/src/main/java/com/yihu/iot/interceptor/GateWayInterceptor.java

@ -0,0 +1,164 @@
package com.yihu.iot.interceptor;
/**
 * Created by chenweida on 2017/8/17.
 */
import com.alibaba.fastjson.JSONObject;
import com.yihu.iot.dao.gateway.GcHttpLogDao;
import com.yihu.iot.dao.gateway.GcTokenDao;
import com.yihu.iot.model.BaseResultModel;
import com.yihu.jw.entity.iot.gateway.GcHttpLog;
import com.yihu.jw.entity.iot.gateway.GcToken;
import com.yihu.jw.util.common.IpUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
/**
 * 对外的请求拦截
 */
@Component
public class GateWayInterceptor implements HandlerInterceptor {
    private Logger logger = LoggerFactory.getLogger(GateWayInterceptor.class);
    @Autowired
    private GcTokenDao gcTokenDaoDao;
    public static String status = "1";
    @Autowired
    private GcHttpLogDao httpLogDao;
    /**
     * preHandle:预处理回调方法
     *
     * @param request
     * @param response
     * @param handler
     * @return
     * @throws Exception
     */
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        boolean flag = true;
        String accesstoken = request.getHeader("accesstoken");
        String ip = IpUtil.getIpAddress(request);
        //********************************判断accesstoken********************************
        try {
            if (org.springframework.util.StringUtils.isEmpty(accesstoken)) {
                saveHttpLog(ip, JSONObject.toJSONString(request.getParameterMap()), null, accesstoken, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), BaseResultModel.statusEm.token_null.getMessage());
                //没权限
                BaseResultModel baseResultModel = new BaseResultModel(BaseResultModel.statusEm.token_null.getCode(), BaseResultModel.statusEm.token_null.getMessage());
                response.getOutputStream().write(JSONObject.toJSONString(baseResultModel).getBytes());
                flag = false;
            }
            GcToken gcToken = gcTokenDaoDao.findByToken(accesstoken);
            if (gcToken == null) {
                saveHttpLog(ip, JSONObject.toJSONString(request.getParameterMap()), null, accesstoken, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), BaseResultModel.statusEm.token_no_power.getMessage());
                //没权限
                BaseResultModel baseResultModel = new BaseResultModel(BaseResultModel.statusEm.token_no_power.getCode(), BaseResultModel.statusEm.token_no_power.getMessage());
                response.getOutputStream().write(JSONObject.toJSONString(baseResultModel).getBytes());
                flag = false;
            }
            if (gcToken.getDel() == null || gcToken.getDel() == 0) {
                saveHttpLog(ip, JSONObject.toJSONString(request.getParameterMap()), null, accesstoken, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), BaseResultModel.statusEm.token_out_effect.getMessage());
                //token无效
                BaseResultModel baseResultModel = new BaseResultModel(BaseResultModel.statusEm.token_out_effect.getCode(), BaseResultModel.statusEm.token_out_effect.getMessage());
                response.getOutputStream().write(JSONObject.toJSONString(baseResultModel).getBytes());
                flag = false;
            }
            if (System.currentTimeMillis() > gcToken.getOutTime().getTime()) {
                saveHttpLog(ip, JSONObject.toJSONString(request.getParameterMap()), null, accesstoken, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), BaseResultModel.statusEm.token_out_time.getMessage());
                //token过期
                BaseResultModel baseResultModel = new BaseResultModel(BaseResultModel.statusEm.token_out_time.getCode(), BaseResultModel.statusEm.token_out_time.getMessage());
                response.getOutputStream().write(JSONObject.toJSONString(baseResultModel).getBytes());
                flag = false;
            }
        } catch (Exception e) {
            saveHttpLog(ip, JSONObject.toJSONString(request.getParameterMap()), null, accesstoken, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), e.getMessage());
            return false;
        }
        //********************************判断accesstoken********************************
        return flag;
    }
    /**
     * 后处理回调方法
     *
     * @param request
     * @param response
     * @param handler
     * @param modelAndView
     * @throws Exception
     */
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        String output = "";
        if (modelAndView != null) {
            output = JSONObject.toJSONString(modelAndView.getModelMap());
        } else {
            Object returnObj = request.getAttribute("returnObj");
            if (returnObj != null) {
                output = JSONObject.toJSONString(returnObj);
            }
        }
        HandlerMethod handlerMethod = (HandlerMethod) handler;
//        response.getOutputStream()
        String token = request.getHeader("accesstoken");
        String ip = IpUtil.getIpAddress(request);
        saveHttpLog(ip,
                JSONObject.toJSONString(request.getParameterMap()),
                output,
                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 {
    }
    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);
        if(StringUtils.isNotEmpty(output)&&output.length() > 3000) {
            output = output.substring(0, 3000);
        }
        gcHttpLog.setOutput(output);
        gcHttpLog.setToken(token);
        gcHttpLog.setMethod(method);
        gcHttpLog.setFlag(flag);
        gcHttpLog.setMessage(message);
        httpLogDao.save(gcHttpLog);
    }
    public String getStatus() {
        return status;
    }
}

+ 98 - 0
svr/svr-iot/src/main/java/com/yihu/iot/model/BaseResultModel.java

@ -0,0 +1,98 @@
package com.yihu.iot.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
 * Created by chenweida on 2017/8/17.
 */
@ApiModel("返回实体")
public class BaseResultModel {
    @ApiModelProperty(value = "状态", required = false, access = "response")
    protected Integer status = statusEm.success.getCode();
    @ApiModelProperty(value = "信息", required = false, access = "response")
    protected String message = "成功";
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getMessage() {
        return message;
    }
    public void setMessage(String message) {
        this.message = message;
    }
    public enum statusEm {
        success(10000, "请求成功"),//请求成功
        error_Appid(-9000, "appid不存在"),//appid不存在
        error_AppSecret(-9001, "AppSecret不存在"),//AppSecret不存在
        token_out_effect(-9002, "无效的token"),//token无效
        token_no_power(-9003, "用户没权限"),// 没权限 包括未授权 或者uri错误
        token_out_time(-9004, "accesstoken已过期"),//token无效
        token_null(-9005, "accesstoken为空"),// 没权限 包括未授权 或者uri错误
        error_params(-10000, "请求失败 参数错误"),//请求失败 参数错误
        error_no_ip(-10010, "请求失败,获取IP失败"),//请求失败,获取IP失败
        login_system_error(-10020, "系统异常"),
        login_publickey_error(-10030, "获取公钥失败"),
        file_upload_error(-10040, "文件上传失败"),
        find_error(-10050, "查询失败"),
        opera_error(-10060, "操作失败"),
        no_openid(-30000,"用户openId为空无法发送"),
        login_account_error(-20010, "账号不存在"),
        login_password_error(-20020, "密码错误"),
        login_IMEI_error(-20030, "获取imei失败");
        ;
        statusEm(Integer code, String message) {
            this.code = code;
            this.message = message;
        }
        private Integer code;
        private String message;
        public Integer getCode() {
            return code;
        }
        public void setCode(Integer code) {
            this.code = code;
        }
        public String getMessage() {
            return message;
        }
        public void setMessage(String message) {
            this.message = message;
        }
    }
    public BaseResultModel() {
    }
    public BaseResultModel(String message) {
        this.message = message;
    }
    public BaseResultModel(Integer status, String message) {
        this.status = status;
        this.message = message;
    }
}

+ 33 - 0
svr/svr-iot/src/main/java/com/yihu/iot/model/GcClientDetailsModel.java

@ -0,0 +1,33 @@
package com.yihu.iot.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
 * GtClientDetails entity. @author MyEclipse Persistence Tools
 */
@ApiModel(description = "")
public class GcClientDetailsModel{
    // Fields
    @ApiModelProperty(value = "appId", required = false, access = "response")
    private String appId;
    @ApiModelProperty(value = "appSecret", required = false, access = "response")
    private String appSecret;
    public String getAppId() {
        return appId;
    }
    public void setAppId(String appId) {
        this.appId = appId;
    }
    public String getAppSecret() {
        return appSecret;
    }
    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }
}

+ 51 - 0
svr/svr-iot/src/main/java/com/yihu/iot/model/GcTokenModel.java

@ -0,0 +1,51 @@
package com.yihu.iot.model;
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 accesstoken;
    @ApiModelProperty(value = "创建时间", required = false, access = "response")
    private Date createTime;
    @ApiModelProperty(value = "过期时间", required = false, access = "response")
    private Long outTime;
    public String getAccesstoken() {
        return accesstoken;
    }
    public void setAccesstoken(String accesstoken) {
        this.accesstoken = accesstoken;
    }
    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;
    }*/
    public Long getOutTime() {
        return outTime;
    }
    public void setOutTime(Long outTime) {
        this.outTime = outTime;
    }
}

+ 39 - 0
svr/svr-iot/src/main/java/com/yihu/iot/model/ResultOneModel.java

@ -0,0 +1,39 @@
package com.yihu.iot.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
 * Created by chenweida on 2017/8/17.
 * 对外放回的实体
 */
@ApiModel("返回的实体类")
public class ResultOneModel<T> extends BaseResultModel {
    @ApiModelProperty(value = "返回数据", required = false, access = "response")
    private T result;
    public T getResult() {
        return result;
    }
    public void setResult(T result) {
        this.result = result;
    }
    public ResultOneModel(T result) {
        this.result = result;
    }
    public ResultOneModel() {
    }
    public ResultOneModel(Integer code, String message) {
        super(code, message);
    }
    public ResultOneModel(Integer status, String message, T result) {
        super(status, message);
        this.result = result;
    }
}

+ 39 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/gateway/GcClientDetailsService.java

@ -0,0 +1,39 @@
package com.yihu.iot.service.gateway;
import com.yihu.iot.dao.gateway.GcClientDetailsDao;
import com.yihu.jw.entity.iot.gateway.GcClientDetails;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import static com.sun.xml.internal.ws.util.JAXWSUtils.getUUID;
/**
 * Created by chenweida on 2017/8/17.
 */
@Service
public class GcClientDetailsService{
    @Autowired
    private GcClientDetailsDao gtClientDetailsDao;
    public GcClientDetails findByAppId(String appid) {
        return gtClientDetailsDao.findByAppid(appid);
    }
    @Transactional
    public GcClientDetails createClientDetails(String appUri,String createUserName,String creatieUser,String remark) throws Exception{
        GcClientDetails gcClientDetails = new GcClientDetails();
        gcClientDetails.setAppId(getUUID());
        gcClientDetails.setAppSecret(getUUID());
        gcClientDetails.setAppUri(appUri);
        gcClientDetails.setCreateUserName(createUserName);
        gcClientDetails.setCreatieUser(creatieUser);
        gcClientDetails.setCreatieTime(new Date());
        gcClientDetails.setDel(1);
        gcClientDetails.setRemark(remark);
        return gtClientDetailsDao.save(gcClientDetails);
    }
}

+ 101 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/gateway/GcTokenService.java

@ -0,0 +1,101 @@
package com.yihu.iot.service.gateway;
import com.yihu.iot.dao.gateway.GcTokenDao;
import com.yihu.iot.dao.gateway.GcTokenLogDao;
import com.yihu.jw.entity.iot.gateway.GcToken;
import com.yihu.jw.entity.iot.gateway.GcTokenLog;
import com.yihu.jw.util.date.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/**
 * Created by chenweida on 2017/8/17.
 */
@Service
public class GcTokenService {
    @Autowired
    private GcTokenLogDao tokenLogDao;
    @Autowired
    private GcTokenDao tokenDao;
    @Value("${interceptor.accesstoken.time}")
    private Integer tokenTime;
    /**
     * 根据appid生成token
     *
     * @param appid
     * @param appSecret
     * @return
     */
    @Transactional
    public GcToken createToken(String appid, String appSecret, String ip, String overTime) {
        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小时过期
            if(StringUtils.isEmpty(overTime)){
                if(tokenTime==null){
                    tokenTime=2;
                }
                gc.setOutTime(DateUtil.getNextMin(date, tokenTime*60));
            }else{
                gc.setOutTime(DateUtil.strToDate(overTime));
            }
            gc.setAccesstoken(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.setAccesstoken(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);
    }
    public List<GcToken> findByAppId(String appid){
        return tokenDao.findByAppId(appid);
    }
}

+ 5 - 0
svr/svr-iot/src/main/resources/application.yml

@ -60,6 +60,11 @@ fast-dfs:
    max-size: 20
    max-size: 20
    wait-time: 500
    wait-time: 500
##拦截器开关
interceptor:
  accesstoken:
    status: 1 ###  1开启 0 关闭
    time: 2 ##对外接的accesstoken生命周期 2小时
---
---
spring:
spring:
  profiles: jwdev
  profiles: jwdev