From f31f0991c0d2036e563b886f57de4cf45d3c72cb Mon Sep 17 00:00:00 2001
From: dcb <xgybdcb@163.com>
Date: 星期二, 01 七月 2025 14:51:59 +0800
Subject: [PATCH] 实时模拟异步功能实现

---
 src/main/resources/mapper/SimuMapper.xml |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/src/main/resources/mapper/SimuMapper.xml b/src/main/resources/mapper/SimuMapper.xml
index f640144..d86d159 100644
--- a/src/main/resources/mapper/SimuMapper.xml
+++ b/src/main/resources/mapper/SimuMapper.xml
@@ -1,8 +1,38 @@
 <?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.se.nsl.mapper.SimuMapper">
+    <insert id="insert" parameterType="com.se.nsl.domain.po.Simu">
+        <selectKey resultType="java.lang.Long" order="AFTER" keyProperty="id">
+            select currval('nsl.simu_id_seq'::regclass) as id
+        </selectKey>
+
+        insert into nsl.tbl_yj_tr_simulate (
+            name, service_name, type, area_type, area_name, data, status, result, create_time, create_user, bak, geom)
+        values (
+            #{name},
+            #{serviceName},
+            #{type},
+            #{areaType},
+            #{areaName},
+            #{data},
+            #{status},
+            #{result},
+            now(),
+            #{createUser},
+            #{bak},
+            <choose>
+                <when test="geom != null and geom != ''">
+                    ST_GeomFromText('${geom}')
+                </when>
+                <otherwise>
+                    null
+                </otherwise>
+            </choose>
+        )
+    </insert>
+
     <insert id="inserts" parameterType="com.se.nsl.domain.po.Simu">
-        insert into nsl.simu (
+        insert into nsl.tbl_yj_tr_simulate (
             name, service_name, type, area_type, data, status, result, create_time, create_user, bak, geom)
         values
         <foreach collection="list" item="item" separator=",">
@@ -17,14 +47,21 @@
             now(),
             #{item.createUser},
             #{item.bak},
-            ${item.geom}
+            <choose>
+                <when test="item.geom != null and item.geom != ''">
+                    ST_GeomFromText('${item.geom}')
+                </when>
+                <otherwise>
+                    null
+                </otherwise>
+            </choose>
         )
         </foreach>
     </insert>
 
     <update id="updates" parameterType="com.se.nsl.domain.po.Simu">
         <foreach collection="list" item="item" separator=";">
-            update nsl.simu
+            update nsl.tbl_yj_tr_simulate
             set name=#{item.name},
                 service_name=#{item.serviceName},
                 type=#{item.type},
@@ -35,8 +72,19 @@
                 update_time=now(),
                 update_user=#{item.updateUser},
                 bak=#{item.bak},
-                geom=${item.geom}
+                <choose>
+                    <when test="item.geom != null and item.geom != ''">
+                        geom = ST_GeomFromText('${item.geom}')
+                    </when>
+                    <otherwise>
+                        geom = null
+                    </otherwise>
+                </choose>
             where id = #{item.id}
         </foreach>
     </update>
+
+    <update id="updateResult" parameterType="com.se.nsl.domain.po.Simu">
+        update nsl.tbl_yj_tr_simulate set result=#{result} where id = #{id}
+    </update>
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.3