Commit fa19bc31 authored by 罗超's avatar 罗超

新增总经理视图与数据服务相关分类

parent 118cc96f
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Common.Plugin
{
public class FriendTimeHelper
{
public static String FriendFormat(long dateTime)
{
String fTime = String.Empty;
try
{
DateTime dt = new DateTime(dateTime);
return FriendFormat(dt);
}
catch
{
return dateTime.ToString();
}
}
public static String FriendFormat(String dateTime)
{
String fTime = String.Empty;
try
{
DateTime dt = DateTime.Parse(dateTime);
return FriendFormat(dt);
}
catch
{
return dateTime;
}
}
public static String FriendFormat(DateTime dateTime)
{
if (dateTime == null)
{
return String.Empty;
}
int nowYear = DateTime.Now.Year;
int year = dateTime.Year;
if (nowYear - year == 0)
{
//本年内
int nowMounth = DateTime.Now.Month;
int mounth = dateTime.Month;
if (nowMounth - mounth == 0)
{
//本月内
int nowDay = DateTime.Now.Day;
int day = dateTime.Day;
if (nowDay - day == 0)
{
//当天
int nowHour = DateTime.Now.Hour;
int hour = dateTime.Hour;
if (nowHour - hour == 0)
{
int nowMinute = DateTime.Now.Minute;
int minute = dateTime.Minute;
int diff = nowMinute - minute;
if (diff < 2)
{
return "刚刚";
}
else
{
return $"{diff} 分钟前";
}
}
else
{
return dateTime.ToString("HH:mm:ss");
}
}
else
{
return dateTime.ToString("dd HH:mm:ss");
}
}
else
{
//跨月
return dateTime.ToString("MM-dd HH:mm:ss");
}
}
else
{
//跨年
return dateTime.ToString("yyyy-MM-dd HH:mm:ss");
}
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Edu.Model.Entity.System
{
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_General_Manager_View
{
/// <summary>
/// Id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 日期
/// </summary>
public DateTime Day { get; set; }
/// <summary>
/// Stu
/// </summary>
public string Stu { get; set; }
/// <summary>
/// Visit
/// </summary>
public string Visit { get; set; }
/// <summary>
/// Reserve
/// </summary>
public string Reserve { get; set; }
/// <summary>
/// Follow
/// </summary>
public string Follow { get; set; }
/// <summary>
/// Invalid
/// </summary>
public string Invalid { get; set; }
/// <summary>
/// UnFollow
/// </summary>
public int UnFollow { get; set; }
/// <summary>
/// MakeCall
/// </summary>
public string MakeCall { get; set; }
/// <summary>
/// InvalidCall
/// </summary>
public string InvalidCall { get; set; }
/// <summary>
/// Company
/// </summary>
public string Company { get; set; }
/// <summary>
/// Contacts
/// </summary>
public string Contacts { get; set; }
/// <summary>
/// LangOrder
/// </summary>
public string LangOrder { get; set; }
/// <summary>
/// LangMoney
/// </summary>
public string LangMoney { get; set; }
/// <summary>
/// LangGuest
/// </summary>
public string LangGuest { get; set; }
/// <summary>
/// LangOutPayOrder
/// </summary>
public string LangOutPayOrder { get; set; }
/// <summary>
/// LangOutPayMoney
/// </summary>
public decimal LangOutPayMoney { get; set; }
/// <summary>
/// LiuOrder
/// </summary>
public string LiuOrder { get; set; }
/// <summary>
/// LiuMoney
/// </summary>
public string LiuMoney { get; set; }
/// <summary>
/// LiuGuest
/// </summary>
public string LiuGuest { get; set; }
/// <summary>
/// LiuOutPayOrder
/// </summary>
public int LiuOutPayOrder { get; set; }
/// <summary>
/// LiuOutPayMoney
/// </summary>
public decimal LiuOutPayMoney { get; set; }
/// <summary>
/// Activity
/// </summary>
public string Activity { get; set; }
/// <summary>
/// ActivityOrder
/// </summary>
public string ActivityOrder { get; set; }
/// <summary>
/// ActivityGuest
/// </summary>
public string ActivityGuest { get; set; }
/// <summary>
/// ActivityMoney
/// </summary>
public string ActivityMoney { get; set; }
/// <summary>
/// ActivityOutPayMoney
/// </summary>
public decimal ActivityOutPayMoney { get; set; }
/// <summary>
/// TradeStu
/// </summary>
public int TradeStu { get; set; }
/// <summary>
/// StopStu
/// </summary>
public string StopStu { get; set; }
/// <summary>
/// FinishStu
/// </summary>
public string FinishStu { get; set; }
/// <summary>
/// ArrearsStu
/// </summary>
public string ArrearsStu { get; set; }
/// <summary>
/// ImArrearsStu
/// </summary>
public int ImArrearsStu { get; set; }
/// <summary>
/// ImFinishStu
/// </summary>
public int ImFinishStu { get; set; }
/// <summary>
/// RenewStu
/// </summary>
public string RenewStu { get; set; }
/// <summary>
/// RecommendStu
/// </summary>
public string RecommendStu { get; set; }
/// <summary>
/// FollowStu
/// </summary>
public string FollowStu { get; set; }
/// <summary>
/// StudyStu
/// </summary>
public string StudyStu { get; set; }
/// <summary>
/// AbsenceStu
/// </summary>
public string AbsenceStu { get; set; }
/// <summary>
/// ConsumeHour
/// </summary>
public string ConsumeHour { get; set; }
/// <summary>
/// ConsumeMoney
/// </summary>
public string ConsumeMoney { get; set; }
/// <summary>
/// TimeHourFee
/// </summary>
public string TimeHourFee { get; set; }
/// <summary>
/// EmpCount
/// </summary>
public int EmpCount { get; set; }
/// <summary>
/// InactiveEmpCount
/// </summary>
public int InactiveEmpCount { get; set; }
/// <summary>
/// NewEmpCount
/// </summary>
public string NewEmpCount { get; set; }
/// <summary>
/// LeaveEmpCount
/// </summary>
public string LeaveEmpCount { get; set; }
/// <summary>
/// RedEventCount
/// </summary>
public string RedEventCount { get; set; }
/// <summary>
/// BlackEventCount
/// </summary>
public string BlackEventCount { get; set; }
/// <summary>
/// AbsenceCount
/// </summary>
public string AbsenceCount { get; set; }
/// <summary>
/// AbsenteeismCount
/// </summary>
public string AbsenteeismCount { get; set; }
/// <summary>
/// AFLeaveCount
/// </summary>
public string AFLeaveCount { get; set; }
/// <summary>
/// CourseCount
/// </summary>
public int CourseCount { get; set; }
/// <summary>
/// SellCourseCount
/// </summary>
public int SellCourseCount { get; set; }
/// <summary>
/// CourseRank
/// </summary>
public string CourseRank { get; set; }
/// <summary>
/// PlanCount
/// </summary>
public string PlanCount { get; set; }
/// <summary>
/// FullRate
/// </summary>
public string FullRate { get; set; }
/// <summary>
/// AvgClassTime
/// </summary>
public string AvgClassTime { get; set; }
/// <summary>
/// NoneClassTeacher
/// </summary>
public string NoneClassTeacher { get; set; }
/// <summary>
/// ExamCount
/// </summary>
public string ExamCount { get; set; }
/// <summary>
/// UnLessonClass
/// </summary>
public string UnLessonClass { get; set; }
/// <summary>
/// UnLessonTeacher
/// </summary>
public string UnLessonTeacher { get; set; }
/// <summary>
/// IncomeMoney
/// </summary>
public string IncomeMoney { get; set; }
/// <summary>
/// PayMoney
/// </summary>
public string PayMoney { get; set; }
/// <summary>
/// UnIncomeMoney
/// </summary>
public decimal UnIncomeMoney { get; set; }
/// <summary>
/// UnPayMoney
/// </summary>
public decimal UnPayMoney { get; set; }
/// <summary>
/// MonthCommission
/// </summary>
public decimal MonthCommission { get; set; }
/// <summary>
/// SumCommission
/// </summary>
public decimal SumCommission { get; set; }
/// <summary>
/// UnPubCommission
/// </summary>
public decimal UnPubCommission { get; set; }
/// <summary>
/// RewardInfo
/// </summary>
public string RewardInfo { get; set; }
/// <summary>
/// PrivateReturnCommission
/// </summary>
public string PrivateReturnCommission { get; set; }
/// <summary>
/// CustomerReturnCommission
/// </summary>
public string CustomerReturnCommission { get; set; }
/// <summary>
/// StuReturnCommission
/// </summary>
public string StuReturnCommission { get; set; }
/// <summary>
/// SurplusHours
/// </summary>
public string SurplusHours { get; set; }
}
}
using Edu.Common.Plugin;
using Edu.Model.Entity.System;
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Model.ViewModel.System
{
public class RB_General_Manager_ViewModel : RB_General_Manager_View
{
/// <summary>
/// 友好的时间格式
/// </summary>
public string FirendTime {
get
{
if (Day != null)
return FriendTimeHelper.FriendFormat(Day);
return "";
}
}
}
}
using Edu.Model.ViewModel.System;
using Edu.Repository.System;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace Edu.Module.System
{
public class DataServiceModule
{
/// <summary>
/// 总经理视图仓储
/// </summary>
private readonly RB_General_Manager_ViewRepository gmViewRepository = new RB_General_Manager_ViewRepository();
/// <summary>
/// 获取指定日期的数据
/// </summary>
/// <param name="datetime"></param>
/// <returns></returns>
public RB_General_Manager_ViewModel GetViewModelModule(string datetime)
{
return gmViewRepository.GetViewModel(datetime);
}
public async Task<RB_General_Manager_ViewModel> UpdateTodayViewModuleAsync()
{
var day = DateTime.Now.ToString("yyyy-MM-dd");
var p = await gmViewRepository.UpdateTodayView();
return GetViewModelModule(day);
}
}
}
using Edu.Model.Entity.System;
using Edu.Model.ViewModel.System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VT.FW.DB.Dapper;
namespace Edu.Repository.System
{
public class RB_General_Manager_ViewRepository:BaseRepository<RB_General_Manager_View>
{
/// <summary>
/// 查询指定日期的数据
/// </summary>
/// <param name="datetime"></param>
/// <returns></returns>
public RB_General_Manager_ViewModel GetViewModel(string datetime)
{
string sql = $"select * from {nameof(RB_General_Manager_View)} where where DATE_FORMAT(`Day`,'%Y-%m-%d')=@date";
DynamicParameters parameters = new DynamicParameters();
parameters.Add("date", datetime);
return Get<RB_General_Manager_ViewModel>(sql, parameters).FirstOrDefault();
}
/// <summary>
/// 更新今日数据
/// </summary>
public async Task<bool> UpdateTodayView()
{
try
{
var sql = "call proc_GeneralManagerView(100000)";
Execute(sql);
return true;
}
catch (Exception)
{
return false;
}
}
}
}
using Edu.Common.API;
using Edu.Common.Plugin;
using Edu.Module.System;
using Edu.WebApi.Filter;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using System;
namespace Edu.WebApi.Controllers.DataService
{
[Route("api/[controller]/[action]")]
[ApiExceptionFilter]
[ApiController]
[EnableCors("AllowCors")]
public class DataServiceController : BaseController
{
private DataServiceModule dataServiceModule = new DataServiceModule();
/// <summary>
/// 获取总经理视图数据
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetGMView()
{
var param = JObject.FromObject(RequestParm.Msg);
var day = param.GetStringValue("day");
day = String.IsNullOrEmpty(day) ? DateTime.Now.ToString("yyyy-MM-dd") : day;
var result = dataServiceModule.GetViewModelModule(day);
return ApiResult.Success(data: result);
}
/// <summary>
/// 手动更新今日数据
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult UpdateGMView()
{
var result = dataServiceModule.UpdateTodayViewModuleAsync();
return ApiResult.Success(data: result);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment