12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using Newtonsoft.Json;
- using Quartz;
- using Ropin.Inspection.Common.Helper;
- using Ropin.Inspection.Model.SearchModel;
- using Ropin.Inspection.Model.ViewModel;
- using Ropin.Inspection.Service.Interface;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Ropin.Inspection.Tasks.QuartzNet.Jobs
- {
- public class Job_InspectionWorkOrder_Quartz : JobBase, IJob
- {
- private readonly ITispRecordItemService _tispRecordItemService;
- private readonly IReportService _reportService;
- private readonly ITispContentGroupService _tispContentGroupService;
- public Job_InspectionWorkOrder_Quartz(ITispRecordItemService tispRecordItemService, IReportService reportService, ITasksQzServices tasksQzServices, ITispContentGroupService tispContentGroupService)
- {
- _tispRecordItemService = tispRecordItemService;
- _tasksQzServices = tasksQzServices;
- _reportService = reportService;
- _tispContentGroupService = tispContentGroupService;
- }
- public async Task Execute(IJobExecutionContext context)
- {
- var executeLog = await ExecuteJob(context, async () => await Run(context));
- }
- public async Task Run(IJobExecutionContext context)
- {
- JobDataMap data = context.JobDetail.JobDataMap;
- string storeCode = data.GetString("JobParam");
- DateTime beginDate;//=Convert.ToDateTime("2025-02-07 00:00:00");
- DateTime endDate;//=Convert.ToDateTime("2025-03-20 00:00:00");
- DateHelper.GetPeriod(DateHelper.Period.Week, out beginDate, out endDate);
- TispContentGroupsSearchModel searchModel = new TispContentGroupsSearchModel();
- searchModel.C_StoreCode = storeCode;
- var list = await _tispContentGroupService.GetContentGroupsAsync(searchModel);
- if (list!=null)
- {
- var rows = list.GroupBy(item =>new { item.C_DevStoreCode,item.C_DevName }).ToList();
- foreach (var item in rows)
- {
- if (item!=null)
- {
- var l = await _tispRecordItemService.GetInspectionWorkOrderAsync(beginDate, endDate, storeCode, item.Key.C_DevStoreCode);
- ReportViewModel reportViewModel = new ReportViewModel
- {
- G_ID = Guid.NewGuid(),
- C_StoreCode = storeCode,
- C_DevStoreCode = item.Key.C_DevStoreCode,
- I_Type = 5,
- C_GroupName = "点检工单记录",
- C_Name = item.Key.C_DevName + "点检工单记录" + "(" + DateTime.Now.AddDays(1).ToString("yyyy/MM/dd HH:mm") + ")",
- C_Status = "1",
- D_CreateTime = DateTime.Parse(DateTime.Now.AddDays(1).ToString("yyyy/MM/dd HH:mm")),
- D_Start = beginDate,
- D_End = endDate,
- C_Data = JsonConvert.SerializeObject(l)
- };
- await _reportService.CreateOneAsync(reportViewModel);
- }
- }
- }
- }
- }
- }
|