Compare commits
3 Commits
081467c514
...
3ffa5181a7
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ffa5181a7 | |||
| 2cb951bc72 | |||
| 6378186e61 |
|
|
@ -1,9 +1,6 @@
|
|||
package com.ruoyi.web.controller.app;
|
||||
|
||||
import com.ruoyi.app.domain.AppLocation;
|
||||
import com.ruoyi.app.domain.AppPendingStorage;
|
||||
import com.ruoyi.app.domain.AppPmsOrderIn;
|
||||
import com.ruoyi.app.domain.AppTask;
|
||||
import com.ruoyi.app.domain.*;
|
||||
import com.ruoyi.app.service.IAppPendingStorageService;
|
||||
import com.ruoyi.app.service.IAppPmsOrderInService;
|
||||
import com.ruoyi.app.service.IAppPmsOrderOutService;
|
||||
|
|
@ -37,8 +34,7 @@ import java.util.*;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/app/pms")
|
||||
public class AppPmsController extends BaseController
|
||||
{
|
||||
public class AppPmsController extends BaseController {
|
||||
@Autowired
|
||||
private IAppPmsOrderInService appPmsOrderInService;// 入库单
|
||||
@Autowired
|
||||
|
|
@ -56,8 +52,7 @@ public class AppPmsController extends BaseController
|
|||
@Log(title = "Pms入库单请求", skipAuth = true)
|
||||
@PostMapping("/orderIn")
|
||||
@Anonymous
|
||||
public AjaxResult pmsOrderIn(@RequestBody PmsOrderInRequest orderInRequest)
|
||||
{
|
||||
public AjaxResult pmsOrderIn(@RequestBody PmsOrderInRequest orderInRequest) {
|
||||
// TODO
|
||||
// 判断数据是否缺失
|
||||
Integer orderType = orderInRequest.getOrderType();
|
||||
|
|
@ -103,13 +98,32 @@ public class AppPmsController extends BaseController
|
|||
@Log(title = "Pms出库单请求", skipAuth = true)
|
||||
@PostMapping("/orderOut")
|
||||
@Anonymous
|
||||
public AjaxResult pmsOrderOut(@RequestBody PmsOrderOutRequest orderOutRequest)
|
||||
{
|
||||
public AjaxResult pmsOrderOut(@RequestBody PmsOrderOutRequest orderOutRequest) {
|
||||
// TODO
|
||||
// 判断请求数据完整性
|
||||
if (StringUtils.isEmpty(orderOutRequest.getListId())
|
||||
|| orderOutRequest.getOrderType() == null
|
||||
|| StringUtils.isEmpty(orderOutRequest.getCustomerId())
|
||||
|| StringUtils.isEmpty(orderOutRequest.getGoodsId())
|
||||
|| orderOutRequest.getGoodsNum() == null
|
||||
|| StringUtils.isEmpty(orderOutRequest.getGoodsDesc())) {
|
||||
return error("请求数据不完整。");
|
||||
}
|
||||
// 判断入库单号是否重复
|
||||
AppPmsOrderOut existAppPmsOrderOut = appPmsOrderOutService.selectAppPmsOrderOutByListId(orderOutRequest.getListId());
|
||||
if (existAppPmsOrderOut != null) {
|
||||
return error("出库单号重复。");
|
||||
}
|
||||
AppPmsOrderOut appPmsOrderOut = new AppPmsOrderOut();
|
||||
appPmsOrderOut.setListId(orderOutRequest.getListId());
|
||||
appPmsOrderOut.setOrderType(Long.valueOf(orderOutRequest.getOrderType()));
|
||||
appPmsOrderOut.setCustomerId(orderOutRequest.getCustomerId());
|
||||
appPmsOrderOut.setGoodsId(orderOutRequest.getGoodsId());
|
||||
appPmsOrderOut.setGoodsNum(BigDecimal.valueOf(orderOutRequest.getGoodsNum()));
|
||||
appPmsOrderOut.setGoodsDesc(orderOutRequest.getGoodsDesc());
|
||||
appPmsOrderOut.setCreateTime(new Date());
|
||||
appPmsOrderOut.setUpdateTime(new Date());
|
||||
|
||||
|
||||
|
||||
|
||||
return success();
|
||||
return toAjax(appPmsOrderOutService.insertAppPmsOrderOut(appPmsOrderOut));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.ruoyi.app.service.*;
|
|||
import com.ruoyi.app.service.impl.AppPendingStorageServiceImpl;
|
||||
import com.ruoyi.common.annotation.Anonymous;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.uuid.IdUtils;
|
||||
import com.ruoyi.web.controller.section.EnhanceDataList;
|
||||
import com.ruoyi.web.domain.*;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
|
@ -473,4 +474,158 @@ public class AppTaskController extends BaseController
|
|||
{
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求出库
|
||||
* @param outRequest 出库请求
|
||||
* @return 结果
|
||||
*/
|
||||
@ApiOperation("请求出库")
|
||||
@PostMapping("/createOutRequest")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Anonymous
|
||||
public AjaxResult createOutRequest(@RequestBody TaskOutRequest outRequest)
|
||||
{
|
||||
// 判断请求数据完整性
|
||||
if (outRequest == null || StringUtils.isEmpty(outRequest.getGoodsId())
|
||||
|| outRequest.getNeedNum() == null || outRequest.getNeedNum().compareTo(BigDecimal.ZERO) <= 0) {
|
||||
return error("请求参数不完整。");
|
||||
}
|
||||
// 根据需求查询库存(正常)
|
||||
AppStock stockQuery = new AppStock();
|
||||
stockQuery.setGoodsId(outRequest.getGoodsId());
|
||||
stockQuery.setStockStatus(0L);
|
||||
List<AppStock> appStocks = appStockService.selectAppStockList(stockQuery);
|
||||
BigDecimal totalNeedNum = outRequest.getNeedNum();
|
||||
for (AppStock appStock : appStocks) {
|
||||
// 需求够了
|
||||
if (totalNeedNum.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
break;
|
||||
}
|
||||
AppLocation moveLocation = outerLocation(appStock.getLocationId());
|
||||
String preTaskId = "";
|
||||
AppTask moveTask = new AppTask();
|
||||
if (moveLocation != null) {
|
||||
if (StringUtils.isEmpty(moveLocation.getLocationId())) {
|
||||
continue;
|
||||
}
|
||||
// 查询这个位置有没有任务
|
||||
AppTask inTaskQuery = new AppTask();
|
||||
inTaskQuery.setDestination(moveLocation.getLocationId());
|
||||
List<AppTask> inTasks = appTaskService.selectAppTaskList(inTaskQuery);
|
||||
if (inTasks != null && !inTasks.isEmpty()) {
|
||||
moveTask.setPreTask(inTasks.get(0).getTaskId());
|
||||
preTaskId = IdUtils.fastUUID();
|
||||
} else {
|
||||
// 判断origin
|
||||
AppTask outTaskQuery = new AppTask();
|
||||
outTaskQuery.setOrigin(moveLocation.getLocationId());
|
||||
List<AppTask> outTasks = appTaskService.selectAppTaskList(outTaskQuery);
|
||||
if (outTasks == null || outTasks.isEmpty()) {
|
||||
preTaskId = IdUtils.fastUUID();
|
||||
}
|
||||
}
|
||||
// 需要创建移库任务
|
||||
if (StringUtils.isNotEmpty(preTaskId)) {
|
||||
AppLocation moveDestination = appLocationService.requestLocation(moveLocation.getEquipmentId());
|
||||
if (moveDestination == null) {
|
||||
continue;
|
||||
}
|
||||
// 创建移库任务
|
||||
moveTask.setTaskId(IdUtils.fastUUID());
|
||||
moveTask.setTaskType(3);
|
||||
moveTask.setTaskStatus(0);
|
||||
moveTask.setTaskPriority(1);
|
||||
moveTask.setVehicleId(moveLocation.getVehicleId());
|
||||
moveTask.setOrigin(moveLocation.getLocationId());
|
||||
moveTask.setDestination(moveDestination.getLocationId());
|
||||
moveTask.setCreateTime(new Date());
|
||||
moveTask.setOpUser("system");
|
||||
appTaskService.insertAppTask(moveTask);
|
||||
moveDestination.setIsWorking(1);
|
||||
moveDestination.setLocationStatus(1);
|
||||
moveDestination.setVehicleId(moveLocation.getVehicleId());
|
||||
appLocationService.updateAppLocation(moveDestination);
|
||||
}
|
||||
}
|
||||
// 计算需求
|
||||
BigDecimal opNum;
|
||||
BigDecimal stockNum = appStock.getRemainNum();
|
||||
if (appStock.getRemainNum().compareTo(totalNeedNum) >= 0) {
|
||||
opNum = totalNeedNum;
|
||||
totalNeedNum = BigDecimal.ZERO;
|
||||
appStock.setRemainNum(appStock.getRemainNum().subtract(totalNeedNum));
|
||||
} else {
|
||||
opNum = appStock.getRemainNum();
|
||||
totalNeedNum = totalNeedNum.subtract(appStock.getRemainNum());
|
||||
appStock.setRemainNum(BigDecimal.ZERO);
|
||||
}
|
||||
appStock.setStockStatus(1L);// 设置状态出库中
|
||||
// 生成出库任务,并将此任务的preTask设置为移库任务
|
||||
AppTask outTask = new AppTask();
|
||||
outTask.setTaskId(IdUtils.fastUUID());
|
||||
outTask.setTaskType(2);
|
||||
outTask.setTaskStatus(0);
|
||||
outTask.setTaskPriority(1);
|
||||
outTask.setVehicleId(appStock.getVehicleId());
|
||||
outTask.setOrigin(appStock.getLocationId());
|
||||
outTask.setCreateTime(new Date());
|
||||
outTask.setGoodsId(appStock.getGoodsId());
|
||||
outTask.setOpNum(opNum);
|
||||
outTask.setStockNum(stockNum);
|
||||
outTask.setOpUser("");// TODO 需要设定
|
||||
outTask.setPreTask(preTaskId);
|
||||
outTask.setRemark(outRequest.getRemark());
|
||||
appTaskService.insertAppTask(outTask);
|
||||
// 更新库存
|
||||
appStockService.updateAppStock(appStock);
|
||||
}
|
||||
if (totalNeedNum.compareTo(outRequest.getNeedNum()) == 0) {
|
||||
// 没有库存
|
||||
return error("没有库存");
|
||||
} else if (totalNeedNum.compareTo(BigDecimal.ZERO) > 0) {
|
||||
return error("库存不足");
|
||||
} else {
|
||||
return success("处理出库请求成功,并已生成出库任务。");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否需要生成移库任务
|
||||
* @param targetLocationId 目标库位
|
||||
* @return 结果
|
||||
*/
|
||||
private AppLocation outerLocation(String targetLocationId) {
|
||||
AppLocation moveLocation = new AppLocation();
|
||||
// 查询到目标库位
|
||||
AppLocation targetLocation = appLocationService.selectAppLocationByLocationId(targetLocationId);
|
||||
if (targetLocation == null) {
|
||||
return null;
|
||||
}
|
||||
if (targetLocation.getwDepth() == 1) {
|
||||
// 深度1不需要移库
|
||||
return null;
|
||||
} else {
|
||||
// 判断深度为1的库位是否被占用
|
||||
AppLocation depth1LocationQuery = new AppLocation();
|
||||
depth1LocationQuery.setEquipmentId(targetLocation.getEquipmentId());
|
||||
depth1LocationQuery.setwLayer(targetLocation.getwLayer());
|
||||
depth1LocationQuery.setwRow(targetLocation.getwRow());
|
||||
depth1LocationQuery.setwCol(targetLocation.getwCol());
|
||||
depth1LocationQuery.setwDepth(1);
|
||||
List<AppLocation> depth1Locations = appLocationService.selectAppLocationList(depth1LocationQuery);
|
||||
if (depth1Locations == null || depth1Locations.isEmpty()) {
|
||||
return moveLocation;
|
||||
}
|
||||
AppLocation depth1Location = depth1Locations.get(0);
|
||||
if (depth1Location.getIsLock() == 1) {
|
||||
return moveLocation;
|
||||
}
|
||||
if (depth1Location.getLocationStatus() == 1) {
|
||||
return depth1Location;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
package com.ruoyi.web.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 出库请求
|
||||
*/
|
||||
public class TaskOutRequest {
|
||||
/**
|
||||
* 物料号
|
||||
*/
|
||||
private String goodsId;
|
||||
/**
|
||||
* 需求数量
|
||||
*/
|
||||
private BigDecimal needNum;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
public String getGoodsId() {
|
||||
return goodsId;
|
||||
}
|
||||
|
||||
public void setGoodsId(String goodsId) {
|
||||
this.goodsId = goodsId;
|
||||
}
|
||||
|
||||
public BigDecimal getNeedNum() {
|
||||
return needNum;
|
||||
}
|
||||
|
||||
public void setNeedNum(BigDecimal needNum) {
|
||||
this.needNum = needNum;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
}
|
||||
|
|
@ -20,10 +20,11 @@
|
|||
<result property="stockNum" column="stock_num" />
|
||||
<result property="opUser" column="op_user" />
|
||||
<result property="preTask" column="pre_task" />
|
||||
<result property="remark" column="remark" />
|
||||
</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 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 from app_task_bak
|
||||
</sql>
|
||||
|
||||
<select id="selectAppTaskBakList" parameterType="AppTaskBak" resultMap="AppTaskBakResult">
|
||||
|
|
@ -42,6 +43,7 @@
|
|||
<if test="stockNum != null "> and stock_num = #{stockNum}</if>
|
||||
<if test="opUser != null and opUser != ''"> and op_user = #{opUser}</if>
|
||||
<if test="preTask != null and preTask != ''"> and pre_task = #{preTask}</if>
|
||||
<if test="remark != null and remark != ''"> and remark = #{remark}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
|
@ -68,6 +70,7 @@
|
|||
<if test="stockNum != null">stock_num,</if>
|
||||
<if test="opUser != null">op_user,</if>
|
||||
<if test="preTask != null">pre_task,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="taskId != null">#{taskId},</if>
|
||||
|
|
@ -85,6 +88,7 @@
|
|||
<if test="stockNum != null">#{stockNum},</if>
|
||||
<if test="opUser != null">#{opUser},</if>
|
||||
<if test="preTask != null">#{preTask},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
|
@ -105,6 +109,7 @@
|
|||
<if test="stockNum != null">stock_num = #{stockNum},</if>
|
||||
<if test="opUser != null">op_user = #{opUser},</if>
|
||||
<if test="preTask != null">pre_task = #{preTask},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where task_id = #{taskId}
|
||||
</update>
|
||||
|
|
|
|||
|
|
@ -21,10 +21,11 @@
|
|||
<result property="opUser" column="op_user" />
|
||||
<result property="opUser" column="op_user" />
|
||||
<result property="preTask" column="pre_task" />
|
||||
<result property="remark" column="remark" />
|
||||
</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 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 from app_task
|
||||
</sql>
|
||||
|
||||
<select id="selectAppTaskList" parameterType="AppTask" resultMap="AppTaskResult">
|
||||
|
|
@ -43,6 +44,7 @@
|
|||
<if test="stockNum != null "> and stock_num = #{stockNum}</if>
|
||||
<if test="opUser != null and opUser != ''"> and op_user = #{opUser}</if>
|
||||
<if test="preTask != null and preTask != ''"> and pre_task = #{preTask}</if>
|
||||
<if test="remark != null and remark != ''"> and remark = #{remark}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
|
@ -69,6 +71,7 @@
|
|||
<if test="stockNum != null">stock_num,</if>
|
||||
<if test="opUser != null">op_user,</if>
|
||||
<if test="preTask != null">pre_task,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="taskId != null">#{taskId},</if>
|
||||
|
|
@ -86,6 +89,7 @@
|
|||
<if test="stockNum != null">#{stockNum},</if>
|
||||
<if test="opUser != null">#{opUser},</if>
|
||||
<if test="preTask != null">#{preTask},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
|
@ -109,6 +113,7 @@
|
|||
<if test="appTask.stockNum != null">stock_num,</if>
|
||||
<if test="appTask.opUser != null">op_user,</if>
|
||||
<if test="appTask.preTask != null">pre_task,</if>
|
||||
<if test="appTask.remark != null">remark,</if>
|
||||
</trim>
|
||||
)
|
||||
values
|
||||
|
|
@ -129,6 +134,7 @@
|
|||
<if test="appTask.stockNum != null">#{appTask.stockNum},</if>
|
||||
<if test="appTask.opUser != null">#{appTask.opUser},</if>
|
||||
<if test="appTask.preTask != null">#{appTask.preTask},</if>
|
||||
<if test="appTask.remark != null">#{appTask.remark},</if>
|
||||
</trim>
|
||||
)
|
||||
</foreach>
|
||||
|
|
@ -152,6 +158,7 @@
|
|||
<if test="stockNum != null">stock_num = #{stockNum},</if>
|
||||
<if test="opUser != null">op_user = #{opUser},</if>
|
||||
<if test="preTask != null">pre_task = #{preTask},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where task_id = #{taskId}
|
||||
</update>
|
||||
|
|
@ -174,6 +181,7 @@
|
|||
<if test="appTask.stockNum != null">stock_num = #{appTask.stockNum},</if>
|
||||
<if test="appTask.opUser != null">op_user = #{appTask.opUser},</if>
|
||||
<if test="appTask.preTask != null">pre_task = #{appTask.preTask},</if>
|
||||
<if test="appTask.remark != null">remark = #{appTask.remark},</if>
|
||||
</trim>
|
||||
where task_id = #{appTask.taskId}
|
||||
</foreach>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user