| | |
| | | package cn.iocoder.yudao.module.mes.service.qc; |
| | | |
| | | import cn.iocoder.yudao.framework.common.exception.ServiceException; |
| | | import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Component; |
| | | import java.math.BigDecimal; |
| | |
| | | /** 按数量汇总质检结果,不推断不合格品的后续处置方式。 */ |
| | | @Component |
| | | public class MesQcCompletionHelper { |
| | | @Resource private StorageAttachmentApi storageApi; |
| | | @Resource private org.springframework.jdbc.core.JdbcTemplate jdbcTemplate; |
| | | |
| | | public void lockDocument(String type, Long id) { |
| | |
| | | if (total.signum() <= 0 || checked == null || total.compareTo(checked) != 0) { |
| | | throw new ServiceException(400, "合格数量与不合格数量之和须大于零且等于检测数量"); |
| | | } |
| | | var attachments = storageApi.listAttachments("mes_qc_" + type + "_attachment", id); |
| | | if (attachments == null || attachments.isEmpty()) throw new ServiceException(400, "请先上传检验附件"); |
| | | // 检验附件改为非必填,完成检验时不再强制校验是否已上传。 |
| | | // 与现有 mes_qc_check_result 字典一致:1 通过,2 不通过。 |
| | | return unqualified.signum() == 0 ? 1 : 2; |
| | | } |