如图所示
emmmm
好吧,随便说几个用到的吧
一、根据某个字段,排序存储map的list集合
类{方法{List<Map<String,Object>> arrayList = 一个集合;List<Map<String, Object>> list = arrayList.stream().sorted(paring(类名::getAttribute, Comparator.nullsFirst(Comparator.naturalOrder())).reversed()) .collect(Collectors.toList());}private static Double getAttribute(Map<String, Object> map){if (ObjectUtil.isEmpty(map.get("XXXX"))){return null;}else{return Double.parseDouble((String) map.get("XXXX")) ;}}}}
二、AOP,统一处理代码
//类一 controller@YYY@GetMapping("/XXX")public Object XXX(@ApiParam("页码") @RequestParam(value = "pageNo") Integer pageNo,@ApiParam("页数") @RequestParam(value = "pageSize") Integer pageSize) {return Object;}//另一个类定义注解 @Retention(RetentionPolicy.RUNTIME)@Target(ElementType.METHOD)public @interface YYY{}//另一个类定义切面@Aspect@Order(123) //顺序public class Filter {@Around("@annotation(YYY)")public Object before(ProceedingJoinPoint point, Api api) throws Throwable {//前Object data = point.proceed(paramValues);// 方法运行//后}}
三、定时任务,每小时一次
@Component@Configurable@EnableScheduling@Slf4jpublic class XXXTask extends AbstractTask {@Scheduled(cron = "0 0 */1 * * ?")public void method(){}}
四、加行锁
<select id="selectOneInfoByLock" parameterType="java.lang.Integer" resultMap="CustomResultMap">SELECT * FROM `XXX`<where>id = #{id}</where>for update;</select>//Java 代码中加注解@Transactional(isolation = Isolation.READ_COMMITTED)
五、POI导出excel合并单元格,(举例合并1到5行,的第8列和第10列)
HSSFWorkbook book = new HSSFWorkbook();HSSFSheet sheet = book.createSheet(title);int startRowIndex = 1;int rowIndex = 5;//填充数据-----//自己填充//------------List<List<Integer>> mergeParams = new ArrayList<>();// 依次放入 起始行 结束行 起始列 结束列for (int i = 0; i < commonTotalSize; i++) {List<Integer> mergeParam = new ArrayList<>(2);mergeParam.add(startRowIndex);mergeParam.add(rowIndex - 1);if (i == 0){mergeParam.add(8);mergeParam.add(8);}else if(i == 1){mergeParam.add(10);mergeParam.add(10);}mergeParams.add(mergeParam);}}}for (List<Integer> list : mergeParams) {if (!Objects.equals(list.get(0), list.get(1))){sheet.addMergedRegion(new CellRangeAddress(list.get(0), list.get(1), list.get(2), list.get(3)));}}return book;
活动作品 ,混一首