|
@ -1,16 +1,15 @@
|
|
|
package com.yihu.wlyy.service.synergy;
|
|
|
|
|
|
import com.yihu.wlyy.entity.*;
|
|
|
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.*;
|
|
|
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 +18,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.*;
|
|
|
|
|
@ -57,6 +58,8 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
private ManageSynergyWorkorderReminderDao manageSynergyWorkorderReminderDao;
|
|
|
@Autowired
|
|
|
private ManageSynergyWorkorderServicerLogDao manageSynergyWorkorderServicerLogDao;
|
|
|
@Autowired
|
|
|
private TownDao townDao;
|
|
|
|
|
|
/**
|
|
|
* 根据服务编码获取工单
|
|
@ -88,41 +91,42 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public List<Map<String,Object>> workorderList(String code,String keywords,Integer workorderType,
|
|
|
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) 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 = "";
|
|
|
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){//我接收
|
|
|
whereSql +=" and w.create_user_type=1 ";//创建人为医生
|
|
|
whereSql += " and e.executor_code ="+code+" ";
|
|
|
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){//我接收
|
|
|
whereSql +=" and w.create_user_type=2 ";//创建人为客服
|
|
|
whereSql += " and e.executor_code ="+code+" ";
|
|
|
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 e.create_user ='"+code+"' ";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//关键字查询
|
|
|
servicerTable +=" left join wlyy.manage_synergy_workorder_servicer s on s.workorder_code=w.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+"%' ) ";
|
|
@ -133,7 +137,7 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
}
|
|
|
//是否是我负责的
|
|
|
if(isMyTask!=null){
|
|
|
whereSql += " and e.executor_code ="+code+" and e.executor_type=1 ";
|
|
|
whereSql += " and e.executor_code ='"+code+"' and e.executor_type=1 ";
|
|
|
}
|
|
|
//工单状态
|
|
|
if(status!=null){
|
|
@ -145,7 +149,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)){
|
|
@ -164,21 +172,34 @@ 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+
|
|
|
" left join wlyy.vmanage_synergy_workorder_executor e on e.workorder_code=w.code " +
|
|
|
" where w.status in (2,3) and w.del=1 " +
|
|
|
" and e.del=1 "+whereSql+ " order by w.priority desc,w.service_time desc";
|
|
|
List<Map<String,Object>> resultWorkorderList = jdbcTemplate.queryForList(sql);
|
|
|
|
|
|
" where w.del=1 " +
|
|
|
" and 1=1 "+whereSql+ " order by w.priority desc,w.service_time desc";
|
|
|
List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sql);
|
|
|
int count = 0;
|
|
|
if(rstotal!=null&&rstotal.size()>0&&rstotal.get(0).get("id")!=null){
|
|
|
count = rstotal.size();
|
|
|
}
|
|
|
String finalSql = sql+" LIMIT "+(page-1)*pageSize+","+pageSize;
|
|
|
List<Map<String,Object>> resultWorkorderList = jdbcTemplate.queryForList(finalSql);
|
|
|
List<Map<String,Object>> resultList = new ArrayList<>();
|
|
|
for(Map<String,Object> one : resultWorkorderList){
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
@ -219,9 +240,16 @@ 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);
|
|
|
}
|
|
|
return resultList;
|
|
|
Map<String,Object> resultMap = new HashMap<>();
|
|
|
resultMap.put("currPage",page);
|
|
|
resultMap.put("pageSize",pageSize);
|
|
|
resultMap.put("totalCount",count);
|
|
|
resultMap.put("detailModelList",resultList);
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -276,12 +304,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 +326,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 +344,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;
|
|
|
}
|
|
@ -349,6 +387,7 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
String diseaseCode,String healthCode,String serveCode,Integer isFollow) throws Exception{
|
|
|
String whereSql ="";
|
|
|
String leftSql ="";
|
|
|
String orderBySql =" l.id desc";
|
|
|
if(StringUtils.isNotEmpty(townCode)){
|
|
|
whereSql+=" and s.town='"+townCode+"' ";
|
|
|
}
|
|
@ -373,17 +412,21 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
}
|
|
|
if(isFollow!=null&&isFollow==1){//跟进
|
|
|
leftSql+=" LEFT JOIN manage_synergy_workorder_servicer_log ll on ll.service_patient_code=s.code ";
|
|
|
whereSql+=" and ll.follow_up=2 ";
|
|
|
whereSql+=" and ll.follow_up=2 and ll.workorder_service_code not in (select DISTINCT lll.workorder_service_code from manage_synergy_workorder_servicer_log lll where lll.follow_up=1 and lll.workorder_code='"+workorderCode+"') ";
|
|
|
orderBySql=" ll.id desc";
|
|
|
whereSql+=" and s.status=3 ";
|
|
|
}else{
|
|
|
whereSql+=" and s.status=1 ";
|
|
|
}
|
|
|
String sql =" select DISTINCT w.*,s.mobile,s.service_patient_name,s.service_patient_code,s.code as servicerCode,s.town_name,s.hospital_name " +
|
|
|
String sql =" select DISTINCT w.*,s.mobile,s.service_patient_name,s.service_patient_code,s.code as servicerCode,s.town_name,s.hospital_name, " +
|
|
|
" w.create_user_name " +
|
|
|
" from manage_synergy_workorder_servicer s " +
|
|
|
" LEFT JOIN manage_synergy_workorder w on s.workorder_code=w.code " +
|
|
|
" LEFT JOIN manage_synergy_workorder_executor e on e.workorder_code=w.code " + leftSql+
|
|
|
" LEFT JOIN manage_synergy_workorder_customer_log l on l.service_patient_code=s.service_patient_code " +
|
|
|
" where s.status=1 and s.workorderCode='"+workorderCode+"' " +
|
|
|
" LEFT JOIN manage_synergy_workorder_customer_log l on l.workorder_service_code=s.service_patient_code " +
|
|
|
" where s.workorder_code='"+workorderCode+"' " +
|
|
|
" and w.del=1 and w.status=2 and e.del=1 "+
|
|
|
whereSql+" order by l.id desc";
|
|
|
whereSql+" order by "+orderBySql;
|
|
|
List<Map<String,Object>> resultWorkorderList = jdbcTemplate.queryForList(sql);
|
|
|
Map<String,Object> resultMap = new HashMap<>();
|
|
|
if(resultWorkorderList.size()>0){
|
|
@ -393,6 +436,7 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
resultMap.put("patientName",workorderMap.get("service_patient_name"));//居民姓名
|
|
|
Integer callNum = customerLogDao.callNumByWorkorder(workorderMap.get("servicerCode")+"");
|
|
|
resultMap.put("callNum",callNum);//已呼叫次数
|
|
|
resultMap.putAll(this.getPatientInfo(workorderMap.get("service_patient_code") + ""));
|
|
|
Patient patient =patientDao.findByCode(workorderMap.get("service_patient_code")+"");
|
|
|
Integer sex = patient.getSex();
|
|
|
String sexName ="";
|
|
@ -429,6 +473,22 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
serveType+=","+one.getLabelName();
|
|
|
}
|
|
|
resultMap.put("serveType",StringUtils.isNotEmpty(serveType)?serveType.substring(1):"");//服务类型
|
|
|
|
|
|
//获取提交记录
|
|
|
String servicerCode = workorderMap.get("servicerCode")+"";
|
|
|
List<ManageSynergyWorkorderServicerLogDO> list = manageSynergyWorkorderServicerLogDao.findByWorkorderServiceCode(servicerCode);
|
|
|
if(list.size()>0){
|
|
|
ManageSynergyWorkorderServicerLogDO log = list.get(0);
|
|
|
Map<String,Object> m = new HashMap<>();
|
|
|
m.put("personal",log.getPersonal());
|
|
|
m.put("callCode",log.getCallCode());
|
|
|
m.put("callStatus",log.getCallStatus());
|
|
|
m.put("emphasis",log.getEmphasis());
|
|
|
m.put("followUp",log.getFollowUp());
|
|
|
m.put("remark",log.getRemark());
|
|
|
m.put("returnVisit",log.getReturnVisit());
|
|
|
resultMap.put("servicerLog",m);
|
|
|
}
|
|
|
return resultMap;
|
|
|
}else{
|
|
|
throw new Exception("没有任务");
|
|
@ -454,6 +514,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");
|
|
@ -473,17 +535,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);
|
|
|
}
|
|
@ -542,10 +606,10 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
|
|
|
public Map<String, Object> loadingInfo(String workorderCode, String customerCode) {
|
|
|
Map<String,Object> resultMap = new HashMap<>();
|
|
|
String sql = "SELECT s.service_patient_name, s.service_patient_code, s.`code`, s.s.hospital_name,s.town_name " +
|
|
|
String sql = "SELECT s.service_patient_name, s.service_patient_code, s.`code`, s.hospital_name,s.town_name " +
|
|
|
"from (SELECT DISTINCT r.patient,cl.workorder_code from manage_synergy_workorder_customer_log cl " +
|
|
|
"LEFT JOIN manage_call_record r on cl.call_code = r.`code` " +
|
|
|
"where cl.workorder_code = " + workorderCode + " and cl.create_user_code = " + customerCode + " and cl.`status` = 0 ORDER BY cl.create_time LIMIT 0,1) p " +
|
|
|
"where cl.workorder_code = '" + workorderCode + "' and cl.create_user_code = '" + customerCode + "' and cl.`status` = 0 ORDER BY cl.create_time LIMIT 0,1) p " +
|
|
|
"LEFT JOIN manage_synergy_workorder_servicer s on p.workorder_code = s.workorder_code and s.service_patient_code = p.patient and s.`status`=1";
|
|
|
|
|
|
Map<String, Object> result = (Map<String, Object>) jdbcTemplate.queryForList(sql);
|
|
@ -555,17 +619,23 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
resultMap.put("hospitalName", result.get("hospital_name"));//所属社区
|
|
|
Integer callNum = customerLogDao.callNumByWorkorder((String) result.get("code"));
|
|
|
resultMap.put("callNum",callNum);//已呼叫次数
|
|
|
resultMap.putAll(this.getPatientInfo(patientCode));
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
public Map<String,Object> getPatientInfo(String patientCode){
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
Patient patient = patientDao.findByCode(patientCode);
|
|
|
Integer sex = patient.getSex();
|
|
|
String sexName = "";
|
|
|
if(sex==1){
|
|
|
sexName="男";
|
|
|
}else if(sex==2){
|
|
|
sexName="女";
|
|
|
if(sex == 1){
|
|
|
sexName = "男";
|
|
|
}else if(sex == 2){
|
|
|
sexName = "女";
|
|
|
}else{
|
|
|
sexName="未知";
|
|
|
sexName = "未知";
|
|
|
}
|
|
|
resultMap.put("sex",sexName);//性别
|
|
|
resultMap.put("sex", sexName);//性别
|
|
|
Integer age = IdCardUtil.getAgeForIdcard(patient.getIdcard());
|
|
|
resultMap.put("age",age);//年龄
|
|
|
SignFamily signFamily = signFamilyDao.findSignByPatient(patientCode);
|
|
@ -580,7 +650,7 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
List<SignPatientLabelInfo> labelHealthType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patientCode, "2", 1);
|
|
|
String healthType="";
|
|
|
for(SignPatientLabelInfo one:labelHealthType){
|
|
|
healthType+=","+one.getLabelName();
|
|
|
healthType += ","+one.getLabelName();
|
|
|
}
|
|
|
resultMap.put("healthType", StringUtils.isNotEmpty(healthType) ? healthType.substring(1) : "");//健康情况
|
|
|
List<SignPatientLabelInfo> labelServeType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patientCode, "2", 1);
|
|
@ -612,7 +682,7 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
Integer myFinishedCount = workorderServicerDao.countByWorkorderCodeAndExecutorCodeAndStatus(workorderCode,userCode,3);
|
|
|
resultMap.put("myFinishedCount",myFinishedCount);
|
|
|
//待跟进
|
|
|
Integer followCount = manageSynergyWorkorderServicerLogDao.findByWorkorderCode(workorderCode);
|
|
|
Integer followCount = manageSynergyWorkorderServicerLogDao.findByWorkorderCodeAndFollowUp(workorderCode);
|
|
|
resultMap.put("followCount",followCount);
|
|
|
return resultMap;
|
|
|
}
|
|
@ -625,8 +695,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();
|
|
@ -662,6 +736,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;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -715,4 +823,356 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
}
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
public void taskSubmit(String workorderCode,String dealResultRemark,String dealResultAccessory) throws Exception{
|
|
|
|
|
|
ManageSynergyWorkorderDO manageSynergyWorkorderDO = workOrderDao.findByCode(workorderCode);
|
|
|
manageSynergyWorkorderDO.setDealResultRemark(dealResultRemark);
|
|
|
manageSynergyWorkorderDO.setDealResultAccessory(dealResultAccessory);
|
|
|
manageSynergyWorkorderDO.setStatus(3);
|
|
|
workOrderDao.save(manageSynergyWorkorderDO);
|
|
|
}
|
|
|
|
|
|
public JSONObject getLabels(String labelType) {
|
|
|
String url = wlyyUrl + "/wlyygc/doctor/label/labels?labelType=" + labelType;
|
|
|
String response = httpClientUtil.get(url, "UTF-8");
|
|
|
JSONObject jsonObject = new JSONObject(response);
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
|
public JSONObject getUnitLabels(String currentRoleCode, String currentRoleLevel) {
|
|
|
String url = wlyyUrl + "/wlyygc/doctor/label/unitLabels?currentRoleCode=" + currentRoleCode + "¤tRoleLevel=" + currentRoleLevel;
|
|
|
String response = httpClientUtil.get(url, "UTF-8");
|
|
|
JSONObject jsonObject = new JSONObject(response);
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 到处Excel表
|
|
|
* @param code
|
|
|
* @param keywords
|
|
|
* @param workorderType
|
|
|
* @param isMyTask
|
|
|
* @param status
|
|
|
* @param priority
|
|
|
* @param timeout
|
|
|
* @param workorderCode
|
|
|
* @param principal
|
|
|
* @param serviceStartTime
|
|
|
* @param serviceEndTime
|
|
|
* @param patientName
|
|
|
* @param ssc
|
|
|
* @param idcard
|
|
|
* @param userType
|
|
|
* @param isAcceptTask
|
|
|
* @param response
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
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 userName,String hospitalName,
|
|
|
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 ";//创建人为医生
|
|
|
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+"' ";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//关键字查询
|
|
|
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+"%' ";
|
|
|
}
|
|
|
//需求方
|
|
|
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+
|
|
|
|
|
|
" 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);
|
|
|
List<String> header = null;
|
|
|
if(isAcceptTask==1){//我接收的任务
|
|
|
header = new ArrayList<>(Arrays.asList("服务编号","服务类型","创建时间","服务对象","工单状态","需求方","负责人","服务内容"));
|
|
|
}else if(isAcceptTask==2){//我派发的任务
|
|
|
header = new ArrayList<>(Arrays.asList("服务编号","服务类型","创建时间","服务对象","工单状态","家庭医生","所属机构","服务内容"));
|
|
|
}
|
|
|
int i = 0;
|
|
|
for (String h : header) {
|
|
|
Label label = new Label(0, i, h);
|
|
|
ws.addCell(label);
|
|
|
i++;
|
|
|
}
|
|
|
Integer workorderTypeR = null;
|
|
|
String workorderTypeName = null;
|
|
|
Date createTime = null;
|
|
|
for(Map<String,Object> one:list){
|
|
|
workorderTypeR = (Integer) one.get("workorder_type");
|
|
|
createTime = (Date)one.get("create_time");
|
|
|
addCell(ws, i, 0, one.get("code")+"","");
|
|
|
switch (workorderTypeR){
|
|
|
case 0: workorderTypeName="咨询";break;
|
|
|
case 1: workorderTypeName="健康教育";break;
|
|
|
case 2: workorderTypeName="预约";break;
|
|
|
case 3: workorderTypeName="随访";break;
|
|
|
case 4: workorderTypeName="问卷调查";break;
|
|
|
case 5: workorderTypeName="疾病筛查";break;
|
|
|
}
|
|
|
addCell(ws, i, 1, workorderTypeName,"");
|
|
|
addCell(ws, i, 2, DateUtil.dateToStr(createTime,"yyyy--MM-dd HH:mm:ss"),"");
|
|
|
if(isAcceptTask==1){//我接收的任务
|
|
|
String[] servicer = (one.get("servicer_key")+"").split(",");
|
|
|
Integer servicerCount = (Integer) one.get("servicer_count");
|
|
|
addCell(ws, i, 1, servicer[0]+"等"+servicerCount+"人","");
|
|
|
}else if(isAcceptTask==2){//我派发的任务
|
|
|
String[] servicer = (one.get("servicer_key")+"").split(",");
|
|
|
addCell(ws, i, 1, servicer[0],"");
|
|
|
}
|
|
|
Integer statusR = (Integer) one.get("status");
|
|
|
String statusName="";
|
|
|
switch (statusR){
|
|
|
case 0:statusName="草稿";break;
|
|
|
case 1:statusName="未接受";break;
|
|
|
case 2:statusName="处理中";break;
|
|
|
case 3:statusName="处理完成";break;
|
|
|
case 4:statusName="退回";break;
|
|
|
}
|
|
|
addCell(ws, i, 3, statusName,"");
|
|
|
addCell(ws, i, 4, one.get("create_user_name")+"","");
|
|
|
if(isAcceptTask==1){//我接收的任务
|
|
|
List<ManageSynergyWorkorderExecutorDO> managerList = workorderExecutorDao.findByWorkorderCode(one.get("code")+"",1);
|
|
|
String managerName = managerList.size()>0?managerList.get(0).getExecutorName():"";
|
|
|
addCell(ws, i, 5, managerName,"");//负责人
|
|
|
}else if(isAcceptTask==2) {//我派发的任务
|
|
|
addCell(ws, i, 5, one.get("hospital_name")+"","");//所属机构
|
|
|
}
|
|
|
addCell(ws, i, 5, one.get("content")+"","");
|
|
|
i++;
|
|
|
}
|
|
|
wwb.write();
|
|
|
wwb.close();
|
|
|
}catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
if (wwb != null) wwb.close();
|
|
|
throw e;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//添加单元格内容
|
|
|
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);
|
|
|
}
|
|
|
ws.addCell(label);
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @param workorderCode
|
|
|
* @param workorderServiceCode
|
|
|
* @param userCode
|
|
|
* @param userName
|
|
|
* @param callCode
|
|
|
* @param status
|
|
|
*/
|
|
|
public void addWorkorderCustomerLog(String workorderCode,String workorderServiceCode,String userCode,String userName,String callCode,String status){
|
|
|
|
|
|
}
|
|
|
}
|