Bladeren bron

十防台账查询代码部分(视图待完善)

wuhonghao 4 jaren geleden
bovenliggende
commit
beafaca300

+ 40 - 0
railway-admin/src/main/java/com/railway/web/controller/business/baseinfo/BusPreventController.java

@@ -1,12 +1,24 @@
 package com.railway.web.controller.business.baseinfo;
 
 
+import com.github.pagehelper.Page;
+import com.railway.business.baseinfo.domain.BusPrevent;
+import com.railway.business.baseinfo.domain.BusSdtz;
+import com.railway.business.baseinfo.domain.BusZzdzxx;
+import com.railway.business.baseinfo.service.IBusLineService;
+import com.railway.business.baseinfo.service.IBusPreventService;
+import com.railway.business.baseinfo.service.IBusZzdzxxService;
 import com.railway.common.core.controller.BaseController;
+import com.railway.common.core.page.TableDataInfo;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+
 /**
  * @author wuhonghao
  */
@@ -16,6 +28,34 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping(value = "business/catenary/bus/prevent")
 public class BusPreventController extends BaseController {
 
+    private final IBusPreventService busPreventService;
+    private final IBusZzdzxxService busZzdzxxService;
+
+    public BusPreventController(IBusPreventService busPreventService,IBusZzdzxxService busZzdzxxService) {
+        this.busPreventService = busPreventService;
+        this.busZzdzxxService = busZzdzxxService;
+    }
+
+    @ApiOperation(value = "智能查询")
+    @GetMapping(value = "smartQuery")
+    public TableDataInfo smartQuery(BusPrevent busPrevent) {
+        //如果传入查询条件为支柱号则将支柱号转化为公里标
+        if(busPrevent.getPillarCode()!=null){
+            BusZzdzxx busZzdzxx = new BusZzdzxx();
+            busZzdzxx.setPillarCode(busPrevent.getPillarCode());
+            busZzdzxx.setXingbie(busPrevent.getXingbie());
+            busZzdzxx.setStationId(busPrevent.getStationId());
+            List<BusZzdzxx> list = busZzdzxxService.getList(busZzdzxx);
+            if(list!=null&&list.size()==1){
+                busPrevent.setMarker(list.get(0).getMarker());
+            }else{
+                return null;
+            }
+        }
 
+        startPage();
+        List<BusPrevent> list = busPreventService.smartQuery(busPrevent);
+        return getDataTable(list);
+    }
 
 }

+ 11 - 4
railway-business/src/main/java/com/railway/business/baseinfo/domain/BusPrevent.java

@@ -1,15 +1,19 @@
 package com.railway.business.baseinfo.domain;
 
+import com.railway.common.core.domain.BaseEntity;
+import com.sun.org.apache.xpath.internal.objects.XString;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import lombok.EqualsAndHashCode;
 
 /**
  * @author wuhonghao
  */
 @Data
 @ApiModel("十防台账")
-public class BusPrevent {
+@EqualsAndHashCode(callSuper = true)
+public class BusPrevent extends BaseEntity {
 
     @ApiModelProperty(value = "主键", hidden = true)
     private String preventId;
@@ -27,16 +31,19 @@ public class BusPrevent {
     private String stationId;
 
     @ApiModelProperty(value = "支柱号")
-    private String pillar_code;
+    private String pillarCode;
 
     @ApiModelProperty(value = "台账类别")
-    private String record_type;
+    private String recordType;
+
+    @ApiModelProperty(value = "支柱范围")
+    private String pillarArea;
 
     @ApiModelProperty(value = "公里标")
     private String marker;
 
     @ApiModelProperty(value = "风险源")
-    private String risk_source;
+    private String riskSource;
 
     @ApiModelProperty(value = "采取措施")
     private String measures;

+ 22 - 0
railway-business/src/main/java/com/railway/business/baseinfo/mapper/BusPreventMapper.java

@@ -0,0 +1,22 @@
+package com.railway.business.baseinfo.mapper;
+
+import com.github.pagehelper.Page;
+import com.railway.business.baseinfo.domain.BusPrevent;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+/**
+* 智能查询-十防台账
+* @author wuhonghao
+* @date 2021/11/19
+*/
+@Mapper
+@Repository
+public interface BusPreventMapper {
+
+    /**
+    * 智能查询
+    */
+    Page<BusPrevent> smartQuery(BusPrevent busPrevent);
+
+}

+ 22 - 0
railway-business/src/main/java/com/railway/business/baseinfo/service/IBusPreventService.java

@@ -0,0 +1,22 @@
+package com.railway.business.baseinfo.service;
+
+import com.github.pagehelper.Page;
+import com.railway.business.baseinfo.domain.BusBlq;
+import com.railway.business.baseinfo.domain.BusPrevent;
+
+import java.util.List;
+
+/**
+ * 智能查询-十防台账
+ * @author wuhonghao
+ * @date 2021/11/19
+ */
+public interface IBusPreventService {
+
+
+    /**
+    * 智能查询
+    */
+    List<BusPrevent> smartQuery(BusPrevent busPrevent);
+
+}

+ 39 - 0
railway-business/src/main/java/com/railway/business/baseinfo/service/impl/BusPreventServiceImpl.java

@@ -0,0 +1,39 @@
+package com.railway.business.baseinfo.service.impl;
+
+import com.github.pagehelper.Page;
+import com.railway.business.baseinfo.domain.BusBlq;
+import com.railway.business.baseinfo.domain.BusPrevent;
+import com.railway.business.baseinfo.domain.BusZzdzxx;
+import com.railway.business.baseinfo.mapper.BusBlqMapper;
+import com.railway.business.baseinfo.mapper.BusPreventMapper;
+import com.railway.business.baseinfo.mapper.BusZzdzxxMapper;
+import com.railway.business.baseinfo.service.IBusPreventService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 基础数据-避雷器
+ *
+ * @author wuhonghao
+ * @date 2021/10/17
+ */
+@Service
+@Transactional(readOnly = true)
+public class BusPreventServiceImpl implements IBusPreventService {
+
+  private final BusPreventMapper busPreventMapper;
+
+  public BusPreventServiceImpl(BusPreventMapper busPreventMapper) {
+    this.busPreventMapper = busPreventMapper;
+  }
+  /**
+   * 查询列表
+   */
+  @Override
+  public List<BusPrevent> smartQuery(BusPrevent busPrevent) {
+    return busPreventMapper.smartQuery(busPrevent);
+  }
+}

+ 63 - 0
railway-business/src/main/resources/mapper/baseinfo/BusPreventMapper.xml

@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+  "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.railway.business.baseinfo.mapper.BusPreventMapper">
+
+  <resultMap id="BaseResultMap" type="com.railway.business.baseinfo.domain.BusPrevent">
+    <result column="prevent_id" property="preventId"/>
+    <result column="line_id" property="lineId"/>
+    <result column="xingbie" property="xingbie"/>
+    <result column="station_id" property="stationId"/>
+    <result column="pillar_code" property="pillarCode"/>
+    <result column="record_type" property="recordType"/>
+    <result column="marker" property="marker"/>
+    <result column="risk_source" property="riskSource"/>
+    <result column="measures" property="measures"/>
+  </resultMap>
+
+  <sql id="Base_Column_List">
+    prevent_id,
+    line_id,
+    xingbie,
+    station_id,
+    pillar_code,
+    record_type,
+    marker,
+    risk_source,
+    measures
+  </sql>
+
+
+  <select id="smartQuery" resultMap="BaseResultMap">
+  SELECT
+    prevent_id,
+    line_id,
+    xingbie,
+    station_id,
+    pillar_code,
+    record_type,
+    marker,
+    risk_source,
+    measures
+  FROM
+  v_prevent v
+    <where>
+      <if test="lineId!=null and lineId!=''">
+        and v.line_id=#{lineId}
+      </if>
+      <if test="xingbie!=null and xingbie!=''">
+        and v.xingbie=#{xingbie}
+      </if>
+      <if test="stationId!=null and stationId!=''">
+        and v.station_id=#{stationId}
+      </if>
+      <if test="pillarCode!=null and pillarCode!=''">
+        and v.pillar_code=#{pillarCode}
+      </if>
+      <if test="marker != null and marker != ''">
+        AND (marker + 0.0) BETWEEN (#{marker} + 0.0) - (#{pillarArea} + 0.0) AND (#{marker} + 0.0) +
+        (#{pillarArea} + 0.0)
+      </if>
+    </where>
+  </select>
+</mapper>