2025-10-28 12:20:20 +08:00
|
|
|
|
package com.klp.controller;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
import java.util.Arrays;
|
2025-12-08 13:14:11 +08:00
|
|
|
|
import java.util.stream.Collectors;
|
2025-10-28 12:20:20 +08:00
|
|
|
|
|
2026-01-10 11:34:01 +08:00
|
|
|
|
import com.klp.common.core.domain.AjaxResult;
|
2025-11-27 13:32:06 +08:00
|
|
|
|
import com.klp.domain.vo.WmsMaterialCoilExportVo;
|
2025-10-28 12:20:20 +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;
|
|
|
|
|
|
import com.klp.domain.vo.WmsMaterialCoilVo;
|
|
|
|
|
|
import com.klp.domain.bo.WmsMaterialCoilBo;
|
|
|
|
|
|
import com.klp.service.IWmsMaterialCoilService;
|
|
|
|
|
|
import com.klp.common.core.page.TableDataInfo;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 钢卷物料表
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author Joshi
|
|
|
|
|
|
* @date 2025-07-18
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Validated
|
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
|
@RestController
|
|
|
|
|
|
@RequestMapping("/wms/materialCoil")
|
|
|
|
|
|
public class WmsMaterialCoilController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
private final IWmsMaterialCoilService iWmsMaterialCoilService;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询钢卷物料表列表
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/list")
|
|
|
|
|
|
public TableDataInfo<WmsMaterialCoilVo> list(WmsMaterialCoilBo bo, PageQuery pageQuery) {
|
|
|
|
|
|
return iWmsMaterialCoilService.queryPageList(bo, pageQuery);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-11-27 13:08:09 +08:00
|
|
|
|
* 导出钢卷物料表列表(完整字段版本)
|
2025-10-28 12:20:20 +08:00
|
|
|
|
*/
|
|
|
|
|
|
@Log(title = "钢卷物料表", businessType = BusinessType.EXPORT)
|
|
|
|
|
|
@PostMapping("/export")
|
|
|
|
|
|
public void export(WmsMaterialCoilBo bo, HttpServletResponse response) {
|
2025-11-27 13:32:06 +08:00
|
|
|
|
List<WmsMaterialCoilExportVo> list = iWmsMaterialCoilService.queryExportList(bo);
|
|
|
|
|
|
ExcelUtil.exportExcel(list, "钢卷物料表", WmsMaterialCoilExportVo.class, response);
|
2025-10-28 12:20:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-11 08:40:07 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 查询钢卷物料表列表(POST请求,支持大量coilIds查询)
|
|
|
|
|
|
* 功能与GET /list相同,但使用POST请求体传递参数,避免URL长度限制
|
|
|
|
|
|
* 特别适合需要查询大量coilIds的场景
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("/listByPost")
|
|
|
|
|
|
public TableDataInfo<WmsMaterialCoilVo> listByPost(@RequestBody WmsMaterialCoilBo bo, PageQuery pageQuery) {
|
|
|
|
|
|
return iWmsMaterialCoilService.queryPageList(bo, pageQuery);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-02 13:28:52 +08:00
|
|
|
|
/**
|
2025-12-02 14:45:06 +08:00
|
|
|
|
* 钢卷发货,将钢卷状态更新为已发货,且更新发货时间
|
2025-12-02 13:28:52 +08:00
|
|
|
|
*
|
|
|
|
|
|
* @param coilId 主键
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Log(title = "钢卷物料表", businessType = BusinessType.DELETE)
|
2025-12-02 14:46:22 +08:00
|
|
|
|
@GetMapping("/exportCoil/{coilId}")
|
|
|
|
|
|
public R<Void> remove(@NotNull(message = "主键不能为空")
|
2025-12-02 13:28:52 +08:00
|
|
|
|
@PathVariable("coilId") Long coilId) {
|
|
|
|
|
|
|
|
|
|
|
|
return toAjax(iWmsMaterialCoilService.exportCoil(coilId));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-11 17:42:15 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 钢卷发货撤回,将钢卷状态更新为未发货,且清空发货时间
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param coilId 主键
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Log(title = "钢卷物料表", businessType = BusinessType.UPDATE)
|
|
|
|
|
|
@GetMapping("/withdrawExportCoil/{coilId}")
|
|
|
|
|
|
public R<Void> withdrawExport(@NotNull(message = "主键不能为空")
|
|
|
|
|
|
@PathVariable("coilId") Long coilId) {
|
|
|
|
|
|
|
|
|
|
|
|
return toAjax(iWmsMaterialCoilService.withdrawExportCoil(coilId));
|
|
|
|
|
|
}
|
2025-10-28 12:20:20 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取钢卷物料表详细信息
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param coilId 主键
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/{coilId}")
|
|
|
|
|
|
public R<WmsMaterialCoilVo> getInfo(@NotNull(message = "主键不能为空")
|
2025-11-05 22:18:10 +08:00
|
|
|
|
@PathVariable("coilId") Long coilId) {
|
2025-10-28 12:20:20 +08:00
|
|
|
|
return R.ok(iWmsMaterialCoilService.queryById(coilId));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 新增钢卷物料表
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Log(title = "钢卷物料表", businessType = BusinessType.INSERT)
|
|
|
|
|
|
@RepeatSubmit()
|
|
|
|
|
|
@PostMapping()
|
2025-11-17 10:47:36 +08:00
|
|
|
|
public R<WmsMaterialCoilVo> add(@Validated(AddGroup.class) @RequestBody WmsMaterialCoilBo bo) {
|
|
|
|
|
|
return R.ok(iWmsMaterialCoilService.insertByBo(bo));
|
2025-10-28 12:20:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 修改钢卷物料表
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Log(title = "钢卷物料表", businessType = BusinessType.UPDATE)
|
|
|
|
|
|
@RepeatSubmit()
|
|
|
|
|
|
@PutMapping()
|
|
|
|
|
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody WmsMaterialCoilBo bo) {
|
|
|
|
|
|
return toAjax(iWmsMaterialCoilService.updateByBo(bo));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 简单更新钢卷物料表
|
|
|
|
|
|
* 直接更新属性内容,不进行历史记录处理
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Log(title = "钢卷物料表", businessType = BusinessType.UPDATE)
|
|
|
|
|
|
@RepeatSubmit()
|
|
|
|
|
|
@PutMapping("/update")
|
|
|
|
|
|
public R<Void> update(@Validated(EditGroup.class) @RequestBody WmsMaterialCoilBo bo) {
|
|
|
|
|
|
return toAjax(iWmsMaterialCoilService.updateSimple(bo));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 删除钢卷物料表
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param coilIds 主键串
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Log(title = "钢卷物料表", businessType = BusinessType.DELETE)
|
|
|
|
|
|
@DeleteMapping("/{coilIds}")
|
|
|
|
|
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
2025-11-05 22:18:10 +08:00
|
|
|
|
@PathVariable("coilIds") Long[] coilIds) {
|
2025-10-28 12:20:20 +08:00
|
|
|
|
return toAjax(iWmsMaterialCoilService.deleteWithValidByIds(Arrays.asList(coilIds), true));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 钢卷溯源查询
|
|
|
|
|
|
* 根据入场钢卷号查询二维码,解析content中的steps,然后根据steps中的钢卷号反向查询数据库
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param enterCoilNo 入场钢卷号
|
|
|
|
|
|
* @param currentCoilNo 当前钢卷号(可选参数,用于查询特定子钢卷)
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/trace")
|
|
|
|
|
|
public R<Map<String, Object>> trace(@RequestParam @NotBlank(message = "入场钢卷号不能为空") String enterCoilNo,
|
|
|
|
|
|
@RequestParam(required = false) String currentCoilNo) {
|
|
|
|
|
|
Map<String, Object> traceResult = iWmsMaterialCoilService.queryTrace(enterCoilNo, currentCoilNo);
|
|
|
|
|
|
return R.ok(traceResult);
|
|
|
|
|
|
}
|
2025-10-29 14:13:06 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询各个库区中不同类型的钢卷分布情况
|
2025-10-29 14:40:09 +08:00
|
|
|
|
* 按库区分组,统计每种物品类型和物品ID的钢卷数量和重量
|
2025-10-29 14:13:06 +08:00
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/distributionByWarehouse")
|
2025-10-29 14:40:09 +08:00
|
|
|
|
public R<List<WmsMaterialCoilVo>> getDistributionByWarehouse(
|
|
|
|
|
|
@RequestParam(required = false) String itemType,
|
|
|
|
|
|
@RequestParam(required = false) Long itemId) {
|
|
|
|
|
|
List<WmsMaterialCoilVo> distribution = iWmsMaterialCoilService.getDistributionByWarehouse(itemType, itemId);
|
2025-10-29 14:13:06 +08:00
|
|
|
|
return R.ok(distribution);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-03 17:06:17 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 查询各个库区中不同类型的钢卷分布情况
|
|
|
|
|
|
* 按库区分组,统计每种物品类型和物品ID的钢卷数量和重量
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/distributionByActualWarehouse")
|
|
|
|
|
|
public R<List<WmsMaterialCoilVo>> getDistributionByActualWarehouse(
|
|
|
|
|
|
@RequestParam(required = false) String itemType,
|
|
|
|
|
|
@RequestParam(required = false) Long itemId) {
|
|
|
|
|
|
List<WmsMaterialCoilVo> distribution = iWmsMaterialCoilService.getDistributionByActualWarehouse(itemType, itemId);
|
|
|
|
|
|
return R.ok(distribution);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-29 14:13:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 查询不同类型的钢卷在不同库区的分布情况
|
2025-10-29 14:40:09 +08:00
|
|
|
|
* 按物品类型和物品ID分组,统计每个库区的钢卷数量和重量
|
2025-10-29 14:13:06 +08:00
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/distributionByItemType")
|
2025-10-29 14:40:09 +08:00
|
|
|
|
public R<List<WmsMaterialCoilVo>> getDistributionByItemType(
|
|
|
|
|
|
@RequestParam(required = false) String itemType,
|
|
|
|
|
|
@RequestParam(required = false) Long itemId) {
|
|
|
|
|
|
List<WmsMaterialCoilVo> distribution = iWmsMaterialCoilService.getDistributionByItemType(itemType, itemId);
|
2025-10-29 14:13:06 +08:00
|
|
|
|
return R.ok(distribution);
|
|
|
|
|
|
}
|
2025-11-17 17:57:57 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询不同类型的钢卷在不同库区的分布情况
|
|
|
|
|
|
* 按物品类型和物品ID分组,统计每个库区的钢卷数量和重量
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/distributionByActualItemType")
|
|
|
|
|
|
public R<List<WmsMaterialCoilVo>> getDistributionByActualItemType(
|
|
|
|
|
|
@RequestParam(required = false) String itemType,
|
|
|
|
|
|
@RequestParam(required = false) Long itemId) {
|
|
|
|
|
|
List<WmsMaterialCoilVo> distribution = iWmsMaterialCoilService.getDistributionByActualItemType(itemType, itemId);
|
|
|
|
|
|
return R.ok(distribution);
|
|
|
|
|
|
}
|
2025-12-08 13:08:20 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-08 13:14:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 批量更新钢卷发货状态
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param coilIds 钢卷ID,多个ID用逗号分隔
|
|
|
|
|
|
* @param status 目标状态 (0=在库, 1=在途, 2=已出库)
|
|
|
|
|
|
* @return 操作结果
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Log(title = "钢卷物料表", businessType = BusinessType.UPDATE)
|
|
|
|
|
|
@PutMapping("/batchUpdateDeliveryStatus")
|
|
|
|
|
|
public R<Void> batchUpdateDeliveryStatus(
|
|
|
|
|
|
@RequestParam String coilIds,
|
|
|
|
|
|
@RequestParam Integer status) {
|
|
|
|
|
|
|
|
|
|
|
|
// 解析钢卷ID列表
|
|
|
|
|
|
List<Long> coilIdList = Arrays.stream(coilIds.split(","))
|
|
|
|
|
|
.map(String::trim)
|
|
|
|
|
|
.filter(s -> !s.isEmpty())
|
|
|
|
|
|
.map(Long::valueOf)
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
Boolean result = iWmsMaterialCoilService.batchUpdateDeliveryStatus(coilIdList, status);
|
|
|
|
|
|
return result ? R.ok() : R.fail("批量更新失败");
|
|
|
|
|
|
}
|
2026-01-10 11:34:01 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 根据更新前的钢卷ID列表获取更新后的钢卷ID映射关系
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/nextCoilIds")
|
|
|
|
|
|
public R<Map<Long, String>> getUpdatedCoilIdsByOldCoilIds(@RequestParam List<Long> oldCoilIds)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (oldCoilIds == null || oldCoilIds.isEmpty()) {
|
|
|
|
|
|
return R.fail("钢卷ID列表不能为空");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
Map<Long, String> result = iWmsMaterialCoilService.getUpdatedCoilIdsByOldCoilIds(oldCoilIds);
|
|
|
|
|
|
return R.ok(result);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
return R.fail("获取更新后的钢卷ID失败: " + e.getMessage());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-12 15:51:43 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 检查钢卷号是否重复
|
|
|
|
|
|
* 前端传入入场钢卷号和当前钢卷号,返回哪个钢卷号重复
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param enterCoilNo 入场钢卷号
|
|
|
|
|
|
* @param currentCoilNo 当前钢卷号
|
|
|
|
|
|
* @return 返回结果,包含:
|
|
|
|
|
|
* - duplicateType: "enter" (入场钢卷号重复), "current" (当前钢卷号重复), "both" (都重复), "none" (都不重复)
|
|
|
|
|
|
* - enterCoilNoDuplicate: 入场钢卷号是否重复
|
|
|
|
|
|
* - currentCoilNoDuplicate: 当前钢卷号是否重复
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/checkCoilNoDuplicate")
|
|
|
|
|
|
public R<Map<String, Object>> checkCoilNoDuplicate(
|
2026-01-16 10:12:10 +08:00
|
|
|
|
@RequestParam(required = false) Long coilId,
|
2026-01-12 15:51:43 +08:00
|
|
|
|
@RequestParam(required = false) String enterCoilNo,
|
|
|
|
|
|
@RequestParam(required = false) String currentCoilNo) {
|
2026-01-16 10:12:10 +08:00
|
|
|
|
Map<String, Object> result = iWmsMaterialCoilService.checkCoilNoDuplicate(coilId,enterCoilNo, currentCoilNo);
|
2026-01-12 15:51:43 +08:00
|
|
|
|
return R.ok(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 根据入场钢卷号前缀查询最大的入场钢卷号
|
|
|
|
|
|
* 前端传入入场钢卷号的前四位,查询所有符合的入场钢卷号,返回最大值
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param enterCoilNoPrefix 入场钢卷号前缀(前四位)
|
|
|
|
|
|
* @return 返回结果,包含:
|
|
|
|
|
|
* - maxEnterCoilNo: 最大的入场钢卷号
|
|
|
|
|
|
* - prefix: 前缀值
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/getMaxEnterCoilNo")
|
|
|
|
|
|
public R<Map<String, Object>> getMaxEnterCoilNoByPrefix(
|
|
|
|
|
|
@RequestParam @NotBlank(message = "入场钢卷号前缀不能为空") String enterCoilNoPrefix) {
|
|
|
|
|
|
Map<String, Object> result = iWmsMaterialCoilService.getMaxEnterCoilNoByPrefix(enterCoilNoPrefix);
|
|
|
|
|
|
return R.ok(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-15 15:14:41 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 查询data_type=1的重复钢卷分组
|
|
|
|
|
|
* - 入场钢卷号重复分组
|
|
|
|
|
|
* - 当前钢卷号重复分组
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/duplicateGroups")
|
|
|
|
|
|
public R<Map<String, Object>> getDuplicateCoilGroups() {
|
|
|
|
|
|
Map<String, Object> result = iWmsMaterialCoilService.getDuplicateCoilGroups();
|
|
|
|
|
|
return R.ok(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-19 14:11:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 复活历史钢卷
|
|
|
|
|
|
* 将dataType=0的历史钢卷恢复为dataType=1的当前钢卷
|
|
|
|
|
|
* 同时清空实际库位绑定,并检查当前钢卷号是否重复
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param coilId 钢卷ID
|
|
|
|
|
|
* @return 复活结果,包含success状态、错误信息、钢卷ID和当前钢卷号
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Log(title = "钢卷物料表", businessType = BusinessType.UPDATE)
|
|
|
|
|
|
@GetMapping("/reviveCoil/{coilId}")
|
|
|
|
|
|
public R<Map<String, Object>> reviveCoil(
|
|
|
|
|
|
@NotNull(message = "钢卷ID不能为空")
|
|
|
|
|
|
@PathVariable("coilId") Long coilId) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
Map<String, Object> result = iWmsMaterialCoilService.reviveCoil(coilId);
|
|
|
|
|
|
// 根据业务结果返回成功/失败的统一响应
|
|
|
|
|
|
if (Boolean.TRUE.equals(result.get("success"))) {
|
|
|
|
|
|
return R.ok(result);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return R.fail(result.get("message").toString(), result);
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
return R.fail("复活钢卷失败:" + e.getMessage());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-28 12:20:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|