@ -16,17 +16,11 @@ import org.nl.wms.sch.base.point.LockType;
import org.nl.wms.sch.base.point.PointStatus ;
import org.nl.wms.sch.base.point.PointType ;
import org.nl.wms.sch.base.region.RegionEnum ;
import org.nl.wms.sch.task.CallEmptyVehicleTask ;
import org.nl.wms.sch.task.CallMaterialTask ;
import org.nl.wms.sch.task.SendFullVehicleTask ;
import org.nl.wms.sch.task.SendResiduesMaterialTask ;
import org.nl.wms.sch.task.SendEmptyVehicleTask ;
import org.nl.wms.sch.task.* ;
import org.nl.wms.util.CommonUtils ;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
import java.util.concurrent.locks.Lock ;
/ * *
* @author 张江玮
* @date 2022 / 11 / 04 18 : 25
@ -65,12 +59,7 @@ public class PdaServiceImpl implements PdaService {
point . put ( "status" , "2" ) ;
}
}
// for (Object o : points) {
// JSONObject point = (JSONObject) o;
// if (StrUtil.equals(point.getString("lock_type"), LockType.TASK_LOCKED.getCode())) {
// point.put("status", "3");
// }
// }
return points ;
}
@ -117,7 +106,7 @@ public class PdaServiceImpl implements PdaService {
if ( StrUtil . isNotEmpty ( vehicleCode ) ) {
JSONObject vehicle = WQLObject . getWQLObject ( "md_pb_vehicle" ) . query ( "vehicle_code = '" + vehicleCode + "'" ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( vehicle ) ) {
throw new BadRequestException ( "该载具号不存在,请从组盘功能添加 " ) ;
throw new BadRequestException ( "该载具号不存在" ) ;
}
JSONObject existPoint = pointTable . query ( "vehicle_code = '" + vehicleCode + "'" ) . uniqueResult ( 0 ) ;
@ -185,7 +174,7 @@ public class PdaServiceImpl implements PdaService {
. query ( "material_code = '" + materialCode + "'" )
. uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( material ) ) {
throw new BadRequestException ( "条码为" + code + "的物料信息不存在,请从后台管理界面添加 " ) ;
throw new BadRequestException ( "条码为" + code + "的物料信息不存在" ) ;
}
JSONObject vm = new JSONObject ( ) ;
@ -248,10 +237,6 @@ public class PdaServiceImpl implements PdaService {
vm . put ( "create_time" , oldVm . getString ( "create_time" ) ) ;
vmTable . insert ( vm ) ;
}
// for (Object o : materials) {
// JSONObject material = (JSONObject) o;
//
// }
vehicle . put ( "vehicle_status" , VehicleStatus . HAS_MATERIAL . getCode ( ) ) ;
} else {
@ -268,52 +253,56 @@ public class PdaServiceImpl implements PdaService {
}
@Override
public JSONObject queryInventory ( String materialCode , String vehicleCode ) {
JSONObject vehicle = WQLObject
. getWQLObject ( "md_pb_vehicle" )
. query ( "vehicle_code = '" + vehicleCode + "' ")
. uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( vehicle ) ) {
throw new BadRequestException ( "该载具号不存在,请从组盘功能添加" ) ;
}
if ( StrUtil . equals ( vehicle . getString ( "vehicle_status" ) , VehicleStatus . EMPTY . getCode ( ) ) ) {
throw new BadRequestException ( "该载具为空载具" ) ;
public JSONArray queryInventory ( String materialCode , String vehicleCode ) {
if ( StrUtil . isNotEmpty ( materialCode ) ) {
JSONObject material = WQLObject
. getWQLObject ( "md_me_materialbase " )
. query ( "material_code = '" + materialCode + "'" )
. uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( material ) ) {
throw new BadRequestException ( "该物料号不存在" ) ;
}
}
JSONObject point = WQLObject
. getWQLObject ( "sch_base_point" )
. query ( "vehicle_code = '" + vehicleCode + "'" )
. uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( point ) ) {
throw new BadRequestException ( "该载具不存在于点位上" ) ;
}
if ( ! StrUtil . equals ( point . getString ( "region_code" ) , RegionEnum . ZC . getCode ( ) ) ) {
throw new BadRequestException ( "该载具不在暂存区" ) ;
}
if ( StrUtil . equals ( point . getString ( "is_used" ) , "0" ) ) {
throw new BadRequestException ( "该载具所在点位已被禁用" ) ;
}
JSONObject result = new JSONObject ( ) ;
result . put ( "point_id" , point . getString ( "point_id" ) ) ;
result . put ( "point_name" , point . getString ( "point_name" ) ) ;
if ( StrUtil . isNotEmpty ( vehicleCode ) ) {
JSONObject vehicle = WQLObject
. getWQLObject ( "md_pb_vehicle" )
. query ( "vehicle_code = '" + vehicleCode + "'" )
. uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( vehicle ) ) {
throw new BadRequestException ( "该载具号不存在" ) ;
}
if ( StrUtil . equals ( vehicle . getString ( "vehicle_status" ) , VehicleStatus . EMPTY . getCode ( ) ) ) {
throw new BadRequestException ( "该载具为空载具" ) ;
}
JSONObject material = WQLObject
. getWQLObject ( "md_me_materialbase" )
. query ( "material_code = '" + materialCode + "'" )
. uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( material ) ) {
throw new BadRequestException ( "该物料号不存在" ) ;
JSONObject point = WQLObject
. getWQLObject ( "sch_base_point" )
. query ( "vehicle_code = '" + vehicleCode + "'" )
. uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( point ) ) {
throw new BadRequestException ( "该载具不存在于点位上" ) ;
}
if ( ! StrUtil . equals ( point . getString ( "region_code" ) , RegionEnum . ZC . getCode ( ) ) ) {
throw new BadRequestException ( "该载具不在暂存区" ) ;
}
if ( StrUtil . equals ( point . getString ( "is_used" ) , "0" ) ) {
throw new BadRequestException ( "该载具所在点位已被禁用" ) ;
}
}
JSONArray detail = WQL
JSONArray result = WQL
. getWO ( "PDA" )
. addParam ( "flag" , "5" )
. addParam ( "vehicle_id" , vehicle . getString ( "vehicle_id" ) )
. addParam ( "material_id" , material . getString ( "material_id" ) )
. addParam ( "material_code" , materialCode )
. addParam ( "vehicle_code" , vehicleCode )
. process ( )
. getResultJSONArray ( 0 ) ;
result . put ( "detail" , detail ) ;
if ( ObjectUtil . isEmpty ( result ) ) {
throw new BadRequestException ( "未找到符合条件的暂存区点位" ) ;
}
return result ;
}
@ -355,14 +344,11 @@ public class PdaServiceImpl implements PdaService {
if ( StrUtil . equals ( point . getString ( "point_status" ) , PointStatus . EMPTY . getCode ( ) ) ) {
throw new BadRequestException ( "该点位为空位" ) ;
}
if ( StrUtil . equals ( point . getString ( "region_id" ) , RegionEnum . ZC . getId ( ) ) ) {
throw new BadRequestException ( "暂存区不能生成入库任务" ) ;
}
String regionId = point . getString ( "region_id" ) ;
if ( StrUtil . equals ( regionId , RegionEnum . JJ . getId ( ) )
& & point . getString ( "point_code" ) . startsWith ( "JJC" ) ) {
throw new BadRequestException ( "交接区出库位不能生成入库任务" ) ;
if ( StrUtil . equals ( regionId , RegionEnum . ZC . getId ( ) )
| | ( StrUtil . equals ( regionId , RegionEnum . JJ . getId ( ) )
& & point . getString ( "point_code" ) . startsWith ( "JJC" ) ) ) {
throw new BadRequestException ( "只有交接区的入库位和接料区才能发起入库任务" ) ;
}
JSONObject vehicle = WQLObject
@ -420,7 +406,7 @@ public class PdaServiceImpl implements PdaService {
throw new BadRequestException ( "终点有载具" ) ;
}
if ( ! StrUtil . equals ( nextPoint . getString ( "region_id" ) , RegionEnum . JJ . getId ( ) )
& & nextPoint . getString ( "point_code" ) . startsWith ( "JJC" ) ) {
& & nextPoint . getString ( "point_code" ) . startsWith ( "JJC" ) ) {
throw new BadRequestException ( "只有终点为交接区的出库位才能生成出库任务" ) ;
}