using BLL;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
namespace WebAPI.Controllers
{
///
/// 焊接日报
///
public class PreWeldingDailyController : ApiController
{
#region 根据主键获取详细
///
/// 根据主键获取详细
///
///
///
public Model.ResponeData getWeldingDailyInfo(string weldingDailyId, string unitWorkId)
{
var responeData = new Model.ResponeData();
try
{
responeData.data = APIPreWeldingDailyService.getWeldingDailyInfo(weldingDailyId, unitWorkId);
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
#region 列表-查询
///
/// 列表-查询
///
///
///
///
public Model.ResponeData getPreWeldingDailyList(string projectId, int pageIndex)
{
var responeData = new Model.ResponeData();
try
{
var getDataList = APIPreWeldingDailyService.getPreWeldingDailyList(projectId);
int pageCount = getDataList.Count();
if (pageCount > 0 && pageIndex > 0)
{
getDataList = getDataList.Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList();
}
responeData.data = new { pageCount, getDataList };
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
#region 根据日期、单位工程Id获取日报记录
///
/// 根据日期、单位工程Id获取日报记录
///
/// 日期
/// 单位工程Id
///
public Model.ResponeData GetWeldingDailyList(string date, string unitWorkId)
{
var responeData = new Model.ResponeData();
try
{
responeData.data = APIPreWeldingDailyService.GetWeldingDailyList(date, unitWorkId);
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
#region 获取焊接任务单记录
///
/// 获取日报明细记录
///
/// 日报id
/// 单位工程id
/// 焊接日期
/// 项目id
///
[HttpGet]
public ResponseData> GetWeldingTasks(string weldingDailyId, string unitWorkId, string date, string projectId)
{
ResponseData> res = new ResponseData>();
res.successful = true;
res.resultValue = BLL.APIPreWeldingDailyService.GetWeldingTasks(weldingDailyId, unitWorkId, date, projectId);
return res;
}
#endregion
#region 保存焊接日报
///
/// 保存WeldingDaily
///
/// 施工方案
///
[HttpPost]
public Model.ResponseData SaveWeldingDaily([FromBody] Model.HJGL_WeldingDaily newItem)
{
ResponseData res = new ResponseData();
try
{
if (string.IsNullOrEmpty(newItem.WeldingDailyId))
{
newItem.WeldingDailyId = Guid.NewGuid().ToString();
APIPreWeldingDailyService.SaveWeldingDaily(newItem);
res.resultValue = newItem.WeldingDailyId;
}
else
{
APIPreWeldingDailyService.SaveWeldingDaily(newItem);
res.resultValue = newItem.WeldingDailyId;
}
APIPreWeldingDailyService.SaveWeldingDaily(newItem);
}
catch (Exception ex)
{
res.successful = false;
}
res.successful = true;
return res;
}
///
/// 根据焊口id保存到日报
///
///
///
///
///
[HttpGet]
public Model.ResponeData SaveWeldingDailyByWeldJointId(string WeldJointId,string Personid,string time)
{
var responeData = new Model.ResponeData();
try
{
string res= APIPreWeldingDailyService.SaveWeldingDailyByWeldJointId(WeldJointId, Personid,time );
if (!string.IsNullOrEmpty(res))
{
responeData.code = 0;
responeData.message = res;
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
///
/// 根据焊口id保存到日报(增加焊接位置参数)
///
///
///
///
///
///
[HttpGet]
public Model.ResponeData SaveWeldingDailyByWeldJointId(string WeldJointId, string Personid, string time,string weldingLocation)
{
var responeData = new Model.ResponeData();
try
{
string res = APIPreWeldingDailyService.SaveWeldingDailyByWeldJointId(WeldJointId, Personid, time, weldingLocation);
if (!string.IsNullOrEmpty(res))
{
responeData.code = 0;
responeData.message = res;
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
///
/// 根据焊口id保存到日报
///
/// 焊口号
/// 人员ID
/// 时间
/// 焊接位置
/// 焊工类型
///
[HttpGet]
public Model.ResponeData SaveWeldingDailyByWeldJointId(string WeldJointId, string Personid, string time,string weldingLocation,int welderType)
{
var responeData = new Model.ResponeData();
try
{
string res = APIPreWeldingDailyService.SaveWeldingDailyByWeldJointId(WeldJointId, Personid, time, weldingLocation, welderType);
if (!string.IsNullOrEmpty(res))
{
responeData.code = 0;
responeData.message = res;
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
///
/// 根据焊口id保存到日报,并保存焊前、焊后附件
///
/// 焊口日报和附件参数
///
[HttpPost]
public Model.ResponeData SaveWeldingDailyByWeldJointId([FromBody] Model.WeldingDailyByWeldJointAttachItem newItem)
{
var responeData = new Model.ResponeData();
try
{
string res = APIPreWeldingDailyService.SaveWeldingDailyByWeldJointIdWithAttach(newItem);
if (!string.IsNullOrEmpty(res))
{
responeData.code = 0;
responeData.message = res;
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
#region 更新焊接日报焊口信息
///
/// 更新焊接日报焊口信息
///
/// 日报明细项
///
[HttpPost]
public Model.ResponeData SaveWeldingDailyDetail([FromBody] Model.WeldingDailyItem newItem)
{
var responeData = new Model.ResponeData();
try
{
APIPreWeldingDailyService.SaveWeldingDailyDetail(newItem.WeldingDailyId, newItem.SelectIds, newItem.NotSelectIds, newItem.ProjectId);
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
#region 保存焊接日报
///
/// 保存PreWeldingDaily
///
/// 施工方案
///
[HttpPost]
public Model.ResponeData SavePreWeldingDaily([FromBody] Model.HJGL_PreWeldingDailyItem newItem)
{
var responeData = new Model.ResponeData();
try
{
APIPreWeldingDailyService.SavePreWeldingDaily(newItem);
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
#region 焊接日报待审核
///
/// 获取焊接日报待审核列表。
///
/// 项目ID
/// 单位工程ID,可为空
/// 焊接日期,可为空,格式如 yyyy-MM-dd
/// 管线编号关键字,可为空
/// 焊工编号关键字,可为空
/// 页码,从1开始;小于等于0时返回全部记录
/// 待审核明细列表及总记录数
[HttpGet]
public Model.ResponeData GetPendingWeldingDailyTempDetailList(string projectId,
string unitWorkId = null, string weldingDate = null, string pipelineCode = null,
string welderCode = null, int pageIndex = 0)
{
var responeData = new Model.ResponeData();
try
{
if (string.IsNullOrWhiteSpace(projectId))
{
responeData.code = 0;
responeData.message = "项目ID不能为空";
return responeData;
}
var getDataList = APIWeldReportService.GetPendingWeldingDailyTempDetailList(
projectId, unitWorkId, weldingDate, pipelineCode, welderCode);
int pageCount = getDataList.Count;
if (pageCount > 0 && pageIndex > 0)
{
getDataList = getDataList.Skip(Funs.PageSize * (pageIndex - 1))
.Take(Funs.PageSize).ToList();
}
responeData.data = new { pageCount, getDataList };
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
///
/// 查看单条焊接日报待审核明细。
///
/// 待审核明细ID
/// 待审核明细
[HttpGet]
public Model.ResponeData GetPendingWeldingDailyTempDetail(string tempDetailId)
{
var responeData = new Model.ResponeData();
try
{
responeData.data = APIWeldReportService.GetPendingWeldingDailyTempDetail(tempDetailId);
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
///
/// 批量审核通过焊接日报待审核明细。
///
/// 批量审核参数
/// 批量处理结果
[HttpPost]
public Model.ResponeData AuditPendingWeldingDailyTempDetails(
[FromBody] Model.WeldingDailyTempDetailBatchRequest request)
{
var responeData = new Model.ResponeData();
try
{
if (request == null)
{
responeData.code = 0;
responeData.message = "参数不能为空";
return responeData;
}
string errlog = APIWeldReportService.AuditPendingWeldingDailyTempDetails(
request.TempDetailIds, request.AuditMan);
if (!string.IsNullOrEmpty(errlog))
{
responeData.code = 0;
responeData.message = errlog;
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
///
/// 批量删除焊接日报待审核明细。
///
/// 批量删除参数
/// 批量处理结果
[HttpPost]
public Model.ResponeData DeletePendingWeldingDailyTempDetails(
[FromBody] Model.WeldingDailyTempDetailBatchRequest request)
{
var responeData = new Model.ResponeData();
try
{
if (request == null)
{
responeData.code = 0;
responeData.message = "参数不能为空";
return responeData;
}
string errlog = APIWeldReportService.DeletePendingWeldingDailyTempDetails(request.TempDetailIds);
if (!string.IsNullOrEmpty(errlog))
{
responeData.code = 0;
responeData.message = errlog;
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
}
}