/**
* 房间已经预定的时间统计表
*/
public interface RoomOrderTimeRepository extends JpaRepository{
@Query("select new com.ddzrh.dto.RoomOrderTimeOutPut(r.orderTime,COUNT(r.orderTime) )" +
" from RoomOrderTime as r " +
" where r.roomTypeId =:roomId"+
" GROUP BY r.orderTime" )
List queryRoomOrderTime(@Param("roomId") Integer roomId);
}
@Data
public class RoomOrderTimeOutPut {
private Date orderTime;
private Long orderNum;
public RoomOrderTimeOutPut(Date orderTime, Long orderNum) {
this.orderTime = orderTime;
this.orderNum = orderNum;
}
}
使用@Query(value = "select new com.wd.cloud.uoserver.dto.TjVO(u.orgId ,count(u.orgId)) from User u group by orgId")进行查询。
@Value
public class TjVO {
Long orgId;
Long registerCount;
}
/**
* 按机构统计注册人数
* @param pageable
* @return
*/
@Query(value = "select new com.wd.cloud.uoserver.dto.TjVO(u.orgId ,count(u.orgId)) from User u group by orgId")
Page tjByOrgId(Pageable pageable);
/**
* 按天统计注册人数
* @return
*/
@Query(value = "select DATE_FORMAT(gmt_create,\"%Y-%m-%d\") as registerDate,count(*) as registerCount from user group by registerDate",nativeQuery = true)
List tj();
/**
* 按机构统计注册人数
* @param pageable 分页
* @return
*/
@Query(value = "select org_id as orgId,count(*) as registerCount from user group by orgId",
countQuery = "select count(*) from user group by org_id", nativeQuery = true)
Page tjByOrgId(Pageable pageable);
测试:
@RunWith(SpringRunner.class)
@SpringBootTest
public class UoServerApplicationTests {
@Autowired
UserRepository userRepository;
@Test
public void contextLoads() {
List tjDTOList = userRepository.tj();
tjDTOList.forEach(tjDTO -> {
Console.log("registerDate={},registerCount={}", tjDTO.getRegisterDate(), tjDTO.getRegisterCount());
});
}
}
结果日志:
Hibernate: select DATE_FORMAT(gmt_create,"%Y-%m-%d") as registerDate,count(*) >as registerCount from user group by registerDate registerDate=2019-01-28,registerCount=7393 registerDate=2019-03-07,registerCount=1
需求:根据机构分组,统计机构总人数和用户类型为2的人数
@Component
public class SpecBuilder {
@PersistenceContext
private EntityManager entityManager;
public List
测试:
@RunWith(SpringRunner.class)
@SpringBootTest
public class UoServerApplicationTests {
@Autowired
SpecBuilder specBuilder;
@Test
public void contextLoads() {
List tjDTOList1 = specBuilder.tj(169L);
tjDTOList1.forEach(tjDTO -> {
Console.log("orgId={},总人数={},管理员人数={}", tjDTO[0], tjDTO[1], tjDTO[2]);
});
}
}
1.java.util.Timer.schedule(TimerTask task, long delay):多长时间(毫秒)后执行任务
2.java.util.Timer.schedule(TimerTask task, Date time):设定某个时间执行任务
3.java.util.Timer.schedule(TimerTask task, long delay,longperiod
java.lang.UnsupportedClassVersionError: cn/support/cache/CacheType : Unsupported major.minor version 51.0 (unable to load class cn.support.cache.CacheType)
at org.apache.catalina.loader.WebappClassL
昨天发了一个提问,启动5个线程将一个List中的内容,然后将5个线程的内容拼接起来,由于时间比较急迫,自己就写了一个Demo,希望对菜鸟有参考意义。。
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
public c
select list.listname, list.createtime,listcount from dream_list as list , (select listid,count(listid) as listcount from dream_list_user group by listid order by count(
此文转自IBM.
Apache 服务简介
Web 服务器也称为 WWW 服务器或 HTTP 服务器 (HTTP Server),它是 Internet 上最常见也是使用最频繁的服务器之一,Web 服务器能够为用户提供网页浏览、论坛访问等等服务。
由于用户在通过 Web 浏览器访问信息资源的过程中,无须再关心一些技术性的细节,而且界面非常友好,因而 Web 在 Internet 上一推出就得到
1) I love you not because of who you are, but because of who I am when I am with you. 我爱你,不是因为你是一个怎样的人,而是因为我喜欢与你在一起时的感觉。 2) No man or woman is worth your tears, and the one who is, won‘t