using System.Collections.Generic;
|
using System.Linq;
|
using CommonHelper;
|
using CommonHelper.Format;
|
using GasolineBlend.Entity;
|
using Pissa.Service.Extend;
|
using SqlSugar;
|
|
namespace Pissa.Service.DbService
|
{
|
public class SysService:Repository<SysCountry>
|
{
|
|
/// <summary>
|
/// 获取字典信息
|
/// </summary>
|
/// <param name="dictCode"></param>
|
/// <returns></returns>
|
public List<SysDictItem> GetDictItems(string dictCode)
|
{
|
var res = Context.Queryable<SysDictItem>()
|
.Where(a => a.DictId == SqlFunc.Subqueryable<SysDict>().Where(b => b.DictCode == dictCode)
|
.Select(b => b.Id))
|
.OrderBy(a=>a.SortOrder)
|
.ToList();
|
return res;
|
}
|
|
/// <summary>
|
/// 获取ipc
|
/// </summary>
|
/// <param name="year">年份</param>
|
/// <param name="parentCode">父编码</param>
|
/// <returns></returns>
|
public List<SysIpcClass> GetIpcClass(int year, string parentCode = "")
|
{
|
var res = Context.Queryable<SysIpcClass>()
|
.Where(a => a.Year == year)
|
.Where(a => a.ParentCode == parentCode)
|
.OrderBy(a => a.Sort1).OrderBy(a => a.Sort2)
|
.ToList();
|
return res;
|
}
|
|
/// <summary>
|
/// 获取cpc
|
/// </summary>
|
/// <param name="parentCode">父编码</param>
|
/// <returns></returns>
|
public List<SysCpcClass> GetCpcClass( string parentCode = "")
|
{
|
var res = Context.Queryable<SysCpcClass>()
|
.Where(a => a.ParentCode == parentCode)
|
.WhereIF(parentCode.IsNullOrEmpty(), a=>a.Code.Length ==1)
|
.OrderBy(a=>a.Sort1).OrderBy(a => a.Sort2)
|
.ToList();
|
return res;
|
}
|
/// <summary>
|
/// 获取产业分类
|
/// </summary>
|
/// <returns></returns>
|
public List<IviewTree> GetStraindustryTree()
|
{
|
var data = Context.Queryable<SysStraindustry>().OrderBy(a => a.Code).ToList();
|
var tree = TreeHelper.GenerateIviewTree(data, a => a.Code,
|
a => a.Code.Contains(".") ? a.Code.Substring(0, a.Code.IndexOf(".")) : null,
|
a => a.Code,
|
a=>a.Name
|
).ToList();
|
return tree;
|
}
|
|
/// <summary>
|
/// 获取国民经济行业分类
|
/// </summary>
|
/// <returns></returns>
|
public List<IviewTree> GetEcoindustryTree()
|
{
|
var data = Context.Queryable<SysEcoindustry>().OrderBy(a=>a.Code).ToList();
|
var tree = TreeHelper.GenerateIviewTree(data, a => a.Code,
|
a =>a.Code.Length>3?a.Code.Substring(0,a.Code.Length-1):(a.Code.Length==3?a.Code.Substring(0,1): null),
|
a => a.Code,
|
a => a.Name).ToList();
|
return tree;
|
}
|
|
/// <summary>
|
/// 插入搜索记录
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
public bool AddPatentSearchLog(SysPatentSearchLog model)
|
{
|
var id = Context.Insertable<SysPatentSearchLog>(model).ExecuteReturnIdentity();
|
return true;
|
}
|
/// <summary>
|
/// 获取搜索记录分页
|
/// </summary>
|
/// <param name="userId"></param>
|
/// <param name="pageIndex"></param>
|
/// <param name="pageSize"></param>
|
/// <returns></returns>
|
public Page<SysPatentSearchLog> GetPatentSearchLog(string userId, int pageIndex, int pageSize,string searchType)
|
{
|
if (pageIndex <= 0)
|
pageIndex = 1;
|
if (pageSize <= 0)
|
pageSize = 20;
|
|
var page = Context.Queryable<SysPatentSearchLog>()
|
.Where(a => a.UserId == userId)
|
.WhereIF(!string.IsNullOrWhiteSpace(searchType),a=>a.SearchType == searchType)
|
.OrderBy(a => a.SearchTime, OrderByType.Desc)
|
.ToPage(pageIndex, pageSize);
|
return page;
|
}
|
/// <summary>
|
/// 洛迦诺分类
|
/// </summary>
|
/// <returns></returns>
|
public List<IviewTree> GetLoccn()
|
{
|
var data = Context.Queryable<SysLoccn>().OrderBy(a => a.Sort1).OrderBy(a=>a.Sort2).ToList();
|
var tree = TreeHelper.GenerateIviewTree(data, a => a.Code,
|
a => a.ParentCode,
|
a => a.Code,
|
a => a.Desc).ToList();
|
return tree;
|
}
|
|
}
|
}
|