Эх сурвалжийг харах

1、车队班组导出接口

zk 2 жил өмнө
parent
commit
5d57aeca33

+ 1 - 0
pom.xml

@@ -52,6 +52,7 @@
         <pagehelper-spring-boot-starter.version>1.4.7</pagehelper-spring-boot-starter.version>
         <junit.version>4.13.2</junit.version>
         <xxljob.version>2.4.0</xxljob.version>
+        <project.version>1.0.0</project.version>
     </properties>
 
     <dependencyManagement>

+ 25 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfFleetController.java

@@ -7,12 +7,18 @@ import com.sckw.core.model.page.PageHelperUtil;
 import com.sckw.core.model.page.PageResult;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
+import com.sckw.excel.easyexcel.RequestHolder;
+import com.sckw.excel.utils.ExcelUtil;
 import com.sckw.fleet.model.KwfDriver;
 import com.sckw.fleet.model.KwfFleet;
 import com.sckw.fleet.model.dto.KwfFleetDto;
+import com.sckw.fleet.model.vo.KwfDriverVo;
+import com.sckw.fleet.model.vo.KwfFleetVo;
 import com.sckw.fleet.service.KwfFleetService;
+import jakarta.servlet.http.HttpServletResponse;
 import jakarta.validation.Valid;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 import java.util.HashMap;
 import java.util.List;
@@ -66,6 +72,25 @@ public class KwfFleetController {
         return HttpResult.ok(fleetService.findList(params));
     }
 
+    /**
+     * @param params 查询参数
+     * @description 导出
+     * @author zk
+     * @date 2023/07/11
+     **/
+    @PostMapping("/export")
+    public HttpResult export(@RequestBody HashMap params) {
+        /**查询分页数据**/
+        List<KwfFleetVo> fleets = fleetService.findPage(params);
+
+        if (!CollectionUtils.isEmpty(fleets)) {
+            HttpServletResponse response = RequestHolder.getResponse();
+            ExcelUtil.download(response, KwfFleetVo.class, fleets);
+            return null;
+        }
+        return HttpResult.error("无数据!");
+    }
+
     /**
      * @param params 新增参数
      * @return HttpResult

+ 0 - 1
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/dao/KwfFleetMapper.java

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.fleet.model.KwfFleet;
 import com.sckw.fleet.model.vo.KwfFleetVo;
 import org.apache.ibatis.annotations.Mapper;
-
 import java.util.List;
 import java.util.Map;
 

+ 67 - 2
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/vo/KwfFleetVo.java

@@ -1,18 +1,83 @@
 package com.sckw.fleet.model.vo;
 
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.sckw.core.model.base.BaseModel;
+import com.sckw.excel.annotation.ExcelContext;
 import com.sckw.fleet.model.KwfFleet;
+import lombok.Data;
+
+import java.util.Date;
 
 /**
  * @author zk
- * @desc 车队信息
+ * @desc 车队班组信息
  * @date 2023/7/6 0006
  */
-public class KwfFleetVo extends KwfFleet {
+@Data
+@ExcelContext(fileName = "车队班组信息", sheetName = "车队班组信息")
+public class KwfFleetVo {
 
     /**
      * 主键id
      */
+    @ExcelIgnore
     private String id;
 
+    /**
+     * 企业id
+     */
+    @ExcelIgnore
+    private Long entId;
+
+    /**
+     * 车队名称
+     */
+    @ExcelProperty(value = "车队班组名称", index = 0)
+    private String name;
+
+    /**
+     * 车队联系人
+     */
+    @ExcelProperty(value = "车队联系人", index = 1)
+    private String contacts;
+
+    /**
+     * 联系电话
+     */
+    @ExcelProperty(value = "联系电话", index = 2)
+    private String phone;
+
+    /**
+     * 创建人
+     */
+    @ExcelIgnore
+    private String createBy;
+
+    /**
+     * 创建人
+     */
+    @ExcelProperty(value = "创建人", index = 3)
+    private String createByName;
+
+    /**
+     * 创建时间
+     */
+    @ExcelProperty(value = "创建时间", index = 4)
+    private String createTime;
+
+
+    /**
+     * 更新时间
+     */
+    @ExcelProperty(value = "更新时间", index = 5)
+    private String updateTime;
+
+    /**
+     * 备注
+     */
+    @ExcelProperty(value = "备注", index = 6)
+    private String remark;
+
 }

+ 22 - 4
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfFleetService.java

@@ -7,18 +7,23 @@ import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.context.LoginUserHolder;
-import com.sckw.core.web.model.LoginUserInfo;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.fleet.dao.KwfFleetMapper;
 import com.sckw.fleet.model.KwfFleet;
 import com.sckw.fleet.model.dto.KwfFleetDto;
+import com.sckw.fleet.model.vo.KwfDriverVo;
 import com.sckw.fleet.model.vo.KwfFleetVo;
+import com.sckw.system.api.RemoteSystemService;
+import com.sckw.system.api.model.dto.res.EntCacheResDto;
+import com.sckw.system.api.model.dto.res.UserCacheResDto;
+import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @author zk
@@ -30,6 +35,8 @@ public class KwfFleetService {
 
     @Autowired
     KwfFleetMapper fleetDao;
+    @DubboReference(version = "2.0.0", group = "design", check = false)
+    private RemoteSystemService remoteSystemService;
 
     /**
      * @param key 主键id
@@ -52,9 +59,20 @@ public class KwfFleetService {
         params.put("entId", LoginUserHolder.getEntId());
         List<KwfFleetVo> fleets = fleetDao.findPage(params);
 
-        /**数据组装**/
-        //dubbo获取用户信息
+        /**获取查询数据**/
+        List<Long> createBys = new ArrayList<>();
+        for (KwfFleetVo fleetVo:fleets) {
+            createBys.add(Long.parseLong(fleetVo.getCreateBy()));
+        }
+        //用户数据集
+        createBys = createBys.stream().distinct().collect(Collectors.toList());
+        Map<Long, UserCacheResDto> users = remoteSystemService.queryUserCacheMapByIds(createBys);
 
+        /**数据组装**/
+        for (KwfFleetVo fleetVo:fleets) {
+            UserCacheResDto user = users == null ? null : users.get(Long.parseLong(fleetVo.getCreateBy()));
+            fleetVo.setCreateByName(user != null ? user.getName() : null);
+        }
         return fleets;
     }