hyx пре 2 година
родитељ
комит
9b8626c85d

+ 70 - 47
nngkxxdp/src/main/java/com/example/nngkxxdp/controller/MapDataController.java

@@ -1,17 +1,19 @@
 package com.example.nngkxxdp.controller;
 
+import java.util.HashMap;
 import java.util.Map;
 
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.http.HttpRequest;
+import org.springframework.web.bind.annotation.*;
 
 import com.example.nngkxxdp.service.MapDataService;
 import com.example.nngkxxdp.util.Blank;
 import com.example.nngkxxdp.util.ConstStr;
 import com.example.nngkxxdp.util.SendUtil;
 
+import javax.servlet.http.HttpServletRequest;
+
 /**
  * @ApplicationName: nngkxxdp
  * @Title: MapDataController
@@ -25,50 +27,71 @@ import com.example.nngkxxdp.util.SendUtil;
 @RequestMapping("mapdata")
 public class MapDataController {
 
-	@Autowired
-	private MapDataService mapDataService;
+    @Autowired
+    private MapDataService mapDataService;
+
+    /**
+     * @return
+     * @Title: insertBatchByJson
+     * @Description: 批量保存地图数据
+     * @author: YJQ
+     * @date: 2022年6月24日 下午3:19:41
+     * @returnType Map<String, Object>
+     */
+    @GetMapping("insertBatchByJson")
+    public Map<String, Object> insertBatchByJson() {
+        return SendUtil.send(true, ConstStr.RESULT_SUCCESS, mapDataService.insertBatchByJson());
+    }
+
+    /**
+     * @param dictType
+     * @return
+     * @Title: getMapDataByDictType
+     * @Description: 根据数据字典类型获取地图数据
+     * @author: YJQ
+     * @date: 2022年6月24日 下午3:52:14
+     * @returnType Map<String, Object>
+     */
+    @GetMapping("getMapDataByDictType")
+    public Map<String, Object> getMapDataByDictType(String dictType) {
+        if (Blank.isEmpty(dictType)) {
+            return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS);
+        }
+        return SendUtil.send(true, ConstStr.RESULT_SUCCESS, mapDataService.getMapDataByDictType(dictType));
+    }
+
+    /**
+     * @return
+     * @Title: getMapDataAll
+     * @Description: 查询所有的地图数据信息
+     * @author: YJQ
+     * @date: 2022年6月24日 下午4:36:07
+     * @returnType Map<String, Object>
+     */
+    @GetMapping("getMapDataAll")
+    public Map<String, Object> getMapDataAll() {
+        return SendUtil.send(true, ConstStr.RESULT_SUCCESS, mapDataService.getMapDataAll());
+    }
 
-	/**
-	 * @Title: insertBatchByJson
-	 * @Description: 批量保存地图数据
-	 * @author: YJQ
-	 * @date: 2022年6月24日 下午3:19:41
-	 * @returnType Map<String,Object>
-	 * @return
-	 */
-	@GetMapping("insertBatchByJson")
-	public Map<String, Object> insertBatchByJson() {
-		return SendUtil.send(true, ConstStr.RESULT_SUCCESS, mapDataService.insertBatchByJson());
-	}
-	
-	/**
-	 * @Title: getMapDataByDictType
-	 * @Description: 根据数据字典类型获取地图数据
-	 * @author: YJQ
-	 * @date: 2022年6月24日 下午3:52:14
-	 * @returnType Map<String,Object>
-	 * @param dictType
-	 * @return
-	 */
-	@GetMapping("getMapDataByDictType")
-	public Map<String, Object> getMapDataByDictType(String dictType) {
-		if (Blank.isEmpty(dictType)) {
-			return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS);
-		}
-		return SendUtil.send(true, ConstStr.RESULT_SUCCESS, mapDataService.getMapDataByDictType(dictType));
-	}
-	
-	/**
-	 * @Title: getMapDataAll
-	 * @Description: 查询所有的地图数据信息
-	 * @author: YJQ
-	 * @date: 2022年6月24日 下午4:36:07
-	 * @returnType Map<String,Object>
-	 * @return
-	 */
-	@GetMapping("getMapDataAll")
-	public Map<String, Object> getMapDataAll() {
-		return SendUtil.send(true, ConstStr.RESULT_SUCCESS, mapDataService.getMapDataAll());
-	}
+    /**
+     * 提交纠错信息
+     */
+    @PostMapping("/saveErrorLog")
+    public Map<String, Object> saveErrorLog(HttpServletRequest request) {
+        Map<String, Object> mapErrorLog = new HashMap<>();
+        mapErrorLog.put("sMapId", request.getParameter("sMapId"));
+        mapErrorLog.put("addressName", request.getParameter("addressName"));
+        mapErrorLog.put("originalAddress", request.getParameter("originalAddress"));
+        mapErrorLog.put("originalCoordinates", request.getParameter("originalCoordinates"));
+        mapErrorLog.put("newAddress", request.getParameter("newAddress"));
+        mapErrorLog.put("newCoordinates", request.getParameter("newCoordinates"));
+        mapErrorLog.put("errorState", request.getParameter("errorState"));
+        try {
+            return mapDataService.saveErrorLog(mapErrorLog);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return SendUtil.send(false, ConstStr.ADD_FAILED);
+    }
 
 }

+ 2 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/dao/MapDataDao.java

@@ -1,6 +1,7 @@
 package com.example.nngkxxdp.dao;
 
 import java.util.List;
+import java.util.Map;
 
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -61,4 +62,5 @@ public interface MapDataDao {
 	 */
 	List<String> getDictType();
 
+	Integer saveErrorLog(Map<String, Object> mapErrorLog);
 }

+ 2 - 1
nngkxxdp/src/main/java/com/example/nngkxxdp/service/MapDataService.java

@@ -46,5 +46,6 @@ public interface MapDataService {
 	 * @return
 	 */
 	Map<String, Object> getMapDataAll();
-	
+
+	Map<String, Object> saveErrorLog(Map<String, Object> mapErrorLog);
 }

+ 13 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/service/impl/MapDataServiceImpl.java

@@ -14,6 +14,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import com.example.nngkxxdp.util.ConstStr;
+import com.example.nngkxxdp.util.SendUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.io.Resource;
 import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
@@ -91,4 +93,15 @@ public class MapDataServiceImpl implements MapDataService {
         return result;
     }
 
+    @Override
+    public Map<String, Object> saveErrorLog(Map<String, Object> mapErrorLog) {
+        if(Blank.isEmpty(mapErrorLog.get("sMapId"))){
+            return SendUtil.send(false, ConstStr.ADD_FAILED, "sMapId为空");
+        }
+        if (mapDataDao.saveErrorLog(mapErrorLog) <= 0) {
+            return SendUtil.send(false, ConstStr.ADD_FAILED, "");
+        }
+        return SendUtil.send(true, ConstStr.ADD_SUCCESS, "");
+    }
+
 }

+ 43 - 35
nngkxxdp/src/main/resources/mapper/MapDataDao.xml

@@ -2,44 +2,52 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.example.nngkxxdp.dao.MapDataDao">
 
-	<sql id="all_base_data">
-		id, dict_type, address, content, dep, img, sptype, tel,
+    <sql id="all_base_data">
+        id
+        , dict_type, address, content, dep, img, sptype, tel,
 		time, url, type, tag, tag2, tag3, specialtype, create_time,
 		update_time
-	</sql>
+    </sql>
 
-	<!-- 批量保存地图数据 -->
-	<insert id="insertBatch" parameterType="java.util.List">
-		INSERT INTO s_map (
-		<include refid="all_base_data" />
-		)
-		VALUES
-		<foreach collection="mapDataList" item="map" separator=",">
-			(NULL,
-			#{map.dictType}, #{map.address}, #{map.content}, #{map.dep},
-			#{map.img}, #{map.sptype}, #{map.tel}, #{map.time}, #{map.url},
-			#{map.type}, #{map.tag}, #{map.tag2}, #{map.tag3},
-			#{map.specialtype}, NOW(), NOW())
-		</foreach>
-	</insert>
-	
-	<!-- 清空表数据信息 -->
-	<update id="clearMapData">
-		TRUNCATE TABLE s_map
-	</update>
+    <!-- 批量保存地图数据 -->
+    <insert id="insertBatch" parameterType="java.util.List">
+        INSERT INTO s_map (
+        <include refid="all_base_data"/>
+        )
+        VALUES
+        <foreach collection="mapDataList" item="map" separator=",">
+            (NULL,
+            #{map.dictType}, #{map.address}, #{map.content}, #{map.dep},
+            #{map.img}, #{map.sptype}, #{map.tel}, #{map.time}, #{map.url},
+            #{map.type}, #{map.tag}, #{map.tag2}, #{map.tag3},
+            #{map.specialtype}, NOW(), NOW())
+        </foreach>
+    </insert>
 
-	<!-- 根据数据字典类型获取地图数据 -->
-	<select id="getMapDataByDictType"
-		resultType="com.example.nngkxxdp.entity.MapData">
-		SELECT
-		<include refid="all_base_data" />
-		FROM s_map
-		WHERE dict_type = #{dictType}
-	</select>
-	
-	<!-- 根据地图数据所有的字典类型 -->
-	<select id="getDictType" resultType="java.lang.String">
-		SELECT dict_type FROM s_map
-	</select>
+    <!-- 清空表数据信息 -->
+    <update id="clearMapData">
+        TRUNCATE TABLE s_map
+    </update>
+
+    <!-- 根据数据字典类型获取地图数据 -->
+    <select id="getMapDataByDictType"
+            resultType="com.example.nngkxxdp.entity.MapData">
+        SELECT
+        <include refid="all_base_data"/>
+        FROM s_map
+        WHERE dict_type = #{dictType}
+    </select>
+
+    <!-- 根据地图数据所有的字典类型 -->
+    <select id="getDictType" resultType="java.lang.String">
+        SELECT dict_type
+        FROM s_map
+    </select>
+
+    <!-- 根据地图数据所有的字典类型 -->
+    <insert id="saveErrorLog" parameterType="map">
+        INSERT INTO s_map_errorlog (s_map_id, address_name, original_address, original_coordinates, new_address, new_coordinates, error_state)
+            VALUE (sMapId, addressName, originalAddress, originalCoordinates, newAddress, newCoordinates, errorState)
+    </insert>
 
 </mapper>