| | |
| | |
|
| | | public enum TaskStsType {
|
| | |
|
| | | //任务状态
|
| | | GENERATE_IN(1L, "创建入库任务"),
|
| | | WCS_EXECUTE_IN(2L, "RCS任务已下发"),
|
| | | WCS_CONTAINER_RECEIVE(3L, "RCS容器到达"),
|
| | |
|
| | | WCS_CONVEYOR_START(4L, "RCS容器流动任务已下发"),
|
| | |
|
| | | WCS_TOTE_LOAD(5L, "RCS取箱完成"),
|
| | |
|
| | | WCS_TOTE_UNLOAD(6L, "RCS放箱完成"),
|
| | |
|
| | | WCS_PUTAWAY_SUCESS(7L, "RCS任务完成"),
|
| | |
|
| | | // WCS_PUTAWAY_FAILED(11L, "任务失败"),
|
| | |
| | | */ |
| | | @Override |
| | | public R checkUpdate(QlyIsptItem params) { |
| | | if (Objects.isNull(params.getId()) || Objects.isNull(params.getIspectId())) { |
| | | if (Objects.isNull(params.getId())) { |
| | | throw new CoolException("参数不能为空!!"); |
| | | } |
| | | IsptItemsParams itemsParams = new IsptItemsParams(); |
| | |
| | | @ApiModelProperty(value= "ID") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 主单ID |
| | | */ |
| | | @ApiModelProperty(value= "主单ID") |
| | | private Long ispectId; |
| | | |
| | | @ApiModelProperty("质检单状态") |
| | | private String isptStatus; |
| | | |
| | | @ApiModelProperty("单据明细ID") |
| | | private Long asnItemId; |
| | | |
| | | /** |
| | | * 编号 |
| | | */ |
| | | @ApiModelProperty(value= "编号") |
| | | private String matnrCode; |
| | | |
| | | /** |
| | | * 物料名称 |
| | | */ |
| | | @ApiModelProperty(value= "物料名称") |
| | | private String maktx; |
| | | |
| | | /** |
| | | * 标签 |
| | | */ |
| | | @ApiModelProperty(value= "标签") |
| | | private String label; |
| | | |
| | | /**∂ |
| | | * 供应商名称 |
| | | */ |
| | | @ApiModelProperty(value= "供应商名称") |
| | | private String splrName; |
| | | |
| | | /** |
| | | * 供应商批次 |
| | | */ |
| | | @ApiModelProperty(value= "供应商批次") |
| | | private String splrBatch; |
| | | |
| | | /** |
| | | * 库存批次 |
| | | */ |
| | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.vincent.rsf.server.manager.service.*; |
| | | import lombok.experimental.Accessors; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @Accessors(chain = true) |
| | | @TableName("man_stock_item") |
| | | public class StockItem implements Serializable { |
| | | |
| | |
| | | * 库存外键标识 |
| | | */ |
| | | @ApiModelProperty(value= "库存外键标识") |
| | | private String stockId; |
| | | private Long stockId; |
| | | |
| | | /** |
| | | * 物料标识 |
| | |
| | | * 锁定原因 |
| | | */ |
| | | @ApiModelProperty(value= "锁定原因") |
| | | @TableField(exist = false) |
| | | private String lockReason; |
| | | |
| | | /** |
| | | * 锁定状态 |
| | | */ |
| | | @ApiModelProperty(value= "锁定状态") |
| | | @TableField(exist = false) |
| | | private Short lockStatus; |
| | | |
| | | /** |
| | | * 锁定人 |
| | | */ |
| | | @ApiModelProperty(value= "锁定人") |
| | | @TableField(exist = false) |
| | | private String locker; |
| | | |
| | | /** |
| | | * 锁定时间 |
| | | */ |
| | | @ApiModelProperty(value= "锁定时间") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | @TableField(exist = false) |
| | | private Date lockedTime; |
| | | |
| | | /** |
| | |
| | | |
| | | public StockItem() {} |
| | | |
| | | public StockItem(String stockId,Long matnrId,Long asnItemId, String code,String matnrk,Double anfme,Double workQty,Double qty,Double weight,String unit,Long shipperId,String splrId,String brand,String batch,String prodTime,Long inspectId,String splrBtch,String asnOrder,String erpToken,String erpOrder,String erpStkAdr,Long locId,String barcode,Double purPrice,String lockReason,Short lockStatus,String locker,Date lockedTime,Integer status,Integer deleted,Integer tenantId,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) { |
| | | public StockItem(Long stockId,Long matnrId,Long asnItemId, String code,String matnrk,Double anfme,Double workQty,Double qty,Double weight,String unit,Long shipperId,String splrId,String brand,String batch,String prodTime,Long inspectId,String splrBtch,String asnOrder,String erpToken,String erpOrder,String erpStkAdr,Long locId,String barcode,Double purPrice,String lockReason,Short lockStatus,String locker,Date lockedTime,Integer status,Integer deleted,Integer tenantId,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) { |
| | | this.stockId = stockId; |
| | | this.matnrId = matnrId; |
| | | this.asnItemId = asnItemId; |
| | |
| | | package com.vincent.rsf.server.manager.schedules; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.api.entity.enums.TaskStsType; |
| | | import com.vincent.rsf.server.manager.entity.*; |
| | | import com.vincent.rsf.server.manager.service.*; |
| | | import com.vincent.rsf.server.system.constant.SerialRuleCode; |
| | | import com.vincent.rsf.server.system.enums.LocStsType; |
| | | import com.vincent.rsf.server.system.utils.SerialRuleUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.sql.Array; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | |
| | | if (taskItems.isEmpty()) { |
| | | throw new CoolException("任务明细为空!!"); |
| | | } |
| | | //获取单据明细ID |
| | | List<Long> ids = taskItems.stream().map(TaskItem::getOrderItemId).collect(Collectors.toList()); |
| | | List<AsnOrderItem> items = asnOrderItemService.list(new LambdaQueryWrapper<AsnOrderItem>().in(AsnOrderItem::getAsnId, ids)); |
| | | if (items.isEmpty()) { |
| | | throw new CoolException("数据错误:明细单据不存在"); |
| | | } |
| | | /**获取订单*/ |
| | | List<Long> orders = items.stream().map(AsnOrderItem::getAsnId).collect(Collectors.toList()); |
| | | Map<Long, List<AsnOrderItem>> listMap = items.stream().collect(Collectors.groupingBy(AsnOrderItem::getAsnId)); |
| | | |
| | | listMap.keySet().forEach(key -> { |
| | | AsnOrder order = asnOrderService.getOne(new LambdaQueryWrapper<AsnOrder>().eq(AsnOrder::getId, key)); |
| | | Map<Long, List<TaskItem>> listMap = taskItems.stream().collect(Collectors.groupingBy(TaskItem::getTaskId)); |
| | | List<StockItem> stockItems = new ArrayList<>(); |
| | | for (Task task : tasks) { |
| | | List<TaskItem> taskItem = listMap.get(task.getId()); |
| | | if (taskItem.isEmpty()) { |
| | | throw new CoolException("数据错误 ") |
| | | } |
| | | Stock stock = new Stock(); |
| | | |
| | | listMap.get(task.getId()).forEach(item -> { |
| | | |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | taskItems.forEach(item -> { |
| | | Stock stock = new Stock(); |
| | | AsnOrder order = asnOrderService.getOne(new LambdaQueryWrapper<AsnOrder>() |
| | | .eq(AsnOrder::getId, item.getOrderId()) |
| | | .select(AsnOrder::getId, AsnOrder::getPoCode, AsnOrder::getCode)); |
| | | if (!Objects.isNull(order.getPoCode()) && StringUtils.isNotBlank(order.getPoCode())) { |
| | | Purchase purchase = purchaseService.getOne(new LambdaQueryWrapper<Purchase>().eq(Purchase::getCode, order.getPoCode())); |
| | | stock.setPlatOrderNo(purchase.getPlatCode()).setPlatToken(purchase.getPlatId()); |
| | |
| | | throw new CoolException("当前业务:" + SerialRuleCode.SYS_STOCK_CODE + ",编码规则不存在!!"); |
| | | } |
| | | stock.setAsnId(order.getId()).setAsnCode(order.getCode()); |
| | | |
| | | if (!stockService.save(stock)) { |
| | | throw new CoolException("库存保存失败!!"); |
| | | } |
| | | Task taskServiceOne = taskService.getOne(new LambdaQueryWrapper<Task>() |
| | | .select(Task::getId, Task::getTargLoc, Task::getOrgLoc, Task::getBarcode) |
| | | .eq(Task::getId, item.getTaskId())); |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, taskServiceOne.getTargLoc())); |
| | | if (Objects.isNull(loc)) { |
| | | throw new CoolException("库位不存在!!"); |
| | | } |
| | | AsnOrderItem orderItem = asnOrderItemService.getOne(new LambdaQueryWrapper<AsnOrderItem>().eq(AsnOrderItem::getId, item.getOrderItemId())); |
| | | if (Objects.isNull(orderItem)) { |
| | | throw new CoolException("单据明细不存在!!"); |
| | | } |
| | | StockItem stockItem = new StockItem(); |
| | | BeanUtils.copyProperties(orderItem, stockItem); |
| | | stockItem.setAsnItemId(item.getOrderItemId()) |
| | | .setBarcode(taskServiceOne.getBarcode()) |
| | | .setLocId(loc.getId()) |
| | | .setId(null) |
| | | .setStockId(stock.getId()); |
| | | stockItems.add(stockItem); |
| | | }); |
| | | |
| | | if (!stockItemService.saveBatch(stockItems)) { |
| | | throw new CoolException("库存修改架失败!!"); |
| | | } |
| | | List<String> locCodes = tasks.stream().map(Task::getTargLoc).collect(Collectors.toList()); |
| | | if (!locService.update(new LambdaUpdateWrapper<Loc>().set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type).in(Loc::getCode, locCodes))) { |
| | | throw new CoolException("库位状态修改失败!!"); |
| | | } |
| | | } |
| | | |
| | | } |