|
@@ -266,7 +266,7 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
|
|
|
// 任务状态: 队列等待 直接删除即可 其他状态 需要请求AMS删除
|
|
|
if (wcsTask.getState() == Constant.TASK_STS.TASK9.getValue().longValue()
|
|
|
|| wcsTask.getState() == Constant.TASK_STS.TASK10.getValue().longValue()) {
|
|
|
- callBack(wcsTask.getTaskNo(), 7, null);
|
|
|
+ return callBack(wcsTask.getTaskNo(), 7, null);
|
|
|
} else {
|
|
|
//请求ams 取消任务
|
|
|
AmsTask amsTaskQuery = new AmsTask();
|
|
@@ -344,24 +344,24 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
|
|
|
|
|
|
@Transactional
|
|
|
@Override
|
|
|
- public void callBack(String taskNo, Integer state, Integer carNo) {
|
|
|
+ public synchronized AjaxResult callBack(String taskNo, Integer state, Integer carNo) {
|
|
|
String updateBy = "NDC";
|
|
|
log.info("agv回传------------->" + taskNo + "," + state);
|
|
|
WcsTask wcsTask = wcsTaskService.selectWcsTaskByTaskNo(taskNo);
|
|
|
if (wcsTask == null) {
|
|
|
log.info("agv回传没有任务记录------------->");
|
|
|
- return;
|
|
|
+ return AjaxResult.error("agv回传没有任务记录------------->");
|
|
|
}
|
|
|
|
|
|
if (state > 1 && state != 7) {
|
|
|
wcsTask.setAgvNo(carNo + "");
|
|
|
}
|
|
|
|
|
|
- if (wcsTask.getState() == 2 || wcsTask.getState() == 7) {
|
|
|
+ if (wcsTask.getState() == 2) {
|
|
|
log.info("已完成的任务无需反馈");
|
|
|
- return;
|
|
|
+ return AjaxResult.error("已完成的任务无需反馈");
|
|
|
}
|
|
|
- //todo 转发类型任务才回调
|
|
|
+ //转发类型任务才回调
|
|
|
if (wcsTask.getTaskType().equals(Constant.TASK_TYPE.FORWARD.getValue())) {
|
|
|
try {
|
|
|
switch (state) {
|
|
@@ -369,23 +369,27 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
|
|
|
wcsTask.setStartTime(new Date());
|
|
|
break;
|
|
|
case 2://完成
|
|
|
- if (wcsTask.getState() != 6) {
|
|
|
- if (wcsTask.getState() == 2) {
|
|
|
- log.info("不能重复放货," + taskNo);
|
|
|
- return;
|
|
|
- }
|
|
|
- wcsTask.setEndTime(new Date());
|
|
|
- // 解锁终点库位
|
|
|
- baseLocationInfoService.unLockLocationStockStatus(Long.parseLong(wcsTask.getLocationTo())
|
|
|
- , Constant.WAREHOUSE_ID, updateBy);
|
|
|
- // 将中间缓存位库存移动到终点
|
|
|
- moveMiddleCacheToDestination(wcsTask);
|
|
|
- // 修改库存标识标识 因为接驳位可以出库也可以入库 所以需要标识当前接驳位的库存是入库还是出库
|
|
|
-// updateInvAsnSoMarking(wcsTask);
|
|
|
- //释放redis锁
|
|
|
- if (!StringUtils.isEmpty(wcsTask.getExt8())) {
|
|
|
- redisCache.unlockCacheObject(Long.parseLong(wcsTask.getExt8()));
|
|
|
- }
|
|
|
+ if (wcsTask.getState() != 4
|
|
|
+ && (StringUtils.isEmpty(wcsTask.getBeforeTask()) || !wcsTask.getBeforeTask().equals("1"))) {
|
|
|
+ log.info("任务未取货,不能直接完成!" + taskNo);
|
|
|
+ return AjaxResult.error("任务未取货,不能直接完成!" + taskNo);
|
|
|
+ }
|
|
|
+ if (wcsTask.getState() == 2) {
|
|
|
+ log.info("不能重复放货," + taskNo);
|
|
|
+ return AjaxResult.error("不能重复放货," + taskNo);
|
|
|
+ }
|
|
|
+ if (wcsTask.getState() == 6) {
|
|
|
+ return AjaxResult.error("不能重复放货," + taskNo);
|
|
|
+ }
|
|
|
+ wcsTask.setEndTime(new Date());
|
|
|
+ // 解锁终点库位
|
|
|
+ baseLocationInfoService.unLockLocationStockStatus(Long.parseLong(wcsTask.getLocationTo())
|
|
|
+ , Constant.WAREHOUSE_ID, updateBy);
|
|
|
+ // 将中间缓存位库存移动到终点
|
|
|
+ moveMiddleCacheToDestination(wcsTask);
|
|
|
+ //释放redis锁
|
|
|
+ if (!StringUtils.isEmpty(wcsTask.getExt8())) {
|
|
|
+ redisCache.unlockCacheObject(Long.parseLong(wcsTask.getExt8()));
|
|
|
}
|
|
|
break;
|
|
|
case 3:
|
|
@@ -393,8 +397,14 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
|
|
|
case 4:
|
|
|
if (wcsTask.getState() == 4) {
|
|
|
log.info("不能重复取货," + taskNo);
|
|
|
- return;
|
|
|
+ return AjaxResult.error("不能重复取货," + taskNo);
|
|
|
}
|
|
|
+ if (wcsTask.getBeforeTask() != null && wcsTask.getBeforeTask().equals("1")) {
|
|
|
+ log.info("不能重复取货," + taskNo);
|
|
|
+ return AjaxResult.error("不能重复取货," + taskNo);
|
|
|
+ }
|
|
|
+ // 标记已经取货完成
|
|
|
+ wcsTask.setBeforeTask("1");
|
|
|
// 解锁起始库位
|
|
|
baseLocationInfoService.unLockLocationStockStatus(Long.parseLong(wcsTask.getLocationFrom())
|
|
|
, Constant.WAREHOUSE_ID, updateBy);
|
|
@@ -409,23 +419,27 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
|
|
|
case 5:
|
|
|
break;
|
|
|
case 6://卸货
|
|
|
- if (wcsTask.getState() != 2) {
|
|
|
- if (wcsTask.getState() == 6) {
|
|
|
- log.info("不能重复放货," + taskNo);
|
|
|
- return;
|
|
|
- }
|
|
|
- wcsTask.setEndTime(new Date());
|
|
|
- // 解锁终点库位
|
|
|
- baseLocationInfoService.unLockLocationStockStatus(Long.parseLong(wcsTask.getLocationTo())
|
|
|
- , Constant.WAREHOUSE_ID, updateBy);
|
|
|
- // 将中间缓存位库存移动到终点
|
|
|
- moveMiddleCacheToDestination(wcsTask);
|
|
|
- // 修改库存标识标识 因为接驳位可以出库也可以入库 所以需要标识当前接驳位的库存是入库还是出库
|
|
|
-// updateInvAsnSoMarking(wcsTask);
|
|
|
- //释放redis锁
|
|
|
- if (!StringUtils.isEmpty(wcsTask.getExt8())) {
|
|
|
- redisCache.unlockCacheObject(Long.parseLong(wcsTask.getExt8()));
|
|
|
- }
|
|
|
+ if (wcsTask.getState() != 4
|
|
|
+ && (StringUtils.isEmpty(wcsTask.getBeforeTask())|| !wcsTask.getBeforeTask().equals("1"))) {
|
|
|
+ log.info("任务未取货,不能直接完成!" + taskNo);
|
|
|
+ return AjaxResult.error("任务未取货,不能直接完成!" + taskNo);
|
|
|
+ }
|
|
|
+ if (wcsTask.getState() == 2) {
|
|
|
+ log.info("不能重复放货," + taskNo);
|
|
|
+ return AjaxResult.error("不能重复放货," + taskNo);
|
|
|
+ }
|
|
|
+ if (wcsTask.getState() == 6) {
|
|
|
+ return AjaxResult.error("不能重复放货," + taskNo);
|
|
|
+ }
|
|
|
+ wcsTask.setEndTime(new Date());
|
|
|
+ // 解锁终点库位
|
|
|
+ baseLocationInfoService.unLockLocationStockStatus(Long.parseLong(wcsTask.getLocationTo())
|
|
|
+ , Constant.WAREHOUSE_ID, updateBy);
|
|
|
+ // 将中间缓存位库存移动到终点
|
|
|
+ moveMiddleCacheToDestination(wcsTask);
|
|
|
+ //释放redis锁
|
|
|
+ if (!StringUtils.isEmpty(wcsTask.getExt8())) {
|
|
|
+ redisCache.unlockCacheObject(Long.parseLong(wcsTask.getExt8()));
|
|
|
}
|
|
|
break;
|
|
|
case 7://取消
|
|
@@ -468,6 +482,7 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
|
|
|
wcsTask.setState(state.longValue());
|
|
|
wcsTask.setUpdateDate(new Date());
|
|
|
wcsTaskService.updateWcsTask(wcsTask);
|
|
|
+ return AjaxResult.error("操作成功!");
|
|
|
}
|
|
|
|
|
|
/**
|