| | |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | |
| | | import com.ruoyi.warehouse.pojo.Warehouse; |
| | | import com.ruoyi.warehouse.service.WarehouseGoodsShelvesService; |
| | | import com.ruoyi.warehouse.service.WarehouseService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | @Autowired |
| | | private WarehouseService warehouseService; |
| | | |
| | | |
| | | @GetMapping("/listPage") |
| | | @ApiOperation("仓库-分页查询") |
| | | @Log(title = "仓库-分页查询", businessType = BusinessType.OTHER) |
| | | public AjaxResult listPage(Page page, Warehouse warehouse) { |
| | | IPage<Warehouse> listPage = warehouseService.listPage(page, warehouse); |
| | | return AjaxResult.success(listPage); |
| | | @ApiOperation("仓库-查询") |
| | | @Log(title = "仓库-查询", businessType = BusinessType.OTHER) |
| | | public AjaxResult listPage( Warehouse warehouse) { |
| | | return AjaxResult.success(warehouseService.listPage( warehouse)); |
| | | } |
| | | @PostMapping("/add") |
| | | @ApiOperation("仓库-添加") |
| | | @Log(title = "仓库-添加", businessType = BusinessType.INSERT) |
| | | public AjaxResult add(@RequestBody Warehouse warehouse) { |
| | | boolean save = warehouseService.save(warehouse); |
| | | return save ? AjaxResult.success("添加成功") : AjaxResult.error("添加失败"); |
| | | return warehouseService.save(warehouse) ? AjaxResult.success("添加成功") : AjaxResult.error("添加失败"); |
| | | } |
| | | |
| | | @PostMapping("/update") |
| | |
| | | @Log(title = "仓库-删除", businessType = BusinessType.DELETE) |
| | | public AjaxResult delete(@RequestBody List<Long> ids) { |
| | | if(CollectionUtils.isEmpty(ids)) return AjaxResult.error("请传入要删除的ID"); |
| | | boolean remove = warehouseService.deleteByIds(ids); |
| | | return remove ? AjaxResult.success("删除成功") : AjaxResult.error("删除失败"); |
| | | return warehouseService.deleteByIds(ids) ? AjaxResult.success("删除成功") : AjaxResult.error("删除失败"); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.warehouse.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | IPage<WarehouseGoodsShelves> listPage = warehouseGoodsShelvesService.listPage(page, warehouseGoodsShelves); |
| | | return AjaxResult.success(listPage); |
| | | } |
| | | |
| | | @GetMapping("/listById") |
| | | @ApiOperation("商品货架-查询") |
| | | @Log(title = "商品货架-查询", businessType = BusinessType.OTHER) |
| | | public AjaxResult listById(Long warehouseId) { |
| | | List<WarehouseGoodsShelves> list = warehouseGoodsShelvesService.list(new QueryWrapper<WarehouseGoodsShelves>().lambda() |
| | | .eq(WarehouseGoodsShelves::getWarehouseId, warehouseId)); |
| | | return AjaxResult.success(list); |
| | | } |
| | | @PostMapping("/add") |
| | | @ApiOperation("商品货架-添加") |
| | | @Log(title = "商品货架-添加", businessType = BusinessType.INSERT) |
| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author 86151 |
| | | * @description 针对表【warehouse(仓库表)】的数据库操作Mapper |
| | |
| | | @Mapper |
| | | public interface WarehouseMapper extends BaseMapper<Warehouse> { |
| | | |
| | | IPage<Warehouse> listPage(Page page,@Param("warehouse") Warehouse warehouse); |
| | | List<Warehouse> listPage(@Param("warehouse") Warehouse warehouse); |
| | | } |
| | | |
| | | |
| | |
| | | package com.ruoyi.warehouse.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | |
| | | /** |
| | | * 创建用户 |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long createUser; |
| | | |
| | | /** |
| | | * 修改时间 |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updateTime; |
| | | |
| | | /** |
| | | * 修改用户 |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Long updateUser; |
| | | |
| | | /** |
| | | * 租户ID |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long tenantId; |
| | | |
| | | @TableField(exist = false) |
| | | private static final long serialVersionUID = 1L; |
| | | } |
| | |
| | | package com.ruoyi.warehouse.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | |
| | | /** |
| | | * 创建用户 |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long createUser; |
| | | |
| | | /** |
| | | * 修改时间 |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updateTime; |
| | | |
| | | /** |
| | | * 修改用户 |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Long updateUser; |
| | | |
| | | /** |
| | | * 租户ID |
| | | */ |
| | | |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long tenantId; |
| | | |
| | | @TableField(exist = false) |
| | | private static final long serialVersionUID = 1L; |
| | | } |
| | |
| | | package com.ruoyi.warehouse.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | |
| | | @Data |
| | | @ApiModel(value = "仓库货架层,列表") |
| | | public class WarehouseGoodsShelvesRowcol implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | /** |
| | | * |
| | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | |
| | | private LocalDateTime createTime; |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 修改时间 |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updateTime; |
| | | |
| | | /** |
| | | * 修改用户 |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long updateUser; |
| | | |
| | | /** |
| | | * 租户ID |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long tenantId; |
| | | /** |
| | | * 备注 |
| | |
| | | package com.ruoyi.warehouse.service; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.warehouse.pojo.Warehouse; |
| | | |
| | |
| | | */ |
| | | public interface WarehouseService extends IService<Warehouse> { |
| | | |
| | | IPage<Warehouse> listPage(Page page, Warehouse warehouse); |
| | | List<Warehouse> listPage( Warehouse warehouse); |
| | | |
| | | boolean deleteByIds(List<Long> ids); |
| | | } |
| | |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean add(WarehouseGoodsShelves warehouseGoodsShelves) { |
| | | int insert = warehouseGoodsShelvesMapper.insert(warehouseGoodsShelves); |
| | | if (insert <= 0) { |
| | |
| | | } |
| | | Long shelvesId = warehouseGoodsShelves.getId(); |
| | | Long warehouseId = warehouseGoodsShelves.getWarehouseId(); |
| | | Long createUser = warehouseGoodsShelves.getCreateUser(); |
| | | Long updateUser = warehouseGoodsShelves.getUpdateUser(); |
| | | // 3. 批量创建行列记录 |
| | | List<WarehouseGoodsShelvesRowcol> rowcolList = new ArrayList<>(); |
| | | for (long i = 1; i <= warehouseGoodsShelves.getStorey(); i++) { |
| | |
| | | rowcol.setStorey(i); |
| | | rowcol.setArrange(j); |
| | | rowcol.setWarehouseGoodsShelvesId(shelvesId); |
| | | rowcol.setWarehouseId(warehouseId); |
| | | rowcol.setCreateUser(createUser); |
| | | rowcol.setUpdateUser(updateUser); |
| | | rowcolList.add(rowcol); |
| | | } |
| | | } |
| | |
| | | if (!rowcolList.isEmpty()) { |
| | | try { |
| | | // 使用批量插入方法替代循环单条插入 |
| | | boolean saveBatch = warehouseGoodsShelvesRowcolService.saveBatch(rowcolList); |
| | | |
| | | if (!saveBatch) { |
| | | log.warn("货架[{}]的行列记录部分添加失败", shelvesId); |
| | | } |
| | | warehouseGoodsShelvesRowcolService.saveBatch(rowcolList); |
| | | } catch (Exception e) { |
| | | log.error("货架[{}]的行列记录批量添加失败", shelvesId, e); |
| | | // 抛出异常触发事务回滚 |
| | |
| | | } |
| | | |
| | | log.info("货架[{}]添加成功,层数:{},排数:{}", |
| | | shelvesId, |
| | | warehouseGoodsShelves.getGoodsShelvesName(), |
| | | warehouseGoodsShelves.getStorey(), |
| | | warehouseGoodsShelves.getArrange()); |
| | | return true; |
| | |
| | | package com.ruoyi.warehouse.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.sql.Array; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | private WarehouseGoodsShelvesService warehouseGoodsShelvesService; |
| | | |
| | | @Override |
| | | public IPage<Warehouse> listPage(Page page, Warehouse warehouse) { |
| | | return warehouseMapper.listPage(page, warehouse); |
| | | public List<Warehouse> listPage(Warehouse warehouse) { |
| | | return warehouseMapper.listPage( warehouse); |
| | | } |
| | | |
| | | @Override |
| | | public boolean deleteByIds(List<Long> ids) { |
| | | for (Long id : ids) { |
| | | WarehouseGoodsShelves shelves = new WarehouseGoodsShelves(); |
| | | shelves.setWarehouseId(id); |
| | | IPage<WarehouseGoodsShelves> page = warehouseGoodsShelvesService.listPage(new Page<>(), shelves); |
| | | if(page.getRecords().size()>0){ |
| | | log.error("仓库下有货架,不能删除"); |
| | | List<WarehouseGoodsShelves> list = warehouseGoodsShelvesService.list(new QueryWrapper<WarehouseGoodsShelves>().lambda() |
| | | .eq(WarehouseGoodsShelves::getWarehouseId, id)); |
| | | if(list.size()>0){ |
| | | log.error("仓库下有货架,不能删除 重新选择"); |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | return removeByIds(ids); |
| | | } |
| | | } |
| | | |
| | |
| | | select * from warehouse |
| | | <where> |
| | | 1=1 |
| | | <if test="warehouseName != null"> |
| | | and warehouse_name like concat('%',#{warehouseName},'%') |
| | | <if test="warehouse.warehouseName != null"> |
| | | and warehouse_name like concat('%',#{warehouse.warehouseName},'%') |
| | | </if> |
| | | </where> |
| | | </select> |