@@ -4,9 +4,11 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil ;
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 ;
import org.nl.modules.common.utils.PointUpdateUtil ;
import org.nl.modules.wql.WQL ;
import org.nl.modules.wql.core.bean.WQLObject ;
import org.nl.wms.cockpit.service.BigScreenService ;
@@ -114,17 +116,46 @@ public class BigScreenServiceImpl implements BigScreenService {
map . put ( " CPDayList " , null ) ;
return null ;
} ) ;
// TODO: 4、设备运行情况
// 4、设备运行情况
CompletableFuture < List < OperationConditionDto > > deviceConditionTask = CompletableFuture . supplyAsync ( ( ) - > {
List < OperationConditionDto > res = new ArrayList < > ( ) ;
for ( int i = 0 ; i < 4 ; i + + ) {
DeviceEnum deviceEnumByIndex = DeviceEnum . getDeviceEnumByIndex ( i ) ;
// 获取所有设备
JSONArray result = WQL . getWO ( " COCKPIT_DEVICE " )
. 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 ;
// 初始化数据 数组下标: 0关机 1待机 2生产中 3故障
JSONObject total = new JSONObject ( ) ;
DeviceEnum [ ] values = DeviceEnum . values ( ) ;
for ( int i = 0 ; i < values . length ; i + + ) {
total . put ( values [ i ] . getCode ( ) , new int [ 4 ] ) ;
}
// 遍历判断
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 ;
String regionCode = device . getString ( " region_code " ) ;
DeviceEnum deviceEnumByCode = DeviceEnum . getDeviceEnumByCode ( regionCode ) ; // 获取属于哪种设备
int [ ] ints = ( int [ ] ) total . get ( deviceEnumByCode . getCode ( ) ) ;
ints [ devicesStatus1 ] = ints [ devicesStatus1 ] + 1 ;
total . put ( deviceEnumByCode . getCode ( ) , ints ) ;
}
// 返回输出值
for ( int i = 0 ; i < values . length ; i + + ) { // 4个
int [ ] ints = ( int [ ] ) total . get ( values [ i ] . getCode ( ) ) ;
OperationConditionDto dto = new OperationConditionDto ( ) ;
dto . setDevice_name ( deviceEnumByIndex . getDevice_name ( ) ) ;
dto . setRunning ( 3 ) ;
dto . setFailure ( 5 ) ;
dto . setShutdown ( 2 ) ;
dto . setStandby ( 6 ) ;
dto . setDevice_name ( values [ i ] . getDevice_name ( ) ) ; // 列名
dto . setRunning ( ints [ 2 ] ) ;
dto . setFailure ( ints [ 3 ] ) ;
dto . setShutdown ( ints [ 0 ] ) ;
dto . setStandby ( ints [ 1 ] ) ;
res . add ( dto ) ;
}
return res ;
@@ -182,21 +213,24 @@ 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 < res . size ( ) ; i + + ) {
JSONObject jsonObject = res . getJSONObject ( i ) ;
jsonObject . put ( " color_status " , ColorEnum . RED . getIndex ( ) ) ;
}
return res ;
} , pool ) ;
stackingPositionTask . thenAccept ( result - > {
// TODO: 颜色、实时数量请求acs系统
for ( int i = 0 ; i < result . size ( ) ; i + + ) {
JSONObject jsonObject = result . getJSONObject ( i ) ;
jsonObject . put ( " color_status " , ColorEnum . RED . getIndex ( ) ) ;
}
map . put ( " StackingPositionList " , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( " 码垛位情况显示: {} " , e . getMessage ( ) , e ) ;
map . put ( " StackingPositionList " , null ) ;
return null ;
} ) ;
// 8、压机信息显示 todo: 压机的状态, 请求acs
// 8、压机信息显示
CompletableFuture < JSONArray > pressMachineTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( " COCKPIT_PROCESS_PRODUCTION " )
. addParamMap ( MapOf . of ( " flag " , " 10 " ) )
@@ -207,6 +241,10 @@ public class BigScreenServiceImpl implements BigScreenService {
jsonObject . put ( " device_status " , DeviceStatusEnum . STANDBY . getCode ( ) ) ;
jsonObject . put ( " open_time " , DateUtil . now ( ) ) ;
}
// todo: 打开ACS系统对接数据
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
return res ;
} , pool ) ;
pressMachineTask . thenAccept ( result - > {
@@ -216,7 +254,7 @@ public class BigScreenServiceImpl implements BigScreenService {
map . put ( " PressMachineList " , null ) ;
return null ;
} ) ;
// 9、混料机信息显示 todo: 设备状态, 请求acs
// 9、混料机信息显示
CompletableFuture < JSONArray > mixMachineTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( " COCKPIT_PROCESS_PRODUCTION " )
. addParamMap ( MapOf . of ( " flag " , " 11 " ) )
@@ -227,6 +265,10 @@ public class BigScreenServiceImpl implements BigScreenService {
jsonObject . put ( " device_status " , DeviceStatusEnum . STANDBY . getCode ( ) ) ;
jsonObject . put ( " open_time " , DateUtil . now ( ) ) ;
}
// todo: 打开ACS系统对接数据
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
return res ;
} , pool ) ;
mixMachineTask . thenAccept ( result - > {
@@ -302,11 +344,14 @@ public class BigScreenServiceImpl implements BigScreenService {
. addParamMap ( MapOf . of ( " flag " , " 13 " ) )
. process ( )
. getResultJSONArray ( 0 ) ;
// TODO: 颜色、实时数量请求acs系统
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 ;
} , pool ) ;
sortAndPalletizingTask . thenAccept ( result - > {
@@ -340,6 +385,7 @@ public class BigScreenServiceImpl implements BigScreenService {
/**
* 工序生产
*
* @return
*/
@Override
@@ -375,7 +421,7 @@ public class BigScreenServiceImpl implements BigScreenService {
BigDecimal . valueOf ( sumPlanDay / 1000 ) . setScale ( 2 , RoundingMode . HALF_UP ) . toString ( ) ) ;
res . put ( " hl_real_day " ,
BigDecimal . valueOf ( sumRealDay / 1000 ) . setScale ( 2 , RoundingMode . HALF_UP ) . toString ( ) ) ;
res . put ( " hl_productivity " , ( int ) ( ( sumRealDay / sumPlanDay ) * 100 ) ) ;
res . put ( " hl_productivity " , ( int ) ( ( sumRealDay / sumPlanDay ) * 100 ) ) ;
res . put ( " HLDayList " , result ) ;
if ( map . containsKey ( " HL " ) ) { // 如果存在
JSONObject hl = ( JSONObject ) map . get ( " HL " ) ;
@@ -475,7 +521,7 @@ public class BigScreenServiceImpl implements BigScreenService {
BigDecimal . valueOf ( sumPlanDay / 10000 ) . setScale ( 2 , RoundingMode . HALF_UP ) . toString ( ) ) ;
res . put ( " yz_real_day " ,
BigDecimal . valueOf ( sumRealDay / 10000 ) . setScale ( 2 , RoundingMode . HALF_UP ) . toString ( ) ) ;
res . put ( " yz_productivity " , ( int ) ( ( sumRealDay / sumPlanDay ) * 100 ) ) ;
res . put ( " yz_productivity " , ( int ) ( ( sumRealDay / sumPlanDay ) * 100 ) ) ;
res . put ( " YZDayList " , result ) ;
if ( map . containsKey ( " YZ " ) ) { // 如果存在
JSONObject yz = ( JSONObject ) map . get ( " YZ " ) ;
@@ -572,7 +618,7 @@ public class BigScreenServiceImpl implements BigScreenService {
}
res . put ( " bz_plan_day " , BigDecimal . valueOf ( sumPlanDay / 10000 ) . setScale ( 2 , RoundingMode . HALF_UP ) . toString ( ) ) ;
res . put ( " bz_real_day " , BigDecimal . valueOf ( sumRealDay / 10000 ) . setScale ( 2 , RoundingMode . HALF_UP ) . toString ( ) ) ;
res . put ( " bz_productivity " , ( int ) ( ( sumRealDay / sumPlanDay ) * 100 ) ) ;
res . put ( " bz_productivity " , ( int ) ( ( sumRealDay / sumPlanDay ) * 100 ) ) ;
res . put ( " BZDayList " , result ) ;
if ( map . containsKey ( " BZ " ) ) { // 如果存在
JSONObject bz = ( JSONObject ) map . get ( " BZ " ) ;
@@ -736,10 +782,22 @@ 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;
// DeviceStatusEnum deviceStatusEnumByCode = DeviceStatusEnum.getDeviceStatusEnumByCode(devicesStatus1);
// device.put("device_status_name", deviceStatusEnumByCode.getDescription());
// }
return res ;
} , pool ) ;
mixDevicePopoverInformationTask . thenAccept ( result - > {
//todo: 请求acs设置开机状态等等信息
//todo: 以下代码去掉
for ( int i = 0 ; i < result . size ( ) ; i + + ) {
JSONObject device = result . getJSONObject ( i ) ;
if ( ! device . getString ( " material_code " ) . equals ( " - " ) ) {
@@ -869,10 +927,21 @@ 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;
// DeviceStatusEnum deviceStatusEnumByCode = DeviceStatusEnum.getDeviceStatusEnumByCode(devicesStatus1);
// device.put("device_status_name", deviceStatusEnumByCode.getDescription());
return res ;
} , pool ) ;
pressPopoverTask . thenAccept ( result - > {
//todo: 请求acs获取开机状态等等信息
//todo: 以下代码去掉
for ( int i = 0 ; i < result . size ( ) ; i + + ) {
JSONObject device = result . getJSONObject ( i ) ;
if ( ! device . getString ( " material_code " ) . equals ( " - " ) ) {
@@ -897,10 +966,13 @@ public class BigScreenServiceImpl implements BigScreenService {
return null ;
} ) ;
// 2、码盘工位弹出框
CompletableFuture < JSONArray > trayStationPopoverTask = CompletableFuture . supplyAsync ( ( ) - > {
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 device status and other information
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
return res ;
} , pool ) ;
trayStationPopoverTask . thenAccept ( result - > {
@@ -910,10 +982,22 @@ public class BigScreenServiceImpl implements BigScreenService {
map . put ( " TrayStationPopoverList " , null ) ;
return null ;
} ) ;
// 3、机械手状态 todo
// 3、机械手状态
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 ( ) ) ;
@@ -1172,7 +1256,7 @@ public class BigScreenServiceImpl implements BigScreenService {
return res ;
} , pool ) ;
manufacturedProductsDayProductionTask . thenAccept ( ( result ) - > {
map . put ( " CPDayList " , result ) ;
map . put ( " CPDayList " , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( " 当日成品生产: {} " , e . getMessage ( ) , e ) ;
map . put ( " CPDayList " , null ) ;
@@ -1215,6 +1299,19 @@ public class BigScreenServiceImpl implements BigScreenService {
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;
// DeviceStatusEnum deviceStatusEnumByCode = 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 ( ) ) ;