|
@ -2,19 +2,25 @@ package com.yihu.jw.care.service.message;
|
|
|
|
|
|
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.message.OrgNoticeDao;
|
|
|
import com.yihu.jw.care.dao.message.UserNoticeDao;
|
|
|
import com.yihu.jw.care.dao.security.SecurityMonitoringOrderDao;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
|
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.care.message.OrgNoticeDO;
|
|
|
import com.yihu.jw.restmodel.ResponseContant;
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.entity.EntityUtils;
|
|
|
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 javax.persistence.criteria.CriteriaBuilder;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.List;
|
|
@ -35,6 +41,10 @@ public class DoctorMessageService {
|
|
|
private PatientBedApplyDao patientBedApplyDao;
|
|
|
@Autowired
|
|
|
private SecurityMonitoringOrderDao securityMonitoringOrderDao;
|
|
|
@Autowired
|
|
|
private OrgNoticeDao orgNoticeDao;
|
|
|
@Autowired
|
|
|
private UserNoticeDao userNoticeDao;
|
|
|
|
|
|
/**
|
|
|
*
|
|
@ -150,7 +160,7 @@ public class DoctorMessageService {
|
|
|
"SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ,\n" +
|
|
|
"base_team_member m where ord.patient = CONVERT(sr.patient USING utf8) and sr.id = r.sign_id and sr.status=1 and \n" +
|
|
|
"r.service_package_id = i.service_package_id and m.team_code = i.team_code and i.del = 1 and sr.`status`=1 and i.code='preventLost' \n" +
|
|
|
"and m.doctor_code = '13' and m.del = '1') ";
|
|
|
"and m.doctor_code = '"+doctor+"' and m.del = '1') ";
|
|
|
}
|
|
|
|
|
|
List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
|
|
@ -177,7 +187,7 @@ public class DoctorMessageService {
|
|
|
"SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ,\n" +
|
|
|
"base_team_member m where ord.patient = CONVERT(sr.patient USING utf8) and sr.id = r.sign_id and sr.status=1 and \n" +
|
|
|
"r.service_package_id = i.service_package_id and m.team_code = i.team_code and i.del = 1 and sr.`status`=1 and i.code='emergencyAssistance' \n" +
|
|
|
"and m.doctor_code = '13' and m.del = '1')";
|
|
|
"and m.doctor_code = '"+doctor+"' and m.del = '1')";
|
|
|
}
|
|
|
|
|
|
List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
|
|
@ -211,4 +221,61 @@ public class DoctorMessageService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public JSONObject newOrgNotice(String jsonDate, String[] patients){
|
|
|
JSONObject result = new JSONObject();
|
|
|
OrgNoticeDO orgNoticeDO = new OrgNoticeDO();
|
|
|
try{
|
|
|
orgNoticeDO = EntityUtils.jsonToEntity(jsonDate, OrgNoticeDO.class);
|
|
|
}catch (Exception e){
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
String failMsg = "参数转换成JSON对象异常:" + e.getMessage();
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
orgNoticeDao.save(orgNoticeDO);
|
|
|
for(String user:patients){
|
|
|
UserNoticeDO userNoticeDO = new UserNoticeDO();
|
|
|
userNoticeDO.setUserId(user);
|
|
|
userNoticeDO.setDel(1);
|
|
|
userNoticeDO.setIsRead(0);
|
|
|
userNoticeDO.setNoticeId(orgNoticeDO.getId());
|
|
|
userNoticeDao.save(userNoticeDO);
|
|
|
}
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
JSONObject Msg = JSONObject.parseObject(JSON.toJSONStringWithDateFormat(orgNoticeDO,"yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue));
|
|
|
result.put(ResponseContant.resultMsg, Msg);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public PageEnvelop getOrgNoticeList(String orgCode,String createUser,String beginTime,String endTime,int page,int size){
|
|
|
page = page>0?page-1:0;
|
|
|
String sqlCount = "select count(id) from base_org_notice where del=1 ";
|
|
|
String sql = "select id,title,org_code orgCode,org_name orgName,DATE_FORMAT(notice_time,'%Y-%m-%d %H:%i:%S') noticeTime,content,img from base_org_notice where del=1 ";
|
|
|
String sqlCondition ="";
|
|
|
if (StringUtils.isNotBlank(orgCode)){
|
|
|
sqlCondition += " and org_code = '"+orgCode+"' ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(createUser)){
|
|
|
sqlCondition += " and create_user = '"+createUser+"' ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(beginTime)){
|
|
|
sqlCondition += " and notice_time >= '"+beginTime+"' ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(endTime)){
|
|
|
sqlCondition += " and notice_time <= '"+endTime+"' ";
|
|
|
}
|
|
|
if (StringUtils.isBlank(beginTime)&&StringUtils.isBlank(endTime)){
|
|
|
String time = DateUtil.getStringDate();
|
|
|
sqlCondition += " and notice_time <= '"+time+"' ";
|
|
|
}
|
|
|
Long count = jdbcTemplate.queryForObject(sqlCount+sqlCondition,Long.class);
|
|
|
sqlCondition += " order by notice_time desc limit "+page*size+","+size;
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+sqlCondition);
|
|
|
return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
|
|
|
}
|
|
|
|
|
|
public OrgNoticeDO orgNoticeDetail(String noticeId){
|
|
|
return orgNoticeDao.findOne(noticeId);
|
|
|
}
|
|
|
|
|
|
}
|