| | |
| | | //package com.dsh; |
| | | // |
| | | //import com.alibaba.fastjson.JSONObject; |
| | | //import com.dsh.communityWorldCup.feignclient.account.model.AppUser; |
| | | //import com.dsh.communityWorldCup.feignclient.account.model.TStudent; |
| | | //import com.dsh.communityWorldCup.feignclient.competition.model.Participant; |
| | | //import com.dsh.communityWorldCup.mapper.WorldCupCompetitorMapper; |
| | | //import com.dsh.communityWorldCup.model.WorldCupRank; |
| | | //import com.dsh.communityWorldCup.service.impl.WorldCupCompetitorServiceImpl; |
| | | //import org.junit.Test; |
| | | //import org.junit.runner.RunWith; |
| | | //import org.springframework.boot.test.context.SpringBootTest; |
| | | //import org.springframework.test.context.junit4.SpringRunner; |
| | | // |
| | | //import javax.annotation.Resource; |
| | | //import java.math.BigDecimal; |
| | | //import java.math.MathContext; |
| | | //import java.math.RoundingMode; |
| | | //import java.util.ArrayList; |
| | | //import java.util.HashMap; |
| | | //import java.util.List; |
| | | //import java.util.Map; |
| | | // |
| | | ///** |
| | | // * @author zhibing.pu |
| | |
| | | //public class CommunityWorldCupApplicationTest { |
| | | // |
| | | // |
| | | // @Resource |
| | | // private WorldCupCompetitorMapper worldCupCompetitorMapper; |
| | | // |
| | | // |
| | | // @Test |
| | | // public void test(){ |
| | | // HashMap<String, String> map = new HashMap<>(); |
| | | // map.put("sign", "0DB011836143EEE2C2E072967C9F4E4B"); |
| | | // map.put("space_id", "2024"); |
| | | // map.put("red_sutu_id", "1037"); |
| | | // map.put("blue_sutu_id", "1036"); |
| | | // map.put("api_url", "http://8.137.22.229:56666/communityWorldCup/base/worldCup/endWorldCupCallback"); |
| | | // map.put("custom", ""); |
| | | // |
| | | // String s = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/batterGame", map); |
| | | // JSONObject jsonObject = JSONObject.parseObject(s); |
| | | // Integer code1 = jsonObject.getInteger("code"); |
| | | // String message = jsonObject.getString("message"); |
| | | // if (200 == code1) { |
| | | // return ResultUtil.success(); |
| | | // } else { |
| | | // return ResultUtil.error(message); |
| | | // WorldCupRank worldCupRank = new WorldCupRank(); |
| | | // worldCupRank.setYear(2024); |
| | | // //总场次 |
| | | // List<Map<String, Object>> lists = worldCupCompetitorMapper.getWorldCupRank(worldCupRank, null); |
| | | // //未负的数据 |
| | | // List<Map<String, Object>> lists1 = worldCupCompetitorMapper.getWorldCupRank1(worldCupRank, null); |
| | | // List<Map<String, Object>> mapList = new ArrayList<>(); |
| | | // for (int i = 0; i < lists.size(); i++) { |
| | | // Map<String, Object> map = lists.get(i); |
| | | // Integer participantType = Integer.valueOf(map.get("participantType").toString()); |
| | | // Long participantId = Long.valueOf(map.get("participantId").toString()); |
| | | // Integer appUserId = Integer.valueOf(map.get("appUserId").toString()); |
| | | // Integer num = Integer.valueOf(null == map.get("num") ? "0" : map.get("num").toString()); |
| | | // map.put("totalSession", num); |
| | | // map.put("winRate", "0"); |
| | | // for (Map<String, Object> objectMap : lists1) { |
| | | // Integer participantType1 = Integer.valueOf(objectMap.get("participantType").toString()); |
| | | // Long participantId1 = Long.valueOf(objectMap.get("participantId").toString()); |
| | | // Integer appUserId1 = Integer.valueOf(objectMap.get("appUserId").toString()); |
| | | // Integer num1 = Integer.valueOf(null == objectMap.get("num") ? "0" : objectMap.get("num").toString()); |
| | | // if(participantType.compareTo(participantType1) == 0 && participantId.compareTo(participantId1) == 0 && appUserId.compareTo(appUserId1) == 0){ |
| | | // map.put("winRate", new BigDecimal(num1).divide(new BigDecimal(num), new MathContext(2, RoundingMode.HALF_EVEN)).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | // break; |
| | | // } |
| | | // } |
| | | // mapList.add(map); |
| | | // } |
| | | // } |
| | | // |