Prechádzať zdrojové kódy

新增供应商导入功能

wanyuan 8 mesiacov pred
rodič
commit
a3552abf56

+ 123 - 20
src/main/java/com/kingtom/shengtai/api/controller/SrmSupplierController.java

@@ -1,10 +1,14 @@
 package com.kingtom.shengtai.api.controller;
 
+import java.io.IOException;
+import java.text.MessageFormat;
 import java.util.*;
+import java.util.concurrent.*;
 import java.util.stream.Collectors;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.dev33.satoken.annotation.SaCheckRole;
+import com.alibaba.excel.EasyExcel;
 import com.kingtom.kirin.api.security.SaSecurityUtils;
 import com.kingtom.kirin.api.system.mapper.SystemMapper;
 import com.kingtom.kirin.api.system.model.SystemUserDTO;
@@ -14,23 +18,30 @@ import com.kingtom.kirin.app.system.model.SystemUser;
 import com.kingtom.kirin.core.common.CommonConst;
 import com.kingtom.kirin.core.common.base.PageInfo;
 import com.kingtom.kirin.core.common.base.Result;
+import com.kingtom.kirin.core.common.exception.AppException;
 import com.kingtom.kirin.core.common.utils.CollectionUtils;
+import com.kingtom.kirin.core.common.utils.IDUtils;
 import com.kingtom.kirin.core.common.utils.JsonUtils;
 import com.kingtom.shengtai.api.mapper.SrmMapper;
 import com.kingtom.shengtai.api.model.SrmSupplierDTO;
+import com.kingtom.shengtai.api.model.SrmSupplierImportDTO;
+import com.kingtom.shengtai.app.srm.excel.SrmSupplierImportTask;
 import com.kingtom.shengtai.app.srm.model.ProductDir;
-import com.kingtom.shengtai.app.srm.service.IProductDirService;
 import com.kingtom.shengtai.app.srm.model.SrmSupplier;
 import com.kingtom.shengtai.app.srm.model.SrmSupplierDO;
+import com.kingtom.shengtai.app.srm.service.IProductDirService;
 import com.kingtom.shengtai.app.srm.service.ISrmSupplierService;
 import com.mybatisflex.core.paginate.Page;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.enums.ParameterIn;
 import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.servlet.http.HttpServletResponse;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * 供应商信息表 控制层。
@@ -41,6 +52,7 @@ import org.springframework.web.bind.annotation.*;
 @Tag(name = "SrmSupplierController", description = "供应商信息表 控制层。")
 @RestController
 @RequestMapping("/srmSuppliers")
+@Slf4j
 public class SrmSupplierController{
 
     @Autowired
@@ -52,8 +64,7 @@ public class SrmSupplierController{
     /**
      * 添加供应商信息表。
      *
-     * @param dto
-     *         供应商信息表
+     * @param dto 供应商信息表
      * @return {@code true} 添加成功,{@code false} 添加失败
      */
     @Operation(summary = "添加供应商信息表。", description = "添加供应商信息表。")
@@ -68,8 +79,7 @@ public class SrmSupplierController{
     /**
      * 根据主键删除供应商信息表。
      *
-     * @param id
-     *         主键
+     * @param id 主键
      * @return {@code true} 删除成功,{@code false} 删除失败
      */
     @Parameter(name = "id", description = "主键", in = ParameterIn.PATH, required = true)
@@ -84,8 +94,7 @@ public class SrmSupplierController{
     /**
      * 根据主键删除供应商信息表。
      *
-     * @param ids
-     *         主键
+     * @param ids 主键
      * @return {@code true} 删除成功,{@code false} 删除失败
      */
     @Operation(summary = "根据主键批量删除供应商信息表。", description = "根据主键批量删除供应商信息表。")
@@ -99,8 +108,7 @@ public class SrmSupplierController{
     /**
      * 根据主键更新供应商信息表。
      *
-     * @param dto
-     *         供应商信息表
+     * @param dto 供应商信息表
      * @return {@code true} 更新成功,{@code false} 更新失败
      */
     @Parameter(name = "id", description = "", in = ParameterIn.PATH, required = true)
@@ -125,8 +133,7 @@ public class SrmSupplierController{
     /**
      * 根据供应商信息表主键获取详细信息。
      *
-     * @param id
-     *         供应商信息表主键
+     * @param id 供应商信息表主键
      * @return 供应商信息表详情
      */
     @Parameter(name = "id", description = "供应商信息表主键", in = ParameterIn.PATH, required = true)
@@ -141,12 +148,9 @@ public class SrmSupplierController{
     /**
      * 分页查询供应商信息表。
      *
-     * @param query
-     *         查询条件
-     * @param pageNum
-     *         当前页码
-     * @param pageSize
-     *         每页数量
+     * @param query    查询条件
+     * @param pageNum  当前页码
+     * @param pageSize 每页数量
      * @return 分页对象
      */
     @Operation(summary = "分页查询供应商信息表。", description = "分页查询供应商信息表。")
@@ -159,11 +163,110 @@ public class SrmSupplierController{
         String state = object.get("state") instanceof String ? object.get("state").toString() : null;
         List<String> products = object.get("products") instanceof Collection<?> ?
                 ((Collection<?>)object.get("products")).stream().map(e -> e instanceof String ? ((String)e) : null)
-                                                       .collect(Collectors.toList()) : null;
+                        .collect(Collectors.toList()) : null;
         Page<SrmSupplierDO> page = iSrmSupplierService.page(name, type, state, products, pageNum, pageSize);
         return Result.ok(CollectionUtils.convertPage(page, SrmSupplierDTO::convert));
     }
 
+    @Operation(description = "获取导入供应商的excel模板")
+    @GetMapping("/importTemplate")
+    @SaCheckPermission(value = {"AuthMenu:srm_supplier:Execute"})
+    public void getSuppliersImportTemplate(HttpServletResponse response) throws IOException{
+        Page<SrmSupplierDO> page = iSrmSupplierService.page(null, null, null, null, 1, 1);
+        SrmSupplierDO supplierDO = CollectionUtils.isEmpty(page.getRecords()) ? null : page.getRecords().get(0);
+        SrmSupplierDTO srmSupplierDTO = SrmSupplierDTO.convert(supplierDO);
+        SrmSupplierImportDTO dto = new SrmSupplierImportDTO();
+        dto.setName(srmSupplierDTO == null || StringUtils.isBlank(srmSupplierDTO.getName()) ? "供应商" :
+                srmSupplierDTO.getName());
+        dto.setMark(srmSupplierDTO == null || StringUtils.isBlank(srmSupplierDTO.getMark()) ? "1" :
+                srmSupplierDTO.getMark());
+        dto.setPerson(srmSupplierDTO == null || StringUtils.isBlank(srmSupplierDTO.getPersonName()) ? "张三" :
+                srmSupplierDTO.getPersonName());
+        dto.setPhone(srmSupplierDTO == null || StringUtils.isBlank(srmSupplierDTO.getPhone()) ? "13188888888" :
+                srmSupplierDTO.getPhone());
+        dto.setType(srmSupplierDTO == null || StringUtils.isBlank(srmSupplierDTO.getType()) ? "类型" :
+                srmSupplierDTO.getType());
+        dto.setAddress(srmSupplierDTO == null || StringUtils.isBlank(srmSupplierDTO.getAddress()) ? "公司地址" :
+                srmSupplierDTO.getAddress());
+        dto.setIntro(srmSupplierDTO == null || StringUtils.isBlank(srmSupplierDTO.getIntro()) ? "公司简介" :
+                srmSupplierDTO.getIntro());
+        if(srmSupplierDTO != null && CollectionUtils.isNotEmpty(srmSupplierDTO.getProduct())){
+            List<ProductDir> dirs = productDirService.findByIds(srmSupplierDTO.getProduct());
+            String collect = dirs.stream().map(ProductDir::getName).collect(Collectors.joining(","));
+            dto.setProduct(StringUtils.isBlank(collect) ? "A产品,B产品" : collect);
+        } else{
+            dto.setProduct("A产品,B产品");
+        }
+        dto.setSuperiorProduct(
+                srmSupplierDTO == null || StringUtils.isBlank(srmSupplierDTO.getSuperiorProduct()) ? "优势产品描述" :
+                        srmSupplierDTO.getSuperiorProduct());
+
+        //这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
+        try{
+            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+            response.setCharacterEncoding("utf-8");
+            response.setHeader("Content-disposition", "attachment;filename=" + IDUtils.newUUID() + ".xlsx");
+            // 这里需要设置不关闭流
+            EasyExcel.write(response.getOutputStream(), SrmSupplierImportDTO.class).autoCloseStream(Boolean.FALSE)
+                    .sheet("模板").doWrite(List.of(dto));
+        } catch(Exception e){
+            log.error(e.getMessage(), e);
+            // 重置response
+            response.reset();
+            response.setContentType("application/json");
+            response.setCharacterEncoding("utf-8");
+            throw new AppException("下载文件失败", e);
+        }
+    }
+
+    @Operation(description = "批量导入供应商")
+    @PostMapping("/import")
+    @SaCheckPermission(value = {"AuthMenu:srm_supplier:Execute"})
+    public Result<Map<String, String>> importSuppliers(@RequestPart("file") MultipartFile file){
+        if(file == null || file.isEmpty()){
+            throw new AppException("导入文件不存在!");
+        }
+        List<SrmSupplierImportDTO> list = null;
+        try{
+            list = EasyExcel.read(file.getInputStream()).head(SrmSupplierImportDTO.class).sheet().doReadSync();
+        } catch(IOException e){
+            throw new AppException("导入文件不存在!");
+        }
+        if(list.isEmpty()){
+            throw new AppException("导入数据为空!");
+        }
+        //用于存储每个任务的Future对象
+        List<Future<String[]>> furtures = new ArrayList<>();
+        // 创建线程池
+        ExecutorService executor = Executors.newSingleThreadExecutor();
+        // 创建CountDownLatch
+        CountDownLatch latch = new CountDownLatch(list.size());
+        for(int i = 0; i < list.size(); i++){
+            SrmSupplierImportTask task = new SrmSupplierImportTask(i, latch, list.get(i));
+            Future<String[]> submit = executor.submit(task);
+            furtures.add(submit);
+        }
+        try{
+            // 等待所有导入任务完成
+            latch.await();
+        } catch(InterruptedException e){
+            Thread.currentThread().interrupt();
+            log.error("Thread interrupted: {}", e.getMessage());
+        } finally{
+            // 关闭线程池
+            executor.shutdown();
+        }
+        Map<String, String> errorInfo = furtures.stream().map(e -> {
+            try{
+                return e.get();
+            } catch(InterruptedException | ExecutionException ex){
+                return null;
+            }
+        }).filter(Objects::nonNull).collect(Collectors.toMap(e -> e[0], e -> e[1]));
+        String msg = MessageFormat.format("导入完成,失败{0}条!", errorInfo.size());
+        return Result.ok(msg, errorInfo);
+    }
+
     /**
      * 我的供应商。
      *
@@ -232,8 +335,8 @@ public class SrmSupplierController{
         }
         List<String> productIds = JsonUtils.toObjectList(supplier.getProduct(), String.class);
         List<ProductDir> dirs = productDirService.findByIds(productIds);
-        LinkedHashMap<String,String> map = new LinkedHashMap<>(dirs.size());
-        dirs.forEach(e-> map.put(e.getCode(),e.getName()));
+        LinkedHashMap<String, String> map = new LinkedHashMap<>(dirs.size());
+        dirs.forEach(e -> map.put(e.getCode(), e.getName()));
         return Result.ok(map);
     }
 

+ 29 - 4
src/main/java/com/kingtom/shengtai/api/controller/SystemExtController.java

@@ -6,13 +6,12 @@ import com.kingtom.kirin.api.security.SaSecurityUtils;
 import com.kingtom.kirin.app.system.model.SystemUser;
 import com.kingtom.kirin.app.system.service.ISystemUserService;
 import com.kingtom.kirin.core.common.base.Result;
+import com.kingtom.kirin.core.common.exception.AppException;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
 
 /**
  * 应用模块名称</p>
@@ -46,6 +45,7 @@ public class SystemExtController{
             return Result.fail("操作失败!");
         }
     }
+
     @Operation(summary = "更新用户的uniapp客户端Id")
     @PostMapping("/user/client")
     public Result<String> removeUserClientId(@RequestBody String clientId){
@@ -62,4 +62,29 @@ public class SystemExtController{
         }
     }
 
+    @Operation(description = "获取导入的excel模板")
+    @GetMapping("/{type}/importTemplate")
+    public ModelAndView getImportTemplate(@PathVariable("type") String type){
+        String url = switch(type){
+            case "srm_supplier" -> "/srmSuppliers/importTemplate";
+            case "org_person" -> "/org/org_persons/importTemplate";
+            default -> throw new AppException("导入类型错误!");
+        };
+        ModelAndView modelAndView = new ModelAndView();
+        modelAndView.setViewName("forward:" + url);
+        return modelAndView;
+    }
+
+    @Operation(description = "批量导入")
+    @PostMapping("/{type}/import")
+    public ModelAndView executeImport(@PathVariable("type") String type){
+        String url = switch(type){
+            case "srm_supplier" -> "/srmSuppliers/import";
+            case "org_person" -> "/org/org_persons/import";
+            default -> throw new AppException("导入类型错误!");
+        };
+        ModelAndView modelAndView = new ModelAndView();
+        modelAndView.setViewName("forward:" + url);
+        return modelAndView;
+    }
 }

+ 66 - 0
src/main/java/com/kingtom/shengtai/api/model/SrmSupplierImportDTO.java

@@ -0,0 +1,66 @@
+package com.kingtom.shengtai.api.model;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 应用模块名称</p>
+ * 代码描述</p>
+ * Copyright: Copyright (C) 2023 , Inc. All rights reserved. <p>
+ * Company: 成都诚唐科技有限责任公司</p>
+ *
+ * @author wany
+ * @since 2023/12/21
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@ColumnWidth(20)
+@HeadRowHeight(30)
+@ContentRowHeight(20)
+public class SrmSupplierImportDTO{
+
+    @ExcelProperty(value = "供应商名称 *")
+    private String name;
+
+    @ExcelProperty(value = "评分 *")
+    private String mark;
+
+    @ExcelProperty(value = "联系人 *")
+    private String person;
+
+    @ExcelProperty(value = "联系电话 *")
+    private String phone;
+
+    @ExcelProperty(value = "供应商类型 *")
+    private String type;
+
+    @ExcelProperty(value = "公司地址")
+    private String address;
+
+    @ExcelProperty(value = "公司简介")
+    private String intro;
+
+    @ExcelProperty(value = "产品")
+    private String product;
+
+    @ExcelProperty(value = "优势产品")
+    private String superiorProduct;
+
+    //    @ExcelProperty(value = "形象图片", converter = StringImageConverter.class)
+    //    private List<String> image;
+    //
+    //    @ExcelProperty(value = "营业执照", converter = StringImageConverter.class)
+    //    private List<String> businessLicense;
+    //
+    //    @ExcelProperty(value = "权威证书", converter = StringImageConverter.class)
+    //    private List<String> certificates;
+
+}

+ 96 - 0
src/main/java/com/kingtom/shengtai/app/srm/excel/SrmSupplierImportTask.java

@@ -0,0 +1,96 @@
+package com.kingtom.shengtai.app.srm.excel;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+
+import com.kingtom.kirin.app.system.model.SystemUser;
+import com.kingtom.kirin.app.system.service.ISystemUserService;
+import com.kingtom.kirin.core.common.excel.ExcelDataImportTask;
+import com.kingtom.kirin.core.common.utils.JsonUtils;
+import com.kingtom.kirin.core.common.utils.SpringContextUtils;
+import com.kingtom.shengtai.api.model.SrmSupplierImportDTO;
+import com.kingtom.shengtai.app.srm.model.ProductDir;
+import com.kingtom.shengtai.app.srm.model.SrmSupplier;
+import com.kingtom.shengtai.app.srm.service.IProductDirService;
+import com.kingtom.shengtai.app.srm.service.ISrmSupplierService;
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * 应用模块名称<p>
+ * 代码描述<p>
+ * Copyright: Copyright (C) 2024 KingTom
+ * , Inc. All rights reserved. <p>
+ * Company: 成都诚唐科技有限责任公司<p>
+ *
+ * @author wany
+ * @since 2024/7/8
+ */
+public class SrmSupplierImportTask extends ExcelDataImportTask<SrmSupplierImportDTO>{
+
+    private ISrmSupplierService srmSupplierService;
+
+    private ISystemUserService  systemUserService;
+
+    private IProductDirService  productDirService;
+
+    public SrmSupplierImportTask(int i, CountDownLatch latch, SrmSupplierImportDTO perosn){
+        super(i, perosn, latch);
+    }
+
+    public ISrmSupplierService getSrmSupplierService(){
+        if(srmSupplierService == null){
+            srmSupplierService = SpringContextUtils.getBean(ISrmSupplierService.class);
+        }
+        return srmSupplierService;
+    }
+
+    public ISystemUserService getSystemUserService(){
+        if(systemUserService == null){
+            systemUserService = SpringContextUtils.getBean(ISystemUserService.class);
+        }
+        return systemUserService;
+    }
+
+    public IProductDirService getProductDirService(){
+        if(productDirService == null){
+            productDirService = SpringContextUtils.getBean(IProductDirService.class);
+        }
+        return productDirService;
+    }
+
+    @Override
+    public void importData(SrmSupplierImportDTO dto){
+        String person = null;
+        if(StringUtils.isNotBlank(dto.getPerson())){
+            List<SystemUser> systemUsersByName = getSystemUserService().findSystemUsersByName(dto.getPerson());
+            person = systemUsersByName.stream().map(SystemUser::getId).findFirst().orElse(null);
+            if(person != null){
+                SrmSupplier byPerson = getSrmSupplierService().findByPerson(person);
+                if(byPerson != null){
+                    return;
+                }
+            }
+        }
+        SrmSupplier supplier = new SrmSupplier();
+        supplier.setName(dto.getName());
+        supplier.setMark(dto.getMark());
+        supplier.setPerson(person);
+        supplier.setPhone(dto.getPhone());
+        supplier.setType(dto.getType());
+        supplier.setAddress(dto.getAddress());
+        supplier.setIntro(dto.getIntro());
+        supplier.setIntro(dto.getIntro());
+        if(StringUtils.isNotBlank(dto.getProduct())){
+            List<ProductDir> productDirs = getProductDirService().findListByNames(
+                    Arrays.asList(dto.getProduct().split(",")));
+            supplier.setProduct(JsonUtils.toJson(productDirs.stream().map(ProductDir::getId).toList()));
+        } else{
+            supplier.setProduct(JsonUtils.toJson(new ArrayList<>()));
+        }
+        supplier.setSuperiorProduct(dto.getSuperiorProduct());
+        getSrmSupplierService().create(supplier);
+    }
+
+}

+ 8 - 1
src/main/java/com/kingtom/shengtai/app/srm/service/IProductDirService.java

@@ -72,6 +72,14 @@ public interface IProductDirService extends IBaseService<ProductDir>{
      */
     ProductDir findByName(String name);
 
+    /**
+     * 根据name查询 产品目录表
+     *
+     * @param names the names
+     * @return product dir
+     */
+    List<ProductDir> findListByNames(List<String> names);
+
     /**
      * 根据code查询 产品目录表
      *
@@ -106,5 +114,4 @@ public interface IProductDirService extends IBaseService<ProductDir>{
      */
     List<Map<String, Object>> findSupplierCountGroupByProduct(boolean filterCount0);
 
-
 }

+ 16 - 12
src/main/java/com/kingtom/shengtai/app/srm/service/impl/ProductDirServiceImpl.java

@@ -11,15 +11,14 @@ import com.kingtom.kirin.core.common.exception.AppException;
 import com.kingtom.kirin.core.common.utils.CollectionUtils;
 import com.kingtom.kirin.core.common.utils.IDUtils;
 import com.kingtom.kirin.core.common.utils.JsonUtils;
+import com.kingtom.shengtai.app.srm.SrmConst;
 import com.kingtom.shengtai.app.srm.dao.IProductDirDao;
 import com.kingtom.shengtai.app.srm.model.ProductDir;
 import com.kingtom.shengtai.app.srm.service.IProductDirService;
-import com.kingtom.shengtai.app.srm.SrmConst;
 import com.mybatisflex.core.paginate.Page;
 import com.mybatisflex.core.query.QueryCondition;
 import com.mybatisflex.core.query.QueryWrapper;
 import com.mybatisflex.core.row.Row;
-import com.mybatisflex.core.service.IService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -54,8 +53,8 @@ public class ProductDirServiceImpl extends BaseServiceImpl<IProductDirDao, Produ
     }
 
     private void saveFileFormal(ProductDir entity){
-        spaceFileService.doFormalOfReplace(entity.getImage(), SrmConst.PRODUCT_DIR_RESOURCE_KEY,
-                entity.getId(), SrmConst.PRODUCT_DIR_IMAGE);
+        spaceFileService.doFormalOfReplace(entity.getImage(), SrmConst.PRODUCT_DIR_RESOURCE_KEY, entity.getId(),
+                SrmConst.PRODUCT_DIR_IMAGE);
     }
 
     private void checkBeforeCreate(ProductDir productDir){
@@ -195,6 +194,11 @@ public class ProductDirServiceImpl extends BaseServiceImpl<IProductDirDao, Produ
         return mapper.selectOneByCondition(PRODUCT_DIR.NAME.eq(name));
     }
 
+    @Override
+    public List<ProductDir> findListByNames(List<String> names){
+        return mapper.selectListByCondition(PRODUCT_DIR.NAME.in(names));
+    }
+
     @Override
     public ProductDir findByCode(String code){
         return mapper.selectOneByCondition(PRODUCT_DIR.CODE.eq(code));
@@ -205,8 +209,8 @@ public class ProductDirServiceImpl extends BaseServiceImpl<IProductDirDao, Produ
         if(StringUtils.isEmpty(id)){
             return new ArrayList<>();
         }
-        QueryCondition condition =
-                QueryCondition.createEmpty().and("path::jsonb ?? '" + id + "'").and(PRODUCT_DIR.ID.ne(id));
+        QueryCondition condition = QueryCondition.createEmpty().and("path::jsonb ?? '" + id + "'")
+                .and(PRODUCT_DIR.ID.ne(id));
         return mapper.selectListByCondition(condition);
     }
 
@@ -225,13 +229,13 @@ public class ProductDirServiceImpl extends BaseServiceImpl<IProductDirDao, Produ
         // FROM srm_supplier ) AS b ON a.ID = b.pid
         //GROUP BY a.ID, a.NAME  HAVING COUNT ( b.sid ) > 0 ORDER BY c DESC;
         QueryWrapper wrapper = QueryWrapper.create().select("a.id", "a.name", "COUNT ( b.sid ) AS c")
-                .from(QueryWrapper.create().select("id,name").from("product_dir").where("id not in(select DISTINCT parent_id from product_dir)")).as("a")
-                .leftJoin(QueryWrapper.create()
-                                      .select("SUBSTRING ( json_array_elements ( product :: json ) :: TEXT, 2, 36 ) AS pid","id AS sid")
-                                      .from("srm_supplier")).as("b").on("a.id = b.pid")
+                .from(QueryWrapper.create().select("id,name").from("product_dir")
+                        .where("id not in(select DISTINCT parent_id from product_dir)")).as("a").leftJoin(
+                        QueryWrapper.create()
+                                .select("SUBSTRING ( json_array_elements ( product :: json ) :: TEXT, 2, 36 ) AS pid",
+                                        "id AS sid").from("srm_supplier")).as("b").on("a.id = b.pid")
                 .groupBy("a.id", "a.name")
-                .having(QueryCondition.createEmpty().and("COUNT ( b.sid ) > 0").when(filterCount0))
-                .orderBy("c desc");
+                .having(QueryCondition.createEmpty().and("COUNT ( b.sid ) > 0").when(filterCount0)).orderBy("c desc");
         List<Row> objects = mapper.selectRowsByQuery(wrapper);
         return objects.stream().map(HashMap::new).collect(Collectors.toList());
     }