|
@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.yihu.jw.care.dao.apply.PatientBedApplyDao;
|
|
|
import com.yihu.jw.care.dao.device.BaseDeviceRepairDao;
|
|
|
import com.yihu.jw.care.dao.device.DeviceDetailDao;
|
|
|
import com.yihu.jw.care.dao.message.OrgNoticeDao;
|
|
|
import com.yihu.jw.care.dao.message.UserNoticeDao;
|
|
|
import com.yihu.jw.care.dao.security.SecurityMonitoringOrderDao;
|
|
@ -14,9 +16,15 @@ import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
|
|
|
import com.yihu.jw.entity.base.notice.UserNoticeDO;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.care.device.DeviceDetail;
|
|
|
import com.yihu.jw.entity.care.message.OrgNoticeDO;
|
|
|
import com.yihu.jw.entity.patient.BaseDeviceRepairEntity;
|
|
|
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.restmodel.ResponseContant;
|
|
|
import com.yihu.jw.restmodel.web.Envelop;
|
|
|
import com.yihu.jw.restmodel.web.ObjEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.entity.EntityUtils;
|
|
@ -24,6 +32,8 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
@ -54,6 +64,14 @@ public class DoctorMessageService {
|
|
|
private DoctorServicePermissionsService doctorServicePermissionsService;
|
|
|
@Autowired
|
|
|
private RoleService roleService;
|
|
|
@Autowired
|
|
|
private BaseDeviceRepairDao baseDeviceRepairDao;
|
|
|
@Autowired
|
|
|
private PatientMessageService patientMessageService;
|
|
|
@Autowired
|
|
|
private DeviceDetailDao deviceDetailDao;
|
|
|
@Autowired
|
|
|
private BasePatientDao basePatientDao;
|
|
|
|
|
|
/**
|
|
|
*
|
|
@ -323,7 +341,7 @@ public class DoctorMessageService {
|
|
|
// List<SystemMessageDO> systemMessageDOS = messageDao.getByReceiverAndType(doctor,"43");
|
|
|
String sql = "select DISTINCT sm.id as id,sm.type AS type,sm.title AS title,sm.sender AS sender,sm.sender_name AS senderName,\n" +
|
|
|
" sm.receiver AS receiver,sm.receiver_name AS receiver_name,sm.relation_code AS relationCode,\n" +
|
|
|
" sm.data AS data,sm.is_read AS isRead,DATE_FORMAT(sm.create_time,'%Y-%m-%d') AS createTime,sm.sender_photo AS sender_photo,pd.category_code,pd.device_name" +
|
|
|
" sm.data AS data,sm.is_read AS isRead,DATE_FORMAT(sm.create_time,'%Y-%m-%d') AS createTime,UNIX_TIMESTAMP(sm.create_time) AS createTimeNum,sm.sender_photo AS sender_photo,pd.category_code,pd.device_name" +
|
|
|
" from base_system_message sm LEFT JOIN wlyy_patient_device pd ON sm.relation_code = pd.device_sn where sm.receiver = '"+doctor+"' AND sm.type=43 and sm.del=1 ";
|
|
|
|
|
|
if (StringUtils.isNotBlank(deviceCode)&&!"''".equals(deviceCode)){
|
|
@ -336,6 +354,10 @@ public class DoctorMessageService {
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String, Object> map : maps) {
|
|
|
Long l = (Long) map.get("createTimeNum");
|
|
|
map.put("timeAgoStr",DateUtil.getTimeAgeStr(l));
|
|
|
}
|
|
|
return maps;
|
|
|
}
|
|
|
|
|
@ -476,4 +498,101 @@ public class DoctorMessageService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 登记维护信息
|
|
|
* @param id 消息id
|
|
|
* @param patientId 居民code
|
|
|
* @param deviceCode 设备sn
|
|
|
* @param deviceName 设备名称
|
|
|
* @param doctorId 医生id
|
|
|
* @param doctorName 医生名字
|
|
|
* @param content 处理内容
|
|
|
* @param img 图片
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional
|
|
|
public Envelop submitRepairMessage(String id,String patientId,String deviceCode,String deviceName,String doctorId,String doctorName,String content,String img){
|
|
|
BaseDeviceRepairEntity baseDeviceRepairEntity = new BaseDeviceRepairEntity();
|
|
|
baseDeviceRepairEntity.setOrderId(id);
|
|
|
baseDeviceRepairEntity.setDeviceSn(deviceCode);
|
|
|
if(StringUtils.isBlank(deviceName)){
|
|
|
//查设备
|
|
|
DeviceDetail bySn = deviceDetailDao.findBySn(deviceCode);
|
|
|
if(bySn != null){
|
|
|
deviceName = bySn.getDeviceName();
|
|
|
}
|
|
|
}
|
|
|
baseDeviceRepairEntity.setDeviceName(deviceName);
|
|
|
baseDeviceRepairEntity.setBindUser(patientId);
|
|
|
//查居民名字
|
|
|
BasePatientDO byId = basePatientDao.findById(patientId);
|
|
|
String userName = "";
|
|
|
if(byId != null){
|
|
|
userName = byId.getName();
|
|
|
}
|
|
|
baseDeviceRepairEntity.setBindUserName(userName);
|
|
|
|
|
|
baseDeviceRepairEntity.setStatus(1);
|
|
|
baseDeviceRepairEntity.setRepairPeoper(patientId);
|
|
|
baseDeviceRepairEntity.setRepairPeoperName(userName);
|
|
|
Date nowDate = DateUtil.getNowDate();
|
|
|
baseDeviceRepairEntity.setCreateTime(nowDate);
|
|
|
baseDeviceRepairEntity.setImg(img);
|
|
|
baseDeviceRepairEntity.setDealTime(nowDate);
|
|
|
baseDeviceRepairEntity.setFeedback(content);
|
|
|
baseDeviceRepairEntity.setType(0);
|
|
|
baseDeviceRepairEntity.setDealPeoper(doctorId);
|
|
|
baseDeviceRepairEntity.setDealPeoperName(doctorName);
|
|
|
baseDeviceRepairDao.save(baseDeviceRepairEntity);
|
|
|
patientMessageService.delMessageRead(id);
|
|
|
return Envelop.getSuccess("操作成功");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 维护信息列表
|
|
|
* @param doctorId
|
|
|
* @param page
|
|
|
* @param pageSize
|
|
|
* @param name
|
|
|
* @return
|
|
|
*/
|
|
|
public PageEnvelop getRepairMassageList(String doctorId,Integer page,Integer pageSize,String name){
|
|
|
page = page>0?page-1:0;
|
|
|
String selectSql = "SELECT re.id,re.order_id orderId,p.name patientName,re.device_sn deviceSn,re.device_name deviceName,CAST(DATE_FORMAT(re.deal_time,'%Y-%m-%d %H:%i:%S') as char) dealTime,re.deal_peoper dealPeoper,re.deal_peoper_name dealPeoperName,p.photo ";
|
|
|
String sql = " from base_device_repair re left join base_patient p on re.bind_user = p.id " +
|
|
|
" where re.type = 0 and re.status = 1 and re.deal_peoper = '"+doctorId+"' ";
|
|
|
if(StringUtils.isNotBlank(name)){
|
|
|
sql += " and ( p.name like '%"+name+"%' or p.idcard like '%"+name+"%') ";
|
|
|
}
|
|
|
String pageSql = " limit "+page*pageSize+","+pageSize+" ";
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(selectSql + sql + pageSql);
|
|
|
String countSql = "SELECT COUNT(re.id) ";
|
|
|
Long total = jdbcTemplate.queryForObject(countSql + sql, Long.class);
|
|
|
//计算时间差
|
|
|
//for (Map<String, Object> map : list) {
|
|
|
// Long l1 = (Long) map.get("dealTimeNum");
|
|
|
// map.put("timeAgoStr",DateUtil.getTimeAgeStr(l1));
|
|
|
//}
|
|
|
return PageEnvelop.getSuccessListWithPage("获取成功",list,page,pageSize,total);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据id获取一条维护信息
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
public ObjEnvelop getRepairMessageListById(Integer id){
|
|
|
String sql = "SELECT re.id,re.order_id orderId,p.name patientName,re.device_sn deviceSn,re.device_name deviceName,CAST(DATE_FORMAT(re.deal_time,'%Y-%m-%d %H:%i:%S') as char) dealTime,re.deal_peoper dealPeoper,re.deal_peoper_name dealPeoperName,p.photo,re.feedback,re.img " +
|
|
|
" from base_device_repair re left join base_patient p on re.bind_user = p.id where re.type = 0 and re.id = "+id;
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
if(!ObjectUtils.isEmpty(list)){
|
|
|
map = list.get(0);
|
|
|
//Long l1 = (Long) map.get("dealTimeNum");
|
|
|
//map.put("timeAgoStr",DateUtil.getTimeAgeStr(l1));
|
|
|
return ObjEnvelop.getSuccess("获取成功",map);
|
|
|
}
|
|
|
return ObjEnvelop.getError("无数据");
|
|
|
}
|
|
|
|
|
|
}
|