no message
parent
a49e53562c
commit
3e4c14ccba
|
|
@ -68,6 +68,15 @@ public interface InventoryRepository extends JpaRepository<Inventory, Long>, Jpa
|
|||
@Query(" from Inventory inv where inv.stockCode=:stockCode and inv.quantity>0 ")
|
||||
List<Inventory> findByStockCode(String stockCode);
|
||||
|
||||
@Query(" from Inventory inv where inv.quantity>0 ")
|
||||
Page<Inventory> queryBigScreenPointInfo(Pageable pageable);
|
||||
@Query(" select " +
|
||||
" inv.stock.code," +
|
||||
" inv.point.code," +
|
||||
" function('group_concat', inv.itemKey.orderNumber) as orderNumber," +
|
||||
" inv.itemKey.item.code," +
|
||||
" sum(inv.quantity) " +
|
||||
" from Inventory inv " +
|
||||
" where inv.quantity>0 " +
|
||||
" group by inv.stock.code,inv.point.code,inv.itemKey.item.code " +
|
||||
" order by inv.point.code ")
|
||||
Page<List<Object[]>> queryBigScreenPointInfo(Pageable pageable);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
import io.swagger.annotations.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
|
|
@ -101,8 +102,7 @@ public class InventoryController {
|
|||
@ApiOperation("查询大屏点位信息")
|
||||
@AnonymousAccess
|
||||
public ResponseEntity<Object> queryBigScreenPointInfo(CurrentPage currentPage) {
|
||||
Page<Inventory> inventoryList = inventoryService.queryBigScreenPointInfo(currentPage.getCurrentPage(), currentPage.getPageSize());
|
||||
|
||||
Page<List<Object[]>> inventoryList = inventoryService.queryBigScreenPointInfo(currentPage.getCurrentPage(), currentPage.getPageSize());
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("total", inventoryList.getTotalElements());
|
||||
object.put("data", inventoryList.getContent());
|
||||
|
|
|
|||
|
|
@ -146,5 +146,6 @@ public interface InventoryService {
|
|||
* @param currentPage 当前页
|
||||
* @param pageSize 每页显示条数
|
||||
*/
|
||||
Page<Inventory> queryBigScreenPointInfo(int currentPage, int pageSize);
|
||||
Page<List<Object[]>> queryBigScreenPointInfo(int currentPage, int pageSize);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ import org.springframework.data.domain.Pageable;
|
|||
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
|
|
@ -49,6 +51,7 @@ public class InventoryServiceImpl implements InventoryService {
|
|||
|
||||
private final InventoryRepository inventoryRepository;
|
||||
private final InventoryMapper inventoryMapper;
|
||||
private final EntityManager entityManager;
|
||||
|
||||
|
||||
@Override
|
||||
|
|
@ -162,8 +165,8 @@ public class InventoryServiceImpl implements InventoryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Page<Inventory> queryBigScreenPointInfo(int currentPage, int pageSize) {
|
||||
Pageable pageable = PageRequest.of(currentPage - 1, pageSize);
|
||||
public Page<List<Object[]>> queryBigScreenPointInfo(int currentPage, int pageSize) {
|
||||
Pageable pageable= PageRequest.of(currentPage - 1, pageSize);
|
||||
return inventoryRepository.queryBigScreenPointInfo(pageable);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
package com.youchain.utils;
|
||||
|
||||
import org.hibernate.dialect.MySQL5InnoDBDialect;
|
||||
import org.hibernate.dialect.function.StandardSQLFunction;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
|
||||
public class MySQLDialectExtended extends MySQL5InnoDBDialect {
|
||||
public MySQLDialectExtended() {
|
||||
super();
|
||||
registerFunction("group_concat", new StandardSQLFunction("group_concat", StandardBasicTypes.STRING));
|
||||
}
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ spring:
|
|||
open-in-view: true
|
||||
properties:
|
||||
hibernate:
|
||||
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
|
||||
dialect: com.youchain.utils.MySQLDialectExtended
|
||||
jdbc:
|
||||
batch_size: 500
|
||||
batch_versioned_data: true
|
||||
|
|
|
|||
Loading…
Reference in New Issue