fix:异常设备查询页面

This commit is contained in:
zhouz
2025-08-25 09:33:45 +08:00
parent f7d2f15f39
commit 3e9551ddc3
9 changed files with 470 additions and 3 deletions

View File

@@ -36,7 +36,7 @@ public class FaultDeviceController {
} }
@GetMapping("/deviceCharge") @GetMapping("/deviceCharge")
@Log("查询有设备故障") @Log("查询有设备故障")
public ResponseEntity<Object> queryDeviceAll(@RequestParam Map whereJson, Pageable page) { public ResponseEntity<Object> queryDeviceAll(@RequestParam Map whereJson, Pageable page) {
return new ResponseEntity<>(faultDeviceService.queryDeviceAll(whereJson, page), HttpStatus.OK); return new ResponseEntity<>(faultDeviceService.queryDeviceAll(whereJson, page), HttpStatus.OK);

View File

@@ -9,8 +9,11 @@ import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.b_lms.bst.ivt.cutpointivt.service.IBstIvtCutpointivtService;
import org.nl.b_lms.bst.ivt.cutpointivt.service.dao.BstIvtCutpointivt;
import org.nl.common.utils.SecurityUtils; import org.nl.common.utils.SecurityUtils;
import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.wql.WQL; import org.nl.modules.wql.WQL;
@@ -19,11 +22,14 @@ import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.modules.wql.util.WqlUtil; import org.nl.modules.wql.util.WqlUtil;
import org.nl.wms.basedata.master.service.FaultDeviceService; import org.nl.wms.basedata.master.service.FaultDeviceService;
import org.nl.wms.basedata.master.service.dto.CustomerbaseDto; import org.nl.wms.basedata.master.service.dto.CustomerbaseDto;
import org.nl.wms.basedata.st.service.UserDeviceService;
import org.nl.wms.ext.acs.service.impl.WmsToAcsServiceImpl; import org.nl.wms.ext.acs.service.impl.WmsToAcsServiceImpl;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.swing.*;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -67,8 +73,8 @@ public class FaultDeviceServiceImpl implements FaultDeviceService {
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
if (ObjectUtil.isNotEmpty(device_code)) { if (ObjectUtil.isNotEmpty(device_code)) {
JSONObject device_jo = WQLObject.getWQLObject("EM_BI_MonitorDevice").query("device_code = '" + device_code + "'").uniqueResult(0); JSONObject device_jo = WQLObject.getWQLObject("EM_BI_MonitorDevice").query("device_code = '" + device_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(device_jo)){ if (ObjectUtil.isEmpty(device_jo)) {
throw new BadRequestException("未查询到设备号为["+device_code+"]的设备信息!"); throw new BadRequestException("未查询到设备号为[" + device_code + "]的设备信息!");
} }
param.put("device_code", device_code); param.put("device_code", device_code);
param.put("product_area", device_jo.getString("product_area")); param.put("product_area", device_jo.getString("product_area"));
@@ -318,4 +324,48 @@ public class FaultDeviceServiceImpl implements FaultDeviceService {
} }
} }
} }
public Map<String, Object> getAllerrorDevice(Map whereJson, Pageable page) {
String device_code = MapUtil.getStr(whereJson, "device_code");
String region_code = MapUtil.getStr(whereJson, "region_code");
UserDeviceService userDeviceService = SpringContextHolder.getBean(UserDeviceService.class);
String inArea = userDeviceService.getInArea();
//查询当前人员对应的设备是多少
JSONArray device_rows = WQLObject.getWQLObject("em_bi_monitordevice").query("region_code in " + inArea + "").getResultJSONArray(0);
List<String> deviceList = new ArrayList<>();
for (int i = 0; i < device_rows.size(); i++) {
JSONObject row = device_rows.getJSONObject(i);
deviceList.add(row.getString("device_code"));
}
// 调用acs接口获取设备
JSONObject result = SpringContextHolder.getBean(WmsToAcsServiceImpl.class).getDeviceErrorInfo(deviceList);
JSONArray data = result.getJSONArray("data");
//查询内包间套轴对接位的异常
if (inArea.contains("NBJ")) {
IBstIvtCutpointivtService bean = SpringContextHolder.getBean(IBstIvtCutpointivtService.class);
List<BstIvtCutpointivt> list = bean.list(new LambdaQueryWrapper<BstIvtCutpointivt>()
.eq(BstIvtCutpointivt::getPoint_type, "1")
.eq(BstIvtCutpointivt::getIs_used, "1")
.ne(BstIvtCutpointivt::getRemark, "")
.isNotNull(BstIvtCutpointivt::getRemark)
.eq(BstIvtCutpointivt::getPoint_status, "2"));
list.stream().forEach(a -> {
JSONObject row = new JSONObject();
row.put("device_code", a.getPoint_code());
row.put("device_name", a.getPoint_code());
row.put("error_code", "");
row.put("error_message", a.getRemark());
data.add(row);
});
}
JSONObject json = new JSONObject();
json.put("content", data);
return json;
}
} }

View File

@@ -22,4 +22,6 @@ public interface UserDeviceService {
*/ */
void save(JSONObject whereJson); void save(JSONObject whereJson);
String getInArea();
} }

View File

@@ -52,6 +52,7 @@ public class UserDeviceServiceImpl implements UserDeviceService {
} }
} }
@Override
public String getInArea() { public String getInArea() {
String currentUserId = SecurityUtils.getCurrentUserId().toString(); String currentUserId = SecurityUtils.getCurrentUserId().toString();
WQLObject userdeviceTab = WQLObject.getWQLObject("st_ivt_userdevice"); WQLObject userdeviceTab = WQLObject.getWQLObject("st_ivt_userdevice");

View File

@@ -3,6 +3,7 @@ package org.nl.wms.ext.acs.service;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@@ -153,4 +154,6 @@ public interface WmsToAcsService {
* @return JSONObject * @return JSONObject
*/ */
JSONObject queryBoxWeigh(JSONObject jo); JSONObject queryBoxWeigh(JSONObject jo);
JSONObject getDeviceErrorInfo(List<String> list);
} }

View File

@@ -16,6 +16,7 @@ import org.nl.wms.sch.tasks.URLEnum;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map; import java.util.Map;
@Service @Service
@@ -517,4 +518,47 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
} }
return result; return result;
} }
@Override
public JSONObject getDeviceErrorInfo(List<String> list) {
String api = "api/wms/getDeviceErrorInfo";
//判断是否连接ACS系统
String isConnect = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("is_connect_acs").getValue();
JSONObject result = new JSONObject();
if (StrUtil.equals("0", isConnect)) {
result.put("status", HttpStatus.OK.value());
result.put("message", "查询失败未连接ACS!");
result.put("data", new JSONArray());
return result;
}
String product_area = "LK";
String acs_url = URLEnum.find(product_area);
if (StrUtil.isEmpty(acs_url)) {
log.info(product_area);
throw new BadRequestException("未查询到区域对应的acs地址");
}
String url = acs_url + api;
try {
String resultMsg = HttpRequest.post(url)
.body(String.valueOf(list))
.execute().body();
result = JSONObject.parseObject(resultMsg);
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
System.out.println(msg);
result.put("status", HttpStatus.BAD_REQUEST);
result.put("message", "网络不通,操作失败!");
result.put("data", new JSONArray());
}
//acs抛异常这里
if (!StrUtil.equals(result.getString("status"), "200")) {
throw new BadRequestException("操作失败:" + result.getString("message"));
}
return result;
}
} }

View File

@@ -0,0 +1,324 @@
<template>
<div class="app-container">
<!--工具栏-->
<div class="head-container">
<div v-if="crud.props.searchToggle">
<!-- 搜索 -->
<el-input
v-model="query.blurry"
size="mini"
clearable
placeholder="输入名称或者描述搜索"
style="width: 200px;"
class="filter-item"
@keyup.enter.native="crud.toQuery"
/>
<rrOperation/>
</div>
<crudOperation :permission="permission"/>
</div>
<!-- 表单渲染 -->
<el-row :gutter="15">
<!--角色管理-->
<el-col :xs="24" :sm="24" :md="14" :lg="14" :xl="17" style="margin-bottom: 10px">
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">角色列表</span>
</div>
<el-table
ref="table"
v-loading="crud.loading"
highlight-current-row
style="width: 100%;"
:data="crud.data"
@selection-change="crud.selectionChangeHandler"
@current-change="handleCurrentChange"
>
<el-table-column show-overflow-tooltip prop="username" label="用户名"/>
<el-table-column show-overflow-tooltip prop="person_name" label="姓名"/>
<el-table-column prop="name" label="部门"/>
<!--<el-table-column show-overflow-tooltip prop="dept" label="部门">
<template slot-scope="scope">
<div>{{ scope.row.dept.name }}</div>
</template>
</el-table-column>-->
</el-table>
<!--分页组件-->
<pagination/>
</el-card>
</el-col>
<!-- 菜单授权 -->
<el-col :xs="24" :sm="24" :md="10" :lg="10" :xl="7">
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<el-tooltip class="item" effect="dark" content="选择指定角色分配菜单" placement="top">
<span class="role-span">区域选择</span>
</el-tooltip>
<el-button
v-permission="['admin','roles:edit']"
:disabled="!showButton"
:loading="menuLoading"
icon="el-icon-check"
size="mini"
style="float: right; padding: 6px 9px"
type="primary"
@click="saveMenu"
>保存
</el-button>
</div>
<el-table
ref="multipleTable"
:data="tableData"
tooltip-effect="dark"
style="width: 100%"
@selection-change="handleSelectionChange">
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column prop="region_code" label="区域编码" />
<el-table-column prop="region_name" label="区域名称" />
</el-table>
</el-card>
</el-col>
</el-row>
</div>
</template>
<script>
import crudUserDevice from '@/views/wms/basedata/product/userDevice/userDevice'
import { getDepts, getDeptSuperior } from '@/views/system/dept/dept'
import { getChild, getMenusTree } from '@/views/system/menu/menu'
import CRUD, { crud, form, header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import Treeselect, { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import DateRangePicker from '@/components/DateRangePicker/index'
const defaultForm = { id: null, name: null, depts: [], description: null, dataScope: '全部', level: 3 }
export default {
name: 'UserStor',
components: { Treeselect, pagination, crudOperation, rrOperation, udOperation, DateRangePicker },
cruds() {
return CRUD({
title: '角色',
url: 'api/userStor',
crudMethod: { ...crudUserDevice },
optShow: { add: false, reset: false, edit: false, del: false }
})
},
mixins: [presenter(), header(), form(defaultForm), crud()],
data() {
return {
level: 3,
currentId: 0, menuLoading: false, showButton: false,
menus: [], menuIds: [], depts: [], deptDatas: [], // 多选时使用
tableData: [{ 'region_code': 'B1Foil', 'region_name': 'B1生箔' }, { 'region_code': 'B1FQ', 'region_name': 'B1分切' }, { 'region_code': 'B2Foil', 'region_name': 'B2生箔' }, { 'region_code': 'B2FQ', 'region_name': 'B2分切' }, { 'region_code': 'CBJ', 'region_name': '穿拔轴区' }, { 'region_code': 'NBJ', 'region_name': '内包间' }, { 'region_code': 'RK', 'region_name': '入库区' }, { 'region_code': 'CK', 'region_name': '出库区' }],
currentRow: null,
permission: {
add: ['admin', 'roles:add'],
edit: ['admin', 'roles:edit'],
del: ['admin', 'roles:del']
},
rules: {
name: [
{ required: true, message: '请输入名称', trigger: 'blur' }
],
permission: [
{ required: true, message: '请输入权限', trigger: 'blur' }
]
}
}
},
methods: {
getMenuDatas(node, resolve) {
setTimeout(() => {
getMenusTree(node.data.id ? node.data.id : 0).then(res => {
resolve(res)
})
}, 100)
},
[CRUD.HOOK.afterRefresh]() {
this.$refs.menu.setCheckedKeys([])
},
// 新增前初始化部门信息
[CRUD.HOOK.beforeToAdd]() {
this.deptDatas = []
},
// 编辑前初始化自定义数据权限的部门信息
[CRUD.HOOK.beforeToEdit](crud, form) {
this.deptDatas = []
if (form.dataScope === '自定义') {
this.getSupDepts(form.depts)
}
const _this = this
form.depts.forEach(function(dept) {
_this.deptDatas.push(dept.id)
})
},
// 提交前做的操作
[CRUD.HOOK.afterValidateCU](crud) {
if (crud.form.dataScope === '自定义' && this.deptDatas.length === 0) {
this.$message({
message: '自定义数据权限不能为空',
type: 'warning'
})
return false
} else if (crud.form.dataScope === '自定义') {
const depts = []
this.deptDatas.forEach(function(data) {
const dept = { id: data }
depts.push(dept)
})
crud.form.depts = depts
} else {
crud.form.depts = []
}
return true
},
// 触发单选
handleCurrentChange(val) {
if (val) {
this.showButton = true
this.$refs.multipleTable.clearSelection()
this.currentRow = val
crudUserDevice.queryuserDevice(val).then(res => {
res.forEach(row => {
this.tableData.forEach(selected => {
if (selected.region_code === row.region_code) {
this.$refs.multipleTable.toggleRowSelection(selected, true)
}
})
})
})
}
},
menuChange(menu) {
// 获取该节点的所有子节点id 包含自身
getChild(menu.id).then(childIds => {
// 判断是否在 menuIds 中,如果存在则删除,否则添加
if (this.menuIds.indexOf(menu.id) !== -1) {
for (let i = 0; i < childIds.length; i++) {
const index = this.menuIds.indexOf(childIds[i])
if (index !== -1) {
this.menuIds.splice(index, 1)
}
}
} else {
for (let i = 0; i < childIds.length; i++) {
const index = this.menuIds.indexOf(childIds[i])
if (index === -1) {
this.menuIds.push(childIds[i])
}
}
}
this.$refs.menu.setCheckedKeys(this.menuIds)
})
},
// 保存菜单
saveMenu() {
const row = {}
row.jo = this.currentRow
row.rows = this.$refs.multipleTable.selection
crudUserDevice.save(row).then(res => {
this.crud.notify('保存成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
})
},
// 改变数据
update() {
// 无刷新更新 表格数据
crudRoles.get(this.currentId).then(res => {
for (let i = 0; i < this.crud.data.length; i++) {
if (res.id === this.crud.data[i].id) {
this.crud.data[i] = res
break
}
}
})
},
// 获取部门数据
getDepts() {
getDepts({ enabled: true }).then(res => {
this.depts = res.content.map(function(obj) {
if (obj.hasChildren) {
obj.children = null
}
return obj
})
})
},
getSupDepts(depts) {
const ids = []
depts.forEach(dept => {
ids.push(dept.id)
})
getDeptSuperior(ids).then(res => {
const date = res.content
this.buildDepts(date)
this.depts = date
})
},
buildDepts(depts) {
depts.forEach(data => {
if (data.children) {
this.buildDepts(data.children)
}
if (data.hasChildren && !data.children) {
data.children = null
}
})
},
// 获取弹窗内部门数据
loadDepts({ action, parentNode, callback }) {
if (action === LOAD_CHILDREN_OPTIONS) {
getDepts({ enabled: true, pid: parentNode.id }).then(res => {
parentNode.children = res.content.map(function(obj) {
if (obj.hasChildren) {
obj.children = null
}
return obj
})
setTimeout(() => {
callback()
}, 200)
})
}
},
// 如果数据权限为自定义则获取部门数据
changeScope() {
if (this.form.dataScope === '自定义') {
this.getDepts()
}
},
checkboxT(row) {
return row.level >= this.level
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss">
.role-span {
font-weight: bold;
color: #303133;
font-size: 15px;
}
</style>
<style rel="stylesheet/scss" lang="scss" scoped>
::v-deep .el-input-number .el-input__inner {
text-align: left;
}
::v-deep .vue-treeselect__multi-value {
margin-bottom: 0;
}
::v-deep .vue-treeselect__multi-value-item {
border: 0;
padding: 0;
}
</style>

View File

@@ -0,0 +1,43 @@
import request from '@/utils/request'
export function queryStor(data) {
return request({
url: '/api/userDevice/queryStor',
method: 'post',
data
})
}
export function queryuserDevice(data) {
return request({
url: '/api/userDevice/queryUserDevice',
method: 'post',
data
})
}
export function save(data) {
return request({
url: '/api/userDevice/save',
method: 'post',
data
})
}
export function getuserDevice(data) {
return request({
url: '/api/userDevice/getuserDevice',
method: 'post',
data
})
}
export function getSect(data) {
return request({
url: '/api/userDevice/getSect',
method: 'post',
data
})
}
export default { queryuserDevice, queryStor, save, getuserDevice, getSect }