| | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Author liurunyu |
| | |
| | | * @return |
| | | */ |
| | | PrControllerTramp getTrampControllerInfo(@Param("controllerId") Long controllerId); |
| | | |
| | | /** |
| | | * 条件查询流浪控制器信息 |
| | | * @param |
| | | * @return |
| | | */ |
| | | List<PrControllerTramp> getTrampControllers(Map<?, ?> params); |
| | | /** |
| | | * 条件查询流浪控制器数量 |
| | | * @param |
| | | * @return recordCount |
| | | */ |
| | | Long getTrampControllersCount(Map<?, ?> params); |
| | | } |
| | |
| | | * 发现时间 |
| | | */ |
| | | @Schema(description = "发现时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "发现时间不能为空") |
| | | // @NotNull(message = "发现时间不能为空") |
| | | public Date findDt;//发现时间( yyyy-mm-dd HH:MM:SS) |
| | | |
| | | } |
| | |
| | | </sql> |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | | <!--@mbg.generated--> |
| | | select |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from pr_controller_tramp |
| | | where id = #{id,jdbcType=BIGINT} |
| | |
| | | </delete> |
| | | <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoPr.PrControllerTramp"> |
| | | <!--@mbg.generated--> |
| | | insert into pr_controller_tramp (id, rtuAddr, protocol, |
| | | insert into pr_controller_tramp (id, rtuAddr, protocol, |
| | | findDt) |
| | | values (#{id,jdbcType=BIGINT}, #{rtuAddr,jdbcType=VARCHAR}, #{protocol,jdbcType=VARCHAR}, |
| | | #{findDt,jdbcType=TIMESTAMP}) |
| | |
| | | <select id="getTrampControllerInfo" resultMap="BaseResultMap"> |
| | | SELECT rtuAddr, protocol, findDt FROM pr_controller_tramp WHERE id = ${controllerId} |
| | | </select> |
| | | |
| | | <!-- 根据条件获取流浪控制器信息--> |
| | | <select id="getTrampControllers" resultMap="BaseResultMap"> |
| | | select CAST(id AS char)AS id, |
| | | rtuAddr, |
| | | protocol, |
| | | findDt |
| | | FROM pr_controller_tramp |
| | | <where> |
| | | <if test="id != null and id !=''"> |
| | | id = #{id,jdbcType=VARCHAR} |
| | | </if> |
| | | <if test="rtuAddr != null and rtuAddr != ''"> |
| | | AND rtuAddr = #{rtuAddr,jdbcType=VARCHAR} |
| | | </if> |
| | | <if test="protocol != null and protocol != ''"> |
| | | AND protocol = #{protocol,jdbcType=VARCHAR} |
| | | </if> |
| | | |
| | | </where> |
| | | </select> |
| | | <!-- 根据条件获取流浪控制器数量--> |
| | | <select id="getTrampControllersCount" resultType="java.lang.Long"> |
| | | select |
| | | COUNT(*) AS recordCount |
| | | FROM pr_controller_tramp |
| | | <where> |
| | | <if test="id != null and id !=''"> |
| | | id = #{id,jdbcType=VARCHAR} |
| | | </if> |
| | | <if test="rtuAddr != null and rtuAddr != ''"> |
| | | AND rtuAddr = #{rtuAddr,jdbcType=VARCHAR} |
| | | </if> |
| | | <if test="protocol != null and protocol != ''"> |
| | | AND protocol = #{protocol,jdbcType=VARCHAR} |
| | | </if> |
| | | |
| | | </where> |
| | | </select> |
| | | </mapper> |
| | |
| | | package com.dy.pipIrrProject.intakeController; |
| | | |
| | | |
| | | import cn.hutool.core.date.DateTime; |
| | | import com.dy.common.aop.SsoAop; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据指定条件获取流浪控制器列表 |
| | | * |
| | | * @param vo 查询条件 |
| | | * @return 符合条件的控制器列表 |
| | | */ |
| | | @Operation(summary = "获得一页流浪控制器记录", description = "返回一页流浪控制器数据") |
| | | @ApiResponses(value = { |
| | | @ApiResponse( |
| | | responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, |
| | | description = "返回一页流浪控制器数据(BaseResponse.content:QueryResultVo[{}])", |
| | | content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, |
| | | schema = @Schema(implementation = PrControllerTramp.class))} |
| | | ) |
| | | }) |
| | | @GetMapping(path = "/getTrampControllers") |
| | | @SsoAop() |
| | | public BaseResponse<QueryResultVo<List<PrControllerTramp>>> getTrampControllers(TrampControllerQueryVo vo) { |
| | | |
| | | try { |
| | | QueryResultVo<List<PrControllerTramp>> res = intakeControllerSv.getTrampControllers(vo); |
| | | if (res.itemTotal != null && res.itemTotal > 0) { |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | } else { |
| | | //请求成功但数据为空 |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | } |
| | | //return BaseResponseUtils.buildSuccess(res); |
| | | } catch (Exception e) { |
| | | log.error("获取流浪控制器记录异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加流浪控制器 |
| | | * @param pct |
| | | * @return |
| | | */ |
| | | @PostMapping("addTrampController") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> addTrampController(@RequestBody PrControllerTramp pct){ |
| | | pct.setFindDt(new Date()); |
| | | Integer rows = intakeControllerSv.addTrampController(pct); |
| | | if (rows == 0) { |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.ADD_TRAMP_CONTROLLER_FAIL.getMessage()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess(true); |
| | | } |
| | | |
| | | /** |
| | | * 删除流浪控制器 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @PostMapping("deleteTrampController") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> deleteTrampController(Long id){ |
| | | PrControllerTramp controllerInfo = intakeControllerSv.getTrampControllerInfo(id); |
| | | if (controllerInfo==null){return BaseResponseUtils.buildFail(ProjectResultCode.NO_EXIST_TRAMP_CONTROLLER.getMessage());} |
| | | |
| | | Integer rows = intakeControllerSv.deleteTrampController(id); |
| | | if (rows == 0) { |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.DELETE_TRAMP_CONTROLLER_FAIL.getMessage()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess(true); |
| | | } |
| | | } |
| | |
| | | package com.dy.pipIrrProject.intakeController; |
| | | |
| | | import cn.hutool.core.date.DateTime; |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pipIrrGlobal.daoPr.PrControllerTrampMapper; |
| | | import com.dy.pipIrrGlobal.daoPr.PrIntakeControllerMapper; |
| | | import com.dy.pipIrrGlobal.pojoPr.PrControllerTramp; |
| | | import com.dy.pipIrrGlobal.pojoPr.PrIntakeController; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.dubbo.common.utils.PojoUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | public Integer deleteTrampController(Long controllerId) { |
| | | return prControllerTrampMapper.deleteByPrimaryKey(controllerId); |
| | | } |
| | | |
| | | //增 |
| | | public Integer addTrampController(PrControllerTramp record){ |
| | | return prControllerTrampMapper.insertSelective(record); |
| | | } |
| | | |
| | | |
| | | /*查*/ |
| | | public QueryResultVo<List<PrControllerTramp>> getTrampControllers(TrampControllerQueryVo queryVo){ |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); |
| | | |
| | | Long itemTotal = prControllerTrampMapper.getTrampControllersCount(params); |
| | | |
| | | QueryResultVo<List<PrControllerTramp>> rsVo = new QueryResultVo<>(); |
| | | rsVo.pageSize = queryVo.pageSize; |
| | | rsVo.pageCurr = queryVo.pageCurr; |
| | | |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | rsVo.obj = prControllerTrampMapper.getTrampControllers(params); |
| | | |
| | | return rsVo; |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrProject.intakeController; |
| | | |
| | | import com.dy.common.webUtil.QueryConditionVo; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.*; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author :WuZeYu |
| | | * @Date :2024/5/8 14:16 |
| | | * @LastEditTime :2024/5/8 14:16 |
| | | * @Description |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ToString(callSuper = true) |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | @Builder |
| | | @Schema(name = "流浪控制器查询条件") |
| | | public class TrampControllerQueryVo extends QueryConditionVo { |
| | | |
| | | @Schema(description = "流浪控制器ID") |
| | | private String id; |
| | | |
| | | @Schema(description = "控制器地址") |
| | | private String rtuAddr; |
| | | |
| | | @Schema(description = "通讯协议") |
| | | public String protocol; |
| | | |
| | | |
| | | } |
| | |
| | | NO_RECORDS(30002, "没有符合条件的控制器数据"), |
| | | PLEASE_INPUT_CONTROLLER_ID(30003, "请输入控制器编号"), |
| | | DELETE_CONTROLLER_FAIL(30004, "控制器删除失败"), |
| | | |
| | | /** |
| | | * 流浪控制器 |
| | | */ |
| | | ADD_TRAMP_CONTROLLER_FAIL(80001, "流浪控制器添加失败"), |
| | | DELETE_TRAMP_CONTROLLER_FAIL(80002, "流浪控制器删除失败"), |
| | | NO_EXIST_TRAMP_CONTROLLER(80003, "该流浪控制器不存在"), |
| | | /** |
| | | * 取水口、控制器关联 |
| | | */ |