|
- using System;
- using Nancy;
- using Learun.Util;
- using System.Collections.Generic;
- using Learun.Application.TwoDevelopment.LogisticsManagement;
- using Learun.Application.TwoDevelopment.AssetManagementSystem;
- using Learun.Application.WorkFlow;
-
- namespace Learun.Application.WebApi
- {
- /// <summary>
- /// 版 本 Learun-ADMS V7.0.6 数字化智慧校园
- /// Copyright (c) 2013-2020 北京泉江科技有限公司
- /// 创 建:超级管理员
- /// 日 期:2022-11-21 10:09
- /// 描 述:考勤记录
- /// </summary>
- public class FundsApplyApi : BaseApi
- {
- private FundsApplyIBLL fundsApplyIBLL = new FundsApplyBLL();
- private FundsApplyDetailIBLL fundsApplyDetailIBLL = new FundsApplyDetailBLL();
- private NWFProcessIBLL nWFProcessIBLL = new NWFProcessBLL();
-
- /// <summary>
- /// 注册接口
- /// <summary>
- public FundsApplyApi()
- : base("/learun/adms/FundsApply")
- {
- Get["/pagelist"] = GetPageList;
- Get["/form"] = GetForm;
- Get["/getEnCode"] = GetEnCode;
- Post["/delete"] = DeleteForm;
- Post["/save"] = SaveForm;
- Post["/submit"] = Submit;
- Get["/shList"] = GetshList;
- }
- #region 获取数据
-
- /// <summary>
- /// 获取页面显示列表分页数据
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetPageList(dynamic _)
- {
- ReqPageParam parameter = this.GetReqData<ReqPageParam>();
- var data = fundsApplyIBLL.GetPageList(parameter.pagination, parameter.queryJson);
- var jsonData = new
- {
- rows = data,
- total = parameter.pagination.total,
- page = parameter.pagination.page,
- records = parameter.pagination.records
- };
- return Success(jsonData);
- }
- /// <summary>
- /// 获取表单数据
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetForm(dynamic _)
- {
- string keyValue = this.GetReqData();
- var FundsApplyData = fundsApplyIBLL.GetFundsApplyEntity(keyValue);
- var FundsApplyDetailData = fundsApplyDetailIBLL.GetListByApplyId(keyValue);
- var jsonData = new
- {
- FundsApply = FundsApplyData,
- FundsApplyDetail = FundsApplyDetailData,
- };
- return Success(jsonData);
- }
-
- /// <summary>
- /// 获取申请单号
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetEnCode(dynamic _)
- {
- var jsonData = new
- {
- EnCode = fundsApplyIBLL.GetCode()
- };
- return Success(jsonData);
- }
-
- /// <summary>
- /// 获取页面显示列表数据
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetshList(dynamic _)
- {
- FundsApplyEntity parameter = this.GetReqData<FundsApplyEntity>();
- var FundsApplyData = fundsApplyIBLL.GetEntityByProcessId(parameter.ProcessId);
- var FundsApplyDetailData = fundsApplyDetailIBLL.GetListByApplyId(FundsApplyData.Id);
- var jsonData = new
- {
- FundsApply = FundsApplyData,
- FundsApplyDetail = FundsApplyDetailData,
- };
- return Success(jsonData);
- }
- #endregion
-
- #region 提交数据
-
- /// <summary>
- /// 删除实体数据
- /// <param name="_"></param>
- /// <summary>
- /// <returns></returns>
- public Response DeleteForm(dynamic _)
- {
- string keyValue = this.GetReqData();
- fundsApplyIBLL.DeleteEntity(keyValue);
- return Success("删除成功!");
- }
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="_"></param>
- /// <summary>
- /// <returns></returns>
- public Response SaveForm(dynamic _)
- {
- ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
- FundsApplyEntity entity = parameter.strEntity.ToObject<FundsApplyEntity>();
- List<FundsApplyDetailEntity> detailList = parameter.fundsApplyDetailList.ToObject<List<FundsApplyDetailEntity>>();
- var code = entity.EnCode;
- var savecode = fundsApplyIBLL.SaveCode(entity.EnCode, parameter.keyValue);
- entity.EnCode = savecode;
-
- var encode = savecode.Substring(13).ToInt();
- if (encode > 99)
- {
- return Fail("保存失败,经费开支单今日数量已超上限,请您明日编辑!");
- }
- if (code != entity.EnCode)
- {
- fundsApplyIBLL.SaveEntity(parameter.keyValue, entity, detailList);
- return Success("保存成功,经费开支申报单号已重复,系统已为您自动变更!");
- }
- fundsApplyIBLL.SaveEntity(parameter.keyValue, entity, detailList);
- return Success("保存成功!");
- }
- /// <summary>
- /// 提交
- /// <param name="_"></param>
- /// <summary>
- /// <returns></returns>
- public Response Submit(dynamic _)
- {
- string keyValue = this.GetReqData();
- var processId = Guid.NewGuid().ToString();
- fundsApplyIBLL.ChangeStatusById(keyValue, 1, processId);
- UserInfo userInfo = LoginUserInfo.Get();
- nWFProcessIBLL.CreateFlow("LC_FundsApply", processId, "", 1, "", userInfo);
- return Success("提交成功!");
- }
- #endregion
-
- #region 私有类
-
- /// <summary>
- /// 表单实体类
- /// <summary>
- private class ReqFormEntity
- {
- public string keyValue { get; set; }
- public string strEntity { get; set; }
- public string fundsApplyDetailList { get; set; }
- }
- #endregion
-
- }
- }
|