fix:物料综合测试并调整接口

This commit is contained in:
shusir
2026-03-11 17:56:35 +08:00
parent 4d79c796c3
commit 123d217fec
11 changed files with 171 additions and 41 deletions

View File

@@ -16,6 +16,9 @@ import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH
@Data @Data
public class MaterialBatchPageReqVO extends PageParam { public class MaterialBatchPageReqVO extends PageParam {
@Schema(description = "分类其他配置")
private String categoryCustomConfig;
@Schema(description = "物料大类id", example = "9381") @Schema(description = "物料大类id", example = "9381")
private Long productId; private Long productId;

View File

@@ -1,5 +1,6 @@
package com.zt.plat.module.qms.resource.material.controller.vo; package com.zt.plat.module.qms.resource.material.controller.vo;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
@@ -29,6 +30,10 @@ public class MaterialBatchRespVO {
@ExcelProperty("物料大类id") @ExcelProperty("物料大类id")
private Long productId; private Long productId;
@Schema(description = "分类自定义配置")
@ExcelProperty("分类自定义配置")
private JSONObject categoryCustomConfig;
@Schema(description = "物料大类名称") @Schema(description = "物料大类名称")
@ExcelProperty("物料大类名称") @ExcelProperty("物料大类名称")
private String productName; private String productName;
@@ -73,6 +78,10 @@ public class MaterialBatchRespVO {
@ExcelProperty("已入库数量") @ExcelProperty("已入库数量")
private BigDecimal inboundEndQuantity; private BigDecimal inboundEndQuantity;
@Schema(description = "检定/校准数量")
@ExcelProperty("检定/校准数量")
private BigDecimal verificationQuantity;
@Schema(description = "锁定数量") @Schema(description = "锁定数量")
@ExcelProperty("锁定数量") @ExcelProperty("锁定数量")
private BigDecimal lockQuantity; private BigDecimal lockQuantity;

View File

@@ -1,5 +1,6 @@
package com.zt.plat.module.qms.resource.material.controller.vo.query; package com.zt.plat.module.qms.resource.material.controller.vo.query;
import cn.hutool.json.JSONObject;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;

View File

@@ -0,0 +1,16 @@
package com.zt.plat.module.qms.resource.material.enums;
/**
* 物料批次业务类型
*
*/
public enum MaterialBatchBusinessType {
/**
* 拆分到工段
*/
batch_assign_gong,
/**
* 检定
*/
verify,
}

View File

@@ -1,7 +1,7 @@
package com.zt.plat.module.qms.resource.material.enums; package com.zt.plat.module.qms.resource.material.enums;
/** /**
* 物料批次工段枚举 * 物料批次操作类型
* *
*/ */
public enum MaterialBatchOperationType { public enum MaterialBatchOperationType {

View File

@@ -92,13 +92,18 @@ public class MaterialInventoryInboundServiceImpl implements MaterialInventoryInb
List<MaterialInfomationDO> infomationDOS = materialInfomationService.saveMaterialInfomationsByBatInb(locationId, reqQuantity, gongduanId, product, batch); List<MaterialInfomationDO> infomationDOS = materialInfomationService.saveMaterialInfomationsByBatInb(locationId, reqQuantity, gongduanId, product, batch);
// 5.保存入库明细 // 5.保存入库明细
materialInventoryInboundDetailService.saveInboundDetails(infomationDOS, inbound, batchId, gongduanId); materialInventoryInboundDetailService.saveInboundDetails(infomationDOS, inbound, batchId, gongduanId);
// 是否为检定入库
Boolean isVerify = materialProductService.checkIsVerifyCategoryByPdtId(batch.getProductId());
// 更新工段已入库数量和可用数量 // 更新工段已入库数量和可用数量
gongDO.setInboundEndQuantity(gongDO.getInboundEndQuantity().add(reqQuantity)); gongDO.setInboundEndQuantity(gongDO.getInboundEndQuantity().add(reqQuantity));
gongDO.setRemaineQuantity(gongDO.getRemaineQuantity().subtract(reqQuantity)); gongDO.setRemaineQuantity(gongDO.getRemaineQuantity().subtract(reqQuantity));
materialBatchService.updateById(gongDO); materialBatchService.updateById(gongDO);
// 更新批次已入库数量和可用数量 // 更新批次已入库数量和可用数量
batch.setInboundEndQuantity(batch.getInboundEndQuantity().add(reqQuantity)); batch.setInboundEndQuantity(batch.getInboundEndQuantity().add(reqQuantity));
batch.setRemaineQuantity(batch.getRemaineQuantity().subtract(reqQuantity)); if (!isVerify) {
// 检定业务 检定流程提交时已经扣减过可用数量
batch.setRemaineQuantity(batch.getRemaineQuantity().subtract(reqQuantity));
}
materialBatchService.updateById(batch); materialBatchService.updateById(batch);
// 更新物料大类预警级别 // 更新物料大类预警级别
materialProductService.updateMaterialProductAlarmLevel(Collections.singletonList(productId)); materialProductService.updateMaterialProductAlarmLevel(Collections.singletonList(productId));

View File

@@ -310,13 +310,19 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService ,
List<MaterialBatchDO> batches = materialBatchService.getBatchListByBatchIds(batIds); List<MaterialBatchDO> batches = materialBatchService.getBatchListByBatchIds(batIds);
if (CollUtil.isEmpty(batches) || batches.size() != batIds.size()) if (CollUtil.isEmpty(batches) || batches.size() != batIds.size())
throw new ServiceException(1_032_160_000, "批次不存在或与传入的批次数量不匹配"); throw new ServiceException(1_032_160_000, "批次不存在或与传入的批次数量不匹配");
// 检定数量检验 for (MaterialBatchDO batch : batches) {
if (batch.getSubmitStatus() != 1)
throw new ServiceException(1_032_160_000, String.format("批次【%s】未提交不可检定", batch.getBatchNo()));
}
// 检定数量校验
Map<Long, MaterialBatchDO> batchDOMapById = batches.stream().collect(Collectors.toMap(MaterialBatchDO::getId, Function.identity())); Map<Long, MaterialBatchDO> batchDOMapById = batches.stream().collect(Collectors.toMap(MaterialBatchDO::getId, Function.identity()));
for (MaterialLifecycleDetailSaveReqVO reqDetail : reqDetails) { for (MaterialLifecycleDetailSaveReqVO reqDetail : reqDetails) {
MaterialBatchDO batchDO = batchDOMapById.get(reqDetail.getBatchId()); MaterialBatchDO batchDO = batchDOMapById.get(reqDetail.getBatchId());
// 可用数量
BigDecimal remaineQuantity = batchDO.getRemaineQuantity(); BigDecimal remaineQuantity = batchDO.getRemaineQuantity();
if (reqDetail.getInfluenceCount().compareTo(BigDecimal.ZERO) <= 0)
throw new ServiceException(1_032_160_000, "检定数量不能小于等于0");
if (reqDetail.getInfluenceCount().compareTo(remaineQuantity) > 0) if (reqDetail.getInfluenceCount().compareTo(remaineQuantity) > 0)
// 可用数量
throw new ServiceException(1_032_160_000, String.format("检定数量超过了批次【%s】可用数量【%s】", batchDO.getBatchNo(), remaineQuantity)); throw new ServiceException(1_032_160_000, String.format("检定数量超过了批次【%s】可用数量【%s】", batchDO.getBatchNo(), remaineQuantity));
if (reqDetail.getQualifiedCount().compareTo(reqDetail.getInfluenceCount()) > 0) if (reqDetail.getQualifiedCount().compareTo(reqDetail.getInfluenceCount()) > 0)
throw new ServiceException(1_032_160_000, "合格数量超过了检定数量"); throw new ServiceException(1_032_160_000, "合格数量超过了检定数量");

View File

@@ -132,4 +132,20 @@ public interface MaterialProductService {
* @return 物料数据 * @return 物料数据
*/ */
MaterialProductRespVO getMaterialProductInfoWithFiles(Long id); MaterialProductRespVO getMaterialProductInfoWithFiles(Long id);
/**
* 获取顶级分类
*
* @param pdtIds 大类ids
* @return 顶级分类
*/
List<MaterialProductDO> getTopCategoriesByPdtIds(List<Long> pdtIds);
/**
* 检查是否是检定的分类
*
* @param productId 大类id
* @return 是否是审核的分类
*/
Boolean checkIsVerifyCategoryByPdtId(Long productId);
} }

View File

@@ -11,9 +11,11 @@ import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.util.object.BeanUtils; import com.zt.plat.framework.common.util.object.BeanUtils;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.zt.plat.module.infra.api.businessfile.dto.BusinessFileWithUrlRespDTO; import com.zt.plat.module.infra.api.businessfile.dto.BusinessFileWithUrlRespDTO;
import com.zt.plat.module.qms.common.service.BusinessFileService; import com.zt.plat.module.qms.common.service.BusinessFileService;
import com.zt.plat.module.qms.core.constant.DataTypeConstant; import com.zt.plat.module.qms.core.constant.DataTypeConstant;
import com.zt.plat.module.qms.enums.QmsCommonConstant;
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductPageReqVO;
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductRespVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductRespVO;
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductSaveReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductSaveReqVO;
@@ -22,6 +24,7 @@ import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialProductDO
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialProductMapper; import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialProductMapper;
import com.zt.plat.module.qms.resource.material.enums.MaterialInventoryAlarmLevel; import com.zt.plat.module.qms.resource.material.enums.MaterialInventoryAlarmLevel;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -39,6 +42,7 @@ import static com.zt.plat.module.qms.enums.ErrorCodeConstants.*;
* *
* @author 后台管理 * @author 后台管理
*/ */
@Slf4j
@Service @Service
@Validated @Validated
public class MaterialProductServiceImpl implements MaterialProductService { public class MaterialProductServiceImpl implements MaterialProductService {
@@ -355,15 +359,21 @@ public class MaterialProductServiceImpl implements MaterialProductService {
.eqIfPresent(MaterialProductDO::getStandardSolutionFlag, queryVO.getStandardSolutionFlag()) .eqIfPresent(MaterialProductDO::getStandardSolutionFlag, queryVO.getStandardSolutionFlag())
.eqIfPresent(MaterialProductDO::getStandardMaterialFlag, queryVO.getStandardMaterialFlag()) .eqIfPresent(MaterialProductDO::getStandardMaterialFlag, queryVO.getStandardMaterialFlag())
.likeIfPresent(MaterialProductDO::getName, queryVO.getName()) .likeIfPresent(MaterialProductDO::getName, queryVO.getName())
.and(StrUtil.isNotEmpty(queryVO.getCategoryCustomConfig()), .and(StrUtil.isNotEmpty(queryVO.getCategoryCustomConfig()),wrapper ->
wrapper -> wrapper.eq(MaterialProductDO::getNodeType, DataTypeConstant.DATA_TYPE_CATEGORY)
wrapper.eq(MaterialProductDO::getNodeType, DataTypeConstant.DATA_TYPE_CATEGORY) .like(MaterialProductDO::getCustomConfig, queryVO.getCategoryCustomConfig()));
.like(MaterialProductDO::getCustomConfig, queryVO.getCategoryCustomConfig()));
List<MaterialProductDO> mtrlDos = materialProductMapper.selectList(wrapperX); List<MaterialProductDO> mtrlDos = materialProductMapper.selectList(wrapperX);
if (CollUtil.isEmpty(mtrlDos)) return List.of(); if (CollUtil.isEmpty(mtrlDos)) return List.of();
return mtrlDos.stream().map(m -> BeanUtils.toBean(m, MaterialProductRespVO.class)).toList(); if (StrUtil.isNotEmpty(queryVO.getCategoryCustomConfig()) && StrUtil.isEmpty(queryVO.getNodeType())) {
List<Long> ctgIds = mtrlDos.stream().map(MaterialProductDO::getId).toList();
List<MaterialProductDO> pdts = materialProductMapper.selectList(Wrappers.lambdaQuery(MaterialProductDO.class)
.in(MaterialProductDO::getParentId, ctgIds));
mtrlDos.addAll(pdts);
}
return BeanUtils.toBean(mtrlDos, MaterialProductRespVO.class);
} }
@Override @Override
@@ -441,4 +451,31 @@ public class MaterialProductServiceImpl implements MaterialProductService {
return respVO; return respVO;
} }
@Override
public List<MaterialProductDO> getTopCategoriesByPdtIds(List<Long> pdtIds) {
List<MaterialProductDO> productDOS = materialProductMapper.selectByIds(pdtIds);
// 获取顶级分类ids ipPath格式/0/2015987059211448321/2018922665117827074/2018932101769150466/
Set<Long> topCategoryIds = productDOS.stream()
.map(MaterialProductDO::getIdPath)
.filter(StrUtil::isNotEmpty)
.map(path -> path.split("/"))
.filter(segments -> segments.length > 2)
.map(segments -> segments[2])
.map(Long::parseLong)
.collect(Collectors.toSet());
return materialProductMapper.selectByIds(topCategoryIds);
}
@Override
public Boolean checkIsVerifyCategoryByPdtId(Long productId) {
List<MaterialProductDO> topCategories = this.getTopCategoriesByPdtIds(Collections.singletonList(productId));
if (CollUtil.isEmpty(topCategories)) return false;
MaterialProductDO topCtg = topCategories.get(0);
JSONObject customConfig = JSONUtil.parseObj(topCtg.getCustomConfig());
Object verifyCalibrateFlag = customConfig.get("verifyCalibrateFlag");
if (verifyCalibrateFlag == null) return false;
return "1".equals(verifyCalibrateFlag);
}
} }

Some files were not shown because too many files have changed in this diff Show More