master
杨万里 2 days ago
parent 6a7af448d7
commit cd85333343

@ -20,6 +20,8 @@ import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
import static com.ruoyi.common.config.datasource.DynamicDataSourceContextHolder.log;
/** /**
* Controller * Controller
* *
@ -135,9 +137,34 @@ public class BaseInventoryController extends BaseController
//出库 //出库
@PostMapping("/pdaOutInventory") @PostMapping("/pdaOutInventory")
@ResponseBody @ResponseBody
public AjaxResult pdaOutInventory(BaseInventory baseInventory, BaseTyre baseTyre) public AjaxResult pdaOutInventory(BaseInventory baseInventory, BaseTyre baseTyre) {
{ // 1. 前置校验
return baseInventoryService.OutInventoryByPda(baseInventory,baseTyre); if (baseInventory == null) {
return error("库存对象不能为空");
}
if (baseInventory.getType() == null) {
return error("出库类型不能为空");
}
// 2. 业务分发
try {
switch (baseInventory.getType()) {
case "0":
// 执行正常出库逻辑
return baseInventoryService.OutInventoryByPda(baseInventory, baseTyre);
case "1":
// 执行调拨出库逻辑 (在baseTyre实体中传递场站ID【部门ID】,)
return baseInventoryService.transferOutInventoryByPda(baseInventory, baseTyre);
default:
// 如果出库类型不匹配,明确报错。
return error("不支持的出库类型: " + baseInventory.getType());
}
} catch (Exception e) {
// 3. 异常捕获:防止后台报错导致前台卡死
log.error("PDA出库异常", e); // 记录日志
return error("出库失败:" + e.getMessage());
}
} }
/** /**

@ -41,10 +41,18 @@ public class BaseInventory extends BaseEntity
private String team; private String team;
private String status; private String status;
private Long deptId; private Long deptId;
//出库类型 0正常出库 1调拨出库
private String type;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getTeam() { public String getTeam() {
return team; return team;

@ -102,4 +102,5 @@ public interface IBaseInventoryService
*/ */
int rollbackBatchInboundByCode(String inboundCode, String operName); int rollbackBatchInboundByCode(String inboundCode, String operName);
AjaxResult transferOutInventoryByPda(BaseInventory baseInventory, BaseTyre baseTyre);
} }

@ -348,6 +348,7 @@ public class BaseInventoryServiceImpl implements IBaseInventoryService
return success; // 返回实际成功撤回条数 return success; // 返回实际成功撤回条数
} }
/** /**
* *
* *
@ -397,4 +398,34 @@ public class BaseInventoryServiceImpl implements IBaseInventoryService
return data; // 返回预览结果 return data; // 返回预览结果
} }
@Override
public AjaxResult transferOutInventoryByPda(BaseInventory baseInventory, BaseTyre baseTyre) {
try {
//查询库存状态
BaseInventory baseInventoryStatus= baseInventoryMapper.selectBaseInventoryByEpc(baseInventory);
if ("1".equals(baseInventoryStatus.getStatus())){
return AjaxResult.error("该轮胎已出库");
}
//更新库存表(在仓-出仓)
baseInventory.setStatus("1");
baseInventory.setUpdateTime(DateUtils.getNowDate());
baseInventory.setUpdateBy(baseInventory.getCreateBy());
int n = baseInventoryMapper.updateBaseInventoryByEpc(baseInventory);
//增加出库记录表
RecordWarehousing recordWarehousing = new RecordWarehousing();
recordWarehousing.setTyreRfid(baseInventory.getTyreRfid());
recordWarehousing.setType("2");
recordWarehousing.setCreateTime(DateUtils.getNowDate());
recordWarehousing.setCreateBy(baseInventory.getCreateBy());
int m = recordWarehousingMapper.insertRecordWarehousing(recordWarehousing);
//调拨出库要修改轮胎的所属部门
int w = baseTyreMapper.updateBaseTyre(baseTyre);
if (n>0&&m>0){
return AjaxResult.success("出库成功!");
}
}catch (Exception e){
return AjaxResult.error(e.getMessage());
}
return AjaxResult.error("出库失败!");
}
} }

@ -89,7 +89,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="tyrePattern != null and tyrePattern != ''"> and tyre_pattern = #{tyrePattern}</if> <if test="tyrePattern != null and tyrePattern != ''"> and tyre_pattern = #{tyrePattern}</if>
<if test="tyreType != null and tyreType != ''"> and tyre_type = #{tyreType}</if> <if test="tyreType != null and tyreType != ''"> and tyre_type = #{tyreType}</if>
<if test="team != null and team != ''"> and d.team like concat('%', #{team}, '%')</if> <if test="team != null and team != ''"> and d.team like concat('%', #{team}, '%')</if>
<if test="carNo != null and carNo != ''"> and car_no = #{carNo}</if> <if test="carNo != null and carNo != ''"> and d.car_no = #{carNo}</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 --> <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(d.create_time,'%Y%m%d') &gt;= date_format(#{params.beginTime},'%Y%m%d') AND date_format(d.create_time,'%Y%m%d') &gt;= date_format(#{params.beginTime},'%Y%m%d')
</if> </if>

Loading…
Cancel
Save