汪菘
1 year ago
6 changed files with 449 additions and 1 deletions
@ -0,0 +1,59 @@ |
|||||
|
|
||||
|
package org.nl.acs.udw.rest; |
||||
|
|
||||
|
|
||||
|
import cn.dev33.satoken.annotation.SaIgnore; |
||||
|
import com.alibaba.fastjson.JSONArray; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.nl.acs.device.device_driver.DriverTypeEnum; |
||||
|
import org.nl.acs.device.device_driver.standard_inspect.OpcPlcDto; |
||||
|
import org.nl.acs.device.service.DeviceExtraService; |
||||
|
import org.nl.acs.device.service.DeviceService; |
||||
|
import org.nl.acs.device.service.dto.DeviceDto; |
||||
|
import org.nl.acs.udw.service.UdwManageService; |
||||
|
import org.nl.modules.logging.annotation.Log; |
||||
|
import org.nl.modules.wql.core.bean.WQLObject; |
||||
|
import org.springframework.data.domain.Pageable; |
||||
|
import org.springframework.http.HttpStatus; |
||||
|
import org.springframework.http.ResponseEntity; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import javax.servlet.http.HttpServletRequest; |
||||
|
import javax.servlet.http.HttpServletResponse; |
||||
|
import java.io.IOException; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
@RestController |
||||
|
@RequiredArgsConstructor |
||||
|
@Api(tags = "内存点位管理") |
||||
|
@RequestMapping("/api/udw") |
||||
|
@Slf4j |
||||
|
public class UdwManagerController { |
||||
|
|
||||
|
private final UdwManageService udwManageService; |
||||
|
|
||||
|
// @GetMapping
|
||||
|
// @Log("查询内存点位")
|
||||
|
// @ApiOperation("查询内存点位")
|
||||
|
// @SaIgnore
|
||||
|
// public ResponseEntity<Object> query(@RequestParam JSONObject whereJson) {
|
||||
|
// return new ResponseEntity<>(udwManageService.queryByConditions(whereJson), HttpStatus.OK);
|
||||
|
// }
|
||||
|
|
||||
|
@GetMapping |
||||
|
@Log("查询内存点位") |
||||
|
@ApiOperation("查询内存点位") |
||||
|
@SaIgnore |
||||
|
//@PreAuthorize("@el.check('device:list')")
|
||||
|
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) { |
||||
|
return new ResponseEntity<>(udwManageService.queryAll(whereJson, page), HttpStatus.OK); |
||||
|
} |
||||
|
} |
@ -1,16 +1,157 @@ |
|||||
package org.nl.acs.udw.service.impl; |
package org.nl.acs.udw.service.impl; |
||||
|
|
||||
|
import cn.hutool.core.util.StrUtil; |
||||
import com.alibaba.fastjson.JSONObject; |
import com.alibaba.fastjson.JSONObject; |
||||
|
import org.nl.acs.task.service.dto.TaskDto; |
||||
|
import org.nl.acs.udw.UnifiedData; |
||||
|
import org.nl.acs.udw.UnifiedDataAccessorFactory; |
||||
import org.nl.acs.udw.dto.UdwDto; |
import org.nl.acs.udw.dto.UdwDto; |
||||
import org.nl.acs.udw.service.UdwManageService; |
import org.nl.acs.udw.service.UdwManageService; |
||||
|
import org.springframework.data.domain.Pageable; |
||||
import org.springframework.stereotype.Service; |
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Iterator; |
||||
import java.util.List; |
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
@Service |
@Service |
||||
public class UdwManagerServiceImpl implements UdwManageService { |
public class UdwManagerServiceImpl implements UdwManageService { |
||||
|
|
||||
|
public UdwManagerServiceImpl() { |
||||
|
} |
||||
|
|
||||
@Override |
@Override |
||||
public List<UdwDto> queryByConditions(JSONObject where) { |
public List<UdwDto> queryByConditions(JSONObject where) { |
||||
|
String unified_key = null; |
||||
|
String keys = null; |
||||
|
|
||||
|
UnifiedDataUnit unifiedDataUnit = UnifiedDataAccessorFactory.getUnifiedDataAppService().getUnifiedDataUnit(unified_key); |
||||
|
if (unifiedDataUnit == null) { |
||||
|
return null; |
||||
|
} else { |
||||
|
String key; |
||||
|
UdwDto udwDto; |
||||
|
Map storage; |
||||
|
ArrayList udwDtos; |
||||
|
Iterator var14; |
||||
|
if (keys != null) { |
||||
|
storage = unifiedDataUnit.getStorage(); |
||||
|
udwDtos = new ArrayList(); |
||||
|
var14 = storage.keySet().iterator(); |
||||
|
|
||||
|
while(var14.hasNext()) { |
||||
|
key = (String)var14.next(); |
||||
|
if (key.indexOf(keys) != -1) { |
||||
|
udwDto = new UdwDto(); |
||||
|
udwDto.setUnified_key(unified_key); |
||||
|
udwDto.setKey(key); |
||||
|
udwDto.setValue(((UnifiedData)storage.get(key)).getValue()); |
||||
|
udwDtos.add(udwDto); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return udwDtos; |
||||
|
} else { |
||||
|
storage = unifiedDataUnit.getStorage(); |
||||
|
udwDtos = new ArrayList(); |
||||
|
var14 = storage.keySet().iterator(); |
||||
|
|
||||
|
while(var14.hasNext()) { |
||||
|
key = (String)var14.next(); |
||||
|
udwDto = new UdwDto(); |
||||
|
udwDto.setUnified_key(unified_key); |
||||
|
udwDto.setKey(key); |
||||
|
udwDto.setValue(((UnifiedData)storage.get(key)).getValue()); |
||||
|
udwDtos.add(udwDto); |
||||
|
} |
||||
|
|
||||
|
return udwDtos; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Map<String, Object> queryAll(Map whereJson, Pageable page) { |
||||
|
|
||||
|
String unified_key = (String) whereJson.get("unified_key"); |
||||
|
String keys = (String) whereJson.get("code"); |
||||
|
if(StrUtil.isEmpty(unified_key)) |
||||
|
{ |
||||
|
unified_key = "opc_value"; |
||||
|
} |
||||
|
// String unified_key = (String) whereJson.get("unified_key");
|
||||
|
// String code = (String) whereJson.get("code");
|
||||
|
|
||||
|
// unified_key = whereJson.get("key").toString();
|
||||
|
// keys = whereJson.get("value").toString();
|
||||
|
|
||||
|
|
||||
|
//[[{"column":"unified_key","value":"cached","compareType":"equals","columnType":"object"}]]
|
||||
|
UnifiedDataUnit unifiedDataUnit = UnifiedDataAccessorFactory.getUnifiedDataAppService().getUnifiedDataUnit(unified_key); |
||||
|
if (unifiedDataUnit == null) { |
||||
return null; |
return null; |
||||
|
} else { |
||||
|
String key; |
||||
|
UdwDto udwDto; |
||||
|
Map storage; |
||||
|
ArrayList udwDtos; |
||||
|
Iterator var14; |
||||
|
if (keys != null) { |
||||
|
storage = unifiedDataUnit.getStorage(); |
||||
|
udwDtos = new ArrayList(); |
||||
|
var14 = storage.keySet().iterator(); |
||||
|
|
||||
|
while(var14.hasNext()) { |
||||
|
key = (String)var14.next(); |
||||
|
if (key.indexOf(keys) != -1) { |
||||
|
udwDto = new UdwDto(); |
||||
|
udwDto.setUnified_key(unified_key); |
||||
|
udwDto.setKey(key); |
||||
|
udwDto.setValue(((UnifiedData)storage.get(key)).getValue()); |
||||
|
udwDtos.add(udwDto); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
Integer currentPageNumber = page.getPageNumber() + 1; |
||||
|
Integer pageMaxSize = page.getPageSize(); |
||||
|
|
||||
|
List orderbyDtoList = (List) udwDtos.stream().skip((currentPageNumber - 1) * pageMaxSize) |
||||
|
.limit(pageMaxSize) |
||||
|
.collect(Collectors.toList()); |
||||
|
|
||||
|
JSONObject jo = new JSONObject(); |
||||
|
jo.put("content", orderbyDtoList); |
||||
|
jo.put("totalElements", udwDtos.size()); |
||||
|
|
||||
|
return jo; |
||||
|
} else { |
||||
|
storage = unifiedDataUnit.getStorage(); |
||||
|
udwDtos = new ArrayList(); |
||||
|
var14 = storage.keySet().iterator(); |
||||
|
|
||||
|
while(var14.hasNext()) { |
||||
|
key = (String)var14.next(); |
||||
|
udwDto = new UdwDto(); |
||||
|
udwDto.setUnified_key(unified_key); |
||||
|
udwDto.setKey(key); |
||||
|
udwDto.setValue(((UnifiedData)storage.get(key)).getValue()); |
||||
|
udwDtos.add(udwDto); |
||||
|
} |
||||
|
Integer currentPageNumber = page.getPageNumber() + 1; |
||||
|
Integer pageMaxSize = page.getPageSize(); |
||||
|
|
||||
|
List orderbyDtoList = (List) udwDtos.stream().skip((currentPageNumber - 1) * pageMaxSize) |
||||
|
.limit(pageMaxSize) |
||||
|
.collect(Collectors.toList()); |
||||
|
|
||||
|
JSONObject jo = new JSONObject(); |
||||
|
jo.put("content", orderbyDtoList); |
||||
|
jo.put("totalElements", udwDtos.size()); |
||||
|
|
||||
|
return jo; |
||||
|
} |
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
|
@ -0,0 +1,27 @@ |
|||||
|
import request from '@/utils/request' |
||||
|
|
||||
|
export function add(data) { |
||||
|
return request({ |
||||
|
url: 'api/deviceErrorLog', |
||||
|
method: 'post', |
||||
|
data |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
export function del(ids) { |
||||
|
return request({ |
||||
|
url: 'api/deviceErrorLog/', |
||||
|
method: 'delete', |
||||
|
data: ids |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
export function edit(data) { |
||||
|
return request({ |
||||
|
url: 'api/deviceErrorLog', |
||||
|
method: 'put', |
||||
|
data |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
export default { add, edit, del } |
@ -0,0 +1,28 @@ |
|||||
|
import request from '@/utils/request' |
||||
|
|
||||
|
export function add(data) { |
||||
|
return request({ |
||||
|
url: 'api/task', |
||||
|
method: 'post', |
||||
|
data |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
export function del(ids) { |
||||
|
return request({ |
||||
|
url: 'api/task/', |
||||
|
method: 'delete', |
||||
|
data: ids |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
export function edit(data) { |
||||
|
return request({ |
||||
|
url: 'api/task', |
||||
|
method: 'put', |
||||
|
data |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
export default { edit, del } |
||||
|
|
@ -0,0 +1,181 @@ |
|||||
|
<template> |
||||
|
<div class="app-container"> |
||||
|
<!--工具栏--> |
||||
|
<div class="head-container"> |
||||
|
<div v-if="crud.props.searchToggle"> |
||||
|
<!-- 搜索 --> |
||||
|
<el-select |
||||
|
v-model="form.unified_key" |
||||
|
placeholder="unified_key" |
||||
|
class="filter-item" |
||||
|
@change="crud.toQuery" |
||||
|
clearable |
||||
|
filterable |
||||
|
size="small"> |
||||
|
<el-option v-for="(item,index) in unified_key" :key="index" :label="item.label" :value="item.value"> |
||||
|
</el-option> |
||||
|
</el-select> |
||||
|
<el-input |
||||
|
v-model="query.code" |
||||
|
size="small" |
||||
|
clearable |
||||
|
placeholder="编号" |
||||
|
style="width: 200px;" |
||||
|
class="filter-item" |
||||
|
@keyup.enter.native="crud.toQuery" |
||||
|
/> |
||||
|
</div> |
||||
|
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'--> |
||||
|
<crudOperation :permission="permission" /> |
||||
|
<!--表单组件--> |
||||
|
<el-dialog |
||||
|
:close-on-click-modal="false" |
||||
|
:before-close="crud.cancelCU" |
||||
|
:visible.sync="crud.status.cu > 0" |
||||
|
:title="crud.status.title" |
||||
|
width="500px" |
||||
|
> |
||||
|
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px"> |
||||
|
<el-form-item label="unified_key"> |
||||
|
<el-input v-model="form.unified_key" style="width: 370px;" /> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="编号"> |
||||
|
<el-input v-model="form.key" style="width: 370px;" /> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="值"> |
||||
|
<el-input v-model="form.value" style="width: 370px;" /> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
<div slot="footer" class="dialog-footer"> |
||||
|
<el-button type="text" @click="crud.cancelCU">取消</el-button> |
||||
|
<el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button> |
||||
|
</div> |
||||
|
</el-dialog> |
||||
|
<!--表格渲染--> |
||||
|
<el-table |
||||
|
ref="table" |
||||
|
v-loading="crud.loading" |
||||
|
:data="crud.data" |
||||
|
size="small" |
||||
|
style="width: 100%;" |
||||
|
@selection-change="crud.selectionChangeHandler" |
||||
|
> |
||||
|
<el-table-column prop="unified_key" label="unified_key" /> |
||||
|
<el-table-column prop="key" label="编号" /> |
||||
|
<el-table-column prop="value" label="值" /> |
||||
|
<el-table-column |
||||
|
v-permission="['admin','instruction:edit','instruction:del']" |
||||
|
fixed="left" |
||||
|
label="操作" |
||||
|
width="150px" |
||||
|
align="center" |
||||
|
> |
||||
|
<template slot-scope="scope"> |
||||
|
<el-button slot="right" size="mini" style="margin-left: -1px;margin-right: 2px" type="text" @click="dialogFormVisible = true"> |
||||
|
查询历史 |
||||
|
</el-button> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
</el-table> |
||||
|
<!--分页组件--> |
||||
|
<pagination /> |
||||
|
<!--弹窗设置设备与图标绑定与角度--> |
||||
|
<el-dialog title="历史" :visible.sync="dialogFormVisible" width="35%"> |
||||
|
<el-form :model="form" size="small"> |
||||
|
<el-form-item label="unified_key" prop="unified_key" label-width="100px"> |
||||
|
<el-input v-model="form.unified_key" :disabled="true" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item label="code" prop="key" label-width="100px"> |
||||
|
<el-input v-model="form.key" :disabled="true" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
</el-form> |
||||
|
</el-dialog> |
||||
|
</div> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import pagination from '@crud/Pagination' |
||||
|
import crudUdwData from '@/api/acs/history/udwData' |
||||
|
import CRUD, { crud, form, header, presenter } from '@crud/crud' |
||||
|
import crudOperation from '@crud/CRUD.operation' |
||||
|
import { getDicts } from '@/api/system/dict' |
||||
|
|
||||
|
const defaultForm = { |
||||
|
unified_key: '', |
||||
|
key: null, |
||||
|
value: null, |
||||
|
last_modify_date: null |
||||
|
} |
||||
|
export default { |
||||
|
dicts: [], |
||||
|
name: 'UdwData', |
||||
|
components: { pagination, crudOperation }, |
||||
|
mixins: [presenter(), header(), form(defaultForm), crud()], |
||||
|
cruds() { |
||||
|
return CRUD({ |
||||
|
title: '数据源', |
||||
|
url: 'api/udw/', |
||||
|
idField: 'key', |
||||
|
sort: 'key', |
||||
|
query: {}, |
||||
|
crudMethod: { ...crudUdwData }, |
||||
|
optShow: { |
||||
|
} |
||||
|
}) |
||||
|
}, |
||||
|
data() { |
||||
|
return { |
||||
|
unified_key: [ |
||||
|
{ |
||||
|
value: '1', |
||||
|
label: 'opc_value' |
||||
|
}, |
||||
|
{ |
||||
|
value: '2', |
||||
|
label: 'cached' |
||||
|
}, |
||||
|
{ |
||||
|
value: '3', |
||||
|
label: 'socket' |
||||
|
} |
||||
|
], |
||||
|
permission: { |
||||
|
}, |
||||
|
dialogFormVisible: false, |
||||
|
rules: { |
||||
|
}, |
||||
|
form: { |
||||
|
unified_key: 'opc_value', |
||||
|
key: null, |
||||
|
value: null, |
||||
|
last_modify_date: null |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
created() { |
||||
|
getDicts().then(data => { |
||||
|
this.dicts = data |
||||
|
}) |
||||
|
}, |
||||
|
methods: { |
||||
|
// 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
||||
|
[CRUD.HOOK.beforeRefresh]() { |
||||
|
return true |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style scoped> |
||||
|
.el-dropdown-link { |
||||
|
cursor: pointer; |
||||
|
color: #409EFF; |
||||
|
} |
||||
|
|
||||
|
.el-icon-arrow-down { |
||||
|
font-size: 12px; |
||||
|
} |
||||
|
</style> |
Loading…
Reference in new issue