| | |
| | | import com.product.common.collect.ListUtils; |
| | | import com.product.core.cache.DataPoolCacheImpl; |
| | | import com.product.core.config.CoreConst; |
| | | import com.product.core.connection.ConnectionManager; |
| | | import com.product.core.dao.BaseDao; |
| | | import com.product.core.entity.DataTableEntity; |
| | | import com.product.core.entity.FieldSetEntity; |
| | |
| | | import com.product.tool.table.enums.FieldType; |
| | | import com.product.util.BaseUtil; |
| | | import com.product.util.SystemParamReplace; |
| | | import com.product.util.UnifySQLFunction; |
| | | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | DataTableEntity data; |
| | | SystemUser user = SpringMVCContextHolder.getCurrentUser(); |
| | | StringBuffer sql = new StringBuffer(); |
| | | sql.append("SELECT a.*,ifnull(b.number,0) number FROM PRODUCT_OA_directory a LEFT JOIN "); |
| | | sql.append( |
| | | "(SELECT COUNT(*) number,directory_uuid FROM PRODUCT_OA_document GROUP BY directory_uuid) b on a.uuid=b.directory_uuid "); |
| | | sql.append("\nSELECT a.*,").append(UnifySQLFunction.ifnull("B.number", "0")).append(" AS number"); |
| | | sql.append("\nFROM product_oa_directory a"); |
| | | sql.append("\nLEFT JOIN ("); |
| | | sql.append("\n SELECT COUNT(*) AS number,directory_uuid"); |
| | | sql.append("\n FROM PRODUCT_OA_document"); |
| | | sql.append("\n GROUP BY directory_uuid"); |
| | | sql.append("\n) b ON a.uuid = b.directory_uuid "); |
| | | |
| | | if ("1".equals(directory_type)) { |
| | | String org_level_uuid = user.getOrg_level_uuid(); |
| | | sql.append("where directory_type = 1 AND org_level_uuid = ? "); |
| | | sql.append("WHERE directory_type = 1 AND org_level_uuid = ? "); |
| | | data = baseDao.listTable(sql.toString(), new Object[]{org_level_uuid}); |
| | | // data = baseDao.listTable(CmnConst.PRODUCT_OA_DIRECTORY, " directory_type = 1 AND org_level_uuid = ?", new String[]{org_level_uuid}, "tricode"); |
| | | // 个人文件夹 |
| | | } else { |
| | | Integer userId = user.getUser_id(); |
| | | sql.append("where directory_type = 2 AND created_by = ? "); |
| | | sql.append("WHERE directory_type = 2 AND created_by = ? "); |
| | | data = baseDao.listTable(sql.toString(), new Object[]{userId}); |
| | | |
| | | // data = baseDao.listTable(CmnConst.PRODUCT_OA_DIRECTORY, " directory_type = 2 AND created_by = ?", new Object[]{userId}, "tricode"); |
| | |
| | | if (!"1".equals(directory_type)) { |
| | | // 查询数量 |
| | | sql.setLength(0); |
| | | sql.append(" SELECT\n"); |
| | | sql.append(" ( SELECT count(*) FROM product_oa_document_collection WHERE document_collector = ? ) collection_count,\n"); |
| | | sql.append(" ( SELECT count(distinct sub_uuid ) FROM product_oa_document_borrow_sub WHERE borrow_uuid IN ( SELECT uuid FROM product_oa_document_borrow WHERE borrower = ? and flow_flag=2) ) borrow_count\n"); |
| | | sql.append(" FROM\n"); |
| | | sql.append("DUAL\n"); |
| | | sql.append("\nSELECT"); |
| | | sql.append("\n (SELECT count(*) FROM product_oa_document_collection WHERE document_collector = ? ) collection_count,"); |
| | | sql.append("\n (SELECT count(distinct sub_uuid ) FROM product_oa_document_borrow_sub WHERE borrow_uuid IN ( SELECT uuid FROM product_oa_document_borrow WHERE borrower = ? and flow_flag=2) ) borrow_count"); |
| | | if(ConnectionManager.DATABASE_TYPE_ORACLE.equals(ConnectionManager.getDatabaseType())) { |
| | | sql.append("\nFROM DUAL"); |
| | | } |
| | | FieldSetEntity fieldSetBySQL = baseDao.getFieldSetBySQL(sql.toString(), new Object[]{user.getUser_id(), user.getUser_id()}, false); |
| | | int collectionCount = 0; |
| | | int borrowCount = 0; |