Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
27
EquipMgr/Tnb.EquipMgr.Entities/Dto/PadMainListOutput.cs
Normal file
27
EquipMgr/Tnb.EquipMgr.Entities/Dto/PadMainListOutput.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities.Dto
|
||||
{
|
||||
public class PadMainListOutput
|
||||
{
|
||||
public string plan_id { get; set; }
|
||||
public string mold_id { get; set; }
|
||||
|
||||
public string mold_code { get; set; }
|
||||
|
||||
public string mold_name { get; set; }
|
||||
|
||||
public string mold_status { get; set; }
|
||||
public string status { get; set; }
|
||||
public string createuser { get; set; }
|
||||
public string createtime { get; set; }
|
||||
public string plan_start_time { get; set; }
|
||||
public string starttime { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
20
EquipMgr/Tnb.EquipMgr.Entities/Dto/PdaMaintainInput.cs
Normal file
20
EquipMgr/Tnb.EquipMgr.Entities/Dto/PdaMaintainInput.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Common.Filter;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities.Dto
|
||||
{
|
||||
public class PdaMaintainInput : PageInputBase
|
||||
{
|
||||
public string status { get; set; }
|
||||
|
||||
public string maintain_info { get; set; }
|
||||
|
||||
public DateTime? start_time { get; set; }
|
||||
public DateTime? end_time { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -207,5 +207,10 @@ public partial class EqpEquipment : BaseEntity<string>
|
||||
/// 二维码
|
||||
/// </summary>
|
||||
public string? qrcode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 挤出件类型
|
||||
/// </summary>
|
||||
public string? tube { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Tnb.EquipMgr
|
||||
string status = queryJson.ContainsKey("status") ? (queryJson["status"].ToString() ?? "") : "";
|
||||
DateTime? start_time = queryJson.ContainsKey("start_time") ? queryJson["start_time"].ToString()=="" ? null : Convert.ToDateTime(queryJson["start_time"]) : null;
|
||||
DateTime? end_time = queryJson.ContainsKey("end_time") ? queryJson["end_time"].ToString()=="" ? null : Convert.ToDateTime(queryJson["end_time"]) : null;
|
||||
|
||||
string now = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
if (string.IsNullOrEmpty(input.sidx))
|
||||
{
|
||||
input.sidx = "a.create_time";
|
||||
@@ -80,6 +80,7 @@ namespace Tnb.EquipMgr
|
||||
.WhereIF(!string.IsNullOrEmpty(equioInfo),(a,b,c)=>b.code.Contains(equioInfo)|| b.name.Contains(equioInfo))
|
||||
.WhereIF(status=="3" && start_time!=null,a=>a.spot_record_date_time>=start_time)
|
||||
.WhereIF(status=="3" && end_time!=null,a=>a.spot_record_date_time<=end_time)
|
||||
.Where(a=>a.create_time.Value.ToString("yyyy-MM-dd")==now)
|
||||
.OrderBy($"{input.sidx} {input.sort}")
|
||||
.Select((a, b, c,d) => new EqpSpotInsRecordListOutput
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Reactive.Joins;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -12,6 +13,7 @@ using DingTalk.Api.Request;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Filter;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
@@ -62,12 +64,14 @@ namespace Tnb.EquipMgr
|
||||
List<dynamic> result = new();
|
||||
var planMoldRelations = await _db.Queryable<ToolMoldMaintainPlanRelation>()
|
||||
.LeftJoin<ToolMoldMaintainPlan>((a, b) => a.maintain_plan_id == b.id)//ToolMoldMaintainPlan
|
||||
.LeftJoin<ToolMoldMaintainRunRecord>((a, b, c) => b.plan_code == c.plan_code)
|
||||
.LeftJoin<ToolMolds>((a, b, c) => a.mold_id == c.id)
|
||||
.LeftJoin<ToolMoldMaintainRunRecord>((a, b, c,d) => d.plan_code == b.plan_code&&d.mold_code==c.mold_code)
|
||||
.Where(a => a.maintain_plan_id == planId)
|
||||
.Select((a, b, c) => new
|
||||
.Select((a, b, c,d) => new
|
||||
{
|
||||
mold_id = a.mold_id,
|
||||
plan_start_time = c.plan_start_time,
|
||||
plan_start_time = d.plan_start_time,
|
||||
designer=d.designer
|
||||
})
|
||||
.ToListAsync();
|
||||
var moldids = planMoldRelations.Select(x => x.mold_id).ToList();
|
||||
@@ -75,7 +79,7 @@ namespace Tnb.EquipMgr
|
||||
foreach (var planMoldRelation in planMoldRelations)
|
||||
|
||||
{
|
||||
var mold= molds.Where(p=>p.id== planMoldRelation.mold_id).FirstOrDefault();
|
||||
var mold = molds.Where(p => p.id == planMoldRelation.mold_id).FirstOrDefault();
|
||||
if (mold != null)
|
||||
{
|
||||
dynamic info = new ExpandoObject();
|
||||
@@ -84,6 +88,7 @@ namespace Tnb.EquipMgr
|
||||
info.mold_name = mold.mold_name;
|
||||
info.mold_status = (await _dictionaryDataService.GetInfo(mold.mold_status!))?.FullName;
|
||||
info.maintain_qty = mold.maintain_qty;
|
||||
info.designer = planMoldRelation.designer == null ? "" : planMoldRelation.designer;
|
||||
info.plan_start_time = planMoldRelation.plan_start_time == null ? "" : ((DateTime)planMoldRelation.plan_start_time).ToString("yyyy-MM-dd");
|
||||
var moldEqpRelation = await _db.Queryable<ToolMoldsEquipment>().FirstAsync(it => it.mold_id == mold.id);
|
||||
if (moldEqpRelation != null)
|
||||
@@ -183,6 +188,51 @@ namespace Tnb.EquipMgr
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetPdaMaintainInfo(PdaMaintainInput input)
|
||||
{
|
||||
DateTime? start_time = input.start_time;
|
||||
DateTime? end_time = input.end_time;
|
||||
if (string.IsNullOrEmpty(input.sidx))
|
||||
{
|
||||
input.sidx = "b.create_time";
|
||||
input.sort = "desc";
|
||||
}
|
||||
else
|
||||
{
|
||||
input.sidx = "b." + input.sidx;
|
||||
}
|
||||
var records = await _db.Queryable<ToolMoldMaintainItemRecord>().Select(p => p.plan_id + p.mold_id).ToListAsync();
|
||||
var result= await _db.Queryable<ToolMoldMaintainPlanRelation>()
|
||||
.LeftJoin<ToolMoldMaintainPlan>((a, b) => a.maintain_plan_id == b.id)
|
||||
.LeftJoin<ToolMolds>((a, b, c) => a.mold_id == c.id)
|
||||
.LeftJoin<ToolMoldMaintainRunRecord>((a, b, c, d) => b.plan_code == d.plan_code && c.mold_code == d.mold_code)
|
||||
.LeftJoin<ToolMoldMaintainItemRecord>((a, b, c, d, e) => e.plan_id == b.id && e.mold_id == c.id)
|
||||
.LeftJoin<UserEntity>((a, b, c, d, e, f) => b.create_id == f.Id)
|
||||
.LeftJoin<DictionaryDataEntity>((a, b, c, d, e, f,g) => c.mold_status == g.Id)
|
||||
.Where((a, b, c, d, e, f) => b.create_time != null)
|
||||
.WhereIF(!string.IsNullOrEmpty(input.maintain_info), (a, b, c, d, e, f, g) => c.mold_code!.Contains(input.maintain_info) || c.mold_name!.Contains(input.maintain_info))
|
||||
.WhereIF(start_time != null, (a, b, c, d, e, f, g) => b.create_time != null && b.create_time >= start_time)
|
||||
.WhereIF(end_time != null, (a, b, c, d, e, f, g) => b.create_time != null && b.create_time <= end_time)
|
||||
.WhereIF(input.status == "待保养", (a, b, c, d, e, f, g) => !records.Contains(a.maintain_plan_id + a.mold_id))
|
||||
.WhereIF(input.status == "已完成", (a, b, c, d, e, f, g) => records.Contains(a.maintain_plan_id + a.mold_id))
|
||||
.Select((a, b, c, d, e, f, g) => new PadMainListOutput
|
||||
{
|
||||
plan_id = b.id,
|
||||
mold_id = c.id,
|
||||
mold_code = c.mold_code!,
|
||||
mold_name = c.mold_name!,
|
||||
mold_status=g.FullName!,
|
||||
status = input.status,
|
||||
createuser = f.RealName,
|
||||
createtime = b.create_time == null ? "" : b.create_time.Value.ToString(DbTimeFormat.SS),
|
||||
plan_start_time = b.plan_start_date == null ? "" : b.plan_start_date.Value.ToString(DbTimeFormat.SS),
|
||||
starttime = d.plan_start_time == null ? "" : d.plan_start_time.Value.ToString(DbTimeFormat.SS),
|
||||
}).OrderBy($"{input.sidx} {input.sort}").ToPagedListAsync((input?.currentPage ?? 1), (input?.pageSize ?? 50));
|
||||
return PageResult<PadMainListOutput>.SqlSugarPageResult(result);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据计划Id、模具ID获取,保养组及项目信息
|
||||
/// </summary>
|
||||
|
||||
@@ -126,5 +126,23 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// 实际完工日期
|
||||
/// </summary>
|
||||
public string? act_end_date { get; set; }
|
||||
/// <summary>
|
||||
/// 挤出件类型
|
||||
/// </summary>
|
||||
public string? tube { get; set; }
|
||||
/// <summary>
|
||||
/// 最小包装
|
||||
/// </summary>
|
||||
public decimal? minpacking { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 主单位数量
|
||||
/// </summary>
|
||||
public string? main_num { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 副单位数量(kg)
|
||||
/// </summary>
|
||||
public string? deputy_num { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -103,6 +103,11 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// 工位
|
||||
/// </summary>
|
||||
public string? station { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 料箱二维码
|
||||
/// </summary>
|
||||
public string material_box_qrcode { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,5 +124,10 @@ public partial class PrdReport : BaseEntity<string>
|
||||
/// 工序id
|
||||
/// </summary>
|
||||
public string? process_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 料箱二维码
|
||||
/// </summary>
|
||||
public string material_box_qrcode { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -400,13 +400,14 @@ namespace Tnb.ProductionMgr
|
||||
.LeftJoin<PerProcessStandardsH>((a,b,c,d,e,f,g,h)=>a.material_id==h.output_material_id && a.eqp_id==h.equip_id && a.mold_id==h.molds_id && h.enabled==1)
|
||||
.LeftJoin<BasStandardTime>((a,b,c,d,e,f,g,h,i)=>a.process_id==i.process_id && i.enabled==1)
|
||||
.LeftJoin<PrdMo>((a,b,c,d,e,f,g,h,i,j)=>a.mo_id==j.id)
|
||||
.LeftJoin<BasMaterialUnit>((a,b,c,d,e,f,g,h,i,j,k)=>a.material_id==k.material_id && k.auxiliary_unit_id=="kg")
|
||||
.Where((a, b) => a.workstation_id == input.stationId && (a.mo_task_status == DictConst.ToBeStartedEnCode || a.mo_task_status == DictConst.MoStatusPauseCode || a.mo_task_status == DictConst.ComplatedEnCode || a.mo_task_status == DictConst.InProgressEnCode) )
|
||||
.WhereIF(!string.IsNullOrEmpty(mo_task_code),a=>a.mo_task_code.Contains(mo_task_code))
|
||||
//.WhereIF(!string.IsNullOrEmpty(mo_task_status),a=>a.mo_task_status==mo_task_status)
|
||||
.WhereIF(statusList.Count>0,a=>statusList.Contains(a.mo_task_status))
|
||||
.WhereIF(status=="3" && start_time!=null,a=>a.act_end_date>=start_time)
|
||||
.WhereIF(status=="3" && end_time!=null,a=>a.act_end_date<=end_time)
|
||||
.Select((a, b, c, d, e,f,g,h,i,j) => new PADPackageTaskPageOutput
|
||||
.Select((a, b, c, d, e,f,g,h,i,j,k) => new PADPackageTaskPageOutput
|
||||
{
|
||||
id = a.id,
|
||||
mo_task_code = a.mo_task_code,
|
||||
@@ -443,6 +444,10 @@ namespace Tnb.ProductionMgr
|
||||
act_start_date = a.act_start_date==null ? "" : a.act_start_date.Value.ToString(DbTimeFormat.SS),
|
||||
act_end_date = a.act_end_date==null ? "" : a.act_end_date.Value.ToString(DbTimeFormat.SS),
|
||||
plan_end_date = a.plan_end_date==null ? "" : a.plan_end_date.Value.ToString(DbTimeFormat.SS),
|
||||
tube = f.tube,
|
||||
minpacking = b.minpacking,
|
||||
main_num = k.number_of_primary_unit,
|
||||
deputy_num = k.number_of_auxiliary_unit,
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderBy($"{input.sidx} {input.sort}")
|
||||
|
||||
@@ -18,17 +18,18 @@ namespace JNPF.TaskScheduler.Listener
|
||||
// }
|
||||
|
||||
[SpareTime("0 0 0 * * ?", "生成设备保养计划", ExecuteType = SpareTimeExecuteTypes.Serial,StartNow = false)]
|
||||
public void GenerateSpotInspectionPlan(SpareTimer timer, long count)
|
||||
public async void GenerateSpotInspectionPlan(SpareTimer timer, long count)
|
||||
{
|
||||
Log.Information("----------------------开始生成设备保养计划----------------------");
|
||||
|
||||
try
|
||||
{
|
||||
List<EqpMaintainTemEquipH> eqpSpotInsTemEquipHsByOne = _repository.GetList(x => x.is_start=="1" && x.plan_cycle_unit == "1");
|
||||
List<EqpMaintainTemEquipH> eqpSpotInsTemEquipHsByCirculate = _repository.GetList(x => x.is_start=="1" && x.plan_cycle_unit == "2");
|
||||
var db = _repository.CopyNew();
|
||||
List<EqpMaintainTemEquipH> eqpSpotInsTemEquipHsByOne = await db.Queryable<EqpMaintainTemEquipH>().Where(x => x.is_start=="1" && x.plan_cycle_unit == "1").ToListAsync();
|
||||
List<EqpMaintainTemEquipH> eqpSpotInsTemEquipHsByCirculate = await db.Queryable<EqpMaintainTemEquipH>().Where(x => x.is_start=="1" && x.plan_cycle_unit == "2").ToListAsync();
|
||||
List<EqpMaintainRecordH> tobeCreateList = new List<EqpMaintainRecordH>();
|
||||
List<EqpMaintainTemEquipH> tobeCreateTemplets = new List<EqpMaintainTemEquipH>();
|
||||
var db = _repository.AsSugarClient();
|
||||
|
||||
|
||||
foreach (var item in eqpSpotInsTemEquipHsByOne)
|
||||
{
|
||||
@@ -56,7 +57,7 @@ namespace JNPF.TaskScheduler.Listener
|
||||
|
||||
if (tobeCreateTemplets != null && tobeCreateTemplets.Count > 0)
|
||||
{
|
||||
List<EqpEquipment> equipments = db.Queryable<EqpEquipment>().Where(x => x.life==Tnb.EquipMgr.EquipmentLife.ENABLE).ToList();
|
||||
List<EqpEquipment> equipments = await db.Queryable<EqpEquipment>().Where(x => x.life==Tnb.EquipMgr.EquipmentLife.ENABLE).ToListAsync();
|
||||
int index = 1;
|
||||
foreach (var item in tobeCreateTemplets)
|
||||
{
|
||||
@@ -67,7 +68,6 @@ namespace JNPF.TaskScheduler.Listener
|
||||
string code = $"{DateTime.Now.ToString("yyyyMMdd")+(index++).ToString().PadLeft(3,'0')}";
|
||||
tobeCreateList.Add(new EqpMaintainRecordH()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
code = code,
|
||||
// equip_type_id = item.equip_type_id,
|
||||
equip_id = item.equip_id,
|
||||
@@ -90,14 +90,14 @@ namespace JNPF.TaskScheduler.Listener
|
||||
if (tobeCreateList != null && tobeCreateList.Count > 0)
|
||||
{
|
||||
List<string> templetIDs = tobeCreateList.Select(x => x.maintain_tem_equip_id).ToList();
|
||||
List<EqpMaintainTemEquipD> spotInsTemEquipDs = db.Queryable<EqpMaintainTemEquipD>().Where(x => templetIDs.Contains(x.maintain_tem_equip_id)).ToList();
|
||||
List<EqpMaintainTemEquipD> spotInsTemEquipDs = await db.Queryable<EqpMaintainTemEquipD>().Where(x => templetIDs.Contains(x.maintain_tem_equip_id)).ToListAsync();
|
||||
List<string> spotInsItemIDs = spotInsTemEquipDs.Select(x => x.maintain_item_id).ToList();
|
||||
List<EqpMaintainItem> spotCheckItems = db.Queryable<EqpMaintainItem>().Where(x => spotInsItemIDs.Contains(x.id)).ToList();
|
||||
List<EqpMaintainItem> spotCheckItems = await db.Queryable<EqpMaintainItem>().Where(x => spotInsItemIDs.Contains(x.id)).ToListAsync();
|
||||
|
||||
|
||||
List<EqpMaintainRecordD> spotInsRecordDs = new List<EqpMaintainRecordD>();
|
||||
foreach (var tobeCreatePlan in tobeCreateList)
|
||||
{
|
||||
List<EqpMaintainRecordD> spotInsRecordDs = new List<EqpMaintainRecordD>();
|
||||
List<string> spotInsItems = spotInsTemEquipDs
|
||||
.Where(x => x.maintain_tem_equip_id == tobeCreatePlan.maintain_tem_equip_id)
|
||||
.Select(x => x.maintain_item_id).ToList();
|
||||
@@ -119,25 +119,30 @@ namespace JNPF.TaskScheduler.Listener
|
||||
});
|
||||
}
|
||||
|
||||
var dbResult = db.Ado.UseTran(() =>
|
||||
{
|
||||
if (tobeCreateList != null && tobeCreateList.Count > 0)
|
||||
{
|
||||
db.Insertable<EqpMaintainRecordH>(tobeCreateList).ExecuteCommand();
|
||||
}
|
||||
|
||||
if (spotInsRecordDs != null && spotInsRecordDs.Count > 0)
|
||||
{
|
||||
db.Insertable<EqpMaintainRecordD>(spotInsRecordDs).ExecuteCommand();
|
||||
}
|
||||
});
|
||||
if (!dbResult.IsSuccess)
|
||||
{
|
||||
Console.WriteLine(dbResult.ErrorMessage);
|
||||
Log.Error(dbResult.ErrorMessage);
|
||||
}
|
||||
Log.Information($"---------------生成{tobeCreateList.Count}个计划---------------");
|
||||
}
|
||||
if (spotInsRecordDs.Count<=0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var dbResult = db.Ado.UseTran(() =>
|
||||
{
|
||||
if (tobeCreateList != null && tobeCreateList.Count > 0)
|
||||
{
|
||||
db.Insertable<EqpMaintainRecordH>(tobeCreateList).ExecuteCommand();
|
||||
}
|
||||
|
||||
if (spotInsRecordDs != null && spotInsRecordDs.Count > 0)
|
||||
{
|
||||
db.Insertable<EqpMaintainRecordD>(spotInsRecordDs).ExecuteCommand();
|
||||
}
|
||||
});
|
||||
if (!dbResult.IsSuccess)
|
||||
{
|
||||
Console.WriteLine(dbResult.ErrorMessage);
|
||||
Log.Error(dbResult.ErrorMessage);
|
||||
}
|
||||
Log.Information($"---------------生成{tobeCreateList.Count}个计划---------------");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
@@ -18,17 +18,17 @@ namespace JNPF.TaskScheduler.Listener
|
||||
// }
|
||||
|
||||
[SpareTime("0 0,30 * * * ?", "生成点巡检计划", ExecuteType = SpareTimeExecuteTypes.Serial,StartNow = false)]
|
||||
public void GenerateSpotInspectionPlan(SpareTimer timer, long count)
|
||||
public async void GenerateSpotInspectionPlan(SpareTimer timer, long count)
|
||||
{
|
||||
Log.Information("----------------------开始生成点巡检计划----------------------");
|
||||
|
||||
try
|
||||
{
|
||||
List<EqpSpotInsTemEquipH> eqpSpotInsTemEquipHsByOne = _repository.GetList(x => x.is_start=="1" && x.plan_cycle_unit == "1");
|
||||
List<EqpSpotInsTemEquipH> eqpSpotInsTemEquipHsByCirculate = _repository.GetList(x => x.is_start=="1" && x.plan_cycle_unit == "2");
|
||||
var db = _repository.CopyNew();
|
||||
List<EqpSpotInsTemEquipH> eqpSpotInsTemEquipHsByOne = await db.Queryable<EqpSpotInsTemEquipH>().Where(x => x.is_start=="1" && x.plan_cycle_unit == "1").ToListAsync();
|
||||
List<EqpSpotInsTemEquipH> eqpSpotInsTemEquipHsByCirculate = await db.Queryable<EqpSpotInsTemEquipH>().Where(x => x.is_start=="1" && x.plan_cycle_unit == "2").ToListAsync();
|
||||
List<EqpSpotInsRecordH> tobeCreateList = new List<EqpSpotInsRecordH>();
|
||||
List<EqpSpotInsTemEquipH> tobeCreateTemplets = new List<EqpSpotInsTemEquipH>();
|
||||
var db = _repository.AsSugarClient();
|
||||
|
||||
foreach (var item in eqpSpotInsTemEquipHsByOne)
|
||||
{
|
||||
@@ -80,7 +80,7 @@ namespace JNPF.TaskScheduler.Listener
|
||||
|
||||
if (tobeCreateTemplets != null && tobeCreateTemplets.Count > 0)
|
||||
{
|
||||
List<EqpEquipment> equipments = db.Queryable<EqpEquipment>().Where(x => x.life==Tnb.EquipMgr.EquipmentLife.ENABLE).ToList();
|
||||
List<EqpEquipment> equipments = await db.Queryable<EqpEquipment>().Where(x => x.life==Tnb.EquipMgr.EquipmentLife.ENABLE).ToListAsync();
|
||||
int index = 1;
|
||||
foreach (var item in tobeCreateTemplets)
|
||||
{
|
||||
@@ -114,14 +114,14 @@ namespace JNPF.TaskScheduler.Listener
|
||||
if (tobeCreateList != null && tobeCreateList.Count > 0)
|
||||
{
|
||||
List<string> templetIDs = tobeCreateList.Select(x => x.spot_ins_tem_equip_id).ToList();
|
||||
List<EqpSpotInsTemEquipD> spotInsTemEquipDs = db.Queryable<EqpSpotInsTemEquipD>().Where(x => templetIDs.Contains(x.spot_ins_tem_equip_id)).ToList();
|
||||
List<EqpSpotInsTemEquipD> spotInsTemEquipDs = await db.Queryable<EqpSpotInsTemEquipD>().Where(x => templetIDs.Contains(x.spot_ins_tem_equip_id)).ToListAsync();
|
||||
List<string> spotInsItemIDs = spotInsTemEquipDs.Select(x => x.spot_ins_item_id).ToList();
|
||||
List<EqpSpotInsItem> spotCheckItems = db.Queryable<EqpSpotInsItem>().Where(x => spotInsItemIDs.Contains(x.id)).ToList();
|
||||
List<EqpSpotInsItem> spotCheckItems = await db.Queryable<EqpSpotInsItem>().Where(x => spotInsItemIDs.Contains(x.id)).ToListAsync();
|
||||
|
||||
|
||||
List<EqpSpotInsRecordD> spotInsRecordDs = new List<EqpSpotInsRecordD>();
|
||||
foreach (var tobeCreatePlan in tobeCreateList)
|
||||
{
|
||||
List<EqpSpotInsRecordD> spotInsRecordDs = new List<EqpSpotInsRecordD>();
|
||||
List<string> spotInsItems = spotInsTemEquipDs
|
||||
.Where(x => x.spot_ins_tem_equip_id == tobeCreatePlan.spot_ins_tem_equip_id)
|
||||
.Select(x => x.spot_ins_item_id).ToList();
|
||||
@@ -130,7 +130,6 @@ namespace JNPF.TaskScheduler.Listener
|
||||
{
|
||||
spotInsRecordDs.Add(new EqpSpotInsRecordD()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
spot_ins_record_id = tobeCreatePlan.id,
|
||||
spot_ins_tem_equip_id = tobeCreatePlan.spot_ins_tem_equip_id,
|
||||
spot_ins_item_id = tobeCreateItem.id,
|
||||
@@ -148,26 +147,31 @@ namespace JNPF.TaskScheduler.Listener
|
||||
remark = tobeCreateItem.remark
|
||||
});
|
||||
}
|
||||
|
||||
var dbResult = db.Ado.UseTran(() =>
|
||||
{
|
||||
if (tobeCreateList != null && tobeCreateList.Count > 0)
|
||||
{
|
||||
db.Insertable<EqpSpotInsRecordH>(tobeCreateList).ExecuteCommand();
|
||||
}
|
||||
|
||||
if (spotInsRecordDs != null && spotInsRecordDs.Count > 0)
|
||||
{
|
||||
db.Insertable<EqpSpotInsRecordD>(spotInsRecordDs).ExecuteCommand();
|
||||
}
|
||||
});
|
||||
if (!dbResult.IsSuccess)
|
||||
{
|
||||
Console.WriteLine(dbResult.ErrorMessage);
|
||||
Log.Error(dbResult.ErrorMessage);
|
||||
}
|
||||
Log.Information($"---------------生成{tobeCreateList.Count}个计划---------------");
|
||||
|
||||
}
|
||||
if (spotInsRecordDs.Count<=0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var dbResult = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
if (tobeCreateList != null && tobeCreateList.Count > 0)
|
||||
{
|
||||
await db.Insertable<EqpSpotInsRecordH>(tobeCreateList).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
if (spotInsRecordDs != null && spotInsRecordDs.Count > 0)
|
||||
{
|
||||
await db.Insertable<EqpSpotInsRecordD>(spotInsRecordDs).ExecuteCommandAsync();
|
||||
}
|
||||
});
|
||||
if (!dbResult.IsSuccess)
|
||||
{
|
||||
Console.WriteLine(dbResult.ErrorMessage);
|
||||
Log.Error(dbResult.ErrorMessage);
|
||||
}
|
||||
Log.Information($"---------------生成{tobeCreateList.Count}个计划---------------");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
Reference in New Issue
Block a user