mysql查询一列逗号分隔

  1. select id from bg_cust_info where for_short="金马衡器";
  2. select GROUP_CONCAT(id) as ids from bg_cust_info where for_short="金马衡器";

map根据value进行排序

  1. Stream<Map.Entry<String, Long>> sorted = nameToNum.entrySet().stream().sorted((a, b) -> (int) (a.getValue() - b.getValue()))

接着map转为list
假设map有5个属性,转为list,包含5个map,每个map包含一个属性

  1. //在上面sorted的基础上:
  2. List<Map.Entry<String, Long>> collect= sorted.collect(Collectors.toList())

Java百分比计算

  1. public static String percentCalculate(long num1, long num2) {
  2. //创建一个数值格式化对象
  3. java.text.NumberFormat numberformat = java.text.NumberFormat.getInstance();
  4. //设置精确到小数点后2位
  5. numberformat.setMaximumFractionDigits(2);
  6. java.text.DecimalFormat df = new java.text.DecimalFormat("##.##%");//传入格式模板
  7. return df.format((float) num1 / (float) num2);
  8. }
  1. private String percentDivide(BigDecimal divisor, BigDecimal sum) {
  2. //求比例 相除
  3. BigDecimal divide = divisor.divide(sum, 4, RoundingMode.HALF_UP);
  4. //将结果装换未百分比
  5. NumberFormat percent = NumberFormat.getPercentInstance();
  6. percent.setMaximumFractionDigits(2);
  7. return percent.format(divide.doubleValue());
  8. }

rest请求接收参数

方式1

  1. @PostMapping("/a")
  2. JsonResponse<Object> suppliesReservesByArea(String areaCode,String name);
  3. POST http://localhost:8066/phe-api/v2/event/materials/suppliesReservesByArea?areaCode=62100000000&name=123

方式2

  1. @PostMapping("/a/{areaCode}")
  2. JsonResponse<Map<String,Object>> materialTypeByArea(@PathVariable("areaCode") @NotBlank String areaCode);
  3. POST http://localhost:8066/phe-api/v2/event/materials/MaterialTypeByArea/62100000000

方式3

  1. @PostMapping("/a")
  2. JsonResponse<Map<String, Object>> getMaterialsByTag(@RequestBody @Validated MaterialQuantityStatisticsVo vo);
  3. POST http://localhost/phe-api/v2/event/materials/countMaterialsByTags
  4. {
  5. "a":"b"
  6. }

如何查看jar包在哪个依赖里面?如果解决依赖冲突?

image.png