@@ -1,11 +1,8 @@
package org.nl.wms.cockpit.service.impl ;
import cn.hutool.core.date.DateUtil ;
import cn.hutool.core.util.ObjectUtil ;
import cn.hutool.json.JSONUtil ;
import com.alibaba.fastjson.JSONArray ;
import com.alibaba.fastjson.JSONObject ;
import lombok.Data ;
import lombok.RequiredArgsConstructor ;
import lombok.extern.slf4j.Slf4j ;
import org.nl.config.thread.ThreadPoolExecutorUtil ;
@@ -17,6 +14,8 @@ import org.nl.wms.cockpit.service.dto.*;
import org.nl.wms.cockpit.service.enums.ColorEnum ;
import org.nl.wms.cockpit.service.enums.DeviceEnum ;
import org.nl.wms.cockpit.service.enums.DeviceStatusEnum ;
import org.nl.wms.ext.acs.service.WmsToAcsService ;
import org.nl.wms.sch.task.util.TaskUtils ;
import org.nl.wms.util.MapOf ;
import org.springframework.stereotype.Service ;
@@ -37,6 +36,8 @@ import java.util.concurrent.ThreadPoolExecutor;
@RequiredArgsConstructor
@Slf4j
public class BigScreenServiceImpl implements BigScreenService {
private final WmsToAcsService wmsToAcsService ;
/**
* 車间情况大屏信息
*
@@ -125,11 +126,9 @@ public class BigScreenServiceImpl implements BigScreenService {
. addParam ( " flag " , " 4 " )
. process ( )
. getResultJSONArray ( 0 ) ;
// TODO: 打开ACS系统对接数据
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(result);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : result;
JSONArray data = result ;
JSONObject devicesStatus = PointUpdateUtil . getDevicesStatus ( result ) ;
JSONArray data = ObjectUtil . isNotEmpty (
devicesStatus . getJSONArray ( " data " ) ) ? devicesStatus . getJSONArray ( " data " ) : result ;
// 初始化数据 数组下标: 0关机 1待机 2生产中 3故障
JSONObject total = new JSONObject ( ) ;
DeviceEnum [ ] values = DeviceEnum . values ( ) ;
@@ -214,34 +213,29 @@ public class BigScreenServiceImpl implements BigScreenService {
. addParamMap ( MapOf . of ( " flag " , " 5 " , " region_code " , " YZ " ) )
. process ( )
. getResultJSONArray ( 0 ) ;
// TODO: 颜色、实时数量请求acs系统
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
// for (int i = 0; i < data.size(); i++) {
// JSONObject jsonObject = data.getJSONObject(i);
// if ( jsonObject. getInteger("move") == 1
// && ObjectUtil.isNotEmpty( jsonObject. getInteger(" encoder_qty"))
// && jsonObject.getInteger("encoder_qty") > 0) {
// // 绿色
// jsonObject.put("color_status", ColorEnum.GREEN.getIndex());
// } else if ( jsonObject. getInteger("move") == 1
// && ObjectUtil.isNotEmpty( jsonObject. getInteger(" encoder_qty"))
// && jsonObject.getInteger("encoder_qty") == 0) {
// // 黄色
// jsonObject.put("color_status", ColorEnum.YELLOW.getIndex());
// } else if (jsonObject.getInteger("move") == 0) {
// // 红色
// jsonObject.put("color_status", ColorEnum.RED.getIndex());
// } else { // 有托盘人工
// jsonObject.put("color_status", ColorEnum.GREEN.getIndex());
// }
// }
for ( int i = 0 ; i < res . size ( ) ; i + + ) {
JSONObject jsonObject = res . getJSONObject ( i ) ;
jsonObject . put ( " color_status " , ColorEnum . RED . getIndex ( ) ) ;
JSONObject devicesStatus = PointUpdateUtil . getDevicesStatus ( res ) ;
JSONArray data = ObjectUtil . isNotEmpty (
devicesStatus . getJSONArray ( " data " ) ) ? devicesStatus . getJSONArray ( " data " ) : res ;
for ( int i = 0 ; i < data . size ( ) ; i + + ) {
JSONObject jsonObject = data . getJSONObject ( i ) ;
if ( jsonObject . getInteger ( " move " ) = = 1
& & ObjectUtil . isNotEmpty ( jsonObject. getInteger( " encoder_qty " ) )
& & jsonObject. getInteger( " encoder_qty" ) > 0 ) {
// 绿色
jsonObject . put ( " color_status " , ColorEnum . GREEN . getIndex ( ) ) ;
} else if ( jsonObject . getInteger ( " move " ) = = 1
& & ObjectUtil . isNotEmpty ( jsonObject. getInteger( " encoder_qty " ) )
& & jsonObject. getInteger( " encoder_qty" ) = = 0 ) {
// 黄色
jsonObject . put ( " color_status " , ColorEnum . YELLOW . getIndex ( ) ) ;
} else if ( jsonObject . getInteger ( " move " ) = = 0 ) {
// 红色
jsonObject . put ( " color_status " , ColorEnum . RED . getIndex ( ) ) ;
} else { // 有托盘人工
jsonObject . put ( " color_status " , ColorEnum . GREEN . getIndex ( ) ) ;
}
}
return res ;
return data ;
} , pool ) ;
stackingPositionTask . thenAccept ( result - > {
map . put ( " StackingPositionList " , result ) ;
@@ -256,16 +250,10 @@ public class BigScreenServiceImpl implements BigScreenService {
. addParamMap ( MapOf . of ( " flag " , " 10 " ) )
. process ( )
. getResultJSONArray ( 0 ) ;
for ( int i = 0 ; i < res . size ( ) ; i + + ) {
JSONObject jsonObject = res . getJSONObject ( i ) ;
jsonObject . put ( " device_status " , D eviceStatusEnum . STANDBY . getCode ( ) ) ;
jsonObject . put ( " open_time " , D ateUtil . now ( ) ) ;
}
// todo: 打开ACS系统对接数据
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
return res ;
JSONObject devicesStatus = PointUpdateUtil . getDevicesStatus ( res ) ;
JSONArray data = ObjectUtil . isNotEmpty (
devicesStatus . getJSONArray ( " data " ) ) ? d evices Status. getJSONArray ( " data " ) : res ;
return d ata ;
} , pool ) ;
pressMachineTask . thenAccept ( result - > {
map . put ( " PressMachineList " , result ) ;
@@ -280,23 +268,16 @@ public class BigScreenServiceImpl implements BigScreenService {
. addParamMap ( MapOf . of ( " flag " , " 11 " ) )
. process ( )
. getResultJSONArray ( 0 ) ;
for ( int i = 0 ; i < res . size ( ) ; i + + ) {
JSONObject jsonObject = res . getJSONObject ( i ) ;
JSONObject devicesStatus = PointUpdateUtil . getDevicesStatus ( res ) ;
JSONArray data = ObjectUtil . isNotEmpty (
devicesStatus . getJSONArray ( " data " ) ) ? devicesStatus . getJSONArray ( " data " ) : res ;
for ( int i = 0 ; i < data . size ( ) ; i + + ) {
JSONObject jsonObject = data . getJSONObject ( i ) ;
jsonObject . put ( " device_status " , DeviceStatusEnum . STANDBY . getCode ( ) ) ;
String now = DateUtil . now ( ) ;
jsonObject . put ( " open_time " , now . substring ( now . indexOf ( '-' ) + 1 ) ) ;
String openTime = jsonObject . getString ( " open_time " ) ;
jsonObject . put ( " open_time " , openTime . substring ( openTime . indexOf ( '-' ) + 1 ) ) ;
}
// todo: 打开ACS系统对接数据
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
// for (int i = 0; i < data.size(); i++) {
// JSONObject jsonObject = data.getJSONObject(i);
// jsonObject.put("device_status", DeviceStatusEnum.STANDBY.getCode());
// String openTime = jsonObject.getString("open_time");
// jsonObject.put("open_time", openTime.substring(openTime.indexOf('-') + 1));
// }
return res ;
return data ;
} , pool ) ;
mixMachineTask . thenAccept ( result - > {
map . put ( " MixMachineList " , result ) ;
@@ -371,34 +352,29 @@ public class BigScreenServiceImpl implements BigScreenService {
. addParamMap ( MapOf . of ( " flag " , " 13 " ) )
. process ( )
. getResultJSONArray ( 0 ) ;
for ( int i = 0 ; i < res . size ( ) ; i + + ) {
JSONObject jsonObject = res . getJSONObject ( i ) ;
jsonObject . put ( " color_status " , ColorEnum . RED . getIndex ( ) ) ;
JSONObject devicesStatus = PointUpdateUtil . getDevicesStatus ( res ) ;
JSONArray data = ObjectUtil . isNotEmpty (
devicesStatus . getJSONArray ( " data " ) ) ? devicesStatus . getJSONArray ( " data " ) : res ;
for ( int i = 0 ; i < data . size ( ) ; i + + ) {
JSONObject jsonObject = data . getJSONObject ( i ) ;
if ( jsonObject . getInteger ( " move " ) = = 1
& & ObjectUtil . isNotEmpty ( jsonObject . getInteger ( " encoder_qty " ) )
& & jsonObject . getInteger ( " encoder_qty " ) > 0 ) {
// 绿色
jsonObject . put ( " color_status " , ColorEnum . GREEN . getIndex ( ) ) ;
} else if ( jsonObject . getInteger ( " move " ) = = 1
& & ObjectUtil . isNotEmpty ( jsonObject . getInteger ( " encoder_qty " ) )
& & jsonObject . getInteger ( " encoder_qty " ) = = 0 ) {
// 黄色
jsonObject . put ( " color_status " , ColorEnum . YELLOW . getIndex ( ) ) ;
} else if ( jsonObject . getInteger ( " move " ) = = 0 ) {
// 红色
jsonObject . put ( " color_status " , ColorEnum . RED . getIndex ( ) ) ;
} else { // 有托盘人工
jsonObject . put ( " color_status " , ColorEnum . GREEN . getIndex ( ) ) ;
}
}
// TODO: 打开ACS系统对接数据
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
// for (int i = 0; i < data.size(); i++) {
// JSONObject jsonObject = data.getJSONObject(i);
// if (jsonObject.getInteger("move") == 1
// && ObjectUtil.isNotEmpty(jsonObject.getInteger("encoder_qty"))
// && jsonObject.getInteger("encoder_qty") > 0) {
// // 绿色
// jsonObject.put("color_status", ColorEnum.GREEN.getIndex());
// } else if (jsonObject.getInteger("move") == 1
// && ObjectUtil.isNotEmpty(jsonObject.getInteger("encoder_qty"))
// && jsonObject.getInteger("encoder_qty") == 0) {
// // 黄色
// jsonObject.put("color_status", ColorEnum.YELLOW.getIndex());
// } else if (jsonObject.getInteger("move") == 0) {
// // 红色
// jsonObject.put("color_status", ColorEnum.RED.getIndex());
// } else { // 有托盘人工
// jsonObject.put("color_status", ColorEnum.GREEN.getIndex());
// }
// }
return res ;
return data ;
} , pool ) ;
sortAndPalletizingTask . thenAccept ( result - > {
map . put ( " SortAndPalletizingList " , result ) ;
@@ -413,15 +389,10 @@ public class BigScreenServiceImpl implements BigScreenService {
. addParamMap ( MapOf . of ( " flag " , " 14 " ) )
. process ( )
. getResultJSONArray ( 0 ) ;
for ( int i = 0 ; i < res . size ( ) ; i + + ) {
JSONObject jsonObject = res . getJSONObject ( i ) ;
jsonObject . put ( " color_status " , ColorEnum . RED . getIndex ( ) ) ;
}
// TODO: 打开ACS系统对接数据
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
return res ;
JSONObject devicesStatus = PointUpdateUtil . getDevicesStatus ( res ) ;
JSONArray data = ObjectUtil . isNotEmpty (
devicesStatus . getJSONArray ( " data " ) ) ? devicesStatus . getJSONArray ( " data " ) : res ;
return data ;
} , pool ) ;
manipulatorInfoTask . thenAccept ( result - > {
map . put ( " ManipulatorInfoList " , result ) ;
@@ -852,39 +823,20 @@ public class BigScreenServiceImpl implements BigScreenService {
CompletableFuture < JSONArray > mixDevicePopoverInformationTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( " COCKPIT_MIX_AND_TRAP " ) . addParamMap ( MapOf . of ( " flag " , " 2 " ) )
. process ( ) . getResultJSONArray ( 0 ) ;
// todo: 打开ACS系统对接数据
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
// for (int i = 0; i < data.size(); i++) {
// JSONObject device = data.getJSONObject(i);
// Integer devicesStatus1 = ObjectUtil.isNotEmpty( device. getInteger(" devices_status") )
// ? device.getInteger("devices_status")
// : 0 ;
// D eviceStatusEnum deviceS tatusEnumByCode = DeviceStatusEnum.getDeviceStatusEnumByCode(devicesStatus1) ;
// device.put("device_status_name", deviceStatusEnumByCode.getDescription());
// }
return res ;
JSONObject devicesStatus = PointUpdateUtil . getDevicesStatus ( res ) ;
JSONArray data = ObjectUtil . isNotEmpty (
devicesStatus . getJSONArray ( " data " ) ) ? devicesStatus . getJSONArray ( " data " ) : res ;
for ( int i = 0 ; i < data . size ( ) ; i + + ) {
JSONObject device = data . getJSONObject ( i ) ;
Integer devicesStatus1 = ObjectUtil . isNotEmpty ( device . getInteger ( " devices_status " ) )
? device. getInteger( " devices_status" )
: 0 ;
DeviceStatusEnum deviceStatusEnumByCode = DeviceStatusEnum . getDeviceStatusEnumByCode ( devicesStatus1 ) ;
d evice. put ( " device_s tatus_name " , deviceStatusEnumByCode . getDescription ( ) ) ;
}
return data ;
} , pool ) ;
mixDevicePopoverInformationTask . thenAccept ( result - > {
//todo: 以下代码去掉
for ( int i = 0 ; i < result . size ( ) ; i + + ) {
JSONObject device = result . getJSONObject ( i ) ;
if ( ! device . getString ( " material_code " ) . equals ( " - " ) ) {
device . put ( " device_status " , DeviceStatusEnum . RUNNING . getCode ( ) ) ;
device . put ( " device_status_name " , DeviceStatusEnum . RUNNING . getDescription ( ) ) ;
device . put ( " open_time " , " 2023-06-02 11:12:02 " ) ;
device . put ( " stand_time " , " 2 " ) ;
device . put ( " work_time " , " 7 " ) ;
} else {
device . put ( " open_time " , " - " ) ;
device . put ( " device_status " , DeviceStatusEnum . STANDBY . getCode ( ) ) ;
device . put ( " device_status_name " , DeviceStatusEnum . STANDBY . getDescription ( ) ) ;
device . put ( " stand_time " , " 5 " ) ;
device . put ( " work_time " , " 0.5 " ) ;
}
device . put ( " error_time " , " 0 " ) ;
}
map . put ( " MixDeviceInfoList " , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( " 获取混料机的弹窗信息: {} " , e . getMessage ( ) , e ) ;
@@ -997,38 +949,20 @@ public class BigScreenServiceImpl implements BigScreenService {
CompletableFuture < JSONArray > pressPopoverTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( " COCKPIT_MOLDING_INFO " ) . addParamMap ( MapOf . of ( " flag " , " 4 " ) )
. process ( ) . getResultJSONArray ( 0 ) ;
// todo: 打开ACS系统对接数据
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
// for (int i = 0; i < data.size(); i++) {
// JSONObject device = data.getJSONObject(i);
// Integer devicesStatus1 = ObjectUtil.isNotEmpty( device. getInteger(" devices_status") )
// ? device.getInteger("devices_status")
// : 0 ;
// D eviceStatusEnum deviceS tatusEnumByCode = DeviceStatusEnum.getDeviceStatusEnumByCode(devicesStatus1) ;
// device.put("device_status_name", deviceStatusEnumByCode.getDescription());
return res ;
JSONObject devicesStatus = PointUpdateUtil . getDevicesStatus ( res ) ;
JSONArray data = ObjectUtil . isNotEmpty (
devicesStatus . getJSONArray ( " data " ) ) ? devicesStatus . getJSONArray ( " data " ) : res ;
for ( int i = 0 ; i < data . size ( ) ; i + + ) {
JSONObject device = data . getJSONObject ( i ) ;
Integer devicesStatus1 = ObjectUtil . isNotEmpty ( device . getInteger ( " devices_status " ) )
? device. getInteger( " devices_status" )
: 0 ;
DeviceStatusEnum deviceStatusEnumByCode = DeviceStatusEnum . getDeviceStatusEnumByCode ( devicesStatus1 ) ;
d evice. put ( " device_s tatus_name " , deviceStatusEnumByCode . getDescription ( ) ) ;
}
return data ;
} , pool ) ;
pressPopoverTask . thenAccept ( result - > {
//todo: 以下代码去掉
for ( int i = 0 ; i < result . size ( ) ; i + + ) {
JSONObject device = result . getJSONObject ( i ) ;
if ( ! device . getString ( " material_code " ) . equals ( " - " ) ) {
device . put ( " device_status " , DeviceStatusEnum . RUNNING . getCode ( ) ) ;
device . put ( " device_status_name " , DeviceStatusEnum . RUNNING . getDescription ( ) ) ;
device . put ( " open_time " , " 2023-06-02 11:12:02 " ) ;
device . put ( " stand_time " , " 2 " ) ;
device . put ( " work_time " , " 7 " ) ;
} else {
device . put ( " open_time " , " - " ) ;
device . put ( " device_status " , DeviceStatusEnum . STANDBY . getCode ( ) ) ;
device . put ( " device_status_name " , DeviceStatusEnum . STANDBY . getDescription ( ) ) ;
device . put ( " stand_time " , " 5 " ) ;
device . put ( " work_time " , " 0.5 " ) ;
}
device . put ( " error_time " , " 0 " ) ;
}
map . put ( " PressPopoverList " , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( " 获取压机弹窗数据: {} " , e . getMessage ( ) , e ) ;
@@ -1039,11 +973,10 @@ public class BigScreenServiceImpl implements BigScreenService {
CompletableFuture < JSONArray > trayStationPopoverTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( " COCKPIT_MOLDING_INFO " ) . addParamMap ( MapOf . of ( " flag " , " 5 " ) )
. process ( ) . getResultJSONArray ( 0 ) ;
// todo: request acs to find d evice status and other information
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res ;
return res ;
JSONObject devicesStatus = PointUpdateUtil . getD evicesS tatus( res ) ;
JSONArray data = ObjectUtil . isNotEmpty (
devicesStatus . getJSONArray ( " data " ) ) ? devicesStatus . getJSONArray ( " data " ) : res ;
return data ;
} , pool ) ;
trayStationPopoverTask . thenAccept ( result - > {
map . put ( " TrayStationPopoverList " , result ) ;
@@ -1056,28 +989,18 @@ public class BigScreenServiceImpl implements BigScreenService {
CompletableFuture < JSONArray > manipulatorConditionTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( " COCKPIT_MOLDING_INFO " ) . addParamMap ( MapOf . of ( " flag " , " 6 " ) )
. process ( ) . getResultJSONArray ( 0 ) ;
// JSONObject devicesStatus = PointUpdateUtil. getDevicesStatus(res) ;
// JSONArray data = ObjectUtil. isNotEmpty(
// devicesStatus. getJSONArray("data")) ? devicesStatus. getJSONArray("data") : res;
// for (int i = 0; i < data.size(); i++) {
// JSONObject device = data. getJSONObject(i) ;
// Integer devicesStatus1 = ObjectUtil. isNotEmpty( device. getInteger(" devices_status") )
// ? device. getInteger(" devices_status" )
// : 0 ;
// DeviceStatusEnum deviceStatusEnumByCode = DeviceStatusEnum. getDeviceStatusEnumByCode( devicesStatus1) ;
// device.put(" device_status_name", deviceStatusEnumByCode. getDescription()) ;
// }
// todo 去掉以下代码
for ( int i = 0 ; i < res . size ( ) ; i + + ) {
JSONObject device = res . getJSONObject ( i ) ;
device . put ( " device_status " , DeviceStatusEnum . RUNNING . getCode ( ) ) ;
device . put ( " device_status_name " , DeviceStatusEnum . RUNNING . getDescription ( ) ) ;
device . put ( " open_time " , " 2023-06-02 11:12:02 " ) ;
device . put ( " stand_time " , " 2 " ) ;
device . put ( " work_time " , " 7 " ) ;
device . put ( " error_time " , " 0 " ) ;
JSONObject devicesStatus = PointUpdateUtil. getDevicesStatus( res ) ;
JSONArray data = ObjectUtil. isNotEmpty (
devicesStatus. getJSONArray( " data " ) ) ? devicesStatus. getJSONArray( " data " ) : res ;
for ( int i = 0 ; i < data . size ( ) ; i + + ) {
JSONObject device = data . getJSONObject( i ) ;
Integer devicesStatus1 = ObjectUtil. isNotEmpty( device. getInteger( " devices_status" ) )
? device. getInteger( " devices_status" )
: 0 ;
DeviceStatusEnum deviceStatusEnumByCode = DeviceStatusEnum. getDeviceStatusEnumByCode( devicesStatus1) ;
device. put ( " device_status_name" , deviceStatusEnumByCode. getDescription( ) ) ;
}
return res ;
return data ;
} , pool ) ;
manipulatorConditionTask . thenAccept ( result - > {
map . put ( " ManipulatorList " , result ) ;
@@ -1368,28 +1291,16 @@ public class BigScreenServiceImpl implements BigScreenService {
JSONObject resObj = new JSONObject ( ) ;
JSONArray res = WQL . getWO ( " COCKPIT_SORTE_AND_PACKAGE " ) . addParamMap ( MapOf . of ( " flag " , " 5 " ) )
. process ( ) . getResultJSONArray ( 0 ) ;
// todo: 向acs申请获取
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
// for (int i = 0; i < data.size(); i++) {
// JSONObject device = data.getJSONObject(i);
// Integer devicesStatus1 = ObjectUtil.isNotEmpty( device. getInteger(" devices_status") )
// ? device.getInteger("devices_status")
// : 0 ;
// D eviceStatusEnum deviceS tatusEnumByCode = DeviceStatusEnum.getDeviceStatusEnumByCode(devicesStatus1) ;
// device.put("device_status_name", deviceStatusEnumByCode.getDescription());
// resObj.put(device.getString("device_code"), device);
// }
// todo 去掉以下代码
for ( int i = 0 ; i < res . size ( ) ; i + + ) {
JSONObject device = res . getJSONObject ( i ) ;
device . put ( " device_status " , DeviceStatusEnum . RUNNING . getCode ( ) ) ;
device . put ( " device_status_name " , DeviceStatusEnum . RUNNING . getDescription ( ) ) ;
device . put ( " open_time " , " 2023-06-02 11:12:02 " ) ;
device . put ( " stand_time " , " 2 " ) ;
device . put ( " work_time " , " 7 " ) ;
device . put ( " error_time " , " 0 " ) ;
JSONObject devicesStatus = PointUpdateUtil . getDevicesStatus ( res ) ;
JSONArray data = ObjectUtil . isNotEmpty (
devicesStatus . getJSONArray ( " data " ) ) ? devicesStatus . getJSONArray ( " data " ) : res ;
for ( int i = 0 ; i < data . size ( ) ; i + + ) {
JSONObject device = data . getJSONObject ( i ) ;
Integer devicesStatus1 = ObjectUtil . isNotEmpty ( device . getInteger ( " devices_status " ) )
? device. getInteger( " devices_status" )
: 0 ;
DeviceStatusEnum deviceStatusEnumByCode = DeviceStatusEnum . getDeviceStatusEnumByCode ( devicesStatus1 ) ;
d evice. put ( " device_s tatus_name " , deviceStatusEnumByCode . getDescription ( ) ) ;
resObj . put ( device . getString ( " device_code " ) , device ) ;
}
return resObj ;
@@ -1414,10 +1325,30 @@ public class BigScreenServiceImpl implements BigScreenService {
map . put ( " HalfSupportCacheList " , null ) ;
return null ;
} ) ;
// 4、包装线
CompletableFuture < JSONArray > packagingLineTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = new JSONArray ( ) ;
JSONObject jsonObject = wmsToAcsService . queryBzx ( ) ;
res = jsonObject . getJSONArray ( " data " ) ;
for ( int i = 0 ; i < res . size ( ) ; i + + ) {
JSONObject BZX = res . getJSONObject ( i ) ;
BZX . put ( " vehicle_type " , BZX . getInteger ( " vehicle_type " ) + 2 ) ;
BZX . put ( " vehicle_code " , TaskUtils . formatVehicleCode ( BZX . getString ( " vehicle_code " ) ) ) ;
}
return res ;
} , pool ) ;
packagingLineTask . thenAccept ( result - > {
map . put ( " PackagingLineList " , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( " 获取包装线数据: {} " , e . getMessage ( ) , e ) ;
map . put ( " PackagingLineList " , null ) ;
return null ;
} ) ;
CompletableFuture < Void > allQuery = CompletableFuture . allOf (
splitOrPalletizingTask ,
devicesInfoTask ,
halfSupportCacheTask ) ;
halfSupportCacheTask ,
packagingLineTask ) ;
CompletableFuture < ConcurrentHashMap < String , Object > > future
= allQuery . thenApply ( ( result ) - > map ) . exceptionally ( ( e ) - > {
log . error ( e . getMessage ( ) , e ) ;