Просмотр исходного кода

根据List<id>获取器件信息

zengchao 8 лет назад
Родитель
Сommit
febf289f94

+ 9 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/api/ComponentController.java

@@ -267,4 +267,13 @@ public class ComponentController {
 		return goodsService.pageGoodsByKeyword(pageInfo, original, keyword);
 	}
 
+	/**
+	 * 根据批次号获取器件信息
+	 * @param batchIds
+	 * @return 器件信息
+	 */
+	@RequestMapping(value = "/batchId", method = RequestMethod.POST, produces = "application/json")
+	public List<ComponentInfo> getBatchBrands(@RequestBody List<Long> batchIds) {
+		return componentService.getBatchComponents(batchIds);
+	}
 }

+ 8 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/dao/ComponentInfoDao.java

@@ -80,4 +80,12 @@ public interface ComponentInfoDao extends JpaSpecificationExecutor<ComponentInfo
 	 * @return 库存数量大于指定值的一页器件
 	 */
 	Page<ComponentInfo> findByImgIsNotNull(Pageable pageable);
+
+	/**
+	 * 根据批次号获取器件信息
+	 * @param batchids id批次号
+	 * @return
+	 */
+	@Query(nativeQuery = true, value = "select * from product$component where cmp_id in :batchids")
+	public List<ComponentInfo> findByBatchids(@Param("batchids") List<Long> batchids);
 }

+ 7 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/service/ComponentService.java

@@ -202,4 +202,11 @@ public interface ComponentService {
 	 * @return 新增器件数量统计
 	 */
 	List<Map<String, Object>> findCountIncreaseComponentByMonth();
+
+	/**
+	 * 根据批次号获取器件信息
+	 * @param batchIds
+	 * @return 器件信息
+	 */
+	List<ComponentInfo> getBatchComponents(List<Long> batchIds);
 }

+ 6 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/service/impl/ComponentServiceImpl.java

@@ -536,5 +536,11 @@ public class ComponentServiceImpl implements ComponentService {
 		return map;
 	}
 
+	public List<ComponentInfo> getBatchComponents(List<Long> batchIds) {
+		if (batchIds.size() == 0) {
+			return componentInfoDao.findAll();
+		}
+		return componentInfoDao.findByBatchids(batchIds);
+	}
 
 }