Commit d9ba64a8 by yubin

inventory

parent 6d104f90
package com.ruoyi.inventory.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.inventory.domain.Inventory;
import com.ruoyi.inventory.service.IInventoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 库存Controller
*
* @author ruoyi
* @date 2025-12-03
*/
@RestController
@RequestMapping("/inventory/inventory")
public class InventoryController extends BaseController
{
@Autowired
private IInventoryService inventoryService;
/**
* 查询库存列表
*/
@PreAuthorize("@ss.hasPermi('inventory:inventory:list')")
@GetMapping("/list")
public TableDataInfo list(Inventory inventory)
{
startPage();
List<Inventory> list = inventoryService.selectInventoryList(inventory);
return getDataTable(list);
}
/**
* 导出库存列表
*/
@PreAuthorize("@ss.hasPermi('inventory:inventory:export')")
@Log(title = "库存", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Inventory inventory)
{
List<Inventory> list = inventoryService.selectInventoryList(inventory);
ExcelUtil<Inventory> util = new ExcelUtil<Inventory>(Inventory.class);
util.exportExcel(response, list, "库存数据");
}
/**
* 获取库存详细信息
*/
@PreAuthorize("@ss.hasPermi('inventory:inventory:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id)
{
return success(inventoryService.selectInventoryById(id));
}
/**
* 新增库存
*/
@PreAuthorize("@ss.hasPermi('inventory:inventory:add')")
@Log(title = "库存", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Inventory inventory)
{
return toAjax(inventoryService.insertInventory(inventory));
}
/**
* 修改库存
*/
@PreAuthorize("@ss.hasPermi('inventory:inventory:edit')")
@Log(title = "库存", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Inventory inventory)
{
return toAjax(inventoryService.updateInventory(inventory));
}
/**
* 删除库存
*/
@PreAuthorize("@ss.hasPermi('inventory:inventory:remove')")
@Log(title = "库存", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(inventoryService.deleteInventoryByIds(ids));
}
}
package com.ruoyi.inventory.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 库存对象 inventory
*
* @author ruoyi
* @date 2025-12-03
*/
public class Inventory extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 编号 */
private String id;
/** 库存类别1普通2退库 */
@Excel(name = "库存类别1普通2退库")
private Long inventoryType;
/** 入库单号 */
@Excel(name = "入库单号")
private String orderId;
/** 物料ID 检索条件 */
@Excel(name = "物料ID 检索条件")
private String materialId;
/** 批次ID 检索条件 */
@Excel(name = "批次ID 检索条件")
private String batchId;
/** 库位ID 检索条件 */
@Excel(name = "库位ID 检索条件")
private String locationId;
/** 货主ID 检索条件 */
@Excel(name = "货主ID 检索条件")
private String ownerId;
/** 库存数量 */
@Excel(name = "库存数量")
private Long quantity;
/** 锁定数量 */
@Excel(name = "锁定数量")
private Long lockedQuantity;
/** 单位重量 */
@Excel(name = "单位重量")
private Long unitWeight;
/** 总重量 暂无用 */
@Excel(name = "总重量 暂无用")
private Long totalWeight;
/** 总体积 暂无用 */
@Excel(name = "总体积 暂无用")
private Long totalVolume;
/** 生产日期 暂无用 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "生产日期 暂无用", width = 30, dateFormat = "yyyy-MM-dd")
private Date productionDate;
/** 失效日期 暂无用 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "失效日期 暂无用", width = 30, dateFormat = "yyyy-MM-dd")
private Date expirationDate;
/** 库存状态 0-已出库 1-正常 字典,检索条件 */
@Excel(name = "库存状态 0-已出库 1-正常 字典,检索条件")
private Long inventoryStatus;
/** 最后入库时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "最后入库时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date lastInboundTime;
/** 最后出库时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "最后出库时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date lastOutboundTime;
/** 应用数据1使用0删除 删除用 */
@Excel(name = "应用数据1使用0删除 删除用")
private Long isUsed;
/** 排序 */
@Excel(name = "排序")
private Long sortNo;
/** 创建日期 */
@Excel(name = "创建日期")
private String createUserCode;
/** 排序号 */
@Excel(name = "排序号")
private String updateUserCode;
public void setId(String id)
{
this.id = id;
}
public String getId()
{
return id;
}
public void setInventoryType(Long inventoryType)
{
this.inventoryType = inventoryType;
}
public Long getInventoryType()
{
return inventoryType;
}
public void setOrderId(String orderId)
{
this.orderId = orderId;
}
public String getOrderId()
{
return orderId;
}
public void setMaterialId(String materialId)
{
this.materialId = materialId;
}
public String getMaterialId()
{
return materialId;
}
public void setBatchId(String batchId)
{
this.batchId = batchId;
}
public String getBatchId()
{
return batchId;
}
public void setLocationId(String locationId)
{
this.locationId = locationId;
}
public String getLocationId()
{
return locationId;
}
public void setOwnerId(String ownerId)
{
this.ownerId = ownerId;
}
public String getOwnerId()
{
return ownerId;
}
public void setQuantity(Long quantity)
{
this.quantity = quantity;
}
public Long getQuantity()
{
return quantity;
}
public void setLockedQuantity(Long lockedQuantity)
{
this.lockedQuantity = lockedQuantity;
}
public Long getLockedQuantity()
{
return lockedQuantity;
}
public void setUnitWeight(Long unitWeight)
{
this.unitWeight = unitWeight;
}
public Long getUnitWeight()
{
return unitWeight;
}
public void setTotalWeight(Long totalWeight)
{
this.totalWeight = totalWeight;
}
public Long getTotalWeight()
{
return totalWeight;
}
public void setTotalVolume(Long totalVolume)
{
this.totalVolume = totalVolume;
}
public Long getTotalVolume()
{
return totalVolume;
}
public void setProductionDate(Date productionDate)
{
this.productionDate = productionDate;
}
public Date getProductionDate()
{
return productionDate;
}
public void setExpirationDate(Date expirationDate)
{
this.expirationDate = expirationDate;
}
public Date getExpirationDate()
{
return expirationDate;
}
public void setInventoryStatus(Long inventoryStatus)
{
this.inventoryStatus = inventoryStatus;
}
public Long getInventoryStatus()
{
return inventoryStatus;
}
public void setLastInboundTime(Date lastInboundTime)
{
this.lastInboundTime = lastInboundTime;
}
public Date getLastInboundTime()
{
return lastInboundTime;
}
public void setLastOutboundTime(Date lastOutboundTime)
{
this.lastOutboundTime = lastOutboundTime;
}
public Date getLastOutboundTime()
{
return lastOutboundTime;
}
public void setIsUsed(Long isUsed)
{
this.isUsed = isUsed;
}
public Long getIsUsed()
{
return isUsed;
}
public void setSortNo(Long sortNo)
{
this.sortNo = sortNo;
}
public Long getSortNo()
{
return sortNo;
}
public void setCreateUserCode(String createUserCode)
{
this.createUserCode = createUserCode;
}
public String getCreateUserCode()
{
return createUserCode;
}
public void setUpdateUserCode(String updateUserCode)
{
this.updateUserCode = updateUserCode;
}
public String getUpdateUserCode()
{
return updateUserCode;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("inventoryType", getInventoryType())
.append("orderId", getOrderId())
.append("materialId", getMaterialId())
.append("batchId", getBatchId())
.append("locationId", getLocationId())
.append("ownerId", getOwnerId())
.append("quantity", getQuantity())
.append("lockedQuantity", getLockedQuantity())
.append("unitWeight", getUnitWeight())
.append("totalWeight", getTotalWeight())
.append("totalVolume", getTotalVolume())
.append("productionDate", getProductionDate())
.append("expirationDate", getExpirationDate())
.append("inventoryStatus", getInventoryStatus())
.append("lastInboundTime", getLastInboundTime())
.append("lastOutboundTime", getLastOutboundTime())
.append("isUsed", getIsUsed())
.append("sortNo", getSortNo())
.append("createTime", getCreateTime())
.append("createUserCode", getCreateUserCode())
.append("updateTime", getUpdateTime())
.append("updateUserCode", getUpdateUserCode())
.toString();
}
}
package com.ruoyi.inventory.mapper;
import java.util.List;
import com.ruoyi.inventory.domain.Inventory;
/**
* 库存Mapper接口
*
* @author ruoyi
* @date 2025-12-03
*/
public interface InventoryMapper
{
/**
* 查询库存
*
* @param id 库存主键
* @return 库存
*/
public Inventory selectInventoryById(String id);
/**
* 查询库存
*
* @param id 库存主键
* @return 库存
*/
public Inventory selectInventory(Inventory inventory);
/**
* 查询库存列表
*
* @param inventory 库存
* @return 库存集合
*/
public List<Inventory> selectInventoryList(Inventory inventory);
/**
* 新增库存
*
* @param inventory 库存
* @return 结果
*/
public int insertInventory(Inventory inventory);
/**
* 修改库存
*
* @param inventory 库存
* @return 结果
*/
public int updateInventory(Inventory inventory);
/**
* 删除库存
*
* @param id 库存主键
* @return 结果
*/
public int deleteInventoryById(String id);
/**
* 批量删除库存
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteInventoryByIds(String[] ids);
}
package com.ruoyi.inventory.service;
import java.util.List;
import com.ruoyi.inventory.domain.Inventory;
/**
* 库存Service接口
*
* @author ruoyi
* @date 2025-12-03
*/
public interface IInventoryService
{
/**
* 查询库存
*
* @param id 库存主键
* @return 库存
*/
public Inventory selectInventoryById(String id);
/**
* 查询库存列表
*
* @param inventory 库存
* @return 库存集合
*/
public List<Inventory> selectInventoryList(Inventory inventory);
Inventory selectInventory(Inventory inventory);
/**
* 新增库存
*
* @param inventory 库存
* @return 结果
*/
public int insertInventory(Inventory inventory);
/**
* 修改库存
*
* @param inventory 库存
* @return 结果
*/
public int updateInventory(Inventory inventory);
/**
* 批量删除库存
*
* @param ids 需要删除的库存主键集合
* @return 结果
*/
public int deleteInventoryByIds(String[] ids);
/**
* 删除库存信息
*
* @param id 库存主键
* @return 结果
*/
public int deleteInventoryById(String id);
}
package com.ruoyi.inventory.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.inventory.domain.OutboundOrderLog;
import com.ruoyi.inventory.mapper.OutboundOrderLogMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.inventory.mapper.InventoryMapper;
import com.ruoyi.inventory.domain.Inventory;
import com.ruoyi.inventory.service.IInventoryService;
/**
* 库存Service业务层处理
*
* @author ruoyi
* @date 2025-12-03
*/
@Service
public class InventoryServiceImpl implements IInventoryService
{
@Autowired
private InventoryMapper inventoryMapper;
@Autowired
private OutboundOrderLogMapper outboundOrderLogMapper;
/**
* 查询库存
*
* @param id 库存主键
* @return 库存
*/
@Override
public Inventory selectInventoryById(String id)
{
return inventoryMapper.selectInventoryById(id);
}
/**
* 查询库存列表
*
* @param inventory 库存
* @return 库存
*/
@Override
public List<Inventory> selectInventoryList(Inventory inventory)
{
return inventoryMapper.selectInventoryList(inventory);
}
@Override
public Inventory selectInventory(Inventory inventory)
{
Inventory inventory1 = inventoryMapper.selectInventory(inventory);
OutboundOrderLog outboundOrderLog = new OutboundOrderLog();
BeanUtils.copyProperties(inventory1,outboundOrderLog);
inventory1.setLockedQuantity(outboundOrderLogMapper.selectLockedQuantity(outboundOrderLog));
return inventory1;
}
/**
* 新增库存
*
* @param inventory 库存
* @return 结果
*/
@Override
public int insertInventory(Inventory inventory)
{
inventory.setCreateTime(DateUtils.getNowDate());
return inventoryMapper.insertInventory(inventory);
}
/**
* 修改库存
*
* @param inventory 库存
* @return 结果
*/
@Override
public int updateInventory(Inventory inventory)
{
inventory.setUpdateTime(DateUtils.getNowDate());
return inventoryMapper.updateInventory(inventory);
}
/**
* 批量删除库存
*
* @param ids 需要删除的库存主键
* @return 结果
*/
@Override
public int deleteInventoryByIds(String[] ids)
{
return inventoryMapper.deleteInventoryByIds(ids);
}
/**
* 删除库存信息
*
* @param id 库存主键
* @return 结果
*/
@Override
public int deleteInventoryById(String id)
{
return inventoryMapper.deleteInventoryById(id);
}
}
...@@ -29,7 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -29,7 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectWarehousesList" parameterType="Warehouses" resultMap="WarehousesResult"> <select id="selectWarehousesList" parameterType="Warehouses" resultMap="WarehousesResult">
<include refid="selectWarehousesVo"/> <include refid="selectWarehousesVo"/>
<where> where is_used=1
<if test="warehousesCode != null and warehousesCode != ''"> and warehouses_code = #{warehousesCode}</if> <if test="warehousesCode != null and warehousesCode != ''"> and warehouses_code = #{warehousesCode}</if>
<if test="warehousesName != null and warehousesName != ''"> and warehouses_name like concat('%', #{warehousesName}, '%')</if> <if test="warehousesName != null and warehousesName != ''"> and warehouses_name like concat('%', #{warehousesName}, '%')</if>
<if test="warehouseType != null "> and warehouse_type = #{warehouseType}</if> <if test="warehouseType != null "> and warehouse_type = #{warehouseType}</if>
...@@ -43,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -43,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="sortNo != null "> and sort_no = #{sortNo}</if> <if test="sortNo != null "> and sort_no = #{sortNo}</if>
<if test="createUserCode != null and createUserCode != ''"> and create_user_code = #{createUserCode}</if> <if test="createUserCode != null and createUserCode != ''"> and create_user_code = #{createUserCode}</if>
<if test="updateUserCode != null and updateUserCode != ''"> and update_user_code = #{updateUserCode}</if> <if test="updateUserCode != null and updateUserCode != ''"> and update_user_code = #{updateUserCode}</if>
</where>
</select> </select>
<select id="selectWarehousesById" parameterType="String" resultMap="WarehousesResult"> <select id="selectWarehousesById" parameterType="String" resultMap="WarehousesResult">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论