basic-server/src/main/java/com/ruoyi/basic/controller/ProductPartController.java
@@ -60,8 +60,8 @@ @ApiOperation(value = "产品零件日志查询") @GetMapping("/productPartLogList") public Result productPartLogList(Page page,Integer id){ return Result.success(productPartService.productPartLogList(page,id)); public Result productPartLogList(Page page,Integer id,String type){ return Result.success(productPartService.productPartLogList(page,id,type)); } } basic-server/src/main/java/com/ruoyi/basic/dto/ProductPartDto.java
@@ -8,4 +8,6 @@ private Integer id; private Integer productId; private String type; } basic-server/src/main/java/com/ruoyi/basic/pojo/ProductPartLog.java
@@ -53,5 +53,8 @@ @ApiModelProperty("是否已复核") private String review; @ApiModelProperty("是否已复核") private String type; } basic-server/src/main/java/com/ruoyi/basic/service/ProductPartService.java
@@ -22,5 +22,5 @@ int productPartReviewById(ProductPartDto productPartDto); IPage<ProductPartLog> productPartLogList(Page page, Integer id); IPage<ProductPartLog> productPartLogList(Page page, Integer id,String Type); } basic-server/src/main/java/com/ruoyi/basic/service/impl/ProductPartServiceImpl.java
@@ -82,36 +82,92 @@ @Override public int productPartReviewById(ProductPartDto productPartDto) { int userId = SecurityUtils.getUserId().intValue(); String username = SecurityUtils.getUsername(); ProductPart productPart = productPartMapper.selectById(productPartDto.getId()); this.isPartNoExist(productPart.getPartNo(), productPart.getProductId(), productPart.getId()); if (productPart.getProductId() == null) { throw new BaseException("缺少产品对象id"); // 定义通用的产品部分对象 Object productPart = null; if ("对象".equals(productPartDto.getType())) { productPart = structureTestObjectPartMapper.selectById(productPartDto.getId()); if (productPart != null && ((StructureTestObjectPart) productPart).getTestObjectId() == null) { throw new BaseException("缺少产品对象id"); } } else { productPart = productPartMapper.selectById(productPartDto.getId()); if (productPart != null && ((ProductPart) productPart).getProductId() == null) { throw new BaseException("缺少产品对象id"); } } productPart.setReview("已复核"); int num = productPartMapper.updateById(productPart); if (productPart == null) { return 0; } // 设置审核状态 if (productPart instanceof StructureTestObjectPart) { ((StructureTestObjectPart) productPart).setReview("已复核"); } else { ((ProductPart) productPart).setReview("已复核"); } // 更新产品部分信息 int num = 0; if (productPart instanceof StructureTestObjectPart) { num = structureTestObjectPartMapper.updateById((StructureTestObjectPart) productPart); } else { num = productPartMapper.updateById((ProductPart) productPart); } // 如果更新成功,创建或更新日志 if (num > 0) { ProductPartLog productPartLog = new ProductPartLog(); productPartLog.setProductPartId(productPart.getId()); productPartLog.setOperName(username); productPartLog.setOperId(userId); productPartLog.setOperTime(LocalDateTime.now()); productPartLog.setColor(productPart.getColor()); productPartLog.setColorCode(productPart.getColorCode()); productPartLog.setPartNo(productPart.getPartNo()); productPartLog.setInspectionItem(productPart.getInspectionItem()); productPartLog.setReview(productPart.getReview()); productPartLogMapper.insert(productPartLog); createOrUpdateProductPartLog(productPart, username, userId, productPartDto.getType(), productPartDto); } return num; } private void createOrUpdateProductPartLog(Object productPart, String username, int userId, String type, ProductPartDto productPartDto) { ProductPartLog productPartLog = new ProductPartLog(); if (productPart instanceof StructureTestObjectPart) { StructureTestObjectPart part = (StructureTestObjectPart) productPart; productPartLog.setProductPartId(part.getId()); productPartLog.setColor(part.getColor()); productPartLog.setColorCode(part.getColorCode()); productPartLog.setPartNo(part.getPartNo()); productPartLog.setInspectionItem(part.getInspectionItem()); productPartLog.setReview(part.getReview()); } else { ProductPart part = (ProductPart) productPart; productPartLog.setProductPartId(part.getId()); productPartLog.setColor(part.getColor()); productPartLog.setColorCode(part.getColorCode()); productPartLog.setPartNo(part.getPartNo()); productPartLog.setInspectionItem(part.getInspectionItem()); productPartLog.setReview(part.getReview()); } productPartLog.setOperName(username); productPartLog.setOperId(userId); productPartLog.setOperTime(LocalDateTime.now()); productPartLog.setType(type); // 检查是否存在相同 ProductPartId 的日志记录 ProductPartLog existingLog = productPartLogMapper.selectOne(new LambdaQueryWrapper<ProductPartLog>().eq(ProductPartLog::getProductPartId, productPartDto.getId())); if (existingLog != null) { // 如果存在,更新记录 productPartLog.setId(existingLog.getId()); // 设置更新记录的 ID productPartLogMapper.updateById(productPartLog); } else { // 如果不存在,插入新记录 productPartLogMapper.insert(productPartLog); } } @Override public IPage<ProductPartLog> productPartLogList(Page page, Integer id) { public IPage<ProductPartLog> productPartLogList(Page page, Integer id, String type) { return productPartLogMapper.selectPage(page, Wrappers.<ProductPartLog>lambdaQuery() .eq(ProductPartLog::getProductPartId, id)); .eq(ProductPartLog::getProductPartId, id) .eq(ProductPartLog::getType, type)); } // 判断零件号是否存在 inspect-server/src/main/java/com/ruoyi/inspect/controller/ReliabilityPlanProductItemController.java
@@ -24,8 +24,8 @@ @ApiOperation("查询可靠性计划成品检验项") @GetMapping("/selectProductItem") public Result selectProductItem() { return Result.success(reliabilityPlanProductItemService.selectProductItem()); public Result selectProductItem(ReliabilityPlanProductItemDto reliabilityPlanProductItemDto) { return Result.success(reliabilityPlanProductItemService.selectProductItem(reliabilityPlanProductItemDto)); } @ApiOperation(value = "添加可靠性计划成品检验项") @@ -40,12 +40,24 @@ return Result.success(reliabilityPlanProductItemService.itemList(reliabilityPlanProductItemDto)); } @ApiOperation(value = "查询原辅材产品检验项") @GetMapping("/materialItem") public Result materialItem(ReliabilityPlanProductItemDto reliabilityPlanProductItemDto) { return Result.success(reliabilityPlanProductItemService.materialItem(reliabilityPlanProductItemDto)); } @ApiOperation(value = "查询产品检验项") @GetMapping("/codeList") public Result codeList(ReliabilityPlanProductItemDto reliabilityPlanProductItemDto) { return Result.success(reliabilityPlanProductItemService.codeList(reliabilityPlanProductItemDto)); } @ApiOperation(value = "查询原辅材产品检验项") @GetMapping("/materialCodeList") public Result materialCodeList(ReliabilityPlanProductItemDto reliabilityPlanProductItemDto) { return Result.success(reliabilityPlanProductItemService.materialCodeList(reliabilityPlanProductItemDto)); } @ApiOperation(value = "删除") @DeleteMapping("/deleteItem") public Result deleteItem(Integer id) { inspect-server/src/main/java/com/ruoyi/inspect/mapper/ReliabilityPlanProductItemMapper.java
@@ -20,4 +20,8 @@ List<Map<String, Object>> itemList(@Param("planId") Integer rePlanId); List<Map<String, Object>> codeList(@Param("planId") Integer rePlanId); List<Map<String, Object>> materialItem(@Param("planId") Integer rePlanId); List<Map<String, Object>> materialCodeList(@Param("planId") Integer rePlanId); } inspect-server/src/main/java/com/ruoyi/inspect/pojo/ReliabilityPlanMaterial.java
@@ -35,9 +35,6 @@ @ApiModelProperty("原辅料名称ID") private Integer materialId; @ApiModelProperty("是否通过") private String isPass; @ApiModelProperty("审核人id") private Integer reviewerId; inspect-server/src/main/java/com/ruoyi/inspect/pojo/ReliabilityPlanProductItem.java
@@ -42,4 +42,9 @@ @ApiModelProperty("关联可靠性计划产品id") private Integer planId; /** * 成品/原辅材 */ @ApiModelProperty("类型") private String type; } inspect-server/src/main/java/com/ruoyi/inspect/service/ReliabilityPlanProductItemService.java
@@ -17,11 +17,15 @@ */ public interface ReliabilityPlanProductItemService extends IService<ReliabilityPlanProductItem> { List<ReliabilityPlanProductItem> selectProductItem(); List<ReliabilityPlanProductItem> selectProductItem(ReliabilityPlanProductItemDto reliabilityPlanProductItemDto); int addOrUpdateItem(ReliabilityPlanProductItemDto reliabilityPlanProductItemDto); List<Map<String, Object>> itemList(ReliabilityPlanProductItemDto reliabilityPlanProductItemDto); List<Map<String, Object>> codeList(ReliabilityPlanProductItemDto reliabilityPlanProductItemDto); List<Map<String, Object>> materialItem(ReliabilityPlanProductItemDto reliabilityPlanProductItemDto); List<Map<String, Object>> materialCodeList(ReliabilityPlanProductItemDto reliabilityPlanProductItemDto); } inspect-server/src/main/java/com/ruoyi/inspect/service/impl/ReliabilityPlanProductItemServiceImpl.java
@@ -27,8 +27,9 @@ private ReliabilityPlanProductItemMapper reliabilityPlanProductItemMapper; @Override public List<ReliabilityPlanProductItem> selectProductItem() { return reliabilityPlanProductItemMapper.selectList(new LambdaQueryWrapper<>()); public List<ReliabilityPlanProductItem> selectProductItem(ReliabilityPlanProductItemDto reliabilityPlanProductItemDto) { return reliabilityPlanProductItemMapper.selectList(new LambdaQueryWrapper<ReliabilityPlanProductItem>().eq(ReliabilityPlanProductItem::getPlanId,reliabilityPlanProductItemDto.getRePlanId()) .eq(ReliabilityPlanProductItem::getType,reliabilityPlanProductItemDto.getType())); } @Override @@ -50,4 +51,14 @@ public List<Map<String, Object>> codeList(ReliabilityPlanProductItemDto reliabilityPlanProductItemDto) { return reliabilityPlanProductItemMapper.codeList(reliabilityPlanProductItemDto.getRePlanId()); } @Override public List<Map<String, Object>> materialItem(ReliabilityPlanProductItemDto reliabilityPlanProductItemDto) { return reliabilityPlanProductItemMapper.materialItem(reliabilityPlanProductItemDto.getRePlanId()); } @Override public List<Map<String, Object>> materialCodeList(ReliabilityPlanProductItemDto reliabilityPlanProductItemDto) { return reliabilityPlanProductItemMapper.materialCodeList(reliabilityPlanProductItemDto.getRePlanId()); } } inspect-server/src/main/resources/mapper/ReliabilityPlanProductItemMapper.xml
@@ -56,5 +56,36 @@ LEFT JOIN standard_method sm ON sm.id = spl.standard_method_list_id WHERE rp.id = #{planId} </select> <select id="materialItem" resultType="java.util.Map"> SELECT sp.inspection_item AS inspectionItem FROM structure_item_parameter sp CROSS JOIN JSON_TABLE (sp.sample, '$[*][*]' COLUMNS (VALUE VARCHAR (255) PATH '$')) AS jt JOIN reliability_plan_material rp ON rp.material_name = jt. VALUE AND rp.id = #{planId} GROUP BY sp.id, sp.inspection_item UNION ALL SELECT inspection_item AS inspectionItem FROM structure_item_parameter WHERE sample IS NULL OR sample = '' OR sample = '[]' ORDER BY inspectionItem ASC; </select> <select id="materialCodeList" resultType="java.util.Map"> SELECT DISTINCT sm.`code` as standard, sm.id FROM (SELECT material_name FROM reliability_plan_material WHERE id = #{planId}) rm JOIN standard_product_list spl ON spl.sample = rm.material_name AND spl.sample IS NOT NULL JOIN standard_method sm ON sm.id = spl.standard_method_list_id; </select> </mapper>