SGGL_SHJ/SGGL/WebAPI/Controllers/CQMS/CQMSRewardAndPunishControll...

285 lines
10 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using BLL;
using Model;
using System;
using System.Collections.Generic;
using System.Web.Http;
namespace WebAPI.Controllers
{
public class CQMSRewardAndPunishController : ApiController
{
/// <summary>
/// 根据项目id获取质量奖罚列表集合
/// </summary>
/// <param name="projectId"></param>
/// <param name="index"></param>
/// <param name="page"></param>
/// <param name="type">0-全部1-奖励2-处罚</param>
/// <returns></returns>
[HttpGet]
public ResponseData<List<RewardAndPunish_RewardAndPunish>> getRewardAndPunishList(string projectId, int index, int page, string type)
{
ResponseData<List<RewardAndPunish_RewardAndPunish>> res = new ResponseData<List<RewardAndPunish_RewardAndPunish>>();
res.successful = true;
res.resultValue = BLL.RewardAndPunishService.getListDataForApi(projectId, index, page, type);
return res;
}
/// <summary>
/// 根据id获取质量奖罚详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
public ResponseData<RewardAndPunish_RewardAndPunish> GetRewardAndPunishByRewardAndPunishId(string id)
{
ResponseData<RewardAndPunish_RewardAndPunish> res = new ResponseData<RewardAndPunish_RewardAndPunish>();
RewardAndPunish_RewardAndPunish cd = BLL.RewardAndPunishService.GetRewardAndPunishByRewardAndPunishIdForApi(id);
res.successful = true;
res.resultValue = BeanUtil.CopyOjbect<RewardAndPunish_RewardAndPunish>(cd, true);
return res;
}
/// <summary>
/// 根据id获取审核记录集合
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public ResponseData<List<RewardAndPunish_RewardAndPunishApprove>> GetApproveById(string id)
{
ResponseData<List<RewardAndPunish_RewardAndPunishApprove>> res = new ResponseData<List<RewardAndPunish_RewardAndPunishApprove>>();
res.successful = true;
res.resultValue = BLL.RewardAndPunishApproveService.GetListDataByIdForApi(id);
return res;
}
/// <summary>
/// 根据id获取当前办理人审批信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public ResponseData<RewardAndPunish_RewardAndPunishApprove> GetCurrApproveById(string id)
{
ResponseData<RewardAndPunish_RewardAndPunishApprove> res = new ResponseData<RewardAndPunish_RewardAndPunishApprove>();
res.successful = true;
res.resultValue = BeanUtil.CopyOjbect<RewardAndPunish_RewardAndPunishApprove>(BLL.RewardAndPunishApproveService.getCurrApproveForApi(id), true);
return res;
}
/// <summary>
/// 保存奖罚主表信息
/// </summary>
/// <param name="rewardAndPunish"></param>
/// <returns></returns>
[HttpPost]
public ResponseData<string> AddRewardAndPunish([FromBody] Model.RewardAndPunish_RewardAndPunish rewardAndPunish)
{
ResponseData<string> res = new ResponseData<string>();
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);
}
/// <summary>
/// 新增办理信息
/// </summary>
/// <param name="approve"></param>
/// <returns></returns>
[HttpPost]
public ResponseData<string> AddApprove([FromBody] Model.RewardAndPunish_RewardAndPunishApprove approve)
{
ResponseData<string> res = new ResponseData<string>();
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;
}
/// <summary>
/// 更新办理信息
/// </summary>
/// <param name="approve"></param>
/// <returns></returns>
[HttpPost]
public ResponseData<string> UpdateApprove([FromBody] Model.RewardAndPunish_RewardAndPunishApprove approve)
{
ResponseData<string> res = new ResponseData<string>();
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")
/// <summary>
/// 根据奖励或处罚获取奖罚事由
/// </summary>
/// <returns></returns>
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;
}
/// <summary>
/// 根据奖罚事由Id获取奖罚决定
/// </summary>
/// <returns></returns>
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;
}
/// <summary>
/// 根据状态获取办理步骤 0-重新编制1-编制2-质量经理审核3-项目经理批准C-审批完成
/// </summary>
/// <returns></returns>
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;
}
/// <summary>
/// 根据是否同意和当前主表状态获取办理步骤
/// </summary>
/// <returns></returns>
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;
}
/// <summary>
/// 根据办理步骤获取办理人
/// </summary>
/// <returns></returns>
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;
}
}
}