Просмотр исходного кода

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

wangzhinan 4 лет назад
Родитель
Сommit
0e8ca457ca
18 измененных файлов с 531 добавлено и 160 удалено
  1. 20 0
      business/base-service/src/main/java/com/yihu/jw/dict/dao/DictDeptDescDao.java
  2. 37 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  3. 2 2
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java
  4. 19 9
      business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java
  5. 4 0
      business/base-service/src/main/java/com/yihu/jw/order/dao/BusinessOrderDao.java
  6. 45 18
      common/common-entity-es/src/main/java/com/yihu/jw/datainput/DataBodySignsDO.java
  7. 80 0
      common/common-entity-es/src/main/java/com/yihu/jw/datainput/MeasureData.java
  8. 37 0
      common/common-entity-es/src/main/java/com/yihu/jw/datainput/PositionData.java
  9. 63 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictDeptDescDO.java
  10. 13 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  11. 42 3
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  12. 51 49
      svr/svr-iot/sql-scripts/body_health_data_es.txt
  13. 2 2
      svr/svr-iot/src/main/java/com/yihu/iot/controller/third/ThirdDataInputController.java
  14. 13 25
      svr/svr-iot/src/main/java/com/yihu/iot/datainput/service/DataInputService.java
  15. 1 1
      svr/svr-iot/src/main/java/com/yihu/iot/datainput/service/DataStandardConvertService.java
  16. 9 0
      svr/svr-iot/src/main/java/com/yihu/iot/datainput/util/RowKeyUtils.java
  17. 2 2
      svr/svr-iot/src/main/java/com/yihu/iot/model/BaseResultModel.java
  18. 91 49
      svr/svr-iot/src/main/java/com/yihu/iot/service/analyzer/IotAnalyzerService.java

+ 20 - 0
business/base-service/src/main/java/com/yihu/jw/dict/dao/DictDeptDescDao.java

@ -0,0 +1,20 @@
package com.yihu.jw.dict.dao;
import com.yihu.jw.entity.base.dict.DictDeptDescDO;
import com.yihu.jw.entity.base.dict.DictDiseaseDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/6/18
 */
public interface DictDeptDescDao extends PagingAndSortingRepository<DictDeptDescDO, String>, JpaSpecificationExecutor<DictDeptDescDO> {
    DictDeptDescDO findByDeptCodeAndOrgCode(String deptCode,String orgCode);
    List<DictDeptDescDO> findByOrgCode(String orgCode);
}

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

@ -2,11 +2,13 @@ package com.yihu.jw.hospital.prescription.service;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.dict.dao.DictDeptDescDao;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.doctor.dao.BaseDoctorPatientDao;
import com.yihu.jw.doctor.service.BaseDoctorInfoService;
import com.yihu.jw.entity.base.dict.DictDeptDescDO;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
@ -238,6 +240,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    @Autowired
    private XzzxEntranceService xzzxEntranceService;
    @Autowired
    private DictDeptDescDao dictDeptDescDao;
    @Value("${demo.flag}")
    private boolean demoFlag;
@ -1038,6 +1043,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        return rs;
    }
    /**
     * 获取医生列表.
     *
@ -6929,4 +6938,32 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        }
        return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find,openid);
    }
    /**
     * 查询科室简介
     * @param orgCode
     * @param deptCode
     * @return
     */
    public MixEnvelop findDeptDesc(String orgCode, String deptCode) {
        DictDeptDescDO deptDescDO = dictDeptDescDao.findByDeptCodeAndOrgCode(deptCode, orgCode);
        if (deptDescDO!=null){
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find,deptDescDO);
        }else {
            return MixEnvelop.getError("无该科室简介");
        }
    }
    /**
     * 查询机构科室
     * @param orgCode
     * @return
     */
    public MixEnvelop findDeptByOrgCode(String orgCode) {
        List<DictDeptDescDO> deptDescDOList = dictDeptDescDao.findByOrgCode(orgCode);
        if (deptDescDOList==null || deptDescDOList.size()==0){
            return MixEnvelop.getError("无科室信息");
        }
        return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find,deptDescDOList);
    }
}

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

@ -220,10 +220,10 @@ public class YkyyEntranceService {
        }
        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+"' ";
            sql+=" and REPORT_TIME >= '"+startTime.replace("-",".")+"' ";
        }
        if(StringUtils.isNoneBlank(endTime)){
            sql+=" and to_char(REPORT_TIME,'yyyy-mm-dd hh24:mi:ss') >= '"+endTime+"' ";
            sql+=" and REPORT_TIME <= '"+endTime.replace("-",".")+"' ";
        }
        sql+="  order by REPORT_TIME desc";
        Map<String,Object> params = new HashedMap();

+ 19 - 9
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -850,6 +850,13 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
    }
    public List<BusinessOrderDO> selectListStatus(String relationCode){
        List<BusinessOrderDO> businessOrderDOList = businessOrderDao.selectListByRelationCode(relationCode);
        return businessOrderDOList;
    }
    /**
     * 易联众退款
     * @param wechatId
@ -1159,16 +1166,19 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
     * @return
     * @throws Exception
     */
    public Map yktMedicalCardTopUp(String mzhm,Double jkje,Integer type,Integer paymentType,String patientId,String wechatId,String hospitalId) throws Exception {
    public Map yktMedicalCardTopUp(String mzhm,Double jkje,Integer type,Integer paymentType,String patientId,String wechatId,String hospitalId,String wxPayType) throws Exception {
        BasePatientDO patientDO = patientDao.findById(patientId);
        BusinessOrderDO businessOrderDO = new BusinessOrderDO();
        businessOrderDO.setPatient(patientId);
        businessOrderDO.setPatientName(patientDO.getName());
        businessOrderDO.setCreateTime(DateUtil.getNowDate());
        businessOrderDO.setOrderCategory("5");
        businessOrderDO.setDescription("眼科就诊卡充值");
        businessOrderDO.setDescription("就诊卡充值");
        businessOrderDO.setPayPrice(jkje);
        businessOrderDO.setOrderNo("HLWYY"+System.currentTimeMillis()+(int)(Math.random()*900)+100);
        businessOrderDO.setRelationCode(mzhm);
        businessOrderDO.setRelationName("就诊卡充值");
        businessOrderDO.setStatus(0);
        if (paymentType==1){
            businessOrderDO.setPayType(2);
        }
@ -1181,31 +1191,31 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        if (type==1){
            businessOrderDO.setOrderType(11);
        }
        Map<String,Object> map=null;
        Map<String,Object> map= new HashMap<>();
        String rs = ykyyService.getNewSerialNumber(mzhm, jkje.intValue(), type, paymentType, patientDO.getUserId(), hospitalId);
        logger.info("眼科获取充值订单接口调用结果:"+rs);
        Map<String,Object> rsMap = JSONObject.parseObject(rs, Map.class);
        if ("10000".equalsIgnoreCase(rsMap.get("code").toString())){
            businessOrderDO.setYkOrderNo(rsMap.get("value").toString());
        }else {
            map.put("error","眼科接口调用失败");
            logger.info("error="+"眼科接口调用失败");
            return map;
            logger.info("error=眼科接口调用失败");
            return rsMap;
        }
        businessOrderDO = businessOrderDao.save(businessOrderDO);
        List<BasePatientWechatDo> patientWechatDoList = patientWechatDao.findByWechatIdAndPatientId(wechatId, patientId);
        if (patientWechatDoList.isEmpty()){
        if (patientWechatDoList==null || patientWechatDoList.size()==0){
            map.put("error","无openId");
            logger.info("error="+"无openId");
            logger.info("error=无openId");
            return map;
        }
        WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
        String url = wxWechatDO.getBaseUrl();
        String notifyUrl =url;
        String price = (int)(businessOrderDO.getPayPrice()*100)+"";
        map = unifiedorder(wechatId,businessOrderDO.getDescription(),price,WeChatConfig.TRADE_TYPE_JSAPI,patientWechatDoList.get(0).getOpenid(),businessOrderDO.getOrderNo(),notifyUrl);
        map = unifiedorder(wechatId,businessOrderDO.getDescription(),price,wxPayType,patientWechatDoList.get(0).getOpenid(),businessOrderDO.getOrderNo(),notifyUrl);
        logger.info("success="+JSONObject.toJSONString(map));
        return map;
    }

+ 4 - 0
business/base-service/src/main/java/com/yihu/jw/order/dao/BusinessOrderDao.java

@ -22,6 +22,10 @@ public interface BusinessOrderDao extends PagingAndSortingRepository<BusinessOrd
    BusinessOrderDO selectByRelationCode(String relationCode);
    @Query("from BusinessOrderDO w where w.relationCode = ?1 order by createTime desc ")
    List<BusinessOrderDO> selectListByRelationCode(String relationCode);
    @Query("from BusinessOrderDO w where w.traceNo = ?1 ")
    BusinessOrderDO selectByTraceNo(String traceNo);

+ 45 - 18
common/common-entity-es/src/main/java/com/yihu/jw/datainput/DataBodySignsDO.java

@ -13,16 +13,19 @@ public class DataBodySignsDO {
    @JestId
    private String id;
    private String access_token; //访问token
    private String data_source; //数据来源
    private String sn;          //设备序列码
    private String ext_code;    //设备A,B键,取值为0,1,代表绑定不同的用户,
    private String device_name; //设备名称
    private String device_model;//设备型号
    private List<Data> data;    //设备所测量的数据内容
    private List<MeasureData> measure_data;    //设备所测量的数据内容
    private List<PositionData> position_data;    //设备所测量的数据内容
    private String idCard;      //设备绑定的用户身份证号
    private String username;    //用户名
    private String usercode;    //用户在系统中的code,唯一识别
    private String rid; // 存到hbase中的id
    private Integer status =0; //状态:0为标准,1为异常
    private Integer del = 1; //删除标记,1代表正常,0代表删除
    public String getId() {
        return this.id;
@ -32,14 +35,6 @@ public class DataBodySignsDO {
        this.id = id;
    }
    public String getAccess_token() {
        return access_token;
    }
    public void setAccess_token(String access_token) {
        this.access_token = access_token;
    }
    public String getData_source() {
        return data_source;
    }
@ -80,14 +75,6 @@ public class DataBodySignsDO {
        this.device_model = device_model;
    }
    public List<Data> getData() {
        return data;
    }
    public void setData(List<Data> data) {
        this.data = data;
    }
    public String getIdCard() {
        return idCard;
    }
@ -111,4 +98,44 @@ public class DataBodySignsDO {
    public void setUsercode(String usercode) {
        this.usercode = usercode;
    }
    public String getRid() {
        return rid;
    }
    public void setRid(String rid) {
        this.rid = rid;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    public List<MeasureData> getMeasure_data() {
        return measure_data;
    }
    public void setMeasure_data(List<MeasureData> measure_data) {
        this.measure_data = measure_data;
    }
    public List<PositionData> getPosition_data() {
        return position_data;
    }
    public void setPosition_data(List<PositionData> position_data) {
        this.position_data = position_data;
    }
}

+ 80 - 0
common/common-entity-es/src/main/java/com/yihu/jw/datainput/MeasureData.java

@ -0,0 +1,80 @@
package com.yihu.jw.datainput;
/**
 * Created by yeshijie on 2020/6/18.
 */
public class MeasureData {
    private String type;//体征类型
    private String measure_time;//测量时间
    private String sign_name;//体征指标名称
    private String sign_value;//体征指标值
    private String sign_unit;//体征指标单位
    private String explain;//测量结果的解释分析
    private String filepath;// 测量附件
    private String reference;//测量结果参考标准
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getMeasure_time() {
        return measure_time;
    }
    public void setMeasure_time(String measure_time) {
        this.measure_time = measure_time;
    }
    public String getSign_name() {
        return sign_name;
    }
    public void setSign_name(String sign_name) {
        this.sign_name = sign_name;
    }
    public String getSign_value() {
        return sign_value;
    }
    public void setSign_value(String sign_value) {
        this.sign_value = sign_value;
    }
    public String getSign_unit() {
        return sign_unit;
    }
    public void setSign_unit(String sign_unit) {
        this.sign_unit = sign_unit;
    }
    public String getExplain() {
        return explain;
    }
    public void setExplain(String explain) {
        this.explain = explain;
    }
    public String getFilepath() {
        return filepath;
    }
    public void setFilepath(String filepath) {
        this.filepath = filepath;
    }
    public String getReference() {
        return reference;
    }
    public void setReference(String reference) {
        this.reference = reference;
    }
}

+ 37 - 0
common/common-entity-es/src/main/java/com/yihu/jw/datainput/PositionData.java

@ -0,0 +1,37 @@
package com.yihu.jw.datainput;
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
/**
 * Created by yeshijie on 2020/6/18.
 */
public class PositionData {
    private GeoPoint location;//坐标 lat lon
    private String altitude; //海拨
    private String position; //位置描述,例如几号病房几床
    public GeoPoint getLocation() {
        return location;
    }
    public void setLocation(GeoPoint location) {
        this.location = location;
    }
    public String getAltitude() {
        return altitude;
    }
    public void setAltitude(String altitude) {
        this.altitude = altitude;
    }
    public String getPosition() {
        return position;
    }
    public void setPosition(String position) {
        this.position = position;
    }
}

+ 63 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictDeptDescDO.java

@ -0,0 +1,63 @@
package com.yihu.jw.entity.base.dict;
import com.yihu.jw.entity.IntegerIdentityEntity;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import org.aspectj.weaver.ast.Test;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/6/18
 */
@Entity
@Table(name = "dict_dept_desc")
@SequenceGenerator(name="id_generated", sequenceName="DICT_HOSPITAL_DEPT_SEQ")
public class DictDeptDescDO extends UuidIdentityEntityWithOperator {
    @Column(name = "org_code")
    private String orgCode;
    @Column(name = "dept_code")
    private String deptCode;
    @Column(name = "dept_name")
    private String deptName;
    @Column(name = "dept_description")
    private String deptDescription;
    public String getOrgCode() {
        return orgCode;
    }
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
    public String getDeptCode() {
        return deptCode;
    }
    public void setDeptCode(String deptCode) {
        this.deptCode = deptCode;
    }
    public String getDeptName() {
        return deptName;
    }
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }
    public String getDeptDescription() {
        return deptDescription;
    }
    public void setDeptDescription(String deptDescription) {
        this.deptDescription = deptDescription;
    }
}

+ 13 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -109,6 +109,18 @@ public class BaseHospitalRequestMapping {
         * 查询机构底下部门
         */
        public static final String findDeptByHospital ="/findDeptByHospital";
        /**
         * 查询机构底下部门
         */
        public static final String findDeptDescByDeptCodeAndOrgCode ="/findDeptDescByDeptCodeAndOrgCode";
        /**
         * 查询机构底下部门
         */
        public static final String findDeptByOrgCode ="/findDeptByOrgCode";
    
        /**
         * 查询有所有已开放的科室
@ -423,6 +435,7 @@ public class BaseHospitalRequestMapping {
        public static final String tradeQuery= "/tradeQuery";
        public static final String selectOrderStatus="/selectOrderStatus";
        public static final String selectOrderListStatus="/selectOrderListStatus";
        public static final String selectPrescriptionList = "/selectPrescriptionList";

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

@ -37,6 +37,7 @@ import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.web.*;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.wlyy.service.WlyyBusinessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -267,6 +268,24 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                          @RequestParam(value = "consultDeptFlag", required = false)String consultDeptFlag) {
        return success(prescriptionService.findDeptByHospital(orgCode,dept,consultDeptFlag));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDeptDescByDeptCodeAndOrgCode)
    @ApiOperation(value = "查询科室介绍", notes = "查询科室介绍")
    public MixEnvelop findDeptDesc(@ApiParam(name = "orgCode", value = "机构code")
                                          @RequestParam(value = "orgCode", required = true)String orgCode,
                                          @ApiParam(name = "deptCode", value = "部门code")
                                          @RequestParam(value = "deptCode", required = true)String deptCode) {
        return prescriptionService.findDeptDesc(orgCode,deptCode);
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDeptByOrgCode)
    @ApiOperation(value = "查询机构下所有科室", notes = "查询机构下所有科室")
    public MixEnvelop findDeptByOrgCode(@ApiParam(name = "orgCode", value = "机构code")
                                   @RequestParam(value = "orgCode", required = true)String orgCode) {
        return prescriptionService.findDeptByOrgCode(orgCode);
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDeptByKeyWord)
    @ApiOperation(value = "查询有所有已开放的科室", notes = "查询有所有已开放的科室")
@ -1287,9 +1306,11 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "patientId", value = "居民Ccode", required = true)
            @RequestParam(required = true)String patientId,
            @ApiParam(name = "hospitalId", value = "医院Ccode", required = true)
            @RequestParam(required = true)String hospitalId) throws Exception {
            @RequestParam(required = true)String hospitalId,
            @ApiParam(name = "wxPayType", value = "微信交易类型 公众号支付:JSAPI  原生扫码支付:NATIVE", required = true)
            @RequestParam(required = true)String wxPayType) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",businessOrderService.yktMedicalCardTopUp(mzhm,jkje,type,paymentType,patientId,wxId,hospitalId));
            return ObjEnvelop.getSuccess("ok",businessOrderService.yktMedicalCardTopUp(mzhm,jkje,type,paymentType,patientId,wxId,hospitalId,wxPayType));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
@ -1313,7 +1334,25 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    
    /**
     * 查询支付info
     * @param relationCode
     * @return
     * @throws Exception
     */
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.selectOrderListStatus)
    @ApiOperation("查询支付info")
    public ObjEnvelop selectOrderListStatus(
            @ApiParam(name = "relationCode", value = "relationCode", required = true)
            @RequestParam(required = true)String relationCode) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",businessOrderService.selectListStatus(relationCode));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    
    /**
     * 易联众统一退款

+ 51 - 49
svr/svr-iot/sql-scripts/body_health_data_es.txt

@ -6,57 +6,25 @@ POST http://172.26.0.112:9200/body_health_data/signs_data/_mapping
{
    "signs_data": {
        "properties": {
            "access_token": {
            "device_name": {
                "type": "string",
                "index": "not_analyzed"
            },
            "device_name": {
            "del": {
                "type": "string",
                "index": "not_analyzed"
            },
            "data": {
            "rid": {
                "type": "string",
                "index": "not_analyzed"
            },
            "status": {
                "type": "string",
                "index": "not_analyzed"
            },
            "measure_data": {
                "properties": {
                    "value1": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "value2": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "value3": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "value4": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "value5": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "value6": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "value7": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "value8": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "value9": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "value10": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "del": {
                    "type": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
@ -64,15 +32,42 @@ POST http://172.26.0.112:9200/body_health_data/signs_data/_mapping
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "rid": {
                        "type": "string",
                        "index": "not_analyzed"
                     "sign_name": {
                         "type": "string",
                         "index": "not_analyzed"
                     },
                     "sign_value": {
                         "type": "string",
                         "index": "not_analyzed"
                     },
                     "sign_unit": {
                         "type": "string",
                         "index": "not_analyzed"
                     },
                      "explain": {
                          "type": "string",
                          "index": "not_analyzed"
                      },
                      "filepath": {
                          "type": "string",
                          "index": "not_analyzed"
                      },
                      "reference": {
                          "type": "string",
                          "index": "not_analyzed"
                      }
                }
            },
            "position_data": {
                "properties": {
                    "location": {
                        "type": "geo_point"
                    },
                    "type": {
                    "altitude": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "status": {
                    "position": {
                        "type": "string",
                        "index": "not_analyzed"
                    }
@ -90,6 +85,10 @@ POST http://172.26.0.112:9200/body_health_data/signs_data/_mapping
                "type": "string",
                "index": "not_analyzed"
            },
            "idcard": {
                "type": "string",
                "index": "not_analyzed"
            },
            "sn": {
                "type": "string",
                "index": "not_analyzed"
@ -109,3 +108,6 @@ POST http://172.26.0.112:9200/body_health_data/signs_data/_mapping
        }
    }
}

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

@ -31,9 +31,9 @@ public class ThirdDataInputController {
    @Autowired
    private DataSearchService dataSearchService;
    @PostMapping(value = IotRequestMapping.ThirdOpen.bindUser)
    @PostMapping(value = IotRequestMapping.ThirdOpen.registedevice)
    @ApiOperation(value = "设备注册绑定", notes = "设备注册并绑定用户")
    public MixEnvelop bindUser(@ApiParam(name = "jsonData", value = "", defaultValue = "") @RequestParam String jsonData){
    public MixEnvelop registedevice(@ApiParam(name = "jsonData", value = "", defaultValue = "") @RequestParam String jsonData){
        try{
            return MixEnvelop.getSuccess(DataRequestMapping.DataInput.message_success,dataInputService.bindUser(jsonData));
        } catch (ApiException e){

+ 13 - 25
svr/svr-iot/src/main/java/com/yihu/iot/datainput/service/DataInputService.java

@ -138,7 +138,6 @@ public class DataInputService {
        //提取json某些项值
        DataBodySignsDO dataBodySignsDO = JSONObject.parseObject(json,DataBodySignsDO.class);
        JSONObject jsonObject = JSONObject.parseObject(json);
        String accessToken= dataBodySignsDO.getAccess_token();
        String dataSource = dataBodySignsDO.getData_source();
        String deviceSn = dataBodySignsDO.getSn();
        String extCode = dataBodySignsDO.getExt_code();
@ -168,7 +167,7 @@ public class DataInputService {
                    measuretime = DateUtils.formatDate(new Date(), DateUtil.yyyy_MM_dd_HH_mm_ss);
                }
                //生成一份json数据的rowkey
                rowkey = RowKeyUtils.makeRowKey(dataSource,deviceSn);
                rowkey = RowKeyUtils.makeRowKey();
                data.put("rid",rowkey);//hbase的rowkey
                rowkeyList.add(rowkey);
            } catch (Exception e) {
@ -264,6 +263,7 @@ public class DataInputService {
        if(StringUtils.isEmpty(json)){
            result.put("response",ConstantUtils.FAIL);
            result.put("msg","parameter json is null");
            result.put("status",-1);
            return result.toString();
        }
        String fileName = "";
@ -277,11 +277,11 @@ public class DataInputService {
            logger.error("json parse error,invalid json string");
            result.put("msg","json parse error,invalid json string");
            result.put("response",ConstantUtils.FAIL);
            result.put("status",-1);
            return result.toString();
        }
        JSONObject jsonObject = JSONObject.parseObject(json);
        String accessToken= dataBodySignsDO.getAccess_token();
        String dataSource = dataBodySignsDO.getData_source();
        String deviceSn = dataBodySignsDO.getSn();
        String extCode = dataBodySignsDO.getExt_code();
@ -293,44 +293,31 @@ public class DataInputService {
            updateBindUser(dataSource,deviceSn,idcard,username);
        }*/
        JSONArray jsonArray = jsonObject.getJSONArray("data");
        JSONArray jsonArray = jsonObject.getJSONArray("measure_data");
        if(null == jsonArray || jsonArray.size() == 0){
            result.put("response",ConstantUtils.FAIL);
            result.put("msg","parameter 'data' of json no exist");
            result.put("status",-1);
            return result.toString();
        }
        List<String> rowkeyList = new ArrayList<>();
        List<Map<String,Map<String,String>>> familyList = new ArrayList<>();
        //生成一份json数据的rowkey
        rowkey = RowKeyUtils.makeRowKey();
        jsonObject.put("rid",rowkey);//hbase的rowkey
        rowkeyList.add(rowkey);
        //循环数据,一组数据存一行,生成一个rowkey,并将该rowkey存到es中
        for(Object obj:jsonArray){
            JSONObject data = (JSONObject)obj;
            data.put("del","1"); //添加删除标记
            try {
                //生成一份json数据的rowkey
                rowkey = RowKeyUtils.makeRowKey(dataSource,deviceSn);
                data.put("rid",rowkey);//hbase的rowkey
                rowkeyList.add(rowkey);
            } catch (Exception e) {
                logger.error("make rowkey error");
                result.put("msg","make rowkey error");
                result.put("response",ConstantUtils.FAIL);
                return result.toString();
            }
            //组装B列
            Map<String, Map<String, String>> family = new HashMap<>();
            Map<String, String> columnsB = new HashMap<>();
            for(String key:data.keySet()){
                if(StringUtils.equalsIgnoreCase("rid",key)){ //存到hbase里的数据不需要rid
                    continue;
                }
                columnsB.put(key,data.getString(key));
            }
            if(data.containsKey("ecg")){
                fileName = data.getString("fileName");
                fileAbsPath = data.getString("filepath");
            }
            family.put(ConstantUtils.familyB,columnsB);
            familyList.add(family);
        }
@ -350,8 +337,10 @@ public class DataInputService {
            rids.addAll(rowkeyList);
            result.put("rid",rids);
            result.put("response",ConstantUtils.SUCCESS);
            result.put("status",200);
        }else{
            result.put("response",ConstantUtils.FAIL);
            result.put("status",-1);
        }
        /*try {
@ -400,7 +389,6 @@ public class DataInputService {
        }
        JSONObject jsonObject = JSONObject.parseObject(json);
        String accessToken= dataBodySignsDO.getAccess_token();
        String dataSource = dataBodySignsDO.getData_source();
        String deviceSn = dataBodySignsDO.getSn();
        String extCode = dataBodySignsDO.getExt_code();
@ -428,7 +416,7 @@ public class DataInputService {
            data.put("del","1"); //添加删除标记
            try {
                //生成一份json数据的rowkey
                rowkey = RowKeyUtils.makeRowKey(dataSource,deviceSn);
                rowkey = RowKeyUtils.makeRowKey();
                data.put("rid",rowkey);//hbase的rowkey
                rowkeyList.add(rowkey);
            } catch (Exception e) {

+ 1 - 1
svr/svr-iot/src/main/java/com/yihu/iot/datainput/service/DataStandardConvertService.java

@ -54,7 +54,7 @@ public class DataStandardConvertService {
        DataBodySignsDO dataBodySignsDO = JSONObject.parseObject(oldJson,DataBodySignsDO.class);
        JSONObject jsonObject = JSONObject.parseObject(oldJson);
        //如果没有授权或者数据来源,则表示数据异常
        if(null == dataBodySignsDO.getAccess_token() || (null != dataBodySignsDO.getAccess_token() && null == dataBodySignsDO.getData_source())){
        if(null == dataBodySignsDO.getData_source()){
            logger.warn("传过来的数据无有效access_token或data_source",oldJson);
            return "";
        }

+ 9 - 0
svr/svr-iot/src/main/java/com/yihu/iot/datainput/util/RowKeyUtils.java

@ -11,6 +11,7 @@ import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.IvParameterSpec;
import java.security.Key;
import java.security.spec.AlgorithmParameterSpec;
import java.util.UUID;
public class RowKeyUtils {
@ -26,6 +27,14 @@ public class RowKeyUtils {
    }
    /**
     * 用uuid做rowkey
     * @return
     */
    public static String makeRowKey(){
        return UUID.randomUUID().toString();
    }
    /**
     * 将rowkey里的信息还原回去
     */

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

@ -31,8 +31,8 @@ public class BaseResultModel {
    public enum statusEm {
        success(10000, "请求成功"),//请求成功
        error_Appid(-9000, "appid不存在"),//appid不存在
        error_AppSecret(-9001, "AppSecret不存在"),//AppSecret不存在
        error_Appid(40004, "appid不存在"),//appid不存在
        error_AppSecret(40001, "AppSecret不存在"),//AppSecret不存在
        token_out_effect(-9002, "无效的token"),//token无效
        token_no_power(-9003, "用户没权限"),// 没权限 包括未授权 或者uri错误
        token_out_time(-9004, "accesstoken已过期"),//token无效

+ 91 - 49
svr/svr-iot/src/main/java/com/yihu/iot/service/analyzer/IotAnalyzerService.java

@ -10,10 +10,8 @@ import com.yihu.iot.datainput.util.ConstantUtils;
import com.yihu.iot.datainput.util.RowKeyUtils;
import com.yihu.iot.service.common.MyJdbcTemplate;
import com.yihu.jw.datainput.DataBodySignsDO;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang.StringUtils;
import org.apache.http.client.utils.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -52,6 +50,14 @@ public class IotAnalyzerService extends BaseJpaService<WlyyIotD, WlyyIotDDao> {
    @Autowired
    private DeviceHealthyInfoMappingDao deviceHealthyInfoMappingDao;
    private String bloodSugarUnit = "mmol/L";
    private String bloodPressureUnit = "mmHg";
    private String pulseUnit = "bpm";
    private String heightUnit = "cm";
    private String weightUnit = "kg";
    private String bmiUnit = "kg/m^2";
    private String waistUnit = "cm";
    public void initIHealthIntoEs(){
        try {
            Integer id = 0;
@ -74,7 +80,7 @@ public class IotAnalyzerService extends BaseJpaService<WlyyIotD, WlyyIotDDao> {
                        DeviceHealthyInfoMapping info = new DeviceHealthyInfoMapping();
                        info.setCreateTime(new Date());
                        info.setIndexId(one.getLong("id"));
                        info.setRid(tmp.getJSONArray("data").getJSONObject(0).getString("rid"));
                        info.setRid(tmp.getString("rid"));
                        infos.add(info);
                    }
                }
@ -94,7 +100,7 @@ public class IotAnalyzerService extends BaseJpaService<WlyyIotD, WlyyIotDDao> {
                deviceHealthyInfoMappingDao.save(infos);
                //下一次
                id = list.get(list.size()-1).getInteger("id");
                list = myJdbcTemplate.queryJson(sql,new Object[]{id});
//                list = myJdbcTemplate.queryJson(sql,new Object[]{id});
            }
        }catch (Exception e){
@ -110,7 +116,6 @@ public class IotAnalyzerService extends BaseJpaService<WlyyIotD, WlyyIotDDao> {
    public String initUpload(JSONObject jsonObject){
        JSONObject json = new JSONObject();
        Integer type = jsonObject.getInteger("type");
        json.put("access_token","iHealth");
        json.put("data_source","iHealth");
        json.put("sn",StringUtils.trimToEmpty(jsonObject.getString("device_sn")));
        json.put("ext_code",StringUtils.trimToEmpty(jsonObject.getString("user_type")));
@ -119,54 +124,111 @@ public class IotAnalyzerService extends BaseJpaService<WlyyIotD, WlyyIotDDao> {
            json.put("device_model",StringUtils.trimToEmpty(jsonObject.getString("device_name")));
        }else{
            //历史数据未绑定居民
            String sql = "SELECT i.device_code,i.device_model,i.device_name from device.wlyy_devices i WHERE device_code = '"+jsonObject.getString("device_sn")+"'";
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
            if(list.size()>0){
                json.put("device_name",StringUtils.trimToEmpty(list.get(0).get("device_name").toString()));
                json.put("device_model",StringUtils.trimToEmpty(list.get(0).get("device_model").toString()));
            if(StringUtils.isNotEmpty(jsonObject.getString("device_sn"))){
                String sql = "SELECT i.device_code,i.device_model,i.device_name from device.wlyy_devices i WHERE device_code = '"+jsonObject.getString("device_sn")+"'";
                List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
                if(list.size()>0){
                    json.put("device_name",StringUtils.trimToEmpty(list.get(0).get("device_name").toString()));
                    json.put("device_model",StringUtils.trimToEmpty(list.get(0).get("device_model").toString()));
                }
            }
        }
        json.put("idcard",StringUtils.trimToEmpty(jsonObject.getString("idcard")));
        json.put("username",StringUtils.trimToEmpty(jsonObject.getString("name")));
        json.put("usercode",StringUtils.trimToEmpty(jsonObject.getString("user")));
        json.put("del",StringUtils.trimToEmpty(jsonObject.getString("del")));
        json.put("status",getStatus(jsonObject.getString("status")));
        JSONArray jsonArray = new JSONArray();
        JSONObject js = new JSONObject();
        js.put("measure_time",subStringTime(jsonObject.getString("record_date")));
        js.put("del",StringUtils.trimToEmpty(jsonObject.getString("del")));
        js.put("status",getStatus(jsonObject.getString("status")));
        js.put("type",String.valueOf(type));
        String measure_time = subStringTime(jsonObject.getString("record_date"));
        switch (type){
            case 1:
                //血糖
                js.put("value1",jsonObject.getString("value1"));
                js.put("value2",jsonObject.getString("value2"));
                JSONObject blood_sugar = new JSONObject();
                blood_sugar.put("measure_time",measure_time);
                blood_sugar.put("type","BloodSugar");
                blood_sugar.put("sign_name","blood_sugar");
                blood_sugar.put("sign_value",jsonObject.getString("value1"));
                blood_sugar.put("sign_unit",bloodSugarUnit);
                jsonArray.add(blood_sugar);
                JSONObject blood_sugar_result = new JSONObject();
                blood_sugar_result.put("measure_time",measure_time);
                blood_sugar_result.put("type","BloodSugar");
                blood_sugar_result.put("sign_name","blood_sugar_result");
                blood_sugar_result.put("sign_value",jsonObject.getString("value2"));
                jsonArray.add(blood_sugar_result);
                break;
            case 2:
                //血压
                js.put("value1",jsonObject.getString("value1"));
                js.put("value2",jsonObject.getString("value2"));
                JSONObject systolic = new JSONObject();
                systolic.put("measure_time",measure_time);
                systolic.put("type","BloodPressure");
                systolic.put("sign_name","systolic");
                systolic.put("sign_value",jsonObject.getString("value1"));
                systolic.put("sign_unit",bloodPressureUnit);
                jsonArray.add(systolic);
                JSONObject diastolic = new JSONObject();
                diastolic.put("measure_time",measure_time);
                diastolic.put("type","BloodPressure");
                diastolic.put("sign_name","diastolic");
                diastolic.put("sign_value",jsonObject.getString("value2"));
                diastolic.put("sign_unit",bloodPressureUnit);
                jsonArray.add(diastolic);
                if(StringUtils.isNotBlank(jsonObject.getString("value3"))){
                    js.put("value3",jsonObject.getString("value3"));
                    JSONObject pulse = new JSONObject();
                    pulse.put("measure_time",measure_time);
                    pulse.put("type","BloodPressure");
                    pulse.put("sign_name","pulse");
                    pulse.put("sign_value",jsonObject.getString("value3"));
                    pulse.put("sign_unit",pulseUnit);
                    jsonArray.add(pulse);
                }
                break;
            case 3:
                //体重/身高/BMI
                js.put("value1",jsonObject.getString("value1"));
                js.put("value2",jsonObject.getString("value2"));
                JSONObject height = new JSONObject();
                height.put("measure_time",measure_time);
                height.put("type","Height");
                height.put("sign_name","height");
                height.put("sign_value",jsonObject.getString("value1"));
                height.put("sign_unit",heightUnit);
                jsonArray.add(height);
                JSONObject weight = new JSONObject();
                weight.put("measure_time",measure_time);
                weight.put("type","Height");
                weight.put("sign_name","weight");
                weight.put("sign_value",jsonObject.getString("value2"));
                weight.put("sign_unit",weightUnit);
                jsonArray.add(weight);
                if(StringUtils.isNotBlank(jsonObject.getString("value3"))){
                    js.put("value3",jsonObject.getString("value3"));
                    JSONObject bmi = new JSONObject();
                    bmi.put("measure_time",measure_time);
                    bmi.put("type","Height");
                    bmi.put("sign_name","bmi");
                    bmi.put("sign_value",jsonObject.getString("value3"));
                    bmi.put("sign_unit",bmiUnit);
                    jsonArray.add(bmi);
                }
                break;
            case 4:
                //腰围
                js.put("value1",jsonObject.getString("value1"));
                JSONObject waist = new JSONObject();
                waist.put("measure_time",measure_time);
                waist.put("type","Waist");
                waist.put("sign_name","waist");
                waist.put("sign_value",jsonObject.getString("value1"));
                waist.put("sign_unit",waistUnit);
                jsonArray.add(waist);
                break;
            default:
                break;
        }
        jsonArray.add(js);
        json.put("data",jsonArray);
        json.put("measure_data",jsonArray);
        //上传
        return json.toJSONString();
    }
@ -289,36 +351,16 @@ public class IotAnalyzerService extends BaseJpaService<WlyyIotD, WlyyIotDDao> {
            logger.error("json parse error,invalid json string");
            return null;
        }
        JSONObject jsonObject = JSONObject.parseObject(json);
        String accessToken= dataBodySignsDO.getAccess_token();
        String dataSource = dataBodySignsDO.getData_source();
        String deviceSn = dataBodySignsDO.getSn();
        String extCode = dataBodySignsDO.getExt_code();
        JSONArray jsonArray = jsonObject.getJSONArray("data");
        JSONArray jsonArray = jsonObject.getJSONArray("measure_data");
        if(null == jsonArray || jsonArray.size() == 0){
            logger.error("msg","parameter 'data' of json no exist");
            return null;
        }
        rowkey = RowKeyUtils.makeRowKey();
        jsonObject.put("rid",rowkey);//hbase的rowkey
        //循环数据,一组数据存一行,生成一个rowkey,并将该rowkey存到es中
        for(Object obj:jsonArray){
            JSONObject data = (JSONObject)obj;
            data.put("del","1"); //添加删除标记
            try {
                String measuretime = jsonObject.getString("measure_time");
                if(null == measuretime){
                    measuretime = DateUtils.formatDate(new Date(), DateUtil.yyyy_MM_dd_HH_mm_ss);
                }
                //生成一份json数据的rowkey
                rowkey = RowKeyUtils.makeRowKey(dataSource,deviceSn);
                data.put("rid",rowkey);//hbase的rowkey
            } catch (Exception e) {
                logger.error("make rowkey error");
                return null;
            }
        }
        return jsonObject;
    }