Files
double-rack/ruoyi-cost/src/main/java/com/ruoyi/cost/controller/CostPriceController.java
Joshi 58efd3841e feat(cost): 添加成本管理系统核心功能模块
- 实现成本项目配置管理,包括增删改查和导出功能
- 实现成本单价历史记录功能,支持按时间追溯价格变化
- 实现生产成本明细管理,记录各班次的详细成本数据
- 集成权限控制和操作日志记录功能
- 提供完整的CRUD接口和数据持久化支持
- 集成Excel导入导出功能便于数据统计分析
2026-06-09 10:20:04 +08:00

105 lines
3.5 KiB
Java

package com.ruoyi.cost.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.cost.domain.CostPrice;
import com.ruoyi.cost.service.ICostPriceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 成本单价历史Controller
*
* @author ruoyi
* @date 2026-06-09
*/
@RestController
@RequestMapping("/cost/price")
public class CostPriceController extends BaseController
{
@Autowired
private ICostPriceService costPriceService;
/**
* 查询成本单价历史列表
*/
@PreAuthorize("@ss.hasPermi('cost:price:list')")
@GetMapping("/list")
public TableDataInfo list(CostPrice costPrice)
{
startPage();
List<CostPrice> list = costPriceService.selectCostPriceList(costPrice);
return getDataTable(list);
}
/**
* 导出成本单价历史列表
*/
@PreAuthorize("@ss.hasPermi('cost:price:export')")
@Log(title = "成本单价历史", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, CostPrice costPrice)
{
List<CostPrice> list = costPriceService.selectCostPriceList(costPrice);
ExcelUtil<CostPrice> util = new ExcelUtil<CostPrice>(CostPrice.class);
util.exportExcel(response, list, "成本单价历史数据");
}
/**
* 获取成本单价历史详细信息
*/
@PreAuthorize("@ss.hasPermi('cost:price:query')")
@GetMapping(value = "/{priceId}")
public AjaxResult getInfo(@PathVariable("priceId") Long priceId)
{
return success(costPriceService.selectCostPriceByPriceId(priceId));
}
/**
* 新增成本单价历史
*/
@PreAuthorize("@ss.hasPermi('cost:price:add')")
@Log(title = "成本单价历史", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody CostPrice costPrice)
{
return toAjax(costPriceService.insertCostPrice(costPrice));
}
/**
* 修改成本单价历史
*/
@PreAuthorize("@ss.hasPermi('cost:price:edit')")
@Log(title = "成本单价历史", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody CostPrice costPrice)
{
return toAjax(costPriceService.updateCostPrice(costPrice));
}
/**
* 删除成本单价历史
*/
@PreAuthorize("@ss.hasPermi('cost:price:remove')")
@Log(title = "成本单价历史", businessType = BusinessType.DELETE)
@DeleteMapping("/{priceIds}")
public AjaxResult remove(@PathVariable Long[] priceIds)
{
return toAjax(costPriceService.deleteCostPriceByPriceIds(priceIds));
}
}