using BLL; using System; using System.Linq; using System.Web.Http; namespace WebAPI.Controllers { /// /// 基础数据信息 /// public class BaseInfoController : ApiController { #region 获取项目列表 /// /// 获取项目列表 /// /// public Model.ResponeData getProjectList() { var responeData = new Model.ResponeData(); try { responeData.data = BLL.APIBaseInfoService.getProjectList(); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 根据项目号获取项目信息 /// /// 根据项目号获取项目信息 /// /// /// public Model.ResponeData getProjectByCode(string projectCode) { var responeData = new Model.ResponeData(); try { responeData.data = BLL.APIBaseInfoService.getProjectByCode(projectCode); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 根据projectId获取单位工程 /// /// 根据projectId获取单位工程 /// /// /// public Model.ResponeData getProjectWorkArea(string projectId) { var responeData = new Model.ResponeData(); try { responeData.data = BLL.APIBaseInfoService.getProjectWorkArea(projectId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 获取单位工程下分部分项 /// /// /// /// public Model.ResponeData getProjectWBSByUnitWorkId(string projectId, string unitWorkId) { var responeData = new Model.ResponeData(); try { responeData.data = BLL.APIBaseInfoService.getProjectWBSByUnitWorkId(projectId, unitWorkId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 根据项目,单位Id获取单位工程 /// /// /// /// public Model.ResponeData GetProjecUnitWorkByUnitId(string projectId, string unitId) { var responeData = new Model.ResponeData(); try { responeData.data = BLL.APIBaseInfoService.GetProjecUnitWorkByUnitId(projectId, unitId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 获取焊接基础信息 /// /// 获取材质列表 /// /// public Model.ResponeData GetMaterial() { var responeData = new Model.ResponeData(); try { responeData.data = BLL.APIBaseInfoService.GetMaterial(); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 根据入库条码获取材料信息 /// /// /// public Model.ResponeData GetMaterialInfoByMaterialCode(string materialCode) { var responeData = new Model.ResponeData(); try { responeData.data = BLL.MaterialCodeLibService.GetBarCodeMaterialInfo(materialCode); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 根据入库条码保存数量 /// [HttpPost] public Model.ResponeData SaveMaterialInfoByBarCode(string barCode, decimal quantity) { var responeData = new Model.ResponeData(); try { responeData.data = BLL.MaterialCodeLibService.SaveBarCodeQuantity(barCode, quantity); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 获取焊接方法 /// /// public Model.ResponeData GetWeldingMethod() { var responeData = new Model.ResponeData(); try { responeData.data = BLL.APIBaseInfoService.GetWeldingMethod(); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 获取焊缝类型 /// /// public Model.ResponeData GetWeldType() { var responeData = new Model.ResponeData(); try { responeData.data = BLL.APIBaseInfoService.GetWeldType(); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 按类型获取焊接耗材。 /// /// 焊材类型:1焊丝,2焊条 /// 焊接耗材列表 public Model.ResponeData GetWeldingConsumables(string consumablesType) { var responeData = new Model.ResponeData(); try { responeData.data = BLL.APIBaseInfoService.GetWeldingConsumables(consumablesType); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 获取探伤类型 /// /// public Model.ResponeData getDetectionType() { var responeData = new Model.ResponeData(); try { responeData.data = BLL.APIBaseInfoService.getDetectionType(); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 获取探伤比例 /// /// public Model.ResponeData getDetectionRate() { var responeData = new Model.ResponeData(); try { responeData.data = BLL.APIBaseInfoService.getDetectionRate(); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 获取坡口类型 /// /// public Model.ResponeData getGrooveType() { var responeData = new Model.ResponeData(); try { responeData.data = BLL.APIBaseInfoService.getGrooveType(); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 获取通知通告 /// /// 获取头条通知 /// /// public Model.ResponeData getTopNotices() { var responeData = new Model.ResponeData(); try { Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString); string returnValue = string.Empty; var notice = (from x in db.InformationProject_Notice where x.IsRelease == true orderby x.ReleaseDate descending select x).FirstOrDefault(); if (notice != null) { returnValue = notice.NoticeTitle; } responeData.data = new { returnValue }; } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 根据项目ID通知通告 /// /// /// /// public Model.ResponeData getNotices(string projectId, int pageIndex) { var responeData = new Model.ResponeData(); try { var noticeList = APIBaseInfoService.getNoticesList(projectId, null); int pageCount = noticeList.Count(); if (pageCount > 0 && pageIndex > 0) { noticeList = noticeList.OrderByDescending(u => u.ReleaseDate).Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList(); } responeData.data = new { pageCount, noticeList }; } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 根据项目ID通知通告 /// /// 项目ID /// 查询条件 /// /// public Model.ResponeData getNoticesQuery(string projectId, string strParam, int pageIndex) { var responeData = new Model.ResponeData(); try { var noticeList = APIBaseInfoService.getNoticesList(projectId, strParam); int pageCount = noticeList.Count(); if (pageCount > 0 && pageIndex > 0) { noticeList = noticeList.OrderByDescending(u => u.ReleaseDate).Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList(); } responeData.data = new { pageCount, noticeList }; } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 根据项目ID通知通告 /// /// 项目ID /// 用户ID /// 查询条件 /// /// public Model.ResponeData getNoticesQuery(string projectId, string userId, string strParam, int pageIndex) { var responeData = new Model.ResponeData(); try { var noticeList = APIBaseInfoService.getNoticesList(projectId, userId, strParam); int pageCount = noticeList.Count(); if (pageCount > 0 && pageIndex > 0) { noticeList = noticeList.Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList(); } responeData.data = new { pageCount, noticeList }; } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 根据noticeId获取通知通告详细 /// /// /// public Model.ResponeData getNoticesByNoticeId(string noticeId) { var responeData = new Model.ResponeData(); try { responeData.data = APIBaseInfoService.getNoticesByNoticeId(noticeId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 获取岗位信息 /// /// 获取岗位信息 /// /// public Model.ResponeData getWorkPost() { var responeData = new Model.ResponeData(); try { responeData.data = APIBaseInfoService.getWorkPost(null); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 获取岗位信息 /// /// public Model.ResponeData getWorkPostQuery(string strParam) { var responeData = new Model.ResponeData(); try { responeData.data = APIBaseInfoService.getWorkPost(strParam); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 获取培训类别 /// /// 获取培训类别 /// /// public Model.ResponeData getTrainType() { var responeData = new Model.ResponeData(); try { responeData.data = APIBaseInfoService.getTrainType(); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 获取培训级别 /// /// 获取培训级别 /// /// public Model.ResponeData getTrainLevel() { var responeData = new Model.ResponeData(); try { responeData.data = APIBaseInfoService.getTrainLevel(); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 获取机具类型 /// /// 获取机具类型 /// /// 是否特殊 /// public Model.ResponeData getSpecialEquipment(bool isSpecial) { var responeData = new Model.ResponeData(); try { responeData.data = APIBaseInfoService.getSpecialEquipment(isSpecial); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 获取工作阶段 /// /// 获取施工方案类别 /// /// public Model.ResponeData getWorkStage() { var responeData = new Model.ResponeData(); try { responeData.data = APIBaseInfoService.getWorkStage(); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 获取项目班组 /// /// 获取项目班组 /// /// /// /// public Model.ResponeData getTeamGroup(string projectId, string unitId) { var responeData = new Model.ResponeData(); try { responeData.data = APIBaseInfoService.getTeamGroup(projectId, unitId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 获取项目班组人数 /// /// /// public Model.ResponeData getTeamGroupPersonNum(string teamGroupId) { var responeData = new Model.ResponeData(); try { responeData.data = TeamGroupService.getTeamGroupPersonNum(teamGroupId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 获取项目班组人数 /// /// /// public Model.ResponeData getTeamGroupLeader(string teamGroupId) { var responeData = new Model.ResponeData(); try { responeData.data = APIBaseInfoService.getTeamGroupLeader(teamGroupId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 获取项目区域 /// /// 获取项目区域 /// /// /// /// public Model.ResponeData getWorkArea(string projectId, string unitId) { var responeData = new Model.ResponeData(); try { responeData.data = APIBaseInfoService.getWorkArea(projectId, unitId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 获取项目图片分类 /// /// 获取项目图片分类 /// /// public Model.ResponeData getPictureType() { var responeData = new Model.ResponeData(); try { responeData.data = APIBaseInfoService.getPictureType(null); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 获取项目图片分类 /// /// public Model.ResponeData getPictureType(string menuType) { var responeData = new Model.ResponeData(); try { responeData.data = APIBaseInfoService.getPictureType(menuType); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 获取岗位类型 /// /// 获取岗位类型 /// /// public Model.ResponeData getPostType() { var responeData = new Model.ResponeData(); try { responeData.data = APIBaseInfoService.getSysConst(ConstValue.Group_PostType); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 获取特岗证书 /// /// 获取特岗证书 /// /// public Model.ResponeData getCertificate() { var responeData = new Model.ResponeData(); try { responeData.data = APIBaseInfoService.getCertificate(); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 获取部门信息 /// /// 获取部门信息 /// /// public Model.ResponeData getDepart() { var responeData = new Model.ResponeData(); try { responeData.data = APIBaseInfoService.getDepart(); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 获取国家基础信息 /// /// 获取应急预案类型 /// /// public Model.ResponeData getCountry() { var responeData = new Model.ResponeData(); try { responeData.data = APIBaseInfoService.getCountry(); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 获取省份基础信息 /// /// 获取应急预案类型 /// /// public Model.ResponeData getProvinceByCountry(string countryId) { var responeData = new Model.ResponeData(); try { responeData.data = APIBaseInfoService.getProvinceByCountry(countryId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 获取实名制数据字典信息 /// /// 获取实名制数据字典信息 /// /// public Model.ResponeData getBasicDataByDictTypeCode(string dictTypeCode) { var responeData = new Model.ResponeData(); try { responeData.data = APIBaseInfoService.getBasicDataByDictTypeCode(dictTypeCode); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 获取焊接位置 /// /// 获取焊接位置 /// /// public Model.ResponeData getWeldingLocation() { var responeData = new Model.ResponeData(); try { responeData.data = APIBaseInfoService.GetWeldingLocationList(); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion /// /// 分页查询入库条码明细。 /// [HttpGet] public Model.ResponeData GetInputDetailBarCodes(string barCodeKeyword, int pageIndex = 1, int pageSize = 20) { var responeData = new Model.ResponeData(); try { pageIndex = pageIndex < 1 ? 1 : pageIndex; pageSize = pageSize < 1 ? 20 : Math.Min(pageSize, 200); var result = APIBaseInfoService.GetInputDetailBarCodes(barCodeKeyword, pageIndex, pageSize); int totalCount = result.Item2; int pageCount = totalCount == 0 ? 0 : (int)Math.Ceiling(totalCount / (double)pageSize); responeData.data = new { pageCount, totalCount, getDataList = result.Item1 }; } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } } }