137 lines
4.0 KiB
C#
137 lines
4.0 KiB
C#
using BLL;
|
||
using System;
|
||
using System.Linq;
|
||
using System.Web.Http;
|
||
using System.Threading.Tasks;
|
||
|
||
namespace WebAPI.Controllers
|
||
{
|
||
/// <summary>
|
||
/// 质量巡检同步控制器
|
||
/// </summary>
|
||
public class CheckControlSyncController : ApiController
|
||
{
|
||
#region 拉取质量巡检数据
|
||
|
||
/// <summary>
|
||
/// 拉取质量巡检数据
|
||
/// </summary>
|
||
/// <returns>响应数据</returns>
|
||
[HttpGet]
|
||
public Model.ResponeData getCheckControlLists()
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
responeData.code = 1;
|
||
responeData.data = APICheckControlSyncService.getCheckControlLists();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
|
||
#endregion
|
||
|
||
|
||
#region 获取质量巡检数据根据项目id和单位统一社会代码
|
||
|
||
/// <summary>
|
||
/// 获取质量巡检数据根据项目id和单位统一社会代码
|
||
/// </summary>
|
||
/// <param name="projectId">项目ID</param>
|
||
/// <param name="collCropCode">单位社会统一信用代码</param>
|
||
/// <returns>响应数据</returns>
|
||
[HttpGet]
|
||
public Model.ResponeData getCheckControlListByProjectIdAndCollCropCode(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);
|
||
if (unit != null)
|
||
{
|
||
responeData.data = APICheckControlSyncService.GetCheckControlListsByProjectIdUnitIdPage(projectId, unit.UnitId);
|
||
}
|
||
else
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "未找到对应单位";
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
|
||
#endregion
|
||
|
||
|
||
#region 推送质量巡检数据
|
||
|
||
/// <summary>
|
||
/// 推送质量巡检数据
|
||
/// </summary>
|
||
/// <param name="projectId">项目ID</param>
|
||
/// <param name="dataId">数据ID(可选)</param>
|
||
/// <returns>响应数据</returns>
|
||
[HttpPost]
|
||
public Model.ResponeData pushCheckControlLists(string projectId, string dataId)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
var returndata = APICheckControlSyncService.pushCheckControlLists(projectId, dataId);
|
||
responeData.code = returndata.code;
|
||
responeData.message = returndata.message;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
|
||
#endregion
|
||
|
||
|
||
#region 接收保存质量巡检数据
|
||
|
||
/// <summary>
|
||
/// 接收保存质量巡检数据
|
||
/// </summary>
|
||
/// <param name="newItem">质量巡检同步数据</param>
|
||
/// <returns>响应数据</returns>
|
||
[HttpPost]
|
||
public Model.ResponeData SaveCheckControlSyncData([FromBody] Model.CheckControlSyncData newItem)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
responeData.code = 1;
|
||
responeData.message = APICheckControlSyncService.SaveCheckControlSyncData(newItem);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
|
||
#endregion
|
||
}
|
||
}
|