| | |
| | | @Resource private MesQcIpqcService ipqcService; |
| | | @Resource private MesQcOqcService oqcService; |
| | | @Resource private MesQcRqcService rqcService; |
| | | @Resource private cn.iocoder.yudao.module.mes.controller.admin.qc.patrol.PatrolMapper patrolMapper; |
| | | @Resource private StorageAttachmentApi storageApi; |
| | | @Resource private org.springframework.jdbc.core.JdbcTemplate jdbcTemplate; |
| | | |
| | | @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" -> { if (patrolMapper.selectById(id) == null) 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; |
| | | } |