feat(cost): 添加成本管理系统核心功能模块

- 实现成本项目配置管理,包括增删改查和导出功能
- 实现成本单价历史记录功能,支持按时间追溯价格变化
- 实现生产成本明细管理,记录各班次的详细成本数据
- 集成权限控制和操作日志记录功能
- 提供完整的CRUD接口和数据持久化支持
- 集成Excel导入导出功能便于数据统计分析
This commit is contained in:
2026-06-09 10:20:04 +08:00
parent dd70c94dd7
commit 58efd3841e
32 changed files with 2812 additions and 0 deletions

View File

@@ -0,0 +1,104 @@
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.CostItem;
import com.ruoyi.cost.service.ICostItemService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 成本项目配置Controller
*
* @author ruoyi
* @date 2026-06-09
*/
@RestController
@RequestMapping("/cost/item")
public class CostItemController extends BaseController
{
@Autowired
private ICostItemService costItemService;
/**
* 查询成本项目配置列表
*/
@PreAuthorize("@ss.hasPermi('cost:item:list')")
@GetMapping("/list")
public TableDataInfo list(CostItem costItem)
{
startPage();
List<CostItem> list = costItemService.selectCostItemList(costItem);
return getDataTable(list);
}
/**
* 导出成本项目配置列表
*/
@PreAuthorize("@ss.hasPermi('cost:item:export')")
@Log(title = "成本项目配置", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, CostItem costItem)
{
List<CostItem> list = costItemService.selectCostItemList(costItem);
ExcelUtil<CostItem> util = new ExcelUtil<CostItem>(CostItem.class);
util.exportExcel(response, list, "成本项目配置数据");
}
/**
* 获取成本项目配置详细信息
*/
@PreAuthorize("@ss.hasPermi('cost:item:query')")
@GetMapping(value = "/{itemId}")
public AjaxResult getInfo(@PathVariable("itemId") Long itemId)
{
return success(costItemService.selectCostItemByItemId(itemId));
}
/**
* 新增成本项目配置
*/
@PreAuthorize("@ss.hasPermi('cost:item:add')")
@Log(title = "成本项目配置", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody CostItem costItem)
{
return toAjax(costItemService.insertCostItem(costItem));
}
/**
* 修改成本项目配置
*/
@PreAuthorize("@ss.hasPermi('cost:item:edit')")
@Log(title = "成本项目配置", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody CostItem costItem)
{
return toAjax(costItemService.updateCostItem(costItem));
}
/**
* 删除成本项目配置
*/
@PreAuthorize("@ss.hasPermi('cost:item:remove')")
@Log(title = "成本项目配置", businessType = BusinessType.DELETE)
@DeleteMapping("/{itemIds}")
public AjaxResult remove(@PathVariable Long[] itemIds)
{
return toAjax(costItemService.deleteCostItemByItemIds(itemIds));
}
}

View File

@@ -0,0 +1,104 @@
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));
}
}

View File

@@ -0,0 +1,104 @@
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.CostProdDetail;
import com.ruoyi.cost.service.ICostProdDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 生产成本明细Controller
*
* @author ruoyi
* @date 2026-06-09
*/
@RestController
@RequestMapping("/cost/detail")
public class CostProdDetailController extends BaseController
{
@Autowired
private ICostProdDetailService costProdDetailService;
/**
* 查询生产成本明细列表
*/
@PreAuthorize("@ss.hasPermi('cost:detail:list')")
@GetMapping("/list")
public TableDataInfo list(CostProdDetail costProdDetail)
{
startPage();
List<CostProdDetail> list = costProdDetailService.selectCostProdDetailList(costProdDetail);
return getDataTable(list);
}
/**
* 导出生产成本明细列表
*/
@PreAuthorize("@ss.hasPermi('cost:detail:export')")
@Log(title = "生产成本明细", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, CostProdDetail costProdDetail)
{
List<CostProdDetail> list = costProdDetailService.selectCostProdDetailList(costProdDetail);
ExcelUtil<CostProdDetail> util = new ExcelUtil<CostProdDetail>(CostProdDetail.class);
util.exportExcel(response, list, "生产成本明细数据");
}
/**
* 获取生产成本明细详细信息
*/
@PreAuthorize("@ss.hasPermi('cost:detail:query')")
@GetMapping(value = "/{detailId}")
public AjaxResult getInfo(@PathVariable("detailId") Long detailId)
{
return success(costProdDetailService.selectCostProdDetailByDetailId(detailId));
}
/**
* 新增生产成本明细
*/
@PreAuthorize("@ss.hasPermi('cost:detail:add')")
@Log(title = "生产成本明细", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody CostProdDetail costProdDetail)
{
return toAjax(costProdDetailService.insertCostProdDetail(costProdDetail));
}
/**
* 修改生产成本明细
*/
@PreAuthorize("@ss.hasPermi('cost:detail:edit')")
@Log(title = "生产成本明细", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody CostProdDetail costProdDetail)
{
return toAjax(costProdDetailService.updateCostProdDetail(costProdDetail));
}
/**
* 删除生产成本明细
*/
@PreAuthorize("@ss.hasPermi('cost:detail:remove')")
@Log(title = "生产成本明细", businessType = BusinessType.DELETE)
@DeleteMapping("/{detailIds}")
public AjaxResult remove(@PathVariable Long[] detailIds)
{
return toAjax(costProdDetailService.deleteCostProdDetailByDetailIds(detailIds));
}
}

View File

@@ -0,0 +1,104 @@
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.CostProdMetric;
import com.ruoyi.cost.service.ICostProdMetricService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 生产指标明细Controller
*
* @author ruoyi
* @date 2026-06-09
*/
@RestController
@RequestMapping("/cost/metric")
public class CostProdMetricController extends BaseController
{
@Autowired
private ICostProdMetricService costProdMetricService;
/**
* 查询生产指标明细列表
*/
@PreAuthorize("@ss.hasPermi('cost:metric:list')")
@GetMapping("/list")
public TableDataInfo list(CostProdMetric costProdMetric)
{
startPage();
List<CostProdMetric> list = costProdMetricService.selectCostProdMetricList(costProdMetric);
return getDataTable(list);
}
/**
* 导出生产指标明细列表
*/
@PreAuthorize("@ss.hasPermi('cost:metric:export')")
@Log(title = "生产指标明细", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, CostProdMetric costProdMetric)
{
List<CostProdMetric> list = costProdMetricService.selectCostProdMetricList(costProdMetric);
ExcelUtil<CostProdMetric> util = new ExcelUtil<CostProdMetric>(CostProdMetric.class);
util.exportExcel(response, list, "生产指标明细数据");
}
/**
* 获取生产指标明细详细信息
*/
@PreAuthorize("@ss.hasPermi('cost:metric:query')")
@GetMapping(value = "/{metricId}")
public AjaxResult getInfo(@PathVariable("metricId") Long metricId)
{
return success(costProdMetricService.selectCostProdMetricByMetricId(metricId));
}
/**
* 新增生产指标明细
*/
@PreAuthorize("@ss.hasPermi('cost:metric:add')")
@Log(title = "生产指标明细", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody CostProdMetric costProdMetric)
{
return toAjax(costProdMetricService.insertCostProdMetric(costProdMetric));
}
/**
* 修改生产指标明细
*/
@PreAuthorize("@ss.hasPermi('cost:metric:edit')")
@Log(title = "生产指标明细", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody CostProdMetric costProdMetric)
{
return toAjax(costProdMetricService.updateCostProdMetric(costProdMetric));
}
/**
* 删除生产指标明细
*/
@PreAuthorize("@ss.hasPermi('cost:metric:remove')")
@Log(title = "生产指标明细", businessType = BusinessType.DELETE)
@DeleteMapping("/{metricIds}")
public AjaxResult remove(@PathVariable Long[] metricIds)
{
return toAjax(costProdMetricService.deleteCostProdMetricByMetricIds(metricIds));
}
}

View File

@@ -0,0 +1,104 @@
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.CostProdReport;
import com.ruoyi.cost.service.ICostProdReportService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 生产月报Controller
*
* @author ruoyi
* @date 2026-06-09
*/
@RestController
@RequestMapping("/cost/report")
public class CostProdReportController extends BaseController
{
@Autowired
private ICostProdReportService costProdReportService;
/**
* 查询生产月报列表
*/
@PreAuthorize("@ss.hasPermi('cost:report:list')")
@GetMapping("/list")
public TableDataInfo list(CostProdReport costProdReport)
{
startPage();
List<CostProdReport> list = costProdReportService.selectCostProdReportList(costProdReport);
return getDataTable(list);
}
/**
* 导出生产月报列表
*/
@PreAuthorize("@ss.hasPermi('cost:report:export')")
@Log(title = "生产月报", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, CostProdReport costProdReport)
{
List<CostProdReport> list = costProdReportService.selectCostProdReportList(costProdReport);
ExcelUtil<CostProdReport> util = new ExcelUtil<CostProdReport>(CostProdReport.class);
util.exportExcel(response, list, "生产月报数据");
}
/**
* 获取生产月报详细信息
*/
@PreAuthorize("@ss.hasPermi('cost:report:query')")
@GetMapping(value = "/{reportId}")
public AjaxResult getInfo(@PathVariable("reportId") Long reportId)
{
return success(costProdReportService.selectCostProdReportByReportId(reportId));
}
/**
* 新增生产月报
*/
@PreAuthorize("@ss.hasPermi('cost:report:add')")
@Log(title = "生产月报", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody CostProdReport costProdReport)
{
return toAjax(costProdReportService.insertCostProdReport(costProdReport));
}
/**
* 修改生产月报
*/
@PreAuthorize("@ss.hasPermi('cost:report:edit')")
@Log(title = "生产月报", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody CostProdReport costProdReport)
{
return toAjax(costProdReportService.updateCostProdReport(costProdReport));
}
/**
* 删除生产月报
*/
@PreAuthorize("@ss.hasPermi('cost:report:remove')")
@Log(title = "生产月报", businessType = BusinessType.DELETE)
@DeleteMapping("/{reportIds}")
public AjaxResult remove(@PathVariable Long[] reportIds)
{
return toAjax(costProdReportService.deleteCostProdReportByReportIds(reportIds));
}
}