|
|
@ -172,18 +172,21 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
|
// 找到当前的设备
|
|
|
|
String deviceCode = param.getString("device_code"); |
|
|
|
String requestNo = param.getString("requestNo"); |
|
|
|
RLock lock = redissonClient.getLock(deviceCode); |
|
|
|
SchBasePoint basePoint = pointService.getById(deviceCode); |
|
|
|
String configCode = basePoint.getRegion_code() + "QLTask"; |
|
|
|
RLock lock = redissonClient.getLock(configCode); |
|
|
|
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS); |
|
|
|
try { |
|
|
|
if (tryLock) { |
|
|
|
SchBasePoint basePoint = pointService.getById(deviceCode); |
|
|
|
if (ObjectUtil.isEmpty(basePoint)) { |
|
|
|
throw new BadRequestException("点位错误!"); |
|
|
|
} |
|
|
|
String configCode = basePoint.getRegion_code() + "QLTask"; |
|
|
|
|
|
|
|
// 组织参数
|
|
|
|
param.put("config_code", configCode); |
|
|
|
taskService.apply(param); |
|
|
|
} else { |
|
|
|
throw new BadRequestException("其他设备占用锁,等待结束!"); |
|
|
|
} |
|
|
|
} finally { |
|
|
|
if (tryLock) { |
|
|
@ -206,18 +209,22 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
|
// 找到当前的设备
|
|
|
|
String deviceCode = param.getString("device_code"); |
|
|
|
String requestNo = param.getString("requestNo"); |
|
|
|
RLock lock = redissonClient.getLock(deviceCode); |
|
|
|
SchBasePoint basePoint = pointService.getById(deviceCode); |
|
|
|
String configCode = basePoint.getRegion_code() + "QKTask"; |
|
|
|
RLock lock = redissonClient.getLock(configCode); |
|
|
|
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS); |
|
|
|
try { |
|
|
|
if (tryLock) { |
|
|
|
SchBasePoint basePoint = pointService.getById(deviceCode); |
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(basePoint)) { |
|
|
|
throw new BadRequestException("点位错误!"); |
|
|
|
} |
|
|
|
String configCode = basePoint.getRegion_code() + "QKTask"; |
|
|
|
|
|
|
|
// 组织参数
|
|
|
|
param.put("config_code", configCode); |
|
|
|
taskService.apply(param); |
|
|
|
} else { |
|
|
|
throw new BadRequestException("其他设备占用锁,等待结束!"); |
|
|
|
} |
|
|
|
} finally { |
|
|
|
if (tryLock) { |
|
|
@ -240,18 +247,22 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
|
// 找到当前的设备
|
|
|
|
String deviceCode = param.getString("device_code"); |
|
|
|
String requestNo = param.getString("requestNo"); |
|
|
|
RLock lock = redissonClient.getLock(deviceCode); |
|
|
|
SchBasePoint basePoint = pointService.getById(deviceCode); |
|
|
|
String configCode = basePoint.getRegion_code() + "SKTask"; |
|
|
|
RLock lock = redissonClient.getLock(configCode); |
|
|
|
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS); |
|
|
|
try { |
|
|
|
if (tryLock) { |
|
|
|
SchBasePoint basePoint = pointService.getById(deviceCode); |
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(basePoint)) { |
|
|
|
throw new BadRequestException("点位错误!"); |
|
|
|
} |
|
|
|
String configCode = basePoint.getRegion_code() + "SKTask"; |
|
|
|
|
|
|
|
// 组织参数
|
|
|
|
param.put("config_code", configCode); |
|
|
|
taskService.apply(param); |
|
|
|
} else { |
|
|
|
throw new BadRequestException("其他设备占用锁,等待结束!"); |
|
|
|
} |
|
|
|
} finally { |
|
|
|
if (tryLock) { |
|
|
@ -274,21 +285,25 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
|
// 找到当前的设备
|
|
|
|
String deviceCode = param.getString("device_code"); |
|
|
|
String requestNo = param.getString("requestNo"); |
|
|
|
RLock lock = redissonClient.getLock(deviceCode); |
|
|
|
SchBasePoint basePoint = pointService.getById(deviceCode); |
|
|
|
String configCode = basePoint.getRegion_code() + "MLTask"; |
|
|
|
RLock lock = redissonClient.getLock(configCode); |
|
|
|
int handling = 0; // 无业务:0
|
|
|
|
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS); |
|
|
|
try { |
|
|
|
if (tryLock) { |
|
|
|
SchBasePoint basePoint = pointService.getById(deviceCode); |
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(basePoint)) { |
|
|
|
throw new BadRequestException("点位错误!"); |
|
|
|
} |
|
|
|
String configCode = basePoint.getRegion_code() + "MLTask"; |
|
|
|
|
|
|
|
// 组织参数
|
|
|
|
param.put("config_code", configCode); |
|
|
|
handling = specialHandling(basePoint.getRegion_code(), param); |
|
|
|
param.put("special_param", handling); |
|
|
|
taskService.apply(param); |
|
|
|
} else { |
|
|
|
throw new BadRequestException("其他设备占用锁,等待结束!"); |
|
|
|
} |
|
|
|
} finally { |
|
|
|
if (tryLock) { |
|
|
@ -322,18 +337,20 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
|
public ApplyTaskResponse applyForceTakeFullVehicle(JSONObject param) { |
|
|
|
String deviceCode = param.getString("device_code"); |
|
|
|
String requestNo = param.getString("requestNo"); |
|
|
|
RLock lock = redissonClient.getLock(deviceCode); |
|
|
|
boolean tryLock = lock.tryLock(5, TimeUnit.SECONDS); |
|
|
|
SchBasePoint basePoint = pointService.getById(deviceCode); |
|
|
|
String configCode = basePoint.getRegion_code() + "QZRKTask"; |
|
|
|
RLock lock = redissonClient.getLock(configCode); |
|
|
|
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS); |
|
|
|
try { |
|
|
|
if (tryLock) { |
|
|
|
SchBasePoint basePoint = pointService.getById(deviceCode); |
|
|
|
if (ObjectUtil.isEmpty(basePoint)) { |
|
|
|
throw new BadRequestException("点位错误!"); |
|
|
|
} |
|
|
|
String configCode = basePoint.getRegion_code() + "QZRKTask"; |
|
|
|
// 组织参数
|
|
|
|
param.put("config_code", configCode); |
|
|
|
taskService.apply(param); |
|
|
|
} else { |
|
|
|
throw new BadRequestException("其他设备占用锁,等待结束!"); |
|
|
|
} |
|
|
|
} finally { |
|
|
|
if (tryLock) { |
|
|
@ -350,18 +367,31 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
|
* @return |
|
|
|
* @see org.nl.wms.ext.acs.service.dto.to.wms.ApplyTaskRequest |
|
|
|
*/ |
|
|
|
@SneakyThrows |
|
|
|
public ApplyTaskResponse applyForceTakeFullVehicleInStorage(JSONObject param) { |
|
|
|
// 找到当前的设备
|
|
|
|
String deviceCode = param.getString("device_code"); |
|
|
|
SchBasePoint basePoint = pointService.getById(deviceCode); |
|
|
|
if (ObjectUtil.isEmpty(basePoint)) { |
|
|
|
throw new BadRequestException("点位错误!"); |
|
|
|
} |
|
|
|
String requestNo = param.getString("requestNo"); |
|
|
|
SchBasePoint basePoint = pointService.getById(deviceCode); |
|
|
|
String configCode = basePoint.getRegion_code() + "SLHSTask"; |
|
|
|
// 组织参数
|
|
|
|
param.put("config_code", configCode); |
|
|
|
taskService.apply(param); |
|
|
|
RLock lock = redissonClient.getLock(configCode); |
|
|
|
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS); |
|
|
|
try { |
|
|
|
if (tryLock) { |
|
|
|
if (ObjectUtil.isEmpty(basePoint)) { |
|
|
|
throw new BadRequestException("点位错误!"); |
|
|
|
} |
|
|
|
// 组织参数
|
|
|
|
param.put("config_code", configCode); |
|
|
|
taskService.apply(param); |
|
|
|
} else { |
|
|
|
throw new BadRequestException("其他设备占用锁,等待结束!"); |
|
|
|
} |
|
|
|
} finally { |
|
|
|
if (tryLock) { |
|
|
|
lock.unlock(); |
|
|
|
} |
|
|
|
} |
|
|
|
return ApplyTaskResponse.responseOk(requestNo); |
|
|
|
} |
|
|
|
|
|
|
@ -445,30 +475,32 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
|
return ApplyTaskResponse.responseError(requestNo, "载具编码不能为空!"); |
|
|
|
} |
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
SchBaseVehiclematerialgroup groupInfo = vehiclematerialgroupService.getGroupInfo(baseRequest.getVehicle_code(), |
|
|
|
GroupBindMaterialStatusEnum.UNBOUND.getValue()); |
|
|
|
SchBaseVehiclematerialgroup groupInfo = vehiclematerialgroupService.getOneByVehicleCode( |
|
|
|
baseRequest.getVehicle_code(), GroupBindMaterialStatusEnum.UNBOUND.getValue()); |
|
|
|
String materialId = groupInfo.getMaterial_id(); |
|
|
|
MdBaseMaterial baseMaterial = materialService.getById(materialId); |
|
|
|
BigDecimal materialWeight = ObjectUtil.isNotEmpty(groupInfo.getMaterial_weight()) |
|
|
|
? groupInfo.getMaterial_weight() : BigDecimal.valueOf(0); |
|
|
|
BigDecimal materialQty = ObjectUtil.isNotEmpty(groupInfo.getMaterial_qty()) |
|
|
|
? BigDecimal.valueOf(groupInfo.getMaterial_qty()) : BigDecimal.valueOf(0); |
|
|
|
String singleWeightStr = baseMaterial.getSingle_weight(); |
|
|
|
BigDecimal singleWeight = BigDecimal.valueOf(Double.parseDouble(singleWeightStr)); |
|
|
|
BigDecimal multiply = materialWeight.multiply(singleWeight); |
|
|
|
BigDecimal multiply = materialQty.multiply(singleWeight); |
|
|
|
// 获取工单
|
|
|
|
PdmBdWorkorder workorder = workorderService.getByCode(groupInfo.getWorkorder_code()); |
|
|
|
String extData = workorder.getExt_data(); |
|
|
|
JSONObject object = JSONObject.parseObject(extData); |
|
|
|
CusterVo custer = wmsToMesService.getCusterByNo(object.getString("custer_no")); |
|
|
|
log.info("包装数据:{}", object); |
|
|
|
String custerNo = object.getString("custer_no"); |
|
|
|
String orderNo = object.getString("order_no"); |
|
|
|
// 组合
|
|
|
|
sb.append(baseRequest.getVehicle_code()).append("##") |
|
|
|
.append(baseMaterial.getMaterial_code()).append("##") |
|
|
|
.append(groupInfo.getMaterial_qty()).append("##") |
|
|
|
.append(multiply).append("##") |
|
|
|
.append(DateUtil.format(DateUtil.parse(DateUtil.today()), "yyyy年MM月dd日")).append("##") |
|
|
|
.append(custer.getCUSTER_NAME()).append("##") |
|
|
|
.append(workorder.getProduction_order()).append("##") |
|
|
|
.append(custerNo).append("##") |
|
|
|
.append(orderNo).append("##") |
|
|
|
.append(baseMaterial.getMaterial_name()).append("##") |
|
|
|
.append(baseMaterial.getMaterial_model()); |
|
|
|
.append(baseMaterial.getMaterial_model()).append("**"); |
|
|
|
return ApplyTaskResponse.responseOk(requestNo, sb.toString()); |
|
|
|
} |
|
|
|
|
|
|
|