@ -4,7 +4,6 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil ;
import cn.hutool.core.util.ObjectUtil ;
import cn.hutool.core.util.StrUtil ;
import com.alibaba.fastjson.JSON ;
import com.alibaba.fastjson.JSONArray ;
import com.alibaba.fastjson.JSONObject ;
import lombok.RequiredArgsConstructor ;
@ -17,7 +16,6 @@ import org.nl.wms.basedata.eum.TrueOrFalse;
import org.nl.wms.basedata.eum.VehicleType ;
import org.nl.wms.ext.acs.service.WmsToAcsService ;
import org.nl.wms.pda.service.PdaService ;
import org.nl.wms.sch.manage.ACSSystem ;
import org.nl.wms.sch.manage.CreateMode ;
import org.nl.wms.sch.manage.PointStatus ;
import org.nl.wms.sch.manage.Region ;
@ -89,6 +87,13 @@ public class PdaServiceImpl implements PdaService {
. addParam ( "where" , "('YZ', 'FJ')" )
. process ( )
. getResultJSONArray ( 0 ) ;
case "vehicle_bind" :
case "vehicle_unbind" :
return WQL
. getWO ( "PDA" )
. addParam ( "flag" , "1" )
. process ( )
. getResultJSONArray ( 0 ) ;
default :
throw new BadRequestException ( "未知功能!" ) ;
}
@ -222,6 +227,14 @@ public class PdaServiceImpl implements PdaService {
default :
throw new BadRequestException ( region . label ( ) + "没有叫空点位!" ) ;
}
case "vehicle_bind" :
case "vehicle_unbind" :
return WQL
. getWO ( "PDA" )
. addParam ( "flag" , "2" )
. addParam ( "region_code" , region_code )
. process ( )
. getResultJSONArray ( 0 ) ;
default :
throw new BadRequestException ( "未知功能!" ) ;
}
@ -229,11 +242,23 @@ public class PdaServiceImpl implements PdaService {
@Override
public JSONArray device ( String func ) {
switch ( func ) {
case "unqualified_report" :
return WQL
. getWO ( "PDA" )
. addParam ( "flag" , "3" )
. process ( )
. getResultJSONArray ( 0 ) ;
case "call_defective" :
return WQL
. getWO ( "PDA" )
. addParam ( "flag" , "3" )
. addParam ( "region_code" , "YZ" )
. process ( )
. getResultJSONArray ( 0 ) ;
default :
throw new BadRequestException ( "未知功能!" ) ;
}
}
@Override
@ -330,12 +355,13 @@ public class PdaServiceImpl implements PdaService {
put ( "device_code" , device_code ) ;
} } ) ;
} } ) ;
JSONObject device = WQLObject . getWQLObject ( "acs_device" ) . query ( "device_code = '" + device_code + "'" ) . uniqueResult ( 0 ) ;
if ( ! "200" . equals ( result . getString ( "status" ) ) ) {
throw new BadRequestException ( "[" + device_code + "] ACS未返回设备信息!" ) ;
throw new BadRequestException ( "[" + device . getString ( "device_name" ) + "] ACS未返回设备信息!" ) ;
}
JSONArray data = result . getJSONArray ( "data" ) ;
if ( ObjectUtil . isEmpty ( data ) ) {
throw new BadRequestException ( "[" + device_code + "] ACS未返回设备信息!" ) ;
throw new BadRequestException ( "[" + device . getString ( "device_name" ) + "] ACS未返回设备信息!" ) ;
}
String mix_num = data . getJSONObject ( 0 ) . getString ( "mix_num" ) ;
if ( StrUtil . isBlank ( mix_num ) ) {
@ -538,4 +564,54 @@ public class PdaServiceImpl implements PdaService {
TaskUtils . addCurrentUpdateColum ( vehicle_update ) ;
WQLObject . getWQLObject ( "st_ivt_vehicle_detail" ) . update ( vehicle_update , "vehicle_type = '2' AND vehicle_code = '" + vehicle_code + "'" ) ;
}
@Override
public void vehicleBind ( String point_code , String vehicle_type , String vehicle_code ) {
JSONObject point_update = new JSONObject ( ) ;
point_update . put ( "point_status" , PointStatus . NOT_EMPTY . value ( ) ) ;
point_update . put ( "vehicle_type" , vehicle_type ) ;
point_update . put ( "vehicle_code" , vehicle_code ) ;
TaskUtils . addCurrentUpdateColum ( point_update ) ;
WQLObject . getWQLObject ( "sch_base_point" ) . update ( point_update , "point_code = '" + point_code + "'" ) ;
}
@Override
public void vehicleUnbind ( String point_code ) {
JSONObject point_update = new JSONObject ( ) ;
point_update . put ( "point_status" , PointStatus . EMPTY . value ( ) ) ;
point_update . put ( "vehicle_type" , "" ) ;
point_update . put ( "vehicle_code" , "" ) ;
TaskUtils . addCurrentUpdateColum ( point_update ) ;
WQLObject . getWQLObject ( "sch_base_point" ) . update ( point_update , "point_code = '" + point_code + "'" ) ;
}
@Override
public void callDefective ( String device_code , String request_param ) {
JSONObject device = WQLObject . getWQLObject ( "pdm_bi_device" ) . query ( "is_used = '1' AND is_delete = '0' AND device_code = '" + device_code + "'" ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( device ) ) {
throw new BadRequestException ( "[" + device_code + "] 不存在或未启用!" ) ;
}
JSONObject point = WQLObject . getWQLObject ( "sch_base_point" ) . query ( "region_code = 'YZ' AND point_type = '3' AND device_code LIKE '%" + device_code + "%'" ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( point ) ) {
throw new BadRequestException ( "[" + device . getString ( "device_name" ) + "] 未找到次品料对接位!" ) ;
}
JSONObject workorder = WQLObject
. getWQLObject ( "pdm_bd_workorder" )
. query ( "is_delete = '0' AND device_code = '" + device_code + "' AND order_status = '3'" )
. uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( workorder ) ) {
throw new BadRequestException ( "[" + point . getString ( "point_code" ) + "] 所属设备 [" + device_code + "] 未开始生产!" ) ;
}
JSONObject method_param = new JSONObject ( ) ;
method_param . put ( "workorder" , workorder ) ;
method_param . put ( "point" , point ) ;
method_param . put ( "create_mode" , CreateMode . SCCJ . value ( ) ) ;
method_param . put ( "request_param" , request_param ) ;
method_param . put ( "create_id" , SecurityUtils . getCurrentUserId ( ) ) ;
method_param . put ( "create_name" , SecurityUtils . getCurrentNickName ( ) ) ;
yzCallMaterialTask . createTask ( method_param ) ;
}
}