| | |
| | | package com.product.mobile.core.service; |
| | | |
| | | import com.product.admin.config.CmnConst; |
| | | import com.product.admin.service.PublicService; |
| | | import com.product.common.lang.StringUtils; |
| | | import com.product.core.dao.BaseDao; |
| | | import com.product.core.entity.DataTableEntity; |
| | | import com.product.core.entity.FieldSetEntity; |
| | | import com.product.core.service.support.AbstractBaseService; |
| | | import com.product.core.spring.context.SpringMVCContextHolder; |
| | | import com.product.module.sys.entity.SystemUser; |
| | | import com.product.module.sys.service.UserService; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | */ |
| | | public DataTableEntity listReadMessage(FieldSetEntity fse) { |
| | | ArrayList <Object> ps= new ArrayList<Object>(); |
| | | String readType = StringUtils.isEmpty(fse.getString("read")) ? "1" : fse.getString("read"); |
| | | ps.add(readType); |
| | | ps.add(SpringMVCContextHolder.getCurrentUserId()); |
| | | StringBuilder f=new StringBuilder(); |
| | | if(fse.getString("type")!=null) { |
| | | f.append(" and SUBSTRING(m.message_type,1,1)=?"); |
| | | ps.add(fse.getString("type")); |
| | | } |
| | | if(fse.getString("key")!=null) { |
| | | if(!StringUtils.isEmpty(fse.getString("key"))) { |
| | | f.append( " and (title like concat('%',?,'%') or content like concat('%',?,'%') or user_name like concat('%',?,'%') ) "); |
| | | ps.add(fse.getString("key")); |
| | | ps.add(fse.getString("key")); |
| | |
| | | sql.append("\nselect m.uuid,m.title,m.content,m.send_user_id,mu.user_name send_user_name,m.send_time,m.message_type,ifnull(m.url,'') url,source_table,source_uuid,thumbnail_img "); |
| | | sql.append("\nfrom product_sys_message m"); |
| | | sql.append("\nleft join product_sys_users mu on mu.user_id=m.send_user_id "); |
| | | sql.append("\ninner join product_sys_message_user u on u.message_uuid=m.uuid and u.read_type=1 and u.user_id=? ").append(f); |
| | | sql.append("\ninner join product_sys_message_user u on u.message_uuid=m.uuid and ifnull(u.read_type, 0)=? and u.user_id=? ").append(f); |
| | | sql.append("\norder by m.send_time desc"); |
| | | DataTableEntity dte = baseDao.listTable(sql.toString(), ps.toArray(), fse.getInteger(CmnConst.PAGESIZE), fse.getInteger(CmnConst.CPAGE)); |
| | | dte.getMeta().addAliasTable("product_sys_message", "m"); |
| | |
| | | * @return |
| | | */ |
| | | public DataTableEntity getTypeMessage(Object type,int read) { |
| | | |
| | | |
| | | ArrayList<Object> ps= new ArrayList<Object>(); |
| | | ps.add(SpringMVCContextHolder.getCurrentUserId()); |
| | | ps.add(read); |
| | |
| | | ps.add(type); |
| | | } |
| | | StringBuilder sql = new StringBuilder(); |
| | | sql.append("\nselect SUBSTRING(message_type,1,1) message_type, count(*) num from product_db_lift.product_sys_message m inner join product_db_lift.product_sys_message_user u on u.message_uuid=m.uuid \r\n" |
| | | sql.append("\nselect SUBSTRING(message_type,1,1) message_type, count(*) num from product_sys_message m inner join product_sys_message_user u on u.message_uuid=m.uuid \r\n" |
| | | + "and u.user_id=? and u.read_type=?").append(f).append(" group by SUBSTRING(message_type,1,1) "); |
| | | DataTableEntity dte = baseDao.listTable(sql.toString(),ps.toArray(),Integer.MAX_VALUE, 1); |
| | | return dte; |
| | | } |
| | | /** |
| | | * 统计分类型消息,会议、任务、最新消息、历史消息 |
| | | * @param fse |
| | | * @return |
| | | */ |
| | | public DataTableEntity getTypeMessage() { |
| | | |
| | | ArrayList<Object> ps= new ArrayList<Object>(); |
| | | SystemUser user=SpringMVCContextHolder.getCurrentUser(); |
| | | ps.add(user.getUser_id()); |
| | | StringBuilder sql = new StringBuilder(); |
| | | sql.append(" select read_type message_type, count(*) num from product_sys_message m inner join product_sys_message_user u on u.message_uuid=m.uuid \r\n" |
| | | + "and u.user_id=? ").append(" group by read_type "); |
| | | ///我的会议 |
| | | sql.append( " union all select 2 as message_type,count(*) num from product_oa_conference_apply where ( CONCAT(',',meeting_master,',') like '%,") |
| | | .append(user.getUser_id()).append(",%' ") |
| | | .append(" or CONCAT(',',meeting_recorder,',') like '%,") |
| | | .append(user.getUser_id()).append(",%'") |
| | | .append(" or CONCAT(',',participator,',') like '%,") |
| | | .append(user.getUser_id()).append(",%'") |
| | | .append(" ) and (start_time>now() or (start_time<now() and now()<end_time))" |
| | | ); |
| | | ///未结束的任务 |
| | | sql.append( " union all select 3 as message_type,count(*) num from product_oa_task_distribution where task_status=1 and finish_type=0 "); |
| | | sql.append( " and ( CONCAT(',',task_persons,',') like '%,").append(user.getUser_id()).append(",%' "); |
| | | DataTableEntity dt=baseDao.listTable("product_sys_org_levels", "org_level_leader_uuid=?", new String[] {user.getUuid()}); |
| | | |
| | | if(!DataTableEntity.isEmpty(dt)) { |
| | | for(int i=0;i<dt.getRows();i++) { |
| | | sql.append(" or CONCAT(',',task_org,',') like '%,").append(dt.getString(i, "uuid")).append(",%' "); |
| | | } |
| | | } |
| | | sql.append(" )"); |
| | | |
| | | DataTableEntity dte = baseDao.listTable(sql.toString(),ps.toArray()); |
| | | return dte; |
| | | } |
| | | |
| | | } |