648540858 пре 11 месеци
родитељ
комит
4b694954d4

+ 9 - 1
src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java

@@ -40,7 +40,15 @@ public class RecordPlanServiceImpl implements IRecordPlanService {
 
     @Override
     public RecordPlan get(Integer planId) {
-        return recordPlanMapper.get(planId);
+        RecordPlan recordPlan = recordPlanMapper.get(planId);
+        if (recordPlan == null) {
+            return null;
+        }
+        List<RecordPlanItem> recordPlanItemList = recordPlanMapper.getItemList(planId);
+        if (!recordPlanItemList.isEmpty()) {
+            recordPlan.setPlanItemList(recordPlanItemList);
+        }
+        return recordPlan;
     }
 
     @Override

+ 26 - 8
src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java

@@ -2,9 +2,7 @@ package com.genersoft.iot.vmp.storager.dao;
 
 import com.genersoft.iot.vmp.service.bean.RecordPlan;
 import com.genersoft.iot.vmp.service.bean.RecordPlanItem;
-import org.apache.ibatis.annotations.Insert;
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Options;
+import org.apache.ibatis.annotations.*;
 
 import java.util.List;
 
@@ -26,15 +24,35 @@ public interface RecordPlanMapper {
     @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
     void add(RecordPlan plan);
 
-    RecordPlan get(Integer planId);
+    @Insert(" <script>" +
+            "INSERT INTO wvp_device_channel (" +
+            "start_time," +
+            "stop_time, " +
+            "week_day," +
+            "create_time," +
+            "update_time) " +
+            "VALUES" +
+            "<foreach collection='commonGBChannels' index='index' item='item' separator=','> " +
+            "(#{item.startTime}, #{item.stopTime}, #{item.weekDay},#{item.planId},#{item.createTime},#{item.updateTime})" +
+            "</foreach> " +
+            " </script>")
+    void batchAddItem(@Param("planId") int planId, List<RecordPlanItem> planItemList);
 
-    List<RecordPlan> query(String query);
+    @Select("select * from wvp_record_plan where  id = #{planId}")
+    RecordPlan get(@Param("planId") Integer planId);
 
-    void update(RecordPlan plan);
+    @Select(" <script>" +
+            "select * from wvp_record_plan where  1=1" +
+            " <if test='query != null'> AND (name LIKE concat('%',#{query},'%') escape '/' )</if> " +
+            " </script>")
+    List<RecordPlan> query(@Param("query") String query);
 
-    void delete(Integer planId);
+    @Update("UPDATE wvp_record_plan SET update_time=#{updateTime}, name=#{name}, snap=#{snap} WHERE id=#{id}")
+    void update(RecordPlan plan);
 
+    @Delete("DELETE FROM wvp_record_plan WHERE id=#{id}")
+    void delete(@Param("planId") Integer planId);
 
-    void batchAddItem(int planId, List<RecordPlanItem> planItemList);
 
+    List<RecordPlanItem> getItemList(Integer planId);
 }