2022-09-05 16:36:31 +08:00
|
|
|
using EmitMapper;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace BLL
|
|
|
|
|
{
|
|
|
|
|
public static class APIUnitService
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据UnitId获取单位信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="unitId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static Model.UnitItem getUnitByUnitId(string unitId)
|
|
|
|
|
{
|
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var getUnit = db.Base_Unit.FirstOrDefault(x => x.UnitId == unitId);
|
|
|
|
|
return ObjectMapperManager.DefaultInstance.GetMapper<Model.Base_Unit, Model.UnitItem>().Map(getUnit);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取所有单位信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="unitId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<Model.BaseInfoItem> getUnitLists()
|
|
|
|
|
{
|
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var units = (from x in db.Base_Unit
|
|
|
|
|
orderby x.UnitName
|
|
|
|
|
select new Model.BaseInfoItem { BaseInfoId = x.UnitId, BaseInfoCode = x.UnitCode, BaseInfoName = x.UnitName }).ToList();
|
2023-03-16 14:35:01 +08:00
|
|
|
return units;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取项目所有单位信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="projectId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<Model.BaseInfoItem> getProjectUnitLists(string projectId)
|
|
|
|
|
{
|
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var units = (from x in db.Base_Unit
|
|
|
|
|
join y in db.Project_ProjectUnit
|
|
|
|
|
on x.UnitId equals y.UnitId
|
|
|
|
|
where y.ProjectId == projectId
|
|
|
|
|
orderby x.UnitName
|
|
|
|
|
select new Model.BaseInfoItem { BaseInfoId = x.UnitId, BaseInfoCode = x.UnitCode, BaseInfoName = x.UnitName }).ToList();
|
2022-09-05 16:36:31 +08:00
|
|
|
return units;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据projectId、unitType获取单位信息(总包1;施工分包2;监理3;业主4;其他5)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="unitId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<Model.UnitItem> getUnitByProjectIdUnitType(string projectId, string unitType)
|
|
|
|
|
{
|
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
List<Model.Base_Unit> units = new List<Model.Base_Unit>();
|
|
|
|
|
if (unitType != Const.ProjectUnitType_2)
|
|
|
|
|
{
|
|
|
|
|
units = (from x in db.Base_Unit
|
|
|
|
|
join y in db.Project_ProjectUnit
|
|
|
|
|
on x.UnitId equals y.UnitId
|
|
|
|
|
where y.ProjectId == projectId && (y.UnitType == unitType || unitType == null)
|
|
|
|
|
orderby x.UnitName
|
|
|
|
|
select x).ToList();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
units = (from x in db.Base_Unit
|
|
|
|
|
join y in db.Project_ProjectUnit
|
|
|
|
|
on x.UnitId equals y.UnitId
|
|
|
|
|
where y.ProjectId == projectId && (y.UnitType == BLL.Const.ProjectUnitType_2 || y.UnitType == BLL.Const.ProjectUnitType_6)
|
|
|
|
|
orderby x.UnitName
|
|
|
|
|
select x).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ObjectMapperManager.DefaultInstance.GetMapper<List<Model.Base_Unit>, List<Model.UnitItem>>().Map(units.ToList());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据projectId、unitType获取单位信息(总包1;施工分包2;监理3;业主4;其他5)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="unitId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<Model.UnitItem> getUnitByProjectIdUnitTypeQuery(string projectId, string strParam, string unitType)
|
|
|
|
|
{
|
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
List<Model.Base_Unit> units = new List<Model.Base_Unit>();
|
|
|
|
|
if (unitType != Const.ProjectUnitType_2)
|
|
|
|
|
{
|
|
|
|
|
units = (from x in db.Base_Unit
|
|
|
|
|
join y in db.Project_ProjectUnit
|
|
|
|
|
on x.UnitId equals y.UnitId
|
|
|
|
|
where y.ProjectId == projectId && (strParam == null || x.UnitName.Contains(strParam))
|
|
|
|
|
&& (y.UnitType == unitType || unitType == null)
|
|
|
|
|
orderby x.UnitName
|
|
|
|
|
select x).ToList();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
units = (from x in db.Base_Unit
|
|
|
|
|
join y in db.Project_ProjectUnit
|
|
|
|
|
on x.UnitId equals y.UnitId
|
|
|
|
|
where y.ProjectId == projectId && (strParam == null || x.UnitName.Contains(strParam))
|
|
|
|
|
&& (y.UnitType == BLL.Const.ProjectUnitType_2 || y.UnitType == BLL.Const.ProjectUnitType_6)
|
|
|
|
|
orderby x.UnitName
|
|
|
|
|
select x).ToList();
|
|
|
|
|
}
|
|
|
|
|
return ObjectMapperManager.DefaultInstance.GetMapper<List<Model.Base_Unit>, List<Model.UnitItem>>().Map(units.ToList());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|