fix: 穿拔轴区增加设备异常报警展示

This commit is contained in:
2025-07-14 16:15:10 +08:00
parent 47d57d9977
commit e65081ae69
3 changed files with 77 additions and 5 deletions

View File

@@ -19,10 +19,14 @@ public enum SlitterEnum {
/**
* 任务类型
*/
TASK_TYPE(MapOf.of("穿拔轴缓存<>穿拔轴位", "010801", "穿拔轴缓存<>分切对接位", "010802", "穿拔轴位<>气胀轴缓存位", "010803"
, "分切机下料AGV任务", "010804", "分切机上气胀轴", "010805", "分切机下气胀轴", "010806", "备货区送载具", "010807"
, "备货区送纸管", "010808", "分切机下料桁架任务", "010809", "分切机下料AGV到内包间", "010810", "套轴异常处理AGV任务", "010811"
, "套轴异常处理桁架任务", "010812", "送气胀轴到分切机任务", "010813", "拔轴完毕出轴", "010814", "穿拔轴缓存<>气胀轴缓存位", "010815", "备货区单独送空载具", "010816"));
TASK_TYPE(MapOf.of("穿拔轴缓存<>穿拔轴位", "010801", "穿拔轴缓存<>分切对接位", "010802"
, "穿拔轴位<>气胀轴缓存位", "010803", "分切机下料AGV任务", "010804"
, "分切机上气胀轴", "010805", "分切机下气胀轴", "010806", "备货区送载具", "010807"
, "备货区送纸管", "010808", "分切机下料桁架任务", "010809", "分切机下料AGV到内包间", "010810"
, "套轴异常处理AGV任务", "010811", "套轴异常处理桁架任务", "010812", "送气胀轴到分切机任务", "010813"
, "拔轴完毕出轴", "010814", "穿拔轴缓存<>气胀轴缓存位", "010815", "备货区单独送空载具", "010816")
);
private Map<String, String> code;
public String code(String desc) {

View File

@@ -1,11 +1,17 @@
package org.nl.b_lms.sch.tasks.slitter.controller;
import cn.dev33.satoken.annotation.SaIgnore;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.b_lms.sch.tasks.slitter.constant.SlitterEnum;
import org.nl.b_lms.sch.tasks.slitter.service.SlitterService;
import org.nl.b_lms.sch.tasks.slitter.util.SlitterTaskUtil;
import org.nl.modules.common.utils.RedisUtils;
import org.nl.modules.logging.annotation.Log;
import org.nl.system.service.dict.ISysDictService;
import org.nl.system.service.dict.dao.Dict;
import org.nl.wms.ext.acs.service.WmsToAcsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -14,6 +20,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @Author: lyd
* @Description:
@@ -28,6 +36,10 @@ public class SlitterController {
private SlitterService slitterService;
@Autowired
private RedisUtils redisUtils;
@Autowired
private WmsToAcsService wmsToAcsService;
@Autowired
private ISysDictService dictService;
@PostMapping("/calPaperNum")
@Log("扣除纸管库存")
@SaIgnore
@@ -44,7 +56,30 @@ public class SlitterController {
@Log("套轴BCP透明链路2")
@SaIgnore
public ResponseEntity<Object> tzInfo2(@RequestBody JSONObject entity){
return new ResponseEntity<>(redisUtils.get("ERROR" + entity.getString("device_code")), HttpStatus.CREATED);
List<String> list = SlitterTaskUtil.objectToList(redisUtils.get("ERROR" + entity.getString("device_code")));
try {
// 获取字典数据
List<Dict> bcbjError = dictService.getDictByName("CBJ_ERROR");
// 判断气胀轴是否有轴
JSONArray device_rows = new JSONArray();
JSONObject device_obj = new JSONObject();
device_rows.add(device_obj);
device_obj.put("device_code", entity.getString("device_code"));
// todo: 暂时都是B1
device_obj.put("product_area", "B1");
JSONObject pointStatus = wmsToAcsService.getPointStatus(device_rows);
JSONObject data = pointStatus.getJSONArray("data").getJSONObject(0);
Dict error = bcbjError.stream()
.filter(p -> p.getValue().equals(data.getString("error")))
.findFirst()
.orElse(null);
list.add(">>>实时获取电气上报异常信息:" + (error != null
? error.getLabel()
: (data.getString("error") + "对应异常信息未定义")));
} catch (Exception e) {
list.add(">>>获取电气上报异常信息失败(此记录不影响流程)...");
}
return new ResponseEntity<>(list, HttpStatus.CREATED);
}
@PostMapping("/v2/tzTaskINfo")
@Log("套轴BCP透明链路2")

View File

@@ -1,5 +1,6 @@
package org.nl.b_lms.sch.tasks.slitter.util;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
@@ -573,4 +574,36 @@ public class SlitterTaskUtil {
Integer::sum
));
}
public static <T, U> List<U> mapList(Collection<T> from, Function<T, U> func) {
if (CollUtil.isEmpty(from)) {
return new ArrayList<>();
}
return from.stream().map(func).collect(Collectors.toList());
}
/**
* 转换List<String>
* @param obj
* @return
*/
public static List<String> objectToList(Object obj) {
// 安全转换为List<String>
List<String> errorList = new ArrayList<>();
if (obj instanceof List) {
for (Object item : (List<?>) obj) {
if (item instanceof String) {
errorList.add((String) item);
} else {
// 非字符串元素处理(按需调整)
errorList.add(item.toString());
}
}
} else if (obj != null) {
// 如果存储的不是List如JSON字符串需额外处理
throw new IllegalStateException("Expected List type from Redis, but got: " + obj.getClass());
}
return errorList;
}
}