| | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | |
| | | |
| | | @Resource |
| | | private AgentProducer agentProducer; |
| | | |
| | | public static void main(String[] args) { |
| | | for(int i = 0; i< 10 ;i++){ |
| | | int randomInt = RandomUtil.randomInt(1, 5); |
| | | System.out.println(randomInt); |
| | | try { |
| | | Thread.sleep(randomInt * 1000L); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | System.out.println(i); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 自动发送红包定时器 |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Scheduled(cron = "0 0 0 * * ? ") |
| | | public void deleteMsg() { |
| | | DateTime date = DateUtil.date(); |
| | | DateTime dateTime = DateUtil.offsetHour(date, -36); |
| | | chatUserMapper.deleteMsgByCreateTime(dateTime); |
| | | List<Long> ids = chatUserMapper.selectChatRedBagByCreateTime(dateTime); |
| | | if(CollUtil.isNotEmpty(ids)){ |
| | | Long aLong = ids.get(0); |
| | | chatUserMapper.deleteChatRedBagById(aLong); |
| | | |
| | | List<Long> recordIds = chatUserMapper.selectChatRedBagRecordByRebBagId(aLong); |
| | | if(CollUtil.isNotEmpty(recordIds)){ |
| | | Long aLong1 = recordIds.get(0); |
| | | chatUserMapper.deleteChatRedBagRecordById(aLong1); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | DateTime date = DateUtil.date(); |
| | | System.out.println(date); |
| | | ArrayList<DateTime> objects = new ArrayList<>(); |
| | | for(int i = 0;i<= 10 ;i++){ |
| | | DateTime dateTime = DateUtil.offsetHour(date, -i); |
| | | objects.add(dateTime); |
| | | } |
| | | |
| | | System.out.println(objects.size()); |
| | | System.out.println(objects); |
| | | objects.remove(0); |
| | | System.out.println(objects); |
| | | System.out.println(objects.size()); |
| | | } |
| | | } |