From a5704a4dd10ad7de4b91f05951e3bb019ccfa256 Mon Sep 17 00:00:00 2001
From: chenjiahe <763432473@qq.com>
Date: 星期四, 30 五月 2024 14:31:04 +0800
Subject: [PATCH] 咨询记录

---
 phi_platform_user/src/main/java/com/hx/phip/service/consultation/impl/ConsultationRecordServiceImpl.java |   72 +++++++++++++++++++++++++++++++----
 phi_platform_user/src/main/java/com/hx/phip/controller/consultation/ConsultationRecordController.java    |   32 ++++++++++++---
 2 files changed, 88 insertions(+), 16 deletions(-)

diff --git a/phi_platform_user/src/main/java/com/hx/phip/controller/consultation/ConsultationRecordController.java b/phi_platform_user/src/main/java/com/hx/phip/controller/consultation/ConsultationRecordController.java
index f1032d0..9098004 100644
--- a/phi_platform_user/src/main/java/com/hx/phip/controller/consultation/ConsultationRecordController.java
+++ b/phi_platform_user/src/main/java/com/hx/phip/controller/consultation/ConsultationRecordController.java
@@ -14,16 +14,15 @@
 import com.hx.phiappt.constants.tool.PageUtil;
 import com.hx.phiappt.constants.tool.user.UserProjectTool;
 import com.hx.phiappt.dao.mapper.*;
-import com.hx.phiappt.model.BaseEntity;
-import com.hx.phiappt.model.ConsultationRecord;
-import com.hx.phiappt.model.Employee;
-import com.hx.phiappt.model.User;
+import com.hx.phiappt.model.*;
 import com.hx.phiappt.model.guide.VisitRecord;
 import com.hx.phiappt.model.user.UserProjectItem;
 import com.hx.phip.service.SystemParameterService;
 import com.hx.phip.service.consultation.ConsultationRecordService;
 import com.hx.util.StringUtils;
+import com.hz.his.dto.consultation.ConsultAppearancePlanVo;
 import com.hz.his.dto.consultation.ConsultRecordDto;
+import com.hz.his.dto.consultation.ConsultTreatProjectVo;
 import com.platform.exception.PlatTipsException;
 import com.platform.resultTool.PlatformCode;
 import com.platform.resultTool.PlatformResult;
@@ -57,7 +56,7 @@
     /**
      * 鏂板
      */
-    @RequestMapping(value = "/add/or/edit", method = RequestMethod.POST)
+    @RequestMapping(value = "/addOrUpdate", method = RequestMethod.POST)
     public PlatformResult addOrEditData(@RequestBody ConsultRecordDto consultRecordDto) {
         //鍙傛暟鏍¢獙
         checkParams(consultRecordDto);
@@ -120,10 +119,26 @@
 
         // 娌荤枟椤圭洰
         sql.delete(0, sql.length());
-        sql.append("SELECT crp.projectId,crp.projectName FROM `consultation_treat_project` AS crp LEFT JOIN project AS pro ON pro.id=crp.projectId WHERE  crp.userId=#{m.userId} AND crp.consultationRecordId =#{m.consultationRecordId} AND crp.isDel=#{m.isDel}");
+        values.put("type", ConsultationTreatProject.PROJECT_TYPE_TREAT);
+        sql.append("SELECT crp.projectId,crp.projectName FROM `consultation_treat_project` AS crp LEFT JOIN project AS pro ON pro.id=crp.projectId WHERE  crp.userId=#{m.userId} AND crp.consultationRecordId =#{m.consultationRecordId} AND crp.isDel=#{m.isDel} AND crp.type = #{m.type}");
         sqlSentence.setSqlSentence(sql.toString());
         List<Map<String, Object>> treatProjectList = commonService.selectListMap(ConsultationTreatProjectMapper.class, sqlSentence);
         consultRecordDto.setTreatProjectList(treatProjectList);
+
+        // 棰勭害椤圭洰
+        sql.delete(0, sql.length());
+        values.put("type", ConsultationTreatProject.PROJECT_TYPE_PRE);
+        sql.append("SELECT crp.projectId,crp.projectName FROM consultation_treat_project AS crp LEFT JOIN project AS pro ON pro.id=crp.projectId WHERE  crp.userId=#{m.userId} AND crp.consultationRecordId =#{m.consultationRecordId} AND crp.isDel=#{m.isDel} AND crp.type = #{m.type}");
+        sqlSentence.setSqlSentence(sql.toString());
+        List<Map<String, Object>> preProjectList = commonService.selectListMap(ConsultationTreatProjectMapper.class, sqlSentence);
+        consultRecordDto.setPreProjectList(JSON.parseArray(JSON.toJSONString(preProjectList), ConsultTreatProjectVo.class));
+
+        //棰滃�艰鍒�
+        sql.delete(0, sql.length());
+        sql.append("SELECT cap.details FROM consultation_appearance_plan cap WHERE cap.consultationRecordId =#{m.consultationRecordId} AND cap.isDel=#{m.isDel}");
+        sqlSentence.setSqlSentence(sql.toString());
+        List<Map<String, Object>> appearancePlan = commonService.selectListMap(ConsultationAppearancePlanMapper.class, sqlSentence);
+        consultRecordDto.setAppearancePlanList(JSON.parseArray(JSON.toJSONString(appearancePlan), ConsultAppearancePlanVo.class));
 
         //闈㈣瘖鍖荤敓
         Employee faceEmp = commonService.selectOneByKey(EmployeeMapper.class, consultRecordDto.getFaceDoctorId());
@@ -270,7 +285,10 @@
         sql.append(" , u.CIQ, f.cnName AS faceDoctorName ,t.cnName AS treatDoctorName,s.name as shopName,u.name as userName ");
         sql.append(" ,insert(CONVERT(AES_DECRYPT(UNHEX(u.tel), #{m.key}) , CHAR), 4, 4, '****') as tel");
         sql.append(" ,uStatistics.recentVisitType,uStatistics.recentVisitStatus,uStatistics.isMakeADeal");
-        sql.append(" ,cr.doubt,cr.dissent,cr.budget,cr.interestedActivities,cr.followUpWorks");
+        sql.append(" ,cr.doubt,cr.dissent,cr.budget,cr.interestedActivities,cr.followUpWorks,cr.userCareer");
+        sql.append(" ,cr.workRest,cr.character,cr.userLike,cr.maritalStatus,cr.preparationPregnancy");
+        sql.append(" ,cr.allergyHistory,cr.diseaseHistory,cr.unanamnesis,cr.anamTreatAgency,cr.anamTreatDoctor");
+        sql.append(" ,cr.anamTreatSatisfaction,cr.estimateMapper,cr.specialSituation");
         sql.append(" FROM consultation_record cr ");
         sql.append(" LEFT JOIN user u ON cr.userId = u.id ");
         sql.append(" LEFT JOIN employee f ON cr.faceDoctorId = f.id");
diff --git a/phi_platform_user/src/main/java/com/hx/phip/service/consultation/impl/ConsultationRecordServiceImpl.java b/phi_platform_user/src/main/java/com/hx/phip/service/consultation/impl/ConsultationRecordServiceImpl.java
index ed8a5ec..fd3c51a 100644
--- a/phi_platform_user/src/main/java/com/hx/phip/service/consultation/impl/ConsultationRecordServiceImpl.java
+++ b/phi_platform_user/src/main/java/com/hx/phip/service/consultation/impl/ConsultationRecordServiceImpl.java
@@ -13,7 +13,9 @@
 import com.hx.phip.service.SystemParameterService;
 import com.hx.phip.service.consultation.ConsultationRecordService;
 import com.hx.util.StringUtils;
+import com.hz.his.dto.consultation.ConsultAppearancePlanVo;
 import com.hz.his.dto.consultation.ConsultRecordDto;
+import com.hz.his.dto.consultation.ConsultTreatProjectVo;
 import com.platform.exception.PlatTipsException;
 import com.platform.resultTool.PlatformCode;
 import org.springframework.beans.BeanUtils;
@@ -37,6 +39,10 @@
     private ConsultationTreatProjectMapper consultationTreatProjectMapper;
     @Resource
     private ConsultationRecommendedProjectMapper consultationRecommendedProjectMapper;
+    @Resource
+    private ProjectMapper projectMapper;
+    @Resource
+    private ConsultationAppearancePlanMapper appearancePlanMapper;
 
     @Override
     public String insertOrEdit(ConsultRecordDto consultRecordDto, SystemParameterService systemParameterService, CommonService commonService) {
@@ -87,6 +93,15 @@
             }
         }
 
+        //鎺ㄨ崘椤圭洰
+        if (!StringUtils.isEmpty(consultRecordDto.getRecommendProjectIds())) {
+            List<String> recommendIdList = new ArrayList<>();
+            for (String s:consultRecordDto.getRecommendProjectIds().split(",")) {
+                recommendIdList.add(s);
+            }
+            handleRecommendPro(recommendIdList,consultationRecord.getId(), consultRecordDto.getUserId());
+        }
+
         //娌荤枟椤圭洰
         if (!StringUtils.isEmpty(consultRecordDto.getTreatProjectIds())) {
             List<String> treatIdList = new ArrayList<>();
@@ -96,14 +111,10 @@
             handleTreatPro(treatIdList,consultationRecord.getId(), consultRecordDto.getUserId());
         }
 
-        //鎺ㄨ崘椤圭洰
-        if (!StringUtils.isEmpty(consultRecordDto.getRecommendProjectIds())) {
-            List<String> recommendIdList = new ArrayList<>();
-            for (String s:consultRecordDto.getRecommendProjectIds().split(",")) {
-                recommendIdList.add(s);
-            }
-            handleRecommendPro(recommendIdList,consultationRecord.getId(), consultRecordDto.getUserId());
-        }
+        //棰勭害椤圭洰
+        preProjectHandle(consultationRecord.getId(),consultationRecord.getUserId(),consultRecordDto.getPreProjectList());
+        //棰滃�艰鍒�
+        appearancePlanHandle(consultationRecord.getId(),consultRecordDto.getAppearancePlanList());
 
         return consultationRecord.getId();
     }
@@ -122,7 +133,7 @@
 
     //---------------------------------------------------------------------
 
-    //澶勭悊娌荤枟椤圭洰
+    /**澶勭悊娌荤枟椤圭洰*/
     public void handleTreatPro(List<String> treatProjectIds,String recordId,String userId){
 
         SqlSentence sqlSentence = new SqlSentence();
@@ -203,6 +214,49 @@
     }
 
 
+    /**棰勭害椤圭洰*/
+    public void preProjectHandle(String recordId,String userId,List<ConsultTreatProjectVo> preProjectList){
+
+        //鍏堝垹闄ゆ棫鐨�
+        consultationTreatProjectMapper.deleteByRecordId(recordId,ConsultationTreatProject.PROJECT_TYPE_PRE);
+
+        if(preProjectList == null || preProjectList.size() == 0){
+            return;
+        }
+
+        ConsultationTreatProject consultationTreatProject;
+        Project project;
+        for(ConsultTreatProjectVo consultTreatProjectVo:preProjectList){
+            if(StringUtils.isEmpty(consultTreatProjectVo.getProjectId())){
+                throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"棰勭害椤圭洰鏍囪瘑涓嶈兘绌猴紒");
+            }
+            project = projectMapper.selectOneByKey(consultTreatProjectVo.getProjectId());
+            if(project == null){
+                throw new PlatTipsException(PlatformCode.ERROR_TIPS,"棰勭害椤圭洰鏍囪瘑閿欒锛�");
+            }
+            consultationTreatProject = new ConsultationTreatProject(userId,project.getId(),project.getName(),recordId,ConsultationTreatProject.PROJECT_TYPE_PRE);
+            consultationTreatProjectMapper.insert(consultationTreatProject);
+        }
+    }
+
+    /**棰滃�艰鍒�*/
+    public void appearancePlanHandle(String recordId,List<ConsultAppearancePlanVo> appearancePlanList){
+
+        //鍏堝垹闄ゆ棫鐨�
+        appearancePlanMapper.deleteByRecordId(recordId);
+
+        if(appearancePlanList == null || appearancePlanList.size() == 0){
+            return;
+        }
+
+        ConsultationAppearancePlan consultationAppearancePlan;
+        for(ConsultAppearancePlanVo consultAppearancePlanVo:appearancePlanList){
+            consultationAppearancePlan = new ConsultationAppearancePlan(consultAppearancePlanVo.getDetails(),recordId);
+            appearancePlanMapper.insert(consultationAppearancePlan);
+        }
+    }
+
+
     //澶勭悊鎺ㄨ崘椤圭洰
     public void handleRecommendPro(List<String> recommendProjectIds,String recordId,String userId){
 

--
Gitblit v1.8.0