using BLL;
using System;
using System.Linq;
using System.Web.Http;
using System.Threading.Tasks;
namespace WebAPI.Controllers
{
public class PersonSyncController : ApiController
{
#region 从分包拉取总包上的项目人员数据
///
/// 从分包拉取总包上的项目人员数据
///
///
public async Task getPersonLists()
{
var responeData = new Model.ResponeData();
try
{
responeData.code = 1;
responeData.data = APIPersonSyncService.getPersonLists();
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
#region 根据项目id和单位统一社会代码获取项目人员
///
/// 根据项目id和单位统一社会代码获取项目人员
///
///
public Model.ResponeData getPersonListByProjectIdAndCollCropCode(string projectId, string collCropCode)
{
var responeData = new Model.ResponeData();
try
{
responeData.code = 1;
var unit = BLL.Funs.DB.Base_Unit.FirstOrDefault(x => x.CollCropCode == collCropCode);
responeData.data = APIPersonSyncService.GetPersonLitsByProjectIdAndUnitId(projectId, unit.UnitId);
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
#region 分包推送项目人员数据到总包
///
/// 分包推送项目人员数据到总包
///
///
[HttpPost]
public async Task pushPersonLists(string projectId, string dataId)
{
var responeData = new Model.ResponeData();
try
{
var returndata = APIPersonSyncService.pushPersonLists(projectId, dataId);
responeData.code = returndata.code;
responeData.message = returndata.message;
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
#region 接收保存分包单位推送到总包的项目人员数据
///
/// 接收保存分包单位推送到总包的项目人员数据
///
/// HSSE数据
///
[HttpPost]
public async Task SavePersonSyncData([FromBody] Model.PersonSyncData newItem)
{
var responeData = new Model.ResponeData();
try
{
responeData.message = await APIPersonSyncService.SavePersonSyncData(newItem);
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
}
}