Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

# Conflicts:
#	patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/synergy/SynergyManagerController.java
wangzhinan 6 years ago
parent
commit
b2cd327f6b
28 changed files with 1762 additions and 212 deletions
  1. 39 15
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyQuestionResult.java
  2. 10 12
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/customer/CustomerQuestionnaireController.java
  3. 66 3
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/customer/CustomerSynergyManageController.java
  4. 42 20
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/survey/SurveyQuestionResult.java
  5. 165 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/survey/SurveyQuestionnaire.java
  6. 120 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/survey/SurveyQuestionnaireOptions.java
  7. 3 3
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageCustomerOnlineRecordDO.java
  8. 66 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageSynergyAccessoryDO.java
  9. 2 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/UserDao.java
  10. 14 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/survey/SurveyQuestionnaireDao.java
  11. 8 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/survey/SurveyQuestionnaireOptionsDao.java
  12. 0 2
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/synergy/ManageCustomerOnlineRecordDao.java
  13. 17 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/synergy/ManageSynergyAccessoryDao.java
  14. 35 27
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/QuestionnaireManageService.java
  15. 8 8
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/ScreenResultManageService.java
  16. 455 52
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/SynergyManageService.java
  17. 41 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/util/http/HttpResponse.java
  18. 449 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/util/http/HttpUtils.java
  19. 54 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/util/http/IPInfoUtils.java
  20. 7 3
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/JMController.java
  21. 9 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/JMService.java
  22. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/imm/ChildFamilyImmuneService.java
  23. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/imm/ChildInfoService.java
  24. 13 33
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/ManagerQuestionnaireService.java
  25. 0 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/ImmuneService.java
  26. 37 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/jimeiJkEdu/DoctorJMJkEduArticleController.java
  27. 1 24
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/ManagerQuestionnaireController.java
  28. 99 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/synergy/SynergyManagerController.java

+ 39 - 15
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyQuestionResult.java

@ -18,9 +18,13 @@ public class SurveyQuestionResult extends IdEntity implements Serializable {
    //唯一标识
    //唯一标识
    private String code;
    private String code;
    //模板编码
    //模板编码
    private String templateCode;
    private String surveyCode;
    //模板标题
    //模板标题
    private  String templateTitle;
    private  String surveyTitle;
    //派发问卷的医生code
    private String doctor;
    //派发问卷的医生名称
    private String doctorName;
    //居民code
    //居民code
    private String patientCode;
    private String patientCode;
    //居民名字
    //居民名字
@ -37,10 +41,12 @@ public class SurveyQuestionResult extends IdEntity implements Serializable {
    public SurveyQuestionResult() {
    public SurveyQuestionResult() {
    }
    }
    public SurveyQuestionResult(String code, String templateCode, String templateTitle, String patientCode, String patientName, Integer type, String createUser, String createUserName, Date createTime) {
    public SurveyQuestionResult(String code, String surveyCode, String surveyTitle, String doctor, String doctorName, String patientCode, String patientName, Integer type, String createUser, String createUserName, Date createTime) {
        this.code = code;
        this.code = code;
        this.templateCode = templateCode;
        this.templateTitle = templateTitle;
        this.surveyCode = surveyCode;
        this.surveyTitle = surveyTitle;
        this.doctor = doctor;
        this.doctorName = doctorName;
        this.patientCode = patientCode;
        this.patientCode = patientCode;
        this.patientName = patientName;
        this.patientName = patientName;
        this.type = type;
        this.type = type;
@ -58,22 +64,40 @@ public class SurveyQuestionResult extends IdEntity implements Serializable {
        this.code = code;
        this.code = code;
    }
    }
    @Column(name = "template_code")
    public String getTemplateCode() {
        return templateCode;
    @Column(name = "survey_code")
    public String getSurveyCode() {
        return surveyCode;
    }
    }
    public void setTemplateCode(String templateCode) {
        this.templateCode = templateCode;
    public void setSurveyCode(String surveyCode) {
        this.surveyCode = surveyCode;
    }
    }
    @Column(name = "template_title")
    public String getTemplateTitle() {
        return templateTitle;
    @Column(name = "survey_title")
    public String getSurveyTitle() {
        return surveyTitle;
    }
    }
    public void setTemplateTitle(String templateTitle) {
        this.templateTitle = templateTitle;
    public void setSurveyTitle(String surveyTitle) {
        this.surveyTitle = surveyTitle;
    }
    @Column(name = "doctor")
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @Column(name = "doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    }
    @Column(name = "patient_code")
    @Column(name = "patient_code")

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

@ -29,12 +29,12 @@ public class CustomerQuestionnaireController extends BaseController {
    @RequestMapping(value = "saveAnswer", method = RequestMethod.POST)
    @RequestMapping(value = "saveAnswer", method = RequestMethod.POST)
    @ApiOperation(value = "保存用户答案")
    @ApiOperation(value = "保存用户答案")
    public String saveAnswer( @ApiParam(value = "问卷题目及选项", required = true)@RequestParam String jsonData,
                              @ApiParam(value = "客服code", required = true)@RequestParam(value = "customerCode")String customerCode,
                              @ApiParam(value = "居民code", required = true)@RequestParam(value = "patientCode")String patientCode,
                              @ApiParam(value = "问卷标签", required = false)@RequestParam(value = "labelType")Integer labelType,
                              @ApiParam(value = "来源(1医生发放 2居民自我评估)", required = false, defaultValue = "1")@RequestParam(value = "source")Integer source,
                              @ApiParam(value = "协同工单服务对象表code", required = true)@RequestParam(value = "serviceCode")String serviceCode) {
    public String saveAnswer( @ApiParam(value = "问卷题目及选项")@RequestParam String jsonData,
                              @ApiParam(value = "客服code")@RequestParam(value = "customerCode", required = true)String customerCode,
                              @ApiParam(value = "居民code")@RequestParam(value = "patientCode", required = true)String patientCode,
                              @ApiParam(value = "问卷标签(疾病筛查问卷要传5,调查问卷传4)")@RequestParam(value = "labelType", required = false)Integer labelType,
                              @ApiParam(value = "来源(1医生发放 2居民自我评估)")@RequestParam(value = "source", required = false, defaultValue = "1")Integer source,
                              @ApiParam(value = "协同工单服务对象表code", required = true)@RequestParam(value = "serviceCode", required = true)String serviceCode) {
        try {
        try {
            return  write(200, "保存成功!", "data", questionnaireService.saveResultAndAnswer(patientCode, labelType, customerCode, source,jsonData, serviceCode));
            return  write(200, "保存成功!", "data", questionnaireService.saveResultAndAnswer(patientCode, labelType, customerCode, source,jsonData, serviceCode));
        } catch (Exception e) {
        } catch (Exception e) {
@ -45,9 +45,9 @@ public class CustomerQuestionnaireController extends BaseController {
    @RequestMapping(value = "getAnswers", method = RequestMethod.GET)
    @RequestMapping(value = "getAnswers", method = RequestMethod.GET)
    @ApiOperation(value = "查看调查统计结果")
    @ApiOperation(value = "查看调查统计结果")
    public String getAnswers(@ApiParam(value = "问卷code", required = true) @RequestParam String templateCode) {
    public String getAnswers(@ApiParam(value = "问卷code", required = true) @RequestParam String surveyCode) {
        try {
        try {
            return write(200, "查询成功!", "data", questionnaireService.getAnswers(templateCode));
            return write(200, "查询成功!", "data", questionnaireService.getAnswers(surveyCode));
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
            return write(-1, "查询失败!");
            return write(-1, "查询失败!");
@ -82,9 +82,7 @@ public class CustomerQuestionnaireController extends BaseController {
    public String isNotException(@ApiParam(value = "协同服务工单code") @RequestParam String workorderCode,
    public String isNotException(@ApiParam(value = "协同服务工单code") @RequestParam String workorderCode,
                                 @ApiParam(value = "客服code") @RequestParam String customerCode) {
                                 @ApiParam(value = "客服code") @RequestParam String customerCode) {
        try {
        try {
            //判断是否有异常中断
            String workorderServiceCode = synergyManageService.isNotException(workorderCode, customerCode);
            return write(200, "查询成功!", "data", workorderServiceCode);
            return write(200, "查询成功!", "data", synergyManageService.isNotException(workorderCode, customerCode));
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
            return write(-1, "查询失败!");
            return write(-1, "查询失败!");
@ -92,7 +90,7 @@ public class CustomerQuestionnaireController extends BaseController {
    }
    }
    @RequestMapping(value = "loadingInfo", method = RequestMethod.GET)
    @RequestMapping(value = "loadingInfo", method = RequestMethod.GET)
    @ApiOperation(value = "载入异常工单信息")
    @ApiOperation(value = "载入异常通话居民信息")
    public String loadingInfo(@ApiParam(value = "协同服务对象code") @RequestParam String workorderServiceCode) {
    public String loadingInfo(@ApiParam(value = "协同服务对象code") @RequestParam String workorderServiceCode) {
        try {
        try {
            return write(200, "查询成功!", "data", synergyManageService.loadingInfo(workorderServiceCode));
            return write(200, "查询成功!", "data", synergyManageService.loadingInfo(workorderServiceCode));

+ 66 - 3
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/customer/CustomerSynergyManageController.java

@ -5,6 +5,7 @@ import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.entity.User;
import com.yihu.wlyy.entity.User;
import com.yihu.wlyy.entity.call.CallRecord;
import com.yihu.wlyy.entity.call.CallRecord;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerLogDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerLogDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyAccessoryDO;
import com.yihu.wlyy.repository.call.CallRecordDao;
import com.yihu.wlyy.repository.call.CallRecordDao;
import com.yihu.wlyy.service.manager.user.UserService;
import com.yihu.wlyy.service.manager.user.UserService;
import com.yihu.wlyy.service.synergy.SynergyManageService;
import com.yihu.wlyy.service.synergy.SynergyManageService;
@ -18,6 +19,7 @@ import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.List;
import java.util.Map;
import java.util.Map;
@ -82,6 +84,19 @@ public class CustomerSynergyManageController extends BaseController {
    }
    }
    @RequestMapping(value = "/getCustomers", method = RequestMethod.GET)
    @ApiOperation(value = "获取客服列表")
    public String getCustomers(){
        try {
            List<User> list = synergyManageService.getCustomers();
            return write(200,"保存成功", "data", list);
        }catch (Exception e){
            error(e);
            return error(-1,"保存失败");
        }
    }
    @RequestMapping(value = "/labels", method = RequestMethod.GET)
    @RequestMapping(value = "/labels", method = RequestMethod.GET)
    @ApiOperation("根据分组类型查找标签")
    @ApiOperation("根据分组类型查找标签")
    public String labels(
    public String labels(
@ -537,10 +552,58 @@ public class CustomerSynergyManageController extends BaseController {
    }
    }
    @RequestMapping(value = "adminIndex",method = RequestMethod.GET)
    @RequestMapping(value = "adminIndex",method = RequestMethod.GET)
    @ApiOperation(value = "管理员首页")
    public String adminIndex(@ApiParam(name="userCode",value="客服code")@RequestParam(value ="userCode")String userCode){
    @ApiOperation(value = "管理员首页.")
    public String adminIndex(){
        try{
        try{
            return write(200,"获取成功!","data",synergyManageService.customerIndex(userCode));
            return write(200,"获取成功!","data",synergyManageService.adminIndex());
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
    @RequestMapping(value = "intervalOnLine",method = RequestMethod.GET)
    @ApiOperation(value = "管理员首页-今日在线服务趋势")
    public String intervalOnLine(){
        try{
            return write(200,"获取成功!","data",synergyManageService.intervalOnLine());
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
    @RequestMapping(value = "TodayCustomerActivy",method = RequestMethod.GET)
    @ApiOperation(value = "管理员首页-客服今日活动")
    public String TodayCustomerActivy(){
        try{
            return write(200,"获取成功!","data",synergyManageService.TodayCustomerActivy());
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
    @RequestMapping(value = "uploadAccessory",method = RequestMethod.POST)
    @ApiOperation(value = "上传附件")
    public String uploadAccessory(@ApiParam(name="workorderCode",value="协同服务工单code",required = true)
                                  @RequestParam(required = true)String workorderCode,HttpServletRequest request){
        try{
            Map<String,Object> map = synergyManageService.uploadAccessory(workorderCode,request);
            return write(200,"获取成功!","data",map);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
    @RequestMapping(value = "accessoryList",method = RequestMethod.GET)
    @ApiOperation(value = "获取附件")
    public String accessoryList(@ApiParam(name="workorderCode",value="协同服务code",required = true)
                                 @RequestParam(required = true)String workorderCode){
        try{
            List<ManageSynergyAccessoryDO> resultList = synergyManageService.accessoryList(workorderCode);
            return write(200,"获取成功!","date",resultList);
        }catch (Exception e){
        }catch (Exception e){
            e.printStackTrace();
            e.printStackTrace();
            return write(-1,"获取失败!");
            return write(-1,"获取失败!");

+ 42 - 20
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/survey/SurveyQuestionResult.java

@ -18,9 +18,13 @@ public class SurveyQuestionResult extends IdEntity implements Serializable {
    //唯一标识
    //唯一标识
    private String code;
    private String code;
    //模板编码
    //模板编码
    private String templateCode;
    private String surveyCode;
    //模板标题
    //模板标题
    private  String templateTitle;
    private  String surveyTitle;
    //派发问卷的医生code
    private String doctor;
    //派发问卷的医生名称
    private String doctorName;
    //居民code
    //居民code
    private String patientCode;
    private String patientCode;
    //居民名字
    //居民名字
@ -43,24 +47,6 @@ public class SurveyQuestionResult extends IdEntity implements Serializable {
        this.code = code;
        this.code = code;
    }
    }
    @Column(name = "template_code")
    public String getTemplateCode() {
        return templateCode;
    }
    public void setTemplateCode(String templateCode) {
        this.templateCode = templateCode;
    }
    @Column(name = "template_title")
    public String getTemplateTitle() {
        return templateTitle;
    }
    public void setTemplateTitle(String templateTitle) {
        this.templateTitle = templateTitle;
    }
    @Column(name = "patient_code")
    @Column(name = "patient_code")
    public String getPatientCode() {
    public String getPatientCode() {
        return patientCode;
        return patientCode;
@ -114,4 +100,40 @@ public class SurveyQuestionResult extends IdEntity implements Serializable {
    public void setCreateTime(Date createTime) {
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
        this.createTime = createTime;
    }
    }
    @Column(name = "survey_code")
    public String getSurveyCode() {
        return surveyCode;
    }
    public void setSurveyCode(String surveyCode) {
        this.surveyCode = surveyCode;
    }
    @Column(name = "survey_title")
    public String getSurveyTitle() {
        return surveyTitle;
    }
    public void setSurveyTitle(String surveyTitle) {
        this.surveyTitle = surveyTitle;
    }
    @Column(name = "doctor")
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @Column(name = "doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
}
}

+ 165 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/survey/SurveyQuestionnaire.java

@ -0,0 +1,165 @@
package com.yihu.wlyy.entity.survey;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * Created by Reece on 2017/3/10.
 */
@Entity
@Table(name = "wlyy_survey_questionnaire")
public class SurveyQuestionnaire extends IdEntity implements Serializable {
    //    问题编码
    private String code;
    //            问题标题
    private String title;
    //    问题说明(可为null)
    private String questionComment;
    //    问题类型(0单选 1多选 2问答)
    private int questionType;
    //    关联编码(按使用类型分类)
    private String surveyCode;
    //    是否必答(0否 1是)
    private int isRequired;
    //    最小答案个数(多选有效)
    private Integer minNum;
    //    最大答案个数(多选有效)
    private Integer maxNum;
    //            排序
    private int sort;
    //    下一题问题编码(问答题逻辑跳转)
    private String questionCodeNext;
    //    删除标志(1正常,0删除)
    private int del;
    //    创建时间
    private Date createTime;
    //    修改时间
    private Date updateTime;
    public SurveyQuestionnaire() {
    }
    public SurveyQuestionnaire(String code, String title, String questionComment, int questionType, String surveyCode, int isRequired, Integer minNum, Integer maxNum, int sort, String questionCodeNext, int del, Date createTime, Date updateTime) {
        this.code = code;
        this.title = title;
        this.questionComment = questionComment;
        this.questionType = questionType;
        this.surveyCode = surveyCode;
        this.isRequired = isRequired;
        this.minNum = minNum;
        this.maxNum = maxNum;
        this.sort = sort;
        this.questionCodeNext = questionCodeNext;
        this.del = del;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getQuestionComment() {
        return questionComment;
    }
    public void setQuestionComment(String questionComment) {
        this.questionComment = questionComment;
    }
    public int getQuestionType() {
        return questionType;
    }
    public void setQuestionType(int questionType) {
        this.questionType = questionType;
    }
    public String getSurveyCode() {
        return surveyCode;
    }
    public void setSurveyCode(String surveyCode) {
        this.surveyCode = surveyCode;
    }
    public int getIsRequired() {
        return isRequired;
    }
    public void setIsRequired(int isRequired) {
        this.isRequired = isRequired;
    }
    public Integer getMinNum() {
        return minNum;
    }
    public void setMinNum(Integer minNum) {
        this.minNum = minNum;
    }
    public Integer getMaxNum() {
        return maxNum;
    }
    public void setMaxNum(Integer maxNum) {
        this.maxNum = maxNum;
    }
    public int getSort() {
        return sort;
    }
    public void setSort(int sort) {
        this.sort = sort;
    }
    public String getQuestionCodeNext() {
        return questionCodeNext;
    }
    public void setQuestionCodeNext(String questionCodeNext) {
        this.questionCodeNext = questionCodeNext;
    }
    public int getDel() {
        return del;
    }
    public void setDel(int del) {
        this.del = del;
    }
}

+ 120 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/survey/SurveyQuestionnaireOptions.java

@ -0,0 +1,120 @@
package com.yihu.wlyy.entity.survey;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
 * Created by Reece on 2017/3/10.
 */
@Entity
@Table(name = "wlyy_survey_questionnaire_options")
public class SurveyQuestionnaireOptions extends IdEntity implements Serializable {
    //选项编码
    private String code;
    //    是否有选项说明(0没有 1有)
    private int haveComment;
    //    	所属问题编码
    private String questionnaireCode;
    //    选项内容
    private String content;
    //        问卷编码
    private String surveyCode;
    //    下一题问题编码(逻辑跳转)
    private String questionCodeNext;
    //    选项说明是否必填(0否 1是)
    private int isRequired;
    //    单题内排序
    private int sort;
    //    删除标志(1正常,0删除)
    private int del;
    public SurveyQuestionnaireOptions() {
    }
    public SurveyQuestionnaireOptions(String code, int haveComment, String questionnaireCode, String content, String surveyCode, String questionCodeNext, int isRequired, int sort, int del) {
        this.code = code;
        this.haveComment = haveComment;
        this.questionnaireCode = questionnaireCode;
        this.content = content;
        this.surveyCode = surveyCode;
        this.questionCodeNext = questionCodeNext;
        this.isRequired = isRequired;
        this.sort = sort;
        this.del = del;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public int getHaveComment() {
        return haveComment;
    }
    public void setHaveComment(int haveComment) {
        this.haveComment = haveComment;
    }
    public String getQuestionnaireCode() {
        return questionnaireCode;
    }
    public void setQuestionnaireCode(String questionnaireCode) {
        this.questionnaireCode = questionnaireCode;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getSurveyCode() {
        return surveyCode;
    }
    public void setSurveyCode(String surveyCode) {
        this.surveyCode = surveyCode;
    }
    public String getQuestionCodeNext() {
        return questionCodeNext;
    }
    public void setQuestionCodeNext(String questionCodeNext) {
        this.questionCodeNext = questionCodeNext;
    }
    public int getIsRequired() {
        return isRequired;
    }
    public void setIsRequired(int isRequired) {
        this.isRequired = isRequired;
    }
    public int getSort() {
        return sort;
    }
    public void setSort(int sort) {
        this.sort = sort;
    }
    public int getDel() {
        return del;
    }
    public void setDel(int del) {
        this.del = del;
    }
}

+ 3 - 3
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageCustomerOnlineRecordDO.java

@ -22,7 +22,7 @@ public class ManageCustomerOnlineRecordDO extends IdEntity {
    private String jobNo;//客服工号
    private String jobNo;//客服工号
    private String seat;//席位
    private String seat;//席位
    private String phone;//客服电话
    private String phone;//客服电话
    private String totalOnlineTime;//在线总时长
    private int totalOnlineTime;//在线总时长(单位:分钟)
    @Column(name = "code")
    @Column(name = "code")
    public String getCode() {
    public String getCode() {
@ -97,11 +97,11 @@ public class ManageCustomerOnlineRecordDO extends IdEntity {
    }
    }
    @Column(name = "total_online_time")
    @Column(name = "total_online_time")
    public String getTotalOnlineTime() {
    public int getTotalOnlineTime() {
        return totalOnlineTime;
        return totalOnlineTime;
    }
    }
    public void setTotalOnlineTime(String totalOnlineTime) {
    public void setTotalOnlineTime(int totalOnlineTime) {
        this.totalOnlineTime = totalOnlineTime;
        this.totalOnlineTime = totalOnlineTime;
    }
    }
}
}

+ 66 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageSynergyAccessoryDO.java

@ -0,0 +1,66 @@
package com.yihu.wlyy.entity.synergy;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by 刘文彬 on 2018/10/14.
 * 工单上传附件
 */
@Entity
@Table(name = "manage_synergy_accessory")
public class ManageSynergyAccessoryDO extends IdEntity {
    private String code;
    private String name;//文件名
    private String url;//文件存储路径
    private String workorderCode;//工单的code
    private Integer del;//逻辑删除(0、有效,1、删除)
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "url")
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    @Column(name = "workorder_code")
    public String getWorkorderCode() {
        return workorderCode;
    }
    public void setWorkorderCode(String workorderCode) {
        this.workorderCode = workorderCode;
    }
    @Column(name = "del")
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

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

@ -40,4 +40,6 @@ public interface UserDao extends PagingAndSortingRepository<User, Long>, JpaSpec
	List<User> findByType(int type);
	List<User> findByType(int type);
	@Query("from User u where u.type = 4")
    List<User> findAllCustomer();
}
}

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

@ -0,0 +1,14 @@
package com.yihu.wlyy.repository.survey;
import com.yihu.wlyy.entity.survey.SurveyQuestionnaire;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface SurveyQuestionnaireDao extends PagingAndSortingRepository<SurveyQuestionnaire,Long>,JpaSpecificationExecutor<SurveyQuestionnaire> {
    @Query("select q from SurveyQuestionnaire q where q.surveyCode = ?1")
    List<SurveyQuestionnaire> findBySurveyCode(String surveyCode);
}

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

@ -0,0 +1,8 @@
package com.yihu.wlyy.repository.survey;
import com.yihu.wlyy.entity.survey.SurveyQuestionnaireOptions;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface SurveyQuestionnaireOptionsDao extends PagingAndSortingRepository<SurveyQuestionnaireOptions,Long>,JpaSpecificationExecutor<SurveyQuestionnaireOptions> {
}

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

@ -11,6 +11,4 @@ import java.util.List;
 */
 */
public interface ManageCustomerOnlineRecordDao extends PagingAndSortingRepository<ManageCustomerOnlineRecordDO, Long> {
public interface ManageCustomerOnlineRecordDao extends PagingAndSortingRepository<ManageCustomerOnlineRecordDO, Long> {
    @Query("select r from ManageCustomerOnlineRecordDO r where r.customerCode=?1 and r.createTime>=?2 and r.createTime<=?3 order by r.createTime")
    List<ManageCustomerOnlineRecordDO> findByCustomerCodeToday(String userCode,String startTime,String endTime);
}
}

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

@ -0,0 +1,17 @@
package com.yihu.wlyy.repository.synergy;
import com.yihu.wlyy.entity.synergy.ManageCustomerOnlineRecordDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyAccessoryDO;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by 刘文彬 on 2018/10/14.
 */
public interface ManageSynergyAccessoryDao extends PagingAndSortingRepository<ManageSynergyAccessoryDO, Long> {
    @Query("select a from ManageSynergyAccessoryDO a where a.workorderCode=?1 and a.del=0")
    List<ManageSynergyAccessoryDO> findByWorkorderCode(String workorderCode);
}

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

@ -2,16 +2,15 @@ package com.yihu.wlyy.service.synergy;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.survey.SurveyQuestionResult;
import com.yihu.wlyy.entity.survey.SurveyQuestionResult;
import com.yihu.wlyy.entity.survey.SurveyTemplateQuestions;
import com.yihu.wlyy.entity.survey.SurveyQuestionnaire;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerDO;
import com.yihu.wlyy.repository.survey.SurveyQuestionResultDao;
import com.yihu.wlyy.repository.survey.SurveyQuestionResultDao;
import com.yihu.wlyy.repository.survey.SurveyTemplateQuestionsDao;
import com.yihu.wlyy.repository.survey.SurveyQuestionnaireDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkOrderDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkOrderDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkorderServicerDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkorderServicerDao;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.query.BaseJpaService;
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.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
@ -38,7 +37,7 @@ public class QuestionnaireManageService extends BaseJpaService {
    @Autowired
    @Autowired
    private ManageSynergyWorkorderServicerDao workorderServicerDao;
    private ManageSynergyWorkorderServicerDao workorderServicerDao;
    @Autowired
    @Autowired
    private SurveyTemplateQuestionsDao templateQuestionDao;
    private SurveyQuestionnaireDao surveyQuestionnaireDao;
    @Autowired
    @Autowired
    private SurveyQuestionResultDao questionResultDao;
    private SurveyQuestionResultDao questionResultDao;
    @Autowired
    @Autowired
@ -97,8 +96,12 @@ public class QuestionnaireManageService extends BaseJpaService {
     * @param jsonData
     * @param jsonData
     * @param serviceCode
     * @param serviceCode
     */
     */
    public String saveResultAndAnswer(String patientCode, Integer labelType, String customerCode, Integer source, String jsonData, String serviceCode) {
        String url = wlyyUrl + "doctor/questionnaire/saveResultAndAnswer";
    public String saveResultAndAnswer(String patientCode, Integer labelType, String customerCode, Integer source, String jsonData, String serviceCode) throws Exception {
        String url = wlyyUrl + "third/synergy/questionnaire/saveResultAndAnswer";
        //查找发放问卷的医生
        String sql = "SELECT w.create_user from manage_synergy_workorder_servicer s, manage_synergy_workorder w " +
                "where s.workorder_code = w.`code` and s.`code`= '" + serviceCode + "'";
        String doctor = jdbcTemplate.queryForObject(sql, String.class);
        String response = "";
        String response = "";
        Map<String, Object> params = new HashMap<>();
        Map<String, Object> params = new HashMap<>();
        params.put("labelType", labelType);
        params.put("labelType", labelType);
@ -106,32 +109,35 @@ public class QuestionnaireManageService extends BaseJpaService {
        params.put("jsonData", jsonData);
        params.put("jsonData", jsonData);
        params.put("customerCode", customerCode);
        params.put("customerCode", customerCode);
        params.put("source", source);
        params.put("source", source);
        params.put("isAgain", 0);
        params.put("doctor", doctor);
        try {
        try {
            response = httpClientUtil.post(url, params);
            response = httpClientUtil.post(url, params);
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
        }
        }
        JSONObject object = JSONObject.parseObject(response);
        JSONObject object = JSONObject.parseObject(response);
        String questionResultCode = object.getString("data");
        if(StringUtils.isNotBlank(questionResultCode)) {
        if(object.getInteger("status") == 200) {
            String questionResultCode = object.getString("data");
            workorderServicerDao.updateRelationCodeByCode(serviceCode, questionResultCode);
            workorderServicerDao.updateRelationCodeByCode(serviceCode, questionResultCode);
            return questionResultCode;
        }
        }
        return questionResultCode;
        throw new Exception("保存失败");
    }
    }
    /**
    /**
     * 查看调查问卷统计结果
     * 查看调查问卷统计结果
     * @param templateCode
     * @param surveyCode
     * @return
     * @return
     */
     */
    public JSONObject getAnswers(String templateCode) {
        String url = wlyyUrl + "doctor/questionnaire/getAnswers?id=" + templateCode;
    public JSONObject getAnswers(String surveyCode) throws Exception {
        String url = wlyyUrl + "third/synergy/questionnaire/getAnswers?id=" + surveyCode;
        String  response = httpClientUtil.get(url, "UTF-8");
        String  response = httpClientUtil.get(url, "UTF-8");
        JSONObject jsonObject = JSONObject.parseObject(response);
        JSONObject jsonObject = JSONObject.parseObject(response);
        if(jsonObject.getString("msg").equals("查询成功!")){
        if(jsonObject.getInteger("status") == 200){
            return JSONObject.parseObject(jsonObject.getString("data"));
            return JSONObject.parseObject(jsonObject.getString("data"));
        }
        }
        return JSONObject.parseObject(response);
        throw new Exception("请求失败");
    }
    }
    /**
    /**
@ -144,35 +150,37 @@ public class QuestionnaireManageService extends BaseJpaService {
        //查找问卷结果信息
        //查找问卷结果信息
        SurveyQuestionResult questionResult = questionResultDao.findByCode(code);
        SurveyQuestionResult questionResult = questionResultDao.findByCode(code);
        String patient = questionResult.getPatientCode();
        String patient = questionResult.getPatientCode();
        String templateCode = questionResult.getTemplateCode();
        String surverCode = questionResult.getSurveyCode();
        //获取模板问题
        //获取模板问题
        List<SurveyTemplateQuestions> questionList = templateQuestionDao.findByTemplateCode(templateCode);
        List<SurveyQuestionnaire> questionList = surveyQuestionnaireDao.findBySurveyCode(surverCode);
        //查找选项和答案
        //查找选项和答案
        Map<String, Object> answerMap = new HashMap<>();
        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) {
        String sql = "SELECT soa.*, sqo.content FROM wlyy_survey_option_answers soa LEFT JOIN wlyy_survey_questions_options sqo ON soa.options_code= sqo.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, surverCode});
        for (SurveyQuestionnaire question : questionList) {
            List<Map<String, Object>> optionList = new ArrayList<>();
            Map<String, Object> map = new HashMap<>();
            Map<String, Object> map = new HashMap<>();
            map.put("question", templateQuestion);
            String qusCode = templateQuestion.getCode();
            map.put("question", question);
            String qusCode = question.getCode();
            for (Map<String, Object> option : optionAnswersList) {
            for (Map<String, Object> option : optionAnswersList) {
                if (option.get("question_code").equals(qusCode)) {
                if (option.get("question_code").equals(qusCode)) {
                    map.put("option", option);
                    optionList.add(option);
                }
                }
            }
            }
            answerMap.put(templateQuestion.getSort() + "", map);
            map.put("option", optionList);
            answerMap.put(question.getSort() + "", map);
        }
        }
        json.put("answer", answerMap);
        json.put("answer", answerMap);
        return json;
        return json;
    }
    }
    public JSONObject getQuestionnaireDetail(String surveyCode) {
        String url = wlyyUrl + "doctor/questionnaire/getQuestionnaireDetail?id=" + surveyCode;
    public JSONObject getQuestionnaireDetail(String surveyCode) throws Exception {
        String url = wlyyUrl + "third/synergy/questionnaire/getQuestionnaireDetail?id=" + surveyCode;
        String response = httpClientUtil.get(url, "UTF-8");
        String response = httpClientUtil.get(url, "UTF-8");
        JSONObject jsonObject = JSONObject.parseObject(response);
        JSONObject jsonObject = JSONObject.parseObject(response);
        if(jsonObject.getString("msg").equals("查询成功")){
        if(jsonObject.getInteger("status") == 200){
            return JSONObject.parseObject(jsonObject.getString("data"));
            return JSONObject.parseObject(jsonObject.getString("data"));
        }
        }
        return JSONObject.parseObject(response);
        throw new Exception("请求失败");
    }
    }
}
}

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

@ -24,14 +24,14 @@ public class ScreenResultManageService {
     * @param code
     * @param code
     * @return
     * @return
     */
     */
    public JSONObject getScreenResultDetail(String code) {
        String url = wlyyUrl + "doctor/screen/getScreenResultDetail?code=" + code;
    public JSONObject getScreenResultDetail(String code) throws Exception {
        String url = wlyyUrl + "third/synergy/screen/getScreenResultDetail?code=" + code;
        String response = httpClientUtil.get(url, "UTF-8");
        String response = httpClientUtil.get(url, "UTF-8");
        JSONObject jsonObject = JSONObject.parseObject(response);
        JSONObject jsonObject = JSONObject.parseObject(response);
        if(jsonObject.getString("msg").equals("查询成功")){
        if(jsonObject.getInteger("status") == 200){
            return JSONObject.parseObject(jsonObject.getString("data"));
            return JSONObject.parseObject(jsonObject.getString("data"));
        }
        }
        return JSONObject.parseObject(response);
        throw new Exception("请求失败");
    }
    }
    /**
    /**
@ -39,13 +39,13 @@ public class ScreenResultManageService {
     * @param templateCode
     * @param templateCode
     * @return
     * @return
     */
     */
    public JSONObject getScreenDetail(String templateCode) {
        String url = wlyyUrl + "/doctor/questionnaire/getAllQuestions?surveyTemplateCode=" + templateCode;
    public JSONObject getScreenDetail(String templateCode) throws Exception {
        String url = wlyyUrl + "third/synergy/questionnaire/getAllQuestions?surveyTemplateCode=" + templateCode;
        String response = httpClientUtil.get(url, "UTF-8");
        String response = httpClientUtil.get(url, "UTF-8");
        JSONObject jsonObject = JSONObject.parseObject(response);
        JSONObject jsonObject = JSONObject.parseObject(response);
        if(jsonObject.getString("msg").equals("查询成功")){
        if(jsonObject.getInteger("status") == 200){
            return JSONObject.parseObject(jsonObject.getString("data"));
            return JSONObject.parseObject(jsonObject.getString("data"));
        }
        }
        return JSONObject.parseObject(response);
        throw new Exception("请求失败");
    }
    }
}
}

+ 455 - 52
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/SynergyManageService.java

@ -10,10 +10,19 @@ import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
import com.yihu.wlyy.util.http.HttpUtils;
import com.yihu.wlyy.util.query.BaseJpaService;
import com.yihu.wlyy.util.query.BaseJpaService;
import jxl.Workbook;
import jxl.Workbook;
import jxl.write.*;
import jxl.write.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.json.JSONObject;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Value;
@ -21,12 +30,19 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.*;
import static org.springframework.util.ResourceUtils.getFile;
/**
/**
 * Created by 刘文彬 on 2018/9/27.
 * Created by 刘文彬 on 2018/9/27.
 */
 */
@ -68,6 +84,8 @@ public class SynergyManageService extends BaseJpaService {
    private FastDFSUtil fastDFSUtil;
    private FastDFSUtil fastDFSUtil;
    @Autowired
    @Autowired
    private ManageCustomerOnlineRecordDao manageCustomerOnlineRecordDao;
    private ManageCustomerOnlineRecordDao manageCustomerOnlineRecordDao;
    @Autowired
    private ManageSynergyAccessoryDao manageSynergyAccessoryDao;
    /**
    /**
     * 根据服务编码获取工单
     * 根据服务编码获取工单
@ -361,6 +379,13 @@ public class SynergyManageService extends BaseJpaService {
            map.put("servicerKey", workorderDO.getServicerKey());
            map.put("servicerKey", workorderDO.getServicerKey());
            map.put("servicerCount", workorderDO.getServicerCount());
            map.put("servicerCount", workorderDO.getServicerCount());
        }
        }
        //如果是随访,查出对象的信息
        if(workorderDO.getType() == 3){
            List<ManageSynergyWorkorderServicerDO> workorderServicerDO = workorderServicerDao.findByWorkorderCode(workorderCode);
            map.put("patientName", workorderServicerDO.get(0).getServicePatientName());
            map.put("idcard", workorderServicerDO.get(0).getIdcard());
            map.put("ssc", workorderServicerDO.get(0).getSsc());
        }
        //超时标签
        //超时标签
        map.put("delayStatus", this.isServiceOverTime(workorderDO.getServiceTime()));
        map.put("delayStatus", this.isServiceOverTime(workorderDO.getServiceTime()));
@ -397,10 +422,14 @@ public class SynergyManageService extends BaseJpaService {
            //获取处理结果
            //获取处理结果
            map.put("resultRemark", workorderDO.getDealResultRemark());
            map.put("resultRemark", workorderDO.getDealResultRemark());
            map.put("accessory", workorderDO.getDealResultAccessory());
            map.put("accessory", workorderDO.getDealResultAccessory());
            if(workorderDO.getType() == 4)
            map.put("relationCode", workorderDO.getRelationCode());
        }else if(status == 4){
        }else if(status == 4){
            //获取退回原因
            //获取退回原因
            map.put("returnedRemark", workorderDO.getReturnedRemark());
            map.put("returnedRemark", workorderDO.getReturnedRemark());
        }
        }
        List<ManageSynergyAccessoryDO> accessoryList = accessoryList(workorderCode);
        map.put("accessoryList",accessoryList);//附件列表
        return map;
        return map;
    }
    }
@ -508,6 +537,7 @@ public class SynergyManageService extends BaseJpaService {
            resultMap.put("doctorCode",workorderMap.get("create_user"));//创建人(医生)code
            resultMap.put("doctorCode",workorderMap.get("create_user"));//创建人(医生)code
            //获取提交记录
            //获取提交记录
            String servicerCode = workorderMap.get("servicerCode")+"";
            String servicerCode = workorderMap.get("servicerCode")+"";
            resultMap.put("servicerCode", servicerCode);
            List<ManageSynergyWorkorderServicerLogDO> list = manageSynergyWorkorderServicerLogDao.findByWorkorderServiceCode(servicerCode);
            List<ManageSynergyWorkorderServicerLogDO> list = manageSynergyWorkorderServicerLogDao.findByWorkorderServiceCode(servicerCode);
            if(list.size()>0){
            if(list.size()>0){
                ManageSynergyWorkorderServicerLogDO log = list.get(0);
                ManageSynergyWorkorderServicerLogDO log = list.get(0);
@ -632,14 +662,17 @@ public class SynergyManageService extends BaseJpaService {
     * @param customerCode
     * @param customerCode
     * @return
     * @return
     */
     */
    public String isNotException(String workorderCode, String customerCode) {
    public Object isNotException(String workorderCode, String customerCode) {
        String sql = "SELECT cl.workorder_service_code  from manage_synergy_workorder_customer_log cl " +
        String sql = "SELECT cl.workorder_service_code  from manage_synergy_workorder_customer_log cl " +
                "where cl.workorder_service_code not in (SELECT l.workorder_service_code from manage_synergy_workorder_customer_log l where l.`status` = 2) " +
                "where cl.workorder_service_code not in (SELECT l.workorder_service_code from manage_synergy_workorder_customer_log l where l.`status` = 1) " +
                "and cl.workorder_code = '" + workorderCode + "' and cl.create_user_code= '" + customerCode + "' " +
                "and cl.workorder_code = '" + workorderCode + "' and cl.create_user_code= '" + customerCode + "' " +
                "GROUP BY cl.workorder_code, cl.create_user_code " +
                "GROUP BY cl.workorder_code, cl.create_user_code " +
                "ORDER BY cl.create_time LIMIT 0, 1";
                "ORDER BY cl.create_time LIMIT 0, 1";
        String  workorderServiceCode = jdbcTemplate.queryForObject(sql, String.class);
        return workorderServiceCode;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        if(list.size() > 0){
            return list.get(0).get("workorder_service_code");
        }
        return null;
    }
    }
    public Map<String, Object> loadingInfo(String workorderServiceCode) {
    public Map<String, Object> loadingInfo(String workorderServiceCode) {
@ -654,8 +687,8 @@ public class SynergyManageService extends BaseJpaService {
        Map<String, Object> result = (Map<String, Object>) jdbcTemplate.queryForList(sql);
        Map<String, Object> result = (Map<String, Object>) jdbcTemplate.queryForList(sql);
        String patientCode = (String) result.get("service_patient_name");
        String patientCode = (String) result.get("service_patient_name");
        */
        */
        String patientCode = workorderServicerDO.getServicePatientName();
        resultMap.put("patientName", patientCode);
        String patientCode = workorderServicerDO.getServicePatientCode();
        resultMap.put("patientName", workorderServicerDO.getServicePatientName());
        resultMap.put("townName", workorderServicerDO.getTownName());//所属区县
        resultMap.put("townName", workorderServicerDO.getTownName());//所属区县
        resultMap.put("hospitalName", workorderServicerDO.getHospitalName());//所属社区
        resultMap.put("hospitalName", workorderServicerDO.getHospitalName());//所属社区
        Integer callNum = customerLogDao.callNumByWorkorder(workorderServiceCode);
        Integer callNum = customerLogDao.callNumByWorkorder(workorderServiceCode);
@ -680,7 +713,7 @@ public class SynergyManageService extends BaseJpaService {
        Integer age = IdCardUtil.getAgeForIdcard(patient.getIdcard());
        Integer age = IdCardUtil.getAgeForIdcard(patient.getIdcard());
        resultMap.put("age",age);//年龄
        resultMap.put("age",age);//年龄
        SignFamily signFamily = signFamilyDao.findSignByPatient(patientCode);
        SignFamily signFamily = signFamilyDao.findSignByPatient(patientCode);
        resultMap.put("signDoctor", signFamily.getDoctor());//签约医生(即:工单创建医生)
        resultMap.put("signDoctor", signFamily.getDoctorName());//签约医生(即:工单创建医生)
        resultMap.put("healthDoctor", signFamily.getDoctorHealthName());//健管师
        resultMap.put("healthDoctor", signFamily.getDoctorHealthName());//健管师
        List<SignPatientLabelInfo> labelDiseaseType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patientCode,  "3", 1);
        List<SignPatientLabelInfo> labelDiseaseType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patientCode,  "3", 1);
        String diseaseType="";
        String diseaseType="";
@ -694,7 +727,7 @@ public class SynergyManageService extends BaseJpaService {
            healthType += ","+one.getLabelName();
            healthType += ","+one.getLabelName();
        }
        }
        resultMap.put("healthType", StringUtils.isNotEmpty(healthType) ? healthType.substring(1) : "");//健康情况
        resultMap.put("healthType", StringUtils.isNotEmpty(healthType) ? healthType.substring(1) : "");//健康情况
        List<SignPatientLabelInfo> labelServeType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patientCode,  "2", 1);
        List<SignPatientLabelInfo> labelServeType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patientCode,  "1", 1);
        String serveType="";
        String serveType="";
        for(SignPatientLabelInfo one:labelServeType){
        for(SignPatientLabelInfo one:labelServeType){
            serveType+=","+one.getLabelName();
            serveType+=","+one.getLabelName();
@ -830,7 +863,7 @@ public class SynergyManageService extends BaseJpaService {
        if(receiveType==1){
        if(receiveType==1){
            sql =" select DISTINCT r.* from manage_synergy_workorder_reminder r " +
            sql =" select DISTINCT r.* from manage_synergy_workorder_reminder r " +
                 " LEFT JOIN manage_synergy_workorder_executor e on r.workorder_code=e.workorder_code " +
                 " LEFT JOIN manage_synergy_workorder_executor e on r.workorder_code=e.workorder_code " +
                 " where e.executor_code='' and e.del=1 and r.deal_with=0 " +sort;
                 " where e.executor_code='"+userCode+"' and e.del=1 and r.deal_with=0 " +sort;
        }else if(receiveType==2){
        }else if(receiveType==2){
            sql =" select r.* from manage_synergy_workorder_reminder r where r.principal_code='"+userCode+"' and r.deal_with=0 "+sort;
            sql =" select r.* from manage_synergy_workorder_reminder r where r.principal_code='"+userCode+"' and r.deal_with=0 "+sort;
        }
        }
@ -839,7 +872,7 @@ public class SynergyManageService extends BaseJpaService {
        for(Map<String,Object> one:List){
        for(Map<String,Object> one:List){
            Map<String,Object> resultMap = new HashMap<>();
            Map<String,Object> resultMap = new HashMap<>();
            resultMap.put("workorderCode",one.get("workorder_code"));
            resultMap.put("workorderCode",one.get("workorder_code"));
            resultMap.put("title","来自"+one.get("create_user_name")+"医生("+one.get("hospital_name")+")催单,请尽快处理(服务编号:)"+one.get("workorder_code"));//标题
            resultMap.put("title","来自"+one.get("create_user_name")+"医生("+one.get("hospital_name")+")催单,请尽快处理(服务编号:"+one.get("workorder_code")+")");//标题
            String workorderTypeName ="";
            String workorderTypeName ="";
            Integer workorderType = (Integer) one.get("workorder_type");
            Integer workorderType = (Integer) one.get("workorder_type");
            switch (workorderType){
            switch (workorderType){
@ -1307,9 +1340,11 @@ public class SynergyManageService extends BaseJpaService {
    }
    }
    public Map<String,Object> customerIndex(String userCode){
    public Map<String,Object> customerIndex(String userCode){
        Map<String,Object> map = new HashMap<>();
        String today = DateUtil.dateToStrShort(new Date());
        String today = DateUtil.dateToStrShort(new Date());
        String callSql ="SELECT * FROM manage_call_record WHERE user_code='"+userCode+"' and create_time>='"+today+" 00:00:00' and create_time<='"+today+" 23:59:59'";
        String startTime=today+" 00:00:00";
        String endTime = today+" 23:59:59";
        Map<String,Object> map = new HashMap<>();
        String callSql ="SELECT * FROM manage_call_record WHERE user_code='"+userCode+"' and create_time>='"+startTime+"' and create_time<='"+endTime+"'";
        //--------------今日外呼量-----------------//
        //--------------今日外呼量-----------------//
        List<CallRecord> waihudList = jdbcTemplate.query(callSql+" and type=2",new BeanPropertyRowMapper<>(CallRecord.class));
        List<CallRecord> waihudList = jdbcTemplate.query(callSql+" and type=2",new BeanPropertyRowMapper<>(CallRecord.class));
        int customerNoCount = 0;
        int customerNoCount = 0;
@ -1320,35 +1355,138 @@ public class SynergyManageService extends BaseJpaService {
            }
            }
        }
        }
        //求总时长
        //求总时长
        int seconds = totalTaklTime(waihudList);
        //求平均时长
        map.put("waihuAvgTalkTime",getAvgTime(seconds,waihudList.size()));
        if (waihudList.size()>0){
            int seconds = totalTaklTime(waihudList);
            //求平均时长
            map.put("waihuAvgTalkTime",getAvgTime(seconds,waihudList.size()));
        }else {
            map.put("waihuAvgTalkTime",0);
        }
        map.put("waihuCount",waihudList.size());
        map.put("waihuCount",waihudList.size());
        map.put("waihuCustomerNoCount",customerNoCount);
        map.put("waihuCustomerNoCount",customerNoCount);
        //--------------今日在线时长-----------------//
        //--------------今日在线时长-----------------//
        String startTime=today+" 00:00:00";
        String endTime = today+" 23:59:59";
        List<ManageCustomerOnlineRecordDO> manageCustomerOnlineRecordDOList = manageCustomerOnlineRecordDao.findByCustomerCodeToday(userCode,startTime,endTime);
        String onLineTime = manageCustomerOnlineRecordDOList.get(0).getTotalOnlineTime();
        for (ManageCustomerOnlineRecordDO customerOnlineRecordDO : manageCustomerOnlineRecordDOList){
        }
        String lineSql="SELECT" +
                " *" +
                " FROM" +
                " `manage_customer_online_record`" +
                " WHERE" +
                " customer_code ='"+userCode+"'" +
                " AND create_time >='"+startTime+"'" +
                " AND create_time <='"+endTime+"'" +
                " ORDER BY" +
                " create_time";
        List<ManageCustomerOnlineRecordDO> manageCustomerOnlineRecordDOList = jdbcTemplate.query(lineSql,new BeanPropertyRowMapper<>(ManageCustomerOnlineRecordDO.class));
        //如果最新一条是离线则直接获取总在线时长就是在线时间,
        // 如果最新一条是在线,则用当前时间减去上一条登录时间加上之前的在线时长为总的在线时长
        Map<String,Object> lineMap = getOnlineAndNotOnlineAndNowOnline(manageCustomerOnlineRecordDOList);
        map.putAll(lineMap);
        //--------------今日接入量-----------------//
        //--------------今日接入量-----------------//
        List<CallRecord> jieruList = jdbcTemplate.query(callSql+" and type=1",new BeanPropertyRowMapper<>(CallRecord.class));
        List<CallRecord> jieruList = jdbcTemplate.query(callSql+" and type=1",new BeanPropertyRowMapper<>(CallRecord.class));
        //求总时长
        //求总时长
        int jieruTotalSecond = totalTaklTime(jieruList);
        int jieruTotalSecond = totalTaklTime(jieruList);
        //求平均时长
        //求平均时长
        map.put("jieruAvgTalkTime",getAvgTime(jieruTotalSecond,jieruList.size()));
        if (jieruList.size()>0){
            map.put("jieruAvgTalkTime",getAvgTime(jieruTotalSecond,jieruList.size()));
        }
        map.put("jieruAvgTalkTime",0);
        map.put("jieruCount",jieruList.size());
        map.put("jieruCount",jieruList.size());
        //--------------今日协同任务外呼数-----------------//
        //--------------今日协同任务完成数-----------------//
        String wanchenSql="SELECT" +
                " count(*) as wanchengCount" +
                " FROM" +
                " `manage_synergy_workorder_servicer`" +
                " WHERE" +
                " executor_code = '"+userCode+"'" +
                " AND executor_type = 2" +
                " AND `status`=3" +
                " AND complete_time >='"+startTime+"'" +
                " AND complete_time<='"+endTime+"'";
        Map<String,Object> wanchenMap = jdbcTemplate.queryForMap(wanchenSql);
        String weiwanchenSql ="SELECT" +
                " COUNT(*) AS weiwanchengCount" +
                " FROM" +
                " `manage_synergy_workorder_servicer`" +
                " WHERE" +
                " executor_code = '"+userCode+"'" +
                " AND executor_type = 2" +
                " AND `status`<3";
        Map<String,Object> weiwanchenMap = jdbcTemplate.queryForMap(weiwanchenSql);
        String fasongSql="SELECT" +
                " COUNT(*) AS fasongCount" +
                " FROM" +
                " manage_synergy_workorder" +
                " WHERE" +
                " create_user = '"+userCode+"'" +
                " AND create_user_type = 2" +
                " AND del = 1" +
                " AND create_time>='"+startTime+"'" +
                " AND create_time<='"+endTime+"'";
        Map<String,Object> fasongMap = jdbcTemplate.queryForMap(fasongSql);
        map.putAll(wanchenMap);
        map.putAll(weiwanchenMap);
        map.putAll(fasongMap);
        return map;
        return map;
    }
    }
    public Map<String,Object> getOnlineAndNotOnlineAndNowOnline(List<ManageCustomerOnlineRecordDO> list){
        Map<String,Object> map = new HashMap<>();
        if (list!=null && list.size()>0){
            //如果最新一条是离线则直接获取总在线时长就是在线时间,
            // 如果最新一条是在线,则用当前时间减去上一条登录时间加上之前的在线时长为总的在线时长
            int status = list.get(list.size()-1).getStatus();
            String firstOnlineTime  = DateUtil.dateToStr(list.get(0).getCreateTime(),DateUtil.YYYY_MM_DD_HH_MM_SS);
            int totalOnlineMinute=0;
            int totalNotOnlineMinute =0;
            int toMinute = 0;
            //离线status==2
            if (status==2){
                totalOnlineMinute =list.get(list.size()-1).getTotalOnlineTime();
                long allTime = list.get(list.size()-1).getCreateTime().getTime()-list.get(0).getCreateTime().getTime();
                totalNotOnlineMinute= Integer.valueOf(String.valueOf(allTime/1000/60))-totalOnlineMinute;
            }
            //在线status==1
            if (status==1){
                //只有一条在线的数据,用当前时间减去数据创建时间
                long onlineDate = 0L;
                long allDateTime = 0L;
                int lastOnlineTime =0;
                Date now = new Date();
                onlineDate = now.getTime()-list.get(list.size()-1).getCreateTime().getTime();
                allDateTime = now.getTime()-list.get(0).getCreateTime().getTime();
                toMinute = Integer.valueOf(String.valueOf(onlineDate/1000/60));
                //多条数据,要加上上一次记录的在线时长
                if(list.size()>1){
                    int notOnlineCount=0;
                    for (ManageCustomerOnlineRecordDO m : list){
                        if (m.getStatus()==2 && notOnlineCount<1){
                            notOnlineCount++;
                            lastOnlineTime = m.getTotalOnlineTime();
                        }
                    }
                }
                totalOnlineMinute=toMinute+lastOnlineTime;
                totalNotOnlineMinute = Integer.valueOf(String.valueOf(allDateTime/1000/60))-totalOnlineMinute;
            }
            map.put("notOnline",totalNotOnlineMinute);
            map.put("online",totalOnlineMinute);
            map.put("nowOnline",toMinute);
            map.put("firstOnlineTime",firstOnlineTime);
        }else {
            map.put("notOnline",0);
            map.put("online",0);
            map.put("nowOnline",0);
            map.put("firstOnlineTime","");
        }
        return map;
    }
    /**
    /**
     * 返回总的秒数
     * 返回总的秒数
     * @param list
     * @param list
@ -1424,18 +1562,99 @@ public class SynergyManageService extends BaseJpaService {
//        System.out.println(aa);
//        System.out.println(aa);
//        System.out.println(a.substring(0,aa));
//        System.out.println(a.substring(0,aa));
//    }
//    }
    public void wordToPDF(String path) throws Exception{
        String groupName = path.substring(0,path.lastIndexOf("/"));
        String remoteFileName =path.substring(path.lastIndexOf("/"),path.length()-1);
        byte[] bb =FastDFSUtil.download(groupName,remoteFileName);
//    public void wordToPDF(String path) throws Exception{
//        String groupName = path.substring(0,path.lastIndexOf("/"));
//        String remoteFileName =path.substring(path.lastIndexOf("/"),path.length()-1);
//        byte[] bb =FastDFSUtil.download(groupName,remoteFileName);
//
//    }
    @Transactional
    public Map<String,Object> uploadAccessory(String workorderCode, HttpServletRequest request) throws Exception{
        Map<String,Object> map = new HashMap<>();
        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
        MultipartFile multipartFile = multipartRequest.getFile("file");
        long size = multipartFile.getSize();
        if(size<=0){
            map.put("uploadStatus",1);//size小于0
            map.put("accessory",null);//
            return map;
        }
        String fileName = multipartFile.getOriginalFilename();
        String type = fileName.split(".")[1];
        if(!("doc".equals(type)||"docx".equals(type)||"xls".equals(type)||"xlsx".equals(type))){
            map.put("uploadStatus",2);//文件类型不对
            map.put("accessory",null);//
            return map;
        }
        String response = request(wlyyUrl + "/upload/chat", multipartFile, null);
        JSONObject rs = new JSONObject(response);
        Integer status =(Integer)rs.get("status");
        if(status==200){
            String url = rs.get("urls")+"";
            ManageSynergyAccessoryDO manageSynergyAccessoryDO = new ManageSynergyAccessoryDO();
            manageSynergyAccessoryDO.setCode(getCode());
            manageSynergyAccessoryDO.setDel(0);
            manageSynergyAccessoryDO.setName(fileName);
            manageSynergyAccessoryDO.setUrl(url);
            manageSynergyAccessoryDO.setWorkorderCode(workorderCode);
            ManageSynergyAccessoryDO accessoryDO = manageSynergyAccessoryDao.save(manageSynergyAccessoryDO);
            map.put("uploadStatus",0);//文件类型正确
            map.put("accessory",accessoryDO);//
            return map;
        }
        throw new Exception();
    }
    public List<ManageSynergyAccessoryDO> accessoryList(String workorderCode){
        List<ManageSynergyAccessoryDO> list = manageSynergyAccessoryDao.findByWorkorderCode(workorderCode);
        return list;
    }
    public String request(String remote_url, MultipartFile file, String type) {
        CloseableHttpClient httpClient = HttpClientBuilder.create().build();
        String result = "";
        try {
            String fileName = file.getOriginalFilename();
            HttpPost httpPost = new HttpPost(remote_url);
            MultipartEntityBuilder builder = MultipartEntityBuilder.create();
            builder.addBinaryBody("file", file.getInputStream(), ContentType.MULTIPART_FORM_DATA, fileName);// 文件流
            builder.addTextBody("filename", fileName);// 类似浏览器表单提交,对应input的name和value
            if (!org.springframework.util.StringUtils.isEmpty(type)) {
                builder.addTextBody("type", type); //发送类型
            }
            HttpEntity entity = builder.build();
            httpPost.setEntity(entity);
            HttpResponse response = httpClient.execute(httpPost);// 执行提交
            HttpEntity responseEntity = response.getEntity();
            if (responseEntity != null) {
                // 将响应内容转换为字符串
                result = EntityUtils.toString(responseEntity, Charset.forName("UTF-8"));
            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                httpClient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return result;
    }
    }
    public Map<String,Object> adminIndex(String userCode){
    public Map<String,Object> adminIndex(){
        List<User> userList = userDao.findByType(4);
        List<User> userList = userDao.findByType(4);
        Map<String,Object> map = new HashMap<>();
        Map<String,Object> map = new HashMap<>();
        String today = DateUtil.dateToStrShort(new Date());
        String today = DateUtil.dateToStrShort(new Date());
        String startTime=today+" 00:00:00";
        String endTime = today+" 23:59:59";
        String callSql ="SELECT" +
        String callSql ="SELECT" +
                " r.*" +
                " r.*" +
                " FROM" +
                " FROM" +
@ -1443,36 +1662,220 @@ public class SynergyManageService extends BaseJpaService {
                " LEFT JOIN wlyy_user u ON r.user_code = u.`code`" +
                " LEFT JOIN wlyy_user u ON r.user_code = u.`code`" +
                " WHERE" +
                " WHERE" +
                " u.type = 4" +
                " u.type = 4" +
                " AND r.create_time >= '"+today+" 00:00:00'" +
                " AND r.create_time <= '"+today+" 23:59:59'";
        //--------------今日外呼量-----------------//
        List<CallRecord> waihudList = jdbcTemplate.query(callSql+" and r.type=2",new BeanPropertyRowMapper<>(CallRecord.class));
        //求总时长
        int seconds = totalTaklTime(waihudList);
        //求平均时长
        map.put("waihuAvgTalkTime",getAvgTime(seconds,waihudList.size()));
        map.put("waihuCount",waihudList.size());
                " AND r.create_time >= '"+startTime+"'" +
                " AND r.create_time <= '"+endTime+"'";
        //--------------今日在线时长-----------------//
        String startTime=today+" 00:00:00";
        String endTime = today+" 23:59:59";
        List<ManageCustomerOnlineRecordDO> manageCustomerOnlineRecordDOList = manageCustomerOnlineRecordDao.findByCustomerCodeToday(userCode,startTime,endTime);
        String onLineTime = manageCustomerOnlineRecordDOList.get(0).getTotalOnlineTime();
        for (ManageCustomerOnlineRecordDO customerOnlineRecordDO : manageCustomerOnlineRecordDOList){
        //正在咨询人数
        //当前客服人数
        map.put("onlineNowCount",userList.size());
        //今日会话总量  今日平均会话时长
        List<CallRecord> allCallRecordList = jdbcTemplate.query(callSql+" and r.answer_status=1",new BeanPropertyRowMapper<>(CallRecord.class));
        map.put("allCallCount",allCallRecordList.size());
        if (allCallRecordList.size()>0){
            int totalSeconds = totalTaklTime(allCallRecordList);
            map.put("allAvgTaklTime",getAvgTime(totalSeconds,allCallRecordList.size()));
        }else {
            map.put("allAvgTaklTime",0);
        }
        }
        //--------------今日接入量-----------------//
        List<CallRecord> jieruList = jdbcTemplate.query(callSql+" and r.type=1",new BeanPropertyRowMapper<>(CallRecord.class));
        //求总时长
        int jieruTotalSecond = totalTaklTime(jieruList);
        //求平均时长
        map.put("jieruAvgTalkTime",getAvgTime(jieruTotalSecond,jieruList.size()));
        map.put("jieruCount",jieruList.size());
        //--------------今日协同任务外呼数-----------------//
        //今日外呼量 今日平均会话时长
        List<CallRecord> waihuCallRecordList = jdbcTemplate.query(callSql+" and r.answer_status=1 and r.type=2 ",new BeanPropertyRowMapper<>(CallRecord.class));
        map.put("waihuCallCount",waihuCallRecordList.size());
        if (waihuCallRecordList.size()>0){
            int waihuTotalSeconds = totalTaklTime(waihuCallRecordList);
            map.put("waihuAvgTaklTime",getAvgTime(waihuTotalSeconds,waihuCallRecordList.size()));
        }else {
            map.put("waihuAvgTaklTime",0);
        }
        //--------------今日协同任务外呼数-----------------//
        String wanchenSql="SELECT" +
                " count(*) AS wanchengCount" +
                " FROM" +
                " `manage_synergy_workorder_servicer` s" +
                " LEFT JOIN wlyy_user u ON s.executor_code = u.`code`" +
                " WHERE" +
                " s.executor_type = 2" +
                " AND s.`status` = 3" +
                " AND s.complete_time >= '"+startTime+"'" +
                " AND s.complete_time <= '"+endTime+"'";
        Map<String,Object> wanchenMap = jdbcTemplate.queryForMap(wanchenSql);
        String weiwanchenSql ="SELECT" +
                " COUNT(*) AS weiwanchengCount" +
                " FROM" +
                " `manage_synergy_workorder_servicer` s" +
                " LEFT JOIN wlyy_user u ON s.executor_code = u.`code`" +
                " WHERE" +
                " executor_type = 2" +
                " AND `status`<3";
        Map<String,Object> weiwanchenMap = jdbcTemplate.queryForMap(weiwanchenSql);
        String fasongSql="SELECT" +
                " COUNT(*) AS fasongCount" +
                " FROM" +
                " (" +
                "  SELECT" +
                "   s.*, w.create_user," +
                "   w.create_user_name" +
                "  FROM" +
                "  manage_synergy_workorder_servicer s" +
                "  LEFT JOIN manage_synergy_workorder w ON s.workorder_code = w.`code`" +
                "  WHERE" +
                "   w.create_user_type = 2" +
                "  AND w.del = 1" +
                "  AND w.create_time >= '"+startTime+"'" +
                "  AND w.create_time <= '"+endTime+"'" +
                " ) a" +
                " LEFT JOIN wlyy_user u ON a.create_user = u.`code`";
        Map<String,Object> fasongMap = jdbcTemplate.queryForMap(fasongSql);
        map.putAll(wanchenMap);
        map.putAll(weiwanchenMap);
        map.putAll(fasongMap);
        return map;
        return map;
    }
    }
    public Map<String,Object> intervalOnLine(){
        Map<String,Object> map = new HashMap<>();
        String today = DateUtil.dateToStrShort(new Date());
        String startTime=today+" 00:00:00";
        String endTime = today+" 23:59:59";
        String allSql="SELECT " +
                " HOUR (r.create_time) AS HOUR, " +
                " count(*) AS Count " +
                " FROM " +
                " manage_call_record r " +
                " LEFT JOIN wlyy_user u ON r.user_code = u.`code` " +
                " WHERE " +
                " r.create_time BETWEEN '"+startTime+"' " +
                " AND '"+endTime+"' " +
                " AND r.answer_status = 1 " +
                " GROUP BY " +
                " HOUR (r.create_time) " +
                " ORDER BY " +
                " HOUR (r.create_time)";
    List<Map<String,Object>> allList = jdbcTemplate.queryForList(allSql);
    String jieruSql ="SELECT " +
            " HOUR (r.create_time) AS HOUR, " +
            " count(*) AS Count " +
            " FROM " +
            " manage_call_record r " +
            " LEFT JOIN wlyy_user u ON r.user_code = u.`code` " +
            " WHERE " +
            " r.create_time BETWEEN '"+startTime+"' " +
            " AND '"+endTime+"' " +
            " AND r.answer_status = 1 " +
            " AND r.type = 1 " +
            " GROUP BY " +
            " HOUR (r.create_time) " +
            " ORDER BY " +
            " HOUR (r.create_time)";
        List<Map<String,Object>> jieruList = jdbcTemplate.queryForList(allSql);
        map.put("all",allList);
        map.put("jieru",jieruList);
        return  map;
    }
    public List<Map<String,Object>> TodayCustomerActivy(){
        List<Map<String,Object>> resultList =  new ArrayList<>();
        String today = DateUtil.dateToStrShort(new Date());
        String startTime=today+" 00:00:00";
        String endTime = today+" 23:59:59";
        /*startTime="2017-11-15 00:00:00";
        endTime="2017-11-22 23:59:59";*/
        String sql="SELECT" +
                " u.`code`,"+
                " u.`name`," +
                " u.`online` as onlineType," +
                " r.type," +
                " COUNT(*) as num"+
                " FROM" +
                " wlyy_user u" +
                " LEFT JOIN manage_call_record r ON u.`code` = r.user_code" +
                " WHERE" +
                " u.type = 4" +
                " AND r.create_time>='"+startTime+"'" +
                " AND r.create_time<='"+endTime+"'" +
                " AND r.answer_status=1"+
                " GROUP BY" +
                " u.`code`," +
                " r.type";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> toList =  new ArrayList<>();
        for (Map<String,Object> map : list){
            resultList.addAll(toList);
            toList.clear();
            String userCode = String.valueOf(map.get("code"));
            String type = String.valueOf(map.get("type"));
            if (resultList.size()==0){
                Map<String,Object> resultMap = new HashMap<>();
                resultMap.put("userCode",userCode);
                resultMap.put("userName",map.get("name"));
                resultMap.put("onlineType",map.get("online"));
                if ("1".equals(type)){
                    resultMap.put("jieruCount",map.get("num"));
                    resultMap.put("waihuCount",0);
                }
                if ("2".equals(type)){
                    resultMap.put("jieruCount",0);
                    resultMap.put("waihuCount",map.get("num"));
                }
                toList.add(resultMap);
            }else {
                int count =0;
                for (Map<String,Object> map1 : resultList){
                    count++;
                    if(userCode.equals(String.valueOf(map1.get("userCode")))){
                        if ("1".equals(type)){
                            map1.put("jieruCount",map.get("num"));
                        }
                        if ("2".equals(type)){
                            map1.put("waihuCount",map.get("num"));
                        }
                    }
                    if (count==resultList.size() && !userCode.equals(String.valueOf(map1.get("userCode")))){
                        Map<String,Object> resultMap = new HashMap<>();
                        resultMap.put("userCode",userCode);
                        resultMap.put("userName",map.get("name"));
                        resultMap.put("onlineType",map.get("onlineType"));
                        if ("1".equals(type)){
                            resultMap.put("jieruCount",map.get("num"));
                            resultMap.put("waihuCount",0);
                        }
                        if ("2".equals(type)){
                            resultMap.put("jieruCount",0);
                            resultMap.put("waihuCount",map.get("num"));
                        }
                        toList.add(resultMap);
                    }
                }
            }
        }
        for (Map<String,Object> reMap : resultList){
            String userCode = String.valueOf(reMap.get("userCode"));
            String lineSql="SELECT" +
                    " *" +
                    " FROM" +
                    " `manage_customer_online_record`" +
                    " WHERE" +
                    " customer_code ='"+userCode+"'" +
                    " AND create_time >='"+startTime+"'" +
                    " AND create_time <='"+endTime+"'" +
                    " ORDER BY" +
                    " create_time";
            List<ManageCustomerOnlineRecordDO> manageCustomerOnlineRecordDOList = jdbcTemplate.query(lineSql,new BeanPropertyRowMapper<>(ManageCustomerOnlineRecordDO.class));
            //如果最新一条是离线则直接获取总在线时长就是在线时间
            // 如果最新一条是在线,则用当前时间减去上一条登录时间加上之前的在线时长为总的在线时长
            Map<String,Object> lineMap = getOnlineAndNotOnlineAndNowOnline(manageCustomerOnlineRecordDOList);
            reMap.putAll(lineMap);
        }
        return resultList;
    }
    public List<User> getCustomers() {
        return userDao.findAllCustomer();
    }
}
}

+ 41 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/util/http/HttpResponse.java

@ -0,0 +1,41 @@
package com.yihu.wlyy.util.http;
/**
 * Utils - Http请求辅助类,简化页面页面判断逻辑
 * Created by progr1mmer on 2018/1/16.
 */
public class HttpResponse {
    private int status;
    private String content;
    public HttpResponse(int status, String content) {
        this.status = status;
        this.content = content;
    }
    public int getStatus() {
        return status;
    }
    public void setStatus(int status) {
        this.status = status;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public boolean isSuccessFlg() {
        return status == 200;
    }
    public String getErrorMsg() {
        return content;
    }
}

+ 449 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/util/http/HttpUtils.java

@ -0,0 +1,449 @@
package com.yihu.wlyy.util.http;
import org.apache.http.HttpEntity;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.*;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.springframework.util.StringUtils;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * Utils - HTTP请求辅助工具类
 * Created by progr1mmer on 2017/9/27.
 */
public class HttpUtils {
    public static HttpResponse doGet(String url, Map<String, Object> params) throws Exception {
        return doGet(url, params, null);
    }
    public static HttpResponse doGet(String url, Map<String, Object> params, Map<String, String> headers) throws Exception {
        return doGet(url, params, headers, null, null);
    }
    public static HttpResponse doGet(String url, Map<String, Object> params, Map<String, String> headers, String username, String password) throws Exception {
        String response;
        int status;
        CloseableHttpClient httpClient = null;
        CloseableHttpResponse closeableHttpResponse = null;
        List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
        if (params != null) {
            for (String key : params.keySet()) {
                Object value = params.get(key);
                if (value != null) {
                    nameValuePairList.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
                }
            }
        }
        String paramStr = EntityUtils.toString(new UrlEncodedFormEntity(nameValuePairList, "UTF-8"));
        HttpGet httpGet = new HttpGet(url + "?" + paramStr);
        if (headers != null) {
            for (String key : headers.keySet()) {
                httpGet.addHeader(key, headers.get(key));
            }
        }
        try {
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                UsernamePasswordCredentials usernamePasswordCredentials = new UsernamePasswordCredentials(username, password);
                CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
                credentialsProvider.setCredentials(AuthScope.ANY, usernamePasswordCredentials);
                httpClient = HttpClients.custom().setDefaultCredentialsProvider(credentialsProvider).build();
            } else {
                httpClient = HttpClients.createDefault();
            }
            closeableHttpResponse = httpClient.execute(httpGet);
            HttpEntity resEntity = closeableHttpResponse.getEntity();
            status = closeableHttpResponse.getStatusLine().getStatusCode();
            response = getRespString(resEntity);
        } finally {
            try {
                if (closeableHttpResponse != null) {
                    closeableHttpResponse.close();
                }
                if (httpClient != null) {
                    httpClient.close();
                }
            }catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (status != HttpStatus.SC_OK) {
//            LogService.getLogger().error(" GET: " + url + " " + status);
        }
        HttpResponse httpResponse = new HttpResponse(status, response);
        return httpResponse;
    }
    public static HttpResponse doPost(String url, Map<String, Object> params) throws Exception {
        return doPost(url, params, null);
    }
    public static HttpResponse doPost(String url, Map<String, Object> params, Map<String, String> headers) throws Exception{
        return doPost(url, params, headers, null, null);
    }
    public static HttpResponse doPost(String url, Map<String, Object> params, Map<String, String> headers, String username, String password) throws Exception{
        String response;
        int status;
        CloseableHttpClient httpClient = null;
        CloseableHttpResponse closeableHttpResponse = null;
        HttpPost httpPost = new HttpPost(url);
        List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
        if (params != null) {
            for (String key : params.keySet()) {
                Object value = params.get(key);
                if (value != null) {
                    nameValuePairList.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
                }
            }
        }
        httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairList, "UTF-8"));
        if (headers != null) {
            for (String key : headers.keySet()) {
                httpPost.addHeader(key, headers.get(key));
            }
        }
        try {
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                UsernamePasswordCredentials usernamePasswordCredentials = new UsernamePasswordCredentials(username, password);
                CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
                credentialsProvider.setCredentials(AuthScope.ANY, usernamePasswordCredentials);
                httpClient = HttpClients.custom().setDefaultCredentialsProvider(credentialsProvider).build();
            } else {
                httpClient = HttpClients.createDefault();
            }
            closeableHttpResponse = httpClient.execute(httpPost);
            HttpEntity resEntity = closeableHttpResponse.getEntity();
            status = closeableHttpResponse.getStatusLine().getStatusCode();
            response = getRespString(resEntity);
        } finally {
            try {
                if (closeableHttpResponse != null) {
                    closeableHttpResponse.close();
                }
                if (httpClient != null) {
                    httpClient.close();
                }
            }catch (Exception e) {
                e.printStackTrace();
            }
        }
        if(status != HttpStatus.SC_OK) {
//            LogService.getLogger().error(" POST: " + url + " " + status);
        }
        HttpResponse httpResponse = new HttpResponse(status, response);
        return httpResponse;
    }
    public static HttpResponse doJsonPost(String url, String jsonData, Map<String, String> headers, String username, String password) throws Exception{
        String response;
        int status;
        CloseableHttpClient httpClient = null;
        CloseableHttpResponse closeableHttpResponse = null;
        HttpPost httpPost = new HttpPost(url);
        httpPost.setHeader("Content-Type", "application/json;charset=UTF-8");
        httpPost.setEntity(new StringEntity(jsonData, "UTF-8"));
        if (headers != null) {
            for (String key : headers.keySet()) {
                httpPost.addHeader(key, headers.get(key));
            }
        }
        try {
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                UsernamePasswordCredentials usernamePasswordCredentials = new UsernamePasswordCredentials(username, password);
                CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
                credentialsProvider.setCredentials(AuthScope.ANY, usernamePasswordCredentials);
                httpClient = HttpClients.custom().setDefaultCredentialsProvider(credentialsProvider).build();
            } else {
                httpClient = HttpClients.createDefault();
            }
            closeableHttpResponse = httpClient.execute(httpPost);
            HttpEntity resEntity = closeableHttpResponse.getEntity();
            status = closeableHttpResponse.getStatusLine().getStatusCode();
            response = getRespString(resEntity);
        } finally {
            try {
                if (closeableHttpResponse != null) {
                    closeableHttpResponse.close();
                }
                if (httpClient != null) {
                    httpClient.close();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if(status != HttpStatus.SC_OK) {
//            LogService.getLogger().error(" POST: " + url + " " + status);
        }
        HttpResponse httpResponse = new HttpResponse(status, response);
        return httpResponse;
    }
    public static HttpResponse doPut(String url, Map<String, Object> params) throws Exception {
        return doPut(url, params, null);
    }
    public static HttpResponse doPut(String url, Map<String, Object> params, Map<String, String> headers) throws Exception {
        return doPut(url, params, headers, null, null);
    }
    public static HttpResponse doPut(String url, Map<String, Object> params, Map<String, String> headers, String username, String password) throws Exception {
        String response;
        int status;
        CloseableHttpClient httpClient = null;
        CloseableHttpResponse closeableHttpResponse = null;
        HttpPut httpPut = new HttpPut(url);
        List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
        if (params != null) {
            for (String key : params.keySet()) {
                Object value = params.get(key);
                if (value != null) {
                    nameValuePairList.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
                }
            }
        }
        httpPut.setEntity(new UrlEncodedFormEntity(nameValuePairList, "UTF-8"));
        if (headers != null) {
            for (String key : headers.keySet()) {
                httpPut.addHeader(key, headers.get(key));
            }
        }
        try {
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                UsernamePasswordCredentials usernamePasswordCredentials = new UsernamePasswordCredentials(username, password);
                CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
                credentialsProvider.setCredentials(AuthScope.ANY, usernamePasswordCredentials);
                httpClient = HttpClients.custom().setDefaultCredentialsProvider(credentialsProvider).build();
            } else {
                httpClient = HttpClients.createDefault();
            }
            closeableHttpResponse = httpClient.execute(httpPut);
            HttpEntity resEntity = closeableHttpResponse.getEntity();
            status = closeableHttpResponse.getStatusLine().getStatusCode();
            response = getRespString(resEntity);
        } finally {
            try {
                if (closeableHttpResponse != null) {
                    closeableHttpResponse.close();
                }
                if (httpClient != null) {
                    httpClient.close();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (status != HttpStatus.SC_OK) {
//            LogService.getLogger().error(" PUT: " + url + " " + status);
        }
        HttpResponse httpResponse = new HttpResponse(status, response);
        return httpResponse;
    }
    public static HttpResponse doJsonPut(String url, String jsonData, Map<String, String> headers, String username, String password) throws Exception {
        String response;
        int status;
        CloseableHttpClient httpClient = null;
        CloseableHttpResponse closeableHttpResponse = null;
        HttpPut httpPut = new HttpPut(url);
        httpPut.setHeader("Content-Type", "application/json;charset=UTF-8");
        httpPut.setEntity(new StringEntity(jsonData, "UTF-8"));
        if (headers != null) {
            for (String key : headers.keySet()) {
                httpPut.addHeader(key, headers.get(key));
            }
        }
        try {
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                UsernamePasswordCredentials usernamePasswordCredentials = new UsernamePasswordCredentials(username, password);
                CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
                credentialsProvider.setCredentials(AuthScope.ANY, usernamePasswordCredentials);
                httpClient = HttpClients.custom().setDefaultCredentialsProvider(credentialsProvider).build();
            } else {
                httpClient = HttpClients.createDefault();
            }
            closeableHttpResponse = httpClient.execute(httpPut);
            HttpEntity resEntity = closeableHttpResponse.getEntity();
            status = closeableHttpResponse.getStatusLine().getStatusCode();
            response = getRespString(resEntity);
        } finally {
            try {
                if (closeableHttpResponse != null) {
                    closeableHttpResponse.close();
                }
                if (httpClient != null) {
                    httpClient.close();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (status != HttpStatus.SC_OK) {
//            LogService.getLogger().error(" PUT: " + url + " " + status);
        }
        HttpResponse httpResponse = new HttpResponse(status, response);
        return httpResponse;
    }
    public static HttpResponse doDelete(String url, Map<String, Object> params) throws Exception {
        return doDelete(url, params, null);
    }
    public static HttpResponse doDelete(String url, Map<String, Object> params, Map<String, String> headers) throws Exception {
        return doDelete(url, params, headers, null, null);
    }
    public static HttpResponse doDelete(String url, Map<String, Object> params, Map<String, String> headers, String username, String password) throws Exception {
        String response;
        int status;
        CloseableHttpClient httpClient = null;
        CloseableHttpResponse closeableHttpResponse = null;
        List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
        if (params != null) {
            for (String key : params.keySet()) {
                Object value = params.get(key);
                if (value != null) {
                    nameValuePairList.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
                }
            }
        }
        String paramStr = EntityUtils.toString(new UrlEncodedFormEntity(nameValuePairList, "UTF-8"));
        HttpDelete httpDelete = new HttpDelete(url + "?" + paramStr);
        if (headers != null) {
            for (String key : headers.keySet()) {
                httpDelete.addHeader(key, headers.get(key));
            }
        }
        try {
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                UsernamePasswordCredentials usernamePasswordCredentials = new UsernamePasswordCredentials(username, password);
                CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
                credentialsProvider.setCredentials(AuthScope.ANY, usernamePasswordCredentials);
                httpClient = HttpClients.custom().setDefaultCredentialsProvider(credentialsProvider).build();
            } else {
                httpClient = HttpClients.createDefault();
            }
            closeableHttpResponse = httpClient.execute(httpDelete);
            HttpEntity resEntity = closeableHttpResponse.getEntity();
            status = closeableHttpResponse.getStatusLine().getStatusCode();
            response = getRespString(resEntity);
        } finally {
            try {
                if (closeableHttpResponse != null) {
                    closeableHttpResponse.close();
                }
                if (httpClient != null) {
                    httpClient.close();
                }
            }catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (status != HttpStatus.SC_OK) {
//            LogService.getLogger().error(" DELETE: " + url + " " + status);
        }
        HttpResponse httpResponse = new HttpResponse(status, response);
        return httpResponse;
    }
    public static HttpResponse doUpload(String url, Map<String, Object> params, File file) throws Exception {
        return doUpload(url, params, null, file, null, null);
    }
    public static HttpResponse doUpload(String url, Map<String, Object> params, Map<String, String> headers, File file) throws Exception {
        return doUpload(url, params, headers, file, null, null);
    }
    public static HttpResponse doUpload(String url, Map<String, Object> params, Map<String, String> headers, File file, String username, String password) throws Exception {
        String response;
        int status;
        CloseableHttpClient httpClient = null;
        CloseableHttpResponse closeableHttpResponse = null;
        HttpPost httpPost = new HttpPost(url);
        MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
        FileBody fileBody = new FileBody(file);
        multipartEntityBuilder.addPart("file", fileBody);
        if (params != null) {
            for (String key : params.keySet()) {
                Object value = params.get(key);
                if (value != null) {
                    multipartEntityBuilder.addTextBody(key, String.valueOf(params.get(key)), ContentType.TEXT_PLAIN);
                }
            }
        }
        if (headers != null) {
            for (String key : headers.keySet()) {
                httpPost.addHeader(key, headers.get(key));
            }
        }
        HttpEntity reqEntity = multipartEntityBuilder.build();
        httpPost.setEntity(reqEntity);
        try {
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                UsernamePasswordCredentials usernamePasswordCredentials = new UsernamePasswordCredentials(username, password);
                CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
                credentialsProvider.setCredentials(AuthScope.ANY, usernamePasswordCredentials);
                httpClient = HttpClients.custom().setDefaultCredentialsProvider(credentialsProvider).build();
            } else {
                httpClient = HttpClients.createDefault();
            }
            closeableHttpResponse = httpClient.execute(httpPost);
            HttpEntity resEntity = closeableHttpResponse.getEntity();
            status = closeableHttpResponse.getStatusLine().getStatusCode();
            response = getRespString(resEntity);
        } finally {
            try {
                if (closeableHttpResponse != null) {
                    closeableHttpResponse.close();
                }
                if (httpClient != null) {
                    httpClient.close();
                }
            }catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (status != HttpStatus.SC_OK) {
//            LogService.getLogger().error(" POST UPLOAD: " + url + " " + status);
        }
        HttpResponse httpResponse = new HttpResponse(status, response);
        return httpResponse;
    }
    private static String getRespString(HttpEntity entity) throws Exception {
        if (entity == null) {
            return null;
        }
        InputStream is = entity.getContent();
        BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
        StringBuilder stringBuilder = new StringBuilder();
        String line;
        while ((line = reader.readLine()) != null) {
            stringBuilder.append(line);
        }
        return stringBuilder.toString();
    }
}

+ 54 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/util/http/IPInfoUtils.java

@ -0,0 +1,54 @@
package com.yihu.wlyy.util.http;
import javax.servlet.http.HttpServletRequest;
/**
 * Utils - ip信息辅助工具类
 * Created by progr1mmer on 2018/1/18.
 */
public class IPInfoUtils {
    private static final long A1 = getIpNum("10.0.0.0");
    private static final long A2 = getIpNum("10.255.255.255");
    private static final long B1 = getIpNum("172.16.0.0");
    private static final long B2 = getIpNum("172.31.255.255");
    private static final long C1 = getIpNum("192.168.0.0");
    private static final long C2 = getIpNum("192.168.255.255");
    private static final long D1 = getIpNum("10.44.0.0");
    private static final long D2 = getIpNum("10.69.0.255");
    private static long getIpNum(String ipAddress) {
        String [] ip = ipAddress.split("\\.");
        long a = Integer.parseInt(ip[0]);
        long b = Integer.parseInt(ip[1]);
        long c = Integer.parseInt(ip[2]);
        long d = Integer.parseInt(ip[3]);
        return a * 256 * 256 * 256 + b * 256 * 256 + c * 256 + d;
    }
    public static boolean isInnerIP(String ip){
        long n = getIpNum(ip);
        return (n >= A1 && n <= A2) || (n >= B1 && n <= B2) || (n >= C1 && n <= C2) || (n >= D1 && n <= D2);
    }
    public static String getIPAddress(HttpServletRequest request) {
        String ip = request.getHeader("x-forwarded-for");
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("Proxy-Client-IP");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("WL-Proxy-Client-IP");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("HTTP_CLIENT_IP");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("HTTP_X_FORWARDED_FOR");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getRemoteAddr();
        }
        return ip;
    }
}

+ 7 - 3
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/JMController.java

@ -43,9 +43,13 @@ public class JMController {
	{
	{
		try {
		try {
			
			
			String data = jmService.GetChildrenInfo(barCode);
			
			return Result.success("获取儿童信息成功!",data);
			String data = jmService.findChildren(barCode);
			JSONObject jsonObject = new JSONObject(data);
			if (jsonObject.getInt("msgCode")==800){
				return Result.success("获取儿童信息成功!",data);
			}else{
				return Result.error(jsonObject.getString("msg"));
			}
		} catch (Exception ex) {
		} catch (Exception ex) {
			ex.printStackTrace();
			ex.printStackTrace();
			return Result.error(ex.getMessage());
			return Result.error(ex.getMessage());

+ 9 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/JMService.java

@ -551,4 +551,13 @@ public class JMService {
        token = redisTemplate.opsForValue().get(redis_key).toString();
        token = redisTemplate.opsForValue().get(redis_key).toString();
        return token;
        return token;
    }
    }
    public String findChildren(String credential)throws Exception  {
        Map<String,String> params = new HashMap<>();
        params.put("act", FIND_CHILDREN);
        params.put("accId", accId);
        params.put("token_ylz", getTokenCheck());
        params.put("etmykh", credential);
        return ylzImmGetSecond(FIND_CHILDREN,"计免预约-获取儿童信息成功",params);
    }
}
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/imm/ChildFamilyImmuneService.java

@ -136,7 +136,7 @@ public class ChildFamilyImmuneService extends BaseService {
		String sql = "select DISTINCT t.*,m.child_name,m.birthday,m.childCode from wlyy_child_immune_vaccin t " +
		String sql = "select DISTINCT t.*,m.child_name,m.birthday,m.childCode from wlyy_child_immune_vaccin t " +
				" inner join ( " +
				" inner join ( " +
				" select a.*,b.name as family_name ,c.name as child_name,c.barcode as barcode ,c.birthday as birthday,c.`code` AS childCode from  wlyy_child_family_immune a " +
				" select a.*,b.name as family_name ,c.name as child_name,c.barcode as barcode ,c.birthday as birthday,c.`code` AS childCode from  wlyy_child_family_immune a " +
				" inner join (select patient,name from wlyy_sign_family where type in (1,2) and `status` = 1 and expenses_status = 1 and doctor = '"+doctorcode+"') b " +
				" inner join (select patient,name from wlyy_sign_family where type in (1,2) and `status` = 1 and expenses_status = 1 and doctor = '"+doctorcode+"' or doctor_health='"+doctorcode+"') b " +
				" on a.family_code = b.patient " +
				" on a.family_code = b.patient " +
				" left join wlyy_child_info c on c.`code` = a.child_code " +
				" left join wlyy_child_info c on c.`code` = a.child_code " +
				") m on m.barcode = t.barcode ";
				") m on m.barcode = t.barcode ";

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/imm/ChildInfoService.java

@ -54,7 +54,7 @@ public class ChildInfoService extends BaseService {
				childInfo.setCreate_time(new Date());
				childInfo.setCreate_time(new Date());
				childInfo.setBarcode(barCode);
				childInfo.setBarcode(barCode);
			}else{
			}else{
				throw new Exception("获取新生儿信息失败!");
				throw new Exception(rejson.getString("msg"));
			}
			}
		}
		}
		
		

+ 13 - 33
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/ManagerQuestionnaireService.java

@ -14,11 +14,8 @@ import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.http.HttpResponse;
import com.yihu.wlyy.util.http.HttpUtils;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONException;
@ -772,6 +769,7 @@ public class ManagerQuestionnaireService extends BaseService {
                opt.put("sort", st);
                opt.put("sort", st);
                opt.put("haveComment", haveComment);
                opt.put("haveComment", haveComment);
                opt.put("isRequired", required);
                opt.put("isRequired", required);
                opt.put("optionCode", option.getCode());
                optList.add(opt);
                optList.add(opt);
            }
            }
@ -779,6 +777,7 @@ public class ManagerQuestionnaireService extends BaseService {
            question.put("type", type);
            question.put("type", type);
            question.put("isRequired", isRequired);
            question.put("isRequired", isRequired);
            question.put("sort", sort);
            question.put("sort", sort);
            question.put("qstCode", qstcode);
            question.put("options", optList);
            question.put("options", optList);
            questions.add(question);
            questions.add(question);
        }
        }
@ -1882,10 +1881,11 @@ public class ManagerQuestionnaireService extends BaseService {
        }
        }
        List<Map<String, Object>> groupPatient = null;
        List<Map<String, Object>> groupPatient = null;
        if (StringUtils.isNotBlank(labelHealthType) || StringUtils.isNotBlank(labelDiseaseType)) {
        if (StringUtils.isNotBlank(labelHealthType) || StringUtils.isNotBlank(labelDiseaseType)) {
            String sql = "SELECT DISTINCT s.patient as service_patient_code, f.`name` as service_patient_name, f.ssc,f.idcard,f.mobile,f.hospital,f.hospital_name,h.town,h.town_name  FROM ( SELECT t.patient," +
            String sql = "SELECT DISTINCT s.patient as servicePatientCode, f.`name` as servicePatientName, f.ssc,f.idcard,f.mobile,f.hospital,f.hospital_name as hospitalName, h.town,h.town_name as townName  FROM ( SELECT t.patient," +
                    " GROUP_CONCAT(',',t.label_type,t.label,',') label FROM " +
                    " GROUP_CONCAT(',',t.label_type,t.label,',') label FROM " +
                    " wlyy_sign_patient_label_info t WHERE t.patient IN (" +
                    tableSql + whereSql + ") AND t. STATUS = 1 GROUP BY t.patient ) s LEFT JOIN wlyy_sign_family f on s.patient=f.patient LEFT JOIN dm_hospital h on f.hospital=h.`code` where 1=1 ";
                    " wlyy_sign_patient_label_info t WHERE t.patient IN ( select p.code " +
                    " from wlyy_sign_family w ,wlyy_admin_team t, dm_hospital h   , wlyy_sign_family_server s    , wlyy_patient p  " +
                    whereSql + ") AND t. STATUS = 1 GROUP BY t.patient ) s LEFT JOIN wlyy_sign_family f on s.patient=f.patient LEFT JOIN dm_hospital h on f.hospital=h.`code` where 1=1 ";
            if (StringUtils.isNotBlank(labelHealthType)) {
            if (StringUtils.isNotBlank(labelHealthType)) {
                String[] aa = labelHealthType.split(",");
                String[] aa = labelHealthType.split(",");
                String bb = "";
                String bb = "";
@ -1910,50 +1910,30 @@ public class ManagerQuestionnaireService extends BaseService {
        return groupPatient;
        return groupPatient;
    }
    }
    /**
     * 调用集美客服派发问卷协同服务接口
     * @param jsonData
     * @param patientInfo
     * @param doctor
     * @return
     * @throws Exception
     */
    public JSONObject createWorkOrder(String jsonData, List<Map<String, Object>> patientInfo, String doctor) throws Exception{
        JSONObject object = new JSONObject(jsonData);
        JSONArray patientInfos = new JSONArray(patientInfo);
        Doctor d = doctorService.findDoctorByCode(doctor);
        object.put("createUser", d.getCode());
        object.put("createUserName", d.getName());
        object.put("createUserType", 1);
        Map<String, Object> param = new HashedMap();
        param.put("patientInfo", patientInfos.toString());
        param.put("jsonData", object.toString());
        HttpResponse response = null;
        response = HttpUtils.doPost(customerUrl + "synergy/questionnaire/createWorkOrder", param);
        JSONObject rs = new JSONObject(response.getContent());
        return rs;
    }
    /**
    /**
     * 保存问卷调查结果和答案
     * 保存问卷调查结果和答案
     * @param jsonData
     * @param jsonData
     * @param patientCode
     * @param patientCode
     * @param customerCode
     * @param customerCode
     * @param doctor
     * @return
     * @return
     * @throws Exception
     * @throws Exception
     */
     */
    public String saveQuestionResultAndAnswer(JSONObject jsonData, String patientCode, String customerCode) throws Exception {
    public String saveQuestionResultAndAnswer(JSONObject jsonData, String patientCode, String customerCode, String doctor) throws Exception {
        String surveyCode = jsonData.get("surveyCode").toString();
        String surveyCode = jsonData.get("surveyCode").toString();
        Survey survey = surveyDao.findById(surveyCode);
        Survey survey = surveyDao.findById(surveyCode);
        Patient patient = patientDao.findByCode(patientCode);
        Patient patient = patientDao.findByCode(patientCode);
        User user = userDao.findByCode(customerCode);
        User user = userDao.findByCode(customerCode);
        Doctor d = doctorDao.findByCode(doctor);
        SurveyQuestionResult questionResult =  new SurveyQuestionResult();
        SurveyQuestionResult questionResult =  new SurveyQuestionResult();
        String code = getCode();
        String code = getCode();
        questionResult.setCode(code);
        questionResult.setCode(code);
        questionResult.setTemplateCode(survey.getCode());
        questionResult.setTemplateTitle(survey.getTitle());
        questionResult.setSurveyCode(survey.getCode());
        questionResult.setSurveyTitle(survey.getTitle());
        questionResult.setPatientCode(patient.getCode());
        questionResult.setPatientCode(patient.getCode());
        questionResult.setPatientName(patient.getName());
        questionResult.setPatientName(patient.getName());
        questionResult.setDoctor(doctor);
        questionResult.setDoctorName(d.getName());
        questionResult.setType(1);
        questionResult.setType(1);
        questionResult.setCreateUser(customerCode);
        questionResult.setCreateUser(customerCode);
        questionResult.setCreateUserName(user.getName());
        questionResult.setCreateUserName(user.getName());

+ 0 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/ImmuneService.java

@ -50,7 +50,6 @@ public class ImmuneService {
		String url = jwUrl + "/third/jm/imm/GetChildrenInfo";
		String url = jwUrl + "/third/jm/imm/GetChildrenInfo";
		List<NameValuePair> params = new ArrayList<>();
		List<NameValuePair> params = new ArrayList<>();
		params.add(new BasicNameValuePair("barCode", barcode));
		params.add(new BasicNameValuePair("barCode", barcode));
		
		String response = httpClientUtil.post(url, params, "UTF-8");
		String response = httpClientUtil.post(url, params, "UTF-8");
		
		
		return response;
		return response;

+ 37 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/jimeiJkEdu/DoctorJMJkEduArticleController.java

@ -350,24 +350,55 @@ public class DoctorJMJkEduArticleController extends BaseController {
            if (patientSet.size() == 0) {
            if (patientSet.size() == 0) {
                return new BaseResultModel("请至少选择一个患者!");
                return new BaseResultModel("请至少选择一个患者!");
            }
            }
            //推送微信模板消息和发送im消息
            if(StringUtils.isEmpty(currentUserRole)){
            if(StringUtils.isEmpty(currentUserRole)){
                currentUserRole = getCurrentRoleCode();
                currentUserRole = getCurrentRoleCode();
            }
            }
            if(StringUtils.isEmpty(currentUserRoleLevel)){
            if(StringUtils.isEmpty(currentUserRoleLevel)){
                currentUserRoleLevel = getCurrentRoleLevel();
                currentUserRoleLevel = getCurrentRoleLevel();
            }
            }
            List<HealthEduArticleES> healthEduArticleESList = jmJkEduArticleService.savePCPushArticle(patientSet, getUID(), Integer.parseInt(sendType),"", teamCode, articleId,leaveWords,currentUserRole,currentUserRoleLevel);
            //推送微信模板消息和发送im消息
            new Thread(() -> {
                //发送任务到redis
                sender(healthEduArticleESList);
            }).start();
//            List<HealthEduArticleES> healthEduArticleESList = jmJkEduArticleService.savePCPushArticle(patientSet, getUID(), Integer.parseInt(sendType),"", teamCode, articleId,leaveWords,currentUserRole,currentUserRoleLevel);
//            new Thread(() -> {
//                //发送任务到redis
//                sender(healthEduArticleESList);
//            }).start();
            new Thread(new HealthEduArticleESTask(patientSet,sendType,teamCode,articleId,leaveWords,currentUserRole,currentUserRoleLevel,getUID())).start();
            return new BaseResultModel();
            return new BaseResultModel();
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            error(e);
            return new BaseResultModel(BaseResultModel.statusEm.opera_error.getCode(), BaseResultModel.statusEm.opera_error.getMessage() + ":" + e.getMessage());
            return new BaseResultModel(BaseResultModel.statusEm.opera_error.getCode(), BaseResultModel.statusEm.opera_error.getMessage() + ":" + e.getMessage());
        }
        }
    }
    }
    class HealthEduArticleESTask implements Runnable {
        Set<String> patientSet;
        String sendType;
        Long teamCode;
        String articleId;
        String leaveWords;
        String currentUserRole;
        String currentUserRoleLevel;
        String sendCode;
        public HealthEduArticleESTask(Set<String> patientSet,String sendType,Long teamCode,String articleId,String leaveWords,String currentUserRole,String currentUserRoleLevel,String sendCode)  {
            this.patientSet=patientSet;
            this.sendType=sendType;
            this.teamCode=teamCode;
            this.articleId=articleId;
            this.leaveWords=leaveWords;
            this.currentUserRole=currentUserRole;
            this.currentUserRoleLevel=currentUserRoleLevel;
            this.sendCode=sendCode;
        }
        @Override
        public void run() {
            try{
                List<HealthEduArticleES> healthEduArticleESList = jmJkEduArticleService.savePCPushArticle(patientSet, sendCode, Integer.parseInt(sendType),"", teamCode, articleId,leaveWords,currentUserRole,currentUserRoleLevel);
                //发送任务到redis
                sender(healthEduArticleESList);
            }catch (Exception e){
                error(e);
            }
        }
    }
    @RequestMapping(value = "doctorSendArticleToSingle", method = RequestMethod.POST)
    @RequestMapping(value = "doctorSendArticleToSingle", method = RequestMethod.POST)

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

@ -583,29 +583,6 @@ 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)
    @RequestMapping(value = "/createWorkOrder",method = RequestMethod.POST)
    @ApiOperation(value = "创建协同服务")
    @ApiOperation(value = "创建协同服务")
    public String createWorkOrder(@ApiParam(name = "jsonData",value = "协同服务json字符串")
    public String createWorkOrder(@ApiParam(name = "jsonData",value = "协同服务json字符串")
@ -626,7 +603,7 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
                                      @RequestParam(value = "currentUserRoleLevel", required = false) String currentUserRoleLevel) {
                                      @RequestParam(value = "currentUserRoleLevel", required = false) String currentUserRoleLevel) {
        try {
        try {
            List<Map<String, Object>> patientInfo = managerQuestionnaireService.initPatient(labelUnitType, labelSexType, labelServerType, labelDiseaseType, labelHealthType, currentUserRole, currentUserRoleLevel);
            List<Map<String, Object>> patientInfo = managerQuestionnaireService.initPatient(labelUnitType, labelSexType, labelServerType, labelDiseaseType, labelHealthType, currentUserRole, currentUserRoleLevel);
            return write(200, "查询成功!", "data", managerQuestionnaireService.createWorkOrder(jsonData, patientInfo, getUID()));
            return write(200, "查询成功!", "data", surveyScreenResultService.createWorkOrder(jsonData, patientInfo, getUID()));
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
            return write(-1, "查询失败!");
            return write(-1, "查询失败!");

+ 99 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/synergy/SynergyManagerController.java

@ -4,16 +4,18 @@ package com.yihu.wlyy.web.third.synergy;/**
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.es.entity.FollowupContentESDO;
import com.yihu.es.entity.FollowupContentESDO;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.service.app.followup.FollowUpService;
import com.yihu.wlyy.service.app.followup.FollowUpService;
import com.yihu.wlyy.service.app.followup.FollowupDrugsService;
import com.yihu.wlyy.service.app.followup.FollowupDrugsService;
import com.yihu.wlyy.service.app.survey.SurveyScreenResultService;
import com.yihu.wlyy.service.survey.ManagerQuestionnaireService;
import com.yihu.wlyy.service.third.jw.ZyDictService;
import com.yihu.wlyy.service.third.jw.ZyDictService;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.*;
@ -34,6 +36,10 @@ public class SynergyManagerController extends BaseController{
    @Autowired
    @Autowired
    private FollowUpService followUpService;
    private FollowUpService followUpService;
    @Autowired
    @Autowired
    private ManagerQuestionnaireService managerQuestionnaireService;
    @Autowired
    private SurveyScreenResultService surveyScreenResultService;
    @Autowired
    private ZyDictService zyDictService;
    private ZyDictService zyDictService;
    @Autowired
    @Autowired
    private FollowupDrugsService followupDrugsService;
    private FollowupDrugsService followupDrugsService;
@ -181,4 +187,96 @@ public class SynergyManagerController extends BaseController{
        }
        }
    }
    }
    @RequestMapping(value = "/questionnaire/saveResultAndAnswer", method = RequestMethod.POST)
    @ApiOperation(value = "保存用户问卷答案")
    public String saveResultAndAnswer( @ApiParam(name = "jsonData", value = "问题和答案字符串")@RequestParam(value = "jsonData") String jsonData,
                                       @ApiParam(name = "patientCode", value = "居民code")@RequestParam(value = "patientCode")String patientCode,
                                       @ApiParam(name = "doctor", value = "医生code")@RequestParam(value = "doctor")String doctor,
                                       @ApiParam(name = "customerCode", value = "客服code")@RequestParam(value = "customerCode")String customerCode,
                                       @ApiParam(name = "labelType", value = "问卷标签")@RequestParam(value = "labelType")Integer labelType,
                                       @ApiParam(name = "isAgain", value = "筛查入口(labelType=5时要填),0是第一次筛查 1是再次评估")@RequestParam(value = "isAgain", required = false)int isAgain,
                                       @ApiParam(name = "source", value = "来源(1医生发放 2居民自我评估)")@RequestParam(value = "source")int source) {
        try {
            JSONObject json = new JSONObject(jsonData);
            if (labelType == 5){
                return  write(200, "保存成功!","data",surveyScreenResultService.saveScreenResultAndAnswer(patientCode, doctor, isAgain, source, json));
            }else {
                return write(200, "保存成功!", "data", managerQuestionnaireService.saveQuestionResultAndAnswer(json, patientCode, customerCode, doctor));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "保存失败!");
        }
    }
    /**
     * 查看调查结果
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/questionnaire/getAnswers", method = RequestMethod.GET)
    @ApiOperation(value = "查看调查问卷结果")
    @ResponseBody
    public String getAnswers(
            @ApiParam(value = "问卷id")
            @RequestParam String id) {
        try {
            JSONObject jsonObject = managerQuestionnaireService.getAnswers(id);
            return write(200, "查询成功!", "data", jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
    /**
     * 查看问卷内容
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/questionnaire/getQuestionnaireDetail", method = RequestMethod.GET)
    @ApiOperation(value = "查看问卷内容")
    @ResponseBody
    public String getQuestionnaireDetail(
            @ApiParam(value = "问卷id")
            @RequestParam String id) {
        try {
            JSONObject jsonObject = managerQuestionnaireService.getQuestionnaireDetail(id);
            return write(200, "查询成功", "data", jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/questionnaire/getAllQuestions",method = RequestMethod.GET)
    @ApiOperation(value = "获取所有问卷题目")
    @ResponseBody
    public String getAllQuestions(@ApiParam(name = "surveyTemplateCode",value = "问卷模板code")@RequestParam(value = "surveyTemplateCode",required = true)String surveyTemplateCode){
        try {
            JSONObject jsonObject = managerQuestionnaireService.getAllQuestions(surveyTemplateCode);
            return write(200, "查询成功!", "data", jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/screen/getScreenResultDetail", method = RequestMethod.GET)
    @ApiOperation(value = "查看筛查结果记录详情")
    @ResponseBody
    public String getScreenResultDetail(@ApiParam(value = "筛查结果唯一code")@RequestParam(value = "code") String code) {
        try {
            return write(200, "获取成功!", "data", surveyScreenResultService.getScreenResultDetail(code));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
}
}