fix 下发工单 获取托盘信息 add 大屏生产统计接口

This commit is contained in:
张江玮
2023-08-18 14:10:27 +08:00
parent a6392a64ec
commit 502aa2fc48
9 changed files with 648 additions and 163 deletions

View File

@@ -1,12 +1,33 @@
package org.nl.acs.device_driver.driver; package org.nl.acs.device_driver.driver;
import cn.hutool.core.util.ObjectUtil;
import org.nl.acs.ext.wms.data.JsonUtl;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.opc.ItemValue;
import org.nl.acs.opc.OpcConfig; import org.nl.acs.opc.OpcConfig;
import org.nl.acs.opc.OpcServerService;
import org.nl.acs.opc.OpcServerServiceImpl;
import org.nl.acs.udw.UnifiedDataAccessor; import org.nl.acs.udw.UnifiedDataAccessor;
import org.nl.acs.udw.UnifiedDataAccessorFactory; import org.nl.acs.udw.UnifiedDataAccessorFactory;
import org.nl.modules.lucene.service.LuceneExecuteLogService;
import org.nl.modules.lucene.service.dto.LuceneLogDto;
import org.nl.modules.wql.exception.WDKException;
import org.nl.modules.wql.util.SpringContextHolder;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements OpcDeviceDriver { public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements OpcDeviceDriver {
UnifiedDataAccessor opcUdw; UnifiedDataAccessor opcUdw;
private Date sendTime;
private String last_items;
private int noLog_sendTimeOut;
private Date noLog_sendTime;
private String noLog_last_items;
public AbstractOpcDeviceDriver() { public AbstractOpcDeviceDriver() {
this.opcUdw = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key); this.opcUdw = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key);
} }
@@ -15,4 +36,100 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
public UnifiedDataAccessor getOpcValueAccessor() { public UnifiedDataAccessor getOpcValueAccessor() {
return this.opcUdw; return this.opcUdw;
} }
public void writing(Map<String, Object> map) {
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class);
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
Map<String, Object> itemMap = new LinkedHashMap<>();
map.forEach((key, value) -> {
if (ObjectUtil.isNotEmpty(value)) {
itemMap.put(getToParam() + key, value);
}
});
if (ObjectUtil.isNotEmpty(itemMap)) {
this.control(itemMap);
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
}
}
public String getToParam() {
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
}
public boolean control(Map<String, Object> itemValues) {
Iterator<Map.Entry<String, Object>> it = itemValues.entrySet().iterator();
ItemValue[] p2;
p2 = new ItemValue[itemValues.size()];
int i = 0;
while (it.hasNext()) {
Map.Entry<String, Object> entry = it.next();
System.out.println("即将写入值:" + entry.getKey() + ":" + entry.getValue());
p2[i] = new ItemValue();
p2[i].setItem_code(entry.getKey());
p2[i].setItem_value(entry.getValue());
i++;
}
return this.control(p2);
}
public boolean control(ItemValue[] itemValues) {
if (itemValues != null && itemValues.length != 0) {
String this_items = JsonUtl.parseWithoutException(itemValues);
boolean need_write = false;
StringBuilder sb = new StringBuilder();
ItemValue[] var5 = itemValues;
int var6 = itemValues.length;
for (int var7 = 0; var7 < var6; ++var7) {
ItemValue itemValue = var5[var7];
String code = itemValue.getItem_code();
Object udw_value = this.getUdwValue(code);
Object write_value = itemValue.getItem_value();
sb.append(code);
sb.append(":");
sb.append(JsonUtl.parseWithoutException(udw_value));
sb.append(";");
// if (!need_write && !UnifiedDataAppService.isEquals(udw_value, write_value)) {
// need_write = true;
// }
}
need_write = true;
if (need_write) {
Date date = new Date();
/*if (StringUtl.isEqual(this_items, this.last_items) && date.getTime() - this.sendTime.getTime() < (long) WcsConfig.opc_write_repeat_check) {
log.trace("发送时间因为小于{}毫秒,而被无视", WcsConfig.opc_write_repeat_check);
return false;
}*/
this.last_items = this_items;
this.sendTime = date;
/* this.execute_log.setResource(this.getDevice().getCode(), this.getDevice().getName());
this.execute_log.log("原始记录{}->变更为{}", new Object[]{sb, this_items});
OpcServerService opcServerService = OpcServerFactory.getOpcServerService();*/
OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerServiceImpl.class);
opcServerService.writeInteger(this.getOpcServer(), itemValues);
UnifiedDataAccessor opcValueAccessor = this.getOpcValueAccessor();
ItemValue[] var17 = itemValues;
int var18 = itemValues.length;
for (int var19 = 0; var19 < var18; ++var19) {
ItemValue itemValue = var17[var19];
String code = itemValue.getItem_code();
Object value = itemValue.getItem_value();
opcValueAccessor.setValue(code, value);
}
}
return true;
} else {
throw new WDKException("下发 无内容");
}
}
} }

View File

@@ -77,4 +77,8 @@ public interface OpcDeviceDriver extends DeviceDriver {
return this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDeviceCode() + "." + item; return this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDeviceCode() + "." + item;
} }
default Object getUdwValue(String protocol) {
return this.getOpcValueAccessor().getValue(protocol);
}
} }

View File

@@ -1284,62 +1284,64 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
String Htrapezoidal = content.getString("htrapezoidal"); String Htrapezoidal = content.getString("htrapezoidal");
String Wthickness = content.getString("wthickness"); String Wthickness = content.getString("wthickness");
this.writing("to_product_code", StrUtil.isBlank(product_code) ? "0" : product_code); HashMap<String, Object> map = new HashMap<>();
this.writing("to_AlongSide", StrUtil.isBlank(AlongSide) ? "0" : AlongSide); map.put("to_product_code", StrUtil.isBlank(product_code) ? "0" : product_code);
this.writing("to_BshortSide", StrUtil.isBlank(BshortSide) ? "0" : BshortSide); map.put("to_AlongSide", StrUtil.isBlank(AlongSide) ? "0" : AlongSide);
this.writing("to_Htrapezoidal", StrUtil.isBlank(Htrapezoidal) ? "0" : Htrapezoidal); map.put("to_BshortSide", StrUtil.isBlank(BshortSide) ? "0" : BshortSide);
this.writing("to_Wthickness", StrUtil.isBlank(Wthickness) ? "0" : Wthickness); map.put("to_Htrapezoidal", StrUtil.isBlank(Htrapezoidal) ? "0" : Htrapezoidal);
map.put("to_Wthickness", StrUtil.isBlank(Wthickness) ? "0" : Wthickness);
//当前托盘砖数量 //当前托盘砖数量
this.writing("to_tray_qty", StrUtil.isBlank(qty) ? "0" : qty); map.put("to_tray_qty", StrUtil.isBlank(qty) ? "0" : qty);
this.writing("to_tray_high", StrUtil.isBlank(tray_high) ? "0" : tray_high); map.put("to_tray_high", StrUtil.isBlank(tray_high) ? "0" : tray_high);
this.writing("to_crib_category", StrUtil.isBlank(crib_category) ? "0" : crib_category); map.put("to_crib_category", StrUtil.isBlank(crib_category) ? "0" : crib_category);
this.writing("to_palletX1_line", StrUtil.isBlank(palletX1_line) ? "0" : palletX1_line); map.put("to_palletX1_line", StrUtil.isBlank(palletX1_line) ? "0" : palletX1_line);
this.writing("to_palletY1_row", StrUtil.isBlank(palletY1_row) ? "0" : palletY1_row); map.put("to_palletY1_row", StrUtil.isBlank(palletY1_row) ? "0" : palletY1_row);
this.writing("to_palletA1_angle", StrUtil.isBlank(palletA1_angle) ? "0" : palletA1_angle); map.put("to_palletA1_angle", StrUtil.isBlank(palletA1_angle) ? "0" : palletA1_angle);
this.writing("to_palletX2_line", StrUtil.isBlank(palletX2_line) ? "0" : palletX2_line); map.put("to_palletX2_line", StrUtil.isBlank(palletX2_line) ? "0" : palletX2_line);
this.writing("to_palletY2_row", StrUtil.isBlank(palletY2_row) ? "0" : palletY2_row); map.put("to_palletY2_row", StrUtil.isBlank(palletY2_row) ? "0" : palletY2_row);
this.writing("to_palletA2_angle", StrUtil.isBlank(palletA2_angle) ? "0" : palletA2_angle); map.put("to_palletA2_angle", StrUtil.isBlank(palletA2_angle) ? "0" : palletA2_angle);
this.writing("to_palletX3_line", StrUtil.isBlank(palletX3_line) ? "0" : palletX3_line); map.put("to_palletX3_line", StrUtil.isBlank(palletX3_line) ? "0" : palletX3_line);
this.writing("to_palletY3_row", StrUtil.isBlank(palletY3_row) ? "0" : palletY3_row); map.put("to_palletY3_row", StrUtil.isBlank(palletY3_row) ? "0" : palletY3_row);
this.writing("to_palletA3_angle", StrUtil.isBlank(palletA3_angle) ? "0" : palletA3_angle); map.put("to_palletA3_angle", StrUtil.isBlank(palletA3_angle) ? "0" : palletA3_angle);
this.writing("to_pressCribX1_line", StrUtil.isBlank(pressCribX1_line) ? "0" : pressCribX1_line); map.put("to_pressCribX1_line", StrUtil.isBlank(pressCribX1_line) ? "0" : pressCribX1_line);
this.writing("to_pressCribY1_row", StrUtil.isBlank(pressCribY1_row) ? "0" : pressCribY1_row); map.put("to_pressCribY1_row", StrUtil.isBlank(pressCribY1_row) ? "0" : pressCribY1_row);
this.writing("to_pressCribA1_angle", StrUtil.isBlank(pressCribA1_angle) ? "0" : pressCribA1_angle); map.put("to_pressCribA1_angle", StrUtil.isBlank(pressCribA1_angle) ? "0" : pressCribA1_angle);
this.writing("to_pressCribX2_line", StrUtil.isBlank(pressCribX2_line) ? "0" : pressCribX2_line); map.put("to_pressCribX2_line", StrUtil.isBlank(pressCribX2_line) ? "0" : pressCribX2_line);
this.writing("to_pressCribY2_row", StrUtil.isBlank(pressCribY2_row) ? "0" : pressCribY2_row); map.put("to_pressCribY2_row", StrUtil.isBlank(pressCribY2_row) ? "0" : pressCribY2_row);
this.writing("to_pressCribA2_angle", StrUtil.isBlank(pressCribA2_angle) ? "0" : pressCribA2_angle); map.put("to_pressCribA2_angle", StrUtil.isBlank(pressCribA2_angle) ? "0" : pressCribA2_angle);
this.writing("to_pressCribX3_line", StrUtil.isBlank(pressCribX3_line) ? "0" : pressCribX3_line); map.put("to_pressCribX3_line", StrUtil.isBlank(pressCribX3_line) ? "0" : pressCribX3_line);
this.writing("to_pressCribY3_row", StrUtil.isBlank(pressCribY3_row) ? "0" : pressCribY3_row); map.put("to_pressCribY3_row", StrUtil.isBlank(pressCribY3_row) ? "0" : pressCribY3_row);
this.writing("to_pressCribA3_angle", StrUtil.isBlank(pressCribA3_angle) ? "0" : pressCribA3_angle); map.put("to_pressCribA3_angle", StrUtil.isBlank(pressCribA3_angle) ? "0" : pressCribA3_angle);
this.writing("to_Zoffset", StrUtil.isBlank(Zoffset) ? "0" : Zoffset); map.put("to_Zoffset", StrUtil.isBlank(Zoffset) ? "0" : Zoffset);
this.writing("to_pallet_layerQty", StrUtil.isBlank(pallet_layerQty) ? "0" : pallet_layerQty); map.put("to_pallet_layerQty", StrUtil.isBlank(pallet_layerQty) ? "0" : pallet_layerQty);
this.writing("to_pressCrib_layerQty", StrUtil.isBlank(pressCrib_layerQty) ? "0" : pressCrib_layerQty); map.put("to_pressCrib_layerQty", StrUtil.isBlank(pressCrib_layerQty) ? "0" : pressCrib_layerQty);
this.writing("to_codeLayerX1_interval", StrUtil.isBlank(codeLayerX1_interval) ? "0" : codeLayerX1_interval); map.put("to_codeLayerX1_interval", StrUtil.isBlank(codeLayerX1_interval) ? "0" : codeLayerX1_interval);
this.writing("to_codeLayerY1_interval", StrUtil.isBlank(codeLayerY1_interval) ? "0" : codeLayerY1_interval); map.put("to_codeLayerY1_interval", StrUtil.isBlank(codeLayerY1_interval) ? "0" : codeLayerY1_interval);
this.writing("to_codeLayerX2_interval", StrUtil.isBlank(codeLayerX2_interval) ? "0" : codeLayerX2_interval); map.put("to_codeLayerX2_interval", StrUtil.isBlank(codeLayerX2_interval) ? "0" : codeLayerX2_interval);
this.writing("to_codeLayerY2_interval", StrUtil.isBlank(codeLayerY2_interval) ? "0" : codeLayerY2_interval); map.put("to_codeLayerY2_interval", StrUtil.isBlank(codeLayerY2_interval) ? "0" : codeLayerY2_interval);
this.writing("to_codeLayerX3_interval", StrUtil.isBlank(codeLayerX3_interval) ? "0" : codeLayerX3_interval); map.put("to_codeLayerX3_interval", StrUtil.isBlank(codeLayerX3_interval) ? "0" : codeLayerX3_interval);
this.writing("to_codeLayerY3_interval", StrUtil.isBlank(codeLayerY3_interval) ? "0" : codeLayerY3_interval); map.put("to_codeLayerY3_interval", StrUtil.isBlank(codeLayerY3_interval) ? "0" : codeLayerY3_interval);
this.writing("to_codeLayerX1_offset", StrUtil.isBlank(codeLayerX1_offset) ? "0" : codeLayerX1_offset); map.put("to_codeLayerX1_offset", StrUtil.isBlank(codeLayerX1_offset) ? "0" : codeLayerX1_offset);
this.writing("to_codeLayerY1_offset", StrUtil.isBlank(codeLayerY1_offset) ? "0" : codeLayerY1_offset); map.put("to_codeLayerY1_offset", StrUtil.isBlank(codeLayerY1_offset) ? "0" : codeLayerY1_offset);
this.writing("to_codeLayerX2_offset", StrUtil.isBlank(codeLayerX2_offset) ? "0" : codeLayerX2_offset); map.put("to_codeLayerX2_offset", StrUtil.isBlank(codeLayerX2_offset) ? "0" : codeLayerX2_offset);
this.writing("to_codeLayerY2_offset", StrUtil.isBlank(codeLayerY2_offset) ? "0" : codeLayerY2_offset); map.put("to_codeLayerY2_offset", StrUtil.isBlank(codeLayerY2_offset) ? "0" : codeLayerY2_offset);
this.writing("to_codeLayerX3_offset", StrUtil.isBlank(codeLayerX3_offset) ? "0" : codeLayerX3_offset); map.put("to_codeLayerX3_offset", StrUtil.isBlank(codeLayerX3_offset) ? "0" : codeLayerX3_offset);
this.writing("to_codeLayerY3_offset", StrUtil.isBlank(codeLayerY3_offset) ? "0" : codeLayerY3_offset); map.put("to_codeLayerY3_offset", StrUtil.isBlank(codeLayerY3_offset) ? "0" : codeLayerY3_offset);
this.writing("to_pressLayerX1_interval", StrUtil.isBlank(pressLayerX1_interval) ? "0" : pressLayerX1_interval); map.put("to_pressLayerX1_interval", StrUtil.isBlank(pressLayerX1_interval) ? "0" : pressLayerX1_interval);
this.writing("to_pressLayerY1_interval", StrUtil.isBlank(pressLayerY1_interval) ? "0" : pressLayerY1_interval); map.put("to_pressLayerY1_interval", StrUtil.isBlank(pressLayerY1_interval) ? "0" : pressLayerY1_interval);
this.writing("to_pressLayerX2_interval", StrUtil.isBlank(pressLayerX2_interval) ? "0" : pressLayerX2_interval); map.put("to_pressLayerX2_interval", StrUtil.isBlank(pressLayerX2_interval) ? "0" : pressLayerX2_interval);
this.writing("to_pressLayerY2_interval", StrUtil.isBlank(pressLayerY2_interval) ? "0" : pressLayerY2_interval); map.put("to_pressLayerY2_interval", StrUtil.isBlank(pressLayerY2_interval) ? "0" : pressLayerY2_interval);
this.writing("to_pressLayerX3_interval", StrUtil.isBlank(pressLayerX3_interval) ? "0" : pressLayerX3_interval); map.put("to_pressLayerX3_interval", StrUtil.isBlank(pressLayerX3_interval) ? "0" : pressLayerX3_interval);
this.writing("to_pressLayerY3_interval", StrUtil.isBlank(pressLayerY3_interval) ? "0" : pressLayerY3_interval); map.put("to_pressLayerY3_interval", StrUtil.isBlank(pressLayerY3_interval) ? "0" : pressLayerY3_interval);
this.writing("to_pressLayerX1_offset", StrUtil.isBlank(pressLayerX1_offset) ? "0" : pressLayerX1_offset); map.put("to_pressLayerX1_offset", StrUtil.isBlank(pressLayerX1_offset) ? "0" : pressLayerX1_offset);
this.writing("to_pressLayerY1_offset", StrUtil.isBlank(pressLayerY1_offset) ? "0" : pressLayerY1_offset); map.put("to_pressLayerY1_offset", StrUtil.isBlank(pressLayerY1_offset) ? "0" : pressLayerY1_offset);
this.writing("to_pressLayerX2_offset", StrUtil.isBlank(pressLayerX2_offset) ? "0" : pressLayerX2_offset); map.put("to_pressLayerX2_offset", StrUtil.isBlank(pressLayerX2_offset) ? "0" : pressLayerX2_offset);
this.writing("to_pressLayerY2_offset", StrUtil.isBlank(pressLayerY2_offset) ? "0" : pressLayerY2_offset); map.put("to_pressLayerY2_offset", StrUtil.isBlank(pressLayerY2_offset) ? "0" : pressLayerY2_offset);
this.writing("to_pressLayerX3_offset", StrUtil.isBlank(pressLayerX3_offset) ? "0" : pressLayerX3_offset); map.put("to_pressLayerX3_offset", StrUtil.isBlank(pressLayerX3_offset) ? "0" : pressLayerX3_offset);
this.writing("to_pressLayerY3_offset", StrUtil.isBlank(pressLayerY3_offset) ? "0" : pressLayerY3_offset); map.put("to_pressLayerY3_offset", StrUtil.isBlank(pressLayerY3_offset) ? "0" : pressLayerY3_offset);
this.writing("to_tool_coordinate", StrUtil.isBlank(tool_coordinate) ? "0" : tool_coordinate); map.put("to_tool_coordinate", StrUtil.isBlank(tool_coordinate) ? "0" : tool_coordinate);
this.writing(this.mode); map.put("to_command", this.mode);
this.writing(map);
} }
this.setRequireSucess(true); this.setRequireSucess(true);
} }

View File

@@ -0,0 +1,125 @@
package org.nl.acs.ext.wms.data;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.type.TypeFactory;
import java.io.IOException;
import java.util.List;
import java.util.Map;
public class JsonUtl {
private static ObjectMapper objectMapper = null;
private static ObjectMapper objectMapperLog = null;
private JsonUtl() {
}
private static ObjectMapper init() {
ObjectMapper objectMapper = new ObjectMapper();
SimpleModule simpleModule = new SimpleModule();
// simpleModule.addSerializer(Enum.class, new EnumSerializer());
// simpleModule.addSerializer(Date.class, new DateSerializer());
// simpleModule.addDeserializer(Enum.class, new EnumDeserializer());
// simpleModule.addDeserializer(Date.class, new DateDeserializers.DateDeserializer());
objectMapper.registerModule(simpleModule);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return objectMapper;
}
public static ObjectMapper getInstance() {
if (objectMapper == null) {
Class var0 = JsonUtl.class;
synchronized(JsonUtl.class) {
if (objectMapper == null) {
objectMapper = init();
}
}
}
return objectMapper;
}
public static ObjectMapper getInstanceLog() {
if (objectMapperLog == null) {
Class var0 = JsonUtl.class;
synchronized(JsonUtl.class) {
if (objectMapperLog == null) {
objectMapperLog = init();
objectMapperLog.setSerializationInclusion(Include.NON_NULL);
}
}
}
return objectMapperLog;
}
public static ObjectMapper getObjectMapper() {
return getInstance();
}
public static String parse(Object object) throws RuntimeException {
try {
return getObjectMapper().writeValueAsString(object);
} catch (JsonProcessingException var2) {
throw new RuntimeException(var2);
}
}
public static String parseWithoutException(Object object) {
try {
return parse(object);
} catch (Exception var2) {
return null;
}
}
public static String parseLog(Object object) {
try {
return getInstanceLog().writeValueAsString(object);
} catch (Exception var2) {
return null;
}
}
public static <T> T format(String json, Class<T> clazz) throws RuntimeException {
try {
return getObjectMapper().readValue(json, clazz);
} catch (IOException var3) {
throw new RuntimeException(var3);
}
}
public static <T> List<T> formatList(String json, Class<T> clazz) throws RuntimeException {
try {
JavaType type = getObjectMapper().getTypeFactory().constructParametricType(List.class, new Class[]{clazz});
return (List)getObjectMapper().readValue(json, type);
} catch (IOException var3) {
throw new RuntimeException(var3);
}
}
public static <T, U> Map<T, U> formatMap(String json, Class<T> clazzKey, Class<U> clazzValue) throws RuntimeException {
try {
JavaType type = getObjectMapper().getTypeFactory().constructParametricType(Map.class, new Class[]{clazzKey, clazzValue});
return (Map)getObjectMapper().readValue(json, type);
} catch (IOException var4) {
throw new RuntimeException(var4);
}
}
public static <T> List<List<T>> formatListTwo(String json, Class<T> clazz) throws RuntimeException {
try {
TypeFactory typeFactory = getObjectMapper().getTypeFactory();
JavaType type = typeFactory.constructParametrizedType(List.class, List.class, new Class[]{clazz});
type = typeFactory.constructParametrizedType(List.class, List.class, new JavaType[]{type});
return (List)getObjectMapper().readValue(json, type);
} catch (IOException var4) {
throw new RuntimeException(var4);
}
}
}

View File

@@ -48,6 +48,7 @@ import org.slf4j.MDC;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -308,14 +309,12 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
if (StrUtil.isEmpty(material_code)) { if (StrUtil.isEmpty(material_code)) {
throw new BadRequestException("物料编码不能为空!"); throw new BadRequestException("物料编码不能为空!");
} }
lnshMixingMillDeviceDriver.writing("to_order_No", producetask_code); HashMap<String, Object> map = new HashMap<>();
lnshMixingMillDeviceDriver.writing("to_weight", qty); map.put("to_order_No", producetask_code);
lnshMixingMillDeviceDriver.writing("to_material_code", material_code); map.put("to_weight", qty);
lnshMixingMillDeviceDriver.writing("to_order_No", producetask_code); map.put("to_material_code", material_code);
lnshMixingMillDeviceDriver.writing("to_weight", qty); map.put("to_command", 1);
lnshMixingMillDeviceDriver.writing("to_material_code", material_code); lnshMixingMillDeviceDriver.writing(map);
lnshMixingMillDeviceDriver.writing(1);
lnshMixingMillDeviceDriver.writing(1);
is_flag = true; is_flag = true;
} }
if (device.getDeviceDriver() instanceof LnshPressDeviceDriver) { if (device.getDeviceDriver() instanceof LnshPressDeviceDriver) {
@@ -329,24 +328,17 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
if (StrUtil.isEmpty(material_code)) { if (StrUtil.isEmpty(material_code)) {
throw new BadRequestException("物料编码不能为空!"); throw new BadRequestException("物料编码不能为空!");
} }
lnshPressDeviceDriver.writing("to_order_No", producetask_code); HashMap<String, Object> map = new HashMap<>();
lnshPressDeviceDriver.writing("to_qty", qty); map.put("to_order_No", producetask_code);
lnshPressDeviceDriver.writing("to_material_code", material_code); map.put("to_qty", qty);
lnshPressDeviceDriver.writing("to_product_code", product_code); map.put("to_material_code", material_code);
lnshPressDeviceDriver.writing("to_AlongSide", AlongSide); map.put("to_product_code", product_code);
lnshPressDeviceDriver.writing("to_BshortSide", BshortSide); map.put("to_AlongSide", AlongSide);
lnshPressDeviceDriver.writing("to_Htrapezoidal", Htrapezoidal); map.put("to_BshortSide", BshortSide);
lnshPressDeviceDriver.writing("to_Wthickness", Wthickness); map.put("to_Htrapezoidal", Htrapezoidal);
lnshPressDeviceDriver.writing("to_order_No", producetask_code); map.put("to_Wthickness", Wthickness);
lnshPressDeviceDriver.writing("to_qty", qty); map.put("to_command", 1);
lnshPressDeviceDriver.writing("to_material_code", material_code); lnshPressDeviceDriver.writing(map);
lnshPressDeviceDriver.writing("to_product_code", product_code);
lnshPressDeviceDriver.writing("to_AlongSide", AlongSide);
lnshPressDeviceDriver.writing("to_BshortSide", BshortSide);
lnshPressDeviceDriver.writing("to_Htrapezoidal", Htrapezoidal);
lnshPressDeviceDriver.writing("to_Wthickness", Wthickness);
lnshPressDeviceDriver.writing(1);
lnshPressDeviceDriver.writing(1);
is_flag = true; is_flag = true;
} }
if (device.getDeviceDriver() instanceof LnshPackagePalletManipulatorDeviceDriver) { if (device.getDeviceDriver() instanceof LnshPackagePalletManipulatorDeviceDriver) {
@@ -360,26 +352,18 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
if (StrUtil.isEmpty(material_code)) { if (StrUtil.isEmpty(material_code)) {
throw new BadRequestException("物料编号不能为空!"); throw new BadRequestException("物料编号不能为空!");
} }
lnshPackagePalletManipulatorDeviceDriver.writing("to_order_No", producetask_code); HashMap<String, Object> map = new HashMap<>();
lnshPackagePalletManipulatorDeviceDriver.writing("to_order_qty", qty); map.put("to_order_No", producetask_code);
lnshPackagePalletManipulatorDeviceDriver.writing("to_material", material_code); map.put("to_order_qty", qty);
lnshPackagePalletManipulatorDeviceDriver.writing("to_product_code", product_code); map.put("to_material", material_code);
lnshPackagePalletManipulatorDeviceDriver.writing("to_AlongSide", AlongSide); map.put("to_product_code", product_code);
lnshPackagePalletManipulatorDeviceDriver.writing("to_BshortSide", BshortSide); map.put("to_AlongSide", AlongSide);
lnshPackagePalletManipulatorDeviceDriver.writing("to_Htrapezoidal", Htrapezoidal); map.put("to_BshortSide", BshortSide);
lnshPackagePalletManipulatorDeviceDriver.writing("to_Wthickness", Wthickness); map.put("to_Htrapezoidal", Htrapezoidal);
lnshPackagePalletManipulatorDeviceDriver.writing("to_vehicle_type", String.valueOf(json.getIntValue("vehicle_type") - 2)); map.put("to_Wthickness", Wthickness);
lnshPackagePalletManipulatorDeviceDriver.writing("to_order_No", producetask_code); map.put("to_vehicle_type", String.valueOf(json.getIntValue("vehicle_type") - 2));
lnshPackagePalletManipulatorDeviceDriver.writing("to_order_qty", qty); map.put("to_command", 1);
lnshPackagePalletManipulatorDeviceDriver.writing("to_material", material_code); lnshPackagePalletManipulatorDeviceDriver.writing(map);
lnshPackagePalletManipulatorDeviceDriver.writing("to_product_code", product_code);
lnshPackagePalletManipulatorDeviceDriver.writing("to_AlongSide", AlongSide);
lnshPackagePalletManipulatorDeviceDriver.writing("to_BshortSide", BshortSide);
lnshPackagePalletManipulatorDeviceDriver.writing("to_Htrapezoidal", Htrapezoidal);
lnshPackagePalletManipulatorDeviceDriver.writing("to_Wthickness", Wthickness);
lnshPackagePalletManipulatorDeviceDriver.writing("to_vehicle_type", String.valueOf(json.getIntValue("vehicle_type") - 2));
lnshPackagePalletManipulatorDeviceDriver.writing(1);
lnshPackagePalletManipulatorDeviceDriver.writing(1);
is_flag = true; is_flag = true;
} }
if (device.getDeviceDriver() instanceof LnshSplitManipulatorDeviceDriver) { if (device.getDeviceDriver() instanceof LnshSplitManipulatorDeviceDriver) {
@@ -393,24 +377,17 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
if (StrUtil.isEmpty(material_code)) { if (StrUtil.isEmpty(material_code)) {
throw new BadRequestException("物料编号不能为空!"); throw new BadRequestException("物料编号不能为空!");
} }
lnshSplitManipulatorDeviceDriver.writing("to_order_No", producetask_code); HashMap<String, Object> map = new HashMap<>();
lnshSplitManipulatorDeviceDriver.writing("to_material_qty", qty); map.put("to_order_No", producetask_code);
lnshSplitManipulatorDeviceDriver.writing("to_material_code", material_code); map.put("to_material_qty", qty);
lnshSplitManipulatorDeviceDriver.writing("to_product_code", product_code); map.put("to_material_code", material_code);
lnshSplitManipulatorDeviceDriver.writing("to_AlongSide", AlongSide); map.put("to_product_code", product_code);
lnshSplitManipulatorDeviceDriver.writing("to_BshortSide", BshortSide); map.put("to_AlongSide", AlongSide);
lnshSplitManipulatorDeviceDriver.writing("to_Htrapezoidal", Htrapezoidal); map.put("to_BshortSide", BshortSide);
lnshSplitManipulatorDeviceDriver.writing("to_Wthickness", Wthickness); map.put("to_Htrapezoidal", Htrapezoidal);
lnshSplitManipulatorDeviceDriver.writing("to_order_No", producetask_code); map.put("to_Wthickness", Wthickness);
lnshSplitManipulatorDeviceDriver.writing("to_material_qty", qty); map.put("to_command", 1);
lnshSplitManipulatorDeviceDriver.writing("to_material_code", material_code); lnshSplitManipulatorDeviceDriver.writing(map);
lnshSplitManipulatorDeviceDriver.writing("to_product_code", product_code);
lnshSplitManipulatorDeviceDriver.writing("to_AlongSide", AlongSide);
lnshSplitManipulatorDeviceDriver.writing("to_BshortSide", BshortSide);
lnshSplitManipulatorDeviceDriver.writing("to_Htrapezoidal", Htrapezoidal);
lnshSplitManipulatorDeviceDriver.writing("to_Wthickness", Wthickness);
lnshSplitManipulatorDeviceDriver.writing(1);
lnshSplitManipulatorDeviceDriver.writing(1);
is_flag = true; is_flag = true;
} }
//下发成功后,写入工单信息表记录 //下发成功后,写入工单信息表记录

View File

@@ -25,8 +25,8 @@ public class DashboardController {
private final DashboardService dashboardService; private final DashboardService dashboardService;
@PostMapping("/homepageData") @PostMapping("/homepageData")
@Log("大屏首页数据") @Log("大屏首页报表")
@ApiOperation("大屏首页数据") @ApiOperation("大屏首页报表")
public ResponseEntity<Object> homepageData(){ public ResponseEntity<Object> homepageData(){
return new ResponseEntity<>(dashboardService.homepageData(), HttpStatus.OK); return new ResponseEntity<>(dashboardService.homepageData(), HttpStatus.OK);
} }
@@ -37,4 +37,11 @@ public class DashboardController {
public ResponseEntity<Object> homepageEquipment(){ public ResponseEntity<Object> homepageEquipment(){
return new ResponseEntity<>(dashboardService.homepageEquipment(), HttpStatus.OK); return new ResponseEntity<>(dashboardService.homepageEquipment(), HttpStatus.OK);
} }
@PostMapping("/productionStatistics")
@Log("生产统计")
@ApiOperation("生产统计")
public ResponseEntity<Object> productionStatistics(){
return new ResponseEntity<>(dashboardService.productionStatistics(), HttpStatus.OK);
}
} }

View File

@@ -1,8 +1,10 @@
package org.nl.wms.dashboard.service; package org.nl.wms.dashboard.service;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.nl.wms.sch.manage.WorkOrderEnum;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
@@ -13,9 +15,9 @@ import org.springframework.stereotype.Service;
public class DashboardService { public class DashboardService {
/** /**
* 大屏首页数据 * 大屏首页报表
* *
* @return 大屏首页数据 * @return 大屏首页报表数据
*/ */
public JSONObject homepageData() { public JSONObject homepageData() {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
@@ -28,7 +30,7 @@ public class DashboardService {
currentEquipmentCondition.put("pausing", 4); currentEquipmentCondition.put("pausing", 4);
currentEquipmentCondition.put("shutdown", 1); currentEquipmentCondition.put("shutdown", 1);
currentEquipmentCondition.put("inTrouble", 1); currentEquipmentCondition.put("inTrouble", 1);
// 每月故障统计--------------------------------------------------------------------------------------------------- // 每月故障统计---------------------------------------------------------------------------------------------------
JSONObject monthlyFailureStatistics = new JSONObject(); JSONObject monthlyFailureStatistics = new JSONObject();
result.put("monthlyFailureStatistics", monthlyFailureStatistics); result.put("monthlyFailureStatistics", monthlyFailureStatistics);
@@ -41,7 +43,7 @@ public class DashboardService {
currentMonth.put("press", 8); currentMonth.put("press", 8);
currentMonth.put("dry", 4); currentMonth.put("dry", 4);
currentMonth.put("sort", 2); currentMonth.put("sort", 2);
// 平均次数 // 平均次数
JSONObject average = new JSONObject(); JSONObject average = new JSONObject();
monthlyFailureStatistics.put("average", average); monthlyFailureStatistics.put("average", average);
@@ -63,12 +65,12 @@ public class DashboardService {
mix.put("completed", 32.25); mix.put("completed", 32.25);
// 困料 // 困料
JSONObject standing = new JSONObject(); JSONObject stand = new JSONObject();
dailyProductionStatistics.put("standing", standing); dailyProductionStatistics.put("stand", stand);
// todo 现在是假数据,后期更新。 // todo 现在是假数据,后期更新。
standing.put("onStanding", 32.25); stand.put("onStanding", 32.25);
standing.put("completed", 16.25); stand.put("completed", 16.25);
// 压制 // 压制
JSONObject press = new JSONObject(); JSONObject press = new JSONObject();
dailyProductionStatistics.put("press", press); dailyProductionStatistics.put("press", press);
@@ -109,7 +111,7 @@ public class DashboardService {
/** /**
* 大屏首页设备 * 大屏首页设备
* *
* @return 大屏首页设备 * @return 大屏首页设备数据
*/ */
public JSONObject homepageEquipment() { public JSONObject homepageEquipment() {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
@@ -117,15 +119,15 @@ public class DashboardService {
// 混料区-------------------------------------------------------------------------------------------------------- // 混料区--------------------------------------------------------------------------------------------------------
JSONObject mix = new JSONObject(); JSONObject mix = new JSONObject();
result.put("mix", mix); result.put("mix", mix);
// 混料机 // 混料机
JSONArray mixingMachine = new JSONArray(); JSONArray mixingMachine = new JSONArray();
mix.put("mixingMachine", mixingMachine); mix.put("mixingMachine", mixingMachine);
// todo 现在是假数据,后期更新。 // todo 现在是假数据,后期更新。
for (int i = 1; i <= 16; i++) { for (int i = 1; i <= 14; i++) {
JSONObject row = new JSONObject(); JSONObject row = new JSONObject();
row.put("equipment", "混料机" + i); row.put("equipment", "混料机" + i);
row.put("status", this.random(1, 4)); row.put("status", this.randomFrom1To(4));
mixingMachine.add(row); mixingMachine.add(row);
} }
@@ -133,11 +135,11 @@ public class DashboardService {
JSONArray unloadLocation = new JSONArray(); JSONArray unloadLocation = new JSONArray();
mix.put("unloadLocation", unloadLocation); mix.put("unloadLocation", unloadLocation);
// todo 现在是假数据,后期更新。 // todo 现在是假数据,后期更新。
for (int i = 1; i <= 16; i++) { for (int i = 1; i <= 14; i++) {
JSONObject row = new JSONObject(); JSONObject row = new JSONObject();
row.put("equipment", "混料机" + i + "下料位1"); row.put("equipment", "混料机" + i + "下料位1");
row.put("status", this.random(1, 4)); row.put("status", this.randomFrom1To(4));
mixingMachine.add(row); unloadLocation.add(row);
} }
// 困料货架------------------------------------------------------------------------------------------------------ // 困料货架------------------------------------------------------------------------------------------------------
@@ -151,15 +153,15 @@ public class DashboardService {
for (int i = 1; i <= 8; i++) { for (int i = 1; i <= 8; i++) {
JSONObject row = new JSONObject(); JSONObject row = new JSONObject();
row.put("equipment", "困料货位" + i); row.put("equipment", "困料货位" + i);
row.put("status", this.random(1, 4)); row.put("status", this.randomFrom1To(4));
String isHasGoods = this.random(0, 1); String pointStatus = this.randomFrom1To(3);
row.put("isHasGoods", isHasGoods); row.put("pointStatus", pointStatus);
if ("1".equals(isHasGoods)) { if ("3".equals(pointStatus)) {
row.put("standStatus", this.random(1, 5)); row.put("standStatus", this.randomFrom1To(5));
} }
storageLocation.add(row); storageLocation.add(row);
} }
// 压制区-------------------------------------------------------------------------------------------------------- // 压制区--------------------------------------------------------------------------------------------------------
JSONObject press = new JSONObject(); JSONObject press = new JSONObject();
result.put("press", press); result.put("press", press);
@@ -171,7 +173,7 @@ public class DashboardService {
for (int i = 1; i <= 10; i++) { for (int i = 1; i <= 10; i++) {
JSONObject row = new JSONObject(); JSONObject row = new JSONObject();
row.put("equipment", "压机" + i + "上料位1"); row.put("equipment", "压机" + i + "上料位1");
row.put("status", this.random(1, 4)); row.put("status", this.randomFrom1To(4));
loadLocation.add(row); loadLocation.add(row);
} }
@@ -182,7 +184,7 @@ public class DashboardService {
for (int i = 1; i <= 10; i++) { for (int i = 1; i <= 10; i++) {
JSONObject row = new JSONObject(); JSONObject row = new JSONObject();
row.put("equipment", "压机" + i); row.put("equipment", "压机" + i);
row.put("status", this.random(1, 4)); row.put("status", this.randomFrom1To(4));
pressMachine.add(row); pressMachine.add(row);
} }
@@ -193,7 +195,7 @@ public class DashboardService {
for (int i = 1; i <= 5; i++) { for (int i = 1; i <= 5; i++) {
JSONObject row = new JSONObject(); JSONObject row = new JSONObject();
row.put("equipment", "码垛机械手" + i); row.put("equipment", "码垛机械手" + i);
row.put("status", this.random(1, 4)); row.put("status", this.randomFrom1To(4));
palletizingRobot.add(row); palletizingRobot.add(row);
} }
@@ -205,7 +207,7 @@ public class DashboardService {
for (int j = 1; j <= 2; j++) { for (int j = 1; j <= 2; j++) {
JSONObject row = new JSONObject(); JSONObject row = new JSONObject();
row.put("equipment", "压机" + i + "下料位" + j); row.put("equipment", "压机" + i + "下料位" + j);
row.put("status", this.random(1, 4)); row.put("status", this.randomFrom1To(4));
unloadLocation.add(row); unloadLocation.add(row);
} }
} }
@@ -221,22 +223,22 @@ public class DashboardService {
for (int i = 1; i <= 28; i += 2) { for (int i = 1; i <= 28; i += 2) {
JSONObject row = new JSONObject(); JSONObject row = new JSONObject();
row.put("equipment", "窑前货位" + i); row.put("equipment", "窑前货位" + i);
row.put("status", this.random(1, 4)); row.put("status", this.randomFrom1To(4));
row.put("isHasGoods", this.random(0, 1)); row.put("pointStatus", this.randomFrom1To(3));
storageLocation.add(row); storageLocation.add(row);
} }
for (int i = 2; i <= 28; i += 2) { for (int i = 2; i <= 28; i += 2) {
JSONObject row = new JSONObject(); JSONObject row = new JSONObject();
row.put("equipment", "窑前货位" + i); row.put("equipment", "窑前货位" + i);
row.put("status", this.random(1, 4)); row.put("status", this.randomFrom1To(4));
row.put("isHasGoods", this.random(0, 1)); row.put("pointStatus", this.randomFrom1To(3));
storageLocation.add(row); storageLocation.add(row);
} }
// 干燥区-------------------------------------------------------------------------------------------------------- // 干燥区--------------------------------------------------------------------------------------------------------
JSONObject dry = new JSONObject(); JSONObject dry = new JSONObject();
result.put("dry", dry); result.put("dry", dry);
// 输送线 // 输送线
JSONArray conveyorLine = new JSONArray(); JSONArray conveyorLine = new JSONArray();
dry.put("conveyorLine", conveyorLine); dry.put("conveyorLine", conveyorLine);
@@ -244,17 +246,265 @@ public class DashboardService {
for (int i = 1; i <= 4; i++) { for (int i = 1; i <= 4; i++) {
JSONObject row = new JSONObject(); JSONObject row = new JSONObject();
row.put("equipment", "窑前输送线" + i); row.put("equipment", "窑前输送线" + i);
row.put("status", this.random(1, 4)); row.put("status", this.randomFrom1To(4));
conveyorLine.add(row); conveyorLine.add(row);
} }
// 桁架 // 桁架
JSONArray gantryRobot = new JSONArray(); JSONArray gantryRobot = new JSONArray();
dry.put("gantryRobot", gantryRobot);
// todo 现在是假数据,后期更新。
{
JSONObject row = new JSONObject();
row.put("equipment", "窑前桁架1");
row.put("status", this.randomFrom1To(4));
gantryRobot.add(row);
row = new JSONObject();
row.put("equipment", "窑后桁架1");
row.put("status", this.randomFrom1To(4));
gantryRobot.add(row);
}
// 窑
JSONArray kiln = new JSONArray();
dry.put("kiln", kiln);
// todo 现在是假数据,后期更新。
for (int i = 1; i <= 4; i++) {
JSONObject row = new JSONObject();
row.put("equipment", "" + i);
row.put("status", this.randomFrom1To(4));
kiln.add(row);
}
// 回车道
JSONArray emptyVehicleConveyorLine = new JSONArray();
dry.put("emptyVehicleConveyorLine", emptyVehicleConveyorLine);
// todo 现在是假数据,后期更新。
{
JSONObject row = new JSONObject();
row.put("equipment", "回车道1");
row.put("status", this.randomFrom1To(4));
emptyVehicleConveyorLine.add(row);
}
// 冷却道
JSONArray coolingConveyorLine = new JSONArray();
dry.put("coolingConveyorLine", coolingConveyorLine);
// todo 现在是假数据,后期更新。
for (int i = 1; i <= 3; i++) {
JSONObject row = new JSONObject();
row.put("equipment", "冷却道" + i);
row.put("status", this.randomFrom1To(4));
coolingConveyorLine.add(row);
}
// 窑后货架------------------------------------------------------------------------------------------------------
JSONObject backWarehouse = new JSONObject();
result.put("backWarehouse", backWarehouse);
// 窑后货位
storageLocation = new JSONArray();
backWarehouse.put("storageLocation", storageLocation);
// todo 现在是假数据,后期更新。
for (int i = 1; i <= 24; i++) {
JSONObject row = new JSONObject();
row.put("equipment", "窑后货位" + i);
row.put("status", this.randomFrom1To(4));
row.put("pointStatus", this.randomFrom1To(3));
storageLocation.add(row);
}
// 分拣区--------------------------------------------------------------------------------------------------------
JSONObject sort = new JSONObject();
result.put("sort", sort);
// 拆垛对接位
loadLocation = new JSONArray();
sort.put("loadLocation", loadLocation);
// todo 现在是假数据,后期更新。
for (int i = 1; i <= 2; i++) {
JSONObject row = new JSONObject();
row.put("equipment", "分拣拆垛1对接位" + i);
row.put("status", this.randomFrom1To(4));
loadLocation.add(row);
}
// 分拣拆垛机械手
JSONArray depalletizingRobot = new JSONArray();
sort.put("depalletizingRobot", depalletizingRobot);
// todo 现在是假数据,后期更新。
{
JSONObject row = new JSONObject();
row.put("equipment", "分拣拆垛机械手1");
row.put("status", this.randomFrom1To(4));
depalletizingRobot.add(row);
}
// 分拣码垛机械手
palletizingRobot = new JSONArray();
sort.put("palletizingRobot", palletizingRobot);
// todo 现在是假数据,后期更新。
{
JSONObject row = new JSONObject();
row.put("equipment", "分拣码垛机械手1");
row.put("status", this.randomFrom1To(4));
palletizingRobot.add(row);
}
// 码垛对接位
unloadLocation = new JSONArray();
sort.put("unloadLocation", unloadLocation);
// todo 现在是假数据,后期更新。
for (int i = 1; i <= 2; i++) {
JSONObject row = new JSONObject();
row.put("equipment", "分拣码垛1对接位" + i);
row.put("status", this.randomFrom1To(4));
unloadLocation.add(row);
}
// 覆膜机
JSONArray laminatingMachine = new JSONArray();
sort.put("laminatingMachine", laminatingMachine);
// todo 现在是假数据,后期更新。
{
JSONObject row = new JSONObject();
row.put("equipment", "覆膜机1");
row.put("status", this.randomFrom1To(4));
laminatingMachine.add(row);
}
// 托盘输送线-----------------------------------------------------------------------------------------------------
JSONObject vehicleConveyorLine = new JSONObject();
result.put("vehicleConveyorLine", vehicleConveyorLine);
// 叠托机
JSONArray trayStacker = new JSONArray();
vehicleConveyorLine.put("trayStacker", trayStacker);
// todo 现在是假数据,后期更新。
{
JSONObject row = new JSONObject();
row.put("equipment", "叠托机1");
row.put("status", this.randomFrom1To(4));
trayStacker.add(row);
}
// 输送线
conveyorLine = new JSONArray();
vehicleConveyorLine.put("conveyorLine", conveyorLine);
// todo 现在是假数据,后期更新。
for (int i = 5; i >= 5; i--) {
JSONObject row = new JSONObject();
row.put("equipment", "拆盘机1对接位" + i);
row.put("status", this.randomFrom1To(4));
conveyorLine.add(row);
}
// 拆盘机
JSONArray trayDestacker = new JSONArray();
vehicleConveyorLine.put("trayDestacker", trayDestacker);
// todo 现在是假数据,后期更新。
{
JSONObject row = new JSONObject();
row.put("equipment", "拆盘机1");
row.put("status", this.randomFrom1To(4));
trayDestacker.add(row);
}
return result; return result;
} }
private String random(int from, int to) { /**
return String.valueOf(from + (int) (Math.random() * (to - from + 1))); * 生产统计
*
* @return 大屏生产统计页面数据
*/
public JSONObject productionStatistics() {
JSONObject result = new JSONObject();
// 总量----------------------------------------------------------------------------------------------------------
JSONObject total = new JSONObject();
result.put("total", total);
// todo 现在是假数据,后期更新。
total.put("pressWeight", 30.25);
total.put("dryWeight", 20.25);
total.put("sortWeight", 16.25);
// 混碾生产------------------------------------------------------------------------------------------------------
JSONArray mixProduction = new JSONArray();
result.put("mixProduction", mixProduction);
// todo 现在是假数据,后期更新。
for (int i = 1; i <= Integer.parseInt(this.randomFrom1To(8)); i++) {
JSONObject row = new JSONObject();
row.put("name", "物料" + i);
row.put("value", Integer.parseInt(this.randomFrom1To(10)) * 100 + 0.25);
mixProduction.add(row);
}
// 在制品设备生产量------------------------------------------------------------------------------------------------
JSONObject pressProduction = new JSONObject();
result.put("pressProduction", pressProduction);
// 当日产量
// todo 现在是假数据,后期更新。
pressProduction.put("dailyProductionQty", 32.25);
// 当班产量
// todo 现在是假数据,后期更新。
pressProduction.put("dailyProductionWeight", 64.25);
// 设备产量
JSONArray equipmentProduction = new JSONArray();
pressProduction.put("equipmentProduction", equipmentProduction);
// todo 现在是假数据,后期更新。
for (int i = 1; i <= Integer.parseInt(this.randomFrom1To(10)); i++) {
JSONObject row = new JSONObject();
row.put("name", "压机" + i);
row.put("qty", Integer.parseInt(this.randomFrom1To(20)) * 1000);
row.put("weight", Integer.parseInt(this.randomFrom1To(20)) * 1000);
equipmentProduction.add(row);
}
// 成品完成率-----------------------------------------------------------------------------------------------------
JSONArray finishedProductCompletionRate = new JSONArray();
result.put("finishedProductCompletionRate", finishedProductCompletionRate);
// todo 现在是假数据,后期更新。
for (int i = 1; i <= Integer.parseInt(this.randomFrom1To(5)); i++) {
JSONObject row = new JSONObject();
row.put("name", "物料" + i);
row.put("completed", Integer.parseInt(this.randomFrom1To(5)) * 1000);
row.put("uncompleted", Integer.parseInt(this.randomFrom1To(5)) * 1000);
finishedProductCompletionRate.add(row);
}
// 生产任务------------------------------------------------------------------------------------------------------
JSONArray workOrder = new JSONArray();
result.put("workOrder", workOrder);
// todo 现在是假数据,后期更新。
for (int i = 1; i <= Integer.parseInt(this.randomFrom1To(10)); i++) {
JSONObject row = new JSONObject();
row.put("workOrderCode", "DD" + String.format("%03d", i));
row.put("equipment", i % 2 == 0 ? "混料机" + i : "压机" + i);
row.put("materialCode", "WL" + String.format("%02d", i));
row.put("customer", "厂家" + i);
int qty = Integer.parseInt(this.randomFrom1To(9)) * 1000;
row.put("planned", qty + "kg");
row.put("completed", qty - Integer.parseInt(this.randomFrom1To(qty)) + "kg");
WorkOrderEnum status = WorkOrderEnum.get(this.randomFrom1To(5));
row.put("status", status.label());
row.put("planStartTime", DateUtil.now());
if (Integer.parseInt(status.value()) > 1) {
row.put("startTime", DateUtil.now());
}
if (Integer.parseInt(status.value()) > 4) {
row.put("endTime", DateUtil.now());
}
workOrder.add(row);
}
return result;
}
private String randomFrom1To(int to) {
return String.valueOf(1 + (int) (Math.random() * to));
} }
} }

View File

@@ -2,6 +2,9 @@ package org.nl.wms.sch.manage;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import java.util.Arrays;
import java.util.stream.Collectors;
/** /**
* @author: lyd * @author: lyd
* @description: 工单枚举 * @description: 工单枚举
@@ -13,13 +16,9 @@ public enum WorkOrderEnum {
ORDER_STATUS_UNPRODUCED("1", "未生产"), ORDER_STATUS_UNPRODUCED("1", "未生产"),
ORDER_STATUS_DELIVERED("2", "已下发"), ORDER_STATUS_DELIVERED("2", "已下发"),
ORDER_STATUS_PRODUCING("3", "生产中"), ORDER_STATUS_PRODUCING("3", "生产中"),
ORDER_STATUS_STOP("4", ""), ORDER_STATUS_STOP("4", ""),
ORDER_STATUS_FINISH("5", "完成"), ORDER_STATUS_FINISH("5", "完成");
IS_NEW_MATERIAL("1", "新料"),
IS_MIXIN_MATERIAL("2", "混料"),
IS_OLD_MATERIAL("3", "旧料")
;
private final String value; private final String value;
private final String label; private final String label;
@@ -30,4 +29,8 @@ public enum WorkOrderEnum {
public String label() { public String label() {
return this.label; return this.label;
} }
public static WorkOrderEnum get(String value) {
return Arrays.stream(WorkOrderEnum.values()).filter(r -> r.value.equals(value)).collect(Collectors.toList()).get(0);
}
} }

View File

@@ -6,7 +6,7 @@ spring:
druid: druid:
db-type: com.alibaba.druid.pool.DruidDataSource db-type: com.alibaba.druid.pool.DruidDataSource
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:lnsh_lms4}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useOldAliasMetadataBehavior=true url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:yksh_lms}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useOldAliasMetadataBehavior=true
username: ${DB_USER:root} username: ${DB_USER:root}
password: ${DB_PWD:123456} password: ${DB_PWD:123456}
# 初始连接数 # 初始连接数