feat(wms): 添加钢卷材质异常修复功能

- 在 IWmsMaterialCoilService 中新增 fixMaterialMismatchCoils 方法用于修复材质异常钢卷
- 在 WmsMaterialCoilController 中新增 /fixMaterialMismatch 接口提供修复功能
- 在 WmsMaterialCoilMapper.xml 中为材质异常查询添加按 coil_id 升序排序
- 在 WmsMaterialCoilServiceImpl 中实现材质异常修复逻辑,包括查询入场钢卷号、查找热轧卷板材质、批量更新 packing_status 等步骤
This commit is contained in:
2026-04-21 13:41:07 +08:00
parent c571b12463
commit bd9beb32eb
4 changed files with 88 additions and 0 deletions

View File

@@ -618,6 +618,13 @@ public class WmsMaterialCoilController extends BaseController {
return iWmsMaterialCoilService.queryMaterialMismatchCoils(pageQuery);
}
@Log(title = "修复材质异常钢卷", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping("/fixMaterialMismatch")
public R<Void> fixMaterialMismatchCoils(@NotNull(message = "钢卷ID不能为空") @RequestParam Long coilId) {
return toAjax(iWmsMaterialCoilService.fixMaterialMismatchCoils(coilId));
}
}

View File

@@ -284,5 +284,17 @@ public interface IWmsMaterialCoilService {
* @return 材质异常的钢卷列表(分页)
*/
TableDataInfo<WmsMaterialCoilVo> queryMaterialMismatchCoils(PageQuery pageQuery);
/**
* 修复材质异常的钢卷
* 1. 根据coilId查询钢卷的入场钢卷号(enterCoilNo)
* 2. 查询该入场钢卷号下的所有钢卷作为一组
* 3. 找到packing_status为该入场钢卷号且itemName LIKE '%热轧卷板%'的itemId
* 4. 用该itemId对应的material更新整组的packing_status
*
* @param coilId 钢卷ID
* @return 修复结果
*/
Boolean fixMaterialMismatchCoils(Long coilId);
}

View File

@@ -5186,5 +5186,73 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
return TableDataInfo.build(voPage);
}
@Override
public Boolean fixMaterialMismatchCoils(Long coilId) {
WmsMaterialCoil coil = baseMapper.selectById(coilId);
if (coil == null) {
throw new RuntimeException("钢卷不存在");
}
String enterCoilNo = coil.getEnterCoilNo();
if (StringUtils.isBlank(enterCoilNo)) {
throw new RuntimeException("入场钢卷号为空");
}
List<WmsMaterialCoil> sameEnterCoilNoCoils = baseMapper.selectList(
Wrappers.lambdaQuery(WmsMaterialCoil.class)
.eq(WmsMaterialCoil::getEnterCoilNo, enterCoilNo)
.eq(WmsMaterialCoil::getDelFlag, 0)
);
if (CollectionUtils.isEmpty(sameEnterCoilNoCoils)) {
throw new RuntimeException("未找到相同入场钢卷号的钢卷");
}
String targetMaterial = null;
for (WmsMaterialCoil c : sameEnterCoilNoCoils) {
if (StringUtils.isNotBlank(c.getItemType()) && c.getItemId() != null) {
String itemType = c.getItemType();
Long itemId = c.getItemId();
if ("raw_material".equals(itemType)) {
WmsRawMaterial rawMaterial = rawMaterialMapper.selectById(itemId);
if (rawMaterial != null && StringUtils.isNotBlank(rawMaterial.getRawMaterialName())
&& rawMaterial.getRawMaterialName().contains("热轧卷板")) {
targetMaterial = rawMaterial.getMaterial();
break;
}
} else if ("product".equals(itemType)) {
WmsProduct product = productMapper.selectById(itemId);
if (product != null && StringUtils.isNotBlank(product.getProductName())
&& product.getProductName().contains("热轧卷板")) {
targetMaterial = product.getMaterial();
break;
}
}
}
}
if (StringUtils.isBlank(targetMaterial)) {
throw new RuntimeException("未找到热轧卷板对应的材质");
}
if (!sameEnterCoilNoCoils.isEmpty()) {
List<Long> coilIds = sameEnterCoilNoCoils.stream()
.map(WmsMaterialCoil::getCoilId)
.collect(Collectors.toList());
LambdaUpdateWrapper<WmsMaterialCoil> updateWrapper = Wrappers.lambdaUpdate();
updateWrapper.in(WmsMaterialCoil::getCoilId, coilIds);
updateWrapper.set(WmsMaterialCoil::getPackingStatus, targetMaterial);
WmsMaterialCoil updateEntity = new WmsMaterialCoil();
updateEntity.setPackingStatus(targetMaterial);
return baseMapper.update(updateEntity, updateWrapper) > 0;
}
return false;
}
}

View File

@@ -951,6 +951,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
OR
(mc.item_type = 'product' AND wp.material IS NOT NULL AND mc.packing_status != wp.material)
)
ORDER BY mc.coil_id ASC
</select>
</mapper>