| | |
| | | package com.taoke.autopay; |
| | | |
| | | import com.taoke.autopay.dao.ClientInfoMapper; |
| | | import com.taoke.autopay.dao.KeyOrderMapper; |
| | | import com.taoke.autopay.entity.ClientInfo; |
| | | import com.taoke.autopay.entity.KeyOrder; |
| | | import com.taoke.autopay.service.ClientInfoService; |
| | | import com.taoke.autopay.service.KeyOrderService; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | import org.springframework.util.AntPathMatcher; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author hxh |
| | |
| | | @Resource |
| | | private ClientInfoService clientInfoService; |
| | | |
| | | @Resource |
| | | private KeyOrderService keyOrderService; |
| | | |
| | | @Test |
| | | public void add(){ |
| | | ClientInfoMapper.DaoQuery query = new ClientInfoMapper.DaoQuery(); |
| | |
| | | List<ClientInfo> list = clientInfoService.list(query); |
| | | |
| | | } |
| | | |
| | | private Long getTargetClientId() { |
| | | List<Long> clientIds = clientInfoService.getRePayClientIds(); |
| | | if (clientIds != null && clientIds.size() > 0) { |
| | | // 查询设备未执行的数量 |
| | | List<List<Long>> clist=new ArrayList<>(); |
| | | for (Long cuid : clientIds) { |
| | | KeyOrderMapper.DaoQuery daoQuery = new KeyOrderMapper.DaoQuery(); |
| | | daoQuery.distributeClientUid =cuid; |
| | | daoQuery.state = KeyOrder.STATE_NOT_PAY; |
| | | daoQuery.minCreateTime=new Date(System.currentTimeMillis() - 1000*60*30L); |
| | | long count = keyOrderService.count(daoQuery); |
| | | clist.add(Arrays.asList(new Long[]{cuid,count})); |
| | | } |
| | | clist.sort(new Comparator<List<Long>>() { |
| | | @Override |
| | | public int compare(List<Long> o1, List<Long> o2) { |
| | | return (int)(o1.get(1)-o2.get(1)); |
| | | } |
| | | }); |
| | | if(clist.size()>1) { |
| | | for (int i = 1; i < clist.size(); i++) { |
| | | if (clist.get(i).get(1).longValue() != clist.get(i - 1).get(1)) { |
| | | clist = clist.subList(0, i); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | Collections.shuffle(clist); |
| | | return clist.get(0).get(0); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Test |
| | | public void testTargetUid(){ |
| | | getTargetClientId(); |
| | | |
| | | } |
| | | |
| | | public static void main(String[] args){ |
| | | AntPathMatcher pathMatcher = new AntPathMatcher(); |
| | | System.out.println( pathMatcher.match("四川/广元", "四川/广元")); |
| | | } |
| | | } |