iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpApiController.java
@@ -22,7 +22,7 @@ * @createTime 2024年08月27日 */ @RestController @RequestMapping("/data/http/api") @RequestMapping("/data/channel/http/api") public class HttpApiController { @Resource iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/controller/admin/DaPointController.java
@@ -1,37 +1,32 @@ package com.iailab.module.data.point.controller.admin; import com.iailab.framework.common.constant.Constant; import com.iailab.framework.common.page.PageData; import com.iailab.framework.common.pojo.CommonResult; import com.iailab.framework.common.util.validation.ValidationUtils; import com.iailab.framework.common.validation.group.AddGroup; import com.iailab.framework.common.validation.group.UpdateGroup; import com.iailab.framework.common.validation.group.DefaultGroup; import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.util.object.BeanUtils; import com.iailab.module.data.point.dto.DaPointDTO; import com.iailab.module.data.point.entity.DaPointEntity; import com.iailab.module.data.point.service.DaPointService; import com.iailab.module.data.point.vo.DaPointPageReqVO; import com.iailab.module.data.point.vo.DaPointRespVO; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; import javax.annotation.Resource; import javax.annotation.security.PermitAll; import javax.validation.Valid; 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 javax.annotation.Resource; import javax.validation.Valid; import java.util.List; import java.util.Map; import java.util.UUID; import static com.iailab.framework.common.pojo.CommonResult.success; /** * @author PanZhibao * @author lirm * @Description * @createTime 2024年05月12日 * @createTime 2024年09月2日 */ @Tag(name = "数据采集,测点") @RestController @@ -43,66 +38,42 @@ private DaPointService daPointService; @GetMapping("page") @Operation(summary = "分页") @Parameters({ @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") }) @PreAuthorize("@ss.hasPermission('data:point:query')") public CommonResult<PageData<DaPointDTO>> page(@RequestParam Map<String, Object> params){ PageData<DaPointDTO> page = daPointService.page(params); return success(page); } @GetMapping("{id}") @Operation(summary = "信息") @PreAuthorize("@ss.hasPermission('data:point:query')") public CommonResult<DaPointDTO> get(@PathVariable("id") String id){ DaPointDTO data = daPointService.get(id); return new CommonResult<DaPointDTO>().setData(data); public CommonResult<PageResult<DaPointRespVO>> page(@Valid DaPointPageReqVO reqVO){ PageResult<DaPointEntity> page = daPointService.queryPage(reqVO); return success(BeanUtils.toBean(page, DaPointRespVO.class)); } @GetMapping("/list") @Operation(summary = "列表") @PreAuthorize("@ss.hasPermission('data:point:query')") public CommonResult<List<DaPointDTO>> list(@Valid @RequestParam Map<String, Object> params) { List<DaPointDTO> list = daPointService.list(params); return success(list); } @PostMapping @Operation(summary = "保存") @PreAuthorize("@ss.hasPermission('data:point:save')") public CommonResult save(@RequestBody DaPointDTO dto){ //效验数据 ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); daPointService.add(dto); return new CommonResult(); @GetMapping("/info/{id}") public CommonResult<DaPointDTO> info(@PathVariable("id") String id){ DaPointDTO info= daPointService.info(id); return success(info); } @PutMapping @Operation(summary = "修改") @PreAuthorize("@ss.hasPermission('data:point:update')") public CommonResult update(@RequestBody DaPointDTO dto){ //效验数据 ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); daPointService.update(dto); return new CommonResult(); @PostMapping("/add") public CommonResult<Boolean> add(@RequestBody DaPointDTO daPointDTO){ String id = UUID.randomUUID().toString(); daPointDTO.setId(id); daPointService.add(daPointDTO); return success(true); } @DeleteMapping @Operation(summary = "删除") @PreAuthorize("@ss.hasPermission('data:point:delete')") public CommonResult delete(@RequestBody String[] ids){ @PutMapping("/update") public CommonResult<Boolean> update(@RequestBody DaPointDTO daPointDTO) { daPointService.update(daPointDTO); return success(true); } @DeleteMapping("/delete") public CommonResult<Boolean> delete(String[] ids) { daPointService.delete(ids); return new CommonResult(); return success(true); } @GetMapping("pointNo") @@ -115,17 +86,17 @@ @PutMapping("/enable") @Operation(summary = "启用") @Transactional public CommonResult enable(@RequestBody String[] ids) { public CommonResult<Boolean> enable(@RequestBody String[] ids) { daPointService.enableByIds(ids); return new CommonResult(); return success(true); } @PutMapping("/disable") @Operation(summary = "禁用") @Transactional public CommonResult disable(@RequestBody String[] ids) { public CommonResult<Boolean> disable(@RequestBody String[] ids) { daPointService.disableByIds(ids); return new CommonResult(); return success(true); } } iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaPointDao.java
@@ -1,10 +1,13 @@ package com.iailab.module.data.point.dao; import com.baomidou.mybatisplus.core.metadata.IPage; import com.iailab.framework.common.dao.BaseDao; import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.mybatis.core.mapper.BaseMapperX; import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX; import com.iailab.framework.tenant.core.db.dynamic.TenantDS; import com.iailab.module.data.point.dto.DaPointDTO; import com.iailab.module.data.point.entity.DaPointEntity; import com.iailab.module.data.point.vo.DaPointPageReqVO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -12,13 +15,13 @@ import java.util.Map; /** * @author PanZhibao * @author lirm * @Description * @createTime 2022年07月12日 13:47:00 * @createTime 2024年09月2日 */ @TenantDS @Mapper public interface DaPointDao extends BaseDao<DaPointEntity> { public interface DaPointDao extends BaseMapperX<DaPointEntity> { IPage<DaPointDTO> getPageList(IPage<DaPointEntity> page, @Param("params") Map<String, Object> params); @@ -27,4 +30,11 @@ List<DaPointDTO> getMeasurePoint(Map<String, Object> params); List<DaPointDTO> getMathPoint(Map<String, Object> params); default PageResult<DaPointEntity> selectPage(DaPointPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX<DaPointEntity>() .likeIfPresent(DaPointEntity::getPointNo, reqVO.getPointNo()) .likeIfPresent(DaPointEntity::getPointName, reqVO.getPointName()) .orderByDesc(DaPointEntity::getCreateTime)); } } iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaPointService.java
@@ -1,31 +1,31 @@ package com.iailab.module.data.point.service; import com.iailab.framework.common.page.PageData; import com.iailab.framework.common.service.BaseService; import com.iailab.framework.common.pojo.PageResult; import com.iailab.module.data.point.dto.DaPointDTO; import com.iailab.module.data.point.entity.DaPointEntity; import com.iailab.module.data.point.vo.DaPointPageReqVO; import java.util.List; import java.util.Map; /** * @author PanZhibao * @author lirm * @Description * @createTime 2024年05月12日 * @createTime 2024年09月2日 */ public interface DaPointService extends BaseService<DaPointEntity> { public interface DaPointService{ PageResult<DaPointEntity> queryPage(DaPointPageReqVO reqVO); PageData<DaPointDTO> page(Map<String, Object> params); DaPointDTO info(String id); DaPointDTO get(String id); void add(DaPointDTO daPointDTO); void update(DaPointDTO daPointDTO); void delete(String[] id); List<DaPointDTO> list(Map<String, Object> params); void add(DaPointDTO dataPoint); void update(DaPointDTO dataPoint); void delete(String[] ids); List<DaPointDTO> getConstantPoint(String freq); @@ -50,4 +50,5 @@ void disableByIds(String[] ids); void updateDefaultValue(DaPointDTO dto); } iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java
@@ -2,38 +2,37 @@ import com.alibaba.fastjson.JSONArray; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.iailab.framework.common.constant.Constant; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.util.object.ConvertUtils; import com.iailab.module.data.common.enums.CommonConstant; import com.iailab.module.data.common.enums.IsEnableEnum; import com.iailab.framework.common.page.PageData; import com.iailab.framework.common.service.impl.BaseServiceImpl; import com.iailab.framework.common.util.object.ConvertUtils; import com.iailab.module.data.point.common.IncreaseCodeEnum; import com.iailab.module.data.point.dao.DaPointDao; import com.iailab.module.data.point.service.DaMeasurePointService; import com.iailab.module.data.point.common.PointTypeEnum; import com.iailab.module.data.point.dao.DaPointDao; import com.iailab.module.data.point.dto.DaMeasurePointDTO; import com.iailab.module.data.point.dto.DaPointDTO; import com.iailab.module.data.point.entity.DaPointEntity; import com.iailab.module.data.point.service.DaMathPointService; import com.iailab.module.data.point.service.DaMeasurePointService; import com.iailab.module.data.point.service.DaPointService; import com.iailab.module.data.point.service.DaSequenceNumService; import com.iailab.module.data.point.vo.DaPointPageReqVO; import org.apache.commons.lang3.StringUtils; import javax.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.util.*; /** * @author PanZhibao * @author lirm * @Description * @createTime 2024年05月12日 * @createTime 2024年09月2日 */ @Service public class DaPointServiceImpl extends BaseServiceImpl<DaPointDao, DaPointEntity> implements DaPointService { public class DaPointServiceImpl extends ServiceImpl<DaPointDao, DaPointEntity> implements DaPointService { @Resource private DaMeasurePointService daMeasurePointService; @@ -44,18 +43,18 @@ @Resource private DaSequenceNumService daSequenceNumService; @Resource private DaPointDao daPointDao; @Override public PageData<DaPointDTO> page(Map<String, Object> params) { IPage<DaPointDTO> page = baseDao.getPageList( getPage(params, Constant.CREATE_TIME, false), params ); return getPageData(page, DaPointDTO.class); public PageResult<DaPointEntity> queryPage(DaPointPageReqVO reqVO) { return daPointDao.selectPage(reqVO); } @Override public DaPointDTO get(String id) { DaPointEntity entity = baseDao.selectById(id); public DaPointDTO info(String id) { DaPointEntity entity = daPointDao.selectById(id); DaPointDTO result = ConvertUtils.sourceToTarget(entity, DaPointDTO.class); if (PointTypeEnum.MEASURE_POINT.getCode().equals(result.getPointType())) { DaMeasurePointDTO measurePoint = daMeasurePointService.getByPoint(id); @@ -86,7 +85,7 @@ .in(!CollectionUtils.isEmpty(pointNos),"point_no", pointNos) .like(StringUtils.isNotBlank(pointNoLike), "point_no", pointNoLike) .last("limit 1, 10"); List<DaPointEntity> list = baseDao.selectList(queryWrapper); List<DaPointEntity> list = daPointDao.selectList(queryWrapper); return ConvertUtils.sourceToTarget(list, DaPointDTO.class); } @@ -110,7 +109,7 @@ } daPointEntity.setIsEnable(CommonConstant.IS_ENABLE); daPointEntity.setCreateTime(new Date()); baseDao.insert(daPointEntity); daPointDao.insert(daPointEntity); } @Override @@ -118,7 +117,7 @@ public void update(DaPointDTO dataPoint) { DaPointEntity daPointEntity = ConvertUtils.sourceToTarget(dataPoint, DaPointEntity.class); daPointEntity.setUpdateTime(new Date()); baseDao.updateById(daPointEntity); daPointDao.updateById(daPointEntity); if (PointTypeEnum.MEASURE_POINT.getName().equals(dataPoint.getPointType())) { DaMeasurePointDTO measurePoint = dataPoint.getMeasurePoint(); measurePoint.setSourceType(dataPoint.getSourceOption().get(0)); @@ -133,7 +132,7 @@ @Override @Transactional(rollbackFor = Exception.class) public void delete(String[] ids) { baseDao.deleteBatchIds(Arrays.asList(ids)); daPointDao.deleteBatchIds(Arrays.asList(ids)); daMeasurePointService.deleteByPoint(ids); daMathPointService.deleteByPoint(ids); } @@ -144,7 +143,7 @@ params.put("pointType", PointTypeEnum.CONSTANT.getCode()); params.put("isEnable", CommonConstant.IS_ENABLE); params.put("minfreqid", freq); return baseDao.getConstantPoint(params); return daPointDao.getConstantPoint(params); } @Override @@ -153,7 +152,7 @@ params.put("pointType", PointTypeEnum.CONSTANT.getCode()); params.put("isEnable", CommonConstant.IS_ENABLE); params.put("pointNos", pointNos); return baseDao.getConstantPoint(params); return daPointDao.getConstantPoint(params); } @Override @@ -162,7 +161,7 @@ params.put("pointType", PointTypeEnum.MEASURE_POINT.getCode()); params.put("isEnable", CommonConstant.IS_ENABLE); params.put("minfreqid", freq); return baseDao.getMeasurePoint(params); return daPointDao.getMeasurePoint(params); } @Override @@ -171,7 +170,7 @@ params.put("pointType", PointTypeEnum.MEASURE_POINT.getCode()); params.put("isEnable", CommonConstant.IS_ENABLE); params.put("pointNos", pointNos); return baseDao.getMeasurePoint(params); return daPointDao.getMeasurePoint(params); } @Override @@ -179,7 +178,7 @@ Map<String, Object> params = new HashMap<>(); params.put("pointType", PointTypeEnum.MEASURE_POINT.getCode()); params.put("pointNo", pointNo); List<DaPointDTO> list = baseDao.getMeasurePoint(params); List<DaPointDTO> list = daPointDao.getMeasurePoint(params); if (CollectionUtils.isEmpty(list)) { return null; } @@ -192,7 +191,7 @@ params.put("pointType", PointTypeEnum.CALCULATE_POINT.getCode()); params.put("isEnable", CommonConstant.IS_ENABLE); params.put("minfreqid", freq); return baseDao.getMathPoint(params); return daPointDao.getMathPoint(params); } @Override @@ -201,14 +200,14 @@ params.put("pointType", PointTypeEnum.CALCULATE_POINT.getCode()); params.put("isEnable", CommonConstant.IS_ENABLE); params.put("pointNos", pointNos); return baseDao.getMathPoint(params); return daPointDao.getMathPoint(params); } @Override public DaPointDTO getByNo(String pointNo) { QueryWrapper<DaPointEntity> wrapper = new QueryWrapper<>(); wrapper.eq("point_no", pointNo); DaPointEntity entity = baseDao.selectOne(wrapper); DaPointEntity entity = daPointDao.selectOne(wrapper); return ConvertUtils.sourceToTarget(entity, DaPointDTO.class); } @@ -216,7 +215,7 @@ public List<DaPointDTO> getByNos(List<String> pointNos) { QueryWrapper<DaPointEntity> wrapper = new QueryWrapper<>(); wrapper.in("point_no", pointNos); List<DaPointEntity> list = baseDao.selectList(wrapper); List<DaPointEntity> list = daPointDao.selectList(wrapper); return ConvertUtils.sourceToTarget(list, DaPointDTO.class); } @@ -226,7 +225,7 @@ wrapper.eq("point_no", dto.getPointNo()); DaPointEntity entity = new DaPointEntity(); entity.setDefaultValue(dto.getDefaultValue()); baseDao.update(entity, wrapper); daPointDao.update(entity, wrapper); } @Override @@ -238,7 +237,7 @@ DaPointEntity entity = new DaPointEntity(); entity.setId(item); entity.setIsEnable(IsEnableEnum.ENABLE.value()); baseDao.updateById(entity); daPointDao.updateById(entity); }); } @@ -251,7 +250,7 @@ DaPointEntity entity = new DaPointEntity(); entity.setId(item); entity.setIsEnable(IsEnableEnum.DISABLE.value()); baseDao.updateById(entity); daPointDao.updateById(entity); }); } }