add:配盘呼叫功能
This commit is contained in:
@@ -4,6 +4,7 @@ import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import org.nl.common.base.ResponseData;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.wms.pm_manage.demand.service.IPlatingDemandService;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PlatingCallParam;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PlatingDemandCompleteParam;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -36,4 +37,18 @@ public class PdaPlatingDemandController {
|
||||
platingDemandService.complete(id, param);
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@GetMapping("/call")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> callList(@RequestParam String loadPort) {
|
||||
return ResponseData.build(platingDemandService.callList(loadPort), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/call/{palletCode}")
|
||||
@SaIgnore
|
||||
@Log("PDA下发配盘呼叫任务")
|
||||
public ResponseEntity<Object> call(@PathVariable String palletCode, @RequestBody PlatingCallParam param) {
|
||||
platingDemandService.call(param.getLoadPort(), palletCode);
|
||||
return ResponseData.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.nl.wms.pm_manage.demand.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PlatingDemandCompleteParam;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PlatingCallDto;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PlatingDemandDto;
|
||||
|
||||
import java.util.List;
|
||||
@@ -14,4 +15,6 @@ public interface IPlatingDemandService {
|
||||
List<PlatingDemandDto> unfinished();
|
||||
PlatingDemandDto detail(String id);
|
||||
void complete(String id, PlatingDemandCompleteParam param);
|
||||
List<PlatingCallDto> callList(String loadPort);
|
||||
void call(String loadPort, String palletCode);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.nl.wms.pm_manage.demand.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PlatingCallDto {
|
||||
private String palletCode;
|
||||
private String startPointCode;
|
||||
private boolean calling;
|
||||
private List<Item> items;
|
||||
|
||||
@Data
|
||||
public static class Item {
|
||||
private String materialCode;
|
||||
private String materialName;
|
||||
private BigDecimal qty;
|
||||
private String unit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package org.nl.wms.pm_manage.demand.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PlatingCallParam {
|
||||
private String loadPort;
|
||||
}
|
||||
@@ -22,9 +22,14 @@ import org.nl.wms.pm_manage.demand.service.dao.PmPlatingDemandItem;
|
||||
import org.nl.wms.pm_manage.demand.service.dao.mapper.PmPlatingDemandItemMapper;
|
||||
import org.nl.wms.pm_manage.demand.service.dao.mapper.PmPlatingDemandMapper;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PlatingDemandCompleteParam;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PlatingCallDto;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PlatingDemandDto;
|
||||
import org.nl.wms.sch_manage.enums.TaskStatus;
|
||||
import org.nl.wms.sch_manage.service.ISchBasePointService;
|
||||
import org.nl.wms.sch_manage.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch_manage.service.core.tasks.PlatingCallTask;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBasePoint;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBaseTask;
|
||||
import org.nl.wms.warehouse_manage.enums.IOSEnum;
|
||||
import org.nl.wms.warehouse_manage.inAndOut.service.dao.IOStorInv;
|
||||
import org.nl.wms.warehouse_manage.inAndOut.service.dao.IOStorInvDis;
|
||||
@@ -84,6 +89,10 @@ public class PlatingDemandServiceImpl implements IPlatingDemandService {
|
||||
private IMdPbStoragevehicleinfoService storagevehicleinfoService;
|
||||
@Resource
|
||||
private ISchBasePointService pointService;
|
||||
@Resource
|
||||
private ISchBaseTaskService taskService;
|
||||
@Resource
|
||||
private PlatingCallTask platingCallTask;
|
||||
|
||||
@Override
|
||||
public List<PlatingDemandDto> preview(List<String> workOrderCodes) {
|
||||
@@ -292,6 +301,101 @@ public class PlatingDemandServiceImpl implements IPlatingDemandService {
|
||||
demandMapper.update(null, update);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlatingCallDto> callList(String loadPort) {
|
||||
String port = requireText(loadPort, "请扫描上料口点位");
|
||||
if (pointService.getById(port) == null) throw new BadRequestException("上料口点位不存在:" + port);
|
||||
List<GroupPlate> plates = groupplateService.list(new LambdaQueryWrapper<GroupPlate>()
|
||||
.eq(GroupPlate::getLoad_port, port)
|
||||
.eq(GroupPlate::getStatus, GROUP_PLATE_STATUS.code("出库"))
|
||||
.orderByAsc(GroupPlate::getStoragevehicle_code)
|
||||
.orderByAsc(GroupPlate::getCreate_time));
|
||||
if (plates.isEmpty()) return Collections.emptyList();
|
||||
|
||||
Set<String> palletCodes = plates.stream().map(GroupPlate::getStoragevehicle_code).collect(Collectors.toSet());
|
||||
Map<String, String> pointByPallet = pointService.list(new LambdaQueryWrapper<SchBasePoint>()
|
||||
.in(SchBasePoint::getVehicle_code, palletCodes)).stream()
|
||||
.collect(Collectors.toMap(SchBasePoint::getVehicle_code, SchBasePoint::getPoint_code, (first, second) -> first));
|
||||
Set<String> callingPallets = taskService.list(new LambdaQueryWrapper<SchBaseTask>()
|
||||
.eq(SchBaseTask::getConfig_code, "PlatingCallTask")
|
||||
.in(SchBaseTask::getTask_status, Arrays.asList(
|
||||
TaskStatus.CREATE.getCode(), TaskStatus.APPLY.getCode(), TaskStatus.CREATED.getCode(),
|
||||
TaskStatus.ISSUED.getCode(), TaskStatus.EXECUTING.getCode()))
|
||||
.in(SchBaseTask::getVehicle_code, palletCodes)).stream()
|
||||
.map(SchBaseTask::getVehicle_code).collect(Collectors.toSet());
|
||||
Set<String> materialCodes = plates.stream().map(GroupPlate::getMaterial_code).collect(Collectors.toSet());
|
||||
Map<String, MdMeMaterialbase> materials = materialService.list(new LambdaQueryWrapper<MdMeMaterialbase>()
|
||||
.in(MdMeMaterialbase::getMaterial_code, materialCodes)).stream()
|
||||
.collect(Collectors.toMap(MdMeMaterialbase::getMaterial_code, Function.identity(), (first, second) -> first));
|
||||
|
||||
List<PlatingCallDto> result = new ArrayList<>();
|
||||
for (Map.Entry<String, List<GroupPlate>> entry : plates.stream().collect(Collectors.groupingBy(
|
||||
GroupPlate::getStoragevehicle_code, LinkedHashMap::new, Collectors.toList())).entrySet()) {
|
||||
PlatingCallDto dto = new PlatingCallDto();
|
||||
dto.setPalletCode(entry.getKey());
|
||||
dto.setStartPointCode(pointByPallet.get(entry.getKey()));
|
||||
dto.setCalling(callingPallets.contains(entry.getKey()));
|
||||
dto.setItems(entry.getValue().stream().map(plate -> {
|
||||
PlatingCallDto.Item item = new PlatingCallDto.Item();
|
||||
MdMeMaterialbase material = materials.get(plate.getMaterial_code());
|
||||
item.setMaterialCode(plate.getMaterial_code());
|
||||
item.setMaterialName(material == null ? null : material.getMaterial_name());
|
||||
item.setQty(plate.getQty());
|
||||
item.setUnit(plate.getQty_unit_name());
|
||||
return item;
|
||||
}).collect(Collectors.toList()));
|
||||
result.add(dto);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void call(String loadPort, String palletCode) {
|
||||
String port = requireText(loadPort, "请扫描上料口点位");
|
||||
String pallet = requireText(palletCode, "托盘编码不能为空");
|
||||
List<SchBasePoint> lockedPoints = pointService.list(new LambdaQueryWrapper<SchBasePoint>()
|
||||
.and(q -> q.eq(SchBasePoint::getPoint_code, port).or().eq(SchBasePoint::getVehicle_code, pallet))
|
||||
.orderByAsc(SchBasePoint::getPoint_code).last("for update"));
|
||||
SchBasePoint destination = lockedPoints.stream().filter(p -> port.equals(p.getPoint_code())).findFirst().orElse(null);
|
||||
if (destination == null) throw new BadRequestException("上料口点位不存在:" + port);
|
||||
if (destination.getVehicle_code() != null && !destination.getVehicle_code().trim().isEmpty())
|
||||
throw new BadRequestException("上料口点位已有托盘:" + destination.getVehicle_code());
|
||||
List<SchBasePoint> starts = lockedPoints.stream().filter(p -> pallet.equals(p.getVehicle_code())).collect(Collectors.toList());
|
||||
if (starts.size() > 1) throw new BadRequestException("托盘绑定多个点位,请先核实:" + pallet);
|
||||
SchBasePoint start = starts.isEmpty() ? null : starts.get(0);
|
||||
if (start == null) throw new BadRequestException("未找到托盘所在点位:" + pallet);
|
||||
if (Objects.equals(start.getPoint_code(), port)) throw new BadRequestException("托盘已在当前上料口点位");
|
||||
List<GroupPlate> plates = groupplateService.list(new LambdaQueryWrapper<GroupPlate>()
|
||||
.eq(GroupPlate::getStoragevehicle_code, pallet).last("for update"));
|
||||
if (plates.isEmpty())
|
||||
throw new BadRequestException("该托盘没有当前上料口的出库组盘数据");
|
||||
if (plates.stream().anyMatch(p -> !port.equals(p.getLoad_port()) || !GROUP_PLATE_STATUS.code("出库").equals(p.getStatus())))
|
||||
throw new BadRequestException("托盘包含其他上料口或非出库状态的组盘,请先核实");
|
||||
if (!taskService.list(new LambdaQueryWrapper<SchBaseTask>()
|
||||
.and(q -> q.eq(SchBaseTask::getVehicle_code, pallet)
|
||||
.or().in(SchBaseTask::getPoint_code1, Arrays.asList(start.getPoint_code(), port))
|
||||
.or().in(SchBaseTask::getPoint_code2, Arrays.asList(start.getPoint_code(), port)))
|
||||
.in(SchBaseTask::getTask_status, Arrays.asList(
|
||||
TaskStatus.CREATE.getCode(), TaskStatus.APPLY.getCode(), TaskStatus.CREATED.getCode(),
|
||||
TaskStatus.ISSUED.getCode(), TaskStatus.EXECUTING.getCode())).last("for update")).isEmpty())
|
||||
throw new BadRequestException("托盘或起终点已有未完成搬运任务");
|
||||
|
||||
JSONObject task = new JSONObject();
|
||||
task.put("config_code", "PlatingCallTask");
|
||||
task.put("point_code1", start.getPoint_code());
|
||||
task.put("point_code2", port);
|
||||
task.put("vehicle_code", pallet);
|
||||
task.put("Priority", "1");
|
||||
task.put("groupIds", plates.stream().map(GroupPlate::getGroup_id).collect(Collectors.toList()));
|
||||
platingCallTask.create(task);
|
||||
}
|
||||
|
||||
private String requireText(String value, String message) {
|
||||
if (value == null || value.trim().isEmpty()) throw new BadRequestException(message);
|
||||
return value.trim();
|
||||
}
|
||||
|
||||
private void saveOutbound(PmPlatingDemand demand, Map<PmPlatingDemandItem, BigDecimal> allocations, Structattr struct, String palletCode) {
|
||||
List<PmPlatingDemandItem> items = new ArrayList<>(allocations.keySet());
|
||||
Map<String, MdMeMaterialbase> materials = materialService.list(new LambdaQueryWrapper<MdMeMaterialbase>().in(MdMeMaterialbase::getMaterial_code, items.stream().map(PmPlatingDemandItem::getMaterial_code).collect(Collectors.toList()))).stream().collect(Collectors.toMap(MdMeMaterialbase::getMaterial_code, Function.identity()));
|
||||
|
||||
@@ -31,6 +31,7 @@ public class StructAreaDeliveryAutoTask {
|
||||
@Autowired
|
||||
private ISchBasePointService iSchBasePointService;
|
||||
@Autowired
|
||||
@org.springframework.beans.factory.annotation.Qualifier("Point2PointTask")
|
||||
private Point2PointTask point2PointTask;
|
||||
@Autowired
|
||||
private IMdPbGroupplateService iMdPbGroupplateService;
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package org.nl.wms.sch_manage.service.core.tasks;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.wms.sch_manage.enums.TaskStatus;
|
||||
import org.nl.wms.sch_manage.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch_manage.service.core.TaskType;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBaseTask;
|
||||
import org.nl.wms.warehouse_manage.enums.IOSEnum;
|
||||
import org.nl.wms.warehouse_manage.service.IMdPbGroupplateService;
|
||||
import org.nl.wms.warehouse_manage.service.dao.GroupPlate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Component(value = "PlatingCallTask")
|
||||
@TaskType("PlatingCallTask")
|
||||
public class PlatingCallTask extends Point2PointTask {
|
||||
@Resource
|
||||
private IMdPbGroupplateService groupplateService;
|
||||
@Resource
|
||||
private ISchBaseTaskService callTaskService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String create(JSONObject json) {
|
||||
json.put("config_code", "PlatingCallTask");
|
||||
String id = super.create(json);
|
||||
SchBaseTask task = callTaskService.getById(id);
|
||||
task.setIs_delete(false);
|
||||
callTaskService.updateById(task);
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateTaskStatus(String taskCode, TaskStatus status) {
|
||||
SchBaseTask task = lockTask(taskCode);
|
||||
if (TaskStatus.FINISHED.getCode().equals(task.getTask_status())
|
||||
|| TaskStatus.CANCELED.getCode().equals(task.getTask_status())) return;
|
||||
super.updateTaskStatus(taskCode, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void forceFinish(String taskCode) {
|
||||
finishTask(lockTask(taskCode));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void cancel(String taskCode) {
|
||||
lockTask(taskCode);
|
||||
super.cancel(taskCode);
|
||||
}
|
||||
|
||||
private SchBaseTask lockTask(String taskCode) {
|
||||
SchBaseTask task = callTaskService.getOne(new LambdaQueryWrapper<SchBaseTask>()
|
||||
.eq(SchBaseTask::getTask_code, taskCode)
|
||||
.eq(SchBaseTask::getConfig_code, "PlatingCallTask").last("for update"));
|
||||
if (task == null) throw new BadRequestException("配盘呼叫任务不存在");
|
||||
return task;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void finishTask(SchBaseTask task) {
|
||||
task = lockTask(task.getTask_code());
|
||||
if (TaskStatus.FINISHED.getCode().equals(task.getTask_status())) return;
|
||||
if (TaskStatus.CANCELED.getCode().equals(task.getTask_status()))
|
||||
throw new BadRequestException("已取消的任务不能完成");
|
||||
List<String> groupIds = JSONObject.parseObject(task.getRequest_param()).getJSONArray("groupIds").toJavaList(String.class);
|
||||
if (groupIds.isEmpty()) throw new BadRequestException("配盘呼叫任务缺少组盘明细");
|
||||
super.finishTask(task);
|
||||
groupplateService.remove(new LambdaQueryWrapper<GroupPlate>()
|
||||
.in(GroupPlate::getGroup_id, groupIds)
|
||||
.eq(GroupPlate::getStoragevehicle_code, task.getVehicle_code())
|
||||
.eq(GroupPlate::getLoad_port, task.getPoint_code2())
|
||||
.eq(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("出库")));
|
||||
}
|
||||
}
|
||||
@@ -86,6 +86,7 @@ public class Point2PointTask extends AbstractTask {
|
||||
acsTaskDto.setTask_code(taskDao.getTask_code());
|
||||
acsTaskDto.setStart_device_code(taskDao.getPoint_code1());
|
||||
acsTaskDto.setNext_device_code(taskDao.getPoint_code2());
|
||||
acsTaskDto.setVehicle_code(taskDao.getVehicle_code());
|
||||
acsTaskDto.setPriority(taskDao.getPriority());
|
||||
acsTaskDto.setTask_type("1");
|
||||
return acsTaskDto;
|
||||
|
||||
Reference in New Issue
Block a user