This commit is contained in:
15066119699 2025-03-15 13:51:26 +08:00
parent e40990ee77
commit 81c873f0e7
10 changed files with 253 additions and 30 deletions

View File

@ -60,6 +60,19 @@ public class AppPmsOrderOutController extends BaseController
return getDataTable(list);
}
/**
* 根据波次号查询物料信息列表
*/
@GetMapping("/selectList/{orderWave}")
public AjaxResult selectList(@PathVariable("orderWave") String orderWave)
{
logger.info("根据波次查询物料列表={}",orderWave);
AppPmsOrderOut appPmsOrderOut = new AppPmsOrderOut();
appPmsOrderOut.setOrderWave(orderWave);
List<AppPmsOrderOut> list = appPmsOrderOutService.selectAppPmsOrderOutList(appPmsOrderOut);
return success(list);
}
/**
* 导出请填写功能名称列表
*/

View File

@ -3,6 +3,7 @@ package com.ruoyi.web.controller.app;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import javax.xml.stream.Location;
@ -536,7 +537,7 @@ public class AppTaskController extends BaseController
logger.info("接收生成波次请求:{}", JSONObject.toJSONString(appPmsOrderOutList));
//1.判断是否已生成波次
String orderCode = OrderCodeFactory.getOrderCode("", "");
int s = 0;
for (AppPmsOrderOut appPmsOrderOut : appPmsOrderOutList) {
if(appPmsOrderOut.getGenerateWave() == 1){
return error("已生成波次的,不能重复生成");
@ -555,6 +556,7 @@ public class AppTaskController extends BaseController
appPmsOrderOut1.setGenerateWave(1);
appPmsOrderOut1.setUpdateTime(new Date());
appPmsOrderOut1.setUpdateBy(getUsername());
appPmsOrderOut1.setWaveLineNum(++s);
appPmsOrderOutService.updateAppPmsOrderOut(appPmsOrderOut1);
}
@ -575,6 +577,68 @@ public class AppTaskController extends BaseController
appWaveService.insertAppWave(appWave);
return success("创建波次成功");
}
/**
* 波次出库请求
* appPmsOrderOutList 出库单列表
* @return 结果
*/
@ApiOperation("波次出库")
@PostMapping("/createWaveOutRequest")
@Transactional(rollbackFor = Exception.class)
public AjaxResult createWaveOutRequest(@RequestBody AppWave appWave)
{
// 判断是否为空
if (StringUtils.isBlank(appWave.getWaveId())) {
return error("波次单号细不能为空");
}
//根据波次单号查询该波次状态是否为未执行否则不能再次创建波次
AppWave appWave1 = appWaveService.selectAppWaveByWaveId(appWave.getWaveId());
if(appWave1.getWaveStatus() != 0){
return error("波次单号状态为已执行,不能再次创建波次");
}
//更新为已生成任务1
appWave.setWaveStatus(1);
appWave.setUpdateTime(new Date());
appWaveService.updateAppWave(appWave);
//根据波次单号去出库单表去查询出库单列表
AppPmsOrderOut appPmsOrderOut = new AppPmsOrderOut();
appPmsOrderOut.setOrderWave(appWave.getWaveId());
List<AppPmsOrderOut> appPmsOrderOutList = appPmsOrderOutService.selectAppPmsOrderOutList(appPmsOrderOut);
//判断是否锁定
if(appPmsOrderOutList.stream().anyMatch(e -> StringUtils.compare("1", e.getIsLock()) == 0)){
return error("波次单号中有锁定的,不能再次创建波次");
}
//根据 java8 Stream 根据物料编号 去重并且统计总出库数量生成AppPmsOrderOut列表
List<AppPmsOrderOut> appPmsOrderOutList1 = appPmsOrderOutList.stream().collect(Collectors.groupingBy(AppPmsOrderOut::getGoodsId)).entrySet().stream().map(e -> {
AppPmsOrderOut appPmsOrderOut1 = new AppPmsOrderOut();
appPmsOrderOut1.setGoodsId(e.getKey());
appPmsOrderOut1.setOrderStatus(0);
appPmsOrderOut1.setIsLock("0");
appPmsOrderOut1.setGoodsDesc(e.getValue().get(0).getGoodsDesc());
appPmsOrderOut1.setOrderWave(appWave.getWaveId());
appPmsOrderOut1.setPickNum(e.getValue().stream().map(AppPmsOrderOut::getGoodsNum).reduce(BigDecimal.ZERO, BigDecimal::add));
return appPmsOrderOut1;
}).collect(Collectors.toList());
//把该波次出库单锁定
appPmsOrderOutList1.forEach(e -> {
e.setIsLock("1");
e.setUpdateTime(new Date());
e.setUpdateBy(getUsername());
e.setShelvesNum(e.getPickNum());
appPmsOrderOutService.updateAppPmsOrderOut(e);
});
handleOut(appPmsOrderOutList1,2);
return success("处理出库请求成功,并已生成出库任务。");
}
/**
* 出库单出库请求
* appPmsOrderOutList 出库单列表
@ -598,7 +662,26 @@ public class AppTaskController extends BaseController
if (appPmsOrderOutList.stream().map(AppPmsOrderOut::getListId).distinct().count() > 1) {
return error("手动出库紧支持单个出库单出库");
}
//如果已经生成波次则不允许手动出库了
for (AppPmsOrderOut appPmsOrderOut : appPmsOrderOutList) {
if(appPmsOrderOut.getGenerateWave() == 1){
return error("已生成波次出库,不允许手动出库");
}
}
handleOut(appPmsOrderOutList,1);
return success("处理出库请求成功,并已生成出库任务。");
}
/**
*
* @param appPmsOrderOutList
* @param type 1:手动出库2:波次出库
*/
private void handleOut(List<AppPmsOrderOut> appPmsOrderOutList,int type) {
//
logger.info("请求出库单明细:{}", appPmsOrderOutList);
//value: 以托盘号为key该托盘出库该物料的出库数量为value的map
@ -608,9 +691,11 @@ public class AppTaskController extends BaseController
logger.info("已出库完成的忽略:{}",appPmsOrderOut.getGoodsId());
throw new RuntimeException("有出库单已全部出库,请重新选择");
}
if("1".equals(appPmsOrderOut.getIsLock())){
logger.info("已锁定的忽略:{}",appPmsOrderOut.getGoodsId());
throw new RuntimeException("有出库单已锁定,请重新选择");
if(type == 1) {
if ("1".equals(appPmsOrderOut.getIsLock())) {
logger.info("已锁定的忽略:{}", appPmsOrderOut.getGoodsId());
throw new RuntimeException("有出库单已锁定,请重新选择");
}
}
if(appPmsOrderOut.getShelvesNum() == null || appPmsOrderOut.getShelvesNum().compareTo(BigDecimal.ZERO) == 0){
logger.info("出库数量为0忽略{}",appPmsOrderOut.getGoodsId());
@ -656,8 +741,10 @@ public class AppTaskController extends BaseController
//存储在大的map中
goodsMap.put(appPmsOrderOut.getGoodsId(),ctlMap);
logger.info("更新累计出库数量:{}",appPmsOrderOut);
appPmsOrderOut.setIsLock("1");
appPmsOrderOutService.updatePickNum(appPmsOrderOut);
if(type == 1) {
appPmsOrderOut.setIsLock("1");
appPmsOrderOutService.updatePickNum(appPmsOrderOut);
}
}
//创建出库任务
@ -695,7 +782,12 @@ public class AppTaskController extends BaseController
//根据每个托盘创建出库任务
//1. 判断出库任务是否已产生该托盘的任务
//获取订单号
String orderId = appPmsOrderOutList.get(0).getOrderId();
String orderId;
if(type == 1) {
orderId = appPmsOrderOutList.get(0).getOrderId();
} else {
orderId = appPmsOrderOutList.get(0).getOrderWave();
}
ctlGoodsMap.forEach((key,value) ->{
List<AppTask> appTasks = getAppTaskByVehicleId(key,null);
if(!CollectionUtils.isEmpty(appTasks)){
@ -704,11 +796,10 @@ public class AppTaskController extends BaseController
}
//出库
setCk(key,value,orderId);
setCk(key,value,orderId,type);
});
return success("处理出库请求成功,并已生成出库任务。");
}
private List<AppTask> getAppTaskByVehicleId(String vehicleId,String locationId) {
@ -719,10 +810,12 @@ public class AppTaskController extends BaseController
appTask.setTaskType(AppConstants.TASK_TYPE_OUT);
}
//判断该托盘是否产生任务
return appTaskService.selectAppTaskList(appTask);
List<AppTask> appTasks = appTaskService.selectAppTaskList(appTask);
return appTasks;
}
private void setCk(String vehicleId,Map<String,BigDecimal> map,String orderId) {
private void setCk(String vehicleId,Map<String,BigDecimal> map,String orderId,int type) {
AppStock appStock = new AppStock();
appStock.setVehicleId(vehicleId);
//该托盘的所有物料
@ -945,6 +1038,11 @@ public class AppTaskController extends BaseController
//库存编号
appTask.setStockId(tMiStock1.getStockId());
appTask.setCreateTime(new Date());
if(type == 1){
appTask.setCkWave(0);
}else{
appTask.setCkWave(1);
}
appTaskService.insertAppTask(appTask);
}
@ -1195,6 +1293,11 @@ public class AppTaskController extends BaseController
return success(selectedAppTaskList);
}
/**
* 拣货接口
* @param requests
* @return
*/
@Anonymous
@PostMapping("/pickComplete")
public AjaxResult pickComplete(@RequestBody List<PickCompleteReq> requests) {
@ -1232,24 +1335,46 @@ public class AppTaskController extends BaseController
//查询出库单 根据orderId和goodsId
AppPmsOrderOut appPmsOrderOut = new AppPmsOrderOut();
appPmsOrderOut.setGoodsId(task.getGoodsId());
appPmsOrderOut.setOrderId(task.getOrderId());
if(task.getCkWave() == 0){
appPmsOrderOut.setOrderId(task.getOrderId());
}else{
appPmsOrderOut.setOrderWave(task.getOrderId());
}
appPmsOrderOut.setIsLock("1");
List<AppPmsOrderOut> appPmsOrderOuts = appPmsOrderOutService.selectAppPmsOrderOutList(appPmsOrderOut);
if(CollectionUtils.isEmpty(appPmsOrderOuts)){
return error("数据服务异常,请重试");
return error("获取出库单失败,请确认是否已经拣选完成!");
}
AppPmsOrderOut appPmsOrderOut1 = appPmsOrderOuts.get(0);
if(appPmsOrderOut1.getTrNum() == null) appPmsOrderOut1.setTrNum(BigDecimal.ZERO);
appPmsOrderOut1.setTrNum(appPmsOrderOut1.getTrNum().add(request.getPickNum()));
appPmsOrderOut1.setShelvesNum(BigDecimal.ZERO);
if(appPmsOrderOut1.getTrNum().compareTo(appPmsOrderOut1.getGoodsNum()) == 0){
appPmsOrderOut1.setOrderStatus(2);
}else{
appPmsOrderOut1.setOrderStatus(1);
int length = 1;
if(task.getCkWave() == 1){
length = appPmsOrderOuts.size();
}
BigDecimal total = request.getPickNum();
for(int i = 0; i < length; i++) {
AppPmsOrderOut appPmsOrderOut1 = appPmsOrderOuts.get(i);
if (appPmsOrderOut1.getTrNum() == null) appPmsOrderOut1.setTrNum(BigDecimal.ZERO);
if(total.compareTo(BigDecimal.ZERO) <= 0){
break;
}
if(total.compareTo(appPmsOrderOut1.getGoodsNum()) >= 0){
appPmsOrderOut1.setTrNum(appPmsOrderOut1.getGoodsNum());
total = total.subtract(appPmsOrderOut1.getGoodsNum());
}else{
appPmsOrderOut1.setTrNum(appPmsOrderOut1.getTrNum().add(appPmsOrderOut1.getGoodsNum().subtract(total)));
total = BigDecimal.ZERO;
}
appPmsOrderOut1.setIsLock("0");
appPmsOrderOutService.updateAppPmsOrderOut(appPmsOrderOut1);
appPmsOrderOut1.setShelvesNum(BigDecimal.ZERO);
if (appPmsOrderOut1.getTrNum().compareTo(appPmsOrderOut1.getGoodsNum()) == 0) {
appPmsOrderOut1.setOrderStatus(2);
} else {
appPmsOrderOut1.setOrderStatus(1);
}
appPmsOrderOut1.setIsLock("0");
appPmsOrderOutService.updateAppPmsOrderOut(appPmsOrderOut1);
}
}
logger.info("拣货成功===》》》》》》》》》》》》》》》》》》");
return success("捡货成功");

View File

@ -44,7 +44,7 @@ public class AppPmsOrderOut extends BaseEntity
private String goodsId;
/** 出库数量 */
@Excel(name = "出库数量")
@Excel(name = "订单数量")
private BigDecimal goodsNum;
/** 物料描述 */
@ -82,6 +82,16 @@ public class AppPmsOrderOut extends BaseEntity
// 波次号
private String orderWave;
private Integer waveLineNum;
public Integer getWaveLineNum() {
return waveLineNum;
}
public void setWaveLineNum(Integer waveLineNum) {
this.waveLineNum = waveLineNum;
}
public Integer getGenerateWave() {
return generateWave;
}

View File

@ -82,6 +82,15 @@ public class AppPmsOrderOutBak extends BaseEntity
private Integer generateWave;
// 波次号
private String orderWave;
private Integer waveLineNum;
public Integer getWaveLineNum() {
return waveLineNum;
}
public void setWaveLineNum(Integer waveLineNum) {
this.waveLineNum = waveLineNum;
}
public Integer getGenerateWave() {
return generateWave;

View File

@ -91,6 +91,16 @@ public class AppTask extends BaseEntity
private String locationId;
// @Excel(name = "库存编号")
private String stockId;
//是否是波次任务
private Integer ckWave;
public Integer getCkWave() {
return ckWave;
}
public void setCkWave(Integer ckWave) {
this.ckWave = ckWave;
}
public String getStockId() {
return stockId;

View File

@ -20,7 +20,8 @@ public class AppTaskBak extends BaseEntity
/** 任务号 */
private String taskId;
//订单号
private String orderId;
/** 任务类型 */
@Excel(name = "任务类型")
private Integer taskType;
@ -81,7 +82,33 @@ public class AppTaskBak extends BaseEntity
//1.零捡 2全量
private Integer ckType;
private String stockId;
//是否是波次任务
private Integer ckWave;
public Integer getCkWave() {
return ckWave;
}
public String getStockId() {
return stockId;
}
public void setStockId(String stockId) {
this.stockId = stockId;
}
public String getOrderId() {
return orderId;
}
public void setOrderId(String orderId) {
this.orderId = orderId;
}
public void setCkWave(Integer ckWave) {
this.ckWave = ckWave;
}
public String getLocationId() {
return locationId;
}

View File

@ -26,11 +26,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" />
<result property="generateWave" column="generate_wave" />
<result property="orderWave" column="order_wave" />
<result property="waveLineNum" column="wave_line_num" />
</resultMap>
<sql id="selectAppPmsOrderOutBakVo">
select record_id, order_id, list_id, order_type, customer_id, goods_id, goods_num, pick_num, tr_num, shelves_num, stock_num, goods_desc, spare1, spare2, order_status, is_lock, create_time, create_by, update_time ,
generate_wave, order_wave from app_pms_order_out_bak
generate_wave, order_wave,wave_line_num from app_pms_order_out_bak
</sql>
<select id="selectAppPmsOrderOutBakList" parameterType="AppPmsOrderOutBak" resultMap="AppPmsOrderOutBakResult">
@ -41,6 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="orderType != null "> and order_type = #{orderType}</if>
<if test="goodsDesc != null and goodsDesc != ''"> and goods_desc = #{goodsDesc}</if>
<if test="orderWave != null and orderWave != ''"> and order_wave = #{orderWave}</if>
<if test="waveLineNum != null and waveLineNum != ''"> and wave_line_num = #{waveLineNum}</if>
</where>
</select>
@ -73,6 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">update_time,</if>
<if test="generateWave != null">generate_wave,</if>
<if test="orderWave != null">order_wave,</if>
<if test="waveLineNum != null">wave_line_num,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="recordId != null">#{recordId},</if>
@ -96,6 +99,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">#{updateTime},</if>
<if test="generateWave != null">#{generateWave},</if>
<if test="orderWave != null">#{orderWave},</if>
<if test="waveLineNum != null">#{waveLineNum},</if>
</trim>
</insert>
@ -122,6 +126,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="generateWave != null">generate_wave = #{generateWave},</if>
<if test="orderWave != null">order_wave = #{orderWave},</if>
<if test="waveLineNum != null">wave_line_num = #{waveLineNum},</if>
</trim>
where record_id = #{recordId}
</update>

View File

@ -26,12 +26,13 @@
<result property="updateTime" column="update_time" />
<result property="generateWave" column="generate_wave" />
<result property="orderWave" column="order_wave" />
<result property="waveLineNum" column="wave_line_num" />
</resultMap>
<sql id="selectAppPmsOrderOutVo">
select record_id, list_id, order_type, customer_id, goods_id, goods_num, goods_desc, spare1, spare2,pick_num,tr_num,shelves_num,stock_num,order_status,is_lock,order_id,create_time,create_by,update_time,
generate_wave, order_wave from app_pms_order_out
generate_wave, order_wave,wave_line_num from app_pms_order_out
</sql>
<select id="selectAppPmsOrderOutList" parameterType="AppPmsOrderOut" resultMap="AppPmsOrderOutResult">
@ -47,6 +48,7 @@
<if test="orderId != null and orderId != ''"> and order_id = #{orderId}</if>
<if test="generateWave != null "> and generate_wave = #{generateWave}</if>
<if test="orderWave != null and orderWave != ''"> and order_wave = #{orderWave}</if>
<if test="waveLineNum != null and waveLineNum != ''"> and wave_line_num = #{waveLineNum}</if>
</where>
order by create_time desc
</select>
@ -80,6 +82,7 @@
<if test="updateTime != null">update_time,</if>
<if test="generateWave != null">generate_wave,</if>
<if test="orderWave != null">order_wave,</if>
<if test="waveLineNum != null">wave_line_num,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
@ -104,6 +107,7 @@
<if test="updateTime != null">#{updateTime},</if>
<if test="generateWave != null">#{generateWave},</if>
<if test="orderWave != null">#{orderWave},</if>
<if test="waveLineNum != null">#{waveLineNum},</if>
</trim>
</insert>
@ -129,6 +133,7 @@
<if test="orderStatus != null">order_status = #{orderStatus},</if>
<if test="generateWave != null">generate_wave = #{generateWave},</if>
<if test="orderWave != null">order_wave = #{orderWave},</if>
<if test="waveLineNum != null">wave_line_num = #{waveLineNum},</if>
</trim>
where record_id = #{recordId}

View File

@ -23,10 +23,13 @@
<result property="remark" column="remark" />
<result property="locationId" column="location_id" />
<result property="ckType" column="ck_type" />
<result property="stockId" column="stock_id" />
<result property="orderId" column="order_id" />
<result property="ckWave" column="ck_wave" />
</resultMap>
<sql id="selectAppTaskBakVo">
select task_id, task_type, task_status, task_priority, vehicle_id, origin, destination, wcs_task_id, create_time, finish_time, goods_id, op_num, stock_num, op_user, pre_task, remark,location_id,ck_type from app_task_bak
select task_id, task_type, task_status, task_priority, vehicle_id, origin, destination, wcs_task_id, create_time, finish_time, goods_id, op_num, stock_num, op_user, pre_task, remark,location_id,ck_type,stock_id,order_id,ck_wave from app_task_bak
</sql>
<select id="selectAppTaskBakList" parameterType="AppTaskBak" resultMap="AppTaskBakResult">
@ -47,6 +50,11 @@
<if test="preTask != null and preTask != ''"> and pre_task = #{preTask}</if>
<if test="remark != null and remark != ''"> and remark = #{remark}</if>
<if test="locationId != null and locationId != ''"> and location_id = #{locationId}</if>
<if test="orderId != null and orderId != ''"> and order_id = #{orderId}</if>
<if test="stockId != null and stockId != ''"> and stock_id = #{stockId}</if>
<if test="ckWave != null and ckWave != ''"> and ck_wave = #{ckWave}</if>
<if test="ckType != null and ckType != ''"> and ck_type = #{ckType}</if>
</where>
</select>
@ -75,7 +83,10 @@
<if test="preTask != null">pre_task,</if>
<if test="remark != null">remark,</if>
<if test="locationId != null">location_id,</if>
<if test="ckType != null">ck_type,</if>
<if test="ckType != null">ck_type,
<if test="stockId != null">stock_id,</if>
<if test="orderId != null">order_id,</if>
<if test="ckWave != null">ck_wave,</if></if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="taskId != null">#{taskId},</if>
@ -96,6 +107,9 @@
<if test="remark != null">#{remark},</if>
<if test="locationId != null">#{locationId},</if>
<if test="ckType != null">#{ckType},</if>
<if test="stockId != null">#{stockId},</if>
<if test="orderId != null">#{orderId},</if>
<if test="ckWave != null">#{ckWave},</if>
</trim>
</insert>

View File

@ -27,10 +27,11 @@
<result property="ckType" column="ck_type" />
<result property="stockId" column="stock_id" />
<result property="orderId" column="order_id" />
<result property="ckWave" column="ck_wave" />
</resultMap>
<sql id="selectAppTaskVo">
select task_id, task_type, task_status, task_priority, vehicle_id, origin, destination, wcs_task_id, create_time, finish_time, goods_id, op_num, stock_num, op_user, pre_task, remark,plc_id,location_id,ck_type,stock_id,order_id from app_task
select task_id, task_type, task_status, task_priority, vehicle_id, origin, destination, wcs_task_id, create_time, finish_time, goods_id, op_num, stock_num, op_user, pre_task, remark,plc_id,location_id,ck_type,stock_id,order_id,ck_wave from app_task
</sql>
<select id="selectAppTaskList" parameterType="AppTask" resultMap="AppTaskResult">
@ -53,6 +54,8 @@
<if test="locationId != null and locationId != ''"> and location_id = #{locationId}</if>
<if test="ckType != null and ckType != ''"> and ck_type = #{ckType}</if>
<if test="orderId != null and orderId != ''"> and order_id = #{orderId}</if>
<if test="stockId != null and stockId != ''"> and stock_id = #{stockId}</if>
<if test="ckWave != null and ckWave != ''"> and ck_wave = #{ckWave}</if>
</where>
</select>
@ -84,6 +87,7 @@
<if test="ckType != null">ck_type,</if>
<if test="stockId != null">stock_id,</if>
<if test="orderId != null">order_id,</if>
<if test="ckWave != null">ck_wave,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="taskId != null">#{taskId},</if>
@ -106,6 +110,7 @@
<if test="ckType != null">#{ckType},</if>
<if test="stockId != null">#{stockId},</if>
<if test="orderId != null">#{orderId},</if>
<if test="ckWave != null">#{ckWave},</if>
</trim>
</insert>