2025-09-17 15:20:53 +08:00
|
|
|
|
package com.gear.oa.controller;
|
|
|
|
|
|
|
|
|
|
|
|
import com.gear.common.annotation.Log;
|
|
|
|
|
|
import com.gear.common.annotation.RepeatSubmit;
|
|
|
|
|
|
import com.gear.common.core.controller.BaseController;
|
|
|
|
|
|
import com.gear.common.core.domain.PageQuery;
|
|
|
|
|
|
import com.gear.common.core.domain.R;
|
|
|
|
|
|
import com.gear.common.core.page.TableDataInfo;
|
|
|
|
|
|
import com.gear.common.core.validate.AddGroup;
|
|
|
|
|
|
import com.gear.common.core.validate.EditGroup;
|
|
|
|
|
|
import com.gear.common.enums.BusinessType;
|
|
|
|
|
|
import com.gear.common.utils.poi.ExcelUtil;
|
|
|
|
|
|
import com.gear.oa.domain.bo.GearStockBo;
|
|
|
|
|
|
import com.gear.oa.domain.vo.GearStockVo;
|
|
|
|
|
|
import com.gear.oa.service.IGearStockService;
|
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import javax.validation.constraints.NotEmpty;
|
|
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
import java.util.List;
|
2026-05-18 17:48:43 +08:00
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
import java.math.BigDecimal;
|
2025-09-17 15:20:53 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 库存:原材料/产品与库区/库位的存放关系
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author Joshi
|
|
|
|
|
|
* @date 2025-07-18
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Validated
|
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
|
@RestController
|
|
|
|
|
|
@RequestMapping("/gear/stock")
|
|
|
|
|
|
public class GearStockController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
private final IGearStockService iGearStockService;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询库存:原材料/产品与库区/库位的存放关系列表
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/list")
|
|
|
|
|
|
public TableDataInfo<GearStockVo> list(GearStockBo bo, PageQuery pageQuery) {
|
|
|
|
|
|
return iGearStockService.queryPageList(bo, pageQuery);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 17:48:43 +08:00
|
|
|
|
@PostMapping("/sumQuantityByItemIds")
|
|
|
|
|
|
public R<Map<Long, BigDecimal>> sumQuantityByItemIds(@RequestParam(defaultValue = "product") String itemType,
|
|
|
|
|
|
@RequestBody List<Long> itemIds) {
|
|
|
|
|
|
return R.ok(iGearStockService.sumQuantityByItemIds(itemType, itemIds));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-17 15:20:53 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 导出库存:原材料/产品与库区/库位的存放关系列表
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Log(title = "库存:原材料/产品与库区/库位的存放关系", businessType = BusinessType.EXPORT)
|
|
|
|
|
|
@PostMapping("/export")
|
|
|
|
|
|
public void export(GearStockBo bo, HttpServletResponse response) {
|
|
|
|
|
|
List<GearStockVo> list = iGearStockService.queryList(bo);
|
|
|
|
|
|
ExcelUtil.exportExcel(list, "库存:原材料-产品与库区-库位的存放关系", GearStockVo.class, response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取库存:原材料/产品与库区/库位的存放关系详细信息
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param stockId 主键
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/{stockId}")
|
|
|
|
|
|
public R<GearStockVo> getInfo(@NotNull(message = "主键不能为空")
|
|
|
|
|
|
@PathVariable Long stockId) {
|
|
|
|
|
|
return R.ok(iGearStockService.queryById(stockId));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 新增库存:原材料/产品与库区/库位的存放关系
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Log(title = "库存:原材料/产品与库区/库位的存放关系", businessType = BusinessType.INSERT)
|
|
|
|
|
|
@RepeatSubmit()
|
|
|
|
|
|
@PostMapping()
|
|
|
|
|
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody GearStockBo bo) {
|
|
|
|
|
|
return toAjax(iGearStockService.insertByBo(bo));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 修改库存:原材料/产品与库区/库位的存放关系
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Log(title = "库存:原材料/产品与库区/库位的存放关系", businessType = BusinessType.UPDATE)
|
|
|
|
|
|
@RepeatSubmit()
|
|
|
|
|
|
@PutMapping()
|
|
|
|
|
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody GearStockBo bo) {
|
|
|
|
|
|
return toAjax(iGearStockService.updateByBo(bo));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 删除库存:原材料/产品与库区/库位的存放关系
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param stockIds 主键串
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Log(title = "库存:原材料/产品与库区/库位的存放关系", businessType = BusinessType.DELETE)
|
|
|
|
|
|
@DeleteMapping("/{stockIds}")
|
|
|
|
|
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
|
|
|
|
|
@PathVariable Long[] stockIds) {
|
|
|
|
|
|
return toAjax(iGearStockService.deleteWithValidByIds(Arrays.asList(stockIds), true));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 测试递归查询功能
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/test/warehouse/{warehouseId}")
|
|
|
|
|
|
public R<String> testWarehouseQuery(@PathVariable Long warehouseId) {
|
|
|
|
|
|
GearStockBo bo = new GearStockBo();
|
|
|
|
|
|
bo.setWarehouseId(warehouseId);
|
|
|
|
|
|
List<GearStockVo> list = iGearStockService.queryList(bo);
|
|
|
|
|
|
return R.ok("查询到 " + list.size() + " 条库存记录,仓库ID: " + warehouseId);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|