fwq
2024-09-20 945e8d97f4688b0a91460e4bdc99ba963de66178
其-治疗方案推荐设备
1个文件已修改
139 ■■■■■ 已修改文件
phi_platform_user/src/main/java/com/hx/phip/controller/micro/MicroRecordV2Controller.java 139 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/controller/micro/MicroRecordV2Controller.java
@@ -32,6 +32,7 @@
import com.hx.phiappt.model.micro.MicroRecord;
import com.hx.phiappt.model.micro.MicroRecordData;
import com.hx.phiappt.model.treatPlan.TreatPlan;
import com.hx.phiappt.model.treatPlan.TreatPlanItem;
import com.hx.phiappt.util.SystemParameterUtil;
import com.hx.phiappt.vo.mj.MjDataVo;
import com.hx.phiappt.vo.mj.MjIndicationVo;
@@ -1273,56 +1274,45 @@
        if (mjSkinReport == null){
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "美际报告数据获取异常,请联系管理员!");
        }
        //校验归属
        if (StringUtils.noNull(dto.getUserId()) && !dto.getUserId().equals(mjSkinReport.getCustomerId())){
            logger.error("皮测详细数据校验归属,参数客户:{},报告客户{}",dto.getUserId(),mjSkinReport.getCustomerId());
            throw new TipsException("获取报告信息失败,请联系您的专属客服!");
        }
        //处理链接
        if (!StringUtils.isEmpty(mjSkinReport.getShareUrl()) && !mjSkinReport.getShareUrl().contains("https")) {
            mjSkinReport.setShareUrl( mjSkinReport.getShareUrl().replace("http", "https"));
        }
        if (!StringUtils.isEmpty(mjSkinReport.getViewUrl()) && !mjSkinReport.getViewUrl().contains("https")) {
            mjSkinReport.setViewUrl(mjSkinReport.getViewUrl().replace("http", "https"));
        }
        //返回数据
        Map<String,Object> data = new HashMap<>();
        data.put("mjSkinReportId",mjRecordId);
        data.put("userId",mjSkinReport.getCustomerId());
        data.put("viewUrl",mjSkinReport.getViewUrl());
        SqlSentence sqlSentence = new SqlSentence();
        Map<String, Object> sqlMap = new HashMap<>();
        sqlMap.put("isDel",BaseEntity.NO);
        sqlMap.put("isUp",BaseEntity.YES);
        sqlMap.put("mjSkinReportId",mjRecordId);
        //返回数据
        Map<String,Object> data = new HashMap<>();
        //1.美际报告数据
        data.put("mjSkinReportId",mjRecordId);
        data.put("icon",mjSkinReport.getIcon());
        data.put("shareUrl",mjSkinReport.getShareUrl());
        data.put("viewUrl",mjSkinReport.getViewUrl());
        //获取自然光的照片
        Map<String, Object> map = getMiddleFileUrl(mjSkinReport, sqlMap, sqlSentence);
        //文件验签访问返回
        //2.照片验签访问返回
        data.put("fileUrl", ComparePhotoUtil.getDecryptImagesUrl(sFileService, map.get("fileUrl").toString()));
        //症状,分类名
        Map<String, String> nameTypeMap = getIndMap();
        List<String> typeNameList = nameTypeMap.values().stream().distinct().collect(Collectors.toList());
        data.put("typeNameList",typeNameList);
        //3.返回分类名
        data.put("typeNameList",nameTypeMap.values().stream().distinct().collect(Collectors.toList()));
        //适应症名称,数据
        Map<String, MjIndicationDetailVo> detailVoMap = getMjIndicationDetailVoMap(nameTypeMap, mjSkinReport, sqlMap, sqlSentence);
        //查询上一次同类型的美际报告,上一次分值
        MjSkinReport lastMjSkinReport = getLastMjSkinReport(mjSkinReport, sqlMap, sqlSentence);
        if (lastMjSkinReport != null && StringUtils.noNull(lastMjSkinReport.getContents())) {
            List<MjDataVo> mjDataVoList = JSONArray.parseArray(lastMjSkinReport.getContents(), MjDataVo.class);
            if (mjDataVoList != null && mjDataVoList.size() > 0) {
                for (MjDataVo mjDataVo : mjDataVoList) {
                    MjIndicationDetailVo mjIndicationDetailVo = detailVoMap.get(mjDataVo.getName());
                    if (mjIndicationDetailVo == null) {
                        continue;
                    }
                    if (mjDataVo.getResult() != null) {
                        mjIndicationDetailVo.setLastScore(mjDataVo.getResult().toString());
                    }
                    detailVoMap.put(mjDataVo.getName(), mjIndicationDetailVo);
                }
            }
        }
        //返回症状数据
        //4.返回症状数据
        List<MjIndicationDetailVo> detailVoList = new ArrayList<>();
        for (Map.Entry<String, MjIndicationDetailVo> voEntry : detailVoMap.entrySet()) {
            detailVoList.add(voEntry.getValue());
@@ -1337,9 +1327,10 @@
     */
    private Map<String, MjIndicationDetailVo> getMjIndicationDetailVoMap(Map<String, String> nameTypeMap
            , MjSkinReport mjSkinReport, Map<String, Object> sqlMap, SqlSentence sqlSentence) {
        //适应症名称,适应症数据
        Map<String, MjIndicationDetailVo> detailVoMap = new HashMap<>();
        MjIndicationDetailVo mjIndicationDetailVo = null;
        //封装症状数据
        //1.封装症状数据
        if (StringUtils.noNull(mjSkinReport.getContents())) {
            List<MjDataVo> mjDataVoList = JSONArray.parseArray(mjSkinReport.getContents(), MjDataVo.class);
            //处理分类
@@ -1347,7 +1338,8 @@
                for (MjDataVo mjDataVo : mjDataVoList) {
                    mjIndicationDetailVo = new MjIndicationDetailVo();
                    mjIndicationDetailVo.setName(mjDataVo.getName());
                    mjIndicationDetailVo.setTypeName(nameTypeMap.get(mjDataVo.getName()));
                    String typeName = nameTypeMap.get(mjDataVo.getName());
                    mjIndicationDetailVo.setTypeName(StringUtils.isEmpty(typeName) ? "其他" : typeName);
                    mjIndicationDetailVo.setDegree(MjSkinReport.getDegree(mjDataVo.getLevel()));
                    if (mjDataVo.getResult() != null) {
                        mjIndicationDetailVo.setScore(mjDataVo.getResult().toString());
@@ -1359,7 +1351,7 @@
        if (detailVoMap.size() < 1) {
            return detailVoMap;
        }
        //查询治疗方案数据
        //2.查询适应症数据
        sqlMap.put("dataType", Indication.DATA_TYPE_MICRO_PLAN);
        StringBuilder sql = new StringBuilder();
        sql.append(" SELECT i.id,i.name,i.byName,i.description,i.dailyCare,i.beautScience,i.reason,i.imgUrl FROM indication AS i ");
@@ -1383,38 +1375,83 @@
                detailVoMap.put(indication.getName(), mjIndicationDetailVo);
            }
        }
        //处理治疗项目
        //3.处理治疗设备和治疗项目
        if (indicationList != null && indicationList.size() > 0) {
            //先查询适应症关联的治疗方案
            sqlMap.put("typeStr", TreatPlan.TYPE_STR_INDICATION);
            sql.delete(0, sql.length());
            sql.append(" SELECT i.commonId,d.name AS commonName FROM treat_plan_item AS i ");
            sql.append(" JOIN treat_plan AS t ON t.id = i.treatPlanId ");
            sql.append(" JOIN treat_plan_indication AS p ON p.treatPlanId = i.treatPlanId ");
            sql.append(" SELECT t.id,d.name FROM treat_plan AS t ");
            sql.append(" JOIN treat_plan_indication AS p ON p.treatPlanId = t.id ");
            sql.append(" JOIN indication AS d ON d.id = p.indicationId ");
            sql.append(" WHERE i.isDel = #{m.isDel} AND p.isDel = #{m.isDel}  ");
            sql.append(" AND t.isDel = #{m.isDel} AND t.typeStr = #{m.typeStr} AND t.isUp = #{m.isUp} ");
            sql.append(" AND d.isDel = #{m.isDel} AND d.id IN ( ");
            sql.append(" WHERE t.isDel = #{m.isDel} AND t.typeStr = #{m.typeStr} AND t.isUp = #{m.isUp}   ");
            sql.append(" AND p.isDel = #{m.isDel} AND d.isDel = #{m.isDel} ");
            sql.append("  AND d.id IN ( ");
            for (Indication indication : indicationList) {
                sql.append("'").append(indication.getId()).append("'").append(",");
            }
            sql.delete(sql.length() - 1, sql.length());
            sql.append(" )");
            sql.append(" GROUP BY i.commonId,d.id ");
            sql.append(" GROUP BY t.id,d.id ");
            sqlSentence.sqlSentence(sql.toString(), sqlMap);
            List<MicroPlanItem> microPlanItemList = commonService.selectList(MicroPlanItemMapper.class, sqlSentence);
            if (microPlanItemList != null && microPlanItemList.size() > 0) {
                for (MicroPlanItem microPlanItem : microPlanItemList) {
                    mjIndicationDetailVo = detailVoMap.get(microPlanItem.getCommonName());
                    if (mjIndicationDetailVo == null){
            logger.info("查询适应症关联的治疗方案sql:{},Map:{}", sqlSentence.getSqlSentence(),JSON.toJSONString(sqlSentence.getM()));
            List<TreatPlan> treatPlanList = commonService.selectList(TreatPlanMapper.class, sqlSentence);
            if (treatPlanList != null && treatPlanList.size() > 0){
                //治疗方案对应的设备
                String deviceSql = " SELECT id,describeMsg,imgUrl FROM treat_plan_device WHERE isDel = 0 AND treatPlanId = #{m.treatPlanId} ";
                //治疗方案对应的项目
                String projectSql = " SELECT id,commonId FROM treat_plan_item WHERE isDel = 0 AND treatPlanId = #{m.treatPlanId} ";
                //返回的数据
                List<Map<String, Object>> deviceTotalList = null;
                //治疗的项目标识
                List<String> goodsIdList = null;
                for (TreatPlan treatPlan : treatPlanList) {
                    sqlMap.put("treatPlanId", treatPlan.getId());
                    mjIndicationDetailVo = detailVoMap.get(treatPlan.getName());
                    if (mjIndicationDetailVo == null) {
                        continue;
                    }
                    List<String> goodsIdList = mjIndicationDetailVo.getGoodsIdList();
                    if (goodsIdList == null) {
                        goodsIdList = new ArrayList<>();
                    deviceTotalList = mjIndicationDetailVo.getDeviceList();
                    if (deviceTotalList == null){
                        deviceTotalList = new ArrayList<>();
                    }
                    goodsIdList.add(microPlanItem.getCommonId());
                    mjIndicationDetailVo.setGoodsIdList(goodsIdList);
                    detailVoMap.put(microPlanItem.getCommonName(), mjIndicationDetailVo);
                    //查询设备数据
                    sqlSentence.sqlSentence(deviceSql, sqlMap);
                    List<Map<String, Object>> deviceList = commonService.selectListMap(TreatPlanDeviceMapper.class, sqlSentence);
                    if (deviceList != null && deviceList.size() > 0) {
                        //查询项目数据
                        sqlSentence.sqlSentence(projectSql, sqlMap);
                        List<TreatPlanItem> projectList = commonService.selectList(TreatPlanItemMapper.class, sqlSentence);
                        if (projectList != null && projectList.size() > 0) {
                            goodsIdList = projectList.stream().map(TreatPlanItem::getCommonId).collect(Collectors.toList());
                        }else {
                            goodsIdList = new ArrayList<>();
                        }
                        //给每个设备数据关联上相同治疗方案的推荐项目
                        for (Map<String, Object> map : deviceList) {
                            map.put("goodsIdList", goodsIdList);
                        }
                        deviceTotalList.addAll(deviceList);
                    }
                    mjIndicationDetailVo.setDeviceList(deviceTotalList);
                    detailVoMap.put(treatPlan.getName(), mjIndicationDetailVo);
                }
            }
        }
        //4.查询上一次同类型的美际报告,上一次分值
        MjSkinReport lastMjSkinReport = getLastMjSkinReport(mjSkinReport, sqlMap, sqlSentence);
        if (lastMjSkinReport != null && StringUtils.noNull(lastMjSkinReport.getContents())) {
            List<MjDataVo> mjDataVoList = JSONArray.parseArray(lastMjSkinReport.getContents(), MjDataVo.class);
            if (mjDataVoList != null && mjDataVoList.size() > 0) {
                for (MjDataVo mjDataVo : mjDataVoList) {
                    mjIndicationDetailVo = detailVoMap.get(mjDataVo.getName());
                    if (mjIndicationDetailVo == null) {
                        continue;
                    }
                    if (mjDataVo.getResult() != null) {
                        mjIndicationDetailVo.setLastScore(mjDataVo.getResult().toString());
                    }
                    detailVoMap.put(mjDataVo.getName(), mjIndicationDetailVo);
                }
            }
        }