Browse Source

优化

platform-api
yx 2 years ago
parent
commit
44e10228a6
  1. 9
      ruoyi-api/src/main/java/com/ruoyi/api/app/WaterDataApiController.java
  2. 3
      ruoyi-api/src/main/java/com/ruoyi/api/params/WaterDataParams.java
  3. 46
      ruoyi-api/src/main/java/com/ruoyi/api/service/WaterDataApiService.java
  4. 102
      ruoyi-code/src/main/java/com/ruoyi/code/scwaterdata/controller/ScWaterDataController.java
  5. 43
      ruoyi-code/src/main/java/com/ruoyi/code/scwaterdata/domain/ScWaterData.java
  6. 17
      ruoyi-code/src/main/java/com/ruoyi/code/scwaterdata/mapper/ScWaterDataMapper.java
  7. 21
      ruoyi-code/src/main/java/com/ruoyi/code/scwaterdata/service/IScWaterDataService.java
  8. 33
      ruoyi-code/src/main/java/com/ruoyi/code/scwaterdata/service/impl/ScWaterDataServiceImpl.java
  9. 3
      ruoyi-code/src/main/resources/mapper/scWaterData/ScWaterDataMapper.xml

9
ruoyi-api/src/main/java/com/ruoyi/api/app/WaterDataApiController.java

@ -2,6 +2,7 @@ package com.ruoyi.api.app;
import com.ruoyi.api.controller.AbstractApiController; import com.ruoyi.api.controller.AbstractApiController;
import com.ruoyi.api.params.WaterDataParams; import com.ruoyi.api.params.WaterDataParams;
import com.ruoyi.api.service.WaterDataApiService;
import com.ruoyi.common.core.page.R; import com.ruoyi.common.core.page.R;
import com.ruoyi.common.validator.ValidatorUtils; import com.ruoyi.common.validator.ValidatorUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -10,6 +11,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/** /**
* 系统对外接口-检测信息 * 系统对外接口-检测信息
@ -19,7 +22,8 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j @Slf4j
public class WaterDataApiController extends AbstractApiController { public class WaterDataApiController extends AbstractApiController {
@Resource
private WaterDataApiService waterDataApiService;
/** /**
* 水位数据查询 * 水位数据查询
* *
@ -30,8 +34,7 @@ public class WaterDataApiController extends AbstractApiController {
public R query(@RequestBody WaterDataParams params) { public R query(@RequestBody WaterDataParams params) {
log.info("[水位数据查询接口查询参数为{}]", params); log.info("[水位数据查询接口查询参数为{}]", params);
ValidatorUtils.validateV2(params); ValidatorUtils.validateV2(params);
System.out.println(params); return waterDataApiService.query(params,getMarketAuthDto());
return R.ok();
} }
} }

3
ruoyi-api/src/main/java/com/ruoyi/api/params/WaterDataParams.java

@ -3,12 +3,13 @@ package com.ruoyi.api.params;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal; import java.math.BigDecimal;
@Data @Data
public class WaterDataParams { public class WaterDataParams {
@NotBlank(message = "站点ID不能为空") @NotNull(message = "站点ID不能为空")
private Long stnmId; private Long stnmId;
@NotBlank(message = "开始时间不能为空") @NotBlank(message = "开始时间不能为空")

46
ruoyi-api/src/main/java/com/ruoyi/api/service/WaterDataApiService.java

@ -0,0 +1,46 @@
package com.ruoyi.api.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.api.dto.MarketAuthDto;
import com.ruoyi.api.dto.StationData;
import com.ruoyi.api.params.StationDataParams;
import com.ruoyi.api.params.WaterDataParams;
import com.ruoyi.code.sctaationinfo.domain.ScStationInfo;
import com.ruoyi.code.sctaationinfo.service.IScStationInfoService;
import com.ruoyi.code.scwaterdata.domain.ScWaterData;
import com.ruoyi.code.scwaterdata.service.IScWaterDataService;
import com.ruoyi.common.core.page.R;
import com.ruoyi.common.utils.ClassReflection;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
public class WaterDataApiService {
@Resource
private IScWaterDataService scWaterDataService;
public R query(WaterDataParams params, MarketAuthDto marketAuthDto) {
Long stnmId = params.getStnmId();
String startTime = params.getStartTime();
String endTime = params.getEndTime();
List<ScWaterData> list = scWaterDataService.list(
new QueryWrapper<ScWaterData>()
.in("stnm_id", marketAuthDto.getQueryList())
.eq("stnm_id", stnmId)
.between("tm",startTime,endTime)
);
return R.ok().put("data", list);
}
}

102
ruoyi-code/src/main/java/com/ruoyi/code/scwaterdata/controller/ScWaterDataController.java

@ -0,0 +1,102 @@
package com.ruoyi.code.scwaterdata.controller;
import java.util.List;
import java.util.Arrays;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import javax.annotation.Resource;
import com.ruoyi.common.core.page.R;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.code.scwaterdata.domain.ScWaterData;
import com.ruoyi.code.scwaterdata.service.IScWaterDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
/**
* 水尺-水位数据Controller
*
* @author ruoyi
* @date 2022-07-01
*/
@RestController
@RequestMapping("/system/data")
public class ScWaterDataController extends BaseController
{
@Resource
private IScWaterDataService scWaterDataService;
/**
* 查询列表
*/
@PreAuthorize("@ss.hasPermi('system:data:list')")
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params){
return scWaterDataService.queryPage(params);
}
/**
* 获取详细信息
*/
@RequestMapping("/info/{id}")
@PreAuthorize("@ss.hasPermi('system:data:query')")
public R info(@PathVariable("id") Long id){
ScWaterData scWaterData = scWaterDataService.getById(id);
return R.ok().put("data", scWaterData);
}
/**
* 导出列表
*/
@PreAuthorize("@ss.hasPermi('system:data:export')")
@Log(title = "列表", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ScWaterData scWaterData)
{
List<ScWaterData> list = scWaterDataService.list();
ExcelUtil<ScWaterData> util = new ExcelUtil<ScWaterData>(ScWaterData.class);
util.exportExcel(response, list, "列表数据");
}
/**
* 新增
*/
@RequestMapping("/add")
@Log(title = "ScWaterData", businessType = BusinessType.INSERT)
@PreAuthorize("@ss.hasPermi('system:data:add')")
public R add(@RequestBody ScWaterData scWaterData){
scWaterDataService.save(scWaterData);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/edit")
@PreAuthorize("@ss.hasPermi('system:data:edit')")
@Log(title = "ScWaterData", businessType = BusinessType.UPDATE)
public R edit(@RequestBody ScWaterData scWaterData){
scWaterDataService.updateById(scWaterData);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete/{ids}")
@PreAuthorize("@ss.hasPermi('system:data:remove')")
@Log(title = "ScWaterData", businessType = BusinessType.DELETE)
public R delete(@PathVariable Long[] ids){
scWaterDataService.removeByIds(Arrays.asList(ids));
return R.ok();
}
}

43
ruoyi-code/src/main/java/com/ruoyi/code/scwaterdata/domain/ScWaterData.java

@ -0,0 +1,43 @@
package com.ruoyi.code.scwaterdata.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import lombok.Data;
/**
* 水尺-水位数据对象 sc_water_data
*
* @author ruoyi
* @date 2022-07-01
*/
@Data
@TableName("sc_water_data")
public class ScWaterData implements Serializable
{
private static final long serialVersionUID = 1L;
/** 主键自增 */
@TableId(type = IdType.INPUT)
private Long id;
/** 测站ID */
private Long stnmId;
/** 时间 */
private Date tm;
/** 水位值 */
private BigDecimal value;
/** 图片名称 */
private String imgName;
}

17
ruoyi-code/src/main/java/com/ruoyi/code/scwaterdata/mapper/ScWaterDataMapper.java

@ -0,0 +1,17 @@
package com.ruoyi.code.scwaterdata.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import com.ruoyi.code.scwaterdata.domain.ScWaterData;
/**
* Mapper接口
*
* @author ruoyi
* @date 2022-07-01
*/
@Mapper
public interface ScWaterDataMapper extends BaseMapper<ScWaterData>
{
}

21
ruoyi-code/src/main/java/com/ruoyi/code/scwaterdata/service/IScWaterDataService.java

@ -0,0 +1,21 @@
package com.ruoyi.code.scwaterdata.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.core.page.R;
import java.util.Map;
import com.ruoyi.code.scwaterdata.domain.ScWaterData;
/**
* Service接口
*
* @author ruoyi
* @date 2022-07-01
*/
public interface IScWaterDataService extends IService<ScWaterData>
{
/**
* 查询
*/
R queryPage(Map<String, Object> params);
}

33
ruoyi-code/src/main/java/com/ruoyi/code/scwaterdata/service/impl/ScWaterDataServiceImpl.java

@ -0,0 +1,33 @@
package com.ruoyi.code.scwaterdata.service.impl;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.page.R;
import com.ruoyi.common.utils.Query;
import org.springframework.stereotype.Service;
import com.ruoyi.code.scwaterdata.mapper.ScWaterDataMapper;
import com.ruoyi.code.scwaterdata.domain.ScWaterData;
import com.ruoyi.code.scwaterdata.service.IScWaterDataService;
/**
* Service业务层处理
*
* @author ruoyi
* @date 2022-07-01
*/
@Service("scWaterDataService")
public class ScWaterDataServiceImpl extends ServiceImpl<ScWaterDataMapper, ScWaterData> implements IScWaterDataService
{
@Override
public R queryPage(Map<String, Object> params) {
IPage<ScWaterData> page = this.page(
new Query<ScWaterData>().getPage(params),
new QueryWrapper<ScWaterData>()
);
return R.ok().put("count", page.getTotal()).put("data", page.getRecords());
}
}

3
ruoyi-code/src/main/resources/mapper/camera/ScStationInfoMapper.xml → ruoyi-code/src/main/resources/mapper/scWaterData/ScWaterDataMapper.xml

@ -2,7 +2,6 @@
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.code.camera.mapper.ScStationInfoMapper"> <mapper namespace="com.ruoyi.code.scwaterdata.mapper.ScWaterDataMapper">
</mapper> </mapper>
Loading…
Cancel
Save