Explorar el Código

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/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/synergy/SynergyManageService.java
wangzhinan hace 6 años
padre
commit
3709edf9b8

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

@ -98,22 +98,13 @@ public class CustomerSynergyManageController extends BaseController {
    }
    @RequestMapping(value = "/unitLabels", method = RequestMethod.GET)
    @ApiOperation("获取所属社区")
    public String unitLabels(@ApiParam(name = "currentRoleCode", value = "选择的区县", required = false)
                             @RequestParam(value = "currentRoleCode", required = false) String currentRoleCode) {
    @ApiOperation("根据地区查找卫计委下属单位标签")
    public String unitLabels(@ApiParam(name = "currentRoleCode", value = "地点对应的code")
                             @RequestParam(value = "currentRoleCode", required = true) String currentRoleCode,
                             @ApiParam(name = "currentRoleLevel", value = "1省2城市3区县", required = false)
                             @RequestParam(value = "currentRoleLevel", required = true) String currentRoleLevel) {
        try {
            return write(200,"获取成功", "data", synergyManageService.getUnitLabels(currentRoleCode));
        } catch (Exception e) {
            error(e);
            return error(-1,"获取失败");
        }
    }
    @RequestMapping(value = "/towns", method = RequestMethod.GET)
    @ApiOperation("获取所属区县")
    public String towns() {
        try {
            return write(200,"获取成功", "data", synergyManageService.getTowns());
            return write(200,"获取成功", "data", synergyManageService.getUnitLabels(currentRoleCode, currentRoleLevel));
        } catch (Exception e) {
            error(e);
            return error(-1,"获取失败");
@ -134,7 +125,7 @@ public class CustomerSynergyManageController extends BaseController {
                                @RequestParam(value = "status", required = false)Integer status,
                                @ApiParam(name = "priority", value = "工单优先级(0、普通,1、加急)", required = false)
                                @RequestParam(value = "priority", required = false)Integer priority,
                                @ApiParam(name = "timeout", value = "是否超时1、超时,null全部", required = false)
                                @ApiParam(name = "timeout", value = "是否超时1、超时,2、否超时,null全部", required = false)
                                @RequestParam(value = "timeout", required = false)Integer timeout,
                                @ApiParam(name = "workorderCode", value = "服务编号", required = false)
                                @RequestParam(value = "workorderCode", required = false)String workorderCode,
@ -154,6 +145,10 @@ public class CustomerSynergyManageController extends BaseController {
                                @RequestParam(value = "userType", required = true)Integer userType,
                                @ApiParam(name = "isAcceptTask", value = "1、我接收到的任务,2、我派发的任务,3、待接收(客服管理员),4、已接收(客服管理员)", required = true)
                                @RequestParam(value = "isAcceptTask", required = true)Integer isAcceptTask,
                                @ApiParam(name = "userName", value = "需求方", required = false)
                                @RequestParam(value = "userName", required = false)String userName,
                                @ApiParam(name = "hospitalName", value = "所属机构", required = false)
                                @RequestParam(value = "hospitalName", required = false)String hospitalName,
                                @ApiParam(name = "page", value = "第几页,从1开始", required = true)
                                @RequestParam(value = "page", required = true,defaultValue = "1")Integer page,
                                @ApiParam(name = "pageSize", value = "每页分页大小", required = true)
@ -163,7 +158,7 @@ public class CustomerSynergyManageController extends BaseController {
                userCode = getUID();
            }
            Map<String,Object> result = synergyManageService.workorderList(userCode,keywords,workorderType,isMyTask,status,priority,timeout,workorderCode,
                    principal,serviceStartTime,serviceEndTime,patientName,ssc,idcard,userType,isAcceptTask,page,pageSize);
                    principal,serviceStartTime,serviceEndTime,patientName,ssc,idcard,userType,isAcceptTask,userName,hospitalName,page,pageSize);
            return write(200, "获取成功", "data", result);
        } catch (Exception e) {
            error(e);
@ -251,8 +246,8 @@ public class CustomerSynergyManageController extends BaseController {
    @RequestMapping(value = "saveCallLabel",method = RequestMethod.POST)
    @ApiOperation(value = "保存所有通话标签")
    public String saveCallLabel(@ApiParam(name="callCode",value="通话记录code")@RequestParam(required = false)String callCode,
                                @ApiParam(name="callLabels",value="通话标签,多个用逗号隔开")@RequestParam(required = false)String callLabels){
    public String saveCallLabel(@ApiParam(name="callCode",value="通话记录code")@RequestParam(value = "callCode")String callCode,
                                @ApiParam(name="callLabels",value="通话标签,多个用逗号隔开")@RequestParam(value = "callLabels",required = false)String callLabels){
        try{
            String sql ="UPDATE manage_call_record SET call_label='"+callLabels+"' WHERE `code`='"+callCode+"'";
            jdbcTemplate.update(sql);
@ -265,7 +260,7 @@ public class CustomerSynergyManageController extends BaseController {
    @RequestMapping(value = "getCallInfo",method = RequestMethod.GET)
    @ApiOperation(value = "获取通话的详情")
    public String getCallTypeAndContent(@ApiParam(name="callCode",value="通话记录code")@RequestParam(required = false)String callCode){
    public String getCallTypeAndContent(@ApiParam(name="callCode",value="通话记录code")@RequestParam(value ="callCode")String callCode){
        try{
            CallRecord callRecord = callRecordDao.findByCode(callCode);
            return write(200,"查询成功!","data",callCode);
@ -276,10 +271,10 @@ public class CustomerSynergyManageController extends BaseController {
    }
    @RequestMapping(value = "saveCallInfo",method = RequestMethod.POST)
    @ApiOperation(value = "显示所有通话标签")
    public String saveCallInfo(@ApiParam(name="callCode",value="通话记录code")@RequestParam(required = false)String callCode,
                                @ApiParam(name="serviceType",value="服务类型,多个用逗号隔开")@RequestParam(required = false)String serviceType,
                               @ApiParam(name="serviceContent",value="服务记录")@RequestParam(required = false)String serviceContent){
    @ApiOperation(value = "保存通话记录详情")
    public String saveCallInfo(@ApiParam(name="callCode",value="通话记录code")@RequestParam(value ="callCode")String callCode,
                                @ApiParam(name="serviceType",value="服务类型,多个用逗号隔开")@RequestParam(value = "serviceType",required = false)String serviceType,
                               @ApiParam(name="serviceContent",value="服务记录")@RequestParam(value = "serviceContent",required = false)String serviceContent){
        try{
            String sql ="UPDATE manage_call_record SET service_type='"+serviceType+"',service_content='"+serviceContent+"' WHERE `code`='"+callCode+"'";
            jdbcTemplate.update(sql);
@ -322,5 +317,17 @@ public class CustomerSynergyManageController extends BaseController {
        }
    }
    @RequestMapping(value = "getDealList",method = RequestMethod.GET)
    @ApiOperation(value = "通话详情获取待办事项")
    public String getDealList(@ApiParam(name="idcard",value="居民身份证")@RequestParam(value ="idcard")String idcard){
        try{
            return write(200,"获取成功!","data",synergyManageService.getDealList(idcard));
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
}

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

@ -58,7 +58,7 @@ public class DoctorSynergyManageController extends BaseController {
                userCode = getUID();
            }
            Map<String,Object> result = synergyManageService.workorderList(userCode,null,workorderType,null,status,null,null,null,
                    null,serviceStartTime,serviceEndTime,null,null,null,1,isAcceptTask,page,pageSize);
                    null,serviceStartTime,serviceEndTime,null,null,null,1,isAcceptTask,null,null,page,pageSize);
            return write(200, "获取成功", "data", result);
        } catch (Exception e) {
            error(e);
@ -75,8 +75,8 @@ public class DoctorSynergyManageController extends BaseController {
            if(!StringUtils.isNotEmpty(userCode)){
                userCode = getUID();
            }
            synergyManageService.reminder(workorderCode,userCode,1);
            return write(200, "请求成功");
            Integer reminderStatus = synergyManageService.reminder(workorderCode,userCode,1);
            return write(200, "请求成功","data",reminderStatus);
        }catch (Exception e){
            error(e);
            return error(-1, "请求失败");

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

@ -13,4 +13,5 @@ import java.util.List;
public interface ManageSynergyWorkorderReminderDao extends PagingAndSortingRepository<ManageSynergyWorkordeReminderDO, Long> {
    List<ManageSynergyWorkordeReminderDO> findByPrincipalCodeAndDealWith(String principalCode,Integer dealWith);
    List<ManageSynergyWorkordeReminderDO> findByWorkorderCode(String workorderCode);
}

+ 80 - 6
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/account/CustomerService.java

@ -3,9 +3,11 @@ package com.yihu.wlyy.service.manager.account;
import com.yihu.wlyy.entity.*;
import com.yihu.wlyy.entity.call.CallRecord;
import com.yihu.wlyy.entity.call.CallService;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerDO;
import com.yihu.wlyy.repository.*;
import com.yihu.wlyy.repository.call.CallRecordDao;
import com.yihu.wlyy.repository.call.CallServiceDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkorderServicerDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.manager.family.FamilyMemberService;
import com.yihu.wlyy.service.manager.hos.HosDoctorService;
@ -92,9 +94,11 @@ public class CustomerService extends BaseService{
				doctors.add(doctor);
			}
		}
		String labelSql="SELECT  DISTINCT CASE call_label WHEN '1' THEN '有待跟踪' WHEN '2' THEN '电话骚扰' WHEN '3' THEN '态度恶劣' END FROM manage_call_record mcr WHERE (caller_number='"+patient.getPhone()+"' OR caller_number='"+patient.getMobile()+"') AND type=1 AND call_label IS NOT NULL";
		List<Map<String,Object>> labelInfo = jdbcTemplate.queryForList(labelSql);
		resp.put("signInfo",signInfo);
		resp.put("doctors",doctors);
		resp.put("labelInfo",labelInfo);
		return resp;
	}
@ -167,7 +171,7 @@ public class CustomerService extends BaseService{
		//发送短信消息啦
		String mobile = doctor.getMobile();
		if(!StringUtils.isBlank(mobile)&&!"2".equals(type)){
			msg+="\n您可通过微信关注\"i健康智能助手\"公众号更快更便捷的获取服务信息。";
			msg+=" 您可通过微信关注\"i健康智能助手\"公众号更快更便捷的获取服务信息。";
			List<NameValuePair> par = new ArrayList<NameValuePair>();
			par.add(new BasicNameValuePair("mobiles", mobile));
			par.add(new BasicNameValuePair("content", msg));
@ -387,13 +391,83 @@ public class CustomerService extends BaseService{
	public Map<String,Object> getCallRecordInfo(String code){
		CallRecord callRecord = callRecordDao.findByCode(code);
		List<CallService> consultService = callServiceDao.findByCallCodeAndType(code,0);
		List<CallService> orderService = callServiceDao.findByCallCodeAndType(code,1);
		/*List<CallService> consultService = callServiceDao.findByCallCodeAndType(code,0);
		List<CallService> orderService = callServiceDao.findByCallCodeAndType(code,1);*/
		String type="";
		String relationCode="";
		String sql="";
		List<Map<String,Object>> resultList = new ArrayList<>();
		//咨询
		if ("0".equals(type)){
			sql="SELECT " +
				" a.code as workCode," +
				" a.content, " +
				" a.`status`, " +
				" a.service_patient_name, " +
				" c.deal_type, " +
				" c.deal_content, " +
				" a.remark " +
				" FROM " +
				" manage_synergy_workorder_reserve_consult c " +
				" INNER JOIN ( " +
				" SELECT " +
				"  w.*, s.service_patient_name " +
				"  FROM " +
				"  manage_synergy_workorder w " +
				"  LEFT JOIN manage_synergy_workorder_servicer s ON w.`code` = s.workorder_code " +
				" ) a " +
				" WHERE " +
				" call_code = '"+code+"'";
			resultList = jdbcTemplate.queryForList(sql);
		}
		//健康教育
		if ("1".equals(type)){
		}
		//预约
		if ("2".equals(type)){
			sql="SELECT" +
					" a. CODE AS workCode," +
					" a.`status`," +
					" a.service_patient_name," +
					" c.order_hospital_name," +
					" c.order_dept_name," +
					" c.order_time" +
					"FROM" +
					" manage_synergy_workorder_reserve_consult c" +
					"INNER JOIN (" +
					" SELECT" +
					"  w.*, s.service_patient_name" +
					" FROM" +
					"  manage_synergy_workorder w" +
					" LEFT JOIN manage_synergy_workorder_servicer s ON w.`code` = s.workorder_code" +
					") a" +
					"WHERE" +
					" call_code = '"+code+"'";
			resultList = jdbcTemplate.queryForList(sql);
		}
		//随访
		if ("3".equals(type)){
		}
		//问卷调查
		if ("4".equals(type)){
		}
		//疾病筛查
		if ("5".equals(type)){
			sql="SELECT * FROM `wlyy_survey_screen_result` WHERE `code`='"+relationCode+"'";
			resultList = jdbcTemplate.queryForList(sql);
		}
		List<PatientReservation> patientReservation = patientReservationDao.findByCallCode(code);
		Map<String,Object> rs = new HashedMap();
		rs.put("callRecord",callRecord);
		rs.put("consultService",consultService);
		rs.put("orderService",orderService);
		/*rs.put("consultService",consultService);
		rs.put("orderService",orderService);*/
		rs.put("patientReservation",patientReservation);
		return rs;
	}

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

@ -11,6 +11,8 @@ import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.util.query.BaseJpaService;
import jxl.Workbook;
import jxl.write.*;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -19,6 +21,8 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.*;
@ -92,8 +96,8 @@ public class SynergyManageService extends BaseJpaService {
     */
    public Map<String,Object> workorderList(String code,String keywords,Integer workorderType,
                               Integer isMyTask,Integer status,Integer priority,Integer timeout,String workorderCode,
                               String principal,String serviceStartTime,String serviceEndTime,
                               String patientName,String ssc,String idcard,Integer userType,Integer isAcceptTask,Integer page, Integer pageSize) throws Exception{
                               String principal,String serviceStartTime,String serviceEndTime,String patientName,String ssc,String idcard,
                               Integer userType,Integer isAcceptTask,String userName,String hospitalName,Integer page, Integer pageSize) throws Exception{
        String servicerTable = " left join wlyy.manage_synergy_workorder_executor e on e.workorder_code=w.code AND e.del = 1  " ;
        String whereSql = "";
@ -111,7 +115,7 @@ public class SynergyManageService extends BaseJpaService {
                whereSql += " and e.executor_code ='"+code+"' ";
            }else if(isAcceptTask==2){//我派发
                whereSql +=" and w.create_user_type=2 ";//创建人为客服
                whereSql += " and e.create_user ='"+code+"' ";
                whereSql += " and w.create_user ='"+code+"' ";
            }
        }else if(userType==3){//医生
            if(isAcceptTask==1){//我接收
@ -148,7 +152,11 @@ public class SynergyManageService extends BaseJpaService {
        }
        //是否超时
        if(timeout!=null){
            whereSql +=" and w.service_time >'"+DateUtil.dateToStrLong(new Date())+"' ";
            if(timeout==1){
                whereSql +=" and w.service_time >'"+DateUtil.dateToStrLong(new Date())+"' ";
            }else if(timeout==2){
                whereSql +=" and w.service_time <='"+DateUtil.dateToStrLong(new Date())+"' ";
            }
        }
        //服务编码
        if(StringUtils.isNotEmpty(workorderCode)){
@ -167,15 +175,22 @@ public class SynergyManageService extends BaseJpaService {
        }
        //服务对象
        if(StringUtils.isNotEmpty(patientName)){
            whereSql+=" s.service_patient_name like '%"+keywords+"%' ";
            whereSql+=" and s.service_patient_name like '%"+keywords+"%' ";
        }
        //社保卡号
        if(StringUtils.isNotEmpty(ssc)){
            whereSql+=" s.ssc like '%"+keywords+"%' ";
            whereSql+=" and s.ssc like '%"+keywords+"%' ";
        }
        //身份证号
        if(StringUtils.isNotEmpty(idcard)){
            whereSql+=" s.idcard like '%"+keywords+"%' ";
            whereSql+=" and s.idcard like '%"+keywords+"%' ";
        }
        //需求方
        if(StringUtils.isNotEmpty(userName)){
            whereSql+=" and w.create_user_name like '%"+userName+"%' ";
        }
        if(StringUtils.isNotEmpty(hospitalName)){
            whereSql+=" and w.hospital_name like '%"+hospitalName+"%' ";
        }
        String sql =" select DISTINCT w.* from wlyy.manage_synergy_workorder w  " +servicerTable+
@ -228,6 +243,8 @@ public class SynergyManageService extends BaseJpaService {
            map.put("managerName",managerName);//负责人的名称
            Integer finishedServicerCount = workorderServicerDao.findByWorkorderCodeCount(one.get("code")+"",3);
            map.put("finishedServicerCount",finishedServicerCount);//服务完成人数
            map.put("userName",one.get("create_user_name"));
            map.put("hospitalName",one.get("hospital_name"));
            resultList.add(map);
        }
        Map<String,Object> resultMap = new HashMap<>();
@ -479,6 +496,8 @@ public class SynergyManageService extends BaseJpaService {
            workorderDO.setReturnedRemark(jsonObject.getString("returnedRemark"));
            this.sendMessage(workorderDO, null, 26);
        }else if(status == 2){
            //设置接收时间
            workorderDO.setReceiverTime(new Date());
            //创建负责人信息
            List<ManageSynergyWorkorderExecutorDO> list = new ArrayList<>();
            String manager = jsonObject.getString("manager");
@ -498,17 +517,19 @@ public class SynergyManageService extends BaseJpaService {
            //保存协作者信息
            String collaborator = jsonObject.getString("collaborator");
            String[] collaborators = manager.split(",");
            for(String c : collaborators){
                ManageSynergyWorkorderExecutorDO executorDO = new ManageSynergyWorkorderExecutorDO();
                User u = userDao.findByCode(c);
                executorDO.setCode(getCode());
                executorDO.setWorkorderCode(code);
                executorDO.setExecutorType(1);
                executorDO.setExecutorCode(c);
                executorDO.setExecutorName(u.getName());
                executorDO.setDel(1);
                list.add(executorDO);
            if(StringUtils.isNotBlank(collaborator)) {
                String[] collaborators = collaborator.split(",");
                for (String c : collaborators) {
                    ManageSynergyWorkorderExecutorDO executorDO = new ManageSynergyWorkorderExecutorDO();
                    User u = userDao.findByCode(c);
                    executorDO.setCode(getCode());
                    executorDO.setWorkorderCode(code);
                    executorDO.setExecutorType(2);
                    executorDO.setExecutorCode(c);
                    executorDO.setExecutorName(u.getName());
                    executorDO.setDel(1);
                    list.add(executorDO);
                }
            }
            workorderExecutorDao.save(list);
        }
@ -656,8 +677,12 @@ public class SynergyManageService extends BaseJpaService {
     * @throws Exception
     */
    @Transactional
    public void reminder(String workorderCode,String userCode,Integer userType) throws Exception{
    public Integer reminder(String workorderCode,String userCode,Integer userType) throws Exception{
        Integer reminderStatus = reminderStatus(workorderCode);
        if(reminderStatus==3||reminderStatus==4){
            return reminderStatus;
        }
        ManageSynergyWorkorderDO manageSynergyWorkorderDO = workOrderDao.findByCode(workorderCode);
        if(manageSynergyWorkorderDO==null){
            throw new Exception();
@ -693,6 +718,40 @@ public class SynergyManageService extends BaseJpaService {
        workordeReminderDO.setDealWith(0);
        workordeReminderDO.setPriority(manageSynergyWorkorderDO.getPriority());
        manageSynergyWorkorderReminderDao.save(workordeReminderDO);
        return reminderStatus;
    }
    public Integer reminderStatus(String workorderCode) throws Exception{
        Integer reminderStatus=4;//默认是不满足催单条件
        ManageSynergyWorkorderDO workorderDO = workOrderDao.findByCode(workorderCode);
        //工单状态(0、草稿,1、未接受,2、处理中,3、处理完成,4、退回)
        //1、当单子超过1小时扔未被接收或退回时
        //2、当单子被接收后,如果距离服务时间小于4小时,则允许用户进行催单操作。
        //3、当已催促过客服时,再次催单
        //4、不满足催单条件时
        List<ManageSynergyWorkordeReminderDO> list = manageSynergyWorkorderReminderDao.findByWorkorderCode(workorderCode);
        if(workorderDO.getStatus()==1){
            if(list.size()>0){
                reminderStatus=3;
            }else{
                //单子超过1小时
                long h1= 60*60*1000L;
                if(new Date().getTime()-workorderDO.getCreateTime().getTime()>h1){
                    reminderStatus=1;
                }
            }
        }else if(workorderDO.getStatus()==2){
            if(list.size()>0){
                reminderStatus=3;
            }else{
                //距离服务时间小于4小时
                long h4= 4*60*60*1000L;
                if(workorderDO.getServiceTime().getTime()-new Date().getTime()<h4){
                    reminderStatus=2;
                }
            }
        }
        return reminderStatus;
    }
    /**
@ -840,108 +899,186 @@ public class SynergyManageService extends BaseJpaService {
        return  jsonObject;
    }
    public JSONObject getUnitLabels(String currentRoleCode) {
        String url = wlyyUrl + "/wlyygc/doctor/label/unitLabels?currentRoleCode=" + currentRoleCode + "&currentRoleLevel=3";
    public JSONObject getUnitLabels(String currentRoleCode, String currentRoleLevel) {
        String url = wlyyUrl + "/wlyygc/doctor/label/unitLabels?currentRoleCode=" + currentRoleCode + "&currentRoleLevel=" + currentRoleLevel;
        String response = httpClientUtil.get(url, "UTF-8");
        JSONObject jsonObject = new JSONObject(response);
        return  jsonObject;
    }
    public List<Town> getTowns() {
        return (List<Town>) townDao.findAll();
    }
    public void exportWorkorder(String code,String keywords,Integer workorderType,
                                Integer isMyTask,Integer status,Integer priority,Integer timeout,String workorderCode,
                                String principal,String serviceStartTime,String serviceEndTime,
                                String patientName,String ssc,String idcard,Integer userType,Integer isAcceptTask){
        String servicerTable = " left join wlyy.manage_synergy_workorder_executor e on e.workorder_code=w.code AND e.del = 1  " ;
        String whereSql = "";
        if(userType==3){//客服管理员
            whereSql +=" and w.create_user_type=1 ";//创建人为医生
            if(isAcceptTask==3){//待接收
                whereSql +=" and w.status =1 ";
                servicerTable ="";
            }else if(isAcceptTask==4){//已接收
                whereSql +=" and w.status in (2,3) ";
            }
        }else if(userType==2){//客服
            if(isAcceptTask==1){//我接收
                                String patientName,String ssc,String idcard,Integer userType,Integer isAcceptTask,HttpServletResponse response) throws Exception{
        WritableWorkbook wwb = null;
        try{
            String servicerTable = " left join wlyy.manage_synergy_workorder_executor e on e.workorder_code=w.code AND e.del = 1  " ;
            String whereSql = "";
            if(userType==3){//客服管理员
                whereSql +=" and w.create_user_type=1 ";//创建人为医生
                whereSql += " and e.executor_code ='"+code+"' ";
            }else if(isAcceptTask==2){//我派发
                whereSql +=" and w.create_user_type=2 ";//创建人为客服
                whereSql += " and e.create_user ='"+code+"' ";
                if(isAcceptTask==3){//待接收
                    whereSql +=" and w.status =1 ";
                    servicerTable ="";
                }else if(isAcceptTask==4){//已接收
                    whereSql +=" and w.status in (2,3) ";
                }
            }else if(userType==2){//客服
                if(isAcceptTask==1){//我接收
                    whereSql +=" and w.create_user_type=1 ";//创建人为医生
                    whereSql += " and e.executor_code ='"+code+"' ";
                }else if(isAcceptTask==2){//我派发
                    whereSql +=" and w.create_user_type=2 ";//创建人为客服
                    whereSql += " and e.create_user ='"+code+"' ";
                }
            }else if(userType==3){//医生
                if(isAcceptTask==1){//我接收
                    whereSql +=" and w.create_user_type=2 ";//创建人为客服
                    whereSql += " and e.executor_code ='"+code+"' ";
                }else if(isAcceptTask==2){//我派发
                    whereSql +=" and w.create_user_type=2 ";//创建人为医生
                    whereSql += " and e.create_user ='"+code+"' ";
                }
            }
        }else if(userType==3){//医生
            if(isAcceptTask==1){//我接收
                whereSql +=" and w.create_user_type=2 ";//创建人为客服
                whereSql += " and e.executor_code ='"+code+"' ";
            }else if(isAcceptTask==2){//我派发
                whereSql +=" and w.create_user_type=2 ";//创建人为医生
                whereSql += " and e.create_user ='"+code+"' ";
            //关键字查询
            if(StringUtils.isNotEmpty(keywords)){
                servicerTable +=" left join wlyy.manage_synergy_workorder_servicer s on s.workorder_code=w.code ";
                whereSql += " and w.servicer_count<=10  ";
                whereSql += " and (w.create_user_name like '%"+keywords+"%' or s.service_patient_name like '%"+keywords+"%' " +
                        " or s.ssc like '%"+keywords+"%' or s.idcard like '%"+keywords+"%' ) ";
            }
        }
            //服务类型
            if(workorderType!=null){
                whereSql += " and w.type ="+workorderType+" ";
            }
            //是否是我负责的
            if(isMyTask!=null){
                whereSql += " and e.executor_code ='"+code+"' and e.executor_type=1 ";
            }
            //工单状态
            if(status!=null){
                whereSql +=" and w.status ="+status+" ";
            }
            //优先级
            if(priority!=null){
                whereSql+= " and w.priority="+priority+" ";
            }
            //是否超时
            if(timeout!=null){
                whereSql +=" and w.service_time >'"+DateUtil.dateToStrLong(new Date())+"' ";
            }
            //服务编码
            if(StringUtils.isNotEmpty(workorderCode)){
                whereSql+=" and w.code like '%"+workorderCode+"%' ";
            }
            //负责人
            if(StringUtils.isNotEmpty(principal)){
                whereSql+=" and e.code like '%"+principal+"%' and e.executor_type=1 ";
            }
            //服务时间
            if(StringUtils.isNotEmpty(serviceStartTime)){
                whereSql+=" and w.service_time>='"+serviceStartTime+"' ";
            }
            if(StringUtils.isNotEmpty(serviceEndTime)){
                whereSql+=" and w.service_time<='"+serviceEndTime+"' ";
            }
            //服务对象
            if(StringUtils.isNotEmpty(patientName)){
                whereSql+=" s.service_patient_name like '%"+keywords+"%' ";
            }
            //社保卡号
            if(StringUtils.isNotEmpty(ssc)){
                whereSql+=" s.ssc like '%"+keywords+"%' ";
            }
            //身份证号
            if(StringUtils.isNotEmpty(idcard)){
                whereSql+=" s.idcard like '%"+keywords+"%' ";
            }
            String sql =" select DISTINCT w.* from wlyy.manage_synergy_workorder w  " +servicerTable+
        //关键字查询
        if(StringUtils.isNotEmpty(keywords)){
            servicerTable +=" left join wlyy.manage_synergy_workorder_servicer s on s.workorder_code=w.code ";
            whereSql += " and w.servicer_count<=10  ";
            whereSql += " and (w.create_user_name like '%"+keywords+"%' or s.service_patient_name like '%"+keywords+"%' " +
                    " or s.ssc like '%"+keywords+"%' or s.idcard like '%"+keywords+"%' ) ";
        }
        //服务类型
        if(workorderType!=null){
            whereSql += " and w.type ="+workorderType+" ";
        }
        //是否是我负责的
        if(isMyTask!=null){
            whereSql += " and e.executor_code ='"+code+"' and e.executor_type=1 ";
        }
        //工单状态
        if(status!=null){
            whereSql +=" and w.status ="+status+" ";
        }
        //优先级
        if(priority!=null){
            whereSql+= " and w.priority="+priority+" ";
        }
        //是否超时
        if(timeout!=null){
            whereSql +=" and w.service_time >'"+DateUtil.dateToStrLong(new Date())+"' ";
        }
        //服务编码
        if(StringUtils.isNotEmpty(workorderCode)){
            whereSql+=" and w.code like '%"+workorderCode+"%' ";
        }
        //负责人
        if(StringUtils.isNotEmpty(principal)){
            whereSql+=" and e.code like '%"+principal+"%' and e.executor_type=1 ";
        }
        //服务时间
        if(StringUtils.isNotEmpty(serviceStartTime)){
            whereSql+=" and w.service_time>='"+serviceStartTime+"' ";
        }
        if(StringUtils.isNotEmpty(serviceEndTime)){
            whereSql+=" and w.service_time<='"+serviceEndTime+"' ";
        }
        //服务对象
        if(StringUtils.isNotEmpty(patientName)){
            whereSql+=" s.service_patient_name like '%"+keywords+"%' ";
        }
        //社保卡号
        if(StringUtils.isNotEmpty(ssc)){
            whereSql+=" s.ssc like '%"+keywords+"%' ";
                    " where w.del=1  " +
                    " and 1=1 "+whereSql+ " order by w.priority desc,w.service_time desc";
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
            //生成excel
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename="+ new String( "patientHealthIndexDataList.xls"));
            OutputStream os = response.getOutputStream();
            wwb = Workbook.createWorkbook(os);
            WritableSheet ws = Workbook.createWorkbook(os).createSheet("sheet",1);
            String[] header = {"SN码","创建日期","身份证号","姓名","数据类型","value1","value2","value3","value4","value5","value6","value7"};
            int i = 0;
            for (String h : header) {
                Label label = new Label(0, i, h);
                ws.addCell(label);
                i++;
            }
            for(Map<String,Object> one:list){
//                addCell(ws, i, 0, m.getDeviceSn(),"");
//                addCell(ws, i, 1, format.format(m.getCzrq()),"");
//                addCell(ws, i, 2, m.getIdcard(),"");
//                addCell(ws, i, 3, m.getUserName(),"");
//                addCell(ws, i, 4, type,"");
//                addCell(ws, i, 5, m.getValue1(),"");
//                addCell(ws, i, 6, m.getValue2(),"");
//                addCell(ws, i, 7, m.getValue3(),"");
//                addCell(ws, i, 8, m.getValue4(),"");
//                addCell(ws, i, 9, m.getValue5(),"");
//                addCell(ws, i, 10, m.getValue6(),"");
//                addCell(ws, i, 11, m.getValue7(),"");
                i++;
            }
            wwb.write();
            wwb.close();
        }catch (Exception e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
            throw e;
        }
        //身份证号
        if(StringUtils.isNotEmpty(idcard)){
            whereSql+=" s.idcard like '%"+keywords+"%' ";
    }
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column, String data, String memo) throws WriteException {
        Label label = new Label(column ,row, data);
        if(!org.springframework.util.StringUtils.isEmpty(memo)){
            WritableCellFeatures cellFeatures = new WritableCellFeatures();
            cellFeatures.setComment(memo);
            label.setCellFeatures(cellFeatures);
        }
        String sql =" select DISTINCT w.* from wlyy.manage_synergy_workorder w  " +servicerTable+
        ws.addCell(label);
    }
                " where w.del=1  " +
                " and 1=1 "+whereSql+ " order by w.priority desc,w.service_time desc";
    public List<Map<String,Object>> getDealList(String idcard){
        Patient patient = patientDao.findByIdcard(idcard);
        if (patient==null){
            return null;
        }
        String sql ="SELECT" +
                " s.create_time," +
                " s.service_patient_name," +
                " w.priority," +
                " w.relation_code," +
                " w.relation_code_name," +
                " w.create_user_type," +
                " w.create_user_name," +
                " w.create_user," +
                " w.remark," +
                " w.service_time" +
                " FROM" +
                " `manage_synergy_workorder_servicer` s" +
                " LEFT JOIN manage_synergy_workorder w ON s.workorder_code = w.`code`" +
                " WHERE" +
                " s.service_patient_code = '"+patient.getCode()+"'" +
                " AND s.`status` = 1" +
                " ORDER BY" +
                " s.create_time" +
                " LIMIT 2";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> map : list){
            int isOver = isServiceOverTime(DateUtil.strToDate(String.valueOf(map.get("service_time")),DateUtil.YYYY_MM_DD_HH_MM_SS));
            map.put("isOver",isOver);
        }
        return list;
    }
}

+ 4 - 2
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/wechat/WechatService.java

@ -56,7 +56,8 @@ public class WechatService extends BaseService {
					"a.mobile," +
					"t.openid_time," +
					"t.medicare_number,"+
					"CONCAT(LEFT (a.idcard,6),'**********',RIGHT (a.idcard,2)) idcard," +
//					"CONCAT(LEFT (a.idcard,6),'**********',RIGHT (a.idcard,2)) idcard," +
					"a.idcard, " +
					"a.doctor_name," +
					"a.doctor_health_name," +
					"t.sick_village_name," +
@ -79,7 +80,8 @@ public class WechatService extends BaseService {
					"a.openid_time," +
					"a.openid, " +
					"a.medicare_number," +
					"CONCAT(LEFT (a.idcard,6),'**********',RIGHT (a.idcard,2)) idcard," +
//					"CONCAT(LEFT (a.idcard,6),'**********',RIGHT (a.idcard,2)) idcard," +
					"a.idcard, " +
					"b.doctor_name," +
					"b.doctor_health_name," +
					"b.hospital_name," +

+ 7 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/survey/SurveyScreenResultService.java

@ -312,9 +312,13 @@ public class SurveyScreenResultService extends BaseService {
            Map<String, Object> map = new HashMap<>();
            map.put("question", surveyTemplateQuestions);
            String qusCode = surveyTemplateQuestions.getCode();
            for (Map<String, Object> option : optionAnswersList) {
                if (option.get("question_code").equals(qusCode)) {
                    map.put("option", option);
            if (optionAnswersList==null || optionAnswersList.size()==0){
                map.put("option",new HashMap<String,Object>());
            }else {
                for (Map<String, Object> option : optionAnswersList) {
                    if (option.get("question_code").equals(qusCode)) {
                        map.put("option", option);
                    }
                }
            }
            answerMap.put(surveyTemplateQuestions.getSort() + "", map);

+ 174 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/synergy/ManageSynergyService.java

@ -0,0 +1,174 @@
package com.yihu.wlyy.service.synergy;
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.DateUtil;
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.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 ManageSynergyService 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){
        String response = null;
        JSONArray array = new JSONArray();
        String patientCode1 = null;
        Doctor doctor1 = doctorDao.findByCode(doctor);
        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());
            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);
        }
        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);
        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());
            }
            followup.setFollowupDate(DateUtil.strToDate(serviceDate));
            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 + "followup/saveFollowupProjectData";
        Map<String, String> params = new HashMap<>();
        params.put("servicers",array.toJSONString());
        try {
            response = httpClientUtil.httpPost(url,params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return response;
    }
    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 Integer 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){
            Integer reminderStatus = (Integer) result.get("data");
            return reminderStatus;
        }
        throw new Exception("请求客服系统服务失败!");
    }
}

+ 1 - 7
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/synergy/SynergyManageService.java

@ -66,7 +66,6 @@ public class SynergyManageService extends BaseService {
        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;
@ -75,7 +74,6 @@ public class SynergyManageService extends BaseService {
            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());
@ -86,7 +84,6 @@ public class SynergyManageService extends BaseService {
            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);
@ -97,8 +94,6 @@ public class SynergyManageService extends BaseService {
        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());
@ -132,10 +127,9 @@ public class SynergyManageService extends BaseService {
            object.put("relationCode",objectId);
            object.put("relationCodeName","疾病筛查");
        }
        String url = customerUrl + "synergy/doctor/createWorkorder";
        String url = customerUrl + "followup/saveFollowupProjectData";
        Map<String, String> params = new HashMap<>();
        params.put("servicers",array.toJSONString());
        params.put("workorder",object.toJSONString());
        try {
            response = httpClientUtil.httpPost(url,params);
        } catch (Exception e) {

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

@ -1,7 +1,7 @@
package com.yihu.wlyy.web.doctor.synergy;
import com.yihu.wlyy.service.jimeiJkEdu.JMJkEduArticleService;
import com.yihu.wlyy.service.synergy.SynergyManageService;
import com.yihu.wlyy.service.synergy.ManageSynergyService;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.third.gateway.vo.base.BaseResultModel;
import io.swagger.annotations.Api;
@ -28,7 +28,7 @@ import java.util.Set;
public class SynergyManageController extends BaseController {
    @Autowired
    private SynergyManageService synergyManageService;
    private ManageSynergyService manageSynergyService;
    @Autowired
    private JMJkEduArticleService jmJkEduArticleService;
@ -41,7 +41,7 @@ public class SynergyManageController extends BaseController {
                                   @ApiParam(name="role", value="1医生,2客服管理员,3普通客服")
                                   @RequestParam(required = true)Integer role){
        try {
            return write(200,"保存成功","data", synergyManageService.getWorkOrderInfo(workorderCode, patient, role));
            return write(200,"保存成功","data", manageSynergyService.getWorkOrderInfo(workorderCode, patient, role));
        }catch (Exception e){
            error(e);
            return error(-1,"保存失败");
@ -93,7 +93,7 @@ public class SynergyManageController extends BaseController {
            if (patientSet.size() == 0) {
                return new BaseResultModel("请至少选择一个患者!");
            }
            synergyManageService.createWorkorder(getUID(),patientSet,type,objectId,serviceDate,priority,remark,followupClass,followupType);
            manageSynergyService.createWorkorder(getUID(),patientSet,type,objectId,serviceDate,priority,remark,followupClass,followupType);
            return new BaseResultModel();
        } catch (Exception e) {
            error(e);
@ -123,7 +123,7 @@ public class SynergyManageController extends BaseController {
            if(!StringUtils.isNotEmpty(userCode)){
                userCode = getUID();
            }
            JSONObject result = synergyManageService.workorderList(userCode,workorderType,status,serviceStartTime,serviceEndTime,isAcceptTask,page,pageSize);
            JSONObject result = manageSynergyService.workorderList(userCode,workorderType,status,serviceStartTime,serviceEndTime,isAcceptTask,page,pageSize);
            return write(200, "获取成功", "data", result);
        } catch (Exception e) {
            error(e);
@ -141,8 +141,8 @@ public class SynergyManageController extends BaseController {
            if(!StringUtils.isNotEmpty(userCode)){
                userCode = getUID();
            }
            synergyManageService.reminder(userCode,workorderCode);
            return write(200, "请求成功");
            Integer reminderStatus = manageSynergyService.reminder(userCode,workorderCode);
            return write(200, "请求成功","data",reminderStatus);
        }catch (Exception e){
            error(e);
            return error(-1, "请求失败");

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

@ -52,7 +52,7 @@ rehabilitation:
  url: http://localhost:10055/svr-wlyy-rehabilitation/
#集美客服配置
customerService:
  url: http://localhost:8180/
  url: http://localhost:8082/
#小程序
applets: