|
@ -44,8 +44,6 @@ import java.util.concurrent.TimeUnit; |
|
|
@Slf4j |
|
|
@Slf4j |
|
|
public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
|
|
|
|
|
|
private final RedissonClient redissonClient; |
|
|
|
|
|
|
|
|
|
|
|
private final HLCallEmptyTask hlCallEmptyTask; |
|
|
private final HLCallEmptyTask hlCallEmptyTask; |
|
|
|
|
|
|
|
|
private final HLSendMaterialTask hlSendMaterialTask; |
|
|
private final HLSendMaterialTask hlSendMaterialTask; |
|
@ -187,19 +185,11 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public JSONObject apply(JSONObject param) { |
|
|
public JSONObject apply(JSONObject param) { |
|
|
String point_code = param.getString("device_code"); |
|
|
String point_code = param.getString("device_code"); |
|
|
if (StrUtil.isBlank(point_code)) { |
|
|
|
|
|
throw new BadRequestException("点位不能为空!"); |
|
|
|
|
|
} |
|
|
|
|
|
String type = param.getString("type"); |
|
|
String type = param.getString("type"); |
|
|
if (StrUtil.isBlank(type)) { |
|
|
if (StrUtil.isBlank(type)) { |
|
|
throw new BadRequestException("任务类型不能为空!"); |
|
|
throw new BadRequestException("任务类型不能为空!"); |
|
|
} |
|
|
} |
|
|
RLock lock = redissonClient.getFairLock("acs_to_wms:" + point_code); |
|
|
String task_code; |
|
|
boolean try_lock = false; |
|
|
|
|
|
String task_code = null; |
|
|
|
|
|
try { |
|
|
|
|
|
try_lock = lock.tryLock(5, TimeUnit.SECONDS); |
|
|
|
|
|
if (try_lock) { |
|
|
|
|
|
JSONObject point = param.getJSONObject("point"); |
|
|
JSONObject point = param.getJSONObject("point"); |
|
|
if (ObjectUtil.isEmpty(point)) { |
|
|
if (ObjectUtil.isEmpty(point)) { |
|
|
point = WQLObject |
|
|
point = WQLObject |
|
@ -242,11 +232,6 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
case YZ: |
|
|
case YZ: |
|
|
method_param.put("workorder", param.getJSONObject("workorder")); |
|
|
method_param.put("workorder", param.getJSONObject("workorder")); |
|
|
method_param.put("vd", param.getJSONObject("vd")); |
|
|
method_param.put("vd", param.getJSONObject("vd")); |
|
|
JSONObject device = WQLObject |
|
|
|
|
|
.getWQLObject("pdm_bi_device") |
|
|
|
|
|
.query("device_code = '" + point.getString("device_code") + "'") |
|
|
|
|
|
.uniqueResult(0); |
|
|
|
|
|
method_param.put("device", device); |
|
|
|
|
|
task_code = yzSendMaterialTask.createTask(method_param); |
|
|
task_code = yzSendMaterialTask.createTask(method_param); |
|
|
break; |
|
|
break; |
|
|
case SZ: |
|
|
case SZ: |
|
@ -283,8 +268,22 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
break; |
|
|
break; |
|
|
case "3": |
|
|
case "3": |
|
|
// 送空
|
|
|
// 送空
|
|
|
|
|
|
vehicle_code = TaskUtils.formatVehicleCode(param.getString("vehicle_code")); |
|
|
|
|
|
if ("0000".equals(vehicle_code)) { |
|
|
|
|
|
vehicle_code = point.getString("vehicle_code"); |
|
|
|
|
|
if (StrUtil.isBlank(vehicle_code) || "0000".equals(vehicle_code)) { |
|
|
|
|
|
throw new BadRequestException("未知载具编码!"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
method_param.put("vehicle_code", vehicle_code); |
|
|
|
|
|
|
|
|
switch (region) { |
|
|
switch (region) { |
|
|
case FJ: |
|
|
case FJ: |
|
|
|
|
|
JSONObject vd_update = new JSONObject(); |
|
|
|
|
|
vd_update.put("is_delete", TrueOrFalse.TRUE.value()); |
|
|
|
|
|
WQLObject |
|
|
|
|
|
.getWQLObject("st_ivt_vehicle_detail") |
|
|
|
|
|
.update(vd_update, "vehicle_type = '2' AND vehicle_code = '" + vehicle_code + "'"); |
|
|
task_code = fjSendEmptyTask.createTask(method_param); |
|
|
task_code = fjSendEmptyTask.createTask(method_param); |
|
|
break; |
|
|
break; |
|
|
default: |
|
|
default: |
|
@ -310,11 +309,6 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
.query("is_delete = '0' AND device_code = '" + device_code + "' AND order_status = '3'") |
|
|
.query("is_delete = '0' AND device_code = '" + device_code + "' AND order_status = '3'") |
|
|
.uniqueResult(0); |
|
|
.uniqueResult(0); |
|
|
method_param.put("workorder", work_order); |
|
|
method_param.put("workorder", work_order); |
|
|
JSONObject device = WQLObject |
|
|
|
|
|
.getWQLObject("pdm_bi_device") |
|
|
|
|
|
.query("device_code = '" + device_code + "'") |
|
|
|
|
|
.uniqueResult(0); |
|
|
|
|
|
method_param.put("device", device); |
|
|
|
|
|
task_code = yzCallEmptyTask.createTask(method_param); |
|
|
task_code = yzCallEmptyTask.createTask(method_param); |
|
|
break; |
|
|
break; |
|
|
case GTK: |
|
|
case GTK: |
|
@ -327,15 +321,6 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
default: |
|
|
default: |
|
|
throw new BadRequestException("未知任务类型!"); |
|
|
throw new BadRequestException("未知任务类型!"); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
|
log.error("lock fail!", e); |
|
|
|
|
|
} finally { |
|
|
|
|
|
if (try_lock) { |
|
|
|
|
|
lock.unlock(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
JSONObject result = new JSONObject(); |
|
|
JSONObject result = new JSONObject(); |
|
|
result.put("message", "申请任务成功,任务编码 [" + task_code + "]"); |
|
|
result.put("message", "申请任务成功,任务编码 [" + task_code + "]"); |
|
|
result.put("status", HttpStatus.OK.value()); |
|
|
result.put("status", HttpStatus.OK.value()); |
|
|