| | |
| | | |
| | | import cn.iocoder.yudao.framework.common.exception.ServiceException; |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; |
| | | import cn.iocoder.yudao.module.mes.service.qc.iqc.MesQcIqcService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.ipqc.MesQcIpqcService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.oqc.MesQcOqcService; |
| | |
| | | @GetMapping("/list") |
| | | @PreAuthorize("@ss.hasPermission('mes:qc-' + #type.toLowerCase() + ':query')") |
| | | public CommonResult<List<StorageBlobRespDTO>> list( |
| | | @RequestParam @Pattern(regexp = "iqc|ipqc|oqc|rqc") String type, |
| | | @RequestParam @Pattern(regexp = "iqc|ipqc|oqc|rqc|patrol") String type, |
| | | @RequestParam @NotNull Long id) { |
| | | validateDocument(type, id); |
| | | var files = storageApi.listAttachments(recordType(type), id); |
| | |
| | | @PreAuthorize("@ss.hasPermission('mes:qc-' + #type.toLowerCase() + ':update')") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public CommonResult<Boolean> remove( |
| | | @RequestParam @Pattern(regexp = "iqc|ipqc|oqc|rqc") String type, |
| | | @RequestParam @Pattern(regexp = "iqc|ipqc|oqc|rqc|patrol") String type, |
| | | @RequestParam @NotNull Long id, @RequestParam @NotNull Long blobId) { |
| | | lockDocument(type, id); |
| | | validateDocument(type, id); |
| | |
| | | |
| | | private String recordType(String type) { |
| | | return switch (type) { |
| | | case "iqc", "ipqc", "oqc", "rqc" -> "mes_qc_" + type + "_attachment"; |
| | | case "iqc", "ipqc", "oqc", "rqc", "patrol" -> "mes_qc_" + type + "_attachment"; |
| | | default -> throw new ServiceException(400, "质检类型无效"); |
| | | }; |
| | | } |
| | |
| | | case "ipqc" -> "mes_qc_ipqc"; |
| | | case "oqc" -> "mes_qc_oqc"; |
| | | case "rqc" -> "mes_qc_rqc"; |
| | | case "patrol" -> "mes_qc_patrol"; |
| | | default -> throw new ServiceException(400, "质检类型无效"); |
| | | }; |
| | | var ids = jdbcTemplate.queryForList("SELECT id FROM " + table + " WHERE id = ? AND deleted = 0 FOR UPDATE", Long.class, id); |
| | |
| | | case "ipqc" -> ipqcService.validateIpqcExists(id).getStatus(); |
| | | case "oqc" -> oqcService.validateOqcExists(id).getStatus(); |
| | | case "rqc" -> rqcService.validateRqcExists(id).getStatus(); |
| | | case "patrol" -> { |
| | | var ids = jdbcTemplate.queryForList( |
| | | "SELECT id FROM mes_qc_patrol WHERE id = ? AND tenant_id = ? AND deleted = 0", |
| | | Long.class, id, TenantContextHolder.getRequiredTenantId()); |
| | | if (ids.isEmpty()) throw new ServiceException(400, "巡检记录不存在"); |
| | | yield 0; |
| | | } |
| | | default -> throw new ServiceException(400, "质检类型无效"); |
| | | }; |
| | | } |
| | | |
| | | @Data public static class SaveReq { |
| | | @NotNull @Pattern(regexp = "iqc|ipqc|oqc|rqc") private String type; |
| | | @NotNull @Pattern(regexp = "iqc|ipqc|oqc|rqc|patrol") private String type; |
| | | @NotNull private Long id; |
| | | @NotEmpty @Size(max = 50) private List<@NotNull Long> blobIds; |
| | | } |
| | | @Data public static class AppendReq { |
| | | @NotNull @Pattern(regexp = "iqc|ipqc|oqc|rqc") private String type; |
| | | @NotNull @Pattern(regexp = "iqc|ipqc|oqc|rqc|patrol") private String type; |
| | | @NotNull private Long id; |
| | | @NotNull private Long blobId; |
| | | } |