|
|
@@ -0,0 +1,105 @@
|
|
|
+package com.zksy.park.controller;
|
|
|
+
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.zksy.common.annotation.Log;
|
|
|
+import com.zksy.common.core.domain.Result;
|
|
|
+import com.zksy.common.enums.BusinessType;
|
|
|
+import com.zksy.common.utils.SearchUtil;
|
|
|
+import com.zksy.park.domain.SmartEmployment;
|
|
|
+import com.zksy.park.domain.WaterUsageData;
|
|
|
+import com.zksy.park.service.WaterUsageDataService;
|
|
|
+import com.zksy.park.utils.DowntemplateUtil;
|
|
|
+import com.zksy.park.utils.ExcelExportUtil;
|
|
|
+import com.zksy.park.utils.ExcelImportUtil;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 智慧用工
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+@RequestMapping("/waterUsageData")
|
|
|
+@Api(tags = "用水信息", description = "用水信息")
|
|
|
+public class WaterUsageDataController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WaterUsageDataService service;
|
|
|
+
|
|
|
+ @GetMapping("/getById/{id}")
|
|
|
+ @ApiOperation(value = "用水信息搜索getById")
|
|
|
+ public Result getById(@PathVariable String id) {
|
|
|
+ return Result.ok(service.getById(id));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/findByPage")
|
|
|
+ @ApiOperation(value = "用水信息分页")
|
|
|
+ public Result findByPage(long pageNum, long pageSize, String conditionJson) throws Exception {
|
|
|
+ return Result.ok(service.page(new Page<>(pageNum, pageSize), SearchUtil.parseWhereSql(conditionJson)));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/getList")
|
|
|
+ @ApiOperation(value = "查询所有用水信息")
|
|
|
+ public Result getList(String conditionJson) throws Exception {
|
|
|
+ return Result.ok(service.list(SearchUtil.parseWhereSql(conditionJson)));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/save")
|
|
|
+ @ApiOperation(value = "新增用水信息")
|
|
|
+ @Log(title = "用水信息", businessType = BusinessType.INSERT)
|
|
|
+ public Result<Object> save(@RequestBody WaterUsageData entity) {
|
|
|
+ entity.setCreateTime(LocalDateTime.now());
|
|
|
+ return Result.ok(service.save(entity),"新增成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/updateById")
|
|
|
+ @ApiOperation(value = "用水信息修改")
|
|
|
+ @Log(title = "修改用水信息", businessType = BusinessType.UPDATE)
|
|
|
+ public Result<Object> updateById(@RequestBody WaterUsageData entity) {
|
|
|
+ return Result.ok(service.updateById(entity),"修改成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/deleteById")
|
|
|
+ @ApiOperation(value = "用水信息删除")
|
|
|
+ @Log(title = "删除v", businessType = BusinessType.DELETE)
|
|
|
+ public Result<Object> deleteById(String id) {
|
|
|
+ return Result.ok(service.removeById(id),"删除成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/deleteBatchById")
|
|
|
+ @ApiOperation(value = "用水信息批量删除")
|
|
|
+ @Log(title = "用水信息批量删除", businessType = BusinessType.DELETE)
|
|
|
+ public Result<Object> deleteBatchById(@RequestParam List<String> ids) {
|
|
|
+ return Result.ok(service.removeByIds(ids),"删除成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/exportExcel")
|
|
|
+ @ApiOperation(value = "导出用水信息Excel")
|
|
|
+ @Log(title = "导出用水信息Excel", businessType = BusinessType.EXPORT)
|
|
|
+ public void exportExcel(HttpServletResponse response,String conditionJson) throws Exception {
|
|
|
+ ExcelExportUtil.exportExcel(response,service.list(SearchUtil.parseWhereSql(conditionJson)), WaterUsageData.class, "用水信息","用水信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/importExcel")
|
|
|
+ @ApiOperation(value = "导入用水信息Excel")
|
|
|
+ @Log(title = "导入用水信息Excel", businessType = BusinessType.IMPORT)
|
|
|
+ public Result<Object> importExcel(@RequestParam("file") MultipartFile file) {
|
|
|
+ return Result.ok(service.saveOrUpdateBatch(ExcelImportUtil.importExcel(file, WaterUsageData.class)));
|
|
|
+ }
|
|
|
+ @GetMapping("/downloadTemplateWord")
|
|
|
+ @ApiOperation(value = "下载用水信息模板", notes = "下载用水信息模板")
|
|
|
+ public void getUploadTemplate(HttpServletResponse response) throws IOException {
|
|
|
+ DowntemplateUtil.downloadTemplate(response,"用水信息");
|
|
|
+ }
|
|
|
+}
|