Files
klp-oa/klp-wms/src/main/java/com/klp/controller/WmsDeliveryWaybillDetailController.java
Joshi 002ac3f3ab refactor(crm): 统一配卷查询接口并增加筛选功能
- 将所有配卷查询接口统一为POST + Body BO方式
- 为配卷查询添加钢卷号、材料类型、质量状态、发货状态筛选条件
- 在合同详情页面为生产成果和发货配卷添加筛选表单
- 在订单页面为发货配卷添加筛选功能
- 在销售员页面为生产成果和计划发货添加筛选功能
- 更新异议管理页面的配卷查询参数结构
- 增加订单ID参数用于合同ID相关查询的兼容性处理
2026-07-09 19:01:36 +08:00

223 lines
9.2 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.klp.controller;
import java.util.*;
import java.util.stream.Collectors;
import com.klp.domain.vo.WmsMaterialCoilVo;
import org.springframework.format.annotation.DateTimeFormat;
import com.klp.domain.vo.WmsMaterialCoilBindVo;
import com.klp.domain.vo.WmsDeliveryCoilRelationVo;
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.WmsDeliveryWaybillDetailVo;
import com.klp.domain.bo.WmsDeliveryWaybillDetailBo;
import com.klp.service.IWmsDeliveryWaybillDetailService;
import com.klp.domain.bo.WmsMaterialCoilBo;
import com.klp.domain.bo.PrincipalCoilQueryBo;
import com.klp.service.IWmsMaterialCoilService;
import com.klp.common.core.page.TableDataInfo;
/**
* 发货单明细
*
* @author klp
* @date 2025-11-25
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/wms/deliveryWaybillDetail")
public class WmsDeliveryWaybillDetailController extends BaseController {
private final IWmsDeliveryWaybillDetailService iWmsDeliveryWaybillDetailService;
private final IWmsMaterialCoilService iWmsMaterialCoilService;
/**
* 查询发货单明细列表
*/
@GetMapping("/list")
public TableDataInfo<WmsDeliveryWaybillDetailVo> list(WmsDeliveryWaybillDetailBo bo, PageQuery pageQuery) {
return iWmsDeliveryWaybillDetailService.queryPageList(bo, pageQuery);
}
/**
* 导出发货单明细列表
*/
@Log(title = "发货单明细", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(WmsDeliveryWaybillDetailBo bo, HttpServletResponse response) {
List<WmsDeliveryWaybillDetailVo> list = iWmsDeliveryWaybillDetailService.queryList(bo);
ExcelUtil.exportExcel(list, "发货单明细", WmsDeliveryWaybillDetailVo.class, response);
}
/**
* 获取发货单明细详细信息
*
* @param detailId 主键
*/
@GetMapping("/{detailId}")
public R<WmsDeliveryWaybillDetailVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long detailId) {
return R.ok(iWmsDeliveryWaybillDetailService.queryById(detailId));
}
/**
* 根据钢卷ID查询发货关联信息发货单明细+发货单+发货计划+钢卷信息)
*
* @param coilId 钢卷ID
*/
@GetMapping("/coilRelation/{coilId}")
public R<WmsDeliveryCoilRelationVo> getCoilRelation(@NotNull(message = "钢卷ID不能为空")
@PathVariable Long coilId) {
return R.ok(iWmsDeliveryWaybillDetailService.queryRelationByCoilId(coilId));
}
/**
* 新增发货单明细
*/
@Log(title = "发货单明细", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody WmsDeliveryWaybillDetailBo bo) {
return toAjax(iWmsDeliveryWaybillDetailService.insertByBo(bo));
}
/**
* 批量新增发货单明细
*/
@Log(title = "发货单明细", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping("/batch")
public R<Void> batchAdd(@Validated(AddGroup.class) @RequestBody List<WmsDeliveryWaybillDetailBo> boList) {
return toAjax(iWmsDeliveryWaybillDetailService.insertBatchByBo(boList));
}
/**
* 修改发货单明细
*/
@Log(title = "发货单明细", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody WmsDeliveryWaybillDetailBo bo) {
return toAjax(iWmsDeliveryWaybillDetailService.updateByBo(bo));
}
/**
* 删除发货单明细
*
* @param detailIds 主键串
*/
@Log(title = "发货单明细", businessType = BusinessType.DELETE)
@DeleteMapping("/{detailIds}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] detailIds) {
return toAjax(iWmsDeliveryWaybillDetailService.deleteWithValidByIds(Arrays.asList(detailIds), true));
}
/**
* 查询已发货绑定的钢卷列表
*/
@GetMapping("/boundCoilList")
public TableDataInfo<WmsMaterialCoilBindVo> boundCoilList(
WmsMaterialCoilBo bo,
PageQuery pageQuery,
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime,
@RequestParam(required = false) Long planId) {
List<Long> boundCoilIds;
if (planId != null) {
boundCoilIds = iWmsDeliveryWaybillDetailService.getBoundCoilIdsByPlanId(planId, startTime, endTime);
} else if (startTime != null || endTime != null) {
boundCoilIds = iWmsDeliveryWaybillDetailService.getBoundCoilIdsByTimeRange(startTime, endTime);
} else {
boundCoilIds = iWmsDeliveryWaybillDetailService.getBoundCoilIds();
}
if (boundCoilIds == null || boundCoilIds.isEmpty()) {
return new TableDataInfo<>();
}
bo.setCoilIds(boundCoilIds.stream().map(String::valueOf).collect(java.util.stream.Collectors.joining(",")));
// startTime/endTime 已用于 waybill delivery_time 筛选,清除避免误作为 coil update_time 条件
bo.setStartTime(null);
bo.setEndTime(null);
bo.setStatusFirst(true);
if (planId == null) {
bo.setOrderByPlanDesc(true);
}
return iWmsMaterialCoilService.queryPageListWithBindInfo(bo, pageQuery);
}
/**
* 统计已发货绑定钢卷的汇总数据
* 根据coilIds查询条件统计毛重、净重、数量等指标
*/
@GetMapping("/statistics")
public R<java.util.Map<String, java.math.BigDecimal>> getStatistics(
WmsMaterialCoilBo bo,
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime,
@RequestParam(required = false) Long planId) {
List<Long> boundCoilIds;
if (planId != null) {
boundCoilIds = iWmsDeliveryWaybillDetailService.getBoundCoilIdsByPlanId(planId, startTime, endTime);
} else if (startTime != null || endTime != null) {
boundCoilIds = iWmsDeliveryWaybillDetailService.getBoundCoilIdsByTimeRange(startTime, endTime);
} else {
boundCoilIds = iWmsDeliveryWaybillDetailService.getBoundCoilIds();
}
if (boundCoilIds == null || boundCoilIds.isEmpty()) {
return R.ok(new HashMap<>());
}
bo.setCoilIds(boundCoilIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
// startTime/endTime 已用于 waybill delivery_time 筛选,清除避免误作为 coil update_time 条件
bo.setStartTime(null);
bo.setEndTime(null);
return R.ok(iWmsMaterialCoilService.getStatistics(bo));
}
/**
* 根据负责人(principal)查询已发货绑定的钢卷列表(分页),支持钢卷信息筛选
*/
@PostMapping("/coilListByPrincipal")
public TableDataInfo<WmsMaterialCoilVo> coilListByPrincipal(@RequestBody PrincipalCoilQueryBo bo) {
List<Long> boundCoilIds = iWmsDeliveryWaybillDetailService.getBoundCoilIdsByPrincipal(bo.getPrincipal());
if (boundCoilIds == null || boundCoilIds.isEmpty()) {
return new TableDataInfo<>();
}
WmsMaterialCoilBo coilBo = bo.getCoilBo() != null ? bo.getCoilBo() : new WmsMaterialCoilBo();
coilBo.setCoilIds(boundCoilIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
PageQuery pageQuery = new PageQuery();
pageQuery.setPageNum(bo.getPageNum());
pageQuery.setPageSize(bo.getPageSize());
return iWmsMaterialCoilService.queryPageList(coilBo, pageQuery);
}
/**
* 根据负责人(principal)统计已发货绑定钢卷的汇总数据,支持钢卷信息筛选
*/
@PostMapping("/coilListByPrincipal/statistics")
public R<java.util.Map<String, java.math.BigDecimal>> getCoilListByPrincipalStatistics(@RequestBody PrincipalCoilQueryBo bo) {
List<Long> boundCoilIds = iWmsDeliveryWaybillDetailService.getBoundCoilIdsByPrincipal(bo.getPrincipal());
if (boundCoilIds == null || boundCoilIds.isEmpty()) {
return R.ok();
}
WmsMaterialCoilBo coilBo = bo.getCoilBo() != null ? bo.getCoilBo() : new WmsMaterialCoilBo();
coilBo.setCoilIds(boundCoilIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
return R.ok(iWmsMaterialCoilService.getStatistics(coilBo));
}
}