/* *所有关于Dt_PLCinfoDetail类的业务代码应在此处编写 *可使用repository.调用常用方法,获取EF/Dapper等信息 *如果需要事务请使用repository.DbContextBeginTransaction *也可使用DBServerProvider.手动获取数据库相关信息 *用户信息、权限、角色等使用UserContext.Current操作 *Dt_PLCinfoDetailService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter */ using WIDESEA_Core.BaseProvider; using WIDESEA_Core.Extensions.AutofacManager; using WIDESEA_Entity.DomainModels; using System.Linq; using WIDESEA_Core.Utilities; using System.Linq.Expressions; using WIDESEA_Core.Extensions; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.AspNetCore.Http; using WIDESEA_Services.IRepositories; using System; using WIDESEA_Services.Repositories; using System.Collections.Generic; namespace WIDESEA_Services.Services { public partial class Dt_PLCinfoDetailService { private readonly IHttpContextAccessor _httpContextAccessor; private readonly IDt_PLCinfoDetailRepository _repository;//访问数据库 [ActivatorUtilitiesConstructor] public Dt_PLCinfoDetailService( IDt_PLCinfoDetailRepository dbRepository, IHttpContextAccessor httpContextAccessor ) : base(dbRepository) { _httpContextAccessor = httpContextAccessor; _repository = dbRepository; //多租户会用到这init代码,其他情况可以不用 //base.Init(dbRepository); } public static WebResponseContent GetPLCinfoDetailData(SaveModel saveModel) { Dt_PLCinfoDetail plcinfoDetail = new Dt_PLCinfoDetail(); List ListplcinfoDetail = new List(); string plcdetail_number = saveModel.MainData["plcdetail_number"].ToString(); string plcdetail_value = saveModel.MainData["plcdetail_value"].ToString(); for (int i = Convert.ToInt32(saveModel.MainData["plcdetail_value"]); i <= Convert.ToInt32(saveModel.MainData["plcdetail_value"]) + 46; i++) { string plcdetail_valtype = null; string plcdetail_name = null; string plcdetail_opratortype = null; string plcdetail_remark = null; int a = i % 50; switch (a) { case 0: plcdetail_valtype = "Struct"; plcdetail_opratortype = "Disable"; plcdetail_remark = "交互"; break; case 2: plcdetail_valtype = "String"; plcdetail_name = "W_Line_TrayBarcode"; plcdetail_opratortype = "Write"; plcdetail_remark = "托盘条码"; break; case 30: plcdetail_valtype = "DInt"; plcdetail_name = "W_Line_TargetPosition"; plcdetail_opratortype = "Write"; plcdetail_remark = "目标位置"; break; case 34: plcdetail_valtype = "DInt"; plcdetail_name = "W_Line_TaskNum"; plcdetail_opratortype = "Write"; plcdetail_remark = "任务号"; break; case 38: plcdetail_valtype = "Int"; plcdetail_opratortype = "Disable"; plcdetail_remark = "备用"; break; case 40: plcdetail_valtype = "Int"; plcdetail_opratortype = "Disable"; plcdetail_remark = "备用"; break; case 42: plcdetail_valtype = "Int"; plcdetail_opratortype = "Disable"; plcdetail_remark = "备用"; break; case 44: plcdetail_valtype = "Int"; plcdetail_opratortype = "Disable"; plcdetail_remark = "备用"; break; case 46: plcdetail_valtype = "Int"; plcdetail_opratortype = "Disable"; plcdetail_remark = "备用"; break; } if (plcdetail_valtype != null) { plcinfoDetail = new Dt_PLCinfoDetail() { plcdetail_id = Guid.NewGuid(), plcdetail_headid = new Guid("B6147197-E558-430B-92A1-286A1E4DBB01"), plcdetail_db = "DB12", plcdetail_valtype = plcdetail_valtype, plcdetail_value = (Convert.ToInt32(saveModel.MainData["plcdetail_value"]) + a).ToString(), plcdetail_number = plcdetail_number, plcdetail_name = plcdetail_name, plcdetail_opratortype = plcdetail_opratortype, plcdetail_equipment = "ConveyorLine", plcdetail_remark = plcdetail_remark, }; ListplcinfoDetail.Add(plcinfoDetail); } if (Convert.ToInt32(saveModel.MainData["plcdetail_value"]) == i) { for (int j = 0; j <= 17; j++) { plcdetail_valtype = null; plcdetail_name = null; plcdetail_opratortype = null; plcdetail_remark = null; if (j >= 10) plcdetail_value = Convert.ToInt32(saveModel.MainData["plcdetail_value"]) + 1 + "." + j % 10; else plcdetail_value = Convert.ToInt32(saveModel.MainData["plcdetail_value"]) + "." + j; switch (j) { case 0: plcdetail_valtype = "Bool"; plcdetail_name = "R_Line_InteractionRequest"; plcdetail_opratortype = "Read"; plcdetail_remark = "扫码请求交互"; break; case 1: plcdetail_valtype = "Bool"; plcdetail_opratortype = "Disable"; break; case 2: plcdetail_valtype = "Bool"; plcdetail_name = "R_Line_InboundInteractionRequest"; plcdetail_opratortype = "Read"; plcdetail_remark = "入库请求交互"; break; case 3: plcdetail_valtype = "Bool"; plcdetail_name = "W_Line_InboundInteractionComplete"; plcdetail_opratortype = "Write"; plcdetail_remark = "入库交互完成"; break; case 4: plcdetail_valtype = "Bool"; plcdetail_name = "R_Line_OutboundInteractionRequest"; plcdetail_opratortype = "Read"; plcdetail_remark = "入库请求交互"; break; case 5: plcdetail_valtype = "Bool"; plcdetail_opratortype = "Disable"; break; case 6: plcdetail_valtype = "Bool"; plcdetail_name = "R_Line_ReallocationRequest"; plcdetail_opratortype = "Read"; plcdetail_remark = "请求重新分配路线"; break; case 7: plcdetail_valtype = "Bool"; plcdetail_name = "W_Line_ReallocationComplete"; plcdetail_opratortype = "Write"; plcdetail_remark = "完成重新分配路线"; break; case 10: plcdetail_valtype = "Bool"; plcdetail_opratortype = "Disable"; break; case 11: plcdetail_valtype = "Bool"; plcdetail_opratortype = "Disable"; break; case 12: plcdetail_valtype = "Bool"; plcdetail_opratortype = "Disable"; break; case 13: plcdetail_valtype = "Bool"; plcdetail_opratortype = "Disable"; break; case 14: plcdetail_valtype = "Bool"; plcdetail_opratortype = "Disable"; break; case 15: plcdetail_valtype = "Bool"; plcdetail_opratortype = "Disable"; break; case 16: plcdetail_valtype = "Bool"; plcdetail_opratortype = "Disable"; break; case 17: plcdetail_valtype = "Bool"; plcdetail_opratortype = "Disable"; break; } if (plcdetail_valtype != null) { plcinfoDetail = new Dt_PLCinfoDetail() { plcdetail_id = Guid.NewGuid(), plcdetail_headid = new Guid("B6147197-E558-430B-92A1-286A1E4DBB01"), plcdetail_db = "DB12", plcdetail_valtype = plcdetail_valtype, plcdetail_value = plcdetail_value, plcdetail_number = plcdetail_number, plcdetail_name = plcdetail_name, plcdetail_opratortype = plcdetail_opratortype, plcdetail_equipment = "ConveyorLine", plcdetail_remark = plcdetail_remark, }; ListplcinfoDetail.Add(plcinfoDetail); } } } } Dt_PLCinfoDetailRepository.Instance.AddRange(ListplcinfoDetail, true); return new WebResponseContent().OK(); } } }