From 14cb329f0fec66711e3ddeba7e80db289c7fe8fc Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期四, 31 十月 2024 08:51:04 +0800 Subject: [PATCH] 测点列表.xlsx --- iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/point/DaPointDao.xml | 66 ++++++++++++++++++++++ iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaPointService.java | 8 ++ iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/vo/DaPointExcelVO.java | 10 ++- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java | 40 ++++++++++++- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/controller/admin/DaPointController.java | 29 +++++---- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaPointDao.java | 10 +-- 6 files changed, 137 insertions(+), 26 deletions(-) diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/controller/admin/DaPointController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/controller/admin/DaPointController.java index f4d16b2..532099c 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/controller/admin/DaPointController.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/controller/admin/DaPointController.java @@ -55,7 +55,7 @@ @PreAuthorize("@ss.hasPermission('data:point:query')") @GetMapping("page") - public CommonResult<PageResult<DaPointDTO>> page(@Valid DaPointPageReqVO reqVO){ + public CommonResult<PageResult<DaPointDTO>> page(@Valid DaPointPageReqVO reqVO) { PageResult<DaPointDTO> page = daPointService.queryPage(reqVO); return success(page); } @@ -70,14 +70,14 @@ @PreAuthorize("@ss.hasPermission('data:point:query')") @GetMapping("/info/{id}") - public CommonResult<DaPointDTO> info(@PathVariable("id") String id){ - DaPointDTO info= daPointService.info(id); + public CommonResult<DaPointDTO> info(@PathVariable("id") String id) { + DaPointDTO info = daPointService.info(id); return success(info); } @PreAuthorize("@ss.hasPermission('data:point:create')") @PostMapping("create") - public CommonResult<Boolean> create(@RequestBody DaPointDTO daPointDTO){ + public CommonResult<Boolean> create(@RequestBody DaPointDTO daPointDTO) { String id = UUID.randomUUID().toString(); daPointDTO.setId(id); daPointService.add(daPointDTO); @@ -100,7 +100,7 @@ @PreAuthorize("@ss.hasPermission('data:point:query')") @GetMapping("pointNo") - public CommonResult<List<DaPointDTO>> getpoint(@RequestParam Map<String, Object> params){ + public CommonResult<List<DaPointDTO>> getPoint(@RequestParam Map<String, Object> params) { List<DaPointDTO> list = daPointService.list(params); return new CommonResult<List<DaPointDTO>>().setData(list); @@ -129,11 +129,16 @@ @PreAuthorize("@ss.hasPermission('data:point:export')") @ApiAccessLog(operateType = EXPORT) public void exportPointList(@Validated DaPointPageReqVO exportReqVO, - HttpServletResponse response) throws IOException { + HttpServletResponse response) throws IOException { exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List<DaPointEntity> list = daPointService.queryExcelList(exportReqVO).getList(); - List<DaPointExcelVO> daPointExcelVOlist = ConvertUtils.sourceToTarget(list,DaPointExcelVO.class); - ExcelUtils.write(response, "测点列表.xls", "数据", DaPointExcelVO.class, daPointExcelVOlist); + List<DaPointExcelVO> dataList = new ArrayList<>(); + 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)); + ExcelUtils.write(response, "测点列表.xls", "测点列表", DaPointExcelVO.class, dataList); } @GetMapping("/exportValue") @@ -149,16 +154,16 @@ List<String> pointNos = new ArrayList<>(); pointNos.add(pointNo); queryDto.setPointNos(pointNos); - try{ + try { if (start == null) { queryDto.setStart(new Date()); - }else{ + } else { queryDto.setStart(formatter.parse(start)); } if (end == null) { queryDto.setEnd(new Date()); - }else{ + } else { queryDto.setStart(formatter.parse(end)); } } catch (ParseException e) { diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaPointDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaPointDao.java index fc14b78..e122d5a 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaPointDao.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaPointDao.java @@ -27,6 +27,8 @@ IPage<DaPointDTO> getPageList(IPage<DaPointEntity> page, @Param("params") DaPointPageReqVO reqVO); + List<DaPointDTO> getList(DaPointPageReqVO reqVO); + List<DaPointDTO> getConstantPoint(Map<String, Object> params); List<DaPointDTO> getMeasurePoint(Map<String, Object> params); @@ -35,13 +37,9 @@ default IPage<DaPointDTO> selectPageList(DaPointPageReqVO reqVO) { return getPageList(getPage(reqVO), reqVO); - }; - - default PageResult<DaPointEntity> selectExcelList(DaPointPageReqVO reqVO) { - return selectPage(reqVO,new QueryWrapper<>()); } - default DaPointEntity selectByPointName(String pointName){ + default DaPointEntity selectByPointName(String pointName) { return selectOne("point_name", pointName); - }; + } } diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaPointService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaPointService.java index 02a487f..8897e3a 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaPointService.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaPointService.java @@ -57,5 +57,11 @@ PointImportRespVO importPointList(List<PointImportExcelVO> importPoints, boolean isUpdateSupport); - PageResult<DaPointEntity> queryExcelList(DaPointPageReqVO exportReqVO); + List<DaPointDTO> getList(DaPointPageReqVO exportReqVO); + + List<DaPointDTO> getConstantPoint(DaPointPageReqVO reqVO); + + List<DaPointDTO> getMeasurePoint(DaPointPageReqVO reqVO); + + List<DaPointDTO> getMathPoint(DaPointPageReqVO reqVO); } diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java index fee2663..a2b1ce0 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java @@ -109,11 +109,17 @@ if (params.get("pointNos") != null) { pointNos = JSONArray.parseArray(JSONArray.toJSONString(params.get("pointNos")), String.class); } + List<String> pointTypes = new ArrayList<>(); + if (params.get("pointTypes") != null) { + pointTypes = Arrays.asList(params.get("pointTypes").toString().split(",")); + } + Object pointNoLike = params.get("pointNoLike"); QueryWrapper<DaPointEntity> queryWrapper = new QueryWrapper(); queryWrapper.eq(!ObjectUtils.isEmpty(pointType), "point_type", pointType); queryWrapper.in(pointNos.size() != 0,"point_no", pointNos); queryWrapper.like(!ObjectUtils.isEmpty(pointNoLike), "point_no", pointNoLike); + queryWrapper.in(pointTypes.size() != 0,"point_type", pointTypes); List<DaPointEntity> list = daPointDao.selectList(queryWrapper); return ConvertUtils.sourceToTarget(list, DaPointDTO.class); } @@ -167,6 +173,15 @@ } @Override + public List<DaPointDTO> getConstantPoint(DaPointPageReqVO reqVO) { + Map<String, Object> params = new HashMap<>(); + params.put("pointType", PointTypeEnum.CONSTANT.getCode()); + params.put("pointNo", reqVO.getPointNo()); + params.put("pointName", reqVO.getPointName()); + return daPointDao.getConstantPoint(params); + } + + @Override public List<DaPointDTO> getConstantPoint(String freq) { Map<String, Object> params = new HashMap<>(); params.put("pointType", PointTypeEnum.CONSTANT.getCode()); @@ -182,6 +197,16 @@ params.put("isEnable", CommonConstant.IS_ENABLE); params.put("pointNos", pointNos); return daPointDao.getConstantPoint(params); + } + + @Override + public List<DaPointDTO> getMeasurePoint(DaPointPageReqVO reqVO) { + Map<String, Object> params = new HashMap<>(); + params.put("pointType", PointTypeEnum.MEASURE_POINT.getCode()); + params.put("pointNo", reqVO.getPointNo()); + params.put("pointName", reqVO.getPointName()); + params.put("sourceName", reqVO.getSourceName()); + return daPointDao.getMeasurePoint(params); } @Override @@ -212,6 +237,15 @@ return null; } return list.get(0); + } + + @Override + public List<DaPointDTO> getMathPoint(DaPointPageReqVO reqVO) { + Map<String, Object> params = new HashMap<>(); + params.put("pointType", PointTypeEnum.CALCULATE_POINT.getCode()); + params.put("pointNo", reqVO.getPointNo()); + params.put("pointName", reqVO.getPointName()); + return daPointDao.getMathPoint(params); } @Override @@ -311,10 +345,8 @@ } @Override - public PageResult<DaPointEntity> queryExcelList(DaPointPageReqVO exportReqVO) { - - return daPointDao.selectExcelList(exportReqVO); - + public List<DaPointDTO> getList(DaPointPageReqVO exportReqVO) { + return daPointDao.getList(exportReqVO); } @Override diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/vo/DaPointExcelVO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/vo/DaPointExcelVO.java index bb08cac..80040d0 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/vo/DaPointExcelVO.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/vo/DaPointExcelVO.java @@ -69,11 +69,15 @@ @ExcelProperty("数据源类型") private String sourceType; - @Schema(description = "数据源ID") - @ExcelProperty("数据源ID") - private String sourceId; + @Schema(description = "数据源名称") + @ExcelProperty("数据源名称") + private String sourceName; @Schema(description = "测点Tag") @ExcelProperty("测点Tag") private String tagNo; + + @Schema(description = "计算公式") + @ExcelProperty("计算公式") + private String expression; } \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/point/DaPointDao.xml b/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/point/DaPointDao.xml index c1b5099..976c199 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/point/DaPointDao.xml +++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/point/DaPointDao.xml @@ -68,6 +68,71 @@ order by t1.create_time desc </select> + <select id="getList" resultType="com.iailab.module.data.point.dto.DaPointDTO"> + select + t1.id, + t1.point_no, + t1.point_name, + t1.point_type , + t1.data_type, + t1.unit, + t1.unittransfactor, + t1.default_value, + t1.max_value, + t1.min_value, + t1.minfreqid, + t1.remark, + t1.is_enable, + t1.creator, + t1.create_time, + t1.updater, + t1.update_time, + t2.source_type, + t3.source_name, + t2.tag_no, + t2.dimension, + t2.value_type + from t_da_point t1 + left join t_da_measure_point t2 on t2.point_id = t1.id + left join ( + select id source_id,server_name source_name + from t_channel_opcua_device + union + select id source_id, name source_name + from t_channel_modbus_device + union + select id source_id, code source_name + from t_http_api + union + select id source_id, instance_name source_name + from t_channel_kio_device + ) t3 on t3.source_id = t2.source_id + <where> + <if test="pointNo != null and pointNo != ''"> + and t1.point_no like concat('%', #{pointNo}, '%') + </if> + <if test="pointName != null and pointName != ''"> + and t1.point_name like concat('%', #{pointName}, '%') + </if> + <if test="pointType != null and pointType != ''"> + and t1.point_type = #{pointType} + </if> + <if test="dataType != null and dataType != ''"> + and t1.data_type = #{dataType} + </if> + <if test="sourceName != null and sourceName != ''"> + and t3.source_name like concat('%', #{sourceName}, '%') + </if> + <if test="tagNo != null and tagNo != ''"> + and t2.tag_no like concat('%', #{tagNo}, '%') + </if> + <if test="isEnable != null "> + and t1.is_enable = #{isEnable} + </if> + </where> + order by t1.create_time desc + </select> + <select id="getConstantPoint" resultType="com.iailab.module.data.point.dto.DaPointDTO"> SELECT t1.point_no, @@ -145,6 +210,7 @@ </if> </where> </select> + <select id="getMathPoint" resultType="com.iailab.module.data.point.dto.DaPointDTO"> SELECT t1.point_no, -- Gitblit v1.9.3