From b02beccf4567068cb47a3f1181a00039456c872d Mon Sep 17 00:00:00 2001 From: zqy <2522236926@qq.com> Date: 星期三, 06 八月 2025 15:37:20 +0800 Subject: [PATCH] 用户修改姓名和电话同步修改uaid --- zhang-content/src/main/java/com/ruoyi/service/impl/ZHealthNowServiceImpl.java | 123 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 123 insertions(+), 0 deletions(-) diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZHealthNowServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZHealthNowServiceImpl.java index 9243746..b7a416f 100644 --- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZHealthNowServiceImpl.java +++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZHealthNowServiceImpl.java @@ -1,10 +1,28 @@ package com.ruoyi.service.impl; +import com.alibaba.fastjson2.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.bean.BeanUtils; +import com.ruoyi.domain.ZHealthNote; import com.ruoyi.domain.ZHealthNow; +import com.ruoyi.domain.ZHealthNow; +import com.ruoyi.domain.ZInfoUser; +import com.ruoyi.domain.dto.ZHealthNowDto; +import com.ruoyi.domain.dto.ZHealthNowDto; +import com.ruoyi.domain.health.*; import com.ruoyi.mapper.ZHealthNowMapper; import com.ruoyi.service.ZHealthNowService; +import com.ruoyi.service.ZInfoUserService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; + +import javax.sql.rowset.BaseRowSet; +import java.util.List; +import java.util.stream.Collectors; /** * @Author Jinquan_Ou @@ -14,4 +32,109 @@ **/ @Service public class ZHealthNowServiceImpl extends ServiceImpl<ZHealthNowMapper, ZHealthNow> implements ZHealthNowService { + + @Autowired + ZInfoUserService zInfoUserService; + @Override + public AjaxResult selectData() { + SysUser user = SecurityUtils.getLoginUser().getUser(); + Long userId = user.getUserId(); + + LambdaQueryWrapper<ZHealthNow> lqw = new LambdaQueryWrapper<>(); + lqw.eq(ZHealthNow::getUid,userId); + ZHealthNow zHealthNow = getOne(lqw); + + if(zHealthNow==null) + { + //鏍规嵁userId鏌ヨ鍒癷nfouser鐨剈aid + ZInfoUser zInfoUser = zInfoUserService.getInfoBysysId(userId); +// System.out.println("sdfsdf999000550"); + + //鎷垮埌鎵�鏈夌殑sysid + List<Long> fms = zInfoUserService.findByUaidToFaid(zInfoUser.getUaid()).stream().map(ZInfoUser::getSysId).collect(Collectors.toList()); + System.out.println(fms.size()); + + for(Long id:fms) + { + LambdaQueryWrapper<ZHealthNow> lqw1 = new LambdaQueryWrapper<>(); + + if(!id.equals(userId)) + { + lqw1.eq(ZHealthNow::getUid, id); + zHealthNow = getOne(lqw1); + break; + } + } + System.out.println(zHealthNow); + System.out.println("sdfsdf9990000"); + System.out.println("sdfsdf9990000"); + System.out.println("sdfsdf9990000"); + } + //濡傛灉鏄涓�娆¤繘鏉ワ紝涔嬪墠娌℃湁杩欎釜鐢ㄦ埛鐨勬暟鎹紝鎶涘紓甯歌鐢ㄦ埛鍏堟彃鍏ユ暟鎹� + if(zHealthNow == null){ + throw new RuntimeException("绗竴娆¤繘鏉�,璇峰厛濉啓濂芥暟鎹�"); + } + + //灏佽瑕佽繑鍥炵殑鏁版嵁 + ZHealthNowDto returnData = new ZHealthNowDto(); + BeanUtils.copyProperties(zHealthNow,returnData); + +// returnData.setName(zHealthNow.getName()); +// returnData.setSex(zHealthNow.getSex()); +// returnData.setEducationLevel(zHealthNow.getEducationLevel()); +// returnData.setWork(zHealthNow.getWork()); +// returnData.setPhone(zHealthNow.getPhone()); +// returnData.setEmail(zHealthNow.getEmail()); +// returnData.setMedicine(zHealthNow.getMedicine()); +// returnData.setBaseDisease(zHealthNow.getBaseDisease()); + + //灏唈son鏁扮粍杞崲鎴愬璞� + returnData.setBrainDiseaseClass(JSON.parseObject(zHealthNow.getBrain(), BrainDisease.class)); + returnData.setHeartDiseaseClass(JSON.parseObject(zHealthNow.getHeart(), HeartDisease.class)); + returnData.setVascularDiseaseClass(JSON.parseObject(zHealthNow.getBlood(), VascularDisease.class)); + returnData.setDigestiveSystemDiseaseClass(JSON.parseObject(zHealthNow.getDigestiveSystem(), DigestiveSystemDisease.class)); + returnData.setRespiratorySystemDiseaseClass(JSON.parseObject(zHealthNow.getDigestiveSystem(), RespiratorySystemDisease.class)); + returnData.setKidneyDiseaseClass(JSON.parseObject(zHealthNow.getKidney(), KidneyDisease.class)); + returnData.setOtherDiseaseClass(JSON.parseObject(zHealthNow.getOther(), OtherDisease.class)); + + return AjaxResult.success(returnData); + + + } + + @Override + public AjaxResult saveOrUpdateData(ZHealthNowDto zHealthNowDto) { + SysUser user = SecurityUtils.getLoginUser().getUser(); + Long userId = user.getUserId(); + + LambdaQueryWrapper<ZHealthNow> lqw = new LambdaQueryWrapper<>(); + lqw.eq(ZHealthNow::getUid,userId); + ZHealthNow getResult = getOne(lqw); + + ZHealthNow zHealthNow = new ZHealthNow(); + + BeanUtils.copyProperties(zHealthNowDto,zHealthNow); + zHealthNow.setUid(userId); + zHealthNow.setBrain(JSON.toJSONString(zHealthNowDto.getBrainDiseaseClass())); + zHealthNow.setHeart(JSON.toJSONString(zHealthNowDto.getHeartDiseaseClass())); + zHealthNow.setBlood(JSON.toJSONString(zHealthNowDto.getVascularDiseaseClass())); + zHealthNow.setDigestiveSystem(JSON.toJSONString(zHealthNowDto.getDigestiveSystemDiseaseClass())); + zHealthNow.setBreathSystem(JSON.toJSONString(zHealthNowDto.getRespiratorySystemDiseaseClass())); + zHealthNow.setKidney(JSON.toJSONString(zHealthNowDto.getKidneyDiseaseClass())); + zHealthNow.setOther(JSON.toJSONString(zHealthNowDto.getOtherDiseaseClass())); + + + if(getResult == null){ + //濡傛灉鏄涓�娆¤繘鏉ワ紝閭d箞鏄柊澧炴暟鎹� + save(zHealthNow); + }else { + //濡傛灉涓嶆槸绗竴娆★紝閭e氨鏄慨鏀规暟鎹簡 + zHealthNow.setId(getResult.getId()); + updateById(zHealthNow); + } + + return AjaxResult.success(); + + + } } -- Gitblit v1.9.1