@ -12,6 +12,7 @@ import org.nl.wms.cockpit.service.BigScreenService;
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.util.MapOf ;
import org.springframework.stereotype.Service ;
@ -85,7 +86,7 @@ public class BigScreenServiceImpl implements BigScreenService {
map . put ( "YZDayList" , dtos ) ;
return null ;
} ) ;
// 3、当日成品
// TODO: 3、当日成品
CompletableFuture < List < ManufacturedProductsDto > > manufacturedProductsDayProductionTask = CompletableFuture . supplyAsync ( ( ) - > {
List < ManufacturedProductsDto > res = new ArrayList < > ( ) ;
Random random = new Random ( ) ;
@ -107,7 +108,7 @@ public class BigScreenServiceImpl implements BigScreenService {
map . put ( "CPDayList" , null ) ;
return null ;
} ) ;
// 4、设备运行情况
// TODO: 4、设备运行情况
CompletableFuture < List < OperationConditionDto > > deviceConditionTask = CompletableFuture . supplyAsync ( ( ) - > {
List < OperationConditionDto > res = new ArrayList < > ( ) ;
for ( int i = 0 ; i < 4 ; i + + ) {
@ -129,7 +130,7 @@ public class BigScreenServiceImpl implements BigScreenService {
map . put ( "DeviceConditionList" , null ) ;
return null ;
} ) ;
// 5、近一个月故障次数前5台设备
// TODO: 5、近一个月故障次数前5台设备
CompletableFuture < List < OperationConditionDto > > lastMonthFailureTask = CompletableFuture . supplyAsync ( ( ) - > {
List < OperationConditionDto > res = new ArrayList < > ( ) ;
Random random = new Random ( ) ;
@ -148,7 +149,7 @@ public class BigScreenServiceImpl implements BigScreenService {
map . put ( "LastMonthFailureList" , null ) ;
return null ;
} ) ;
// 6、最近10次设备故障
// TODO: 6、最近10次设备故障
CompletableFuture < List < FailureDeviceInfoDto > > lastTenFailureTask = CompletableFuture . supplyAsync ( ( ) - > {
List < FailureDeviceInfoDto > res = new ArrayList < > ( ) ;
for ( int i = 0 ; i < 5 ; i + + ) {
@ -177,6 +178,7 @@ public class BigScreenServiceImpl implements BigScreenService {
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 ( ) ) ;
@ -187,11 +189,15 @@ public class BigScreenServiceImpl implements BigScreenService {
map . put ( "StackingPositionList" , null ) ;
return null ;
} ) ;
// 8、压机信息显示
// 8、压机信息显示 todo: 压机的状态,请求acs
CompletableFuture < JSONArray > pressMachineTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_PROCESS_PRODUCTION" ) . addParamMap ( MapOf . of ( "flag" , "6 " ) )
JSONArray res = WQL . getWO ( "COCKPIT_PROCESS_PRODUCTION" ) . 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" , DeviceStatusEnum . STANDBY . getCode ( ) ) ;
}
return res ;
} , pool ) ;
pressMachineTask . thenAccept ( result - > {
@ -201,11 +207,15 @@ public class BigScreenServiceImpl implements BigScreenService {
map . put ( "PressMachineList" , null ) ;
return null ;
} ) ;
// 9、混料机信息显示
// 9、混料机信息显示 todo: 设备状态,请求acs
CompletableFuture < JSONArray > mixMachineTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_PROCESS_PRODUCTION" ) . addParamMap ( MapOf . of ( "flag" , "7 " ) )
JSONArray res = WQL . getWO ( "COCKPIT_PROCESS_PRODUCTION" ) . addParamMap ( MapOf . of ( "flag" , "11 " ) )
. process ( )
. getResultJSONArray ( 0 ) ;
for ( int i = 0 ; i < res . size ( ) ; i + + ) {
JSONObject jsonObject = res . getJSONObject ( i ) ;
jsonObject . put ( "device_status" , DeviceStatusEnum . STANDBY . getCode ( ) ) ;
}
return res ;
} , pool ) ;
mixMachineTask . thenAccept ( result - > {
@ -215,32 +225,58 @@ public class BigScreenServiceImpl implements BigScreenService {
map . put ( "MixMachineList" , null ) ;
return null ;
} ) ;
// 10、困料货架的信息显示
CompletableFuture < JSONArray > trappedMaterialShelfTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_PROCESS_PRODUCTION" ) . addParamMap ( MapOf . of ( "flag" , "8" ) )
. process ( )
. getResultJSONArray ( 0 ) ;
// 10、困料货架的信息显示 todo: 数据?
// CompletableFuture<JSONArray> trappedMaterialShelfTask = CompletableFuture.supplyAsync(() -> {
// JSONArray res = WQL.getWO("COCKPIT_PROCESS_PRODUCTION").addParamMap(MapOf.of("flag", "8"))
// .process()
// .getResultJSONArray(0);
// return res;
// }, pool);
// trappedMaterialShelfTask.thenAccept(result -> {
// map.put("TrappedMaterialShelfList", result);
// }).exceptionally((e) -> {
// log.error("困料货架的信息显示: {}", e.getMessage(), e);
// map.put("TrappedMaterialShelfList", null);
// return null;
// });
// 11、半成品货架数据显示 todo: 数据?
// CompletableFuture<JSONArray> semiFinishedProductShelfTask = CompletableFuture.supplyAsync(() -> {
// JSONArray res = WQL.getWO("COCKPIT_PROCESS_PRODUCTION").addParamMap(MapOf.of("flag", "9"))
// .process()
// .getResultJSONArray(0);
// return res;
// }, pool);
// semiFinishedProductShelfTask.thenAccept(result -> {
// map.put("SemiFinishedProductShelfList", result);
// }).exceptionally((e) -> {
// log.error("半成品货架数据显示: {}", e.getMessage(), e);
// map.put("SemiFinishedProductShelfList", null);
// return null;
// });
// 12、混料机下料位
CompletableFuture < JSONArray > mixBlankingTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_MIX_AND_TRAP" ) . addParamMap ( MapOf . of ( "flag" , "3" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
return res ;
} , pool ) ;
trappedMaterialShelfTask . thenAccept ( result - > {
map . put ( "TrappedMaterialShelfList" , result ) ;
mixBlanking Task. thenAccept ( result - > {
map . put ( "MixBlanking List" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "困料货架的信息显示: {}" , e . getMessage ( ) , e ) ;
map . put ( "TrappedMaterialShelfList" , null ) ;
log . error ( "混料机下料位 显示: {}" , e . getMessage ( ) , e ) ;
map . put ( "MixBlanking List" , null ) ;
return null ;
} ) ;
// 11、半成品货架数据显示
CompletableFuture < JSONArray > semiFinishedProductShelfTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_PROCESS_PRODUCTION" ) . addParamMap ( MapOf . of ( "flag" , "9" ) )
. process ( )
. getResultJSONArray ( 0 ) ;
// 13、困料货架数据显示
CompletableFuture < JSONArray > trappedShelfTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_PROCESS_PRODUCTION" ) . addParamMap ( MapOf . of ( "flag" , "12" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
return res ;
} , pool ) ;
semiFinishedProductShelfTask . thenAccept ( result - > {
map . put ( "SemiFinishedProductShelfList" , result ) ;
trapped ShelfTask. thenAccept ( result - > {
map . put ( "Trapped ShelfList" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "半成品货架数据显示: {}" , e . getMessage ( ) , e ) ;
map . put ( "SemiFinishedProductShelfList" , null ) ;
log . error ( "获取困料货架数据显示 - 6货位信息 : {}" , e . getMessage ( ) , e ) ;
map . put ( "Trapped ShelfList" , null ) ;
return null ;
} ) ;
CompletableFuture < Void > allQuery = CompletableFuture . allOf (
@ -252,8 +288,9 @@ public class BigScreenServiceImpl implements BigScreenService {
stackingPositionTask ,
pressMachineTask ,
mixMachineTask ,
trappedMaterialShelfTask ,
semiFinishedProductShelfTask ) ;
trappedShelfTask ) ;
// trappedMaterialShelfTask,
// semiFinishedProductShelfTask);
CompletableFuture < ConcurrentHashMap < String , Object > > future = allQuery . thenApply ( ( result ) - > map ) . exceptionally ( ( e ) - > {
log . error ( e . getMessage ( ) , e ) ;
return null ;
@ -286,15 +323,15 @@ public class BigScreenServiceImpl implements BigScreenService {
mixMaterialStorage . thenAccept ( ( result ) - > {
// 整理数据
JSONObject res = new JSONObject ( ) ;
int sumRealDay = 0 ;
int sumPlanDay = 0 ;
double sumRealDay = 0 ;
double sumPlanDay = 0 ;
for ( NumberDto numberDto : result ) {
sumRealDay + = numberDto . getReal_qty ( ) ;
sumPlanDay + = numberDto . getPlan_qty ( ) ;
}
res . put ( "hl_plan_day" , BigDecimal . valueOf ( ( double ) sumPlanDay / 1000 ) . setScale ( 2 , RoundingMode . HALF_UP ) . toString ( ) ) ;
res . put ( "hl_real_day" , BigDecimal . valueOf ( ( double ) sumRealDay / 1000 ) . setScale ( 2 , RoundingMode . HALF_UP ) . toString ( ) ) ;
res . put ( "hl_productivity" , sumRealDay / sumPlanDay ) ;
res . put ( "hl_plan_day" , 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 ( "HLDayList" , result ) ;
if ( map . containsKey ( "HL" ) ) { // 如果存在
JSONObject hl = ( JSONObject ) map . get ( "HL" ) ;
@ -340,7 +377,7 @@ public class BigScreenServiceImpl implements BigScreenService {
JSONObject hl = ( JSONObject ) map . get ( "HL" ) ;
res . put ( "hl_plan_day" , hl . getString ( "hl_plan_day" ) ) ;
res . put ( "hl_real_day" , hl . getString ( "hl_real_day" ) ) ;
res . put ( "hl_productivity" , hl . getString ( "hl_productivity" ) ) ;
res . put ( "hl_productivity" , hl . getInteger ( "hl_productivity" ) ) ;
res . put ( "HLDayList" , hl . getJSONArray ( "HLDayList" ) ) ;
map . put ( "HL" , res ) ;
} else {
@ -356,7 +393,7 @@ public class BigScreenServiceImpl implements BigScreenService {
JSONObject hl = ( JSONObject ) map . get ( "HL" ) ;
res . put ( "hl_plan_day" , hl . getString ( "hl_plan_day" ) ) ;
res . put ( "hl_real_day" , hl . getString ( "hl_real_day" ) ) ;
res . put ( "hl_productivity" , hl . getString ( "hl_productivity" ) ) ;
res . put ( "hl_productivity" , hl . getInteger ( "hl_productivity" ) ) ;
res . put ( "HLDayList" , hl . getJSONArray ( "HLDayList" ) ) ;
map . put ( "HL" , res ) ;
} else {
@ -367,7 +404,7 @@ public class BigScreenServiceImpl implements BigScreenService {
// 2.1 获取成型的计划与实际生产数量:单位万块, 每天的合格与不合格数量
CompletableFuture < List < NumberDto > > yzPlanAndRealStorage = CompletableFuture . supplyAsync ( ( ) - > {
List < NumberDto > res = new CopyOnWriteArrayList < > ( ) ;
// 查找所有混捻每周 的数据
// 查找所有压制 的数据
JSONArray result = WQL . getWO ( "COCKPIT_PROCESS_PRODUCTION" ) . addParamMap ( MapOf . of ( "flag" , "1" , "region_code" , "YZ" ) ) . process ( ) . getResultJSONArray ( 0 ) ;
if ( ObjectUtil . isNotEmpty ( result ) ) {
res = result . toJavaList ( NumberDto . class ) ;
@ -378,15 +415,15 @@ public class BigScreenServiceImpl implements BigScreenService {
yzPlanAndRealStorage . thenAccept ( ( result ) - > {
// 整理数据
JSONObject res = new JSONObject ( ) ;
int sumRealDay = 0 ;
int sumPlanDay = 0 ;
double sumRealDay = 0 ;
double sumPlanDay = 0 ;
for ( NumberDto numberDto : result ) {
sumRealDay + = numberDto . getReal_qty ( ) ;
sumPlanDay + = numberDto . getPlan_qty ( ) ;
}
res . put ( "yz_plan_day" , BigDecimal . valueOf ( ( double ) sumPlanDay / 10000 ) . setScale ( 2 , RoundingMode . HALF_UP ) . toString ( ) ) ;
res . put ( "yz_real_day" , BigDecimal . valueOf ( ( double ) sumRealDay / 10000 ) . setScale ( 2 , RoundingMode . HALF_UP ) . toString ( ) ) ;
res . put ( "yz_productivity" , sumRealDay / sumPlanDay ) ;
res . put ( "yz_plan_day" , 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 ( "YZDayList" , result ) ;
if ( map . containsKey ( "YZ" ) ) { // 如果存在
JSONObject yz = ( JSONObject ) map . get ( "YZ" ) ;
@ -432,7 +469,7 @@ public class BigScreenServiceImpl implements BigScreenService {
JSONObject yz = ( JSONObject ) map . get ( "YZ" ) ;
res . put ( "yz_plan_day" , yz . getString ( "yz_plan_day" ) ) ;
res . put ( "yz_real_day" , yz . getString ( "yz_real_day" ) ) ;
res . put ( "yz_productivity" , yz . getString ( "yz_productivity" ) ) ;
res . put ( "yz_productivity" , yz . getInteger ( "yz_productivity" ) ) ;
res . put ( "YZDayList" , yz . getJSONArray ( "YZDayList" ) ) ;
map . put ( "YZ" , res ) ;
} else {
@ -448,7 +485,7 @@ public class BigScreenServiceImpl implements BigScreenService {
JSONObject yz = ( JSONObject ) map . get ( "YZ" ) ;
res . put ( "yz_plan_day" , yz . getString ( "yz_plan_day" ) ) ;
res . put ( "yz_real_day" , yz . getString ( "yz_real_day" ) ) ;
res . put ( "yz_productivity" , yz . getString ( "yz_productivity" ) ) ;
res . put ( "yz_productivity" , yz . getInteger ( "yz_productivity" ) ) ;
res . put ( "YZDayList" , yz . getJSONArray ( "YZDayList" ) ) ;
map . put ( "YZ" , res ) ;
} else {
@ -469,15 +506,15 @@ public class BigScreenServiceImpl implements BigScreenService {
bzPlanAndRealStorage . thenAccept ( ( result ) - > {
// 整理数据
JSONObject res = new JSONObject ( ) ;
int sumRealDay = 0 ;
int sumPlanDay = 0 ;
double sumRealDay = 0 ;
double sumPlanDay = 0 ;
for ( NumberDto numberDto : result ) {
sumRealDay + = numberDto . getReal_qty ( ) ;
sumPlanDay + = numberDto . getPlan_qty ( ) ;
}
res . put ( "bz_plan_day" , BigDecimal . valueOf ( ( double ) sumPlanDay / 10000 ) . setScale ( 2 , RoundingMode . HALF_UP ) . toString ( ) ) ;
res . put ( "bz_real_day" , BigDecimal . valueOf ( ( double ) sumRealDay / 10000 ) . setScale ( 2 , RoundingMode . HALF_UP ) . toString ( ) ) ;
res . put ( "bz_productivity" , sumRealDay / sumPlanDay ) ;
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 ( "BZDayList" , result ) ;
if ( map . containsKey ( "BZ" ) ) { // 如果存在
JSONObject bz = ( JSONObject ) map . get ( "BZ" ) ;
@ -521,7 +558,7 @@ public class BigScreenServiceImpl implements BigScreenService {
JSONObject bz = ( JSONObject ) map . get ( "BZ" ) ;
res . put ( "bz_plan_day" , bz . getString ( "bz_plan_day" ) ) ;
res . put ( "bz_real_day" , bz . getString ( "bz_real_day" ) ) ;
res . put ( "bz_productivity" , bz . getString ( "bz_productivity" ) ) ;
res . put ( "bz_productivity" , bz . getInteger ( "bz_productivity" ) ) ;
res . put ( "BZDayList" , bz . getJSONArray ( "BZDayList" ) ) ;
map . put ( "BZ" , res ) ;
} else {
@ -536,7 +573,7 @@ public class BigScreenServiceImpl implements BigScreenService {
JSONObject bz = ( JSONObject ) map . get ( "BZ" ) ;
res . put ( "bz_plan_day" , bz . getString ( "bz_plan_day" ) ) ;
res . put ( "bz_real_day" , bz . getString ( "bz_real_day" ) ) ;
res . put ( "bz_productivity" , bz . getString ( "bz_productivity" ) ) ;
res . put ( "bz_productivity" , bz . getInteger ( "bz_productivity" ) ) ;
res . put ( "BZDayList" , bz . getJSONArray ( "BZDayList" ) ) ;
map . put ( "BZ" , res ) ;
} else {
@ -544,6 +581,7 @@ public class BigScreenServiceImpl implements BigScreenService {
}
return null ;
} ) ;
// todo: 假数据
// 4 成品出入库
CompletableFuture < List < InventoryDto > > cpDeviceDataStorage = CompletableFuture . supplyAsync ( ( ) - > {
List < InventoryDto > res = new CopyOnWriteArrayList < > ( ) ;
@ -609,6 +647,544 @@ public class BigScreenServiceImpl implements BigScreenService {
return map ;
}
/ * *
* open_time 开机时间 yyyy - MM - dd HH : mm : ss
* stand_time 待机时间 小时
* work_time 生产时间 小时
* error_time 故障时间 小时
* /
@Override
public ConcurrentHashMap < String , Object > blendingCondition ( ) {
ThreadPoolExecutor pool = ThreadPoolExecutorUtil . getPoll ( ) ;
ConcurrentHashMap < String , Object > map = new ConcurrentHashMap < > ( ) ;
// 1、当日混料任务
CompletableFuture < JSONArray > mixedDayListTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_MIX_AND_TRAP" ) . addParamMap ( MapOf . of ( "flag" , "1" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
return res ;
} , pool ) ;
mixedDayListTask . thenAccept ( result - > {
map . put ( "MixDayList" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "获取当日混料任务信息: {}" , e . getMessage ( ) , e ) ;
map . put ( "MixDayList" , null ) ;
return null ;
} ) ;
// 2、获取混料机的弹窗信息
CompletableFuture < JSONArray > mixDevicePopoverInformationTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_MIX_AND_TRAP" ) . addParamMap ( MapOf . of ( "flag" , "2" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
return res ;
} , pool ) ;
mixDevicePopoverInformationTask . thenAccept ( result - > {
//todo: 请求acs设置开机状态等等信息
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 ) ;
map . put ( "MixDeviceInfoList" , null ) ;
return null ;
} ) ;
// 3、获取料盅货架的显示信息
CompletableFuture < JSONArray > cupRackDisplayTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_MIX_AND_TRAP" ) . addParamMap ( MapOf . of ( "flag" , "3" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
return res ;
} , pool ) ;
cupRackDisplayTask . thenAccept ( result - > {
map . put ( "CupRackDisplayList" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "获取料盅货架的显示信息: {}" , e . getMessage ( ) , e ) ;
map . put ( "CupRackDisplayList" , null ) ;
return null ;
} ) ;
CompletableFuture < Void > allQuery = CompletableFuture . allOf (
mixedDayListTask ,
mixDevicePopoverInformationTask ,
cupRackDisplayTask ) ;
CompletableFuture < ConcurrentHashMap < String , Object > > future = allQuery . thenApply ( ( result ) - > map ) . exceptionally ( ( e ) - > {
log . error ( e . getMessage ( ) , e ) ;
return null ;
} ) ;
future . join ( ) ;
return map ;
}
@Override
public ConcurrentHashMap < String , Object > trappedMaterialCondition ( ) {
ThreadPoolExecutor pool = ThreadPoolExecutorUtil . getPoll ( ) ;
ConcurrentHashMap < String , Object > map = new ConcurrentHashMap < > ( ) ;
// 1、困料库存
CompletableFuture < JSONArray > trappedStockTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_MIX_AND_TRAP" ) . addParamMap ( MapOf . of ( "flag" , "4" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
return res ;
} , pool ) ;
trappedStockTask . thenAccept ( result - > {
map . put ( "TrappedStockList" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "获取困料库存信息: {}" , e . getMessage ( ) , e ) ;
map . put ( "TrappedStockList" , null ) ;
return null ;
} ) ;
// 2、当天困料出入库
CompletableFuture < JSONArray > trappedIOStockTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_MIX_AND_TRAP" ) . addParamMap ( MapOf . of ( "flag" , "5" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
return res ;
} , pool ) ;
trappedIOStockTask . thenAccept ( result - > {
map . put ( "TrappedIOStockList" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "获取当天困料出入库信息: {}" , e . getMessage ( ) , e ) ;
map . put ( "TrappedIOStockList" , null ) ;
return null ;
} ) ;
// 3、困料货架数据显示 - 40货位
CompletableFuture < JSONArray > trappedShelf40Task = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_MIX_AND_TRAP" ) . addParamMap ( MapOf . of ( "flag" , "6" , "point_type" , "1" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
return res ;
} , pool ) ;
trappedShelf40Task . thenAccept ( result - > {
map . put ( "TrappedShelf40List" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "获取困料货架数据显示 - 40货位信息: {}" , e . getMessage ( ) , e ) ;
map . put ( "TrappedShelf40List" , null ) ;
return null ;
} ) ;
// 4、困料货架数据显示 - 6货位
CompletableFuture < JSONArray > trappedShelf6Task = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_MIX_AND_TRAP" ) . addParamMap ( MapOf . of ( "flag" , "6" , "point_type" , "2" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
return res ;
} , pool ) ;
trappedShelf6Task . thenAccept ( result - > {
map . put ( "TrappedShelf6List" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "获取困料货架数据显示 - 6货位信息: {}" , e . getMessage ( ) , e ) ;
map . put ( "TrappedShelf6List" , null ) ;
return null ;
} ) ;
CompletableFuture < Void > allQuery = CompletableFuture . allOf (
trappedStockTask ,
trappedIOStockTask ,
trappedShelf40Task ,
trappedShelf6Task ) ;
CompletableFuture < ConcurrentHashMap < String , Object > > future = allQuery . thenApply ( ( result ) - > map ) . exceptionally ( ( e ) - > {
log . error ( e . getMessage ( ) , e ) ;
return null ;
} ) ;
future . join ( ) ;
return map ;
}
@Override
public ConcurrentHashMap < String , Object > moldingMaterialCondition ( ) {
ThreadPoolExecutor pool = ThreadPoolExecutorUtil . getPoll ( ) ;
ConcurrentHashMap < String , Object > map = new ConcurrentHashMap < > ( ) ;
// 1、压机弹窗数据
CompletableFuture < JSONArray > pressPopoverTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_MOLDING_INFO" ) . addParamMap ( MapOf . of ( "flag" , "4" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
return res ;
} , pool ) ;
pressPopoverTask . thenAccept ( result - > {
//todo: 请求acs获取开机状态等等信息
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 ) ;
map . put ( "PressPopoverList" , null ) ;
return null ;
} ) ;
// 2、码盘工位弹出框
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
return res ;
} , pool ) ;
trayStationPopoverTask . thenAccept ( result - > {
map . put ( "TrayStationPopoverList" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "获取码盘工位弹出框数据: {}" , e . getMessage ( ) , e ) ;
map . put ( "TrayStationPopoverList" , null ) ;
return null ;
} ) ;
// 3、机械手状态 todo
CompletableFuture < JSONArray > manipulatorConditionTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_MOLDING_INFO" ) . addParamMap ( MapOf . of ( "flag" , "6" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
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" ) ;
}
return res ;
} , pool ) ;
manipulatorConditionTask . thenAccept ( result - > {
map . put ( "ManipulatorList" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "机械手弹出框数据: {}" , e . getMessage ( ) , e ) ;
map . put ( "ManipulatorList" , null ) ;
return null ;
} ) ;
CompletableFuture < Void > allQuery = CompletableFuture . allOf (
pressPopoverTask ,
trayStationPopoverTask ,
manipulatorConditionTask ) ;
CompletableFuture < ConcurrentHashMap < String , Object > > future = allQuery . thenApply ( ( result ) - > map ) . exceptionally ( ( e ) - > {
log . error ( e . getMessage ( ) , e ) ;
return null ;
} ) ;
future . join ( ) ;
return map ;
}
@Override
public ConcurrentHashMap < String , Object > moldingTableDate ( ) {
ThreadPoolExecutor pool = ThreadPoolExecutorUtil . getPoll ( ) ;
ConcurrentHashMap < String , Object > map = new ConcurrentHashMap < > ( ) ;
// 1、当日压制任务
CompletableFuture < JSONArray > moldingDayTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_MOLDING_INFO" ) . addParamMap ( MapOf . of ( "flag" , "1" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
return res ;
} , pool ) ;
moldingDayTask . thenAccept ( result - > {
map . put ( "MoldingDayList" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "获取当日压制任务信息: {}" , e . getMessage ( ) , e ) ;
map . put ( "MoldingDayList" , null ) ;
return null ;
} ) ;
// 2、成型库存任务半成品货架
CompletableFuture < JSONArray > semiFinishedProductShelfTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_MOLDING_INFO" ) . addParamMap ( MapOf . of ( "flag" , "2" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
return res ;
} , pool ) ;
semiFinishedProductShelfTask . thenAccept ( result - > {
map . put ( "SemiFinishedProductShelList" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "获取半成品货架信息: {}" , e . getMessage ( ) , e ) ;
map . put ( "SemiFinishedProductShelList" , null ) ;
return null ;
} ) ;
// 3、成型出入库信息
CompletableFuture < JSONArray > moldingIOStoringTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_MOLDING_INFO" ) . addParamMap ( MapOf . of ( "flag" , "3" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
return res ;
} , pool ) ;
moldingIOStoringTask . thenAccept ( result - > {
map . put ( "MoldingIOStoringList" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "获取半成品货架信息: {}" , e . getMessage ( ) , e ) ;
map . put ( "MoldingIOStoringList" , null ) ;
return null ;
} ) ;
CompletableFuture < Void > allQuery = CompletableFuture . allOf (
moldingDayTask ,
semiFinishedProductShelfTask ,
moldingIOStoringTask ) ;
CompletableFuture < ConcurrentHashMap < String , Object > > future = allQuery . thenApply ( ( result ) - > map ) . exceptionally ( ( e ) - > {
log . error ( e . getMessage ( ) , e ) ;
return null ;
} ) ;
future . join ( ) ;
return map ;
}
@Override
public ConcurrentHashMap < String , Object > firingAndDrying ( ) {
ThreadPoolExecutor pool = ThreadPoolExecutorUtil . getPoll ( ) ;
ConcurrentHashMap < String , Object > map = new ConcurrentHashMap < > ( ) ;
// 1、半成品库存
CompletableFuture < JSONArray > semiFinishedGoodsTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_FIR_AND_DRY" ) . addParamMap ( MapOf . of ( "flag" , "1" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
return res ;
} , pool ) ;
semiFinishedGoodsTask . thenAccept ( result - > {
map . put ( "SemiFinishedGoodsList" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "获取半成品库存信息: {}" , e . getMessage ( ) , e ) ;
map . put ( "SemiFinishedGoodsList" , null ) ;
return null ;
} ) ;
// 2、半成品出入库
CompletableFuture < JSONArray > semiFinishedIOTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_FIR_AND_DRY" ) . addParamMap ( MapOf . of ( "flag" , "2" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
return res ;
} , pool ) ;
semiFinishedIOTask . thenAccept ( result - > {
map . put ( "SemiFinishedIOList" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "获取半成品出入库信息: {}" , e . getMessage ( ) , e ) ;
map . put ( "SemiFinishedIOList" , null ) ;
return null ;
} ) ;
// todo: 3、烧制窑内物料
CompletableFuture < JSONArray > fireInTheKilnTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = new JSONArray ( ) ;
Random random = new Random ( ) ;
for ( int i = 1 ; i < = 5 ; i + + ) {
JSONObject r = new JSONObject ( ) ;
r . put ( "qty" , random . nextInt ( 2000 - 100 + 1 ) + 100 ) ;
r . put ( "material_code" , "物料" + i ) ;
res . add ( r ) ;
}
return res ;
} , pool ) ;
fireInTheKilnTask . thenAccept ( result - > {
map . put ( "FireInTheKilnList" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "获取烧制窑内物料信息: {}" , e . getMessage ( ) , e ) ;
map . put ( "FireInTheKilnList" , null ) ;
return null ;
} ) ;
// todo: 4、冷却窑内物料
CompletableFuture < JSONArray > coolingInTheKilnTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = new JSONArray ( ) ;
Random random = new Random ( ) ;
for ( int i = 1 ; i < = 5 ; i + + ) {
JSONObject r = new JSONObject ( ) ;
r . put ( "qty" , random . nextInt ( 2000 - 100 + 1 ) + 100 ) ;
r . put ( "material_code" , "物料" + i ) ;
res . add ( r ) ;
}
return res ;
} , pool ) ;
coolingInTheKilnTask . thenAccept ( result - > {
map . put ( "CoolingInTheKilnList" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "获取烧制窑内物料信息: {}" , e . getMessage ( ) , e ) ;
map . put ( "CoolingInTheKilnList" , null ) ;
return null ;
} ) ;
CompletableFuture < Void > allQuery = CompletableFuture . allOf (
semiFinishedGoodsTask ,
semiFinishedIOTask ,
fireInTheKilnTask ,
coolingInTheKilnTask ) ;
CompletableFuture < ConcurrentHashMap < String , Object > > future = allQuery . thenApply ( ( result ) - > map ) . exceptionally ( ( e ) - > {
log . error ( e . getMessage ( ) , e ) ;
return null ;
} ) ;
future . join ( ) ;
return map ;
}
@Override
public ConcurrentHashMap < String , Object > firingAndDryingPopover ( ) {
ThreadPoolExecutor pool = ThreadPoolExecutorUtil . getPoll ( ) ;
ConcurrentHashMap < String , Object > map = new ConcurrentHashMap < > ( ) ;
// 1、获取半成品货架弹窗
CompletableFuture < JSONArray > finishedProductShelfTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_FIR_AND_DRY" ) . addParamMap ( MapOf . of ( "flag" , "3" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
return res ;
} , pool ) ;
finishedProductShelfTask . thenAccept ( result - > {
map . put ( "FinishedProductShelfList" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "获取半成品货架弹窗信息: {}" , e . getMessage ( ) , e ) ;
map . put ( "FinishedProductShelfList" , null ) ;
return null ;
} ) ;
CompletableFuture < Void > allQuery = CompletableFuture . allOf (
finishedProductShelfTask ) ;
CompletableFuture < ConcurrentHashMap < String , Object > > future = allQuery . thenApply ( ( result ) - > map ) . exceptionally ( ( e ) - > {
log . error ( e . getMessage ( ) , e ) ;
return null ;
} ) ;
future . join ( ) ;
return map ;
}
@Override
public ConcurrentHashMap < String , Object > sortingAndPackaging ( ) {
ThreadPoolExecutor pool = ThreadPoolExecutorUtil . getPoll ( ) ;
ConcurrentHashMap < String , Object > map = new ConcurrentHashMap < > ( ) ;
// 1、半托缓存
CompletableFuture < JSONArray > halfSupportCacheTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_SORTE_AND_PACKAGE" ) . addParamMap ( MapOf . of ( "flag" , "1" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
return res ;
} , pool ) ;
halfSupportCacheTask . thenAccept ( result - > {
map . put ( "HalfSupportCacheList" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "获取半托缓存信息: {}" , e . getMessage ( ) , e ) ;
map . put ( "HalfSupportCacheList" , null ) ;
return null ;
} ) ;
// 2、包装区物料
CompletableFuture < JSONArray > packingAreaTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_SORTE_AND_PACKAGE" ) . addParamMap ( MapOf . of ( "flag" , "2" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
return res ;
} , pool ) ;
packingAreaTask . thenAccept ( result - > {
map . put ( "PackingAreaTaskList" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "获取包装区物料信息: {}" , e . getMessage ( ) , e ) ;
map . put ( "PackingAreaTaskList" , null ) ;
return null ;
} ) ;
// 3、当日拆码垛
CompletableFuture < JSONArray > sortingTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_SORTE_AND_PACKAGE" ) . addParamMap ( MapOf . of ( "flag" , "3" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
return res ;
} , pool ) ;
sortingTask . thenAccept ( result - > {
map . put ( "SortingDayList" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "获取当日拆码垛信息: {}" , e . getMessage ( ) , e ) ;
map . put ( "SortingDayList" , null ) ;
return null ;
} ) ;
// todo: 4、当日成品
CompletableFuture < List < ManufacturedProductsDto > > manufacturedProductsDayProductionTask = CompletableFuture . supplyAsync ( ( ) - > {
List < ManufacturedProductsDto > res = new ArrayList < > ( ) ;
Random random = new Random ( ) ;
// 使用随机数
for ( int i = 1 ; i < = 5 ; i + + ) {
ManufacturedProductsDto manufacturedProductsDto = new ManufacturedProductsDto ( ) ;
manufacturedProductsDto . setInventory_qty ( random . nextInt ( 2000 - 100 + 1 ) + 100 ) ;
manufacturedProductsDto . setQualified_in_qty ( random . nextInt ( 2000 - 100 + 1 ) + 100 ) ;
manufacturedProductsDto . setUnqualified_in_qty ( random . nextInt ( 2000 - 100 + 1 ) + 100 ) ;
manufacturedProductsDto . setMaterial_code ( "成品" + i ) ;
res . add ( manufacturedProductsDto ) ;
}
return res ;
} , pool ) ;
manufacturedProductsDayProductionTask . thenAccept ( ( result ) - > {
map . put ( "CPDayList" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "当日成品生产: {}" , e . getMessage ( ) , e ) ;
map . put ( "CPDayList" , null ) ;
return null ;
} ) ;
CompletableFuture < Void > allQuery = CompletableFuture . allOf (
halfSupportCacheTask ,
packingAreaTask ,
sortingTask ,
manufacturedProductsDayProductionTask ) ;
CompletableFuture < ConcurrentHashMap < String , Object > > future = allQuery . thenApply ( ( result ) - > map ) . exceptionally ( ( e ) - > {
log . error ( e . getMessage ( ) , e ) ;
return null ;
} ) ;
future . join ( ) ;
return map ;
}
@Override
public ConcurrentHashMap < String , Object > sortingAndPackagingPopover ( ) {
ThreadPoolExecutor pool = ThreadPoolExecutorUtil . getPoll ( ) ;
ConcurrentHashMap < String , Object > map = new ConcurrentHashMap < > ( ) ;
// 1、拆码工位
CompletableFuture < JSONArray > splitOrPalletizingTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_SORTE_AND_PACKAGE" ) . addParamMap ( MapOf . of ( "flag" , "4" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
return res ;
} , pool ) ;
splitOrPalletizingTask . thenAccept ( result - > {
map . put ( "SplitOrPalletizingList" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "拆码工位: {}" , e . getMessage ( ) , e ) ;
map . put ( "SplitOrPalletizingList" , null ) ;
return null ;
} ) ;
// 2、设备弹窗
CompletableFuture < JSONObject > devicesInfoTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONObject resObj = new JSONObject ( ) ;
JSONArray res = WQL . getWO ( "COCKPIT_SORTE_AND_PACKAGE" ) . addParamMap ( MapOf . of ( "flag" , "5" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
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" ) ;
resObj . put ( device . getString ( "device_code" ) , device ) ;
}
return resObj ;
} , pool ) ;
devicesInfoTask . thenAccept ( result - > {
map . put ( "DevicesInfoList" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "设备弹窗: {}" , e . getMessage ( ) , e ) ;
map . put ( "DevicesInfoList" , null ) ;
return null ;
} ) ;
// 3、半托缓存位
CompletableFuture < JSONArray > halfSupportCacheTask = CompletableFuture . supplyAsync ( ( ) - > {
JSONArray res = WQL . getWO ( "COCKPIT_SORTE_AND_PACKAGE" ) . addParamMap ( MapOf . of ( "flag" , "6" ) )
. process ( ) . getResultJSONArray ( 0 ) ;
return res ;
} , pool ) ;
halfSupportCacheTask . thenAccept ( result - > {
map . put ( "HalfSupportCacheList" , result ) ;
} ) . exceptionally ( ( e ) - > {
log . error ( "获取码盘工位弹出框数据: {}" , e . getMessage ( ) , e ) ;
map . put ( "HalfSupportCacheList" , null ) ;
return null ;
} ) ;
CompletableFuture < Void > allQuery = CompletableFuture . allOf (
splitOrPalletizingTask ,
devicesInfoTask ,
halfSupportCacheTask ) ;
CompletableFuture < ConcurrentHashMap < String , Object > > future = allQuery . thenApply ( ( result ) - > map ) . exceptionally ( ( e ) - > {
log . error ( e . getMessage ( ) , e ) ;
return null ;
} ) ;
future . join ( ) ;
return map ;
}
/ * *
* 处理空白数据 - 工序
*