Browse Source

解决找不到Mapper映射文件

yanghuangyu 1 year ago
parent
commit
6646442b2f

+ 0 - 2
climate_data/src/main/java/com/climate/data/mapper/CliTqStationMapper.java

@@ -2,7 +2,6 @@ package com.climate.data.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.climate.data.domain.CliTqStation;
-import org.apache.ibatis.annotations.Mapper;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
@@ -10,7 +9,6 @@ import java.util.List;
 /**
  * @author
  */
-@Mapper
 @Repository
 public interface CliTqStationMapper extends BaseMapper<CliTqStation> {
 

+ 4 - 2
climate_data/src/main/java/com/climate/data/service/impl/CliTqStationServiceImpl.java

@@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.ListUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -39,6 +40,7 @@ public class CliTqStationServiceImpl implements CliTqStationService {
     }
 
     @Override
+    @Transactional
     public List<CliTqStation> listSta(String adminCodes) {
         /** 2. 调用方法的参数定义,并赋值
          /** 2.1  接口ID */
@@ -107,7 +109,7 @@ public class CliTqStationServiceImpl implements CliTqStationService {
                     stationList.add(station);
                 }
                 //切分数据
-                List<List<CliTqStation>> partition = ListUtils.partition(stationList, 500);
+                List<List<CliTqStation>> partition = ListUtils.partition(stationList, 200);
                 System.out.println(partition);
                 for (int i = 0; i < partition.size(); i++) {
                     List<CliTqStation> weaTqstaList = partition.get(i);
@@ -115,7 +117,7 @@ public class CliTqStationServiceImpl implements CliTqStationService {
                     if (insert > 0) {
                         System.out.println("插入成功");
                     } else {
-                        throw new RuntimeException("插入数据库失败");
+                        System.out.println("插入失败");
                     }
                 }
             }

climate_data/src/main/resources/mapper.data/CliComfortMapper.xml → climate_data/src/main/resources/mapper/data/CliComfortMapper.xml


+ 18 - 18
climate_data/src/main/resources/mapper.data/CliTqStationMapper.xml

@@ -15,31 +15,31 @@
             "cnty",
             "type"
         ) VALUES (
-                     #{id},
-                     #{stationId},
-                     #{stationName},
-                     #{province},
-                     #{city},
-                     #{cnty},
-                     #{adminCode},
-                     #{type}
+             #{id},
+             #{stationId},
+             #{stationName},
+             #{province},
+             #{city},
+             #{cnty},
+             #{adminCode},
+             #{type}
                  )
 
     </insert>
 
     <!-- 批量插入数据 -->
     <insert id="insertBatch">
-        INSERT INTO "cli_tq_station" (
-        "id",
-        "station_id",
-        "station_name",
-        "province",
-        "city",
-        "cnty",
-        "admin_code",
-        "type"
+        INSERT INTO cli_tq_station (
+        id,
+        station_id,
+        station_name,
+        province,
+        city,
+        cnty,
+        admin_code,
+        type
         ) VALUES
-        <foreach collection="list" item="item" separator=",">
+        <foreach collection="list" item="item" >
             (
             #{item.id},
             #{item.stationId},