Browse Source

#ADD 小程序补货首页

谭斌 2 years ago
parent
commit
2d61a48be0

+ 6 - 0
device-api-service/pom.xml

@@ -77,6 +77,12 @@
             <artifactId>sys-sdk</artifactId>
             <version>1.0</version>
         </dependency>
+        <dependency>
+            <groupId>com.xy</groupId>
+            <artifactId>xy-oss</artifactId>
+            <version>1.0</version>
+            <scope>compile</scope>
+        </dependency>
 
     </dependencies>
 </project>

+ 14 - 0
device-api-service/src/main/java/com/xy/service/DeviceInfoServiceImpl.java

@@ -33,6 +33,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import jodd.introspector.MapperFunction;
 import lombok.RequiredArgsConstructor;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
@@ -258,6 +259,19 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
         ExcelUtils.write(response, "设备列表.xls", "设备列表", DeviceInfoDto.DeviceExcelVO.class, deviceExcelVOS);
     }
 
+
+    @Async
+    @ApiOperation("导出设备(异步)")
+    @PostMapping("exportDevices/async")
+    public void exportDevicesAsync(DeviceInfoDto.Page page) {
+        PageBean<DeviceInfoDto.Vo2> pageBean = queryPage(page);
+        List<DeviceInfoDto.Vo2> records = pageBean.getRecords();
+        List<DeviceInfoDto.DeviceExcelVO> deviceExcelVOS = BeanUtil.copyToList(records, DeviceInfoDto.DeviceExcelVO.class);
+        //TODO:
+        // 输出
+//        ExcelUtils.write(response, "设备列表.xls", "设备列表", DeviceInfoDto.DeviceExcelVO.class, deviceExcelVOS);
+    }
+
     @PostMapping("nearbyPage")
     @ApiOperation("附近设备分页查询")
     public R<PageBean<DeviceInfoDto.Vo2>> nearbyPage(@RequestBody DeviceInfoDto.Page page) {

+ 34 - 0
device-api-service/src/main/java/com/xy/service/ExportAsyncService.java

@@ -0,0 +1,34 @@
+package com.xy.service;
+
+import com.xy.annotate.RestMappingController;
+import com.xy.dto.DeviceInfoDto;
+import com.xy.utils.R;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import javax.validation.Valid;
+
+/***
+ * 异步导出处理
+ * @author 谭斌
+ * @date 2023/3/4 10:44
+ */
+@Service
+@RequiredArgsConstructor
+@Api(tags = "文件导出-异步")
+@RestMappingController("export/async")
+public class ExportAsyncService {
+
+    private final DeviceInfoServiceImpl deviceInfoService;
+
+    @ApiOperation("导出设备信息")
+    @PostMapping("deviceInfo")
+    public R exportDeviceInfo(@RequestBody @Valid DeviceInfoDto.Page page) {
+        deviceInfoService.exportDevicesAsync(page);
+        return R.ok();
+    }
+}