Pārlūkot izejas kodu

Merge branch 'dev' of humingfen/patient-co-management into dev

liuwenbin 7 gadi atpakaļ
vecāks
revīzija
bc4e786e8a
20 mainītis faili ar 495 papildinājumiem un 121 dzēšanām
  1. 73 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/customer/CustomerQuestionnaireController.java
  2. 36 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/customer/CustomerScreenResultController.java
  3. 0 4
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/customer/ScreenResultController.java
  4. 2 3
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/doctor/DoctorQuestionnaireController.java
  5. 1 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/survey/SurveyTemplateQuestion.java
  6. 2 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/survey/SurveyQuestionResultDao.java
  7. 0 26
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/survey/SurveyTemplateQuestionDao.java
  8. 29 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/survey/SurveyTemplateQuestionsDao.java
  9. 7 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/synergy/ManageSynergyWorkorderServicerDao.java
  10. 9 10
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/survey/SurveyTemplateQuestionService.java
  11. 4 4
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/survey/SurveyTemplateService.java
  12. 182 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/QuestionnaireManageService.java
  13. 0 69
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/QuestionnaireManagerService.java
  14. 35 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/ScreenResultManageService.java
  15. 40 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/util/HttpClientUtil.java
  16. 6 1
      patient-co-manage/wlyy-manage/src/main/resources/application.yml
  17. 10 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyQuestionResultDao.java
  18. 1 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyTemplatesDao.java
  19. 35 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/ManagerQuestionnaireService.java
  20. 23 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/ManagerQuestionnaireController.java

+ 73 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/customer/CustomerQuestionnaireController.java

@ -1,4 +1,76 @@
package com.yihu.wlyy.controller.synergy.customer;
public class CustomerQuestionnaireController {
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.service.synergy.QuestionnaireManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
/**
 * 客服端问卷调查
 * Created by Humingfen on 2018/9/29.
 */
@Controller
@RequestMapping(value = "/customer/question")
@Api(description = "客服端-接收问卷协同服务")
public class CustomerQuestionnaireController extends BaseController {
    @Autowired
    private QuestionnaireManageService questionnaireService;
    @RequestMapping(value = "saveAnswer", method = RequestMethod.POST)
    @ApiOperation(value = "保存用户答案")
    public String saveAnswer( @ApiParam(value = "问卷题目及选项")@RequestParam String jsonData,
                              @ApiParam(value = "客服code")@RequestParam(value = "customerCode")String customerCode,
                              @ApiParam(value = "居民code")@RequestParam(value = "patientCode")String patientCode,
                              @ApiParam(value = "问卷标签")@RequestParam(value = "labelType")Integer labelType,
                              @ApiParam(value = "筛查入口(labelType=5时要填),0是第一次筛查 1是再次评估", defaultValue = "1")@RequestParam(value = "isAgain")int isAgain,
                              @ApiParam(value = "来源(1医生发放 2居民自我评估)")@RequestParam(value = "source")int source,
                              @ApiParam(value = "协同工单服务对象表code")@RequestParam(value = "source")String serviceCode) {
        try {
            return  write(200, "保存成功!", "data", questionnaireService.saveResultAndAnswer(patientCode, labelType, customerCode, isAgain, source,jsonData, serviceCode));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "保存失败!");
        }
    }
    @RequestMapping(value = "getAnswers", method = RequestMethod.GET)
    @ApiOperation(value = "查看调查统计结果")
    public String getAnswers(@ApiParam(value = "问卷code") @RequestParam String templateCode) {
        try {
            return write(200, "查询成功!", "data", questionnaireService.getAnswers(templateCode));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "getResult", method = RequestMethod.GET)
    @ApiOperation(value = "查看客服对居民调查问卷结果")
    public String getResult(@ApiParam(value = "调查结果code") @RequestParam String questionResultCode) {
        try {
            return write(200, "查询成功!", "data", questionnaireService.getReuslt(questionResultCode));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "getQuestionnaireDetail", method = RequestMethod.GET)
    @ApiOperation(value = "查看调查问卷内容")
    public String getQuestionnaireDetail(@ApiParam(value = "调查问卷code") @RequestParam String surveyCode) {
        try {
            return write(200, "查询成功!", "data", questionnaireService.getQuestionnaireDetail(surveyCode));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
}

+ 36 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/customer/CustomerScreenResultController.java

@ -0,0 +1,36 @@
package com.yihu.wlyy.controller.synergy.customer;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.service.synergy.ScreenResultManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
/**
 * 客服端疾病筛查
 * Created by Humingfen on 2018/9/29.
 */
@Controller
@RequestMapping(value = "/customer/screen")
@Api(description = "客服端-接收问卷协同服务")
public class CustomerScreenResultController extends BaseController {
    @Autowired
    private ScreenResultManageService screenResultService;
    @RequestMapping(value = "getScreenResultDetail", method = RequestMethod.GET)
    @ApiOperation(value = "查看筛查结果记录详情")
    public String getScreenResultDetail(@ApiParam(value = "筛查结果唯一code")@RequestParam(value = "code") String code) {
        try {
            return write(200, "获取成功!", "data", screenResultService.getScreenResultDetail(code));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
}

+ 0 - 4
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/customer/ScreenResultController.java

@ -1,4 +0,0 @@
package com.yihu.wlyy.controller.synergy.customer;
public class ScreenResultController {
}

+ 2 - 3
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/doctor/DoctorQuestionnaireController.java

@ -5,7 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerDO;
import com.yihu.wlyy.service.synergy.QuestionnaireManagerService;
import com.yihu.wlyy.service.synergy.QuestionnaireManageService;
import com.yihu.wlyy.service.synergy.SynergyManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -30,7 +30,7 @@ public class DoctorQuestionnaireController extends BaseController {
    @Autowired
    ObjectMapper objectMapper;
    @Autowired
    private QuestionnaireManagerService questionnaireService;
    private QuestionnaireManageService questionnaireService;
    @Autowired
    private SynergyManageService synergyManageService;
@ -48,6 +48,5 @@ public class DoctorQuestionnaireController extends BaseController {
            error(e);
            return error(-1,"保存失败");
        }
    }
}

+ 1 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/survey/SurveyTemplateQuestion.java

@ -14,7 +14,7 @@ import java.util.Date;
 */
@Entity
@Table(name = "wlyy_survey_template_questions")
public class SurveyTemplateQuestion extends IdEntity{
public class SurveyTemplateQuestions extends IdEntity{
    private static final long serialVersionUID = 1L;
    private String code;
    private String templateCode;//模板code

+ 2 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/survey/SurveyQuestionResultDao.java

@ -8,4 +8,6 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 * Created by humingfen on 2018/9/27.
 */
public interface SurveyQuestionResultDao extends PagingAndSortingRepository<SurveyQuestionResult, Long>, JpaSpecificationExecutor<SurveyQuestionResult> {
    SurveyQuestionResult findByCode(String code);
}

+ 0 - 26
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/survey/SurveyTemplateQuestionDao.java

@ -1,26 +0,0 @@
package com.yihu.wlyy.repository.survey;
import com.yihu.wlyy.entity.survey.SurveyTemplateQuestion;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by yeshijie on 2017/3/7.
 */
public interface SurveyTemplateQuestionDao extends PagingAndSortingRepository<SurveyTemplateQuestion,Long>,JpaSpecificationExecutor<SurveyTemplateQuestion> {
    @Query("update SurveyTemplateQuestion set del = 0 where templateCode=?1 and del = 1")
    @Modifying
    void updateDelByTemplateCode(String templateCode);
    @Modifying
    void deleteByTemplateCode(String templateCode);
    List<SurveyTemplateQuestion> findByTemplateCodeAndDel(String templateCode,String del);
    SurveyTemplateQuestion findByCode(String code);
}

+ 29 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/survey/SurveyTemplateQuestionsDao.java

@ -0,0 +1,29 @@
package com.yihu.wlyy.repository.survey;
import com.yihu.wlyy.entity.survey.SurveyTemplateQuestions;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by yeshijie on 2017/3/7.
 */
public interface SurveyTemplateQuestionsDao extends PagingAndSortingRepository<SurveyTemplateQuestions,Long>,JpaSpecificationExecutor<SurveyTemplateQuestions> {
    @Query("update SurveyTemplateQuestions set del = 0 where templateCode=?1 and del = 1")
    @Modifying
    void updateDelByTemplateCode(String templateCode);
    @Modifying
    void deleteByTemplateCode(String templateCode);
    List<SurveyTemplateQuestions> findByTemplateCodeAndDel(String templateCode, String del);
    SurveyTemplateQuestions findByCode(String code);
    @Query("select q from SurveyTemplateQuestions q where q.templateCode = ?1")
    List<SurveyTemplateQuestions> findByTemplateCode(String templateCode);
}

+ 7 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/synergy/ManageSynergyWorkorderServicerDao.java

@ -1,11 +1,18 @@
package com.yihu.wlyy.repository.synergy;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerDO;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;
public interface ManageSynergyWorkorderServicerDao extends PagingAndSortingRepository<ManageSynergyWorkorderServicerDO, Long> {
    @Query(" select count(1) from ManageSynergyWorkorderServicerDO s where s.workorderCode=?1 and s.status=?2 ")
    Integer findByWorkorderCodeCount(String workorderCode,Integer status);
    @Transactional
    @Modifying
    @Query("update ManageSynergyWorkorderServicerDO s set s.relationCode = ?2 where s.code = ?1")
    void updateRelationCodeByCode(String serviceCode, String questionResultCode);
}

+ 9 - 10
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/survey/SurveyTemplateQuestionService.java

@ -1,12 +1,11 @@
package com.yihu.wlyy.service.manager.survey;
import com.yihu.wlyy.entity.survey.SurveyTemplateQuestion;
import com.yihu.wlyy.repository.survey.SurveyTemplateQuestionDao;
import com.yihu.wlyy.entity.survey.SurveyTemplateQuestions;
import com.yihu.wlyy.repository.survey.SurveyTemplateQuestionsDao;
import com.yihu.wlyy.util.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
@ -14,9 +13,9 @@ import java.util.List;
 * Created by ysj on 2017/3/3.
 */
@Service
public class SurveyTemplateQuestionService extends BaseJpaService<SurveyTemplateQuestion,Long> {
public class SurveyTemplateQuestionService extends BaseJpaService<SurveyTemplateQuestions,Long> {
    @Autowired
    SurveyTemplateQuestionDao surveyTemplateQuestionDao;
    SurveyTemplateQuestionsDao surveyTemplateQuestionDao;
    /**
     * 根据模板code删除数据
@ -36,19 +35,19 @@ public class SurveyTemplateQuestionService extends BaseJpaService<SurveyTemplate
     * @param templateCode
     * @return
     */
    public List<SurveyTemplateQuestion> findByTemplateCode(String templateCode){
    public List<SurveyTemplateQuestions> findByTemplateCode(String templateCode){
        return surveyTemplateQuestionDao.findByTemplateCodeAndDel(templateCode,"1");
    }
    public void save(List<SurveyTemplateQuestion> surveyTemplateQuestions){
    public void save(List<SurveyTemplateQuestions> surveyTemplateQuestions){
        surveyTemplateQuestionDao.save(surveyTemplateQuestions);
    }
    public SurveyTemplateQuestion save(SurveyTemplateQuestion surveyTemplateQuestion){
       return surveyTemplateQuestionDao.save(surveyTemplateQuestion);
    public SurveyTemplateQuestions save(SurveyTemplateQuestions surveyTemplateQuestions){
       return surveyTemplateQuestionDao.save(surveyTemplateQuestions);
    }
    public SurveyTemplateQuestion findByCode(String code){
    public SurveyTemplateQuestions findByCode(String code){
        return  surveyTemplateQuestionDao.findByCode(code);
    }
}

+ 4 - 4
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/survey/SurveyTemplateService.java

@ -5,7 +5,7 @@ import com.yihu.wlyy.entity.User;
import com.yihu.wlyy.entity.survey.SurveyLabelInfo;
import com.yihu.wlyy.entity.survey.SurveyTemplate;
import com.yihu.wlyy.entity.survey.SurveyTemplateOption;
import com.yihu.wlyy.entity.survey.SurveyTemplateQuestion;
import com.yihu.wlyy.entity.survey.SurveyTemplateQuestions;
import com.yihu.wlyy.repository.SystemDictDao;
import com.yihu.wlyy.repository.survey.SurveyTemplateDao;
import com.yihu.wlyy.service.manager.user.UserService;
@ -57,7 +57,7 @@ public class SurveyTemplateService extends BaseJpaService<SurveyTemplate,Long> {
    public SurveyTemplate saveOrUpdate(String jsonData,String loginUserId){
        JSONArray array = new JSONArray(jsonData);
        List<SurveyTemplate> surveyTemplates = new ArrayList<>();
        List<SurveyTemplateQuestion> surveyTemplateQuestions = new ArrayList<>();
        List<SurveyTemplateQuestions> surveyTemplateQuestions = new ArrayList<>();
        List<SurveyTemplateOption> surveyTemplateOptions = new ArrayList<>();
        List<SurveyLabelInfo> surveyLabelInfos = new ArrayList<>();
        SurveyTemplate surveyTemplate = null;
@ -87,7 +87,7 @@ public class SurveyTemplateService extends BaseJpaService<SurveyTemplate,Long> {
            if(!jsonObject.isNull("questions")){
                JSONArray questionsArray = (JSONArray)jsonObject.get("questions");
                for(Object questionObj:questionsArray){
                    SurveyTemplateQuestion surveyTemplateQuestion = new SurveyTemplateQuestion();
                    SurveyTemplateQuestions surveyTemplateQuestion = new SurveyTemplateQuestions();
                    JSONObject questionJson = (JSONObject)questionObj;
                    clazzReflect.formatToClazz(surveyTemplateQuestion,questionJson);
                    surveyTemplateQuestion.setCreateTime(new Date());
@ -206,7 +206,7 @@ public class SurveyTemplateService extends BaseJpaService<SurveyTemplate,Long> {
        if(surveyTemplate==null) throw new  RuntimeException("模板不存在!");
        JSONObject surveyTemplateJson = new JSONObject(surveyTemplate);
        if(loadQuestion==1l){
            List<SurveyTemplateQuestion> surveyTemplateQuestions = this.surveyTemplateQuestionService.findByTemplateCode(surveyTemplate.getCode());
            List<SurveyTemplateQuestions> surveyTemplateQuestions = this.surveyTemplateQuestionService.findByTemplateCode(surveyTemplate.getCode());
            JSONArray questions = new JSONArray(surveyTemplateQuestions);

+ 182 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/QuestionnaireManageService.java

@ -0,0 +1,182 @@
package com.yihu.wlyy.service.synergy;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.survey.SurveyQuestionResult;
import com.yihu.wlyy.entity.survey.SurveyTemplateQuestions;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerDO;
import com.yihu.wlyy.repository.survey.SurveyQuestionResultDao;
import com.yihu.wlyy.repository.survey.SurveyTemplateQuestionsDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkOrderDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkorderServicerDao;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by humingfen on 2018/09/27.
 */
@Service
public class QuestionnaireManageService extends BaseJpaService {
    @Value("${wlyy.url}")
    private String wlyyUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private ManageSynergyWorkOrderDao workOrderDao;
    @Autowired
    private ManageSynergyWorkorderServicerDao workorderServicerDao;
    @Autowired
    private SurveyTemplateQuestionsDao templateQuestionDao;
    @Autowired
    private SurveyQuestionResultDao questionResultDao;
    /**
     * 创建协同服务
     * @param workorderDO
     * @param workorderServicerDOS
     * @return
     */
    public boolean createWorkOrder(ManageSynergyWorkorderDO workorderDO, List<ManageSynergyWorkorderServicerDO> workorderServicerDOS) {
        String servicer = null;
        int size = workorderServicerDOS.size();
        int len = 0;
        if(size > 5){
            len = 5;
        }else {
            len = size;
        }
        //获取服务对象最多五个人
        for(int i = 0; i < len; i++){
            servicer += workorderServicerDOS.get(i).getServicePatientName() + ",";
        }
        servicer = servicer.substring(0, servicer.length()-1);
        //保存协同服务工单
        workorderDO.setCode(getCode());
        workorderDO.setStatus(1);
        workorderDO.setCreateTime(new Date());
        workorderDO.setDel(1);
        workorderDO.setServicerCount(size);
        workorderDO.setServicerKey(servicer);
        workOrderDao.save(workorderDO);
        //保存协同服务工单的服务对象
        for(ManageSynergyWorkorderServicerDO servicerDO : workorderServicerDOS){
            servicerDO.setCode(getCode());
            servicerDO.setWorkorderType(workorderDO.getType());
            servicerDO.setWorkorderCode(workorderDO.getCode());
            servicerDO.setStatus(1);
            servicerDO.setCreateTime(new Date());
            workorderServicerDao.save(servicerDO);
        }
        return true;
    }
    /**
     * 保存问卷结果
     * @param patientCode
     * @param labelType
     * @param customerCode
     * @param isAgain
     * @param source
     * @param jsonData
     * @param serviceCode
     */
    public String saveResultAndAnswer(String patientCode, Integer labelType, String customerCode, int isAgain, int source, String jsonData, String serviceCode) {
        String url = wlyyUrl + "doctor/questionnaire/saveResultAndAnswer";
        String response = "";
        Map<String, Object> params = new HashMap<>();
        params.put("labelType", labelType);
        params.put("patientCode", patientCode);
        params.put("jsonData", jsonData);
        params.put("customerCode", customerCode);
        params.put("source", source);
        try {
            response = httpClientUtil.post(url, params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        JSONObject object = JSONObject.parseObject(response);
        String questionResultCode = object.getString("data");
        if(StringUtils.isNotBlank(questionResultCode)) {
            workorderServicerDao.updateRelationCodeByCode(serviceCode, questionResultCode);
        }
        return questionResultCode;
    }
    /**
     * 查看调查问卷统计结果
     * @param templateCode
     * @return
     */
    public JSONObject getAnswers(String templateCode) {
        String url = wlyyUrl + "doctor/questionnaire/getAnswers";
        String response = "";
        Map<String, Object> params = new HashMap<>();
        params.put("templateId", templateCode);
        try {
            response = httpClientUtil.post(url, params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return JSONObject.parseObject(response);
    }
    /**
     * 根据问卷结果code查看居民填写问卷详情
     * @param code
     * @return
     */
    public JSONObject getReuslt(String code){
        JSONObject json = new JSONObject();
        //查找问卷结果信息
        SurveyQuestionResult questionResult = questionResultDao.findByCode(code);
        String patient = questionResult.getPatientCode();
        String templateCode = questionResult.getTemplateCode();
        //获取模板问题
        List<SurveyTemplateQuestions> questionList = templateQuestionDao.findByTemplateCode(templateCode);
        //查找选项和答案
        Map<String, Object> answerMap = new HashMap<>();
        String sql = "SELECT soa.*, sto.content FROM wlyy_survey_option_answers soa LEFT JOIN wlyy_survey_template_options sto ON soa.options_code= sto.code WHERE soa.screen_result_code = ? AND soa.patient=? AND soa.survey_code=?";
        List<Map<String, Object>> optionAnswersList = jdbcTemplate.queryForList(sql, new Object[]{code, patient, templateCode});
        for (SurveyTemplateQuestions templateQuestion : questionList) {
            Map<String, Object> map = new HashMap<>();
            map.put("question", templateQuestion);
            String qusCode = templateQuestion.getCode();
            for (Map<String, Object> option : optionAnswersList) {
                if (option.get("question_code").equals(qusCode)) {
                    map.put("option", option);
                }
            }
            answerMap.put(templateQuestion.getSort() + "", map);
        }
        json.put("answer", answerMap);
        return json;
    }
    public JSONObject getQuestionnaireDetail(String surveyCode) {
        String url = wlyyUrl + "doctor/questionnaire/getQuestionnaireDetail";
        String response = "";
        Map<String, Object> params = new HashMap<>();
        params.put("id", surveyCode);
        try {
            response = httpClientUtil.post(url, params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return JSONObject.parseObject(response);
    }
}

+ 0 - 69
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/QuestionnaireManagerService.java

@ -1,69 +0,0 @@
package com.yihu.wlyy.service.synergy;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerDO;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkOrderDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkorderServicerDao;
import com.yihu.wlyy.util.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
 * Created by humingfen on 2018/09/27.
 */
@Service
public class QuestionnaireManagerService extends BaseJpaService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private ManageSynergyWorkOrderDao workOrderDao;
    @Autowired
    private ManageSynergyWorkorderServicerDao workorderServicerDao;
    /**
     * 创建协同服务
     * @param workorderDO
     * @param workorderServicerDOS
     * @return
     */
    public boolean createWorkOrder(ManageSynergyWorkorderDO workorderDO, List<ManageSynergyWorkorderServicerDO> workorderServicerDOS) {
        String servicer = null;
        int size = workorderServicerDOS.size();
        int len = 0;
        if(size > 5){
            len = 5;
        }else {
            len = size;
        }
        //获取服务对象最多五个人
        for(int i = 0; i < len; i++){
            servicer += workorderServicerDOS.get(i).getServicePatientName() + ",";
        }
        servicer = servicer.substring(0, servicer.length()-1);
        //保存协同服务工单
        workorderDO.setCode(getCode());
        workorderDO.setStatus(1);
        workorderDO.setCreateTime(new Date());
        workorderDO.setDel(1);
        workorderDO.setServicerCount(size);
        workorderDO.setServicerKey(servicer);
        workOrderDao.save(workorderDO);
        //保存协同服务工单的服务对象
        for(ManageSynergyWorkorderServicerDO servicerDO : workorderServicerDOS){
            servicerDO.setCode(getCode());
            servicerDO.setWorkorderType(workorderDO.getType());
            servicerDO.setWorkorderCode(workorderDO.getCode());
            servicerDO.setStatus(1);
            servicerDO.setCreateTime(new Date());
            workorderServicerDao.save(servicerDO);
        }
        return true;
    }
}

+ 35 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/ScreenResultManageService.java

@ -0,0 +1,35 @@
package com.yihu.wlyy.service.synergy;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.util.HttpClientUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
 * Created by humingfen on 2018/09/29.
 */
@Service
public class ScreenResultManageService {
    @Value("${wlyy.url}")
    private String wlyyUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    public JSONObject getScreenResultDetail(String code) {
        String url = wlyyUrl + "doctor/screen/getScreenResultDetail";
        String response = "";
        Map<String, String> params = new HashMap<>();
        params.put("code", code);
        try {
            response = httpClientUtil.httpPost(url, params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return JSONObject.parseObject(response);
    }
}

+ 40 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/util/HttpClientUtil.java

@ -110,6 +110,46 @@ public class HttpClientUtil {
		}
	}
	/**
	 * http调用方法
	 *
	 * @param url
	 * @param params
	 * @return
	 * @throws Exception
	 */
	public  String post(String url, Map<String, Object> params) throws Exception {
		CloseableHttpClient httpclient = HttpClients.createDefault();
		RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(30000).setConnectTimeout(10000).build();//设置请求和传输超时时间
		try {
			HttpPost httpPost = new HttpPost(url);
			httpPost.setConfig(requestConfig);
			if (params != null && params.size() > 0) {
				List<NameValuePair> valuePairs = new ArrayList<NameValuePair>(params.size());
				for (Map.Entry<String, Object> entry : params.entrySet()) {
					NameValuePair nameValuePair = new BasicNameValuePair(entry.getKey(), String.valueOf(entry.getValue()));
					valuePairs.add(nameValuePair);
				}
				UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(valuePairs, "UTF-8");
				httpPost.setEntity(formEntity);
			}
			CloseableHttpResponse resp = httpclient.execute(httpPost);
			try {
				HttpEntity entity = resp.getEntity();
				String respContent = EntityUtils.toString(entity, "UTF-8").trim();
				return respContent;
			} finally {
				resp.close();
			}
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			httpclient.close();
		}
	}
	/**
	 * 发送get请求
	 * @param url 请求地址

+ 6 - 1
patient-co-manage/wlyy-manage/src/main/resources/application.yml

@ -104,7 +104,9 @@ reservation:
healthbank:
  url: http://172.19.103.33:8660/svr-wlyy-health-bank/svr-health-bank/
#  url: http://192.168.131.133:10051/svr-health-bank/
#i健康1.0接口
wlyy:
  url: http://localhost:8080/wlyy/
wechat:
  appId: wxd03f859efdf0873d
  appSecret: 2935b54b53a957d9516c920a544f2537
@ -212,6 +214,9 @@ reservation:
#健康活动url
healthbank:
  url: http://172.19.103.33:8660/svr-wlyy-health-bank/svr-health-bank/
#i健康1.0接口
wlyy:
  url: http://localhost:8080/wlyy/
wechat:
  appId: wx1f129f7b51701428
  appSecret: 988f005d8309ed1795939e0f042431fb

+ 10 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyQuestionResultDao.java

@ -0,0 +1,10 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.survey.SurveyQuestionResult;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by humingfen on 2018/9/29.
 */
public interface SurveyQuestionResultDao extends PagingAndSortingRepository<SurveyQuestionResult, Long> {
}

+ 1 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyTemplatesDao.java

@ -6,7 +6,6 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
/**
@ -25,7 +24,7 @@ public interface SurveyTemplatesDao extends PagingAndSortingRepository<SurveyTem
    @Query("select count(t.id)  from SurveyTemplates t where t.title like ?1 ")
    int distinctLikeTitle(String title);
    @Query("select  t from SurveyTemplates t where t.code = ?1 ")
    @Query("select  t from SurveyTemplates t where t.code = ?1 and t.del = 1")
    SurveyTemplates findById(String code);
    @Modifying

+ 35 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/ManagerQuestionnaireService.java

@ -3,10 +3,12 @@ package com.yihu.wlyy.service.survey;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.survey.*;
import com.yihu.wlyy.entity.manage.User;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.doctor.*;
import com.yihu.wlyy.repository.manage.UserDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.BaseService;
@ -96,6 +98,10 @@ public class ManagerQuestionnaireService extends BaseService {
    private WechatTemplateConfigDao templateConfigDao;
    @Autowired
    private DoctorService doctorService;
    @Autowired
    private UserDao userDao;
    @Autowired
    private SurveyQuestionResultDao questionResultDao;
    private Logger logger = LoggerFactory.getLogger(this.getClass());
@ -1920,4 +1926,33 @@ public class ManagerQuestionnaireService extends BaseService {
        JSONObject rs = new JSONObject(response.getContent());
        return rs.getString("message");
    }
    /**
     * 保存问卷调查结果和答案
     * @param jsonData
     * @param patientCode
     * @param customerCode
     * @return
     * @throws Exception
     */
    public String saveQuestionResultAndAnswer(JSONObject jsonData, String patientCode, String customerCode) throws Exception {
        String surveyCode = jsonData.get("surveyCode").toString();
        SurveyTemplates templates = surveyTemplatesDao.findById(surveyCode);
        Patient patient = patientDao.findByCode(patientCode);
        User user = userDao.findByCode(customerCode);
        SurveyQuestionResult questionResult =  new SurveyQuestionResult();
        String code = getCode();
        questionResult.setCode(code);
        questionResult.setTemplateCode(templates.getCode());
        questionResult.setTemplateTitle(templates.getTitle());
        questionResult.setPatientCode(patient.getCode());
        questionResult.setPatientName(patient.getName());
        questionResult.setType(1);
        questionResult.setCreateUser(customerCode);
        questionResult.setCreateUserName(user.getName());
        questionResult.setCreateTime(new Date());
        questionResultDao.save(questionResult);
        this.saveAnswer(patientCode, code, jsonData);
        return code;
    }
}

+ 23 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/ManagerQuestionnaireController.java

@ -587,6 +587,29 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
    }
    @RequestMapping(value = "saveResultAndAnswer", method = RequestMethod.POST)
    @ApiOperation(value = "协同服务保存用户答案")
    public String saveResultAndAnswer( @RequestParam String jsonData,
                                       @ApiParam(value = "居民code")@RequestParam(value = "patientCode")String patientCode,
                                       @ApiParam(value = "客服code")@RequestParam(value = "customerCode")String customerCode,
                                       @ApiParam(value = "问卷标签")@RequestParam(value = "labelType")Integer labelType,
                                       @ApiParam(value = "筛查入口(labelType=5时要填),0是第一次筛查 1是再次评估")@RequestParam(value = "isAgain")int isAgain,
                                       @ApiParam(value = "来源(1医生发放 2居民自我评估)")@RequestParam(value = "source")int source) {
        try {
            JSONObject json = new JSONObject(jsonData);
            if (labelType==5){
                return  write(200, "保存成功!","data",surveyScreenResultService.saveScreenResultAndAnswer(patientCode, customerCode, isAgain, source, json));
            }else {
                return write(200, "保存成功!", "data", managerQuestionnaireService.saveQuestionResultAndAnswer(json, patientCode, customerCode));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "保存失败!");
        }
    }
    @RequestMapping(value = "/createWorkOrder",method = RequestMethod.POST)
    @ApiOperation(value = "创建协同服务")
    public String getAllQuestions(@ApiParam(name = "jsonData",value = "协同服务json字符串")