using BLL; using System; using System.Collections.Generic; using System.Linq; using System.Web.Http; namespace WebAPI.Controllers { /// /// 隐患整改单 /// public class RectifyNoticesController : ApiController { #region 根据Id获取隐患整改单 /// /// 根据Id获取隐患整改单 /// /// /// public Model.ResponeData getRectifyNoticesById(string rectifyNoticesId) { var responeData = new Model.ResponeData(); try { responeData.data = BLL.APIRectifyNoticesService.getRectifyNoticesById(rectifyNoticesId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 根据projectId、states获取隐患整改单 /// /// 根据projectId、states获取隐患整改单 /// /// /// 状态 0待提交;1待签发;2待整改;3待审核;4待复查;5已完成 /// 页码 /// public Model.ResponeData getRectifyNoticesByProjectIdStates(string projectId, string states, int pageIndex) { var responeData = new Model.ResponeData(); try { List getDataList = new List(); int pageCount = Funs.DB.Check_RectifyNotices.Count(x => x.ProjectId == projectId && (x.States == states || states == null)); if (pageCount > 0 && pageIndex > 0) { getDataList = BLL.APIRectifyNoticesService.getRectifyNoticesByProjectIdStates(projectId, states, pageIndex); } responeData.data = new { pageCount, getDataList }; } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 根据projectId获取各状态风险数 /// /// 根据projectId获取各状态风险数 /// /// /// public Model.ResponeData getRectifyNoticesCount(string projectId) { var responeData = new Model.ResponeData(); try { //总数 0待提交;1待签发;2待整改;3待审核;4待复查;5已完成 var getDataList = Funs.DB.Check_RectifyNotices.Where(x => x.ProjectId == projectId); int tatalCount = getDataList.Count(); //待提交 0 int count0 = getDataList.Where(x => x.States == "0").Count(); //待签发 1 int count1 = getDataList.Where(x => x.States == "1").Count(); //待整改 2 int count2 = getDataList.Where(x => x.States == "2").Count(); //待审核 3 int count3 = getDataList.Where(x => x.States == "3").Count(); //待复查 4 int count4 = getDataList.Where(x => x.States == "4").Count(); //已完成 5 int count5 = getDataList.Where(x => x.States == "5").Count(); responeData.data = new { tatalCount, count0, count1, count2, count3, count4, count5 }; } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 保存RectifyNotices /// /// 保存RectifyNotices /// /// /// [HttpPost] public Model.ResponeData SaveRectifyNotices([FromBody] Model.RectifyNoticesItem rectifyNotices) { var responeData = new Model.ResponeData(); try { BLL.APIRectifyNoticesService.SaveRectifyNotices(rectifyNotices); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion } }