|
@@ -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;
|
|
|
}
|
|
|
|
|
|
/**
|