Quellcode durchsuchen

优化项目定位问题

Simon vor 1 Jahr
Ursprung
Commit
54762a6968

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

@@ -54,7 +54,7 @@ spring:
     basename: i18n/messages
   profiles:
     # 测试环境
-#        active: test
+#    active: test
     # 开发环境
 #    active: dev
     # 生产环境

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

@@ -7,23 +7,30 @@ import com.ruoyi.system.domain.dto.*;
 
 /**
  * 设备列Mapper接口
- * 
+ *
  * @author zhengjie
  * @date 2023-08-30
  */
-public interface TDeviceListMapper 
-{
+public interface TDeviceListMapper {
     /**
      * 查询设备列
-     * 
+     *
      * @param id 设备列主键
      * @return 设备列
      */
     public TDeviceList selectTDeviceListById(Integer id);
 
+    /**
+     * 查询设备列集合
+     *
+     * @param userId 用户ID
+     * @return 设备列集合
+     */
+    public List<TDeviceList> selectTDeviceListByUserId(Integer userId);
+
     /**
      * 查询设备列列表
-     * 
+     *
      * @param tDeviceList 设备列
      * @return 设备列集合
      */
@@ -171,7 +178,7 @@ public interface TDeviceListMapper
 
     /**
      * 新增设备列
-     * 
+     *
      * @param tDeviceList 设备列
      * @return 结果
      */
@@ -179,7 +186,7 @@ public interface TDeviceListMapper
 
     /**
      * 修改设备列
-     * 
+     *
      * @param tDeviceList 设备列
      * @return 结果
      */
@@ -187,7 +194,7 @@ public interface TDeviceListMapper
 
     /**
      * 删除设备列
-     * 
+     *
      * @param id 设备列主键
      * @return 结果
      */
@@ -195,7 +202,7 @@ public interface TDeviceListMapper
 
     /**
      * 批量删除设备列
-     * 
+     *
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */

+ 2 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TSearchLocationInfoServiceImpl.java

@@ -135,8 +135,8 @@ public class TSearchLocationInfoServiceImpl implements ITSearchLocationInfoServi
                         List<TShouhuanInfo> shouhuanInfos = shouhuanInfoService.selectTShouhuanInfoListBydeviceIdCode(mapper.getDeviceIdCode());
                         if (shouhuanInfos != null && !shouhuanInfos.isEmpty()) {
                             TShouhuanInfo shouhuanInfo = shouhuanInfos.get(0);
-                            mapper.setGpsLong(shouhuanInfo.getGpsLong());
-                            mapper.setGpsLat(shouhuanInfo.getGpsLat());
+                            mapper.setGpsLong(shouhuanInfo.getUseGpsLong());
+                            mapper.setGpsLat(shouhuanInfo.getUseGpsLat());
                         }
                         //配置设备电子围栏
                         mapper.setaMapFenceList(getAMapFenceByDeviceId(mapper.getDeviceId()));

+ 37 - 14
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TUserProfileServiceImpl.java

@@ -11,10 +11,12 @@ import java.util.List;
 
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.system.domain.TDeviceList;
 import com.ruoyi.system.domain.TServiceManage;
 import com.ruoyi.system.domain.dto.AddUserDto;
 import com.ruoyi.system.domain.dto.TUserProfileDto;
 import com.ruoyi.system.domain.dto.UserAgeDto;
+import com.ruoyi.system.mapper.TDeviceListMapper;
 import com.ruoyi.system.mapper.TEmergentPeopleMapper;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
@@ -45,6 +47,8 @@ public class TUserProfileServiceImpl implements ITUserProfileService {
     private TUserProfileMapper tUserProfileMapper;
     @Autowired
     private TEmergentPeopleMapper tEmergentPeopleMapper;
+    @Autowired
+    private TDeviceListMapper tDeviceListMapper;
 
     /**
      * 查询用户档案
@@ -144,19 +148,23 @@ public class TUserProfileServiceImpl implements ITUserProfileService {
         //根据身份证号查询数据库中的用户信息
         List<TUserProfile> userList = tUserProfileMapper.selectTUserProfileBySfzIdV2(tUserProfile.getSfzid());
         if (userList != null && !userList.isEmpty()) {
-            //如果表中有该用户则提示
-            StringBuilder stringBuilder = new StringBuilder();
-            stringBuilder.append("修改用户信息已存在");
-            //如果有用户名,则提示
-            if (!StringUtils.isEmpty(tUserProfile.getName())) {
-                stringBuilder.append(", 用户名:" + tUserProfile.getName());
-            }
-            //如果有身份证号,则提示
-            if (!StringUtils.isEmpty(tUserProfile.getSfzid())) {
-                stringBuilder.append(", 身份证号:" + tUserProfile.getSfzid());
+            for (TUserProfile profile : userList) {
+                if (profile.getId() != tUserProfile.getId()) {
+                    //如果表中有该用户则提示
+                    StringBuilder stringBuilder = new StringBuilder();
+                    stringBuilder.append("修改用户信息异常");
+                    //如果有用户名,则提示
+                    if (!StringUtils.isEmpty(tUserProfile.getName())) {
+                        stringBuilder.append(", 用户名:" + tUserProfile.getName());
+                    }
+                    //如果有身份证号,则提示
+                    if (!StringUtils.isEmpty(tUserProfile.getSfzid())) {
+                        stringBuilder.append(", 身份证号:" + tUserProfile.getSfzid());
+                    }
+                    stringBuilder.append("!");
+                    throw new ServiceException(stringBuilder.toString());
+                }
             }
-            stringBuilder.append("!");
-            throw new ServiceException(stringBuilder.toString());
         }
         tUserProfileMapper.deleteTEmergentPeopleByProfileId(tUserProfile.getId());
         insertTEmergentPeople(tUserProfile);
@@ -173,8 +181,23 @@ public class TUserProfileServiceImpl implements ITUserProfileService {
     @Transactional
     @Override
     public int deleteTUserProfileByIds(Integer[] ids) {
-        tUserProfileMapper.deleteTEmergentPeopleByProfileIds(ids);
-        return tUserProfileMapper.deleteTUserProfileByIds(ids);
+        //判断是否为空
+        if (ids == null || ids.length == 0) {
+            throw new ServiceException("删除的用户主键禁止为空!");
+        }
+        //
+        int count = 0;
+        for (Integer userId : ids) {
+            List<TDeviceList> tDeviceLists = tDeviceListMapper.selectTDeviceListByUserId(userId);
+            //判断用户是否有设备
+            if (tDeviceLists != null && !tDeviceLists.isEmpty()) {
+                //如果有设备,则提示删除用户失败
+                throw new ServiceException("该用户有绑定设备,禁止删除!");
+            }
+            tUserProfileMapper.deleteTEmergentPeopleByProfileId(userId);
+            count = count + tUserProfileMapper.deleteTUserProfileByIds(ids);
+        }
+        return count;
     }
 
     /**

+ 5 - 0
ruoyi-system/src/main/resources/mapper/system/TDeviceListMapper.xml

@@ -181,6 +181,11 @@
         <include refid="selectTDeviceListVo"/>
     </select>
 
+    <select id="selectTDeviceListByUserId" parameterType="Integer" resultMap="TDeviceListResult">
+        <include refid="selectTDeviceListVo"/>
+        where userid = #{userid}
+    </select>
+
 
     <insert id="insertTDeviceList" parameterType="TDeviceList" useGeneratedKeys="true" keyProperty="id">
         insert into t_device_list