高家顺 il y a 3 ans
Parent
commit
e9bc2fca5b

+ 5 - 6
src/main/java/com/macro/mall/tiny/modules/business/model/BTower.java

@@ -1,17 +1,16 @@
 package com.macro.mall.tiny.modules.business.model;
 
-import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.util.Date;
-
+import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
-import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
 
 /**
  * <p>

+ 18 - 6
src/main/java/com/macro/mall/tiny/modules/business/model/KrBTower.java

@@ -1,14 +1,15 @@
 package com.macro.mall.tiny.modules.business.model;
 
-import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.IdType;
-import java.util.Date;
 import com.baomidou.mybatisplus.annotation.TableId;
-import java.io.Serializable;
+import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
-import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Objects;
 
 /**
  * <p>
@@ -19,7 +20,6 @@ import lombok.EqualsAndHashCode;
  * @since 2021-09-07
  */
 @Data
-@EqualsAndHashCode(callSuper = false)
 @TableName("kr_b_tower")
 @ApiModel(value="KrBTower对象", description="杆塔表")
 public class KrBTower implements Serializable {
@@ -93,5 +93,17 @@ public class KrBTower implements Serializable {
     @ApiModelProperty(value = "创建时间")
     private Date createTime;
 
-
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        KrBTower krBTower = (KrBTower) o;
+        return Objects.equals(lineId, krBTower.lineId) &&
+                Objects.equals(towerName, krBTower.towerName);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(lineId, towerName);
+    }
 }

+ 1 - 1
src/main/resources/mapper/business/BTowerMapper.xml

@@ -2,7 +2,7 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.macro.mall.tiny.modules.business.mapper.BTowerMapper">
 
-    <insert id="saveAndUpdate" parameterType="List">
+    <insert id="saveAndUpdate" parameterType="list">
         INSERT INTO b_tower (
         sort,
         name,

+ 53 - 0
src/main/resources/mapper/business/KrBTowerMapper.xml

@@ -2,6 +2,59 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.macro.mall.tiny.modules.business.mapper.KrBTowerMapper">
 
+    <insert id="saveAndUpdate" parameterType="list">
+        INSERT INTO kr_b_tower (
+        sort,
+        name,
+        shape,
+        hardware_type,
+        line_id,
+        lon,
+        lat,
+        has_file,
+        create_time
+        )
+        VALUES
+        <foreach collection="towerList" item="item" separator=",">
+            (
+            #{item.lineId},
+            #{item.towerIndex},
+            #{item.towerName},
+            #{item.towerNumber},
+            #{item.hardwareType},
+            #{item.longitude},
+            #{item.latitude},
+            #{item.type},
+            #{item.isStation},
+            #{item.isWeather},
+            #{item.circuit},
+            #{item.height},
+            #{item.practicalHeight},
+            #{item.cornerDirection},
+            #{item.cornerNumber},
+            #{item.span},
+            #{item.servuceBegintime},
+            #{item.remark},
+            #{item.hasFile},
+            #{item.creatorId},
+            #{item.createTime}
+            )
+        </foreach>
+        ON DUPLICATE KEY UPDATE
+        tower_name = VALUES(tower_name),
+        tower_number = VALUES(tower_number),
+        hardware_type = VALUES(hardware_type),
+        longitude = VALUES(longitude),
+        latitude = VALUES(latitude),
+        type = VALUES(type),
+        is_station = VALUES(is_station),
+        is_weather = VALUES(is_weather),
+        lat = VALUES(lat),
+        has_file = VALUES(has_file),
+        create_time = VALUES(create_time);
+
+    </insert>
+
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.macro.mall.tiny.modules.business.model.KrBTower">
         <id column="id" property="id" />