|
|
@ -5,6 +5,7 @@ import cn.hutool.core.util.IdUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import cn.hutool.http.HttpStatus; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import lombok.SneakyThrows; |
|
|
@ -50,6 +51,7 @@ import org.nl.wms.sch.task_manage.enums.PointStatusEnum; |
|
|
|
import org.nl.wms.sch.task_manage.enums.WorkOrderStatusEnum; |
|
|
|
import org.nl.wms.sch.task_manage.task.TaskFactory; |
|
|
|
import org.nl.wms.sch.task_manage.task.core.TaskStatus; |
|
|
|
import org.nl.wms.sch.task_manage.task.tasks.fj.mapper.FJMapper; |
|
|
|
import org.nl.wms.util.CommonUtils; |
|
|
|
import org.nl.wms.util.PointUtils; |
|
|
|
import org.nl.wms.util.TaskUtils; |
|
|
@ -63,6 +65,7 @@ import javax.annotation.PostConstruct; |
|
|
|
import java.lang.reflect.InvocationTargetException; |
|
|
|
import java.lang.reflect.Method; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
@ -115,6 +118,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
|
private WmsToMesService wmsToMesService; |
|
|
|
@Autowired |
|
|
|
private WmsToMmsService wmsToMmsService; |
|
|
|
@Autowired |
|
|
|
private FJMapper fjMapper; |
|
|
|
|
|
|
|
// 初始化反射方法
|
|
|
|
@PostConstruct |
|
|
@ -169,7 +174,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
|
String deviceCode = param.getString("device_code"); |
|
|
|
String requestNo = param.getString("requestNo"); |
|
|
|
RLock lock = redissonClient.getLock(deviceCode); |
|
|
|
boolean tryLock = lock.tryLock(5, TimeUnit.SECONDS); |
|
|
|
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS); |
|
|
|
try { |
|
|
|
if (tryLock) { |
|
|
|
SchBasePoint basePoint = pointService.getById(deviceCode); |
|
|
@ -203,7 +208,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
|
String deviceCode = param.getString("device_code"); |
|
|
|
String requestNo = param.getString("requestNo"); |
|
|
|
RLock lock = redissonClient.getLock(deviceCode); |
|
|
|
boolean tryLock = lock.tryLock(5, TimeUnit.SECONDS); |
|
|
|
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS); |
|
|
|
try { |
|
|
|
if (tryLock) { |
|
|
|
SchBasePoint basePoint = pointService.getById(deviceCode); |
|
|
@ -237,7 +242,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
|
String deviceCode = param.getString("device_code"); |
|
|
|
String requestNo = param.getString("requestNo"); |
|
|
|
RLock lock = redissonClient.getLock(deviceCode); |
|
|
|
boolean tryLock = lock.tryLock(5, TimeUnit.SECONDS); |
|
|
|
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS); |
|
|
|
try { |
|
|
|
if (tryLock) { |
|
|
|
SchBasePoint basePoint = pointService.getById(deviceCode); |
|
|
@ -271,7 +276,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
|
String deviceCode = param.getString("device_code"); |
|
|
|
String requestNo = param.getString("requestNo"); |
|
|
|
RLock lock = redissonClient.getLock(deviceCode); |
|
|
|
boolean tryLock = lock.tryLock(5, TimeUnit.SECONDS); |
|
|
|
int handling = 0; // 无业务:0
|
|
|
|
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS); |
|
|
|
try { |
|
|
|
if (tryLock) { |
|
|
|
SchBasePoint basePoint = pointService.getById(deviceCode); |
|
|
@ -281,7 +287,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
|
String configCode = basePoint.getRegion_code() + "MLTask"; |
|
|
|
// 组织参数
|
|
|
|
param.put("config_code", configCode); |
|
|
|
param.put("special_param", specialHandling(basePoint.getRegion_code())); |
|
|
|
handling = specialHandling(basePoint.getRegion_code(), param); |
|
|
|
param.put("special_param", handling); |
|
|
|
taskService.apply(param); |
|
|
|
} |
|
|
|
} finally { |
|
|
@ -289,15 +296,37 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
|
lock.unlock(); |
|
|
|
} |
|
|
|
} |
|
|
|
return ApplyTaskResponse.responseOk(requestNo); |
|
|
|
return ApplyTaskResponse.responseOk(requestNo, "任务创建成功", handling); |
|
|
|
} |
|
|
|
|
|
|
|
// todo: 特殊处理
|
|
|
|
protected String specialHandling(String regionCode) { |
|
|
|
if (regionCode.equals("FJ")) { |
|
|
|
protected int specialHandling(String regionCode, JSONObject param) { |
|
|
|
int torus = 0; // 无业务:0, 分拣剩余1托:1,分拣剩余0托:2
|
|
|
|
if (regionCode.equals("FJ")) { // 判断是否够码满
|
|
|
|
// 分拣需要在这设置特殊值
|
|
|
|
} |
|
|
|
return null; |
|
|
|
// 校验是否够码满一托
|
|
|
|
List<ApplyDeviceDto> list = JSONArray.parseArray(param.getString("list"), ApplyDeviceDto.class); |
|
|
|
PdmBdWorkorder workorder = workorderService.getDeviceDockingProductionTask(param.getString("device_code")); |
|
|
|
// 1 获取点位相应数量
|
|
|
|
int sum = 0; |
|
|
|
for (ApplyDeviceDto applyDeviceDto : list) { |
|
|
|
sum += Integer.parseInt(applyDeviceDto.getQty()); |
|
|
|
} |
|
|
|
// 2 获取库存量 surplusNumber
|
|
|
|
int surplusNumber = fjMapper.getInventoryQuantity(workorder.getMaterial_id()); |
|
|
|
// 3 现有总数 total
|
|
|
|
int total = sum + surplusNumber; |
|
|
|
// 4 获取木托盘需要多少块 needFullNumber
|
|
|
|
String needFullNumberStr = fjMapper.getNeedFullNumber(workorder.getMaterial_id()); |
|
|
|
int needFullNumber = TaskUtils.convertMultiply(needFullNumberStr); |
|
|
|
int surplus = total / needFullNumber; |
|
|
|
if (surplus == 1) { |
|
|
|
return 1; |
|
|
|
} else if (surplus == 0) { |
|
|
|
return 2; |
|
|
|
} |
|
|
|
} |
|
|
|
return torus; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|