فهرست منبع

转发点表批量删除

xusl 1 سال پیش
والد
کامیت
444c6fc448

+ 20 - 20
backend/src/main/java/com/jiayue/pfr/controller/di/ProtocolSenderDataPointController.java

@@ -98,10 +98,10 @@ public class ProtocolSenderDataPointController {
   }
 
 
-//  @GetMapping("/maxProtocolNoInTunnel")
-//  public ResponseVO getMaxProtocolNoInTunnel(String tunnelId) {
-//    return ResponseVO.success(protocolSenderDataPointService.getMaxProtocolNoInTunnel(tunnelId));
-//  }
+  @GetMapping("/maxProtocolNoInTunnel")
+  public SaResultRefit getMaxProtocolNoInTunnel(String tunnelId) {
+    return SaResultRefit.data(protocolSenderDataPointService.getMaxProtocolNoInTunnel(Integer.parseInt(tunnelId)));
+  }
 
   /**
    * 通过通道id查询转发点表
@@ -133,7 +133,7 @@ public class ProtocolSenderDataPointController {
   public SaResultRefit findByTunnelIdAndGatherPoint(@PathVariable("tunnelId") String tunnelId, @PathVariable("equipmentId") String equipmentId, @PathVariable("equipmentType") Integer equipmentType) {
     //TODO 代码不合理  需郑媛修改   方法所放置的类也不对   @CreateBy 修唯
     try {
-      List list = protocolSenderDataPointService.getPointByTunnelIdAndPointId(Integer.parseInt(tunnelId), equipmentId, equipmentType);
+      List list = protocolSenderDataPointService.getPointByTunnelIdAndPointId(tunnelId, equipmentId, equipmentType);
       return SaResultRefit.data(list);
     } catch (Exception e) {
       e.printStackTrace();
@@ -242,21 +242,21 @@ public class ProtocolSenderDataPointController {
     }
   }
 
-//  @DeleteMapping("/batchDeleteSenderDataPoint/{pointIds}")
-//  public ResponseVO batchDeleteGatherDataPoint(@PathVariable Integer[] pointIds) {
-//    try {
-//      for (int i = 0; i < pointIds.length; i++) {
-//        ProtocolSenderDataPoint point = new ProtocolSenderDataPoint();
-//        point.setId(pointIds[i]);
-//        protocolSenderDataPointService.deleteAll(point);
-//      }
-//      return ResponseVO.success(1);
-//    } catch (Exception e) {
-//      e.printStackTrace();
-//      log.error("批量删除异常");
-//      return ResponseVO.fail(e);
-//    }
-//  }
+  @DeleteMapping("/batchDeleteSenderDataPoint/{pointIds}")
+  public SaResultRefit batchDeleteGatherDataPoint(@PathVariable Integer[] pointIds) {
+    try {
+      for (int i = 0; i < pointIds.length; i++) {
+        ProtocolSenderDataPoint point = new ProtocolSenderDataPoint();
+        point.setId(pointIds[i]);
+        protocolSenderDataPointService.deleteAll(point);
+      }
+      return SaResultRefit.data(1);
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error("批量删除异常");
+      return SaResultRefit.errorTips("");
+    }
+  }
 
   /**
    * 手动置数

+ 4 - 2
backend/src/main/java/com/jiayue/pfr/mapper/di/ProtocolSenderDataPointMapper.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.jiayue.pfr.entity.ProtocolGatherDataPoint;
 import com.jiayue.pfr.entity.ProtocolSenderDataPoint;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
 
 import java.util.List;
 
@@ -28,6 +30,6 @@ public interface ProtocolSenderDataPointMapper extends BaseMapper<ProtocolSender
 //   * @param tunnelId 通道id
 //   * @return {@link Integer}
 //   */
-//  @Query(value = "SELECT max(protocolPointNo) FROM ProtocolSenderDataPoint where tunnelId= :tunnelId")
-//  Integer getMaxProtocolNoInTunnel(@Param("tunnelId") String tunnelId);
+  @Select(value = "SELECT max(protocol_point_no) FROM t_protocol_sender_data_point where tunnel_id= #{tunnelId}")
+  Integer getMaxProtocolNoInTunnel(Integer tunnelId);
 }

+ 19 - 19
backend/src/main/java/com/jiayue/pfr/service/di/impl/ProtocolSenderDataPointService.java

@@ -55,17 +55,17 @@ public class ProtocolSenderDataPointService {
 //	}
 //
 //
-//	/**
-//	 * 获取到通道最末尾的值以便批量添加转发点位时获取到最末点位
-//	 *
-//	 * @param tunnelId 通道id
-//	 * @return {@link Integer}
-//	 */
-//	public Integer getMaxProtocolNoInTunnel(String tunnelId) {
-//		return this.protocolSenderDataPointRepository.getMaxProtocolNoInTunnel(tunnelId);
-//	}
-//
-//
+	/**
+	 * 获取到通道最末尾的值以便批量添加转发点位时获取到最末点位
+	 *
+	 * @param tunnelId 通道id
+	 * @return {@link Integer}
+	 */
+	public Integer getMaxProtocolNoInTunnel(Integer tunnelId) {
+		return this.protocolSenderDataPointMapper.getMaxProtocolNoInTunnel(tunnelId);
+	}
+
+
 	/**
 	 * 查询所有转发点位
 	 *
@@ -175,11 +175,11 @@ public class ProtocolSenderDataPointService {
 			e.printStackTrace();
 		}
 	}
-//
-//	public void deleteAll(ProtocolSenderDataPoint point) {
-//		protocolSenderDataPointRepository.delete(point);
-//	}
-//
+
+	public void deleteAll(ProtocolSenderDataPoint point) {
+		protocolSenderDataPointMapper.deleteById(point.getId());
+	}
+
 	/**
 	 * 通过通道id查询转发点表
 	 *
@@ -220,10 +220,10 @@ public class ProtocolSenderDataPointService {
 	 * @param equipmentType
 	 * @return list
 	 */
-	public List getPointByTunnelIdAndPointId(Integer tunnelId, String equipmentId, Integer equipmentType) {
+	public List getPointByTunnelIdAndPointId(String tunnelId, String equipmentId, Integer equipmentType) {
 		List list = new ArrayList();
 		if (equipmentId.equals("ALL")) {
-			list = getPointByTunnelId(tunnelId);
+			list = getPointByTunnelId(Integer.parseInt(tunnelId));
 			return list;
 		}
 		List<ProtocolGatherDataPoint> points = this.protocolGatherDataPointService.getByEquipmentId(Integer.parseInt(equipmentId), EquipmentTypeEnum.valueOf(equipmentType).name());
@@ -232,7 +232,7 @@ public class ProtocolSenderDataPointService {
 			if (tunnelId.equals("ALL")) {
 				senderDataPoints = this.findByGatherPoint(points.get(i).getId());
 			} else {
-				senderDataPoints = this.findByTunnelIdAndGatherPoint(tunnelId, points.get(i).getId());
+				senderDataPoints = this.findByTunnelIdAndGatherPoint(Integer.parseInt(tunnelId), points.get(i).getId());
 			}
 			senderDataPoints.sort(Comparator.comparing(ProtocolSenderDataPoint::getProtocolPointNo));
 			List<ProtocolGatherDataPoint> gatherDataPoints = protocolGatherDataPointService.getAll();

+ 13 - 13
ui/src/views/dataexchange/senderdatapoint/multiAdd.vue

@@ -49,7 +49,7 @@
           />
         </vxe-select>
       </vxe-form-item>
-      <vxe-form-item v-show="formData.dataSource=='GATHER'" title="设备类型" field="eqType" span="6">
+      <vxe-form-item v-show="formData.dataSource==1" title="设备类型" field="eqType" span="6">
         <vxe-select v-model="formData.eqType" placeholder="请选择设备类型" size="medium"
                     @change="flushEqsOfSelectEqType">
           <vxe-option
@@ -60,13 +60,13 @@
           />
         </vxe-select>
       </vxe-form-item>
-      <vxe-form-item v-show="formData.dataSource=='GATHER'" title="设备名" field="equipmentId" span="10">
+      <vxe-form-item v-show="formData.dataSource==1" title="设备名" field="equipmentId" span="10">
         <vxe-select v-model="formData.equipmentId" placeholder="请选择设备名" size="medium"
                     @change="flushAttrsOfSelectEq">
           <vxe-option v-for="(item,index) in eqsOfSelectEqType" :key="index" :value="item.id" :label="item.name"/>
         </vxe-select>
       </vxe-form-item>
-      <vxe-form-item v-show="formData.dataSource=='GATHER'" title="设备属性" field="equipmentAttrs" span="14">
+      <vxe-form-item v-show="formData.dataSource==1" title="设备属性" field="equipmentAttrs" span="14">
         <el-select v-model="formData.equipmentAttrs" multiple collapse-tags placeholder="请选择设备属性" size="small">
           <el-option
             v-for="item in attrsOfSelectEq"
@@ -77,7 +77,7 @@
       </vxe-form-item>
 
       <vxe-form-item
-        v-show="formData.dataSource=='FORECAST'"
+        v-show="formData.dataSource==3"
         title="预测数据属性"
         field="forecastType"
         span="10"
@@ -87,7 +87,7 @@
           <vxe-option v-for="item in enums.forecastType" :key="item.value" :value="item.value" :label="item.label"/>
         </vxe-select>
       </vxe-form-item>
-      <vxe-form-item v-show="formData.dataSource=='FORECAST'" title="预测天数" span="10" field="forecastNode">
+      <vxe-form-item v-show="formData.dataSource==3" title="预测天数" span="10" field="forecastNode">
         <el-select
           v-model="formData.forecastNode"
           multiple
@@ -99,7 +99,7 @@
           <el-option v-for="item in forecastDay" :key="item.value" :value="item.value" :label="item.label"/>
         </el-select>
       </vxe-form-item>
-      <vxe-form-item v-show="formData.dataSource=='FORECAST'" title="预测点位" span="10" field="forecastPointNumber">
+      <vxe-form-item v-show="formData.dataSource==3" title="预测点位" span="10" field="forecastPointNumber">
         <el-select v-model="formData.forecastPointNumber" multiple collapse-tags placeholder="请选择预测点数"
                    size="small">
           <el-option v-for="item in forecastAttributeList" :value="item.pointNumber" :label="item.pointNumber"/>
@@ -136,7 +136,7 @@ export default {
       saveButDisable: false,
       formData: {
         eqType: '',
-        dataSource: 'GATHER',
+        dataSource: 1,
         tunnelId: '',
         protocolPointType: '',
         equipmentId: '',
@@ -193,7 +193,7 @@ export default {
         max = await this.resultHandler(_this.$axios.get('/dataExchange/senderProtocolDataPoint/maxProtocolNoInTunnel', {params: {tunnelId: _this.formData.tunnelId}})).then(res => {
           return res == null ? 0 : res
         })
-        if (this.formData.dataSource == 'GATHER') {
+        if (this.formData.dataSource == 1) {
           if (this.formData.equipmentAttrs.length == 0) {
             _this.$XModal.message({message: '并未选择需要添加的属性'})
             return
@@ -236,7 +236,7 @@ export default {
                 param.gatherPoint = _this.formData.equipmentAttrs[i]
                 param.protocolPointNo = max * 1 + i * 1 + 1
                 _this.$axios.post('/dataExchange/senderProtocolDataPoint/saveDataPoint', param).then(res => {
-                  if (res.code == 0) {
+                  if (res.code == 200) {
                     _this.$XModal.message({message: '保存转发点位成功'})
                     _this.saveButDisable = false
                   } else {
@@ -249,7 +249,7 @@ export default {
               _this.saveButDisable = false
             }
           })
-        } else if (this.formData.dataSource == 'FORECAST') {
+        } else if (this.formData.dataSource == 3) {
           if (this.formData.forecastPointNumber.length == 0) {
             _this.$XModal.message({message: '并未选择需要添加的预测属性'})
             return
@@ -289,7 +289,7 @@ export default {
                 pointNumbers: _this.formData.forecastPointNumber
               }
               _this.$axios.post('/dataExchange/senderProtocolDataPoint/batchSaveForecastPoint', param).then(res => {
-                if (res.code == 0) {
+                if (res.code == 200) {
                   _this.$XModal.message({message: '保存转发点位成功'})
                   _this.saveButDisable = false
                 } else {
@@ -345,7 +345,7 @@ export default {
         // 当设备类型是电站时对数数据进行处理后返回
         return new Promise(function (resolve, reject) {
           axios.get('/electricField/').then(res => {
-            if (res.code == 0) {
+            if (res.code == 200) {
               const eqs = []
               res.data.id = res.data.stationCode
               eqs.push(res.data)
@@ -435,7 +435,7 @@ export default {
     resetForm() {
       this.formData = {
         eqType: '',
-        dataSource: 'GATHER',
+        dataSource: 1,
         tunnelId: '',
         protocolPointType: '',
         equipmentId: '',