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")
@Log("查询有设备故障")
@Log("查询有设备故障")
public ResponseEntity<Object> queryDeviceAll(@RequestParam Map whereJson, Pageable page) {
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.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
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.modules.common.exception.BadRequestException;
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.wms.basedata.master.service.FaultDeviceService;
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.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -67,8 +73,8 @@ public class FaultDeviceServiceImpl implements FaultDeviceService {
JSONObject param = new JSONObject();
if (ObjectUtil.isNotEmpty(device_code)) {
JSONObject device_jo = WQLObject.getWQLObject("EM_BI_MonitorDevice").query("device_code = '" + device_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(device_jo)){
throw new BadRequestException("未查询到设备号为["+device_code+"]的设备信息!");
if (ObjectUtil.isEmpty(device_jo)) {
throw new BadRequestException("未查询到设备号为[" + device_code + "]的设备信息!");
}
param.put("device_code", device_code);
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);
String getInArea();
}

View File

@@ -52,6 +52,7 @@ public class UserDeviceServiceImpl implements UserDeviceService {
}
}
@Override
public String getInArea() {
String currentUserId = SecurityUtils.getCurrentUserId().toString();
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.JSONObject;
import java.util.List;
import java.util.Map;
/**
@@ -153,4 +154,6 @@ public interface WmsToAcsService {
* @return JSONObject
*/
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.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
@@ -517,4 +518,47 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
}
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;
}
}