feat: 装箱区点位清除与空架设置

This commit is contained in:
2024-08-29 10:25:44 +08:00
parent 89947ee04f
commit 0d60b7bd01
6 changed files with 183 additions and 32 deletions

View File

@@ -20,6 +20,7 @@ public enum TagNameEnum {
CUT_UP("手持分切上料"),
CUT_UP_CONFIRM("手持分切确认上料"),
CUT_EMPTY_BACK("手持空轴送回"),
SUB_ROLL_DOWN("手持子卷下线"),
GX_IN("手持管芯入库"),
GX_OUT("手持管芯出库"),
SWITCH_STATUS_OF_LIFT("货梯切换状态"),

View File

@@ -0,0 +1,43 @@
package org.nl.wms.pda.st.controller;
import cn.dev33.satoken.annotation.SaIgnore;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.logging.annotation.Log;
import org.nl.wms.pda.st.service.ZxPdaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Author: lyd
* @Description: 装箱区控制类
* @Date: 2024/8/29
*/
@RestController
@RequestMapping("/api/pda/encasement")
@Slf4j
@SaIgnore
public class ZxPdaController {
@Autowired
private ZxPdaService zxPdaService;
@PostMapping("/setEmptyVehicle")
@Log("装箱区-设置空架子")
public ResponseEntity<Object> setEmptyVehicle(@RequestBody JSONObject param) {
return new ResponseEntity<>(zxPdaService.setEmptyVehicle(param), HttpStatus.OK);
}
@PostMapping("/doClearPoint")
@Log("装箱区-清空点位")
public ResponseEntity<Object> doClearPoint(@RequestBody JSONObject param) {
return new ResponseEntity<>(zxPdaService.doClearPoint(param), HttpStatus.OK);
}
@PostMapping("/getZxPointList")
@Log("装箱区-下拉框")
public ResponseEntity<Object> getZxPointList() {
return new ResponseEntity<>(zxPdaService.getZxPointList(), HttpStatus.OK);
}
}

View File

@@ -0,0 +1,31 @@
package org.nl.wms.pda.st.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
/**
* @Author: lyd
* @Description:
* @Date: 2024/8/29
*/
public interface ZxPdaService {
/**
* 装箱区-设置空架子
* @param param /
* @return /
*/
JSONObject setEmptyVehicle(JSONObject param);
/**
* 清空点位
* @param param /
* @return /
*/
JSONObject doClearPoint(JSONObject param);
/**
* 装箱区-下拉框
* @return
*/
JSONArray getZxPointList();
}

View File

@@ -121,6 +121,7 @@ public class NbjPdaServiceImpl implements NbjPdaService {
@Override
@Transactional(rollbackFor = Exception.class)
public JSONObject doSubVolumeDown(JSONObject param) {
MDC.put(GeneralDefinition.MDC_KEY, TagNameEnum.SUB_ROLL_DOWN.getTag());
log.info("手持子卷下线,送到货梯 - {}", param);
// point_code, vehicle_code, container_name
String pointCode = param.getString("point_code");
@@ -132,7 +133,7 @@ public class NbjPdaServiceImpl implements NbjPdaService {
throw new BadRequestException("该点位已经创建过任务!");
}
SchBasePoint startPoint = pointService.getById(pointCode);
startPoint.setPoint_status("2");
startPoint.setPoint_status("3");
// 子卷号
startPoint.setMaterial_code(containerName);
startPoint.setVehicle_code(vehicleCode);

View File

@@ -0,0 +1,87 @@
package org.nl.wms.pda.st.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.exception.BadRequestException;
import org.nl.wms.pda.st.service.ZxPdaService;
import org.nl.wms.sch.point.service.ISchBasePointService;
import org.nl.wms.sch.point.service.dao.SchBasePoint;
import org.nl.wms.sch.task.service.ISchBaseTaskService;
import org.nl.wms.sch.task.service.dao.SchBaseTask;
import org.nl.wms.sch.task_manage.core.enums.TaskFinishedTypeEnum;
import org.nl.wms.util.PointUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author: lyd
* @Description:
* @Date: 2024/8/29
*/
@Slf4j
@Service
public class ZxPdaServiceImpl implements ZxPdaService {
@Autowired
private ISchBasePointService pointService;
@Autowired
private ISchBaseTaskService taskService;
@Override
public JSONObject setEmptyVehicle(JSONObject param) {
log.info("装箱区-设置空架子: {}", param);
// point_code, vehicle_code
String pointCode = param.getString("point_code");
String vehicleCode = param.getString("vehicle_code");
List<SchBaseTask> schBaseTasks = taskService.checkHaveTask(pointCode);
if (schBaseTasks.size() > 0) {
throw new BadRequestException("点位[" + pointCode + "]存在未完成任务,不能放空架子!");
}
LambdaUpdateWrapper<SchBasePoint> lam = new LambdaUpdateWrapper<>();
lam.set(SchBasePoint::getVehicle_code, vehicleCode)
.set(SchBasePoint::getMaterial_code, "")
.set(SchBasePoint::getPoint_status, "2")
.eq(SchBasePoint::getPoint_code, pointCode);
boolean update = pointService.update(lam);
log.info("更新装箱区点位{} - 设置有空架子 - 更新状态:{}", pointCode, update);
JSONObject result = new JSONObject();
result.put("status", HttpStatus.OK.value());
result.put("message", update ? "更新成功" : "更新失败");
return result;
}
@Override
public JSONObject doClearPoint(JSONObject param) {
log.info("装箱区-清空点位: {}", param);
// point_code
String pointCode = param.getString("point_code");
List<SchBaseTask> schBaseTasks = taskService.checkHaveTask(pointCode);
if (schBaseTasks.size() > 0) {
throw new BadRequestException("点位[" + pointCode + "]存在未完成任务,不能清除!");
}
PointUtils.clearPoint(pointService.getById(pointCode), TaskFinishedTypeEnum.MANUAL_PDA);
JSONObject result = new JSONObject();
result.put("status", HttpStatus.OK.value());
result.put("message", "点位清空成功");
return result;
}
@Override
public JSONArray getZxPointList() {
List<SchBasePoint> zxZcList = pointService.getPointByConditions("A1", "A1-ZXZC",
null, null, null, false);
JSONArray jsonArray = zxZcList.stream()
.map(item -> {
JSONObject jsonObject = new JSONObject();
jsonObject.put("text", item.getPoint_name());
jsonObject.put("value", item.getPoint_code());
return jsonObject;
})
.collect(Collectors.toCollection(JSONArray::new));
return jsonArray;
}
}

View File

@@ -1,5 +1,6 @@
package org.nl.wms.sch.task_manage.tasks.nbj;
import com.alibaba.fastjson.JSONObject;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.exception.BadRequestException;
@@ -12,19 +13,16 @@ import org.nl.wms.sch.task_manage.TaskStatus;
import org.nl.wms.sch.task_manage.core.constant.GeneralDefinition;
import org.nl.wms.sch.task_manage.core.enums.TaskFinishedTypeEnum;
import org.nl.wms.util.TaskUtils;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static org.nl.wms.util.TaskUtils.checkTaskOptionStatus;
import static org.nl.wms.util.TaskUtils.setUpdateByPC;
import static org.nl.wms.util.PointUtils.clearPoint;
import static org.nl.wms.util.PointUtils.setUpdateByType;
import static org.nl.wms.util.TaskUtils.checkTaskOptionStatus;
import static org.nl.wms.util.TaskUtils.setUpdateByPC;
/**
* @Author: lyd
@@ -39,8 +37,6 @@ public class SubRollDownAGVTask extends AbstractTask {
private ISchBaseTaskService taskService;
@Autowired
private ISchBasePointService pointService;
@Autowired
private RedissonClient redissonClient;
@Override
public void create() throws BadRequestException {
@@ -50,43 +46,35 @@ public class SubRollDownAGVTask extends AbstractTask {
@Override
public void createCompletion(SchBaseTask task) {
// update: 查找空位没任务的货梯 -> 查找一楼暂存位空位
List<SchBasePoint> lifts = pointService.getAllBusinessNotTaskPoint("A1", "A1-LIFT-AREA",
"1", "1", null, null);
if (lifts.size() == 0) {
throw new BadRequestException("暂无可用的货梯!");
}
SchBasePoint liftPoint = lifts.get(0);
RLock lock = redissonClient.getLock(liftPoint.getPoint_code());
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
try {
if (tryLock) {
task.setPoint_code2(liftPoint.getPoint_code());
// 创建任务
task.setHandle_class(THIS_CLASS);
task.setTask_status(TaskStatus.START_AND_POINT.getCode());
setUpdateByPC(task);
taskService.save(task);
} else {
throw new BadRequestException("点位编码:" + liftPoint.getPoint_code() + "正在使用中,请重试!");
TaskUtils.createTask("A1-ZXZC", () -> {
List<SchBasePoint> zxPoints = pointService.getAllBusinessNotTaskPoint("A1", "A1-ZXZC",
"1", "1", null, null);
if (zxPoints.size() == 0) {
throw new BadRequestException("暂无可用的装箱暂存位!");
}
} finally {
if (tryLock) {
lock.unlock();
}
}
SchBasePoint zxPoint = zxPoints.get(0);
task.setPoint_code2(zxPoint.getPoint_code());
// 创建任务
task.setHandle_class(THIS_CLASS);
task.setTask_status(TaskStatus.START_AND_POINT.getCode());
setUpdateByPC(task);
taskService.save(task);
});
}
@Override
@Transactional(rollbackFor = Exception.class)
public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) {
checkTaskOptionStatus(taskObj);
JSONObject requestObj = JSONObject.parseObject(taskObj.getRequest_param());
// 起点清空(没有取货完成的业务),终点赋值
String startPointCode = taskObj.getPoint_code1();
String endPointCode = taskObj.getPoint_code2();
SchBasePoint startPoint = pointService.getById(startPointCode);
SchBasePoint endPoint = pointService.getById(endPointCode);
clearPoint(startPoint, taskFinishedType);
endPoint.setPoint_status("2");
endPoint.setPoint_status("3");
endPoint.setMaterial_code(requestObj.getString("container_name"));
endPoint.setVehicle_code(taskObj.getVehicle_code());
setUpdateByType(endPoint, taskFinishedType);
pointService.updateById(endPoint);