1
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Dynamic;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
@@ -112,5 +113,30 @@ namespace Tnb.EquipMgr
|
||||
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result.IsSuccess ? "保存成功" : result.ErrorMessage;
|
||||
}
|
||||
public async Task<dynamic> GetTools()
|
||||
{
|
||||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||||
dic.Add("26149307089941", "在库");
|
||||
dic.Add("26149309121045", "生产");
|
||||
dic.Add("26149311082005", "保养");
|
||||
dic.Add("26149314425877", "报废");
|
||||
dic.Add("26149312750101", "外协");
|
||||
dic.Add("26149320818965", "维修");
|
||||
List<dynamic> result = new();
|
||||
var ToolMolds = await _db.Queryable<ToolMolds>().ToListAsync();
|
||||
foreach (var tool in ToolMolds)
|
||||
{
|
||||
dynamic info = new ExpandoObject();
|
||||
info.mold_code=tool.mold_code;
|
||||
info.mold_name = tool.mold_name;
|
||||
info.mold_status= dic.Where(p=>p.Key==tool.mold_status).Any()? dic.Where(p => p.Key == tool.mold_status).First().Value:"";
|
||||
info.warehosue_id=tool.warehosue_id;
|
||||
info.location_id=tool.location_id;
|
||||
|
||||
result.Add(info);
|
||||
}
|
||||
|
||||
return ToolMolds;
|
||||
}
|
||||
}
|
||||
}
|
||||
38
QcMgr/Tnb.QcMgr.Entities/Dto/CheckTaskData.cs
Normal file
38
QcMgr/Tnb.QcMgr.Entities/Dto/CheckTaskData.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.QcMgr.Entities
|
||||
{
|
||||
public class CheckTaskData
|
||||
{
|
||||
public string? checktype { get; set; }
|
||||
|
||||
public string? materialid { get; set; }
|
||||
public string? processid { get; set; }
|
||||
public string? workid { get; set; }
|
||||
public string? wareid { get; set; }
|
||||
public List<CheckTaskDataInput>? checktypes { get; set; }
|
||||
}
|
||||
|
||||
public class CheckTaskDataInput
|
||||
{
|
||||
public string? id { get; set; }
|
||||
public List<TaskItemInput>? items { get; set; }
|
||||
}
|
||||
public class TaskItemInput
|
||||
{
|
||||
public string? itemid { get; set; }
|
||||
public string? extype { get; set; }
|
||||
public string? excontent { get; set; }
|
||||
public string? check { get; set; }
|
||||
public string? errorcause { get; set; }
|
||||
public string? errorlevel { get; set; }
|
||||
public string? remark { get; set; }
|
||||
public string? attachment { get; set; }
|
||||
public string? isexec { get; set; }
|
||||
public string? customer { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,7 @@ namespace Tnb.QcMgr
|
||||
CheckPlansOut.addid = QcCheckPlanAdd.id;
|
||||
CheckPlansOut.triggertype = QcCheckPlanAdd.triggertype!;
|
||||
CheckPlansOut.content = QcCheckPlanAdd.content!;
|
||||
CheckPlansOut.number= QcCheckPlanAdd.number;
|
||||
CheckPlansOut.number = QcCheckPlanAdd.number;
|
||||
}
|
||||
if (QcCheckPlanDs != null && QcCheckPlanDs.Count > 0)
|
||||
{
|
||||
@@ -137,7 +137,18 @@ namespace Tnb.QcMgr
|
||||
Item.setShow.remark = !string.IsNullOrEmpty(Item.setData.remark);
|
||||
Item.setShow.attachment = !string.IsNullOrEmpty(Item.setData.attachment);
|
||||
Item.setShow.customer = !string.IsNullOrEmpty(Item.setData.customer);
|
||||
Item.setShow.isexec = Item.setData.isexec == null ? false : true;
|
||||
if (Item.setData.isexec == null)
|
||||
{
|
||||
Item.setShow.isexec = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!Item.setData.isexec.attachment&& !Item.setData.isexec.remark)
|
||||
Item.setShow.isexec = false;
|
||||
else
|
||||
Item.setShow.isexec = true;
|
||||
}
|
||||
|
||||
CheckPlansOut.checktypes.Where(p => p.checktypeid == QcCheckPlanD.typeid).First()?.items?.Add(Item);
|
||||
}
|
||||
}
|
||||
@@ -187,6 +198,7 @@ namespace Tnb.QcMgr
|
||||
{
|
||||
if (string.IsNullOrEmpty(CheckPlanInput.mainid))
|
||||
return;
|
||||
await _timeTaskService.DeleteByName("生成质检任务" + CheckPlanInput.mainid);
|
||||
await db.Deleteable<QcCheckPlanD>(p => p.mainid == CheckPlanInput.mainid).ExecuteCommandAsync();
|
||||
await db.Deleteable<QcCheckPlanAdd>(p => p.mainid == CheckPlanInput.mainid).ExecuteCommandAsync();
|
||||
QcCheckPlanAdd QcCheckPlanAdd = new QcCheckPlanAdd();
|
||||
@@ -280,10 +292,47 @@ namespace Tnb.QcMgr
|
||||
JoinType.Left,a.id == e.planid,
|
||||
});
|
||||
GetQuery(Query, entity);
|
||||
var list = await Query
|
||||
.WhereIF(!string.IsNullOrEmpty(entity.materialid), (a, b, c, d, e) => c.materialid == entity.materialid)
|
||||
.WhereIF(!string.IsNullOrEmpty(entity.processid), (a, b, c, d, e) => d.processid == entity.processid)
|
||||
.WhereIF(!string.IsNullOrEmpty(entity.workid), (a, b, c, d, e) => e.workid == entity.workid).ToListAsync();
|
||||
var list = await Query.ToListAsync();
|
||||
List<string> removes = new List<string>();
|
||||
foreach (var data in list)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(entity.materialid))
|
||||
{
|
||||
if (_repository.AsSugarClient().Queryable<QcCheckPlanMaterial>().Where(p => p.planid == data.id).Any())
|
||||
{
|
||||
if (!_repository.AsSugarClient().Queryable<QcCheckPlanMaterial>().Where(p => p.planid == data.id && p.materialid == entity.materialid).Any())
|
||||
{
|
||||
removes.Add(data.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(entity.processid))
|
||||
{
|
||||
if (_repository.AsSugarClient().Queryable<QcCheckPlanProcess>().Where(p => p.planid == data.id).Any())
|
||||
{
|
||||
if (!_repository.AsSugarClient().Queryable<QcCheckPlanProcess>().Where(p => p.planid == data.id && p.processid == entity.processid).Any())
|
||||
{
|
||||
removes.Add(data.id);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(entity.workid))
|
||||
{
|
||||
if (_repository.AsSugarClient().Queryable<QcCheckPlanWork>().Where(p => p.planid == data.id).Any())
|
||||
{
|
||||
if (!_repository.AsSugarClient().Queryable<QcCheckPlanWork>().Where(p => p.planid == data.id && p.workid == entity.workid).Any())
|
||||
{
|
||||
removes.Add(data.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list = list.Where(p => !removes.Contains(p.id)).ToList();
|
||||
// .WhereIF(!string.IsNullOrEmpty(entity.materialid), (a, b, c, d, e) => c.materialid == entity.materialid)
|
||||
// .WhereIF(!string.IsNullOrEmpty(entity.processid), (a, b, c, d, e) => d.processid == entity.processid)
|
||||
// .WhereIF(!string.IsNullOrEmpty(entity.workid), (a, b, c, d, e) => e.workid == entity.workid).ToListAsync();
|
||||
Filter(list, entity);
|
||||
if (list.Count > 0)
|
||||
await SaveTask(list, entity);
|
||||
@@ -410,5 +459,6 @@ namespace Tnb.QcMgr
|
||||
await _repository.AsSugarClient().Insertable(ExecDs).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,12 @@ namespace Tnb.QcMgr
|
||||
private async Task<dynamic> GetListAsync(VisualDevModelListQueryInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
Dictionary<string,string> dic= new Dictionary<string,string>();
|
||||
dic.Add("ok", "合格");
|
||||
dic.Add("no", "不合格");
|
||||
dic.Add("barelyok", "让步合格");
|
||||
dic.Add("await", "待检");
|
||||
dic.Add("temporarily", "暂控");
|
||||
Dictionary<string, string> queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
|
||||
string materialid = queryJson.ContainsKey("materialid") ? queryJson["materialid"].ToString() : "";
|
||||
string checktype = queryJson.ContainsKey("checktype") ? queryJson["checktype"].ToString() : "";
|
||||
@@ -47,6 +53,7 @@ namespace Tnb.QcMgr
|
||||
var list = await db.Queryable<DictionaryDataEntity>()
|
||||
.LeftJoin<DictionaryTypeEntity>((a, b) => a.DictionaryTypeId == b.Id)
|
||||
.Where((a, b) => b.FullName == "质检状态" || b.FullName == "质检类型选择").ToListAsync();
|
||||
var BasLocations= await db.Queryable<BasLocation>().ToListAsync();
|
||||
var result = await db.Queryable<QcCheckExecH>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.materialid == b.id)
|
||||
.LeftJoin<BasProcess>((a, b, c) => a.processid == c.id)
|
||||
@@ -70,11 +77,13 @@ namespace Tnb.QcMgr
|
||||
tasktime = a.tasktime == null ? "" : a.tasktime,
|
||||
exectime = a.exectime == null ? "" : a.exectime,
|
||||
execuser = e.RealName == null ? "" : e.RealName,
|
||||
}).OrderByDescending(a => a.tasktime).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
}).OrderByDescending(a =>DateTime.Parse( a.exectime)).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
foreach (var item in result.list)
|
||||
{
|
||||
item.checktype = list.Select(p => p.Id).Contains(item.checktype) ? list.Where(p => p.Id == item.checktype).First().FullName : "";
|
||||
item.status = list.Select(p => p.Id).Contains(item.status) ? list.Where(p => p.Id == item.status).First().FullName : "";
|
||||
item.result = dic.Where(p => p.Key == item.result).Any() ? dic.Where(p => p.Key == item.result).First().Value : "";
|
||||
item.wareid = BasLocations.Where(p => p.id == item.wareid).Any() ? BasLocations.Where(p => p.id == item.wareid).First().location_code: "";
|
||||
}
|
||||
return PageResult<QcCheckExecHOut>.SqlSugarPageResult(result);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ using Tnb.QcMgr.Entities;
|
||||
using Tnb.QcMgr.Entities.Entity;
|
||||
using Tnb.QcMgr.Interfaces;
|
||||
using JNPF.Common.Extension;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace Tnb.QcMgr
|
||||
{
|
||||
@@ -56,6 +57,12 @@ namespace Tnb.QcMgr
|
||||
private async Task<dynamic> GetListAsync(VisualDevModelListQueryInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||||
dic.Add("ok", "合格");
|
||||
dic.Add("no", "不合格");
|
||||
dic.Add("barelyok", "让步合格");
|
||||
dic.Add("await", "待检");
|
||||
dic.Add("temporarily", "暂控");
|
||||
Dictionary<string, string> queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
|
||||
string materialid = queryJson.ContainsKey("materialid") ? queryJson["materialid"].ToString() : "";
|
||||
string checktype = queryJson.ContainsKey("checktype") ? queryJson["checktype"].ToString() : "";
|
||||
@@ -63,6 +70,7 @@ namespace Tnb.QcMgr
|
||||
var list = await db.Queryable<DictionaryDataEntity>()
|
||||
.LeftJoin<DictionaryTypeEntity>((a, b) => a.DictionaryTypeId == b.Id)
|
||||
.Where((a, b) => b.FullName == "质检状态" || b.FullName == "质检类型选择").ToListAsync();
|
||||
var BasLocations = await db.Queryable<BasLocation>().ToListAsync();
|
||||
var result = await db.Queryable<QcCheckExecH>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.materialid == b.id)
|
||||
.LeftJoin<BasProcess>((a, b, c) => a.processid == c.id)
|
||||
@@ -86,11 +94,13 @@ namespace Tnb.QcMgr
|
||||
tasktime = a.tasktime == null ? "" : a.tasktime,
|
||||
exectime = a.exectime == null ? "" : a.exectime,
|
||||
execuser = e.RealName == null ? "" : e.RealName,
|
||||
}).OrderByDescending(a => a.tasktime).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
}).OrderByDescending(a => DateTime.Parse(a.tasktime)).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
foreach (var item in result.list)
|
||||
{
|
||||
item.checktype = list.Select(p => p.Id).Contains(item.checktype) ? list.Where(p => p.Id == item.checktype).First().FullName : "";
|
||||
item.status = list.Select(p => p.Id).Contains(item.status) ? list.Where(p => p.Id == item.status).First().FullName : "";
|
||||
item.result = dic.Where(p => p.Key == item.result).Any() ? dic.Where(p => p.Key == item.result).First().Value : "";
|
||||
item.wareid = BasLocations.Where(p => p.id == item.wareid).Any() ? BasLocations.Where(p => p.id == item.wareid).First().location_code : "";
|
||||
}
|
||||
return PageResult<QcCheckExecHOut>.SqlSugarPageResult(result);
|
||||
}
|
||||
@@ -164,8 +174,8 @@ namespace Tnb.QcMgr
|
||||
Item.setShow.extype = !string.IsNullOrEmpty(Item.setData.extype);
|
||||
Item.setShow.excontent = !string.IsNullOrEmpty(QcCheckExecD.excontent);
|
||||
Item.setShow.check = !string.IsNullOrEmpty(Item.setData.check);
|
||||
Item.setShow.errorcause = Item.setData.errorcause?.Count == 0 ? false : true;
|
||||
Item.setShow.errorlevel = Item.setData.errorlevel?.Count == 0 ? false : true;
|
||||
Item.setShow.errorcause = Item.setData.errorcause==null|| Item.setData.errorcause?.Count == 0 ? false : true;
|
||||
Item.setShow.errorlevel = Item.setData.errorlevel == null || Item.setData.errorlevel?.Count == 0 ? false : true;
|
||||
Item.setShow.remark = !string.IsNullOrEmpty(Item.setData.remark);
|
||||
Item.setShow.attachment = !string.IsNullOrEmpty(Item.setData.attachment);
|
||||
Item.setShow.customer = !string.IsNullOrEmpty(Item.setData.customer);
|
||||
@@ -209,6 +219,8 @@ namespace Tnb.QcMgr
|
||||
{
|
||||
foreach (var item in exextype.items)
|
||||
{
|
||||
if (item.postItemForm == null)
|
||||
throw Oops.Oh("执行失败");
|
||||
var QcCheckExecD = QcCheckExecDs.Where(p => p.id == item.itemdid).FirstOrDefault();
|
||||
if (QcCheckExecD == null)
|
||||
continue;
|
||||
@@ -229,7 +241,7 @@ namespace Tnb.QcMgr
|
||||
insert.itemid = QcCheckExecD.itemid;
|
||||
insert.create_id = QcCheckExecD.create_id;
|
||||
insert.create_time = QcCheckExecD.create_time;
|
||||
insert.postdata = item.postItemForm;
|
||||
insert.postdata =
|
||||
insert.result = item.result;
|
||||
insert.checkindex = (i + 1).ToString();
|
||||
QcCheckExecDinsert.Add(insert);
|
||||
@@ -247,8 +259,7 @@ namespace Tnb.QcMgr
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
throw Oops.Oh(ErrorCode.COM1000);
|
||||
throw Oops.Oh("执行失败");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,6 +350,59 @@ namespace Tnb.QcMgr
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task CreateTaskData(CheckTaskData checkTaskData)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var DictionaryType = await db.Queryable<DictionaryTypeEntity>().Where(p => p.FullName == "质检状态").FirstAsync();
|
||||
var DictionaryData = await db.Queryable<DictionaryDataEntity>().Where(p => p.DictionaryTypeId == DictionaryType.Id && p.FullName == "待执行").FirstAsync();
|
||||
QcCheckExecH QcCheckExecH = new QcCheckExecH();
|
||||
QcCheckExecH.checktype = checkTaskData.checktype;
|
||||
QcCheckExecH.materialid = checkTaskData.materialid;
|
||||
QcCheckExecH.processid = checkTaskData.processid;
|
||||
QcCheckExecH.workid = checkTaskData.workid;
|
||||
QcCheckExecH.wareid = checkTaskData.wareid;
|
||||
QcCheckExecH.status = DictionaryData.Id;
|
||||
QcCheckExecH.tasktime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
QcCheckExecH.create_id = _userManager.UserId;
|
||||
QcCheckExecH.create_time = DateTime.Now;
|
||||
List<QcCheckExecD> QcCheckExecDs = new List<QcCheckExecD>();
|
||||
if (checkTaskData.checktypes != null)
|
||||
{
|
||||
foreach (var checktype in checkTaskData.checktypes)
|
||||
{
|
||||
if (checktype.items != null)
|
||||
{
|
||||
foreach (var item in checktype.items)
|
||||
{
|
||||
QcCheckExecD QcCheckExecD = new QcCheckExecD();
|
||||
QcCheckExecD.mainid = QcCheckExecH.id;
|
||||
QcCheckExecD.typeid = checktype.id;
|
||||
QcCheckExecD.itemid = item.itemid;
|
||||
QcCheckExecD.extype = item.extype;
|
||||
QcCheckExecD.excontent = item.excontent;
|
||||
QcCheckExecD.check = item.check;
|
||||
QcCheckExecD.errorcause = item.errorcause?.Replace("\"", "").Trim();
|
||||
QcCheckExecD.errorlevel = item.errorlevel?.Replace("\"", "").Trim();
|
||||
QcCheckExecD.remark = item.remark;
|
||||
QcCheckExecD.attachment = item.attachment;
|
||||
QcCheckExecD.isexec = item.isexec;
|
||||
QcCheckExecD.custom = item.customer;
|
||||
QcCheckExecD.create_id = _userManager.UserId;
|
||||
QcCheckExecD.create_time = DateTime.Now;
|
||||
QcCheckExecDs.Add(QcCheckExecD);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
await db.Ado.BeginTranAsync();
|
||||
await db.Insertable(QcCheckExecH).ExecuteCommandAsync();
|
||||
await db.Insertable(QcCheckExecDs).ExecuteCommandAsync();
|
||||
await db.Ado.CommitTranAsync();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,5 +16,5 @@ public interface ITimeTaskService
|
||||
/// </summary>
|
||||
void StartTimerJob();
|
||||
|
||||
List<TimeTaskEntity> GetTasks();
|
||||
Task<List<TimeTaskEntity>> GetTasks();
|
||||
}
|
||||
|
||||
@@ -26,15 +26,16 @@ namespace Tnb.TaskScheduler.Listener
|
||||
{
|
||||
try
|
||||
{
|
||||
var TimeTasks = timeTaskService.GetTasks();
|
||||
var timeTaskEntity = TimeTasks.Where(p => p.Id == timer.WorkerName && p.EnabledMark == 1).First();
|
||||
var TimeTasks =await timeTaskService.GetTasks();
|
||||
var timeTaskEntity = TimeTasks.Where(p => p.Id == timer.WorkerName && p.EnabledMark == 1).FirstOrDefault();
|
||||
if (timeTaskEntity == null)
|
||||
return;
|
||||
ContentModel? comtentModel = timeTaskEntity.ExecuteContent.ToObject<ContentModel>();
|
||||
var ToolMoldMaintainRule = await repository.AsSugarClient().Queryable<ToolMoldMaintainRule>().Where(p => p.id == comtentModel.parameter.Where(p => p.field == "id").First().value).FirstAsync();
|
||||
var client = repository.CopyNew();
|
||||
var ToolMoldMaintainRule = await client.Queryable<ToolMoldMaintainRule>().Where(p => p.id == comtentModel.parameter.Where(p => p.field == "id").First().value).FirstAsync();
|
||||
if (ToolMoldMaintainRule == null)
|
||||
return;
|
||||
var ToolMoldMaintainRuleRelations= await repository.AsSugarClient().Queryable<ToolMoldMaintainRuleRelation>().Where(p => p.rule_id == ToolMoldMaintainRule.id).ToListAsync();
|
||||
var ToolMoldMaintainRuleRelations= await client.Queryable<ToolMoldMaintainRuleRelation>().Where(p => p.rule_id == ToolMoldMaintainRule.id).ToListAsync();
|
||||
if (ToolMoldMaintainRuleRelations.Count() > 0)
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
@@ -58,8 +59,8 @@ namespace Tnb.TaskScheduler.Listener
|
||||
toolMoldMaintainPlanRelation.group_id = ToolMoldMaintainRuleRelation.item_group_id;
|
||||
toolMoldMaintainPlanRelations.Add(toolMoldMaintainPlanRelation);
|
||||
}
|
||||
await repository.AsSugarClient().Insertable(toolMoldMaintainPlanRelations).ExecuteCommandAsync();
|
||||
await repository.AsSugarClient().Insertable(toolMoldMaintainPlan).ExecuteCommandAsync();
|
||||
await client.Insertable(toolMoldMaintainPlanRelations).ExecuteCommandAsync();
|
||||
await client.Insertable(toolMoldMaintainPlan).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aop.Api.Domain;
|
||||
using JNPF;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
@@ -32,71 +33,120 @@ namespace Tnb.TaskScheduler.Listener
|
||||
{
|
||||
try
|
||||
{
|
||||
var TimeTasks = timeTaskService.GetTasks();
|
||||
var timeTaskEntity = TimeTasks.Where(p => p.Id == timer.WorkerName && p.EnabledMark == 1).First();
|
||||
var TimeTasks =await timeTaskService.GetTasks();
|
||||
var timeTaskEntity = TimeTasks.Where(p => p.Id == timer.WorkerName && p.EnabledMark == 1).FirstOrDefault();
|
||||
if (timeTaskEntity == null)
|
||||
return;
|
||||
ContentModel? comtentModel = timeTaskEntity.ExecuteContent.ToObject<ContentModel>();
|
||||
var PlanH = await repository.AsSugarClient().Queryable<QcCheckPlanH>().Where(p => p.id == comtentModel.parameter.Where(p => p.field == "id").First().value).FirstAsync();
|
||||
var PlanDs = await repository.AsSugarClient().Queryable<QcCheckPlanD>().Where(p => p.mainid == PlanH.id).ToListAsync();
|
||||
var client= repository.CopyNew();
|
||||
var PlanH = await client.Queryable<QcCheckPlanH>().Where(p => p.id == comtentModel.parameter.Where(p => p.field == "id").First().value).FirstAsync();
|
||||
var PlanDs = await client.Queryable<QcCheckPlanD>().Where(p => p.mainid == PlanH.id).ToListAsync();
|
||||
if (PlanH == null || PlanDs.Count == 0)
|
||||
return;
|
||||
var PlanMaterials = repository.AsSugarClient().Queryable<QcCheckPlanMaterial>().Where(p => p.planid == PlanH.id).Select(p => p.materialid).ToList();
|
||||
var PlanProcesss = repository.AsSugarClient().Queryable<QcCheckPlanProcess>().Where(p => p.planid == PlanH.id).Select(p => p.processid).ToList();
|
||||
var PlanWork = repository.AsSugarClient().Queryable<QcCheckPlanWork>().Where(p => p.planid == PlanH.id).Select(p => p.workid).ToList();
|
||||
//物料工序工位不能同时为空
|
||||
if (PlanMaterials.Count == 0 && PlanProcesss.Count == 0 && PlanWork.Count == 0)
|
||||
return;
|
||||
var PrdMoTasks = await repository.AsSugarClient().Queryable<PrdMoTask>()
|
||||
.WhereIF(PlanMaterials.Count > 0, p => PlanMaterials.Contains(p.material_id))
|
||||
.WhereIF(PlanProcesss.Count > 0, p => PlanProcesss.Contains(p.process_id))
|
||||
.WhereIF(PlanWork.Count > 0, p => PlanWork.Contains(p.workstation_id))
|
||||
.Where(p => p.mo_task_status == "InProgress")//进行中
|
||||
.ToListAsync();
|
||||
|
||||
var DictionaryType = await repository.AsSugarClient().Queryable<DictionaryTypeEntity>().Where(p => p.FullName == "质检状态").FirstAsync();
|
||||
var DictionaryData = await repository.AsSugarClient().Queryable<DictionaryDataEntity>().Where(p => p.DictionaryTypeId == DictionaryType.Id && p.FullName == "待执行").FirstAsync();
|
||||
var time = DateTime.Now;
|
||||
foreach (var PrdMoTask in PrdMoTasks)
|
||||
List<string> strs = new List<string>();
|
||||
strs.Add("26589795199765");//首检
|
||||
strs.Add("26589835919125");//生产检
|
||||
strs.Add("26590141686549");//巡检
|
||||
if (strs.Contains(PlanH.checktype))
|
||||
{
|
||||
var PlanMaterials = await client.Queryable<QcCheckPlanMaterial>().Where(p => p.planid == PlanH.id).Select(p => p.materialid).ToListAsync();
|
||||
var PlanProcesss = await client.Queryable<QcCheckPlanProcess>().Where(p => p.planid == PlanH.id).Select(p => p.processid).ToListAsync();
|
||||
var PlanWork = await client.Queryable<QcCheckPlanWork>().Where(p => p.planid == PlanH.id).Select(p => p.workid).ToListAsync();
|
||||
//物料工序工位不能同时为空
|
||||
if (PlanMaterials.Count == 0 && PlanProcesss.Count == 0 && PlanWork.Count == 0)
|
||||
return;
|
||||
var PrdMoTasks = await client.Queryable<PrdMoTask>()
|
||||
.WhereIF(PlanMaterials.Count > 0, p => PlanMaterials.Contains(p.material_id))
|
||||
.WhereIF(PlanProcesss.Count > 0, p => PlanProcesss.Contains(p.process_id))
|
||||
.WhereIF(PlanWork.Count > 0, p => PlanWork.Contains(p.workstation_id))
|
||||
.Where(p => p.mo_task_status == "InProgress")//进行中
|
||||
.ToListAsync();
|
||||
|
||||
QcCheckExecH qcCheckExecH = new QcCheckExecH();
|
||||
qcCheckExecH.id = SnowflakeIdHelper.NextId();
|
||||
qcCheckExecH.checktype = PlanH.checktype;
|
||||
qcCheckExecH.status = DictionaryData.Id;
|
||||
qcCheckExecH.tasktime = time.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
qcCheckExecH.materialid = PrdMoTask.material_id;
|
||||
qcCheckExecH.processid = PrdMoTask.process_id;
|
||||
qcCheckExecH.workid = PrdMoTask.workstation_id;
|
||||
qcCheckExecH.create_time = time;
|
||||
var ExecDs = new List<QcCheckExecD>();
|
||||
foreach (var PlanD in PlanDs)
|
||||
var DictionaryType = await client.Queryable<DictionaryTypeEntity>().Where(p => p.FullName == "质检状态").FirstAsync();
|
||||
var DictionaryData = await client.Queryable<DictionaryDataEntity>().Where(p => p.DictionaryTypeId == DictionaryType.Id && p.FullName == "待执行").FirstAsync();
|
||||
var time = DateTime.Now;
|
||||
foreach (var PrdMoTask in PrdMoTasks)
|
||||
{
|
||||
QcCheckExecD QcCheckExecD = new QcCheckExecD();
|
||||
QcCheckExecD.mainid = qcCheckExecH.id;
|
||||
QcCheckExecD.extype = PlanD.extype;
|
||||
QcCheckExecD.excontent = PlanD.excontent;
|
||||
QcCheckExecD.check = PlanD.check;
|
||||
QcCheckExecD.errorcause = PlanD.errorcause;
|
||||
QcCheckExecD.errorlevel = PlanD.errorlevel;
|
||||
QcCheckExecD.remark = PlanD.remark;
|
||||
QcCheckExecD.attachment = PlanD.attachment;
|
||||
QcCheckExecD.isexec = PlanD.isexec;
|
||||
QcCheckExecD.custom = PlanD.custom;
|
||||
QcCheckExecD.typeid = PlanD.typeid;
|
||||
QcCheckExecD.itemid = PlanD.itemid;
|
||||
QcCheckExecD.create_time = time;
|
||||
ExecDs.Add(QcCheckExecD);
|
||||
|
||||
QcCheckExecH qcCheckExecH = new QcCheckExecH();
|
||||
qcCheckExecH.id = SnowflakeIdHelper.NextId();
|
||||
qcCheckExecH.checktype = PlanH.checktype;
|
||||
qcCheckExecH.status = DictionaryData.Id;
|
||||
qcCheckExecH.tasktime = time.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
qcCheckExecH.materialid = PrdMoTask.material_id;
|
||||
qcCheckExecH.processid = PrdMoTask.process_id;
|
||||
qcCheckExecH.workid = PrdMoTask.workstation_id;
|
||||
qcCheckExecH.create_time = time;
|
||||
var ExecDs = new List<QcCheckExecD>();
|
||||
foreach (var PlanD in PlanDs)
|
||||
{
|
||||
QcCheckExecD QcCheckExecD = new QcCheckExecD();
|
||||
QcCheckExecD.mainid = qcCheckExecH.id;
|
||||
QcCheckExecD.extype = PlanD.extype;
|
||||
QcCheckExecD.excontent = PlanD.excontent;
|
||||
QcCheckExecD.check = PlanD.check;
|
||||
QcCheckExecD.errorcause = PlanD.errorcause;
|
||||
QcCheckExecD.errorlevel = PlanD.errorlevel;
|
||||
QcCheckExecD.remark = PlanD.remark;
|
||||
QcCheckExecD.attachment = PlanD.attachment;
|
||||
QcCheckExecD.isexec = PlanD.isexec;
|
||||
QcCheckExecD.custom = PlanD.custom;
|
||||
QcCheckExecD.typeid = PlanD.typeid;
|
||||
QcCheckExecD.itemid = PlanD.itemid;
|
||||
QcCheckExecD.create_time = time;
|
||||
ExecDs.Add(QcCheckExecD);
|
||||
}
|
||||
await client.Insertable(qcCheckExecH).ExecuteCommandAsync();
|
||||
await client.Insertable(ExecDs).ExecuteCommandAsync();
|
||||
}
|
||||
await repository.AsSugarClient().Insertable(qcCheckExecH).ExecuteCommandAsync();
|
||||
await repository.AsSugarClient().Insertable(ExecDs).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
var PlanMaterials = await client.Queryable<QcCheckPlanMaterial>().Where(p => p.planid == PlanH.id).Select(p => p.materialid).ToListAsync();
|
||||
var DictionaryType = await client.Queryable<DictionaryTypeEntity>().Where(p => p.FullName == "质检状态").FirstAsync();
|
||||
var DictionaryData = await client.Queryable<DictionaryDataEntity>().Where(p => p.DictionaryTypeId == DictionaryType.Id && p.FullName == "待执行").FirstAsync();
|
||||
var time = DateTime.Now;
|
||||
foreach (var Material in PlanMaterials)
|
||||
{
|
||||
QcCheckExecH qcCheckExecH = new QcCheckExecH();
|
||||
qcCheckExecH.id = SnowflakeIdHelper.NextId();
|
||||
qcCheckExecH.checktype = PlanH.checktype;
|
||||
qcCheckExecH.status = DictionaryData.Id;
|
||||
qcCheckExecH.tasktime = time.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
qcCheckExecH.materialid = Material;
|
||||
qcCheckExecH.processid = "";
|
||||
qcCheckExecH.workid = "";
|
||||
qcCheckExecH.create_time = time;
|
||||
var ExecDs = new List<QcCheckExecD>();
|
||||
foreach (var PlanD in PlanDs)
|
||||
{
|
||||
QcCheckExecD QcCheckExecD = new QcCheckExecD();
|
||||
QcCheckExecD.mainid = qcCheckExecH.id;
|
||||
QcCheckExecD.extype = PlanD.extype;
|
||||
QcCheckExecD.excontent = PlanD.excontent;
|
||||
QcCheckExecD.check = PlanD.check;
|
||||
QcCheckExecD.errorcause = PlanD.errorcause;
|
||||
QcCheckExecD.errorlevel = PlanD.errorlevel;
|
||||
QcCheckExecD.remark = PlanD.remark;
|
||||
QcCheckExecD.attachment = PlanD.attachment;
|
||||
QcCheckExecD.isexec = PlanD.isexec;
|
||||
QcCheckExecD.custom = PlanD.custom;
|
||||
QcCheckExecD.typeid = PlanD.typeid;
|
||||
QcCheckExecD.itemid = PlanD.itemid;
|
||||
QcCheckExecD.create_time = time;
|
||||
ExecDs.Add(QcCheckExecD);
|
||||
}
|
||||
await client.Insertable(qcCheckExecH).ExecuteCommandAsync();
|
||||
await client.Insertable(ExecDs).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
}
|
||||
//只执行一次的 修改EnabledMark字段
|
||||
var InterfaceParameter = comtentModel.parameter.Where(p => p.field == "doonce").FirstOrDefault();
|
||||
if (InterfaceParameter != null && bool.Parse(InterfaceParameter.value))
|
||||
{
|
||||
timeTaskEntity.EnabledMark = 0;
|
||||
await repository.AsSugarClient().Updateable(timeTaskEntity).ExecuteCommandAsync();
|
||||
await client.Updateable(timeTaskEntity).ExecuteCommandAsync();
|
||||
SpareTime.Cancel(timeTaskEntity.Id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,9 +136,9 @@ public class TimeTaskService : ITimeTaskService, IDynamicApiController, ITransie
|
||||
#endregion
|
||||
|
||||
#region Post
|
||||
public List<TimeTaskEntity> GetTasks()
|
||||
public async Task<List<TimeTaskEntity>> GetTasks()
|
||||
{
|
||||
var list= _repository.AsQueryable().ToList();
|
||||
var list = await _repository.CopyNew().Queryable<TimeTaskEntity>().ToListAsync();
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user