李永德
2 years ago
9 changed files with 456 additions and 108 deletions
@ -0,0 +1,123 @@ |
|||
package org.nl.modules.common.utils; |
|||
|
|||
import cn.hutool.core.date.DateUtil; |
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.modules.wql.core.bean.WQLObject; |
|||
import org.nl.wms.ext.acs.service.impl.WmsToAcsServiceImpl; |
|||
import org.nl.wms.sch.manage.DeviceStatusEnum; |
|||
import org.nl.wms.sch.manage.PointEnum; |
|||
|
|||
/** |
|||
* @author: lyd |
|||
* @description: 点位更新工具类 |
|||
* @Date: 2022/11/23 |
|||
*/ |
|||
@Slf4j |
|||
public class PointUpdateUtil { |
|||
/** |
|||
* 清理点位 |
|||
*/ |
|||
public static void clearPoint(String point_code) { |
|||
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point"); |
|||
JSONObject pointObj = pointTab.query("point_code = '" + point_code + "'").uniqueResult(0); |
|||
pointObj.put("point_status", PointEnum.POINT_STATUS_EMPTY_POSITION.getCode()); |
|||
pointObj.put("lock_type", PointEnum.LOCK_TYPE_FALSE.getCode()); |
|||
pointObj.put("vehicle_type", ""); |
|||
pointObj.put("vehicle_code", ""); |
|||
pointObj.put("vehicle_qty", "0"); |
|||
pointObj.put("material_id", ""); |
|||
pointObj.put("pcsn", ""); |
|||
pointObj.put("ivt_qty", "0"); |
|||
pointObj.put("qty_unit_id", ""); |
|||
pointObj.put("ivt_weight", "0"); |
|||
pointObj.put("weight_unit_id", ""); |
|||
pointObj.put("instorage_time", ""); |
|||
pointObj.put("is_full", "0"); |
|||
pointObj.put("standing_time", "0"); |
|||
pointObj.put("warn_time", "0"); |
|||
pointObj.put("group_id", ""); |
|||
pointTab.update(pointObj); |
|||
} |
|||
|
|||
/** |
|||
* 点位:空载具 |
|||
*/ |
|||
public static void setVehicle(JSONObject jsonObject) { |
|||
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point"); |
|||
JSONObject pointObj = pointTab.query("point_code = '" + jsonObject.getString("point_code") + "'").uniqueResult(0); |
|||
pointObj.put("lock_type", PointEnum.LOCK_TYPE_FALSE.getCode()); |
|||
pointObj.put("point_status", PointEnum.POINT_STATUS_EMPTY_VEHICLE.getCode()); |
|||
pointObj.put("vehicle_code", jsonObject.getString("vehicle_code")); |
|||
pointObj.put("vehicle_qty", "1"); |
|||
pointObj.put("instorage_time", DateUtil.now()); |
|||
pointObj.put("is_full", "1"); |
|||
pointObj.put("ivt_qty", "0"); |
|||
pointObj.put("pcsn", null); |
|||
pointObj.put("material_id", null); |
|||
pointObj.put("standing_time", "0"); |
|||
pointTab.update(pointObj); |
|||
} |
|||
|
|||
/** |
|||
* 访问acs获取点位数据更新点位信息: |
|||
* 分拣呼叫空托盘、空钢托盘叠盘架 |
|||
* @param pointCodes |
|||
* @deprecated 只更新点位状态和载具类型 |
|||
*/ |
|||
public static void updatePoint(JSONArray pointCodes) { |
|||
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point"); |
|||
WmsToAcsServiceImpl wmsToAcsService = new WmsToAcsServiceImpl(); |
|||
// 向ACS查询点位状态
|
|||
JSONObject pointStatus = wmsToAcsService.getPointStatus(pointCodes); |
|||
// 找到对应的载具类型再去下发
|
|||
JSONArray deviceDatas = pointStatus.getJSONArray("data"); |
|||
if (ObjectUtil.isNotEmpty(deviceDatas)) { |
|||
for (int j = 0; j < deviceDatas.size(); j++) { |
|||
JSONObject pointObj = deviceDatas.getJSONObject(j); |
|||
String point_code = pointObj.getString("device_code"); |
|||
String mode = pointObj.getString("mode"); // 工作状态:0脱机,其他正常
|
|||
String error = pointObj.getString("error"); // 0是正常
|
|||
String point_status = pointObj.getString("move"); // 点位状态:0无货,1有货(具体是空载具还是物料不知道)
|
|||
//将托盘类型456....
|
|||
String vehicle_type = pointObj.getString("container_type"); |
|||
if (mode.equals("0") || !error.equals("0")) { |
|||
// 点位异常
|
|||
vehicle_type = ""; |
|||
point_status = "0"; |
|||
if (point_code.startsWith("BZX")) point_status = "1"; |
|||
} |
|||
JSONObject pointObj2 = pointTable.query("point_code = '" + point_code + "'").uniqueResult(0); |
|||
pointObj2.put("point_status", Integer.parseInt(point_status) + 1); // 1空位, 2空载具
|
|||
pointObj2.put("vehicle_type", vehicle_type); |
|||
pointTable.update(pointObj2); |
|||
} |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 查找设备状态: 单个 |
|||
* @return |
|||
*/ |
|||
public static String getDeviceStatus(String deviceCode) { |
|||
WmsToAcsServiceImpl wmsToAcsService = new WmsToAcsServiceImpl(); |
|||
// 封装
|
|||
JSONArray devices = new JSONArray(); |
|||
JSONObject device = new JSONObject(); |
|||
device.put("device_code", deviceCode); |
|||
devices.add(device); |
|||
// 向ACS查询点位状态
|
|||
JSONObject deviceStatus = wmsToAcsService.getPointStatus(devices); |
|||
JSONArray statusJSONArray = deviceStatus.getJSONArray("data"); |
|||
if (ObjectUtil.isEmpty(statusJSONArray)) return DeviceStatusEnum.SHUTDOWN.getCode(); |
|||
JSONObject deviceJson = statusJSONArray.getJSONObject(0); |
|||
String point_code = deviceJson.getString("device_code"); |
|||
String mode = deviceJson.getString("mode"); // 工作状态:0脱机,其他正常
|
|||
String error = deviceJson.getString("error"); // 0是正常
|
|||
log.info("device_code: " + point_code + ", mode: " + mode + ", error: " + error); |
|||
if (!error.equals("0")) return DeviceStatusEnum.FAILURE.getCode(); |
|||
return mode.equals("0") ? DeviceStatusEnum.STANDBY.getCode() : DeviceStatusEnum.RUNNING.getCode(); |
|||
} |
|||
} |
@ -0,0 +1,76 @@ |
|||
package org.nl.wms.cockpit.service.dto; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonInclude; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Builder; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* @Author: lyd |
|||
* @Description: 设备信息数据 |
|||
* @Date: 2023/3/8 |
|||
*/ |
|||
@Data |
|||
@Builder |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public class DeviceInfoDto implements Serializable { |
|||
/** |
|||
* 设备编码 |
|||
*/ |
|||
private String device_code; |
|||
/** |
|||
* 设备名称 |
|||
*/ |
|||
private String device_name; |
|||
/** |
|||
* 设备类型 |
|||
*/ |
|||
private String device_model; |
|||
/** |
|||
* 设备状态枚举: 0关机(停机),1开机(运行),2故障 |
|||
*/ |
|||
private String device_status; |
|||
/** |
|||
* 设备状态:RGV |
|||
*/ |
|||
@Builder.Default |
|||
private String device_status_name = null; |
|||
/** |
|||
* 当前生产名称 |
|||
*/ |
|||
private String material_name; |
|||
/** |
|||
* 已工作时间 |
|||
*/ |
|||
@Builder.Default |
|||
private String work_time = "0"; |
|||
/** |
|||
* 已生产数量 |
|||
*/ |
|||
private BigDecimal real_qty; |
|||
/** |
|||
* 生产时间 |
|||
*/ |
|||
private String realproducestart_date; |
|||
/** |
|||
* 载具数量(当前窑车数) |
|||
*/ |
|||
private Integer vehicle_qty; |
|||
/** |
|||
* 载具类型 |
|||
*/ |
|||
private String vehicle_type; |
|||
/** |
|||
* 容量 |
|||
*/ |
|||
private Integer vehicle_max_qty; |
|||
/** |
|||
* 图片名字 |
|||
*/ |
|||
private String device_url; |
|||
} |
@ -0,0 +1,61 @@ |
|||
package org.nl.wms.sch.manage; |
|||
|
|||
import cn.hutool.core.util.StrUtil; |
|||
|
|||
/** |
|||
* @Author: lyd |
|||
* @Description: 设备枚举 |
|||
* @Date: 2023/3/9 |
|||
*/ |
|||
public enum DeviceEnum { |
|||
HLJ("1", "混料机", "HLJ", "HLJ"), |
|||
HLJ_S("2", "高速混料机", "HLJ_S", "HLJ_S"), |
|||
YZJ("3", "压制机", "YZJ", "YZJ"), |
|||
YZJ_S("4", "高速压制机", "YZJ_S", "YZJ_S"), |
|||
FJJXS("5", "分拣机械手", "FJJXS", "FJJXS"), |
|||
CPX("6", "拆盘线", "CPX", "CPX"), |
|||
BZX("6", "包装线", "BZX", "BZX"), |
|||
YAO("7", "窑设备", "YAO", "YAO"), |
|||
DPJ("8", "叠盘架", "DPJ", "DPJ"), |
|||
CPJ("9", "拆盘架", "CPJ", "CPJ"), |
|||
MDJXS("10", "码垛机械手", "MDJXS", "MDJXS"), |
|||
RGV("11", "RGV", "RGV", "RGV"); |
|||
|
|||
private final String model; |
|||
private final String name; |
|||
private final String keyName; |
|||
private final String pictureName; |
|||
|
|||
DeviceEnum(String model, String name, String keyName, String pictureName) { |
|||
this.model = model; |
|||
this.name = name; |
|||
this.keyName = keyName; |
|||
this.pictureName = pictureName; |
|||
} |
|||
|
|||
public static DeviceEnum get(String model, String code) { |
|||
for (DeviceEnum deviceEnum : DeviceEnum.values()) { |
|||
if (code.equals(BZX.pictureName)) return BZX; |
|||
if (StrUtil.equals(deviceEnum.model, model)) { |
|||
return deviceEnum; |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
public String getModel() { |
|||
return model; |
|||
} |
|||
|
|||
public String getName() { |
|||
return name; |
|||
} |
|||
|
|||
public String getKeyName() { |
|||
return keyName; |
|||
} |
|||
|
|||
public String getPictureName() { |
|||
return pictureName; |
|||
} |
|||
} |
@ -0,0 +1,28 @@ |
|||
package org.nl.wms.sch.manage; |
|||
|
|||
/** |
|||
* @Author: lyd |
|||
* @Description: 设备状态枚举 |
|||
* @Date: 2023/3/10 |
|||
*/ |
|||
public enum DeviceStatusEnum { |
|||
STANDBY("1", "待机"), |
|||
RUNNING("2", "运行"), |
|||
FAILURE("3", "故障"), |
|||
SHUTDOWN("4", "关机"); |
|||
private final String code; |
|||
private final String description; |
|||
|
|||
DeviceStatusEnum(String code, String description) { |
|||
this.code = code; |
|||
this.description = description; |
|||
} |
|||
|
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public String getDescription() { |
|||
return description; |
|||
} |
|||
} |
Loading…
Reference in new issue