zhangliwen пре 1 година
родитељ
комит
bbd2d86f97

BIN
SCADA_DAQ/Content.zip


+ 2 - 0
SCADA_DAQ/Customer/Models/MotorcycleTypeManagement/AddMotorcycleTypeModel.cs

@@ -2,6 +2,7 @@
 using SqlSchema.DBNames;
 using System;
 using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -81,6 +82,7 @@ namespace SCADA_DAQ.Customer.Models.MotorcycleTypeManagement
         /// </summary>
         [AutoViewProperty("车型名称", Icon = "BedSingle")]
         [Column(T_Col_Name.APP_TaiLing_MotorcycleTypeManagement.MotorcycleTypeName_Str)]
+        [Required]   // 必须
         public string CarModelName
         {
             get { return _CarModelName; }

+ 6 - 2
SCADA_DAQ/Customer/Models/ProductionLineManagement/AddProductionLineManagementModel.cs

@@ -2,6 +2,7 @@
 using SqlSchema.DBNames;
 using System;
 using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -14,7 +15,7 @@ namespace SCADA_DAQ.Customer.Models.ProductionLineManagement
     [Table(nameof(SqlSchema.DBModel.APP_TaiLing_ProductionLineManagement))]
     public class AddProductionLineManagementModel : ObservableObject
     {
-        
+
 
         ///// <summary>
         ///// ID
@@ -38,8 +39,9 @@ namespace SCADA_DAQ.Customer.Models.ProductionLineManagement
         /// <summary>
         /// 车间号
         /// </summary>
-        [AutoViewProperty("车间号", Icon = "",IsEnable = true)]
+        [AutoViewProperty("车间号", Icon = "", IsEnable = true)]
         [Column(T_Col_Name.APP_TaiLing_ProductionLineManagement.WorkShopId_Str)]
+        [Required]
         public string WorkShopId
         {
             get { return _WorkShopId; }
@@ -60,6 +62,7 @@ namespace SCADA_DAQ.Customer.Models.ProductionLineManagement
         /// </summary>
         [AutoViewProperty("产线号", Icon = "", IsEnable = true)]
         [Column(T_Col_Name.APP_TaiLing_ProductionLineManagement.ProductionLineId_Str)]
+        [Required]
         public string ProductionLineId
         {
             get { return _ProductionLineId; }
@@ -82,6 +85,7 @@ namespace SCADA_DAQ.Customer.Models.ProductionLineManagement
         /// </summary>
         [AutoViewProperty("产线名称", Icon = "")]
         [Column(T_Col_Name.APP_TaiLing_ProductionLineManagement.ProductionLineName_Str)]
+        [Required]
         public string ProductionLineName
         {
             get { return _ProductionLineName; }

+ 11 - 6
SCADA_DAQ/Customer/Models/TaskManagement/AddTaskModel.cs

@@ -4,10 +4,12 @@ using SCADA_DAQ.Customer.Models.MotorcycleTypeManagement;
 using SqlSchema.DBNames;
 using System;
 using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
+
 namespace SCADA_DAQ.Customer.Models.TaskManagement
 {
     /// <summary>
@@ -20,7 +22,6 @@ namespace SCADA_DAQ.Customer.Models.TaskManagement
         /// <summary>
         /// 车间号
         /// </summary>
-        private string _WorkShopId = CustomerEnv.ProductionLineConfigValue.WorkShopId;
         [AutoViewProperty("车间号", Icon = "", IsEnable =false)]
         [Column(T_Col_Name.APP_TaiLing_TaskManagement.WorkShopId_Str)]
         public string WorkShopId
@@ -35,11 +36,11 @@ namespace SCADA_DAQ.Customer.Models.TaskManagement
                 }
             }
         }
+        private string _WorkShopId = CustomerEnv.ProductionLineConfigValue.WorkShopId;
 
         /// <summary>
         /// 产线号
         /// </summary>
-        private string _ProductionLineId = CustomerEnv.ProductionLineConfigValue.ProductionLineId;
         [AutoViewProperty("产线号", Icon = "", IsEnable =false)]
         [Column(T_Col_Name.APP_TaiLing_TaskManagement.ProductionLineId_Str)]
         public string ProductionLineId
@@ -54,13 +55,14 @@ namespace SCADA_DAQ.Customer.Models.TaskManagement
                 }
             }
         }
+        private string _ProductionLineId = CustomerEnv.ProductionLineConfigValue.ProductionLineId;
 
         /// <summary>
         /// 批次号
         /// </summary>
-        private string _OrderId;
         [AutoViewProperty("批次号", Icon = "")]
         [Column(T_Col_Name.APP_TaiLing_TaskManagement.OrderId_Str)]
+        [Required]   // 必须
         public string OrderId
         {
             get { return _OrderId; }
@@ -73,11 +75,11 @@ namespace SCADA_DAQ.Customer.Models.TaskManagement
                 }
             }
         }
+        private string _OrderId;
 
         /// <summary>
         /// 工单日期
         /// </summary>
-        private DateTime _OrderDatetime = DateTime.Now;
         [AutoViewProperty("工单日期", Icon = "")]
         [Column(T_Col_Name.APP_TaiLing_TaskManagement.OrderDatetime_Dt)]
         public DateTime OrderDatetime
@@ -92,11 +94,11 @@ namespace SCADA_DAQ.Customer.Models.TaskManagement
                 }
             }
         }
+        private DateTime _OrderDatetime = DateTime.Now;
 
         /// <summary>
         /// 工单顺序
         /// </summary>
-        private int _OrderSequence;
         [AutoViewProperty("工单顺序", Icon = "")]
         [Column(T_Col_Name.APP_TaiLing_TaskManagement.OrderSequence_Int)]
         public int OrderSequence
@@ -111,11 +113,11 @@ namespace SCADA_DAQ.Customer.Models.TaskManagement
                 }
             }
         }
+        private int _OrderSequence;
 
         /// <summary>
         /// 计划产量
         /// </summary>
-        private int _ScheduledProduction;
         [AutoViewProperty("计划产量", Icon = "")]
         [Column(T_Col_Name.APP_TaiLing_TaskManagement.ScheduledProduction_Int)]
         public int ScheduledProduction
@@ -130,6 +132,7 @@ namespace SCADA_DAQ.Customer.Models.TaskManagement
                 }
             }
         }
+        private int _ScheduledProduction;
 
 
         /// <summary>
@@ -180,6 +183,7 @@ namespace SCADA_DAQ.Customer.Models.TaskManagement
             DisplayMemberPath = "MotorcycleTypeName",
             SelectedValuePath = "MotorcycleTypeName")]
         [Column(T_Col_Name.APP_TaiLing_TaskManagement.MotorcycleTypeName_Str)]
+        [Required]   // 必须
         public string MotorcycleTypeName
         {
             get { return _MotorcycleTypeName; }
@@ -202,6 +206,7 @@ namespace SCADA_DAQ.Customer.Models.TaskManagement
             Env.SgIDAL.APP_TaiLing_MotorcycleTypeManagement.GetData<MotorcycleTypeModel>();
 
 
+
         /// <summary>
         /// 工单状态
         /// </summary>

+ 79 - 80
SCADA_DAQ/Customer/Models/TaskManagement/TaskManagementModel.cs

@@ -14,7 +14,6 @@ namespace SCADA_DAQ.Customer.Models.TaskManagement
     public class TaskManagementModel : ObservableObject
     {
 
-
         /// <summary>
         /// ID
         /// </summary>
@@ -33,49 +32,30 @@ namespace SCADA_DAQ.Customer.Models.TaskManagement
         }
         private int _ID;
 
-
         /// <summary>
-        /// 车间号
+        /// 工单日期
         /// </summary>
-        [AutoViewProperty("车间号", Icon = "")]
-        [Column(T_Col_Name.APP_TaiLing_TaskManagement.WorkShopId_Str)]
-        public string WorkShopId
+        [AutoViewProperty("工单日期", Icon = "", IsReadOnly =true)]
+        [Column(T_Col_Name.APP_TaiLing_TaskManagement.OrderDatetime_Dt)]
+        public DateTime OrderDatetime
         {
-            get { return _WorkShopId; }
+            get { return _OrderDatetime; }
             set
             {
-                if (value != _WorkShopId)
+                if (value != _OrderDatetime)
                 {
-                    _WorkShopId = value;
-                    OnPropertyChanged(nameof(WorkShopId));
+                    _OrderDatetime = value;
+                    OnPropertyChanged(nameof(OrderDatetime));
                 }
             }
         }
-        private string _WorkShopId;
+        private DateTime _OrderDatetime;
 
-        /// <summary>
-        /// 产线号
-        /// </summary>
-        [AutoViewProperty("产线号", Icon = "")]
-        [Column(T_Col_Name.APP_TaiLing_TaskManagement.ProductionLineId_Str)]
-        public string ProductionLineId
-        {
-            get { return _ProductionLineId; }
-            set
-            {
-                if (value != _ProductionLineId)
-                {
-                    _ProductionLineId = value;
-                    OnPropertyChanged(nameof(ProductionLineId));
-                }
-            }
-        }
-        private string _ProductionLineId;
 
         /// <summary>
         /// 批次号
         /// </summary>
-        [AutoViewProperty("批次号", Icon = "")]
+        [AutoViewProperty("批次号", Icon = "" ,IsReadOnly = true)]
         [Column(T_Col_Name.APP_TaiLing_TaskManagement.OrderId_Str)]
         public string OrderId
         {
@@ -91,48 +71,50 @@ namespace SCADA_DAQ.Customer.Models.TaskManagement
         }
         private string _OrderId;
 
+        
+
         /// <summary>
-        /// 工单日期
+        /// 工单顺序
         /// </summary>
-        [AutoViewProperty("工单日期", Icon = "")]
-        [Column(T_Col_Name.APP_TaiLing_TaskManagement.OrderDatetime_Dt)]
-        public DateTime OrderDatetime
+        [AutoViewProperty("工单顺序", Icon = "", IsReadOnly = true)]
+        [Column(T_Col_Name.APP_TaiLing_TaskManagement.OrderSequence_Int)]
+        public int OrderSequence
         {
-            get { return _OrderDatetime; }
+            get { return _OrderSequence; }
             set
             {
-                if (value != _OrderDatetime)
+                if (value != _OrderSequence)
                 {
-                    _OrderDatetime = value;
-                    OnPropertyChanged(nameof(OrderDatetime));
+                    _OrderSequence = value;
+                    OnPropertyChanged(nameof(OrderSequence));
                 }
             }
         }
-        private DateTime _OrderDatetime;
+        private int _OrderSequence;
 
         /// <summary>
-        /// 工单顺序
+        /// 车型名称
         /// </summary>
-        [AutoViewProperty("工单顺序", Icon = "")]
-        [Column(T_Col_Name.APP_TaiLing_TaskManagement.OrderSequence_Int)]
-        public int OrderSequence
+        [AutoViewProperty("车型名称", Icon = "", IsReadOnly = true)]
+        [Column(T_Col_Name.APP_TaiLing_TaskManagement.MotorcycleTypeName_Str)]
+        public string MotorcycleTypeName
         {
-            get { return _OrderSequence; }
+            get { return _MotorcycleTypeName; }
             set
             {
-                if (value != _OrderSequence)
+                if (value != _MotorcycleTypeName)
                 {
-                    _OrderSequence = value;
-                    OnPropertyChanged(nameof(OrderSequence));
+                    _MotorcycleTypeName = value;
+                    OnPropertyChanged(nameof(MotorcycleTypeName));
                 }
             }
         }
-        private int _OrderSequence;
+        private string _MotorcycleTypeName;
 
         /// <summary>
         /// 计划产量
         /// </summary>
-        [AutoViewProperty("计划产量", Icon = "")]
+        [AutoViewProperty("计划产量", Icon = "", IsReadOnly =true)]
         [Column(T_Col_Name.APP_TaiLing_TaskManagement.ScheduledProduction_Int)]
         public int ScheduledProduction
         {
@@ -167,10 +149,29 @@ namespace SCADA_DAQ.Customer.Models.TaskManagement
         }
         private int _CurrentProduction;
 
+        /// <summary>
+        /// 工单状态
+        /// </summary>
+        [AutoViewProperty("工单状态", Icon = "", IsReadOnly = true)]
+        [Column(T_Col_Name.APP_TaiLing_TaskManagement.OrderState_Str)]
+        public string OrderState
+        {
+            get { return _OrderState; }
+            set
+            {
+                if (value != _OrderState)
+                {
+                    _OrderState = value;
+                    OnPropertyChanged(nameof(OrderState));
+                }
+            }
+        }
+        private string _OrderState;
+
         /// <summary>
         /// 开始生产时间
         /// </summary>
-        [AutoViewProperty("开始生产时间", Icon = "")]
+        [AutoViewProperty("开始生产时间", Icon = "", IsReadOnly = true)]
         [Column(T_Col_Name.APP_TaiLing_TaskManagement.WorkStartTime_Dt)]
         public DateTime WorkStartTime
         {
@@ -189,7 +190,7 @@ namespace SCADA_DAQ.Customer.Models.TaskManagement
         /// <summary>
         /// 结束生产时间
         /// </summary>
-        [AutoViewProperty("结束生产时间", Icon = "")]
+        [AutoViewProperty("结束生产时间", Icon = "", IsReadOnly = true)]
         [Column(T_Col_Name.APP_TaiLing_TaskManagement.WorkEndTime_Dt)]
         public DateTime WorkEndTime
         {
@@ -206,63 +207,61 @@ namespace SCADA_DAQ.Customer.Models.TaskManagement
         private DateTime _WorkEndTime;
 
         /// <summary>
-        /// 工单状态
+        /// 生产总时长
         /// </summary>
-        [AutoViewProperty("工单状态", Icon = "")]
-        [Column(T_Col_Name.APP_TaiLing_TaskManagement.OrderState_Str)]
-        public string OrderState
+        [AutoViewProperty("生产总时长", Icon = "", IsReadOnly = true)]
+        [Column(T_Col_Name.APP_TaiLing_TaskManagement.DurationSec_Int)]
+        public int DurationSec
         {
-            get { return _OrderState; }
+            get { return _DurationSec; }
             set
             {
-                if (value != _OrderState)
+                if (value != _DurationSec)
                 {
-                    _OrderState = value;
-                    OnPropertyChanged(nameof(OrderState));
+                    _DurationSec = value;
+                    OnPropertyChanged(nameof(DurationSec));
                 }
             }
         }
-        private string _OrderState;
+        private int _DurationSec;
 
         /// <summary>
-        /// 车型名称
+        /// 车间号
         /// </summary>
-        [AutoViewProperty("车型名称", Icon = "")]
-        [Column(T_Col_Name.APP_TaiLing_TaskManagement.MotorcycleTypeName_Str)]
-        public string MotorcycleTypeName
+        [AutoViewProperty("车间号", Icon = "", IsReadOnly = true)]
+        [Column(T_Col_Name.APP_TaiLing_TaskManagement.WorkShopId_Str)]
+        public string WorkShopId
         {
-            get { return _MotorcycleTypeName; }
+            get { return _WorkShopId; }
             set
             {
-                if (value != _MotorcycleTypeName)
+                if (value != _WorkShopId)
                 {
-                    _MotorcycleTypeName = value;
-                    OnPropertyChanged(nameof(MotorcycleTypeName));
+                    _WorkShopId = value;
+                    OnPropertyChanged(nameof(WorkShopId));
                 }
             }
         }
-        private string _MotorcycleTypeName;
+        private string _WorkShopId;
 
         /// <summary>
-        /// 生产总时长
+        /// 产线号
         /// </summary>
-        [AutoViewProperty("生产总时长", Icon = "")]
-        [Column(T_Col_Name.APP_TaiLing_TaskManagement.DurationSec_Int)]
-        public int DurationSec
+        [AutoViewProperty("产线号", Icon = "", IsReadOnly = true)]
+        [Column(T_Col_Name.APP_TaiLing_TaskManagement.ProductionLineId_Str)]
+        public string ProductionLineId
         {
-            get { return _DurationSec; }
+            get { return _ProductionLineId; }
             set
             {
-                if (value != _DurationSec)
+                if (value != _ProductionLineId)
                 {
-                    _DurationSec = value;
-                    OnPropertyChanged(nameof(DurationSec));
+                    _ProductionLineId = value;
+                    OnPropertyChanged(nameof(ProductionLineId));
                 }
             }
         }
-        private int _DurationSec;
-
-
+        private string _ProductionLineId;
 
 
     }

+ 7 - 11
SCADA_DAQ/Customer/UctFrmParameterSet.xaml.cs

@@ -34,17 +34,13 @@ namespace SCADA_DAQ.Customer
         {
             InitializeComponent();
             ToolBar.Visibility=Visibility.Collapsed;
-            //ParameterSettings.Content = new AutoView(CustomerEnv.ProductionLineConfigValue, new string[]
-            //{
-            //    nameof(ParameterSettingsModel.WorkShopId),
-            //    nameof(ParameterSettingsModel.ProductionLineId),
-            //    nameof(ParameterSettingsModel.ProductionLineAdministrator),
-            //    nameof(ParameterSettingsModel.ProductionLineName),
-            //    nameof(ParameterSettingsModel.ProductionLineShortName),
-            //    nameof(ParameterSettingsModel.NumberOfPeople),
-            //    nameof(ParameterSettingsModel.PLCName)
-            //})
-            ParameterSettings.Content = new AutoView(CustomerEnv.ProductionLineConfigValue)
+            ParameterSettings.Content = new AutoView(CustomerEnv.ProductionLineConfigValue, new string[]
+            {
+                nameof(ParameterSettingsModel.WorkShopId),
+                nameof(ParameterSettingsModel.ProductionLineId),
+                nameof(ParameterSettingsModel.PlcName)
+            })
+            //ParameterSettings.Content = new AutoView(CustomerEnv.ProductionLineConfigValue)
             { MaxTitleWidth = 150 };
 
         }

+ 65 - 1
SCADA_DAQ/Customer/UctFrmTaskManagement.xaml.cs

@@ -1,12 +1,18 @@
-using SCADA.CommonCtrl.WpfControl;
+using Microsoft.DwayneNeed.Numerics;
+using Microsoft.DwayneNeed.Win32.Gdi32;
+using NPOI.SS.Formula.Eval;
+using SCADA.CommonCtrl.WpfControl;
 using SCADA.CommonLib;
 using SCADA.CommonLib.CommonModel;
+using SCADA.CommonLib.Data.DIL;
+using SCADA.CommonLib.Helper;
 using SCADA_DAQ.Customer.Models;
 using SCADA_DAQ.Customer.Models.MotorcycleTypeManagement;
 using SCADA_DAQ.Customer.Models.TaskManagement;
 using SqlSchema.DBNames;
 using System;
 using System.Collections.Generic;
+using System.Data;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -55,6 +61,64 @@ namespace SCADA_DAQ.Customer
                 = "MotorcycleTypeName";
             MainGrid.DataTableColumnLables[T_Col_Name.APP_TaiLing_TaskManagement.MotorcycleTypeName_Str].SelectedValuePath
                 = "MotorcycleTypeName";
+
+
+            MainGrid.CellEditEnding += MainGrid_CellEditEnding;
+        }
+
+        private void MainGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
+        {
+            string newValue = (e.EditingElement as TextBox).Text;   // 新编辑的值
+            var item = (DataRowView)((SmartGrid)sender).CurrentItem;
+            //var cell = ((SmartGrid)sender).CurrentCell;
+            //var x = cell.Column;
+            //var y = cell.Item;
+            //var column = ((SmartGrid)sender).CurrentCell.Column.Header;
+            
+            var orderId = Convert.ToString(item[T_Col_Name.APP_TaiLing_TaskManagement.OrderId_Str]);
+            var scheduledProduction = Convert.ToInt32(item[T_Col_Name.APP_TaiLing_TaskManagement.ScheduledProduction_Int]);
+            var currentProduction = Convert.ToInt32(item[T_Col_Name.APP_TaiLing_TaskManagement.CurrentProduction_Int]);
+            var workStartTime = item[T_Col_Name.APP_TaiLing_TaskManagement.WorkStartTime_Dt];
+            var orderDatetime = Convert.ToDateTime(item[T_Col_Name.APP_TaiLing_TaskManagement.OrderDatetime_Dt]);
+            var workShopId = CustomerEnv.ProductionLineConfigValue.WorkShopId;
+            var productionLineId = CustomerEnv.ProductionLineConfigValue.ProductionLineId;
+
+            //if (e.Column.Header.ToString() == "计划产量")
+            //    return;
+
+            if (e.Column.Header.ToString() == "当前产量")
+            {
+                currentProduction = Convert.ToInt32(newValue);
+            }
+            if (scheduledProduction > currentProduction)
+                return;
+            var taskInfo = Env.SgIDAL.APP_TaiLing_TaskManagement?.GetData<TaskManagementModel>()?
+                .Where(t => t.OrderId == orderId && t.WorkShopId == workShopId
+                     && t.ProductionLineId == productionLineId)
+                .OrderBy(t => t.ID).LastOrDefault();
+            if (taskInfo == null)
+                return;
+
+            if (workStartTime is DBNull)
+            {
+                var dateDiff = (DateTime.Now - orderDatetime).TotalSeconds.ToInt();  // 时间差/s
+                Env.SgIDAL.APP_TaiLing_TaskManagement.Update($"OrderId_Str='{orderId}' AND WorkShopId_Str='{workShopId}' AND ProductionLineId_Str='{productionLineId}'",
+                    new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.WorkStartTime_Dt, orderDatetime),
+                    new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.WorkEndTime_Dt, DateTime.Now.Format()),
+                    new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.DurationSec_Int, dateDiff),
+                    new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.OrderState_Str, "已生产")
+                );
+            }
+            else
+            {
+                var dateDiff = (DateTime.Now - taskInfo.WorkStartTime).TotalSeconds.ToInt();  // 时间差/s
+                Env.SgIDAL.APP_TaiLing_TaskManagement.Update($"OrderId_Str='{orderId}' AND WorkShopId_Str='{workShopId}' AND ProductionLineId_Str='{productionLineId}'",
+                    new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.WorkEndTime_Dt, DateTime.Now.Format()),
+                    new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.DurationSec_Int, dateDiff),
+                    new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.OrderState_Str, "已生产")
+                );
+            }
+            
         }
 
         private void Schedual_DateTimeChanged(object sender, DateTimeChangedArgs e)

+ 1 - 0
SCADA_DAQ/SCADA_DAQ.csproj

@@ -221,6 +221,7 @@
       <HintPath>..\Lib\SCADA_DAQ.Plugin.RESTful.dll</HintPath>
       <Private>False</Private>
     </Reference>
+    <Reference Include="System.ComponentModel.DataAnnotations" />
     <Reference Include="System.Data.SQLite">
       <HintPath>..\Lib\System.Data.SQLite.dll</HintPath>
       <Private>False</Private>