Browse Source

2022-09-16 添加使用记录的权限。

zhuchangxue 3 years ago
parent
commit
b27095885f

+ 5 - 0
zd-common/zd-common-core/src/main/java/com/zd/common/core/domain/per/PerPrefix.java

@@ -726,6 +726,11 @@ public class PerPrefix {
     public static final String BOTTLE_USERECORD= "bottle:useRecord:";
 
     /***
+     * 气瓶使用(管理端)
+     */
+    public static final String BOTTLE_USERECORDADMIN= "bottle:useRecordAdmin:";
+
+    /***
      * 气瓶入库-2版
      */
     public static final String BOTTLE_BOTTLESTORAGE= "bottle:bottleStorage:";

+ 78 - 4
zd-modules/zd-bottle-parent/zd-bottle/src/main/java/com/zd/bottle/controller/UseRecordController.java

@@ -10,6 +10,7 @@ import com.zd.bottle.vo.WebUseRecordVo;
 import com.zd.common.core.domain.per.PerFun;
 import com.zd.common.core.domain.per.PerPrefix;
 import com.zd.common.core.utils.DateUtils;
+import com.zd.common.core.utils.SecurityUtils;
 import com.zd.common.core.utils.poi.ExcelUtil;
 import com.zd.common.core.web.controller.BaseController;
 import com.zd.common.core.web.page.TableDataInfo;
@@ -19,6 +20,7 @@ import com.zd.common.response.ResultData;
 import com.zd.common.security.annotation.PreAuthorize;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.hadoop.security.SecurityUtil;
 import org.springframework.beans.BeanUtils;
 import org.springframework.web.bind.annotation.*;
 
@@ -46,13 +48,34 @@ public class UseRecordController extends BaseController<UseRecord> {
     private UseRecordService useRecordService;
 
     /**
-     * 查询使用记录列表
+     * 查询使用记录列表(学生端)
      */
     @PreAuthorize(hasPermi = PerPrefix.BOTTLE_USERECORD + PerFun.LIST)
     @GetMapping("/list")
     @ApiOperation(value = "查询使用记录列表")
     public TableDataInfo<UseRecordVo> list(UseRecord useRecord) {
         startPage("use_time","descending");
+        useRecord.setUserId(SecurityUtils.getUserId());
+        List<UseRecord> records =useRecordService.getList(useRecord);
+        TableDataInfo<UseRecord> dataTable = getDataTable(records);
+        TableDataInfo<UseRecordVo> info = new TableDataInfo<>();
+        if (CollUtil.isNotEmpty(records)) {
+            BeanUtils.copyProperties(dataTable, info);
+            List<UseRecordVo> recordVos = useRecordService.getListVo(records);
+            info.setRows(recordVos);
+        }
+        return info;
+    }
+
+
+    /**
+     * 查询使用记录列表(管理端)
+     */
+    @PreAuthorize(hasPermi = PerPrefix.BOTTLE_USERECORDADMIN + PerFun.LIST)
+    @GetMapping("/listByAdmin")
+    @ApiOperation(value = "查询使用记录列表")
+    public TableDataInfo<UseRecordVo> listByAdmin(UseRecord useRecord) {
+        startPage("use_time","descending");
         List<UseRecord> records =useRecordService.getList(useRecord);
         TableDataInfo<UseRecord> dataTable = getDataTable(records);
         TableDataInfo<UseRecordVo> info = new TableDataInfo<>();
@@ -76,13 +99,39 @@ public class UseRecordController extends BaseController<UseRecord> {
     }
 
     /**
-     * 导出使用记录列表
+     * 导出使用记录列表(学生端)
      */
     @PreAuthorize(hasPermi = PerPrefix.BOTTLE_USERECORD + PerFun.EXPORT)
     @ApiOperation(value = "导出使用记录列表")
     @Log(title = "使用记录", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(HttpServletResponse response, UseRecord useRecord) throws IOException {
+        useRecord.setUserId(SecurityUtils.getUserId());
+        List<UseRecord> records =useRecordService.getList(useRecord);
+        List<UseRecordVo> info = new ArrayList<>();
+        if (CollUtil.isNotEmpty(records)) {
+            info = useRecordService.getListVo(records);
+            info.forEach(i-> {
+                BigDecimal afterUse = i.getAfterUse();
+                i.setBeforeUseValue(i.getBeforeUse().stripTrailingZeros().toPlainString()+"MPa");
+                if (afterUse!=null){
+                    i.setAfterUseValue(afterUse.stripTrailingZeros().toPlainString()+"MPa");
+                }
+            });
+        }
+        ExcelUtil<UseRecordVo> util = new ExcelUtil<>(UseRecordVo.class);
+        util.exportExcel(response, info, "使用记录数据" + DateUtils.getDate());
+    }
+
+
+    /**
+     * 导出使用记录列表(管理端)
+     */
+    @PreAuthorize(hasPermi = PerPrefix.BOTTLE_USERECORDADMIN + PerFun.EXPORT)
+    @ApiOperation(value = "导出使用记录列表")
+    @Log(title = "使用记录", businessType = BusinessType.EXPORT)
+    @PostMapping("/exportByAdmin")
+    public void exportByAdmin(HttpServletResponse response, UseRecord useRecord) throws IOException {
         List<UseRecord> records =useRecordService.getList(useRecord);
         List<UseRecordVo> info = new ArrayList<>();
         if (CollUtil.isNotEmpty(records)) {
@@ -100,7 +149,7 @@ public class UseRecordController extends BaseController<UseRecord> {
     }
 
     /**
-     * 管理端端获取使用记录详细信息
+     * 管理端端获取使用记录详细信息(学生端)
      */
     @PreAuthorize(hasPermi = PerPrefix.BOTTLE_USERECORD + PerFun.QUERY)
     @ApiOperation(value = "管理端端获取使用记录详细信息")
@@ -110,6 +159,16 @@ public class UseRecordController extends BaseController<UseRecord> {
     }
 
     /**
+     * 管理端端获取使用记录详细信息(管理端)
+     */
+    @PreAuthorize(hasPermi = PerPrefix.BOTTLE_USERECORDADMIN + PerFun.QUERY)
+    @ApiOperation(value = "管理端端获取使用记录详细信息")
+    @GetMapping(value = "/bottleByAdmin/{id}")
+    public ResultData<WebUseRecordVo> getBottleInfoByAdmin(@PathVariable("id") Long id) {
+        return ResultData.success(useRecordService.getBottleInfo(id));
+    }
+
+    /**
      * 信息统计管理端端获取气瓶使用记录详细信息
      */
     @ApiOperation(value = "信息统计管理端端获取气瓶使用记录详细信息")
@@ -173,12 +232,27 @@ public class UseRecordController extends BaseController<UseRecord> {
     }
 
     /***
-     * 查询使用记录
+     * 查询使用记录(学生端)
      */
+    @PreAuthorize(hasPermi = PerPrefix.BOTTLE_USERECORD + PerFun.LISTDETAIL)
     @ApiOperation(value = "查询使用记录")
     @GetMapping(value = "/getUseDetails")
     public TableDataInfo<UseRecord> getUseDetails(UseRecord useRecord) {
         startPage("create_time","descending");
+        useRecord.setUserId(SecurityUtils.getUserId());
+        List<UseRecord> records =useRecordService.getList(useRecord);
+        return getDataTable(records);
+    }
+
+
+    /***
+     * 查询使用记录(管理端)
+     */
+    @PreAuthorize(hasPermi = PerPrefix.BOTTLE_USERECORDADMIN + PerFun.LISTDETAIL)
+    @ApiOperation(value = "查询使用记录")
+    @GetMapping(value = "/getUseDetailsByAdmin")
+    public TableDataInfo<UseRecord> getUseDetailsByAdmin(UseRecord useRecord) {
+        startPage("create_time","descending");
         List<UseRecord> records =useRecordService.getList(useRecord);
         return getDataTable(records);
     }