代码更新:

1. 增加确认后打印标签的功能
2. 备料界面显示配料物料列表的功能
This commit is contained in:
梁州 2024-12-10 16:59:38 +08:00
parent ca6b2fd716
commit 91f3f45015
10 changed files with 369 additions and 46 deletions

View File

@ -12,10 +12,7 @@ import com.wms.entity.app.dto.PageDto;
import com.wms.entity.app.dto.StockOfGoodsDto; import com.wms.entity.app.dto.StockOfGoodsDto;
import com.wms.entity.app.dto.extend.StockDetailInfo; import com.wms.entity.app.dto.extend.StockDetailInfo;
import com.wms.entity.app.request.*; import com.wms.entity.app.request.*;
import com.wms.entity.app.vo.BoxPrintData; import com.wms.entity.app.vo.*;
import com.wms.entity.app.vo.StandPickFinishVo;
import com.wms.entity.app.vo.StandPickVo;
import com.wms.entity.app.vo.TaskVO;
import com.wms.entity.app.wcs.*; import com.wms.entity.app.wcs.*;
import com.wms.entity.table.*; import com.wms.entity.table.*;
import com.wms.service.*; import com.wms.service.*;
@ -165,6 +162,7 @@ public class TaskController {
* 工作服务 * 工作服务
*/ */
private final IWorkService workService; private final IWorkService workService;
private final WorkFlowLastService workFlowLastService;// 服务
/** /**
* 接收入库任务请求 * 接收入库任务请求
@ -1084,6 +1082,109 @@ public class TaskController {
} }
} }
/**
* 获取当前要拣选的物料列表
*
* @param workQuery 查询参数
* @return 生成的vo信息
*/
@PostMapping("/getWorkGoodsList")
@ResponseBody
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
public String getWorkGoodsList(@RequestBody WorkQuery workQuery) {
ResponseEntity response = new ResponseEntity();
try {
// 没有传入站台号
if (StringUtils.isEmpty(workQuery.getStandId())) {
response.setCode(ResponseCode.ERROR.getCode());
response.setMessage("站台号不允许为空。");
response.setReturnData(Collections.emptyList());
return convertJsonString(response);
}
Stand targetStand;
if (StringUtils.isNotEmpty(workQuery.getStandId())) {
// 站台号从请求参数中获取
targetStand = standService.getById(workQuery.getStandId());
} else {
// 站台号从ip获取
targetStand = standService.getOne(new LambdaQueryWrapper<Stand>()
.eq(Stand::getStandIp, HttpUtils.getIpAddr(servletRequest))
.eq(Stand::getStandType, 2)
.last("limit 1"));
}
if (targetStand == null) {
response.setCode(ResponseCode.ERROR.getCode());
response.setMessage("查询拣选站台错误。");
return convertJsonString(response);
}
// 查找当前站台已到达的拣选任务
PickTask pickTask = pickTaskService.getOne(new LambdaQueryWrapper<PickTask>()
.eq(PickTask::getStandId, targetStand.getStandId())
.eq(PickTask::getPickStatus, PickTaskStatusEnum.FINISH.getCode())
.last("limit 1"));
if (pickTask == null) {
response.setCode(ResponseCode.OK.getCode());
response.setMessage("没有待拣选的箱子。");
response.setReturnData(Collections.emptyList());
return convertJsonString(response);
}
// 当前箱子里面的物料种类是不是当前站台的工作流所需要的
String vehicleId = pickTask.getVehicleId();
// 查找库存信息
List<Stock> stockList = stockService.list(new LambdaQueryWrapper<Stock>()
.eq(Stock::getVehicleId, vehicleId));
if (stockList == null || stockList.isEmpty()) {
response.setCode(ResponseCode.OK.getCode());
response.setMessage("当前箱子无库存。");
response.setReturnData(Collections.emptyList());
return convertJsonString(response);
}
// 物料列表
List<StockDetailInfo> goodsRelatedList = stockList.stream().map(Stock::getGoodsRelated).toList();
List<String> goodsIdList = goodsRelatedList.stream().map(StockDetailInfo::getGoodsId).distinct().toList();
// 查找工作流
List<WorkFlow> workFlows = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
.eq(WorkFlow::getWorkStation, targetStand.getStandId())
.in(WorkFlow::getGoodsId, goodsIdList)
.eq(WorkFlow::getWorkStatus, 1)
.ne(WorkFlow::getLightStatus, 2)
.apply("picked_num < need_num")
.orderByDesc(WorkFlow::getLightStatus));
if (workFlows == null || workFlows.isEmpty()) {
response.setCode(ResponseCode.OK.getCode());
response.setMessage("当前箱子物料都不使用。");
response.setReturnData(Collections.emptyList());
return convertJsonString(response);
}
List<String> needGoodsIdList = workFlows.stream().map(WorkFlow::getGoodsId).distinct().toList();
List<PickingGoodsVo> pickingGoodsVoList = new ArrayList<>();
// 查一下物料信息
List<Goods> goodsInfoList = goodsService.list(new LambdaQueryWrapper<Goods>()
.in(Goods::getGoodsId, needGoodsIdList));
for (String goodsId : needGoodsIdList) {
PickingGoodsVo pickingGoodsVo = new PickingGoodsVo();
pickingGoodsVo.setVehicleId(vehicleId);
pickingGoodsVo.setGoodsId(goodsId);
List<Goods> goodsList = goodsInfoList.stream().filter(goods -> goods.getGoodsId().equals(goodsId)).toList();
if (!goodsList.isEmpty()) {
pickingGoodsVo.setGoodsName(goodsList.get(0).getGoodsName());
}
pickingGoodsVoList.add(pickingGoodsVo);
}
response.setCode(ResponseCode.OK.getCode());
response.setMessage("查询成功。");
response.setReturnData(pickingGoodsVoList);
return convertJsonString(response);
} catch (Exception e) {
// 回滚事务
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
response.setCode(ResponseCode.ERROR.getCode());
response.setMessage("查询待拣物料异常");
return convertJsonString(response);
}
}
/** /**
* 查询当前站台的正在拣选的物料是否完成 * 查询当前站台的正在拣选的物料是否完成
* *
@ -2297,6 +2398,97 @@ public class TaskController {
} }
} }
/**
* 请求打印标签的数据已经确认过的
*
* @param printRequest 请求信息
* @return 结果
*/
@PostMapping("/requestOldPrintData")
@ResponseBody
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
@MyLog(logTitle = "请求打印标签的数据(确认过)", logMethod = "requestPrintData")
public String requestOldPrintData(@RequestBody PrintRequest printRequest) {
logger.info("请求打印标签的数据(确认过):{}ip地址{}", convertJsonString(printRequest), HttpUtils.getIpAddr(servletRequest));
ResponseEntity response = new ResponseEntity();
try {
// 获取站台号
String standId = "";
if (StringUtils.isNotEmpty(printRequest.getStandId())) {
// 站台号从请求参数中获取
standId = printRequest.getStandId();
} else {
// 站台号从ip获取
Stand standOfIp = standService.getOne(new LambdaQueryWrapper<Stand>()
.eq(Stand::getStandIp, HttpUtils.getIpAddr(servletRequest))
.eq(Stand::getStandType, 2)
.last("limit 1"));
if (standOfIp != null && StringUtils.isNotEmpty(standOfIp.getStandId())) {
standId = standOfIp.getStandId();
}
}
if (StringUtils.isEmpty(standId)) {
logger.error("请求参数缺少站台号。");
response.setCode(ResponseCode.ERROR.getCode());
response.setMessage("请求参数缺少站台号。");
return convertJsonString(response);
}
// 根据站台号查找电子标签配置表
List<ELocationConfigLast> eLocationConfigsLast = eLocationConfigLastService.list(new LambdaQueryWrapper<ELocationConfigLast>()
.eq(ELocationConfigLast::getWorkStation, standId));
if (eLocationConfigsLast == null || eLocationConfigsLast.isEmpty()) {
logger.error("没有可以打印的标签。");
response.setCode(ResponseCode.ERROR.getCode());
response.setMessage("没有可以打印的标签。");
return convertJsonString(response);
}
List<BoxPrintData> boxPrintDatas = new ArrayList<>();
for (ELocationConfigLast eLocationConfigLast : eLocationConfigsLast) {
BoxPrintData boxPrintData = new BoxPrintData();
// 查找电子标签库位
ETagLocation eTagLocation = etagLocationService.getOne(new LambdaQueryWrapper<ETagLocation>()
.eq(ETagLocation::getELocationId, eLocationConfigLast.getELocationId())
.last("limit 1"));
// 获取工作流信息
List<WorkFlowLast> workFlowsLast = workFlowLastService.list(new LambdaQueryWrapper<WorkFlowLast>()
.eq(WorkFlowLast::getWorkOrder, eLocationConfigLast.getWorkOrder())
.eq(WorkFlowLast::getWorkCenter, eLocationConfigLast.getWorkCenter())
.eq(WorkFlowLast::getWorkStation, eLocationConfigLast.getWorkStation()));
// 查询DBS
KateDBS kateDBS = kateDBSService.getOne(new LambdaQueryWrapper<KateDBS>()
.eq(KateDBS::getWorkOrder, eLocationConfigLast.getWorkOrder())
.last("limit 1"));
if (eTagLocation == null || workFlowsLast == null || workFlowsLast.isEmpty() || kateDBS == null) {
// 存在数据异常跳过
continue;
}
// 开始设定标签信息
boxPrintData.setSequenceNo(eTagLocation.getSequenceId());
boxPrintData.setMachineNo(kateDBS.getMachineNo());
boxPrintData.setSmallWorkCenter(eLocationConfigLast.getWorkCenter());
boxPrintData.setWorkOrder(eLocationConfigLast.getWorkOrder());
boxPrintData.setGoodsCount(workFlowsLast.stream().map(WorkFlowLast::getGoodsId).distinct().toList().size());
boxPrintData.setGoodsNumCount(workFlowsLast.stream().map(WorkFlowLast::getPickedNum).reduce(BigDecimal.ZERO, BigDecimal::add));
boxPrintData.setOpTime(workFlowsLast.get(0).getFinishTime());
boxPrintData.setOpUser(workFlowsLast.get(0).getOpUser());
boxPrintDatas.add(boxPrintData);
}
logger.info("获取打印标签成功(确认过)。");
response.setCode(ResponseCode.OK.getCode());
response.setMessage("获取打印标签成功(确认过)。");
response.setReturnData(boxPrintDatas);
return convertJsonString(response);
} catch (Exception e) {
// 回滚事务
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
logger.error("获取打印标签(确认过)异常,{}", convertJsonString(e));
response.setCode(ResponseCode.ERROR.getCode());
response.setMessage("获取打印标签(确认过)异常。");
return convertJsonString(response);
}
}
/** /**
* 请求当前大盒子个数 * 请求当前大盒子个数
* *

View File

@ -1,7 +1,12 @@
package com.wms.entity.app.vo; package com.wms.entity.app.vo;
import lombok.Getter;
import lombok.Setter;
import java.util.List; import java.util.List;
@Setter
@Getter
public class MenuEntity { public class MenuEntity {
/** /**
* 菜单Id * 菜单Id
@ -28,43 +33,4 @@ public class MenuEntity {
*/ */
private List<MenuEntity> children; private List<MenuEntity> children;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLabelName() {
return labelName;
}
public void setLabelName(String labelName) {
this.labelName = labelName;
}
public String getIconValue() {
return iconValue;
}
public void setIconValue(String iconValue) {
this.iconValue = iconValue;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public List<MenuEntity> getChildren() {
return children;
}
public void setChildren(List<MenuEntity> children) {
this.children = children;
}
} }

View File

@ -0,0 +1,23 @@
package com.wms.entity.app.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class PickingGoodsVo {
/**
* 箱号
*/
@JsonProperty("vehicleId")
private String vehicleId;
/**
* 料号
*/
@JsonProperty("goodsId")
private String goodsId;
/**
* 料名
*/
@JsonProperty("goodsName")
private String goodsName;
}

View File

@ -0,0 +1,88 @@
package com.wms.entity.table;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 工作站台-工单-工位的工作流
*/
@Data
@TableName(value = "tbl_app_work_flow_last", autoResultMap = true)
public class WorkFlowLast {
/**
* id
*/
@TableId("work_flow_id")
private String workFlowId;
/**
* 外键工单表id
*/
@TableField("order_id")
private String orderId;
/**
* 工作站台
*/
@TableField("work_station")
private String workStation;
/**
* 工单
*/
@TableField("work_order")
private String workOrder;
/**
* 工位
*/
@TableField("work_center")
private String workCenter;
/**
* 物料编号
*/
@TableField("goods_id")
private String goodsId;
/**
* 已拣货数量
*/
@TableField("picked_num")
private BigDecimal pickedNum;
/**
* 需求数量
*/
@TableField("need_num")
private BigDecimal needNum;
/**
* 亮灯状态
* 0未亮灯
* 1已亮灯
* 2已拍灯
*/
@TableField("light_status")
private Integer lightStatus;
/**
* 工作状态
* 0未开始
* 1正在做
* 2已完成
*/
@TableField("work_status")
private Integer workStatus;
/**
* 任务创建时间
*/
@TableField("create_time")
private LocalDateTime createTime;
/**
* 任务完成时间
*/
@TableField("finish_time")
private LocalDateTime finishTime;
/**
* 操作人员
*/
@TableField("op_user")
private String opUser;
}

View File

@ -0,0 +1,14 @@
package com.wms.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wms.entity.table.WorkFlow;
import com.wms.entity.table.WorkFlowLast;
import org.apache.ibatis.annotations.Mapper;
/**
* 上次工作流mapper
*/
@Mapper
public interface WorkFlowLastMapper extends BaseMapper<WorkFlowLast> {
}

View File

@ -0,0 +1,11 @@
package com.wms.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wms.entity.table.WorkFlow;
import com.wms.entity.table.WorkFlowLast;
/**
* 工作流服务接口
*/
public interface WorkFlowLastService extends IService<WorkFlowLast> {
}

View File

@ -1,10 +1,10 @@
package com.wms.service.business.serviceImplements; package com.wms.service.business.serviceImplements;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.wms.constants.enums.ConfigMapKeyEnum; import com.wms.constants.enums.ConfigMapKeyEnum;
import com.wms.constants.enums.TaskType; import com.wms.constants.enums.TaskType;
import com.wms.constants.enums.WmsTaskStatus;
import com.wms.entity.app.dto.WorkCenterAndOrderDto; import com.wms.entity.app.dto.WorkCenterAndOrderDto;
import com.wms.entity.table.*; import com.wms.entity.table.*;
import com.wms.service.*; import com.wms.service.*;
@ -54,6 +54,7 @@ public class WorkServiceImplements implements IWorkService {
private final OutsideVehiclesService outsideVehiclesService;// 外部流转箱服务 private final OutsideVehiclesService outsideVehiclesService;// 外部流转箱服务
private final StandService standService;// 站台服务 private final StandService standService;// 站台服务
private final TaskService taskService;// 任务服务 private final TaskService taskService;// 任务服务
private final WorkFlowLastService workFlowLastService;// 服务
private final List<String> workCreatingStations = new ArrayList<>();// 当前正在创建任务的站台 private final List<String> workCreatingStations = new ArrayList<>();// 当前正在创建任务的站台
private final List<String> workDoingStations = new ArrayList<>();// 当前正在执行任务的站台 private final List<String> workDoingStations = new ArrayList<>();// 当前正在执行任务的站台
private final List<String> workFinishingStations = new ArrayList<>();// 当前正在完成任务的站台 private final List<String> workFinishingStations = new ArrayList<>();// 当前正在完成任务的站台
@ -437,6 +438,9 @@ public class WorkServiceImplements implements IWorkService {
List<WorkFlow> workFlowList = workFlowService.list(new LambdaQueryWrapper<WorkFlow>() List<WorkFlow> workFlowList = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
.eq(WorkFlow::getWorkStation, workStation) .eq(WorkFlow::getWorkStation, workStation)
.eq(WorkFlow::getWorkStatus, 2)); .eq(WorkFlow::getWorkStatus, 2));
// 保存防止标签未打印
workFlowLastService.remove(new LambdaQueryWrapper<WorkFlowLast>().eq(WorkFlowLast::getWorkStation, workStation));
workFlowLastService.saveBatch(BeanUtil.copyToList(workFlowList, WorkFlowLast.class));
// workSummary列表 // workSummary列表
List<WorkSummary> workSummaryList = new ArrayList<>(); List<WorkSummary> workSummaryList = new ArrayList<>();
for (WorkFlow workFlow : workFlowList) { for (WorkFlow workFlow : workFlowList) {

View File

@ -0,0 +1,17 @@
package com.wms.service.serviceImplements;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wms.entity.table.WorkFlowLast;
import com.wms.mapper.WorkFlowLastMapper;
import com.wms.service.WorkFlowLastService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 工作流服务实现
*/
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class WorkFlowLastServiceImpl extends ServiceImpl<WorkFlowLastMapper, WorkFlowLast> implements WorkFlowLastService {
}

View File

@ -146,9 +146,11 @@ public class GoodsExcelVo extends KanbanExcelVo {
* @return excel对象 * @return excel对象
*/ */
public static GoodsExcelVo of(Goods goodsPo) { public static GoodsExcelVo of(Goods goodsPo) {
GoodsExcelVo tempVo = new GoodsExcelVo(); GoodsExcelVo tempVo;
tempVo = BeanUtil.copyProperties(goodsPo, GoodsExcelVo.class); tempVo = BeanUtil.copyProperties(goodsPo, GoodsExcelVo.class);
tempVo.setKanban(goodsPo.getKanbanList()); if (goodsPo.getKanbanList() != null && !goodsPo.getKanbanList().isEmpty()) {
tempVo.setKanban(goodsPo.getKanbanList());
}
return tempVo; return tempVo;
} }
} }

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wms.mapper.WorkFlowLastMapper">
</mapper>