jinquanOu
2024-06-11 5d7b0a0bbcae6844e2296ef53c3f4c88293dacfe
zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorServiceImpl.java
@@ -6,7 +6,9 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.EsModel;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.MapUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.domain.*;
@@ -60,6 +62,10 @@
    @Resource
    private RestHighLevelClient restHighLevelClient;
    @Resource
    ZfDoctorShareService zfDoctorShareService;
    @Override
    public AjaxResult selectDoctorList(ZfDoctor zfDoctor, Integer pageNum, Integer pageSize) {
//        LambdaQueryWrapper<ZfDoctor> lqw = buildCondition(zfDoctor);
@@ -72,6 +78,10 @@
//        return AjaxResult.success(data);
        //要查自己家庭的
        ZInfoUser myself = zInfoUserService.getMyself();
        if (myself == null) {
            //   System.out.println("ssssss");
            return AjaxResult.success("您没加入到对应的家庭,请联系管理员");
        }
        Long familyId = myself.getFamilyId();
        //也要查别人授权的
        List<ZAuthority> authority = zAuthorityService.getAuthority();
@@ -80,8 +90,11 @@
        idList.add(familyId);
//        String familyIds = listFamilyIds();
//        String secondFamilyAuthority = listSecondFamilyIds();
        LambdaQueryWrapper<ZfDoctor> lqw = buildCondition(zfDoctor, idList);
        //查看别人分享
        List<ZfDoctor> bs = zfDoctorShareService.listUserId(myself.getUserId());
        LambdaQueryWrapper<ZfDoctor> lqw = buildCondition(zfDoctor, idList);
        Page<ZfDoctor> zfDoctorPage = new Page<>(pageNum, pageSize);
        Page<ZfDoctor> pageResult = page(zfDoctorPage, lqw);
@@ -89,7 +102,7 @@
        List<ZfDoctor> beanRecords = pageResult.getRecords();//得到查询出来的数据
        List<ZfDoctor> dtoResult = markOwnData(familyId, beanRecords);
        dtoResult.addAll(bs);
        HashMap<String, Object> data = MapUtils.getResult(pageResult, dtoResult);
        return AjaxResult.success(data);
    }
@@ -111,8 +124,12 @@
        //加上自己家庭的id
        idList.add(familyId);
        //查看别人分享
        List<ZfDoctor> bs = zfDoctorShareService.listUserId(myself.getUserId());
        LambdaQueryWrapper<ZfDoctor> lambdaQueryWrapper = buildCondition(zfDoctor, idList);
        List<ZfDoctor> beanRecords = list(lambdaQueryWrapper);
        beanRecords.addAll(bs);
        log.info("从数据库中查到的为:{}", beanRecords);
        return markOwnData(familyId, beanRecords);
    }
@@ -150,10 +167,14 @@
        }
        log.info("数据列表为:{}", dataList);
        for (ZfDoctor zfDoctor : dataList) {
            if (zfDoctor.getSymptom().length() == 0 || zfDoctor.getSymptom() == null) {
                throw new RuntimeException("症状为空,导入数据失败");
            } else {
            zfDoctorService.addData(zfDoctor);
        }
        }
        return AjaxResult.success("导入数据成功");
    }
@@ -170,6 +191,10 @@
        List<ZAuthority> authority = zAuthorityService.getAuthority();
        List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(DOCTOR_LIST_ADD)).map(ZAuthority::getFid).collect(Collectors.toList());
        familyIdList.add(familyId);
//        List<ZfDoctorShare> authority1 = zfDoctorShareService.getAuthority();
//        List<Long> idList1 = authority1.stream().filter(auth -> auth.getShareContent().toString().equals(DOCTOR_LIST)).map(ZfDoctorShare::getShareId).collect(Collectors.toList());
        zfDoctorService.addData(zfDoctor);
        if (zfDoctor.getFamilyId()!=null && !familyIdList.contains(zfDoctor.getFamilyId())) {
            throw new RuntimeException("你没有权限操作此家庭的数据");
@@ -203,8 +228,11 @@
            esModel.setBy5("/family/zfDoctor");
            esModel.setBy6(zfDoctor.getCmedical());
            esModel.setBy7(zfDoctor.getWmedical());
//            esModel.setBy7();
            esModel.setRemark(zfDoctor.getRemark());
            esModel.setFid(familyId);
            //这里存储查询详情的路径
            esService.insertTable(esModel);
            return AjaxResult.success();
@@ -212,6 +240,7 @@
            return AjaxResult.error();
        }
    }
    @Resource
    ZfLogService zfLogService;
@@ -417,4 +446,21 @@
        }
        return lqw;
    }
//        private List<Long> buildCondition1(){
//        List<ZfDoctorShare> authority1 = zfDoctorShareService.getAuthority();
//        List<Long> idList1 = authority1.stream().filter(auth -> auth.getShareContent().toString().equals(DOCTOR_LIST)).map(ZfDoctorShare::getShareId).collect(Collectors.toList());
//        return idList1;
//    }
//    private LambdaQueryWrapper<ZfDoctor> buildCondition2(ZfDoctor zfDoctor, List<Long> IdList) {
//        LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>();
//        lqw.in(ZfDoctorShare::getShareId, IdList);
//        List<ZfDoctorShare> beanRecords = list(lqw);
//        for (ZfDoctorShare shareContent : beanRecords){
//            zfDoctorService.getById(shareContent);
//        }
//
//    }
}