Browse Source

优化项目新增用户、修改用户重复问题问题(身份证号查询)

Simon 1 year ago
parent
commit
77a48b1563

+ 53 - 66
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TDataDisplayController.java

@@ -27,14 +27,13 @@ import java.util.stream.Collectors;
 
 /**
  * 数据大屏Controller
- * 
+ *
  * @author zhengjie
  * @date 2023-09-08
  */
 @RestController
 @RequestMapping("/system/display")
-public class TDataDisplayController extends BaseController
-{
+public class TDataDisplayController extends BaseController {
     @Autowired
     private ITShouhuanAlarmListService tShouhuanAlarmListService;
 
@@ -54,32 +53,30 @@ public class TDataDisplayController extends BaseController
      * 查询SOS预警处理列表
      */
     @GetMapping("/list")
-    public TableDataInfo list(DataAlarmListDto dataAlarmListDto)
-    {
+    public TableDataInfo list(DataAlarmListDto dataAlarmListDto) {
         startPage();
         List<DataAlarmListDto> list = tShouhuanAlarmListService.selectTShouhuanAlarmList(dataAlarmListDto);
-        List<AlarmListDto> alarmListDtoList = new ArrayList<>();
-        for (DataAlarmListDto dto : list){
-            AlarmListDto alarmListDto = new AlarmListDto();
-            alarmListDto.setName(dto.getName());
-            alarmListDto.setTelno(dto.getTel_one());
-            alarmListDto.setLocation(getCounterLocation(dto.getGps_long() + "," + dto.getGps_lat()));
-            alarmListDto.setAlarmMessage(tDeviceListService.checkMessage(dto.getAlarm_type()));
-            alarmListDto.setCreatetime(dto.getCreatetime());
-            alarmListDtoList.add(alarmListDto);
-        }
-        return getDataTable1(alarmListDtoList,tShouhuanAlarmListService.selectTShouhuanAlarmListCount());
+        List<AlarmListDto> alarmListDtos = list.stream().map(
+                mapper -> {
+                    AlarmListDto alarmListDto = new AlarmListDto();
+                    alarmListDto.setName(mapper.getName());
+                    alarmListDto.setTelno(mapper.getTel_one());
+                    alarmListDto.setLocation(getCounterLocation(mapper.getGps_long() + "," + mapper.getGps_lat()));
+                    alarmListDto.setAlarmMessage(tDeviceListService.checkMessage(mapper.getAlarm_type()));
+                    alarmListDto.setCreatetime(mapper.getCreatetime());
+                    return alarmListDto;
+                }
+        ).collect(Collectors.toList());
+        return getDataTable1(alarmListDtos, tShouhuanAlarmListService.selectTShouhuanAlarmListCount());
     }
 
     @GetMapping("/count")
-    public AjaxResult count()
-    {
+    public AjaxResult count() {
         return success(userProfileService.selectuserAgeCount());
     }
 
     @GetMapping("/alarm")
-    public AjaxResult alarm()
-    {
+    public AjaxResult alarm() {
         AlarmStatusDto dto = new AlarmStatusDto();
         dto.setAlarmSOSSolve(tShouhuanAlarmListService.selectTShouhuanAlarmSOSSolve());
         dto.setUn_alarmSOSSolve(tShouhuanAlarmListService.selectTShouhuanAlarmSOS() - tShouhuanAlarmListService.selectTShouhuanAlarmSOSSolve());
@@ -97,22 +94,20 @@ public class TDataDisplayController extends BaseController
     }
 
     @GetMapping("/percent")
-    public AjaxResult percent()
-    {
+    public AjaxResult percent() {
         AlarmPercentDto dto = new AlarmPercentDto();
-        dto.setAlarmSOS(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmSOSSolve(),tShouhuanAlarmListService.selectTShouhuanAlarmSOS()));
-        dto.setAlarmRail(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmRailSolve(),tShouhuanAlarmListService.selectTShouhuanAlarmRail()));
-        dto.setAlarmFall(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmFallSolve(),tShouhuanAlarmListService.selectTShouhuanAlarmFall()));
+        dto.setAlarmSOS(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmSOSSolve(), tShouhuanAlarmListService.selectTShouhuanAlarmSOS()));
+        dto.setAlarmRail(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmRailSolve(), tShouhuanAlarmListService.selectTShouhuanAlarmRail()));
+        dto.setAlarmFall(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmFallSolve(), tShouhuanAlarmListService.selectTShouhuanAlarmFall()));
         int statusSum = tShouhuanAlarmListService.selectTShouhuanAlarmStatus() + tShouhuanAlarmListService.selectTShouhuanAlarmStatusSolve();
-        dto.setAlarmStauts(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmStatus(),statusSum));
+        dto.setAlarmStauts(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmStatus(), statusSum));
         int alarmAll = tShouhuanAlarmListService.selectTShouhuanAlarmSOSSolve() + tShouhuanAlarmListService.selectTShouhuanAlarmRailSolve() + tShouhuanAlarmListService.selectTShouhuanAlarmRailSolve() + tShouhuanAlarmListService.selectTShouhuanAlarmFallSolve() + tShouhuanAlarmListService.selectTShouhuanAlarmOtherSolve();
-        dto.setAlarmAll(checkPercent(alarmAll,tShouhuanAlarmListService.selectTShouhuanAlarmListCount()));
+        dto.setAlarmAll(checkPercent(alarmAll, tShouhuanAlarmListService.selectTShouhuanAlarmListCount()));
         return success(dto);
     }
 
     @GetMapping("/deviceView")
-    public AjaxResult deviceView()
-    {
+    public AjaxResult deviceView() {
         DeviceViewDto dto = new DeviceViewDto();
         dto.setDeviceCount(tShouhuanAlarmListService.selectTShouhuanAlarmStatus() + tShouhuanAlarmListService.selectTShouhuanAlarmStatusSolve());
         dto.setDeviceOnline(tShouhuanAlarmListService.selectTShouhuanAlarmStatus());
@@ -122,41 +117,38 @@ public class TDataDisplayController extends BaseController
     }
 
     @GetMapping("/deviceType")
-    public AjaxResult deviceType()
-    {
+    public AjaxResult deviceType() {
         Integer total = tDeviceListService.selectDeviceListCount();
         List<DeviceTypeDto> deviceListDto = tDeviceListService.selectDeviceListDto();
-        for (DeviceTypeDto listDto : deviceListDto){
+        for (DeviceTypeDto listDto : deviceListDto) {
             listDto.setDeviceStr(checkDeviceType(listDto.getDevice_model()));
-            listDto.setDevicePercent(checkPercent(listDto.getCount(),total));
+            listDto.setDevicePercent(checkPercent(listDto.getCount(), total));
         }
         AjaxResult ajax = new AjaxResult();
-        ajax.put("list",deviceListDto);
+        ajax.put("list", deviceListDto);
         ajax.put("total", total);
-        return AjaxResult.success("操作成功",ajax);
+        return AjaxResult.success("操作成功", ajax);
     }
 
     @GetMapping("/userAgeAll")
-    public AjaxResult userAgeAll()
-    {
+    public AjaxResult userAgeAll() {
         Integer total = userProfileService.selectuserAgeCount();
         List<UserAgeDto> dtoList = userProfileService.selectuserAgeDto();
         dtoList.removeIf(user -> StringUtils.isNull(user.getAge()));
         AjaxResult ajax = new AjaxResult();
-        ajax.put("list",dtoList);
+        ajax.put("list", dtoList);
         ajax.put("total", total);
-        return AjaxResult.success("操作成功",ajax);
+        return AjaxResult.success("操作成功", ajax);
     }
 
     @GetMapping("/mapGpsView")
-    public AjaxResult mapGpsView()
-    {
+    public AjaxResult mapGpsView() {
         List<MapGpsDto> dtoList = itShouhuanInfoService.selectMapGpsView();
         AjaxResult ajax = new AjaxResult();
         ajax.put("lnglat", dtoList);
         AjaxResult ajax1 = new AjaxResult();
-        ajax1.put("pointList",ajax);
-        return AjaxResult.success("操作成功",ajax1);
+        ajax1.put("pointList", ajax);
+        return AjaxResult.success("操作成功", ajax1);
     }
 
     @GetMapping("/mapGpsViewV2")
@@ -187,8 +179,7 @@ public class TDataDisplayController extends BaseController
      * 用户新增
      */
     @GetMapping("/addUser")
-    public AjaxResult addUser()
-    {
+    public AjaxResult addUser() {
         List<AddUserDto> dtoList = userProfileService.selectAddUser();
         return success(dtoList);
     }
@@ -197,21 +188,20 @@ public class TDataDisplayController extends BaseController
      * 设备新增
      */
     @GetMapping("/addDevice")
-    public AjaxResult addDevice()
-    {
+    public AjaxResult addDevice() {
         List<AddDeviceDto> dtoList = tDeviceListService.selectAddDevice();
         LocalDate currentDate = LocalDate.now();
         LocalDate lastMonthDate = currentDate.minusMonths(1);
-        int year= currentDate.getYear();
-        if (dtoList.size() == 2){
-            int lastMonth = lastMonthDate.getMonthValue()-1;
+        int year = currentDate.getYear();
+        if (dtoList.size() == 2) {
+            int lastMonth = lastMonthDate.getMonthValue() - 1;
             AddDeviceDto dto = new AddDeviceDto();
             dto.setMonth(year + "-0" + lastMonth);
             dto.setCount(0);
             dtoList.add(dto);
-        }else if (dtoList.size() == 1){
+        } else if (dtoList.size() == 1) {
             int lastMonth = lastMonthDate.getMonthValue();
-            int lastlastMonth = lastMonthDate.getMonthValue()-1;
+            int lastlastMonth = lastMonthDate.getMonthValue() - 1;
             AddDeviceDto dto = new AddDeviceDto();
             dto.setMonth(year + "-0" + lastMonth);
             dto.setCount(0);
@@ -226,10 +216,9 @@ public class TDataDisplayController extends BaseController
     }
 
     @GetMapping("/alarmStatusList")
-    public AjaxResult alarmStatusList()
-    {
+    public AjaxResult alarmStatusList() {
         List<AlarmStatusListDto> dtoList = tShouhuanAlarmListService.selectAlarmStatusListDto();
-        for (AlarmStatusListDto dto : dtoList){
+        for (AlarmStatusListDto dto : dtoList) {
             dto.setAlarm_msg(tDeviceListService.checkMessage(dto.getAlarm_type()));
         }
         return success(dtoList);
@@ -239,8 +228,7 @@ public class TDataDisplayController extends BaseController
      * 设备总览
      */
     @GetMapping("/deviceOver")
-    public AjaxResult deviceOver()
-    {
+    public AjaxResult deviceOver() {
         DeviceOverDto dto = new DeviceOverDto();
         dto.setBindDevice(tDeviceListService.selectDeviceListCount());
         dto.setBindUser(tDeviceListService.selectTDeviceListBandUser());
@@ -252,11 +240,10 @@ public class TDataDisplayController extends BaseController
      * 查询SOS预警处理列表
      */
     @GetMapping("/alarmList")
-    public AjaxResult alarmList(DataAlarmListDto dataAlarmListDto)
-    {
+    public AjaxResult alarmList(DataAlarmListDto dataAlarmListDto) {
         List<DataAlarmListDto> list = tShouhuanAlarmListService.selectTShouhuanAlarmList(dataAlarmListDto);
         List<MessageAlarmListDto> messageAlarmListDtoList = new ArrayList<>();
-        for (DataAlarmListDto dto : list){
+        for (DataAlarmListDto dto : list) {
             MessageAlarmListDto alarmListDto = new MessageAlarmListDto();
             alarmListDto.setName(dto.getName());
             alarmListDto.setAlarm_msg(tDeviceListService.checkMessage(dto.getAlarm_type()));
@@ -272,13 +259,13 @@ public class TDataDisplayController extends BaseController
     }
 
 
-
     /**
      * 逆地理编码
+     *
      * @param location
      * @return
      */
-    public String getCounterLocation(String location){
+    public String getCounterLocation(String location) {
 
         Map<String, String> params = new HashMap<>();
         params.put("location", location);
@@ -292,15 +279,15 @@ public class TDataDisplayController extends BaseController
     /**
      * 计算百分比
      */
-    public String checkPercent(int num1, int num2){
+    public String checkPercent(int num1, int num2) {
         NumberFormat numberFormat = NumberFormat.getInstance();
         numberFormat.setMaximumFractionDigits(2);
-        String result = numberFormat.format((float)num1/(float)num2*100);
+        String result = numberFormat.format((float) num1 / (float) num2 * 100);
         return result;
     }
 
-    public String checkDeviceType(Integer device_model){
-        switch (device_model){
+    public String checkDeviceType(Integer device_model) {
+        switch (device_model) {
             case 0:
                 return "S8";
             case 1:

+ 21 - 14
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TUserProfileMapper.java

@@ -13,15 +13,14 @@ import com.ruoyi.system.domain.dto.UserAgeDto;
 
 /**
  * 用户档案Mapper接口
- * 
+ *
  * @author zhengjie
  * @date 2023-08-25
  */
-public interface TUserProfileMapper 
-{
+public interface TUserProfileMapper {
     /**
      * 查询用户档案
-     * 
+     *
      * @param id 用户档案主键
      * @return 用户档案
      */
@@ -35,9 +34,17 @@ public interface TUserProfileMapper
      */
     public TUserProfile selectTUserProfileBySfzId(String sfzid);
 
+    /**
+     * 查询用户档案
+     *
+     * @param sfzid 身份证
+     * @return 用户档案
+     */
+    public List<TUserProfile> selectTUserProfileBySfzIdV2(String sfzid);
+
     /**
      * 查询用户档案列表
-     * 
+     *
      * @param tUserProfile 用户档案
      * @return 用户档案集合
      */
@@ -53,7 +60,7 @@ public interface TUserProfileMapper
 
     /**
      * 新增用户档案
-     * 
+     *
      * @param tUserProfile 用户档案
      * @return 结果
      */
@@ -61,7 +68,7 @@ public interface TUserProfileMapper
 
     /**
      * 修改用户档案
-     * 
+     *
      * @param tUserProfile 用户档案
      * @return 结果
      */
@@ -69,7 +76,7 @@ public interface TUserProfileMapper
 
     /**
      * 删除用户档案
-     * 
+     *
      * @param id 用户档案主键
      * @return 结果
      */
@@ -77,7 +84,7 @@ public interface TUserProfileMapper
 
     /**
      * 批量删除用户档案
-     * 
+     *
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */
@@ -85,24 +92,24 @@ public interface TUserProfileMapper
 
     /**
      * 批量删除紧急联系人
-     * 
+     *
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */
     public int deleteTEmergentPeopleByProfileIds(Integer[] ids);
-    
+
     /**
      * 批量新增紧急联系人
-     * 
+     *
      * @param tEmergentPeopleList 紧急联系人列表
      * @return 结果
      */
     public int batchTEmergentPeople(List<TEmergentPeople> tEmergentPeopleList);
-    
+
 
     /**
      * 通过用户档案主键删除紧急联系人信息
-     * 
+     *
      * @param id 用户档案ID
      * @return 结果
      */

+ 59 - 7
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TUserProfileServiceImpl.java

@@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.stream.Collectors;
 
 import com.ruoyi.common.utils.StringUtils;
 import org.springframework.transaction.annotation.Transactional;
@@ -90,7 +91,32 @@ public class TUserProfileServiceImpl implements ITUserProfileService {
     @Transactional
     @Override
     public int insertTUserProfile(TUserProfile tUserProfile) {
+        if (tUserProfile == null) {
+            throw new ServiceException("新增用户信息数据不能为空!");
+        }
+        //新增用户创建时间
         tUserProfile.setCreateTime(DateUtils.getNowDate());
+        //判断提交数据格式是否正确
+        if (tUserProfile.getSfzid() == null || tUserProfile.getSfzid().isEmpty()) {
+            throw new ServiceException("新增用户信息数据身份证号格式异常!");
+        }
+        //根据身份证号查询数据库中的用户信息
+        TUserProfile user = tUserProfileMapper.selectTUserProfileBySfzId(tUserProfile.getSfzid());
+        if (user != null) {
+            //如果表中有该用户则提示
+            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());
+        }
         int rows = tUserProfileMapper.insertTUserProfile(tUserProfile);
         insertTEmergentPeople(tUserProfile);
         return rows;
@@ -105,9 +131,36 @@ public class TUserProfileServiceImpl implements ITUserProfileService {
     @Transactional
     @Override
     public int updateTUserProfile(TUserProfile tUserProfile) {
+        if (tUserProfile == null) {
+            throw new ServiceException("修改用户信息数据不能为空!");
+        }
+        //修改用户信息更新时间
+        tUserProfile.setUpdateTime(DateUtils.getNowDate());
+        //判断提交数据格式是否正确
+        if (tUserProfile.getSfzid() == null || tUserProfile.getSfzid().isEmpty()) {
+            throw new ServiceException("修改用户信息数据身份证号格式异常!");
+        }
+        //根据身份证号查询数据库中的用户信息
+        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());
+            }
+            stringBuilder.append("!");
+            throw new ServiceException(stringBuilder.toString());
+        }
         tUserProfileMapper.deleteTEmergentPeopleByProfileId(tUserProfile.getId());
         insertTEmergentPeople(tUserProfile);
-        return tUserProfileMapper.updateTUserProfile(tUserProfile);
+        int rows = tUserProfileMapper.updateTUserProfile(tUserProfile);
+        return rows;
     }
 
     /**
@@ -232,13 +285,12 @@ public class TUserProfileServiceImpl implements ITUserProfileService {
      */
     public void insertTEmergentPeople(TUserProfile tUserProfile) {
         List<TEmergentPeople> tEmergentPeopleList = tUserProfile.getTEmergentPeopleList();
-        Integer id = tUserProfile.getId();
         if (StringUtils.isNotNull(tEmergentPeopleList)) {
-            List<TEmergentPeople> list = new ArrayList<TEmergentPeople>();
-            for (TEmergentPeople tEmergentPeople : tEmergentPeopleList) {
-                tEmergentPeople.setProfileId(id);
-                list.add(tEmergentPeople);
-            }
+            List<TEmergentPeople> list = tEmergentPeopleList.stream()
+                    .map(mapper -> {
+                        mapper.setProfileId(tUserProfile.getId());
+                        return mapper;
+                    }).collect(Collectors.toList());
             if (list.size() > 0) {
                 tUserProfileMapper.batchTEmergentPeople(list);
             }

+ 256 - 182
ruoyi-system/src/main/resources/mapper/system/TUserProfileMapper.xml

@@ -1,216 +1,286 @@
 <?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.TUserProfileMapper">
-    
+
     <resultMap type="TUserProfile" id="TUserProfileResult">
-        <result property="id"    column="id"    />
-        <result property="name"    column="name"    />
-        <result property="gender"    column="gender"    />
-        <result property="sfzid"    column="sfzid"    />
-        <result property="telOne"    column="tel_one"    />
-        <result property="telTwo"    column="tel_two"    />
-        <result property="telThree"    column="tel_three"    />
-        <result property="birthday"    column="birthday"    />
-        <result property="age"    column="age"    />
-        <result property="marrStatus"    column="marr_status"    />
-        <result property="national"    column="national"    />
-        <result property="local"    column="local"    />
-        <result property="clientType"    column="client_type"    />
-        <result property="liveStatus"    column="live_status"    />
-        <result property="familyAddress"    column="family_address"    />
-        <result property="detailAddress"    column="detail_address"    />
-        <result property="houseAddress"    column="house_address"    />
-        <result property="houseDetailAddress"    column="house_detail_address"    />
-        <result property="serviceid"    column="serviceid"    />
-        <result property="oldmenStatus"    column="oldmen_status"    />
-        <result property="changeContent"    column="change_content"    />
-        <result property="loseMonth"    column="lose_month"    />
-        <result property="treatMonth"    column="treat_month"    />
-        <result property="isTreat"    column="is_treat"    />
-        <result property="serviceType"    column="service_type"    />
-        <result property="treateSure"    column="treate_sure"    />
-        <result property="moneyCome"    column="money_come"    />
-        <result property="moneyMonth"    column="money_month"    />
-        <result property="cardCode"    column="card_code"    />
-        <result property="slowIllness"    column="slow_illness"    />
-        <result property="bloodType"    column="blood_type"    />
-        <result property="shiStatus"    column="shi_status"    />
-        <result property="disablityStatus"    column="disablity_status"    />
-        <result property="disablityEntry"    column="disablity_entry"    />
-        <result property="educaLevel"    column="educa_level"    />
-        <result property="special"    column="special"    />
-        <result property="title"    column="title"    />
-        <result property="unity"    column="unity"    />
-        <result property="natureHeart"    column="nature_heart"    />
-        <result property="eatPoint"    column="eat_point"    />
-        <result property="speciality"    column="speciality"    />
-        <result property="hobby"    column="hobby"    />
-        <result property="photo"    column="photo"    />
-        <result property="otherPhoto"    column="other_photo"    />
-        <result property="remarks"    column="remarks"    />
-        <result property="createTime"    column="createtime"    />
+        <result property="id" column="id"/>
+        <result property="name" column="name"/>
+        <result property="gender" column="gender"/>
+        <result property="sfzid" column="sfzid"/>
+        <result property="telOne" column="tel_one"/>
+        <result property="telTwo" column="tel_two"/>
+        <result property="telThree" column="tel_three"/>
+        <result property="birthday" column="birthday"/>
+        <result property="age" column="age"/>
+        <result property="marrStatus" column="marr_status"/>
+        <result property="national" column="national"/>
+        <result property="local" column="local"/>
+        <result property="clientType" column="client_type"/>
+        <result property="liveStatus" column="live_status"/>
+        <result property="familyAddress" column="family_address"/>
+        <result property="detailAddress" column="detail_address"/>
+        <result property="houseAddress" column="house_address"/>
+        <result property="houseDetailAddress" column="house_detail_address"/>
+        <result property="serviceid" column="serviceid"/>
+        <result property="oldmenStatus" column="oldmen_status"/>
+        <result property="changeContent" column="change_content"/>
+        <result property="loseMonth" column="lose_month"/>
+        <result property="treatMonth" column="treat_month"/>
+        <result property="isTreat" column="is_treat"/>
+        <result property="serviceType" column="service_type"/>
+        <result property="treateSure" column="treate_sure"/>
+        <result property="moneyCome" column="money_come"/>
+        <result property="moneyMonth" column="money_month"/>
+        <result property="cardCode" column="card_code"/>
+        <result property="slowIllness" column="slow_illness"/>
+        <result property="bloodType" column="blood_type"/>
+        <result property="shiStatus" column="shi_status"/>
+        <result property="disablityStatus" column="disablity_status"/>
+        <result property="disablityEntry" column="disablity_entry"/>
+        <result property="educaLevel" column="educa_level"/>
+        <result property="special" column="special"/>
+        <result property="title" column="title"/>
+        <result property="unity" column="unity"/>
+        <result property="natureHeart" column="nature_heart"/>
+        <result property="eatPoint" column="eat_point"/>
+        <result property="speciality" column="speciality"/>
+        <result property="hobby" column="hobby"/>
+        <result property="photo" column="photo"/>
+        <result property="otherPhoto" column="other_photo"/>
+        <result property="remarks" column="remarks"/>
+        <result property="createTime" column="createtime"/>
     </resultMap>
 
     <resultMap id="TUserProfileTEmergentPeopleResult" type="TUserProfile" extends="TUserProfileResult">
-        <collection property="tEmergentPeopleList" notNullColumn="sub_id" javaType="java.util.List" resultMap="TEmergentPeopleResult" />
+        <collection property="tEmergentPeopleList" notNullColumn="sub_id" javaType="java.util.List"
+                    resultMap="TEmergentPeopleResult"/>
     </resultMap>
 
     <resultMap type="TEmergentPeople" id="TEmergentPeopleResult">
-        <result property="id"    column="sub_id"    />
-        <result property="profileId"    column="sub_profile_id"    />
-        <result property="name"    column="sub_name"    />
-        <result property="telno"    column="sub_telno"    />
-        <result property="relation"    column="sub_relation"    />
-        <result property="isConn"    column="sub_is_conn"    />
+        <result property="id" column="sub_id"/>
+        <result property="profileId" column="sub_profile_id"/>
+        <result property="name" column="sub_name"/>
+        <result property="telno" column="sub_telno"/>
+        <result property="relation" column="sub_relation"/>
+        <result property="isConn" column="sub_is_conn"/>
     </resultMap>
 
     <sql id="selectTUserProfileVo">
-        select id, name, gender, sfzid, tel_one, tel_two, tel_three, birthday, age, marr_status, national, local, client_type, live_status, family_address, detail_address, house_address, house_detail_address, serviceid, oldmen_status, change_content, lose_month, treat_month, is_treat, service_type, treate_sure, money_come, money_month, card_code, slow_illness, blood_type, shi_status, disablity_status, disablity_entry, educa_level, special, title, unity, nature_heart, eat_point, speciality, hobby, photo, other_photo, remarks, createtime from t_user_profile
+        select id,
+               name,
+               gender,
+               sfzid,
+               tel_one,
+               tel_two,
+               tel_three,
+               birthday,
+               age,
+               marr_status, national, local, client_type, live_status, family_address, detail_address, house_address, house_detail_address, serviceid, oldmen_status, change_content, lose_month, treat_month, is_treat, service_type, treate_sure, money_come, money_month, card_code, slow_illness, blood_type, shi_status, disablity_status, disablity_entry, educa_level, special, title, unity, nature_heart, eat_point, speciality, hobby, photo, other_photo, remarks, createtime
+        from t_user_profile
     </sql>
 
     <select id="selectTUserProfileList" parameterType="TUserProfile" resultMap="TUserProfileResult">
         <include refid="selectTUserProfileVo"/>
-        <where>  
-            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
-            <if test="gender != null "> and gender = #{gender}</if>
-            <if test="sfzid != null  and sfzid != ''"> and sfzid = #{sfzid}</if>
-            <if test="telOne != null  and telOne != ''"> and tel_one = #{telOne}</if>
-            <if test="telTwo != null  and telTwo != ''"> and tel_two = #{telTwo}</if>
-            <if test="telThree != null  and telThree != ''"> and tel_three = #{telThree}</if>
-            <if test="birthday != null  and birthday != ''"> and birthday = #{birthday}</if>
-            <if test="age != null "> and age = #{age}</if>
-            <if test="marrStatus != null "> and marr_status = #{marrStatus}</if>
-            <if test="national != null "> and national = #{national}</if>
-            <if test="local != null "> and local = #{local}</if>
-            <if test="clientType != null "> and client_type = #{clientType}</if>
-            <if test="liveStatus != null "> and live_status = #{liveStatus}</if>
-            <if test="familyAddress != null  and familyAddress != ''"> and family_address = #{familyAddress}</if>
-            <if test="detailAddress != null  and detailAddress != ''"> and detail_address = #{detailAddress}</if>
-            <if test="houseAddress != null  and houseAddress != ''"> and house_address = #{houseAddress}</if>
-            <if test="houseDetailAddress != null  and houseDetailAddress != ''"> and house_detail_address = #{houseDetailAddress}</if>
-            <if test="serviceid != null "> and serviceid = #{serviceid}</if>
-            <if test="oldmenStatus != null  and oldmenStatus != ''"> and oldmen_status = #{oldmenStatus}</if>
-            <if test="changeContent != null  and changeContent != ''"> and change_content = #{changeContent}</if>
-            <if test="loseMonth != null  and loseMonth != ''"> and lose_month = #{loseMonth}</if>
-            <if test="treatMonth != null  and treatMonth != ''"> and treat_month = #{treatMonth}</if>
-            <if test="isTreat != null "> and is_treat = #{isTreat}</if>
-            <if test="serviceType != null "> and service_type = #{serviceType}</if>
-            <if test="treateSure != null "> and treate_sure = #{treateSure}</if>
-            <if test="moneyCome != null "> and money_come = #{moneyCome}</if>
-            <if test="moneyMonth != null  and moneyMonth != ''"> and money_month = #{moneyMonth}</if>
-            <if test="cardCode != null  and cardCode != ''"> and card_code = #{cardCode}</if>
-            <if test="slowIllness != null  and slowIllness != ''"> and slow_illness = #{slowIllness}</if>
-            <if test="bloodType != null "> and blood_type = #{bloodType}</if>
-            <if test="shiStatus != null "> and shi_status = #{shiStatus}</if>
-            <if test="disablityStatus != null "> and disablity_status = #{disablityStatus}</if>
-            <if test="disablityEntry != null "> and disablity_entry = #{disablityEntry}</if>
-            <if test="educaLevel != null "> and educa_level = #{educaLevel}</if>
-            <if test="special != null  and special != ''"> and special = #{special}</if>
-            <if test="title != null  and title != ''"> and title = #{title}</if>
-            <if test="unity != null  and unity != ''"> and unity = #{unity}</if>
-            <if test="natureHeart != null  and natureHeart != ''"> and nature_heart = #{natureHeart}</if>
-            <if test="eatPoint != null  and eatPoint != ''"> and eat_point = #{eatPoint}</if>
-            <if test="speciality != null  and speciality != ''"> and speciality = #{speciality}</if>
-            <if test="hobby != null  and hobby != ''"> and hobby = #{hobby}</if>
-            <if test="photo != null  and photo != ''"> and photo = #{photo}</if>
-            <if test="otherPhoto != null  and otherPhoto != ''"> and other_photo = #{otherPhoto}</if>
-            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
-            <if test="createTime != null "> and createtime = #{createTime}</if>
+        <where>
+            <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
+            <if test="gender != null ">and gender = #{gender}</if>
+            <if test="sfzid != null  and sfzid != ''">and sfzid = #{sfzid}</if>
+            <if test="telOne != null  and telOne != ''">and tel_one = #{telOne}</if>
+            <if test="telTwo != null  and telTwo != ''">and tel_two = #{telTwo}</if>
+            <if test="telThree != null  and telThree != ''">and tel_three = #{telThree}</if>
+            <if test="birthday != null  and birthday != ''">and birthday = #{birthday}</if>
+            <if test="age != null ">and age = #{age}</if>
+            <if test="marrStatus != null ">and marr_status = #{marrStatus}</if>
+            <if test="national != null ">and national = #{national}</if>
+            <if test="local != null ">and local = #{local}</if>
+            <if test="clientType != null ">and client_type = #{clientType}</if>
+            <if test="liveStatus != null ">and live_status = #{liveStatus}</if>
+            <if test="familyAddress != null  and familyAddress != ''">and family_address = #{familyAddress}</if>
+            <if test="detailAddress != null  and detailAddress != ''">and detail_address = #{detailAddress}</if>
+            <if test="houseAddress != null  and houseAddress != ''">and house_address = #{houseAddress}</if>
+            <if test="houseDetailAddress != null  and houseDetailAddress != ''">and house_detail_address =
+                #{houseDetailAddress}
+            </if>
+            <if test="serviceid != null ">and serviceid = #{serviceid}</if>
+            <if test="oldmenStatus != null  and oldmenStatus != ''">and oldmen_status = #{oldmenStatus}</if>
+            <if test="changeContent != null  and changeContent != ''">and change_content = #{changeContent}</if>
+            <if test="loseMonth != null  and loseMonth != ''">and lose_month = #{loseMonth}</if>
+            <if test="treatMonth != null  and treatMonth != ''">and treat_month = #{treatMonth}</if>
+            <if test="isTreat != null ">and is_treat = #{isTreat}</if>
+            <if test="serviceType != null ">and service_type = #{serviceType}</if>
+            <if test="treateSure != null ">and treate_sure = #{treateSure}</if>
+            <if test="moneyCome != null ">and money_come = #{moneyCome}</if>
+            <if test="moneyMonth != null  and moneyMonth != ''">and money_month = #{moneyMonth}</if>
+            <if test="cardCode != null  and cardCode != ''">and card_code = #{cardCode}</if>
+            <if test="slowIllness != null  and slowIllness != ''">and slow_illness = #{slowIllness}</if>
+            <if test="bloodType != null ">and blood_type = #{bloodType}</if>
+            <if test="shiStatus != null ">and shi_status = #{shiStatus}</if>
+            <if test="disablityStatus != null ">and disablity_status = #{disablityStatus}</if>
+            <if test="disablityEntry != null ">and disablity_entry = #{disablityEntry}</if>
+            <if test="educaLevel != null ">and educa_level = #{educaLevel}</if>
+            <if test="special != null  and special != ''">and special = #{special}</if>
+            <if test="title != null  and title != ''">and title = #{title}</if>
+            <if test="unity != null  and unity != ''">and unity = #{unity}</if>
+            <if test="natureHeart != null  and natureHeart != ''">and nature_heart = #{natureHeart}</if>
+            <if test="eatPoint != null  and eatPoint != ''">and eat_point = #{eatPoint}</if>
+            <if test="speciality != null  and speciality != ''">and speciality = #{speciality}</if>
+            <if test="hobby != null  and hobby != ''">and hobby = #{hobby}</if>
+            <if test="photo != null  and photo != ''">and photo = #{photo}</if>
+            <if test="otherPhoto != null  and otherPhoto != ''">and other_photo = #{otherPhoto}</if>
+            <if test="remarks != null  and remarks != ''">and remarks = #{remarks}</if>
+            <if test="createTime != null ">and createtime = #{createTime}</if>
         </where>
     </select>
-    
+
     <select id="selectTUserProfileById" parameterType="Integer" resultMap="TUserProfileTEmergentPeopleResult">
-        select a.id, a.name, a.gender, a.sfzid, a.tel_one, a.tel_two, a.tel_three, a.birthday, a.age, a.marr_status, a.national, a.local, a.client_type, a.live_status, a.family_address, a.detail_address, a.house_address, a.house_detail_address, a.serviceid, a.oldmen_status, a.change_content, a.lose_month, a.treat_month, a.is_treat, a.service_type, a.treate_sure, a.money_come, a.money_month, a.card_code, a.slow_illness, a.blood_type, a.shi_status, a.disablity_status, a.disablity_entry, a.educa_level, a.special, a.title, a.unity, a.nature_heart, a.eat_point, a.speciality, a.hobby, a.photo, a.other_photo, a.remarks, a.createtime,
- b.id as sub_id, b.profile_id as sub_profile_id, b.name as sub_name, b.telno as sub_telno, b.relation as sub_relation, b.is_conn as sub_is_conn
+        select a.id,
+               a.name,
+               a.gender,
+               a.sfzid,
+               a.tel_one,
+               a.tel_two,
+               a.tel_three,
+               a.birthday,
+               a.age,
+               a.marr_status,
+               a.national,
+               a.local,
+               a.client_type,
+               a.live_status,
+               a.family_address,
+               a.detail_address,
+               a.house_address,
+               a.house_detail_address,
+               a.serviceid,
+               a.oldmen_status,
+               a.change_content,
+               a.lose_month,
+               a.treat_month,
+               a.is_treat,
+               a.service_type,
+               a.treate_sure,
+               a.money_come,
+               a.money_month,
+               a.card_code,
+               a.slow_illness,
+               a.blood_type,
+               a.shi_status,
+               a.disablity_status,
+               a.disablity_entry,
+               a.educa_level,
+               a.special,
+               a.title,
+               a.unity,
+               a.nature_heart,
+               a.eat_point,
+               a.speciality,
+               a.hobby,
+               a.photo,
+               a.other_photo,
+               a.remarks,
+               a.createtime,
+               b.id         as sub_id,
+               b.profile_id as sub_profile_id,
+               b.name       as sub_name,
+               b.telno      as sub_telno,
+               b.relation   as sub_relation,
+               b.is_conn    as sub_is_conn
         from t_user_profile a
-        left join t_emergent_people b on b.profile_id = a.id
+                 left join t_emergent_people b on b.profile_id = a.id
         where a.id = #{id}
     </select>
     <select id="selectTUserProfileListByDevice" resultType="com.ruoyi.system.domain.dto.TUserProfileDto">
         select id, name, gender, sfzid, tel_one, age, family_address from t_user_profile
         <where>
-            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
-            <if test="gender != null "> and gender = #{gender}</if>
-            <if test="sfzid != null  and sfzid != ''"> and sfzid = #{sfzid}</if>
-            <if test="telOne != null  and telOne != ''"> and tel_one = #{telOne}</if>
-            <if test="age != null "> and age = #{age}</if>
-            <if test="familyAddress != null  and familyAddress != ''"> and family_address = #{familyAddress}</if>
+            <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
+            <if test="gender != null ">and gender = #{gender}</if>
+            <if test="sfzid != null  and sfzid != ''">and sfzid = #{sfzid}</if>
+            <if test="telOne != null  and telOne != ''">and tel_one = #{telOne}</if>
+            <if test="age != null ">and age = #{age}</if>
+            <if test="familyAddress != null  and familyAddress != ''">and family_address = #{familyAddress}</if>
         </where>
     </select>
     <select id="selectTUserProfileBySfzId" resultType="com.ruoyi.system.domain.TUserProfile">
-        select * from t_user_profile
+        select *
+        from t_user_profile
+        where sfzid = #{sfzid}
+    </select>
+    <select id="selectTUserProfileBySfzIdV2" resultType="com.ruoyi.system.domain.TUserProfile">
+        <include refid="selectTUserProfileVo"/>
         where sfzid = #{sfzid}
     </select>
     <select id="selectuserAgeDto" resultType="com.ruoyi.system.domain.dto.UserAgeDto">
-        SELECT
-        CASE
-        WHEN age &lt; 20
-        THEN
-        '10'
-        WHEN age &gt;= 20
-        AND age &lt; 30 THEN
-        '20'
-        WHEN age &gt;= 30
-        AND age &lt; 40 THEN
-        '30'
-        WHEN age &gt;= 40
-        AND age &lt; 50 THEN
-        '40'
-        WHEN age &gt;= 50
-        AND age &lt; 60 THEN
-        '50'
-        WHEN age &gt;= 60
-        AND age &lt; 70 THEN
-        '60'
-        WHEN age &gt;= 70
-        AND age &lt; 80 THEN
-        '70'
-        WHEN age &gt;= 80
-        AND age &lt; 90 THEN
-        '80'
-        WHEN age &gt; 90 THEN
-        '100以上'
-        END AS age,
-        count(*) AS count
+        SELECT CASE
+                   WHEN age &lt; 20
+                       THEN
+                       '10'
+                   WHEN age &gt;= 20
+                       AND age &lt; 30 THEN
+                       '20'
+                   WHEN age &gt;= 30
+                       AND age &lt; 40 THEN
+                       '30'
+                   WHEN age &gt;= 40
+                       AND age &lt; 50 THEN
+                       '40'
+                   WHEN age &gt;= 50
+                       AND age &lt; 60 THEN
+                       '50'
+                   WHEN age &gt;= 60
+                       AND age &lt; 70 THEN
+                       '60'
+                   WHEN age &gt;= 70
+                       AND age &lt; 80 THEN
+                       '70'
+                   WHEN age &gt;= 80
+                       AND age &lt; 90 THEN
+                       '80'
+                   WHEN age &gt; 90 THEN
+                       '100以上'
+                   END AS age,
+               count(*) AS count
         FROM
-        t_user_profile
+            t_user_profile
         GROUP BY
-        CASE
-        WHEN age &lt; 20
-        THEN
-        '10'
-        WHEN age &gt;= 20
-        AND age &lt; 30 THEN
-        '20'
-        WHEN age &gt;= 30
-        AND age &lt; 40 THEN
-        '30'
-        WHEN age &gt;= 40
-        AND age &lt; 50 THEN
-        '40'
-        WHEN age &gt;= 50
-        AND age &lt; 60 THEN
-        '50'
-        WHEN age &gt;= 60
-        AND age &lt; 70 THEN
-        '60'
-        WHEN age &gt;= 70
-        AND age &lt; 80 THEN
-        '70'
-        WHEN age &gt;= 80
-        AND age &lt; 90 THEN
-        '80'
-        WHEN age &gt; 90 THEN
-        '100以上'
+            CASE
+            WHEN age &lt; 20
+            THEN
+            '10'
+            WHEN age &gt;= 20
+            AND age &lt; 30 THEN
+            '20'
+            WHEN age &gt;= 30
+            AND age &lt; 40 THEN
+            '30'
+            WHEN age &gt;= 40
+            AND age &lt; 50 THEN
+            '40'
+            WHEN age &gt;= 50
+            AND age &lt; 60 THEN
+            '50'
+            WHEN age &gt;= 60
+            AND age &lt; 70 THEN
+            '60'
+            WHEN age &gt;= 70
+            AND age &lt; 80 THEN
+            '70'
+            WHEN age &gt;= 80
+            AND age &lt; 90 THEN
+            '80'
+            WHEN age &gt; 90 THEN
+            '100以上'
         END;
     </select>
     <select id="selectuserAgeCount" resultType="java.lang.Integer">
-        select IFNULL(count(*),0) from t_user_profile
+        select IFNULL(count(*), 0)
+        from t_user_profile
     </select>
     <select id="selectAddUser" resultType="com.ruoyi.system.domain.dto.AddUserDto">
-        SELECT DATE_FORMAT(createtime, '%Y-%m') AS month, COUNT(*) AS count FROM t_user_profile GROUP BY month;
+        SELECT DATE_FORMAT(createtime, '%Y-%m') AS month, COUNT(*) AS count
+        FROM t_user_profile
+        GROUP BY month;
     </select>
 
     <insert id="insertTUserProfile" parameterType="TUserProfile" useGeneratedKeys="true" keyProperty="id">
@@ -261,7 +331,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="otherPhoto != null">other_photo,</if>
             <if test="remarks != null">remarks,</if>
             <if test="createTime != null">createtime,</if>
-         </trim>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="name != null">#{name},</if>
             <if test="gender != null">#{gender},</if>
@@ -308,7 +378,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="otherPhoto != null">#{otherPhoto},</if>
             <if test="remarks != null">#{remarks},</if>
             <if test="createTime != null">#{createTime},</if>
-         </trim>
+        </trim>
     </insert>
 
     <update id="updateTUserProfile" parameterType="TUserProfile">
@@ -364,30 +434,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </update>
 
     <delete id="deleteTUserProfileById" parameterType="Integer">
-        delete from t_user_profile where id = #{id}
+        delete
+        from t_user_profile
+        where id = #{id}
     </delete>
 
     <delete id="deleteTUserProfileByIds" parameterType="String">
-        delete from t_user_profile where id in 
+        delete from t_user_profile where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
     </delete>
-    
+
     <delete id="deleteTEmergentPeopleByProfileIds" parameterType="String">
-        delete from t_emergent_people where profile_id in 
+        delete from t_emergent_people where profile_id in
         <foreach item="profileId" collection="array" open="(" separator="," close=")">
             #{profileId}
         </foreach>
     </delete>
 
     <delete id="deleteTEmergentPeopleByProfileId" parameterType="Integer">
-        delete from t_emergent_people where profile_id = #{profileId}
+        delete
+        from t_emergent_people
+        where profile_id = #{profileId}
     </delete>
 
     <insert id="batchTEmergentPeople">
         insert into t_emergent_people( id, profile_id, name, telno, relation, is_conn) values
-		<foreach item="item" index="index" collection="list" separator=",">
+        <foreach item="item" index="index" collection="list" separator=",">
             ( #{item.id}, #{item.profileId}, #{item.name}, #{item.telno}, #{item.relation}, #{item.isConn})
         </foreach>
     </insert>