diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json new file mode 100644 index 0000000..622ea20 --- /dev/null +++ b/.vs/VSWorkspaceState.json @@ -0,0 +1,7 @@ +{ + "ExpandedNodes": [ + "" + ], + "SelectedNode": "\\Znyc.Dispatching.sln", + "PreviewInSolutionExplorer": false +} \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 0012440..157ac6c 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -7,8 +7,14 @@ EXPOSE 443 ENV TZ=Asia/Shanghai RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +RUN sed -i 's@/deb.debian.org/@/mirrors.aliyun.com/@g' /etc/apt/sources.list +RUN apt-get clean +RUN apt update && apt install libgdiplus -y +RUN ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll - +COPY msyh.ttc /usr/share/fonts/msyh.tt +COPY msyhbd.ttc /usr/share/fonts/msyhbd.tt +COPY msyhl.ttc /usr/share/fonts/msyhl.tt FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src @@ -22,12 +28,15 @@ COPY ["Znyc.Dispatching.MongoDb.Repository/Znyc.Dispatching.MongoDb.Repository.c COPY ["Znyc.Dispatching.WeChat.Core/Znyc.Dispatching.WeChat.Core.csproj", "Znyc.Dispatching.WeChat.Core/"] RUN dotnet restore "Znyc.Dispatching.Web.Entry/Znyc.Dispatching.Web.Entry.csproj" COPY . . -WORKDIR "/src/Znyc.Dispatching.Web.Entry" -RUN dotnet build "Znyc.Dispatching.Web.Entry.csproj" -c Release -o /app/build +WORKDIR "/src/Znyc.Dispatching.Web.Entry" +RUN dotnet build "Znyc.Dispatching.Web.Entry.csproj" -c Release -o /app/build + + FROM build AS publish RUN dotnet publish "Znyc.Dispatching.Web.Entry.csproj" -c Release -o /app/publish + FROM base AS final WORKDIR /app COPY --from=publish /app/publish . diff --git a/src/Dockerfile b/src/Dockerfile index c221dd2..770fda4 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -7,7 +7,14 @@ EXPOSE 443 ENV TZ=Asia/Shanghai RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +RUN sed -i 's@/deb.debian.org/@/mirrors.aliyun.com/@g' /etc/apt/sources.list +RUN apt-get clean +RUN apt update && apt install libgdiplus -y +RUN ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll +COPY msyh.ttc /usr/share/fonts/msyh.tt +COPY msyhbd.ttc /usr/share/fonts/msyhbd.tt +COPY msyhl.ttc /usr/share/fonts/msyhl.tt FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src @@ -22,7 +29,7 @@ COPY ["Znyc.Dispatching.WeChat.Core/Znyc.Dispatching.WeChat.Core.csproj", "Znyc. RUN dotnet restore "Znyc.Dispatching.Web.Entry/Znyc.Dispatching.Web.Entry.csproj" COPY . . WORKDIR "/src/Znyc.Dispatching.Web.Entry" -RUN dotnet build "Znyc.Dispatching.Web.Entry.csproj" -c Release -o /app/build +RUN dotnet build "Znyc.Dispatching.Web.Entry.csproj" -c Release -o /app/build FROM build AS publish RUN dotnet publish "Znyc.Dispatching.Web.Entry.csproj" -c Release -o /app/publish diff --git a/src/Znyc.Dispatching.Application/Cache/Services/CacheService.cs b/src/Znyc.Dispatching.Application/Cache/Services/CacheService.cs index e5ba643..239cfd3 100644 --- a/src/Znyc.Dispatching.Application/Cache/Services/CacheService.cs +++ b/src/Znyc.Dispatching.Application/Cache/Services/CacheService.cs @@ -9,6 +9,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Znyc.Dispatching.Common.Extensions; using Znyc.Dispatching.Core; using Znyc.Dispatching.Core.Cache; using Znyc.Dispatching.Core.Entitys; @@ -35,6 +36,8 @@ namespace Znyc.Dispatching.Application private readonly IRepository _orderRepository; private readonly IRepository _vehiclePersonRepository; private readonly IRepository _userRepository; + private readonly IRepository PayTypeRepository; + public CacheService(IRedisCache redisCache, IRepository vehicleRepository, @@ -47,6 +50,7 @@ namespace Znyc.Dispatching.Application IRepository projectPersonRepository, IRepository projectRepository, IRepository userRepository, + IRepository PayTypeRepository, IRepository orderRepository) { _redisCache = redisCache; @@ -61,6 +65,7 @@ namespace Znyc.Dispatching.Application _vehiclePersonRepository = vehiclePersonRepositor; _userRepository = userRepository; _orderRepository = orderRepository; + this.PayTypeRepository = PayTypeRepository; } #region 短信验证码 @@ -326,7 +331,9 @@ namespace Znyc.Dispatching.Application StopTag = x.StopTag, IsOpenDispatch = x.IsOpenDispatch, IsSchedulingAddProject = x.IsSchedulingAddProject, - IsOpenVehicleType = x.IsOpenVehicleType + IsOpenVehicleType = x.IsOpenVehicleType, + IsShowDate = x.IsShowDate, + IsShowCheckType = x.IsShowCheckType }).FirstOrDefaultAsync()); if (companyOutput.IsNotNull()) { @@ -514,7 +521,7 @@ namespace Znyc.Dispatching.Application public async Task> GetVehicleByCompanyIdAsync(long companyId) { string cacheKey = CommonConst.CACHE_KEY_VEHICLEBYCOMPANYID + $"{companyId}"; - return await _redisCache.CacheShellAsync(cacheKey, (int)TimeSpan.FromDays(60).TotalSeconds, () => + var res = await _redisCache.CacheShellAsync(cacheKey, (int)TimeSpan.FromDays(60).TotalSeconds, () => _vehicleRepository .Where(x => x.CompanyId == companyId) .Select(x => new VehicleGpsOutput @@ -538,6 +545,12 @@ namespace Znyc.Dispatching.Application }) .OrderBy(x => x.Sort) .ToListAsync()); + + + + + return res; + } /// @@ -614,11 +627,19 @@ namespace Znyc.Dispatching.Application public async Task GetVehicleAsync(long vehicleId) { string cacheKey = CommonConst.CACHE_KEY_VEHICLE + $"{vehicleId}"; - return await _redisCache.CacheShellAsync(cacheKey, (int)TimeSpan.FromDays(90).TotalSeconds, - () => _vehicleRepository.Where(x => x.Id == vehicleId).FirstOrDefaultAsync()); + Vehicle vehicle = await _redisCache.GetAsync(cacheKey); + if (vehicle == null) + { + + vehicle = _vehicleRepository.DetachedEntities.Where(x => x.Id == vehicleId).FirstOrDefault(); + if (vehicle.IsNotNull()) + await _redisCache.SetAsync(cacheKey, vehicle, TimeSpan.FromDays(8)); + } + return vehicle; } + #endregion 车辆 #region 员工 @@ -696,6 +717,7 @@ namespace Znyc.Dispatching.Application await _redisCache.DelAsync(cacheKey); } + /// /// 获取员工列表缓存 /// @@ -734,6 +756,35 @@ namespace Znyc.Dispatching.Application return _redisCache.Subscribe(channels); } + + /// + /// 员工分页 + /// + /// + /// + [NonAction] + public async Task SetEmployeeListPageAsync(EmployeeListPage employeeListPage,long companyId) + { + string cacheKey = string.Format(CommonConst.EMPLOYEELISTPAGE, companyId); + await _redisCache.SetAsync(cacheKey, employeeListPage, TimeSpan.FromDays(13)); + } + + [NonAction] + public async Task RemoveEmployeeListPageAsync(long companyId) + { + string cacheKey = string.Format(CommonConst.EMPLOYEELISTPAGE, companyId); + await _redisCache.DelAsync(cacheKey); + } + + [NonAction] + public async Task GetEmployeeListPageAsync(long companyId) + { + string cacheKey = string.Format(CommonConst.EMPLOYEELISTPAGE, companyId); + return await _redisCache.GetAsync(cacheKey); + } + + + #endregion 员工 #region 未读警报提醒 @@ -914,6 +965,198 @@ namespace Znyc.Dispatching.Application } #endregion + + #region 设置超速车辆 + + + /// + /// + /// + /// + /// + [NonAction] + public async Task GetSpeedAsync(long vehicleId) + { + string cacheKey = CommonConst.CACHE_KEY_VEHICLESTART + $"{vehicleId}"; + return await _redisCache.GetAsync(cacheKey); + } + + + /// + /// + /// + /// + /// + [NonAction] + public async Task GetStopAsync(long vehicleId) + { + string cacheKey = CommonConst.CACHE_KEY_VEHICLESTOP + $"{vehicleId}"; + return await _redisCache.GetAsync(cacheKey); + } + + + + /// + /// + /// + /// + /// + [NonAction] + public async Task DelSpeedAsync(long vehicleId) + { + string cacheKey = CommonConst.CACHE_KEY_VEHICLESTOP + $"{vehicleId}"; + await _redisCache.DelAsync(cacheKey); + } + + + /// + /// + /// + /// + /// + [NonAction] + public async Task DelStopAsync(long vehicleId) + { + string cacheKey = CommonConst.CACHE_KEY_VEHICLESTART + $"{vehicleId}"; + await _redisCache.DelAsync(cacheKey); + } + + + + /// + /// 获取设置超速车辆 + /// + /// + /// + [NonAction] + public async Task> GetSpeedVehicleAsync() + { + string cacheKey = CommonConst.CACHE_KEY_VEHICLE+"Speed"; + return await _redisCache.CacheShellAsync(cacheKey, (int)TimeSpan.FromDays(90).TotalSeconds, + () => _vehicleRepository.Where(x => x.IsOverspeedAlarm).ToListAsync()); + } + + + + + + + /// + /// 设置车辆缓存 + /// + /// + /// + [NonAction] + public async Task SetSpeedVehicleAsync(Vehicle vehicle) + { + string cacheKey = CommonConst.CACHE_KEY_SPEEDVEHICLE + $"{vehicle.Id}"; + await _redisCache.SetAsync(cacheKey, vehicle, TimeSpan.FromDays(8)); + } + + /// + /// 删除车辆缓存 + /// + /// + /// + [NonAction] + public async Task RemoveSpeedVehicleAsync(long vehicleId) + { + string cacheKey = CommonConst.CACHE_KEY_SPEEDVEHICLE + $"{vehicleId}"; + await _redisCache.DelAsync(cacheKey); + } + + + + /// + /// 获取设置离线报警车辆 + /// + /// + [NonAction] + public async Task> GetoffVehiclesAsync() + { + string cacheKey = CommonConst.CACHE_KEY_VEHICLE + "Off"; + return await _redisCache.CacheShellAsync(cacheKey, (int)TimeSpan.FromDays(90).TotalSeconds, + () => _vehicleRepository.Where(x => x.IsOveroffAlarm).ToListAsync()); + } + + + /// + /// 获取是否已经推送 + /// + /// + /// + [NonAction] + public async Task GetOffVehicleAsync(long vehicleId) + { + string cacheKey = CommonConst.CACHE_KEY_OFFVEHICLE + $"{vehicleId}"; + return await _redisCache.GetAsync(cacheKey); + } + + + /// + /// 设置推送标志 + /// + /// + /// + [NonAction] + public async Task SetOffVehicleAsync(Vehicle vehicle) + { + string cacheKey = CommonConst.CACHE_KEY_OFFVEHICLE + $"{vehicle.Id}"; + await _redisCache.SetAsync(cacheKey, vehicle); + } + + + #endregion + + + #region + + + + /// + /// + /// + /// + /// + [NonAction] + public async Task> GetStopVehicleAsync() + { + string cacheKey = CommonConst.CACHE_KEY_VEHICLE+"Stop"; + return await _redisCache.CacheShellAsync(cacheKey, (int)TimeSpan.FromMinutes(1).TotalSeconds, + () => _vehicleRepository.Where(x => x.IsOverstopAlarm).ToListAsync()); + } + + + /// + /// 删除车辆缓存 + /// + /// + /// + [NonAction] + public async Task RemoveStopVehicleAsync() + { + string cacheKey = CommonConst.CACHE_KEY_VEHICLE + "Stop"; + await _redisCache.DelAsync(cacheKey); + } + + + + ///// + ///// 设置车辆缓存 + ///// + ///// + ///// + //[NonAction] + //public async Task SetStopVehicleAsync(Vehicle vehicle) + //{ + // string cacheKey = CommonConst.CACHE_KEY_VEHICLE+ "Stop"; + // await _redisCache.SetAsync(cacheKey, vehicle, TimeSpan.FromDays(8)); + //} + + + #endregion + + #region 工程信息 /// /// 同步工程列表缓存 @@ -989,7 +1232,7 @@ namespace Znyc.Dispatching.Application /// /// /// - [NonAction] + [NonAction] public async Task SetProjectAsync(ProjectOutput project) { string cacheKey = string.Format(CommonConst.CACHE_KEY_PROJECT, project.Id); @@ -1043,7 +1286,43 @@ namespace Znyc.Dispatching.Application #endregion + #region 开支类型 + public async Task> GetPayTypeAll(long compayId,bool isenable=true) + { + string cacheKey = string.Format(CommonConst.CACHE_KEY_PAYTYPE); + var projectOutput = await _redisCache.GetAsync>(cacheKey); + if (projectOutput.IsNotNull()) + return projectOutput; + + var res = await this.PayTypeRepository.DetachedEntities + .Where(x => x.IsDeleted == false) + .WhereIf(isenable,x => x.Enable ==0) + .Where(x =>x.CompayId == 0 || x.CompayId == compayId) + .Select(x => new PayTypeOutPut() + { + ID= x.Id, + Enable = (PayTypeOutEnum)x.Enable, + TypeName = x.TypeName, + IsEdit = (PayTypeOutEnum)x.IsEdit + }).ToListAsync(); + + return res; + } + + /// + /// 删除订单列表缓存 + /// + /// + /// + [NonAction] + public async Task RemovePayTypeAllAsync(long companyId) + { + string cacheKey = string.Format(CommonConst.CACHE_KEY_PAYTYPE); + await _redisCache.DelAsync(cacheKey); + } + + #endregion #region 订单 @@ -1123,6 +1402,19 @@ namespace Znyc.Dispatching.Application await _redisCache.DelAsync(cacheKey); } + /// + /// 获取车辆车组人员缓存 + /// + /// + /// + [NonAction] + public async Task> GetVehiclePersonByIDAsync(long vehicleId) + { + string cacheKey = CommonConst.CACHE_KEY_VEHICLEPERSON + $"{vehicleId}"; + return await _redisCache.GetAsync>(cacheKey); + } + + /// /// 获取车辆车组人员缓存 /// @@ -1146,7 +1438,6 @@ namespace Znyc.Dispatching.Application #endregion - #region Order /// /// 设置缓存 @@ -1183,7 +1474,7 @@ namespace Znyc.Dispatching.Application string cacheKey = CommonConst.CACHE_KEY_GPSREALTIME + $"{orderId}"; return await _redisCache.GetAsync(cacheKey); } - #endregion + @@ -1230,6 +1521,6 @@ namespace Znyc.Dispatching.Application string cacheKey = CommonConst.CACHE_KEY_ORDERREAD + $"{orderId}"; return await _redisCache.ExistsAsync(cacheKey); } - + #endregion } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.Application/Cache/Services/ICacheService.cs b/src/Znyc.Dispatching.Application/Cache/Services/ICacheService.cs index d6375ab..8c8db60 100644 --- a/src/Znyc.Dispatching.Application/Cache/Services/ICacheService.cs +++ b/src/Znyc.Dispatching.Application/Cache/Services/ICacheService.cs @@ -424,6 +424,16 @@ namespace Znyc.Dispatching.Application Task> GetYardListAsync(long companyId); #endregion + #region 开支类型缓存 + Task> GetPayTypeAll(long compayId,bool isEnable); + /// + /// 删除缓存 + /// + /// + /// + Task RemovePayTypeAllAsync(long orderId); + + #endregion #region 工程信息 /// @@ -493,6 +503,9 @@ namespace Znyc.Dispatching.Application /// Task> GetVehiclePersonAsync(long vehicleId); + + Task> GetVehiclePersonByIDAsync(long vehicleId); + #endregion #region Order @@ -550,5 +563,59 @@ namespace Znyc.Dispatching.Application /// Task ExistsOrderReadAsync(long orderId); #endregion + + + #region 超速车辆 + + + /// + /// 获取所有公司超速车辆缓存 + /// + /// + Task> GetSpeedVehicleAsync(); + + + /// + /// 获取所有公司超速车辆缓存 + /// + /// + Task> GetoffVehiclesAsync(); + + + /// + /// 获取所有公司超速车辆缓存 + /// + /// + Task GetOffVehicleAsync(long id); + + + Task SetOffVehicleAsync(Vehicle vehicle); + + + Task> GetStopVehicleAsync(); + + Task RemoveStopVehicleAsync(); + + + Task SetSpeedVehicleAsync(Vehicle vehicle); + + Task RemoveSpeedVehicleAsync(long vehicleId); + + + Task GetStopAsync(long ID); + + Task GetSpeedAsync(long ID); + + Task SetEmployeeListPageAsync(EmployeeListPage employeeListPage, long companyId); + Task RemoveEmployeeListPageAsync(long companyId); + Task GetEmployeeListPageAsync(long companyId); + + + Task DelStopAsync(long ID); + + Task DelSpeedAsync(long ID); + + + #endregion } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.Application/Company/Dto/Input/RegisterInuput.cs b/src/Znyc.Dispatching.Application/Company/Dto/Input/RegisterInuput.cs index e996f2d..7a89327 100644 --- a/src/Znyc.Dispatching.Application/Company/Dto/Input/RegisterInuput.cs +++ b/src/Znyc.Dispatching.Application/Company/Dto/Input/RegisterInuput.cs @@ -16,7 +16,7 @@ namespace Znyc.Dispatching.Application /// /// 用户名 /// - [MaxLength(8, ErrorMessage = "用户名不得超过8个字")] + public string UserName { get; set; } /// diff --git a/src/Znyc.Dispatching.Application/Company/Dto/OutPut/CompanyOutput.cs b/src/Znyc.Dispatching.Application/Company/Dto/OutPut/CompanyOutput.cs index 81b5fd9..8f3fb31 100644 --- a/src/Znyc.Dispatching.Application/Company/Dto/OutPut/CompanyOutput.cs +++ b/src/Znyc.Dispatching.Application/Company/Dto/OutPut/CompanyOutput.cs @@ -76,6 +76,16 @@ namespace Znyc.Dispatching.Application /// public bool IsOpenVehicleType { get; set; } - #endregion + #endregion + + + ///// + ///// 是否启用安全检查 + ///// + public bool IsShowCheckType { get; set; } + + + public bool IsShowDate { get; set; } + } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.Application/Company/Services/CompanyService.cs b/src/Znyc.Dispatching.Application/Company/Services/CompanyService.cs index 8f4f6f1..a3e86c6 100644 --- a/src/Znyc.Dispatching.Application/Company/Services/CompanyService.cs +++ b/src/Znyc.Dispatching.Application/Company/Services/CompanyService.cs @@ -109,7 +109,7 @@ namespace Znyc.Dispatching.Application } /// - /// 平台入驻 + /// 平台入驻 /// /// /// @@ -119,8 +119,7 @@ namespace Znyc.Dispatching.Application [Route("api/v1/register")] public async Task RegisterAsync(RegisterInuput registerInuput) { - var jsCode2JsonResult = - await SnsApi.JsCode2JsonAsync(_weixinSettingOptions.WxOpenAppId, _weixinSettingOptions.WxOpenAppSecret, + var jsCode2JsonResult = await SnsApi.JsCode2JsonAsync(_weixinSettingOptions.WxOpenAppId, _weixinSettingOptions.WxOpenAppSecret, registerInuput.JsCode); if (jsCode2JsonResult.IsNull()) { @@ -141,10 +140,11 @@ namespace Znyc.Dispatching.Application } } - + System.Console.WriteLine(registerInuput.UserName.Length.ToString()); + System.Console.WriteLine(registerInuput.UserName); var entity = registerInuput.Adapt(); entity.Status = (int)CommonStatusEnum.REVIEW; - entity.ContactPerson = registerInuput.UserName ?? "企业管理员"; + entity.ContactPerson = registerInuput.UserName.ToString() ?? "企业管理员"; entity.ContactPhone = registerInuput.Phone; entity.CompanyLogo = CommonConst.DEFAULT_AVATARURL; entity.StopTag = CommonConst.DEFAULT_STAPTAG; @@ -303,5 +303,42 @@ namespace Znyc.Dispatching.Application await _repository.UpdateNowAsync(company); await _cacheService.RemoveCompanyAsync(_userManager.CompanyId); } + + /// + /// + /// + /// + [HttpPut] + [Route("api/v1/company/showcheck")] + public async Task UpdateShowcheckAsync() + { + var company = await _repository.FirstOrDefaultAsync(x => x.Id == _userManager.CompanyId); + if (company.IsNull()) + { + throw Oops.Bah("公司不存在"); + + } + company.IsShowCheckType = !company.IsShowCheckType; + await _repository.UpdateNowAsync(company); + await _cacheService.RemoveCompanyAsync(_userManager.CompanyId); + } + /// + /// + /// + /// + [HttpPut] + [Route("api/v1/company/showDate")] + public async Task UpdateShowDateAsync() + { + var company = await _repository.FirstOrDefaultAsync(x => x.Id == _userManager.CompanyId); + if (company.IsNull()) + { + throw Oops.Bah("公司不存在"); + + } + company.IsShowDate = !company.IsShowDate; + await _repository.UpdateNowAsync(company); + await _cacheService.RemoveCompanyAsync(_userManager.CompanyId); + } } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.Application/Consumption/Dto/Output/CakeJson.cs b/src/Znyc.Dispatching.Application/Consumption/Dto/Output/CakeJson.cs new file mode 100644 index 0000000..d73ea92 --- /dev/null +++ b/src/Znyc.Dispatching.Application/Consumption/Dto/Output/CakeJson.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + public class CakeJson + { + public string name { get; set; } + + public string CarNo { get; set; } + + public decimal value { get; set; } + } +} diff --git a/src/Znyc.Dispatching.Application/Consumption/Dto/Output/CarTotalOutPut.cs b/src/Znyc.Dispatching.Application/Consumption/Dto/Output/CarTotalOutPut.cs new file mode 100644 index 0000000..d7f9bb3 --- /dev/null +++ b/src/Znyc.Dispatching.Application/Consumption/Dto/Output/CarTotalOutPut.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + public class CarTotalOutPut + { + public List CarTotalOutPutInfo { get; set; } + [Column(TypeName = "decimal(10, 2)")] + public decimal Total { get; set; } + + } + + public class CarTotalOutPutInfo + { + public long CarNo { get; set; } + + public String CarName { get; set; } + + [Column(TypeName = "decimal(10, 2)")] + public decimal Money { get; set; } + } +} diff --git a/src/Znyc.Dispatching.Application/Consumption/Dto/Output/ColumnJson.cs b/src/Znyc.Dispatching.Application/Consumption/Dto/Output/ColumnJson.cs new file mode 100644 index 0000000..cd5a4df --- /dev/null +++ b/src/Znyc.Dispatching.Application/Consumption/Dto/Output/ColumnJson.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + public class ColumnJson + { + + public List categories { get; set; } = new List(); + + + public List data { get; set; } = new List(); + + } +} diff --git a/src/Znyc.Dispatching.Application/Consumption/Dto/Output/ConsumptionMeterOutput.cs b/src/Znyc.Dispatching.Application/Consumption/Dto/Output/ConsumptionMeterOutput.cs new file mode 100644 index 0000000..bfb8aa0 --- /dev/null +++ b/src/Znyc.Dispatching.Application/Consumption/Dto/Output/ConsumptionMeterOutput.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + public class ConsumptionMeterOutput + { + /// + /// 累计花费 + /// + public string Cumulative { get; set; } + + /// + /// 平均日花费 + /// + public string Average { get; set; } + + ///// + ///// 饼状图json + ///// + //public string CakeJson { get; set; } + + + ///// + ///// 柱状图json + ///// + //public string ColumnJson { get; set; } + + + /// + /// 饼状图 + /// + public List Expenditures { get; set; } + + + /// + /// 柱状图 + /// + public ColumnJson ColumnJson { get; set; } + + } + + public class Expenditure + { + /// + /// 类型名称 + /// + public string Name { get; set; } + + + /// + /// 车辆编号 + /// + public string CarNo { get; set; } + + + /// + /// 花费金额 + /// + [Column(TypeName = "decimal(10, 2)")] + public decimal Value { get; set; } + + } + +} diff --git a/src/Znyc.Dispatching.Application/Consumption/Dto/Output/ConsumptionOutput.cs b/src/Znyc.Dispatching.Application/Consumption/Dto/Output/ConsumptionOutput.cs new file mode 100644 index 0000000..6dcf44b --- /dev/null +++ b/src/Znyc.Dispatching.Application/Consumption/Dto/Output/ConsumptionOutput.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + public class ConsumptionOutput + { + /// + /// ID + /// + public long ID { get; set; } + + + /// + /// 时间 + /// + public DateTime CreatedTime { get; set; } + + + + /// + /// 车辆编号 + /// + public string CarNo { get; set; } + + /// + /// 开支类别ID + /// + public long PayTyepID { get; set; } + + /// + /// 开支类别 + /// + public string PayTyepName { get; set; } + + /// + /// 车ID + /// + public long CarID { get; set; } + + /// + /// 车名称 + /// + public string CarName { get; set; } + + + /// + /// 支付途径 + /// + public string PayChannel { get; set; } + + /// + /// 金额 + /// + public decimal Money { get; set; } + + /// + /// 备注 + /// + public string Remarks { get; set; } + } +} diff --git a/src/Znyc.Dispatching.Application/Consumption/Dto/input/ConsumptionInput.cs b/src/Znyc.Dispatching.Application/Consumption/Dto/input/ConsumptionInput.cs new file mode 100644 index 0000000..073b457 --- /dev/null +++ b/src/Znyc.Dispatching.Application/Consumption/Dto/input/ConsumptionInput.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + public class ConsumptionInput + { + + public long? ID { get; set; } + + /// + /// 开支类别ID + /// + public long PayTyepID { get; set; } + + /// + /// 创建时间 + /// + public DateTime CreatedTime { get; set; } + + /// + /// 开支类别 + /// + public string PayTyepName { get; set; } + + /// + /// 车ID + /// + public List CarIDs { get; set; } + + /// + /// 车牌号 + /// + public string CarName { get; set; } + + + /// + /// 支付途径 + /// + public string PayChannel { get; set; } + + /// + /// 金额 + /// + public decimal Money { get; set; } + + /// + /// 备注 + /// + public string Remarks { get; set; } + } +} diff --git a/src/Znyc.Dispatching.Application/Consumption/Services/ConsumptionService.cs b/src/Znyc.Dispatching.Application/Consumption/Services/ConsumptionService.cs new file mode 100644 index 0000000..2d20e8f --- /dev/null +++ b/src/Znyc.Dispatching.Application/Consumption/Services/ConsumptionService.cs @@ -0,0 +1,434 @@ +using Furion.DatabaseAccessor; +using Furion.DependencyInjection; +using Furion.DynamicApiController; +using Furion.FriendlyException; +using Mapster; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using System.Threading.Tasks; +using Yitter.IdGenerator; +using Znyc.Dispatching.Common.Extensions; +using Znyc.Dispatching.Core; +using Znyc.Dispatching.Core.Entitys; +using Znyc.Dispatching.Core.Extension; +using Znyc.Dispatching.Core.Helpers; + +namespace Znyc.Dispatching.Application +{ + /// + /// 开支记录 + /// + [ApiDescriptionSettings(Name = "consumption", Order = 33)] + public class ConsumptionService : IConsumptionService, IDynamicApiController, ITransient + { + private readonly IUserManager userManager; + private readonly ICacheService cacheService; + private readonly IRepository repository; + private readonly IRepository vehicleRepository; + + public ConsumptionService(IRepository repository, + IUserManager userManager, + ICacheService cacheService, IRepository vehicleRepository) + { + this.repository = repository; + this.userManager = userManager; + this.cacheService = cacheService; + this.vehicleRepository = vehicleRepository; + } + + + /// + /// 开支记录分页查询 + /// + /// + /// + /// + /// + /// + /// + /// + [HttpGet] + [Route("api/v1/consumption/search")] + public async Task> PageAsync(DateTime startTime, DateTime endTime, int? type, long? CarNo, int currentPage = 1, int pageSize = 10) + { + var res = from x in this.repository.AsQueryable() + .WhereIf(type.IsNotNull(), x => x.PayTyepID == type) + .Where(x => x.IsDeleted == false) + .Where(x => x.CreatedTime >= startTime && x.CreatedTime < endTime) + .Where(x => x.CompayID == this.userManager.CompanyId) + .OrderByDescending(x => x.CreatedTime) + join d in this.vehicleRepository.AsQueryable() on x.CarID equals d.Id into results + from d in results.DefaultIfEmpty() + select new + { + x.ProductID, + x.Id, + x.PayTyepID, + x.CarID, + x.CarName, + CarNo = x.CarNo == "全部" ? x.CarNo : d.VehicleCode, + x.CompayID, + x.CreatedTime, + x.CreatedUserId, + x.IsDeleted, + x.PayChannel, + x.PayTyepName, + x.Remarks, + x.ModifiedTime, + x.ModifiedUserId, + Money = x.Money + }; + var page = res.ToPagedList(currentPage, pageSize); + + var respage = page.Adapt>(); + return respage; + } + + + /// + /// 开支记录分页查询 + /// + /// + /// + /// + /// + /// + /// + /// + [HttpGet] + [Route("api/v1/consumption/Info")] + public async Task> PageInfoAsync(DateTime startTime, DateTime endTime, int? type, long? CarNo, int currentPage = 1, int pageSize = 10) + { + //统计所有车辆数 + var conut = await this.vehicleRepository.DetachedEntities + .Where(x => x.IsDeleted == false) + .Where(x => x.CompanyId == this.userManager.CompanyId).ToListAsync(); + //获取当前车牌号 + var cars = await this.vehicleRepository.DetachedEntities + .Where(x => x.IsDeleted == false) + .Where(x => x.Id == CarNo) + .Where(x => x.CompanyId == this.userManager.CompanyId).FirstOrDefaultAsync(); + + var res = from x in this.repository.AsQueryable() + .WhereIf(type.IsNotNull(), x => x.PayTyepID == type) + .Where(x => x.IsDeleted == false) + .Where(x => x.CarID == CarNo || x.CarNo == "全部") + .Where(x => x.CreatedTime >= startTime && x.CreatedTime < endTime) + .Where(x => x.CompayID == this.userManager.CompanyId) + .OrderByDescending(x => x.CreatedTime) + join d in this.vehicleRepository.AsQueryable() on x.CarID equals d.Id into results + from d in results.DefaultIfEmpty() + select new + { + x.ProductID, + x.Id, + x.PayTyepID, + x.CarID, + x.CarName, + CarNo = x.CarNo == "全部" ? cars.VehicleCode: d.VehicleCode, + x.CompayID, + x.CreatedTime, + x.CreatedUserId, + x.IsDeleted, + x.PayChannel, + x.PayTyepName, + x.Remarks, + x.ModifiedTime, + x.ModifiedUserId, + Money = x.CarNo =="全部" ? (x.Money /conut.Count) :x.Money + }; + + var page = res.ToPagedList(currentPage, pageSize); + var respage = page.Adapt>(); + return respage; + } + + + /// + /// 开支统计 + /// + /// + /// + /// + [HttpGet] + [Route("api/v1/consumption/Statistics")] + public async Task Statistics(DateTime startTime, DateTime endTime) + { + List expenditures = new List(); + ColumnJson columnJson = new ColumnJson(); + List cakeJsons = new List(); + var allCar = await this.vehicleRepository + .Where(x => x.IsDeleted == false) + .Where(x => x.CompanyId == this.userManager.CompanyId).ToListAsync(); + + var Day = TimeHelper.ExecDateDay(startTime,endTime); + + var reslq = from x in this.repository.AsQueryable() + .Where(x => x.IsDeleted == false) + .Where(x => x.CompayID == this.userManager.CompanyId) + .Where(x => x.CreatedTime >= startTime && x.CreatedTime < endTime) + .OrderByDescending(x => x.CreatedTime) + join d in this.vehicleRepository.AsQueryable() on x.CarID equals d.Id into results + from d in results.DefaultIfEmpty() + select new + { + x.ProductID, + x.Id, + x.PayTyepID, + x.CarID, + x.CarName, + CarNo = x.CarNo == "全部" ? x.CarNo : d.VehicleCode, + x.CompayID, + x.CreatedTime, + x.CreatedUserId, + x.IsDeleted, + x.PayChannel, + x.PayTyepName, + x.Remarks, + x.ModifiedTime, + x.ModifiedUserId, + Money = x.Money + }; + var res = reslq.ToList(); + + var sum = res.Sum(x => x.Money); + var Avg = Math.Round(sum / Day, 2); + + var PayTyeps = res.GroupBy(x => x.PayTyepID).ToList(); + + foreach (var item in PayTyeps) + { + expenditures.Add(new Expenditure() + { + Name = res.Where(x =>x.PayTyepID == item.Key).FirstOrDefault().PayTyepName, + Value = res.Where(x => x.PayTyepID == item.Key).Sum((x) => x.Money) + }); + } + + + foreach (var item in allCar) + { + //设置平摊 + columnJson.categories.Add(item.VehicleCode); + var CarSum = res.Where(x => x.CarNo == item.VehicleCode).Sum(x =>x.Money); + + + var CarAvg = res.Where(x =>x.PayChannel.Contains("平摊")).Sum(x => x.Money)/allCar.Count; + columnJson.data.Add(Math.Round(CarSum + CarAvg,2)); + } + + return new ConsumptionMeterOutput() + { + Cumulative = sum.ToString(), + Average = Avg.ToString(), + ColumnJson = columnJson, + Expenditures = expenditures + }; + } + + + /// + /// 车辆分组开支统计 + /// + /// + /// + /// + [HttpGet] + [Route("api/v1/consumption/CarTotal")] + public async Task CarTotal(DateTime startTime, DateTime endTime) + { + CarTotalOutPut carTotalOutPut = new CarTotalOutPut(); + var reslq = from x in this.repository.AsQueryable() + .Where(x => x.IsDeleted == false) + .Where(x => x.CompayID == this.userManager.CompanyId) + .Where(x => x.CreatedTime >= startTime && x.CreatedTime < endTime) + .OrderByDescending(x => x.CreatedTime) + join d in this.vehicleRepository.AsQueryable() on x.CarID equals d.Id into results + from d in results.DefaultIfEmpty() + select new + { + x.ProductID, + x.Id, + x.PayTyepID, + x.CarID, + x.CarName, + CarNo = d.VehicleCode, + x.CompayID, + x.CreatedTime, + x.CreatedUserId, + x.IsDeleted, + x.PayChannel, + x.PayTyepName, + x.Remarks, + x.ModifiedTime, + x.ModifiedUserId, + Money = x.Money + }; + //var carmoney = reslq.GroupBy(x => x.CarID, x => x.Money); + + var allCar = await this.vehicleRepository + .Where(x => x.IsDeleted == false) + .Where(x => x.CompanyId == this.userManager.CompanyId).ToListAsync(); + List grres = new List(); + + var JunMoney = reslq.Where(x =>x.PayChannel == "平摊").Sum(x=>x.Money)/allCar.Count; + + foreach (var item in allCar) + { + var money = reslq.Where(x => x.CarID == item.Id).Where(x=>x.PayChannel != "平摊").Sum(x => x.Money); + grres.Add(new CarTotalOutPutInfo() + { + CarNo = item.Id, + CarName = item.VehicleCode, + Money = Math.Round(JunMoney + money, 2) + }); + } + + return new CarTotalOutPut() + { + Total = (int)grres.Sum(x => x.Money), + CarTotalOutPutInfo = grres + }; + } + + + + + /// + /// 新增开支 + /// + /// + /// + [HttpPost] + [Route("api/v1/consumption/InsertAsync")] + public async Task InsertAsync(ConsumptionInput consumptionInput) + { + var result = false; + long ProductID = YitIdHelper.NextId(); + //平摊 + if (consumptionInput.PayChannel == "平摊") + { + var res = await this.vehicleRepository + .Where(x => x.IsDeleted == false) + .Where(x => x.CompanyId == this.userManager.CompanyId).ToListAsync(); + if (res.Count == 0) + return result; + consumptionInput.CarIDs.Add(1); + } + + var avg = consumptionInput.Money / consumptionInput.CarIDs.Count; + + foreach (var item in consumptionInput.CarIDs) + { + var map = consumptionInput.Adapt(); + Console.WriteLine("车辆ID" + item); + var carRes = await this.cacheService.GetVehicleAsync(item); + if (carRes.IsNull()) + { + map.CarID = item; + map.CarName = "平摊"; + map.CarNo = "全部"; + } + else + { + map.CarName = carRes.VehiclePlate; + map.CarNo = carRes.VehicleCode; + map.CarID = item; + } + + + map.Money = avg; + map.ProductID = ProductID; + + map.CreatedTime = consumptionInput.CreatedTime; + map.CreatedUserId = this.userManager.CompanyId; + map.CompayID = this.userManager.CompanyId; + var res = await this.repository.InsertNowAsync(map); + if (res.IsNotNull()) + result = true; + } + return result; + } + + + /// + /// 更新开支 + /// + /// + /// + [HttpPut] + [Route("api/v1/consumption/UpdateAsync")] + public async Task UpdateAsync(ConsumptionInput payTypeInput) + { + bool result = false; + if (payTypeInput.ID.IsNull()) + throw Oops.Oh($"编辑缺少ID!"); + + var carres = await this.vehicleRepository + .Where(x => x.IsDeleted == false) + .Where(x => x.CompanyId == this.userManager.CompanyId).ToListAsync(); + //平摊 + if (payTypeInput.PayChannel == "平摊") + { + if (carres.Count == 0) + return result; + + var map = payTypeInput.Adapt(); + map.CarID = 1; + map.CarName = "平摊"; + map.CompayID = this.userManager.CompanyId; + map.ModifiedUserId = this.userManager.UserId; + map.ModifiedTime = System.DateTime.Now; + var resUp = await this.repository.UpdateNowAsync(map); + if (resUp.IsNotNull()) + result = true; + + return result; + } + + for (int i = 0; i < payTypeInput.CarIDs.Count; i++) + { + var carRes = carres.Where(x => x.Id == payTypeInput.CarIDs[i]).FirstOrDefault(); + if (carRes.IsNull()) + throw Oops.Oh("车辆信息不存在!"); + var map = payTypeInput.Adapt(); + map.CarID = payTypeInput.CarIDs[i]; + map.CarName = carRes.VehiclePlate; + map.CarNo = carRes.VehicleCode; + map.CompayID = this.userManager.CompanyId; + map.ModifiedUserId = this.userManager.UserId; + map.ModifiedTime = System.DateTime.Now; + var resUp = await this.repository.UpdateNowAsync(map); + if (resUp.IsNotNull()) + result = true; + } + + return result; + } + + /// + /// 删除油耗信息 + /// + /// + /// + [HttpDelete] + [Route("api/v1/consumption/{id}")] + public async Task DeleteAsync(long id) + { + var oil = await this.repository.FirstOrDefaultAsync(x => x.Id == id); + if (oil.IsNull()) + throw Oops.Oh("暂无该信息"); + oil.IsDeleted = true; + var result = await this.repository.UpdateNowAsync(oil); + if (result.IsNull()) + { + throw Oops.Oh("删除油耗信息失败"); + } + } + + } +} diff --git a/src/Znyc.Dispatching.Application/Consumption/Services/IConsumptionService.cs b/src/Znyc.Dispatching.Application/Consumption/Services/IConsumptionService.cs new file mode 100644 index 0000000..279249f --- /dev/null +++ b/src/Znyc.Dispatching.Application/Consumption/Services/IConsumptionService.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + public interface IConsumptionService + { + + + } +} diff --git a/src/Znyc.Dispatching.Application/Declaration/Dto/Output/WorkDeclarationOutput.cs b/src/Znyc.Dispatching.Application/Declaration/Dto/Output/WorkDeclarationOutput.cs new file mode 100644 index 0000000..3c29268 --- /dev/null +++ b/src/Znyc.Dispatching.Application/Declaration/Dto/Output/WorkDeclarationOutput.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + public class WorkDeclarationOutput + { + /// + /// 公司名称 + /// + public long CompanyName { get; set; } + + /// + /// 车型 + /// + public int CarType { get; set; } + + /// + /// 到场时间 + /// + public DateTime ArriveDate { get; set; } + + + /// + /// 报单信息 + /// + public string Info { get; set; } + + /// + /// 报单员 + /// + public string ReportSheetName { get; set; } + + /// + /// 联系电话 + /// + public string Phone { get; set; } + } +} diff --git a/src/Znyc.Dispatching.Application/Declaration/Services/DeclarationService.cs b/src/Znyc.Dispatching.Application/Declaration/Services/DeclarationService.cs new file mode 100644 index 0000000..1603b4a --- /dev/null +++ b/src/Znyc.Dispatching.Application/Declaration/Services/DeclarationService.cs @@ -0,0 +1,52 @@ +using Furion.DatabaseAccessor; +using Furion.DependencyInjection; +using Furion.DynamicApiController; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Znyc.Dispatching.Core; +using Znyc.Dispatching.Core.Entitys; + +namespace Znyc.Dispatching.Application +{ + public class DeclarationService : IDeclarationService, IDynamicApiController, ITransient + { + private readonly IUserManager userManager; + + private readonly IRepository repository; + + public DeclarationService(IRepository repository, + IUserManager userManager) + { + this.repository = repository; + this.userManager = userManager; + } + + + #region 工地方 + + ///// + ///// 工地端报单列表 + ///// + ///// + ///// + ///// + ///// + ///// + //[HttpGet] + //[Route("api/v1/admin/declaration/search")] + //public async Task PageAsync(int status = 0, int currentPage = 1, int pageSize = 10, string key = "") + //{ + // //var compay = this, + + // //var res = this.repository.Where(x =>x.State == status).Where(x =>x.CompanyId == user) + //} + + #endregion + + + } +} diff --git a/src/Znyc.Dispatching.Application/Declaration/Services/IDeclarationService.cs b/src/Znyc.Dispatching.Application/Declaration/Services/IDeclarationService.cs new file mode 100644 index 0000000..20bdf73 --- /dev/null +++ b/src/Znyc.Dispatching.Application/Declaration/Services/IDeclarationService.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + public interface IDeclarationService + { + + } +} diff --git a/src/Znyc.Dispatching.Application/Document/Services/DocumentService.cs b/src/Znyc.Dispatching.Application/Document/Services/DocumentService.cs index e2f5917..34524d2 100644 --- a/src/Znyc.Dispatching.Application/Document/Services/DocumentService.cs +++ b/src/Znyc.Dispatching.Application/Document/Services/DocumentService.cs @@ -46,6 +46,10 @@ namespace Znyc.Dispatching.Application ["secretId"] = _uploadInfoOptions.secretId, ["secretKey"] = _uploadInfoOptions.secretKey }; + foreach (var item in values) + { + Console.WriteLine(item.Value); + } Dictionary credential = STSClient.genCredential(values); foreach (KeyValuePair kvp in credential) { diff --git a/src/Znyc.Dispatching.Application/Employee/Services/EmployeeService.cs b/src/Znyc.Dispatching.Application/Employee/Services/EmployeeService.cs index c756bdf..830a066 100644 --- a/src/Znyc.Dispatching.Application/Employee/Services/EmployeeService.cs +++ b/src/Znyc.Dispatching.Application/Employee/Services/EmployeeService.cs @@ -78,6 +78,12 @@ namespace Znyc.Dispatching.Application public async Task PageAsync([Required] int currentPage, [Required] int pageSize, [FromQuery] int status, [Required] int roleId, [FromQuery] string orderby, [FromQuery] string key = "") { + //var employeeListPage = await _cacheService.GetEmployeeListPageAsync(_userManager.CompanyId); + + //if (employeeListPage.IsNotNull()) + // return employeeListPage; + + //查询角色表看看是否是业务员 -- 如果不是,提示不可以进行邀请工地人员 var employees = (await _cacheService.GetEmployeeListAsync(_userManager.CompanyId)) .WhereIf(status != 0, x => x.Status == status) .WhereIf(roleId > 0, x => x.RoleId == roleId) @@ -85,7 +91,10 @@ namespace Znyc.Dispatching.Application x => new long[] { (long)RoleStatusEnum.CrewMembers, (long)RoleStatusEnum.Outside, (long)RoleStatusEnum.PartTimeSalesman,(long)RoleStatusEnum.Salesman }.Contains(x.RoleId)) .WhereIf(key.IsNotEmptyOrNull(), x => x.EmployeeName.Contains(key) || x.EmployeePhone.Contains(key)) - .Adapt>(); + .OrderBy(x => x.EmployeeName) + .Skip((currentPage - 1) * pageSize) + .Take(pageSize); + //.Adapt>(); var employeeOutputs = new List(); if (orderby == "role") @@ -93,10 +102,11 @@ namespace Znyc.Dispatching.Application employees = employees.OrderBy(x => x.RoleName).ToList(); foreach (var INDEX_STRING in ROLEINDEX_STRINGS) { + var res = employees.Where(x => StringHelper.GetStringFirstSpell(x.RoleName) == INDEX_STRING); employeeOutputs.Add(new EmployeeListOutputs() { Char = INDEX_STRING, - List = employees.Where(x => StringHelper.GetStringFirstSpell(x.RoleName) == INDEX_STRING).ToList() + List = res.Adapt>() }); }; } @@ -106,18 +116,20 @@ namespace Znyc.Dispatching.Application foreach (var INDEX_STRING in INDEX_STRINGS) { + var res = employees.Where(x => StringHelper.GetStringFirstSpell(x.EmployeeName) == INDEX_STRING); employeeOutputs.Add(new EmployeeListOutputs() { - Char = INDEX_STRING, - List = employees.Where(x => StringHelper.GetStringFirstSpell(x.EmployeeName) == INDEX_STRING).ToList() + Char = INDEX_STRING, + List = res.Adapt>() }); }; } var data = new EmployeeListPage() { EmployeeList = employeeOutputs, - Total = employees.Count + Total = employees.Count() }; + await _cacheService.SetEmployeeListPageAsync(data, _userManager.CompanyId); return data; } @@ -129,7 +141,13 @@ namespace Znyc.Dispatching.Application [Route("api/v1/employee/{id}")] public async Task GetByIdAsync(long id) { - return await _cacheService.GetEmployeeAsync(id); + var res = await _cacheService.GetEmployeeAsync(id); + if(res == null) + { + var reares = await this._repository.DetachedEntities.FirstOrDefaultAsync(x =>x.Id== id); + return reares.Adapt(); + } + return res; } /// @@ -181,6 +199,7 @@ namespace Znyc.Dispatching.Application RoleId = employeeAdd.RoleId, }); //清除员工列表Cache + await _cacheService.RemoveEmployeeListPageAsync(_userManager.CompanyId); await _cacheService.RemoveEmployeeListAsync(_userManager.CompanyId); return employee.Entity.UserId; } @@ -237,8 +256,8 @@ namespace Znyc.Dispatching.Application await _cacheService.RemoveEmployeeListAsync(employee2.CompanyId); } } - - + //分页列表清除 + await _cacheService.RemoveEmployeeListPageAsync(_userManager.CompanyId); //清除员工Cache await _cacheService.RemoveEmployeeAsync(employee.Id); //清除用户Cache @@ -294,6 +313,7 @@ namespace Znyc.Dispatching.Application .FirstOrDefaultAsync(x => x.Id == id && x.CompanyId == _userManager.CompanyId); employee.IsDeleted = true; await _repository.UpdateNowAsync(employee); + await _cacheService.RemoveEmployeeListPageAsync(_userManager.CompanyId); await _cacheService.RemoveCacheByUserIdAsync(employee.UserId); await _cacheService.RemoveEmployeeAsync(employee.Id); await _cacheService.RemoveEmployeeListAsync(_userManager.CompanyId); diff --git a/src/Znyc.Dispatching.Application/Job/IJobService.cs b/src/Znyc.Dispatching.Application/Job/IJobService.cs index 225b82b..09a96d6 100644 --- a/src/Znyc.Dispatching.Application/Job/IJobService.cs +++ b/src/Znyc.Dispatching.Application/Job/IJobService.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using Furion.TaskScheduler; +using System.Threading.Tasks; namespace Dilon.Core.Service { @@ -6,5 +7,10 @@ namespace Dilon.Core.Service { Task SyncOrderStatusAsync(); + + Task SyncVehicleOff(); + + + Task Syncspeeding(); } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.Application/Job/JobService.cs b/src/Znyc.Dispatching.Application/Job/JobService.cs index bc45e24..42e4cfb 100644 --- a/src/Znyc.Dispatching.Application/Job/JobService.cs +++ b/src/Znyc.Dispatching.Application/Job/JobService.cs @@ -1,6 +1,8 @@ -using Furion.DatabaseAccessor; +using Furion; +using Furion.DatabaseAccessor; using Furion.DependencyInjection; using Furion.DynamicApiController; +using Furion.TaskScheduler; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -8,7 +10,10 @@ using Microsoft.Extensions.Options; using Newtonsoft.Json; using Senparc.Weixin.MP.AdvancedAPIs; using Senparc.Weixin.MP.AdvancedAPIs.TemplateMessage; +using Senparc.Weixin.MP.CommonAPIs; +using Senparc.Weixin.MP.Entities; using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Znyc.Dispatching.Application; @@ -16,6 +21,7 @@ using Znyc.Dispatching.Core; using Znyc.Dispatching.Core.Entitys; using Znyc.Dispatching.Core.Extension; using Znyc.Dispatching.Core.Helpers; +using Znyc.Dispatching.MongoDb.Repository.Collection; using Znyc.Dispatching.MongoDb.Repository.Repositorys; using Znyc.Dispatching.WeChat.Core.CommonService.TemplateMessage; @@ -25,7 +31,7 @@ namespace Dilon.Core.Service /// 任务调度服务 /// [ApiDescriptionSettings(Name = "job", Order = 40)] - public class JobService : IJobService, IDynamicApiController, IScoped + public class JobService : IJobService, IDynamicApiController, IScoped, ISpareTimeWorker { private readonly IRepository _roleRepository; private readonly IVehicleService _vehicleService; @@ -40,6 +46,8 @@ namespace Dilon.Core.Service private readonly WeixinSettingOptions _weixinSettingOptions; private readonly IRepository _yardRepository; private readonly IRepository _companyRepository; + private readonly IRepository _userRepository; + public JobService( IRepository roleRepository, IVehicleService vehicleService, @@ -53,6 +61,7 @@ namespace Dilon.Core.Service IRepository wxUserRelationRepository, IOptions weixinSettingOptions, IRepository yardRepository, + IRepository userRepository, IRepository companyRepository) { _roleRepository = roleRepository; @@ -68,9 +77,167 @@ namespace Dilon.Core.Service _weixinSettingOptions = weixinSettingOptions.Value; _yardRepository = yardRepository; _companyRepository = companyRepository; + _userRepository = userRepository; + } + + + + /// + /// 停留提醒 + /// + /// + [HttpGet] + [AllowAnonymous] + public async Task Syncstoping() + { + //查询设置了停留提醒 + + List vehicleList = await _cacheService.GetStopVehicleAsync(); + //var wxUser = _wxUserRelationRepository.Where(x => x.WxOfficialOpenId.IsNotNull()).ToArray(); + vehicleList.ForEach(async v => + { + + //获取车辆启动时间 + var stop = await _cacheService.GetStopAsync(v.Id); + + //获取车辆停留时间 + var start = await _cacheService.GetSpeedAsync(v.Id); + + if (stop.IsNotNull() && start.IsNotNull()) + { + var vehicle = await _cacheService.GetVehicleAsync(v.Id); + var actual = (stop.GpsTime - start.GpsTime).TotalMinutes; + var isPush = vehicle.Overstop < (stop.GpsTime - start.GpsTime).TotalMinutes; + + if (isPush) + { + var userss = from e in _employeeRepository.Where(x =>x.CompanyId == v.CompanyId && x.RoleId == 1005 && x.Status == (int)CommonStatusEnum.ENABLE) + .AsQueryable() + join u in _wxUserRelationRepository.Where(x =>x.IsDeleted == false).AsQueryable() + on e.UserId equals u.UserId + select new NoticeOutput + { + OpenId = u.WxOfficialOpenId + + }; + + foreach (NoticeOutput i in userss.ToList()) + { + Console.WriteLine(i.OpenId); + var time = (start.GpsTime - stop.GpsTime).TotalMinutes.ToString()+"分"; + if (!string.IsNullOrEmpty(i.OpenId.Trim())) + { + var url = "pages/callPhone/callPhone?phone=" + vehicle.DriverPhone; + + WeixinTemplate_Stop data = new WeixinTemplate_Stop("车辆停留提醒", start.VehicleCode, stop.GpsTime.ToString(), start.GpsTime.ToString(), time, stop.Address, "点击联系司机", url); + TemplateModel_MiniProgram miniProgram = new TemplateModel_MiniProgram(); + miniProgram.appid = _weixinSettingOptions.WxOpenAppId; + miniProgram.pagepath = url; + AccessTokenResult accessTokenResult = await CommonApi.GetTokenAsync(App.Configuration["SenparcWeixinSetting:WeixinAppId"], App.Configuration["SenparcWeixinSetting:WeixinAppSecret"]); + SendTemplateMessageResult result = await TemplateApi.SendTemplateMessageAsync(_weixinSettingOptions.WeixinAppId, i.OpenId, data.TemplateId, "", data, miniProgram); + + }; + } + } + await _cacheService.DelStopAsync(v.Id); + } + await _cacheService.DelSpeedAsync(v.Id); + + }); } - #region Order + + /// + /// 超速提醒 + /// + /// + [HttpGet] + [AllowAnonymous] + public async Task Syncspeeding() + { + //查询设置了超速的车辆 + + List vehicleList = await _cacheService.GetSpeedVehicleAsync(); + var vehicleGpss = await _gpsRealTimeRepository.GetGpsRealTimeListByVehicleId(vehicleList.Select(x => x.Id).ToList()); + var time = DateTime.Now.AddSeconds(-40); + + vehicleGpss.ForEach(async vehicle => + { + Console.WriteLine("超速提醒:" + vehicle.VehiclePlate); + var car = await _cacheService.GetVehicleAsync(vehicle.VehicleId); + if (car?.Overspeed <= vehicle.Speed && vehicle?.GpsTime.AddHours(8) > time) + { + + var userss = from e in _employeeRepository.Where(x => + x.CompanyId == vehicle.CompanyId && x.RoleId == 1005 && x.Status == (int)CommonStatusEnum.ENABLE) + .AsQueryable() + join u in _userRepository.Where(x => x.Status == CommonStatusEnum.ENABLE).AsQueryable() + on e.UserId equals u.Id + select new NoticeOutput + { + OpenId = u.OpenId + }; + foreach (NoticeOutput i in userss.ToList()) + { + var wxUser = _wxUserRelationRepository.Where(x => x.OpenId == i.OpenId).FirstOrDefault(); + + if (wxUser.IsNotNull() && !string.IsNullOrEmpty(wxUser.WxOfficialOpenId.Trim())) + { + var url = "pages/callPhone/callPhone?phone=" + vehicle.DriverPhone; + WeixinTemplate_Speed data = new WeixinTemplate_Speed("车辆超速提醒", vehicle.GpsTime.ToString(), vehicle.Address, vehicle.VehicleCode, "点击联系司机", url); + AccessTokenResult accessTokenResult = await CommonApi.GetTokenAsync(App.Configuration["SenparcWeixinSetting:WeixinAppId"], App.Configuration["SenparcWeixinSetting:WeixinAppSecret"]); + SendTemplateMessageResult result = await TemplateApi.SendTemplateMessageAsync(_weixinSettingOptions.WeixinAppId, + wxUser.WxOfficialOpenId, data.TemplateId, "", data); + }; + } + } + }); + } + + + /// + /// 离线设置提醒 + /// + /// + [HttpGet] + [AllowAnonymous] + public async Task SyncVehicleOff() + { + List vehicleList = await _cacheService.GetoffVehiclesAsync(); + + vehicleList.ForEach(async x => { + var vehicle = await _cacheService.GetOffVehicleAsync(x.Id); + if(vehicle == null) + { + var car = await _gpsRealTimeRepository.GetGpsRealTimeByVehicleId(x.Id); + if (car != null) + { + var userss = await _employeeRepository.Where(x => x.CompanyId == car.CompanyId && (x.RoleId == 1005 || x.RoleId == 1007 || x.RoleId == 1002) && x.Status == (int)CommonStatusEnum.ENABLE).ToListAsync(); + userss.ForEach(async x => { + var users = await _userRepository.Where(u => u.Id == x.UserId).ToListAsync(); + foreach (var user in users) + { + var wxUser = _wxUserRelationRepository.Where(x => x.OpenId == user.OpenId).FirstOrDefault(); + + if (wxUser.IsNotNull() && !string.IsNullOrEmpty(wxUser.WxOfficialOpenId.Trim())) + { + var url = "pages/callPhone/callPhone?phone=" + car.DriverPhone; + WeixinTemplate_AssignOrder data = new WeixinTemplate_AssignOrder("车辆离线提醒", car.VehicleCode, DateTime.Now.ToString(), car.Address, "尊敬的用户,你的车辆于" + DateTime.Now + ",地点:" + car.Address + "已离线:编号" + car.VehicleCode, "", null, "PCzqF_bIWdxCwPnS-Xhk47qQPWaxNv75L9oedwsD44c"); + AccessTokenResult accessTokenResult = await CommonApi.GetTokenAsync(App.Configuration["SenparcWeixinSetting:WeixinAppId"], App.Configuration["SenparcWeixinSetting:WeixinAppSecret"]); + SendTemplateMessageResult result = await TemplateApi.SendTemplateMessageAsync(_weixinSettingOptions.WeixinAppId, + wxUser.WxOfficialOpenId, data.TemplateId, "", data); + }; + await _cacheService.SetOffVehicleAsync(vehicle); + } + + }); + } + + + } + }); + + } + + #region Order [HttpGet] [AllowAnonymous] @@ -100,7 +267,7 @@ namespace Dilon.Core.Service var orderContent = arriveOrder.OrderContent.Length > 45 ? HtmlHelper.ReplaceHtmlMark(arriveOrder.OrderContent.Substring(0, 45)) + "..." : HtmlHelper.ReplaceHtmlMark(arriveOrder.OrderContent) + "..."; //管理员 - var adminUserIds = await _employeeRepository.DetachedEntities.Where(x => x.CompanyId == arriveOrder.CompanyId && x.RoleId == (int)RoleStatusEnum.Administrator && x.Status == 1 && !x.IsDeleted).Select(x => x.UserId).ToListAsync(); + var adminUserIds = await _employeeRepository.DetachedEntities.Where(x => x.CompanyId == arriveOrder.CompanyId && x.UserId != arriveOrder.AssignUserId && x.RoleId == (int)RoleStatusEnum.Administrator && x.Status == 1 && !x.IsDeleted).Select(x => x.UserId).ToListAsync(); //派单人 adminUserIds.Add(arriveOrder.AssignUserId); //获取订单所有车组人员信息 @@ -148,7 +315,7 @@ namespace Dilon.Core.Service var orderContent = appearOrder.OrderContent.Length > 45 ? HtmlHelper.ReplaceHtmlMark(appearOrder.OrderContent.Substring(0, 45)) + "..." : HtmlHelper.ReplaceHtmlMark(appearOrder.OrderContent) + "..."; //管理员 - var adminUserIds = await _employeeRepository.DetachedEntities.Where(x => x.CompanyId == appearOrder.CompanyId && x.RoleId == (int)RoleStatusEnum.Administrator && x.Status == 1 && !x.IsDeleted).Select(x => x.UserId).ToListAsync(); + var adminUserIds = await _employeeRepository.DetachedEntities.Where(x => x.CompanyId == appearOrder.CompanyId && x.UserId != appearOrder.AssignUserId && x.RoleId == (int)RoleStatusEnum.Administrator && x.Status == 1 && !x.IsDeleted).Select(x => x.UserId).ToListAsync(); //派单人 adminUserIds.Add(appearOrder.AssignUserId); //获取订单所有车组人员信息 @@ -192,7 +359,7 @@ namespace Dilon.Core.Service var orderContent = signeOrder.OrderContent.Length > 45 ? HtmlHelper.ReplaceHtmlMark(signeOrder.OrderContent.Substring(0, 45)) + "..." : HtmlHelper.ReplaceHtmlMark(signeOrder.OrderContent) + "..."; //管理员 - var adminUserIds = await _employeeRepository.DetachedEntities.Where(x => x.CompanyId == signeOrder.CompanyId && x.RoleId == (int)RoleStatusEnum.Administrator && x.Status == 1 && !x.IsDeleted).Select(x => x.UserId).ToListAsync(); + var adminUserIds = await _employeeRepository.DetachedEntities.Where(x => x.CompanyId == signeOrder.CompanyId && x.UserId != signeOrder.AssignUserId && x.RoleId == (int)RoleStatusEnum.Administrator && x.Status == 1 && !x.IsDeleted).Select(x => x.UserId).ToListAsync(); //派单人 adminUserIds.Add(signeOrder.AssignUserId); //获取订单所有车组人员信息 @@ -204,7 +371,7 @@ namespace Dilon.Core.Service var wxAdminUser = _wxUserRelationRepository.Where(x => x.UserId == adminUserId).FirstOrDefault(); if (wxAdminUser.IsNotNull() && wxAdminUser.WxOfficialOpenId.IsNotNull()) { - var data = new WeixinTemplate_AssignOrder("完工返回提醒", signeOrder.ProjectName, "出车任务", orderContent, signeOrder.ArriveDate.ToString("yyyy -MM-dd HH:mm:ss"), $"[{signeOrder.VehicleCode}]号车,{orderVehicleDriverName},{orderVehicleCrewsName}已完工返回"); + var data = new WeixinTemplate_AssignOrder("离开返回提醒", signeOrder.ProjectName, "出车任务", orderContent, signeOrder.ArriveDate.ToString("yyyy -MM-dd HH:mm:ss"), $"[{signeOrder.VehicleCode}]号车,{orderVehicleDriverName},{orderVehicleCrewsName}已离开"); TemplateModel_MiniProgram miniProgram = new TemplateModel_MiniProgram(); miniProgram.appid = _weixinSettingOptions.WxOpenAppId; miniProgram.pagepath = $"pages/taskInfo/taskInfo?id={signeOrder.Id}&isDriver=false&type=2"; @@ -243,7 +410,7 @@ namespace Dilon.Core.Service var orderContent = homeOrder.OrderContent.Length > 45 ? HtmlHelper.ReplaceHtmlMark(homeOrder.OrderContent.Substring(0, 45)) + "..." : HtmlHelper.ReplaceHtmlMark(homeOrder.OrderContent) + "..."; //管理员 - var adminUserIds = await _employeeRepository.DetachedEntities.Where(x => x.CompanyId == homeOrder.CompanyId && x.RoleId == (int)RoleStatusEnum.Administrator && x.Status == 1 && !x.IsDeleted).Select(x => x.UserId).ToListAsync(); + var adminUserIds = await _employeeRepository.DetachedEntities.Where(x => x.CompanyId == homeOrder.CompanyId && x.UserId != homeOrder.AssignUserId && x.RoleId == (int)RoleStatusEnum.Administrator && x.Status == 1 && !x.IsDeleted).Select(x => x.UserId).ToListAsync(); //派单人 adminUserIds.Add(homeOrder.AssignUserId); //获取订单所有车组人员信息 @@ -273,5 +440,8 @@ namespace Dilon.Core.Service } } #endregion + + + } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.Application/Login/Dto/Output/TicketOut.cs b/src/Znyc.Dispatching.Application/Login/Dto/Output/TicketOut.cs new file mode 100644 index 0000000..cc7dc83 --- /dev/null +++ b/src/Znyc.Dispatching.Application/Login/Dto/Output/TicketOut.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application.Login +{ + public class TicketOut + { + public int Id { get; set; } + + public string Name { get; set; } + + /// + /// Ticket值 + /// + public string TicketStr { get; set; } + } +} diff --git a/src/Znyc.Dispatching.Application/Login/Services/LoginService.cs b/src/Znyc.Dispatching.Application/Login/Services/LoginService.cs index 35b8e5c..2f4d303 100644 --- a/src/Znyc.Dispatching.Application/Login/Services/LoginService.cs +++ b/src/Znyc.Dispatching.Application/Login/Services/LoginService.cs @@ -11,10 +11,12 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using System.Collections.Generic; using System.Linq; +using Newtonsoft.Json; using System.Threading.Tasks; using Znyc.Dispatching.Core; using Znyc.Dispatching.Core.Entitys; using Znyc.Dispatching.Core.Extension; +using Znyc.Dispatching.WeChat.Core; using Znyc.Dispatching.WeChat.Core.CommonService.TemplateMessage.WxOpen; namespace Znyc.Dispatching.Application @@ -31,6 +33,7 @@ namespace Znyc.Dispatching.Application private readonly IUserManager _userManager; private readonly IRepository _userRepository; private readonly WeixinSettingOptions _weixinSettingOptions; + private readonly WxOpenSetting wxOpenSetting; private readonly IWxUserRelationService _wxUserRelationService; private readonly ILogger _logger; private readonly IRoleMenuService _roleMenuService; @@ -46,6 +49,7 @@ namespace Znyc.Dispatching.Application IWxUserRelationService wxUserRelationService, ILogger logger, IMapper mapper, + IOptions wxOpenSetting, IRoleMenuService roleMenuService ) { @@ -59,6 +63,7 @@ namespace Znyc.Dispatching.Application _logger = logger; _mapper = mapper; _roleMenuService = roleMenuService; + this.wxOpenSetting = wxOpenSetting.Value; } /// @@ -115,7 +120,7 @@ namespace Znyc.Dispatching.Application if (company.IsNull()) { - throw Oops.Bah("").StatusCode(4012); + throw Oops.Bah("公司错误,请联系管理员").StatusCode(4012); } var employee = employeeList.Find(x => x.CompanyId == company.Id); if (employee.Status == (int)CommonStatusEnum.DISABLE) @@ -125,6 +130,7 @@ namespace Znyc.Dispatching.Application //用户中间表 await _wxUserRelationService.AddOrUpdateAsync(user.Id, jsCode2JsonResult.openid, jsCode2JsonResult.unionid); + // 生成 token string accessToken = JWTEncryption.Encrypt(new Dictionary { @@ -178,5 +184,47 @@ namespace Znyc.Dispatching.Application { await _cacheService.RemoveCacheByUserIdAsync(_userManager.UserId); } + + + + /// + /// 获取Ticket + /// + /// + /// + [HttpPost] + [UnitOfWork] + [AllowAnonymous] + [Route("api/v1/WxScanCode")] + public async Task WxScanCode() + { + var jsCode2JsonResult = await SnsApi.GetToken("wx35b31406546e5430", "67bced4e3f1120e7aaf2b84fb8a281d5"); + TicketArg ticketArg = new TicketArg(); + ticketArg.expire_seconds = 604800; + ticketArg.action_name = "QR_SCENE"; + ticketArg.action_info = new Action_Info() { scene = new Scene() { scene_id = 10 } }; + + var ticket = await SnsApi.GetTicket(jsCode2JsonResult.Access_Token, ticketArg); + return ticket; + } + + + /// + /// 获取Ticket + /// + /// + /// + [HttpGet] + [UnitOfWork] + [AllowAnonymous] + [Route("api/v1/WxScanCodeCallback")] + public async Task WxScanCodeCallback(string token, string timestamp, string nonce) + { + + + return ""; + } + + } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.Application/Mapper/Mapper.cs b/src/Znyc.Dispatching.Application/Mapper/Mapper.cs index 9c9aa51..57c6e3f 100644 --- a/src/Znyc.Dispatching.Application/Mapper/Mapper.cs +++ b/src/Znyc.Dispatching.Application/Mapper/Mapper.cs @@ -1,4 +1,5 @@ using Mapster; +using System.Collections.Generic; using Znyc.Dispatching.Core; using Znyc.Dispatching.Core.Entitys; @@ -16,6 +17,21 @@ namespace Znyc.Dispatching.Application.Mapper config.ForType() .Map(dest => dest.Picture, src => CommonConst.DEFAULT_ORDERVISA + src.Picture); + config.ForType() + .Map(dest => dest.Picture, src => CommonConst.DEFAULT_ORDERVISA + src.Picture); + + #region 支付类型 + config.ForType() + .Map(dest => dest.Enable, s =>s.Enable); + config.ForType() + .Map(dest => dest.Enable, s => s.Enable); + #endregion + + + #region 开支登记 + config.ForType, PagedList>(); + config.ForType, PagedList>(); + #endregion } } diff --git a/src/Znyc.Dispatching.Application/Oil/Dto/Input/OilAddInput.cs b/src/Znyc.Dispatching.Application/Oil/Dto/Input/OilAddInput.cs index ee61730..a7822ef 100644 --- a/src/Znyc.Dispatching.Application/Oil/Dto/Input/OilAddInput.cs +++ b/src/Znyc.Dispatching.Application/Oil/Dto/Input/OilAddInput.cs @@ -41,11 +41,17 @@ namespace Znyc.Dispatching.Application /// /// 油单价 /// - public decimal OilPrice { get; set; } + public decimal? OilPrice { get; set; } = 0; /// /// 金额 /// public decimal AmountMoney { get; set; } + + + /// + /// 备注 + /// + public string Remarks { get; set; } } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.Application/Oil/Dto/OutPut/NewCensusOilOutput.cs b/src/Znyc.Dispatching.Application/Oil/Dto/OutPut/NewCensusOilOutput.cs new file mode 100644 index 0000000..c7633cf --- /dev/null +++ b/src/Znyc.Dispatching.Application/Oil/Dto/OutPut/NewCensusOilOutput.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + public class NewCensusOilOutput + { + /// + /// 累计花费 + /// + public string Cumulative { get; set; } + + /// + /// 平均日花费 + /// + public string Average { get; set; } + + /// + /// 柱状图 + /// + public ColumnJson ColumnJson { get; set; } + + /// + /// 饼图 + /// + public List Expenditures { get; set; } + + /// + /// 四大标签 + /// + public List FourExpenditures { get; set; } + } + + +} diff --git a/src/Znyc.Dispatching.Application/Oil/Dto/OutPut/OilCatTotalOutput.cs b/src/Znyc.Dispatching.Application/Oil/Dto/OutPut/OilCatTotalOutput.cs new file mode 100644 index 0000000..e4eb994 --- /dev/null +++ b/src/Znyc.Dispatching.Application/Oil/Dto/OutPut/OilCatTotalOutput.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + public class OilCatTotalOutput + { + public List OilCatOutputInfos { get; set; } + + public int Total { get; set; } + + } + + public class OilCatOutputInfo + { + public long ID { get; set; } + /// + /// 车牌号 + /// + public string CarName { get; set; } + + /// + /// 工作时长 + /// + public string WoekAmount { get; set; } + + /// + /// 时长 + /// + public int TimeAmount { get; set; } + + /// + /// 油耗 + /// + public int OilPtion { get; set; } + + /// + /// 油耗比 + /// + public string OilThan { get; set; } + } +} diff --git a/src/Znyc.Dispatching.Application/Oil/Dto/OutPut/OilOutput.cs b/src/Znyc.Dispatching.Application/Oil/Dto/OutPut/OilOutput.cs index 2fa0068..3900f7f 100644 --- a/src/Znyc.Dispatching.Application/Oil/Dto/OutPut/OilOutput.cs +++ b/src/Znyc.Dispatching.Application/Oil/Dto/OutPut/OilOutput.cs @@ -32,11 +32,16 @@ /// /// 油单价 /// - public decimal OilPrice { get; set; } + public decimal? OilPrice { get; set; } = 0; /// /// 金额 /// public decimal AmountMoney { get; set; } + + /// + /// 备注 + /// + public string Remarks { get; set; } } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.Application/Oil/Services/IOilService.cs b/src/Znyc.Dispatching.Application/Oil/Services/IOilService.cs index 57f68d9..bd2b135 100644 --- a/src/Znyc.Dispatching.Application/Oil/Services/IOilService.cs +++ b/src/Znyc.Dispatching.Application/Oil/Services/IOilService.cs @@ -13,12 +13,13 @@ namespace Znyc.Dispatching.Application /// /// 加油记录 /// + /// /// /// /// /// /// - Task> PlusOilPageAsync(int currentPage, int pageSize, DateTime startTime, DateTime endTime); + Task> PlusOilPageAsync(long? VehicleId, int currentPage, int pageSize, DateTime startTime, DateTime endTime); /// /// 油耗统计 diff --git a/src/Znyc.Dispatching.Application/Oil/Services/OilService.cs b/src/Znyc.Dispatching.Application/Oil/Services/OilService.cs index c252534..8185644 100644 --- a/src/Znyc.Dispatching.Application/Oil/Services/OilService.cs +++ b/src/Znyc.Dispatching.Application/Oil/Services/OilService.cs @@ -13,6 +13,9 @@ using System.Threading.Tasks; using Znyc.Dispatching.Core; using Znyc.Dispatching.Core.Entitys; using Znyc.Dispatching.Core.Extension; +using Znyc.Dispatching.Core.Helpers; +using System.Text.Json; +using Znyc.Dispatching.Common.Extensions; namespace Znyc.Dispatching.Application { @@ -24,12 +27,15 @@ namespace Znyc.Dispatching.Application { private readonly IRepository _repository; private readonly IUserManager _userManager; + private readonly IRepository vehicleRepository; public OilService( IRepository repository, + IRepository vehicleRepository, IUserManager userManager ) { + this.vehicleRepository = vehicleRepository; _repository = repository; _userManager = userManager; } @@ -38,6 +44,7 @@ namespace Znyc.Dispatching.Application /// /// 加油记录 /// + /// /// /// /// @@ -45,26 +52,27 @@ namespace Znyc.Dispatching.Application /// [HttpGet] [Route("api/v1/plus/oils/search")] - public async Task> PlusOilPageAsync(int currentPage, int pageSize, DateTime startTime, DateTime endTime) + public async Task> PlusOilPageAsync(long? VehicleId, int currentPage, int pageSize, DateTime startTime, DateTime endTime) { - var oils = (await _repository.DetachedEntities + var res = from x in _repository.AsQueryable() .Where(x => x.CompanyId == _userManager.CompanyId && x.IsDeleted == false) .Where(startTime.IsNotNull(), x => x.CreatedTime >= startTime) .Where(endTime.IsNotNull(), x => x.CreatedTime <= endTime) - .OrderByDescending(x => x.PlusOilDate) - .Select(x => new OilOutput() - { - Id = x.Id, - VehicleId = x.VehicleId, - PlusOilDate = x.PlusOilDate.ToString("yyyy-MM-dd"), - VehicleCode = x.VehicleCode, - PlusOilOrder = x.PlusOilOrder, - PlusOilAmount = x.PlusOilAmount, - OilPrice = x.OilPrice, - AmountMoney = x.AmountMoney - }) - .ToPagedListAsync(currentPage, pageSize)).Adapt>(); - return oils; + .WhereIf(VehicleId.IsNotNull(), x => x.VehicleId == VehicleId) + join d in this.vehicleRepository.AsQueryable() on x.VehicleId equals d.Id + select new OilOutput + { + Id = x.Id, + VehicleId = x.VehicleId, + PlusOilDate = x.PlusOilDate.ToString("yyyy-MM-dd"), + VehicleCode = d.VehicleCode, + PlusOilOrder = x.PlusOilOrder, + PlusOilAmount = x.PlusOilAmount, + OilPrice = x.OilPrice, + AmountMoney = x.AmountMoney + }; + + return res.ToPagedList(currentPage, pageSize).Adapt>(); ; } /// @@ -83,7 +91,7 @@ namespace Znyc.Dispatching.Application SUM(PlusOilAmount)AS PlusOilAmount FROM dc_oil WHERE CompanyId = @companyId AND IsDeleted=FALSE AND VehicleId > 0 And PlusOilDate >= @startTime And PlusOilDate <= @endTime GROUP BY VehicleId,VehicleCode - ORDER BY PlusOilCount DESC,PlusOilAmount DESC,AmountMoney DESC" + ORDER BY PlusOilCount DESC,PlusOilAmount DESC,AmountMoney D ESC" .SqlQueryAsync(new { companyId = _userManager.CompanyId, startTime = startTime, endTime = endTime }); CensusOilOutput data = new CensusOilOutput() { CensusOilList = oilList }; foreach (var item in oilList) @@ -103,9 +111,23 @@ namespace Znyc.Dispatching.Application [Route("api/v1/oil/{id}")] public async Task GetByIdAsync(long id) { - Oil oil = await _repository.DetachedEntities.FirstOrDefaultAsync(x => x.Id == id); - var result = oil.Adapt(); - result.PlusOilDate = oil.PlusOilDate.ToString("yyyy-MM-dd"); + var oil = from x in _repository.AsQueryable() + .Where(x => x.CompanyId == _userManager.CompanyId && x.IsDeleted == false) + .Where(x => x.Id == id) + join d in this.vehicleRepository.AsQueryable() on x.VehicleId equals d.Id + select new Oil + { + Id = x.Id, + VehicleId = x.VehicleId, + PlusOilDate = x.PlusOilDate, + VehicleCode = d.VehicleCode, + PlusOilOrder = x.PlusOilOrder, + PlusOilAmount = x.PlusOilAmount, + OilPrice = x.OilPrice, + AmountMoney = x.AmountMoney + }; + var result = oil.SingleOrDefault().Adapt(); + result.PlusOilDate = result.PlusOilDate.ToString("yyyy-MM-dd"); return result; } @@ -165,5 +187,206 @@ namespace Znyc.Dispatching.Application } } + + + /// + /// 油耗统计 + /// + /// + /// + /// + [HttpGet] + [Route("api/v1/newcensus/oils/search")] + public async Task NewOilCensusPageAsync(DateTime startTime, DateTime endTime) + { + List expenditures = new List(); + List fourExpenditures = new List(); + + List cakeJsons = new List(); + var Day = TimeHelper.ExecDateDay(startTime, endTime); + + var reslq = from x in _repository.AsQueryable() + .Where(x => x.IsDeleted == false) + .Where(x => x.CompanyId == _userManager.CompanyId) + .Where(x => x.CreatedTime >= startTime && x.CreatedTime < endTime) + join d in this.vehicleRepository.AsQueryable() on x.VehicleId equals d.Id + select new Oil + { + VehicleCode = d.VehicleCode, + VehicleId = x.VehicleId, + AmountMoney = x.AmountMoney, + PlusOilAmount = x.PlusOilAmount, + CompanyId = x.CompanyId, + CreatedTime = x.CreatedTime, + CreatedUserId = x.CreatedUserId, + Id = x.Id, + IsDeleted = x.IsDeleted, + ModifiedTime = x.ModifiedTime, + ModifiedUserId = x.ModifiedUserId, + OilPrice = x.OilPrice, + PlusOilDate = x.PlusOilDate, + PlusOilOrder = x.PlusOilOrder, + Remarks = x.Remarks + }; + var res = reslq.ToList(); + + + //var res = await _repository.DetachedEntities + // .Where(x => x.IsDeleted == false) + // .Where(x => x.CompanyId == _userManager.CompanyId) + // .Where(x => x.CreatedTime >= startTime && x.CreatedTime < endTime) + // .OrderByDescending(x => x.CreatedTime).Select(x => new Oil { AmountMoney = x.AmountMoney, PlusOilAmount = x.PlusOilAmount, VehicleCode = x.VehicleCode, }).ToListAsync(); + + var sum = res.Sum(x => x.AmountMoney); + var Avg = Math.Round(sum / Day, 2); + + ColumnJson columnJson = new ColumnJson(); + + var carsinfo = res.GroupBy(x => x.VehicleCode,x => new { x.AmountMoney,x.PlusOilAmount }).ToList(); + + if (carsinfo.Count() == 0) + return new NewCensusOilOutput(); + + + var cars = carsinfo.Select(x => x.Key); + + foreach (var item in cars) + { + var car = res.Where(x => x.VehicleCode == item); + expenditures.Add(new Expenditure() + { + CarNo = item, + Name = car.FirstOrDefault().VehicleCode, + Value = car.Sum(x =>(Convert.ToInt32(x.PlusOilAmount))) + + }); + columnJson.categories.Add(car.FirstOrDefault().VehicleCode); + columnJson.data.Add(car.Sum(x => x.AmountMoney)); + } + + //油量最高得车 + var TopAmoCode = carsinfo.OrderByDescending(x => x.Sum(x => Convert.ToInt32(x.PlusOilAmount))).Select(x => new { VehicleCode = x.Key, PlusOilAmount = x.Sum(x => Convert.ToInt32(x.PlusOilAmount)) }).FirstOrDefault(); + if (TopAmoCode.IsNotNull()) + { + fourExpenditures.Add(new Expenditure() + { + Name = "油量最高", + CarNo = TopAmoCode.VehicleCode, + Value = TopAmoCode.PlusOilAmount, + }); + + } + + //油量最低得车 + var DowAmoCode = carsinfo.OrderBy(x => x.Sum(x => Convert.ToInt32(x.PlusOilAmount))).Select(x => new { VehicleCode = x.Key, PlusOilAmount = x.Sum(x => Convert.ToInt32(x.PlusOilAmount)) }).FirstOrDefault(); + if (DowAmoCode.IsNotNull()) + { + fourExpenditures.Add(new Expenditure() + { + Name = "油量最低", + CarNo = DowAmoCode.VehicleCode, + Value = DowAmoCode.PlusOilAmount, + }); + + + } + //油费最高得车 + var TopMonCode = carsinfo.OrderByDescending(x => x.Sum(x => x.AmountMoney)).Select(x => new { VehicleCode = x.Key, AmountMoney = x.Sum(x => x.AmountMoney) }).FirstOrDefault(); + if (TopMonCode.IsNotNull()) + { + fourExpenditures.Add(new Expenditure() + { + Name = "油费最高", + CarNo = TopMonCode.VehicleCode, + Value = TopMonCode.AmountMoney, + }); + + } + + //邮费最低的车 + var DowMonCode = carsinfo.OrderBy(x =>x.Sum(x=>x.AmountMoney)).Select(x => new { VehicleCode = x.Key, AmountMoney = x.Sum(x => x.AmountMoney) }).FirstOrDefault(); + if (DowMonCode.IsNotNull()) + { + + fourExpenditures.Add(new Expenditure() + { + Name = "油费最低", + CarNo = DowMonCode.VehicleCode, + Value = DowMonCode.AmountMoney, + }); + } + + + return new NewCensusOilOutput() + { + Average = Avg.ToString(), + Cumulative = sum.ToString(), + ColumnJson = columnJson, + Expenditures = expenditures, + FourExpenditures = fourExpenditures + }; + } + + + + /// + /// 车辆分组统计 + /// + /// + /// + /// + [HttpGet] + [Route("api/v1/newcensus/OilsTotal")] + public async Task CarTotal(DateTime startTime, DateTime endTime) + { + OilCatTotalOutput carTotalOutPut = new OilCatTotalOutput(); + //var res = await _repository.DetachedEntities + // .Where(x => x.IsDeleted == false) + // .Where(x => x.CompanyId == _userManager.CompanyId) + // .Where(x => x.CreatedTime >= startTime && x.CreatedTime < endTime) + // .OrderByDescending(x => x.CreatedTime).ToListAsync(); + + + var reslq = from x in _repository.AsQueryable() + .Where(x => x.IsDeleted == false) + .Where(x => x.CompanyId == _userManager.CompanyId) + .Where(x => x.CreatedTime >= startTime && x.CreatedTime < endTime) + join d in this.vehicleRepository.AsQueryable() on x.VehicleId equals d.Id + select new Oil + { + VehicleCode = d.VehicleCode, + VehicleId = x.VehicleId, + AmountMoney = x.AmountMoney, + PlusOilAmount = x.PlusOilAmount, + CompanyId = x.CompanyId, + CreatedTime = x.CreatedTime, + CreatedUserId = x.CreatedUserId, + Id = x.Id, + IsDeleted = x.IsDeleted, + ModifiedTime = x.ModifiedTime, + ModifiedUserId = x.ModifiedUserId, + OilPrice = x.OilPrice, + PlusOilDate = x.PlusOilDate, + PlusOilOrder = x.PlusOilOrder, + Remarks = x.Remarks + }; + var res = reslq.ToList(); + + + var grres = res.GroupBy(x => x.VehicleId, x => new { x.PlusOilAmount,x.VehicleCode }).Select(x => new OilCatOutputInfo() { + ID = x.Key, + CarName = x.First().VehicleCode, + OilPtion = x.Sum(x=> Convert.ToInt32(x.PlusOilAmount)), + WoekAmount = "0", + OilThan = "0", + TimeAmount = 0 + }) .ToList(); + + return new OilCatTotalOutput() + { + Total = grres.Sum(x => x.OilPtion), + OilCatOutputInfos = grres + }; + } } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.Application/Order/Dto/Input/Sign/SignInput.cs b/src/Znyc.Dispatching.Application/Order/Dto/Input/Sign/SignInput.cs index 1974516..36ee7c2 100644 --- a/src/Znyc.Dispatching.Application/Order/Dto/Input/Sign/SignInput.cs +++ b/src/Znyc.Dispatching.Application/Order/Dto/Input/Sign/SignInput.cs @@ -19,5 +19,7 @@ namespace Znyc.Dispatching.Application /// [Required(ErrorMessage = "请上传签证单")] public string Picture { get; set; } + + } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.Application/Order/Dto/Input/StayAssign/StayAssignInput.cs b/src/Znyc.Dispatching.Application/Order/Dto/Input/StayAssign/StayAssignInput.cs index 7d1e09d..74a04ff 100644 --- a/src/Znyc.Dispatching.Application/Order/Dto/Input/StayAssign/StayAssignInput.cs +++ b/src/Znyc.Dispatching.Application/Order/Dto/Input/StayAssign/StayAssignInput.cs @@ -8,6 +8,7 @@ namespace Znyc.Dispatching.Application /// public class StayAssignInput { + [Required(ErrorMessage = "缺少ID")] public long Id { get; set; } /// @@ -18,7 +19,7 @@ namespace Znyc.Dispatching.Application /// /// 工程名称 /// - public string ProjectName { get; set; } + public string? ProjectName { get; set; } /// /// 业务员Id diff --git a/src/Znyc.Dispatching.Application/Order/Dto/OutPut/DistinguishOut.cs b/src/Znyc.Dispatching.Application/Order/Dto/OutPut/DistinguishOut.cs new file mode 100644 index 0000000..ad0e121 --- /dev/null +++ b/src/Znyc.Dispatching.Application/Order/Dto/OutPut/DistinguishOut.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + public class DistinguishOut + { + public long vehicleTypeID { get; set; } + + public string vehicleName { get; set; } + + public DateTime dateTime { get; set; } + + + } +} diff --git a/src/Znyc.Dispatching.Application/Order/Dto/OutPut/OrderOutput.cs b/src/Znyc.Dispatching.Application/Order/Dto/OutPut/OrderOutput.cs index b5fc6ec..2d81292 100644 --- a/src/Znyc.Dispatching.Application/Order/Dto/OutPut/OrderOutput.cs +++ b/src/Znyc.Dispatching.Application/Order/Dto/OutPut/OrderOutput.cs @@ -161,6 +161,15 @@ namespace Znyc.Dispatching.Application /// public List OrderVisas { get; set; } + + + /// + /// 安检明细 + /// + public List OrderCheck { get; set; } + + + /// /// 是否外请车 /// @@ -205,6 +214,29 @@ namespace Znyc.Dispatching.Application /// public DateTime? ArriveHomeDate { get; set; } + //泵送时长 + public string Time { get; set; } + + /// + /// 到达时间 + /// + public DateTime ArriveTime { get; set; } + + /// + /// 小时 + /// + public string Hour { get; set; } + + /// + /// 分钟 + /// + public string Minute { get; set; } + + /// + /// 方量 + /// + public string Party { get; set; } + } /// diff --git a/src/Znyc.Dispatching.Application/Order/Services/OrderService.cs b/src/Znyc.Dispatching.Application/Order/Services/OrderService.cs index f133e3f..dd04a7f 100644 --- a/src/Znyc.Dispatching.Application/Order/Services/OrderService.cs +++ b/src/Znyc.Dispatching.Application/Order/Services/OrderService.cs @@ -1,3 +1,4 @@ +using Furion; using Furion.ClayObject; using Furion.DatabaseAccessor; using Furion.DatabaseAccessor.Extensions; @@ -6,6 +7,7 @@ using Furion.DynamicApiController; using Furion.FriendlyException; using Mapster; using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; @@ -15,6 +17,8 @@ using Senparc.Weixin.MP.AdvancedAPIs; using Senparc.Weixin.MP.AdvancedAPIs.TemplateMessage; using System; using System.Collections.Generic; +using System.Drawing; +using System.IO; using System.Linq; using System.Threading.Tasks; using Znyc.Dispatching.Common.Extensions; @@ -22,6 +26,7 @@ using Znyc.Dispatching.Core; using Znyc.Dispatching.Core.Entitys; using Znyc.Dispatching.Core.Extension; using Znyc.Dispatching.Core.Helpers; +using Znyc.Dispatching.Core.Util; using Znyc.Dispatching.MongoDb.Repository.Repositorys; using Znyc.Dispatching.WeChat.Core.CommonService.TemplateMessage; @@ -40,6 +45,7 @@ namespace Znyc.Dispatching.Application private readonly IRepository _orderVehicleRepository; private readonly IRepository _vehicleRepository; private readonly IRepository _orderVisaRepository; + private readonly IRepository orderCheckRepository; private readonly WeixinSettingOptions _weixinSettingOptions; private readonly IRepository _wxUserRelationRepository; private readonly IGpsRealTimeRepository _gpsRealTimeRepository; @@ -69,6 +75,7 @@ namespace Znyc.Dispatching.Application IEmployeeService employeeService, IRepository vehiclePersonitory, ILogger logger, + IRepository orderCheckRepository, IRepository projectPersonRepository, IRepository vehicleTypeRepository, IRepository constructionRpository, @@ -94,11 +101,122 @@ namespace Znyc.Dispatching.Application _constructionRpository = constructionRpository; _employeeRepository = employeeRepository; _projectRepository = projectRepository; + this.orderCheckRepository = orderCheckRepository; } #region 管理员/调度端/业务员端 + + /// + /// 字符识别 + /// + /// + /// + [HttpGet] + [AllowAnonymous] + [Route("api/v1/admin/order/getdistinguish")] + public DistinguishOut Getdistinguish(string chars) + { + DistinguishOut distinguishOut = new DistinguishOut(); + try + { + + //查询所有车型 + var vehicleTypes = _vehicleTypeRepository.DetachedEntities.Where(x => x.CompanyId == _userManager.CompanyId).Select(x => new { x.Name, x.Id }).ToList(); + + chars = chars.Replace(":", " ").Replace(":", " "); + var res = chars.Split("时间 "); + + DateTime dateTime = new DateTime(); + //标准年月日 + var y = res[1].Contains("年"); + List lsSp = new List(); + if (y) + { + lsSp = res[1].Split("年").ToList(); + var years = Convert.ToInt32(lsSp[0]) == dateTime.Year ? 0 : Convert.ToInt32(lsSp[0]) - DateTime.Now.Year; + dateTime = dateTime.AddYears(years); + } + var m = res[1].Contains("月"); + + if (y & m) + { + lsSp = lsSp[1].Split("月").ToList(); + var months = Convert.ToInt32(lsSp[0]) == dateTime.Month ? 0 : Convert.ToInt32(lsSp[0]) - DateTime.Now.Month; + dateTime = dateTime.AddMonths(months); + } + var d = res[1].Contains("日"); + + if (y & m & d) + { + lsSp = lsSp[1].Split("日").ToList(); + var days = Convert.ToInt32(lsSp[0]) == dateTime.Day ? 0 : Convert.ToInt32(lsSp[0]) - DateTime.Now.Day; + dateTime = dateTime.AddDays(days); + } + + if (res[1].Contains("今天")) + dateTime = DateTime.Now; + + if (res[1].Contains("明天")) + dateTime = DateTime.Now.AddDays(1); + + if (res[1].Contains("中午")) + { + //var h = DateTimeHelper.RemoveNotNumber(item.Split("中午")[1].Replace(":", "")).Substring(0, 1).ToInt(); + dateTime = dateTime.AddHours(DateTime.Now.Hour - 12); + } + + //具体时间 + if (res[1].Contains("上午")) + { + var h = DateTimeHelper.RemoveNotNumber(res[1].Split("上午")[1]).ToInt(); + dateTime = dateTime.AddHours(h - dateTime.Hour); + } + if (res[1].Contains("早上")) + { + var h = DateTimeHelper.RemoveNotNumber(res[1].Split("早上")[1]).ToInt(); + dateTime = dateTime.AddHours(h - dateTime.Hour); + } + if (res[1].Contains("下午")) + { + var h = DateTimeHelper.RemoveNotNumber(res[1].Split("下午")[1]).ToInt(); + dateTime = dateTime.AddHours(h - dateTime.Hour); + } + dateTime = dateTime.AddMinutes(-dateTime.Minute); + distinguishOut.dateTime = dateTime; + + var sg = chars.Split("施工方式 "); + var sgfs = sg[1].Split(" "); + + var rnn = DateTimeHelper.RemoveNotNumber(sgfs[1]); + + foreach (var vehicleType in vehicleTypes) + { + if (rnn == vehicleType.Name) + { + distinguishOut.vehicleName = vehicleType.Name; + distinguishOut.vehicleTypeID = vehicleType.Id; + break; + } + if (vehicleType.Name.Contains(rnn)) + { + distinguishOut.vehicleName = vehicleType.Name; + distinguishOut.vehicleTypeID = vehicleType.Id; + break; + } + } + return distinguishOut; + } + catch (Exception) + { + + return distinguishOut; + } + + } + + /// /// 管理端任务列表 /// @@ -117,8 +235,8 @@ namespace Znyc.Dispatching.Application var orders = allOrders .WhereIf(status == 1, x => x.Status == (int)OrderStatus.StayAssign) - .WhereIf(status == 2, x => new int[] { (int)OrderStatus.Assign, (int)OrderStatus.Receive, (int)OrderStatus.Travel, (int)OrderStatus.Appear }.Contains(x.Status)) - .WhereIf(status == 3, x => new int[] { (int)OrderStatus.Complete, (int)OrderStatus.Leave, (int)OrderStatus.Sign, (int)OrderStatus.ArriveHome }.Contains(x.Status)) + .WhereIf(status == 2, x => new int[] { (int)OrderStatus.Assign, (int)OrderStatus.Complete, (int)OrderStatus.Check, (int)OrderStatus.Receive, (int)OrderStatus.Travel, (int)OrderStatus.Appear }.Contains(x.Status)) + .WhereIf(status == 3, x => new int[] { (int)OrderStatus.Leave, (int)OrderStatus.Sign, (int)OrderStatus.ArriveHome }.Contains(x.Status)) .WhereIf(status == 4, x => x.Status == (int)OrderStatus.Evaluate) .WhereIf(new long[] { (long)RoleStatusEnum.Salesman, (long)RoleStatusEnum.PartTimeSalesman }.Contains(_userManager.RoleId), x => x.CreatedUserId == _userManager.UserId || x.SalesmanId == _userManager.UserId) @@ -148,6 +266,7 @@ namespace Znyc.Dispatching.Application { order.OrderVehicleDriverName = users.Where(x => x.Id == order.VehicleId).FirstOrDefault()?.UserName; order.OrderVehicleDriverPhone = users.Where(x => x.Id == order.VehicleId).FirstOrDefault()?.Phone; + } } else @@ -157,7 +276,12 @@ namespace Znyc.Dispatching.Application order.OrderVehicleDriverName = orderVehicles.Where(x => x.OrderId == order.Id).FirstOrDefault()?.UserName; order.OrderVehicleDriverPhone = orderVehicles.Where(x => x.OrderId == order.Id).FirstOrDefault()?.UserPhone; } + var res = await _userRepository.Where(x => x.Id == order.AssignUserId).FirstOrDefaultAsync(); + if (res != null) + order.AssignUserName = res.UserName; + } + order.StatusName = typeof(OrderStatus).GetDescription(order.Status); string vehicleTypeName = ""; if (order.VehicleType > 0) @@ -173,13 +297,16 @@ namespace Znyc.Dispatching.Application if (new long[] { (long)OrderStatus.Receive, (long)OrderStatus.Travel }.Contains(order.Status)) { var gpsRealTime = gpsRealTimes.FirstOrDefault(x => x.VehicleId == order.VehicleId); - string origin = (double)gpsRealTime.Longitude + "," + (double)gpsRealTime.Latitude; - string destination = (double)order.Longitude + "," + (double)order.Latitude; - var pathPlanningModel = MapHelper.GetPathPlanningByDriving(origin, destination); - if (pathPlanningModel.status == "1" && pathPlanningModel.info == "OK") + if (gpsRealTime.IsNotNull()) { - order.Distance = $"{ Convert.ToDouble(pathPlanningModel.route.paths[0].distance) / 1000}KM"; - order.ExpectArriveDate = DateTimeHelper.ToChineseDate(Convert.ToInt32(pathPlanningModel.route.paths[0].duration)); + string origin = (double)gpsRealTime.Longitude + "," + (double)gpsRealTime.Latitude; + string destination = (double)order.Longitude + "," + (double)order.Latitude; + var pathPlanningModel = MapHelper.GetPathPlanningByDriving(origin, destination); + if (pathPlanningModel.status == "1" && pathPlanningModel.info == "OK") + { + order.Distance = $"{ Convert.ToDouble(pathPlanningModel.route.paths[0].distance) / 1000}KM"; + order.ExpectArriveDate = DateTimeHelper.ToChineseDate(Convert.ToInt32(pathPlanningModel.route.paths[0].duration)); + } } } } @@ -208,6 +335,45 @@ namespace Znyc.Dispatching.Application } + /// + /// 保存分享 + /// + /// + /// + [HttpPost] + [AllowAnonymous] + [Route("api/v1/order/ShareAsync")] + public async Task ShareAsync(StayAssignInput stayAssign) + { + var order = await _repository.FindOrDefaultAsync(stayAssign.Id); + if (order.IsNull()) + return false; + order.Longitude = stayAssign.Longitude; + order.Latitude = stayAssign.Latitude; + order.Address = stayAssign.Address; + var isorder = await _repository.UpdateNowAsync(order); + + //消息推送 + if (isorder.IsNotNull()) + { + var user = await _userRepository.Where(x => x.Id == order.CreatedUserId).FirstOrDefaultAsync(); + var company = await _companyRepository.Where(x => x.Id == order.CompanyId).FirstOrDefaultAsync(); + var wxUser = _wxUserRelationRepository.Where(x => x.UserId == order.CreatedUserId).FirstOrDefault(); + + var data = new WeixinTemplate_AssignOrder("地址更新通知", order.ProjectName, "地址更新", order.OrderContent, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), $"派单地址已更新,地址为:{order.Address}。请及时派工!"); + TemplateModel_MiniProgram miniProgram = new TemplateModel_MiniProgram(); + miniProgram.appid = _weixinSettingOptions.WxOpenAppId; + miniProgram.pagepath = $"pages/taskInfo/taskInfo?id={order.Id}&isDriver=false&type=0&isOutSide=true"; + var result = await TemplateApi.SendTemplateMessageAsync(_weixinSettingOptions.WeixinAppId, wxUser.WxOfficialOpenId, data.TemplateId, "pages/index/index", data, miniProgram); + return true; + } + else + { + return false; + } + } + + /// /// 保存待指派 @@ -215,9 +381,11 @@ namespace Znyc.Dispatching.Application /// /// [HttpPost] + [AllowAnonymous] [Route("api/v1/order/stayassign")] - public async Task StayAssignAsync(StayAssignInput stayAssign) + public async Task StayAssignAsync(StayAssignInput stayAssign) { + long ID = 0; var order = await _repository.FindOrDefaultAsync(stayAssign.Id); long constructionId = 0; long projectId = stayAssign.ProjectId; @@ -236,7 +404,7 @@ namespace Znyc.Dispatching.Application { constructionId = await GetConstructionId(stayAssign.ConstructionId, stayAssign.ConstructionName); } - + order.AssignUserId = _userManager.UserId; order.ProjectId = projectId; order.ProjectName = stayAssign.ProjectName; order.ArriveDate = stayAssign.ArriveDate; @@ -249,6 +417,7 @@ namespace Znyc.Dispatching.Application order.VehicleCode = ""; order.OrderVehiclePerson = ""; await _repository.UpdateNowAsync(order); + ID = order.Id; } else { @@ -275,19 +444,21 @@ namespace Znyc.Dispatching.Application order.ProjectId = projectId; order.VehicleCode = ""; order.OrderVehiclePerson = ""; + order.AssignUserId = _userManager.UserId; var orderId = (await _repository.InsertNowAsync(order)).Entity.Id; if (orderId <= 0) { throw Oops.Bah($"任务保存失败"); } + ID = orderId; + } await InsertProjectPersonAsync(stayAssign.OrderContent, projectId, constructionId); await UpdateProjectAddressAsync(projectId, stayAssign.Latitude, stayAssign.Longitude, stayAssign.Address); + return ID; } - - /// /// 指派订单 /// @@ -319,10 +490,10 @@ namespace Znyc.Dispatching.Application bool isChange = false; #region order - + RegexHelper.ReturnPhones(assign.OrderContent); long projectId = assign.ProjectId; //工程名称是否存在,不存在新增,返回工程信息 - if (assign.ProjectId == 0) + if (assign.ProjectName is not null) { projectId = await GetProjectId(assign.Latitude, assign.Longitude, assign.Address, assign.ProjectName); } @@ -332,6 +503,8 @@ namespace Znyc.Dispatching.Application { constructionId = await GetConstructionId(assign.ConstructionId, assign.ConstructionName); } + + //未保存直接指派 if (order.IsNull()) { @@ -357,6 +530,8 @@ namespace Znyc.Dispatching.Application throw Oops.Bah($"指派失败"); } + + var orderContent = assign.OrderContent.Length > 45 ? HtmlHelper.ReplaceHtmlMark((assign.OrderContent.Substring(0, 45))) + "..." : HtmlHelper.ReplaceHtmlMark(assign.OrderContent) + "..."; if (assign.IsOutside) { @@ -395,6 +570,7 @@ namespace Znyc.Dispatching.Application TemplateModel_MiniProgram miniProgram = new TemplateModel_MiniProgram(); miniProgram.appid = _weixinSettingOptions.WxOpenAppId; miniProgram.pagepath = $"pages/taskInfo/taskInfo?id={order.Id}&isDriver={orderVehicle.IsDriver.ToString().ToLower()}&type=1"; + Console.WriteLine("出车通知!WxOfficialOpenId:{0},WeixinAppId:{1}", wxUser.WxOfficialOpenId, _weixinSettingOptions.WeixinAppId); var result = await TemplateApi.SendTemplateMessageAsync(_weixinSettingOptions.WeixinAppId, wxUser.WxOfficialOpenId, data.TemplateId, "pages/index/index", data, miniProgram); Console.WriteLine($"{miniProgram.pagepath}"); Console.WriteLine($"保存直接指派{JsonConvert.SerializeObject(result)}"); @@ -405,8 +581,7 @@ namespace Znyc.Dispatching.Application } } } - //保存后指派 - else + else //保存后指派 { var orderContent = HtmlHelper.ReplaceHtmlMark(assign.OrderContent); @@ -445,7 +620,7 @@ namespace Znyc.Dispatching.Application message += "[施工地点]"; } - if (order.VehicleId != assign.VehicleId && order.VehicleId>0) + if (order.VehicleId != assign.VehicleId && order.VehicleId > 0) { isChangeVehicle = true; isChange = true; @@ -474,10 +649,11 @@ namespace Znyc.Dispatching.Application order.ArriveDate = assign.ArriveDate; order.ConstructionId = constructionId; order.ProjectId = projectId; + await _repository.UpdateNowAsync(order); var newOrderVehicles = assign.OrderVehicles.Adapt>(); var oldOrderVehicles = _orderVehicleRepository.Where(x => x.OrderId == order.Id).ToList(); - orderContent = assign.OrderContent.Length > 45 ? HtmlHelper.ReplaceHtmlMark(assign.OrderContent.Substring(0, 45)) + "..." : HtmlHelper.ReplaceHtmlMark(assign.OrderContent) + "..."; + orderContent = assign.OrderContent.Length > 45 ? HtmlHelper.ReplaceHtmlMark(assign.OrderContent.Substring(0, 45)) + "..." : HtmlHelper.ReplaceHtmlMark(assign.OrderContent) + "..."; if (order.IsOutside) { @@ -500,10 +676,10 @@ namespace Znyc.Dispatching.Application //需撤销的list var revokeOldOrderVehicles = oldOrderVehicles.Except(newOrderVehicles, new OrderVehicleCompara()).ToList(); //是否替换司机 - isChangePersonnel= revokeOldOrderVehicles.Any(x => x.IsDriver); + isChangePersonnel = revokeOldOrderVehicles.Any(x => x.IsDriver); foreach (var revokeOldOrderVehicle in revokeOldOrderVehicles) { - + await _orderVehicleRepository.DeleteNowAsync(revokeOldOrderVehicle); var wxUser = _wxUserRelationRepository.Where(x => x.UserId == revokeOldOrderVehicle.UserId).FirstOrDefault(); if (wxUser.IsNotNull() && wxUser.WxOfficialOpenId.IsNotNull()) @@ -524,6 +700,8 @@ namespace Znyc.Dispatching.Application var newlyOrderVehicles = newOrderVehicles.Except(oldOrderVehicles, new OrderVehicleCompara()).ToList(); foreach (var newlyOrderVehicle in newlyOrderVehicles) { + Console.WriteLine(newlyOrderVehicle.UserName); + newlyOrderVehicle.UserName = newlyOrderVehicle.UserName == "" || newlyOrderVehicle.UserName.IsNull() ? newlyOrderVehicle.UserPhone : newlyOrderVehicle.UserName; var newVehicleId = (await _orderVehicleRepository.InsertNowAsync(newlyOrderVehicle)).Entity.Id; if (newVehicleId > 0) { @@ -540,7 +718,7 @@ namespace Znyc.Dispatching.Application var result = await TemplateApi.SendTemplateMessageAsync(_weixinSettingOptions.WeixinAppId, wxUser.WxOfficialOpenId, data.TemplateId, "pages/index/index", data, miniProgram); Console.WriteLine($"{miniProgram.pagepath}"); Console.WriteLine($"出车任务通知{JsonConvert.SerializeObject(result)}"); - // isChangePersonnel = true; + // isChangePersonnel = true; } @@ -576,34 +754,53 @@ namespace Znyc.Dispatching.Application await InsertProjectPersonAsync(assign.OrderContent, projectId, constructionId); await UpdateProjectAddressAsync(projectId, assign.Latitude, assign.Longitude, assign.Address); - //同步车组人员 - if (assign.IsReplaceOrderVehicle) + + //List personOutput = new List(); + + var orderVehicles = await _orderVehicleRepository.Where(x => x.OrderId == order.Id).ToListAsync(); + await _vehiclePersonitory.Context.DeleteRangeAsync(b => b.VehicleId == order.VehicleId); ; + foreach (var orderVehicle in orderVehicles) { - var orderVehicles = await _orderVehicleRepository.Where(x => x.OrderId == order.Id).ToListAsync(); - await _vehiclePersonitory.Context.DeleteRangeAsync(b => b.VehicleId == order.VehicleId); ; - foreach (var orderVehicle in orderVehicles) + + var vehiclePerson = new VehiclePerson() { - var vehiclePerson = new VehiclePerson() - { - VehicleId = order.VehicleId, - UserId = orderVehicle.UserId, - UserName = orderVehicle.UserName, - UserPhone = orderVehicle.UserPhone, - IsDriver = orderVehicle.IsDriver - - }; - await _vehiclePersonitory.InsertNowAsync(vehiclePerson); + VehicleId = order.VehicleId, + UserId = orderVehicle.UserId, + UserName = orderVehicle.UserName, + UserPhone = orderVehicle.UserPhone, + IsDriver = orderVehicle.IsDriver + + }; + //personOutput.Add(new VehiclePersonOutput() + //{ + // UserId = orderVehicle.UserId, + // VehicleId = order.VehicleId, + // UserName = orderVehicle.UserName, + // UserPhone = orderVehicle.UserPhone, + // IsDriver = orderVehicle.IsDriver + //}); + await _vehiclePersonitory.InsertNowAsync(vehiclePerson); + var vehicles = await _vehicleRepository.Where(x => x.Id == order.VehicleId).FirstOrDefaultAsync(); + if (vehicles.IsNotNull()) + { + vehicles.ContactPerson = orderVehicle.UserName; + vehicles.ContactPhone = orderVehicle.UserPhone; + await _vehicleRepository.UpdateAsync(vehicles); } - await _cacheService.RemoveVehiclePersonAsync(order.VehicleId); } + //设置车组人员 + //await _cacheService.SetVehiclePersonAsync(personOutput, order.VehicleId); + + await _cacheService.RemoveVehicleAsync(order.VehicleId); + await _cacheService.RemoveVehiclePersonAsync(order.VehicleId); + + } #endregion } - - /// /// 完成订单 /// @@ -626,6 +823,8 @@ namespace Znyc.Dispatching.Application //推送至所有车组人员已完工通知 var orderVehicles = _orderVehicleRepository.Where(x => x.OrderId == order.Id).ToList(); + var orderVehicleDriverName = orderVehicles.FirstOrDefault(x => x.IsDriver).UserName; + var orderVehicleCrewsName = string.Join(",", orderVehicles.Where(x => !x.IsDriver).Select(x => x.UserName).ToList()); if (orderVehicles.IsNotNull() && orderVehicles.Count > 0) { foreach (var orderVehicle in orderVehicles) @@ -648,7 +847,7 @@ namespace Znyc.Dispatching.Application var wxUser = _wxUserRelationRepository.Where(x => x.UserId == order.AssignUserId).FirstOrDefault(); if (wxUser.IsNotNull() && wxUser.WxOfficialOpenId.IsNotNull()) { - var data = new WeixinTemplate_AssignOrder("已完工通知", order.ProjectName, "已完工", orderContent, order.ArriveDate.ToString("yyyy-MM-dd HH:mm:ss"), "恭喜任务已完成!返回时记得交单哦,辛苦 了~"); + var data = new WeixinTemplate_AssignOrder("已完工通知", order.ProjectName, "已完工", orderContent, order.ArriveDate.ToString("yyyy-MM-dd HH:mm:ss"), $"[{order.VehicleCode}]号车,{orderVehicleDriverName},{orderVehicleCrewsName}已完工"); TemplateModel_MiniProgram miniProgram = new TemplateModel_MiniProgram(); miniProgram.appid = _weixinSettingOptions.WxOpenAppId; miniProgram.pagepath = $"pages/taskInfo/taskInfo?id={order.Id}&isDriver=false&type=2"; @@ -752,7 +951,6 @@ namespace Znyc.Dispatching.Application } - #endregion #region 司机端 @@ -769,77 +967,101 @@ namespace Znyc.Dispatching.Application var order = await _repository.FindOrDefaultAsync(orderId); if (order.IsNotNull()) { + Console.WriteLine("接单"); var orderContent = order.OrderContent.Length > 45 ? HtmlHelper.ReplaceHtmlMark(order.OrderContent.Substring(0, 45)) + "..." : HtmlHelper.ReplaceHtmlMark(order.OrderContent) + "..."; var isDriver = _orderVehicleRepository.Any(x => x.OrderId == orderId && x.IsDriver == true && x.UserId == _userManager.UserId); if (isDriver) { - order.ReceiveDate = DateTime.Now; - order.Status = (int)OrderStatus.Receive; - //存储当前定位信息 - var vehicleGps = await _gpsRealTimeRepository.GetGpsRealTimeByVehicleId(order.VehicleId); - if (vehicleGps.IsNotNull()) + + //判断公司是否开启安检 + var compay = await _cacheService.GetCompanyAsync(_userManager.CompanyId, _userManager.UserId); + if (compay.IsShowCheckType) { - dynamic clay = Clay.Object(new + order.ReceiveDate = DateTime.Now; + order.Status = (int)OrderStatus.Check; + //推送完工提交签证单通知给司机 + var wxUser = _wxUserRelationRepository.Where(x => x.UserId == _userManager.UserId).FirstOrDefault(); + if (wxUser.IsNotNull() && wxUser.WxOfficialOpenId.IsNotNull()) { - Latitude = vehicleGps.Latitude, - Longitude = vehicleGps.Longitude - }); - await _cacheService.SetVehicleGpsAsync(orderId, clay); + var data = new WeixinTemplate_AssignOrder("现场拍照通知", order.ProjectName, "现场拍照", orderContent, order.ArriveDate.ToString("yyyy -MM-dd HH:mm:ss"), "到达施工现场后请点击这里,拍照回传!"); + TemplateModel_MiniProgram miniProgram = new TemplateModel_MiniProgram(); + miniProgram.appid = _weixinSettingOptions.WxOpenAppId; + miniProgram.pagepath = $"pages/taskInfo/taskInfo?id={order.Id}&isDriver=true&type=1"; + var result = await TemplateApi.SendTemplateMessageAsync(_weixinSettingOptions.WeixinAppId, wxUser.WxOfficialOpenId, data.TemplateId, "pages/index/index", data, miniProgram); + Console.WriteLine($"{miniProgram.pagepath}"); + Console.WriteLine($"提交环境单通知{JsonConvert.SerializeObject(result)}"); + + } } - await _repository.UpdateNowAsync(order); - //推送完工提交签证单通知给司机 - var wxUser = _wxUserRelationRepository.Where(x => x.UserId == _userManager.UserId).FirstOrDefault(); - if (wxUser.IsNotNull() && wxUser.WxOfficialOpenId.IsNotNull()) + else { - var data = new WeixinTemplate_AssignOrder("完工提交签证单通知", order.ProjectName, "完工提交签证单", orderContent, order.ArriveDate.ToString("yyyy -MM-dd HH:mm:ss"), "完工后请点击这里,拍照回传签证单!"); - TemplateModel_MiniProgram miniProgram = new TemplateModel_MiniProgram(); - miniProgram.appid = _weixinSettingOptions.WxOpenAppId; - miniProgram.pagepath = $"pages/taskInfo/taskInfo?id={order.Id}&isDriver=true&type=1"; - var result = await TemplateApi.SendTemplateMessageAsync(_weixinSettingOptions.WeixinAppId, wxUser.WxOfficialOpenId, data.TemplateId, "pages/index/index", data, miniProgram); - Console.WriteLine($"{miniProgram.pagepath}"); - Console.WriteLine($"完工提交签证单通知{JsonConvert.SerializeObject(result)}"); + order.ReceiveDate = DateTime.Now; + order.Status = (int)OrderStatus.Receive; + //存储当前定位信息 + var vehicleGps = await _gpsRealTimeRepository.GetGpsRealTimeByVehicleId(order.VehicleId); + if (vehicleGps.IsNotNull()) + { + dynamic clay = Clay.Object(new + { + Latitude = vehicleGps.Latitude, + Longitude = vehicleGps.Longitude + }); + await _cacheService.SetVehicleGpsAsync(orderId, clay); + } + await _repository.UpdateNowAsync(order); + //推送完工提交签证单通知给司机 + var wxUser = _wxUserRelationRepository.Where(x => x.UserId == _userManager.UserId).FirstOrDefault(); + if (wxUser.IsNotNull() && wxUser.WxOfficialOpenId.IsNotNull()) + { + var data = new WeixinTemplate_AssignOrder("完工提交签证单通知", order.ProjectName, "完工提交签证单", orderContent, order.ArriveDate.ToString("yyyy -MM-dd HH:mm:ss"), "完工后请点击这里,拍照回传签证单!"); + TemplateModel_MiniProgram miniProgram = new TemplateModel_MiniProgram(); + miniProgram.appid = _weixinSettingOptions.WxOpenAppId; + miniProgram.pagepath = $"pages/taskInfo/taskInfo?id={order.Id}&isDriver=true&type=1"; + var result = await TemplateApi.SendTemplateMessageAsync(_weixinSettingOptions.WeixinAppId, wxUser.WxOfficialOpenId, data.TemplateId, "pages/index/index", data, miniProgram); + Console.WriteLine($"{miniProgram.pagepath}"); + Console.WriteLine($"完工提交签证单通知{JsonConvert.SerializeObject(result)}"); + + } + + + + } - //v1.2.7 推送至派单调度以及管理员 + + //管理员 + var adminUserIds = await _employeeRepository.DetachedEntities.Where(x => x.CompanyId == _userManager.CompanyId && x.UserId != order.AssignUserId && x.RoleId == (int)RoleStatusEnum.Administrator && x.Status == 1 && !x.IsDeleted).Select(x => x.UserId).ToListAsync(); + //派单人 + adminUserIds.Add(order.AssignUserId); + //获取订单所有车组人员信息 + var orderVehicles = await _orderVehicleRepository.DetachedEntities.Where(x => x.OrderId == order.Id).ToListAsync(); + var orderVehicleDriverName = orderVehicles.FirstOrDefault(x => x.IsDriver).UserName; + var orderVehicleCrewsName = string.Join(",", orderVehicles.Where(x => !x.IsDriver).Select(x => x.UserName).ToList()); + foreach (var adminUserId in adminUserIds) { - //管理员 - var adminUserIds = await _employeeRepository.DetachedEntities.Where(x => x.CompanyId == _userManager.CompanyId && x.RoleId == (int)RoleStatusEnum.Administrator && x.Status == 1 && !x.IsDeleted).Select(x => x.UserId).ToListAsync(); - //派单人 - adminUserIds.Add(order.AssignUserId); - //获取订单所有车组人员信息 - var orderVehicles = await _orderVehicleRepository.DetachedEntities.Where(x => x.OrderId == order.Id).ToListAsync(); - var orderVehicleDriverName = orderVehicles.FirstOrDefault(x => x.IsDriver).UserName; - var orderVehicleCrewsName = string.Join(",", orderVehicles.Where(x => !x.IsDriver).Select(x => x.UserName).ToList()); - foreach (var adminUserId in adminUserIds) + var wxAdminUser = _wxUserRelationRepository.Where(x => x.UserId == adminUserId).FirstOrDefault(); + Console.WriteLine("提醒管理员" + adminUserId); + if (wxAdminUser.IsNotNull() && wxAdminUser.WxOfficialOpenId.IsNotNull()) { - var wxAdminUser = _wxUserRelationRepository.Where(x => x.UserId == adminUserId).FirstOrDefault(); - if (wxAdminUser.IsNotNull() && wxAdminUser.WxOfficialOpenId.IsNotNull()) - { - var data = new WeixinTemplate_AssignOrder("已接单提醒", order.ProjectName, "已接单", orderContent, order.ArriveDate.ToString("yyyy -MM-dd HH:mm:ss"), $"[{order.VehicleCode}]号车,{orderVehicleDriverName}已接单,{orderVehicleCrewsName}已阅读"); - TemplateModel_MiniProgram miniProgram = new TemplateModel_MiniProgram(); - miniProgram.appid = _weixinSettingOptions.WxOpenAppId; - miniProgram.pagepath = $"pages/taskInfo/taskInfo?id={order.Id}&isDriver=false&type=2"; - var result = await TemplateApi.SendTemplateMessageAsync(_weixinSettingOptions.WeixinAppId, wxAdminUser.WxOfficialOpenId, data.TemplateId, "pages/index/index", data, miniProgram); - Console.WriteLine($"{miniProgram.pagepath}"); - Console.WriteLine($"已接单提醒{JsonConvert.SerializeObject(result)}"); - } + var data = new WeixinTemplate_AssignOrder("已接单提醒", order.ProjectName, "已接单", orderContent, order.ArriveDate.ToString("yyyy -MM-dd HH:mm:ss"), $"[{order.VehicleCode}]号车,{orderVehicleDriverName}已接单,{orderVehicleCrewsName}已阅读"); + TemplateModel_MiniProgram miniProgram = new TemplateModel_MiniProgram(); + miniProgram.appid = _weixinSettingOptions.WxOpenAppId; + miniProgram.pagepath = $"pages/taskInfo/taskInfo?id={order.Id}&isDriver=false&type=2"; + var result = await TemplateApi.SendTemplateMessageAsync(_weixinSettingOptions.WeixinAppId, wxAdminUser.WxOfficialOpenId, data.TemplateId, "pages/index/index", data, miniProgram); + Console.WriteLine($"{miniProgram.pagepath}"); + Console.WriteLine($"已接单提醒{JsonConvert.SerializeObject(result)}"); } } - //v1.2.8推送变更提醒 + if (order.ModifiedUserId > 0) { var message = await _cacheService.GetOrderReadAsync(order.Id); if (message.IsNotEmptyOrNull()) { - //管理员 - var adminUserIds = await _employeeRepository.DetachedEntities.Where(x => x.CompanyId == _userManager.CompanyId && x.RoleId == (int)RoleStatusEnum.Administrator && x.Status == 1 && !x.IsDeleted).Select(x => x.UserId).ToListAsync(); //派单人 adminUserIds.Add(order.AssignUserId); //业务员 if (order.SalesmanId > 0) adminUserIds.Add(order.SalesmanId); - //获取订单所有车组人员信息 - var orderVehicles = await _orderVehicleRepository.DetachedEntities.Where(x => x.OrderId == order.Id).ToListAsync(); - var orderVehicleDriverName = orderVehicles.FirstOrDefault(x => x.IsDriver).UserName; - var orderVehicleCrewsName = string.Join(",", orderVehicles.Where(x => !x.IsDriver).Select(x => x.UserName).ToList()); + foreach (var adminUserId in adminUserIds) { var wxAdminUser = _wxUserRelationRepository.Where(x => x.UserId == adminUserId).FirstOrDefault(); @@ -849,6 +1071,7 @@ namespace Znyc.Dispatching.Application TemplateModel_MiniProgram miniProgram = new TemplateModel_MiniProgram(); miniProgram.appid = _weixinSettingOptions.WxOpenAppId; miniProgram.pagepath = $"pages/taskInfo/taskInfo?id={order.Id}&isDriver=false&type=2"; + Console.WriteLine("接单OpenID" + wxAdminUser.WxOfficialOpenId); var result = await TemplateApi.SendTemplateMessageAsync(_weixinSettingOptions.WeixinAppId, wxAdminUser.WxOfficialOpenId, data.TemplateId, "pages/index/index", data, miniProgram); Console.WriteLine($"{miniProgram.pagepath}"); Console.WriteLine($"已接单提醒{JsonConvert.SerializeObject(result)}"); @@ -858,6 +1081,7 @@ namespace Znyc.Dispatching.Application } } + } else { @@ -869,76 +1093,307 @@ namespace Znyc.Dispatching.Application throw Oops.Bah("订单不存在"); } } - /// - /// 签单 + /// 删除安检图片 /// - /// + /// /// - [HttpPost] - [UnitOfWork] - [Route("api/v1/order/sign")] - public async Task SignAsync(SignInput sign) + [HttpGet] + [Route("api/v1/order/deleteImg")] + public async Task DeleteCheckAsync(string picture) { + var index = picture.LastIndexOf("/"); + var res = picture.Substring(index + 1); + var pics = await this.orderCheckRepository.Where(x => x.Picture == res).ToListAsync(); + foreach (var ordercheck in pics) + { + ordercheck.OrderId = 0; + await orderCheckRepository.UpdateAsync(ordercheck); + } + } - var order = await _repository.FindOrDefaultAsync(sign.OrderId); - if (order.IsNotNull()) + + /// + /// 删除回执图片 + /// + /// + /// + [HttpGet] + [Route("api/v1/order/deleteReceipt")] + public async Task DeleteReceiptAsync(string picture) + { + var index = picture.LastIndexOf("/"); + var res = picture.Substring(index + 1); + var pics = await this._orderVisaRepository.Where(x => x.Picture == res).ToListAsync(); + foreach (var ordercheck in pics) { - var orderContent = order.OrderContent.Length > 45 ? HtmlHelper.ReplaceHtmlMark(order.OrderContent.Substring(0, 45)) + "..." : HtmlHelper.ReplaceHtmlMark(order.OrderContent) + "..."; + ordercheck.OrderId = 0; + await _orderVisaRepository.UpdateAsync(ordercheck); + } - var isDriver = _orderVehicleRepository.Any(x => x.OrderId == sign.OrderId && x.IsDriver == true); - if (isDriver) + } + + + + + + + + /// + /// 安检图片上传 + /// + /// + /// + /// + /// + [HttpPost] + [AllowAnonymous] + [Route("api/v1/order/checkImg")] + public async Task CheckImgAsync(long OrderId, string location, string Tag, IFormFile formFiles) + { + string resfles = ""; + var filePath = ""; + List files = new List(); + //保存图片 + var savePath = Path.Combine(App.HostEnvironment.ContentRootPath, "uploads"); + if (!Directory.Exists(savePath)) Directory.CreateDirectory(savePath); + + if (formFiles.IsNull()) + return ""; + using (var memoryStream = new MemoryStream()) + { + await formFiles.CopyToAsync(memoryStream); + using (var image = Image.FromStream(memoryStream)) { - order.SignDate = DateTime.Now; - order.Status = (int)OrderStatus.Sign; - await _repository.UpdateNowAsync(order); - //推送通知 - var ordervisa = await _orderVisaRepository.Where(x => x.OrderId == sign.OrderId).FirstOrDefaultAsync(); - if (ordervisa.IsNotNull()) + //调整图片大小 + var sizeImg = WaterMarkHelper.resizeImage(image, new Size(2000, 2000)); + //地址 + var address = MapHelper.GetLocationByLngLat(Convert.ToDecimal(location.Split(":")[0]), Convert.ToDecimal(location.Split(":")[1])); + + var order = await _repository.FindOrDefaultAsync(OrderId); + Console.WriteLine("订单" + order.Id); + var fileName = Guid.NewGuid().ToString("N") + Path.GetExtension(formFiles.FileName); + //图片路径 + filePath = Path.Combine(savePath, fileName); // 可以替代为你需要存储的真实路径 + //存入本地 + WaterMarkHelper.AddImageSignText(sizeImg, filePath, order.Address + "\n" + DateTime.Now.ToString(), 9, 100, 30); + //上传到存储桶 + COSClientUtil cOSClient = new COSClientUtil(); + string prefix = "https://znyc-imagers-1306377152.cos.ap-guangzhou.myqcloud.com"; + var serverFileName = "/dispatching/wx/upload/ordervisa/" + fileName; + var res = cOSClient.NewUpload(prefix, serverFileName, filePath); + resfles = prefix + serverFileName; + //var orderchecks = await orderCheckRepository.Where(x => x.OrderId == OrderId && x.Tag != Tag).ToListAsync(); + //foreach (var ordercheck in orderchecks) + //{ + // ordercheck.OrderId = 0; + // await orderCheckRepository.UpdateAsync(ordercheck); + //} + + + var reschekc = await this.orderCheckRepository.InsertNowAsync(new OrderCheck() { - await _orderVisaRepository.DeleteNowAsync(ordervisa); - } + OrderId = OrderId, + Picture = fileName, + Tag = Tag + }); + + } + + } + + return resfles; + + } + + + /// + /// 安检图片上传 + /// + /// + /// + /// + /// + [HttpPost] + [AllowAnonymous] + [Route("api/v1/order/signImg")] + public async Task SignImgAsync(long OrderId, string location, string Tag, IFormFile formFiles) + { + Console.WriteLine(location); + string resfles = ""; + List files = new List(); + //保存图片 + var savePath = Path.Combine(App.HostEnvironment.ContentRootPath, "uploads"); + if (!Directory.Exists(savePath)) Directory.CreateDirectory(savePath); + + if (formFiles.IsNull()) + return ""; + + using (var memoryStream = new MemoryStream()) + { + await formFiles.CopyToAsync(memoryStream); + using (var image = Image.FromStream(memoryStream)) + { + //调整图片大小 + var sizeImg = WaterMarkHelper.resizeImage(image, new Size(2000, 2000)); + + var order = await _repository.FindOrDefaultAsync(OrderId); + Console.WriteLine("订单"+order.Id); + //地址 + var address = MapHelper.GetLocationByLngLat(Convert.ToDecimal(location.Split(":")[0]), Convert.ToDecimal(location.Split(":")[1])); + + Console.WriteLine("地址" + address); + + var fileName = Guid.NewGuid().ToString("N") + Path.GetExtension(formFiles.FileName); + //图片路径 + var filePath = Path.Combine(savePath, fileName); // 可以替代为你需要存储的真实路径 + Console.WriteLine("存入本地"); + //存入本地 + WaterMarkHelper.AddImageSignText(sizeImg, filePath, order.Address + "\n" + DateTime.Now.ToString(), 9, 100, 30); + //上传到存储桶 + COSClientUtil cOSClient = new COSClientUtil(); + string prefix = "https://znyc-imagers-1306377152.cos.ap-guangzhou.myqcloud.com"; + var serverFileName = "/dispatching/wx/upload/ordervisa/" + fileName; + var res = cOSClient.NewUpload(prefix, serverFileName, filePath); + resfles = prefix + serverFileName; + //var ordervisas = await _orderVisaRepository.Where(x => x.OrderId == OrderId && x.Tag != Tag).ToListAsync(); + //foreach (var ordervisa in ordervisas) + //{ + // ordervisa.OrderId = 0; + // await _orderVisaRepository.UpdateAsync(ordervisa); + //} + var orderVisaId = (await _orderVisaRepository.InsertNowAsync(new OrderVisa() { - OrderId = sign.OrderId, - Picture = sign.Picture, + OrderId = OrderId, + Picture = fileName, + Tag = Tag })).Entity.Id; if (orderVisaId <= 0) { throw Oops.Bah("签单失败"); } - //推送至所有车组人员已完工通知 - var orderVehicles = _orderVehicleRepository.Where(x => x.OrderId == order.Id).ToList(); - if (orderVehicles.IsNotNull() && orderVehicles.Count > 0) + } + } + return resfles; + + } + + + /// + /// 安检完成安检 + /// + /// + /// + [HttpGet] + [UnitOfWork] + [Route("api/v1/order/check")] + public async Task CheckAsync(long OrderId) + { + + //获取订单 + var order = await _repository.FindOrDefaultAsync(OrderId); + if (order == null) + throw Oops.Bah("订单不存在"); + + var orderContent = order.OrderContent.Length > 45 ? HtmlHelper.ReplaceHtmlMark(order.OrderContent.Substring(0, 45)) + "..." : HtmlHelper.ReplaceHtmlMark(order.OrderContent) + "..."; + var isDriver = _orderVehicleRepository.Any(x => x.OrderId == OrderId && x.IsDriver == true); + if (isDriver) + { + order.ArriveDate = DateTime.Now; + order.Status = (int)OrderStatus.Complete; + await _repository.UpdateNowAsync(order); + + var orderVehicles = _orderVehicleRepository.Where(x => x.OrderId == order.Id).ToList(); + var orderVehicleDriverName = orderVehicles.FirstOrDefault(x => x.IsDriver).UserName; + var orderVehicleCrewsName = string.Join(",", orderVehicles.Where(x => !x.IsDriver).Select(x => x.UserName).ToList()); + if (orderVehicles.IsNotNull() && orderVehicles.Count > 0) + { + foreach (var orderVehicle in orderVehicles) { - foreach (var orderVehicle in orderVehicles) + var wxUser = _wxUserRelationRepository.Where(x => x.UserId == orderVehicle.UserId).FirstOrDefault(); + if (wxUser.IsNotNull() && wxUser.WxOfficialOpenId.IsNotNull()) { - var wxUser = _wxUserRelationRepository.Where(x => x.UserId == orderVehicle.UserId).FirstOrDefault(); - if (wxUser.IsNotNull() && wxUser.WxOfficialOpenId.IsNotNull()) - { - var data = new WeixinTemplate_AssignOrder("已完工通知", order.ProjectName, "已完工", orderContent, order.ArriveDate.ToString("yyyy -MM-dd HH:mm:ss"), "恭喜任务已完成!返回时记得交单哦,辛苦了~"); - TemplateModel_MiniProgram miniProgram = new TemplateModel_MiniProgram(); - miniProgram.appid = _weixinSettingOptions.WxOpenAppId; - miniProgram.pagepath = $"pages/taskInfo/taskInfo?id={order.Id}&isDriver={orderVehicle.IsDriver.ToString().ToLower()}&type=1"; - var result = await TemplateApi.SendTemplateMessageAsync(_weixinSettingOptions.WeixinAppId, wxUser.WxOfficialOpenId, data.TemplateId, "pages/index/index", data, miniProgram); - Console.WriteLine($"{miniProgram.pagepath}"); - Console.WriteLine($"已完工通知{JsonConvert.SerializeObject(result)}"); + var data = new WeixinTemplate_AssignOrder("完工提交签证单通知", order.ProjectName, "完工提交签证单", orderContent, order.ArriveDate.ToString("yyyy -MM-dd HH:mm:ss"), "完工后请点击这里,拍照回传签证单!"); + TemplateModel_MiniProgram miniProgram = new TemplateModel_MiniProgram(); + miniProgram.appid = _weixinSettingOptions.WxOpenAppId; + miniProgram.pagepath = $"pages/taskInfo/taskInfo?id={order.Id}&isDriver=true&type=1"; + var result = await TemplateApi.SendTemplateMessageAsync(_weixinSettingOptions.WeixinAppId, wxUser.WxOfficialOpenId, data.TemplateId, "pages/index/index", data, miniProgram); + Console.WriteLine($"{miniProgram.pagepath}"); + Console.WriteLine($"完工提交签证单通知{JsonConvert.SerializeObject(result)}"); - } } } + } + { + //推送至派单人 + var wxUser = _wxUserRelationRepository.Where(x => x.UserId == order.AssignUserId).FirstOrDefault(); + if (wxUser.IsNotNull() && wxUser.WxOfficialOpenId.IsNotNull()) { + var data = new WeixinTemplate_AssignOrder("现场拍照通知", order.ProjectName, "现场拍照", orderContent, order.ArriveDate.ToString("yyyy -MM-dd HH:mm:ss"), $"[{order.VehicleCode}]号车,{orderVehicleDriverName},{orderVehicleCrewsName}现场拍照"); + TemplateModel_MiniProgram miniProgram = new TemplateModel_MiniProgram(); + miniProgram.appid = _weixinSettingOptions.WxOpenAppId; + miniProgram.pagepath = $"pages/taskInfo/taskInfo?id={order.Id}&isDriver=false&type=2"; + await TemplateApi.SendTemplateMessageAsync(_weixinSettingOptions.WeixinAppId, wxUser.WxOfficialOpenId, data.TemplateId, "pages/index/index", data, miniProgram); + Console.WriteLine($"{miniProgram.pagepath}"); + } + } + } + else + { + throw Oops.Bah("暂无权限"); + } + } + + /// + /// 签单 + /// + /// + [HttpGet] + [UnitOfWork] + [Route("api/v1/order/sign")] + public async Task SignAsync(long OrderId, string Party, string Hour, string Minute) + { + + var order = await _repository.FindOrDefaultAsync(OrderId); + + + if (order.IsNotNull()) + { + var orderContent = order.OrderContent.Length > 45 ? HtmlHelper.ReplaceHtmlMark(order.OrderContent.Substring(0, 45)) + "..." : HtmlHelper.ReplaceHtmlMark(order.OrderContent) + "..."; + + var isDriver = _orderVehicleRepository.Any(x => x.OrderId == OrderId && x.IsDriver == true); + if (isDriver) + { + var status = order.Status; + order.CompleteDate = DateTime.Now; + order.Status = (int)OrderStatus.Sign; + order.Party = Party; + order.Hour = Hour ?? "0"; + order.Minute = Minute ?? "0"; + //order.StartTime = startTime; + //order.EndTime = endTime; + //order.StartTime = DateTimeOffset.FromUnixTimeSeconds(startTime).ToLocalTime().DateTime; + //order.EndTime = DateTimeOffset.FromUnixTimeSeconds(endTime).ToLocalTime().DateTime; + await _repository.UpdateNowAsync(order); + if (status != 70) + { + var orderVehicles = _orderVehicleRepository.Where(x => x.OrderId == order.Id).ToList(); + var orderVehicleDriverName = orderVehicles.FirstOrDefault(x => x.IsDriver).UserName; + var orderVehicleCrewsName = string.Join(",", orderVehicles.Where(x => !x.IsDriver).Select(x => x.UserName).ToList()); + //推送至派单人 var wxUser = _wxUserRelationRepository.Where(x => x.UserId == order.AssignUserId).FirstOrDefault(); if (wxUser.IsNotNull() && wxUser.WxOfficialOpenId.IsNotNull()) { - var data = new WeixinTemplate_AssignOrder("已完工通知", order.ProjectName, "已完工", orderContent, order.ArriveDate.ToString("yyyy -MM-dd HH:mm:ss"), "恭喜任务已完成!返回时记得交单哦,辛苦了~"); + var data = new WeixinTemplate_AssignOrder("已完工通知", order.ProjectName, "已完工", orderContent, order.CompleteDate.ToString("yyyy -MM-dd HH:mm:ss"), $"[{order.VehicleCode}]号车,{orderVehicleDriverName},{orderVehicleCrewsName}已完工"); TemplateModel_MiniProgram miniProgram = new TemplateModel_MiniProgram(); miniProgram.appid = _weixinSettingOptions.WxOpenAppId; miniProgram.pagepath = $"pages/taskInfo/taskInfo?id={order.Id}&isDriver=false&type=2"; await TemplateApi.SendTemplateMessageAsync(_weixinSettingOptions.WeixinAppId, wxUser.WxOfficialOpenId, data.TemplateId, "pages/index/index", data, miniProgram); Console.WriteLine($"{miniProgram.pagepath}"); + //} } } } @@ -953,11 +1408,6 @@ namespace Znyc.Dispatching.Application } } - - - - - /// /// 车组人员端任务列表 /// @@ -997,7 +1447,15 @@ namespace Znyc.Dispatching.Application { order.StatusName = "已接单"; } - if (new int[] { (int)OrderStatus.Complete, (int)OrderStatus.Sign, (int)OrderStatus.Leave, (int)OrderStatus.Evaluate, (int)OrderStatus.ArriveHome }.Contains(order.Status)) + if (new int[] { (int)OrderStatus.Check, (int)OrderStatus.Travel, (int)OrderStatus.Appear }.Contains(order.Status)) + { + order.StatusName = "已接单"; + } + if (new int[] { (int)OrderStatus.Complete }.Contains(order.Status)) + { + order.StatusName = "已安检"; + } + if (new int[] { (int)OrderStatus.Sign, (int)OrderStatus.Leave, (int)OrderStatus.Evaluate, (int)OrderStatus.ArriveHome }.Contains(order.Status)) { order.StatusName = "已完工"; } @@ -1080,8 +1538,14 @@ namespace Znyc.Dispatching.Application orderOutput.VehicleId = order.VehicleId; orderOutput.VehicleCode = order.VehicleCode; orderOutput.Status = order.Status; - orderOutput.StatusName = typeof(OrderStatus).GetDescription(order.Status); + orderOutput.Party = order.Party == "null" ? "" : order.Party; + orderOutput.ArriveDate = order.ArriveDate; + orderOutput.Hour = order.Hour == null || order.Hour == "0" ? "" : order.Hour; + orderOutput.Minute = order.Minute == null || order.Minute == "0" ? "" : order.Minute; + + orderOutput.Time = order.Hour == "null" ? "" : order.Hour; + orderOutput.StatusName = typeof(OrderStatus).GetDescription(order.Status); if (order.ProjectName.IsNotEmptyOrNull()) { orderOutput.OrderTitle = order.ProjectName; @@ -1106,6 +1570,7 @@ namespace Znyc.Dispatching.Application orderStatusDate.Add("接单", order.ReceiveDate.IsNull() ? "" : order.ReceiveDate.ToDateTime().ToString("yyyy-MM-dd HH:mm:ss")); orderStatusDate.Add("出发", order.TravelDate.IsNull() ? "" : order.TravelDate.ToDateTime().ToString("yyyy-MM-dd HH:mm:ss")); orderStatusDate.Add("到达", order.AppearDate.IsNull() ? "" : order.AppearDate.ToDateTime().ToString("yyyy-MM-dd HH:mm:ss")); + orderStatusDate.Add("施工", order.AppearDate.IsNull() ? "" : order.AppearDate.ToDateTime().ToString("yyyy-MM-dd HH:mm:ss")); orderStatusDate.Add("完工", order.CompleteDate.IsNull() ? "" : order.CompleteDate.ToDateTime().ToString("yyyy-MM-dd HH:mm:ss")); orderStatusDate.Add("签单", order.SignDate.IsNull() ? "" : order.SignDate.ToDateTime().ToString("yyyy-MM-dd HH:mm:ss")); orderStatusDate.Add("离开", order.LeaveDate.IsNull() ? "" : order.LeaveDate.ToDateTime().ToString("yyyy-MM-dd HH:mm:ss")); @@ -1115,9 +1580,10 @@ namespace Znyc.Dispatching.Application else { orderStatusDate.Add("派单", order.AssignDate.IsNull() ? "" : order.AssignDate.ToDateTime().ToString("yyyy-MM-dd HH:mm:ss")); + orderStatusDate.Add("接单", order.ReceiveDate.IsNull() ? "" : order.ReceiveDate.ToDateTime().ToString("yyyy-MM-dd HH:mm:ss")); if (order.Status == (int)OrderStatus.Receive) { - orderStatusDate.Add("接单", order.ReceiveDate.IsNull() ? "" : order.ReceiveDate.ToDateTime().ToString("yyyy-MM-dd HH:mm:ss")); + } orderStatusDate.Add("签单", order.SignDate.IsNull() ? "" : order.SignDate.ToDateTime().ToString("yyyy-MM-dd HH:mm:ss")); } @@ -1154,11 +1620,19 @@ namespace Znyc.Dispatching.Application } //签证单 - var orderVisas = _orderVisaRepository.Where(x => x.OrderId == order.Id).ToList(); + var orderVisas = _orderVisaRepository.Where(x => x.OrderId == order.Id).OrderByDescending(x => x.CreatedTime).ToList(); if (orderVisas.Count > 0) { orderOutput.OrderVisas = orderVisas.Adapt>(); } + + //安检 + var orderCheck = this.orderCheckRepository.Where(x => x.OrderId == order.Id).OrderByDescending(x => x.CreatedTime).ToList(); + if (orderCheck.Count > 0) + { + orderOutput.OrderCheck = orderCheck.Adapt>(); + } + orderOutput.Distance = ""; orderOutput.ExpectArriveDate = ""; //查询当前车辆是否有任务 @@ -1168,14 +1642,18 @@ namespace Znyc.Dispatching.Application { //车辆Gps var gpsRealTime = await _gpsRealTimeRepository.GetGpsRealTimeByVehicleId(order.VehicleId); - string origin = (double)gpsRealTime.Longitude + "," + (double)gpsRealTime.Latitude; - string destination = (double)order.Longitude + "," + (double)order.Latitude; - var pathPlanningModel = MapHelper.GetPathPlanningByDriving(origin, destination); - if (pathPlanningModel.status == "1" && pathPlanningModel.info == "OK") + if (gpsRealTime != null) { - orderOutput.Distance = $"{ Convert.ToDouble(pathPlanningModel.route.paths[0].distance) / 1000}KM"; - orderOutput.ExpectArriveDate = DateTimeHelper.ToChineseDate(Convert.ToInt32(pathPlanningModel.route.paths[0].duration)); + string origin = (double)gpsRealTime.Longitude + "," + (double)gpsRealTime.Latitude; + string destination = (double)order.Longitude + "," + (double)order.Latitude; + var pathPlanningModel = MapHelper.GetPathPlanningByDriving(origin, destination); + if (pathPlanningModel.status == "1" && pathPlanningModel.info == "OK") + { + orderOutput.Distance = $"{ Convert.ToDouble(pathPlanningModel.route.paths[0].distance) / 1000}KM"; + orderOutput.ExpectArriveDate = DateTimeHelper.ToChineseDate(Convert.ToInt32(pathPlanningModel.route.paths[0].duration)); + } } + } } catch (Exception ex) @@ -1270,7 +1748,7 @@ namespace Znyc.Dispatching.Application { var isDriver = _orderVehicleRepository.Any(x => x.OrderId == sign.OrderId && x.IsDriver == true); - if (isDriver || _userManager.SuperAdmin) + if (isDriver || _userManager.SuperAdmin || _userManager.RoleId == 1004) { var ordervisa = await _orderVisaRepository.Where(x => x.OrderId == sign.OrderId).FirstOrDefaultAsync(); if (ordervisa.IsNotNull()) @@ -1323,11 +1801,11 @@ namespace Znyc.Dispatching.Application x => x.CreatedUserId == _userManager.UserId || x.SalesmanId == _userManager.UserId) .Where(x => x.CompanyId == _userManager.CompanyId && x.IsDeleted == false && !new int[] { (int)OrderStatus.StayAssign, (int)OrderStatus.Cancel }.Contains(x.Status)) .Where(status == 1, x => x.Status == (int)OrderStatus.Assign) - .Where(status == 2, x => new int[] { (int)OrderStatus.Receive, (int)OrderStatus.Travel, (int)OrderStatus.Appear }.Contains(x.Status)) - .Where(status == 3, x => new int[] { (int)OrderStatus.Complete, (int)OrderStatus.Leave, (int)OrderStatus.Sign, (int)OrderStatus.ArriveHome }.Contains(x.Status)) + .Where(status == 2, x => new int[] { (int)OrderStatus.Receive, (int)OrderStatus.Complete, (int)OrderStatus.Travel, (int)OrderStatus.Appear }.Contains(x.Status)) + .Where(status == 3, x => new int[] { (int)OrderStatus.Leave, (int)OrderStatus.Sign, (int)OrderStatus.ArriveHome }.Contains(x.Status)) .Where(status == 4, x => x.Status == (int)OrderStatus.Evaluate) - .Where(startTime.IsNotNull(), x => x.CreatedTime >= startTime) - .Where(endTime.IsNotNull(), x => x.CreatedTime <= endTime) + .Where(startTime.IsNotNull(), x => x.ArriveDate >= startTime) + .Where(endTime.IsNotNull(), x => x.ArriveDate <= endTime) .Where(key.IsNotNull(), x => x.OrderVehiclePerson.Contains(key) || x.VehicleCode.Contains(key) || x.OrderContent.Contains(key) || x.ProjectName.Contains(key)) .OrderByDescending(x => x.ArriveDate) .Select(x => new OrderListOutput @@ -1365,11 +1843,19 @@ namespace Znyc.Dispatching.Application { item.StatusName = "未接单"; } + if (new int[] { (int)OrderStatus.Check, (int)OrderStatus.Travel, (int)OrderStatus.Appear }.Contains(item.Status)) + { + item.StatusName = "待安检"; + } if (new int[] { (int)OrderStatus.Receive, (int)OrderStatus.Travel, (int)OrderStatus.Appear }.Contains(item.Status)) { item.StatusName = "已接单"; } - if (new int[] { (int)OrderStatus.Complete, (int)OrderStatus.Sign, (int)OrderStatus.Leave, (int)OrderStatus.ArriveHome }.Contains(item.Status)) + if (new int[] { (int)OrderStatus.Complete }.Contains(item.Status)) + { + item.StatusName = "已安检"; + } + if (new int[] { (int)OrderStatus.Sign, (int)OrderStatus.Leave, (int)OrderStatus.ArriveHome }.Contains(item.Status)) { item.StatusName = "已完工"; } @@ -1639,6 +2125,5 @@ namespace Znyc.Dispatching.Application - - #endregion - \ No newline at end of file + +#endregion diff --git a/src/Znyc.Dispatching.Application/OrderCheck/Dto/Input/CheckInput.cs b/src/Znyc.Dispatching.Application/OrderCheck/Dto/Input/CheckInput.cs new file mode 100644 index 0000000..52316ec --- /dev/null +++ b/src/Znyc.Dispatching.Application/OrderCheck/Dto/Input/CheckInput.cs @@ -0,0 +1,27 @@ +using Microsoft.AspNetCore.Http; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + public class CheckInput + { + /// + /// OrderId + /// + public long OrderId { get; set; } + + + + /// + /// 图片路径 + /// + public string location { get; set; } + + + public IFormFile FormFiles { get; set; } + } +} diff --git a/src/Znyc.Dispatching.Application/OrderCheck/Dto/OutPut/CheckOutPut.cs b/src/Znyc.Dispatching.Application/OrderCheck/Dto/OutPut/CheckOutPut.cs new file mode 100644 index 0000000..388ab57 --- /dev/null +++ b/src/Znyc.Dispatching.Application/OrderCheck/Dto/OutPut/CheckOutPut.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + public class CheckOutPut + { + /// + /// 图片路径 + /// + public string Picture { get; set; } + } +} diff --git a/src/Znyc.Dispatching.Application/PayType/Dto/Enum/PayTypeOutEnum.cs b/src/Znyc.Dispatching.Application/PayType/Dto/Enum/PayTypeOutEnum.cs new file mode 100644 index 0000000..621551f --- /dev/null +++ b/src/Znyc.Dispatching.Application/PayType/Dto/Enum/PayTypeOutEnum.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + /// + /// + /// + public enum PayTypeOutEnum + { + 启用 = 0, + 停用 = 1, + } +} diff --git a/src/Znyc.Dispatching.Application/PayType/Dto/InPut/PayTypeInput.cs b/src/Znyc.Dispatching.Application/PayType/Dto/InPut/PayTypeInput.cs new file mode 100644 index 0000000..b5841af --- /dev/null +++ b/src/Znyc.Dispatching.Application/PayType/Dto/InPut/PayTypeInput.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + public class PayTypeInput + { + + /// + /// 类别ID + /// + public long? ID { get; set; } + + + + + /// + /// 开支类别 + /// + public string TypeName { get; set; } + + /// + /// 是否启用 + /// + public PayTypeOutEnum Enable { get; set; } + + + } +} diff --git a/src/Znyc.Dispatching.Application/PayType/Dto/OutPut/PayTypeOutPut.cs b/src/Znyc.Dispatching.Application/PayType/Dto/OutPut/PayTypeOutPut.cs new file mode 100644 index 0000000..b74a323 --- /dev/null +++ b/src/Znyc.Dispatching.Application/PayType/Dto/OutPut/PayTypeOutPut.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + public class PayTypeOutPut + { + /// + /// 类比ID 修改删除用 + /// + public long ID { get; set; } + /// + /// 开支类别 + /// + public string TypeName { get; set; } + + /// + /// 是否启用 + /// + public PayTypeOutEnum Enable { get; set; } + + /// + /// 是否能编辑 0 可以 1 否 + /// + public PayTypeOutEnum IsEdit { get; set; } + } +} diff --git a/src/Znyc.Dispatching.Application/PayType/Services/IPayTypeService.cs b/src/Znyc.Dispatching.Application/PayType/Services/IPayTypeService.cs new file mode 100644 index 0000000..ac89af4 --- /dev/null +++ b/src/Znyc.Dispatching.Application/PayType/Services/IPayTypeService.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + /// + /// 支付类型管理接口 + /// + public interface IPayTypeService + { + + } +} diff --git a/src/Znyc.Dispatching.Application/PayType/Services/PayTypeService.cs b/src/Znyc.Dispatching.Application/PayType/Services/PayTypeService.cs new file mode 100644 index 0000000..c8818e5 --- /dev/null +++ b/src/Znyc.Dispatching.Application/PayType/Services/PayTypeService.cs @@ -0,0 +1,110 @@ +using Furion.DatabaseAccessor; +using Furion.DependencyInjection; +using Furion.DynamicApiController; +using Furion.FriendlyException; +using Mapster; +using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; +using System.Threading.Tasks; +using Znyc.Dispatching.Core; +using Znyc.Dispatching.Core.Entitys; +using Znyc.Dispatching.Core.Extension; + +namespace Znyc.Dispatching.Application +{ + /// + /// 支付类型管理 + /// + [ApiDescriptionSettings(Name = "paytype", Order = 32)] + public class PayTypeService : IPayTypeService, IDynamicApiController, ITransient + { + private readonly IUserManager userManager; + private readonly ICacheService cacheService; + private readonly IRepository repository; + + + public PayTypeService(IRepository repository, + IUserManager userManager, + ICacheService cacheService) + { + this.repository = repository; + this.userManager = userManager; + this.cacheService = cacheService; + } + + + /// + /// 获取开支类别 + /// + /// + [HttpGet] + [Route("api/v1/PayType")] + public async Task> GetAll(bool Enable) + { + var compayId = this.userManager.CompanyId; + if (compayId.IsNull()) + throw Oops.Oh($"用户公司为空!"); + if(this.userManager.RoleId == 1005 || this.userManager.RoleId == 1004) + return await this.cacheService.GetPayTypeAll(compayId, Enable); + return await this.cacheService.GetPayTypeAll(compayId, Enable); + } + + + /// + /// 添加支付类型 + /// + /// + /// + [HttpPost] + [Route("api/v1/paytype/InsertAsync")] + public async Task InsertAsync(PayTypeInput payTypeInput) + { + var result = false; + if (payTypeInput.IsNull()) + return result; + var res = await this.repository.InsertNowAsync(new PayType() + { + TypeName = payTypeInput.TypeName, + Enable = 0, + CreatedTime = System.DateTime.Now, + CreatedUserId = this.userManager.UserId, + IsDeleted = false, + CompayId = this.userManager.CompanyId, + IsEdit = 0, + }); + await this.cacheService.RemovePayTypeAllAsync(userManager.CompanyId); + if (res.Entity.Id > 0) + result = true; + + return result; + } + + + /// + /// 编辑支付类型 + /// + /// + [HttpPut] + [UnitOfWork] + [Route("api/v1/paytype/UpdateAsync")] + public async Task UpdateAsync(PayTypeInput payTypeInput) + { + bool result = false; + if (payTypeInput.IsNull()) + return result; + if (payTypeInput.ID.IsNull()) + throw Oops.Oh($"编辑缺少ID!"); + var res = await this.repository.FindOrDefaultAsync(payTypeInput.ID); + if (res.IsNull()) + throw Oops.Oh("ID查询为空"); + res.TypeName = payTypeInput.TypeName; + res.Enable = (int)payTypeInput.Enable; + res.ModifiedUserId = this.userManager.UserId; + res.ModifiedTime = System.DateTime.Now; + var resUp = await this.repository.UpdateNowAsync(res); + if(resUp.IsNotNull()) + result = true; + return result; + } + } +} diff --git a/src/Znyc.Dispatching.Application/Project/Services/ProjectService.cs b/src/Znyc.Dispatching.Application/Project/Services/ProjectService.cs index b66a0b2..7fd19c8 100644 --- a/src/Znyc.Dispatching.Application/Project/Services/ProjectService.cs +++ b/src/Znyc.Dispatching.Application/Project/Services/ProjectService.cs @@ -78,7 +78,10 @@ namespace Znyc.Dispatching.Application .WhereIf(new long[] { (long)RoleStatusEnum.Salesman, (long)RoleStatusEnum.PartTimeSalesman }.Contains(_userManager.RoleId), x => x.SalesmanId == _userManager.UserId) .WhereIf(key.IsNotEmptyOrNull(), x => x.ProjectName.Contains(key)) - .Adapt>(); + .OrderBy(x =>x.ProjectName) + .Skip((currentPage - 1) * pageSize) + .Take(pageSize) + .Adapt>(); var projectOutputs = new List(); foreach (var INDEX_STRING in INDEX_STRINGS) diff --git a/src/Znyc.Dispatching.Application/SpareTimeWorker/Server/ISpareTimeWorkerService.cs b/src/Znyc.Dispatching.Application/SpareTimeWorker/Server/ISpareTimeWorkerService.cs new file mode 100644 index 0000000..1136edb --- /dev/null +++ b/src/Znyc.Dispatching.Application/SpareTimeWorker/Server/ISpareTimeWorkerService.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application.SpareTimeWorker.Server +{ + public interface ISpareTimeWorkerService + { + Task TimeWorker(); + } +} diff --git a/src/Znyc.Dispatching.Application/SpareTimeWorker/Server/SpareTimeWorkerService.cs b/src/Znyc.Dispatching.Application/SpareTimeWorker/Server/SpareTimeWorkerService.cs new file mode 100644 index 0000000..b0fbef4 --- /dev/null +++ b/src/Znyc.Dispatching.Application/SpareTimeWorker/Server/SpareTimeWorkerService.cs @@ -0,0 +1,35 @@ +using Furion.RemoteRequest.Extensions; +using Furion.TaskScheduler; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application.SpareTimeWorker.Server +{ + public class SpareTimeWorkerService: ISpareTimeWorker + { + [SpareTime(600000, "jobName", StartNow = true)] + public async Task TimeWorker(SpareTimer timer, long count) + { + + await "http://localhost/api/job/sync-vehicle-off".GetAsync(); + // await "http://localhost/api/job/sync-vehicle-off".GetAsync(); + + } + + [SpareTime(60000, "vehicleName", StartNow = true)] + public async Task VehicleWorker(SpareTimer timer, long count) + { + + Console.WriteLine("车辆异常提醒"); + ////停留 + await "http://localhost/api/job/syncstoping".GetAsync(); + ////超速 + //await "http://localhost/api/job/syncspeeding".GetAsync(); + + } + + } +} diff --git a/src/Znyc.Dispatching.Application/User/Dto/Input/UserAddInput.cs b/src/Znyc.Dispatching.Application/User/Dto/Input/UserAddInput.cs index 8dbc27f..d197fc2 100644 --- a/src/Znyc.Dispatching.Application/User/Dto/Input/UserAddInput.cs +++ b/src/Znyc.Dispatching.Application/User/Dto/Input/UserAddInput.cs @@ -36,6 +36,8 @@ namespace Znyc.Dispatching.Application.Dto.Input /// [Required(ErrorMessage = "请选择角色")] public long RoleId { get; set; } + + } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.Application/User/Services/UserService.cs b/src/Znyc.Dispatching.Application/User/Services/UserService.cs index fb7ee02..6e7889c 100644 --- a/src/Znyc.Dispatching.Application/User/Services/UserService.cs +++ b/src/Znyc.Dispatching.Application/User/Services/UserService.cs @@ -31,18 +31,26 @@ namespace Znyc.Dispatching.Application public class UserService : IUserService, IDynamicApiController, ITransient { private readonly ICacheService _cacheService; - private readonly IRepository _companyRepository; - private readonly IRepository _employeeRepository; - private readonly IRepository _repository; + private readonly SmsProviderOptions _smsProviderOptions; private readonly IUserManager _userManager; private readonly WeixinSettingOptions _weixinSettingOptions; - private readonly IRepository _userRoleRepository; + private readonly IWxUserRelationService _wxUserRelationService; private readonly IRoleMenuService _roleMenuService; private readonly ILogger _logger; + + private readonly IRepository _repository; + private readonly IRepository _companyRepository; + private readonly IRepository _employeeRepository; + private readonly IRepository _userRoleRepository; private readonly IRepository _vehiclePersonRepository; + private readonly IRepository workPlaceRepository; private readonly IRepository _projectPersonRepository; + private readonly IRepository wrokPlaceEmployee; + + + public UserService( IUserManager userManager, ICacheService cacheService, @@ -56,6 +64,8 @@ namespace Znyc.Dispatching.Application IOptions weixinSettingOptions, ILogger logger, IRepository vehiclePersonRepository, + IRepository workPlaceRepository, + IRepository wrokPlaceEmployee, IRepository projectPersonRepository) { _repository = repository; @@ -71,6 +81,8 @@ namespace Znyc.Dispatching.Application _logger = logger; _vehiclePersonRepository = vehiclePersonRepository; _projectPersonRepository = projectPersonRepository; + this.workPlaceRepository = workPlaceRepository; + this.wrokPlaceEmployee = wrokPlaceEmployee; } /// @@ -141,6 +153,9 @@ namespace Znyc.Dispatching.Application [Route("api/v1/user/register")] public async Task RegisterUserAsync(UserAddInput input) { + + User userEntity = new User(); + var jsCode2JsonResult = await SnsApi.JsCode2JsonAsync(_weixinSettingOptions.WxOpenAppId, _weixinSettingOptions.WxOpenAppSecret, input.DecryptPhoneAddInput.JsCode); @@ -205,7 +220,7 @@ namespace Znyc.Dispatching.Application } //用户 - var userEntity = await _repository.InsertNowAsync(new User + var userEntityTask = await _repository.InsertNowAsync(new User { OpenId = jsCode2JsonResult.openid, UserName = input.UserName, @@ -213,11 +228,14 @@ namespace Znyc.Dispatching.Application Phone = phone, Status = CommonStatusEnum.ENABLE }); + + userEntity = userEntityTask.Entity; + var isDefault = input.RoleId == (int)RoleStatusEnum.Outside ? false : true; //员工 var employeeEntity = await _employeeRepository.InsertNowAsync(new Employee { - UserId = userEntity.Entity.Id, + UserId = userEntity.Id, AvatarUrl = input.AvatarUrl, EmployeeName = input.UserName, EmployeePhone = phone, @@ -227,30 +245,29 @@ namespace Znyc.Dispatching.Application IsDefault = isDefault, Status = (int)CommonStatusEnum.ENABLE }); - //用户角色 - //await _userRoleRepository.InsertNowAsync(new UserRole - //{ - // UserId = userEntity.Entity.Id, - // RoleId = input.RoleId - //}); + + //清除员工列表Cache await _cacheService.RemoveEmployeeListAsync(input.CompanyId); //用户中间表 - await _wxUserRelationService.AddOrUpdateAsync(userEntity.Entity.Id, jsCode2JsonResult.openid, jsCode2JsonResult.unionid); - user = userEntity.Entity; + await _wxUserRelationService.AddOrUpdateAsync(userEntity.Id, jsCode2JsonResult.openid, jsCode2JsonResult.unionid); + user = userEntity; employee = employeeEntity.Entity; + + } else { - employee = await _employeeRepository.Where(x => x.UserId == user.Id && x.Status == (int)CommonStatusEnum.ENABLE && x.CompanyId == input.CompanyId).FirstOrDefaultAsync(); + userEntity = user; + employee = await _employeeRepository.Where(x => x.UserId == userEntity.Id && x.Status == (int)CommonStatusEnum.ENABLE && x.CompanyId == input.CompanyId).FirstOrDefaultAsync(); if (employee.IsNull()) { var employeenew = new Employee { - UserId = user.Id, + UserId = userEntity.Id, AvatarUrl = input.AvatarUrl, EmployeeName = input.UserName, - EmployeePhone = user.Phone, + EmployeePhone = userEntity.Phone, CompanyId = input.CompanyId, RoleId = input.RoleId, RoleName = typeof(RoleStatusEnum).GetDescription((int)input.RoleId), @@ -264,10 +281,10 @@ namespace Znyc.Dispatching.Application //员工 var employeeEntity = await _employeeRepository.InsertNowAsync(new Employee { - UserId = user.Id, + UserId = userEntity.Id, AvatarUrl = input.AvatarUrl, EmployeeName = input.UserName, - EmployeePhone = user.Phone, + EmployeePhone = userEntity.Phone, CompanyId = input.CompanyId, RoleId = input.RoleId, RoleName = typeof(RoleStatusEnum).GetDescription(input.RoleId.ObjToInt()), @@ -278,6 +295,18 @@ namespace Znyc.Dispatching.Application company = new Company() { Id = input.CompanyId }; } } + + // 工地方 + if(input.RoleId == 1009) + { + await this.wrokPlaceEmployee.InsertAsync(new WorkPlaceEmployee() + { + UserId = userEntity.Id, + CreatedTime = DateTime.Now, + IsDeleted= false, + }); + } + // 生成 token string accessToken = JWTEncryption.Encrypt(new Dictionary { @@ -319,9 +348,11 @@ namespace Znyc.Dispatching.Application break; } return loginOutput; + } + + - } /// /// 修改用户信息 diff --git a/src/Znyc.Dispatching.Application/Vehicle/Dto/OutPut/MapMonitorDataOutput.cs b/src/Znyc.Dispatching.Application/Vehicle/Dto/OutPut/MapMonitorDataOutput.cs index f704aeb..15f8410 100644 --- a/src/Znyc.Dispatching.Application/Vehicle/Dto/OutPut/MapMonitorDataOutput.cs +++ b/src/Znyc.Dispatching.Application/Vehicle/Dto/OutPut/MapMonitorDataOutput.cs @@ -63,157 +63,157 @@ namespace Znyc.Dispatching.Application - ///// - ///// 所属公司 - ///// - //public long CompanyId { get; set; } - - - ///// - ///// 车牌号 - ///// - //public string VehiclePlate { get; set; } + /// + /// 所属公司 + /// + public long CompanyId { get; set; } + + + /// + /// 车牌号 + /// + public string VehiclePlate { get; set; } + + /// + /// 联系人电话 + /// + public long VehicleType { get; set; } + + /// + /// 联系人 + /// + public string ContactPerson { get; set; } + + /// + /// 联系电话 + /// + public string ContactPhone { get; set; } + + /// + /// SimNo + /// + public string SimNo { get; set; } + + /// + /// 状态(字典 0正常 1停用 2删除) + /// + public int Status { get; set; } = 0; + + /// + /// 打火状态 + /// + public int Acc { get; set; } = 0; + + /// + /// 工作状态 + /// + public int Work { get; set; } = 0; + + /// + /// GPS时间 + /// + public string GpsTime { get; set; } + + /// + /// Gps服务器接收时间 + /// + public string RecTime { get; set; } - ///// - ///// 联系人电话 - ///// - //public long VehicleType { get; set; } - - ///// - ///// 联系人 - ///// - //public string ContactPerson { get; set; } - - ///// - ///// 联系电话 - ///// - //public string ContactPhone { get; set; } - - ///// - ///// SimNo - ///// - //public string SimNo { get; set; } - - ///// - ///// 状态(字典 0正常 1停用 2删除) - ///// - //public int Status { get; set; } = 0; - - ///// - ///// 打火状态 - ///// - //public int Acc { get; set; } = 0; - - ///// - ///// 工作状态 - ///// - //public int Work { get; set; } = 0; - - ///// - ///// GPS时间 - ///// - //public string GpsTime { get; set; } - - ///// - ///// Gps服务器接收时间 - ///// - //public string RecTime { get; set; } - - ///// - ///// gps状态 - ///// - //public int GpsState { get; set; } = 0; - - ///// - ///// 方向 - ///// - //public int Direct { get; set; } = 0; - - ///// - ///// 速度 - ///// - //public int Speed { get; set; } = 0; - - ///// - ///// 静止时长 - ///// - //public string DurationTime { get; set; } - - ///// - ///// acc工作时长 - ///// - //public string AccDurationTime { get; set; } - - - - - - ///// - ///// 地点 - ///// - //public string Address { get; set; } - - ///// - ///// work工作时长 - ///// - //public string WorkDurationTime { get; set; } - - ///// - ///// 离线时长 - ///// - //public string OfflineTime { get; set; } - - ///// - ///// 更新时间 - ///// - //public DateTime ModifiedTime { get; set; } - - ///// - ///// IMEL号 - ///// - //public string ImeiNo { get; set; } - - - ///// - ///// 设备类型 - ///// - //public int TerminalType { get; set; } - - ///// - ///// 开通时间 - ///// - //public DateTime OpenTime { get; set; } - - ///// - ///// 到期时间 - ///// - //public DateTime ExpireTime { get; set; } - - ///// - ///// 设备类型 - ///// - //public string TerminalTypeName { get; set; } - - ///// - ///// Gps信号源 - ///// - //public string GpsSignalSource { get; set; } - - - ///// - ///// Gps信号模式 1 GPS,2 基站 - ///// - //public int GpsMode { get; set; } - - ///// - ///// 位置基本信息报警标志位 --欠压 - ///// - //public int GpsAlert { get; set; } - - ///// - ///// 掉电 - ///// - //public int Useing { get; set; } + /// + /// gps状态 + /// + public int GpsState { get; set; } = 0; + + /// + /// 方向 + /// + public int Direct { get; set; } = 0; + + /// + /// 速度 + /// + public int Speed { get; set; } = 0; + + /// + /// 静止时长 + /// + public string DurationTime { get; set; } + + /// + /// acc工作时长 + /// + public string AccDurationTime { get; set; } + + + + + + /// + /// 地点 + /// + public string Address { get; set; } + + /// + /// work工作时长 + /// + public string WorkDurationTime { get; set; } + + /// + /// 离线时长 + /// + public string OfflineTime { get; set; } + + /// + /// 更新时间 + /// + public DateTime ModifiedTime { get; set; } + + /// + /// IMEL号 + /// + public string ImeiNo { get; set; } + + + /// + /// 设备类型 + /// + public int TerminalType { get; set; } + + /// + /// 开通时间 + /// + public DateTime OpenTime { get; set; } + + /// + /// 到期时间 + /// + public DateTime ExpireTime { get; set; } + + /// + /// 设备类型 + /// + public string TerminalTypeName { get; set; } + + /// + /// Gps信号源 + /// + public string GpsSignalSource { get; set; } + + + /// + /// Gps信号模式 1 GPS,2 基站 + /// + public int GpsMode { get; set; } + + /// + /// 位置基本信息报警标志位 --欠压 + /// + public int GpsAlert { get; set; } + + /// + /// 掉电 + /// + public int Useing { get; set; } } diff --git a/src/Znyc.Dispatching.Application/Vehicle/Dto/OutPut/VehicleBaiscListOutput.cs b/src/Znyc.Dispatching.Application/Vehicle/Dto/OutPut/VehicleBaiscListOutput.cs index 121168a..89afc05 100644 --- a/src/Znyc.Dispatching.Application/Vehicle/Dto/OutPut/VehicleBaiscListOutput.cs +++ b/src/Znyc.Dispatching.Application/Vehicle/Dto/OutPut/VehicleBaiscListOutput.cs @@ -24,7 +24,7 @@ namespace Znyc.Dispatching.Application /// /// 车组人员 /// - public List VehiclePerson { get; set; } + public List? VehiclePerson { get; set; } /// /// 车组人员姓名 diff --git a/src/Znyc.Dispatching.Application/Vehicle/Dto/OutPut/VehicleGpsOutput.cs b/src/Znyc.Dispatching.Application/Vehicle/Dto/OutPut/VehicleGpsOutput.cs index ff8897f..f485b99 100644 --- a/src/Znyc.Dispatching.Application/Vehicle/Dto/OutPut/VehicleGpsOutput.cs +++ b/src/Znyc.Dispatching.Application/Vehicle/Dto/OutPut/VehicleGpsOutput.cs @@ -203,5 +203,10 @@ namespace Znyc.Dispatching.Application /// public int Direct { get; set; } = 0; + public bool IsOverstopAlarm { get; set; } + + public bool IsOveroffAlarm { get; set; } + + public int Overstop { get; set; } } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.Application/Vehicle/Dto/OutPut/VehiclesOutPut.cs b/src/Znyc.Dispatching.Application/Vehicle/Dto/OutPut/VehiclesOutPut.cs new file mode 100644 index 0000000..c8c07fe --- /dev/null +++ b/src/Znyc.Dispatching.Application/Vehicle/Dto/OutPut/VehiclesOutPut.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + public class VehiclesOutPut + { + /// + /// 车辆ID + /// + public long Id { get; set; } + + + /// + /// 车牌号 + /// + public string VehiclePlate { get; set; } + } +} diff --git a/src/Znyc.Dispatching.Application/Vehicle/Services/VehicleService.cs b/src/Znyc.Dispatching.Application/Vehicle/Services/VehicleService.cs index f547f1f..d5b382d 100644 --- a/src/Znyc.Dispatching.Application/Vehicle/Services/VehicleService.cs +++ b/src/Znyc.Dispatching.Application/Vehicle/Services/VehicleService.cs @@ -15,6 +15,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; +using System.Threading; using System.Threading.Tasks; using Znyc.Dispatching.Application.Services; using Znyc.Dispatching.Common.Extensions; @@ -80,6 +81,26 @@ namespace Znyc.Dispatching.Application _oilRepository = oilRepository; } + + + /// + /// 初始化车辆 + /// + /// + [HttpGet] + [AllowAnonymous] + [Route("api/v1/InitVehicle")] + public async Task InitVehicle() + { + var vehicles = _repository.DetachedEntities.AsQueryable().ToList(); + vehicles.ForEach( x => + { + _cacheService.GetVehicleAsync(x.Id); + }); + + } + + /// /// 根据id获取车辆Gps信息 /// @@ -96,11 +117,17 @@ namespace Znyc.Dispatching.Application //gps数据 GpsRealTime gpsRealTime = await _gpsRealTimeRepository.GetGpsRealTimeByVehicleId(vehicleId); - if(gpsRealTime.IsNotNull()) + if (gpsRealTime.IsNotNull()) { var Timeres = TimeHelper.ExecDateDiff(gpsRealTime.GpsTime.AddHours(8), DateTime.Now); if (Timeres > 15) + { gpsRealTime.GpsState = 0; + gpsRealTime.Acc = 0; + gpsRealTime.Work = 0; + gpsRealTime.GpsMode = 2; + gpsRealTime.Useing = 1; + } } VehicleGpsOutput vehicleGpsOutput = new VehicleGpsOutput @@ -115,28 +142,30 @@ namespace Znyc.Dispatching.Application Work = gpsRealTime?.Work ?? 0, Status = vehicle.Status, ImeiNo = vehicle.ImeiNo, - Speed = gpsRealTime?.Speed ?? 0, + Speed = gpsRealTime?.Speed ?? 0, TerminalType = (int)vehicle.TerminalType, OpenTime = vehicle.OpenTime, - Direct = gpsRealTime?.Direct ?? 0, + Direct = gpsRealTime?.Direct ?? 0, ExpireTime = vehicle.ExpireTime, AccDurationTime = gpsRealTime?.AccDurationTime ?? "0分钟", IsOverspeedAlarm = vehicle.IsOverspeedAlarm, + IsOveroffAlarm = vehicle.IsOveroffAlarm, GpsTime = gpsRealTime?.GpsTime.AddHours(8).ToString("yyyy-MM-dd HH:mm:ss") ?? "未激活", - Address = gpsRealTime?.Address?? "暂无位置", + Address = gpsRealTime?.Address ?? "暂无位置", Overspeed = vehicle.Overspeed, - GpsMode = gpsRealTime?.GpsMode??2, - GpsAlert = gpsRealTime.IsNull()? 1 :gpsRealTime.GpsAlert, - Useing = gpsRealTime.IsNull() ? 1:gpsRealTime.Useing, - GpsState = gpsRealTime.IsNull() ? 0:gpsRealTime.GpsState, + IsOverstopAlarm = vehicle.IsOverstopAlarm, + Overstop = vehicle.Overstop, + GpsMode = gpsRealTime?.GpsMode ?? 2, + GpsAlert = gpsRealTime.IsNull() ? 1 : gpsRealTime.GpsAlert, + Useing = gpsRealTime.IsNull() ? 1 : gpsRealTime.Useing, + GpsState = gpsRealTime.IsNull() ? 0 : gpsRealTime.GpsState, WorkDurationTime = gpsRealTime?.WorkDurationTime ?? "0分钟", DurationTime = gpsRealTime?.DurationTime ?? "0分钟", RecTime = gpsRealTime?.RecTime.AddHours(8).ToString("yyyy-MM-dd HH:mm-ss") ?? "未激活", OfflineTime = gpsRealTime.IsNull() || - gpsRealTime?.RecTime < Convert.ToDateTime("2000-01-01 00:00:00.000") - ? "未激活" - : StringHelper.ShowTimeInterval(gpsRealTime?.RecTime.AddHours(8)), - + gpsRealTime?.RecTime < Convert.ToDateTime("2000-01-01 00:00:00.000") + ? "未激活" + : StringHelper.ShowTimeInterval(gpsRealTime?.RecTime.AddHours(8)), GpsSignalSource = "卫星", TerminalTypeName = typeof(TerminalTypeEnum).GetDescription((int)TerminalTypeEnum.BSJKGM_08) ?? "未知设备型号", @@ -154,70 +183,84 @@ namespace Znyc.Dispatching.Application [Route("api/v1/maps")] public async Task> GetMapMonitorAsync() { - List vehicleGpsOutput = new List(); + List vehicleGpsOutput = new List(); List gpsRealTimels = new List(); - if(_userManager.CompanyId != 0) - { - //车辆 - vehicleGpsOutput = (await _cacheService.GetVehicleByCompanyIdAsync(_userManager.CompanyId)) - .Where(x => x.IsActivate && x.IsGps).ToList(); - gpsRealTimels = await _gpsRealTimeRepository.GetGpsRealTimeByCompanyId(_userManager.CompanyId); - } - else - { - await _cacheService.RemoveAllVehicleByCompanyIdAsync(); - //车辆 - vehicleGpsOutput = (await _cacheService.GetAllVehicleByCompanyIdAsync()) - .Where(x => x.IsActivate && x.IsGps).ToList(); - var carID = vehicleGpsOutput.Select(x =>x.Id).ToList(); - gpsRealTimels = await _gpsRealTimeRepository.GetGpsRealTimeListByVehicleId(carID); - } + //车辆缓存 + vehicleGpsOutput = (await _cacheService.GetVehicleByCompanyIdAsync(_userManager.CompanyId)) .Where(x => x.IsActivate && x.IsGps && x.Status == 1).ToList(); + // + gpsRealTimels = await _gpsRealTimeRepository.GetGpsRealTimeByCompanyId(_userManager.CompanyId); //公司 var company = await _cacheService.GetCompanyAsync(_userManager.CompanyId, _userManager.UserId); //返回地图数据 var mapMonitorList = new List(); + foreach (VehicleGpsOutput vehicle in vehicleGpsOutput) - { + { var mapMonitorDataOutput = new MapMonitorDataOutput { Id = vehicle.Id, + VehiclePlate = vehicle.VehiclePlate, VehicleCode = vehicle.VehicleCode, - Longitude = vehicle.Longitude, - Latitude = vehicle.Latitude, - - Width = "17px", - Height = "30px", - Anchor = new Anchor() - { - X = ".5", - Y = ".5" - }, - CustomCallout = new CustomCallout() - { - AnchorX = "0", - AnchorY = ".5", - Display = "ALWAYS" - } - + ContactPerson = vehicle.ContactPerson, + ContactPhone = vehicle.ContactPhone, + Status = vehicle.Status, + SimNo = vehicle.SimNo, + CompanyId = vehicle.CompanyId, + ImeiNo = vehicle.ImeiNo, + OpenTime = vehicle.OpenTime, + ExpireTime = vehicle.ExpireTime, + TerminalTypeName = + typeof(TerminalTypeEnum).GetDescription((int)TerminalTypeEnum.BSJKGM_08) ?? "未知设备型号" }; var gpsRealTime = gpsRealTimels.FirstOrDefault(x => x.VehicleId == vehicle.Id); if (gpsRealTime.IsNotNull()) { - var Path = gpsRealTime.GpsState == 0 ? "stop" : gpsRealTime.GpsState == 1 ? "road" : "static"; + var Timeres = TimeHelper.ExecDateDiff(gpsRealTime.GpsTime.AddHours(8), DateTime.Now); + if (Timeres > 15) + { + gpsRealTime.GpsState = 0; + gpsRealTime.Acc = 0; + gpsRealTime.Work = 0; + gpsRealTime.GpsMode = 2; + gpsRealTime.Useing = 1; + } + mapMonitorDataOutput.Longitude = gpsRealTime.Longitude; + mapMonitorDataOutput.Latitude = gpsRealTime.Latitude; + + if (gpsRealTime?.GpsState != 2 && gpsRealTime?.GpsState != 0&& gpsRealTime?.GpsState != 1) + { + gpsRealTime.GpsState = 2; + } - mapMonitorDataOutput.Rotate = gpsRealTime?.Direct ?? 0; - mapMonitorDataOutput.Longitude = gpsRealTime?.Longitude ?? company.Longitude; - mapMonitorDataOutput.Latitude = gpsRealTime?.Latitude ?? company.Latitude; - mapMonitorDataOutput.IconPath = "/map/static/images/index/" + Path + ".png"; + mapMonitorDataOutput.GpsTime = gpsRealTime?.GpsTime.AddHours(8).ToString("yyyy-MM-dd HH:mm:ss") ?? "未激活"; + mapMonitorDataOutput.RecTime = gpsRealTime?.RecTime.AddHours(8).ToString("yyyy-MM-dd HH:mm-ss") ?? "未激活"; + mapMonitorDataOutput.Direct = gpsRealTime?.Direct ?? 0; + mapMonitorDataOutput.DurationTime = gpsRealTime?.DurationTime ?? "0分钟"; + mapMonitorDataOutput.Acc = gpsRealTime?.Acc ?? 0; + mapMonitorDataOutput.Speed = gpsRealTime?.Speed ?? 0; + mapMonitorDataOutput.GpsState = gpsRealTime?.GpsState ?? 0; + mapMonitorDataOutput.AccDurationTime = gpsRealTime?.AccDurationTime ?? "0分钟"; + mapMonitorDataOutput.Address = gpsRealTime.IsNull() || gpsRealTime.Address.IsNull() ? "暂无位置" : gpsRealTime?.Address; + mapMonitorDataOutput.Work = gpsRealTime?.Work ?? 0; + mapMonitorDataOutput.WorkDurationTime = gpsRealTime?.WorkDurationTime ?? "0分钟"; + mapMonitorDataOutput.OfflineTime = gpsRealTime.IsNull() || + gpsRealTime?.RecTime < Convert.ToDateTime("2000-01-01 00:00:00.000") + ? "未激活" + : StringHelper.ShowTimeInterval(gpsRealTime?.RecTime.AddHours(8)); + mapMonitorDataOutput.GpsSignalSource = "卫星"; + + mapMonitorDataOutput.GpsMode = gpsRealTime.GpsMode; + mapMonitorDataOutput.GpsAlert = gpsRealTime.GpsAlert; + mapMonitorDataOutput.Useing = gpsRealTime.Useing; }; mapMonitorList.Add(mapMonitorDataOutput); } return mapMonitorList; } - /// + /// . /// 分页查询 /// /// @@ -230,31 +273,32 @@ namespace Znyc.Dispatching.Application public async Task PageAsync([Required] int status = -1, [Required] int currentPage = 1, [Required] int pageSize = 10, [FromQuery] string key = null) { - - List vehicles = new List(); - if (_userManager.CompanyId != 0) - { - //车辆 - vehicles = (await _cacheService.GetVehicleByCompanyIdAsync(_userManager.CompanyId)) - .Where(x => x.IsActivate && x.IsGps).ToList(); - } - else - { - //车辆 - vehicles = (await _cacheService.GetAllVehicleByCompanyIdAsync()) - .Where(x => x.IsActivate && x.IsGps).ToList(); - } - + //车辆 + vehicles = (await _cacheService.GetVehicleByCompanyIdAsync(_userManager.CompanyId)) + .Where(x => x.IsActivate && x.IsGps && x.Status == 1).ToList(); //gps车辆数据 List gpsRealTimes = await _gpsRealTimeRepository.GetGpsRealTimeByCompanyId(_userManager.CompanyId); - //车辆列表 - //List vehicles = (await _cacheService.GetVehicleByCompanyIdAsync(_userManager.CompanyId)).Where(x => x.IsActivate && x.IsGps).ToList(); List vehicleGpsOutputsList = new List(); foreach (VehicleGpsOutput vehicle in vehicles) { GpsRealTime gpsRealTime = gpsRealTimes.FirstOrDefault(x => x.VehicleId == vehicle.Id); + + if (gpsRealTime.IsNotNull()) + { + var Timeres = TimeHelper.ExecDateDiff(gpsRealTime.GpsTime.AddHours(8), DateTime.Now); + if (Timeres > 15) + { + gpsRealTime.GpsState = 0; + gpsRealTime.Acc = 0; + gpsRealTime.Work = 0; + gpsRealTime.GpsMode = 2; + gpsRealTime.Useing = 1; + } + + } + VehicleGpsOutput vehicleGpsOutput = new VehicleGpsOutput { Id = vehicle.Id, @@ -270,10 +314,12 @@ namespace Znyc.Dispatching.Application gpsRealTime.IsNull() || gpsRealTime?.RecTime < Convert.ToDateTime("2000-01-01 00:00:00.000") ? "未激活" : StringHelper.ShowTimeInterval(gpsRealTime?.RecTime.AddHours(8)), + GpsTime = gpsRealTime.IsNull() || gpsRealTime?.GpsTime < Convert.ToDateTime("2000-01-01 00:00:00.000") ? "2000-01-01 00:00:00.000" : gpsRealTime?.GpsTime.ToString("yyyy-MM-dd HH:mm-ss"), + ContactPerson = vehicle.ContactPerson, ContactPhone = vehicle.ContactPhone, Address = gpsRealTime.IsNull() || gpsRealTime.Address.IsNull() ? "暂无位置" : gpsRealTime?.Address, @@ -290,7 +336,7 @@ namespace Znyc.Dispatching.Application { vehicleGpsOutput = vehicleGpsOutputsList .WhereIf(status > -1, x => x.GpsState == status) - .WhereIf(key.IsNotEmptyOrNull(), x => x.VehicleCode.Contains(key) || x.VehiclePlate.Contains(key)) + .WhereIf(key.IsNotEmptyOrNull(), x => x.VehicleCode.Contains(key)) .OrderBy(x => x.VehicleCode) .Skip((currentPage - 1) * pageSize) .Take(pageSize) @@ -326,6 +372,7 @@ namespace Znyc.Dispatching.Application await _cacheService.RemoveVehicleAsync(input.Id); await _cacheService.RemoveVehicleByCompanyIdAsync(_userManager.CompanyId); + } /// @@ -350,10 +397,13 @@ namespace Znyc.Dispatching.Application CompanyOutput company = await _cacheService.GetCompanyAsync(_userManager.CompanyId, _userManager.UserId); //车辆 Vehicle vehicle = await _cacheService.GetVehicleAsync(vehicleId); + + List list = await FindGpsByTime(vehicleId, startTime, endTime); //停留标示数据 int stopTag = (await _dictionaryService.GetAsync(company.StopTag)).Value.ToInt(); //车辆行驶记录 - List list = await FindGpsByTime(vehicleId, startTime, endTime); + + Console.WriteLine("处理前"+list.Count); //过滤数据 List finalGpsList = GpsDataProcessing(list); //处理数据 @@ -363,12 +413,13 @@ namespace Znyc.Dispatching.Application List stopList = new List(); TimeSpan stopTimeSpan = new TimeSpan(); - if (finalGpsList.Count < 30) + if (finalGpsList.Count < 2) { - throw Oops.Oh("暂无轨迹"); + Console.WriteLine("处理后"+finalGpsList.Count); + throw Oops.Oh("暂无轨迹,或轨迹点太少"); } int firstGpsTime = finalGpsList[0].GpsTime.ToTimestamp(); - List rectifyList = finalGpsList.Select(x => new TrackPlayBackCorrectInput + List rectifyList = finalGpsList.Where(x=>x.Latitude.ToString().Length>14).Select(x => new TrackPlayBackCorrectInput { Longitude = x.Longitude.ToString("f6").ToDecimal(), Latitude = x.Latitude.ToString("f6").ToDecimal(), @@ -378,29 +429,30 @@ namespace Znyc.Dispatching.Application }).ToList(); string c = JsonConvert.SerializeObject(rectifyList); List rectifyOutput = new List(); - int size = 500; + int size = 500; //接口限制 //原始轨迹点 int reultCount = finalGpsList.Count; int integerCount = (int)Math.Ceiling((decimal)reultCount / size); for (int i = 0; i < integerCount; i++) { - TrackPlayBackCorrectOutput res = JsonConvert.DeserializeObject(HttpRequestHelper.HttpPost("https://restapi.amap.com/v4/grasproad/driving?key=89981abaf32ae94b09a639c54845e089", - rectifyList.Skip(i * size).Take(size))); - if (res.ErrCode == 0) - { - - rectifyOutput.AddRange(res.data.points.ToList()); - } - else - { + + //TrackPlayBackCorrectOutput res = JsonConvert.DeserializeObject(HttpRequestHelper.HttpPost("https://restapi.amap.com/v4/grasproad/driving?key=89981abaf32ae94b09a639c54845e089", + //rectifyList.Skip(i * size).Take(size))); + //if (res.ErrCode == 0) + //{ + + // rectifyOutput.AddRange(res.data.points.ToList()); + //} + //else + //{ List residuePoints = rectifyList.Skip(i * size).Select(x => new Points { Latitude = x.Latitude, Longitude = x.Longitude }).ToList(); rectifyOutput.AddRange(residuePoints); - } + //} } decimal totalDistance = 0;//总里程 @@ -427,8 +479,11 @@ namespace Znyc.Dispatching.Application newFinalGpsList = newFinalGpsList.Distinct().ToList(); for (int i = 0; i < newFinalGpsList.Count; i++) { + TrackPlaybackOutput output = new TrackPlaybackOutput(); VehicleGps gps = newFinalGpsList[i]; + + //Console.WriteLine("第一时间"+gps.GpsTime); output.Longitude = gps.Longitude; output.Latitude = gps.Latitude; output.GpsTime = gps.GpsTime.AddHours(8); @@ -445,70 +500,10 @@ namespace Znyc.Dispatching.Application output.Work = gps.Work; output.WorkDurationTime = ""; output.TotalDistance = 0; - if (i != 0) - { - VehicleGps preGps = newFinalGpsList[i - 1]; - totalDistance += DistanceHelper.GetDistance(Convert.ToDouble(gps.Latitude), - Convert.ToDouble(gps.Longitude), - Convert.ToDouble(preGps.Latitude), Convert.ToDouble(preGps.Longitude)); - output.TotalDistance = totalDistance; - //用于计算停留点 - if (gps.GpsTime.ConvertToTimestamp() - preGps.GpsTime.ConvertToTimestamp() > 300) - { - string durationTime = TimeHelper.TimeSpanFormat(gps.GpsTime - preGps.GpsTime, 3); - string address = MapHelper.GetLocationByLngLat(reult.LastOrDefault().Longitude, - reult.LastOrDefault().Latitude); - //停留点 - reult.LastOrDefault().DurationTime = durationTime; - if (firstGps.GpsTime.ConvertToTimestamp() != preGps.GpsTime.ConvertToTimestamp()) - { - reult.LastOrDefault().StopPointIdx = ++stopIdx; - reult.LastOrDefault().IsStopPoint = true; - } - reult.LastOrDefault().Address = address; - reult.LastOrDefault().StartTime = preGps.GpsTime.AddHours(8); - reult.LastOrDefault().EndTime = gps.GpsTime.AddHours(8); - stopTimeSpan += (gps.GpsTime - preGps.GpsTime); - //如果第一点是停留点,则将停留时间更新到第一个点上 - if (firstGps.GpsTime == preGps.GpsTime) - { - stopList.LastOrDefault().Behavior = "停留" + durationTime; - } - else - { - //停留点插入轨迹动态列表 - Stop stop = new Stop(); - stop.GpsTime = preGps.GpsTime.AddHours(8); - stop.Latitude = preGps.Latitude; - stop.Longitude = preGps.Longitude; - stop.Address = address; - stop.State = "停" + stopIdx; - stop.Status = 1; - stop.Behavior = "停留" + durationTime; - stop.TotalDistance = totalDistance != 0 ? totalDistance : 0; - stop.StartTime = preGps.GpsTime; - stop.EndTime = output.GpsTime; - stopList.Add(stop); - } - } - if (i == newFinalGpsList.Count - 1) - { - Stop stop = new Stop(); - VehicleGps lastGps = newFinalGpsList[i]; - string address = lastGps.Address; - output.Address = address; - stop.Latitude = lastGps.Latitude; - stop.Longitude = lastGps.Longitude; - stop.GpsTime = lastGps.GpsTime.AddHours(8); - stop.Address = lastGps.Address; - stop.State = "终点"; - stop.Status = 3; - stop.Behavior = ""; - stop.TotalDistance = totalDistance != 0 ? totalDistance : 0; - stopList.Add(stop); - } - } - else + //Console.WriteLine("第二时间"+output.GpsTime.ToString()); + + //获取起点 + if (i == 0 ) { firstGps = newFinalGpsList[0]; string address = firstGps.Address; @@ -525,6 +520,7 @@ namespace Znyc.Dispatching.Application }; stopList.Add(stop); output.Address = address; + continue; } if (newFinalGpsList.Count == 1) { @@ -540,7 +536,81 @@ namespace Znyc.Dispatching.Application stop.Behavior = ""; stop.TotalDistance = 0; stopList.Add(stop); + continue; } + + + VehicleGps preGps = newFinalGpsList[i - 1]; + totalDistance += DistanceHelper.GetDistance(Convert.ToDouble(gps.Latitude), + Convert.ToDouble(gps.Longitude), + Convert.ToDouble(preGps.Latitude), Convert.ToDouble(preGps.Longitude)); + output.TotalDistance = totalDistance; + //用于计算停留点 + + var time = gps.GpsTime.ConvertToTimestamp() - preGps.GpsTime.ConvertToTimestamp(); + + if (reult.Count >1 && time > stopTag && (gps.Speed != 21 && gps.Speed > 5 || preGps.Speed != 21 && preGps.Speed > 5) ) + { + + Console.WriteLine("停留点:时间{0},速度{1},{2}", time, preGps.Speed,gps.Speed); + string durationTime = TimeHelper.TimeSpanFormat(gps.GpsTime - preGps.GpsTime, 3); + if(reult.LastOrDefault().IsNull()) + Console.WriteLine(reult.Count); + string address = MapHelper.GetLocationByLngLat(reult.LastOrDefault().Longitude, + reult.LastOrDefault().Latitude); + + //停留点 + reult.LastOrDefault().DurationTime = durationTime; + if (firstGps.GpsTime.ConvertToTimestamp() != preGps.GpsTime.ConvertToTimestamp()) + { + reult.LastOrDefault().StopPointIdx = ++stopIdx; + + } + reult.LastOrDefault().Address = address; + reult.LastOrDefault().StartTime = preGps.GpsTime.AddHours(8); + reult.LastOrDefault().EndTime = gps.GpsTime.AddHours(8); + stopTimeSpan += (gps.GpsTime - preGps.GpsTime); + //如果第一点是停留点,则将停留时间更新到第一个点上 + if (firstGps.GpsTime == preGps.GpsTime) + { + stopList.LastOrDefault().Behavior = "停留" + durationTime; + } + else + { + reult.LastOrDefault().IsStopPoint = true; + //停留点插入轨迹动态列表 + Stop stop = new Stop(); + stop.GpsTime = preGps.GpsTime.AddHours(8); + stop.Latitude = preGps.Latitude; + stop.Longitude = preGps.Longitude; + stop.Address = address; + stop.State = "停" + stopIdx; + stop.Status = 1; + stop.Behavior = "停留" + durationTime; + stop.TotalDistance = totalDistance != 0 ? totalDistance : 0; + stop.StartTime = preGps.GpsTime; + stop.EndTime = output.GpsTime.AddHours(8); + stopList.Add(stop); + } + } + if (i == newFinalGpsList.Count - 1) + { + Stop stop = new Stop(); + VehicleGps lastGps = newFinalGpsList[i]; + string address = lastGps.Address; + output.Address = address; + stop.Latitude = lastGps.Latitude; + stop.Longitude = lastGps.Longitude; + stop.GpsTime = lastGps.GpsTime.AddHours(8); + stop.Address = lastGps.Address; + stop.State = "终点"; + stop.Status = 3; + stop.Behavior = ""; + stop.TotalDistance = totalDistance != 0 ? totalDistance : 0; + stopList.Add(stop); + } + + reult.Add(output); } #endregion 计算停留点 @@ -561,6 +631,9 @@ namespace Znyc.Dispatching.Application return trackPlaybackListOutput; } + + + /// /// 修改超速报警/速度 /// @@ -574,15 +647,61 @@ namespace Znyc.Dispatching.Application public async Task UpdateOverSpeedAsync(long vehicleId, bool isOverspeedAlarm, [DataValidation(ValidationTypes.PositiveNumber, ErrorMessage = "超速报警时速必须为数字")] int overSpeed) { Vehicle vehicle = await _cacheService.GetVehicleAsync(vehicleId); + vehicle.Overspeed = overSpeed; vehicle.IsOverspeedAlarm = isOverspeedAlarm; + await _repository.UpdateNowAsync(vehicle); + + await _cacheService.SetVehicleAsync(vehicle); + await _cacheService.RemoveVehicleByCompanyIdAsync(_userManager.CompanyId); + return true; + } + + + /// + /// 修改停留报警 + /// + /// + /// + /// + /// + [HttpPut] + [Route("api/v1/vehicle/overstop/{vehicleId}/{isOverstopAlarm}/{overStop}")] + + public async Task UpdateOverStopAsync(long vehicleId, bool isOverstopAlarm, [DataValidation(ValidationTypes.PositiveNumber, ErrorMessage = "报警值必须为数字")] int overStop) + { + Vehicle vehicle = await _cacheService.GetVehicleAsync(vehicleId); + vehicle.Overstop = overStop; + vehicle.IsOverstopAlarm = isOverstopAlarm; await _repository.UpdateIncludeNowAsync(vehicle, - new[] { nameof(Vehicle.IsOverspeedAlarm), nameof(Vehicle.Overspeed) }, true); - await _cacheService.RemoveVehicleAsync(vehicleId); + new[] { nameof(Vehicle.IsOverstopAlarm), nameof(Vehicle.Overstop) }, true); + await _cacheService.SetVehicleAsync(vehicle); + await _cacheService.RemoveStopVehicleAsync(); await _cacheService.RemoveVehicleByCompanyIdAsync(_userManager.CompanyId); return true; } + + + /// + /// 设置车辆离线 + /// + /// + [HttpPut] + [Route("api/v1/vehicle/overoff/{vehicleId}/{IsOveroffAlarm}")] + public async Task VehicleOfflineAsync(long vehicleId, bool IsOveroffAlarm) + { + Vehicle vehicle = await _cacheService.GetVehicleAsync(vehicleId); + vehicle.IsOveroffAlarm = IsOveroffAlarm; + await _repository.UpdateIncludeNowAsync(vehicle, + new[] { nameof(Vehicle.IsOveroffAlarm)}, true); + await _cacheService.SetVehicleAsync(vehicle); + await _cacheService.RemoveVehicleByCompanyIdAsync(_userManager.CompanyId); + return true; + } + + + /// /// 超速报警列表 /// @@ -670,6 +789,8 @@ namespace Znyc.Dispatching.Application /// private async Task> FindGpsByTime(long vehicleId, DateTime startTime, DateTime endTime) { + //startTime = startTime.AddHours(-8); + //endTime = endTime.AddHours(-8); string smon = startTime.ToString("MM"); string emon = endTime.ToString("MM"); string syear = startTime.ToString("yyyyMM"); @@ -711,12 +832,12 @@ namespace Znyc.Dispatching.Application /// /// /// - private List GpsDataProcessing(List list) + private List GpsDataProcessing(List list, int Mub = 20) { List carGpsList = new List(); - int moveDistance = 40; + int moveDistance = 50; //轨迹点数小于10个, 则提示暂无轨迹 - if (list.Count < 20) + if (list.Count < Mub) { return new List(); } @@ -750,7 +871,7 @@ namespace Znyc.Dispatching.Application double max = distanceList.Max(); int maxIndex = distanceList.IndexOf(max); //最大值是否是第一个点, 以及距离大于625米, 150 km/h 乘 15秒 - if (maxIndex == 0 && max > 625) + if (maxIndex == 0 && max > 400) { list.Remove(list.FirstOrDefault()); } @@ -770,9 +891,9 @@ namespace Znyc.Dispatching.Application decimal distance = DistanceHelper.GetDistance((double)preGps.Latitude, (double)preGps.Longitude, (double)model.Latitude, (double)model.Longitude) * 1000; long ts = model.GpsTime.ConvertToTimestamp() - preGps.GpsTime.ConvertToTimestamp(); - if (distance > 0 && distance < 50 * 1000) + if (distance > 0 && distance < 50 * 100) { - if (distance < (decimal)(150 / 3.6 * ts)) + if (distance < (decimal)(120 / 3.6 * ts)) { carGpsList.Add(model); preGps = model; @@ -786,7 +907,6 @@ namespace Znyc.Dispatching.Application } } List finalGpsList = new List(); //处理完后的最终集合 - //去掉距离太近的点, 去重 preGps = null; foreach (VehicleGps gps in carGpsList) @@ -811,46 +931,243 @@ namespace Znyc.Dispatching.Application return carGpsList; } + private decimal[] GetGpsLoacInfo(List finalGpsList, MapMonitorDataOutput mapMonitorDataOutput, GpsRealTime gpsRealTime) + { + List carGpsList = new List(); + VehicleGps carGpsinfo = new VehicleGps(); + if (finalGpsList.Count > 0) + { + //获取上一条状态 + if (finalGpsList.Count == 1) + { + + carGpsinfo = finalGpsList.Last(); + } + else + { + carGpsinfo = finalGpsList[finalGpsList.Count - 2]; + } + + + var start = gpsRealTime.Latitude + "%2C" + gpsRealTime.Longitude; + var end = carGpsinfo.Latitude + "%2C" + carGpsinfo.Longitude; + + if (gpsRealTime.Speed != 0 && gpsRealTime.GpsState == 1) //运动状态 + { + int j = 1; + bool isEnd = start == end; + while (isEnd && finalGpsList.Count > 2) + { + carGpsinfo = finalGpsList[finalGpsList.Count - (j + 2)]; + end = carGpsinfo.Latitude + "%2C" + carGpsinfo.Longitude; + j++; + isEnd = start == end; + } + if (!isEnd) + { + gpsRealTime.Direct = gpsRealTime.Direct < 1 ? gpsRealTime.Direct + 2 : gpsRealTime.Direct - 1; + var gpsres = MapHelper.pointLatLngs(start, end, 10000, gpsRealTime.Direct); + if (gpsres.status != 0) + throw new Exception(String.Format("转换发生异常{0}", gpsres.message)); + + var coors = gpsres.result.routes[0].polyline; + if (coors.Length < 70) + { + for (var i = 2; i < coors.Length; i++) + { + var Y = (decimal)coors[i - 2]; + var x = (decimal)coors[i]; + coors[i] = (Y + x / 1000000); + } + carGpsList.Add((decimal)coors[coors.Length - 2]); + carGpsList.Add((decimal)coors[coors.Length - 1]); + Console.WriteLine("动态规划成功:" + gpsRealTime.VehiclePlate + + "规划前开始坐标:{0},规划前结束坐标:{1}。 规划后坐标:{2}", start, end, carGpsList[0] + "," + carGpsList[1]); + } + else + { + for (var i = 2; i < coors.Length; i++) + { + var Y = (decimal)coors[i - 2]; + var x = (decimal)coors[i]; + coors[i] = (Y + x / 1000000); + } + Console.WriteLine("规划过长,取反:{0}{1}", coors[7], coors[6]); + carGpsList.Add((decimal)coors[6]); + carGpsList.Add((decimal)coors[7]); + } + } + else + { + carGpsList.Add(gpsRealTime.Latitude); + carGpsList.Add(gpsRealTime.Longitude); + } + } + else //静止状态 + { + if(gpsRealTime.Acc == 0) + { + carGpsList.Add(gpsRealTime.Latitude); + carGpsList.Add(gpsRealTime.Longitude); + } + else if (carGpsinfo.Speed > 0 && gpsRealTime.Acc == 1) + { + gpsRealTime.Direct = gpsRealTime.Direct < 1 ? gpsRealTime.Direct + 2 : gpsRealTime.Direct - 1; + + var gpsres = MapHelper.pointLatLngs(start, end, 10000, gpsRealTime.Direct); + if (gpsres.status != 0) + throw new Exception(String.Format("转换发生异常{0},角度{1}", gpsres.message, gpsRealTime.Direct)); + var coors = gpsres.result.routes[0].polyline; + if (coors.Length < 70) + { + for (var i = 2; i < coors.Length; i++) + { + var Y = (decimal)coors[i - 2]; + var x = (decimal)coors[i]; + coors[i] = (Y + x / 1000000); + } + carGpsList.Add((decimal)coors[coors.Length - 2]); + carGpsList.Add((decimal)coors[coors.Length - 1]); + Console.WriteLine("静态规划成功:" + gpsRealTime.VehiclePlate + + "规划前开始坐标:{0},规划前结束坐标:{1}。 规划后坐标:{2}", start, end, carGpsList[0] + "," + carGpsList[1]); + } + + + } + else + { + carGpsList.Add(gpsRealTime.Latitude); + carGpsList.Add(gpsRealTime.Longitude); + } + + + } + } + else + { + carGpsList.Add(gpsRealTime.Latitude); + carGpsList.Add(gpsRealTime.Longitude); + } + + var add = MapHelper.geocoder(gpsRealTime.Latitude+","+gpsRealTime.Longitude, 10000); + if (add.status == 0) + gpsRealTime.Address = add.result.pois.Length > 0?add.result.pois[0].address: add.result.address; + + Console.WriteLine("最终返回定位:{0}{1},地址:{2}。定位:{3}{4}",gpsRealTime.Longitude,gpsRealTime.Latitude, gpsRealTime.Address, gpsRealTime.Longitude, gpsRealTime.Latitude); + return carGpsList.ToArray(); + } + /// - /// 离线车辆报警 + /// 动态轨迹点预处理(车辆) /// + /// /// - [HttpGet] - public async Task VehicleOfflineAsync() + private List GpsDataDynamic(List list, int Mub = 20) { - List gpsRealTimeList = await _gpsRealTimeRepository.GetOfflineGpsRealTime(); - foreach (GpsRealTime item in gpsRealTimeList) + List carGpsList = new List(); + int moveDistance = 10; + //轨迹点数小于10个, 则提示暂无轨迹 + if (list.Count < Mub) { - IQueryable users = from e in _employeeRepository.Where(x => - x.CompanyId == item.CompanyId && x.RoleId == 1 && x.Status == (int)CommonStatusEnum.ENABLE) - .AsQueryable() - join u in _userRepository.Where(x => x.Status == CommonStatusEnum.ENABLE).AsQueryable() - on e.UserId equals u.Id - select new NoticeOutput - { - OpenId = u.OpenId - }; - foreach (NoticeOutput i in users) + return new List(); + } + //判断前五个点是否正常 + for (int i = 0; i < 5; i++) + { + List firstToTenGps = new List(); + + for (int j = 0; j < 10 - i; j++) + { + VehicleGps model = list[j]; + firstToTenGps.Add(model); + } + + if (!firstToTenGps.Any()) { - // WxUserRelation wxUserRelation = await _wxUserRelationRepository.DetachedEntities - // .Where(x => x.OpenId == i.OpenId).FirstOrDefaultAsync(); - // if (wxUserRelation.WxOfficialOpenId.IsNotNull()) - // { - // WeixinTemplate_OfflineNotice data = new WeixinTemplate_OfflineNotice("尊敬的用户,你的车辆已离线", - // item.VehicleCode, item.VehiclePlate, item.Address); - // AccessTokenResult accessTokenResult = await CommonApi.GetTokenAsync(App.Configuration["SenparcWeixinSetting:WeixinAppId"], - // App.Configuration["SenparcWeixinSetting:WeixinAppSecret"]); - // SendTemplateMessageResult result = await TemplateApi.SendTemplateMessageAsync(accessTokenResult.access_token, - // wxUserRelation.WxOfficialOpenId, data.TemplateId, "", data); - // } + continue; + } + { + //平均经纬度 + double avgLat = Convert.ToDouble(firstToTenGps.Average(x => x.Latitude)); + double avgLng = Convert.ToDouble(firstToTenGps.Average(x => x.Longitude)); + //所有点距离 + List distanceList = + firstToTenGps.Select( + model => + Convert.ToDouble(DistanceHelper.GetDistance(avgLat, avgLng, + Convert.ToDouble(model.Latitude), + Convert.ToDouble(model.Longitude))) * 1000).ToList(); + //找出最大值的位置 + double max = distanceList.Max(); + int maxIndex = distanceList.IndexOf(max); + //最大值是否是第一个点, 以及距离大于625米, 150 km/h 乘 15秒 + if (maxIndex == 0 && max > 150) + { + list.Remove(list.FirstOrDefault()); + } + else + { + break; + } } } - return true; + //去掉太远的点 + VehicleGps preGps = null; + foreach (VehicleGps model in list) + { + if (preGps != null) + { + decimal distance = DistanceHelper.GetDistance((double)preGps.Latitude, (double)preGps.Longitude, + (double)model.Latitude, (double)model.Longitude) * 1000; + long ts = model.GpsTime.ConvertToTimestamp() - preGps.GpsTime.ConvertToTimestamp(); + if (distance > 0 && distance < 5 * 100) + { + if (distance < (decimal)(120 / 3.6 * ts)) + { + carGpsList.Add(model); + preGps = model; + } + } + } + else + { + carGpsList.Add(model); + preGps = model; + } + } + List finalGpsList = new List(); //处理完后的最终集合 + + //去掉距离太近的点, 去重 + preGps = null; + foreach (VehicleGps gps in carGpsList) + { + if (preGps != null) + { + decimal distance = DistanceHelper.GetDistance((double)preGps.Latitude, (double)preGps.Longitude, + (double)gps.Latitude, (double)gps.Longitude) * 1000; + if (distance > moveDistance) + { + finalGpsList.Add(gps); + preGps = gps; + } + } + else + { + finalGpsList.Add(gps); + preGps = gps; + } + } + + return carGpsList; } + + + + #region 轨迹 /// @@ -1116,13 +1433,24 @@ namespace Znyc.Dispatching.Application public async Task BasicsPageAsync([Required] int currentPage, [Required] int pageSize, [FromQuery] int status, [FromQuery] string key) { var vehicleGpsList = (await _cacheService.GetVehicleByCompanyIdAsync(_userManager.CompanyId)) - .WhereIf(status > 0, x => x.Status == status) + .WhereIf(status!=0, x => x.Status == status) .WhereIf(key.IsNotEmptyOrNull(), x => x.VehicleCode.Contains(key)).Adapt>(); foreach (var item in vehicleGpsList) { + //item.VehiclePerson = await _cacheService.GetVehiclePersonByIDAsync(item.Id); + //if (item.VehiclePerson.IsNull()) + //{ + // item.VehiclePerson = new List(); + //} + //else + //{ + // item.VehiclePersonName = item.VehiclePerson.Find(x => x.IsDriver == true)?.UserName; + // item.VehiclePersonPhone = item.VehiclePerson.Find(x => x.IsDriver == true)?.UserPhone; + //} item.VehiclePerson = await _cacheService.GetVehiclePersonAsync(item.Id); item.VehiclePersonName = item.VehiclePerson.Find(x => x.IsDriver == true)?.UserName; item.VehiclePersonPhone = item.VehiclePerson.Find(x => x.IsDriver == true)?.UserPhone; + } var vehicleOutputs = new List(); foreach (var INDEX_STRING in INDEX_STRINGS) @@ -1191,6 +1519,7 @@ namespace Znyc.Dispatching.Application } } + #region 修改车组人员 var oldVehiclePersons = await _vehiclePersonRepository.DetachedEntities .Where(x => x.VehicleId == input.Id && x.IsDeleted == false) @@ -1235,6 +1564,8 @@ namespace Znyc.Dispatching.Application throw Oops.Oh("修改车辆基础信息失败"); } + + //同步修改油耗表和订单表设备号 if (input.VehicleCode != vehicle.VehicleCode) { @@ -1250,6 +1581,49 @@ namespace Znyc.Dispatching.Application #endregion - } -} \ No newline at end of file + #region 查询车辆 + + /// + /// 根据id获取车辆Gps信息 + /// + /// + /// + [HttpGet] + [Route("api/v1/vehicle/Vehicles")] + public async Task> GetVehiclesAsync() + { + var input = new List(); + //车辆 + var vehicles = await _cacheService.GetVehicleByCompanyIdAsync(this._userManager.CompanyId); + if (vehicles.IsNull()) + { + var res = await this._repository.DetachedEntities.Where(x => x.CompanyId == this._userManager.CompanyId).ToListAsync(); + if (res.IsNull()) + throw Oops.Oh("公司无车辆"); + vehicles = res.Adapt>(); + + } + foreach (var item in vehicles) + { + VehiclesOutPut vehiclesOut = new VehiclesOutPut(); + vehiclesOut.VehiclePlate = item.VehicleCode; + vehiclesOut.Id = item.Id; + input.Add(vehiclesOut); + } + return input; + } + + + + + #endregion + + + #region 初始化车辆 + + + #endregion + + } +} \ No newline at end of file diff --git a/src/Znyc.Dispatching.Application/WorkPlace/Dto/Output/WorkPlaceOutput.cs b/src/Znyc.Dispatching.Application/WorkPlace/Dto/Output/WorkPlaceOutput.cs new file mode 100644 index 0000000..9d8eec9 --- /dev/null +++ b/src/Znyc.Dispatching.Application/WorkPlace/Dto/Output/WorkPlaceOutput.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + public class WorkPlaceListPage + { + } +} diff --git a/src/Znyc.Dispatching.Application/WorkPlace/Dto/input/WorkPlaceAddInput.cs b/src/Znyc.Dispatching.Application/WorkPlace/Dto/input/WorkPlaceAddInput.cs new file mode 100644 index 0000000..d8984be --- /dev/null +++ b/src/Znyc.Dispatching.Application/WorkPlace/Dto/input/WorkPlaceAddInput.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + public class WorkPlaceAddInput + { + } +} diff --git a/src/Znyc.Dispatching.Application/WorkPlace/Dto/input/WorkPlaceListPage.cs b/src/Znyc.Dispatching.Application/WorkPlace/Dto/input/WorkPlaceListPage.cs new file mode 100644 index 0000000..38eeeb3 --- /dev/null +++ b/src/Znyc.Dispatching.Application/WorkPlace/Dto/input/WorkPlaceListPage.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + public class WorkPlaceOutput + { + + } +} diff --git a/src/Znyc.Dispatching.Application/WorkPlace/Dto/input/WorkPlaceUpdateInput.cs b/src/Znyc.Dispatching.Application/WorkPlace/Dto/input/WorkPlaceUpdateInput.cs new file mode 100644 index 0000000..304f3de --- /dev/null +++ b/src/Znyc.Dispatching.Application/WorkPlace/Dto/input/WorkPlaceUpdateInput.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + public class WorkPlaceUpdateInput + { + } +} diff --git a/src/Znyc.Dispatching.Application/WorkPlace/Services/IWorkPlaceService.cs b/src/Znyc.Dispatching.Application/WorkPlace/Services/IWorkPlaceService.cs new file mode 100644 index 0000000..ef3df06 --- /dev/null +++ b/src/Znyc.Dispatching.Application/WorkPlace/Services/IWorkPlaceService.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Application +{ + public interface IWorkPlaceService + { + + Task PageAsync(int currentPage, int pageSize, int status, int roleId, string key, string orderby); + + + /// + /// 根据id获取员工资料 + /// + /// + Task GetByIdAsync(long id); + + /// + /// 添加员工信息 + /// + /// + /// + Task AddAsync(WorkPlaceAddInput input); + + /// + /// 编辑员工信息 + /// + /// + Task UpdateAsync(WorkPlaceUpdateInput input); + + + /// + /// 软删除员工信息 + /// + /// + /// + Task DeleteByIdAsync(long id); + } +} diff --git a/src/Znyc.Dispatching.Application/WorkPlace/Services/WorkPlaceService.cs b/src/Znyc.Dispatching.Application/WorkPlace/Services/WorkPlaceService.cs new file mode 100644 index 0000000..346acb7 --- /dev/null +++ b/src/Znyc.Dispatching.Application/WorkPlace/Services/WorkPlaceService.cs @@ -0,0 +1,55 @@ +using Furion.DatabaseAccessor; +using Furion.DependencyInjection; +using Furion.DynamicApiController; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Znyc.Dispatching.Core.Entitys; + +namespace Znyc.Dispatching.Application +{ + + public class WorkPlaceService : IWorkPlaceService, IDynamicApiController, ITransient + { + /// + /// + /// + private readonly IRepository workPlaceRepository; + + /// + /// + /// + /// + public WorkPlaceService(IRepository workPlaceRepository) + { + this.workPlaceRepository = workPlaceRepository; + } + + public Task AddAsync(WorkPlaceAddInput input) + { + throw new NotImplementedException(); + } + + public Task DeleteByIdAsync(long id) + { + throw new NotImplementedException(); + } + + public Task GetByIdAsync(long id) + { + throw new NotImplementedException(); + } + + public Task PageAsync(int currentPage, int pageSize, int status, int roleId, string key, string orderby) + { + throw new NotImplementedException(); + } + + public Task UpdateAsync(WorkPlaceUpdateInput input) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/Znyc.Dispatching.Application/Znyc.Dispatching.Application.csproj b/src/Znyc.Dispatching.Application/Znyc.Dispatching.Application.csproj index fe90e2b..dec898c 100644 --- a/src/Znyc.Dispatching.Application/Znyc.Dispatching.Application.csproj +++ b/src/Znyc.Dispatching.Application/Znyc.Dispatching.Application.csproj @@ -34,12 +34,14 @@ + + @@ -48,10 +50,12 @@ + + diff --git a/src/Znyc.Dispatching.Application/Znyc.Dispatching.Application.xml b/src/Znyc.Dispatching.Application/Znyc.Dispatching.Application.xml index f3ecbf3..7479733 100644 --- a/src/Znyc.Dispatching.Application/Znyc.Dispatching.Application.xml +++ b/src/Znyc.Dispatching.Application/Znyc.Dispatching.Application.xml @@ -291,6 +291,13 @@ + + + 员工分页 + + + + 设置未读警报提醒缓存 @@ -383,6 +390,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 获取设置超速车辆 + + + + + + + 设置车辆缓存 + + + + + + + 删除车辆缓存 + + + + + + + 获取设置离线报警车辆 + + + + + + 获取是否已经推送 + + + + + + + 设置推送标志 + + + + + + + + + + + + + + 删除车辆缓存 + + + + 同步工程列表缓存 @@ -426,6 +516,13 @@ + + + 删除订单列表缓存 + + + + 设置订单列表缓存 @@ -463,6 +560,13 @@ + + + 获取车辆车组人员缓存 + + + + 获取车辆车组人员缓存 @@ -911,6 +1015,13 @@ + + + 删除缓存 + + + + 同步工程列表缓存 @@ -1027,6 +1138,24 @@ + + + 获取所有公司超速车辆缓存 + + + + + + 获取所有公司超速车辆缓存 + + + + + + 获取所有公司超速车辆缓存 + + + 公司输入实体 @@ -1203,7 +1332,7 @@ - 平台入驻 + 平台入驻 @@ -1241,6 +1370,18 @@ + + + + + + + + + + + + 注册公司 @@ -1408,6 +1549,227 @@ + + + 开支类别ID + + + + + 创建时间 + + + + + 开支类别 + + + + + 车ID + + + + + 车牌号 + + + + + 支付途径 + + + + + 金额 + + + + + 备注 + + + + + 累计花费 + + + + + 平均日花费 + + + + + 饼状图 + + + + + 柱状图 + + + + + 类型名称 + + + + + 车辆编号 + + + + + 花费金额 + + + + + ID + + + + + 时间 + + + + + 车辆编号 + + + + + 开支类别ID + + + + + 开支类别 + + + + + 车ID + + + + + 车名称 + + + + + 支付途径 + + + + + 金额 + + + + + 备注 + + + + + 开支记录 + + + + + 开支记录分页查询 + + + + + + + + + + + + 开支记录分页查询 + + + + + + + + + + + + 开支统计 + + + + + + + + 车辆分组开支统计 + + + + + + + + 新增开支 + + + + + + + 更新开支 + + + + + + + 删除油耗信息 + + + + + + + 公司名称 + + + + + 车型 + + + + + 到场时间 + + + + + 报单信息 + + + + + 报单员 + + + + + 联系电话 + + 主键Id @@ -1679,6 +2041,11 @@ 角色菜单列表 + + + Ticket值 + + 用户登录 @@ -1704,6 +2071,20 @@ + + + 获取Ticket + + + + + + + 获取Ticket + + + + 操作日志服务 @@ -1959,6 +2340,11 @@ 金额 + + + 备注 + + @@ -2013,6 +2399,56 @@ 油耗统计 + + + 累计花费 + + + + + 平均日花费 + + + + + 柱状图 + + + + + 饼图 + + + + + 四大标签 + + + + + 车牌号 + + + + + 工作时长 + + + + + 时长 + + + + + 油耗 + + + + + 油耗比 + + 主键 @@ -2048,15 +2484,21 @@ 金额 + + + 备注 + + 油耗服务 - + 加油记录 + @@ -2103,10 +2545,11 @@ 油耗管理 - + 加油记录 + @@ -2148,6 +2591,37 @@ + + + 油耗统计 + + + + + + + + 车辆分组统计 + + + + + + + + OrderId + + + + + 图片路径 + + + + + 图片路径 + + @@ -2707,6 +3181,11 @@ 签证明细 + + + 安检明细 + + 是否外请车 @@ -2742,9 +3221,29 @@ 施工单位 - + + + 到家时间 + + + + + 到达时间 + + + + + 小时 + + + + + 分钟 + + + - 到家时间 + 方量 @@ -2874,6 +3373,13 @@ 派工订单管理 + + + 字符识别 + + + + 管理端任务列表 @@ -2884,6 +3390,13 @@ + + + 保存分享 + + + + 保存待指派 @@ -2926,11 +3439,49 @@ - + + + 删除安检图片 + + + + + + + 删除回执图片 + + + + + + + 安检图片上传 + + + + + + + + + 安检图片上传 + + + + + + + + + 安检完成安检 + + + + + 签单 - @@ -3050,6 +3601,75 @@ + + + + + + + + 类别ID + + + + + 开支类别 + + + + + 是否启用 + + + + + 类比ID 修改删除用 + + + + + 开支类别 + + + + + 是否启用 + + + + + 是否能编辑 0 可以 1 否 + + + + + 支付类型管理接口 + + + + + 支付类型管理 + + + + + 获取开支类别 + + + + + + 添加支付类型 + + + + + + + 编辑支付类型 + + + 公司输入实体 @@ -4083,6 +4703,151 @@ + + + 所属公司 + + + + + 车牌号 + + + + + 联系人电话 + + + + + 联系人 + + + + + 联系电话 + + + + + SimNo + + + + + 状态(字典 0正常 1停用 2删除) + + + + + 打火状态 + + + + + 工作状态 + + + + + GPS时间 + + + + + Gps服务器接收时间 + + + + + gps状态 + + + + + 方向 + + + + + 速度 + + + + + 静止时长 + + + + + acc工作时长 + + + + + 地点 + + + + + work工作时长 + + + + + 离线时长 + + + + + 更新时间 + + + + + IMEL号 + + + + + 设备类型 + + + + + 开通时间 + + + + + 到期时间 + + + + + 设备类型 + + + + + Gps信号源 + + + + + Gps信号模式 1 GPS,2 基站 + + + + + 位置基本信息报警标志位 --欠压 + + + + + 掉电 + + 总数 @@ -4608,6 +5373,16 @@ 行驶数 + + + 车辆ID + + + + + 车牌号 + + 根据id获取车辆Gps信息 @@ -4705,6 +5480,12 @@ 车辆信息服务 + + + 初始化车辆 + + + 根据id获取车辆Gps信息 @@ -4719,7 +5500,7 @@ - + . 分页查询 @@ -4753,6 +5534,21 @@ + + + 修改停留报警 + + + + + + + + + 设置车辆离线 + + + 超速报警列表 @@ -4776,17 +5572,18 @@ 结束时间 - + 轨迹点预处理(车辆) - + - 离线车辆报警 + 动态轨迹点预处理(车辆) + @@ -4830,6 +5627,50 @@ + + + 根据id获取车辆Gps信息 + + + + + + + 根据id获取员工资料 + + + + + + 添加员工信息 + + + + + + + 编辑员工信息 + + + + + + 软删除员工信息 + + + + + + + + + + + + + + + @@ -5206,5 +6047,23 @@ 任务调度服务 + + + 停留提醒 + + + + + + 超速提醒 + + + + + + 离线设置提醒 + + + diff --git a/src/Znyc.Dispatching.Core/Config/UploadOptions.cs b/src/Znyc.Dispatching.Core/Config/UploadOptions.cs index 34779ef..98de84e 100644 --- a/src/Znyc.Dispatching.Core/Config/UploadOptions.cs +++ b/src/Znyc.Dispatching.Core/Config/UploadOptions.cs @@ -17,7 +17,7 @@ namespace Znyc.Dispatching.Core public string Region { get; set; } /// - /// 头像上传配置 + ///头像上传配置 /// public FileUploadConfig Avatar { get; set; } diff --git a/src/Znyc.Dispatching.Core/Config/WxOpenSetting.cs b/src/Znyc.Dispatching.Core/Config/WxOpenSetting.cs new file mode 100644 index 0000000..671a504 --- /dev/null +++ b/src/Znyc.Dispatching.Core/Config/WxOpenSetting.cs @@ -0,0 +1,28 @@ +using Furion.ConfigurableOptions; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Core +{ + [OptionsSettings("WxOpenSetting")] + public class WxOpenSetting : IConfigurableOptions + { + /// + /// 小程序 + /// + public string AppID { get; set; } + + /// + /// + public string WxOpenAppSecret { get; set; } + + /// + /// 请求CODEURL + /// + public string OpenUrl { get; set; } + + } +} diff --git a/src/Znyc.Dispatching.Core/Const/CommonConst.cs b/src/Znyc.Dispatching.Core/Const/CommonConst.cs index 639a7ca..5ce2222 100644 --- a/src/Znyc.Dispatching.Core/Const/CommonConst.cs +++ b/src/Znyc.Dispatching.Core/Const/CommonConst.cs @@ -149,6 +149,32 @@ /// public const string CACHE_KEY_VEHICLE = "vehicle:_"; + + + /// + /// 车辆停下 + /// + public const string CACHE_KEY_VEHICLESTOP = "vehicleStop:_"; + + + /// + /// 车辆启动 + /// + public const string CACHE_KEY_VEHICLESTART = "vehicleStart:_"; + + + /// + /// 超速车辆缓存 + /// + public const string CACHE_KEY_OFFVEHICLE = "Offvehicle:_"; + + + /// + /// 超速车辆缓存 + /// + public const string CACHE_KEY_SPEEDVEHICLE = "speedvehicle:_"; + + /// /// 车辆GPS信息缓存 /// @@ -169,6 +195,13 @@ /// public const string CACHE_KEY_EMPLOYEES = "employees:{0}"; + + /// + /// 员工分页列表缓存 + /// + public const string EMPLOYEELISTPAGE = "employeespage"; + + /// /// 未读报警消息 /// @@ -229,5 +262,12 @@ public const string CACHE_KEY_ORDERREAD = "orderread_"; #endregion + #region 开支管理缓存 + + /// + /// 开支类型 + /// + public const string CACHE_KEY_PAYTYPE = "pay:Type"; + #endregion } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.Core/Entitys/Company.cs b/src/Znyc.Dispatching.Core/Entitys/Company.cs index 27adbaf..4265de5 100644 --- a/src/Znyc.Dispatching.Core/Entitys/Company.cs +++ b/src/Znyc.Dispatching.Core/Entitys/Company.cs @@ -31,7 +31,6 @@ namespace Znyc.Dispatching.Core.Entitys /// [Comment("联系人")] [Required] - [MaxLength(30)] public string ContactPerson { get; set; } /// @@ -102,5 +101,22 @@ namespace Znyc.Dispatching.Core.Entitys [Comment("是否启用任务车型选项")] public bool IsOpenVehicleType { get; set; } + + + ///// + ///// 是否启用安全检查,默认为关 + ///// + //[Comment("是否启用安全检查")] + + public bool IsShowCheckType { get; set; } + + + ///// + ///// 是否启用数据上传 + ///// + //[Comment("是否启用安全检查")] + + public bool IsShowDate { get; set; } + } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.Core/Entitys/Consumption.cs b/src/Znyc.Dispatching.Core/Entitys/Consumption.cs new file mode 100644 index 0000000..f8db507 --- /dev/null +++ b/src/Znyc.Dispatching.Core/Entitys/Consumption.cs @@ -0,0 +1,70 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Core.Entitys +{ + [Table("dc_consumption")] + [Comment("消费详情表")] + public class Consumption : DEntityBase + { + /// + /// 开支类别ID + /// + public long PayTyepID { get; set; } + + /// + /// 平摊ID + /// + + public long ProductID { get; set; } + + + /// + /// 公司ID + /// + public long CompayID { get; set; } + + /// + /// 开支类别 + /// + public string PayTyepName { get; set; } + + /// + /// 车ID + /// + public long CarID { get; set; } + + + /// + /// 车牌号 + /// + public string CarName { get; set; } + + /// + /// 车辆编号 + /// + public string CarNo { get; set; } + + + /// + /// 支付途径 + /// + public string PayChannel { get; set; } + + /// + /// 金额 + /// + public decimal Money { get; set; } + + /// + /// 备注 + /// + public string Remarks { get; set; } + + } +} diff --git a/src/Znyc.Dispatching.Core/Entitys/Declaration.cs b/src/Znyc.Dispatching.Core/Entitys/Declaration.cs new file mode 100644 index 0000000..8bf6294 --- /dev/null +++ b/src/Znyc.Dispatching.Core/Entitys/Declaration.cs @@ -0,0 +1,131 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Core.Entitys +{ + + /// + /// 派单订单表 + /// + [Table("dc_declaration")] + [Comment("派单订单表")] + public class Declaration: DEntityBase + { + /// + /// 公司Id + /// + public long CompanyId { get; set; } + + /// + /// 车型 + /// + public int CarType { get; set; } + + /// + /// 到场时间 + /// + public DateTime ArriveDate { get; set; } + + /// + /// 结束时间 + /// + public DateTime EndTime { get; set; } + + + /// + /// 地址 + /// + public string Address { get; set; } + + /// + /// 报单信息 + /// + public string Info { get; set; } + + + + + /// + /// 报单员 + /// + public string ReportSheetID { get; set; } + + + /// + /// 报单员 + /// + public string ReportSheetName { get; set; } + + + /// + /// 经度 + /// + public decimal Longitude { get; set; } + + /// + /// 纬度 + /// + public decimal Latitude { get; set; } + + + /// + /// 工程名称 + /// + public string ProjectName { get; set; } + + + /// + /// 施工位置 + /// + public string Position { get; set; } + + + /// + /// 施工量 + /// + public string Amount { get; set; } + + + /// + /// 公里数 + /// + public long Kilometre { get; set; } + + + /// + /// 联系电话 + /// + public string Phone { get; set; } + + + /// + /// 报单状态 + /// + public int State { get; set; } + + #region 审核 + + /// + /// 审核人 + /// + public string ReviewName { get; set; } + + /// + /// 审核人ID + /// + public string ReviewID { get; set; } + + + + + + #endregion + + + } +} diff --git a/src/Znyc.Dispatching.Core/Entitys/Oil.cs b/src/Znyc.Dispatching.Core/Entitys/Oil.cs index 71242f1..3f221dd 100644 --- a/src/Znyc.Dispatching.Core/Entitys/Oil.cs +++ b/src/Znyc.Dispatching.Core/Entitys/Oil.cs @@ -44,12 +44,18 @@ namespace Znyc.Dispatching.Core.Entitys /// /// 油单价 /// - public decimal OilPrice { get; set; } + public decimal OilPrice { get; set; } = 0; /// /// 金额 /// public decimal AmountMoney { get; set; } + /// + /// 备注 + /// + public string Remarks { get; set; } + + } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.Core/Entitys/Order.cs b/src/Znyc.Dispatching.Core/Entitys/Order.cs index 7edf4bd..e452e52 100644 --- a/src/Znyc.Dispatching.Core/Entitys/Order.cs +++ b/src/Znyc.Dispatching.Core/Entitys/Order.cs @@ -48,7 +48,7 @@ namespace Znyc.Dispatching.Core.Entitys public string Address { get; set; } /// - /// 状态,10=待指派,20=已指派,未接单,30=已接单,40=已出发,50=已完成,60=已签单,70=已离开,80=已评价,101=撤销 + /// 状态,10=待指派, 11=安全检查 20=已指派,未接单,30=已接单,40=已出发,50=已完成,60=已签单,70=已离开,80=已评价,101=撤销 新增安全状态 /// public int Status { get; set; } @@ -152,6 +152,21 @@ namespace Znyc.Dispatching.Core.Entitys public long ConstructionId { get; set; } + /// + /// 小时 + /// + public string Hour { get;set ; } + + /// + /// 分钟 + /// + public string Minute { get; set; } + + /// + /// 方量 + /// + public string Party { get; set; } + /// diff --git a/src/Znyc.Dispatching.Core/Entitys/OrderCheck.cs b/src/Znyc.Dispatching.Core/Entitys/OrderCheck.cs new file mode 100644 index 0000000..1cef332 --- /dev/null +++ b/src/Znyc.Dispatching.Core/Entitys/OrderCheck.cs @@ -0,0 +1,31 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Core.Entitys +{ + [Table("dc_order_check")] + [Comment("订单安检表")] + public class OrderCheck : DEntityBase + { + + /// + /// 订单Id + /// + public long OrderId { get; set; } + + /// + /// 图片路径 + /// + public string Picture { get; set; } + + + public string Tag { get; set; } + + + } +} diff --git a/src/Znyc.Dispatching.Core/Entitys/OrderVehicle.cs b/src/Znyc.Dispatching.Core/Entitys/OrderVehicle.cs index 692d5d8..b3bb85e 100644 --- a/src/Znyc.Dispatching.Core/Entitys/OrderVehicle.cs +++ b/src/Znyc.Dispatching.Core/Entitys/OrderVehicle.cs @@ -1,4 +1,5 @@ using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace Znyc.Dispatching.Core.Entitys @@ -25,6 +26,7 @@ namespace Znyc.Dispatching.Core.Entitys /// /// 姓名 /// + [MaxLength(100)] public string UserName { get; set; } diff --git a/src/Znyc.Dispatching.Core/Entitys/OrderVisa.cs b/src/Znyc.Dispatching.Core/Entitys/OrderVisa.cs index 7ecab98..12df0e7 100644 --- a/src/Znyc.Dispatching.Core/Entitys/OrderVisa.cs +++ b/src/Znyc.Dispatching.Core/Entitys/OrderVisa.cs @@ -16,14 +16,13 @@ namespace Znyc.Dispatching.Core.Entitys /// public long OrderId { get; set; } - - /// /// 图片路径 /// public string Picture { get; set; } + public string Tag { get; set; } } diff --git a/src/Znyc.Dispatching.Core/Entitys/PayType.cs b/src/Znyc.Dispatching.Core/Entitys/PayType.cs new file mode 100644 index 0000000..75db079 --- /dev/null +++ b/src/Znyc.Dispatching.Core/Entitys/PayType.cs @@ -0,0 +1,36 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Core.Entitys +{ + [Table("dc_paytype")] + [Comment("支付类型表")] + public class PayType : DEntityBase + { + /// + /// 开支类别 + /// + public string TypeName { get; set; } + + /// + /// 是否启用 0 启用 1禁用 + /// + public int Enable { get; set; } + + /// + /// 是否可以编辑 0 可以编辑 1,不可以编辑 + /// + public int IsEdit { get; set; } + + /// + /// 公司ID + /// + public long CompayId { get; set; } + + } +} diff --git a/src/Znyc.Dispatching.Core/Entitys/RecordPlusOil.cs b/src/Znyc.Dispatching.Core/Entitys/RecordPlusOil.cs new file mode 100644 index 0000000..8e2fb42 --- /dev/null +++ b/src/Znyc.Dispatching.Core/Entitys/RecordPlusOil.cs @@ -0,0 +1,51 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Core.Entitys +{ + [Table("dc_recordplusoil")] + [Comment("加油记录表")] + public class RecordPlusOil : DEntityBase + { + + /// + /// 车辆编号 + /// + public string CarNo { get; set; } + + + /// + /// 加油单号 + /// + public string PlusOilNo { get; set; } + + /// + /// 升 + /// + public string Rise { get; set; } + + + /// + /// 单价 + /// + public decimal Price { get; set; } + + + /// + /// 总价 + /// + public decimal Total { get; set; } + + + /// + /// 备注 + /// + public string Remarks { get; set; } + + } +} diff --git a/src/Znyc.Dispatching.Core/Entitys/Vehicle.cs b/src/Znyc.Dispatching.Core/Entitys/Vehicle.cs index 20f1b3c..b15e63a 100644 --- a/src/Znyc.Dispatching.Core/Entitys/Vehicle.cs +++ b/src/Znyc.Dispatching.Core/Entitys/Vehicle.cs @@ -171,6 +171,29 @@ namespace Znyc.Dispatching.Core.Entitys public int Overspeed { get; set; } + + /// + /// 是否开启超速报警 + /// + [Comment("是否开启超速报警")] + public bool IsOverstopAlarm { get; set; } + + /// + /// 超速速度 + /// + [Comment("超速速度")] + [DataValidation(ValidationTypes.PositiveNumber)] + public int Overstop { get; set; } + + + /// + /// 是否开启离线报警 + /// + [Comment("是否开启离线报警")] + public bool IsOveroffAlarm { get; set; } + + + /// /// 排序 /// diff --git a/src/Znyc.Dispatching.Core/Entitys/VehiclePerson.cs b/src/Znyc.Dispatching.Core/Entitys/VehiclePerson.cs index fabde1c..51bfa71 100644 --- a/src/Znyc.Dispatching.Core/Entitys/VehiclePerson.cs +++ b/src/Znyc.Dispatching.Core/Entitys/VehiclePerson.cs @@ -12,7 +12,7 @@ namespace Znyc.Dispatching.Core.Entitys { /// - /// 公司Id + /// 车辆Id /// [Comment("车辆Id")] public long VehicleId { get; set; } diff --git a/src/Znyc.Dispatching.Core/Entitys/WorkPlace.cs b/src/Znyc.Dispatching.Core/Entitys/WorkPlace.cs new file mode 100644 index 0000000..714a621 --- /dev/null +++ b/src/Znyc.Dispatching.Core/Entitys/WorkPlace.cs @@ -0,0 +1,79 @@ +using Furion.DatabaseAccessor; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Core.Entitys +{ + [SuppressChangedListener] + [Table("dc_workplace")] + [Comment("工地表")] + public class WorkPlace : DEntityBase + { + + /// + /// 公司名称 + /// + [Comment("公司名称")] + [Required] + [MaxLength(8)] + public string CompanyName { get; set; } + + /// + /// 公司Logo + /// + [Comment("公司Logo")] + public string CompanyLogo { get; set; } + + + /// + /// 精度 + /// + [Comment("精度")] + public decimal Longitude { get; set; } + + /// + /// 纬度 + /// + [Comment("纬度")] + public decimal Latitude { get; set; } + + /// + /// 地址 + /// + [Comment("地址")] + [MaxLength(35)] + public string Address { get; set; } + + /// + /// 审核时间 + /// + [Comment("审核时间")] + public DateTime AuditTime { get; set; } + + /// + /// 状态(字典 0正常 1停用 2删除) + /// + [Comment("状态")] + public int Status { get; set; } + + /// + /// 停留标示Id + /// + [Comment("停留标示Id")] + public long StopTag { get; set; } + + + /// + /// 是否启用任务车型选项,默认为关 + /// + [Comment("是否启用任务车型选项")] + + public bool IsOpenVehicleType { get; set; } + } +} diff --git a/src/Znyc.Dispatching.Core/Entitys/WorkPlaceEmployee.cs b/src/Znyc.Dispatching.Core/Entitys/WorkPlaceEmployee.cs new file mode 100644 index 0000000..851fe72 --- /dev/null +++ b/src/Znyc.Dispatching.Core/Entitys/WorkPlaceEmployee.cs @@ -0,0 +1,42 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Core.Entitys +{ + [Table("dc_workplaceemployee")] + [Comment("工地中间表")] + public class WorkPlaceEmployee: DEntityBase + { + /// + /// UnionId + /// + [Comment("UnionId")] + [Required] + [MaxLength(32)] + public string UnionId { get; set; } + + /// + /// 工地ID + /// + [Comment("工地ID")] + + public string? WordPlaceID { get; set; } + + /// + /// 用户Id + /// + [Comment("用户Id")] + [Required] + public long UserId { get; set; } + + + + + } +} diff --git a/src/Znyc.Dispatching.Core/Entitys/Yard.cs b/src/Znyc.Dispatching.Core/Entitys/Yard.cs index eb474a5..626384e 100644 --- a/src/Znyc.Dispatching.Core/Entitys/Yard.cs +++ b/src/Znyc.Dispatching.Core/Entitys/Yard.cs @@ -21,7 +21,6 @@ namespace Znyc.Dispatching.Core.Entitys /// 联系人 /// [Comment("联系人")] - [MaxLength(30)] public string ContactPerson { get; set; } /// diff --git a/src/Znyc.Dispatching.Core/Enums/DeclarationEnum.cs b/src/Znyc.Dispatching.Core/Enums/DeclarationEnum.cs new file mode 100644 index 0000000..8b60792 --- /dev/null +++ b/src/Znyc.Dispatching.Core/Enums/DeclarationEnum.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Core.Enums +{ + + /// + /// 报单状态 + /// + public enum DeclarationEnum + { + + /// + /// 未接单 + /// + [Description("未接单")] + MissedOrder = 0, + + /// + /// 待审核 + /// + [Description("待审核")] + StayCheck = 1, + + /// + /// 已审核 + /// + [Description("已审核")] + EndCheck = 2, + + /// + /// 待指派 + /// + [Description("待指派")] + Assign = 3, + + /// + /// 工作中 + /// + [Description("工作中")] + WordHit = 4, + + + /// + /// 已完工 + /// + [Description("已完工")] + OverWord = 10 + + } +} diff --git a/src/Znyc.Dispatching.Core/Enums/OrderStatus.cs b/src/Znyc.Dispatching.Core/Enums/OrderStatus.cs index 6beb44f..853353b 100644 --- a/src/Znyc.Dispatching.Core/Enums/OrderStatus.cs +++ b/src/Znyc.Dispatching.Core/Enums/OrderStatus.cs @@ -20,6 +20,12 @@ namespace Znyc.Dispatching.Core [Description("待指派")] StayAssign = 10, + /// + /// 安检 + /// + [Description("待安检")] + Check = 11, + /// /// 已指派(未接单) /// @@ -44,10 +50,12 @@ namespace Znyc.Dispatching.Core [Description("已到达")] Appear = 50, + + /// /// 已完成 /// - [Description("已完成")] + [Description("已安检")] Complete = 60, /// diff --git a/src/Znyc.Dispatching.Core/Extension/DictionaryExtensions.cs b/src/Znyc.Dispatching.Core/Extension/DictionaryExtensions.cs index 7f1b5c0..e2322c8 100644 --- a/src/Znyc.Dispatching.Core/Extension/DictionaryExtensions.cs +++ b/src/Znyc.Dispatching.Core/Extension/DictionaryExtensions.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; @@ -10,6 +11,28 @@ namespace Znyc.Dispatching.Core /// public static class DictionaryExtensions { + + + public static IEnumerable Distinct( + this IEnumerable source, Func comparer) + where T : class + => source.Distinct(new DynamicEqualityComparer(comparer)); + + private sealed class DynamicEqualityComparer : IEqualityComparer + where T : class + { + private readonly Func _func; + + public DynamicEqualityComparer(Func func) + { + _func = func; + } + + public bool Equals(T x, T y) => _func(x, y); + + public int GetHashCode(T obj) => 0; + } + /// /// 将一个字典转化为 QueryString /// diff --git a/src/Znyc.Dispatching.Core/Extension/RestfulResultProvider.cs b/src/Znyc.Dispatching.Core/Extension/RestfulResultProvider.cs index 213f814..41ebd3e 100644 --- a/src/Znyc.Dispatching.Core/Extension/RestfulResultProvider.cs +++ b/src/Znyc.Dispatching.Core/Extension/RestfulResultProvider.cs @@ -1,5 +1,6 @@ using Furion.DataValidation; using Furion.DependencyInjection; +using Furion.FriendlyException; using Furion.UnifyResult; using Furion.UnifyResult.Internal; using Microsoft.AspNetCore.Http; diff --git a/src/Znyc.Dispatching.Core/Helpers/DateTimeHelper.cs b/src/Znyc.Dispatching.Core/Helpers/DateTimeHelper.cs index 57c6c1e..edcd16a 100644 --- a/src/Znyc.Dispatching.Core/Helpers/DateTimeHelper.cs +++ b/src/Znyc.Dispatching.Core/Helpers/DateTimeHelper.cs @@ -18,6 +18,15 @@ namespace Znyc.Dispatching.Core.Helpers DateTime tempToday = new DateTime(dt.Year, dt.Month, dt.Day); return today.Equals(tempToday); } + /// + /// 去掉字符串中的非数字 + /// + /// + /// + public static string RemoveNotNumber(string key) + { + return System.Text.RegularExpressions.Regex.Replace(key, @"[^\d]*", ""); + } /// diff --git a/src/Znyc.Dispatching.Core/Helpers/MapHelper/MapHelper.cs b/src/Znyc.Dispatching.Core/Helpers/MapHelper/MapHelper.cs index 68f7413..b31050f 100644 --- a/src/Znyc.Dispatching.Core/Helpers/MapHelper/MapHelper.cs +++ b/src/Znyc.Dispatching.Core/Helpers/MapHelper/MapHelper.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Net; using System.Text; using Znyc.Dispatching.Core.MapModel; +using Znyc.Dispatching.Core.Options; namespace Znyc.Dispatching.Core.Helpers { @@ -13,6 +14,127 @@ namespace Znyc.Dispatching.Core.Helpers { private static readonly double EARTH_RADIUS = 6378.137; private const string key = "82c0ac5c67dc9b13a3bb5b8fd4813996"; //高德 + private const string keyTX = "2RRBZ-BKNW6-E6FSM-M5B4R-AMQWH-UGBGB"; + /// + /// Π + /// 圆周率 + /// + private const double PI = 3.14159265358979324; + private const double X_PI = 3.14159265358979324 * 3000.0 / 180.0; + private const double A = 6378245.0; + private const double EE = 0.00669342162296594323; + private const double LON_BOUNDARY_MIN = 72.004; + private const double LAT_BOUNDARY_MIN = 0.8293; + private const double LON_BOUNDARY_MAX = 137.8347; + private const double LAT_BOUNDARY_MAX = 55.8271; + + + + /// + /// 是否中国境内坐标 + /// + /// + /// + /// + private static bool OutOfChina(double gpsLat, double gpsLng) + { + if (gpsLng < LON_BOUNDARY_MIN || gpsLng > LON_BOUNDARY_MAX) + { + return true; + } + + if (gpsLat < LAT_BOUNDARY_MIN || gpsLat > LAT_BOUNDARY_MAX) + { + return true; + } + + return false; + } + + #region WGS坐标系与GCJ02坐标系互转 + + /// + /// WGS84坐标系转GCJ02坐标系 + /// + /// WGS坐标,纬度 + /// WGS坐标,经度 + /// GCJ02坐标,纬度 + /// GCJ02坐标,经度 + public static void WGS84_to_GCJ02(double wgsLat, double wgsLng, out double gcjLat, out double gcjLng) + { + if (OutOfChina(wgsLat, wgsLng)) + { + gcjLat = wgsLat; + gcjLng = wgsLng; + } + else + { + double dLat = TransformLat(wgsLng - 105.0, wgsLat - 35.0); + double dLon = TransformLon(wgsLng - 105.0, wgsLat - 35.0); + double radLat = wgsLat / 180.0 * PI; + double magic = Math.Sin(radLat); + magic = 1 - EE * magic * magic; + double sqrtMagic = Math.Sqrt(magic); + dLat = (dLat * 180.0) / ((A * (1 - EE)) / (magic * sqrtMagic) * PI); + dLon = (dLon * 180.0) / (A / sqrtMagic * Math.Cos(radLat) * PI); + gcjLat = wgsLat + dLat; + gcjLng = wgsLng + dLon; + } + } + + public static void GCJ02_to_WGS84(double gcjLat, double gcjLng, out double wgsLat, out double wgsLng) + { + WGS84_to_GCJ02(gcjLat, gcjLng, out wgsLat, out wgsLng); + + wgsLng = gcjLng * 2 - wgsLng; + wgsLat = gcjLat * 2 - wgsLat; + } + + private static double TransformLat(double x, double y) + { + double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.Sqrt(Math.Abs(x)); + ret += (20.0 * Math.Sin(6.0 * x * PI) + 20.0 * Math.Sin(2.0 * x * PI)) * 2.0 / 3.0; + ret += (20.0 * Math.Sin(y * PI) + 40.0 * Math.Sin(y / 3.0 * PI)) * 2.0 / 3.0; + ret += (160.0 * Math.Sin(y / 12.0 * PI) + 320 * Math.Sin(y * PI / 30.0)) * 2.0 / 3.0; + return ret; + } + + private static double TransformLon(double x, double y) + { + double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.Sqrt(Math.Abs(x)); + ret += (20.0 * Math.Sin(6.0 * x * PI) + 20.0 * Math.Sin(2.0 * x * PI)) * 2.0 / 3.0; + ret += (20.0 * Math.Sin(x * PI) + 40.0 * Math.Sin(x / 3.0 * PI)) * 2.0 / 3.0; + ret += (150.0 * Math.Sin(x / 12.0 * PI) + 300.0 * Math.Sin(x / 30.0 * PI)) * 2.0 / 3.0; + return ret; + } + + #endregion + + #region 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的互转 + + public static void GCJ02_to_Bd09(double gcjLat, double gcjLng, out double bdLat, out double bdLng) + { + double z = Math.Sqrt(gcjLng * gcjLng + gcjLat * gcjLat) + 0.00002 * Math.Sin(gcjLat * PI); + double theta = Math.Atan2(gcjLat, gcjLng) + 0.000003 * Math.Cos(gcjLng * PI); + bdLng = z * Math.Cos(theta) + 0.0065; + bdLat = z * Math.Sin(theta) + 0.006; + } + + + public static void BD09_to_GCJ02(double bdLat, double bdLng, out double gcjLat, out double gcjLng) + { + double x = bdLng - 0.0065, y = bdLat - 0.006; + double z = Math.Sqrt(x * x + y * y) - 0.00002 * Math.Sin(y * PI); + double theta = Math.Atan2(y, x) - 0.000003 * Math.Cos(x * PI); + gcjLng = z * Math.Cos(theta); + gcjLat = z * Math.Sin(theta); + } + + #endregion + + + + /// /// 传入经度纬度 @@ -70,11 +192,21 @@ namespace Znyc.Dispatching.Core.Helpers /// 失败返回"" public static MapLocation GetMapLocation(string strLatLng, int timeout = 10000) { - string url = - string.Format("http://restapi.amap.com/v3/geocode/regeo?key={0}&batch=true&location={1}", - key, strLatLng); - string apiText = HttpGet(url, timeout); - return JObject.Parse(apiText).ToObject(); + try + { + string url = + string.Format("http://restapi.amap.com/v3/geocode/regeo?key={0}&batch=true&location={1}", + key, strLatLng); + string apiText = HttpGet(url, timeout); + return JObject.Parse(apiText).ToObject(); + } + catch (Exception e) + { + + Console.WriteLine(e.Message); + return null; + + } } @@ -177,9 +309,10 @@ namespace Znyc.Dispatching.Core.Helpers string strLatLng = longitude + "," + latitude; MapLocation mapLocation = GetMapLocation(strLatLng); - + Console.WriteLine("查询地址"); if (Convert.ToInt32(mapLocation.Status) == 1) { + Regeocode map = mapLocation.Regeocodes.First(); switch (type) { @@ -349,5 +482,66 @@ namespace Znyc.Dispatching.Core.Helpers } #endregion + + #region 腾讯 + + public static Rootobject pointLatLngs(string start, string end,int timeout,int heading) + { + try + { + string url = + string.Format("https://apis.map.qq.com/ws/direction/v1/driving?output=json&key=2RRBZ-BKNW6-E6FSM-M5B4R-AMQWH-UGBGB&to={0}&from={1}&heading={2}", + start,end, heading); + string apiText = HttpGet(url, timeout); + return JObject.Parse(apiText).ToObject(); + } + catch (Exception e) + { + Console.WriteLine(e.Message); + return new Rootobject(); + } + + } + + + public static Rootobject pointwalkings(string start, string end, int timeout, int heading) + { + try + { + string url = + string.Format("https://apis.map.qq.com/ws/direction/v1/walking?output=json&key=2RRBZ-BKNW6-E6FSM-M5B4R-AMQWH-UGBGB&to={0}&from={1}&heading={2}", + start, end, heading); + string apiText = HttpGet(url, timeout); + return JObject.Parse(apiText).ToObject(); + } + catch (Exception e) + { + Console.WriteLine(e.Message); + return new Rootobject(); + } + + } + + public static GeocoderLoaction geocoder(string location,int timeout) + { + try + { + string url = + string.Format("https://apis.map.qq.com/ws/geocoder/v1/?location={0}&key=2RRBZ-BKNW6-E6FSM-M5B4R-AMQWH-UGBGB&get_poi=1", + location); + string apiText = HttpGet(url, timeout); + return JObject.Parse(apiText).ToObject(); + } + catch (Exception e) + { + Console.WriteLine(e.Message); + return new GeocoderLoaction(); + } + + } + + + #endregion + } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.Core/Helpers/MapHelper/MapModel/GeocoderLoaction.cs b/src/Znyc.Dispatching.Core/Helpers/MapHelper/MapModel/GeocoderLoaction.cs new file mode 100644 index 0000000..d60ae6d --- /dev/null +++ b/src/Znyc.Dispatching.Core/Helpers/MapHelper/MapModel/GeocoderLoaction.cs @@ -0,0 +1,214 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Core.Helpers +{ + public class GeocoderLoaction + { + + public int status { get; set; } + public string message { get; set; } + public string request_id { get; set; } + public Result result { get; set; } + + + public class Result + { + public Location location { get; set; } + public string address { get; set; } + public Formatted_Addresses formatted_addresses { get; set; } + public Address_Component address_component { get; set; } + public Ad_Info ad_info { get; set; } + public Address_Reference address_reference { get; set; } + public int poi_count { get; set; } + public Pois[] pois { get; set; } + } + + public class Location + { + public float lat { get; set; } + public float lng { get; set; } + } + + public class Formatted_Addresses + { + public string recommend { get; set; } + public string rough { get; set; } + } + + public class Address_Component + { + public string nation { get; set; } + public string province { get; set; } + public string city { get; set; } + public string district { get; set; } + public string street { get; set; } + public string street_number { get; set; } + } + + public class Ad_Info + { + public string nation_code { get; set; } + public string adcode { get; set; } + public string city_code { get; set; } + public string name { get; set; } + public Location1 location { get; set; } + public string nation { get; set; } + public string province { get; set; } + public string city { get; set; } + public string district { get; set; } + } + + public class Location1 + { + public float lat { get; set; } + public float lng { get; set; } + } + + public class Address_Reference + { + public Business_Area business_area { get; set; } + public Famous_Area famous_area { get; set; } + public Crossroad crossroad { get; set; } + public Town town { get; set; } + public Street_Number street_number { get; set; } + public Street street { get; set; } + public Landmark_L2 landmark_l2 { get; set; } + } + + public class Business_Area + { + public string id { get; set; } + public string title { get; set; } + public Location2 location { get; set; } + public int _distance { get; set; } + public string _dir_desc { get; set; } + } + + public class Location2 + { + public float lat { get; set; } + public float lng { get; set; } + } + + public class Famous_Area + { + public string id { get; set; } + public string title { get; set; } + public Location3 location { get; set; } + public int _distance { get; set; } + public string _dir_desc { get; set; } + } + + public class Location3 + { + public float lat { get; set; } + public float lng { get; set; } + } + + public class Crossroad + { + public string id { get; set; } + public string title { get; set; } + public Location4 location { get; set; } + public float _distance { get; set; } + public string _dir_desc { get; set; } + } + + public class Location4 + { + public float lat { get; set; } + public float lng { get; set; } + } + + public class Town + { + public string id { get; set; } + public string title { get; set; } + public Location5 location { get; set; } + public int _distance { get; set; } + public string _dir_desc { get; set; } + } + + public class Location5 + { + public float lat { get; set; } + public float lng { get; set; } + } + + public class Street_Number + { + public string id { get; set; } + public string title { get; set; } + public Location6 location { get; set; } + public float _distance { get; set; } + public string _dir_desc { get; set; } + } + + public class Location6 + { + public float lat { get; set; } + public float lng { get; set; } + } + + public class Street + { + public string id { get; set; } + public string title { get; set; } + public Location7 location { get; set; } + public float _distance { get; set; } + public string _dir_desc { get; set; } + } + + public class Location7 + { + public float lat { get; set; } + public float lng { get; set; } + } + + public class Landmark_L2 + { + public string id { get; set; } + public string title { get; set; } + public Location8 location { get; set; } + public int _distance { get; set; } + public string _dir_desc { get; set; } + } + + public class Location8 + { + public float lat { get; set; } + public float lng { get; set; } + } + + public class Pois + { + public string id { get; set; } + public string title { get; set; } + public string address { get; set; } + public string category { get; set; } + public Location9 location { get; set; } + public Ad_Info1 ad_info { get; set; } + public float _distance { get; set; } + public string _dir_desc { get; set; } + } + + public class Location9 + { + public float lat { get; set; } + public float lng { get; set; } + } + + public class Ad_Info1 + { + public string adcode { get; set; } + public string province { get; set; } + public string city { get; set; } + public string district { get; set; } + } + + } +} diff --git a/src/Znyc.Dispatching.Core/Helpers/MapHelper/MapModel/PathPlanning.cs b/src/Znyc.Dispatching.Core/Helpers/MapHelper/MapModel/PathPlanning.cs index 2eae202..0049527 100644 --- a/src/Znyc.Dispatching.Core/Helpers/MapHelper/MapModel/PathPlanning.cs +++ b/src/Znyc.Dispatching.Core/Helpers/MapHelper/MapModel/PathPlanning.cs @@ -117,4 +117,10 @@ namespace Znyc.Dispatching.Core.MapModel [JsonProperty("polyline")] public object Polyline { get; set; } } + + + + + + } \ No newline at end of file diff --git a/src/Znyc.Dispatching.Core/Helpers/RegexHelper.cs b/src/Znyc.Dispatching.Core/Helpers/RegexHelper.cs index ec6af20..7345208 100644 --- a/src/Znyc.Dispatching.Core/Helpers/RegexHelper.cs +++ b/src/Znyc.Dispatching.Core/Helpers/RegexHelper.cs @@ -213,7 +213,6 @@ namespace Znyc.Dispatching.Core.Helpers { string pattern = @"(^|\s*\+?0?0?86|\D)(1\d{2})[-\s]{0,3}(\d{4})[-\s]{0,3}(\d{4})(?=\D|$)"; MatchCollection matchCol = Regex.Matches(value.Trim(), pattern); - string[] result = new string[matchCol.Count]; if (matchCol.Count > 0) { diff --git a/src/Znyc.Dispatching.Core/Helpers/TimeHelper.cs b/src/Znyc.Dispatching.Core/Helpers/TimeHelper.cs index 3abc582..f8c003e 100644 --- a/src/Znyc.Dispatching.Core/Helpers/TimeHelper.cs +++ b/src/Znyc.Dispatching.Core/Helpers/TimeHelper.cs @@ -21,6 +21,22 @@ namespace Znyc.Dispatching.Core.Helpers return Convert.ToInt32(ts3.TotalMinutes); } + + /// + /// 比较两个时间相差的天数 + /// + /// 开始时间 + /// 结束时间 + /// 返回(分钟) + public static int ExecDateDay(DateTime dateBegin, DateTime dateEnd) + { + TimeSpan ts1 = new TimeSpan(dateBegin.Ticks); + TimeSpan ts2 = new TimeSpan(dateEnd.Ticks); + TimeSpan ts3 = ts1.Subtract(ts2).Duration(); + //你想转的格式 + return Convert.ToInt32(ts3.TotalDays); + } + /// /// 时间差格式转换 /// diff --git a/src/Znyc.Dispatching.Core/Helpers/WaterMarkHelper.cs b/src/Znyc.Dispatching.Core/Helpers/WaterMarkHelper.cs new file mode 100644 index 0000000..bb290ca --- /dev/null +++ b/src/Znyc.Dispatching.Core/Helpers/WaterMarkHelper.cs @@ -0,0 +1,324 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Drawing.Imaging; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Core.Helpers +{ + public static class WaterMarkHelper + { + #region 添加水印 + + /// + /// 文字水印 + /// + /// 服务器图片相对路径 + /// 保存文件名 + /// 水印文字 + /// 图片水印位置 0=不使用 1=左上 2=中上 3=右上 4=左中 9=右下 + /// 附加水印图片质量,0-100 + /// 字体大小 + /// 字体 + public static void AddImageSignText(Image img, string filename, string watermarkText, int watermarkStatus, int quality, int fontsize, string fontname = "微软雅黑") + { + //byte[] _ImageBytes = File.ReadAllBytes(imgPath); + //Image img = Image.FromStream(new MemoryStream(_ImageBytes)); + //filename = GetMapPath(filename); + + Graphics g = Graphics.FromImage(img); + + //watermarkText = get_uft8(watermarkText); + Font drawFont = new Font(fontname, fontsize, FontStyle.Regular, GraphicsUnit.Pixel); + SizeF crSize; + crSize = g.MeasureString(watermarkText, drawFont); + + float xpos = 0; + float ypos = 0; + + switch (watermarkStatus) + { + case 1: + xpos = (float)img.Width * (float).01; + ypos = (float)img.Height * (float).01; + break; + case 2: + xpos = ((float)img.Width * (float).50) - (crSize.Width / 2); + ypos = (float)img.Height * (float).01; + break; + case 3: + xpos = ((float)img.Width * (float).99) - crSize.Width; + ypos = (float)img.Height * (float).01; + break; + case 4: + xpos = (float)img.Width * (float).01; + ypos = ((float)img.Height * (float).50) - (crSize.Height / 2); + break; + case 5: + xpos = ((float)img.Width * (float).50) - (crSize.Width / 2); + ypos = ((float)img.Height * (float).50) - (crSize.Height / 2); + break; + case 6: + xpos = ((float)img.Width * (float).99) - crSize.Width; + ypos = ((float)img.Height * (float).50) - (crSize.Height / 2); + break; + case 7: + xpos = (float)img.Width * (float).01; + ypos = ((float)img.Height * (float).99) - crSize.Height; + break; + case 8: + xpos = ((float)img.Width * (float).50) - (crSize.Width / 2); + ypos = ((float)img.Height * (float).99) - crSize.Height; + break; + case 9: + xpos = ((float)img.Width * (float).99) - crSize.Width; + ypos = ((float)img.Height * (float).99) - crSize.Height; + break; + } + + g.DrawString(watermarkText, drawFont, new SolidBrush(Color.White), xpos + 1, ypos + 1); + g.DrawString(watermarkText, drawFont, new SolidBrush(Color.Black), xpos, ypos); + + ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders(); + ImageCodecInfo ici = null; + foreach (ImageCodecInfo codec in codecs) + { + if (codec.MimeType.IndexOf("jpeg") > -1) + ici = codec; + } + EncoderParameters encoderParams = new EncoderParameters(); + long[] qualityParam = new long[1]; + if (quality < 0 || quality > 100) + quality = 80; + + qualityParam[0] = quality; + + EncoderParameter encoderParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, qualityParam); + encoderParams.Param[0] = encoderParam; + + if (ici != null) + img.Save(filename, ici, encoderParams); + else + img.Save(filename); + + g.Dispose(); + img.Dispose(); + } + + + public static string get_uft8(string unicodeString) + { + string keyword; + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + byte[] buffer = Encoding.GetEncoding("GB2312").GetBytes(unicodeString); + return Encoding.GetEncoding("GB2312").GetString(buffer); + //keyword = Encoding.UTF8.GetString(buffer); + //Console.WriteLine("编码后"+keyword); + //return keyword; + } + + + + /// + /// 添加文字水印 + /// + /// + /// + /// 字体大小 + /// 水印开始X坐标(自动扣除文字宽度) + /// 水印开始Y坐标(自动扣除文字高度 + /// 0-255 值越大透明度越低 + /// 文件后缀名 + /// + public static Image AddTextToImg(Image image, string text, float fontSize, float rectX, float rectY, int opacity, string externName) + { + + Bitmap bitmap = new Bitmap(image, image.Width, image.Height); + + Graphics g = Graphics.FromImage(bitmap); + + //下面定义一个矩形区域 + float rectWidth = text.Length * (fontSize + 10); + float rectHeight = fontSize + 20; + + //声明矩形域 + + RectangleF textArea = new RectangleF(rectX - rectWidth, rectY - rectHeight, rectWidth, rectHeight); + + Font font = new Font("Verdana", fontSize, FontStyle.Bold); //定义字体 + + Brush whiteBrush = new SolidBrush(Color.FromArgb(opacity,255, 255, 255)); //画文字用 + + g.DrawString(text, font, whiteBrush, textArea); + + MemoryStream ms = new MemoryStream(); + + //保存图片 + switch (externName) + { + case ".jpg": + bitmap.Save(ms, ImageFormat.Jpeg); + break; + case ".gif": + bitmap.Save(ms, ImageFormat.Gif); + break; + case ".png": + bitmap.Save(ms, ImageFormat.Png); + break; + default: + bitmap.Save(ms, ImageFormat.Jpeg); + break; + } + + + Image h_hovercImg = Image.FromStream(ms); + + g.Dispose(); + + bitmap.Dispose(); + + return h_hovercImg; + + } + + + /// + /// 添加图片水印 + /// + /// + /// + /// 水印开始X坐标(自动扣除图片宽度) + /// 水印开始Y坐标(自动扣除图片高度 + /// 透明度 0-1 + /// 文件后缀名 + /// + public static Image AddImgToImg(Image image, Image watermark, float rectX, float rectY, float opacity, string externName) + { + + Bitmap bitmap = new Bitmap(image, image.Width, image.Height); + + Graphics g = Graphics.FromImage(bitmap); + + + //下面定义一个矩形区域 + float rectWidth = watermark.Width + 10; + float rectHeight = watermark.Height + 10; + + //声明矩形域 + RectangleF textArea = new RectangleF(rectX - rectWidth, rectY - rectHeight, rectWidth, rectHeight); + + Bitmap w_bitmap = ChangeOpacity(watermark, opacity); + + g.DrawImage(w_bitmap, textArea); + + MemoryStream ms = new MemoryStream(); + + //保存图片 + switch (externName) + { + case ".jpg": + bitmap.Save(ms, ImageFormat.Jpeg); + break; + case ".gif": + bitmap.Save(ms, ImageFormat.Gif); + break; + case ".png": + bitmap.Save(ms, ImageFormat.Png); + break; + default: + bitmap.Save(ms, ImageFormat.Jpeg); + break; + } + + Image h_hovercImg = Image.FromStream(ms); + + g.Dispose(); + + bitmap.Dispose(); + return h_hovercImg; + + } + + /// + /// 改变图片的透明度 + /// + /// 图片 + /// 透明度 + /// + public static Bitmap ChangeOpacity(Image img, float opacityvalue) + { + + float[][] nArray ={ new float[] {1, 0, 0, 0, 0}, + + new float[] {0, 1, 0, 0, 0}, + + new float[] {0, 0, 1, 0, 0}, + + new float[] {0, 0, 0, opacityvalue, 0}, + + new float[] {0, 0, 0, 0, 1}}; + + ColorMatrix matrix = new ColorMatrix(nArray); + + ImageAttributes attributes = new ImageAttributes(); + + attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); + + Image srcImage = img; + + Bitmap resultImage = new Bitmap(srcImage.Width, srcImage.Height); + + Graphics g = Graphics.FromImage(resultImage); + + g.DrawImage(srcImage, new Rectangle(0, 0, srcImage.Width, srcImage.Height), 0, 0, srcImage.Width, srcImage.Height, GraphicsUnit.Pixel, attributes); + + return resultImage; + } + + #endregion + + + + #region 图片大小 + + public static Image resizeImage(Image imgToResize, Size size) + { + //获取图片宽度 + int sourceWidth = imgToResize.Width; + //获取图片高度 + int sourceHeight = imgToResize.Height; + + float nPercent = 0; + float nPercentW = 0; + float nPercentH = 0; + //计算宽度的缩放比例 + nPercentW = ((float)size.Width / (float)sourceWidth); + //计算高度的缩放比例 + nPercentH = ((float)size.Height / (float)sourceHeight); + + if (nPercentH < nPercentW) + nPercent = nPercentH; + else + nPercent = nPercentW; + //期望的宽度 + int destWidth = (int)(sourceWidth * nPercent); + //期望的高度 + int destHeight = (int)(sourceHeight * nPercent); + + Bitmap b = new Bitmap(destWidth, destHeight); + Graphics g = Graphics.FromImage((System.Drawing.Image)b); + g.InterpolationMode = InterpolationMode.HighQualityBicubic; + //绘制图像 + g.DrawImage(imgToResize, 0, 0, destWidth, destHeight); + g.Dispose(); + return (System.Drawing.Image)b; + } + + + #endregion + } +} diff --git a/src/Znyc.Dispatching.Core/Options/Drivings.cs b/src/Znyc.Dispatching.Core/Options/Drivings.cs new file mode 100644 index 0000000..45031eb --- /dev/null +++ b/src/Znyc.Dispatching.Core/Options/Drivings.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Core.Options +{ + public class Rootobject + { + public int status { get; set; } + public string message { get; set; } + public string request_id { get; set; } + public Result result { get; set; } + } + + public class Result + { + public Route[] routes { get; set; } + } + + public class Route + { + public string mode { get; set; } + public int distance { get; set; } + public int duration { get; set; } + public int traffic_light_count { get; set; } + public int toll { get; set; } + public Restriction restriction { get; set; } + public decimal[] polyline { get; set; } + public Step[] steps { get; set; } + public object[] tags { get; set; } + public Taxi_Fare taxi_fare { get; set; } + } + + public class Restriction + { + public int status { get; set; } + } + + public class Taxi_Fare + { + public int fare { get; set; } + } + + public class Step + { + public string instruction { get; set; } + public int[] polyline_idx { get; set; } + public string road_name { get; set; } + public string dir_desc { get; set; } + public int distance { get; set; } + public string act_desc { get; set; } + public string accessorial_desc { get; set; } + } +} diff --git a/src/Znyc.Dispatching.Core/Util/COSClientUtil.cs b/src/Znyc.Dispatching.Core/Util/COSClientUtil.cs new file mode 100644 index 0000000..14400c6 --- /dev/null +++ b/src/Znyc.Dispatching.Core/Util/COSClientUtil.cs @@ -0,0 +1,254 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.Core.Util +{ + public class COSClientUtil + { + + string Bucket = ""; + string Region = ""; //根据区域需要变更 + string protocol = ""; + string prefix = "https://znyc-imagers-1306377152.cos.ap-guangzhou.myqcloud.com"; + // 上传文件 + //NewUpload(prefix, "/dir/demo/web.rar", "C:\\web.rar"); + //删除文件 + // NEWDeleteFile(prefix, "/dir/demo/web.rar"); + //下载文件 + //FileDownload(prefix, "/dir/demo/0379aeb8-4a31-ec76-e79c-9cde8b021c98.jpg", "C:\\temp\\0379aeb8-4a31-ec76-e79c-9cde8b021c98.jpg"); //ok + public string SecretId = "AKID61h8KHyQcaJmBMHxNXS7XhcHgqmSt42k";//写自己的id + public string SecretKey = "VkkV0FEyTihSxDDyUkkV0GG0VllV0Ril";//写自己的密钥 + + #region 获取签名处理 + + /// + /// + /// + /// + /// + /// + /// + /// + public string gettxkey(string strModel, string pathname, string qheaderlist, string qurlparamlist) + { + + strModel = strModel.ToLower(); + if (pathname.IndexOf("/") != 0) + { + pathname = "/" + pathname; + } + var singtime = ""; + + + var now = new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds(); + var exp = new DateTimeOffset(DateTime.Now.AddMinutes(15)).ToUnixTimeSeconds(); + singtime = now + ";" + exp; + + + string s1 = HmacSha1Sign(singtime, SecretKey); + + string s2 = strModel + "\n" + pathname + "\n" + qurlparamlist + "\n" + qheaderlist + "\n"; + + string t1 = ""; + t1 = EncryptToSHA1(s2); + + string s3 = "sha1\n" + singtime + "\n" + t1 + "\n"; + + string s4 = HmacSha1Sign(s3, s1); + + var authorization = "q-sign-algorithm=sha1&q-ak=" + SecretId + "&q-sign-time=" + singtime + "&q-key-time=" + singtime + "&q-header-list=" + qheaderlist + "&q-url-param-list=" + qurlparamlist + "&q-signature=" + s4; + return authorization; + + } + public string EncryptToSHA1(string str) + { + var buffer = Encoding.UTF8.GetBytes(str); + var data = System.Security.Cryptography.SHA1.Create().ComputeHash(buffer); + + var sb = new StringBuilder(); + foreach (var t in data) + { + sb.Append(t.ToString("X2")); + } + + return sb.ToString().ToLower(); + } + + /// + /// HMAC-SHA1加密算法 + /// + /// 密钥 + /// 源文 + /// + public string HmacSha1Sign(string EncryptText, string EncryptKey) + { + HMACSHA1 myHMACSHA1 = new HMACSHA1(Encoding.Default.GetBytes(EncryptKey)); + byte[] RstRes = myHMACSHA1.ComputeHash(Encoding.Default.GetBytes(EncryptText)); + StringBuilder EnText = new StringBuilder(); + foreach (byte Byte in RstRes) + { + EnText.AppendFormat("{0:x2}", Byte); + } + return EnText.ToString(); + } + #endregion + + #region 文件处理,上传,下载,删除 + + + /// + /// put 方式上传文件 + /// + /// 路径 + /// 存的地址 + /// 本地文件地址 + /// + public string NewUpload(string url, string remotePath, string localPath) + { + var sign = gettxkey("put", remotePath, "", ""); + string strurl = url + remotePath + "?sign=" + sign; + return HttpPut(strurl, localPath, sign); + + } + public string HttpPut(string inUrl, string inFilePath, string sign) + { + //服务器路径       + string isok = "ok"; + + //文件路径       + // string fileName = "mysales.txt"; + + // 得到文件名,文件扩展名字,服务器路径 + + // 创建WebClient实例 + WebClient myWebClient = new WebClient(); + //header.Add("Authorization", sign); + myWebClient.Headers.Add("Authorization", sign); + //访问权限设置       + myWebClient.Credentials = CredentialCache.DefaultCredentials; + + // 要上传的文件 + FileStream fs = new FileStream(inFilePath, FileMode.Open, FileAccess.Read); + BinaryReader br = new BinaryReader(fs); + try + { + byte[] postArray = br.ReadBytes((int)fs.Length); + Stream postStream = myWebClient.OpenWrite(inUrl, "PUT"); + if (postStream.CanWrite) + { + postStream.Write(postArray, 0, postArray.Length); + + } + else + { + + } + postStream.Close(); + } + catch (WebException errMsg) + { + isok = errMsg.Message; + } + return isok; + } + /// + /// 删除文件 + /// + /// + /// 文件路径 + /// + public string NEWDeleteFile(string url, string remotePath) + { + + string message = "ok"; + var sign = gettxkey("DELETE", remotePath, "", ""); + + string strurl = url + remotePath; + + var request = (HttpWebRequest)WebRequest.Create(strurl); + + request.Method = "DELETE"; + request.Headers.Add("Authorization", sign); + + try + { + var response = (HttpWebResponse)request.GetResponse(); + + var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); + + + } + catch (Exception ex) + { + message = ex.Message; + } + return message; + } + /// + /// 文件下载 + /// + /// + /// 下载地址 + /// 保存地址 + /// + public string FileDownload(string url, string remotePath, string path) + { + + string strisok = "ok"; + string tempPath = System.IO.Path.GetDirectoryName(path) + @"\temp"; + System.IO.Directory.CreateDirectory(tempPath); //创建临时文件目录 + string tempFile = tempPath + @"\" + System.IO.Path.GetFileName(path) + ".temp"; //临时文件 + if (System.IO.File.Exists(tempFile)) + { + System.IO.File.Delete(tempFile); //存在则删除 + } + try + { + FileStream fs = new FileStream(tempFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite); + // 设置参数 + HttpWebRequest request = WebRequest.Create(url + remotePath) as HttpWebRequest; + request.Method = "get"; + var sign = gettxkey("get", remotePath, "", ""); + request.Headers.Add("Authorization", sign); + //发送请求并获取相应回应数据 + HttpWebResponse response = request.GetResponse() as HttpWebResponse; + //直到request.GetResponse()程序才开始向目标网页发送Post请求 + Stream responseStream = response.GetResponseStream(); + //创建本地文件写入流 + //Stream stream = new FileStream(tempFile, FileMode.Create); + byte[] bArr = new byte[1024]; + int size = responseStream.Read(bArr, 0, (int)bArr.Length); + while (size > 0) + { + //stream.Write(bArr, 0, size); + fs.Write(bArr, 0, size); + size = responseStream.Read(bArr, 0, (int)bArr.Length); + } + //stream.Close(); + fs.Close(); + responseStream.Close(); + System.IO.File.Move(tempFile, path); + //删除文件夹 tempPath + Directory.Delete(tempPath, true); + } + catch (Exception ex) + { + strisok = ex.Message; + } + + return strisok; + + } + #endregion + + + + } + +} diff --git a/src/Znyc.Dispatching.Core/Znyc.Dispatching.Core.csproj b/src/Znyc.Dispatching.Core/Znyc.Dispatching.Core.csproj index e96f8ea..80f3af9 100644 --- a/src/Znyc.Dispatching.Core/Znyc.Dispatching.Core.csproj +++ b/src/Znyc.Dispatching.Core/Znyc.Dispatching.Core.csproj @@ -12,6 +12,15 @@ + + + tlbimp + 4 + 2 + d37e2a3e-8545-3a39-9f4f-31827c9124ab + + + Always @@ -35,6 +44,8 @@ + + diff --git a/src/Znyc.Dispatching.Core/Znyc.Dispatching.Core.xml b/src/Znyc.Dispatching.Core/Znyc.Dispatching.Core.xml index 39f06a9..f610f8f 100644 --- a/src/Znyc.Dispatching.Core/Znyc.Dispatching.Core.xml +++ b/src/Znyc.Dispatching.Core/Znyc.Dispatching.Core.xml @@ -215,9 +215,9 @@ - - 头像上传配置 - + + 头像上传配置 + @@ -314,6 +314,20 @@ 公众号 + + + 小程序 + + + + + + + + + 请求CODEURL + + @@ -508,6 +522,26 @@ 车辆缓存 + + + 车辆停下 + + + + + 车辆启动 + + + + + 超速车辆缓存 + + + + + 超速车辆缓存 + + 车辆GPS信息缓存 @@ -528,6 +562,11 @@ 员工列表缓存 + + + 员工分页列表缓存 + + 未读报警消息 @@ -583,6 +622,11 @@ + + + 开支类型 + + 公司表 @@ -683,6 +727,151 @@ 状态 + + + 开支类别ID + + + + + 平摊ID + + + + + 公司ID + + + + + 开支类别 + + + + + 车ID + + + + + 车牌号 + + + + + 车辆编号 + + + + + 支付途径 + + + + + 金额 + + + + + 备注 + + + + + 派单订单表 + + + + + 公司Id + + + + + 车型 + + + + + 到场时间 + + + + + 结束时间 + + + + + 地址 + + + + + 报单信息 + + + + + 报单员 + + + + + 报单员 + + + + + 经度 + + + + + 纬度 + + + + + 工程名称 + + + + + 施工位置 + + + + + 施工量 + + + + + 公里数 + + + + + 联系电话 + + + + + 报单状态 + + + + + 审核人 + + + + + 审核人ID + + 自定义实体基类 @@ -1261,6 +1450,11 @@ 金额 + + + 备注 + + 派工订单表 @@ -1303,7 +1497,7 @@ - 状态,10=待指派,20=已指派,未接单,30=已接单,40=已出发,50=已完成,60=已签单,70=已离开,80=已评价,101=撤销 + 状态,10=待指派, 11=安全检查 20=已指派,未接单,30=已接单,40=已出发,50=已完成,60=已签单,70=已离开,80=已评价,101=撤销 新增安全状态 @@ -1401,6 +1595,31 @@ 施工单位 + + + 小时 + + + + + 分钟 + + + + + 方量 + + + + + 订单Id + + + + + 图片路径 + + 派工订单车组人员表 @@ -1446,6 +1665,26 @@ 图片路径 + + + 开支类别 + + + + + 是否启用 0 启用 1禁用 + + + + + 是否可以编辑 0 可以编辑 1,不可以编辑 + + + + + 公司ID + + 工程信息表 @@ -1521,6 +1760,36 @@ 联系人电话 + + + 车辆编号 + + + + + 加油单号 + + + + + 升 + + + + + 单价 + + + + + 总价 + + + + + 备注 + + 意见反馈表 @@ -1821,6 +2090,21 @@ 超速速度 + + + 是否开启超速报警 + + + + + 超速速度 + + + + + 是否开启离线报警 + + 排序 @@ -1858,7 +2142,7 @@ - 公司Id + 车辆Id @@ -1906,6 +2190,66 @@ 状态(字典 0正常 1停用 2删除) + + + 公司名称 + + + + + 公司Logo + + + + + 精度 + + + + + 纬度 + + + + + 地址 + + + + + 审核时间 + + + + + 状态(字典 0正常 1停用 2删除) + + + + + 停留标示Id + + + + + 是否启用任务车型选项,默认为关 + + + + + UnionId + + + + + 工地ID + + + + + 用户Id + + 微信中间表 @@ -2086,6 +2430,61 @@ 修改状态 + + + 报单状态 + + + + + 未接单 + + + + + 待审核 + + + + + 已审核 + + + + + 待指派 + + + + + 工作中 + + + + + 已完工 + + + + + 默认 + + + + + 接口 + + + + + 网站 + + + + + 循环时间 + + 系统错误码 @@ -2491,26 +2890,6 @@ 静止 - - - 默认 - - - - - 接口 - - - - - 网站 - - - - - 循环时间 - - HTTP状态码 @@ -2813,6 +3192,11 @@ 待指派 + + + 安检 + + 已指派(未接单) @@ -4016,6 +4400,13 @@ + + + 去掉字符串中的非数字 + + + + 时间转换 @@ -4175,6 +4566,29 @@ + + + Π + 圆周率 + + + + + 是否中国境内坐标 + + + + + + + + WGS84坐标系转GCJ02坐标系 + + WGS坐标,纬度 + WGS坐标,经度 + GCJ02坐标,纬度 + GCJ02坐标,经度 + 传入经度纬度 @@ -4535,6 +4949,14 @@ 结束时间 返回(分钟) + + + 比较两个时间相差的天数 + + 开始时间 + 结束时间 + 返回(分钟) + 时间差格式转换 @@ -4639,6 +5061,51 @@ + + + 文字水印 + + 服务器图片相对路径 + 保存文件名 + 水印文字 + 图片水印位置 0=不使用 1=左上 2=中上 3=右上 4=左中 9=右下 + 附加水印图片质量,0-100 + 字体大小 + 字体 + + + + 添加文字水印 + + + + 字体大小 + 水印开始X坐标(自动扣除文字宽度) + 水印开始Y坐标(自动扣除文字高度 + 0-255 值越大透明度越低 + 文件后缀名 + + + + + 添加图片水印 + + + + 水印开始X坐标(自动扣除图片宽度) + 水印开始Y坐标(自动扣除图片高度 + 透明度 0-1 + 文件后缀名 + + + + + 改变图片的透明度 + + 图片 + 透明度 + + XSS过滤 @@ -4832,6 +5299,50 @@ sql高级代理 + + + + + + + + + + + + + HMAC-SHA1加密算法 + + 密钥 + 源文 + + + + + put 方式上传文件 + + 路径 + 存的地址 + 本地文件地址 + + + + + 删除文件 + + + 文件路径 + + + + + 文件下载 + + + 下载地址 + 保存地址 + + 阿里云oss文件上传工具类 diff --git a/src/Znyc.Dispatching.Core/coreconfig.Development.json b/src/Znyc.Dispatching.Core/coreconfig.Development.json index 0bd5a9f..e13e4a8 100644 --- a/src/Znyc.Dispatching.Core/coreconfig.Development.json +++ b/src/Znyc.Dispatching.Core/coreconfig.Development.json @@ -13,16 +13,17 @@ }, "Cache": { //测试环境调试配置,非必要请在本地进行开发调试 - "RedisConnectionString": "81.71.148.57:46379,password=dfeFEgeGH/,defaultDatabase=6" + "RedisConnectionString": "81.71.148.57:46379,password=dfeFEgeGH/,defaultDatabase=7" + //"RedisConnectionString": "81.71.148.57:46379,password=vtgA9HXFQQYA9g8Z,defaultDatabase=7" //"RedisConnectionString": "127.0.0.1:6379" }, "SnowId": { "WorkerId": "1" }, "SMSProvider": { - "SecretId": "AKIDGSN2VjJkZ7pIYzcdo0zjDCKCnQpEhXbW", - "SecretKey": "rQDI7fuoUyIEvLT5RWKqkUyGQJwBiU2P", - "SmsSdkAppid": "1400497500", + "SecretId": "AKID61h8KHyQcaJmBMHxNXS7XhcHgqmSt42k", + "SecretKey": "VkkV0FEyTihSxDDyUkkV0GG0VllV0Ril", + "SmsSdkAppid": "1306377152", "Sign": "众能云车", "Region": "ap-guangzhou", "TemplateList": [ diff --git a/src/Znyc.Dispatching.Core/coreconfig.Production.json b/src/Znyc.Dispatching.Core/coreconfig.Production.json index 73a0341..fb7d3c7 100644 --- a/src/Znyc.Dispatching.Core/coreconfig.Production.json +++ b/src/Znyc.Dispatching.Core/coreconfig.Production.json @@ -19,8 +19,8 @@ "WorkerId": "1" }, "SMSProvider": { - "SecretId": "AKIDGSN2VjJkZ7pIYzcdo0zjDCKCnQpEhXbW", - "SecretKey": "rQDI7fuoUyIEvLT5RWKqkUyGQJwBiU2P", + "SecretId": "AKID61h8KHyQcaJmBMHxNXS7XhcHgqmSt42k", + "SecretKey": "VkkV0FEyTihSxDDyUkkV0GG0VllV0Ril", "SmsSdkAppid": "1400497500", "Sign": "众能云车", "Region": "ap-guangzhou", diff --git a/src/Znyc.Dispatching.Core/coreconfig.Staging.json b/src/Znyc.Dispatching.Core/coreconfig.Staging.json index bd839a3..4fff299 100644 --- a/src/Znyc.Dispatching.Core/coreconfig.Staging.json +++ b/src/Znyc.Dispatching.Core/coreconfig.Staging.json @@ -18,9 +18,9 @@ "WorkerId": "1" }, "SMSProvider": { - "SecretId": "AKIDGSN2VjJkZ7pIYzcdo0zjDCKCnQpEhXbW", - "SecretKey": "rQDI7fuoUyIEvLT5RWKqkUyGQJwBiU2P", - "SmsSdkAppid": "1400497500", + "SecretId": "AKID61h8KHyQcaJmBMHxNXS7XhcHgqmSt42k", + "SecretKey": "VkkV0FEyTihSxDDyUkkV0GG0VllV0Ril", + "SmsSdkAppid": "1306377152", "Sign": "众能云车", "Region": "ap-guangzhou", "TemplateList": [ diff --git a/src/Znyc.Dispatching.EntityFramework.Core/dbsettings.Development.json b/src/Znyc.Dispatching.EntityFramework.Core/dbsettings.Development.json index 2e4f91b..fda2011 100644 --- a/src/Znyc.Dispatching.EntityFramework.Core/dbsettings.Development.json +++ b/src/Znyc.Dispatching.EntityFramework.Core/dbsettings.Development.json @@ -1,7 +1,8 @@ { "ConnectionStrings": { //���Ի����������ã��DZ�Ҫ���ڱ��ؽ��п������� - "DefaultConnection": "Server=81.71.148.57;Port=43306;Database=znyc_dispatching;Uid=znyc;Pwd=bIQISVSO;Charset=utf8mb4;AllowLoadLocalInfile=true" + //"DefaultConnection": "Server=81.71.148.57;Port=43306;Database=znyc_dispatching;Uid=guest;Pwd=4Y2e2WtekfDYWfT8;Charset=utf8mb4;AllowLoadLocalInfile=true", + "DefaultConnection": "Server=81.71.148.57; Port=43306; Database=znyc_dispatching; Uid=znyc; Pwd=bIQISVSO; Charset=utf8mb4" //"DefaultConnection": "Server=127.0.0.1;Port=3306;Database=znyc_dispatching;Uid=root;Pwd=123456;Charset=utf8mb4" } } diff --git a/src/Znyc.Dispatching.MongoDb.Repository/IRepositorys/IGpsRealTimeRepository.cs b/src/Znyc.Dispatching.MongoDb.Repository/IRepositorys/IGpsRealTimeRepository.cs index 3c5a7b2..245944f 100644 --- a/src/Znyc.Dispatching.MongoDb.Repository/IRepositorys/IGpsRealTimeRepository.cs +++ b/src/Znyc.Dispatching.MongoDb.Repository/IRepositorys/IGpsRealTimeRepository.cs @@ -12,6 +12,7 @@ namespace Znyc.Dispatching.MongoDb.Repository.Repositorys Task> GetGpsRealTimeByCompanyId(long companyId); + Task> GetSpeeding(int Speed); Task> GetOfflineGpsRealTime(); Task UpdateGpsRealTime(object id, GpsRealTime gpsRealTime); diff --git a/src/Znyc.Dispatching.MongoDb.Repository/IRepositorys/IMongodbBaseRepository.cs b/src/Znyc.Dispatching.MongoDb.Repository/IRepositorys/IMongodbBaseRepository.cs index a77360e..b8cf2aa 100644 --- a/src/Znyc.Dispatching.MongoDb.Repository/IRepositorys/IMongodbBaseRepository.cs +++ b/src/Znyc.Dispatching.MongoDb.Repository/IRepositorys/IMongodbBaseRepository.cs @@ -16,7 +16,7 @@ namespace Znyc.Dispatching.MongoDb.Repository.Repositorys Task> GetVehicleGpsListAsync(string tbName, FilterDefinition filter); /// - /// 查询车辆停留点 + /// 查询车辆停留点 /// /// /// @@ -50,5 +50,8 @@ namespace Znyc.Dispatching.MongoDb.Repository.Repositorys /// Task GetAlertCountAsync(string tbName, FilterDefinition filter); + + + } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.MongoDb.Repository/Repositorys/GpsRealTimeRepository.cs b/src/Znyc.Dispatching.MongoDb.Repository/Repositorys/GpsRealTimeRepository.cs index 5e4a6fe..ef9a812 100644 --- a/src/Znyc.Dispatching.MongoDb.Repository/Repositorys/GpsRealTimeRepository.cs +++ b/src/Znyc.Dispatching.MongoDb.Repository/Repositorys/GpsRealTimeRepository.cs @@ -60,6 +60,18 @@ namespace Znyc.Dispatching.MongoDb.Repository.Repositorys x.GpsState == (int)GpsStatusEnum.OFFLINE && x.Status == (int)CommonStatusEnum.ENABLE); } + + /// + /// 查询所有超速车辆信息 + /// + /// + public async Task> GetSpeeding(int Speed) + { + return await _gpsRealTimemongoDbRepository.QueryListAsync(x => + x.Speed >= Speed && x.Status == (int)CommonStatusEnum.ENABLE); + } + + /// /// 修改车辆信息 /// diff --git a/src/Znyc.Dispatching.MongoDb.Repository/Repositorys/MongodbBaseRepository.cs b/src/Znyc.Dispatching.MongoDb.Repository/Repositorys/MongodbBaseRepository.cs index 8e8a3d1..b8c5f06 100644 --- a/src/Znyc.Dispatching.MongoDb.Repository/Repositorys/MongodbBaseRepository.cs +++ b/src/Znyc.Dispatching.MongoDb.Repository/Repositorys/MongodbBaseRepository.cs @@ -93,5 +93,7 @@ namespace Znyc.Dispatching.MongoDb.Repository.Repositorys } + + } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.Tasks/HangfireDispose.cs b/src/Znyc.Dispatching.Tasks/HangfireDispose.cs index 2ef950a..d379a4d 100644 --- a/src/Znyc.Dispatching.Tasks/HangfireDispose.cs +++ b/src/Znyc.Dispatching.Tasks/HangfireDispose.cs @@ -1,10 +1,11 @@ -using Hangfire; +using Furion.TaskScheduler; +using Hangfire; using System; using Znyc.Dispatching.Tasks.TaskJobs; namespace Znyc.Dispatching.Tasks { - public class HangfireDispose + public class HangfireDispose { public static void HangfireService() @@ -34,11 +35,18 @@ namespace Znyc.Dispatching.Tasks //每晚预热昨天的轨迹 //RecurringJob.AddOrUpdate(s => s.Execute(), "0 0 0 */1 * ? ", TimeZoneInfo.Utc); + ////查询 每小时提醒一次 + //RecurringJob.AddOrUpdate(s => s.SyncVehicleoffAsync(), "0 0 0/1 * * ? ", TimeZoneInfo.Local); + + RecurringJob.AddOrUpdate(s => s.SyncOrderStatusAsync(), "0 0/1 * * * ? ", TimeZoneInfo.Local); + //每30天预热一次角色菜单缓存 RecurringJob.AddOrUpdate(s => s.RoleMenuExecuteAsync(), "0 0 5 1 * ? ", TimeZoneInfo.Local); - RecurringJob.AddOrUpdate(s => s.SyncOrderStatusAsync(), "0 0/1 * * * ? ", TimeZoneInfo.Local); + + + diff --git a/src/Znyc.Dispatching.Tasks/TaskJobs/AutoOrderJob.cs b/src/Znyc.Dispatching.Tasks/TaskJobs/AutoOrderJob.cs index 98deea2..01d3699 100644 --- a/src/Znyc.Dispatching.Tasks/TaskJobs/AutoOrderJob.cs +++ b/src/Znyc.Dispatching.Tasks/TaskJobs/AutoOrderJob.cs @@ -1,4 +1,6 @@ using Dilon.Core.Service; +using Furion.DatabaseAccessor; +using Furion.TaskScheduler; using System.Threading.Tasks; namespace Znyc.Dispatching.Tasks.TaskJobs @@ -16,13 +18,25 @@ namespace Znyc.Dispatching.Tasks.TaskJobs } + + /// /// /// /// public async Task SyncOrderStatusAsync() { - await _jobService.SyncOrderStatusAsync(); + //await _jobService.SyncOrderStatusAsync(); } + + + ///// + ///// + ///// + ///// + //public async Task SyncVehicleoffAsync() + //{ + // await _jobService.SyncVehicleOff(); + //} } } diff --git a/src/Znyc.Dispatching.Tasks/TasksStartup.cs b/src/Znyc.Dispatching.Tasks/TasksStartup.cs index 97fbe2b..a502ea6 100644 --- a/src/Znyc.Dispatching.Tasks/TasksStartup.cs +++ b/src/Znyc.Dispatching.Tasks/TasksStartup.cs @@ -62,7 +62,7 @@ namespace Znyc.Dispatching.MongoDb.Repository } }; - app.UseHangfireDashboard("/dc_job", options); + app.UseHangfireDashboard("/dc_job"); HangfireDispose.HangfireService(); } } diff --git a/src/Znyc.Dispatching.Tasks/Znyc.Dispatching.Tasks.csproj b/src/Znyc.Dispatching.Tasks/Znyc.Dispatching.Tasks.csproj index 389e8de..9c43861 100644 --- a/src/Znyc.Dispatching.Tasks/Znyc.Dispatching.Tasks.csproj +++ b/src/Znyc.Dispatching.Tasks/Znyc.Dispatching.Tasks.csproj @@ -5,7 +5,7 @@ - + diff --git a/src/Znyc.Dispatching.WeChat.Core/CommonService/TemplateMessage/Weixin/WeixinTemplate_AssignOrder.cs b/src/Znyc.Dispatching.WeChat.Core/CommonService/TemplateMessage/Weixin/WeixinTemplate_AssignOrder.cs index edaa9d9..1c314c5 100644 --- a/src/Znyc.Dispatching.WeChat.Core/CommonService/TemplateMessage/Weixin/WeixinTemplate_AssignOrder.cs +++ b/src/Znyc.Dispatching.WeChat.Core/CommonService/TemplateMessage/Weixin/WeixinTemplate_AssignOrder.cs @@ -48,4 +48,75 @@ namespace Znyc.Dispatching.WeChat.Core.CommonService.TemplateMessage remark = new TemplateDataItem(_remark); } } + + + /// + /// + /// + public class WeixinTemplate_Speed : TemplateMessageBase + { + const string TEMPLATE_ID = "RMlgZ-5L8dDd0vR5teOb0WepN_JLtCOW-G7lQad-jII"; + + public TemplateDataItem first { get; set; } + + public TemplateDataItem keyword1 { get; set; } + + public TemplateDataItem keyword2 { get; set; } + + public TemplateDataItem keyword3 { get; set; } + + + /// + /// + /// + public TemplateDataItem remark { get; set; } + + public WeixinTemplate_Speed(string _first, string Time, string Add, string CarNo, string _remark, string url = null, string templateId = TEMPLATE_ID) + : base(templateId, url, "超速通知") + { + first = new TemplateDataItem(_first); + keyword1 = new TemplateDataItem(Time); + keyword2 = new TemplateDataItem(Add); + keyword3 = new TemplateDataItem(CarNo); + remark = new TemplateDataItem(_remark); + } + } + + + /// + /// + /// + public class WeixinTemplate_Stop : TemplateMessageBase + { + const string TEMPLATE_ID = "zsloSeSF_V5zlBJ0j0smwdC_SKPi8x9LigmHitg3wcc"; + + public TemplateDataItem first { get; set; } + + public TemplateDataItem keyword1 { get; set; } + + public TemplateDataItem keyword2 { get; set; } + + public TemplateDataItem keyword3 { get; set; } + + public TemplateDataItem keyword4 { get; set; } + + public TemplateDataItem keyword5 { get; set; } + + /// + /// + /// + public TemplateDataItem remark { get; set; } + + public WeixinTemplate_Stop(string _first, string CarNo,string StartTime,string EndTime, string StopTime,string Add, string _remark, string url = null, string templateId = TEMPLATE_ID) + : base(templateId, url, "停留通知") + { + first = new TemplateDataItem(_first); + keyword1 = new TemplateDataItem(CarNo); + keyword2 = new TemplateDataItem(StartTime); + keyword3 = new TemplateDataItem(EndTime); + keyword4 = new TemplateDataItem(StopTime); + keyword5 = new TemplateDataItem(Add); + remark = new TemplateDataItem(_remark); + } + } } diff --git a/src/Znyc.Dispatching.WeChat.Core/CommonService/TemplateMessage/WxOpen/SnsApi.cs b/src/Znyc.Dispatching.WeChat.Core/CommonService/TemplateMessage/WxOpen/SnsApi.cs index 74f0eec..dadfc1c 100644 --- a/src/Znyc.Dispatching.WeChat.Core/CommonService/TemplateMessage/WxOpen/SnsApi.cs +++ b/src/Znyc.Dispatching.WeChat.Core/CommonService/TemplateMessage/WxOpen/SnsApi.cs @@ -31,5 +31,28 @@ namespace Znyc.Dispatching.WeChat.Core.CommonService.TemplateMessage.WxOpen .ConfigureAwait(false); return result; } + + + public static async Task GetToken(string appId, string secret) + { + string urlFormat = Config.ApiMpHost+ "/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}"; + string url = string.Format(urlFormat, appId, secret); + + GetToken result = await CommonJsonSend.SendAsync(null, url, null, CommonJsonSendType.GET) + .ConfigureAwait(false); + return result; + } + + + public static async Task GetTicket(string access_token, TicketArg ticketArg) + { + string urlFormat = Config.ApiMpHost + "/cgi-bin/qrcode/create?access_token={0}"; + string url = string.Format(urlFormat, access_token); + + TicketOut result = await CommonJsonSend.SendAsync(null, url, ticketArg, CommonJsonSendType.POST) + .ConfigureAwait(false); + return result; + } + } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.WeChat.Core/Entity/Arg/TicketArg.cs b/src/Znyc.Dispatching.WeChat.Core/Entity/Arg/TicketArg.cs new file mode 100644 index 0000000..ac76df2 --- /dev/null +++ b/src/Znyc.Dispatching.WeChat.Core/Entity/Arg/TicketArg.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.WeChat.Core +{ + public class TicketArg + { + + public int expire_seconds { get; set; } + public string action_name { get; set; } + public Action_Info action_info { get; set; } + } + + public class Action_Info + { + public Scene scene { get; set; } + } + + public class Scene + { + public int scene_id { get; set; } + } +} diff --git a/src/Znyc.Dispatching.WeChat.Core/Entity/Out/GetToken.cs b/src/Znyc.Dispatching.WeChat.Core/Entity/Out/GetToken.cs new file mode 100644 index 0000000..b932f5b --- /dev/null +++ b/src/Znyc.Dispatching.WeChat.Core/Entity/Out/GetToken.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.WeChat.Core +{ + public class GetToken + { + public string Access_Token { get; set; } + + public string Expires_In { get; set; } + + } +} diff --git a/src/Znyc.Dispatching.WeChat.Core/Entity/Out/TicketOut.cs b/src/Znyc.Dispatching.WeChat.Core/Entity/Out/TicketOut.cs new file mode 100644 index 0000000..2e82555 --- /dev/null +++ b/src/Znyc.Dispatching.WeChat.Core/Entity/Out/TicketOut.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Znyc.Dispatching.WeChat.Core +{ + public class TicketOut + { + public string ticket { get; set; } + public int expire_seconds { get; set; } + public string url { get; set; } + + } +} diff --git a/src/Znyc.Dispatching.WeChat.Core/wechatsettings.Development.json b/src/Znyc.Dispatching.WeChat.Core/wechatsettings.Development.json index 5660f9f..d593fe7 100644 --- a/src/Znyc.Dispatching.WeChat.Core/wechatsettings.Development.json +++ b/src/Znyc.Dispatching.WeChat.Core/wechatsettings.Development.json @@ -14,5 +14,10 @@ "EncodingAESKey": "", "WeixinAppId": "wx07c574aca93ae8d9", "WeixinAppSecret": "2d202f91258131f63565e11bdb065f6b" + }, + "WxOpenSetting": { + "AppID": "wx29a1bf151a5bff2b", + "AppSecret": "2f362cfbf1c5ddee277faf2f668cb6bc", + "OpenUrl": "https://open.weixin.qq.com/" } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.WeChat.Core/wechatsettings.Production.json b/src/Znyc.Dispatching.WeChat.Core/wechatsettings.Production.json index ded8ef4..d68c8e8 100644 --- a/src/Znyc.Dispatching.WeChat.Core/wechatsettings.Production.json +++ b/src/Znyc.Dispatching.WeChat.Core/wechatsettings.Production.json @@ -15,5 +15,10 @@ "EncodingAESKey": "#{EncodingAESKey}#", "WeixinAppId": "wx07c574aca93ae8d9", "WeixinAppSecret": "2d202f91258131f63565e11bdb065f6b" + }, + "WxOpenSetting": { + "AppID": "wx29a1bf151a5bff2b", + "AppSecret": "2f362cfbf1c5ddee277faf2f668cb6bc", + "OpenUrl": "https://open.weixin.qq.com/" } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.WeChat.Core/wechatsettings.Staging.json b/src/Znyc.Dispatching.WeChat.Core/wechatsettings.Staging.json index 5660f9f..d593fe7 100644 --- a/src/Znyc.Dispatching.WeChat.Core/wechatsettings.Staging.json +++ b/src/Znyc.Dispatching.WeChat.Core/wechatsettings.Staging.json @@ -14,5 +14,10 @@ "EncodingAESKey": "", "WeixinAppId": "wx07c574aca93ae8d9", "WeixinAppSecret": "2d202f91258131f63565e11bdb065f6b" + }, + "WxOpenSetting": { + "AppID": "wx29a1bf151a5bff2b", + "AppSecret": "2f362cfbf1c5ddee277faf2f668cb6bc", + "OpenUrl": "https://open.weixin.qq.com/" } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.Web.Core/Startup.cs b/src/Znyc.Dispatching.Web.Core/Startup.cs index 9fc6292..35bece0 100644 --- a/src/Znyc.Dispatching.Web.Core/Startup.cs +++ b/src/Znyc.Dispatching.Web.Core/Startup.cs @@ -23,7 +23,7 @@ namespace Znyc.Dispatching.WeChat.Core services.AddCorsAccessor(); services.AddRemoteRequest(); services.AddConfigurableOptions(); - + services.AddTaskScheduler(); services.AddControllersWithViews() .AddNewtonsoftJson(options => @@ -50,6 +50,7 @@ namespace Znyc.Dispatching.WeChat.Core services.AddConfigurableOptions(); //配置微信 services.AddConfigurableOptions(); + services.AddConfigurableOptions(); //配置短信 services.AddConfigurableOptions(); diff --git a/src/Znyc.Dispatching.Web.Entry/Properties/launchSettings.json b/src/Znyc.Dispatching.Web.Entry/Properties/launchSettings.json index 577cd94..3278566 100644 --- a/src/Znyc.Dispatching.Web.Entry/Properties/launchSettings.json +++ b/src/Znyc.Dispatching.Web.Entry/Properties/launchSettings.json @@ -23,7 +23,7 @@ "ASPNETCORE_ENVIRONMENT": "Development" }, "dotnetRunMessages": "true", - "applicationUrl": "http://localhost:80" + "applicationUrl": "http://0.0.0.0:80" }, "Docker": { "commandName": "Docker", diff --git a/src/Znyc.Dispatching.Web.Entry/appsettings.Development.json b/src/Znyc.Dispatching.Web.Entry/appsettings.Development.json index c8827d1..b530cf7 100644 --- a/src/Znyc.Dispatching.Web.Entry/appsettings.Development.json +++ b/src/Znyc.Dispatching.Web.Entry/appsettings.Development.json @@ -1,61 +1,61 @@ { "AllowedHosts": "*", "Upload": { - //ͷ�� + //ͷ "avatar": { - //�ϴ�·�� D:/upload/admin/avatar + //ϴ· D:/upload/admin/avatar "uploadPath": "../upload/avatar", - //����·�� + //· "requestPath": "/upload/avatar", - //��ȡ·�� + //ȡ· "readPath": "https://znyc-images-1304677865.cos.ap-guangzhou.myqcloud.com/", - //·�����ڸ�ʽ yyyy/MM/dd + //·ڸʽ yyyy/MM/dd "dateTimeFormat": "", - //{�û����} + //{û} "format": "", - //ͼƬ��С������ 1M = 1 * 1024 * 1024 + //ͼƬС 1M = 1 * 1024 * 1024 "maxSize": 1048576, - //��������ϴ�������-1������ + //ϴ-1 "limit": 1, - //ͼƬ��ʽ + //ͼƬʽ "contentType": [ "image/jpg", "image/png", "image/jpeg", "image/gif" ] }, - //�ĵ�ͼƬ + //ĵͼƬ "document": { - //�ϴ�·�� D:/upload/admin/document + //ϴ· D:/upload/admin/document "uploadPath": "../upload/document", - //����·�� + //· "requestPath": "/images", - //·�����ڸ�ʽ yyyy/MM/dd + //·ڸʽ yyyy/MM/dd "dateTimeFormat": "", - //{�ĵ����} + //{ĵ} "format": "", - //ͼƬ��С������ 1M = 1 * 1024 * 1024 + //ͼƬС 1M = 1 * 1024 * 1024 "maxSize": 1048576, - //��������ϴ�������-1������ + //ϴ-1 "limit": -1, - //ͼƬ��ʽ + //ͼƬʽ "contentType": [ "image/jpg", "image/png", "image/jpeg", "image/gif" ] }, - "secretId": "AKIDGSN2VjJkZ7pIYzcdo0zjDCKCnQpEhXbW", - "secretKey": "rQDI7fuoUyIEvLT5RWKqkUyGQJwBiU2P", - "bucket": "znyc-images-1304677865", + "secretId": "AKID61h8KHyQcaJmBMHxNXS7XhcHgqmSt42k", + "secretKey": "VkkV0FEyTihSxDDyUkkV0GG0VllV0Ril", + "bucket": "znyc-images-1306377152", "region": "ap-guangzhou" }, "UploadInfo": { - "secretId": "AKIDGMBk7D3cuvf8KFtGMBj00iALFsEJ7dsq", - "secretKey": "i9IBn8Bzav0pMcbJkunPjmY3HsCF2Zom", - "bucket": "znyc-images-1304677865", + "secretId": "AKID61h8KHyQcaJmBMHxNXS7XhcHgqmSt42k", + "secretKey": "VkkV0FEyTihSxDDyUkkV0GG0VllV0Ril", + "bucket": "znyc-images-1306377152", "region": "ap-guangzhou", "allowPrefix": "a.jpg", "durationSeconds": 1800, "allowActions": [ "name/cos:PutObject", - // ����ϴ���С�����ϴ� + // ϴСϴ "name/cos:PostObject", - // ��Ƭ�ϴ� + // Ƭϴ "name/cos:InitiateMultipartUpload", "name/cos:ListMultipartUploads", "name/cos:ListParts", @@ -84,6 +84,6 @@ }, "SnowId": { - "WorkerId": "1" // ȡֵ��Χ0~63,Ĭ��1 + "WorkerId": "1" // ȡֵΧ0~63,Ĭ1 } } \ No newline at end of file diff --git a/src/Znyc.Dispatching.Web.Entry/appsettings.Production.json b/src/Znyc.Dispatching.Web.Entry/appsettings.Production.json index a133484..805aa46 100644 --- a/src/Znyc.Dispatching.Web.Entry/appsettings.Production.json +++ b/src/Znyc.Dispatching.Web.Entry/appsettings.Production.json @@ -5,7 +5,7 @@ "AllowedHosts": "*", "Upload": { - //ͷ + //ͷ~` "avatar": { //ϴ· D:/upload/admin/avatar "uploadPath": "../upload/avatar", @@ -13,7 +13,6 @@ "requestPath": "/upload/avatar", //ȡ· "readPath": "https://znyc-images-1304677865.cos.ap-guangzhou.myqcloud.com/", - //·ڸʽ yyyy/MM/dd "dateTimeFormat": "", //{û} @@ -25,33 +24,18 @@ //ͼƬʽ "contentType": [ "image/jpg", "image/png", "image/jpeg", "image/gif" ] }, - //ĵͼƬ - "document": { - //ϴ· D:/upload/admin/document - "uploadPath": "../upload/document", - //· - "requestPath": "/images", - //·ڸʽ yyyy/MM/dd - "dateTimeFormat": "", - //{ĵ} - "format": "", - //ͼƬС 1M = 1 * 1024 * 1024 - "maxSize": 1048576, - //ϴ-1 - "limit": -1, - //ͼƬʽ - "contentType": [ "image/jpg", "image/png", "image/jpeg", "image/gif" ] - }, + + "secretId": "AKIDGSN2VjJkZ7pIYzcdo0zjDCKCnQpEhXbW", "secretKey": "rQDI7fuoUyIEvLT5RWKqkUyGQJwBiU2P", - "bucket": "znyc-images-1304677865", + "bucket": "znyc-images-1306377152", "region": "ap-guangzhou" }, "UploadInfo": { - "secretId": "AKIDGMBk7D3cuvf8KFtGMBj00iALFsEJ7dsq", - "secretKey": "i9IBn8Bzav0pMcbJkunPjmY3HsCF2Zom", - "bucket": "znyc-images-1304677865", + "secretId": "AKID61h8KHyQcaJmBMHxNXS7XhcHgqmSt42k", + "secretKey": "VkkV0FEyTihSxDDyUkkV0GG0VllV0Ril", + "bucket": "znyc-images-1306377152", "region": "ap-guangzhou", "allowPrefix": "a.jpg", "durationSeconds": 1800, diff --git a/src/Znyc.Dispatching.Web.Entry/appsettings.Staging.json b/src/Znyc.Dispatching.Web.Entry/appsettings.Staging.json index 4737a10..de08448 100644 --- a/src/Znyc.Dispatching.Web.Entry/appsettings.Staging.json +++ b/src/Znyc.Dispatching.Web.Entry/appsettings.Staging.json @@ -41,13 +41,13 @@ "secretId": "AKIDGSN2VjJkZ7pIYzcdo0zjDCKCnQpEhXbW", "secretKey": "rQDI7fuoUyIEvLT5RWKqkUyGQJwBiU2P", - "bucket": "znyc-images-1304677865", + "bucket": "znyc-images-1306377152", "region": "ap-guangzhou" }, "UploadInfo": { - "secretId": "AKIDGMBk7D3cuvf8KFtGMBj00iALFsEJ7dsq", - "secretKey": "i9IBn8Bzav0pMcbJkunPjmY3HsCF2Zom", - "bucket": "znyc-images-1304677865", + "secretId": "AKID61h8KHyQcaJmBMHxNXS7XhcHgqmSt42k", + "secretKey": "VkkV0FEyTihSxDDyUkkV0GG0VllV0Ril", + "bucket": "znyc-images-1306377152", "region": "ap-guangzhou", "allowPrefix": "a.jpg", "durationSeconds": 1800, diff --git a/src/Znyc.Dispatching.Web.Entry/uploads/5d08560acd3f40ca8d0f9e78f93aa3c4.jpg b/src/Znyc.Dispatching.Web.Entry/uploads/5d08560acd3f40ca8d0f9e78f93aa3c4.jpg new file mode 100644 index 0000000..92fef17 Binary files /dev/null and b/src/Znyc.Dispatching.Web.Entry/uploads/5d08560acd3f40ca8d0f9e78f93aa3c4.jpg differ diff --git a/src/Znyc.Dispatching.Web.Entry/uploads/ab0a9f5afa004acdb131272365034116.jpg b/src/Znyc.Dispatching.Web.Entry/uploads/ab0a9f5afa004acdb131272365034116.jpg new file mode 100644 index 0000000..e98a77e Binary files /dev/null and b/src/Znyc.Dispatching.Web.Entry/uploads/ab0a9f5afa004acdb131272365034116.jpg differ diff --git a/src/Znyc.Dispatching.Web.Entry/uploads/ae0db7de904147c3adf14ec115393001.jpg b/src/Znyc.Dispatching.Web.Entry/uploads/ae0db7de904147c3adf14ec115393001.jpg new file mode 100644 index 0000000..0a875dc Binary files /dev/null and b/src/Znyc.Dispatching.Web.Entry/uploads/ae0db7de904147c3adf14ec115393001.jpg differ diff --git a/src/Znyc.Dispatching.Web.Entry/uploads/d97a1d59ea924e1cbfaf9ad6ac8f74c1.jpg b/src/Znyc.Dispatching.Web.Entry/uploads/d97a1d59ea924e1cbfaf9ad6ac8f74c1.jpg new file mode 100644 index 0000000..3098623 Binary files /dev/null and b/src/Znyc.Dispatching.Web.Entry/uploads/d97a1d59ea924e1cbfaf9ad6ac8f74c1.jpg differ diff --git a/src/Znyc.Dispatching.Web.Entry/uploads/dfa71c78e3324bad8d6d5ee8cb0944fc.jpg b/src/Znyc.Dispatching.Web.Entry/uploads/dfa71c78e3324bad8d6d5ee8cb0944fc.jpg new file mode 100644 index 0000000..3b528ea Binary files /dev/null and b/src/Znyc.Dispatching.Web.Entry/uploads/dfa71c78e3324bad8d6d5ee8cb0944fc.jpg differ diff --git a/src/msyh.ttc b/src/msyh.ttc new file mode 100644 index 0000000..37c28de Binary files /dev/null and b/src/msyh.ttc differ diff --git a/src/msyhbd.ttc b/src/msyhbd.ttc new file mode 100644 index 0000000..7949a5f Binary files /dev/null and b/src/msyhbd.ttc differ diff --git a/src/msyhl.ttc b/src/msyhl.ttc new file mode 100644 index 0000000..448e2ed Binary files /dev/null and b/src/msyhl.ttc differ