Commit 4170a3e7 by huangjy

feat:批量编辑长者,批量编辑设备属性

parent daa119d8
......@@ -81,4 +81,24 @@ public class IotDevicePropertiesOperateService extends IotCommonService {
}
public String deviceWriteAttr(String deviceId, Map<String, Object> map) {
String url = iotUrl + DEVICE_PREFIX_URL + deviceId + "/property";
for (Map.Entry<String, Object> entry : map.entrySet()) {
String body = JsonUtil.toJson(entry);
HttpRequest request = buildRequest(url, body);
try {
ResponseMessage responseMessage = sendPut(url, request);
log.info("写入设备属性信息,返回信息:{}", responseMessage.getMessage());
if (responseMessage.getStatus() != 200) {
String errorMsg = "设备:" + deviceId + ",属性:" + entry.getKey() + "写入失败:" + responseMessage.getMessage();
log.error("设备写入失败:{}",errorMsg);
return errorMsg;
}
} catch (IOException e) {
log.error("调用:{}接口异常:{}", url, e.getMessage());
}
}
return "";
}
}
......@@ -6,6 +6,7 @@ import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.device.PlatDeviceAttrDTO;
import com.makeit.dto.platform.device.PlatDeviceEditDTO;
import com.makeit.dto.platform.device.PlatDeviceQueryDTO;
import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO;
......@@ -94,5 +95,13 @@ public class PlatDeviceController {
platDeviceService.editDeviceProperties(dto);
return ApiResponseUtils.success();
}
@ApiOperation(value = "批量编辑设备属性",notes = "批量编辑属性,仅相同产品类型的设备可批量编辑属性,点击展示该产品类型的可编辑属性(呼吸心率设备不可编辑设备属性,空间可编辑雷达安装方式和雷达功能模式,跌倒可编辑雷达安装高度")
@PostMapping("batchEditProperties")
public ApiResponseEntity<List<String>> batchEditProperties(@RequestBody PlatDeviceAttrDTO dto) {
platDeviceService.batchEditProperties(dto);
return ApiResponseUtils.success();
}
}
......@@ -13,6 +13,7 @@ import com.makeit.dto.platform.elder.PlatElderCheckInDTO;
import com.makeit.dto.platform.elder.PlatElderCheckOutDTO;
import com.makeit.dto.platform.elder.PlatElderQueryDTO;
import com.makeit.dto.platform.elder.add.PlatElderAddDTO;
import com.makeit.dto.platform.elder.add.PlatElderBatchEditDTOVO;
import com.makeit.dto.platform.elder.add.PlatElderDTOVO;
import com.makeit.service.platform.elder.PlatElderService;
import com.makeit.vo.platform.elder.PlatElderListVO;
......@@ -95,6 +96,13 @@ public class PlatElderController {
return ApiResponseUtils.success();
}
@ApiOperation("批量编辑")
@PostMapping("batchEdit")
public ApiResponseEntity<?> batchEdit( @RequestBody PlatElderBatchEditDTOVO dto) {
platElderService.batchEdit(dto);
return ApiResponseUtils.success();
}
@ApiOperation("详情")
@PostMapping("view")
public ApiResponseEntity<PlatElderDTOVO> view(@RequestBody BaseIdDTO baseIdDTO) {
......
package com.makeit.dto.platform.device;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel(value = "PlatDevice设备属性对象", description = "批量编辑设备属性")
public class PlatDeviceAttrDTO extends PlatDeviceBaseAttrDTO {
@ApiModelProperty(value = "设备id集合 不是id是oriDeviceId")
private List<String> deviceIdList;
}
package com.makeit.dto.platform.device;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel(value = "设备属性基类对象", description = "设备属性基类")
public class PlatDeviceBaseAttrDTO {
@ApiModelProperty(value = "雷达安装方式 雷达安装方式 初始安装时,空间要配置:侧装轨迹模式, 跌倒要配置:顶装,实际安装高度;不需要改变")
private Integer radarMount;
@ApiModelProperty(value = "雷达功能模式 默认侧装轨迹\n" +
"侧装下\n" +
"0为存在模式,1为轨迹模式;\n" +
"顶装下\n" +
"0为存在模式,1为区块模式;")
private Integer radarMode;
@ApiModelProperty(value = "\"最小值\":200,\"最大值\":380,\"步\n" +
"进\":1,\"单位\":\"cm\"")
private Integer radarHight;
}
package com.makeit.dto.platform.elder.add;
import com.makeit.common.dto.BaseTenantDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* <p>
* 长者基本信息
* </p>
*
* @author eugene young
* @since 2023-08-29
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "Elder批量变价对象", description = "长者批量编辑DTO")
public class PlatElderBatchEditDTOVO extends BaseTenantDTO {
@ApiModelProperty(value = "ID 添加不需要传此参数")
private List<String> idList;
@ApiModelProperty(value = "呼吸率,范围用-区分")
private String respiratoryRate;
@ApiModelProperty(value = "呼吸率异常时间 单位:s")
private String respiratoryExceptionTime;
@ApiModelProperty(value = "心率,范围用-区分")
private String heartRate;
@ApiModelProperty(value = "心率异常时间 单位 s")
private String heartExceptionTime;
}
package com.makeit.dto.wechat.device;
import com.makeit.dto.platform.device.PlatDeviceBaseAttrDTO;
import com.makeit.module.iot.dto.UserServerInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......@@ -15,21 +16,11 @@ import lombok.Data;
*/
@Data
@ApiModel(value = "PlatDeviceAttrWechatDTO对象", description = "设备属性 跌倒:安装方式 安装高度 空间人体:安装方式 功能模式")
public class PlatDeviceAttrWechatDTO {
public class PlatDeviceAttrWechatDTO extends PlatDeviceBaseAttrDTO {
@ApiModelProperty(value = "设备id")
private String deviceId;
@ApiModelProperty(value = "雷达安装方式 雷达安装方式")
private Integer radarMount;
@ApiModelProperty(value = "雷达功能模式 默认侧装轨迹\n" +
"侧装下\n" +
"0为存在模式,1为轨迹模式;\n" +
"顶装下\n" +
"0为存在模式,1为区块模式;")
private Integer radarMode;
@ApiModelProperty(value = "\"最小值\":200,\"最大值\":380,\"步\n" +
"进\":1,\"单位\":\"cm\"")
private Integer radarHight;
@ApiModelProperty(value = "读取硬件的系统参数,主要读取服务信息和雷达信息,多个逗号隔开")
private String readProperties;
......
......@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.dataScreen.PlatDataScreenQueryDTO;
import com.makeit.dto.platform.device.PlatDeviceAttrDTO;
import com.makeit.dto.platform.device.PlatDeviceDetailDTO;
import com.makeit.dto.platform.device.PlatDeviceEditDTO;
import com.makeit.dto.platform.device.PlatDeviceQueryDTO;
......@@ -71,6 +72,5 @@ public interface PlatDeviceService extends IService<PlatDevice> {
PlatDeviceViewVO viewByDeviceId(String id);
boolean updateDeviceStatus(String messageType, String deviceId, String iot_tenantId);
void batchEditProperties(PlatDeviceAttrDTO dto);
}
......@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.makeit.common.dto.BaseTenantDTO;
import com.makeit.common.entity.BaseBusEntity;
......@@ -14,9 +15,7 @@ import com.makeit.common.entity.BaseEntity;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.dataScreen.PlatDataScreenQueryDTO;
import com.makeit.dto.platform.device.PlatDeviceDetailDTO;
import com.makeit.dto.platform.device.PlatDeviceEditDTO;
import com.makeit.dto.platform.device.PlatDeviceQueryDTO;
import com.makeit.dto.platform.device.*;
import com.makeit.dto.saas.device.PlatDeviceEditSaasDTO;
import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO;
......@@ -403,6 +402,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
@Override
public void editDeviceProperties(PlatDeviceAttrWechatDTO dto) {
log.info("写入设备属性请求参数:{}",JSON.toJSONString(dto));
String deviceId = dto.getDeviceId();
PlatDeviceOther other = platDeviceOtherService.getOne(new QueryWrapper<PlatDeviceOther>().lambda()
.eq(PlatDeviceOther::getOriDeviceId, deviceId));
......@@ -417,8 +417,11 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
platDeviceOtherService.updateById(other);
}
log.info("写入设备属性请求参数:{}",JSON.toJSONString(dto));
devicePropertiesOperateService.deviceWrite(deviceId, dto.getRadarMount(), dto.getRadarMode(), dto.getRadarHight(), usrServerInfo);
Map<String, Object> map = getAttrMap(dto);
if (dto.getUsrServerInfo() != null) {
map.put("usrServerInfo",JSON.toJSONString(dto.getUsrServerInfo()));
}
devicePropertiesOperateService.deviceWriteAttr(deviceId, map);
if (dto.getRadarMount() != null) {
//更新区域设置设备安装方式
......@@ -426,7 +429,40 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
.set(PlatRegionSetting::getInstallType, dto.getRadarMount())
.eq(PlatRegionSetting::getDeviceId, deviceId));
}
}
private static Map<String, Object> getAttrMap(PlatDeviceBaseAttrDTO dto) {
Map<String, Object> map = Maps.newHashMap();
if (dto.getRadarMount() != null) {
map.put("radarMount", dto.getRadarMount());
}
if (dto.getRadarMode() != null) {
map.put("radarMode", dto.getRadarMode());
}
if (dto.getRadarHight() != null) {
map.put("radarHight", dto.getRadarHight() );
}
return map;
}
@Override
public void batchEditProperties(PlatDeviceAttrDTO dto) {
if (CollectionUtils.isEmpty(dto.getDeviceIdList())) {
return;
}
PlatDeviceOther other = platDeviceOtherService.getOne(new QueryWrapper<PlatDeviceOther>().lambda()
.eq(PlatDeviceOther::getOriDeviceId, dto.getDeviceIdList()));
Map<String, Object> map = getAttrMap(dto);
List<String> resultList = Lists.newArrayList();
for (String deviceId : dto.getDeviceIdList()) {
String result = devicePropertiesOperateService.deviceWriteAttr(deviceId, map);
if (StringUtils.isNotEmpty(result)) {
resultList.add(result);
}
}
if (CollectionUtils.isNotEmpty(resultList)) {
throw new RuntimeException("修改设备属性失败:" + resultList.get(0));
}
}
@Override
......
......@@ -6,6 +6,7 @@ import com.makeit.common.page.PageVO;
import com.makeit.common.vo.ExcelImportVo;
import com.makeit.dto.platform.elder.*;
import com.makeit.dto.platform.elder.add.PlatElderAddDTO;
import com.makeit.dto.platform.elder.add.PlatElderBatchEditDTOVO;
import com.makeit.dto.platform.elder.add.PlatElderDTOVO;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.elder.PlatElder;
......@@ -62,6 +63,8 @@ public interface PlatElderService extends IService<PlatElder> {
/*小程序*/
List<PlatElderWechatSimpleVO> listMy();
void batchEdit(PlatElderBatchEditDTOVO dto);
/*小程序*/
}
......@@ -837,8 +837,20 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
if (StringUtils.isNotBlank(oldBedId) && !oldBedId.equals(dto.getBedId())) {
checkOutInternal(oldBedId);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void batchEdit(PlatElderBatchEditDTOVO dto) {
if (CollectionUtils.isEmpty(dto.getIdList())) {
return;
}
List<PlatElderHealthInfo> healthInfoList = platElderHealthInfoService.list(new QueryWrapper<PlatElderHealthInfo>().lambda()
.in(PlatElderHealthInfo::getElderId, dto.getIdList()));
for (PlatElderHealthInfo elderHealthInfo : healthInfoList) {
BeanUtils.copyProperties(dto, elderHealthInfo);
platElderHealthInfoService.saveOrUpdate(elderHealthInfo);
}
}
//@TenantIdIgnore
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment