diff --git a/src/main/java/com/wms/controller/TaskController.java b/src/main/java/com/wms/controller/TaskController.java index 4815c54..a8d4775 100644 --- a/src/main/java/com/wms/controller/TaskController.java +++ b/src/main/java/com/wms/controller/TaskController.java @@ -12,10 +12,7 @@ import com.wms.entity.app.dto.PageDto; import com.wms.entity.app.dto.StockOfGoodsDto; import com.wms.entity.app.dto.extend.StockDetailInfo; import com.wms.entity.app.request.*; -import com.wms.entity.app.vo.BoxPrintData; -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.vo.*; import com.wms.entity.app.wcs.*; import com.wms.entity.table.*; import com.wms.service.*; @@ -165,6 +162,7 @@ public class TaskController { * 工作服务 */ 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() + .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() + .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 stockList = stockService.list(new LambdaQueryWrapper() + .eq(Stock::getVehicleId, vehicleId)); + if (stockList == null || stockList.isEmpty()) { + response.setCode(ResponseCode.OK.getCode()); + response.setMessage("当前箱子无库存。"); + response.setReturnData(Collections.emptyList()); + return convertJsonString(response); + } + // 物料列表 + List goodsRelatedList = stockList.stream().map(Stock::getGoodsRelated).toList(); + List goodsIdList = goodsRelatedList.stream().map(StockDetailInfo::getGoodsId).distinct().toList(); + // 查找工作流 + List workFlows = workFlowService.list(new LambdaQueryWrapper() + .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 needGoodsIdList = workFlows.stream().map(WorkFlow::getGoodsId).distinct().toList(); + List pickingGoodsVoList = new ArrayList<>(); + // 查一下物料信息 + List goodsInfoList = goodsService.list(new LambdaQueryWrapper() + .in(Goods::getGoodsId, needGoodsIdList)); + for (String goodsId : needGoodsIdList) { + PickingGoodsVo pickingGoodsVo = new PickingGoodsVo(); + pickingGoodsVo.setVehicleId(vehicleId); + pickingGoodsVo.setGoodsId(goodsId); + List 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() + .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 eLocationConfigsLast = eLocationConfigLastService.list(new LambdaQueryWrapper() + .eq(ELocationConfigLast::getWorkStation, standId)); + if (eLocationConfigsLast == null || eLocationConfigsLast.isEmpty()) { + logger.error("没有可以打印的标签。"); + response.setCode(ResponseCode.ERROR.getCode()); + response.setMessage("没有可以打印的标签。"); + return convertJsonString(response); + } + List boxPrintDatas = new ArrayList<>(); + for (ELocationConfigLast eLocationConfigLast : eLocationConfigsLast) { + BoxPrintData boxPrintData = new BoxPrintData(); + // 查找电子标签库位 + ETagLocation eTagLocation = etagLocationService.getOne(new LambdaQueryWrapper() + .eq(ETagLocation::getELocationId, eLocationConfigLast.getELocationId()) + .last("limit 1")); + // 获取工作流信息 + List workFlowsLast = workFlowLastService.list(new LambdaQueryWrapper() + .eq(WorkFlowLast::getWorkOrder, eLocationConfigLast.getWorkOrder()) + .eq(WorkFlowLast::getWorkCenter, eLocationConfigLast.getWorkCenter()) + .eq(WorkFlowLast::getWorkStation, eLocationConfigLast.getWorkStation())); + // 查询DBS + KateDBS kateDBS = kateDBSService.getOne(new LambdaQueryWrapper() + .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); + } + } + /** * 请求当前大盒子个数 * diff --git a/src/main/java/com/wms/entity/app/vo/MenuEntity.java b/src/main/java/com/wms/entity/app/vo/MenuEntity.java index c79ceb6..c013bcf 100644 --- a/src/main/java/com/wms/entity/app/vo/MenuEntity.java +++ b/src/main/java/com/wms/entity/app/vo/MenuEntity.java @@ -1,7 +1,12 @@ package com.wms.entity.app.vo; +import lombok.Getter; +import lombok.Setter; + import java.util.List; +@Setter +@Getter public class MenuEntity { /** * 菜单Id @@ -28,43 +33,4 @@ public class MenuEntity { */ private List 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 getChildren() { - return children; - } - - public void setChildren(List children) { - this.children = children; - } } diff --git a/src/main/java/com/wms/entity/app/vo/PickingGoodsVo.java b/src/main/java/com/wms/entity/app/vo/PickingGoodsVo.java new file mode 100644 index 0000000..1d6027c --- /dev/null +++ b/src/main/java/com/wms/entity/app/vo/PickingGoodsVo.java @@ -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; +} diff --git a/src/main/java/com/wms/entity/table/WorkFlowLast.java b/src/main/java/com/wms/entity/table/WorkFlowLast.java new file mode 100644 index 0000000..440ab44 --- /dev/null +++ b/src/main/java/com/wms/entity/table/WorkFlowLast.java @@ -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; +} diff --git a/src/main/java/com/wms/mapper/WorkFlowLastMapper.java b/src/main/java/com/wms/mapper/WorkFlowLastMapper.java new file mode 100644 index 0000000..df0f3d8 --- /dev/null +++ b/src/main/java/com/wms/mapper/WorkFlowLastMapper.java @@ -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 { + +} \ No newline at end of file diff --git a/src/main/java/com/wms/service/WorkFlowLastService.java b/src/main/java/com/wms/service/WorkFlowLastService.java new file mode 100644 index 0000000..b4abea2 --- /dev/null +++ b/src/main/java/com/wms/service/WorkFlowLastService.java @@ -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 { +} diff --git a/src/main/java/com/wms/service/business/serviceImplements/WorkServiceImplements.java b/src/main/java/com/wms/service/business/serviceImplements/WorkServiceImplements.java index 81f2233..a24c15c 100644 --- a/src/main/java/com/wms/service/business/serviceImplements/WorkServiceImplements.java +++ b/src/main/java/com/wms/service/business/serviceImplements/WorkServiceImplements.java @@ -1,10 +1,10 @@ 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.update.LambdaUpdateWrapper; import com.wms.constants.enums.ConfigMapKeyEnum; import com.wms.constants.enums.TaskType; -import com.wms.constants.enums.WmsTaskStatus; import com.wms.entity.app.dto.WorkCenterAndOrderDto; import com.wms.entity.table.*; import com.wms.service.*; @@ -54,6 +54,7 @@ public class WorkServiceImplements implements IWorkService { private final OutsideVehiclesService outsideVehiclesService;// 外部流转箱服务 private final StandService standService;// 站台服务 private final TaskService taskService;// 任务服务 + private final WorkFlowLastService workFlowLastService;// 服务 private final List workCreatingStations = new ArrayList<>();// 当前正在创建任务的站台 private final List workDoingStations = new ArrayList<>();// 当前正在执行任务的站台 private final List workFinishingStations = new ArrayList<>();// 当前正在完成任务的站台 @@ -437,6 +438,9 @@ public class WorkServiceImplements implements IWorkService { List workFlowList = workFlowService.list(new LambdaQueryWrapper() .eq(WorkFlow::getWorkStation, workStation) .eq(WorkFlow::getWorkStatus, 2)); + // 保存,防止标签未打印 + workFlowLastService.remove(new LambdaQueryWrapper().eq(WorkFlowLast::getWorkStation, workStation)); + workFlowLastService.saveBatch(BeanUtil.copyToList(workFlowList, WorkFlowLast.class)); // workSummary列表 List workSummaryList = new ArrayList<>(); for (WorkFlow workFlow : workFlowList) { diff --git a/src/main/java/com/wms/service/serviceImplements/WorkFlowLastServiceImpl.java b/src/main/java/com/wms/service/serviceImplements/WorkFlowLastServiceImpl.java new file mode 100644 index 0000000..cf2c317 --- /dev/null +++ b/src/main/java/com/wms/service/serviceImplements/WorkFlowLastServiceImpl.java @@ -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 implements WorkFlowLastService { +} diff --git a/src/main/java/com/wms/utils/excel/vo/GoodsExcelVo.java b/src/main/java/com/wms/utils/excel/vo/GoodsExcelVo.java index 3498cc7..572099c 100644 --- a/src/main/java/com/wms/utils/excel/vo/GoodsExcelVo.java +++ b/src/main/java/com/wms/utils/excel/vo/GoodsExcelVo.java @@ -146,9 +146,11 @@ public class GoodsExcelVo extends KanbanExcelVo { * @return excel对象 */ public static GoodsExcelVo of(Goods goodsPo) { - GoodsExcelVo tempVo = new GoodsExcelVo(); + GoodsExcelVo tempVo; tempVo = BeanUtil.copyProperties(goodsPo, GoodsExcelVo.class); - tempVo.setKanban(goodsPo.getKanbanList()); + if (goodsPo.getKanbanList() != null && !goodsPo.getKanbanList().isEmpty()) { + tempVo.setKanban(goodsPo.getKanbanList()); + } return tempVo; } } diff --git a/src/main/resources/mapper/WorkFlowLastMapper.xml b/src/main/resources/mapper/WorkFlowLastMapper.xml new file mode 100644 index 0000000..8a7229f --- /dev/null +++ b/src/main/resources/mapper/WorkFlowLastMapper.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file