using BLL; using Model; using System; using System.Collections.Generic; using System.Web.Http; namespace WebAPI.Controllers { public class CQMSRewardAndPunishController : ApiController { /// /// 根据项目id获取质量奖罚列表集合 /// /// /// /// /// 0-全部,1-奖励,2-处罚 /// [HttpGet] public ResponseData> getRewardAndPunishList(string projectId, int index, int page, string type) { ResponseData> res = new ResponseData>(); res.successful = true; res.resultValue = BLL.RewardAndPunishService.getListDataForApi(projectId, index, page, type); return res; } /// /// 根据id获取质量奖罚详情 /// /// /// [HttpGet] public ResponseData GetRewardAndPunishByRewardAndPunishId(string id) { ResponseData res = new ResponseData(); RewardAndPunish_RewardAndPunish cd = BLL.RewardAndPunishService.GetRewardAndPunishByRewardAndPunishIdForApi(id); res.successful = true; res.resultValue = BeanUtil.CopyOjbect(cd, true); return res; } /// /// 根据id获取审核记录集合 /// /// /// public ResponseData> GetApproveById(string id) { ResponseData> res = new ResponseData>(); res.successful = true; res.resultValue = BLL.RewardAndPunishApproveService.GetListDataByIdForApi(id); return res; } /// /// 根据id获取当前办理人审批信息 /// /// /// public ResponseData GetCurrApproveById(string id) { ResponseData res = new ResponseData(); res.successful = true; res.resultValue = BeanUtil.CopyOjbect(BLL.RewardAndPunishApproveService.getCurrApproveForApi(id), true); return res; } /// /// 保存奖罚主表信息 /// /// /// [HttpPost] public ResponseData AddRewardAndPunish([FromBody] Model.RewardAndPunish_RewardAndPunish rewardAndPunish) { ResponseData res = new ResponseData(); try { if (string.IsNullOrEmpty(rewardAndPunish.RewardAndPunishId)) { rewardAndPunish.RewardAndPunishId = Guid.NewGuid().ToString(); BLL.RewardAndPunishService.AddRewardAndPunishForApi(rewardAndPunish); SaveAttachFile(rewardAndPunish.RewardAndPunishId, BLL.Const.RewardAndPunishMenuId, rewardAndPunish.AttachUrl); res.resultValue = rewardAndPunish.RewardAndPunishId; } else { BLL.RewardAndPunishService.UpdateRewardAndPunishForApi(rewardAndPunish); SaveAttachFile(rewardAndPunish.RewardAndPunishId, BLL.Const.RewardAndPunishMenuId, rewardAndPunish.AttachUrl); res.resultValue = rewardAndPunish.RewardAndPunishId; } res.successful = true; } catch (Exception e) { res.resultHint = e.StackTrace; res.successful = false; } return res; } public static void SaveAttachFile(string dataId, string menuId, string url) { Model.ToDoItem toDoItem = new Model.ToDoItem { MenuId = menuId, DataId = dataId, UrlStr = url, }; APIUpLoadFileService.SaveAttachUrl(toDoItem); } /// /// 新增办理信息 /// /// /// [HttpPost] public ResponseData AddApprove([FromBody] Model.RewardAndPunish_RewardAndPunishApprove approve) { ResponseData res = new ResponseData(); try { Model.RewardAndPunish_RewardAndPunish RewardAndPunish = new Model.RewardAndPunish_RewardAndPunish(); RewardAndPunish.RewardAndPunishId = approve.RewardAndPunishId; RewardAndPunish.State = approve.ApproveType; BLL.RewardAndPunishService.UpdateRewardAndPunishForApi(RewardAndPunish); res.resultValue = BLL.RewardAndPunishApproveService.AddRewardAndPunishApproveForApi(approve); res.successful = true; } catch (Exception e) { res.resultHint = e.StackTrace; res.successful = false; } return res; } /// /// 更新办理信息 /// /// /// [HttpPost] public ResponseData UpdateApprove([FromBody] Model.RewardAndPunish_RewardAndPunishApprove approve) { ResponseData res = new ResponseData(); try { approve.ApproveDate = DateTime.Now; BLL.RewardAndPunishApproveService.UpdateRewardAndPunishApproveForApi(approve); res.successful = true; } catch (Exception e) { res.resultHint = e.StackTrace; res.successful = false; } return res; } ///获取奖罚对象接口 Unit/getUnitByProjectIdUnitType(projectId,"2") /// /// 根据奖励或处罚获取奖罚事由 /// /// public Model.ResponeData getCause(string type) { var responeData = new Model.ResponeData(); try { responeData.data = APIBaseInfoService.getRewardAndPunishCause(type); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 根据奖罚事由Id获取奖罚决定 /// /// public Model.ResponeData getRewardAndPunishDecision(string typeId) { var responeData = new Model.ResponeData(); try { string rewardAndPunishDecision = string.Empty; Model.Base_RewardType rt = BLL.RewardTypeService.GetRewardTypeById(typeId); Model.Base_PunishType pt = BLL.PunishTypeService.GetPunishTypeById(typeId); if (rt != null) { rewardAndPunishDecision = rt.RewardDecision; } else if (pt != null) { rewardAndPunishDecision = pt.PunishDecision; } responeData.data = rewardAndPunishDecision; } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 根据状态获取办理步骤 0-重新编制,1-编制,2-质量经理审核,3-项目经理批准,C-审批完成 /// /// public Model.ResponeData getHandleListByState(string state) { var responeData = new Model.ResponeData(); try { responeData.data = RewardAndPunishService.GetDHandleTypeByStateForApi(state); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 根据是否同意和当前主表状态获取办理步骤 /// /// public Model.ResponeData getChangeHandle(bool isAgree,string state) { var responeData = new Model.ResponeData(); try { if (state == Const.RewardAndPunish_Audit2) { responeData.data = isAgree == true ? Const.RewardAndPunish_Complete : Const.RewardAndPunish_ReCompile; } else if (state == Const.RewardAndPunish_Audit1) { responeData.data = isAgree == true ? Const.RewardAndPunish_Audit2 : Const.RewardAndPunish_ReCompile; } } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 根据办理步骤获取办理人 /// /// public Model.ResponeData getHandleManListByState(string state, string id, string projectId) { var responeData = new Model.ResponeData(); try { responeData.data = RewardAndPunishService.GetHandleManListForApi(state, id, projectId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } } }