import cn.hutool.cache.Cache; import cn.hutool.cache.CacheUtil; import cn.hutool.core.bean.BeanPath; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.codec.Base64Decoder; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.lang.Console; import cn.hutool.core.lang.WeightRandom; import cn.hutool.core.map.MapUtil; import cn.hutool.core.text.StrFormatter; import cn.hutool.core.util.*; import cn.hutool.core.util.RandomUtil; import cn.hutool.extra.emoji.EmojiUtil; import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpUtil; import cn.hutool.json.JSON; import cn.hutool.json.JSONArray; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import cn.hutool.poi.excel.BigExcelWriter; import cn.hutool.poi.excel.ExcelUtil; import cn.hutool.poi.excel.ExcelWriter; import com.aliyuncs.exceptions.ClientException; import com.github.pagehelper.PageHelper; import com.xzx.gc.GcUserApplication; import com.xzx.gc.common.Result; import com.xzx.gc.common.constant.Constants; import com.xzx.gc.common.constant.OrderEnum; import com.xzx.gc.common.constant.SmsConstant; import com.xzx.gc.common.dto.gdmap.*; import com.xzx.gc.common.exception.RestException; import com.xzx.gc.common.utils.*; import com.xzx.gc.common.utils.ali.SmsUtil; import com.xzx.gc.common.utils.gdmap.GdMapUtil; import com.xzx.gc.common.utils.gdmap.GdTraceUtil; import com.xzx.gc.common.utils.image.QrCodeBaseUtils; import com.xzx.gc.common.utils.image.QrCodeGraphicsUtils; import com.xzx.gc.entity.*; import com.xzx.gc.user.dto.JhyInfoListDto; import com.xzx.gc.user.service.JhyInfoService; import com.xzx.gc.user.vo.JhyInfoListVo; import com.xzx.gc.util.BeanUtils; import lombok.Data; import lombok.extern.slf4j.Slf4j; import net.coobird.thumbnailator.Thumbnails; import org.apache.commons.lang3.RandomStringUtils; import org.junit.Test; import org.junit.runner.RunWith; import org.locationtech.spatial4j.context.SpatialContext; import org.locationtech.spatial4j.distance.DistanceUtils; import org.locationtech.spatial4j.shape.Rectangle; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import sun.misc.Regexp; import tk.mybatis.mapper.entity.Example; import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.StringWriter; import java.io.UnsupportedEncodingException; import java.math.BigDecimal; import java.math.RoundingMode; import java.net.URL; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import java.util.List; import java.util.*; import java.util.regex.Pattern; import java.util.stream.Collectors; @Slf4j @RunWith(SpringRunner.class) @SpringBootTest(classes = {GcUserApplication.class}) @ActiveProfiles("dev") public class CodeTest { @Autowired private JhyInfoService jhyInfoService; @Test public void jhyList(){ JhyInfoListDto jhyInfoListDto = new JhyInfoListDto(); jhyInfoListDto.setPage(1); jhyInfoListDto.setLimit(10); jhyInfoListDto.setIsJhy(1); Map stringObjectMap = jhyInfoService.queryList(jhyInfoListDto); System.out.println(stringObjectMap.get("date")); } @Test public void 测试数组() throws ClientException { Map map=new HashMap(); map.put("code", "123"); SmsUtil.send("18163623487", map, "SMS_178990101", "1"); // List select = new ArrayList<>(); // List collect = select.stream().map(x -> x.getFenceId()).distinct().collect(Collectors.toList()); // System.out.println(collect.size()); String format = DateUtil.format(new Date(), DateUtils.DATE_FORMAT_H); System.out.println(format); String format1 = DateUtil.format(DateUtil.offsetDay(new Date(), 1), DateUtils.DATE_FORMAT_YMD); format1=format1+" 08:00:00"; System.out.println(format1); System.out.println(DateUtil.offsetHour(DateUtil.parse(format1),2)); } @Test public void data(){ List list=new ArrayList<>(); UserInfo userInfo=new UserInfo(); userInfo.setMobilePhone("百分之10"); userInfo.setUserId("6.2"); list.add(userInfo); userInfo=new UserInfo(); userInfo.setMobilePhone("百分之10"); userInfo.setUserId("6.3"); userInfo.setRegsterType(1); list.add(userInfo); UserInfo userInfo1 = list.stream().filter(x -> x.getUserId().equals("6.3")).collect(Collectors.toList()).get(0); int registType = Convert.toInt(userInfo1.getRegsterType()); userInfo1.setRegsterType(registType++); for (UserInfo info : list) { System.out.println(info.getRegsterType()); } } public String a11(){ try { return "3"; }catch (Exception e){ }finally { System.out.println("4"); } return "0"; } @Test public void ex(){ ArrayList> rows = new ArrayList<>(); String str = null; for(int i = 0;i < 100000;i++){ Map row1 = new LinkedHashMap<>(); // str = "M0"+RandomUtil.randomString(8).toUpperCase(); // str = "M1"+RandomUtil.randomString(8).toUpperCase(); // str = "M2"+RandomUtil.randomString(8).toUpperCase(); // str = "M3"+RandomUtil.randomString(8).toUpperCase(); // str = "M4"+RandomUtil.randomString(8).toUpperCase(); // str = "M5"+RandomUtil.randomString(8).toUpperCase(); // str = "M6"+RandomUtil.randomString(8).toUpperCase(); // str = "M7"+RandomUtil.randomString(8).toUpperCase(); // str = "M8"+RandomUtil.randomString(8).toUpperCase(); str = "M9"+RandomUtil.randomString(8).toUpperCase(); row1.put("编码", str); rows.add(row1); } Set> maps = RandomUtil.randomEleSet(rows, 10000); System.out.println(maps); // 通过工具类创建writer ExcelWriter writer = ExcelUtil.getWriter("d:/编码M9.xlsx"); // 合并单元格后的标题行,使用默认标题样式 // writer.merge(maps.size() - 1, "编码"); // 一次性写出内容,使用默认样式,强制输出标题 writer.write(maps, true); // 关闭writer,释放内存 writer.close(); } @Test public void ex2(){ List row1 = CollUtil.newArrayList("aa", "bb", "cc", "dd", DateUtil.date(), 3.22676575765); List row2 = CollUtil.newArrayList("aa1", "bb1", "cc1", "dd1", DateUtil.date(), 250.7676); List row3 = CollUtil.newArrayList("aa2", "bb2", "cc2", "dd2", DateUtil.date(), 0.111); List row4 = CollUtil.newArrayList("aa3", "bb3", "cc3", "dd3", DateUtil.date(), 35); List row5 = CollUtil.newArrayList("aa4", "bb4", "cc4", "dd4", DateUtil.date(), 28.00); List> rows = CollUtil.newArrayList(row1, row2, row3, row4, row5); BigExcelWriter writer= ExcelUtil.getBigWriter("e:/xxx.xlsx"); // 一次性写出内容,使用默认样式 writer.write(rows); // 关闭writer,释放内存 writer.close(); } @Test public void testSort(){ Object sw = sw(0); Integer integer = Convert.toInt(sw); System.out.println(integer); System.out.println(DateUtil.today()); // Map map=MapUtil.newHashMap(); // map.put("time","4月2号11时43分"); // map.put("money","4800"); // map.put("fix","5000"); // String content = StrUtil.format("尊敬的客户,截至{time},您的账户余额为:{money}元,已不足{fix},请及时充值,以免影响您的业务和正常交易", map); // SmsUtil.sendPoint("18163623487", content); List list=new ArrayList<>(); UserInfo userInfo=new UserInfo(); userInfo.setUserType("1"); userInfo.setMobilePhone("1"); userInfo.setRegistTime("2019-09-27 12:44:22"); list.add(userInfo); userInfo=new UserInfo(); userInfo.setUserType("1"); // userInfo.setMobilePhone("2"); userInfo.setRegistTime("2019-10-27 10:44:22"); // list.add(userInfo); userInfo=new UserInfo(); userInfo.setUserType("2"); // userInfo.setMobilePhone("2"); userInfo.setRegistTime("2019-10-27 10:44:22"); list.add(userInfo); List list3=new ArrayList<>(); list3.add("123"); list3.add("1234"); String join = CollUtil.join(list3, ","); System.out.println(join); if(false||true){ System.out.println("aaacc"); } // List list2=new ArrayList<>(); // // list2.add(new BigDecimal("3")); // list2.add(new BigDecimal("32")); // list2.add(new BigDecimal("1")); // // CollUtil.sort(list2,new IndexedComparator<>().reversed()); // // System.out.println(CollUtil.getFirst(list2)); // // Dict dict=Dict.create(); // List list3= (List) dict.get("fz"); // System.out.println(list3); // // // System.out.println("group"); // // List> registTime1 = CollUtils.groupByField(list, "registTime","1"); // System.out.println(registTime1); // // // PartnerConfig partnerConfig=new PartnerConfig(); // partnerConfig.setDelFlag(Convert.toByte(0)); // // System.out.println("错误"+partnerConfig.getDelFlag()); } @Test public void 权重(){ UserInfo userInfo=new UserInfo(); userInfo.setMobilePhone("百分之10"); userInfo.setUserId("6.2"); UserInfo userInfo2=new UserInfo(); userInfo2.setMobilePhone("百分之30"); userInfo2.setUserId("3.222222"); UserInfo userInfo3=new UserInfo(); userInfo3.setMobilePhone("百分之60"); userInfo3.setUserId("1"); ArrayList userInfos = CollUtil.newArrayList(userInfo, userInfo2, userInfo3); WeightRandom.WeightObj weightObj= new WeightRandom.WeightObj(userInfo,0.01); WeightRandom.WeightObj weightObj2= new WeightRandom.WeightObj(userInfo2,0.3); WeightRandom.WeightObj weightObj3= new WeightRandom.WeightObj(userInfo3,0.6); WeightRandom random = RandomUtil.weightRandom(CollUtil.newArrayList(weightObj, weightObj2, weightObj3)); for (int i = 0; i < 10; i++) { UserInfo next = random.next(); // System.out.println(next.getMobilePhone()); } // CollUtil.sort(userInfos,new PropertyComparator<>("userId")); CollUtil.sort(userInfos, (o1, o2) -> { if(Convert.toBigDecimal(o1.getUserId()).compareTo(Convert.toBigDecimal(o2.getUserId()))>0){ return -1; }else if(Convert.toBigDecimal(o1.getUserId()).compareTo(Convert.toBigDecimal(o2.getUserId()))==0){ return 0; }else { return 1; } }); for (UserInfo info : userInfos) { System.out.println(info.getUserId()); } } public Object sw(int a){ switch (a){ case 0: System.out.println("00"); return "22"; case 1 : System.out.println("11"); break; } System.out.println("2233"); return null; } @Test public void changeName(){ // String dir="D:\\mp3\\aa"; // String pre="img_"; // // File file = FileUtil.file(dir); // File[] files = file.listFiles(); // int i=1; // for (File file1 : files) { // FileUtil.rename(file1,pre+i+".jpg",false,true); // i++; // } // String trade_account_log_queue = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, "trade_account_log_queue"); // System.out.println(trade_account_log_queue); // // DateTime dateTime = DateUtil.offsetMonth(new Date(), -3); // System.out.println(dateTime.toJdkDate()); // String phone="2,3"; // String[] strings = StrUtil.splitToArray(phone, Convert.toChar(",")); // // for (String string : strings) { // System.out.println(string); // } List select=CollUtil.newArrayList(); String join = CollUtil.join(select, "、"); System.out.println(join); // PartnerFence partnerFence=new PartnerFence(); // partnerFence.setFenceId("2"); // select.add(partnerFence); // PartnerFence partnerFence2=new PartnerFence(); // partnerFence2.setFenceId("3"); // select.add(partnerFence2); // List collect = select.stream().map(x -> x.getFenceId()).distinct().collect(Collectors.toList()); // for (String s : collect) { // System.out.println(s); // } } public void mysql() throws Exception { Class.forName("com.mysql.cj.jdbc.Driver"); System.out.println("成功加载MySQL驱动!"); String url="jdbc:mysql://localhost:3306/t_xzxdev?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true"; //JDBC的URL Connection conn; conn = DriverManager.getConnection(url, "root","admin!@#00");//url 账号 密码 Statement stmt = conn.createStatement(); //创建Statement对象 System.out.println("成功连接到数据库 !"); String sql = "select * from xzx_user_trace_info where create_time='2020-07-04'"; //要执行的SQL ResultSet rs = stmt.executeQuery(sql);//创建数据对象 while (rs.next()){ String key=rs.getString(3); String service=rs.getString(4); String tid=rs.getString(5); String traceId=rs.getString(6); CommonTraceDto commonTraceDto=new CommonTraceDto(); commonTraceDto.setKey(key); commonTraceDto.setSid(service); commonTraceDto.setTid(tid); commonTraceDto.setTrid(traceId); GdTraceUtil.deleteTrace(commonTraceDto); } rs.close(); stmt.close(); conn.close(); } @Test public void testgd(){ // Result a64d28b2e036f4688b05916ef321b17d = GdTraceUtil.findTerminal("a64d28b2e036f4688b05916ef321b17d", "163516", "270101239", ""); // Console.log(a64d28b2e036f4688b05916ef321b17d); String key="73c5b455875594781c87d24903680274"; // // GdTraceUtil.createTraceProp(key, "163817", "address", "string"); // GdTraceUtil.createTraceProp(key, "163998", "address", "string"); // GdTraceUtil.createTraceProp(key, "164018", "address", "string"); key="921f67e45fe9afe7d2730658e147ca2a"; Result fence = GdMapUtil.findFence(key, null, null); Console.log(fence); } @Test public void testdel() throws Exception { // GdTraceUtil.deleteTrace() mysql(); } @Test public void 是否在围栏(){ // System.out.println("123"); // String key="d985739d075432bcbb3c0e8115c22bf1"; // String sid="160778"; // Result se1 = GdTraceUtil.createService(key, "se3"); // Result se2 = GdTraceUtil.createService(key, "se4"); // GdTraceUtil.createTerminal(key,se1.getData().toString(),"董杰回收员2"); // GdTraceUtil.findTerminal(key,se1.getData().toString(),"董杰回收员2"); // GdTraceUtil.findTerminal(key,se2.getData().toString(),"董杰回收员2"); // String testKey="ab5180b0423f279143d006177f330b7a"; String key="a64d28b2e036f4688b05916ef321b17d"; // Result result = GdMapUtil.findFence(keyReal, null, null); // JSONArray data = result.getData(); // for (Object datum : data) { // Console.log(datum); // JSONObject jsonObject = JSONUtil.parseObj(datum); // String gid = jsonObject.getStr("gid"); // if(!gid.equals("dabaff06-bda3-40c3-bc43-57818a0a2c6f")){ // GdMapUtil.deleteFence(testKey,gid); // } // } //宁乡正式 key="f28decf4aed2d20104c16d3532682810"; String lon="112.550025"; String lat="28.251580"; Result inFence = GdMapUtil.isInFence(lon + "," + lat + "," + DateUtil.currentSeconds(), GdMapUtil.getDiu(key),key); // GdTraceUtil.deleteTerminal(key,sid,"1"); // Result fence = GdMapUtil.findFence(key, null, null); // for (Object o : fence.getData()) { // JSONObject jsonObject= (JSONObject) o; // System.out.println(jsonObject.getStr("points")); // } // GdMapUtil.deleteFence(key,"c34683d4-7385-415f-88e0-04990403dca6"); } @Test public void 测试查询围栏(){ String key="ab5180b0423f279143d006177f330b7a"; String gid="dabaff06-bda3-40c3-bc43-57818a0a2c6f"; Result fence = GdMapUtil.findFence(key, gid, null); for (Object o : fence.getData()) { JSONObject jsonObject= (JSONObject) o; System.out.println(jsonObject.getStr("points")); } } @Test public void 拷贝(){ HomeServiceInfo byId=new HomeServiceInfo(); byId.setShowFlag(Convert.toShort(1)); byId.setId(Convert.toLong(100)); HomeServiceInfo homeServiceAddDTO=new HomeServiceInfo(); homeServiceAddDTO.setShowFlag(Convert.toShort(2)); BeanUtil.copyProperties(byId,homeServiceAddDTO,BeanUtils.getNotNullPropertyNames(homeServiceAddDTO)); System.out.println(homeServiceAddDTO.getId()); System.out.println(homeServiceAddDTO.getShowFlag()); } @Test public void 创建服务(){ //开福区测试key String key="d985739d075432bcbb3c0e8115c22bf1"; Result service1 = GdTraceUtil.createService(key, key+"_"+OrderEnum.推广员全天轨迹.getValue()); //2 Result service2 = GdTraceUtil.createService(key, key+"_"+OrderEnum.回收员订单轨迹.getValue()); //1 Result service3 = GdTraceUtil.createService(key, key+"_"+OrderEnum.回收员全天轨迹.getValue()); //3 } @Test public void 创建终端(){ //开福区测试key String key="d985739d075432bcbb3c0e8115c22bf1"; String sid="164776"; GdTraceUtil.createTerminal(key,sid,"USER1260718805714862080"); } @Test public void testService(){ // FindTraceDto findTraceDto = new FindTraceDto(); // findTraceDto.setKey("a64d28b2e036f4688b05916ef321b17d"); // findTraceDto.setSid("163477"); // findTraceDto.setTid("270247841"); // findTraceDto.setTrid("300"); // Result> trace = GdTraceUtil.findTrace(findTraceDto); // List data = trace.getData(); // Console.log(data); /** f28decf4aed2d20104c16d3532682810 13:35:19.871 [main] DEBUG com.xzx.gc.common.utils.gdmap.GdTraceUtil - 查询服务成功,id:164598,名字:回收员订单轨迹 13:35:19.876 [main] DEBUG com.xzx.gc.common.utils.gdmap.GdTraceUtil - 查询服务成功,id:164618,名字:推广员全天轨迹 13:35:19.876 [main] DEBUG com.xzx.gc.common.utils.gdmap.GdTraceUtil - 查询服务成功,id:164638,名字:回收员全天轨迹 */ // Result result = GdTraceUtil.findService("ec8dbc1f5b3c681df48f40f8f6045b49"); // String key="ab5180b0423f279143d006177f330b7a"; // GdTraceUtil.createService(key,key+"_"+OrderEnum.推广员全天轨迹.name()); // GdTraceUtil.createService(key,key+"_"+OrderEnum.回收员订单轨迹.name()); // GdTraceUtil.createService(key,key+"_"+OrderEnum.回收员全天轨迹.name()); // FindTraceDto findTraceDto = new FindTraceDto(); // findTraceDto.setKey("a64d28b2e036f4688b05916ef321b17d"); // findTraceDto.setSid("164837"); // findTraceDto.setTid("270310092"); // findTraceDto.setTrid("60"); // GdTraceUtil.findTrace(findTraceDto); } @Test public void test(){ } @Test public void testAuth(){ // String version="v1.41"; // if(StrUtil.isNotBlank(version)&&version.startsWith("v")) { // double versionDouble = 0; // try { // versionDouble = Convert.toDouble(version.substring(1)); // } catch (Exception e) { // } // if (NumberUtil.compare(versionDouble, Convert.toDouble("1.2")) > 0) { // System.out.println(111); // } // } // GdReverseGEODto gdReverseGEODto = new GdReverseGEODto(); // gdReverseGEODto.setLocation("112.941143666111111111" + "," + "28.128611073482222221"); // Result areaInfo = GdMapUtil.getAreaInfo(gdReverseGEODto, 3); // if (areaInfo.getCode() == 0) { // String townName = (String) areaInfo.getData(); // System.out.println(townName); // } // Long a=3L; // System.out.println(a==3); // System.out.println(a.equals(3)); // // // String s="aa【反倒是反倒是】;\nb【aa】;\nbc【cc】;\n"; // // String s1 = s.replaceAll("【.+?】", ""); // System.out.println(s1); // DateTime parse3 = DateUtil.parse("2020-01-20 09:22:57", DateUtils.DATE_FORMAT_YMD); // DateTime nowData = DateUtil.parse(DateUtil.now(), DateUtils.DATE_FORMAT_YMD); // // //当天下单用户量 // if (DateUtil.isSameDay(parse3, nowData)) { //// System.out.println(22); // } // // String s = DateUtil.parse("2020-01-20 09:22:57", DateUtils.DATE_FORMAT_YMD).toString(DateUtils.DATE_FORMAT_YMD); // // // //// System.out.println(s); // // DateTime parse = DateUtil.parse("2020-01-20 09:22:57", DateUtils.DATE_FORMAT_YMDHMS); // DateTime dateTime = DateUtil.offsetHour(parse, 12); // System.out.println(dateTime.toString()); // UserInfo userInfo=new UserInfo(); // userInfo.setMobilePhone("123"); // // String a=userInfo.getMobilePhone(); // a=a+"44"; // System.out.println(userInfo.getMobilePhone()); // double distance= Double.MAX_VALUE; // System.out.println(distance); } @Test public void testSms() throws ClientException { // Map map=new HashMap(); // map.put("date","2019-10-12 18:00:00"); //// map.put( "valid_code", "12345"); // String templateCode=Constants.ORDER_SMS_CANCLE_ZT_TEMPLATE; //// String templateCode=Constants.ORDER_SMS_ZT_TEMPLATE; // String phoneNum="18163623487"; //// SmsUtil.send(phoneNum, map, templateCode, CommonEnum.助通短信.getValue()); // // // // String s1 = NumberUtil.roundStr("4.222222", 0, RoundingMode.DOWN); //// System.out.println(s1); // // String parse = DateUtil.parse("2019-10-18 8:00:00", DateUtils.DATE_FORMAT_YMD).toDateStr(); // System.out.println(parse); // Long a=3L; // Long a2=new Long("3"); // // System.out.println(a.equals(a2)); // System.out.println(a==a2); // Map map = new HashMap(); // map.put("date", DateUtil.now()); // String templateCode = Constants.ORDER_SMS_CANCLE_ZT_TEMPLATE; // String phoneNum ="18163623487"; // SmsUtil.send(phoneNum, map, templateCode, CommonEnum.助通短信.getValue()); Map map=new HashMap<>(); map.put("a","123"); String a= (String) map.get("a"); System.out.println(a); map.clear(); map.put("b","456"); a= (String) map.get("b"); String a1= (String) map.get("a"); System.out.println(a); System.out.println("=="+map.size()); } @Test public void chin(){ //ReUtil.RE_CHINESE // String s=" / by zero"; // String s1="失败"; // String s2="失败:订单:"+123; // boolean match = isChinese(s); // System.out.println(match); // match = isChinese(s1); // System.out.println(match); // match = isChinese(s2); // System.out.println(match); UserInfo user=new UserInfo(); user.setMobilePhone("456"); String mobilePhone = user.getMobilePhone(); user.setMobilePhone("123"); System.out.println(mobilePhone); String json="{ \"startRow\": 1, \"navigatepageNums\": [ 1 ], \"prePage\": 0, \"hasNextPage\": false, \"nextPage\": 0, \"pageSize\": 10, \"endRow\": 1, \"list\": [ { \"orderType\": \"1\", \"createUserId\": \"35\", \"queueNum\": 1, \"address\": \"皇爵花园酒店(省政府店)\", \"receiver\": \"22\", \"distance\": \"14.382\", \"star\": \"4.5\", \"orderId\": \"DD1215092224803602432\", \"orderItemList\": [ ], \"receiverName\": \"要你好看\", \"latitude\": \"28.116697\", \"orderStatus\": \"2\", \"relaPhone\": \"15616122416\", \"type\": 0, \"appraiseFlag\": false, \"relaName\": \"说过的\", \"receiverPhone\": \"15616122416\", \"createTime\": \"2020-01-09 10:05:36\", \"reserveTime\": \"01-09 15:10:00\", \"reserveTimeForYear\": \"2020-01-09 15:10:00\", \"completeOrderNum\": 0, \"addressArea\": \"湖南省长沙市天心区正塘坡路188省政府东门、天心区政府北门\", \"longitude\": \"112.989917\" } ], \"pageNum\": 1, \"navigatePages\": 8, \"navigateFirstPage\": 1, \"total\": 1, \"pages\": 1, \"size\": 1, \"isLastPage\": true, \"hasPreviousPage\": false, \"navigateLastPage\": 1, \"isFirstPage\": true }"; String s = JSONUtil.toJsonPrettyStr(json); JSON parse = JSONUtil.parse(json); // String s1 = JSONUtil.toJsonStr(parse, 10); String s1=""; final StringWriter sw = new StringWriter(); synchronized (sw.getBuffer()) { s1 = parse.write(sw, 4, 10).toString(); } System.out.println(s1); } @Test public void init(){ // SystemUtil.dumpSystemInfo(); // String s="DD1205284627149881344,DD1205293808070295552,DD1205306356664500224,DD1205309314437349376,DD1205309997513310208,DD1205334232738693120,DD1205343573566947328,DD1205355320264753152,DD1205358748927918080,DD1205363389166125056,DD1205377222937018368,DD1205403644896346112,DD1205408141030850560,DD1205413478102335488,DD1205439123851182080,DD1205826909783588864,DD1206006978862776320,DD1206015561448947712,DD1206106253340835840,DD1206114363128283136,DD1206130462351818752,DD1206130632695087104,DD1206205858132918272,DD1206366520192663552,DD1206394308408770560,DD1206399246501281792,DD1206401582418231296,DD1206408873813082112,DD1206411105472217088,DD1206436449965178880,DD1206456871020527616,DD1206478581585281024,DD1206492784303931392,DD1206501305384828928,DD1206503893706604544,DD1206514464707444736,DD1206727638916399104,DD1206733844959592448,DD1206740309631959040,DD1206768272201089024,DD1206802031961047040,DD1206806635373264896,DD1206817943925686272,DD1206824291254009856,DD1206826430575542272,DD1206832332280037376,DD1206838742954934272,DD1206847019201724416,DD1206851561762979840,DD1206871285628534784,DD1206877357193953280,DD1206901865900539904,DD1207099026097438720,DD1207101762754969600,DD1207101865762881536,DD1207121802808131584,DD1207133869803962368,DD1207138722303311872,DD1207146429227859968,DD1207171357767499776,DD1207173865759965184,DD1207198889858433024,DD1207199761464164352,DD1207199950157512704,DD1207206604815073280,DD1207207277640155136"; // System.out.println(s.split(",").length); // String s="3.2222222222222"; // String s2="3.22234"; // String s3="3"; // String s4="3.333236"; // // System.out.println(NumberUtil.toBigDecimal(NumberUtil.roundStr(s, 6, RoundingMode.DOWN))); // System.out.println(Convert.toDouble(NumberUtil.roundStr(s2, 6, RoundingMode.DOWN))); // System.out.println(Convert.toDouble(NumberUtil.roundStr(s3, 6, RoundingMode.DOWN))); // System.out.println(NumberUtil.roundStr(s4, 6, RoundingMode.DOWN)); // List list=new ArrayList<>(); BigDecimal bigDecimal=new BigDecimal("455"); BigDecimal round = NumberUtil.round(bigDecimal, 2, RoundingMode.DOWN); System.out.println(round); // list.add("1"); // // for (Iterator iterator = list.iterator(); iterator.hasNext(); ) { // String next = iterator.next(); // iterator.remove(); // } // // for (String s : list) { // System.out.println(s); // } } // 根据Unicode编码完美的判断中文汉字和符号 private static boolean isChinese(char c) { Character.UnicodeBlock ub = Character.UnicodeBlock.of(c); if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION) { return true; } return false; } // 完整的判断中文汉字和符号 public static boolean isChinese(String strName) { char[] ch = strName.toCharArray(); for (int i = 0; i < ch.length; i++) { char c = ch[i]; if (isChinese(c)) { return true; } } return false; } @Test public void 生成海报() throws Exception { // String spuName = "大哥哥"; //// String linkUrl = "https://w.url.cn/s/AiNukkx"; // boolean logoStatus = false; // String logoPath = "https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTLG86dQHEcYs1rmEMcYBwXHUnzmwo8ujQwRhmm7bMnsRsCqmHCpNicy71HR5ZNNibeAG0ykEiacr3pUw/132"; // String backgroundUrl = "d:/poster_login_bg.png"; //// String spuPicUrl = folderPath + "/item.jpg"; // String spuLeaguerPrice = "大哥哥"; // String spuPrice = "邀请你加入小棕熊环保一起赚钱"; // byte[] linkUrl= CodeTest.generateAcode2("123","pages/index/index",""); //// GraphicsUtils.createPosterByRedTemplate(linkUrl, logoStatus, logoPath, backgroundUrl, "", //// spuLeaguerPrice, spuPrice, spuName); // // System.out.println("2".equals(null)); // BigDecimal rewardMoneyBigDecimal=new BigDecimal("0.234500000"); // BigDecimal mul=new BigDecimal("1"); // BigDecimal add = NumberUtil.mul(rewardMoneyBigDecimal, mul); // System.out.println(Convert.toStr(add)); // BigDecimal bigDecimal = Convert.toBigDecimal("0"); // String s = NumberUtil.roundStr(Convert.toStr(bigDecimal), 2, RoundingMode.DOWN); // System.out.println(s); // Map map=new HashMap(); // map.put("other_number",Convert.toStr("2.332","0")); // map.put("amount","1.9"); // map.put("others",Convert.toStr("321.11","0")); //// SmsUtil.send("18163623487", map, "4338", "2"); // // String content=StrUtil.format("【小棕熊到家】回收员帮你下的订单已完成,回收重量{other_number}kg,金额{amount}元,返利{others}元",map); // SmsUtil.sendPoint("18163623487",content); String[] s22=new String[]{"18684731218","18273181385","18008483553","18390886257","18670339967","15211094627","15274808342","13975860004","13755060468","18216239027"}; String[] s33=new String[10]; s33[0]="https://wx.qlogo.cn/mmopen/vi_32/U5jyRWgg4zsFA44k5ySflpC7NMNicibS6YDUMFnaDnokJaBW69J7OQbklYibNQ0qbgo270asYJibfv58t3JeMAGvXg/132"; s33[1]="https://wx.qlogo.cn/mmopen/vi_32/XIRRvR0SYoy1ia6GxFX1bGiak6MJFibIq1uzYxsSjoghTewib4TMG1wib3MCOM7KTVMibrrJUE36a708DsRFIt8WyV7Q/132"; s33[2]="https://wx.qlogo.cn/mmopen/vi_32/M28iciaQHnYx9ibOxwQG2j8ZQKq8fMykM6cUYGxsI9PUiar5yh4pV35FgPEShlRQE2n1xicKcibNGia3YmJKWqI3Dkreg/132"; s33[3]="https://wx.qlogo.cn/mmopen/vi_32/0iaiauALtEFdWl06BQwc7Tl4FPscDbFID4icUasCZWkrxgg2gMziaKIDhy259A3MxnceLNZBIYXgKA6gbfNHPnYaNg/132"; s33[4]="https://wx.qlogo.cn/mmopen/vi_32/nQKC0vQbYH5CC491ftO1jLV3euu3zwJaG95wu3X22cqDFKykqhCbJAobr0nwQSiaIq3aG9O5MRiajSHNdo6Y1GZg/132"; s33[5]="https://wx.qlogo.cn/mmopen/vi_32/wTfCic9AZ7tuQxNr2TVJHx8dLGXCW1rKYBtkaQYoclp0JjhRZomvzGlVHOd2GlObQoX6UbxqLzQNrg7GYEkdoqQ/132"; s33[6]="https://wx.qlogo.cn/mmopen/vi_32/icTj2kgLGptIPaJMtSlykOpic7wglAfxAHVhXIlk1HDohwUZVvSQBnnPgGUIkZDgjDpZ31rTicXgWhBzX548LArCQ/132"; s33[7]="https://wx.qlogo.cn/mmopen/vi_32/WLofJh4MdlLMcGUCDBOibtHj0MsKN7NvMdw3IWck3uewXbfZOF7x1Ym5pQHvIibmr2IhZkicRSBka36bOh7Gv6IMA/132"; s33[8]="https://wx.qlogo.cn/mmopen/vi_32/WaoJzYaQHictDAUE1jU5kvwuBJHmMnaibmCFvfYrNnbWUm0xWVoJl2b6w44lNOaG86ASvibUzFvU12jWPIh08BSmw/132"; s33[9]="https://wx.qlogo.cn/mmopen/vi_32/D3NLzo5CozKPic4nn92EO9HibWhxAv9nSCh1XEiaFwFvOzWbFCyDiaQro391GR0ItaoATLoCXnGicqiaWamDLvI8GrZg/132"; // String[] s22=new String[]{"13755023860"}; // String[] s33=new String[1]; // s33[0]="https://wx.qlogo.cn/mmopen/vi_32/EDlCibFBaaa9h7A697WaZicQh0V4oUqBs3RakW1MOAILQ2gWld90GS5nHky0jACQsIvqgSLx6xPlp1N6oV6aqPww/132"; for (int i = 0; i < s22.length; i++) { String s1=s22[i]; String aa=s33[i]; if("1".equals(aa)){ aa="http://localhost/static/微信图片_20191221221856.jpg"; System.out.println(s1); } //海报图名称 String imageName="/"+s1 +"_poster.jpg"; //二维码图名称 String imgName="/user_" + s1 + "_acode.jpg"; generateAcode("poster=" + s1, "pages/login/login", imgName, "800px"); String path=Constants.IMG_UPLOAD_PATH+imgName; // String backgroundUrl=Constants.IMG_TEMPALRE_PATH+"/微信图片_20191221220256.jpg"; String backgroundUrl=Constants.IMG_TEMPALRE_PATH+"/user_share_poster_bg.png"; try { s1 = StrUtil.replace(s1, 3, 7, Convert.toChar("*")); generatePoster(imageName, path, aa, backgroundUrl, s1); } catch (Exception e) { ExceptionUtils.err("生成分享海报失败",e); } } } @Test public void changeMoney(){ // System.out.println( intChange2Str(111)); // System.out.println( intChange2Str(1)); // System.out.println( intChange2Str(10000)); // System.out.println( intChange2Str(100000)); // // String do6aVAda831U871r = SecurityUtil.decrypt("Do6aVAda831U871r", "tsUdeys3Z0itHh9IoPBoEg=="); // System.out.println(do6aVAda831U871r); BigDecimal bigDecimal=new BigDecimal("5.21"); BigDecimal bigDecimal2=new BigDecimal("-0.01"); BigDecimal sub = NumberUtil.add(bigDecimal, bigDecimal2); // BigDecimal sub2 = NumberUtil.sub(bigDecimal, bigDecimal2); // System.out.println(sub.toString()); // System.out.println(sub2.toString()); // BigDecimal shareRatio=new BigDecimal("0.004"); // shareRatio=NumberUtil.round(shareRatio,2, RoundingMode.HALF_UP); // System.out.println(shareRatio); if(2==2){ System.out.println("456"); // return; } System.out.println("789"); int type=0; switch (type){ case 0: if(1==1){ break; } System.out.println("123"); break; } } private String intChange2Str(int number) { String str = ""; if (number <= 0) { str = ""; } else if (number < 10000) { str = number + "阅读"; } else { double d = (double) number; double num = d / 10000;//1.将数字转换成以万为单位的数字 BigDecimal b = new BigDecimal(num); double f1 = b.setScale(1,BigDecimal.ROUND_HALF_UP).doubleValue();//2.转换后的数字四舍五入保留小数点后一位; str = f1 + "万阅读"; } return str; } @Test public void test121(){ // String s="1,2,3"; // String s1="2,4,5"; // String s2="7,4,5"; // // // Collection intersection = CollUtil.intersection(Arrays.asList(s.split(",")), Arrays.asList(s1.split(","))); // // System.out.println(intersection.toArray().length); // for (String s3 : intersection) { // System.out.println(s3); // } // Collection intersection2 = CollUtil.intersection(Arrays.asList(s.split(",")), Arrays.asList(s2.split(","))); // System.out.println(intersection2.toArray().length); // // Result inFence = GdMapUtil.isInFence("112.980288" + "," + "28.239595" + "," + DateUtil.currentSeconds(), GdMapUtil.getDiu("123"),Constants.GD_MAP_KEY); // System.out.println(inFence.getData().toString()); // List byIds =new ArrayList<>(); // OrderInfo orderInfo=new OrderInfo(); // orderInfo.setCreateUserId("1"); // orderInfo.setOrderId("1"); // byIds.add(orderInfo); // // orderInfo=new OrderInfo(); // orderInfo.setCreateUserId("2"); // orderInfo.setOrderId("2"); // byIds.add(orderInfo); // // // orderInfo=new OrderInfo(); // orderInfo.setCreateUserId("1"); // orderInfo.setOrderId("3"); // byIds.add(orderInfo); // // orderInfo=new OrderInfo(); // orderInfo.setCreateUserId("1"); // orderInfo.setOrderId("4"); // byIds.add(orderInfo); // // //先筛选是被推广的用户 // ArrayList collect = byIds.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(OrderInfo::getCreateUserId))), ArrayList::new)); // // for (OrderInfo info : collect) { // System.out.println(info.getCreateUserId()+"==="+info.getOrderId()); // } GdGEODto gdGEODto=new GdGEODto(); // if(StrUtil.isNotBlank(addressReq.getCityName())) { // gdGEODto.setCity(addressReq.getCityName()); // } gdGEODto.setAddress("湖南省长沙市雨花区奥林匹克花园11栋104门面"); Result locationByAddress = GdMapUtil.getLocationByAddress(gdGEODto); if(locationByAddress.getCode()==0&&locationByAddress.getData()!=null){ System.out.println(locationByAddress.getData().toString().split(",")[0]); System.out.println(locationByAddress.getData().toString().split(",")[1]); } GdReverseGEODto gdReverseGEODto = new GdReverseGEODto(); gdReverseGEODto.setLocation(locationByAddress.getData().toString().split(",")[0]+","+locationByAddress.getData().toString().split(",")[1]); Result areaInfo = GdMapUtil.getAreaInfo(gdReverseGEODto, 0); if(areaInfo.getCode()==0) { AddressInfo addressInfo1 = (AddressInfo) areaInfo.getData(); String adcode = addressInfo1.getAdcode(); System.out.println(adcode); } } @Test public void testTime(){ // String s="2019-12-23 13:56:18"; // String date=DateUtil.now(); // long between = DateUtil.between(DateUtil.parse(s,DateUtils.DATE_FORMAT_YMDHMS), DateUtil.parse(date,DateUtils.DATE_FORMAT_YMDHMS), DateUnit.SECOND); // System.out.println(between); // // // String emoji = EmojiUtil.toUnicode(":smile:");//😄 // System.out.println(emoji); // System.out.println("1"+EmojiUtil.removeAllEmojis(emoji)); // // System.out.println(DateUtil.date().toDateStr()); // // DateTime parse = DateUtil.parse(s, DateUtils.DATE_FORMAT_YMD); // System.out.println(parse); // Set strings=new HashSet<>(); // strings.add("a"); // strings.add("a"); //// System.out.println(strings.size()); // // System.out.println(Convert.toInt("1.4")); // System.out.println(Convert.toInt("2.8")); // // StrBuilder strBuilder=StrBuilder.create(); // strBuilder.append("33,22,11,"); // String s = strBuilder.subString(0, strBuilder.length() - 1); // System.out.println(s); // DateTime parse = DateUtil.parse("2019-12-30 13:40:54", DateUtils.DATE_FORMAT_YMD); // DateTime parse2= DateUtil.parse(DateUtil.now(),DateUtils.DATE_FORMAT_YMD); // if(!DateUtil.isSameDay(parse,parse2)){ // System.out.println(111); // } // // String s = JSONUtil.toJsonPrettyStr("222"); // System.out.println(s); String s="b28="; String s1 = Base64Decoder.decodeStr(s); System.out.println(s1); } /** * @param imgName 图片名称 * @param codePath 二维码路径 * @param avata 头像全路径 * @param backgroundUrl 背景图地址 * @param spuName 文字 * @throws Exception */ public String generatePoster(String imgName,String codePath, String avata, String backgroundUrl, String spuName) throws Exception { String urlPrefix=""; String imgPath=Constants.IMG_UPLOAD_PATH+imgName; //背景图 BufferedImage bufferImage = QrCodeBaseUtils.imageToBufferedImage(backgroundUrl); Graphics2D graphics = bufferImage.createGraphics(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //小程序码 BufferedImage qrCodeImage = ImageIO.read(new File(codePath)); graphics.drawImage(qrCodeImage, 100, 340, null); //头像 BufferedImage logoBufferImage = Thumbnails.of(new URL(avata)).size(150, 150).asBufferedImage(); graphics.drawImage(logoBufferImage, 57, 94, null); //文字 Font font = new Font("黑体", Font.BOLD, 40); graphics.setFont(font); graphics.setPaint(Color.black); graphics.drawString(spuName, 230, 160); QrCodeGraphicsUtils.savePic(bufferImage, 1, "jpg", 0.8, imgPath); graphics.dispose(); return urlPrefix+"/"+imgName; } public String generateAcode(String scene,String path,String imgName,String width){ String urlPrefix=""; String imgPath=Constants.IMG_UPLOAD_PATH+imgName; if(!FileUtil.exist(imgPath)){ //调用二维码接口 String url = StrFormatter.format("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={}", getAccessToken()); cn.hutool.json.JSONObject obj = JSONUtil.createObj(); //最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~, // 其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式) obj.put("scene", scene); //必须是已经发布的小程序存在的页面(否则报错),例如 pages/index/index, // 根路径前不要填加 /,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面 obj.put("path", path); //最小 280px,最大 1280px obj.put("width", width); obj.put("auto_color", false); cn.hutool.json.JSONObject obj2 = JSONUtil.createObj(); obj2.put("r", 0); obj2.put("g", 0); obj2.put("b", 0); obj.put("line_color", obj2); //是否需要透明底色,为 true 时,生成透明底色的小程序码 obj.put("is_hyaline", false); byte[] data = HttpRequest.post(url).body(obj.toString(), "application/json").execute().bodyBytes(); FileUtil.writeBytes(data, imgPath); } return urlPrefix+"/"+imgName; } /** * 获取微信token * @return */ public static String getAccessToken(){ //获取微信accessToken String url=StrFormatter.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}",Constants.WX_APPID,Constants.WX_SECRET); String s = HttpUtil.get(url); cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(s); String access_token = jsonObject.getStr("access_token"); String expires_in = jsonObject.getStr("expires_in"); return access_token; } @Test public void abc(){ //获取微信accessToken // String url=StrFormatter.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}",Constants.WX_APPID,Constants.WX_SECRET); // String s = HttpUtil.get(url); // cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(s); // String access_token = jsonObject.getStr("access_token"); // String expires_in = jsonObject.getStr("expires_in"); String url=StrFormatter.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}",Constants.WX_APPID,Constants.WX_SECRET); // String s = HttpUtil.get(url); // cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(s); // String access_token = jsonObject.getStr("access_token"); // String expires_in = jsonObject.getStr("expires_in"); // System.out.println(expires_in); ArrayList strings = CollUtil.newArrayList("1", "2"); for (Iterator iterator = strings.iterator(); iterator.hasNext(); ) { String next = iterator.next(); if(next.equals("2")){ iterator.remove(); continue; } System.out.println("哈哈"); } System.out.println(strings.size()); } public static byte[] generateAcode2(String scene,String path,String imgName){ String imgPath=Constants.IMG_UPLOAD_PATH+imgName; //调用二维码接口 String url = StrFormatter.format("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={}", getAccessToken()); cn.hutool.json.JSONObject obj = JSONUtil.createObj(); //最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~, // 其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式) obj.put("scene", scene); //必须是已经发布的小程序存在的页面(否则报错),例如 pages/index/index, // 根路径前不要填加 /,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面 obj.put("path", path); //最小 280px,最大 1280px obj.put("width", "800px"); obj.put("auto_color", false); cn.hutool.json.JSONObject obj2 = JSONUtil.createObj(); obj2.put("r", 0); obj2.put("g", 0); obj2.put("b", 0); obj.put("line_color", obj2); //是否需要透明底色,为 true 时,生成透明底色的小程序码 obj.put("is_hyaline", false); byte[] data = HttpRequest.post(url).body(obj.toString(), "application/json").execute().bodyBytes(); return data; } @Test public void 查看附件1公里(){ //筛选附近1公里的 double lon = Convert.toDouble("112.994338"); double lat=Convert.toDouble("28.151839"); //单位千米 int radius = 1; SpatialContext geo = SpatialContext.GEO; Rectangle rectangle = geo.getDistCalc().calcBoxByDistFromPt(geo.makePoint(lon, lat), radius * DistanceUtils.KM_TO_DEG, geo, null); double latitude = Convert.toDouble("28.151792534722222",Convert.toDouble(0)); double longitude = Convert.toDouble("112.99511881510416",Convert.toDouble(0)); System.out.println(rectangle.getMinX() + "-" + rectangle.getMaxX());// 经度范围 System.out.println(rectangle.getMinY() + "-" + rectangle.getMaxY());// 纬度范围 if(NumberUtil.compare(latitude,rectangle.getMinY())<0){ System.out.println("超出"); }else if(NumberUtil.compare(latitude,rectangle.getMaxY())>0){ System.out.println("超出"); }else if(NumberUtil.compare(longitude,rectangle.getMinX())<0){ System.out.println("超出"); }else if(NumberUtil.compare(longitude,rectangle.getMaxX())>0){ System.out.println("超出"); }else{ System.out.println("成功"); } } @Test public void test111(){ Double a= Convert.toDouble(StrUtil.removePrefix("v1.4", "v")); // String c="Abc"; // String a1 = MD5Util.getMD5String(c); // System.out.println(a1); // String s = SecureUtil.md5(c).toUpperCase(); // System.out.println(s); String s = EmojiUtil.toUnicode(":laughing:"); System.out.println(s); } @Test public void join(){ List list=new ArrayList(); UserInfo userInfo=new UserInfo(); userInfo.setUserId("1"); UserInfo userInfo2=new UserInfo(); // userInfo2.setUserId(""); UserInfo userInfo3=new UserInfo(); userInfo3.setUserId("3"); // list.add(userInfo); list.add(userInfo2); // list.add(userInfo3); String roleIds = list.stream().map(x->x.getUserId()). collect(Collectors.joining(",")); String[] split = roleIds.split(","); for (String s : split) { System.out.println(s); System.out.println(s.equals("null")); } String obj="2019-10-22 11:0:33"; DateTime parse = DateUtil.parse(obj.toString(), DateUtils.DATE_FORMAT_YMDHMS); System.out.println(parse); GdReverseGEODto gdReverseGEODto = new GdReverseGEODto(); gdReverseGEODto.setLocation("112.99961" + "," + "28.096663"); Result areaInfo = GdMapUtil.getAreaInfo(gdReverseGEODto, 3); System.out.println(areaInfo); } @Test public void test1() throws UnsupportedEncodingException, InterruptedException { // String payOrderId=IdUtils.generate("ZF",0); // System.out.println(payOrderId); // //回收员 // Thread.sleep(2000); // String otherPayOrderId=IdUtils.generate("ZF",0); // while (otherPayOrderId.equals(payOrderId)){ // otherPayOrderId=IdUtils.generate("ZF",0); // } // System.out.println(otherPayOrderId); // DateUtil.parse(":00","yyyy-MM-dd HH:mm"); // System.out.println(1); // String encode = Base64.encode("测试2"); // System.out.println(encode); // boolean base64 = isBase64(encode); // System.out.println(base64); // // List list=new ArrayList<>(); // UserTargetInfo userTargetInfo=new UserTargetInfo(); // userTargetInfo.setCreateTime("2019-10-11 15:52:31"); // // UserTargetInfo userTargetInfo2=new UserTargetInfo(); // userTargetInfo2.setCreateTime("2019-10-11 15:52:30"); // // list.add(userTargetInfo); // list.add(userTargetInfo2); // // List collect = list.stream().sorted(Comparator.comparing(UserTargetInfo::getCreateTime).reversed()).collect(Collectors.toList()); // // // for (UserTargetInfo info : collect) { // System.out.println(info.getCreateTime()); // } // // RedisDS redisDS = Singleton.get(RedisDS.class,new Setting("redis.properties", true), "xzx"); // Jedis jedis =redisDS.getJedis(); // System.out.println(jedis.get("a")); String s="\"[{\\\"content\\\":\\\"我们经常都会说职位没有高低贵贱之分,但是当我们看到那些不体面的工作时,还是会从内心里发出抵触。不过不管是什么职业和工作,都有它存在的理由,并且你还不能小瞧了它,人家不仅为环保做出了一份贡献,或许人家的收入可能比你还多呢。虽然干着大家不认为体面的工作—破烂的回收者,但是保护的却是城市的生活环境,我们有个光荣的称号一小棕熊环保回收员,请大家支持我们,为环保贡献自己一份力量。\\\\r\\\\n跟大家说说可回收物品,以废纸为例,回收的废纸需要通过碎解、净化、浮选以及漂白等几步工作才能完成再生处理。1.25吨废纸可节省,4立方的木材,100立方的水,减少60磅的工业废气排放等。看似简单的这几步工序,却能为我们节省不少的社会资源,回收可再次利用的废品有利于节约资源和保护环境。\\\\r\\\\n近几年,习大大非常重视环保工作,习大大在全国生态环境保护大会上提出,「要加快建立健全以生态价值观念为准则的生态文化体系」,树立尊重自然、顺应自然、保护自然的生态价值观,把生态文明建设放在突出地位,才能从根本上减少人为对自然环境的破坏。\\\\r\\\\n环保回收行业需要变革,小棕熊回收用自主研发的创新模式去改善回收行业的现状,小棕熊回收有规范化的运营、专业的回收团队、自建的物流体系,刷新人们印象中环保回收的样子。小棕熊回收团队运用互联网+的概念,将环保回收与互联网结合成一个创新的回收模式,用户只需在小棕熊到家微信小程序上下单 ,环保回收就交给小棕熊处理。\\\\r\\\\n小粽熊让城市更美,天空更蓝\\\\r\\\\n\\\",\\\"createTime\\\":\\\"2019-09-06 14:20:06\\\",\\\"createUserId\\\":\\\"0\\\",\\\"noticeId\\\":6,\\\"noticeType\\\":\\\"1\\\",\\\"picture\\\":\\\"https://res.cnxzx.com/resource/static/img/images-1.png\\\",\\\"title\\\":\\\"我们收的不是破烂儿!请叫我们环保达人\\\"},{\\\"content\\\":\\\"工作正在上海如火如荼开展,引发广泛关注。“史上最严垃圾分类”也会轮到长沙吗?事实上,早在2017年长沙就被列为全国46个垃圾分类重点城市之一。按照要求,2020年,46个重点城市要基本建成垃圾分类处理系统。长沙市城管执法局7月1日透露,长沙垃圾分类工作已步入“快车道”,今年将实现全市633个社区生活垃圾分类全覆盖,同时加快完善分类投放、分类收集、分类运输、分类处置的垃圾分类体系。\\\\r\\\\n长沙市城管执法局环卫处处长钟庭表示,长沙的垃圾分类意识培养与分类体系建设同步。2017年3月,长沙被列为生活垃圾强制分类重点城市之一。与第一批试点城市相比,虽然长沙起步较晚,但在顶层设计、激励配套等方面具有一定优势。“培养居民分类意识和完善分类体系,目前在长沙正同步进行,‘先分后混’会影响分类效果和居民积极性,而后端建设好了前端没有分类,整个分类链条就会脱节。因此,这是一项相互依赖的系统工程。”\\\\r\\\\n据了解,长沙垃圾终端处理已从“卫生填埋”向“清洁焚烧”转变,构建多点支撑的垃圾终端处理体系,预计2021年长沙城区将实现生活垃圾“零填埋”。\\\\r\\\\n\\\",\\\"createTime\\\":\\\"2019-09-06 14:19:13\\\",\\\"createUserId\\\":\\\"0\\\",\\\"noticeId\\\":5,\\\"noticeType\\\":\\\"1\\\",\\\"picture\\\":\\\"https://res.cnxzx.com/resource/static/img/images-2.png\\\",\\\"title\\\":\\\"长沙:垃圾分类工作步入快车道\\\"},{\\\"content\\\":\\\"什么是垃圾分类?\\\\r\\\\n生活垃圾分类是指按照生活垃圾的成分、属性、利用价值对环境影响以及现有处理方式的要求,分离成不同类别的若干类。欧美发达国家与国内城市的生活垃圾分类经验告诉我们:生活垃圾分类是生活垃圾的减量化,资源化、无害化的基础。\\\\r\\\\n生活中我们每天都会产生各种各样的垃圾,如何去分类呢?让小编为您来科普~垃圾分类品种。\\\\r\\\\n生活垃圾的基本分类:可回收物、有害垃圾、湿垃圾和干垃圾。\\\\r\\\\n1有害垃圾:\\\\r\\\\n主要包括:废硒鼓、废电池(镉镍电池、氧化汞电池、铅蓄电池等),废荧光灯管(日光灯管、节能灯等),废温度计,废血压计,废药品及其包装物,废油漆、溶剂及其包装物,废杀虫剂、消毒剂及其包装物,废胶片及废相纸等。\\\\r\\\\n2可回收物:\\\\r\\\\n主要包括:废纸、废塑料、废金属、废旧纺织物、废玻璃、废弃电器电子类产品(包括废弃计算机、打印机、复印机、传真机、扫描仪、投影仪、电视机、空调机等)、废纸塑铝复合包装等适宜回收循环利用和资源化利用类的废弃物。\\\\r\\\\n3湿垃圾\\\\r\\\\n主要包括:食品加工、饮食服务、单位供餐等活动中的食物残余和食品加工废料等餐厨垃圾。\\\\r\\\\n4干垃圾\\\\r\\\\n主要包括:污损后不宜回收利用的包装物、餐巾纸、厕纸、尿不湿、竹木和陶瓷碎片等除可回收物、有害垃圾、湿垃圾以外的其他生活垃圾。\\\\r\\\\n\\\",\\\"createTime\\\":\\\"2019-09-06 14:17:52\\\",\\\"createUserId\\\":\\\"0\\\",\\\"noticeId\\\":4,\\\"noticeType\\\":\\\"1\\\",\\\"picture\\\":\\\"https://res.cnxzx.com/resource/static/img/images-3.png\\\",\\\"title\\\":\\\"垃圾分类小知识\\\"},{\\\"content\\\":\\\"最近,网上热议上海人快被垃圾分类逼疯了,甚至有人因此而逃离上海。而原本看着热闹的其他城市“吃瓜群众”惊闻,全国46个重点城市,其实一个也跑不掉,包括长沙。\\\\r\\\\n作为全国46个重点推进生活垃圾分类城市之一,长沙自2017年起正式启动垃圾分类试点工作,之后陆续出台一系列方案和办法,并将宣传活动深入开展至全市各机关、社区、学校、商圈、企业。本月,长沙启动生活垃圾分类“五进”宣传活动,至十月份,每月各区县(市)将分别开展丰富的宣传活动,使市民能够深入了解垃圾分类的意义,引导居民从身边做起、从点滴做起,自觉、科学地开展生活垃圾分类。\\\\r\\\\n今天,记者走访长沙市岳麓区航空母舰小区发现,一场浩大的“撤桶运动”已在小区铺开。航空母舰小区有着20多年历史,全小区共136户居民。过去,为方便居民投放垃圾,每层电梯口都设有垃圾桶。但自从岳麓区开始推行垃圾分类后,小区决定推行“撤桶并点”行动,撤走各楼层垃圾桶,设置集中的垃圾分类投放点。\\\\r\\\\n走进航空母舰小区大门,可以看到设在楼外的垃圾分类定点投放站,里面摆放有4个不同颜色的垃圾桶,分别存放厨余垃圾、其他垃圾、可回收物、有害垃圾。旁边的洗手池内,还摆放有香皂供居民和工作人员进行清洁。“撤桶并点是推行垃圾分类的必经也是必要之路。”来自长沙市源方环保公益发展中心的志愿者李媛表示,这一做法集中解决了楼层垃圾投放难以监管、难以取证的问题;同时,还有利于改善居住环境,减轻保洁压力,确保消防安全。“虽然短期来说,可能需要一定的适应期,但从长远角度来看,一定有利于居民生活。”\\\\r\\\\n\\\",\\\"createTime\\\":\\\"2019-08-27 16:17:52\\\",\\\"createUserId\\\":\\\"1\\\",\\\"noticeId\\\":3,\\\"noticeType\\\":\\\"1\\\",\\\"picture\\\":\\\"https://res.cnxzx.com/resource/static/img/images-4.png\\\",\\\"title\\\":\\\"别再看热闹!长沙生活垃圾分类五进宣传活动来了\\\"},{\\\"content\\\":\\\"做一桶环保酵素相当于种了10棵树,做一升环保酵素可以净化1000升河水。”4月22日“世界地球日”即将来临,今天,2018年长沙市开福区“五老”助学队党支部进校园宣讲活动走进清水塘第二小学,湖南商学院副教授陶开宇为孩子们上了一堂别开生面的环保课。\\\\r\\\\n“孩子们,我们平时生活中留下的蔬果垃圾,都可以利用起来,制作成环保酵素。”现场,每个学生都带来了红糖、矿泉水、果皮和小毛巾,在陶开宇的指导下,孩子们跟着志愿者老师一步一步学习制作环保酵素。“环保酵素产生的液体和气体应用非常广泛,不仅可以帮助减少垃圾、作为洗洁剂使用,还能净化水体。”志愿者老师还用现场制作的环保酵素清洗带有污垢的锅盖,让孩子们大开眼界。\\\\r\\\\n“我们要从源头上减少垃圾,减少环境污染。”“保护环境要做到循环用水、垃圾分类、低碳出行、绿色能源。”“我要把今天学到的教给爸爸妈妈和身边的朋友。”孩子们兴致很高,纷纷表示收获很大。\\\\r\\\\n\\\",\\\"createTime\\\":\\\"2019-08-26 15:17:52\\\",\\\"createUserId\\\":\\\"1\\\",\\\"noticeId\\\":2,\\\"noticeType\\\":\\\"1\\\",\\\"picture\\\":\\\"https://res.cnxzx.com/resource/static/img/images-5.png\\\",\\\"title\\\":\\\"果皮垃圾可以变废为宝\\\"},{\\\"content\\\":\\\"“生活垃圾分类体系建设一定要体现科学性与合理性,关键在于‘便利’‘有效’‘利用’和‘无害’。”陈勇认为,生活垃圾分类的方式不应过于复杂,否则难以长期坚持。“在一些地方实行的精细分类固然好,但是会增加处理成本与市民负担,其次也很难保证100%利用。”\\\\r\\\\n目前,长沙推行的是“干湿分类为主、四分类为辅”的分类方式。“分类的首要问题在于‘干湿分离’,也就一定要把干垃圾和湿垃圾分开。其次则是将有害垃圾、大件垃圾分类投放。”陈勇说,餐厨垃圾、厨余垃圾等“湿垃圾”是生活垃圾处置的“七寸”所在,必须探索有针对性的处理技术与模式。针对湿垃圾处置,陈勇建议在收运前端进行脱水处理,不仅能实现源头减量60%至70%,还能减少运输过程中的“跑冒滴漏”。垃圾分类结束多年“慢跑”,开始步入“快车道”。如何实现有效减量化、资源化、无害化处置,已成为当下不少城市面临的现实难题。\\\\r\\\\n“实行垃圾分类,关系广大人民群众生活环境,关系节约使用资源,也是社会文明水平的一个重要体现。”习近平总书记对垃圾分类高度关注。作为全国46个生活垃圾强制分类重点城市之一,长沙也正加速搭建生活垃圾分类投放、分类收集、分类运输、分类处理“全链条”。今日,中国工程院院士陈勇接受长沙晚报记者专访,为长沙加速推进垃圾分类、建设更加科学合理的分类体系支招。\\\\r\\\\n\\\",\\\"createTime\\\":\\\"2019-08-25 14:17:52\\\",\\\"createUserId\\\":\\\"1\\\",\\\"noticeId\\\":1,\\\"noticeType\\\":\\\"1\\\",\\\"picture\\\":\\\"https://res.cnxzx.com/resource/static/img/images-6.png\\\",\\\"title\\\":\\\"院士为长沙垃圾分类支招:推行上门收集\\\"}]\""; // com.alibaba.fastjson.JSONObject sysNoticeVos = com.alibaba.fastjson.JSONObject.parseObject(s); if("3".equals(null)){ System.out.println(223); } // System.out.println(sysNoticeVos); // for (SysNoticeVo sysNoticeVo : sysNoticeVos) { // System.out.println(sysNoticeVo.getContent()); // } RestException e=new RestException(); e.setMsg("123"); ExceptionUtils.err(e.getMsg(),e); } public static boolean isBase64(String str) { String base64Pattern = "^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$"; return Pattern.matches(base64Pattern, str); } @Test public void test2(){ // String s=RandomUtil.randomString(16); // System.out.println(s); // String encrypt = SecurityUtil.encrypt("ah0tsfwicokld4oa", "123"); // //RkDK4VU513B6RVsy75DEJg== // System.out.println(encrypt); // LogUtils.writeIp("192.168.1.110","请求头部对"); // // String date="2019-01-02 11:22:33"; // String s = DateUtil.parseDateTime(date).toString(DateUtils.DATE_FORMAT_HM); // System.out.println(s); // // String s1 = StrUtil.split(date, " ")[0]; // System.out.println(s1); // // List list=new ArrayList(); // list.clear(); // // // UserInfo userInfo=new UserInfo(); // userInfo.setUserId("11"); // log.info("哈哈{}",userInfo); int weight=0; String portData="wn00000070kgwn00000070kgwn00000070kgwn00000070kgwn00000070kgwn00000070kgwn00000070kgwn00000070kgwn00000070kgwn00000070kgwn0"; while ((weight=test(portData))!=-1){ break; } System.out.println(weight); } public int test(String s){ String[] kgwns = s.split("kgwn"); if(kgwns!=null&&kgwns.length>2){ String kgwn = kgwns[1]; String substring = kgwn.substring(kgwn.length() - 4); int i = Integer.parseInt(substring); return i; } return -1; } @Test public void test3(){ Cache lruCache = CacheUtil.newLRUCache(3); //通过实例化对象创建 //LRUCache lruCache = new LRUCache(3); lruCache.put("key1", "value1", DateUnit.SECOND.getMillis() * 3); lruCache.put("key2", "value2", DateUnit.SECOND.getMillis() * 3); lruCache.put("key3", "value3", DateUnit.SECOND.getMillis() * 3); lruCache.get("key1");//使用时间推近 lruCache.put("key4", "value4", DateUnit.SECOND.getMillis() * 3); //由于缓存容量只有3,当加入第四个元素的时候,根据LRU规则,最少使用的将被移除(2被移除) String value2 = lruCache.get("key2");//null String value3 = lruCache.get("key3");//null System.out.println(value2); System.out.println(value3); } @Test public void test4() throws UnsupportedEncodingException { //// Validator.validateEmail("aa","邮箱格式不正确"); // String s = "5eow3f5y4a9kqa9x"; // System.out.println(s); // String encrypt = SecurityUtil.encrypt(s, "456"); ////BFjvPvXcSRxrKnWlxYP14MxjxE97YCdNoNL6FFXt6LI= // String decrypt = SecurityUtil.decrypt(s, "BFjvPvXcSRxrKnWlxYP14MxjxE97YCdNoNL6FFXt6LI"); // // System.out.println(decrypt); String s=RandomStringUtils.randomAlphanumeric(32); byte[] gzip = ZipUtil.gzip(s, "UTF-8"); String s1 =new String(gzip,"UTF-8"); System.out.println(s1); } @Data class ExamInfoDict{ private int id; private int examType; private int answerIs; } @Data class UserInfoDict{ int id; String photoPath; List list; } @Test public void ts5(){ //------------------------------------------------- 考试信息列表 ExamInfoDict examInfoDict = new ExamInfoDict(); examInfoDict.setId(1); examInfoDict.setExamType(0); examInfoDict.setAnswerIs(1); ExamInfoDict examInfoDict1 = new ExamInfoDict(); examInfoDict1.setId(2); examInfoDict1.setExamType(0); examInfoDict1.setAnswerIs(0); ExamInfoDict examInfoDict2 = new ExamInfoDict(); examInfoDict2.setId(3); examInfoDict2.setExamType(1); examInfoDict2.setAnswerIs(0); List examInfoDicts = new ArrayList(); examInfoDicts.add(examInfoDict); examInfoDicts.add(examInfoDict1); examInfoDicts.add(examInfoDict2); //------------------------------------------------- 用户信息 UserInfoDict userInfoDict = new UserInfoDict(); userInfoDict.setId(1); userInfoDict.setPhotoPath("yx.mm.com"); userInfoDict.setList(examInfoDicts); Map tempMap = new HashMap(); tempMap.put("userInfo", userInfoDict); tempMap.put("flag", 1); BeanPath resolver = new BeanPath("userInfo.list[0].id"); Object result = resolver.get(tempMap);//ID为1 System.out.println(result); List property = (List) BeanUtil.getProperty(tempMap, "userInfo.list"); Console.log(property); } @Test public void test5(){ // StrBuilder strBuilder = StrBuilder.create(); // int i=-1; // if (i < 0) { // i += 256; // } // if (i < 16) // strBuilder.append("0"); // strBuilder.append("123"); // // System.out.println(strBuilder.toString()); // String encrypt = SecurityUtil.encrypt(Constants.PWD_DECRET, "{\"userId\":22}"); // System.out.println(encrypt); // String decrypt = SecurityUtil.decrypt(Constants.PWD_DECRET, "2eoF8F5Z3bsY9/UDrd6h4g=="); String s= "{\"userId\":\"27\",\"devCode\":\"abcdefg\"}"; String s1 = SecurityUtil.encrypt(Constants.PWD_DECRET,s); System.out.println(s1); } @Test public void test6(){ // String mo="18163623487"; // String replace = StrUtil.replace(mo, 3, 7, Convert.toChar("*")); // System.out.println(replace); // //// String decrypt = SecurityUtil.decrypt(Constants.PWD_DECRET, "KHEZGG/d4dW8AupSg9yISA=="); //// System.out.println(decrypt); // String s="{\"userId\":51}"; // String encrypt = SecurityUtil.encrypt(Constants.PWD_DECRET, s); // // System.out.println(encrypt); // RSA rsa = new RSA(); // String privateKeyBase64 = rsa.getPrivateKeyBase64(); // String publicKeyBase64 = rsa.getPublicKeyBase64(); // // System.out.println(privateKeyBase64); // System.out.println(publicKeyBase64); // String encrypt = SecurityUtil.encrypt("123"); // System.out.println(encrypt); // // RSA rsa = new RSA(null,Constants.RSA_PUBLIC_SECRET); // encrypt = rsa.encryptBase64("123", KeyType.PublicKey); // // System.out.println(encrypt); // // String s="HMIWlPv7Y8RQa1IqVqfn0UV48+CKAg4gW+vEo5KoY5HP27ELim1JhWdBUaqqCsydwOYi10/ytraRgiot8798NxmJ5wCYUvizUhF6u9yvku0tLdfjl2uoSkVryo8M/dYZRob28G7rYEJ6uDLvSgO5WejbyIAPd+PfRtsbAlceDls="; // String decrypt = SecurityUtil.decrypt(s); // System.out.println(decrypt); // // String encrypt1 = SecurityUtil.encrypt("123"); // // System.out.println(encrypt1); // String xzx = RandomStringUtils.randomAlphanumeric(32); // System.out.println(xzx); // // String bfcC6lKF3J4QZ38Z1 = SecurityUtil.encrypt(Constants.PWD_DECRET, "123456"); // System.out.println(bfcC6lKF3J4QZ38Z1); // String bfcC6lKF3J4QZ38Z = SecurityUtil.decrypt(Constants.PWD_DECRET, bfcC6lKF3J4QZ38Z1); // System.out.println(bfcC6lKF3J4QZ38Z); Long a=3L; System.out.println(a==3); System.out.println(a.equals(3)); System.out.println(a.equals("3")); // String aa = SecurityUtil.decrypt(encrypt); // System.out.println(aa); // String encrypt = SecurityUtil.encrypt(Constants.PWD_DECRET, "123"); // // System.out.println(encrypt); // // encrypt = SecurityUtil.encrypt(Constants.PWD_DECRET, "123"); // // System.out.println(encrypt); } @Test public void test7(){ double lon = Convert.toDouble("112.935633"); double lat=Convert.toDouble("28.131605"); //单位千米 int radius = 1; SpatialContext geo = SpatialContext.GEO; Rectangle rectangle = geo.getDistCalc().calcBoxByDistFromPt(geo.makePoint(lon, lat), radius * DistanceUtils.KM_TO_DEG, geo, null); System.out.println(rectangle); } @Test public void testJVM(){ // Console.log("**************java信息******************"); // Console.log(SystemUtil.getJavaRuntimeInfo()); // Console.log("**************系统信息******************"); // Console.log(SystemUtil.getOsInfo()); // Console.log("**************用户信息******************"); // Console.log(SystemUtil.getUserInfo()); // Console.log("**************主机信息******************"); // Console.log(SystemUtil.getHostInfo()); // Console.log("**************内存信息******************"); // Console.log(SystemUtil.getRuntimeInfo()); // // String c=a(); // System.out.println(c); // String s=RandomStringUtils.randomAlphanumeric(16); // System.out.println(s); // String encrypt = SecurityUtil.encrypt(s, "123456"); // System.out.println(encrypt); String s= "{\"userId\":\"USER1194135295260758016\",\"devCode\":\"abcdefg\"}"; String s1 = SecurityUtil.encrypt(Constants.PWD_DECRET,s); System.out.println(s1); try { String extra=",x2ixEmv2yp2S6bmjwmsFUmZ3idqWnrKfcGd9zseLj6Z9nUEBMuS6Kyr/lLg1Lu8nHWkqEjDhlrJjplHClrV4+Q=="; extra=StrUtil.removePrefix(extra,","); String decrypt = SecurityUtil.decrypt(Constants.PWD_DECRET, extra); JSONObject parse = JSONUtil.parseObj(decrypt); String userId=parse.getStr("userId"); } catch (Exception e) { ExceptionUtils.err("解码失败",e); } // String s2="sjbVsNam/bONkX8BziljdZLV7d9uFu6frM4GYY33NpU73UMxXsh8T52hnqhXU5Y"; // System.out.println(s2); // String decrypt = SecurityUtil.decrypt(Constants.PWD_DECRET, s1); // System.out.println(decrypt); } @Test public void a(){ // String s="0"; // String s1="0.00"; // int i = Convert.toBigDecimal(s,BigDecimal.ZERO).compareTo(Convert.toBigDecimal(s1,BigDecimal.ZERO)); // System.out.println(i); WeightInfo weightInfo=new WeightInfo(); weightInfo.setBatchNo(UUID.randomUUID().toString()); weightInfo.setCreateTime(DateUtil.now()); weightInfo.setDevCode("11"); weightInfo.setUserId("2"); weightInfo.setWeight("3"); System.out.println(JSONUtil.toJsonPrettyStr(weightInfo)); String s="22"; String s1 = s.split(",")[0]; System.out.println(s1); } @Test public void test11(){ UserInfo userInfo=new UserInfo(); userInfo.setMobilePhone("18163623487"); generateByUi(userInfo); } public Map generateByUi(UserInfo userInfo){ log.trace("开始生成海报图:{}",userInfo.getUserId()); //海报图名称 String userId=userInfo.getUserId(); String imageName="/user_" + userId + "_poster.jpg"; //二维码图名称 String imgName="/user_" + userId + "_acode.jpg"; generateAcodeUi("poster=" + userInfo.getMobilePhone(), "pages/login/login", imgName, "800px"); String path=Constants.IMG_UPLOAD_PATH+imgName; // if(StrUtil.isBlank(userInfo.getAvatar())){ // userInfo.setAvatar(Constants.IMG_TEMPALRE_VIEW+"/xzx-qr.png"); // } userInfo.setMobilePhone(new BusinessUtil().changeMobile(userInfo.getMobilePhone())); String backgroundUrl=Constants.IMG_TEMPALRE_PATH+"/user_share_poster_bg2.png"; Map s = null; try { s = generatePosterByUi(imageName, path, userInfo.getAvatar(), backgroundUrl, userInfo.getMobilePhone()); } catch (Exception e) { ExceptionUtils.err("生成分享海报失败",e); } return s; } public static Map generatePosterByUi(String imgName, String codePath, String avata, String backgroundUrl, String spuName) throws Exception { String urlPrefix="http://192.168.0.82/static/upload"; String imgPath="/xzx/resource/static/ui/"+imgName; //背景图 BufferedImage bufferImage = QrCodeBaseUtils.imageToBufferedImage(backgroundUrl); Graphics2D graphics = bufferImage.createGraphics(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //小程序码 BufferedImage qrCodeImage = ImageIO.read(new File(codePath)); graphics.drawImage(qrCodeImage, 100, 160, null); //头像 // BufferedImage logoBufferImage = Thumbnails.of(new URL(avata)).size(150, 150).asBufferedImage(); // graphics.drawImage(logoBufferImage, 57, 94, null); //文字 Font font = new Font("黑体", Font.BOLD, 34); graphics.setFont(font); graphics.setPaint(Color.black); graphics.drawString(spuName, 670, 954); QrCodeGraphicsUtils.savePic(bufferImage, 1, "jpg", 0.8, imgPath); graphics.dispose(); Map map=new HashMap<>(); map.put("viewUrl",urlPrefix+"/"+imgName); map.put("uploadUrl",imgPath); return map; } /** * 生成小程序码 * @param scene 参数 * @param path 跳转路径 * @param imgName 图片唯一名称 * @return */ public static String generateAcodeUi(String scene,String path,String imgName,String width){ String urlPrefix="http://192.168.0.82/static/upload"; String imgPath=Constants.IMG_UPLOAD_PATH+imgName; if(!FileUtil.exist(imgPath)){ //调用二维码接口 String url = StrFormatter.format("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={}", getAccessToken()); cn.hutool.json.JSONObject obj = JSONUtil.createObj(); //最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~, // 其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式) obj.put("scene", scene); //必须是已经发布的小程序存在的页面(否则报错),例如 pages/index/index, // 根路径前不要填加 /,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面 obj.put("path", path); //最小 280px,最大 1280px obj.put("width", width); obj.put("auto_color", false); cn.hutool.json.JSONObject obj2 = JSONUtil.createObj(); obj2.put("r", 0); obj2.put("g", 0); obj2.put("b", 0); obj.put("line_color", obj2); //是否需要透明底色,为 true 时,生成透明底色的小程序码 obj.put("is_hyaline", false); byte[] data = HttpRequest.post(url).body(obj.toString(), "application/json").execute().bodyBytes(); FileUtil.writeBytes(data, imgPath); } return urlPrefix+"/"+imgName; } public Result say(int i){ System.out.println(i); if(1==i){ say(14); return null; } System.out.println(33); return Result.success(""); } }