MYSQL迁移数据库到另一台机器 mysqldump
1 2 mysqlddump -u root -p -all-databases > /d/databases.sql
1 2 mysqldump -u root --all-databases > /home/databases.sql
或者直接复制数据目录到新机器
Linux服务启动脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 #!/bin/sh echo " =====关闭isup应用======" ids=`ps -ef | grep "uap-modules-isup-2.2.0.jar" | grep -v "grep" | awk '{print $2}' ` echo "当前服务进程id:" $ids for i in $ids do echo "Kill ID--> the process [ $i ]" kill -9 $i done echo " =====>启动isup应用中...." nohup java -jar -Xms128m -Xmx512m -XX:PermSize=128M -XX:MaxPermSize=512M uap-modules-isup-2.2.0.jar --server.port=9209 --spring.profiles.active=test --spring.cloud.nacos.discovery.server-addr=10.129.138.144:8848 --spring.cloud.nacos.discovery.group=yun-144 --spring.cloud.nacos.config.namespace=090d6ad3-0fc5-4411-9dab-7c144c128add > log /isup.log 2>&1 & echo " =====>启动isup应用完成OK" tail -f log /isup.log
分段批量入库
1 2 3 4 5 6 7 8 9 10 11 12 int limit = 500 ;int size = filter.size();int checkTimes = ((size - 1 ) / limit) + 1 ;for (int i = 0 ; i <= checkTimes - 1 ; i++) { int aa = i * limit; int bb = (i + 1 ) * limit; if (i == checkTimes - 1 ) { bb = size; } List<SupplierEvaluationYear> subList = filter.subList(aa, bb); saveBatch(subList); }
根据属性高低排名
1 2 3 4 5 6 List<?> tempList = entry.getValue().stream() .filter(s -> !Integer.valueOf(NO_LEVEL).equals(s.getTempEvaluateGrade())) .sorted(Comparator.comparing(SupplierGroupEvaluationYear::getTempEvaluateGrade).reversed() .thenComparing(SupplierGroupEvaluationYear::getOverallScore, Comparator.nullsFirst(BigDecimal::compareTo)) .thenComparing(SupplierGroupEvaluationYear::getSupplyAmount, Comparator.nullsFirst(BigDecimal::compareTo)).reversed()).collect(toList());
重复key属性取值
1 sysDeptList.stream().collect(Collectors.toMap(SysDept::getDeptName, SysDept::getDeptId, (k1, k2) -> k2));
多属性去重
1 qualifiedList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getEnterpriseId() + "-" + o.getTenantId()))), ArrayList::new ));
过滤重复分组
1 2 TreeMap<Integer, SupplierRuleGrade> levelRuleMap = levelRulesList.stream().collect( Collectors.toMap(SupplierRuleGrade::getLevel, Function.identity(), (o1, o2) -> o1, TreeMap::new ));
计算出现次数
1 Map<String, Long> nameMap = unitList.stream().collect(Collectors.groupingBy(p -> p, Collectors.counting()));
倒叙
1 dataMap.keySet().stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList());
Mysql递归查询 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 WITH RECURSIVE subcategories AS ( SELECT department_id, parent_id, `name` FROM t_department WHERE department_id = 1 UNION ALL SELECT c.department_id, c.parent_id, c.`name` FROM t_department c INNER JOIN subcategories sc ON c.parent_id = sc.department_id ) SELECT * FROM subcategories;