Forráskód Böngészése

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/controller/synergy/doctor/DoctorSynergyManageController.java
#	patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/SynergyManageService.java
wangzhinan 6 éve
szülő
commit
888a112482

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

@ -5,14 +5,8 @@ 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.repository.PatientDao;
import com.yihu.wlyy.repository.SignFamilyDao;
import com.yihu.wlyy.repository.SignPatientLabelInfoDao;
import com.yihu.wlyy.repository.UserDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkOrderDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkorderCustomerLogDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkorderExecutorDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkorderServicerDao;
import com.yihu.wlyy.repository.*;
import com.yihu.wlyy.repository.synergy.*;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.IdCardUtil;
@ -50,13 +44,19 @@ public class SynergyManageService extends BaseJpaService {
    @Autowired
    private UserDao userDao;
    @Autowired
    private ManageSynergyWorkorderCustomerLogDao manageSynergyWorkorderCustomerLogDao;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private SignPatientLabelInfoDao signPatientLabelInfoDao;
    @Autowired
    private ManageSynergyWorkorderCustomerLogDao customerLogDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private ManageSynergyWorkorderReminderDao manageSynergyWorkorderReminderDao;
    @Autowired
    private ManageSynergyWorkorderServicerLogDao manageSynergyWorkorderServicerLogDao;
    /**
     * 根据服务编码获取工单
@ -89,9 +89,9 @@ public class SynergyManageService extends BaseJpaService {
     * @throws Exception
     */
    public List<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) throws Exception{
                                                  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) throws Exception{
        String servicerTable = "";
        String whereSql = "";
@ -276,12 +276,13 @@ public class SynergyManageService extends BaseJpaService {
    public Map<String, Object> getWorkOrderInfo(String workorderCode, String patient, Integer role) {
        Map<String, Object> map = new HashMap<>();
        ManageSynergyWorkorderDO workorderDO = workOrderDao.findByCode(workorderCode);
        Integer status = workorderDO.getStatus();
        //存入协同服务工单信息
        map.put("code", workorderCode);
        map.put("type", workorderDO.getType());
        map.put("priority", workorderDO.getPriority());
        map.put("serviceTime", workorderDO.getServiceTime());
        map.put("status", workorderDO.getStatus());
        map.put("status", status);
        map.put("title", workorderDO.getRelationCodeName());
        map.put("remark", workorderDO.getRemark());
        map.put("createTime", workorderDO.getCreateTime());
@ -297,7 +298,7 @@ public class SynergyManageService extends BaseJpaService {
            map.put("ssc", workorderServicerDO.getSsc());
            map.put("completeTime", workorderServicerDO.getCompleteTime());
        }else {
            if(role == 3){
            if(status == 2 || status == 3){
                //获取工单完成人数
                int count = workorderServicerDao.findByWorkorderCodeCount(workorderCode, 3);
                map.put("count", count);
@ -315,26 +316,35 @@ public class SynergyManageService extends BaseJpaService {
            map.put("status", "未接收");
        }
        if(role == 3){
            //普通客服显示接收者
        if(status == 2){
            //接收者
            map.put("receiverName", workorderDO.getReceiverName());
            map.put("receiverTime", workorderDO.getReceiverTime());
            //获取负责人信息
            List<ManageSynergyWorkorderExecutorDO> managerList = workorderExecutorDao.findByWorkorderCode(workorderCode,1);
            List<ManageSynergyWorkorderExecutorDO> collaboratorList = workorderExecutorDao.findByWorkorderCode(workorderCode,2);
            String manager = managerList.size()>0 ? managerList.get(0).getExecutorName() : "";
            //获取负责人信息
            for(ManageSynergyWorkorderExecutorDO m : managerList){
                User manager = userDao.findByCode(m.getExecutorCode());
                map.put("managerName", manager.getName());
                map.put("managerJobNo", manager.getJobNo());
                map.put("managerPhone", manager.getMobile());
            }
            String collaborator = "";
            for(ManageSynergyWorkorderExecutorDO one:collaboratorList){
            for(ManageSynergyWorkorderExecutorDO one : collaboratorList){
                collaborator += "、" + one.getExecutorName();
            }
            map.put("manager", manager);//负责人
            map.put("collaboratorList", StringUtils.isNotEmpty(collaborator) ? collaborator.substring(1) : "");//参与人可能有多个
        }
        //获取处理结果
        if(workorderDO.getStatus() == 3){
            map.put("remark", workorderDO.getDealResultRemark());
        if(status == 3){
            //获取处理结果
            map.put("resultRemark", workorderDO.getDealResultRemark());
            map.put("accessory", workorderDO.getDealResultAccessory());
        }else if(status == 4){
            //获取退回原因
            map.put("returnedRemark", workorderDO.getReturnedRemark());
        }
        return map;
    }
@ -390,8 +400,8 @@ public class SynergyManageService extends BaseJpaService {
            Map<String,Object> workorderMap = resultWorkorderList.get(0);
            //居民信息
            resultMap.put("mobile",workorderMap.get("mobile"));//电话号码
            resultMap.put("mobile",workorderMap.get("mobile"));//居民姓名
            Integer callNum = manageSynergyWorkorderCustomerLogDao.callNumByWorkorder(workorderMap.get("servicerCode")+"");
            resultMap.put("patientName",workorderMap.get("service_patient_name"));//居民姓名
            Integer callNum = customerLogDao.callNumByWorkorder(workorderMap.get("servicerCode")+"");
            resultMap.put("callNum",callNum);//已呼叫次数
            Patient patient =patientDao.findByCode(workorderMap.get("service_patient_code")+"");
            Integer sex = patient.getSex();
@ -530,80 +540,6 @@ public class SynergyManageService extends BaseJpaService {
        }
    }
    /**
     * 创建工单
     *
     * @param manageSynergyWorkorderDO
     * @param manageSynergyWorkorderServicerDOS
     */
    public void createWorkorder(ManageSynergyWorkorderDO manageSynergyWorkorderDO,List<ManageSynergyWorkorderServicerDO> manageSynergyWorkorderServicerDOS){
        manageSynergyWorkorderDO.setCode(getWorkorderNo());
        ManageSynergyWorkorderDO manageSynergyWorkorderDO1 = workOrderDao.save(manageSynergyWorkorderDO);
        for (ManageSynergyWorkorderServicerDO servicerDO:manageSynergyWorkorderServicerDOS){
            servicerDO.setWorkorderType(manageSynergyWorkorderDO1.getType());
            servicerDO.setWorkorderCode(manageSynergyWorkorderDO1.getCode());
            servicerDO.setRelationCode(manageSynergyWorkorderDO1.getRelationCode());
            servicerDO.setCreateTime(new Date());
            servicerDO.setRelationCodeName(manageSynergyWorkorderDO1.getRelationCodeName());
            workorderServicerDao.save(servicerDO);
        }
    }
    /**
     * 添加随访计划
     *
     * @param doctor
     * @param patient
     * @param date
     * @param followupType
     * @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){
        String response = null;
        String url = wlyyUrl + "followup/addFollowup";
        Map<String, Object> params = new HashMap<>();
        params.put("doctor",doctor);
        params.put("patient",patient);
        params.put("date",date);
        params.put("followupType",followupType);
        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) {
            e.printStackTrace();
        }
        return response;
    }
    /**
     * 保存随访数据
     *
     * @param followup
     * @return
     */
    public String saveFollowupProjectData(String followup){
        String response = null;
        String url = wlyyUrl + "followup/saveFollowupProjectData";
        Map<String, Object> params = new HashMap<>();
        params.put("followup",followup);
        try {
            response = httpClientUtil.post(url, params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return response;
    }
    /**
     * 查找该客服该工单是否有异常工单
     * @param workorderCode
@ -671,14 +607,14 @@ public class SynergyManageService extends BaseJpaService {
     * @param workorderCode
     * @param userCode
     */
    public void workorderRate(String workorderCode,String userCode){
    public Map<String,Object> workorderRate(String workorderCode,String userCode){
        Map<String,Object> resultMap = new HashMap<>();
        //完成情况
        //1、有效
        Integer validCount = workorderServicerDao.findByWorkorderCodeCount(workorderCode,3);
        resultMap.put("validCount",validCount);
        //2、无效
        resultMap.put("invalidCount","");
        resultMap.put("invalidCount",0);
        //3、总数
        ManageSynergyWorkorderDO manageSynergyWorkorder = workOrderDao.findByCode(workorderCode);
        resultMap.put("allCount",manageSynergyWorkorder.getServicerCount());
@ -686,27 +622,28 @@ public class SynergyManageService extends BaseJpaService {
        Integer myFinishedCount = workorderServicerDao.countByWorkorderCodeAndExecutorCodeAndStatus(workorderCode,userCode,3);
        resultMap.put("myFinishedCount",myFinishedCount);
        //待跟进
        resultMap.put("followCount","");
        Integer followCount = manageSynergyWorkorderServicerLogDao.findByWorkorderCode(workorderCode);
        resultMap.put("followCount",followCount);
        return resultMap;
    }
    /**
     * 催单
     * @param workorderServicerCode
     * @param workorderCode
     * @param userCode
     * @param userType
     * @throws Exception
     */
    @Transactional
    public void reminder(String workorderServicerCode,String userCode,Integer userType) throws Exception{
    public void reminder(String workorderCode,String userCode,Integer userType) throws Exception{
        ManageSynergyWorkorderServicerDO manageSynergyWorkorderServicerDO = workorderServicerDao.findByCode(workorderServicerCode);
        if(manageSynergyWorkorderServicerDO==null){
        ManageSynergyWorkorderDO manageSynergyWorkorderDO = workOrderDao.findByCode(workorderCode);
        if(manageSynergyWorkorderDO==null){
            throw new Exception();
        }
        ManageSynergyWorkordeReminderDO workordeReminderDO = new ManageSynergyWorkordeReminderDO();
        workordeReminderDO.setCode(getCode());
        workordeReminderDO.setWorkorderCode(manageSynergyWorkorderServicerDO.getWorkorderCode());
        workordeReminderDO.setServicePatientCode(workorderServicerCode);
        workordeReminderDO.setWorkorderCode(workorderCode);
        workordeReminderDO.setCreateUser(userCode);
        //创建人类型(1、医生,2、客服,3、客服负责人)
        if(userType==1){
@ -717,23 +654,147 @@ public class SynergyManageService extends BaseJpaService {
            workordeReminderDO.setCreateUserName(user.getName());
        }
        workordeReminderDO.setCreateUserType(userType);
        workordeReminderDO.setHospital(manageSynergyWorkorderServicerDO.getHospital());
        workordeReminderDO.setHospitalName(manageSynergyWorkorderServicerDO.getHospitalName());
        workordeReminderDO.setHospital(manageSynergyWorkorderDO.getHospital());
        workordeReminderDO.setHospitalName(manageSynergyWorkorderDO.getHospitalName());
        workordeReminderDO.setCreateTime(new Date());
        List<ManageSynergyWorkorderExecutorDO> list = workorderExecutorDao.findByWorkorderCode(manageSynergyWorkorderServicerDO.getWorkorderCode(),1);
        List<ManageSynergyWorkorderExecutorDO> list = workorderExecutorDao.findByWorkorderCode(workorderCode,1);
        if(list!=null&&list.size()>0){
            workordeReminderDO.setPrincipalCode(list.get(0).getExecutorCode());
            workordeReminderDO.setPrincipalName(list.get(0).getExecutorName());
        }
        workordeReminderDO.setWorkorderType(manageSynergyWorkorderServicerDO.getWorkorderType());
        workordeReminderDO.setRelationCode(manageSynergyWorkorderServicerDO.getRelationCode());
        workordeReminderDO.setRelationCodeName(manageSynergyWorkorderServicerDO.getRelationCodeName());
        ManageSynergyWorkorderDO manageSynergyWorkorderDO = workOrderDao.findByCode(manageSynergyWorkorderServicerDO.getWorkorderCode());
        workordeReminderDO.setWorkorderType(manageSynergyWorkorderDO.getType());
        workordeReminderDO.setRelationCode(manageSynergyWorkorderDO.getRelationCode());
        workordeReminderDO.setRelationCodeName(manageSynergyWorkorderDO.getRelationCodeName());
        workordeReminderDO.setServiceTime(manageSynergyWorkorderDO!=null?manageSynergyWorkorderDO.getServiceTime():null);
        workordeReminderDO.setServicerKey(manageSynergyWorkorderDO!=null?manageSynergyWorkorderDO.getServicerKey():null);
        workordeReminderDO.setWorkorderRemark(manageSynergyWorkorderDO!=null?manageSynergyWorkorderDO.getRemark():null);
        workordeReminderDO.setDealWith(0);
        workordeReminderDO.setPriority(manageSynergyWorkorderDO.getPriority());
        manageSynergyWorkorderReminderDao.save(workordeReminderDO);
    }
    /**
     * 催单列表
     * @param userCode
     * @param receiveType 1、客服,2、客服负责人
     * @param sortType 1、升序,2、降序
     */
    public List<Map<String,Object>> reminderList(String userCode,Integer receiveType,Integer sortType){
        String sql ="";
        String sort ="";
        if(sortType==1){
            sort=" order by r.create_time asc ";
        }else if(sortType==2){
            sort=" order by r.create_time desc ";
        }
        if(receiveType==1){
            sql =" select DISTINCT r.* from manage_synergy_workorder_reminder r " +
                    " LEFT JOIN manage_synergy_workorder_executor e on r.workorder_code=e.workorder_code " +
                    " where e.executor_code='' and e.del=1 and r.deal_with=0 " +sort;
        }else if(receiveType==2){
            sql =" select r.* from manage_synergy_workorder_reminder r where r.principal_code='"+userCode+"' and r.deal_with=0 "+sort;
        }
        List<Map<String,Object>> List = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> resultList = new ArrayList<>();
        for(Map<String,Object> one:List){
            Map<String,Object> resultMap = new HashMap<>();
            resultMap.put("workorderCode",one.get("workorder_code"));
            resultMap.put("title","来自"+one.get("create_user_name")+"医生("+one.get("hospital_name")+")催单,请尽快处理(服务编号:)"+one.get("workorder_code"));//标题
            String workorderTypeName ="";
            Integer workorderType = (Integer) one.get("workorder_type");
            switch (workorderType){
                case 0: workorderTypeName="咨询";break;
                case 1: workorderTypeName="健康教育";break;
                case 2: workorderTypeName="预约";break;
                case 3: workorderTypeName="随访";break;
                case 4: workorderTypeName="问卷调查";break;
                case 5: workorderTypeName="疾病筛查";break;
            }
            resultMap.put("workorderTypeName",workorderTypeName);
            resultMap.put("workorderType",one.get("workorder_type"));
            resultMap.put("priority",one.get("priority"));
            resultMap.put("relationCodeName",one.get("relation_code_name"));
            resultMap.put("serviceTime",DateUtil.dateToStr((Date)one.get("service_time"),"yyyy-MM-dd HH:mm:ss"));
            resultMap.put("reminderTime",DateUtil.dateToStr((Date)one.get("create_time"),"yyyy-MM-dd HH:mm:ss"));
            resultMap.put("servicerKey",one.get("servicer_key"));
            resultMap.put("workorderRemark",one.get("workorder_remark"));
            Integer overTimeFlag = isServiceOverTime((Date)one.get("service_time"));
            resultMap.put("overTimeFlag",overTimeFlag);
            resultList.add(resultMap);
        }
        return resultList;
    }
    /**
     * 创建工单
     *
     * @param manageSynergyWorkorderDO
     * @param manageSynergyWorkorderServicerDOS
     */
    public void createWorkorder(ManageSynergyWorkorderDO manageSynergyWorkorderDO,List<ManageSynergyWorkorderServicerDO> manageSynergyWorkorderServicerDOS){
        manageSynergyWorkorderDO.setCode(getWorkorderNo());
        ManageSynergyWorkorderDO manageSynergyWorkorderDO1 = workOrderDao.save(manageSynergyWorkorderDO);
        for (ManageSynergyWorkorderServicerDO servicerDO:manageSynergyWorkorderServicerDOS){
            servicerDO.setWorkorderType(manageSynergyWorkorderDO1.getType());
            servicerDO.setWorkorderCode(manageSynergyWorkorderDO1.getCode());
            servicerDO.setRelationCode(manageSynergyWorkorderDO1.getRelationCode());
            servicerDO.setCreateTime(new Date());
            servicerDO.setRelationCodeName(manageSynergyWorkorderDO1.getRelationCodeName());
            workorderServicerDao.save(servicerDO);
        }
    }
    /**
     * 添加随访计划
     *
     * @param doctor
     * @param patient
     * @param date
     * @param followupType
     * @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){
        String response = null;
        String url = wlyyUrl + "followup/addFollowup";
        Map<String, Object> params = new HashMap<>();
        params.put("doctor",doctor);
        params.put("patient",patient);
        params.put("date",date);
        params.put("followupType",followupType);
        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) {
            e.printStackTrace();
        }
        return response;
    }
    /**
     * 保存随访数据
     *
     * @param followup
     * @return
     */
    public String saveFollowupProjectData(String followup){
        String response = null;
        String url = wlyyUrl + "followup/saveFollowupProjectData";
        Map<String, Object> params = new HashMap<>();
        params.put("followup",followup);
        try {
            response = httpClientUtil.post(url, params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return response;
    }
}