|
|
|
|
@ -1,9 +1,12 @@
|
|
|
|
|
package cn.iocoder.yudao.module.mes.controller.admin.mqtt;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.controller.admin.mqttdatarecord.vo.MqttDataRecordPageReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.controller.admin.mqttrecord.vo.MqttRecordSaveReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.dal.dataobject.formula.FormulaRecordDO;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.dal.dataobject.mqttdatarecord.MqttDataRecordDO;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.dal.mysql.formula.FormulaRecordMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.dal.mysql.mqttdatarecord.MqttDataRecordMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.service.mqttrecord.MqttRecordService;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
@ -80,4 +83,31 @@ public class MqttServerDataController {
|
|
|
|
|
public CommonResult<BigDecimal> getSum(MqttDataRecordPageReqVO reqVO) {
|
|
|
|
|
return success(mqttDataRecordMapper.selectSum(reqVO));
|
|
|
|
|
}
|
|
|
|
|
@Resource
|
|
|
|
|
private FormulaRecordMapper formulaRecordMapper;
|
|
|
|
|
@GetMapping("/getSimulateValue")
|
|
|
|
|
@Operation(summary = "模拟数据最新值")
|
|
|
|
|
public CommonResult<String> getSimulateValue(@RequestParam("random")int random,@RequestParam("type")String type
|
|
|
|
|
,@RequestParam("id")Long id,@RequestParam("plusValue") double plusValue) {
|
|
|
|
|
if(id!=null){
|
|
|
|
|
FormulaRecordDO recordDO = formulaRecordMapper.selectById(id);
|
|
|
|
|
if(recordDO==null)return success("0.000");
|
|
|
|
|
if(random == 1){
|
|
|
|
|
if(type.equals("int")){
|
|
|
|
|
int i = RandomUtil.randomInt(1,10);
|
|
|
|
|
recordDO.setDataValue(recordDO.getDataValue().add(BigDecimal.valueOf(i)));
|
|
|
|
|
}
|
|
|
|
|
if(type.equals("double")){
|
|
|
|
|
double i = RandomUtil.randomDouble(1,10);
|
|
|
|
|
recordDO.setDataValue(recordDO.getDataValue().add(BigDecimal.valueOf(i)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
recordDO.setDataValue(recordDO.getDataValue().add(BigDecimal.valueOf(plusValue)));
|
|
|
|
|
}
|
|
|
|
|
formulaRecordMapper.updateById(recordDO);
|
|
|
|
|
return success(recordDO.getDataValue().toString());
|
|
|
|
|
}
|
|
|
|
|
return success("0.000");
|
|
|
|
|
}
|
|
|
|
|
}
|