| @@ -4,6 +4,8 @@ public enum StatusCode { | |||
| SUCCESS("1","success"), | |||
| FAIL("0","faile"), | |||
| PARAM_EMPTY("9901","params is null"), | |||
| DAO_UPDATE_COUNT_ZERO_EXCEPTION("9921","更新失败"), | |||
| DAO_ERROR("9902","数据库操作失败"), | |||
| PARAMS_JSON_ERROR("2","参数不是json格式"), | |||
| @@ -0,0 +1,297 @@ | |||
| package com.inet.ailink.receiver.controller; | |||
| import com.inet.ailink.receiver.entity.BaseEntity; | |||
| public class DataBrush extends BaseEntity { | |||
| private String brushModel; | |||
| private String brushTime; | |||
| private String brushTimeLeft; | |||
| private String brushTimeRight; | |||
| private String lastBattery; | |||
| private Integer appUserId; | |||
| private Integer subUserId; | |||
| private Integer deviceId; | |||
| private Integer dataFrom; | |||
| private String brushTimeDefault; | |||
| private String uploadTime; | |||
| private Integer brushZone; | |||
| private Integer uc; | |||
| private Integer dc; | |||
| private Integer ur; | |||
| private Integer dr; | |||
| private Integer ul; | |||
| private Integer dl; | |||
| private Integer uco; | |||
| private Integer dco; | |||
| private Integer ulo; | |||
| private Integer dlo; | |||
| private Integer uro; | |||
| private Integer dro; | |||
| private Integer uld; | |||
| private Integer uci; | |||
| private Integer urd; | |||
| private Integer dlu; | |||
| private Integer dci; | |||
| private Integer dru; | |||
| private Integer uli; | |||
| private Integer dli; | |||
| private Integer uri; | |||
| private Integer dri; | |||
| public String getBrushModel() { | |||
| return brushModel; | |||
| } | |||
| public void setBrushModel(String brushModel) { | |||
| this.brushModel = brushModel; | |||
| } | |||
| public String getBrushTime() { | |||
| return brushTime; | |||
| } | |||
| public void setBrushTime(String brushTime) { | |||
| this.brushTime = brushTime; | |||
| } | |||
| public String getBrushTimeLeft() { | |||
| return brushTimeLeft; | |||
| } | |||
| public void setBrushTimeLeft(String brushTimeLeft) { | |||
| this.brushTimeLeft = brushTimeLeft; | |||
| } | |||
| public String getBrushTimeRight() { | |||
| return brushTimeRight; | |||
| } | |||
| public void setBrushTimeRight(String brushTimeRight) { | |||
| this.brushTimeRight = brushTimeRight; | |||
| } | |||
| public String getLastBattery() { | |||
| return lastBattery; | |||
| } | |||
| public void setLastBattery(String lastBattery) { | |||
| this.lastBattery = lastBattery; | |||
| } | |||
| public Integer getAppUserId() { | |||
| return appUserId; | |||
| } | |||
| public void setAppUserId(Integer appUserId) { | |||
| this.appUserId = appUserId; | |||
| } | |||
| public Integer getSubUserId() { | |||
| return subUserId; | |||
| } | |||
| public void setSubUserId(Integer subUserId) { | |||
| this.subUserId = subUserId; | |||
| } | |||
| public Integer getDeviceId() { | |||
| return deviceId; | |||
| } | |||
| public void setDeviceId(Integer deviceId) { | |||
| this.deviceId = deviceId; | |||
| } | |||
| public Integer getDataFrom() { | |||
| return dataFrom; | |||
| } | |||
| public void setDataFrom(Integer dataFrom) { | |||
| this.dataFrom = dataFrom; | |||
| } | |||
| public String getBrushTimeDefault() { | |||
| return brushTimeDefault; | |||
| } | |||
| public void setBrushTimeDefault(String brushTimeDefault) { | |||
| this.brushTimeDefault = brushTimeDefault; | |||
| } | |||
| public String getUploadTime() { | |||
| return uploadTime; | |||
| } | |||
| public void setUploadTime(String uploadTime) { | |||
| this.uploadTime = uploadTime; | |||
| } | |||
| public Integer getBrushZone() { | |||
| return brushZone; | |||
| } | |||
| public void setBrushZone(Integer brushZone) { | |||
| this.brushZone = brushZone; | |||
| } | |||
| public Integer getUc() { | |||
| return uc; | |||
| } | |||
| public void setUc(Integer uc) { | |||
| this.uc = uc; | |||
| } | |||
| public Integer getDc() { | |||
| return dc; | |||
| } | |||
| public void setDc(Integer dc) { | |||
| this.dc = dc; | |||
| } | |||
| public Integer getUr() { | |||
| return ur; | |||
| } | |||
| public void setUr(Integer ur) { | |||
| this.ur = ur; | |||
| } | |||
| public Integer getDr() { | |||
| return dr; | |||
| } | |||
| public void setDr(Integer dr) { | |||
| this.dr = dr; | |||
| } | |||
| public Integer getUl() { | |||
| return ul; | |||
| } | |||
| public void setUl(Integer ul) { | |||
| this.ul = ul; | |||
| } | |||
| public Integer getDl() { | |||
| return dl; | |||
| } | |||
| public void setDl(Integer dl) { | |||
| this.dl = dl; | |||
| } | |||
| public Integer getUco() { | |||
| return uco; | |||
| } | |||
| public void setUco(Integer uco) { | |||
| this.uco = uco; | |||
| } | |||
| public Integer getDco() { | |||
| return dco; | |||
| } | |||
| public void setDco(Integer dco) { | |||
| this.dco = dco; | |||
| } | |||
| public Integer getUlo() { | |||
| return ulo; | |||
| } | |||
| public void setUlo(Integer ulo) { | |||
| this.ulo = ulo; | |||
| } | |||
| public Integer getDlo() { | |||
| return dlo; | |||
| } | |||
| public void setDlo(Integer dlo) { | |||
| this.dlo = dlo; | |||
| } | |||
| public Integer getUro() { | |||
| return uro; | |||
| } | |||
| public void setUro(Integer uro) { | |||
| this.uro = uro; | |||
| } | |||
| public Integer getDro() { | |||
| return dro; | |||
| } | |||
| public void setDro(Integer dro) { | |||
| this.dro = dro; | |||
| } | |||
| public Integer getUld() { | |||
| return uld; | |||
| } | |||
| public void setUld(Integer uld) { | |||
| this.uld = uld; | |||
| } | |||
| public Integer getUci() { | |||
| return uci; | |||
| } | |||
| public void setUci(Integer uci) { | |||
| this.uci = uci; | |||
| } | |||
| public Integer getUrd() { | |||
| return urd; | |||
| } | |||
| public void setUrd(Integer urd) { | |||
| this.urd = urd; | |||
| } | |||
| public Integer getDlu() { | |||
| return dlu; | |||
| } | |||
| public void setDlu(Integer dlu) { | |||
| this.dlu = dlu; | |||
| } | |||
| public Integer getDci() { | |||
| return dci; | |||
| } | |||
| public void setDci(Integer dci) { | |||
| this.dci = dci; | |||
| } | |||
| public Integer getDru() { | |||
| return dru; | |||
| } | |||
| public void setDru(Integer dru) { | |||
| this.dru = dru; | |||
| } | |||
| public Integer getUli() { | |||
| return uli; | |||
| } | |||
| public void setUli(Integer uli) { | |||
| this.uli = uli; | |||
| } | |||
| public Integer getDli() { | |||
| return dli; | |||
| } | |||
| public void setDli(Integer dli) { | |||
| this.dli = dli; | |||
| } | |||
| public Integer getUri() { | |||
| return uri; | |||
| } | |||
| public void setUri(Integer uri) { | |||
| this.uri = uri; | |||
| } | |||
| public Integer getDri() { | |||
| return dri; | |||
| } | |||
| public void setDri(Integer dri) { | |||
| this.dri = dri; | |||
| } | |||
| } | |||
| @@ -4,6 +4,7 @@ | |||
| import com.inet.ailink.receiver.common.vo.Response; | |||
| import com.inet.ailink.receiver.service.impl.BloodPressureServiceImpl; | |||
| import com.inet.ailink.receiver.service.impl.BodyFatServiceImpl; | |||
| import com.inet.ailink.receiver.service.impl.DataBrushServiceImpl; | |||
| import com.inet.ailink.receiver.service.impl.TrackPositionerLogsServiceImpl; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @@ -25,6 +26,9 @@ public class DeDataBaseController extends BaseController { | |||
| @Autowired | |||
| private TrackPositionerLogsServiceImpl trackPositionerLogsServiceImpl; | |||
| @Autowired | |||
| private DataBrushServiceImpl dataBrushServiceImpl; | |||
| /** | |||
| * 4G/WIFI+BLE设备测量结果数据 | |||
| * @param params | |||
| @@ -40,12 +44,13 @@ public class DeDataBaseController extends BaseController { | |||
| if(paramsByte.length >1){ | |||
| if(cid == 17 || cid == 25 || cid == 57){//WIFI_BLE体脂秤 cid = 17 ,WIFI体脂秤 cid = 25 ,4G体脂秤 cid = 57 | |||
| writeOutResponse(response, bodyFatServiceImpl.saveWeighDataByAdc(paramsByte, request)); | |||
| }else if(cid == 18 || cid == 24){//WIFI_BLE牙刷 cid = 18 ,WIFI牙刷 cid = 24 | |||
| writeOutResponse(response, dataBrushServiceImpl.saveBrush(paramsByte, request)); | |||
| }else if(cid == 48 || cid == 56){//4G血压仪 cid = 48,WIFI+BLE血压仪 cid = 56 | |||
| writeOutResponse(response, bloodPressureServiceImpl.saveOrUpdateBloodPressure(paramsByte, request)); | |||
| }else if(cid == 121 || cid == 144){//一次性温湿度计CID=144[0x0090] | |||
| writeOutResponse(request,paramsByte,response, trackPositionerLogsServiceImpl.saveTrackPositionerLogsBatch(paramsByte, request)); | |||
| } | |||
| else{ | |||
| }else{ | |||
| Response<Object> result = new Response<Object>(); | |||
| result.setStatus(StatusCode.DEVICE_UN_SUPPORT.getCode()); | |||
| writeOutResponse(response, result); | |||
| @@ -0,0 +1,8 @@ | |||
| package com.inet.ailink.receiver.mapper; | |||
| import com.inet.ailink.receiver.controller.DataBrush; | |||
| public interface IDataBrushDao extends BaseDao<DataBrush>{ | |||
| } | |||
| @@ -79,8 +79,6 @@ | |||
| if(bloodPressureDao.insert(bloodPressure) > 0){ | |||
| result.setStatus(StatusCode.SUCCESS.getCode()); | |||
| result.setData(bloodPressure.getId()); | |||
| //推送给APP | |||
| //aliyunPushService.pushForBloodPressure(bloodPressure); | |||
| }else{ | |||
| result.setStatus(StatusCode.FAIL.getCode()); | |||
| } | |||
| @@ -100,12 +100,8 @@ | |||
| //增加数据来源与计算次数,APP收到消息后,进行数据计算 | |||
| bodyFat.setSource(1); | |||
| bodyFat.setCalculationTimes(0); | |||
| System.out.println("bodyFat = " + bodyFat); | |||
| //将当前wifi秤上传的重量(可能为kg/st/lb/斤),转换为kg数值 | |||
| BigDecimal kgWeight = WeightUnitUtils.getKg(new BigDecimal(bodyFat.getWeight()) ,Integer.parseInt(bodyFat.getWeightUnit()),Integer.parseInt(bodyFat.getWeightPoint())); | |||
| System.out.println("kgWeight = " + kgWeight); | |||
| if(bodyFat.getBodyFatId() == null){//新增体重数据 | |||
| updateResult = bodyFatDao.insert(bodyFat); | |||
| }else{//修改体重数据 | |||
| @@ -0,0 +1,168 @@ | |||
| package com.inet.ailink.receiver.service.impl; | |||
| import com.inet.ailink.receiver.common.enums.StatusCode; | |||
| import com.inet.ailink.receiver.common.utils.Base64TeaUitls; | |||
| import com.inet.ailink.receiver.common.utils.JsonUtils; | |||
| import com.inet.ailink.receiver.common.utils.TlvUtils; | |||
| import com.inet.ailink.receiver.common.vo.Response; | |||
| import com.inet.ailink.receiver.controller.DataBrush; | |||
| import com.inet.ailink.receiver.entity.Device; | |||
| import com.inet.ailink.receiver.entity.Tlv; | |||
| import com.inet.ailink.receiver.mapper.IDataBrushDao; | |||
| import com.inet.ailink.receiver.mapper.ISysDeviceInfoDao; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @Service | |||
| @Transactional(rollbackFor=Exception.class) | |||
| public class DataBrushServiceImpl extends BaseServiceImpl<IDataBrushDao, DataBrush> | |||
| { | |||
| @Autowired | |||
| IDataBrushDao dataBrushDao; | |||
| @Autowired | |||
| ISysDeviceInfoDao deviceInfoDao; | |||
| @Override | |||
| protected IDataBrushDao getEntityDao() { | |||
| return dataBrushDao; | |||
| } | |||
| public Response<Object> saveBrush(byte[] paramsByte,HttpServletRequest request) { | |||
| Response<Object> result = new Response<Object>(); | |||
| DataBrush dataBrush = new DataBrush(); | |||
| try { | |||
| //解析数据 | |||
| //设备ID | |||
| Integer deviceId = Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(0, 3, paramsByte)+""); | |||
| //查询设备 | |||
| Device device = null; | |||
| if (deviceId != null && deviceId != 0) { | |||
| device = deviceInfoDao.getById(Long.valueOf(deviceId)); | |||
| } | |||
| //设备不存在,返回错误提示,这里配合Postman测试用例,注释该判断,实际使用需要判空设备,请取消注释 | |||
| // if (device == null) { | |||
| // result.setStatus(StatusCode.DEVICE_NOT_EXIT.getCode()); | |||
| // return result; | |||
| // } | |||
| //牙刷工作模式 | |||
| String brushModel = Base64TeaUitls.getStartToEndForInt(4, 4, paramsByte); | |||
| //刷牙时长 | |||
| String brushTime = Base64TeaUitls.getLowConactHighEndForInt(5, 6, paramsByte); | |||
| //左边刷牙时间 | |||
| String brushTimeLeft = Base64TeaUitls.getLowConactHighEndForInt(7, 8, paramsByte); | |||
| //右边刷牙时间 | |||
| String brushTimeRight = Base64TeaUitls.getLowConactHighEndForInt(9, 10, paramsByte); | |||
| //剩余电量 | |||
| String lastBattery = Base64TeaUitls.getStartToEndForInt(11, 11, paramsByte); | |||
| //默认刷牙时间 | |||
| String brushTimeDefault = Base64TeaUitls.getLowConactHighEndForInt(12, 13, paramsByte); | |||
| //设置基础值 | |||
| dataBrush.setDeviceId(deviceId); | |||
| dataBrush.setBrushModel(brushModel); | |||
| dataBrush.setDataFrom(1); | |||
| dataBrush.setBrushTime(brushTime); | |||
| dataBrush.setBrushTimeLeft(brushTimeLeft); | |||
| dataBrush.setBrushTimeRight(brushTimeRight); | |||
| dataBrush.setLastBattery(lastBattery); | |||
| dataBrush.setBrushTimeDefault(brushTimeDefault); | |||
| dataBrush.setSubUserId(-1); | |||
| //查询该设备绑定的账号,分配数据给账号 | |||
| Integer appUserId = 0; | |||
| dataBrush.setAppUserId(appUserId); | |||
| //6区、16区牙刷 | |||
| List<DataBrush> dataBrushList = new ArrayList<>(); | |||
| dataBrush.setBrushZone(4); | |||
| dataBrushList.add(dataBrush); | |||
| if(paramsByte.length > 14){ | |||
| List<Tlv> tlvs = TlvUtils.builderTlvList(paramsByte, 14); | |||
| if(tlvs != null && tlvs.size() > 0){ | |||
| dataBrushList = new ArrayList<>(); | |||
| dataBrushList = convertTlvToDataBrush(tlvs, dataBrush); | |||
| } | |||
| } | |||
| System.out.println(JsonUtils.toJson(dataBrushList)); | |||
| if(dataBrushList != null && dataBrushList.size() > 0){ | |||
| //保存数据,持久化需要自行实现 | |||
| // dataBrushDao.insertBatch(dataBrushList); | |||
| result.setStatus(StatusCode.SUCCESS.getCode()); | |||
| dataBrush.setId(1L); | |||
| result.setData(dataBrush.getId()); | |||
| } | |||
| } catch (Exception e) { | |||
| result.setStatus(StatusCode.PARAMS_dECRYPT_ERROR.getCode()); | |||
| } | |||
| return result; | |||
| } | |||
| /** | |||
| * 解析TLV格式的刷牙数据 | |||
| */ | |||
| public List<DataBrush> convertTlvToDataBrush(List<Tlv> tlvs,DataBrush dataBrush){ | |||
| List<DataBrush> dataBrushList = new ArrayList<>(); | |||
| for (Tlv tlv : tlvs) { | |||
| //6区牙刷 | |||
| if(tlv.getTag() == 1){ | |||
| Long uploadTime = Base64TeaUitls.getLowConactHighEndForLong(0, 3,tlv.getValue()); | |||
| if(uploadTime != null && uploadTime != 0xFFFFFFFFL){ | |||
| dataBrush.setUploadTime(String.valueOf(uploadTime)); | |||
| }else{ | |||
| dataBrush.setUploadTime(String.valueOf(new Date().getTime()/1000L)); | |||
| } | |||
| dataBrush.setBrushZone(6); | |||
| dataBrush.setBrushModel(Base64TeaUitls.getLowConactHighEndForLong(4, 4, tlv.getValue())+""); | |||
| dataBrush.setBrushTime(Base64TeaUitls.getLowConactHighEndForLong(5, 6, tlv.getValue())+""); | |||
| dataBrush.setUc(Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(7, 8, tlv.getValue())+"")); | |||
| dataBrush.setDc(Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(9, 10, tlv.getValue())+"")); | |||
| dataBrush.setUr(Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(11, 12, tlv.getValue())+"")); | |||
| dataBrush.setDr(Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(13, 14, tlv.getValue())+"")); | |||
| dataBrush.setUl(Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(15, 16, tlv.getValue())+"")); | |||
| dataBrush.setDl(Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(17, 18, tlv.getValue())+"")); | |||
| dataBrush.setLastBattery(Base64TeaUitls.getLowConactHighEndForLong(19, 19, tlv.getValue())+""); | |||
| dataBrush.setBrushTimeDefault(Base64TeaUitls.getLowConactHighEndForLong(20, 21, tlv.getValue())+""); | |||
| dataBrushList.add(dataBrush); | |||
| continue; | |||
| } | |||
| //16区牙刷 | |||
| if(tlv.getTag() == 2){ | |||
| dataBrush.setBrushZone(16); | |||
| Long uploadTime = Base64TeaUitls.getLowConactHighEndForLong(0, 3,tlv.getValue()); | |||
| if(uploadTime != null && uploadTime != 0xFFFFFFFFL){ | |||
| dataBrush.setUploadTime(String.valueOf(uploadTime)); | |||
| }else{ | |||
| dataBrush.setUploadTime(String.valueOf(new Date().getTime()/1000L)); | |||
| } | |||
| dataBrush.setBrushModel(Base64TeaUitls.getLowConactHighEndForLong(4, 4, tlv.getValue())+""); | |||
| dataBrush.setBrushTime(Base64TeaUitls.getLowConactHighEndForLong(5, 6, tlv.getValue())+""); | |||
| dataBrush.setUco(Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(7, 8, tlv.getValue())+"")); | |||
| dataBrush.setDco(Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(9, 10, tlv.getValue())+"")); | |||
| dataBrush.setUlo(Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(11, 12, tlv.getValue())+"")); | |||
| dataBrush.setDlo(Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(13, 14, tlv.getValue())+"")); | |||
| dataBrush.setUro(Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(15, 16, tlv.getValue())+"")); | |||
| dataBrush.setDro(Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(17, 18, tlv.getValue())+"")); | |||
| dataBrush.setUld(Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(19, 20, tlv.getValue())+"")); | |||
| dataBrush.setUci(Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(21, 22, tlv.getValue())+"")); | |||
| dataBrush.setUrd(Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(23, 24, tlv.getValue())+"")); | |||
| dataBrush.setDlu(Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(25, 26, tlv.getValue())+"")); | |||
| dataBrush.setDci(Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(27, 28, tlv.getValue())+"")); | |||
| dataBrush.setDru(Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(29, 30, tlv.getValue())+"")); | |||
| dataBrush.setUli(Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(31, 32, tlv.getValue())+"")); | |||
| dataBrush.setDli(Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(33, 34, tlv.getValue())+"")); | |||
| dataBrush.setUri(Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(35, 36, tlv.getValue())+"")); | |||
| dataBrush.setDri(Integer.parseInt(Base64TeaUitls.getLowConactHighEndForLong(37, 38, tlv.getValue())+"")); | |||
| dataBrush.setLastBattery(Base64TeaUitls.getLowConactHighEndForLong(39, 39, tlv.getValue())+""); | |||
| dataBrush.setBrushTimeDefault(Base64TeaUitls.getLowConactHighEndForLong(40, 41, tlv.getValue())+""); | |||
| dataBrushList.add(dataBrush); | |||
| continue; | |||
| } | |||
| } | |||
| return dataBrushList; | |||
| } | |||
| } | |||
| @@ -175,34 +175,26 @@ | |||
| //保存设备 | |||
| public Response<Object> saveDevice(Device device){ | |||
| Response<Object> result = new Response<Object>(); | |||
| int updateResult = 0; | |||
| if(device.getDeviceId() == null){//新增设备 | |||
| //通过pid、vid、cid、mac查询当前设备是否存在,如果存在,则直接返回,否则,新增设备 | |||
| Device params = new Device(); | |||
| params.setPid(device.getPid()); | |||
| params.setVid(device.getVid()); | |||
| params.setCid(device.getCid()); | |||
| params.setMac(device.getMac()); | |||
| Device deviceResult = sysDeviceInfoDao.getLastObjByAttribute(params); | |||
| if(deviceResult != null){ | |||
| //更新设备 | |||
| device.setDeviceId(deviceResult.getDeviceId()); | |||
| sysDeviceInfoDao.update(device); | |||
| result.setStatus(StatusCode.SUCCESS.getCode()); | |||
| result.setData(deviceResult.getDeviceId()); | |||
| return result; | |||
| }else{ | |||
| updateResult = sysDeviceInfoDao.insert(device); | |||
| } | |||
| }else{//修改设备 | |||
| updateResult = sysDeviceInfoDao.update(device); | |||
| } | |||
| if(updateResult>0){ | |||
| result.setStatus(StatusCode.SUCCESS.getCode()); | |||
| result.setData(device.getDeviceId()); | |||
| }else{ | |||
| result.setStatus(StatusCode.FAIL.getCode()); | |||
| } | |||
| System.out.println(JsonUtils.toJson(device)); | |||
| //通过pid、vid、cid、mac查询当前设备是否存在,如果存在,则直接返回,否则,新增设备 | |||
| // Device params = new Device(); | |||
| // params.setPid(device.getPid()); | |||
| // params.setVid(device.getVid()); | |||
| // params.setCid(device.getCid()); | |||
| // params.setMac(device.getMac()); | |||
| // Device deviceResult = sysDeviceInfoDao.getLastObjByAttribute(params); | |||
| // if(deviceResult != null){ | |||
| // //更新设备 | |||
| // device.setDeviceId(deviceResult.getDeviceId()); | |||
| // sysDeviceInfoDao.update(device); | |||
| // }else{ | |||
| // //新增设备 | |||
| // sysDeviceInfoDao.insert(device); | |||
| // } | |||
| result.setStatus(StatusCode.SUCCESS.getCode()); | |||
| //返回设备ID,后续上传测量结果数据将携带此ID,作为设备的唯一标识, | |||
| // 请根据业务需要,改为实际的设备ID,此处只做示例,返回固定值 | |||
| result.setData(1L); | |||
| return result; | |||
| } | |||
| @@ -49,10 +49,11 @@ public class TrackPositionerLogsServiceImpl extends BaseServiceImpl<ITrackPosit | |||
| if (deviceId != null && deviceId != 0) { | |||
| device = deviceInfoDao.getById(Long.valueOf(deviceId)); | |||
| } | |||
| if (device == null) { | |||
| result.setStatus(StatusCode.DEVICE_NOT_EXIT.getCode()); | |||
| return result; | |||
| } | |||
| //设备不存在,返回错误提示,这里配合Postman测试用例,注释该判断,实际使用需要判空设备,请取消注释 | |||
| // if (device == null) { | |||
| // result.setStatus(StatusCode.DEVICE_NOT_EXIT.getCode()); | |||
| // return result; | |||
| // } | |||
| //根据数据类型,截分TLV数据 | |||
| List<Tlv> tlvs = TlvUtils.builderTlvList(paramsByte, 4); | |||
| if (tlvs == null || tlvs.size() <= 0) { | |||
| @@ -1,119 +0,0 @@ | |||
| <?xml version="1.0" encoding="UTF-8" ?> | |||
| <!DOCTYPE mapper | |||
| PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" | |||
| "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd"> | |||
| <mapper namespace="com.inet.ailink.receiver.mapper.IBodyFatDao"> | |||
| <resultMap id="BodyFatResult" type="com.inet.ailink.receiver.entity.BodyFat"> | |||
| </resultMap> | |||
| <!-- 用于select查询公用抽取的列 --> | |||
| <sql id="BodyFatColumns"> | |||
| <![CDATA[ | |||
| body_fat_id as bodyFatId, | |||
| app_user_id as appUserId, | |||
| sub_user_id as subUserId, | |||
| device_id as deviceId, | |||
| weight as weight, | |||
| weight_unit as weightUnit, | |||
| weight_point as weightPoint, | |||
| bmi as bmi, | |||
| bfr as bfr, | |||
| sfr as sfr, | |||
| uvi as uvi, | |||
| rom as rom, | |||
| bmr as bmr, | |||
| bm as bm, | |||
| vwc as vwc, | |||
| body_age as bodyAge, | |||
| pp as pp, | |||
| adc as adc, | |||
| create_time as createTime, | |||
| upload_time as uploadTime, | |||
| heart_rate as heartRate, | |||
| deviceAlgorithm as deviceAlgorithm | |||
| ]]> | |||
| </sql> | |||
| <!-- useGeneratedKeys="true" keyProperty="xxx" for sqlserver and mysql --> | |||
| <insert id="insert" parameterType="com.inet.ailink.receiver.entity.BodyFat" | |||
| useGeneratedKeys="true" keyProperty="bodyFatId" | |||
| flushCache="true"> | |||
| <![CDATA[ | |||
| INSERT INTO | |||
| body_fat ( | |||
| app_user_id, | |||
| sub_user_id, | |||
| device_id, | |||
| weight, | |||
| weight_unit, | |||
| weight_point, | |||
| bmi, | |||
| bfr, | |||
| sfr, | |||
| uvi, | |||
| rom, | |||
| bmr, | |||
| bm, | |||
| vwc, | |||
| body_age, | |||
| pp, | |||
| adc, | |||
| create_time, | |||
| upload_time, | |||
| heart_rate, | |||
| deviceAlgorithm, | |||
| calculationTimes, | |||
| source | |||
| ) VALUES ( | |||
| #{appUserId,javaType=integer,jdbcType=INTEGER}, | |||
| #{subUserId,javaType=integer,jdbcType=INTEGER}, | |||
| #{deviceId,javaType=integer,jdbcType=INTEGER}, | |||
| #{weight,javaType=string,jdbcType=VARCHAR}, | |||
| #{weightUnit,javaType=string,jdbcType=VARCHAR}, | |||
| #{weightPoint,javaType=string,jdbcType=VARCHAR}, | |||
| #{bmi,javaType=string,jdbcType=VARCHAR}, | |||
| #{bfr,javaType=string,jdbcType=VARCHAR}, | |||
| #{sfr,javaType=string,jdbcType=VARCHAR}, | |||
| #{uvi,javaType=string,jdbcType=VARCHAR}, | |||
| #{rom,javaType=string,jdbcType=VARCHAR}, | |||
| #{bmr,javaType=string,jdbcType=VARCHAR}, | |||
| #{bm,javaType=string,jdbcType=VARCHAR}, | |||
| #{vwc,javaType=string,jdbcType=VARCHAR}, | |||
| #{bodyAge,javaType=string,jdbcType=VARCHAR}, | |||
| #{pp,javaType=string,jdbcType=VARCHAR}, | |||
| #{adc,javaType=string,jdbcType=VARCHAR}, | |||
| #{createTimeLong,javaType=long,jdbcType=BIGINT}, | |||
| #{uploadTime,javaType=date,jdbcType=TIMESTAMP}, | |||
| #{heartRate,javaType=string,jdbcType=VARCHAR}, | |||
| #{deviceAlgorithm,javaType=string,jdbcType=VARCHAR}, | |||
| #{calculationTimes,javaType=integer,jdbcType=INTEGER}, | |||
| #{source,javaType=integer,jdbcType=INTEGER} | |||
| ) | |||
| ]]> | |||
| </insert> | |||
| <delete id="delete" parameterType="java.lang.Long"> | |||
| <![CDATA[ | |||
| delete from body_fat | |||
| where body_fat_id = #{bodyFatId} | |||
| ]]> | |||
| </delete> | |||
| <select id="getById" parameterType="long" resultMap="BodyFatResult" flushCache="false"> | |||
| select <include refid="BodyFatColumns" /> | |||
| <![CDATA[ | |||
| from body_fat | |||
| where body_fat_id = #{bodyFatId} | |||
| ]]> | |||
| </select> | |||
| <select id="getByIds" parameterType="list" resultMap="BodyFatResult" flushCache="false"> | |||
| select <include refid="BodyFatColumns" /> | |||
| from body_fat | |||
| where body_fat_id in | |||
| <foreach item="item" index="index" collection="list" open="(" separator="," close=")"> | |||
| #{item} </foreach> | |||
| </select> | |||
| </mapper> | |||