2025-12-02 17:58:16 +08:00
|
|
|
|
package com.klp.controller;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
2025-12-03 10:32:06 +08:00
|
|
|
|
import com.klp.service.IWmsCostCoilDailyService;
|
2025-12-02 17:58:16 +08:00
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import javax.validation.constraints.*;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import com.klp.common.annotation.RepeatSubmit;
|
|
|
|
|
|
import com.klp.common.annotation.Log;
|
|
|
|
|
|
import com.klp.common.core.controller.BaseController;
|
|
|
|
|
|
import com.klp.common.core.domain.PageQuery;
|
|
|
|
|
|
import com.klp.common.core.domain.R;
|
|
|
|
|
|
import com.klp.common.core.validate.AddGroup;
|
|
|
|
|
|
import com.klp.common.core.validate.EditGroup;
|
|
|
|
|
|
import com.klp.common.enums.BusinessType;
|
|
|
|
|
|
import com.klp.common.utils.poi.ExcelUtil;
|
2025-12-03 10:32:06 +08:00
|
|
|
|
import com.klp.domain.vo.WmsCostCoilDailyVo;
|
|
|
|
|
|
import com.klp.domain.bo.WmsCostCoilDailyBo;
|
2025-12-02 17:58:16 +08:00
|
|
|
|
import com.klp.common.core.page.TableDataInfo;
|
|
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
|
import org.springframework.format.annotation.DateTimeFormat;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 钢卷日成本记录表
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author klp
|
|
|
|
|
|
* @date 2025-11-25
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Validated
|
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
|
@RestController
|
|
|
|
|
|
@RequestMapping("/wms/cost/coil")
|
2025-12-03 10:32:06 +08:00
|
|
|
|
public class WmsCostCoilDailyController extends BaseController {
|
2025-12-02 17:58:16 +08:00
|
|
|
|
|
2025-12-03 10:32:06 +08:00
|
|
|
|
private final IWmsCostCoilDailyService iWmsCostCoilDailyService;
|
2025-12-02 17:58:16 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询钢卷日成本记录表列表
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/list")
|
2025-12-03 10:32:06 +08:00
|
|
|
|
public TableDataInfo<WmsCostCoilDailyVo> list(WmsCostCoilDailyBo bo, PageQuery pageQuery) {
|
|
|
|
|
|
return iWmsCostCoilDailyService.queryPageList(bo, pageQuery);
|
2025-12-02 17:58:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 导出钢卷日成本记录表列表
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Log(title = "钢卷日成本记录表", businessType = BusinessType.EXPORT)
|
|
|
|
|
|
@PostMapping("/export")
|
2025-12-03 10:32:06 +08:00
|
|
|
|
public void export(WmsCostCoilDailyBo bo, HttpServletResponse response) {
|
|
|
|
|
|
List<WmsCostCoilDailyVo> list = iWmsCostCoilDailyService.queryList(bo);
|
|
|
|
|
|
ExcelUtil.exportExcel(list, "钢卷日成本记录表", WmsCostCoilDailyVo.class, response);
|
2025-12-02 17:58:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取钢卷日成本记录表详细信息
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param costId 主键
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/{costId}")
|
2025-12-03 10:32:06 +08:00
|
|
|
|
public R<WmsCostCoilDailyVo> getInfo(@NotNull(message = "主键不能为空")
|
2025-12-02 17:58:16 +08:00
|
|
|
|
@PathVariable Long costId) {
|
2025-12-03 10:32:06 +08:00
|
|
|
|
return R.ok(iWmsCostCoilDailyService.queryById(costId));
|
2025-12-02 17:58:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 新增钢卷日成本记录表
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Log(title = "钢卷日成本记录表", businessType = BusinessType.INSERT)
|
|
|
|
|
|
@RepeatSubmit()
|
|
|
|
|
|
@PostMapping()
|
2025-12-03 10:32:06 +08:00
|
|
|
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody WmsCostCoilDailyBo bo) {
|
|
|
|
|
|
return toAjax(iWmsCostCoilDailyService.insertByBo(bo));
|
2025-12-02 17:58:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 修改钢卷日成本记录表
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Log(title = "钢卷日成本记录表", businessType = BusinessType.UPDATE)
|
|
|
|
|
|
@RepeatSubmit()
|
|
|
|
|
|
@PutMapping()
|
2025-12-03 10:32:06 +08:00
|
|
|
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody WmsCostCoilDailyBo bo) {
|
|
|
|
|
|
return toAjax(iWmsCostCoilDailyService.updateByBo(bo));
|
2025-12-02 17:58:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 删除钢卷日成本记录表
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param costIds 主键串
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Log(title = "钢卷日成本记录表", businessType = BusinessType.DELETE)
|
|
|
|
|
|
@DeleteMapping("/{costIds}")
|
|
|
|
|
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
|
|
|
|
|
@PathVariable Long[] costIds) {
|
2025-12-03 10:32:06 +08:00
|
|
|
|
return toAjax(iWmsCostCoilDailyService.deleteWithValidByIds(Arrays.asList(costIds), true));
|
2025-12-02 17:58:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 实时计算指定钢卷的成本
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param coilId 钢卷ID(可选)
|
|
|
|
|
|
* @param calcTime 计算时间点(可选,默认当前时间)
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("/calculate")
|
|
|
|
|
|
public R<Map<String, Object>> calculateCost(@RequestParam(required = false) Long coilId,
|
|
|
|
|
|
@RequestParam(required = false) LocalDateTime calcTime) {
|
2025-12-03 10:32:06 +08:00
|
|
|
|
Map<String, Object> result = iWmsCostCoilDailyService.calculateCost(coilId, calcTime);
|
2025-12-02 17:58:16 +08:00
|
|
|
|
if (result.containsKey("error")) {
|
|
|
|
|
|
return R.fail(result.get("error").toString());
|
|
|
|
|
|
}
|
|
|
|
|
|
return R.ok(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 批量计算多个钢卷的成本
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param coilIds 钢卷ID列表(支持逗号分隔的字符串或数组)
|
|
|
|
|
|
* @param calcTime 计算时间点(可选,默认当前时间)
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("/batchCalculateCost")
|
|
|
|
|
|
public R<List<Map<String, Object>>> batchCalculateCost(@RequestParam String coilIds,
|
|
|
|
|
|
@RequestParam(required = false) LocalDateTime calcTime) {
|
|
|
|
|
|
List<Long> coilIdList = new java.util.ArrayList<>();
|
|
|
|
|
|
if (coilIds != null && !coilIds.trim().isEmpty()) {
|
|
|
|
|
|
String[] ids = coilIds.split(",");
|
|
|
|
|
|
for (String id : ids) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
Long coilId = Long.parseLong(id.trim());
|
|
|
|
|
|
coilIdList.add(coilId);
|
|
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-12-03 10:32:06 +08:00
|
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> results = iWmsCostCoilDailyService.batchCalculateCost(coilIdList, calcTime);
|
2025-12-02 17:58:16 +08:00
|
|
|
|
return R.ok(results);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 批量计算钢卷成本(定时任务使用)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param calcDate 计算日期(可选,默认前一日)
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("/batchCalculate")
|
|
|
|
|
|
@Log(title = "批量计算钢卷成本", businessType = BusinessType.OTHER)
|
|
|
|
|
|
public R<Integer> batchCalculate(@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate calcDate) {
|
|
|
|
|
|
if (calcDate == null) {
|
|
|
|
|
|
calcDate = LocalDate.now().minusDays(1);
|
|
|
|
|
|
}
|
2025-12-03 10:32:06 +08:00
|
|
|
|
int count = iWmsCostCoilDailyService.calculateDailyCost(calcDate);
|
2025-12-02 17:58:16 +08:00
|
|
|
|
return R.ok(count);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询成本统计报表
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param startDate 开始日期
|
|
|
|
|
|
* @param endDate 结束日期
|
|
|
|
|
|
* @param groupBy 分组维度(warehouse/itemType/materialType)
|
|
|
|
|
|
* @param warehouseId 库区ID(可选)
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/report/summary")
|
|
|
|
|
|
public R<Map<String, Object>> queryCostSummary(@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startDate,
|
|
|
|
|
|
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endDate,
|
|
|
|
|
|
@RequestParam(required = false) String groupBy,
|
|
|
|
|
|
@RequestParam(required = false) Long warehouseId) {
|
2025-12-03 10:32:06 +08:00
|
|
|
|
Map<String, Object> result = iWmsCostCoilDailyService.queryCostSummary(startDate, endDate, groupBy, warehouseId);
|
2025-12-02 17:58:16 +08:00
|
|
|
|
return R.ok(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询成本趋势分析
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param startDate 开始日期
|
|
|
|
|
|
* @param endDate 结束日期
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/report/trend")
|
|
|
|
|
|
public R<List<Map<String, Object>>> queryCostTrend(@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startDate,
|
|
|
|
|
|
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endDate) {
|
2025-12-03 10:32:06 +08:00
|
|
|
|
List<Map<String, Object>> result = iWmsCostCoilDailyService.queryCostTrend(startDate, endDate);
|
2025-12-02 17:58:16 +08:00
|
|
|
|
return R.ok(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 按入场钢卷号维度计算成本
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param enterCoilNo 入场钢卷号
|
|
|
|
|
|
* @param calcDate 计算日期(可选,默认当前日期)
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("/calculateByEnterCoilNo")
|
|
|
|
|
|
public R<Map<String, Object>> calculateCostByEnterCoilNo(@RequestParam String enterCoilNo,
|
|
|
|
|
|
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate calcDate) {
|
2025-12-03 10:32:06 +08:00
|
|
|
|
Map<String, Object> result = iWmsCostCoilDailyService.calculateCostByEnterCoilNo(enterCoilNo, calcDate);
|
2025-12-02 17:58:16 +08:00
|
|
|
|
if (result.containsKey("error")) {
|
|
|
|
|
|
return R.fail(result.get("error").toString());
|
|
|
|
|
|
}
|
|
|
|
|
|
return R.ok(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-27 16:54:46 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 按当前钢卷号维度计算成本(单卷详情)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param currentCoilNo 当前钢卷号
|
|
|
|
|
|
* @param calcDate 计算日期(可选,默认当前日期)
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("/calculateByCurrentCoilNo")
|
|
|
|
|
|
public R<Map<String, Object>> calculateCostByCurrentCoilNo(@RequestParam String currentCoilNo,
|
|
|
|
|
|
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate calcDate) {
|
|
|
|
|
|
Map<String, Object> result = iWmsCostCoilDailyService.calculateCostByCurrentCoilNo(currentCoilNo, calcDate);
|
|
|
|
|
|
if (result.containsKey("error")) {
|
|
|
|
|
|
return R.fail(result.get("error").toString());
|
|
|
|
|
|
}
|
|
|
|
|
|
return R.ok(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-02 17:58:16 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 现算成本检索(基于 wms_material_coil)
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/search/material")
|
|
|
|
|
|
public R<Map<String, Object>> searchMaterialCost(@RequestParam(required = false) String enterCoilNo,
|
|
|
|
|
|
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate calcDate,
|
|
|
|
|
|
@RequestParam(required = false, defaultValue = "1") Integer pageNum,
|
|
|
|
|
|
@RequestParam(required = false, defaultValue = "20") Integer pageSize) {
|
2025-12-03 10:32:06 +08:00
|
|
|
|
Map<String, Object> result = iWmsCostCoilDailyService.searchMaterialCost(enterCoilNo, calcDate, pageNum, pageSize);
|
2025-12-02 17:58:16 +08:00
|
|
|
|
return R.ok(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 批量按入场钢卷号维度计算成本(定时任务使用)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param calcDate 计算日期(可选,默认前一日)
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("/batchCalculateByEnterCoilNo")
|
|
|
|
|
|
@Log(title = "批量按入场钢卷号计算成本", businessType = BusinessType.OTHER)
|
|
|
|
|
|
public R<Integer> batchCalculateByEnterCoilNo(@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate calcDate) {
|
|
|
|
|
|
if (calcDate == null) {
|
|
|
|
|
|
calcDate = LocalDate.now().minusDays(1);
|
|
|
|
|
|
}
|
2025-12-03 10:32:06 +08:00
|
|
|
|
int count = iWmsCostCoilDailyService.calculateDailyCostByEnterCoilNo(calcDate);
|
2025-12-02 17:58:16 +08:00
|
|
|
|
return R.ok(count);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询按入场钢卷号统计的成本报表
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param startDate 开始日期
|
|
|
|
|
|
* @param endDate 结束日期
|
|
|
|
|
|
* @param enterCoilNo 入场钢卷号(可选)
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/report/byEnterCoilNo")
|
|
|
|
|
|
public R<List<Map<String, Object>>> queryCostByEnterCoilNo(@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startDate,
|
|
|
|
|
|
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endDate,
|
|
|
|
|
|
@RequestParam(required = false) String enterCoilNo) {
|
2025-12-03 10:32:06 +08:00
|
|
|
|
List<Map<String, Object>> result = iWmsCostCoilDailyService.queryCostByEnterCoilNo(startDate, endDate, enterCoilNo);
|
2025-12-02 17:58:16 +08:00
|
|
|
|
return R.ok(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 囤积成本页数据(分页 + 汇总)
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/stockpile")
|
|
|
|
|
|
public R<Map<String, Object>> queryStockpile(@RequestParam(required = false) String enterCoilNo,
|
|
|
|
|
|
@RequestParam(required = false) String currentCoilNo,
|
|
|
|
|
|
PageQuery pageQuery) {
|
2025-12-03 10:32:06 +08:00
|
|
|
|
Map<String, Object> result = iWmsCostCoilDailyService.queryStockpileCostList(enterCoilNo, currentCoilNo, pageQuery);
|
2025-12-02 17:58:16 +08:00
|
|
|
|
return R.ok(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 成本模块首页概览
|
|
|
|
|
|
* 统计当前「现存且未发货」钢卷的总成本、总净重、总毛重以及平均在库天数
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/overview")
|
|
|
|
|
|
public R<Map<String, Object>> overview() {
|
2025-12-03 10:32:06 +08:00
|
|
|
|
Map<String, Object> result = iWmsCostCoilDailyService.queryOverview();
|
2025-12-02 17:58:16 +08:00
|
|
|
|
return R.ok(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|