//package com.jxy.marketall.utils;
//
//
//import com.alibaba.fastjson.JSONObject;
//import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A;
//import com.jxy.common.core.constant.Constants;
//import com.jxy.common.core.text.Convert;
//import com.jxy.common.core.text.DoubleCalculate;
//import com.jxy.common.core.utils.DateUtils;
//import com.jxy.common.core.utils.StringUtils;
//import com.jxy.common.core.utils.uuid.Seq;
//import com.jxy.common.core.web.Result.AjaxResult;
//
//import com.jxy.marketall.dto.*;
//
//import com.jxy.marketall.entity.KeyValue;
//import com.jxy.marketall.entity.Message;
//
//import com.jxy.marketall.enums.SubscriptionType;
//import com.jxy.marketall.enums.TicketStatusType;
//import com.jxy.marketall.mapper.UserHelpMapper;
//import com.jxy.marketall.vo.TimeZoneVo;
//import org.apache.commons.io.FilenameUtils;
//import org.apache.commons.lang3.ArrayUtils;
//import org.apache.poi.ss.formula.functions.T;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.domain.Sort;
//import org.springframework.data.mongodb.core.MongoTemplate;
//import org.springframework.data.mongodb.core.query.Criteria;
//import org.springframework.data.mongodb.core.query.Query;
//import org.springframework.web.client.RestTemplate;
//
//import javax.annotation.Resource;
//
//import java.math.BigDecimal;
//import java.text.ParseException;
//import java.time.LocalDate;
//import java.time.LocalDateTime;
//import java.time.ZoneId;
//import java.util.*;
//import java.util.stream.Collectors;
//
///**
// * @Description TODO
// * @Date 2022/7/11 11:11
// * @Author 杜懿
// */
//public class Tes{
//    @Resource(name = "restTemplateIgnoreSSL")
//    private static RestTemplate restTemplateIgnoreSSL;
//
//
//
//    public static void main(String[] args) throws ParseException {
//        //String a = "{"
//        //+ "\"_id\":ObjectId(\"65f13be03aaf88ae3daeabd1\"), \"buy43000\" : 8400568, \"buy42000\" : 8986661, \"buy40000\" : 865190, \"buy46000\" : 2020076, \"buy37000\" : 6622304, \"buy36000\" : 2671348, \"buy35000\" : 3425082, \"buy57000\" : 1054808, \"buy55000\" : 388639, \"buy50000\" : 667887, \"buy34000\" : 2751245, \"buy49000\" : 1016564, \"buy61000\" : 782317, \"buy51000\" : 3070936, \"buy38000\" : 999293, \"buy54000\" : 645913, \"buy63000\" : 1112962, \"buy59000\" : 186359, \"buy53000\" : 209426, \"buy58000\" : 522669, \"buy56000\" : 306257, \"buy60000\" : 303457, \"buy33000\" : 1185250, \"buy62000\" : 1496639, \"buy16000\" : 2075325, \"buy28000\" : 4066233, \"buy31000\" : 693908, \"buy29000\" : 9566719, \"buy26000\" : 11474808, \"buy27000\" : 7199278, \"buy39000\" : 2779439, \"buy19000\" : 1649052, \"buy68000\" : 1638444, \"buy41000\" : 5131607, \"buy5000\" : 1386769, \"buy30000\" : 5859864, \"buy32000\" : 310597, \"buy8000\" : 3024819, \"buy2000\" : 1167262, \"buy25000\" : 4201002, \"buy3000\" : 2017850, \"buy0\" : 18560573, \"buy7000\" : 2710894, \"buy11000\" : 2082359, \"buy13000\" : 371100, \"buy22000\" : 1228114, \"buy10000\" : 2508852, \"buy9000\" : 3028038, \"buy20000\" : 1574093, \"buy69000\" : 590701, \"buy1000\" : 1594966, \"buy24000\" : 583424, \"buy6000\" : 2715572, \"buy66000\" : 1189407, \"buy47000\" : 1322233, \"buy72000\" : 666885, \"buy12000\" : 283921, \"buy23000\" : 1545612, \"buy44000\" : 2843626, \"buy52000\" : 1184664, \"buy21000\" : 997903, \"buy18000\" : 562940, \"buy65000\" : 30753, \"buy4000\" : 1229760, \"buy15000\" : 447657, \"buy14000\" : 273102, \"buy45000\" : 561884, \"buy17000\" : 972962, \"buy64000\" : 144778, \"buy48000\" : 860305, \"buy67000\" : 40213, \"unixdt\" : 1710201600 }";
//        //JSONObject o = new JSONObject(a);
//
//        String a = "{" +
//                " \"_id\" :\"65f13be03aaf88ae3daeabd2\", \"buy_amount43000\" : 397670.5376904281, \"buy_amount42000\" : 767034.2420763989, \"buy_amount40000\" : 99665.48176275668, \"buy_amount46000\" : 206246.53063623907, \"buy_amount37000\" : 301599.1273237665, \"buy_amount36000\" : 176019.52679966358, \"buy_amount35000\" : 238924.6055385731, \"buy_amount57000\" : 377744.20912080386, \"buy_amount55000\" : 195260.48502107422, \"buy_amount50000\" : 87439.01977136593, \"buy_amount34000\" : 168721.31240377005, \"buy_amount49000\" : 180329.46878078545, \"buy_amount61000\" : 185031.183799778, \"buy_amount51000\" : 313375.8620308582, \"buy_amount38000\" : 207277.8486718667, \"buy_amount54000\" : 193647.38276923783, \"buy_amount63000\" : 311856.76413115935, \"buy_amount59000\" : 38185.288412855174, \"buy_amount53000\" : 24265.028948545732, \"buy_amount58000\" : 98588.48446104764, \"buy_amount56000\" : 137848.67179311893, \"buy_amount60000\" : 40899.39569006628, \"buy_amount33000\" : 93411.58229201885, \"buy_amount62000\" : 162065.34343984036, \"buy_amount16000\" : 529736.8841792408, \"buy_amount28000\" : 289303.18729147676, \"buy_amount31000\" : 73689.57420574508, \"buy_amount29000\" : 497009.53961673606, \"buy_amount26000\" : 624266.1368051951, \"buy_amount27000\" : 376976.21796900424, \"buy_amount39000\" : 345133.06946392584, \"buy_amount19000\" : 241240.67898876115, \"buy_amount68000\" : 251158.4203289208, \"buy_amount41000\" : 269268.3472917637, \"buy_amount5000\" : 157824.57847333903, \"buy_amount30000\" : 385087.5021972892, \"buy_amount32000\" : 46933.57258607716, \"buy_amount8000\" : 349819.94450432353, \"buy_amount2000\" : 198110.5401349781, \"buy_amount25000\" : 175803.44971073206, \"buy_amount3000\" : 565554.2436629072, \"buy_amount0\" : 4072267.946727287, \"buy_amount7000\" : 317255.86990873865, \"buy_amount11000\" : 254865.52064161754, \"buy_amount13000\" : 155699.79027243346, \"buy_amount22000\" : 235306.56113395002, \"buy_amount10000\" : 328953.8429927505, \"buy_amount9000\" : 367507.6768498568, \"buy_amount20000\" : 354163.87625436275, \"buy_amount69000\" : 244600.3554024914, \"buy_amount1000\" : 142622.80384720216, \"buy_amount24000\" : 62406.335102292454, \"buy_amount6000\" : 328543.3098989847, \"buy_amount66000\" : 252969.2812573937, \"buy_amount47000\" : 136865.1431544493, \"buy_amount72000\" : 282125.4013262847, \"buy_amount12000\" : 51056.25355095868, \"buy_amount23000\" : 239995.53900468553, \"buy_amount44000\" : 206049.6740233786, \"buy_amount52000\" : 94009.00163482186, \"buy_amount21000\" : 150088.7939437478, \"buy_amount18000\" : 171789.13752690234, \"buy_amount65000\" : 4289.07829319004, \"buy_amount4000\" : 199197.05302923173, \"buy_amount15000\" : 80544.81065482534, \"buy_amount14000\" : 47766.528040035635, \"buy_amount45000\" : 51419.351005823155, \"buy_amount17000\" : 238576.92242057182, \"buy_amount64000\" : 16784.91292047001, \"buy_amount48000\" : 177529.61767764398, \"buy_amount67000\" : 7163.084953869558, \"unixdt\" : 1710201600 }";
//        JSONObject buyAmountDto = JSONObject.parseObject(a);
//
//        System.out.println(buyAmountDto);
//        Map<String,Object> map = new LinkedHashMap<>();
//        Map<String,Object> sortMap = new HashMap<>();
//
//        Iterator<Map.Entry<String, Object>> iterator = buyAmountDto.entrySet().iterator();
//        Map.Entry<String, Object> entry;
//        while (iterator.hasNext()){
//            entry =iterator.next();
//            if(entry.getKey().equals("_id")){
//                map.put("id",Convert.toStr(entry.getValue()));
//            }else if(entry.getKey().equals("unixdt")){
//                map.put("date",Convert.toStr(entry.getValue()));
//            }else {
//                sortMap.put(StringUtils.toCamelCase(entry.getKey()),Convert.toInt(entry.getValue()));
//            }
//        }
//        System.out.println(map);
//        System.out.println(sortMap);
//        List<KeyValue> list = sortMap.entrySet().stream().map(c -> new KeyValue(c.getKey(), Convert.toStr(c.getValue())))
//                .collect(Collectors.toList());
//        list.stream().forEach(e -> System.out.println(e));
//        //排序 先去掉key中的buy 剩下的数字按按大小升序排序
//        list.sort(new Comparator<KeyValue>() {
//            @Override
//            public int compare(KeyValue o1, KeyValue o2) {
//                return Convert.toInt(o1.getKey().replace("buyAmount",""))
//                        .compareTo(Convert.toInt(o2.getKey().replace("buyAmount","")));
//            }
//        });
//
//        list.forEach(e -> map.put(e.getKey(),Convert.toInt(e.getValue())));
//
//        //List<KeyValue> list = map.entrySet().stream().map(c -> new KeyValue(c.getKey(), c.getValue()))
//        //        .collect(Collectors.toList());
//        //list = list.stream().sorted(Comparator.comparing(KeyValue::getKey)).collect(Collectors.toList());
//        //list.forEach(e -> System.out.println(e.getKey()+":"+e.getValue()));
//
//        //Map<String,Integer> map2 = new HashMap<>();
//        //map.entrySet().stream().sorted(Map.Entry.<String, Integer>comparingByKey().reversed()).forEachOrdered(e ->map2.put(e.getKey(), e.getValue()) );
//        //System.out.println(map2);
//    }
//
//    public static void test(String msg) {
//
//        for (int i=1;i<6;i++){
//            System.out.println("time "+i+":"+msg);
//        }
//    }
//
//    public static String getStatus(int status) {
//
//        String s = Convert.toStr(status);
//
//        return  EnumUtils.getNumberTypeStr(TicketStatusType.class,s);
//    }
//    public static long getTotalPage(long count,int pageSize){
//
//        long totalPage = (count % pageSize == 0) ? (count / pageSize) : (count / pageSize + 1);
//        return totalPage;
//    }
//
//    public static AjaxResult checkData(List list) {
//
//        if(list.size() < 1){
//            return AjaxResult.error("后台数据获取失败，请稍后再试");
//        }
//        return AjaxResult.success(list);
//    }
//
//    public static List<PageResponDto> getChildrenList(List<Message> list ,long pid,String pUserName){
//
//        //从list中过滤出父id为pid的数据
//        List<Message> collect = list.stream().filter(message -> message.getPid() == pid).collect(Collectors.toList());
//
//        List<PageResponDto> resultList = new ArrayList<>();
//
//        //递归查询子数据
//        collect.stream().forEach(message -> {
//
//            PageResponDto dto = new PageResponDto();
//            dto.setResponid(message.getId());
//            dto.setRespon(message.getContent());
//            dto.setResponDate(message.getSendTime());
//            dto.setResponser(message.getUserName());
//            dto.setResponList(getChildrenList(list,message.getId(),message.getUserName()));
//            dto.setToUser(pUserName);
//
//            resultList.add(dto);
//        });
//
//        return resultList;
//
//    }
//
//    public static BigDecimal getSMALastPoint(List<BigDecimal> decimalList,Integer nDay) {
//        if(decimalList==null || decimalList.size()==0) {
//            return BigDecimal.ZERO;
//        }
//        if(decimalList.size()<nDay) {
//            return Tes.getSMALastPoint(decimalList, nDay);
//        }
//        else {
//            BigDecimal startY = getSMALastPoint(decimalList.subList(0, nDay), nDay);
//            BigDecimal divideNumber = new BigDecimal(nDay);
//            for (int i = nDay; i < decimalList.size(); i++) {
//                BigDecimal newY = (decimalList.get(i).add((new BigDecimal(nDay-1)).multiply(startY))).divide(divideNumber);
//                startY = newY;
//            }
//            return startY;
//            //21/12 24/13
//        }
//    }
//
//
//}
