@ -59,26 +59,47 @@ public class BakingServiceImpl implements BakingService {
public JSONObject ovenInAndOut ( JSONObject whereJson ) {
String option = whereJson . getString ( "option" ) ; // 1-入箱 2-出箱
WQLObject pointTab = WQLObject . getWQLObject ( "SCH_BASE_Point" ) ; // 点位表
WQLObject taskTab = WQLObject . getWQLObject ( "SCH_BASE_Task" ) ; // 任务表
WQLObject coolIvtTab = WQLObject . getWQLObject ( "ST_IVT_CoolPointIvt" ) ; // 冷却区点位库存表
WQLObject hosIvtTab = WQLObject . getWQLObject ( "ST_IVT_HotPointIvt" ) ; // 烤箱区点位库存表
WQLObject hosReMstTab = WQLObject . getWQLObject ( "ST_IVT_HotRegionIOMst" ) ; // 烤箱区出入主表
WQLObject coolTab = WQLObject . getWQLObject ( "ST_IVT_CoolRegionIO" ) ; // 冷却区出入表
WQLObject rawTab = WQLObject . getWQLObject ( "PDM_BI_RawFoilWorkOrder" ) ; // 生箔工单表
WQLObject materTab = WQLObject . getWQLObject ( "md_me_materialbase" ) ; // 物料表
// 点位表
WQLObject pointTab = WQLObject . getWQLObject ( "SCH_BASE_Point" ) ;
// 任务表
WQLObject taskTab = WQLObject . getWQLObject ( "SCH_BASE_Task" ) ;
// 冷却区点位库存表
WQLObject coolIvtTab = WQLObject . getWQLObject ( "ST_IVT_CoolPointIvt" ) ;
// 冷却区出入表
WQLObject coolTab = WQLObject . getWQLObject ( "ST_IVT_CoolRegionIO" ) ;
// 烤箱区点位库存表
WQLObject hosIvtTab = WQLObject . getWQLObject ( "ST_IVT_HotPointIvt" ) ;
// 生箔工单表
WQLObject rawTab = WQLObject . getWQLObject ( "PDM_BI_RawFoilWorkOrder" ) ;
// 物料表
WQLObject materTab = WQLObject . getWQLObject ( "md_me_materialbase" ) ;
//获取人员对应的区域
UserAreaServiceImpl userAreaService = new UserAreaServiceImpl ( ) ;
String in_area_id = userAreaService . getInArea ( ) ;
// 入箱
if ( StrUtil . equals ( option , "1" ) ) {
// 入箱
String container_name = whereJson . getString ( "container_name" ) ; // 母卷号
String temperature = whereJson . getString ( "temperature" ) ; // 温度
String hours = whereJson . getString ( "hours" ) ; // 时间
String point_code1 = whereJson . getString ( "point_code" ) ; // 点位
// 母卷号
String container_name = whereJson . getString ( "container_name" ) ;
// 温度
String temperature = whereJson . getString ( "temperature" ) ;
// 时间
String hours = whereJson . getString ( "hours" ) ;
// 点位
String point_code1 = whereJson . getString ( "point_code" ) ;
if ( ObjectUtil . isEmpty ( container_name ) ) {
throw new BadRequestException ( "母卷号不能为空" ) ;
}
if ( ObjectUtil . isEmpty ( temperature ) ) {
throw new BadRequestException ( "温度不能为空" ) ;
}
if ( ObjectUtil . isEmpty ( hours ) ) {
throw new BadRequestException ( "时间不能为空" ) ;
}
if ( ObjectUtil . isEmpty ( point_code1 ) ) {
throw new BadRequestException ( "点位不能为空" ) ;
}
//校验该设备是否启用,且母卷MES是否请求烘烤
//查询该母卷号、设备号对应的生箔工单
@ -95,51 +116,44 @@ public class BakingServiceImpl implements BakingService {
if ( ObjectUtil . isEmpty ( sb_jo ) ) {
throw new BadRequestException ( "未查询到母卷号:" + container_name + "对应的生箔机台编号!" ) ;
}
//MES启用mes_used为1,且请求烘烤is_baking为0
if ( StrUtil . equals ( "1" , sb_jo . getString ( "mes_used" ) ) & & ! "1" . equals ( raw_jo . getString ( "is_baking" ) ) ) {
throw new BadRequestException ( "该母卷在MES上未进行决策入烘箱,不允许进行入烘箱操作!" ) ;
}
if ( ObjectUtil . isEmpty ( container_name ) ) {
throw new BadRequestException ( "母卷号不能为空" ) ;
}
if ( ObjectUtil . isEmpty ( temperature ) ) {
throw new BadRequestException ( "温度不能为空" ) ;
}
if ( ObjectUtil . isEmpty ( hours ) ) {
throw new BadRequestException ( "时间不能为空" ) ;
}
if ( ObjectUtil . isEmpty ( point_code1 ) ) {
throw new BadRequestException ( "点位不能为空" ) ;
}
/ *
* 根据点位判断是 冷却区入烘箱还是暂存区入烘箱
* /
JSONObject jsonPointZc = pointTab . query ( "point_code = '" + point_code1 + "'" ) . uniqueResult ( 0 ) ;
JSONObject cool_jo = coolIvtTab . query ( "point_code = '" + point_code1 + "' AND point_type = '3'" ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isNotEmpty ( jsonPointZc ) | | ObjectUtil . isNotEmpty ( cool_jo ) ) {
if ( ObjectUtil . isEmpty ( jsonPointZc ) ) {
jsonPointZc = cool_jo ;
}
//判断人员区域操作权限
if ( ! in_area_id . contains ( jsonPointZc . getString ( "product_area" ) ) ) {
throw new BadRequestException ( "当前登录人员暂无【" + jsonPointZc . getString ( "product_area" ) + "】操作权限" ) ;
}
/ *
* 暂存区入烘箱
* /
// 1.查询烘箱对应的空位
// 1.查询烘箱对应的空位:符合温度要求,并且有空位的烘箱
JSONObject jsonMap = new JSONObject ( ) ;
jsonMap . put ( "flag" , "1" ) ;
//区域
jsonMap . put ( "product_area" , jsonPointZc . getString ( "product_area" ) ) ;
//获取温度幅度
//位置1或0
jsonMap . put ( "point_location" , jsonPointZc . getString ( "point_location" ) ) ;
//获取温度幅度
//查询烤箱区点位库存表ST_IVT_HotPointIvt,启用、空位、且无未完成的任务的点位
JSONArray hot_rows = WQL . getWO ( "PDA_BAKING_01" ) . addParamMap ( jsonMap ) . process ( ) . getResultJSONArray ( 0 ) ;
JSONObject jsonHotIvt = new JSONObject ( ) ;
for ( int i = 0 ; i < hot_rows . size ( ) ; i + + ) {
JSONObject hot_row = hot_rows . getJSONObject ( i ) ;
String point_code = hot_row . getString ( "point_code" ) ;
//??
String point_temperature = ( String ) redisUtils . hget ( point_code , "temperature" ) ;
if ( ! ObjectUtil . isEmpty ( point_temperature ) ) {
if ( point_temperature . equals ( temperature ) ) {
@ -148,10 +162,11 @@ public class BakingServiceImpl implements BakingService {
}
}
}
//未找到满足的点位
if ( ObjectUtil . isEmpty ( jsonHotIvt ) ) {
//如果属于B1的烘箱,变更位置再查询
if ( ObjectUtil . isNotEmpty ( cool_jo ) & & cool_jo . getString ( "product_area" ) . equals ( "B1" ) ) {
//二期换另一排查询
jsonMap . put ( "point_location" , jsonPointZc . getString ( "point_location" ) . equals ( "0" ) ? "1" : "0" ) ;
hot_rows = WQL . getWO ( "PDA_BAKING_01" ) . addParamMap ( jsonMap ) . process ( ) . getResultJSONArray ( 0 ) ;
for ( int i = 0 ; i < hot_rows . size ( ) ; i + + ) {
@ -174,36 +189,56 @@ public class BakingServiceImpl implements BakingService {
}
// 2.创建暂存位 --> 烘烤区任务
JSONObject param = new JSONObject ( ) ;
param . put ( "type" , "2" ) ; // 1- 冷却区入烘箱 2- 暂存位入烘箱
// 1- 冷却区入烘箱 2- 暂存位入烘箱
param . put ( "type" , "2" ) ;
//设置起点
if ( ObjectUtil . isNotEmpty ( cool_jo ) ) {
param . put ( "point_code1" , cool_jo . getString ( "point_code" ) ) ;
} else {
param . put ( "point_code1" , point_code1 ) ;
}
//终点
param . put ( "point_code2" , jsonHotIvt . getString ( "point_code" ) ) ;
//母卷
param . put ( "material_code" , container_name ) ;
//任务来源区域
param . put ( "product_area" , jsonPointZc . getString ( "product_area" ) ) ;
//烘烤时间h
param . put ( "request_param" , NumberUtil . mul ( Double . parseDouble ( hours ) , 60 ) ) ;
InHotTask inHotTask = new InHotTask ( ) ;
//创建入烘箱任务
String task_id = inHotTask . createTask ( param ) ;
// 3.插入主表
//查询母卷 对应生箔工单表
JSONObject jsonRaw = rawTab . query ( "container_name = '" + container_name + "' and is_delete = '0'" ) . uniqueResult ( 0 ) ;
//查询物料
JSONObject jsonMater = materTab . query ( "material_code = '" + jsonRaw . getString ( "product_name" ) + "'" ) . uniqueResult ( 0 ) ;
JSONObject hotParam = new JSONObject ( ) ;
//母卷
hotParam . put ( "container_name" , container_name ) ;
//工单标识
hotParam . put ( "workorder_id" , jsonRaw . getString ( "workorder_id" ) ) ;
//产品id
hotParam . put ( "material_id" , jsonMater . getString ( "material_id" ) ) ;
//工单重量
hotParam . put ( "qty" , jsonRaw . get ( "productin_qty" ) ) ;
//出入类型
hotParam . put ( "io_type" , "0" ) ;
hotParam . put ( "qty_unit_id" , jsonMater . getString ( "base_unit_id" ) ) ;
//入烘箱任务id
hotParam . put ( "task_id" , task_id ) ;
//起点
hotParam . put ( "start_point_code" , point_code1 ) ;
//终点
hotParam . put ( "end_point_code" , jsonHotIvt . getString ( "point_code" ) ) ;
//温度
hotParam . put ( "temperature" , temperature ) ;
//烘烤时间
hotParam . put ( "oven_time" , hours ) ;
//创建烘箱主表ST_IVT_HotRegionIOMst
this . createHotIoMst ( hotParam ) ;
} else {
/ *
@ -215,9 +250,10 @@ public class BakingServiceImpl implements BakingService {
if ( ObjectUtil . isEmpty ( jsonCoolIvt ) ) {
throw new BadRequestException ( "请扫描正确的冷却区或对接点位!" ) ;
}
String product_area = jsonCoolIvt . getString ( "product_area" ) ; // 生产区域
String point_location = jsonCoolIvt . getString ( "point_location" ) ; // 位置
// 生产区域
String product_area = jsonCoolIvt . getString ( "product_area" ) ;
// 位置
String point_location = jsonCoolIvt . getString ( "point_location" ) ;
String reging_id = "" ;
if ( ! in_area_id . contains ( product_area ) ) {
@ -249,6 +285,13 @@ public class BakingServiceImpl implements BakingService {
}
map . put ( "reging_id" , reging_id ) ;
map . put ( "point_location" , point_location ) ;
/ * *
* 共用 3
* 点位 1
* 仓位 2
* 入箱 4
* 出箱 5
* /
//只找入箱点位
map . put ( "point_type" , "4" ) ;
@ -288,9 +331,13 @@ public class BakingServiceImpl implements BakingService {
// 3.创建冷却区 --> 烘烤区任务
JSONObject param = new JSONObject ( ) ;
param . put ( "type" , "1" ) ; // 1- 冷却区入烘箱 2- 暂存位入烘箱
//// 1- 冷却区入烘箱 2- 暂存位入烘箱
param . put ( "type" , "1" ) ;
//起点
param . put ( "point_code1" , point_code1 ) ;
//暂存位
param . put ( "point_code2" , point_code2_jo . getString ( "point_code" ) ) ;
//烘烤点位
param . put ( "point_code3" , jsonHotIvt . getString ( "point_code" ) ) ;
param . put ( "material_code" , container_name ) ;
param . put ( "product_area" , product_area ) ;
@ -308,21 +355,31 @@ public class BakingServiceImpl implements BakingService {
}
JSONObject hotParam = new JSONObject ( ) ;
//母卷
hotParam . put ( "container_name" , container_name ) ;
//工单id
hotParam . put ( "workorder_id" , jsonRaw . getString ( "workorder_id" ) ) ;
//产品id
hotParam . put ( "material_id" , jsonMater . getString ( "material_id" ) ) ;
//重量
hotParam . put ( "qty" , jsonRaw . get ( "productin_qty" ) ) ;
hotParam . put ( "qty_unit_id" , jsonMater . getString ( "base_unit_id" ) ) ;
//任务id
hotParam . put ( "task_id" , task_id ) ;
//出入类型
hotParam . put ( "io_type" , "0" ) ;
//起点
hotParam . put ( "start_point_code" , point_code1 ) ;
//终点
hotParam . put ( "end_point_code" , jsonHotIvt . getString ( "point_code" ) ) ;
//温度
hotParam . put ( "temperature" , temperature ) ;
//时间
hotParam . put ( "oven_time" , hours ) ;
this . createHotIoMst ( hotParam ) ;
// 生成冷却区出入表
// 生成冷却区出入表ST_IVT_CoolRegionIO
String currentUserId = SecurityUtils . getCurrentUserId ( ) ;
String currentUsername = SecurityUtils . getCurrentUsername ( ) ;
@ -350,8 +407,9 @@ public class BakingServiceImpl implements BakingService {
jsonCool . put ( "confirm_time" , DateUtil . now ( ) ) ;
coolTab . insert ( jsonCool ) ;
}
} else if ( StrUtil . equals ( option , "2" ) ) {
// 出箱
}
//出箱
else if ( StrUtil . equals ( option , "2" ) ) {
String point_code1 = whereJson . getString ( "point_code" ) ;
if ( ObjectUtil . isEmpty ( point_code1 ) ) {
throw new BadRequestException ( "点位不能为空" ) ;
@ -548,14 +606,18 @@ public class BakingServiceImpl implements BakingService {
@Override
@Transactional ( rollbackFor = Exception . class )
public JSONObject inCoolIvt ( JSONObject whereJson ) {
WQLObject pointTab = WQLObject . getWQLObject ( "SCH_BASE_Point" ) ; // 点位点
WQLObject coolTab = WQLObject . getWQLObject ( "ST_IVT_CoolRegionIO" ) ; // 冷却区出入表
WQLObject rawTab = WQLObject . getWQLObject ( "PDM_BI_RawFoilWorkOrder" ) ; // 生箔工单表
WQLObject materTab = WQLObject . getWQLObject ( "md_me_materialbase" ) ; // 物料表
String point_code1 = whereJson . getString ( "point_code" ) ; // 暂存位:起点
String container_name = whereJson . getString ( "container_name" ) ; // 母卷号
// 点位点
WQLObject pointTab = WQLObject . getWQLObject ( "SCH_BASE_Point" ) ;
// 冷却区出入表
WQLObject coolTab = WQLObject . getWQLObject ( "ST_IVT_CoolRegionIO" ) ;
// 生箔工单表
WQLObject rawTab = WQLObject . getWQLObject ( "PDM_BI_RawFoilWorkOrder" ) ;
// 物料表
WQLObject materTab = WQLObject . getWQLObject ( "md_me_materialbase" ) ;
// 暂存位:起点
String point_code1 = whereJson . getString ( "point_code" ) ;
// 母卷号
String container_name = whereJson . getString ( "container_name" ) ;
//获取人员对应的区域
UserAreaServiceImpl userAreaService = new UserAreaServiceImpl ( ) ;
@ -623,8 +685,11 @@ public class BakingServiceImpl implements BakingService {
// 3.创建任务
JSONObject param = new JSONObject ( ) ;
//点位
param . put ( "point_code1" , point_code1 ) ;
//冷却区
param . put ( "point_code2" , jsonCooIvt . getString ( "full_point_code" ) ) ;
//母卷
param . put ( "container_name" , container_name ) ;
param . put ( "product_area" , jsonPoint . getString ( "product_area" ) ) ;