dengzedong
6 天以前 a6e46fe2b5729e7468b6f3c4e079232801c22520
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/controller/admin/DaPointController.java
@@ -1,6 +1,5 @@
package com.iailab.module.data.point.controller.admin;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.iailab.framework.apilog.core.annotation.ApiAccessLog;
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.framework.common.pojo.PageParam;
@@ -8,11 +7,13 @@
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.framework.excel.core.util.ExcelUtils;
import com.iailab.module.data.api.dto.ApiPointValueQueryDTO;
import com.iailab.module.data.channel.common.service.ChannelSourceService;
import com.iailab.module.data.common.enums.DataSourceType;
import com.iailab.module.data.common.enums.DataTypeEnum;
import com.iailab.module.data.common.enums.MeasureValueType;
import com.iailab.module.data.influxdb.service.InfluxDBService;
import com.iailab.module.data.point.common.PointTypeEnum;
import com.iailab.module.data.point.dto.DaPointDTO;
import com.iailab.module.data.point.entity.DaPointEntity;
import com.iailab.module.data.point.dto.DaPointSimpleDTO;
import com.iailab.module.data.point.service.DaPointService;
import com.iailab.module.data.point.vo.*;
import io.swagger.v3.oas.annotations.Operation;
@@ -20,7 +21,6 @@
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.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -34,8 +34,8 @@
import java.text.SimpleDateFormat;
import java.util.*;
import static com.iailab.framework.common.pojo.CommonResult.success;
import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.iailab.framework.common.pojo.CommonResult.success;
/**
@@ -68,6 +68,14 @@
    public CommonResult<List<DaPointDTO>> list(@Valid @RequestParam Map<String, Object> params) {
        List<DaPointDTO> list = daPointService.list(params);
        return success(list);
    }
    @PreAuthorize("@ss.hasPermission('data:point:query')")
    @GetMapping("/simple-list")
    @Operation(summary = "列表")
    public CommonResult<List<DaPointSimpleDTO>> simpleList(@Valid @RequestParam Map<String, Object> params) {
        List<DaPointDTO> list = daPointService.list(params);
        return success(ConvertUtils.sourceToTarget(list, DaPointSimpleDTO.class));
    }
    @PreAuthorize("@ss.hasPermission('data:point:query')")
@@ -111,7 +119,6 @@
    @PreAuthorize("@ss.hasPermission('data:point:update')")
    @PutMapping("/enable")
    @Operation(summary = "启用")
    @Transactional
    public CommonResult<Boolean> enable(@RequestBody String[] ids) {
        daPointService.enableByIds(ids);
        return success(true);
@@ -120,7 +127,6 @@
    @PreAuthorize("@ss.hasPermission('data:point:update')")
    @PutMapping("/disable")
    @Operation(summary = "禁用")
    @Transactional
    public CommonResult<Boolean> disable(@RequestBody String[] ids) {
        daPointService.disableByIds(ids);
        return success(true);
@@ -132,14 +138,15 @@
    @ApiAccessLog(operateType = EXPORT)
    public void exportPointList(@Validated DaPointPageReqVO exportReqVO,
                                HttpServletResponse response) throws IOException {
        exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
        List<DaPointExcelVO> dataList = new ArrayList<>();
        List<DaPointDTO> measurePointList = daPointService.getMeasurePoint(exportReqVO);
        List<DaPointExcelVO> dataList = ConvertUtils.sourceToTarget(daPointService.getList(exportReqVO), DaPointExcelVO.class);
        /*List<DaPointDTO> measurePointList = daPointService.getMeasurePoint(exportReqVO);
        dataList.addAll(ConvertUtils.sourceToTarget(measurePointList, DaPointExcelVO.class));
        List<DaPointDTO> mathPointList = daPointService.getMathPoint(exportReqVO);
        dataList.addAll(ConvertUtils.sourceToTarget(mathPointList, DaPointExcelVO.class));
        List<DaPointDTO> constantPointList = daPointService.getConstantPoint(exportReqVO);
        dataList.addAll(ConvertUtils.sourceToTarget(constantPointList, DaPointExcelVO.class));
        List<DaPointDTO> cumulatePointList = daPointService.getCumulatePoint(exportReqVO);
        dataList.addAll(ConvertUtils.sourceToTarget(cumulatePointList, DaPointExcelVO.class));*/
        ExcelUtils.write(response, "测点列表.xls", "测点列表", DaPointExcelVO.class, dataList);
    }
@@ -166,7 +173,7 @@
            if (end == null) {
                queryDto.setEnd(new Date());
            } else {
                queryDto.setStart(formatter.parse(end));
                queryDto.setEnd(formatter.parse(end));
            }
        } catch (ParseException e) {
            e.printStackTrace();
@@ -180,14 +187,14 @@
    public void importTemplate(HttpServletResponse response) throws IOException {
        // 手动创建导出 demo
        List<PointImportExcelVO> list = Arrays.asList(
                PointImportExcelVO.builder().pointName("测点1").pointType("MEASURE").dataType("float").valueType("SIMULATE")
                PointImportExcelVO.builder().pointName("测点1").pointType(PointTypeEnum.MEASURE_POINT.getCode()).dataType(DataTypeEnum.FLOAT.getCode()).valueType(MeasureValueType.SIMULATE.getCode())
                        .storeType(null).unit("t(非必填)").unittransfactor(new BigDecimal(1)).defaultValue(new BigDecimal(0)).maxValue(new BigDecimal(10000000.000000)).minValue(new BigDecimal(0))
                        .minfreqid("1min").remark("备注(非必填)").sourceType(DataSourceType.HTTP.getCode())
                        .sourceName("").tagNo("SARD1200G00102RC001")
                        .build()
        );
        // 输出
        ExcelUtils.write(response, "测点导入模板.xlsx", "测点列表", PointImportExcelVO.class, list);
        ExcelUtils.write(response, "测点导入模板.xlsx", "测点列表", PointImportExcelVO.class, list,true);
    }
    @PostMapping("/import")
@@ -196,7 +203,6 @@
            @Parameter(name = "file", description = "Excel 文件", required = true),
            @Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true")
    })
//    @PreAuthorize("@ss.hasPermission('data:point:import')")
    public CommonResult<PointImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
                                                       @RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception {
        List<PointImportExcelVO> list = ExcelUtils.read(file, PointImportExcelVO.class);