Compare commits
2 Commits
71a3807825
...
dev_2026-0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
608da912ea | ||
|
|
55a9d49a34 |
@@ -0,0 +1,490 @@
|
||||
package iot.lidee.scada.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import iot.lidee.common.annotation.Anonymous;
|
||||
import iot.lidee.common.annotation.Log;
|
||||
import iot.lidee.common.config.RuoYiConfig;
|
||||
import iot.lidee.common.constant.HttpStatus;
|
||||
import iot.lidee.common.core.controller.BaseController;
|
||||
import iot.lidee.common.core.domain.AjaxResult;
|
||||
import iot.lidee.common.core.page.TableDataInfo;
|
||||
import iot.lidee.common.enums.BusinessType;
|
||||
import iot.lidee.common.exception.ServiceException;
|
||||
import iot.lidee.common.exception.file.InvalidExtensionException;
|
||||
import iot.lidee.common.utils.StringUtils;
|
||||
import iot.lidee.common.utils.file.MimeTypeUtils;
|
||||
import iot.lidee.common.utils.poi.ExcelUtil;
|
||||
import iot.lidee.iot.domain.Device;
|
||||
import iot.lidee.iot.model.DeviceShortOutput;
|
||||
import iot.lidee.iot.model.ThingsModelItem.Datatype;
|
||||
import iot.lidee.iot.model.ThingsModelItem.ThingsModel;
|
||||
import iot.lidee.iot.model.ThingsModels.ThingsModelValueItem;
|
||||
import iot.lidee.iot.service.IDeviceService;
|
||||
import iot.lidee.scada.domain.Scada;
|
||||
import iot.lidee.scada.domain.ScadaDeviceBind;
|
||||
import iot.lidee.scada.domain.ScadaGallery;
|
||||
import iot.lidee.scada.service.IScadaDeviceBindService;
|
||||
import iot.lidee.scada.service.IScadaService;
|
||||
import iot.lidee.scada.utils.ScadaCollectionUtils;
|
||||
import iot.lidee.scada.utils.ScadaFileUploadUtils;
|
||||
import iot.lidee.scada.utils.ScadaFileUtils;
|
||||
import iot.lidee.scada.vo.DeviceRealDataVO;
|
||||
import iot.lidee.scada.vo.FavoritesVO;
|
||||
import iot.lidee.scada.vo.ScadaDeviceBindDTO;
|
||||
import iot.lidee.scada.vo.ThingsModelHistoryParam;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 组态中心Controller
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2023-11-10
|
||||
*/
|
||||
@Anonymous
|
||||
@Api(tags = "组态中心")
|
||||
@RestController
|
||||
@RequestMapping("/scada/picture")
|
||||
public class ScadaPictureController extends BaseController
|
||||
{
|
||||
@Resource
|
||||
private IScadaService scadaService;
|
||||
|
||||
@Resource
|
||||
private IScadaDeviceBindService scadaDeviceBindService;
|
||||
|
||||
@Resource
|
||||
private IDeviceService deviceService;
|
||||
|
||||
/**
|
||||
* 查询组态中心列表
|
||||
*/
|
||||
@ApiOperation("查询组态中心列表")
|
||||
@PreAuthorize("@ss.hasPermi('scada:center:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(Scada scada)
|
||||
{
|
||||
startPage();
|
||||
List<Scada> list = scadaService.selectScadaList(scada);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出组态中心列表
|
||||
*/
|
||||
@ApiOperation("导出组态中心列表")
|
||||
@PreAuthorize("@ss.hasPermi('scada:center:export')")
|
||||
@Log(title = "组态中心", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, Scada scada)
|
||||
{
|
||||
List<Scada> list = scadaService.selectScadaList(scada);
|
||||
ExcelUtil<Scada> util = new ExcelUtil<Scada>(Scada.class);
|
||||
util.exportExcel(response, list, "组态中心数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取组态中心详细信息
|
||||
*/
|
||||
@ApiOperation("查询组态详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('scada:center:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(scadaService.selectScadaById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增组态中心
|
||||
*/
|
||||
@ApiOperation("新增组态中心")
|
||||
@PreAuthorize("@ss.hasPermi('scada:center:add')")
|
||||
@Log(title = "组态中心", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Scada scada)
|
||||
{
|
||||
return scadaService.insertScada(scada);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改组态中心
|
||||
*/
|
||||
@ApiOperation("修改组态中心")
|
||||
@PreAuthorize("@ss.hasPermi('scada:center:edit')")
|
||||
@Log(title = "组态中心", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody Scada scada)
|
||||
{
|
||||
return toAjax(scadaService.updateScada(scada));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除组态中心
|
||||
*/
|
||||
@ApiOperation("批量删除组态中心")
|
||||
@PreAuthorize("@ss.hasPermi('scada:center:remove')")
|
||||
@Log(title = "组态中心", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(scadaService.deleteScadaByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据guid获取组态详情
|
||||
* @param guid 组态id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("根据guid获取组态详情")
|
||||
@PreAuthorize("@ss.hasPermi('scada:center:query')")
|
||||
@GetMapping(value = "/getByGuid")
|
||||
public AjaxResult getByGuid(String guid) {
|
||||
Scada scada = scadaService.selectScadaByGuid(guid);
|
||||
return AjaxResult.success(scada);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存组态信息
|
||||
*/
|
||||
@ApiOperation("保存组态信息")
|
||||
@Log(title = "组态中心", businessType = BusinessType.INSERT)
|
||||
@PreAuthorize("@ss.hasPermi('scada:center:edit')")
|
||||
@PostMapping("/save")
|
||||
public AjaxResult save(@RequestBody Scada scada)
|
||||
{
|
||||
if (StringUtils.isEmpty(scada.getGuid())) {
|
||||
return AjaxResult.error("guid不能为空");
|
||||
}
|
||||
Scada scadaQuery = new Scada();
|
||||
scadaQuery.setGuid(scada.getGuid());
|
||||
List<Scada> scadaList = scadaService.selectScadaList(scadaQuery);
|
||||
if (StringUtils.isNotEmpty(scada.getBase64())) {
|
||||
MultipartFile multipartFile = ScadaFileUtils.base64toMultipartFile(scada.getBase64());
|
||||
String url;
|
||||
try {
|
||||
url = ScadaFileUploadUtils.upload(RuoYiConfig.getUploadPath(), multipartFile, MimeTypeUtils.IMAGE_EXTENSION);
|
||||
} catch (IOException | InvalidExtensionException e) {
|
||||
throw new ServiceException("修改组态base64转图片异常" + e.getMessage());
|
||||
}
|
||||
scada.setPageImage(url);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(scadaList)) {
|
||||
Scada updateScada = scadaList.get(0);
|
||||
updateScada.setScadaData(scada.getScadaData());
|
||||
updateScada.setPageImage(scada.getPageImage());
|
||||
scadaService.updateScada(updateScada);
|
||||
} else {
|
||||
scadaService.insertScada(scada);
|
||||
// scadaDeviceBindService.insertScadaDeviceBind()
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取组态绑定的设备数,一个组态可以绑定多个设备,用于多个设备的参数绑定
|
||||
* @param scadaDeviceBind 组态guid
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("获取组态绑定的设备列表")
|
||||
@PreAuthorize("@ss.hasPermi('scada:center:query')")
|
||||
@GetMapping(value = "/listDeviceBind")
|
||||
public TableDataInfo listDeviceBind(ScadaDeviceBind scadaDeviceBind) {
|
||||
startPage();
|
||||
List<ScadaDeviceBind> list = scadaDeviceBindService.selectScadaDeviceBindList(scadaDeviceBind);
|
||||
// List<DeviceAllShortOutput> deviceAllShortOutputs = deviceService.selectAllDeviceShortList();
|
||||
// Map<String, String> collect = deviceAllShortOutputs.stream().collect(Collectors.toMap(DeviceAllShortOutput::getSerialNumber, DeviceAllShortOutput::getDeviceName));
|
||||
for (ScadaDeviceBind deviceZtBind : list) {
|
||||
Device device = deviceService.selectShortDeviceBySerialNumber(deviceZtBind.getSerialNumber());
|
||||
if (device != null) {
|
||||
deviceZtBind.setDeviceName(device.getDeviceName());
|
||||
deviceZtBind.setStatus(device.getStatus());
|
||||
}
|
||||
}
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存组态关联设备
|
||||
* @param scadaDeviceBindDTO 组态关联设备
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("保存组态关联设备")
|
||||
@PreAuthorize("@ss.hasPermi('scada:center:edit')")
|
||||
@PostMapping("/saveDeviceBind")
|
||||
public AjaxResult saveDeviceBind(@RequestBody ScadaDeviceBindDTO scadaDeviceBindDTO)
|
||||
{
|
||||
if (StringUtils.isEmpty(scadaDeviceBindDTO.getScadaGuid()) || StringUtils.isEmpty(scadaDeviceBindDTO.getSerialNumbers())) {
|
||||
return error("请选择设备");
|
||||
}
|
||||
List<String> addSerialNumberList = StringUtils.str2List(scadaDeviceBindDTO.getSerialNumbers(), ",", true, true);
|
||||
List<ScadaDeviceBind> scadaDeviceBindList = scadaDeviceBindService.listByGuidAndSerialNumber(scadaDeviceBindDTO.getScadaGuid(), addSerialNumberList);
|
||||
List<String> oldSerialNumberList = scadaDeviceBindList.stream().map(ScadaDeviceBind::getSerialNumber).collect(Collectors.toList());
|
||||
for (String serialNumber : addSerialNumberList) {
|
||||
if (oldSerialNumberList.contains(serialNumber)) {
|
||||
continue;
|
||||
}
|
||||
ScadaDeviceBind scadaDeviceBind = new ScadaDeviceBind();
|
||||
scadaDeviceBind.setScadaGuid(scadaDeviceBindDTO.getScadaGuid());
|
||||
scadaDeviceBind.setSerialNumber(serialNumber);
|
||||
scadaDeviceBindService.insertScadaDeviceBind(scadaDeviceBind);
|
||||
}
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除组态设备关联
|
||||
*/
|
||||
@ApiOperation("删除组态设备关联")
|
||||
@PreAuthorize("@ss.hasPermi('scada:center:edit')")
|
||||
@DeleteMapping("/removeDeviceBind/{ids}")
|
||||
public AjaxResult removeDeviceBind(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(scadaDeviceBindService.deleteScadaDeviceBindByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取绑定设备物模型数据,用于绑定变量
|
||||
* @param scadaGuid 组态guid
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("获取绑定设备物模型列表")
|
||||
@PreAuthorize("@ss.hasPermi('scada:center:query')")
|
||||
@GetMapping("/listDeviceThingsModel")
|
||||
public TableDataInfo getBindDatalist(Integer pageNum, Integer pageSize, String scadaGuid, String serialNumber)
|
||||
{
|
||||
List<DeviceRealDataVO> list= new ArrayList<>();
|
||||
if(StringUtils.isEmpty(scadaGuid)){
|
||||
return getDataTable(list);
|
||||
}
|
||||
ScadaDeviceBind scadaDeviceBind = new ScadaDeviceBind();
|
||||
scadaDeviceBind.setScadaGuid(scadaGuid);
|
||||
scadaDeviceBind.setSerialNumber(serialNumber);
|
||||
// 查询到组态绑定的设备
|
||||
List<ScadaDeviceBind> deviceBindList = scadaDeviceBindService.selectScadaDeviceBindList(scadaDeviceBind);
|
||||
List<String> serialNumberList = deviceBindList.stream().map(ScadaDeviceBind::getSerialNumber).collect(Collectors.toList());
|
||||
// 查询设备信息
|
||||
for (String bindSerialNumber : serialNumberList) {
|
||||
Device device = deviceService.selectDeviceNoModel(bindSerialNumber);
|
||||
if (device == null) {
|
||||
continue;
|
||||
}
|
||||
DeviceShortOutput deviceShortOutput = deviceService.selectDeviceRunningStatusByDeviceId(device.getDeviceId());
|
||||
if (CollectionUtils.isEmpty(deviceShortOutput.getThingsModels())) {
|
||||
continue;
|
||||
}
|
||||
List<ThingsModelValueItem> thingsModelList = deviceShortOutput.getThingsModels();
|
||||
for (ThingsModelValueItem thingsModel : thingsModelList) {
|
||||
Datatype datatype = thingsModel.getDatatype();
|
||||
if ("array".equals(datatype.getType()) && "object".equals(datatype.getArrayType())) {
|
||||
List<ThingsModel>[] arrayParams = datatype.getArrayParams();
|
||||
for (int a = 0; a < arrayParams.length; a++) {
|
||||
for (int i = 0; i < arrayParams[a].size(); i++) {
|
||||
ThingsModel thingsModel1 = arrayParams[a].get(i);
|
||||
DeviceRealDataVO deviceRealDataVO = new DeviceRealDataVO();
|
||||
deviceRealDataVO.setProductId(device.getProductId());
|
||||
deviceRealDataVO.setSerialNumber(bindSerialNumber);
|
||||
deviceRealDataVO.setDeviceName(device.getDeviceName());
|
||||
deviceRealDataVO.setStatus(device.getStatus());
|
||||
if (i < 10) {
|
||||
deviceRealDataVO.setIdentifier("array_0" + a + "_" + thingsModel1.getId());
|
||||
} else {
|
||||
deviceRealDataVO.setIdentifier("array_" + a + "_" + thingsModel1.getId());
|
||||
}
|
||||
deviceRealDataVO.setModelName(thingsModel.getName() + (a + 1) + "_" + thingsModel1.getName());
|
||||
deviceRealDataVO.setUnit(thingsModel1.getDatatype().getUnit());
|
||||
deviceRealDataVO.setType(thingsModel1.getType());
|
||||
list.add(deviceRealDataVO);
|
||||
}
|
||||
}
|
||||
} else if ("array".equals(datatype.getType())) {
|
||||
for (int i = 0; i < datatype.getArrayCount(); i++) {
|
||||
DeviceRealDataVO deviceRealDataVO = new DeviceRealDataVO();
|
||||
deviceRealDataVO.setProductId(device.getProductId());
|
||||
deviceRealDataVO.setSerialNumber(bindSerialNumber);
|
||||
deviceRealDataVO.setDeviceName(device.getDeviceName());
|
||||
deviceRealDataVO.setStatus(device.getStatus());
|
||||
if (i < 10) {
|
||||
deviceRealDataVO.setIdentifier("array_0" + i + "_" + thingsModel.getId());
|
||||
} else {
|
||||
deviceRealDataVO.setIdentifier("array_" + i + "_" + thingsModel.getId());
|
||||
}
|
||||
deviceRealDataVO.setModelName(thingsModel.getName() + (i+1));
|
||||
deviceRealDataVO.setUnit(datatype.getUnit());
|
||||
deviceRealDataVO.setType(thingsModel.getType());
|
||||
list.add(deviceRealDataVO);
|
||||
}
|
||||
} else if ("object".equals(datatype.getType())) {
|
||||
for (ThingsModelValueItem objectThingsModel : datatype.getParams()) {
|
||||
DeviceRealDataVO deviceRealDataVO = new DeviceRealDataVO();
|
||||
deviceRealDataVO.setProductId(device.getProductId());
|
||||
deviceRealDataVO.setSerialNumber(bindSerialNumber);
|
||||
deviceRealDataVO.setDeviceName(device.getDeviceName());
|
||||
deviceRealDataVO.setStatus(device.getStatus());
|
||||
deviceRealDataVO.setIdentifier(objectThingsModel.getId());
|
||||
deviceRealDataVO.setModelName(thingsModel.getName() + "_" + objectThingsModel.getName());
|
||||
deviceRealDataVO.setUnit(objectThingsModel.getDatatype().getUnit());
|
||||
deviceRealDataVO.setType(thingsModel.getType());
|
||||
list.add(deviceRealDataVO);
|
||||
}
|
||||
} else {
|
||||
DeviceRealDataVO deviceRealDataVO = new DeviceRealDataVO();
|
||||
deviceRealDataVO.setProductId(device.getProductId());
|
||||
deviceRealDataVO.setSerialNumber(bindSerialNumber);
|
||||
deviceRealDataVO.setDeviceName(device.getDeviceName());
|
||||
deviceRealDataVO.setStatus(device.getStatus());
|
||||
deviceRealDataVO.setIdentifier(thingsModel.getId());
|
||||
deviceRealDataVO.setModelName(thingsModel.getName());
|
||||
deviceRealDataVO.setUnit(thingsModel.getDatatype().getUnit());
|
||||
deviceRealDataVO.setType(thingsModel.getType());
|
||||
list.add(deviceRealDataVO);
|
||||
}
|
||||
}
|
||||
}
|
||||
List resultList = ScadaCollectionUtils.startPage(list, pageNum, pageSize);
|
||||
TableDataInfo rspData = new TableDataInfo();
|
||||
rspData.setCode(HttpStatus.SUCCESS);
|
||||
rspData.setMsg("查询成功");
|
||||
rspData.setRows(resultList);
|
||||
rspData.setTotal(new PageInfo(list).getTotal());
|
||||
return rspData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入json文件
|
||||
* @param file 文件
|
||||
* @param guid guid
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@ApiOperation("组态页面导入json文件")
|
||||
@PreAuthorize("@ss.hasPermi('scada:center:add')")
|
||||
@PostMapping("/importJson")
|
||||
public AjaxResult importJson(MultipartFile file, String guid) throws IOException {
|
||||
InputStream inputStream = file.getInputStream();
|
||||
if(file.isEmpty()){
|
||||
return AjaxResult.error("无效的配置文件");
|
||||
}
|
||||
if(file.getOriginalFilename().indexOf("json")==-1){
|
||||
return AjaxResult.error("无效的配置文件");
|
||||
}
|
||||
Scada scada = new Scada();
|
||||
try {
|
||||
scada = JSON.parseObject(inputStream, Scada.class);
|
||||
}catch (Exception e){
|
||||
return AjaxResult.error("无效的配置文件");
|
||||
}finally {
|
||||
inputStream.close();
|
||||
}
|
||||
Scada oldScada = new Scada();
|
||||
if (StringUtils.isNotEmpty(guid)) {
|
||||
Scada queryScada = new Scada();
|
||||
queryScada.setGuid(guid);
|
||||
List<Scada> scadaList = scadaService.selectScadaList(queryScada);
|
||||
if (CollectionUtils.isNotEmpty(scadaList)) {
|
||||
oldScada = scadaList.get(0);
|
||||
}
|
||||
}
|
||||
if (oldScada == null) {
|
||||
guid= UUID.randomUUID().toString();
|
||||
scada.setGuid(guid);
|
||||
scadaService.insertScada(scada);
|
||||
} else {
|
||||
scada.setId(oldScada.getId());
|
||||
scadaService.updateScada(scada);
|
||||
}
|
||||
return AjaxResult.success("导入成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 收藏图库
|
||||
* @param favoritesVO 图库收藏传参类
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("个人收藏图库")
|
||||
@PostMapping("/saveGalleryFavorites")
|
||||
public AjaxResult saveGalleryFavorites(@RequestBody FavoritesVO favoritesVO) {
|
||||
return scadaService.saveGalleryFavorites(favoritesVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询收藏图库列表
|
||||
* @param scadaGallery 图库类
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("查询个人收藏图库列表")
|
||||
@GetMapping("/listGalleryFavorites")
|
||||
public TableDataInfo listGalleryFavorites(ScadaGallery scadaGallery)
|
||||
{
|
||||
startPage();
|
||||
List<ScadaGallery> list = scadaService.listGalleryFavorites(scadaGallery);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除收藏图库
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("删除个人收藏图库")
|
||||
@DeleteMapping("/deleteGalleryFavorites/{ids}")
|
||||
public AjaxResult deleteGalleryFavorites(@PathVariable Long[] ids) {
|
||||
return scadaService.deleteGalleryFavorites(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 收藏上传图库
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("个人收藏上传图库")
|
||||
@PostMapping("/uploadGalleryFavorites")
|
||||
public AjaxResult uploadGalleryFavorites(MultipartFile file, String categoryName) {
|
||||
return scadaService.uploadGalleryFavorites(file, categoryName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询变量历史数据
|
||||
* @param param 查询条件
|
||||
* @return iot.lidee.common.core.domain.AjaxResult
|
||||
*/
|
||||
@ApiOperation("查询变量历史数据")
|
||||
@PostMapping("/listThingsModelHistory")
|
||||
public AjaxResult listThingsModelHistory(@RequestBody ThingsModelHistoryParam param) {
|
||||
return success(scadaService.listThingsModelHistory(param));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备运行状态
|
||||
* @param serialNumber 设备编号
|
||||
* @return iot.lidee.common.core.domain.AjaxResult
|
||||
*/
|
||||
@ApiOperation("获取设备运行状态")
|
||||
@GetMapping("/getDeviceStatus")
|
||||
public AjaxResult getDeviceStatus(String serialNumber) {
|
||||
return AjaxResult.success(scadaService.getStatusBySerialNumber(serialNumber));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统相关统计信息
|
||||
* @return iot.lidee.common.core.domain.AjaxResult
|
||||
*/
|
||||
@GetMapping(value = "/statistic")
|
||||
@ApiOperation("获取系统相关统计信息")
|
||||
public AjaxResult getDeviceStatistic()
|
||||
{
|
||||
return AjaxResult.success(scadaService.selectStatistic());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package iot.lidee.iot.domain;
|
||||
import iot.lidee.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import iot.lidee.common.annotation.Excel;
|
||||
@@ -14,40 +15,53 @@ import iot.lidee.common.annotation.Excel;
|
||||
* @date 2021-12-16
|
||||
*/
|
||||
@ApiModel(value = "Category", description = "产品分类对象 iot_category")
|
||||
public class Category extends BaseEntity
|
||||
{
|
||||
public class Category extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 产品分类ID */
|
||||
/**
|
||||
* 产品分类ID
|
||||
*/
|
||||
@ApiModelProperty("产品分类ID")
|
||||
private Long categoryId;
|
||||
|
||||
/** 产品分类名称 */
|
||||
/**
|
||||
* 产品分类名称
|
||||
*/
|
||||
@ApiModelProperty("产品分类名称")
|
||||
@Excel(name = "产品分类名称")
|
||||
private String categoryName;
|
||||
|
||||
/** 租户ID */
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@ApiModelProperty("租户ID")
|
||||
@Excel(name = "租户ID")
|
||||
private Long tenantId;
|
||||
|
||||
/** 租户名称 */
|
||||
/**
|
||||
* 租户名称
|
||||
*/
|
||||
@ApiModelProperty("租户名称")
|
||||
@Excel(name = "租户名称")
|
||||
private String tenantName;
|
||||
|
||||
/** 是否系统通用(0-否,1-是) */
|
||||
/**
|
||||
* 是否系统通用(0-否,1-是)
|
||||
*/
|
||||
@ApiModelProperty("是否系统通用(0-否,1-是)")
|
||||
@Excel(name = "是否系统通用", readConverterExp = "0=-否,1-是")
|
||||
private Integer isSys;
|
||||
|
||||
/** 显示顺序 */
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
@ApiModelProperty("显示顺序")
|
||||
@Excel(name = "显示顺序")
|
||||
private Integer orderNum;
|
||||
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
/**
|
||||
* 删除标志(0代表存在 2代表删除)
|
||||
*/
|
||||
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
|
||||
private String delFlag;
|
||||
|
||||
@@ -60,6 +74,10 @@ public class Category extends BaseEntity
|
||||
@ApiModelProperty("机构ID")
|
||||
private Long deptId;
|
||||
|
||||
private Long parentId;
|
||||
|
||||
private String industryCode;
|
||||
|
||||
public Boolean getShowSenior() {
|
||||
return showSenior;
|
||||
}
|
||||
@@ -84,84 +102,95 @@ public class Category extends BaseEntity
|
||||
isAdmin = admin;
|
||||
}
|
||||
|
||||
public void setCategoryId(Long categoryId)
|
||||
{
|
||||
public void setCategoryId(Long categoryId) {
|
||||
this.categoryId = categoryId;
|
||||
}
|
||||
|
||||
public Long getCategoryId()
|
||||
{
|
||||
public Long getCategoryId() {
|
||||
return categoryId;
|
||||
}
|
||||
public void setCategoryName(String categoryName)
|
||||
{
|
||||
|
||||
public void setCategoryName(String categoryName) {
|
||||
this.categoryName = categoryName;
|
||||
}
|
||||
|
||||
public String getCategoryName()
|
||||
{
|
||||
public String getCategoryName() {
|
||||
return categoryName;
|
||||
}
|
||||
public void setTenantId(Long tenantId)
|
||||
{
|
||||
|
||||
public void setTenantId(Long tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
public Long getTenantId()
|
||||
{
|
||||
public Long getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
public void setTenantName(String tenantName)
|
||||
{
|
||||
|
||||
public void setTenantName(String tenantName) {
|
||||
this.tenantName = tenantName;
|
||||
}
|
||||
|
||||
public String getTenantName()
|
||||
{
|
||||
public String getTenantName() {
|
||||
return tenantName;
|
||||
}
|
||||
public void setIsSys(Integer isSys)
|
||||
{
|
||||
|
||||
public void setIsSys(Integer isSys) {
|
||||
this.isSys = isSys;
|
||||
}
|
||||
public Integer getIsSys()
|
||||
{
|
||||
|
||||
public Integer getIsSys() {
|
||||
return isSys;
|
||||
}
|
||||
|
||||
public void setOrderNum(Integer orderNum)
|
||||
{
|
||||
public void setOrderNum(Integer orderNum) {
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
public Integer getOrderNum()
|
||||
{
|
||||
|
||||
public Integer getOrderNum() {
|
||||
return orderNum;
|
||||
}
|
||||
public void setDelFlag(String delFlag)
|
||||
{
|
||||
|
||||
public void setDelFlag(String delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public String getDelFlag()
|
||||
{
|
||||
public String getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public String getIndustryCode() {
|
||||
return industryCode;
|
||||
}
|
||||
|
||||
public void setIndustryCode(String industryCode) {
|
||||
this.industryCode = industryCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("categoryId", getCategoryId())
|
||||
.append("categoryName", getCategoryName())
|
||||
.append("tenantId", getTenantId())
|
||||
.append("tenantName", getTenantName())
|
||||
.append("isSys", getIsSys())
|
||||
.append("orderNum", getOrderNum())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("categoryId", getCategoryId())
|
||||
.append("categoryName", getCategoryName())
|
||||
.append("tenantId", getTenantId())
|
||||
.append("tenantName", getTenantName())
|
||||
.append("isSys", getIsSys())
|
||||
.append("orderNum", getOrderNum())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.append("parentId", getParentId())
|
||||
.append("industryCode", getIndustryCode())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package iot.lidee.iot.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import iot.lidee.common.annotation.Excel;
|
||||
@@ -14,6 +15,7 @@ import iot.lidee.common.core.domain.BaseEntity;
|
||||
* @date 2021-12-16
|
||||
*/
|
||||
@ApiModel(value = "Group", description = "设备分组对象 iot_group")
|
||||
@Data
|
||||
public class Group extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -46,6 +48,11 @@ public class Group extends BaseEntity
|
||||
@ApiModelProperty("删除标志")
|
||||
private String delFlag;
|
||||
|
||||
|
||||
private Long parentId;
|
||||
|
||||
private String industryCode;
|
||||
|
||||
public void setGroupId(Long groupId)
|
||||
{
|
||||
this.groupId = groupId;
|
||||
|
||||
@@ -879,6 +879,9 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
return dataType;
|
||||
}
|
||||
dataType.setType(datatypeJson.getString("type"));
|
||||
if (dataType.getType() == null) {
|
||||
return dataType;
|
||||
}
|
||||
if (dataType.getType().equals("decimal")) {
|
||||
dataType.setMax(datatypeJson.getBigDecimal("max"));
|
||||
dataType.setMin(datatypeJson.getBigDecimal("min"));
|
||||
|
||||
@@ -7,10 +7,7 @@ import iot.lidee.common.core.redis.RedisKeyBuilder;
|
||||
import iot.lidee.common.utils.DateUtils;
|
||||
import iot.lidee.common.utils.StringUtils;
|
||||
import iot.lidee.iot.cache.ITSLCache;
|
||||
import iot.lidee.iot.domain.Device;
|
||||
import iot.lidee.iot.domain.Product;
|
||||
import iot.lidee.iot.domain.ProductModbusJob;
|
||||
import iot.lidee.iot.domain.ProductSubGateway;
|
||||
import iot.lidee.iot.domain.*;
|
||||
import iot.lidee.iot.mapper.*;
|
||||
import iot.lidee.iot.mapper.*;
|
||||
import iot.lidee.iot.model.ChangeProductStatusModel;
|
||||
@@ -60,6 +57,8 @@ public class ProductServiceImpl implements IProductService {
|
||||
private ProductSubGatewayMapper productSubGatewayMapper;
|
||||
@Resource
|
||||
private ProductModbusJobMapper productModbusJobMapper;
|
||||
@Resource
|
||||
private CategoryMapper categoryMapper;
|
||||
|
||||
|
||||
// select cache
|
||||
@@ -253,6 +252,8 @@ public class ProductServiceImpl implements IProductService {
|
||||
}
|
||||
product.setStatus(product.getStatus() == null ? 1 : product.getStatus());
|
||||
product.setCreateTime(DateUtils.getNowDate());
|
||||
Category category = categoryMapper.selectCategoryByCategoryId(product.getCategoryId());
|
||||
product.setCategoryName(category.getCategoryName());
|
||||
productMapper.insertProduct(product);
|
||||
return product;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="industryCode" column="industry_code" />
|
||||
<result property="parentId" column="parent_id" />
|
||||
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="iot.lidee.iot.model.IdAndName" id="CategoryShortResult">
|
||||
@@ -22,12 +25,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCategoryVo">
|
||||
select category_id, category_name, tenant_id, tenant_name, is_sys,order_num, create_time, update_time, remark from iot_category
|
||||
select category_id, category_name, tenant_id, tenant_name, is_sys,order_num, create_time, update_time, remark, parent_id, industry_code from iot_category
|
||||
</sql>
|
||||
|
||||
<select id="selectCategoryList" parameterType="iot.lidee.iot.domain.Category" resultMap="CategoryResult">
|
||||
select c.category_id, c.category_name, c.tenant_id, c.tenant_name,
|
||||
c.is_sys,c.order_num, c.create_time, c.update_time, c.remark
|
||||
c.is_sys,c.order_num, c.create_time, c.update_time, c.remark,c.parent_id,c.industry_code
|
||||
from iot_category c
|
||||
<where>
|
||||
<if test="deptId != null and showSenior and !isAdmin">
|
||||
@@ -98,6 +101,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="parentId != null">parent_id,</if>
|
||||
<if test="industryCode != null">industry_code,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="categoryName != null and categoryName != ''">#{categoryName},</if>
|
||||
@@ -110,6 +115,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="parentId != null">#{parentId},</if>
|
||||
<if test="industryCode != null">#{industryCode},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -126,6 +133,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="parentId != null">parent_id = #{parentId},</if>
|
||||
<if test="industryCode != null">industry_code = #{industryCode},</if>
|
||||
</trim>
|
||||
where category_id = #{categoryId}
|
||||
</update>
|
||||
|
||||
@@ -13,6 +13,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="industryCode" column="industry_code" />
|
||||
<result property="parentId" column="parent_id" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="iot.lidee.iot.model.IdOutput" id="IdsResult">
|
||||
@@ -20,7 +22,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectGroupVo">
|
||||
select group_id, group_name, group_order, user_id, user_name, create_time, update_time, remark from iot_group
|
||||
select group_id, group_name, group_order, user_id, user_name, create_time, update_time, remark, industry_code, parent_id from iot_group
|
||||
</sql>
|
||||
|
||||
<select id="selectGroupList" parameterType="iot.lidee.iot.domain.Group" resultMap="GroupResult">
|
||||
@@ -55,6 +57,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="parentId != null">parent_id,</if>
|
||||
<if test="industryCode != null">industry_code,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="groupName != null and groupName != ''">#{groupName},</if>
|
||||
@@ -67,6 +71,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="parentId != null">#{parentId},</if>
|
||||
<if test="industryCode != null">#{industryCode},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -93,6 +99,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="parentId != null">parent_id = #{parentId},</if>
|
||||
<if test="industryCode != null">industry_code = #{industryCode},</if>
|
||||
</trim>
|
||||
where group_id = #{groupId}
|
||||
</update>
|
||||
|
||||
@@ -42,7 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectProductList" parameterType="iot.lidee.iot.domain.Product" resultMap="ProductResult">
|
||||
select p.product_id, p.product_name,p.protocol_code,p.transport, p.category_id,
|
||||
p.category_name, p.tenant_id, p.tenant_name, p.is_sys, p.is_authorize,
|
||||
c.category_name, p.tenant_id, p.tenant_name, p.is_sys, p.is_authorize,
|
||||
p.mqtt_account,p.mqtt_password,p.mqtt_secret ,p.status,p.device_type,
|
||||
p.network_method, p.vertificate_method, p.create_time, p.update_time,
|
||||
p.img_url,p.remark,p.guid,
|
||||
@@ -50,7 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
when (select count(product_id) from iot_product where p.tenant_id = #{tenantId}) > 0 then 1
|
||||
else 0
|
||||
end as is_owner,
|
||||
p.location_way from iot_product p
|
||||
p.location_way from iot_product p left join iot_category c on p.category_id=c.category_id
|
||||
<where>
|
||||
<if test="deptId != null and showSenior and !isAdmin">
|
||||
and ( p.tenant_id = #{tenantId}
|
||||
@@ -71,7 +71,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and p.tenant_id = #{tenantId}
|
||||
</if>
|
||||
<if test="productName != null and productName != ''"> and p.product_name like concat('%', #{productName}, '%')</if>
|
||||
<if test="categoryName != null and categoryName != ''"> and p.category_name like concat('%', #{categoryName}, '%')</if>
|
||||
<if test="categoryName != null and categoryName != ''">and c.category_name like concat('%',
|
||||
#{categoryName}, '%')
|
||||
</if>
|
||||
<if test="status != null "> and p.status = #{status}</if>
|
||||
<if test="deviceType != null "> and device_type = #{deviceType}</if>
|
||||
</where>
|
||||
@@ -298,7 +300,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectTerminalUserProduct" resultType="iot.lidee.iot.domain.Product">
|
||||
select distinct p.product_id, p.product_name,p.protocol_code,p.transport, p.category_id,
|
||||
p.category_name, p.tenant_id, p.tenant_name, p.is_sys, p.is_authorize,
|
||||
c.category_name, p.tenant_id, p.tenant_name, p.is_sys, p.is_authorize,
|
||||
p.mqtt_account,p.mqtt_password,p.mqtt_secret ,p.status,p.device_type,
|
||||
p.network_method, p.vertificate_method, p.create_time, p.update_time,
|
||||
p.img_url,p.remark
|
||||
@@ -313,6 +315,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
) as u
|
||||
inner join iot_device d on u.device_id = d.device_id
|
||||
inner join iot_product p on d.product_id = p.product_id
|
||||
left join iot_category c on p.category_id=c.category_id
|
||||
<where>
|
||||
<if test="productName != null and productName != ''">
|
||||
and p.product_name = #{productName}
|
||||
|
||||
Reference in New Issue
Block a user