|
|
@@ -1,35 +1,34 @@
|
|
|
package cn.iocoder.yudao.module.pms.controller.admin.qhse.measure;
|
|
|
|
|
|
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.measure.vo.IotMeasureBookPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.measure.vo.IotMeasureBookRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.measure.vo.IotMeasureBookSaveReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.measure.IotMeasureBookDO;
|
|
|
import cn.iocoder.yudao.module.pms.service.qhse.measure.IotMeasureBookService;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
-import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
-import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserImportRespVO;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
-
|
|
|
-import java.util.*;
|
|
|
-import java.io.IOException;
|
|
|
-
|
|
|
-import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
-import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
-import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
-import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
-
|
|
|
-import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
-
|
|
|
-import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.Parameters;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.List;
|
|
|
|
|
|
-import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
|
|
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
|
|
|
|
|
|
@Tag(name = "管理后台 - 计量器具台账")
|
|
|
@@ -48,6 +47,24 @@ public class IotMeasureBookController {
|
|
|
return success(iotMeasureBookService.createIotMeasureBook(createReqVO));
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/import-template")
|
|
|
+ public void importTemplate(HttpServletResponse response) throws IOException {
|
|
|
+ ExcelUtils.downloadTemplate(response, "计量器具导入模板", IotMeasureBookRespVO.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/import")
|
|
|
+ @Operation(summary = "导入用户")
|
|
|
+ @Parameters({
|
|
|
+ @Parameter(name = "file", description = "Excel 文件", required = true),
|
|
|
+ @Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true")
|
|
|
+ })
|
|
|
+ @PreAuthorize("@ss.hasPermission('system:user:import')")
|
|
|
+ public CommonResult<UserImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
|
|
|
+ @RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception {
|
|
|
+ List<IotMeasureBookRespVO> list = ExcelUtils.read(file, IotMeasureBookRespVO.class);
|
|
|
+ return success(iotMeasureBookService.importBookList(list, updateSupport));
|
|
|
+ }
|
|
|
+
|
|
|
@PutMapping("/update")
|
|
|
@Operation(summary = "更新计量器具台账")
|
|
|
@PreAuthorize("@ss.hasPermission('rq:iot-measure-book:update')")
|