|
@ -1,509 +0,0 @@
|
|
|
package com.yihu.wlyy.service.manager.notification;
|
|
|
|
|
|
import com.yihu.wlyy.entity.*;
|
|
|
import com.yihu.wlyy.repository.*;
|
|
|
import com.yihu.wlyy.service.SMSService;
|
|
|
import com.yihu.wlyy.service.manager.wlyyrole.WlyyRoleService;
|
|
|
import com.yihu.wlyy.service.manager.wlyyrole.WlyyUserRoleService;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.util.query.BaseJpaService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.hibernate.SQLQuery;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageImpl;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* Created by Administrator on 2017/1/22.
|
|
|
*/
|
|
|
@Service
|
|
|
public class WlyyAuditNoticeService extends BaseJpaService<WlyyAuditNotice, WlyyAuditNoticeDao> {
|
|
|
|
|
|
@Autowired
|
|
|
private WlyyRoleDao wlyyRoleDao;
|
|
|
@Autowired
|
|
|
private WlyyRoleService roleService;
|
|
|
@Autowired
|
|
|
private WlyyUserRoleDao wlyyUserRoleDao;
|
|
|
@Autowired
|
|
|
private WlyyUserRoleService wlyyUserRoleService;
|
|
|
@Autowired
|
|
|
private WlyyAuditNoticeDao wlyyAuditNoticeDao;
|
|
|
@Autowired
|
|
|
private WlyyAuditNoticeScopeDao wlyyAuditNoticeScopeDao;
|
|
|
@Autowired
|
|
|
private WlyyAuditNoticeObjectDao wlyyAuditNoticeObjectDao;
|
|
|
@Autowired
|
|
|
private PatientDao patientDao;
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
|
private SMSService smsService;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 新增消息
|
|
|
* @param map
|
|
|
* @param user
|
|
|
*/
|
|
|
@Transactional
|
|
|
public void create(Map<String,String> map,User user){
|
|
|
String communityAuthority = map.get("communityAuthority");
|
|
|
String scope = map.get("scope");// 0- 全市 1 - 指定区 2 - 指定社区
|
|
|
String scopeId = map.get("scopeId");//范围明细ID,scope=1时为区ID串,2时为社区id串
|
|
|
String scopeContent = map.get("scopeContent");//
|
|
|
String city = map.get("city");
|
|
|
String town = map.get("town");
|
|
|
String community = map.get("community");
|
|
|
String conditionDescription = map.get("conditionDescription");
|
|
|
String conditionType = map.get("condition_type");//筛选条件:0-全部;1-根据条件
|
|
|
String condition = map.get("condition");//0 - 全部居民 1 - 设置条件? 设置的条件类别:1:卫计委三大分组(服务类型) 2:健康状况 3:疾病类型
|
|
|
String conditionId = map.get("conditionId");//0 - 全部居民 1 - 设置条件
|
|
|
String serverTypeContent = map.get("serverTypeContent");
|
|
|
String serverTypeId = map.get("serverTypeId");
|
|
|
String healthSituationContent = map.get("healthSituationContent");
|
|
|
String healthSituationId = map.get("healthSituationId");
|
|
|
String diseaseTypeContent = map.get("diseaseTypeContent");
|
|
|
String diseaseTypeId = map.get("diseaseTypeId");
|
|
|
String sendType = map.get("sendType");
|
|
|
String content = map.get("content");
|
|
|
|
|
|
List<Patient> list = getSendPatients(conditionType, scope, city, town, community, serverTypeId, healthSituationId, diseaseTypeId);
|
|
|
|
|
|
//需要审核的通知公告主表
|
|
|
WlyyAuditNotice notice = new WlyyAuditNotice();
|
|
|
notice.setApplyTime(new Date());
|
|
|
notice.setApplyUserHospital(user.getOrganizationId()+"");
|
|
|
notice.setApplyUserId(user.getCode());
|
|
|
notice.setApplyUserName(user.getName());
|
|
|
notice.setConditionDescription(conditionDescription);
|
|
|
notice.setContent(content);
|
|
|
|
|
|
String status = "";// 0 - 创建(瞬间状态) 1- 待提交 2 - 待审核 3 - 待发送 4 - 已发送 5 - 已拒绝 6 - 撤回(处于待审核时可修改为该状态)
|
|
|
if("2".equals(communityAuthority)){
|
|
|
//医生 需要审核
|
|
|
status = "2";
|
|
|
}else{
|
|
|
//管理员 直接发送(设置状态,还未执行)
|
|
|
status = "4";
|
|
|
notice.setAuditTime(new Date());
|
|
|
notice.setAuditUserId(user.getCode());
|
|
|
notice.setAuditUserName(user.getName());
|
|
|
}
|
|
|
notice.setStatus(status);
|
|
|
// notice.setApplyUserHospital(user.getOrganizationName());
|
|
|
|
|
|
notice.setSendType(sendType);
|
|
|
if("1".equals(sendType)){
|
|
|
notice.setSendTime(DateUtil.strToDateLong(map.get("sendTime")+":00"));
|
|
|
}
|
|
|
notice.setTitle(map.get("title"));
|
|
|
notice.setTotalCount(list.size());
|
|
|
wlyyAuditNoticeDao.save(notice);
|
|
|
|
|
|
//消息公告对象范围主表
|
|
|
WlyyAuditNoticeScope noticeScope = new WlyyAuditNoticeScope();
|
|
|
noticeScope.setNoticeId(notice.getId());
|
|
|
noticeScope.setScope(scope);
|
|
|
noticeScope.setScopeContent(scopeContent);
|
|
|
noticeScope.setScopeId(scopeId);
|
|
|
// noticeScope.setCondition(condition);
|
|
|
noticeScope.setCondition(conditionType);
|
|
|
noticeScope.setServerTypeId(serverTypeId);
|
|
|
noticeScope.setServerTypeContent(serverTypeContent);
|
|
|
noticeScope.setHealthSituationId(healthSituationId);
|
|
|
noticeScope.setHealthSituationContent(healthSituationContent);
|
|
|
noticeScope.setDiseaseTypeId(diseaseTypeId);
|
|
|
noticeScope.setDiseaseTypeContent(diseaseTypeContent);
|
|
|
noticeScope.setConditionDescription(conditionDescription);
|
|
|
wlyyAuditNoticeScopeDao.save(noticeScope);
|
|
|
|
|
|
//审核自身消息通知自己发短信操作(新线程)****************新线程发彩信
|
|
|
if (isAuditor(user)) {
|
|
|
sendMsgThread(list, notice);
|
|
|
}
|
|
|
// if("3".equals(status)){
|
|
|
// saveNoticeObject(list,notice);
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 保存消息通知对象
|
|
|
* @param list
|
|
|
* @param notice
|
|
|
*/
|
|
|
// private void saveNoticeObject(List<Patient> list,WlyyAuditNotice notice){
|
|
|
// //需要审核的通知公告对象
|
|
|
// WlyyAuditNoticeObject noticeObject = null;
|
|
|
// List<WlyyAuditNoticeObject> objectList = new ArrayList<>();
|
|
|
// String mobiles = "";
|
|
|
// int i = 0;
|
|
|
// for (Patient p:list){
|
|
|
// noticeObject = new WlyyAuditNoticeObject();
|
|
|
// noticeObject.setNoticeId(notice.getId());
|
|
|
// noticeObject.setToUserId(p.getCode());
|
|
|
// noticeObject.setToUserTel(p.getMobile());
|
|
|
// noticeObject.setContent(notice.getContent());
|
|
|
// //TODO 每次条用发送短信接口,根据返回信息对应更新状态,保存数据(若被中断时?)
|
|
|
// //smsService.sendMsg(mobiles,content);//判断返回值,设置发送状态--立即发送时
|
|
|
//
|
|
|
// noticeObject.setStatus(notice.getStatus());//?未发送
|
|
|
// noticeObject.setSendTime(new Date());
|
|
|
// noticeObject.setInsertTime(new Date());
|
|
|
// objectList.add(noticeObject);
|
|
|
//
|
|
|
// i++;
|
|
|
// mobiles += p.getMobile()+",";
|
|
|
// if(i%901==0){//900条发一次
|
|
|
// mobiles = mobiles.substring(0,mobiles.length()-1);
|
|
|
// //smsService.sendMsg(mobiles,content);
|
|
|
// System.out.println("i="+i+"---mobile="+mobiles);
|
|
|
// mobiles = "";
|
|
|
// }else if(i==list.size()){
|
|
|
// mobiles = mobiles.substring(0,mobiles.length()-1);
|
|
|
// //smsService.sendMsg(mobiles,content);
|
|
|
// System.out.println("i="+i+"---mobile="+mobiles);
|
|
|
// mobiles = "";
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// if(objectList.size()>0){
|
|
|
// wlyyAuditNoticeObjectDao.save(objectList);
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
/**
|
|
|
* 按条件查询居民
|
|
|
* @param conditionType
|
|
|
* @param scope
|
|
|
* @param city
|
|
|
* @param town
|
|
|
* @param community
|
|
|
* @param serverTypeId
|
|
|
* @param healthSituationId
|
|
|
* @param diseaseTypeId
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Patient> getSendPatients(String conditionType,String scope,String city,String town,String community,String serverTypeId,String healthSituationId,String diseaseTypeId){
|
|
|
List<Patient> list = null;
|
|
|
String sql = "";
|
|
|
|
|
|
//根据发送范围,筛选条件过滤出居民
|
|
|
if("0".equals(conditionType)){//筛选条件分支:全部居民
|
|
|
if("0".equals(scope)){
|
|
|
list = patientDao.findByCity(city);//全市全部居民
|
|
|
}else if("1".equals(scope)){
|
|
|
String towns[] = town.split(",");
|
|
|
list = patientDao.findByCityAndTowns(city,towns);//指定区全部居民
|
|
|
}else if("2".equals(scope)){
|
|
|
String communitys[] = community.split(",");
|
|
|
list = patientDao.findByCityAndHospital(city,communitys);//指定社区全部居民
|
|
|
}
|
|
|
}else if ("1".equals(conditionType)){//筛选条件分支:按条件(服务类型、健康状况、疾病类型)
|
|
|
//筛选条件
|
|
|
String conditionSql = "";
|
|
|
if(!StringUtils.isEmpty(serverTypeId)){
|
|
|
conditionSql += " (s.label_type=1 and s.label in ("+serverTypeId+")) ";
|
|
|
String[] serverTypeIds = serverTypeId.split(",");
|
|
|
}
|
|
|
if(!StringUtils.isEmpty(healthSituationId)){
|
|
|
if(StringUtils.isEmpty(conditionSql)){
|
|
|
conditionSql += " (s.label_type=2 and s.label in ("+healthSituationId+"))";
|
|
|
}else {
|
|
|
conditionSql += " or (s.label_type=2 and s.label in ("+healthSituationId+"))";
|
|
|
}
|
|
|
String[] healthSituationIds = healthSituationId.split(",");
|
|
|
}
|
|
|
if(!StringUtils.isEmpty(diseaseTypeId)){
|
|
|
if(StringUtils.isEmpty(conditionSql)){
|
|
|
conditionSql += " (s.label_type=3 and s.label in ("+diseaseTypeId+")) ";
|
|
|
}else {
|
|
|
conditionSql += " or (s.label_type=3 and s.label in ("+diseaseTypeId+")) ";
|
|
|
}
|
|
|
String[] diseaseTypeIds = diseaseTypeId.split(",");
|
|
|
}
|
|
|
//-------------发送范围
|
|
|
if("0".equals(scope)){
|
|
|
sql += "SELECT DISTINCT p.* from wlyy_patient p " +
|
|
|
" WHERE p.city=350200 and p.mobile is not null and p.mobile!='' and p.code in(select DISTINCT s.patient " +
|
|
|
" from wlyy_sign_patient_label_info s " +
|
|
|
" where "+conditionSql+")";
|
|
|
SQLQuery sqlQuery = currentSession().createSQLQuery(sql).addEntity(Patient.class);
|
|
|
list = sqlQuery.list();
|
|
|
}else if("1".equals(scope)){
|
|
|
sql += "SELECT DISTINCT p.* from wlyy_patient p " +
|
|
|
" WHERE p.city=350200 and p.town in ("+town+") and p.mobile is not null and p.mobile!='' and p.code in(select DISTINCT s.patient " +
|
|
|
" from wlyy_sign_patient_label_info s " +
|
|
|
" where "+conditionSql+")";
|
|
|
SQLQuery sqlQuery = currentSession().createSQLQuery(sql).addEntity(Patient.class);
|
|
|
list = sqlQuery.list();
|
|
|
}else if("2".equals(scope)){
|
|
|
community = "'" + community.replace(",","','") + "'";//字符类型数据库需要添加''
|
|
|
sql += "SELECT DISTINCT p.* from wlyy_patient p LEFT JOIN wlyy_sign_family f on p.code = f.patient " +
|
|
|
" WHERE p.city=350200 and f.hospital in ("+community+") and p.mobile is not null and p.mobile!='' and p.code in(select DISTINCT s.patient " +
|
|
|
" from wlyy_sign_patient_label_info s " +
|
|
|
" where "+conditionSql+")";
|
|
|
SQLQuery sqlQuery = currentSession().createSQLQuery(sql).addEntity(Patient.class);
|
|
|
list = sqlQuery.list();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 编辑消息
|
|
|
* @param map
|
|
|
* @param user
|
|
|
*/
|
|
|
@Transactional
|
|
|
public void updateNotice(Map<String,String> map,User user){
|
|
|
Long noticeId = Long.parseLong(map.get("id"));
|
|
|
String communityAuthority = map.get("communityAuthority");
|
|
|
String scope = map.get("scope");// 0- 全市 1 - 指定区 2 - 指定社区
|
|
|
String scopeId = map.get("scopeId");//范围明细ID,scope=1时为区ID串,2时为社区id串
|
|
|
String scopeContent = map.get("scopeContent");//
|
|
|
String city = map.get("city");
|
|
|
String town = map.get("town");
|
|
|
String community = map.get("community");
|
|
|
String conditionDescription = map.get("conditionDescription");
|
|
|
String conditionType = map.get("condition_type");//筛选条件:0-全部;1-根据条件
|
|
|
String serverTypeContent = map.get("serverTypeContent");
|
|
|
String serverTypeId = map.get("serverTypeId");
|
|
|
String healthSituationContent = map.get("healthSituationContent");
|
|
|
String healthSituationId = map.get("healthSituationId");
|
|
|
String diseaseTypeContent = map.get("diseaseTypeContent");
|
|
|
String diseaseTypeId = map.get("diseaseTypeId");
|
|
|
String sendType = map.get("sendType");
|
|
|
String content = map.get("content");
|
|
|
|
|
|
List<Patient> list = getSendPatients(conditionType, scope, city, town, community, serverTypeId, healthSituationId, diseaseTypeId);
|
|
|
|
|
|
//需要审核的通知公告主表
|
|
|
WlyyAuditNotice notice = wlyyAuditNoticeDao.findOne(noticeId);
|
|
|
// notice.setApplyTime(new Date());
|
|
|
// notice.setApplyUserHospital(user.getOrganizationId()+"");
|
|
|
// notice.setApplyUserId(user.getCode());
|
|
|
// notice.setApplyUserName(user.getName());
|
|
|
notice.setConditionDescription(conditionDescription);
|
|
|
notice.setContent(content);
|
|
|
|
|
|
//审核者自己的通知直接发送短信,状态为“4”
|
|
|
if (isAuditor(user)) {
|
|
|
notice.setStatus("4");
|
|
|
} else {
|
|
|
notice.setStatus("2");
|
|
|
}
|
|
|
|
|
|
notice.setSendType(sendType);
|
|
|
if("1".equals(sendType)){
|
|
|
notice.setSendTime(DateUtil.strToDateLong(map.get("sendTime")+":00"));
|
|
|
}
|
|
|
notice.setTitle(map.get("title"));
|
|
|
notice.setTotalCount(list.size());
|
|
|
wlyyAuditNoticeDao.save(notice);
|
|
|
|
|
|
//消息公告对象范围主表
|
|
|
WlyyAuditNoticeScope noticeScope = wlyyAuditNoticeScopeDao.findByNoticeId(noticeId);
|
|
|
noticeScope.setScope(scope);
|
|
|
noticeScope.setScopeContent(scopeContent);
|
|
|
noticeScope.setScopeId(scopeId);
|
|
|
noticeScope.setCondition(conditionType);
|
|
|
noticeScope.setServerTypeId(serverTypeId);
|
|
|
noticeScope.setServerTypeContent(serverTypeContent);
|
|
|
noticeScope.setHealthSituationId(healthSituationId);
|
|
|
noticeScope.setHealthSituationContent(healthSituationContent);
|
|
|
noticeScope.setDiseaseTypeId(diseaseTypeId);
|
|
|
noticeScope.setDiseaseTypeContent(diseaseTypeContent);
|
|
|
noticeScope.setConditionDescription(conditionDescription);
|
|
|
wlyyAuditNoticeScopeDao.save(noticeScope);
|
|
|
|
|
|
//审核者本人修改操作,为待审核状态>>直接通过,发送短信**********************新线程发彩信
|
|
|
if (isAuditor(user)) {
|
|
|
sendMsgThread(list, notice);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//查询通知列表
|
|
|
public Page<WlyyAuditNotice> searchList(String searchNm, String status, User currentUser, int page, int pageSize) throws Exception {
|
|
|
//1、根据当前用户判断其角色(是否有审核权限)1):无-查询本人的消息通知;有-管辖范围的所有消息通知(包括本人的)-添加是否为本人的标记(是本人的才有编辑、删除等操作)否则只是审核、查看
|
|
|
boolean auditor = false;
|
|
|
List<WlyyUserRole> userRoles = wlyyUserRoleDao.findByUser(currentUser.getCode());
|
|
|
if (page <= 0) {
|
|
|
page = 1;
|
|
|
}
|
|
|
if (pageSize <= 0) {
|
|
|
pageSize = 15;
|
|
|
}
|
|
|
PageRequest pageRequest = new PageRequest(page - 1, pageSize);
|
|
|
String filters = "";
|
|
|
if (!StringUtils.isEmpty(searchNm)) {
|
|
|
filters = "title?" + searchNm + " g1;applyUserName?" + searchNm + " g1;";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(status)) {
|
|
|
filters += "status=" + status + ";";
|
|
|
}
|
|
|
if (userRoles.size() > 0) {
|
|
|
auditor = true;
|
|
|
String[] roleCodes = new String[userRoles.size()];
|
|
|
for (int i = 0; i < userRoles.size(); i++) {
|
|
|
roleCodes[i] = userRoles.get(i).getRole();
|
|
|
}
|
|
|
//获取管辖机构codes
|
|
|
String applyUserHospital = "";
|
|
|
List<String> orgCodeList = wlyyUserRoleService.getRoleOrgCodes(roleCodes);
|
|
|
if (orgCodeList.size() > 0) {
|
|
|
applyUserHospital = StringUtils.join(orgCodeList, ",");
|
|
|
filters += "applyUserHospital=" + applyUserHospital + ";";
|
|
|
}
|
|
|
} else {
|
|
|
filters += "applyUserId=" + currentUser.getCode() + ";"; //非管理员只能查看自己的信息通知
|
|
|
}
|
|
|
|
|
|
List<WlyyAuditNotice> list = search("", filters, "", page, pageSize);
|
|
|
for (WlyyAuditNotice notice : list) {
|
|
|
if (!StringUtils.equals(notice.getApplyUserId(), currentUser.getCode())) {
|
|
|
notice.setOwned(false);
|
|
|
}
|
|
|
if (auditor) {
|
|
|
notice.setAuditor(true);
|
|
|
}
|
|
|
}
|
|
|
Page<WlyyAuditNotice> res = new PageImpl<WlyyAuditNotice>(list, pageRequest, getCount(filters));
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
//删除消息通知,同时删除对应的消息通知范围
|
|
|
@Transactional
|
|
|
public boolean deleteNotice(Long noticeId) {
|
|
|
wlyyAuditNoticeDao.delete(noticeId);
|
|
|
WlyyAuditNoticeScope noticeScope = wlyyAuditNoticeScopeDao.findByNoticeId(noticeId);
|
|
|
if (noticeScope != null) {
|
|
|
wlyyAuditNoticeScopeDao.delete(noticeScope.getId());
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
//审核通过发送短信,保存发送对象
|
|
|
@Transactional
|
|
|
public void approve(long noticeId, WlyyAuditNotice notice, User currentUser) {
|
|
|
//1) 查找出通知范围对象
|
|
|
WlyyAuditNoticeScope noticeScope = wlyyAuditNoticeScopeDao.findByNoticeId(noticeId);
|
|
|
String conditionType = noticeScope.getCondition();//筛选条件:0-全部;1-根据条件
|
|
|
String scope = noticeScope.getScope();// 0- 全市 1 - 指定区 2 - 指定社区
|
|
|
String scopeId = noticeScope.getScopeId();//范围明细ID,scope=1时为区ID串,2时为社区id串
|
|
|
// scope为0时-空值;为1时-区编码;为2时区+社区编码
|
|
|
String city = "350200";//厦门市
|
|
|
String town = "";
|
|
|
String community = "";
|
|
|
String serverTypeId = noticeScope.getServerTypeId();
|
|
|
String healthSituationId = noticeScope.getHealthSituationId();
|
|
|
String diseaseTypeId = noticeScope.getDiseaseTypeId();
|
|
|
if ("1".equals(scope)) {
|
|
|
town = scopeId;
|
|
|
}
|
|
|
if ("2".equals(scope) && !StringUtils.isEmpty(scopeId)) {
|
|
|
String[] values = scopeId.split(";|;");
|
|
|
for (String value : values) {
|
|
|
if (!StringUtils.isEmpty(value)) {
|
|
|
community += value.split(":|:")[1] + ",";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(community)) {
|
|
|
community = community.substring(community.length() - 1);
|
|
|
}
|
|
|
|
|
|
//2)查找居民
|
|
|
List<Patient> list = getSendPatients(conditionType, scope, city, town, community, serverTypeId, healthSituationId, diseaseTypeId);
|
|
|
|
|
|
//3)发送短信,保存发送对象信息6
|
|
|
if ("2".equals(notice.getStatus())) {
|
|
|
notice.setStatus("4");//消息通知修改状态
|
|
|
notice.setAuditUserId(currentUser.getCode());//审核者编码
|
|
|
notice.setAuditUserName(currentUser.getName());//审核者名称
|
|
|
wlyyAuditNoticeDao.save(notice);
|
|
|
|
|
|
//审核通过发送短信*******************新线程
|
|
|
sendMsgThread(list, notice);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//判断是否具有对当前消息的审核权限
|
|
|
public boolean isNoticeAuditor(String auditorCode, String noticeHospital) {
|
|
|
String[] roleCodes = wlyyRoleDao.findRoleCodesByUser(auditorCode);
|
|
|
if (roleCodes == null || roleCodes.length <= 0) {
|
|
|
return false;
|
|
|
}
|
|
|
List<String> roleOrgCodes = wlyyUserRoleService.getRoleOrgCodes(roleCodes);
|
|
|
if (roleOrgCodes != null && roleOrgCodes.size() > 0) {
|
|
|
return roleOrgCodes.contains(noticeHospital);
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
//判断当前用户是否是审核者
|
|
|
public boolean isAuditor(User currentUser) {
|
|
|
List<WlyyUserRole> userCode = wlyyUserRoleService.findByUserCode(currentUser.getCode());
|
|
|
if (userCode != null && userCode.size() > 0) {
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
//开启发送短信线程
|
|
|
private void sendMsgThread(List<Patient> list, WlyyAuditNotice notice) {
|
|
|
Thread t = new Thread(new Runnable() {
|
|
|
public void run() {
|
|
|
sendMsg(list, notice);
|
|
|
}
|
|
|
});
|
|
|
t.start();
|
|
|
}
|
|
|
|
|
|
//发送短信
|
|
|
private void sendMsg(List<Patient> list, WlyyAuditNotice notice) {
|
|
|
WlyyAuditNoticeObject noticeObject = null;
|
|
|
List<WlyyAuditNoticeObject> objectList = new ArrayList<>();
|
|
|
String mobiles = "";
|
|
|
int i = 0;
|
|
|
for (Patient p : list) {
|
|
|
noticeObject = new WlyyAuditNoticeObject();
|
|
|
noticeObject.setNoticeId(notice.getId());
|
|
|
noticeObject.setToUserId(p.getCode());
|
|
|
noticeObject.setToUserTel(p.getMobile());
|
|
|
noticeObject.setContent(notice.getContent());
|
|
|
noticeObject.setSendTime(new Date());
|
|
|
noticeObject.setInsertTime(new Date());
|
|
|
noticeObject.setStatus("1");//TODO 短信发送状态(1为已发送),待修改
|
|
|
objectList.add(noticeObject);
|
|
|
|
|
|
i++;
|
|
|
mobiles += p.getMobile() + ",";
|
|
|
if (i % 901 == 0) {//900条发一次
|
|
|
mobiles = mobiles.substring(0, mobiles.length() - 1);
|
|
|
//smsService.sendMsg(mobiles,content);
|
|
|
System.out.println("i=" + i + "---mobile=" + mobiles);
|
|
|
mobiles = "";
|
|
|
} else if (i == list.size()) {
|
|
|
mobiles = mobiles.substring(0, mobiles.length() - 1);
|
|
|
//smsService.sendMsg(mobiles,content);
|
|
|
System.out.println("i=" + i + "---mobile=" + mobiles);
|
|
|
mobiles = "";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//暂时未审核后才保存发送对象+发送短信,那是否有保存改发送对象信息的必要?(数据量大)
|
|
|
// if (objectList.size() > 0) {
|
|
|
// wlyyAuditNoticeObjectDao.save(objectList);
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
}
|