rev:修改设备UI查询,错误代码解析。
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
package org.nl.common.enums;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* acs状态枚举
|
||||
*
|
||||
* @author gbx
|
||||
* @since 2024-01-31
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum AcsDefineEnum {
|
||||
|
||||
//agv状态 1-关机2-运行中3-交通管制4-任务等待5-充电中6-故障中7-低电量
|
||||
AGV_STATUS(MapOf.of("关机", "1", "运行中", "2", "交通管制", "3", "任务等待", "4", "充电中", "5", "故障中", "6", "低电量", "7")),
|
||||
|
||||
//RGV状态 1-空闲 2-任务未派发 3-执行任务中 4-任务完成
|
||||
RGV_STATUS(MapOf.of("1","IDLE","2","SENT","3","WORK","4","COMPLETE")),
|
||||
|
||||
//载具类型
|
||||
VEHICLE_TYPE(MapOf.of("普涂", "1", "连涂", "2")),
|
||||
|
||||
//是否
|
||||
IS_USED(MapOf.of("启用", "1", "未启用", "0"));
|
||||
|
||||
|
||||
private Map<String, String> code;
|
||||
|
||||
public String code(String desc) {
|
||||
String code = this.getCode().get(desc);
|
||||
if (StringUtils.isNotEmpty(code)) {
|
||||
return code;
|
||||
}
|
||||
throw new RuntimeException(this.name() + "对应类型" + desc + "未定义");
|
||||
}
|
||||
|
||||
public Long longCode(String desc) {
|
||||
String code = this.getCode().get(desc);
|
||||
if (StringUtils.isNotEmpty(code)) {
|
||||
return Long.valueOf(code);
|
||||
}
|
||||
throw new RuntimeException(this.name() + "对应类型" + desc + "未定义");
|
||||
}
|
||||
|
||||
public String check(String code) {
|
||||
for (Map.Entry<String, String> entry : this.getCode().entrySet()) {
|
||||
if (entry.getValue().equals(code)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
throw new RuntimeException(this.name() + "对应类型" + code + "未定义");
|
||||
}
|
||||
|
||||
public String check1(String code) {
|
||||
for (Map.Entry<String, String> entry : this.getCode().entrySet()) {
|
||||
if (entry.getValue().equals(code)) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
throw new RuntimeException(this.name() + "对应类型" + code + "未定义");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.nl.common.utils;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2022/11/29 2:55 下午
|
||||
*/
|
||||
public class MapOf implements Serializable {
|
||||
|
||||
public static <K> HashMap of(K... key) {
|
||||
HashMap map = new HashMap<>();
|
||||
for (int i = 0; i < (key.length & ~1); i = i + 2) {
|
||||
map.put(key[i], key[i + 1]);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@@ -33,5 +33,6 @@ public class DasDeviceFault implements Serializable {
|
||||
|
||||
private String failure_info;
|
||||
|
||||
private String current_status;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.enums.AcsDefineEnum;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.ColaBeanUtils;
|
||||
import org.nl.common.utils.RedisUtils;
|
||||
import org.nl.wms.cockpit.service.CockpitService;
|
||||
import org.nl.wms.cockpit.service.dao.CommonData;
|
||||
import org.nl.wms.cockpit.service.dao.ghs.DeviceFaultStatistics;
|
||||
import org.nl.wms.cockpit.service.dao.home.DayData;
|
||||
import org.nl.wms.cockpit.service.dao.home.HomeInfo;
|
||||
import org.nl.wms.cockpit.service.dao.home.TargetAchievement;
|
||||
@@ -35,11 +35,13 @@ import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.nl.common.utils.DateUtil.localDateTimeFormatyMdHms;
|
||||
@@ -297,7 +299,6 @@ public class CockpitServiceImpl implements CockpitService {
|
||||
JSONObject getGhsInfo = new JSONObject();
|
||||
//固化汇总
|
||||
JSONArray curing_summary = cockpitMapper.curingSummary();
|
||||
//todo 近30天固化数据
|
||||
List<Map<String, Object>> monthly_gh_qty = cockpitMapper.getGhsQty("30");
|
||||
List<Map<String, Object>> monthly_gh_qty_default = new ArrayList<>();
|
||||
getWeekWorkStatistics(monthly_gh_qty, monthly_gh_qty_default, "GH", 30);
|
||||
@@ -384,54 +385,56 @@ public class CockpitServiceImpl implements CockpitService {
|
||||
JSONObject getHandlingInfo = new JSONObject();
|
||||
//设备运行状态
|
||||
JSONObject device_status = new JSONObject();
|
||||
//todo 点位状态信息状态信息
|
||||
List<Map<String, Object>> agv_info = cockpitMapper.statusInfo();
|
||||
List<Map<String, Object>> rgv_info = cockpitMapper.statusInfo();
|
||||
List<Map<String, Object>> conveyor_info = cockpitMapper.statusInfo();
|
||||
if (ObjectUtil.isEmpty(agv_info) || ObjectUtil.isEmpty(rgv_info)) {
|
||||
Map<String, Object> item1 = new HashMap<>();
|
||||
item1.put("item_name", "1");
|
||||
item1.put("item_qty", "8");
|
||||
Map<String, Object> item2 = new HashMap<>();
|
||||
item2.put("item_name", "2");
|
||||
item2.put("item_qty", "2");
|
||||
Map<String, Object> item3 = new HashMap<>();
|
||||
item3.put("item_name", "1");
|
||||
item3.put("item_qty", "9");
|
||||
Map<String, Object> item4 = new HashMap<>();
|
||||
item4.put("item_name", "2");
|
||||
item4.put("item_qty", "1");
|
||||
if (ObjectUtil.isEmpty(agv_info)) {
|
||||
agv_info.add(item1);
|
||||
agv_info.add(item2);
|
||||
}
|
||||
if (ObjectUtil.isEmpty(rgv_info)) {
|
||||
rgv_info.add(item3);
|
||||
rgv_info.add(item4);
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isEmpty(conveyor_info)) {
|
||||
Map<String, Object> item1 = new HashMap<>();
|
||||
item1.put("item_name", "3");
|
||||
item1.put("item_qty", "6");
|
||||
Map<String, Object> item2 = new HashMap<>();
|
||||
item2.put("item_name", "4");
|
||||
item2.put("item_qty", "7");
|
||||
Map<String, Object> item3 = new HashMap<>();
|
||||
item3.put("item_name", "5");
|
||||
item3.put("item_qty", "8");
|
||||
conveyor_info.add(item1);
|
||||
conveyor_info.add(item2);
|
||||
conveyor_info.add(item3);
|
||||
}
|
||||
Function<String, Function<Integer, Map<String, Object>>> createItem = itemName -> itemQty -> {
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
item.put("item_name", itemName);
|
||||
item.put("item_qty", itemQty);
|
||||
return item;
|
||||
};
|
||||
// AGV
|
||||
JSONArray agvInfos = (JSONArray) redisUtils.get("AGV1");
|
||||
int agvFaultNum = (int) agvInfos.stream()
|
||||
.map(object -> (JSONObject) object)
|
||||
.filter(jsonObject -> AcsDefineEnum.AGV_STATUS.code("故障中").equals(jsonObject.getString("device_status")))
|
||||
.count();
|
||||
int agvNormalNum = agvInfos.size() - agvFaultNum;
|
||||
List<Map<String, Object>> agv_info = Arrays.asList(
|
||||
createItem.apply("0").apply(agvNormalNum),
|
||||
createItem.apply("1").apply(agvFaultNum)
|
||||
);
|
||||
// RGV
|
||||
JSONArray rgvInfos = (JSONArray) redisUtils.get("RGV1");
|
||||
int rgvFaultNum = (int) rgvInfos.stream()
|
||||
.map(object -> (JSONObject) object)
|
||||
.filter(jsonObject -> StringUtils.isNotBlank(jsonObject.getString("Error")))
|
||||
.count();
|
||||
int rgvNormalNum = rgvInfos.size() - rgvFaultNum;
|
||||
List<Map<String, Object>> rgv_info = Arrays.asList(
|
||||
createItem.apply("0").apply(rgvNormalNum),
|
||||
createItem.apply("1").apply(rgvFaultNum)
|
||||
);
|
||||
// 输送线
|
||||
JSONArray conveyorInfos = (JSONArray) redisUtils.get("site1");
|
||||
int ptConveyorNum = (int) conveyorInfos.stream()
|
||||
.map(object -> (JSONObject) object)
|
||||
.filter(jsonObject -> AcsDefineEnum.VEHICLE_TYPE.code("普涂").equals(jsonObject.getString("pallet_type")))
|
||||
.count();
|
||||
int ltConveyorNum = (int) conveyorInfos.stream()
|
||||
.map(object -> (JSONObject) object)
|
||||
.filter(jsonObject -> AcsDefineEnum.VEHICLE_TYPE.code("连涂").equals(jsonObject.getString("pallet_type")))
|
||||
.count();
|
||||
int emptyConveyorNum = conveyorInfos.size() - ptConveyorNum - ltConveyorNum;
|
||||
List<Map<String, Object>> conveyor_info = Arrays.asList(
|
||||
createItem.apply("2").apply(ltConveyorNum),
|
||||
createItem.apply("3").apply(ptConveyorNum),
|
||||
createItem.apply("4").apply(emptyConveyorNum)
|
||||
);
|
||||
device_status.put("agv_info", agv_info);
|
||||
device_status.put("rgv_info", rgv_info);
|
||||
device_status.put("conveyor_info", conveyor_info);
|
||||
|
||||
|
||||
//实时故障告警
|
||||
List<Map<String, Object>> fault_alarm = cockpitMapper.faultAlarm();
|
||||
faultAlarmDefault(fault_alarm, "TS_RGV02");
|
||||
faultAlarmDefault(fault_alarm, "AGV08");
|
||||
//近30日故障统计
|
||||
JSONArray monthly_fault_statistics = cockpitMapper.monthlyFaultStatistics();
|
||||
if (ObjectUtil.isEmpty(monthly_fault_statistics)) {
|
||||
@@ -454,16 +457,18 @@ public class CockpitServiceImpl implements CockpitService {
|
||||
public JSONObject equipmentInfo(String deviceCode) {
|
||||
JSONObject res = new JSONObject();
|
||||
SchBasePoint point = pointService.getById(deviceCode);
|
||||
if (point == null) {
|
||||
throw new BadRequestException("该设备不存在");
|
||||
}
|
||||
String type = point != null ? point.getRegion_code() : RegionCodeConstant.VEHICLEINFO;
|
||||
List<SchBasePoint> points;
|
||||
switch (point.getRegion_code()) {
|
||||
switch (type) {
|
||||
case RegionCodeConstant.COATED_PLATE_LINE_AREA:
|
||||
// hint: 涂板线是作为一整台设备显示。point:设备点
|
||||
// 涂板线区域,涂板线是作为一整台设备显示,point:设备点
|
||||
JSONArray baoshijian = (JSONArray) redisUtils.get("baoshijian1");
|
||||
points = pointService.getSubSites(deviceCode);
|
||||
res.put("device_code", deviceCode);
|
||||
//todo 运行状态,信号缺失
|
||||
res.put("mode", 2);
|
||||
//todo 当前生产时间,信号缺失
|
||||
res.put("production_time", 0);
|
||||
res.put("device_name", point.getPoint_name());
|
||||
//当前物料
|
||||
JSONObject getDeviceWorker = cockpitMapper.getDeviceWorker(deviceCode);
|
||||
@@ -483,31 +488,52 @@ public class CockpitServiceImpl implements CockpitService {
|
||||
JSONObject one = new JSONObject();
|
||||
one.put("device_code", pointObj.getPoint_code());
|
||||
one.put("device_name", pointObj.getPoint_name());
|
||||
// one.put("mode", "2");
|
||||
for (Object object : baoshijian) {
|
||||
JSONObject jsonObject = (JSONObject) object;
|
||||
if (pointObj.getPoint_code().equals(jsonObject.getString("device_code"))) {
|
||||
one.put("move", jsonObject.getString("move") == null ? "0" : jsonObject.getString("move"));
|
||||
//todo 模式,信号缺失
|
||||
one.put("mode", jsonObject.getString("mode") == null ? "0" : jsonObject.getString("mode"));
|
||||
//todo 错误码(中文),信号缺失
|
||||
one.put("error", jsonObject.getString("error") == null ? "0" : jsonObject.getString("error"));
|
||||
}
|
||||
}
|
||||
array.add(one);
|
||||
}
|
||||
res.put("details", array);
|
||||
//日产量
|
||||
JSONArray production_day = new JSONArray();
|
||||
production_day=cockpitMapper.getProductionDay(deviceCode);
|
||||
res.put("production_day",production_day);
|
||||
JSONArray production_day;
|
||||
//todo 暂时注释当天条件,正式环境需要加上只查当天数据
|
||||
production_day = cockpitMapper.getProductionDay(deviceCode);
|
||||
//班产量
|
||||
JSONArray production_team=new JSONArray();
|
||||
production_team=cockpitMapper.getProductionTeam(deviceCode);
|
||||
res.put("production_team",production_team);
|
||||
JSONArray production_team;
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime todayStart1 = now.toLocalDate().atTime(LocalTime.of(7, 0));
|
||||
LocalDateTime todayEnd1 = now.toLocalDate().atTime(LocalTime.of(18, 0));
|
||||
LocalDateTime todayStart2 = now.toLocalDate().atTime(LocalTime.of(18, 30));
|
||||
LocalDateTime todayEnd12 = now.toLocalDate().plusDays(1).atTime(LocalTime.of(6, 30));
|
||||
Integer dateType = 1;
|
||||
if (now.isAfter(todayStart1) && now.isBefore(todayEnd1)) {
|
||||
//白班
|
||||
dateType = 1;
|
||||
res.put("team", "白班");
|
||||
} else if (now.isAfter(todayStart2) || now.isBefore(todayEnd12)) {
|
||||
//晚班
|
||||
dateType = 2;
|
||||
res.put("team", "晚班");
|
||||
}
|
||||
//todo 暂时注释白晚班查询条件,正式环境需要加上只查班组数据
|
||||
production_team = cockpitMapper.getProductionTeam(deviceCode, dateType);
|
||||
res.put("production_day", production_day);
|
||||
res.put("production_team", production_team);
|
||||
//30日生产记录
|
||||
JSONArray production_history=new JSONArray();
|
||||
production_history=cockpitMapper.getProductionHistory(deviceCode);
|
||||
res.put("production_team",production_history);
|
||||
List<Map<String, Object>> tb_real_qty = cockpitMapper.getTxQty("30", "TBX");
|
||||
List<Map<String, Object>> tb_real_qty_default = new ArrayList<>();
|
||||
getWeekWorkStatistics(tb_real_qty, tb_real_qty_default, "TBX", 30);
|
||||
res.put("production_month ", tb_real_qty_default);
|
||||
break;
|
||||
case RegionCodeConstant.CURING_ZONE:
|
||||
// hint: 固化室,需要显示整个设备+内部位置明细
|
||||
//固化室,需要显示整个设备+内部位置明细
|
||||
points = pointService.getSubSites(deviceCode); // 小固化位置以及进出口(入口是不管的)
|
||||
JSONArray guhuashi = (JSONArray) redisUtils.get("guhuashi1");
|
||||
for (Object object : guhuashi) {
|
||||
@@ -517,12 +543,17 @@ public class CockpitServiceImpl implements CockpitService {
|
||||
res.put("device_statue", point.getPoint_status());
|
||||
JSONObject jsonObject = (JSONObject) object;
|
||||
if (deviceCode.equals(jsonObject.getString("device_code"))) {
|
||||
res.put("current_stage", jsonObject.getString("current_stage"));
|
||||
res.put("humidity_setting", jsonObject.getString("humidity_setting"));
|
||||
res.put("temperature", jsonObject.getString("temperature"));
|
||||
res.put("humidity", jsonObject.getString("humidity"));
|
||||
res.put("device_status", jsonObject.getString("device_statue"));
|
||||
res.put("total_running_time", jsonObject.getString("total_running_time"));
|
||||
res.put("temperature_setting", jsonObject.getString("temperature_setting"));
|
||||
//固化工艺
|
||||
res.put("craft", jsonObject.getString("craft") == null ? "0" : jsonObject.getString("craft"));
|
||||
//todo 需固化时间,阶段设定时,暂无数据默认5
|
||||
res.put("required_time", jsonObject.getString("required_time") == null ? "5" : jsonObject.getString("required_time"));
|
||||
//固化阶段
|
||||
res.put("executing_stage_num", jsonObject.getString("executing_stage_num"));
|
||||
res.put("humidity_setting", jsonObject.getString("humidity_setting"));
|
||||
res.put("humidity", jsonObject.getString("humidity"));
|
||||
res.put("temperature", jsonObject.getString("temperature"));
|
||||
}
|
||||
}
|
||||
JSONArray ghsArray = new JSONArray();
|
||||
@@ -539,22 +570,41 @@ public class CockpitServiceImpl implements CockpitService {
|
||||
one.put("material_type", ObjectUtil.isNotEmpty(pointObj.getVehicle_type()) ? pointObj.getVehicle_type() : "-");
|
||||
ghsArray.add(one);
|
||||
}
|
||||
//todo 需要检查当前固化逻辑是否正确
|
||||
List<String> deviceCodes = ghsArray.stream()
|
||||
.map(r -> ((JSONObject) r).getString("device_code"))
|
||||
.collect(Collectors.toList());
|
||||
List<Map<String, Object>> current_tasks = cockpitMapper.getCurrentTasks(deviceCodes);
|
||||
List<Map<String, Object>> gh_real_qty = cockpitMapper.getGhsQty("30");
|
||||
List<Map<String, Object>> gh_real_qty_default = new ArrayList<>();
|
||||
getWeekWorkStatistics(gh_real_qty, gh_real_qty_default, "GHS", 30);
|
||||
res.put("production_month ", gh_real_qty_default);
|
||||
res.put("current_tasks ", current_tasks);
|
||||
res.put("details", ghsArray);
|
||||
break;
|
||||
case RegionCodeConstant.EMPTY_TEMPORARY_STORAGE_AREA:
|
||||
// 空暂存区
|
||||
// 输送线
|
||||
points = pointService.getSubSites(deviceCode);
|
||||
res.put("device_code", deviceCode);
|
||||
res.put("device_name", point.getPoint_name());
|
||||
res.put("material_type", ObjectUtil.isNotEmpty(point.getVehicle_type()) ? point.getVehicle_type() : "-");
|
||||
res.put("end_time", "-");
|
||||
JSONArray ssxInfos = (JSONArray) redisUtils.get("site1");
|
||||
JSONArray ssxArray = new JSONArray();
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
SchBasePoint pointObj = points.get(i);
|
||||
JSONObject one = new JSONObject();
|
||||
one.put("move", "0");
|
||||
one.put("mode", "0");
|
||||
for (Object object : ssxInfos) {
|
||||
JSONObject jsonObject = (JSONObject) object;
|
||||
if (pointObj.getPoint_code().equals(jsonObject.getString("device_code"))) {
|
||||
one.put("move", jsonObject.getString("move") == null ? "0" : jsonObject.getString("move"));
|
||||
one.put("mode", jsonObject.getString("mode") == null ? "0" : jsonObject.getString("mode"));
|
||||
}
|
||||
}
|
||||
one.put("device_code", pointObj.getPoint_code());
|
||||
one.put("device_name", pointObj.getPoint_name());
|
||||
one.put("move", "0");
|
||||
ssxArray.add(one);
|
||||
}
|
||||
res.put("details", ssxArray);
|
||||
@@ -570,21 +620,113 @@ public class CockpitServiceImpl implements CockpitService {
|
||||
// 货位直接显示,获取组盘信息,组装数据反馈
|
||||
res.put("device_code", deviceCode);
|
||||
res.put("device_name", point.getPoint_name());
|
||||
// res.put("vehicle_code", ObjectUtil.isNotEmpty(point.getVehicle_code()) ? point.getVehicle_code() : "-");
|
||||
// res.put("vehicle_type", ObjectUtil.isNotEmpty(point.getVehicle_type()) ? point.getVehicle_type() : "-");
|
||||
res.put("move", "0");
|
||||
if (ObjectUtil.isNotEmpty(point.getVehicle_type()) && ObjectUtil.isNotEmpty(point.getVehicle_code())) {
|
||||
JSONObject groupInfo = cockpitMapper.getVehicleGroupInfo(point.getVehicle_code(), point.getVehicle_type());
|
||||
if (ObjectUtil.isNotEmpty(groupInfo)) {
|
||||
res.put("storage_info", groupInfo);
|
||||
res.put("move", "1");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RegionCodeConstant.VEHICLEINFO:
|
||||
JSONArray agvInfos = (JSONArray) redisUtils.get("AGV1");
|
||||
JSONArray rgvInfos = (JSONArray) redisUtils.get("RGV1");
|
||||
JSONObject vehicleInfo = agvInfos.stream()
|
||||
.map(object -> (JSONObject) object)
|
||||
.filter(jsonObject -> deviceCode.equals(jsonObject.getString("device_code")))
|
||||
.findFirst()
|
||||
.orElse(new JSONObject());
|
||||
if (ObjectUtil.isNotEmpty(vehicleInfo)) {
|
||||
vehicleInfo.put("type", "AGV");
|
||||
} else {
|
||||
vehicleInfo = rgvInfos.stream()
|
||||
.map(object -> (JSONObject) object)
|
||||
.filter(jsonObject -> deviceCode.equals(jsonObject.getString("vehicle")))
|
||||
.findFirst()
|
||||
.orElse(new JSONObject());
|
||||
if (ObjectUtil.isNotEmpty(vehicleInfo)) {
|
||||
vehicleInfo.put("type", "RGV");
|
||||
}
|
||||
}
|
||||
res = queryVehicleInfo(vehicleInfo);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
getFaultsForDevice(deviceCode, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
private void getFaultsForDevice(String deviceCode, JSONObject res) {
|
||||
JSONObject faultInfo = getFaultsForDevice(deviceCode);
|
||||
//故障次数与故障率
|
||||
if (ObjectUtil.isNotEmpty(faultInfo)) {
|
||||
res.put("fault_total", faultInfo.get("fault_total"));
|
||||
res.put("fault_percentage", faultInfo.get("fault_percentage"));
|
||||
} else {
|
||||
res.put("fault_total", "0");
|
||||
res.put("fault_percentage", "0");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询车辆信息
|
||||
*/
|
||||
|
||||
public JSONObject queryVehicleInfo(JSONObject vehicleInfo) {
|
||||
if (StringUtils.isBlank(vehicleInfo.getString("type"))) {
|
||||
return null;
|
||||
}
|
||||
String deviceCode;
|
||||
//当前任务
|
||||
JSONObject current_tasks = cockpitMapper.getCurrentTask(vehicleInfo.getString("task_id"));
|
||||
String transportOrder = ObjectUtil.isNotEmpty(current_tasks) ? "正常" : "";
|
||||
vehicleInfo.put("transportOrder", transportOrder);
|
||||
String energyLevel = StringUtils.isNotBlank(vehicleInfo.getString("energyLevel")) ? String.valueOf((long) Double.parseDouble(vehicleInfo.getString("energyLevel"))) : "50";
|
||||
vehicleInfo.put("energyLevel", energyLevel);
|
||||
if ("AGV".equals(vehicleInfo.getString("type"))) {
|
||||
deviceCode = StringUtils.isNotBlank(vehicleInfo.getString("device_code")) ? vehicleInfo.getString("device_code") : "err_1";
|
||||
vehicleInfo.put("device_code", deviceCode);
|
||||
//编号
|
||||
String number = StringUtils.isNotBlank(vehicleInfo.getString("device_code")) ? vehicleInfo.getString("device_code").substring(vehicleInfo.getString("device_code").length() - 1) : "";
|
||||
vehicleInfo.put("number", number);
|
||||
String positionX = StringUtils.isNotBlank(vehicleInfo.getString("positionX")) ? vehicleInfo.getString("positionX") : "0";
|
||||
vehicleInfo.put("positionX", positionX);
|
||||
String positionY = StringUtils.isNotBlank(vehicleInfo.getString("positionY")) ? vehicleInfo.getString("positionY") : "0";
|
||||
vehicleInfo.put("positionY", positionY);
|
||||
String positionAngle = StringUtils.isNotBlank(vehicleInfo.getString("positionAngle")) ? vehicleInfo.getString("positionAngle") : "0";
|
||||
vehicleInfo.put("positionAngle", positionAngle);
|
||||
//运行状态
|
||||
String device_status = StringUtils.isNotBlank(vehicleInfo.getString("device_status")) ? AcsDefineEnum.AGV_STATUS.check(vehicleInfo.getString("device_status")) : "";
|
||||
vehicleInfo.put("device_status", device_status);
|
||||
//车辆状态
|
||||
String vehicle_status = device_status.equals(AcsDefineEnum.AGV_STATUS.check("6")) ? "故障" : "正常";
|
||||
vehicleInfo.put("vehicle_status", vehicle_status);
|
||||
} else {
|
||||
deviceCode = StringUtils.isNotBlank(vehicleInfo.getString("vehicle")) ? vehicleInfo.getString("vehicle") : "err_1";
|
||||
vehicleInfo.put("device_code", deviceCode);
|
||||
String open_time = StringUtils.isNotBlank(vehicleInfo.getString("open_time")) ? vehicleInfo.getString("open_time").replaceAll("(?<=\\d) +| +(?=\\d)", "") : "未开机";
|
||||
String end_time = StringUtils.isNotBlank(vehicleInfo.getString("end_time")) ? vehicleInfo.getString("end_time").replaceAll("(?<=\\d) +| +(?=\\d)", "") : "未开机";
|
||||
vehicleInfo.put("open_time", open_time);
|
||||
vehicleInfo.put("end_time", end_time);
|
||||
String production_time = StringUtils.isNotBlank(vehicleInfo.getString("production_time")) ? String.valueOf((long) Double.parseDouble(vehicleInfo.getString("production_time")) / 3600) : "";
|
||||
vehicleInfo.put("production_time", production_time);
|
||||
//运行状态
|
||||
String device_status = StringUtils.isNotBlank(vehicleInfo.getString("status")) ? AcsDefineEnum.RGV_STATUS.check1(vehicleInfo.getString("status")) : "";
|
||||
vehicleInfo.put("device_status", device_status);
|
||||
String vehicle_status = StringUtils.isNotBlank(vehicleInfo.getString("Error")) ? "故障" : "正常";
|
||||
vehicleInfo.put("vehicle_status", vehicle_status);
|
||||
String rfid = StringUtils.isNotBlank(vehicleInfo.getString("rfid")) ? vehicleInfo.getString("rfid") : "";
|
||||
vehicleInfo.put("rfid", rfid);
|
||||
String angle = StringUtils.isNotBlank(vehicleInfo.getString("angle")) ? vehicleInfo.getString("angle") : "";
|
||||
vehicleInfo.put("positionAngle", angle);
|
||||
}
|
||||
vehicleInfo.put("current_tasks", current_tasks);
|
||||
return vehicleInfo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 接收acs推送的设备信息
|
||||
@@ -901,18 +1043,15 @@ public class CockpitServiceImpl implements CockpitService {
|
||||
/**
|
||||
* 查询设备的故障次数和故障率
|
||||
*/
|
||||
private DeviceFaultStatistics getFaultsForDevice(String deviceCode) {
|
||||
long totalFaults = cockpitMapper.getFaultsForDevice(deviceCode);
|
||||
long last30Days = 30; // 假设固定为30天
|
||||
double faultRate = (totalFaults / (double) last30Days) * 100.0;
|
||||
// 返回包含故障数和故障率的对象
|
||||
return new DeviceFaultStatistics(totalFaults, faultRate);
|
||||
private JSONObject getFaultsForDevice(String deviceCode) {
|
||||
return cockpitMapper.getFaultsForDevice(deviceCode);
|
||||
}
|
||||
private static void faultAlarmDefault( List<Map<String, Object>> fault_alarm,String device_name) {
|
||||
|
||||
private static void faultAlarmDefault(List<Map<String, Object>> fault_alarm, String device_name) {
|
||||
if (ObjectUtil.isEmpty(fault_alarm)) {
|
||||
Map<String, Object> item1 = new HashMap<>();
|
||||
item1.put("device_name", device_name);
|
||||
item1.put("fault_cause", "过载");
|
||||
item1.put("fault_cause", "通信失败");
|
||||
item1.put("alarm_time", localDateTimeFormatyMdHms(LocalDateTime.now()));
|
||||
fault_alarm.add(item1);
|
||||
}
|
||||
|
||||
@@ -43,18 +43,17 @@ public interface CockpitMapper {
|
||||
|
||||
List<TargetAchievement> getWorkOrders(@Param("regionCode") String regionCode, @Param("days") Integer days);
|
||||
|
||||
List<Map<String, Object>> getCurrentTasks(@Param("deviceCodes") List<String> deviceCodes);
|
||||
|
||||
JSONObject getCurrentTask(@Param("taskId") String taskId);
|
||||
|
||||
List<TargetAchievement> getGhActualProduction(@Param("days") Integer days);
|
||||
|
||||
|
||||
List<TaskInfo> gettodayGhTaskList();
|
||||
|
||||
@Select("SELECT COUNT(*) AS totalFaults, " +
|
||||
" (COUNT(*) / 30.0) * 100 AS faultRate " +
|
||||
"FROM das_device_fault " +
|
||||
"WHERE device_code = #{deviceCode} " +
|
||||
" AND failure_time >= NOW() - INTERVAL 30 DAY")
|
||||
Long getFaultsForDevice(@Param("deviceCode") String deviceCode);
|
||||
|
||||
JSONObject getFaultsForDevice(@Param("deviceCode") String deviceCode);
|
||||
|
||||
|
||||
List<DayData> getGhCuringSummary();
|
||||
@@ -118,10 +117,10 @@ public interface CockpitMapper {
|
||||
JSONArray getProductionDay(String devicecode);
|
||||
|
||||
//根据所传设备得到该设备班产量
|
||||
JSONArray getProductionTeam(String devicecode);
|
||||
JSONArray getProductionTeam(@Param("deviceCode") String devicecode,@Param("dateType") Integer dateType);
|
||||
|
||||
//根据所传设备得到该设备30天生产记录
|
||||
JSONArray getProductionHistory(String devicecode);
|
||||
List<Map<String, Object>> getProductionHistory(String devicecode);
|
||||
//今日生产连涂生产
|
||||
JSONObject ltProduction();
|
||||
//今日生产普涂生产
|
||||
|
||||
@@ -103,7 +103,63 @@
|
||||
AND vehicle_type = #{vehicleType}
|
||||
</if>
|
||||
</select>
|
||||
<select id="getCurrentTasks" resultType="java.util.HashMap">
|
||||
SELECT
|
||||
g.vehicle_type,
|
||||
g.pcsn,
|
||||
g.material_qty,
|
||||
m.material_name,
|
||||
m.material_spec
|
||||
FROM
|
||||
sch_base_vehiclematerialgroup g
|
||||
LEFT JOIN md_base_material m ON g.material_id = m.material_id
|
||||
WHERE
|
||||
g.vehicle_code IN (
|
||||
SELECT
|
||||
vehicle_code
|
||||
FROM
|
||||
sch_base_point
|
||||
WHERE point_code IN
|
||||
<foreach collection="deviceCodes" item="code" open="(" separator="," close=")">
|
||||
#{code}
|
||||
</foreach>
|
||||
)
|
||||
AND g.is_delete = '0'
|
||||
</select>
|
||||
|
||||
<select id="getCurrentTask" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
t.task_code,
|
||||
t.point_code1,
|
||||
t.point_code2,
|
||||
CASE
|
||||
WHEN t.next_wait_point IS NULL THEN
|
||||
"" ELSE ""
|
||||
END AS next_wait_point,
|
||||
t.vehicle_code,
|
||||
g.vehicle_type,
|
||||
m.material_name,
|
||||
g.pcsn,
|
||||
g.material_qty
|
||||
FROM
|
||||
sch_base_task t
|
||||
LEFT JOIN sch_base_vehiclematerialgroup g ON g.group_id = t.group_id
|
||||
LEFT JOIN md_base_material m ON m.material_id = g.material_id
|
||||
WHERE t.task_id = #{taskId}
|
||||
</select>
|
||||
|
||||
<select id="getFaultsForDevice" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
COUNT(*) AS fault_total, CASE
|
||||
WHEN COUNT(*) = 0 THEN 0
|
||||
ELSE ROUND((COUNT(*) / 30.0) * 100, 0)
|
||||
END AS fault_percentage
|
||||
FROM
|
||||
das_device_fault
|
||||
WHERE
|
||||
device_code = #{deviceCode}
|
||||
AND failure_time >= NOW() - INTERVAL 30 DAY;
|
||||
</select>
|
||||
|
||||
<select id="getGhCuringSummary" resultType="org.nl.wms.cockpit.service.dao.home.DayData">
|
||||
SELECT CASE
|
||||
@@ -354,44 +410,72 @@
|
||||
m.material_id= #{material_id}
|
||||
</select>
|
||||
<select id="getProductionDay" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
w.plan_qty,
|
||||
w.real_qty,
|
||||
(w.plan_qty)-(w.real_qty) AS remain_qty,
|
||||
(w.real_qty)/(w.plan_qty) AS percentage,
|
||||
m.material_name
|
||||
FROM `pdm_bd_workorder` w
|
||||
LEFT JOIN md_base_material m ON m.material_id = w.material_id
|
||||
WHERE
|
||||
DATE(w.create_time)=CURDATE()
|
||||
And w.point_code= #{devicecode}
|
||||
SELECT
|
||||
w.plan_qty,
|
||||
w.real_qty,
|
||||
(w.plan_qty - w.real_qty) AS remain_qty,
|
||||
CASE
|
||||
WHEN w.plan_qty = 0 AND w.real_qty = 0 THEN 0
|
||||
WHEN w.plan_qty = 0 THEN 100
|
||||
ELSE ROUND((w.real_qty * 1.0 / w.plan_qty) * 100, 0)
|
||||
END AS percentage,
|
||||
m.material_spec,
|
||||
m.material_name,
|
||||
g.pcsn
|
||||
FROM
|
||||
pdm_bd_workorder w
|
||||
LEFT JOIN md_base_material m ON m.material_id = w.material_id
|
||||
LEFT JOIN (
|
||||
SELECT p1.workorder_code, p1.pcsn
|
||||
FROM sch_base_vehiclematerialgroup p1
|
||||
INNER JOIN (
|
||||
SELECT workorder_code, MIN(group_id) AS min_group_id
|
||||
FROM sch_base_vehiclematerialgroup
|
||||
GROUP BY workorder_code
|
||||
) p2 ON p1.workorder_code = p2.workorder_code AND p1.group_id = p2.min_group_id
|
||||
) g ON g.workorder_code = w.workorder_code
|
||||
WHERE
|
||||
w.point_code = #{devicecode};
|
||||
# AND DATE(w.create_time) = CURDATE()
|
||||
</select>
|
||||
<select id="getProductionTeam" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
w.plan_qty,
|
||||
w.real_qty,
|
||||
(w.plan_qty)-(w.real_qty) AS remain_qty,
|
||||
(w.real_qty)/(w.plan_qty) AS percentage,
|
||||
m.material_name,
|
||||
w.team
|
||||
FROM `pdm_bd_workorder` w
|
||||
LEFT JOIN md_base_material m ON m.material_id = w.material_id
|
||||
WHERE
|
||||
DATE(w.create_time)=CURDATE()
|
||||
And w.point_code= #{devicecode}
|
||||
And w.workorder_status= 3
|
||||
</select>
|
||||
<select id="getProductionHistory" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
DATE_FORMAT(w.create_time,'%Y-%m-%d') AS date,
|
||||
SUM(w.real_qty) AS total_qty
|
||||
FROM
|
||||
`pdm_bd_workorder` w
|
||||
WHERE
|
||||
create_time >= CURDATE() - INTERVAL 30 DAY
|
||||
And w.point_code= #{devicecode}
|
||||
GROUP BY
|
||||
DATE_FORMAT(w.create_time, '%Y-%m-%d');
|
||||
SELECT
|
||||
w.plan_qty,
|
||||
w.real_qty,
|
||||
(w.plan_qty - w.real_qty) AS remain_qty,
|
||||
CASE
|
||||
WHEN w.plan_qty = 0 AND w.real_qty = 0 THEN 0
|
||||
WHEN w.plan_qty = 0 THEN 100
|
||||
ELSE ROUND((w.real_qty * 1.0 / w.plan_qty) * 100, 0)
|
||||
END AS percentage,
|
||||
m.material_spec,
|
||||
m.material_name,
|
||||
g.pcsn
|
||||
FROM
|
||||
pdm_bd_workorder w
|
||||
LEFT JOIN md_base_material m ON m.material_id = w.material_id
|
||||
LEFT JOIN (
|
||||
SELECT p1.workorder_code, p1.pcsn
|
||||
FROM sch_base_vehiclematerialgroup p1
|
||||
INNER JOIN (
|
||||
SELECT workorder_code, MIN(group_id) AS min_group_id
|
||||
FROM sch_base_vehiclematerialgroup
|
||||
GROUP BY workorder_code
|
||||
) p2 ON p1.workorder_code = p2.workorder_code AND p1.group_id = p2.min_group_id
|
||||
) g ON g.workorder_code = w.workorder_code
|
||||
WHERE
|
||||
w.point_code = #{deviceCode}
|
||||
<!-- AND <choose>-->
|
||||
<!-- <when test="dateType == 1">-->
|
||||
<!-- w.create_time BETWEEN CONCAT(DATE(NOW()), ' 07:00:00') AND CONCAT(DATE(NOW()), ' 18:00:00')-->
|
||||
<!-- </when>-->
|
||||
<!-- <when test="dateType == 2">-->
|
||||
<!-- w.create_time BETWEEN CONCAT(DATE(NOW()), ' 18:30:00') AND CONCAT(DATE_ADD(DATE(NOW()), INTERVAL 1 DAY), ' 06:30:00')-->
|
||||
<!-- </when>-->
|
||||
<!-- <otherwise>-->
|
||||
<!-- 1 = 1-->
|
||||
<!-- </otherwise>-->
|
||||
<!-- </choose>-->
|
||||
</select>
|
||||
<select id="ltProduction" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
@@ -405,6 +489,19 @@
|
||||
AND DATE(w.create_time) = CURDATE()
|
||||
AND point_code LIKE 'LT%';
|
||||
</select>
|
||||
|
||||
<select id="getProductionHistory" resultType="java.util.HashMap">
|
||||
SELECT
|
||||
SUM(w.plan_qty) AS plan_production,
|
||||
SUM(w.real_qty) AS actual_production,
|
||||
ROUND(SUM(w.real_qty) / SUM(w.plan_qty) * 100) AS percentage
|
||||
FROM
|
||||
`pdm_bd_workorder` w
|
||||
WHERE
|
||||
w.workorder_status = 3
|
||||
AND DATE(w.create_time) = CURDATE()
|
||||
AND point_code LIKE 'LT%';
|
||||
</select>
|
||||
<select id="ptProduction" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
SUM(w.plan_qty) AS plan_production,
|
||||
|
||||
@@ -190,6 +190,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
Integer type = param.getInteger("type");
|
||||
String device_code = param.getString("device_code");
|
||||
String state = param.getString("state");
|
||||
String current_status = param.getString("current_status");
|
||||
switch (type) {
|
||||
case 1:
|
||||
//反馈设备状态,将对应固化室修改为传入状态
|
||||
@@ -204,7 +205,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
try {
|
||||
SchBasePoint schBasePoint=pointService.getById(device_code);
|
||||
if(ObjectUtil.isNotEmpty(schBasePoint)) {
|
||||
if ("0".equals(state)) {
|
||||
if ("0".equals(current_status)) {
|
||||
schBasePoint.setIs_used(true);
|
||||
pointService.update(schBasePoint);
|
||||
} else {
|
||||
@@ -215,6 +216,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
dasDeviceFault.setData_id(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
dasDeviceFault.setFailure_time(now);
|
||||
dasDeviceFault.setFailure_info(state);
|
||||
//当前状态
|
||||
dasDeviceFault.setCurrent_status(current_status);
|
||||
cockpitMapper.insertDeviceFault(dasDeviceFault);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,14 +6,30 @@ package org.nl.wms.sch.task_manage.enums;
|
||||
* @Date: 2023/11/22
|
||||
*/
|
||||
public class RegionCodeConstant {
|
||||
/** 固化区域 */
|
||||
public final static String COATED_PLATE_LINE_AREA = "TBX";
|
||||
/**
|
||||
* 固化区域
|
||||
*/
|
||||
public final static String CURING_ZONE = "GH";
|
||||
/** 空架暂存区域 */
|
||||
|
||||
/**
|
||||
* 车辆信息
|
||||
*/
|
||||
public final static String VEHICLEINFO = "VEHICLEINFO";
|
||||
|
||||
/**
|
||||
* 空架暂存区域
|
||||
*/
|
||||
public final static String EMPTY_TEMPORARY_STORAGE_AREA = "KJZC";
|
||||
/** 空架位区域 */
|
||||
|
||||
/**
|
||||
* 空架位区域
|
||||
*/
|
||||
public final static String EMPTY_POSITION_AREA = "KJW";
|
||||
/** 涂板线区域 */
|
||||
public final static String COATED_PLATE_LINE_AREA = "TBX";
|
||||
/** 暂存区域 */
|
||||
|
||||
/**
|
||||
* 暂存区域
|
||||
*/
|
||||
public final static String STAGING_AREA = "ZC";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user