Browse Source

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

# Conflicts:
#	patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/customer/CustomerSynergyManageController.java
#	patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/SynergyManageService.java
liuwenbin 6 years ago
parent
commit
07fbd60cfc
30 changed files with 1368 additions and 172 deletions
  1. 9 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/imm/ChildImmuneVaccin.java
  2. 10 12
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/customer/CustomerQuestionnaireController.java
  3. 100 6
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/customer/CustomerSynergyManageController.java
  4. 20 2
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/doctor/DoctorSynergyManageController.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. 10 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageCustomerOnlineRecordDO.java
  8. 2 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageSynergyWorkorderDO.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. 4 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/synergy/ManageCustomerOnlineRecordDao.java
  13. 20 17
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/QuestionnaireManageService.java
  14. 4 4
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/ScreenResultManageService.java
  15. 415 42
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/SynergyManageService.java
  16. 61 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/SynergyWorkorderServicerLogService.java
  17. 8 4
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/JMController.java
  18. 9 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/JMService.java
  19. 1 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/imm/ChildVaccinImmuneService.java
  20. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/imm/ChildFamilyImmuneService.java
  21. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/imm/ChildInfoService.java
  22. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistHospitalItemService.java
  23. 6 30
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/ManagerQuestionnaireService.java
  24. 40 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/synergy/ManageSynergyService.java
  25. 182 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/synergy/SynergyManageService.java
  26. 0 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/ImmuneService.java
  27. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/imm/DoctorImmController.java
  28. 1 24
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/ManagerQuestionnaireController.java
  29. 35 12
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/synergy/SynergyManageController.java
  30. 118 7
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/synergy/SynergyManagerController.java

+ 9 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/imm/ChildImmuneVaccin.java

@ -27,6 +27,7 @@ public class ChildImmuneVaccin extends IdEntity {
	private String ymbm;                    //疫苗编码
	private String jzzc;                    //接种针次
	private Date jzrq;						  //接种日期
	private int ymsx;						  //疫苗属性(1:一类,2:二类)
	private Integer isOut;					  //是否超过接种日期7天(0是 1不是)
	private Integer alert_tag;              //0待提醒,1已提醒
	private Date alert_time;                //提醒时间
@ -131,6 +132,14 @@ public class ChildImmuneVaccin extends IdEntity {
		this.jzrq = jzrq;
	}
	public int getYmsx() {
		return ymsx;
	}
	public void setYmsx(int ymsx) {
		this.ymsx = ymsx;
	}
	public Integer getIsOut() {
		return isOut;
	}

+ 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)
    @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 {
            return  write(200, "保存成功!", "data", questionnaireService.saveResultAndAnswer(patientCode, labelType, customerCode, source,jsonData, serviceCode));
        } catch (Exception e) {
@ -45,9 +45,9 @@ public class CustomerQuestionnaireController extends BaseController {
    @RequestMapping(value = "getAnswers", method = RequestMethod.GET)
    @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 {
            return write(200, "查询成功!", "data", questionnaireService.getAnswers(templateCode));
            return write(200, "查询成功!", "data", questionnaireService.getAnswers(surveyCode));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
@ -82,9 +82,7 @@ public class CustomerQuestionnaireController extends BaseController {
    public String isNotException(@ApiParam(value = "协同服务工单code") @RequestParam String workorderCode,
                                 @ApiParam(value = "客服code") @RequestParam String customerCode) {
        try {
            //判断是否有异常中断
            String workorderServiceCode = synergyManageService.isNotException(workorderCode, customerCode);
            return write(200, "查询成功!", "data", workorderServiceCode);
            return write(200, "查询成功!", "data", synergyManageService.isNotException(workorderCode, customerCode));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
@ -92,7 +90,7 @@ public class CustomerQuestionnaireController extends BaseController {
    }
    @RequestMapping(value = "loadingInfo", method = RequestMethod.GET)
    @ApiOperation(value = "载入异常工单信息")
    @ApiOperation(value = "载入异常通话居民信息")
    public String loadingInfo(@ApiParam(value = "协同服务对象code") @RequestParam String workorderServiceCode) {
        try {
            return write(200, "查询成功!", "data", synergyManageService.loadingInfo(workorderServiceCode));

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

@ -1,12 +1,15 @@
package com.yihu.wlyy.controller.synergy.customer;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.entity.User;
import com.yihu.wlyy.entity.call.CallRecord;
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.service.manager.user.UserService;
import com.yihu.wlyy.service.synergy.SynergyManageService;
import com.yihu.wlyy.service.synergy.SynergyWorkorderServicerLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -14,10 +17,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -36,11 +36,15 @@ public class CustomerSynergyManageController extends BaseController {
    @Autowired
    private SynergyManageService synergyManageService;
    @Autowired
    private SynergyWorkorderServicerLogService synergyWorkorderServicerLogService;
    @Autowired
    private UserService userService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private CallRecordDao callRecordDao;
    @Autowired
    private ObjectMapper objectMapper;
    @RequestMapping(value = "/getWorkOrderInfo", method = {RequestMethod.GET, RequestMethod.POST})
@ -305,6 +309,21 @@ public class CustomerSynergyManageController extends BaseController {
        }
    }
    @RequestMapping(value = "/createServicerLog",method = RequestMethod.POST)
    @ApiOperation(value = "添加协同服务日志")
    public String dealWorkOrder(@ApiParam(name="servicerLogDO",value="协同服务日志")
                                @RequestParam(name = "servicerLogDO",required = true)String servicerLogDO){
        try {
            ManageSynergyWorkorderServicerLogDO synergyWorkorderServicerLogDO = objectMapper.readValue(servicerLogDO,ManageSynergyWorkorderServicerLogDO.class);
            synergyWorkorderServicerLogService.create(synergyWorkorderServicerLogDO);
            return write(200,"保存成功");
        }catch (Exception e){
            error(e);
            return error(-1,"保存失败");
        }
    }
    @RequestMapping(value = "getDealList",method = RequestMethod.GET)
    @ApiOperation(value = "通话详情获取待办事项")
    public String getDealList(@ApiParam(name="idcard",value="居民身份证")@RequestParam(value ="idcard")String idcard){
@ -317,12 +336,54 @@ public class CustomerSynergyManageController extends BaseController {
        }
    }
    @ApiOperation("新增临时随访记录(返回ID)")
    @RequestMapping(value = "/addFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String addFollowup(@ApiParam(name = "doctor", value = "医生code")
                              @RequestParam(value = "doctor", required = true) String doctor,
                              @ApiParam(name = "patient", value = "患者代码", defaultValue = "443a196ef8744536a531260eb26c05d7")
                              @RequestParam(value = "patient", required = true) String patient,
                              @ApiParam(name = "date", value = "下次随访时间", defaultValue = "2016-12-15 20:00:00")
                              @RequestParam(value = "date", required = true) String date,
                              @ApiParam(name = "followupType", value = "随访方式【字典FOLLOWUP_WAY_DICT】", defaultValue = "12")
                              @RequestParam(value = "followupType", required = true) String followupType,
                              @ApiParam(name = "followupClass", value = "随访类别【1.高血压 2.糖尿病 3高糖】", defaultValue = "1")
                              @RequestParam(value = "followupClass", required = true) String followupClass,
                              @ApiParam(name = "followupManagerStatus", value = "随访管理状态【字典FOLLOWUP_MANAGER_STATUS】", defaultValue = "1")
                              @RequestParam(value = "followupManagerStatus", required = false) String followupManagerStatus,
                              @ApiParam(name = "plandate", value = "下次随访时间", defaultValue = "2016-12-14 20:00:00")
                              @RequestParam(value = "plandate", required = false) String plandate) {
        try {
            String response = synergyManageService.addFollowup(doctor, patient, date, followupType, followupClass, followupManagerStatus,plandate);
            return write(200, "新增临时随访记录成功!", "data", response);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "新增临时随访记录失败!" + e.getMessage());
        }
    }
    @ApiOperation("保存随访项目数据")
    @RequestMapping(value = "/saveFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String saveFollowupProjectData(@ApiParam(name = "followup", value = "随访项目对象")
                                          @RequestParam(value = "followup", required = true)String followup ) {
        try {
            synergyManageService.saveFollowupProjectData(followup);
            return write(200, "保存随访项目数据成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "保存随访项目数据失败!" + e.getMessage());
        }
    }
    @RequestMapping(value = "customerIndex",method = RequestMethod.GET)
    @ApiOperation(value = "客服首页")
    public String customerIndex(@ApiParam(name="userCode",value="客服code")@RequestParam(value ="userCode")String userCode){
        try{
            return write(200,"获取成功!");
            return write(200,"获取成功!","data",synergyManageService.customerIndex(userCode));
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
@ -406,6 +467,39 @@ public class CustomerSynergyManageController extends BaseController {
        }
    }
    @RequestMapping(value = "adminIndex",method = RequestMethod.GET)
    @ApiOperation(value = "管理员首页.")
    public String adminIndex(){
        try{
            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)

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

@ -6,13 +6,13 @@ import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerDO;
import com.yihu.wlyy.service.synergy.SynergyManageService;
import com.yihu.wlyy.service.synergy.SynergyWorkorderServicerLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@ -34,6 +34,8 @@ public class DoctorSynergyManageController extends BaseController {
    private SynergyManageService synergyManageService;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private SynergyWorkorderServicerLogService workorderServicerLogService;
    @RequestMapping(value = "workorderList", method = RequestMethod.GET)
    @ApiOperation("医生端-协同服务列表")
@ -85,7 +87,7 @@ public class DoctorSynergyManageController extends BaseController {
        }
    }
    @RequestMapping(value = "createWorkorder", method = RequestMethod.GET)
    @RequestMapping(value = "createWorkorder", method = RequestMethod.POST)
    @ApiOperation("医生端-创建协同服务")
    public String workorderList(@ApiParam(name = "workorder", value = "工单对象", required = false)
                                @RequestParam(value = "workorder")String workorder,
@ -106,4 +108,20 @@ public class DoctorSynergyManageController extends BaseController {
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "selectByWorkorderCode", method = RequestMethod.POST)
    @ApiOperation("医生端-居民列表")
    public String selectByWorkorderCode(@ApiParam(name = "workorderCode", value = "工单code", required = false)
                                            @RequestParam(value = "workorderCode", required = false)String workorderCode,
                                        @ApiParam(name = "page", value = "页码", defaultValue = "1")
                                        @RequestParam(value = "page", required = false)Integer page,
                                        @ApiParam(name = "size", value = "每页大小", defaultValue = "10")
                                            @RequestParam(value = "size", required = false)Integer size){
        try {
            return write(200, "请求成功","data",workorderServicerLogService.selectByWorkorderCode(workorderCode,page,size));
        }catch (Exception e){
            error(e);
            return error(-1, "请求失败");
        }
    }
}

+ 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;
    }
}

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

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

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

@ -1,5 +1,6 @@
package com.yihu.wlyy.entity.synergy;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
@ -59,6 +60,7 @@ public class ManageSynergyWorkorderDO extends IdEntity {
    }
    @Column(name = "service_time")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm")
    public Date getServiceTime() {
        return serviceTime;
    }

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

@ -38,4 +38,6 @@ public interface UserDao extends PagingAndSortingRepository<User, Long>, JpaSpec
	User findByJobNo(String jobNo);
	List<User> findByType(int type);
}

+ 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> {
}

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

@ -1,10 +1,14 @@
package com.yihu.wlyy.repository.synergy;
import com.yihu.wlyy.entity.synergy.ManageCustomerOnlineRecordDO;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by 刘文彬 on 2018/9/27.
 */
public interface ManageCustomerOnlineRecordDao extends PagingAndSortingRepository<ManageCustomerOnlineRecordDO, Long> {
}

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

@ -2,11 +2,11 @@ package com.yihu.wlyy.service.synergy;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.survey.SurveyQuestionResult;
import com.yihu.wlyy.entity.survey.SurveyTemplateQuestions;
import com.yihu.wlyy.entity.survey.SurveyQuestionnaire;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerDO;
import com.yihu.wlyy.repository.survey.SurveyQuestionResultDao;
import com.yihu.wlyy.repository.survey.SurveyTemplateQuestionsDao;
import com.yihu.wlyy.repository.survey.SurveyQuestionnaireDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkOrderDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkorderServicerDao;
import com.yihu.wlyy.util.HttpClientUtil;
@ -38,7 +38,7 @@ public class QuestionnaireManageService extends BaseJpaService {
    @Autowired
    private ManageSynergyWorkorderServicerDao workorderServicerDao;
    @Autowired
    private SurveyTemplateQuestionsDao templateQuestionDao;
    private SurveyQuestionnaireDao surveyQuestionnaireDao;
    @Autowired
    private SurveyQuestionResultDao questionResultDao;
    @Autowired
@ -98,7 +98,7 @@ public class QuestionnaireManageService extends BaseJpaService {
     * @param serviceCode
     */
    public String saveResultAndAnswer(String patientCode, Integer labelType, String customerCode, Integer source, String jsonData, String serviceCode) {
        String url = wlyyUrl + "doctor/questionnaire/saveResultAndAnswer";
        String url = wlyyUrl + "third/synergy/questionnaire/saveResultAndAnswer";
        String response = "";
        Map<String, Object> params = new HashMap<>();
        params.put("labelType", labelType);
@ -106,6 +106,7 @@ public class QuestionnaireManageService extends BaseJpaService {
        params.put("jsonData", jsonData);
        params.put("customerCode", customerCode);
        params.put("source", source);
        params.put("isAgain", 0);
        try {
            response = httpClientUtil.post(url, params);
        } catch (Exception e) {
@ -121,14 +122,14 @@ public class QuestionnaireManageService extends BaseJpaService {
    /**
     * 查看调查问卷统计结果
     * @param templateCode
     * @param surveyCode
     * @return
     */
    public JSONObject getAnswers(String templateCode) {
        String url = wlyyUrl + "doctor/questionnaire/getAnswers?id=" + templateCode;
    public JSONObject getAnswers(String surveyCode) {
        String url = wlyyUrl + "third/synergy/questionnaire/getAnswers?id=" + surveyCode;
        String  response = httpClientUtil.get(url, "UTF-8");
        JSONObject jsonObject = JSONObject.parseObject(response);
        if(jsonObject.getString("msg").equals("查询成功!")){
        if(jsonObject.getInteger("status") == 200){
            return JSONObject.parseObject(jsonObject.getString("data"));
        }
        return JSONObject.parseObject(response);
@ -146,31 +147,33 @@ public class QuestionnaireManageService extends BaseJpaService {
        String patient = questionResult.getPatientCode();
        String templateCode = questionResult.getTemplateCode();
        //获取模板问题
        List<SurveyTemplateQuestions> questionList = templateQuestionDao.findByTemplateCode(templateCode);
        List<SurveyQuestionnaire> questionList = surveyQuestionnaireDao.findBySurveyCode(templateCode);
        //查找选项和答案
        Map<String, Object> answerMap = new HashMap<>();
        String sql = "SELECT soa.*, sto.content FROM wlyy_survey_option_answers soa LEFT JOIN wlyy_survey_template_options sto ON soa.options_code= sto.code WHERE soa.screen_result_code = ? AND soa.patient=? AND soa.survey_code=?";
        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, templateCode});
        for (SurveyTemplateQuestions templateQuestion : questionList) {
        for (SurveyQuestionnaire question : questionList) {
            List<Map<String, Object>> optionList = new ArrayList<>();
            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) {
                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);
        return json;
    }
    public JSONObject getQuestionnaireDetail(String surveyCode) {
        String url = wlyyUrl + "doctor/questionnaire/getQuestionnaireDetail?id=" + surveyCode;
        String url = wlyyUrl + "third/synergy/questionnaire/getQuestionnaireDetail?id=" + surveyCode;
        String response = httpClientUtil.get(url, "UTF-8");
        JSONObject jsonObject = JSONObject.parseObject(response);
        if(jsonObject.getString("msg").equals("查询成功")){
        if(jsonObject.getInteger("status") == 200){
            return JSONObject.parseObject(jsonObject.getString("data"));
        }
        return JSONObject.parseObject(response);

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

@ -25,10 +25,10 @@ public class ScreenResultManageService {
     * @return
     */
    public JSONObject getScreenResultDetail(String code) {
        String url = wlyyUrl + "doctor/screen/getScreenResultDetail?code=" + code;
        String url = wlyyUrl + "third/synergy/screen/getScreenResultDetail?code=" + code;
        String response = httpClientUtil.get(url, "UTF-8");
        JSONObject jsonObject = JSONObject.parseObject(response);
        if(jsonObject.getString("msg").equals("查询成功")){
        if(jsonObject.getInteger("status") == 200){
            return JSONObject.parseObject(jsonObject.getString("data"));
        }
        return JSONObject.parseObject(response);
@ -40,10 +40,10 @@ public class ScreenResultManageService {
     * @return
     */
    public JSONObject getScreenDetail(String templateCode) {
        String url = wlyyUrl + "/doctor/questionnaire/getAllQuestions?surveyTemplateCode=" + templateCode;
        String url = wlyyUrl + "third/synergy/questionnaire/getAllQuestions?surveyTemplateCode=" + templateCode;
        String response = httpClientUtil.get(url, "UTF-8");
        JSONObject jsonObject = JSONObject.parseObject(response);
        if(jsonObject.getString("msg").equals("查询成功")){
        if(jsonObject.getInteger("status") == 200){
            return JSONObject.parseObject(jsonObject.getString("data"));
        }
        return JSONObject.parseObject(response);

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

@ -1,13 +1,7 @@
package com.yihu.wlyy.service.synergy;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
import com.yihu.wlyy.entity.*;
import com.yihu.wlyy.entity.call.CallRecord;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkordeReminderDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderExecutorDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerDO;
import com.yihu.wlyy.entity.synergy.*;
import com.yihu.wlyy.repository.*;
import com.yihu.wlyy.repository.synergy.*;
@ -19,7 +13,6 @@ import com.yihu.wlyy.util.http.HttpUtils;
import com.yihu.wlyy.util.query.BaseJpaService;
import jxl.Workbook;
import jxl.write.*;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
@ -89,6 +82,8 @@ public class SynergyManageService extends BaseJpaService {
    @Autowired
    private FastDFSUtil fastDFSUtil;
    @Autowired
    private ManageCustomerOnlineRecordDao manageCustomerOnlineRecordDao;
    @Autowired
    private ManageSynergyAccessoryDao manageSynergyAccessoryDao;
    /**
@ -419,6 +414,8 @@ public class SynergyManageService extends BaseJpaService {
            //获取处理结果
            map.put("resultRemark", workorderDO.getDealResultRemark());
            map.put("accessory", workorderDO.getDealResultAccessory());
            if(workorderDO.getType() == 4)
            map.put("relationCode", workorderDO.getRelationCode());
        }else if(status == 4){
            //获取退回原因
            map.put("returnedRemark", workorderDO.getReturnedRemark());
@ -656,14 +653,17 @@ public class SynergyManageService extends BaseJpaService {
     * @param customerCode
     * @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 " +
                "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 + "' " +
                "GROUP BY cl.workorder_code, cl.create_user_code " +
                "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) {
@ -678,8 +678,8 @@ public class SynergyManageService extends BaseJpaService {
        Map<String, Object> result = (Map<String, Object>) jdbcTemplate.queryForList(sql);
        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("hospitalName", workorderServicerDO.getHospitalName());//所属社区
        Integer callNum = customerLogDao.callNumByWorkorder(workorderServiceCode);
@ -704,7 +704,7 @@ public class SynergyManageService extends BaseJpaService {
        Integer age = IdCardUtil.getAgeForIdcard(patient.getIdcard());
        resultMap.put("age",age);//年龄
        SignFamily signFamily = signFamilyDao.findSignByPatient(patientCode);
        resultMap.put("signDoctor", signFamily.getDoctor());//签约医生(即:工单创建医生)
        resultMap.put("signDoctor", signFamily.getDoctorName());//签约医生(即:工单创建医生)
        resultMap.put("healthDoctor", signFamily.getDoctorHealthName());//健管师
        List<SignPatientLabelInfo> labelDiseaseType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patientCode,  "3", 1);
        String diseaseType="";
@ -718,7 +718,7 @@ public class SynergyManageService extends BaseJpaService {
            healthType += ","+one.getLabelName();
        }
        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="";
        for(SignPatientLabelInfo one:labelServeType){
            serveType+=","+one.getLabelName();
@ -897,6 +897,9 @@ public class SynergyManageService extends BaseJpaService {
     */
    public void createWorkorder(ManageSynergyWorkorderDO manageSynergyWorkorderDO,List<ManageSynergyWorkorderServicerDO> manageSynergyWorkorderServicerDOS){
        manageSynergyWorkorderDO.setCode(getWorkorderNo());
        manageSynergyWorkorderDO.setDel(1);
        manageSynergyWorkorderDO.setCreateTime(new Date());
        manageSynergyWorkorderDO.setStatus(1);
        ManageSynergyWorkorderDO manageSynergyWorkorderDO1 = workOrderDao.save(manageSynergyWorkorderDO);
        for (ManageSynergyWorkorderServicerDO servicerDO:manageSynergyWorkorderServicerDOS){
            servicerDO.setWorkorderType(manageSynergyWorkorderDO1.getType());
@ -919,9 +922,8 @@ public class SynergyManageService extends BaseJpaService {
     * @param followupClass
     * @param followupManagerStatus
     * @param plandate
     * @param prescriptioncode
     */
    public String addFollowup(String doctor,String patient, String date, String followupType,String followupClass,String followupManagerStatus,String plandate,String prescriptioncode){
    public String addFollowup(String doctor,String patient, String date, String followupType,String followupClass,String followupManagerStatus,String plandate){
        String response = null;
        String url = wlyyUrl + "followup/addFollowup";
        Map<String, Object> params = new HashMap<>();
@ -932,7 +934,6 @@ public class SynergyManageService extends BaseJpaService {
        params.put("followupClass",followupClass);
        params.put("followupManagerStatus",followupManagerStatus);
        params.put("plandate",plandate);
        params.put("prescriptioncode",prescriptioncode);
        try {
            response = httpClientUtil.post(url, params);
        } catch (Exception e) {
@ -1238,18 +1239,164 @@ public class SynergyManageService extends BaseJpaService {
        return  jdbcTemplate.update(sql);
    }
    public void customerIndex(String userCode){
        Map<String,Object> map = new HashMap<>();
    public Map<String,Object> customerIndex(String userCode){
        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));
        int customerNoCount = 0;
        for(CallRecord callRecord : waihudList){
            //获取客户未接通数量
            if(callRecord.getAnswerStatus()==3){
                customerNoCount++;
            }
        }
        //求总时长
        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("waihuCustomerNoCount",customerNoCount);
        //--------------今日在线时长-----------------//
        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));
        //求总时长
        int jieruTotalSecond = totalTaklTime(jieruList);
        //求平均时长
        if (jieruList.size()>0){
            map.put("jieruAvgTalkTime",getAvgTime(jieruTotalSecond,jieruList.size()));
        }
        map.put("jieruAvgTalkTime",0);
        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;
    }
    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
     * @return
     */
    public int totalTaklTime(List<CallRecord> list){
        int hours = 0;
        int minutes = 0;
        int seconds = 0;
        for(CallRecord callRecord : waihudList){
            //求总时长
        for(CallRecord callRecord : list){
            if (callRecord.getAnswerStatus()==1){
                String talkTime = callRecord.getTalkTime();
                String[] talkTimeStr = talkTime.split(":");
@ -1265,29 +1412,26 @@ public class SynergyManageService extends BaseJpaService {
                    }
                }
            }
            //获取客户未接通数量
            if(callRecord.getAnswerStatus()==3){
                customerNoCount++;
            }
        }
        String avgTalkTime = "";
        seconds = hours*3600+minutes*60+seconds;
        avgTalkTime =seconds/3600+"时";
        if (seconds%3600==0){
           avgTalkTime +="0分0秒";
        return seconds;
    }
    public String getAvgTime(int totalSeconds,int count){
        int avgSeconds = totalSeconds/count;
        String avgTalkTime = "";
        avgTalkTime =avgSeconds/3600+"时";
        if (avgSeconds%3600==0){
            avgTalkTime +="0分0秒";
        }else {
           if (seconds%3600%60==0){
               avgTalkTime +=seconds%3600/60+"分0秒";
           }else {
               avgTalkTime +=seconds%3600/60+"分"+seconds%3600%60+"秒";
           }
            if (avgSeconds%3600%60==0){
                avgTalkTime +=avgSeconds%3600/60+"分0秒";
            }else {
                avgTalkTime +=avgSeconds%3600/60+"分"+avgSeconds%3600%60+"秒";
            }
        }
        map.put("waihuCount",waihudList.size());
        map.put("waihuCustomerNoCount",customerNoCount);
        map.put("waihuAvgTalkTime",avgTalkTime);
        return avgTalkTime;
    }
    /**
     * 添加客户操作记录
     * @param workorderCode
@ -1394,4 +1538,233 @@ public class SynergyManageService extends BaseJpaService {
        }
        return result;
    }
    public Map<String,Object> adminIndex(){
        List<User> userList = userDao.findByType(4);
        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 callSql ="SELECT" +
                " r.*" +
                " FROM" +
                " manage_call_record r" +
                " LEFT JOIN wlyy_user u ON r.user_code = u.`code`" +
                " WHERE" +
                " u.type = 4" +
                " AND r.create_time >= '"+startTime+"'" +
                " AND r.create_time <= '"+endTime+"'";
        //正在咨询人数
        //当前客服人数
        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> 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;
    }
    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;
    }
}

+ 61 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/SynergyWorkorderServicerLogService.java

@ -2,14 +2,26 @@ package com.yihu.wlyy.service.synergy;/**
 * Created by nature of king on 2018/10/9.
 */
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.Patient;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerLogDO;
import com.yihu.wlyy.repository.PatientDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkOrderDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkorderServicerDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkorderServicerLogDao;
import com.yihu.wlyy.util.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * @author wangzhinan
@ -21,6 +33,15 @@ import java.util.Date;
public class SynergyWorkorderServicerLogService extends BaseJpaService {
    @Autowired
    private ManageSynergyWorkorderServicerLogDao manageSynergyWorkorderServicerLogDao;
    @Autowired
    private ManageSynergyWorkOrderDao manageSynergyWorkOrderDao;
    @Autowired
    private ManageSynergyWorkorderServicerDao workorderServicerDao;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
@ -30,6 +51,45 @@ public class SynergyWorkorderServicerLogService extends BaseJpaService {
     */
    public void create(ManageSynergyWorkorderServicerLogDO synergyWorkorderServicerLogDO){
        synergyWorkorderServicerLogDO.setCreateTime(new Date());
        manageSynergyWorkorderServicerLogDao.save(synergyWorkorderServicerLogDO);
        ManageSynergyWorkorderServicerLogDO workorderServicerLogDO = manageSynergyWorkorderServicerLogDao.save(synergyWorkorderServicerLogDO);
        ManageSynergyWorkorderServicerDO workorderServicerDO = workorderServicerDao.findByWorkOrderCodeAndPatientCode(workorderServicerLogDO.getWorkorderCode(),workorderServicerLogDO.getWorkorderServiceCode());
        workorderServicerDO.setStatus(3);
        workorderServicerDao.save(workorderServicerDO);
        String sql = "select * from manage_synergy_workorder_servicer where workorder_code = '"+workorderServicerLogDO.getWorkorderCode()+"' and status IN(1,2)";
        List<ManageSynergyWorkorderServicerDO> workorderServicerDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(ManageSynergyWorkorderServicerDO.class));
        if (workorderServicerDOS == null || workorderServicerDOS.size() == 0){
            ManageSynergyWorkorderDO workorderDO = manageSynergyWorkOrderDao.findByCode(workorderServicerLogDO.getWorkorderCode());
            workorderDO.setStatus(3);
            manageSynergyWorkOrderDao.save(workorderDO);
        }
    }
    /**
     * 根据工单code获取服务对象
     *
     * @param workorderCode 工单code
     * @return
     */
    public JSONObject selectByWorkorderCode(String workorderCode, Integer page, Integer size){
        JSONObject object = new JSONObject();
        String sql = "select * from manage_synergy_workorder_servicer where workorder_code = '"+workorderCode+"' LIMIT "+(page-1)*size+","+size;
        List<ManageSynergyWorkorderServicerDO> workorderServicerDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(ManageSynergyWorkorderServicerDO.class));
        String sqlCount = "select count(1) as total from manage_synergy_workorder_servicer where workorder_code = '"+workorderCode+"'";
        List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sqlCount);
        Long count = 0L;
        if(rstotal!=null&&rstotal.size()>0){
            count = (Long) rstotal.get(0).get("total");
        }
        List<Patient> patients = new ArrayList<>();
        for (ManageSynergyWorkorderServicerDO workorderServicerDO:workorderServicerDOS){
            Patient patient = patientDao.findByCode(workorderServicerDO.getServicePatientCode());
            patients.add(patient);
        }
        object.put("currPage",page);
        object.put("pageSize",size);
        object.put("totalCount",count);
        object.put("detailModelList",patients);
        return object;
    }
}

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

@ -43,9 +43,13 @@ public class JMController {
	{
		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) {
			ex.printStackTrace();
			return Result.error(ex.getMessage());
@ -356,7 +360,7 @@ public class JMController {
			if (jsonObject.getInt("msgCode")==800){
				return Result.success("获取接种记录成功!",data);
			}else{
				return Result.error(jsonObject.getString("msg"));
				return Result.error(jsonObject.getString("body"));
			}
		} catch (Exception ex) {

+ 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();
        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 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/imm/ChildVaccinImmuneService.java

@ -121,6 +121,7 @@ public class ChildVaccinImmuneService extends BaseService {
										childImmuneVaccin.setYmbm(ymbm);
										childImmuneVaccin.setJzzc(jzzc);
										childImmuneVaccin.setJzrq(DateUtil.strToDate(vaccinJsonJSONArray.getJSONObject(j).getString("jzRq"),DateUtil.YYYY_MM_DD));
										childImmuneVaccin.setYmsx(Integer.valueOf(vaccinJsonJSONArray.getJSONObject(j).getString("ymSx")));
										childImmuneVaccin.setAlert_tag(0);
										childImmuneVaccin.setDel(0);
										childImmuneVaccin.setCreate_time(new Date());

+ 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 " +
				" 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 " +
				" 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 " +
				" left join wlyy_child_info c on c.`code` = a.child_code " +
				") 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.setBarcode(barCode);
			}else{
				throw new Exception("获取新生儿信息失败!");
				throw new Exception(rejson.getString("msg"));
			}
		}
		

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistHospitalItemService.java

@ -110,7 +110,7 @@ public class SpecialistHospitalItemService extends BaseService {
    public JSONArray getHospital(String doctor, String patient, String serviceItemName) throws Exception{
        String response = null;
        JSONObject object = new JSONObject();
        String url =specialistUrl + "svr-specialist/selectByHospital1";
        String url =/*"http://localhost:10051/"*/specialistUrl + "svr-specialist/selectByHospital1";
        Map<String,String> params = new HashMap<>();
        SignFamily signFamily = new SignFamily();
        Doctor d = doctorService.findDoctorByCode(doctor);

+ 6 - 30
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.common.account.DoctorService;
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.WeiXinOpenIdUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONException;
@ -772,6 +769,7 @@ public class ManagerQuestionnaireService extends BaseService {
                opt.put("sort", st);
                opt.put("haveComment", haveComment);
                opt.put("isRequired", required);
                opt.put("optionCode", option.getCode());
                optList.add(opt);
            }
@ -779,6 +777,7 @@ public class ManagerQuestionnaireService extends BaseService {
            question.put("type", type);
            question.put("isRequired", isRequired);
            question.put("sort", sort);
            question.put("qstCode", qstcode);
            question.put("options", optList);
            questions.add(question);
        }
@ -1882,10 +1881,11 @@ public class ManagerQuestionnaireService extends BaseService {
        }
        List<Map<String, Object>> groupPatient = null;
        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 " +
                    " 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)) {
                String[] aa = labelHealthType.split(",");
                String bb = "";
@ -1910,30 +1910,6 @@ public class ManagerQuestionnaireService extends BaseService {
        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

+ 40 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/synergy/ManageSynergyService.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.service.synergy;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.followup.Followup;
@ -14,6 +15,7 @@ import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.util.http.HttpResponse;
import com.yihu.wlyy.util.http.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
@ -61,7 +63,7 @@ public class ManageSynergyService extends BaseService {
    }
    public String createWorkorder(String doctor, Set<String> patientSet, Integer type, String objectId, String serviceDate, Integer priority, String remark, String followupClass, String followupType){
    public String createWorkorder(String doctor, Set<String> patientSet, Integer type, String objectId, String serviceDate, Integer priority, String remark, String followupClass, String followupType) throws Exception {
        String response = null;
        JSONArray array = new JSONArray();
        String patientCode1 = null;
@ -130,12 +132,14 @@ public class ManageSynergyService extends BaseService {
        String url = customerUrl + "followup/saveFollowupProjectData";
        Map<String, String> params = new HashMap<>();
        params.put("servicers",array.toJSONString());
        try {
            response = httpClientUtil.httpPost(url,params);
        } catch (Exception e) {
            e.printStackTrace();
        response = httpClientUtil.httpPost(url,params);
        com.alibaba.fastjson.JSONObject object1 = JSON.parseObject(response);
        if (object.getInteger("status")==200){
            return response;
        }else {
            throw new Exception("请求客服系统服务失败!");
        }
        return response;
    }
@ -172,4 +176,34 @@ public class ManageSynergyService extends BaseService {
        }
        throw new Exception("请求客服系统服务失败!");
    }
    /**
     *
     * @param workorderCode
     * @return
     * @throws Exception
     */
    public String selectByWorkorderCode(String workorderCode,Integer page,Integer size) throws Exception{
        String response = null;
        Map<String, String> params = new HashMap<>();
        params.put("workorderCode",workorderCode);
        params.put("page",page.toString());
        params.put("size",size.toString());
        String url = customerUrl + "/synergy/doctor/selectByWorkorderCode";
        com.alibaba.fastjson.JSONObject object = null;
        try {
            response = httpClientUtil.httpPost(url,params);
            object = JSON.parseObject(response);
            com.alibaba.fastjson.JSONObject jsonObject1 = object.getJSONObject("data");
            JSONArray array = jsonObject1.getJSONArray("detailModelList");
            for (int i=0;i<array.size();i++){
                com.alibaba.fastjson.JSONObject jsonObject = array.getJSONObject(i);
                jsonObject.put("age", IdCardUtil.getAgeForIdcard(jsonObject.getString("idcard")));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return object.toString();
    }
}

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

@ -0,0 +1,182 @@
package com.yihu.wlyy.service.synergy;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.followup.Followup;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.followup.FollowUpDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.http.HttpResponse;
import com.yihu.wlyy.util.http.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
 * Created by humingfen on 2018/10/9.
 */
@Service
@Transactional
public class SynergyManageService extends BaseService {
    @Value("${customerService.url}")
    private String customerUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private FollowUpDao followUpDao;
    @Autowired
    private HospitalDao hospitalDao;
    public JSONObject getWorkOrderInfo(String workorderCode, String patient, Integer role) throws Exception {
        Map<String, Object> param = new HashedMap();
        param.put("workorderCode", workorderCode);
        param.put("patient", patient);
        param.put("role", role);
        HttpResponse response = null;
        response = HttpUtils.doPost(customerUrl + "synergy/customer/getWorkOrderInfo", param);
        JSONObject rs = new JSONObject(response.getContent());
        return rs;
    }
    public String createWorkorder(String doctor, Set<String> patientSet, Integer type, String objectId, String serviceDate, Integer priority, String remark, String followupClass, String followupType) throws Exception {
        String response = null;
        JSONArray array = new JSONArray();
        String patientCode1 = null;
        Doctor doctor1 = doctorDao.findByCode(doctor);
        StringBuffer buffer = new StringBuffer();
        for (String patientCode:patientSet){
            if (patientSet.size() == 1){
                patientCode1 = patientCode;
            }
            Patient patient = patientDao.findByCode(patientCode);
            com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
            object.put("servicePatientCode",patient.getCode());
            object.put("servicePatientName",patient.getName());
            buffer.append(patient.getName()+",");
            object.put("ssc",patient.getSsc());
            object.put("idcard",patient.getIdcard());
            object.put("mobile",patient.getMobile());
            object.put("hospital",doctor1.getHospital());
            object.put("hospitalName",doctor1.getHospitalName());
            Hospital hospital = hospitalDao.findByCode(doctor1.getHospital());
            object.put("town", hospital.getTown());
            object.put("townName",hospital.getTownName());
            array.add(object);
        }
        buffer.deleteCharAt(buffer.length()-1);
        com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
        object.put("type",type);
        object.put("serviceTime",serviceDate);
        object.put("priority",priority);
        object.put("createUser",doctor1.getCode());
        object.put("createUserName",doctor1.getName());
        object.put("hospital",doctor1.getHospital());
        object.put("hospitalName",doctor1.getHospitalName());
        object.put("createUserType",1);
        object.put("remark",remark);
        object.put("servicerCount",patientSet.size());
        object.put("servicerKey",buffer);
        if (type == 3){
            Followup followup = new Followup();
            followup.setDoctorCode(doctor1.getCode());
            followup.setDoctorName(doctor1.getName());
            if (patientCode1 != null){
                Patient patient1 = patientDao.findByCode(patientCode1);
                followup.setPatientCode(patient1.getCode());
                followup.setPatientName(patient1.getName());
                followup.setIdcard(patient1.getIdcard());
                SignFamily signFamily = signFamilyDao.findByPatient(patientCode1);
                followup.setAdminTeamCode(signFamily.getAdminTeamId());
                followup.setSignType(Integer.parseInt(signFamily.getSignType()));
                followup.setSignCode(signFamily.getCode());
            }
            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            followup.setFollowupDate(dateFormat.parse(serviceDate+":00"));
            followup.setFollowupType(followupType);
            followup.setFollowupClass(followupClass);
            followup.setOrgCode(doctor1.getHospital());
            followup.setOrgName(doctor1.getHospitalName());
            followup.setDataFrom("2");
            followup.setStatus("2");
            followup.setCreater(doctor1.getCode());
            followup.setCreateTime(new Date());
            followup = followUpDao.save(followup);
            object.put("relationCode",followup.getId());
            object.put("relationCodeName","随访");
        }else if (type == 1){
            object.put("relationCode",objectId);
            object.put("relationCodeName","健康教育");
        }else if (type == 5){
            object.put("relationCode",objectId);
            object.put("relationCodeName","疾病筛查");
        }
        String url = customerUrl + "synergy/doctor/createWorkorder";
        Map<String, String> params = new HashMap<>();
        params.put("servicers",array.toJSONString());
        params.put("workorder",object.toJSONString());
        response = httpClientUtil.httpPost(url,params);
        com.alibaba.fastjson.JSONObject object1 = JSON.parseObject(response);
        if (object1.getInteger("status")==200){
            return response;
        }else {
            throw new Exception("请求客服系统服务失败!");
        }
    }
    public JSONObject workorderList(String userCode,Integer workorderType,Integer status,String serviceStartTime,String serviceEndTime,Integer isAcceptTask,Integer page,Integer pageSize) throws Exception{
        Map<String, Object> param = new HashedMap();
        param.put("userCode",userCode);
        param.put("workorderType",workorderType);
        param.put("status",status);
        param.put("serviceStartTime",serviceStartTime);
        param.put("serviceEndTime",serviceEndTime);
        param.put("isAcceptTask",isAcceptTask);
        param.put("page",page);
        param.put("pageSize",pageSize);
        HttpResponse response = HttpUtils.doGet(customerUrl + "/doctor/synergy/workorderList", param);
        JSONObject result = new JSONObject(response.getContent());
        if(result.getInt("status")==200){
            JSONObject json = result.getJSONObject("data");
            return json;
        }
        throw new Exception("请求客服系统服务失败!");
    }
    public void reminder(String userCode,String workorderCode) throws Exception{
        Map<String, Object> param = new HashedMap();
        param.put("userCode",userCode);
        param.put("workorderCode",workorderCode);
        HttpResponse response = HttpUtils.doPost(customerUrl + "/synergy/doctor/reminder", param);
        JSONObject result = new JSONObject(response.getContent());
        if(result.getInt("status")!=200){
            throw new Exception("请求客服系统服务失败!");
        }
    }
}

+ 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";
		List<NameValuePair> params = new ArrayList<>();
		params.add(new BasicNameValuePair("barCode", barcode));
		
		String response = httpClientUtil.post(url, params, "UTF-8");
		
		return response;

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/imm/DoctorImmController.java

@ -215,7 +215,7 @@ public class DoctorImmController extends BaseController {
				JSONObject json = new JSONObject(jsonObject.getString("data"));
				return write(200, "查询成功","data",json.getJSONArray("body"));
			}else {
				return error(-1,jsonObject.getString("error")+"--"+jsonObject.getString("message") );
				return error(-1,jsonObject.getString("msg") );
			}
		}catch (Exception e){
			error(e);

+ 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)
    @ApiOperation(value = "创建协同服务")
    public String createWorkOrder(@ApiParam(name = "jsonData",value = "协同服务json字符串")
@ -626,7 +603,7 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
                                      @RequestParam(value = "currentUserRoleLevel", required = false) String currentUserRoleLevel) {
        try {
            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) {
            e.printStackTrace();
            return write(-1, "查询失败!");

+ 35 - 12
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/synergy/SynergyManageController.java

@ -1,10 +1,9 @@
package com.yihu.wlyy.web.doctor.synergy;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.service.jimeiJkEdu.JMJkEduArticleService;
import com.yihu.wlyy.service.synergy.ManageSynergyService;
import com.yihu.wlyy.service.synergy.SynergyManageService;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.third.gateway.vo.base.BaseResultModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -31,6 +30,8 @@ public class SynergyManageController extends BaseController {
    @Autowired
    private ManageSynergyService manageSynergyService;
    @Autowired
    private SynergyManageService synergyManageService;
    @Autowired
    private JMJkEduArticleService jmJkEduArticleService;
    @RequestMapping(value = "/getWorkOrderInfo", method = {RequestMethod.GET, RequestMethod.POST})
@ -50,11 +51,10 @@ public class SynergyManageController extends BaseController {
    }
    @RequestMapping(value = "doctorCreateSynergy", method = RequestMethod.POST)
    @ApiOperation("医生创建系统服务")
    @ObserverRequired
    public BaseResultModel doctorSendArticleToPatients(
    @ApiOperation("医生派发协同服务")
    public String doctorSendArticleToPatients(
            @RequestParam(value = "patient", required = false) String patient,
            @RequestParam(value = "group", required = false, defaultValue = "") String group,
            @RequestParam(value = "group", required = false) String group,
            @RequestParam(value = "labelType", required = false) String labelType,
            @RequestParam(value = "teamCode", required = false) Long teamCode,
            @RequestParam(value = "objectId", required = false) String objectId,
@ -69,7 +69,7 @@ public class SynergyManageController extends BaseController {
            String[] patients = new String[]{};
            String[] groups = new String[]{};
            if (StringUtils.isEmpty(patient) && StringUtils.isEmpty(group)) {
                return new BaseResultModel("请至少选择一个患者!");
                return  write(200,"请至少选择一个患者!");
            }else{
                if(StringUtils.isNotBlank(patient)){
                    if(patient.contains(",")){
@ -87,19 +87,19 @@ public class SynergyManageController extends BaseController {
                }
            }
            if (patients.length == 0 && groups.length == 0) {
                return new BaseResultModel("请至少选择一个患者!");
                return  write(200,"请至少选择一个患者!");
            }
            Set<String> patientSet = new HashSet<>(); //放入set中可以去重复
            jmJkEduArticleService.initPatients(getUID(),groups, group,labelType,teamCode,patients,patientSet);
//            jmJkEduArticleService.initPatient(getUID(),groups,group,labelType,teamCode,patients,patientSet);
            if (patientSet.size() == 0) {
                return new BaseResultModel("请至少选择一个患者!");
                return  write(200,"请至少选择一个患者!");
            }
            manageSynergyService.createWorkorder(getUID(),patientSet,type,objectId,serviceDate,priority,remark,followupClass,followupType);
            return new BaseResultModel();
            synergyManageService.createWorkorder(getUID(),patientSet,type,objectId,serviceDate,priority,remark,followupClass,followupType);
            return  write(200,"请求成功");
        } catch (Exception e) {
            error(e);
            return new BaseResultModel(BaseResultModel.statusEm.opera_error.getCode(), BaseResultModel.statusEm.opera_error.getMessage() + ":" + e.getMessage());
            return error(-1,"保存失败");
        }
    }
@ -152,4 +152,27 @@ public class SynergyManageController extends BaseController {
            return error(-1, "请求失败");
        }
    }
    /**
     * 居民列表
     *
     * @param workorderCode
     * @return
     */
    @RequestMapping(value = "selectByWorkorderCode", method = RequestMethod.POST)
    @ApiOperation("医生端-居民列表")
    public String selectByWorkorderCode(@ApiParam(name = "workorderCode", value = "工单code", required = false)
                                        @RequestParam(value = "workorderCode", required = false)String workorderCode,
                                        @ApiParam(name = "page", value = "页码", defaultValue = "1")
                                        @RequestParam(value = "page", required = false)Integer page,
                                        @ApiParam(name = "size", value = "每页大小", defaultValue = "10")
                                            @RequestParam(value = "size", required = false)Integer size){
        try {
            return write(200, "请求成功","data",manageSynergyService.selectByWorkorderCode(workorderCode,page,size));
        }catch (Exception e){
            error(e);
            return error(-1, "请求失败");
        }
    }
}

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

@ -5,29 +5,32 @@ package com.yihu.wlyy.web.third.synergy;/**
import com.alibaba.fastjson.JSONArray;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.service.app.followup.FollowUpService;
import com.yihu.wlyy.service.app.survey.SurveyScreenResultService;
import com.yihu.wlyy.service.survey.ManagerQuestionnaireService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
/**
 * @author wangzhinan
 * @create 2018-10-08 13:56
 * @desc 协同管理
 **/
@Controller
@RequestMapping(value = "/followup", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RestController
@RequestMapping(value = "/third/synergy", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "协同管理接口")
public class SynergyManagerController extends BaseController{
    @Autowired
    private FollowUpService followUpService;
    @Autowired
    private ManagerQuestionnaireService managerQuestionnaireService;
    @Autowired
    private SurveyScreenResultService surveyScreenResultService;
    @ApiOperation("新增临时随访记录(返回ID)")
    @RequestMapping(value = "/addFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
@ -84,4 +87,112 @@ public class SynergyManagerController extends BaseController{
        }
    }
  /*  @RequestMapping(value = "/findDictByName", method = RequestMethod.GET)
    @ApiOperation(value = "药品列表")
    public String findDictByName(@ApiParam(name = "name", value = "药品名称(中文或拼音首字母查询)", defaultValue = "胰岛素")
                                 @RequestParam(value = "name", required = false) String name,
                                 @ApiParam(name = "isinsulin", value = "是否过滤胰岛素:1非胰岛素,2胰岛素", defaultValue = "")
                                 @RequestParam(value = "isinsulin", required = false) String isinsulin) {
        try {
//            return write(200, "操作成功!", "data",zyDictService.findDictByDoctorAndName("e3b3bfb3644011e69616fa163e424525",name,isinsulin));
            return write(200, "操作成功!", "data",zyDictService.findDictByDoctorAndName(getUID(), name,isinsulin));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }*/
    @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 = "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, customerCode, isAgain, source, json));
            }else {
                return write(200, "保存成功!", "data", managerQuestionnaireService.saveQuestionResultAndAnswer(json, patientCode, customerCode));
            }
        } 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, "获取失败!");
        }
    }
}