Przeglądaj źródła

实现户表信息导入

欧阳劲驰 6 dni temu
rodzic
commit
dde4953ca8

+ 2 - 1
custom-gateway-app/src/main/resources/application-zydma.yml

@@ -12,4 +12,5 @@ calling:
       secret-key: panda666.
 security:
   permit-pattern:
-    - ${gateway.routes.zydma}/users/ticket-exchange
+    - ${gateway.routes.zydma}/users/ticket-exchange
+    - ${gateway.routes.zydma}/customer/customer-info-import

+ 6 - 0
custom-gateway-app/src/main/resources/application.yml

@@ -9,8 +9,14 @@ gateway:
     zydma: /zy-dma
 #spring
 spring:
+  #app
   application:
     name: KprCustomGateway
+  #servlet
+  servlet:
+    multipart:
+      max-file-size: 200MB
+      max-request-size: 200MB
   #启用配置
   profiles:
     active: @enable.module@

+ 8 - 1
custom-gateway-core/src/main/java/com/shkpr/service/customgateway/core/constants/Api.java

@@ -58,9 +58,16 @@ public interface Api {
     String URI_INTERNAL_XXX = URI_INTERNAL_H + "/**";
     String URI_INTERNAL_OPS_XXX = "/ops/**";
 
+    //用户
+    String URI_USERS_H = "/users";
+    //户表
+    String URI_CUSTOMER_H = "/customer";
+
+    //ticket交换临时令牌
     String URI_XXX_TICKET_EXCHANGE = "ticket-exchange";
+    //户表信息导入
+    String URI_XXX_CUSTOMER_INFO_IMPORT = "customer-info-import";
 
-    String URI_USERS_H = "/users";
 
     //==========================请求头==========================
     //验证口令

+ 26 - 0
custom-gateway-core/src/main/java/com/shkpr/service/customgateway/core/constants/CustomerStatus.java

@@ -0,0 +1,26 @@
+package com.shkpr.service.customgateway.core.constants;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * 户表状态
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+@Getter
+@AllArgsConstructor
+public enum CustomerStatus {
+    //正常
+    NORMAL((short) 1, "正常"),
+    ;
+    /**
+     * 状态码
+     */
+    private final Short code;
+    /**
+     * 状态名
+     */
+    private final String name;
+}

+ 12 - 12
custom-gateway-core/src/main/java/com/shkpr/service/customgateway/core/utils/ExcelUtil.java

@@ -8,6 +8,7 @@ import com.shkpr.service.customgateway.core.constants.ExcelMetadata;
 import com.shkpr.service.customgateway.core.constants.LogFlagBusiType;
 import org.apache.commons.collections4.map.CaseInsensitiveMap;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.math.NumberUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
@@ -161,7 +162,7 @@ public class ExcelUtil {
         String ext = path.substring(path.lastIndexOf("."));
         //根据后缀名指定枚举
         if (".xls".equalsIgnoreCase(ext)) excelEnum = ExcelEnum.XLS;
-        else if (".xlsx".equalsIgnoreCase(ext)) excelEnum = ExcelEnum.XLS;
+        else if (".xlsx".equalsIgnoreCase(ext)) excelEnum = ExcelEnum.XLSX;
         if (excelEnum == null) return null;
         //解析文件
         try {
@@ -235,10 +236,7 @@ public class ExcelUtil {
                                         //过滤相同的值
                                         .filter(index -> headerRow.getCell(index).getStringCellValue().equals(excelMappingValue))
                                         .findFirst().orElse(-1);
-                            }, Function.identity(),
-                            (it1, it2) -> it2,
-                            CaseInsensitiveMap::new
-                    ));
+                            }, Function.identity(), (it1, it2) -> it2));
             //遍历行
             for (Row row : sheet) {
                 //跳过非数据
@@ -549,17 +547,19 @@ public class ExcelUtil {
                 //设置值
                 field.set(data, value);
             } else {
-                //如值为double类型
-                if (value instanceof Double) {
-                    //对double类型兼容的类型处理
+                //如值为数字类型
+                if (NumberUtils.isParsable(value.toString())) {
+                    //对数字类型兼容的类型处理
                     if (field.getType() == short.class || field.getType() == Short.class)
-                        field.set(data, ((Double) value).shortValue());
+                        field.set(data, ((Double) Double.parseDouble(value.toString())).shortValue());
                     else if (field.getType() == int.class || field.getType() == Integer.class)
-                        field.set(data, ((Double) value).intValue());
+                        field.set(data, ((Double) Double.parseDouble(value.toString())).intValue());
                     else if (field.getType() == long.class || field.getType() == Long.class)
-                        field.set(data, ((Double) value).longValue());
+                        field.set(data, ((Double) Double.parseDouble(value.toString())).longValue());
                     else if (field.getType() == float.class || field.getType() == Float.class)
-                        field.set(data, ((Double) value).floatValue());
+                        field.set(data, ((Double) Double.parseDouble(value.toString())).floatValue());
+                    else if (field.getType() == double.class || field.getType() == Double.class)
+                        field.set(data, (Double) Double.parseDouble(value.toString()));
                 }
             }
         }

+ 11 - 0
custom-gateway-zydma/pom.xml

@@ -27,6 +27,17 @@
             <artifactId>custom-gateway-core</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <!--jts-->
+        <dependency>
+            <groupId>org.locationtech.jts</groupId>
+            <artifactId>jts-core</artifactId>
+            <version>${jts.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.locationtech.jts.io</groupId>
+            <artifactId>jts-io-common</artifactId>
+            <version>${jts.version}</version>
+        </dependency>
     </dependencies>
 
     <!--构建脚本-->

+ 125 - 0
custom-gateway-zydma/src/main/java/com/shkpr/service/customgateway/zydma/controller/CustomerController.java

@@ -0,0 +1,125 @@
+package com.shkpr.service.customgateway.zydma.controller;
+
+import com.global.base.log.LogLevelFlag;
+import com.global.base.log.LogPrintMgr;
+import com.shkpr.service.customgateway.core.constants.*;
+import com.shkpr.service.customgateway.core.domain.ResultResponse;
+import com.shkpr.service.customgateway.core.exception.SelfException;
+import com.shkpr.service.customgateway.core.utils.CommTool;
+import com.shkpr.service.customgateway.core.utils.ExcelUtil;
+import com.shkpr.service.customgateway.zydma.domain.po.CustomerInfo;
+import com.shkpr.service.customgateway.zydma.service.CustomerInfoService;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.MapUtils;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Collectors;
+
+import static com.shkpr.service.customgateway.core.constants.Api.URI_CUSTOMER_H;
+
+/**
+ * 户表controller
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+@Controller
+@RequestMapping("${gateway.routes.zydma}" + URI_CUSTOMER_H)
+public class CustomerController {
+    //log
+    private final static String CLASS_NAME = "ApiGisSurveyController";
+    private final static String BIZ_TYPE = LogFlagBusiType.BUSI_CUSTOMER.toStrValue();
+    /**
+     * 请求序列
+     */
+    final Map<String, AtomicInteger> requestSeq = new ConcurrentHashMap<>();
+
+    final
+    CustomerInfoService customerInfoService;
+
+    public CustomerController(CustomerInfoService customerInfoService) {
+        this.customerInfoService = customerInfoService;
+    }
+
+
+    /**
+     * 户表信息导入
+     *
+     * @param request       request
+     * @param strClientType 客户端类型
+     * @param strUserAgent  用户信息
+     * @param file          excel文件
+     * @return 临时token
+     * @throws SelfException http异常
+     */
+    @PostMapping(value = Api.URI_XXX_CUSTOMER_INFO_IMPORT)
+    public ResultResponse<String> customerInfoImport(HttpServletRequest request
+            , @RequestHeader(value = Api.HEADER_CLIENT_TYPE, required = false) String strClientType
+            , @RequestHeader(value = Api.HEADER_USER_AGENT, required = false) String strUserAgent
+            , @RequestParam(value = "file", required = false) MultipartFile file) throws SelfException {
+        //初始化序列
+        requestSeq.putIfAbsent(Api.URI_XXX_CUSTOMER_INFO_IMPORT, new AtomicInteger(0));
+        //请求信息
+        final String requestURI = request.getRequestURI();
+        final String strPlatform = CommTool.getPlatformByAgent(strClientType, strUserAgent);
+        //参数校验
+        if (file == null || file.isEmpty()) throw new SelfException(ResponseCode.STATUS_ERROR_JSON_FORMAT.getCode() + ""
+                , String.format(Api.EXCEPTION_FORMAT
+                , strPlatform
+                , requestURI
+                , ResponseCode.STATUS_ERROR_JSON_FORMAT.getMessage()));
+
+        //begin
+        long begin = System.currentTimeMillis();
+        String seqMsg = String.format("%d-%d", begin, requestSeq.get(Api.URI_XXX_CUSTOMER_INFO_IMPORT).incrementAndGet());
+        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, BIZ_TYPE, CLASS_NAME
+                , String.format("%s:%s seq:{%s} param:%s begin====>", strPlatform, requestURI, seqMsg, file.getOriginalFilename()));
+        //构建result
+        ResultResponse<String> resultResponse = ResultResponse.failed();
+
+        //解析excel
+        Map<String, List<CustomerInfo>> excel = null;
+        try {
+            excel = ExcelUtil.parseExcel(file.getInputStream(), CustomerInfo.class, ExcelEnum.XLSX);
+        } catch (IOException e) {
+            LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, BIZ_TYPE, CLASS_NAME
+                    , String.format("l文件流获取失败 error:%s", e)
+            );
+        }
+
+        //遍历excel页
+        if (MapUtils.isNotEmpty(excel)) for (Map.Entry<String, List<CustomerInfo>> dataEntry : excel.entrySet()) {
+            //获取数据
+            List<CustomerInfo> dates = dataEntry.getValue().stream()
+                    //修改表状态为正常
+                    .peek(info -> {
+                        info.setStatusCode(CustomerStatus.NORMAL.getCode());
+                        info.setStatusName(CustomerStatus.NORMAL.getName());
+                    })
+                    .collect(Collectors.toList());
+            if (CollectionUtils.isEmpty(dates)) continue;
+            //批量写入数据
+            Boolean upserted = customerInfoService.upsertAll(dates);
+            if (upserted) resultResponse.success(null);
+        }
+
+        //end
+        resultResponse.setTimestamp(System.currentTimeMillis());
+        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, BIZ_TYPE, CLASS_NAME,
+                String.format("%s:%s seq:{%s} rescode:{%s} resmsg:{%s} time:{%d ms} end<===="
+                        , strPlatform, requestURI, seqMsg, resultResponse.getRescode(), resultResponse.getResmsg()
+                        , resultResponse.getTimestamp() - begin));
+        return resultResponse;
+    }
+}

+ 0 - 15
custom-gateway-zydma/src/main/java/com/shkpr/service/customgateway/zydma/controller/TeatController.java

@@ -1,15 +0,0 @@
-package com.shkpr.service.customgateway.zydma.controller;
-
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-@RestController
-@RequestMapping("${gateway.routes.zydma}/test")
-public class TeatController {
-
-    @GetMapping("test")
-    public void test() {
-
-    }
-}

+ 14 - 4
custom-gateway-zydma/src/main/java/com/shkpr/service/customgateway/zydma/controller/UserController.java

@@ -34,6 +34,13 @@ import java.util.concurrent.atomic.AtomicInteger;
 
 import static com.shkpr.service.customgateway.core.constants.Api.URI_USERS_H;
 
+
+/**
+ * 用户controller
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
 @Controller
 @RequestMapping("${gateway.routes.zydma}" + URI_USERS_H)
 public class UserController {
@@ -44,6 +51,7 @@ public class UserController {
      * 请求序列
      */
     final Map<String, AtomicInteger> requestSeq = new ConcurrentHashMap<>();
+
     final
     CallingProperties callingProperties;
     final
@@ -60,12 +68,15 @@ public class UserController {
         this.callingUtil = callingUtil;
     }
 
-
     /**
      * ticket交换临时token
      *
-     * @param ticket 门户token
+     * @param request       request
+     * @param strClientType 客户端类型
+     * @param strUserAgent  用户信息
+     * @param ticket        门户token
      * @return 临时token
+     * @throws SelfException http异常
      */
     @GetMapping(value = Api.URI_XXX_TICKET_EXCHANGE)
     @ResponseBody
@@ -80,13 +91,12 @@ public class UserController {
         final String requestURI = request.getRequestURI();
         final String strPlatform = CommTool.getPlatformByAgent(strClientType, strUserAgent);
         //参数校验
-        if (ticket == null || StringUtils.isBlank(ticket)) {
+        if (ticket == null || StringUtils.isBlank(ticket))
             throw new SelfException(ResponseCode.STATUS_ERROR_JSON_FORMAT.getCode() + ""
                     , String.format(Api.EXCEPTION_FORMAT
                     , strPlatform
                     , requestURI
                     , ResponseCode.STATUS_ERROR_JSON_FORMAT.getMessage()));
-        }
 
         //begin
         long begin = System.currentTimeMillis();

+ 140 - 0
custom-gateway-zydma/src/main/java/com/shkpr/service/customgateway/zydma/domain/po/CustomerInfo.java

@@ -0,0 +1,140 @@
+package com.shkpr.service.customgateway.zydma.domain.po;
+
+import com.shkpr.service.customgateway.core.annotation.ExcelMapping;
+import lombok.Data;
+import org.locationtech.jts.geom.Geometry;
+
+import java.time.LocalDateTime;
+
+/**
+ * 营销用户表
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+@Data
+public class CustomerInfo {
+    /**
+     * 主键ID
+     */
+    private Integer id;
+
+    /**
+     * 用户编号
+     */
+    @ExcelMapping("用户编号")
+    private String code;
+
+    /**
+     * 户主名
+     */
+    @ExcelMapping("户主名")
+    private String name;
+
+    /**
+     * 用户地址
+     */
+    @ExcelMapping("用户地址")
+    private String address;
+
+    /**
+     * 水表口径
+     */
+    @ExcelMapping("水表口径")
+    private Short caliber;
+
+    /**
+     * 用水性质
+     */
+    @ExcelMapping("用水性质")
+    private String natureName;
+
+    /**
+     * 加压等级(名称)
+     */
+    @ExcelMapping("加压等级")
+    private String pressName;
+
+    /**
+     * 水表用途
+     */
+    @ExcelMapping("水表用途")
+    private String usedTypeName;
+
+    /**
+     * 水表编号
+     */
+    @ExcelMapping("水表编号")
+    private String stampInfo;
+
+    /**
+     * 开户时间
+     */
+    @ExcelMapping("开户时间")
+    private LocalDateTime createdAt;
+
+    /**
+     * 换表时间
+     */
+    @ExcelMapping("换表时间")
+    private LocalDateTime updatedAt;
+
+    /**
+     * 用户手机号
+     */
+    @ExcelMapping("用户手机号")
+    private String mobile;
+
+    /**
+     * 用户状态名
+     */
+    @ExcelMapping("用户状态名")
+    private String statusName;
+
+    /**
+     * 用户状态ID
+     */
+    @ExcelMapping("用户状态ID")
+    private Short statusCode;
+
+    /**
+     * 抄表周期ID
+     */
+    @ExcelMapping("抄表周期ID")
+    private Short readCycle;
+
+    /**
+     * 抄表周期名
+     */
+    @ExcelMapping("抄表周期名")
+    private String readCycleName;
+
+    /**
+     * 抄表人员
+     */
+    @ExcelMapping("抄表人员")
+    private String readerName;
+
+    /**
+     * 抄表册
+     */
+    @ExcelMapping("抄表册")
+    private String readbookName;
+
+    /**
+     * 抄表册类型
+     */
+    @ExcelMapping("抄表册类型")
+    private Short readbookType;
+
+    /**
+     * 水表GIS经纬度
+     */
+    @ExcelMapping("水表GIS经纬度")
+    private String gis;
+
+    /**
+     * 水表GIS空间几何信息
+     */
+    private Geometry geomGis;
+}

+ 21 - 0
custom-gateway-zydma/src/main/java/com/shkpr/service/customgateway/zydma/mapper/primary/CustomerInfoMapper.java

@@ -0,0 +1,21 @@
+package com.shkpr.service.customgateway.zydma.mapper.primary;
+
+import com.shkpr.service.customgateway.zydma.domain.po.CustomerInfo;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 户表信息mapper
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+@Mapper
+public interface CustomerInfoMapper {
+    /**
+     * 合并
+     *
+     * @param record 对象
+     * @return 保存数量
+     */
+    int upsert(CustomerInfo record);
+}

+ 21 - 0
custom-gateway-zydma/src/main/java/com/shkpr/service/customgateway/zydma/service/CustomerInfoService.java

@@ -0,0 +1,21 @@
+package com.shkpr.service.customgateway.zydma.service;
+
+import com.shkpr.service.customgateway.zydma.domain.po.CustomerInfo;
+
+import java.util.List;
+
+/**
+ * 户表信息service
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+public interface CustomerInfoService {
+    /**
+     * 批量合并操作
+     *
+     * @param dates 数据集合
+     * @return 合并状态
+     */
+    Boolean upsertAll(List<CustomerInfo> dates);
+}

+ 101 - 0
custom-gateway-zydma/src/main/java/com/shkpr/service/customgateway/zydma/service/impl/CustomerInfoServiceImpl.java

@@ -0,0 +1,101 @@
+package com.shkpr.service.customgateway.zydma.service.impl;
+
+import com.global.base.log.LogLevelFlag;
+import com.global.base.log.LogPrintMgr;
+import com.shkpr.service.customgateway.core.constants.DataSourceNames;
+import com.shkpr.service.customgateway.core.constants.LogFlagBusiType;
+import com.shkpr.service.customgateway.zydma.domain.po.CustomerInfo;
+import com.shkpr.service.customgateway.zydma.mapper.primary.CustomerInfoMapper;
+import com.shkpr.service.customgateway.zydma.service.CustomerInfoService;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.ibatis.session.ExecutorType;
+import org.apache.ibatis.session.SqlSession;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Service;
+
+import java.sql.Connection;
+import java.util.List;
+
+/**
+ * 职能信息service实现
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+@Service
+public class CustomerInfoServiceImpl implements CustomerInfoService {
+    /**
+     * log
+     */
+    private static final String CLASS_NAME = "FunctionInfoServiceImpl";
+    private static final String BIZ_TYPE = LogFlagBusiType.ZAO_YANG_DMA.toStrValue();
+
+    final
+    SqlSessionFactory sqlSessionFactory;
+
+    public CustomerInfoServiceImpl(@Qualifier(DataSourceNames.PRIMARY + "SqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
+        this.sqlSessionFactory = sqlSessionFactory;
+    }
+
+    /**
+     * 批量合并操作
+     *
+     * @param dates 数据集合
+     * @return 合并状态
+     */
+    @Override
+    public Boolean upsertAll(List<CustomerInfo> dates) {
+        if (CollectionUtils.isEmpty(dates)) return true;
+
+        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, BIZ_TYPE, CLASS_NAME
+                , String.format(
+                        "开始批量写入户表信息,开启批处理 数据量:%s"
+                        , dates.size()
+                )
+        );
+        long begin = System.currentTimeMillis();
+
+        //开启批处理
+        try (SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false)) {
+            try {
+                //设置手动提交
+                Connection conn = sqlSession.getConnection();
+                conn.setAutoCommit(false);
+
+                //从session获取mapper
+                CustomerInfoMapper mapper = sqlSession.getMapper(CustomerInfoMapper.class);
+
+                //批量写入
+                dates.forEach(mapper::upsert);
+
+                //发送sql至数据库
+                sqlSession.flushStatements();
+                //提交
+                sqlSession.commit();
+                conn.commit();
+
+                long end = System.currentTimeMillis();
+                LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, BIZ_TYPE, CLASS_NAME
+                        , String.format(
+                                "结束批量写入用户表信息,提交并关闭批处理 用时(毫秒):%d"
+                                , (end - begin)
+                        )
+                );
+                return true;
+            } catch (Exception e) {
+                //回滚
+                sqlSession.rollback();
+
+                LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, BIZ_TYPE, CLASS_NAME
+                        , String.format(
+                                "批量写入户表信息,回滚操作 error:%s"
+                                , e
+                        )
+                );
+
+                return false;
+            }
+        }
+    }
+}

+ 72 - 0
custom-gateway-zydma/src/main/resources/mapper/CustomerInfoMapper.xml

@@ -0,0 +1,72 @@
+<?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.shkpr.service.customgateway.zydma.mapper.primary.CustomerInfoMapper">
+    <insert id="upsert">
+        <trim prefix="insert into customer_info (" suffix=")" suffixOverrides=",">
+            code,
+            <if test="name != null and name != ''">name,</if>
+            <if test="address != null and address != ''">address,</if>
+            <if test="caliber != null">caliber,</if>
+            <if test="natureName != null and natureName != ''">nature_name,</if>
+            <if test="pressName != null and pressName != ''">press_name,</if>
+            <if test="usedTypeName != null and usedTypeName != ''">used_type_name,</if>
+            <if test="stampInfo != null and stampInfo != ''">stamp_info,</if>
+            created_at,
+            updated_at,
+            <if test="mobile != null and mobile != ''">mobile,</if>
+            <if test="statusCode != null">status_code,</if>
+            <if test="statusName != null and statusName != ''">status_name,</if>
+            <if test="readCycleName != null and readCycleName != ''">read_cycle_name,</if>
+            <if test="readerName != null and readerName != ''">reader_name,</if>
+            <if test="readbookName != null and readbookName != ''">readbook_name,</if>
+            <if test="readCycle != null">read_cycle,</if>
+            <if test="readbookType != null">readbook_type,</if>
+            <if test="gis != null and gis != ''">gis,</if>
+            <if test="geomGis != null">geom_gis,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            #{code,jdbcType=VARCHAR},
+            <if test="name != null and name != ''">#{name,jdbcType=VARCHAR},</if>
+            <if test="address != null and address != ''">#{address,jdbcType=VARCHAR},</if>
+            <if test="caliber != null">#{caliber,jdbcType=SMALLINT},</if>
+            <if test="natureName != null and natureName != ''">#{natureName,jdbcType=VARCHAR},</if>
+            <if test="pressName != null and pressName != ''">#{pressName,jdbcType=VARCHAR},</if>
+            <if test="usedTypeName != null and usedTypeName != ''">#{usedTypeName,jdbcType=VARCHAR},</if>
+            <if test="stampInfo != null and stampInfo != ''">#{stampInfo,jdbcType=VARCHAR},</if>
+            <if test="createdAt != null">#{createdAt,jdbcType=TIMESTAMP},</if>
+            timezone('utc', localtimestamp(0) at time zone current_setting('timezone')),
+            timezone('utc', localtimestamp(0) at time zone current_setting('timezone')),
+            <if test="mobile != null and mobile != ''">#{mobile,jdbcType=VARCHAR},</if>
+            <if test="statusCode != null">#{statusCode,jdbcType=SMALLINT},</if>
+            <if test="statusName != null and statusName != ''">#{statusName,jdbcType=VARCHAR},</if>
+            <if test="readCycleName != null and readCycleName != ''">#{readCycleName,jdbcType=VARCHAR},</if>
+            <if test="readerName != null and readerName != ''">#{readerName,jdbcType=VARCHAR},</if>
+            <if test="readbookName != null and readbookName != ''">#{readbookName,jdbcType=VARCHAR},</if>
+            <if test="readCycle != null">#{readCycle,jdbcType=SMALLINT},</if>
+            <if test="readbookType != null">#{readbookType,jdbcType=SMALLINT},</if>
+            <if test="gis != null and gis != ''">#{gis,jdbcType=VARCHAR},</if>
+            <if test="geomGis != null">#{geomGis,jdbcType=OTHER},</if>
+        </trim>
+        on conflict (code) do update set
+        <trim suffixOverrides=",">
+            <if test="name != null and name != ''">name = excluded.name,</if>
+            <if test="address != null and address != ''">address = excluded.address,</if>
+            <if test="caliber != null">caliber = excluded.caliber,</if>
+            <if test="natureName != null and natureName != ''">nature_name = excluded.nature_name,</if>
+            <if test="pressName != null and pressName != ''">press_name = excluded.press_name,</if>
+            <if test="usedTypeName != null and usedTypeName != ''">used_type_name = excluded.used_type_name,</if>
+            <if test="stampInfo != null and stampInfo != ''">stamp_info = excluded.stamp_info,</if>
+            updated_at = excluded.updated_at,
+            <if test="mobile != null and mobile != ''">mobile = excluded.mobile,</if>
+            <if test="statusCode != null">status_code = excluded.status_code,</if>
+            <if test="statusName != null and statusName != ''">status_name = excluded.status_name,</if>
+            <if test="readCycleName != null and readCycleName != ''">read_cycle_name = excluded.read_cycle_name,</if>
+            <if test="readerName != null and readerName != ''">reader_name = excluded.reader_name,</if>
+            <if test="readbookName != null and readbookName != ''">readbook_name = excluded.readbook_name,</if>
+            <if test="readCycle != null">read_cycle = excluded.read_cycle,</if>
+            <if test="readbookType != null">readbook_type = excluded.readbook_type,</if>
+            <if test="gis != null and gis != ''">gis = excluded.gis,</if>
+            <if test="geomGis != null">geom_gis = excluded.geom_gis,</if>
+        </trim>
+    </insert>
+</mapper>

+ 1 - 0
pom.xml

@@ -53,6 +53,7 @@
         <jjwt.version>0.9.0</jjwt.version>
         <okhttp.version>3.14.9</okhttp.version>
         <poi.version>3.17</poi.version>
+        <jts.version>1.19.0</jts.version>
     </properties>
 
     <!--依赖项-->