Explorar o código

优化设备上传功能

Simon %!s(int64=2) %!d(string=hai) anos
pai
achega
858b02a03c

+ 16 - 4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TDeviceListController.java

@@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletResponse;
 
 import com.alibaba.fastjson2.JSONObject;
 import com.ruoyi.system.domain.TServiceManage;
+import com.ruoyi.system.domain.TUserProfile;
 import com.ruoyi.system.domain.dto.*;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -111,20 +112,31 @@ public class TDeviceListController extends BaseController
         util.importTemplateExcel(response, "设备列表模板");
     }
 
+//    /**
+//     * 导入
+//     */
+//    @Log(title = "设备列表", businessType = BusinessType.IMPORT)
+//    @PostMapping("/importData")
+//    @ResponseBody
+//    public AjaxResult importData(MultipartFile file) throws Exception
+//    {
+//        ExcelUtil<TDeviceList> util = new ExcelUtil<TDeviceList>(TDeviceList.class);
+//        List<TDeviceList> tDeviceLists = util.importExcel(file.getInputStream());
+//        String message = tDeviceListService.importTDeviceList(tDeviceLists);
+//        return AjaxResult.success(message);
+//    }
     /**
      * 导入
      */
     @Log(title = "设备列表", businessType = BusinessType.IMPORT)
     @PostMapping("/importData")
     @ResponseBody
-    public AjaxResult importData(MultipartFile file) throws Exception
-    {
+    public AjaxResult importDataV2(MultipartFile file) throws Exception {
         ExcelUtil<TDeviceList> util = new ExcelUtil<TDeviceList>(TDeviceList.class);
         List<TDeviceList> tDeviceLists = util.importExcel(file.getInputStream());
-        String message = tDeviceListService.importTDeviceList(tDeviceLists);
+        String message = tDeviceListService.importTDeviceListV2(tDeviceLists);
         return AjaxResult.success(message);
     }
-
     /**
      * 查询心率列表
      */

+ 2 - 2
ruoyi-admin/src/main/resources/application.yml

@@ -56,9 +56,9 @@ spring:
     # 测试环境
     #    active: test
     # 开发环境
-#    active: dev
+    active: dev
     # 生产环境
-    active: druid
+#    active: druid
 
   # 文件上传
   servlet:

+ 16 - 9
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TFacilityMapper.java

@@ -4,27 +4,34 @@ import java.util.List;
 
 import com.ruoyi.common.annotation.DataSource;
 import com.ruoyi.common.enums.DataSourceType;
+import com.ruoyi.system.domain.TDeviceList;
 import com.ruoyi.system.domain.TFacility;
 
 /**
  * 手环设备Mapper接口
- * 
+ *
  * @author zhengjie
  * @date 2023-08-12
  */
-public interface TFacilityMapper 
-{
+public interface TFacilityMapper {
     /**
      * 查询手环设备
-     * 
+     *
      * @param id 手环设备主键
      * @return 手环设备
      */
     public TFacility selectTFacilityById(Long id);
 
+    /**
+     * 查询设备列列表
+     *
+     * @return 设备列集合
+     */
+    public List<TFacility> selectTDeviceListListByDeviceId(String device_id_code);
+
     /**
      * 查询手环设备列表
-     * 
+     *
      * @param tFacility 手环设备
      * @return 手环设备集合
      */
@@ -32,7 +39,7 @@ public interface TFacilityMapper
 
     /**
      * 新增手环设备
-     * 
+     *
      * @param tFacility 手环设备
      * @return 结果
      */
@@ -40,7 +47,7 @@ public interface TFacilityMapper
 
     /**
      * 修改手环设备
-     * 
+     *
      * @param tFacility 手环设备
      * @return 结果
      */
@@ -48,7 +55,7 @@ public interface TFacilityMapper
 
     /**
      * 删除手环设备
-     * 
+     *
      * @param id 手环设备主键
      * @return 结果
      */
@@ -56,7 +63,7 @@ public interface TFacilityMapper
 
     /**
      * 批量删除手环设备
-     * 
+     *
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */

+ 17 - 9
ruoyi-system/src/main/java/com/ruoyi/system/service/ITDeviceListService.java

@@ -1,21 +1,21 @@
 package com.ruoyi.system.service;
 
 import java.util.List;
+
 import com.ruoyi.system.domain.TDeviceList;
 import com.ruoyi.system.domain.TServiceManage;
 import com.ruoyi.system.domain.dto.*;
 
 /**
  * 设备列Service接口
- * 
+ *
  * @author zhengjie
  * @date 2023-08-30
  */
-public interface ITDeviceListService 
-{
+public interface ITDeviceListService {
     /**
      * 查询设备列
-     * 
+     *
      * @param id 设备列主键
      * @return 设备列
      */
@@ -23,7 +23,7 @@ public interface ITDeviceListService
 
     /**
      * 查询设备列列表
-     * 
+     *
      * @param tDeviceList 设备列
      * @return 设备列集合
      */
@@ -93,9 +93,17 @@ public interface ITDeviceListService
      */
     public String importTDeviceList(List<TDeviceList> tDeviceLists);
 
+    /**
+     * 导入设备列表数据
+     *
+     * @param tDeviceLists 设备列表列表
+     * @return 结果
+     */
+    public String importTDeviceListV2(List<TDeviceList> tDeviceLists);
+
     /**
      * 新增设备列
-     * 
+     *
      * @param tDeviceList 设备列
      * @return 结果
      */
@@ -103,7 +111,7 @@ public interface ITDeviceListService
 
     /**
      * 修改设备列
-     * 
+     *
      * @param tDeviceList 设备列
      * @return 结果
      */
@@ -111,7 +119,7 @@ public interface ITDeviceListService
 
     /**
      * 批量删除设备列
-     * 
+     *
      * @param ids 需要删除的设备列主键集合
      * @return 结果
      */
@@ -119,7 +127,7 @@ public interface ITDeviceListService
 
     /**
      * 删除设备列信息
-     * 
+     *
      * @param id 设备列主键
      * @return 结果
      */

+ 126 - 57
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TDeviceListServiceImpl.java

@@ -17,16 +17,16 @@ import org.springframework.stereotype.Service;
 import com.ruoyi.system.mapper.TDeviceListMapper;
 import com.ruoyi.system.domain.TDeviceList;
 import com.ruoyi.system.service.ITDeviceListService;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 设备列Service业务层处理
- * 
+ *
  * @author zhengjie
  * @date 2023-08-30
  */
 @Service
-public class TDeviceListServiceImpl implements ITDeviceListService 
-{
+public class TDeviceListServiceImpl implements ITDeviceListService {
     @Autowired
     private TDeviceListMapper tDeviceListMapper;
     @Autowired
@@ -36,25 +36,23 @@ public class TDeviceListServiceImpl implements ITDeviceListService
 
     /**
      * 查询设备列
-     * 
+     *
      * @param id 设备列主键
      * @return 设备列
      */
     @Override
-    public TDeviceList selectTDeviceListById(Integer id)
-    {
+    public TDeviceList selectTDeviceListById(Integer id) {
         return tDeviceListMapper.selectTDeviceListById(id);
     }
 
     /**
      * 查询设备列列表
-     * 
+     *
      * @param tDeviceList 设备列
      * @return 设备列
      */
     @Override
-    public List<TDeviceList> selectTDeviceListList(TDeviceList tDeviceList)
-    {
+    public List<TDeviceList> selectTDeviceListList(TDeviceList tDeviceList) {
         return tDeviceListMapper.selectTDeviceListList(tDeviceList);
     }
 
@@ -95,19 +93,19 @@ public class TDeviceListServiceImpl implements ITDeviceListService
 
     /**
      * 新增设备列
-     * 
+     *
      * @param tDeviceList 设备列
      * @return 结果
      */
+    @Transactional
     @Override
-    public int insertTDeviceList(TDeviceList tDeviceList)
-    {
+    public int insertTDeviceList(TDeviceList tDeviceList) {
         TFacility tFacility = new TFacility();
-        if (StringUtils.isNotNull(tDeviceList.getDeviceId())){
+        if (StringUtils.isNotNull(tDeviceList.getDeviceId())) {
             tFacility.setCode(tDeviceList.getDeviceId());
-        }else if (StringUtils.isNotNull(tDeviceList.getSimCode())){
+        } else if (StringUtils.isNotNull(tDeviceList.getSimCode())) {
             tFacility.setTelno(tDeviceList.getSimCode());
-        }else if (StringUtils.isNotNull(tDeviceList.getSerialNumber())){
+        } else if (StringUtils.isNotNull(tDeviceList.getSerialNumber())) {
             tFacility.setIccid(tDeviceList.getSerialNumber());
         }
         tFacility.setCreateTime(DateUtils.getNowDate());
@@ -118,92 +116,163 @@ public class TDeviceListServiceImpl implements ITDeviceListService
 
     /**
      * 修改设备列
-     * 
+     *
      * @param tDeviceList 设备列
      * @return 结果
      */
     @Override
-    public int updateTDeviceList(TDeviceList tDeviceList)
-    {
+    public int updateTDeviceList(TDeviceList tDeviceList) {
         return tDeviceListMapper.updateTDeviceList(tDeviceList);
     }
 
     /**
      * 批量删除设备列
-     * 
+     *
      * @param ids 需要删除的设备列主键
      * @return 结果
      */
     @Override
-    public int deleteTDeviceListByIds(Integer[] ids)
-    {
+    public int deleteTDeviceListByIds(Integer[] ids) {
         return tDeviceListMapper.deleteTDeviceListByIds(ids);
     }
 
     /**
      * 删除设备列信息
-     * 
+     *
      * @param id 设备列主键
      * @return 结果
      */
     @Override
-    public int deleteTDeviceListById(Integer id)
-    {
+    public int deleteTDeviceListById(Integer id) {
         return tDeviceListMapper.deleteTDeviceListById(id);
     }
 
     @Override
     public String importTDeviceList(List<TDeviceList> tDeviceLists) {
 
-        if (StringUtils.isNull(tDeviceLists) || tDeviceLists.size() == 0)
-        {
+        if (StringUtils.isNull(tDeviceLists) || tDeviceLists.size() == 0) {
             throw new ServiceException("导入设备列表信息数据不能为空!");
         }
         int successNum = 0;
         int failureNum = 0;
         StringBuilder successMsg = new StringBuilder();
         StringBuilder failureMsg = new StringBuilder();
-        for (TDeviceList tDeviceList : tDeviceLists)
-        {
-            try
-            {
+        for (TDeviceList tDeviceList : tDeviceLists) {
+            try {
                 TUserProfile user = tUserProfileMapper.selectTUserProfileBySfzId(tDeviceList.getSfzid());
                 TDeviceList device = tDeviceListMapper.selectTDeviceListListByDeviceId(tDeviceList.getDeviceId());
-                if (StringUtils.isNotNull(user) && StringUtils.isNull(device))
-                {
+                if (StringUtils.isNotNull(user) && StringUtils.isNull(device)) {
                     tDeviceList.setUserid(user.getId());
                     tDeviceList.setSfzid(user.getSfzid());
                     tDeviceList.setTelno(user.getTelOne());
                     this.insertTDeviceList(tDeviceList);
                     successNum++;
                     successMsg.append("<br/>" + successNum + "设备列表信息" + " 导入成功");
-                }
-                else
-                {
+                } else {
                     failureNum++;
                     failureMsg.append("<br/>" + failureNum + "设备列表信息" + " 信息不完整");
                 }
-            }
-            catch (Exception e)
-            {
+            } catch (Exception e) {
                 failureNum++;
                 String msg = "<br/>" + failureNum + "设备列表信息" + " 导入失败:";
                 failureMsg.append(msg + e.getMessage());
             }
         }
-        if (failureNum > 0)
-        {
+        if (failureNum > 0) {
             failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
             throw new ServiceException(failureMsg.toString());
-        }
-        else
-        {
+        } else {
             successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
         }
         return successMsg.toString();
 
     }
 
+    @Transactional
+    @Override
+    public String importTDeviceListV2(List<TDeviceList> tDeviceLists) {
+        if (tDeviceLists == null || tDeviceLists.isEmpty()) {
+            throw new ServiceException("导入设备列表信息数据不能为空!");
+        }
+        //批量导入设备数据
+        for (TDeviceList deviceListEntity : tDeviceLists) {
+            //判断提交数据格式是否正确
+            if (deviceListEntity.getSfzid() == null || deviceListEntity.getSfzid().isEmpty()) {
+                throw new ServiceException("导入设备数信息身份证号格式异常!");
+            }
+            //根据身份证号查询数据库中的用户信息
+            TUserProfile user = tUserProfileMapper.selectTUserProfileBySfzId(deviceListEntity.getSfzid());
+            if (user == null) {
+                //如果表中有该用户则提示
+                StringBuilder stringBuilder = new StringBuilder();
+                stringBuilder.append("导入设备数信息未匹配到用户");
+                //如果有设备标识ID,则提示
+                if (!StringUtils.isEmpty(deviceListEntity.getDeviceId())) {
+                    stringBuilder.append(", 设备标识ID:" + deviceListEntity.getDeviceId());
+                }
+                //如果有设备标识ID,则提示
+                if (!StringUtils.isEmpty(deviceListEntity.getName())) {
+                    stringBuilder.append(", 用户名:" + deviceListEntity.getName());
+                }
+                //如果有身份证号,则提示
+                if (!StringUtils.isEmpty(deviceListEntity.getSfzid())) {
+                    stringBuilder.append(", 身份证号:" + deviceListEntity.getSfzid());
+                }
+                stringBuilder.append("!");
+                throw new ServiceException(stringBuilder.toString());
+            }
+            //根据设备ID查询数据库中的设备信息
+            List<TFacility> facilityList = tFacilityMapper.selectTDeviceListListByDeviceId(deviceListEntity.getDeviceId());
+            if (facilityList != null && !facilityList.isEmpty()) {
+                //如果表中有该用户则提示
+                StringBuilder stringBuilder = new StringBuilder();
+                stringBuilder.append("导入设备信息已存在");
+                //如果有设备标识ID,则提示
+                if (!StringUtils.isEmpty(deviceListEntity.getDeviceId())) {
+                    stringBuilder.append(", 设备标识ID:" + deviceListEntity.getDeviceId());
+                }
+                //如果有设备标识ID,则提示
+                if (!StringUtils.isEmpty(deviceListEntity.getName())) {
+                    stringBuilder.append(", 用户名:" + deviceListEntity.getName());
+                }
+                //如果有身份证号,则提示
+                if (!StringUtils.isEmpty(deviceListEntity.getSfzid())) {
+                    stringBuilder.append(", 身份证号:" + deviceListEntity.getSfzid());
+                }
+                stringBuilder.append("!");
+                throw new ServiceException(stringBuilder.toString());
+            }
+            //根据设备ID查询数据库中的设备信息
+            TDeviceList device = tDeviceListMapper.selectTDeviceListListByDeviceId(deviceListEntity.getDeviceId());
+            if (device != null) {
+                //如果表中有该用户则提示
+                StringBuilder stringBuilder = new StringBuilder();
+                stringBuilder.append("导入设备信息已存在");
+                //如果有设备标识ID,则提示
+                if (!StringUtils.isEmpty(deviceListEntity.getDeviceId())) {
+                    stringBuilder.append(", 设备标识ID:" + deviceListEntity.getDeviceId());
+                }
+                //如果有设备标识ID,则提示
+                if (!StringUtils.isEmpty(deviceListEntity.getName())) {
+                    stringBuilder.append(", 用户名:" + deviceListEntity.getName());
+                }
+                //如果有身份证号,则提示
+                if (!StringUtils.isEmpty(deviceListEntity.getSfzid())) {
+                    stringBuilder.append(", 身份证号:" + deviceListEntity.getSfzid());
+                }
+                stringBuilder.append("!");
+                throw new ServiceException(stringBuilder.toString());
+            }
+            deviceListEntity.setUserid(user.getId());
+            deviceListEntity.setSfzid(user.getSfzid());
+            deviceListEntity.setTelno(user.getTelOne());
+            this.insertTDeviceList(deviceListEntity);
+        }
+        StringBuilder successMsg = new StringBuilder();
+        successMsg.append("恭喜您,数据已全部导入成功!共 " + tDeviceLists.size() + " 条,数据如下:");
+        return successMsg.toString();
+    }
+
     /**
      * 判断报警信息
      *
@@ -211,8 +280,8 @@ public class TDeviceListServiceImpl implements ITDeviceListService
      * @return 结果
      */
     @Override
-    public String checkMessage(Integer alarm_type){
-        switch (alarm_type){
+    public String checkMessage(Integer alarm_type) {
+        switch (alarm_type) {
             case 16:
                 return "SOS报警";
             case 17:
@@ -236,39 +305,39 @@ public class TDeviceListServiceImpl implements ITDeviceListService
 
     @Override
     public int deviceValue(CallPoliceDto callPoliceDto) {
-        if (StringUtils.isNotNull(callPoliceDto)){
-            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_blood_high_max())){
+        if (StringUtils.isNotNull(callPoliceDto)) {
+            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_blood_high_max())) {
                 tDeviceListMapper.updateTSettingshouhuan_blood_high_max(callPoliceDto.getShouhuan_blood_high_max());
             }
-            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_blood_high_min())){
+            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_blood_high_min())) {
                 tDeviceListMapper.updateTSettingshouhuan_blood_high_min(callPoliceDto.getShouhuan_blood_high_min());
             }
-            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_blood_low_max())){
+            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_blood_low_max())) {
                 tDeviceListMapper.updateTSettingshouhuan_blood_low_max(callPoliceDto.getShouhuan_blood_low_max());
             }
-            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_blood_low_min())){
+            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_blood_low_min())) {
                 tDeviceListMapper.updateTSettingshouhuan_blood_low_min(callPoliceDto.getShouhuan_blood_low_min());
             }
-            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_body_max())){
+            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_body_max())) {
                 tDeviceListMapper.updateTSettingshouhuan_body_max(callPoliceDto.getShouhuan_body_max());
             }
-            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_body_min())){
+            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_body_min())) {
                 tDeviceListMapper.updateTSettingshouhuan_body_min(callPoliceDto.getShouhuan_body_min());
             }
-            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_oxygen_max())){
+            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_oxygen_max())) {
                 tDeviceListMapper.updateTSettingshouhuan_oxygen_max(callPoliceDto.getShouhuan_oxygen_max());
             }
-            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_oxygen_min())){
+            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_oxygen_min())) {
                 tDeviceListMapper.updateTSettingshouhuan_oxygen_min(callPoliceDto.getShouhuan_oxygen_min());
             }
-            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_heart_max())){
+            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_heart_max())) {
                 tDeviceListMapper.updateTSettingshouhuan_heart_max(callPoliceDto.getShouhuan_heart_max());
             }
-            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_heart_min())){
+            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_heart_min())) {
                 tDeviceListMapper.updateTSettingshouhuan_heart_min(callPoliceDto.getShouhuan_heart_min());
             }
             return 1;
-        }else{
+        } else {
             return 0;
         }
     }

+ 44 - 28
ruoyi-system/src/main/resources/mapper/system/TFacilityMapper.xml

@@ -1,44 +1,58 @@
 <?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">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.system.mapper.TFacilityMapper">
-    
+
     <resultMap type="TFacility" id="TFacilityResult">
-        <result property="id"    column="id"    />
-        <result property="kind"    column="kind"    />
-        <result property="code"    column="code"    />
-        <result property="telno"    column="telno"    />
-        <result property="comCode"    column="com_code"    />
-        <result property="createTime"    column="createtime"    />
-        <result property="status"    column="status"    />
-        <result property="iccid"    column="iccid"    />
-        <result property="puk"    column="puk"    />
+        <result property="id" column="id"/>
+        <result property="kind" column="kind"/>
+        <result property="code" column="code"/>
+        <result property="telno" column="telno"/>
+        <result property="comCode" column="com_code"/>
+        <result property="createTime" column="createtime"/>
+        <result property="status" column="status"/>
+        <result property="iccid" column="iccid"/>
+        <result property="puk" column="puk"/>
     </resultMap>
 
     <sql id="selectTFacilityVo">
-        select id, kind, code, telno, com_code, createtime, status, iccid, puk from t_facility
+        select id,
+               kind,
+               code,
+               telno,
+               com_code,
+               createtime,
+               status,
+               iccid,
+               puk
+        from t_facility
     </sql>
 
     <select id="selectTFacilityList" parameterType="TFacility" resultMap="TFacilityResult">
         <include refid="selectTFacilityVo"/>
-        <where>  
-            <if test="kind != null "> and kind = #{kind}</if>
-            <if test="code != null  and code != ''"> and code = #{code}</if>
-            <if test="telno != null  and telno != ''"> and telno = #{telno}</if>
-            <if test="comCode != null  and comCode != ''"> and com_code = #{comCode}</if>
-            <if test="createTime != null "> and createtime = #{createTime}</if>
-            <if test="status != null "> and status = #{status}</if>
-            <if test="iccid != null "> and iccid = #{iccid}</if>
-            <if test="puk != null "> and puk = #{puk}</if>
+        <where>
+            <if test="kind != null ">and kind = #{kind}</if>
+            <if test="code != null  and code != ''">and code = #{code}</if>
+            <if test="telno != null  and telno != ''">and telno = #{telno}</if>
+            <if test="comCode != null  and comCode != ''">and com_code = #{comCode}</if>
+            <if test="createTime != null ">and createtime = #{createTime}</if>
+            <if test="status != null ">and status = #{status}</if>
+            <if test="iccid != null ">and iccid = #{iccid}</if>
+            <if test="puk != null ">and puk = #{puk}</if>
         </where>
     </select>
-    
+
     <select id="selectTFacilityById" parameterType="Long" resultMap="TFacilityResult">
         <include refid="selectTFacilityVo"/>
         where id = #{id}
     </select>
-        
+
+    <select id="selectTDeviceListListByDeviceId" parameterType="string" resultMap="TFacilityResult">
+        <include refid="selectTFacilityVo"/>
+        where code = #{code}
+    </select>
+
     <insert id="insertTFacility" parameterType="TFacility" useGeneratedKeys="true" keyProperty="id">
         insert into t_facility
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -50,7 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="status != null">status,</if>
             <if test="iccid != null">iccid,</if>
             <if test="puk != null">puk,</if>
-         </trim>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="kind != null">#{kind},</if>
             <if test="code != null">#{code},</if>
@@ -60,7 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="status != null">#{status},</if>
             <if test="iccid != null">#{iccid},</if>
             <if test="puk != null">#{puk},</if>
-         </trim>
+        </trim>
     </insert>
 
     <update id="updateTFacility" parameterType="TFacility">
@@ -79,11 +93,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </update>
 
     <delete id="deleteTFacilityById" parameterType="Long">
-        delete from t_facility where id = #{id}
+        delete
+        from t_facility
+        where id = #{id}
     </delete>
 
     <delete id="deleteTFacilityByIds" parameterType="String">
-        delete from t_facility where id in 
+        delete from t_facility where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>