feat: 增加热成像采集配置的查询和修改功能,以及装置属性
parent
13dacfc2b9
commit
026b71da94
@ -0,0 +1,13 @@
|
|||||||
|
ALTER TABLE `n_sensor`
|
||||||
|
ADD COLUMN `ip` VARCHAR(45) NULL AFTER `order_num`,
|
||||||
|
ADD COLUMN `port` INT NULL AFTER `ip`,
|
||||||
|
ADD COLUMN `username` VARCHAR(45) NULL AFTER `port`,
|
||||||
|
ADD COLUMN `passwd` VARCHAR(45) NULL AFTER `username`;
|
||||||
|
|
||||||
|
CREATE TABLE `thermal_config` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`type_id` int(11) DEFAULT NULL COMMENT '类型id',
|
||||||
|
`maxtemp` varchar(45) DEFAULT NULL,
|
||||||
|
`mintemp` varchar(45) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.xydl.cac.controller;
|
||||||
|
|
||||||
|
import com.xydl.cac.model.Response;
|
||||||
|
import com.xydl.cac.model.ThermalConfigModel;
|
||||||
|
import com.xydl.cac.service.ThermalConfigService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Api(tags = {"热成像测温相关接口"})
|
||||||
|
@RequestMapping("thermal")
|
||||||
|
@Slf4j
|
||||||
|
public class ThermalConfigController extends BasicController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ThermalConfigService configService;
|
||||||
|
|
||||||
|
@GetMapping("getConfig")
|
||||||
|
@ApiOperation("查询配置")
|
||||||
|
public Response<ThermalConfigModel> getConfig() {
|
||||||
|
ThermalConfigModel result = configService.getConfig();
|
||||||
|
return Response.success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("saveConfig")
|
||||||
|
@ApiOperation("修改配置")
|
||||||
|
public Response<String> saveConfig(@Validated @RequestBody ThermalConfigModel model) throws Exception {
|
||||||
|
configService.saveConfig(model);
|
||||||
|
return Response.success("OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.xydl.cac.entity;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Entity
|
||||||
|
@Table(name = "thermal_config")
|
||||||
|
@ApiModel("热成像测温配置表")
|
||||||
|
public class ThermalConfig {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "id")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@Column(name = "type_id")
|
||||||
|
@ApiModelProperty("类型Id")
|
||||||
|
private Integer typeId;
|
||||||
|
|
||||||
|
@ApiModelProperty("最高温字段")
|
||||||
|
@Column(name = "maxtemp")
|
||||||
|
private String maxtemp;
|
||||||
|
|
||||||
|
@ApiModelProperty("最低温字段")
|
||||||
|
@Column(name = "mintemp")
|
||||||
|
private String mintemp;
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.xydl.cac.model;
|
||||||
|
|
||||||
|
import com.xydl.cac.entity.ThermalConfig;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ThermalConfigModel {
|
||||||
|
@NotNull(message = "typeId不能为空")
|
||||||
|
Integer typeId;
|
||||||
|
@NotNull(message = "list不能为空")
|
||||||
|
List<ThermalConfig> list;
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.xydl.cac.repository;
|
||||||
|
|
||||||
|
import com.xydl.cac.entity.ThermalConfig;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface ThermalConfigRepository extends JpaRepository<ThermalConfig, Integer>, JpaSpecificationExecutor<ThermalConfig> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.xydl.cac.service;
|
||||||
|
|
||||||
|
import com.xydl.cac.model.ThermalConfigModel;
|
||||||
|
|
||||||
|
|
||||||
|
public interface ThermalConfigService {
|
||||||
|
|
||||||
|
ThermalConfigModel getConfig();
|
||||||
|
|
||||||
|
void saveConfig(ThermalConfigModel model);
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package com.xydl.cac.service.impl;
|
||||||
|
|
||||||
|
import com.xydl.cac.entity.ThermalConfig;
|
||||||
|
import com.xydl.cac.model.ThermalConfigModel;
|
||||||
|
import com.xydl.cac.repository.ThermalConfigRepository;
|
||||||
|
import com.xydl.cac.service.ThermalConfigService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public class ThermalConfigServiceImpl implements ThermalConfigService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ThermalConfigRepository repository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ThermalConfigModel getConfig() {
|
||||||
|
ThermalConfigModel model = new ThermalConfigModel();
|
||||||
|
List<ThermalConfig> list = repository.findAll();
|
||||||
|
if (!CollectionUtils.isEmpty(list)) {
|
||||||
|
model.setTypeId(list.get(0).getTypeId());
|
||||||
|
model.setList(list);
|
||||||
|
}
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveConfig(ThermalConfigModel model) {
|
||||||
|
repository.deleteAll();
|
||||||
|
for (ThermalConfig item : model.getList()) {
|
||||||
|
item.setId(null);
|
||||||
|
item.setTypeId(model.getTypeId());
|
||||||
|
repository.save(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue