分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-04-20 d2cef0150abe6d14cbfa60c8845795b91a1f5f97
添加入库触发条件,修改上料区任务逻辑
已修改9个文件
已添加2个文件
341 ■■■■■ 文件已修改
代码管理/PCS/WCS_Client/src/api/http.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_Comm/PLCDBItem/StackerReadDBItem.cs 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/PipelineJob.cs 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/VK4Job.cs 79 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/RestockHCJ.cs 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/StationTask.cs 23 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/新文件夹/GetLocation.cs 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/WCSClient/DBExtension.cs 47 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WebApi/appsettings.json 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
´úÂë¹ÜÀí/PCS/WCS_Client/src/api/http.js
@@ -12,7 +12,7 @@
let loadingInstance;
let loadingStatus = false;
if (process.env.NODE_ENV == 'development') {
    axios.defaults.baseURL = 'http://192.168.12.101:8099/';
    axios.defaults.baseURL = 'http://127.0.0.1:8099/';
}
else if (process.env.NODE_ENV == 'debug') {
    axios.defaults.baseURL = 'http://192.168.12.101:8099/';
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_Comm/PLCDBItem/StackerReadDBItem.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WIDESEA_Comm.PLCDBItem
{
    /// <summary>
    /// è¾Šé“信息
    /// </summary>
    public class StackerReadDBItem
    {
        public event Action<string, StackerReadDBItem> OnReadStackerSignal;
        /// <summary>
        /// è¾Šé“编号
        /// </summary>
        public string StackerNo { get; set; }
        /// <summary>
        /// è½¦è½®SN号
        /// </summary>
        public string R_wheel_SN { get; set; }
        /// <summary>
        /// è½¦è½®ç±»åž‹
        /// </summary>
        public Int16 R_wheel_type { get; set; }
        /// <summary>
        /// è½¦è½®é›¶ä»¶çŠ¶æ€
        /// </summary>
        public byte R_part_status { get; set; }
        /// <summary>
        /// è½¦è½®é›¶ä»¶å·¥è‰º
        /// </summary>
        public byte R_part_process { get; set; }
        /// <summary>
        /// è¾Šé“machine_nr
        /// </summary>
        public bool R_machine_nr { get; set; }
        /// <summary>
        /// è¯»å–辊道direction
        /// </summary>
        public byte R_direction { get; set; }
        public void ReadSignal(string signalType, StackerReadDBItem dBItem)
        {
            Task.Run(() =>
            {
                OnReadStackerSignal?.Invoke(signalType, dBItem);
            });
        }
    }
}
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs
@@ -695,15 +695,19 @@
                            if (Stationinfo != null)
                            {
                                #region æ¢ç±»åž‹ç›´æŽ¥å…¥åº“
                                var stationinfo1 = Stations.Where(x => x.enable && x.stationCode != NGStation && x.stationCode != Stationinfo.stationCode && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0 && x.stationType != Work.drawingNo).FirstOrDefault();
                                if (stationinfo1 != null)
                                    agvtask(stationinfoRepository, stationinfo1, Work, name == "3单元下料区" ? "TaskType_OutsourceInbound" : "TaskType_Inbound");
                                #endregion
                                #region æ‰˜ç›˜è½¦è½®å †åž›ç¬¬å››ä¸ªæ—¶ä¸‹å‘另外一个炉号的入库任务
                                if (Stationinfo.quantity + 1 >= 4)
                                {
                                    var stationinfo = Stations.Where(x => x.enable && x.stationCode != NGStation && x.stationCode != Stationinfo.stationCode && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).FirstOrDefault();
                                    //foreach (var stationinfo in stationinfos)
                                    //{
                                    if (stationinfo != null)
                                        agvtask(stationinfoRepository, stationinfo, Work, name == "3单元下料区" ? "TaskType_OutsourceInbound" : "TaskType_Inbound");
                                    //}
                                }
                                #endregion
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs
@@ -23,7 +23,6 @@
            try
            {
                ExecuteJob(context, DoAction);
            }
            catch { }
            return Task.CompletedTask;
@@ -31,15 +30,8 @@
        private void DoAction(IJobExecutionContext context)
        {
            //throw new NotImplementedException();
            //Creation.PLCinfodetail();
            //ReplaceTray.a();
            //EmptyTrayTask.InEmptyTrayTask(); //库内空托任务
            //EmptyTrayTask.task();
            StationTask.CreateTask();
            OutboundTask.CreateOutboundTask();//优化后出库逻辑
            //OutboundTask_a.CreateOutboundTask();
            ReplaceTray.ReplaceTrayTask();
            RestockHCJ.HCJGetBarcode();
            EmptyTrayTask.CreateEmptyTrayTask();
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/PipelineJob.cs
@@ -79,12 +79,6 @@
                ///查找上料区的货位
                var Stations = stationinfoRepository.Find(x => x.area == area_code(number)).OrderBy(x => x.lastUpdateTime);//根据时间先后排序
                //缓存架未启用禁止桁架进入
                //foreach (var station in Stations)
                //{
                //    if (!station.enable || station.location_state != LocationStateEnum.Stroge.ToString())
                //        Gantry_client.WriteByOrder("W_RequestUnload", false, number);//信号为false桁架停止进入
                //}
                var Station = Stations?.Where(x => x.enable && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).OrderBy(x => x.quantity).FirstOrDefault();
                if (Station != null)
@@ -107,7 +101,6 @@
                        WriteDBLog.Error("上料区", $"写入桁架信息:\nW_RequestUnload:false\n\n{Station.stationCode}车轮数量与SN号数量不一致", "PCS");
                        #endregion
                        return;
                        //throw new Exception("上料位车轮数量与SN号数量不一致,上料位编号:" + Station.stationCode);
                    }
                    var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == Station.stationCode).ToList();
                    var PalletSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PalletSignal").First(), client);//读取托盘信号:1:有,2无
@@ -150,7 +143,6 @@
                            Station.location_state = LocationStateEnum.Abnormal.ToString();
                            Station.remark = $"未查询到SN号:{SNS[SNS.Length - 1]}的订单";
                            stationinfoRepository.Update(Station, true);
                            //throw new Exception($"未查询到SN号:{SNS[SNS.Length - 1]}的订单,上料位编号:{Station.stationCode}");
                            WriteDBLog.Error("上料区信息查询", $"写入桁架信息:\nW_RequestUnload:false\n\n{Station.stationCode}未查询到SN号:{SNS[SNS.Length - 1]}的订单", "PCS");
                            return;
                        }
@@ -168,7 +160,6 @@
                        if (Station.quantity <= 0)
                        {
                            Station.stationType = string.Empty;
                            //Station.location_state = LocationStateEnum.Empty.ToString();
                            Station.Number = string.Empty;
                            Station.heatNumber = string.Empty;
                            Station.tray_status = "EmptyTray";
@@ -177,7 +168,6 @@
                        if (count < 1)
                        {
                            WriteDBLog.Error("取料完成", $"上料位信息更新失败!上料位编号:{Station.stationCode}", "PCS");
                            //throw new Exception($"上料位信息更新失败!上料位编号:{Station.stationCode}");
                            return;
                        }
@@ -186,7 +176,6 @@
                        Gantry_client.WriteByOrder("W_IndexNr", (Int16)0, number);//托盘上的第几个车轮
                        Gantry_client.WriteByOrder("W_Storage_Type", (Int16)0, number); //托盘类型1-横放;2-竖放
                        Gantry_client.WriteByOrder("W_Wheel_Type", (Int16)0, number);//车轮类型
                        //Gantry_client.WriteByOrder("W_Wheel_id", SNS[SNS.Length - 1], number);//车轮SN号
                        #endregion
                        Gantry_client.WriteByOrder("W_Storage_update", true, number);//货位状态更新
@@ -220,7 +209,6 @@
            catch (Exception ex)
            {
                WriteDBLog.Error("上料区", $"错误信息:{ex.Message}", "PCS");
                //WritePCSLog.LogAdd(requestin.AreaNr.ToString(), respone.success == 1 ? "成功 " : "失败", "WMS", "AGV", json, JsonConvert.SerializeObject(respone), remark, "检测线上料区", ex.Message);
            }
        }
        /// <summary>
@@ -240,13 +228,13 @@
                List<string> stationCodes = new List<string>() { "S01001001", "S01001002", "W01001001", "W01001002", "W01001003" };
                foreach (var stationCode in stationCodes)
                {
                    if (agvtaskService.Find(x => x.agv_fromaddress == stationCode || x.agv_toaddress == stationCode).Any())
                    if (agvtaskService.Find(x => x.agv_fromaddress == stationCode /*|| x.agv_toaddress == stationCode*/).Any())
                        continue;
                    var station = stationinfoRepository.Find(x => x.stationCode == stationCode && x.enable).FirstOrDefault();
                    if (station == null) continue;
                    var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == stationCode).ToList();
                    var PalletSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PalletSignal").First(), client);//读取托盘信号:1:有,2无
                    var MaterialSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_MaterialSignal").First(), client);//读取货物信号:1:有,2无
                    var station = stationinfoRepository.Find(x => x.stationCode == stationCode && x.enable).FirstOrDefault();
                    if (station == null) continue;
                    if (PalletSignal == 1 && MaterialSignal == 2 && (station.stationCode.Contains("S0100100") ? station.tray_status == "EmptyTray" : true))
                    {
                        var area = station.tray_type == "SmallTray" ? "11" : "10";
@@ -275,32 +263,6 @@
                        if (EmptyStation == null)//查找库内空托盘
                            EmptyStation = GetStation.EmptyPalletStation(area);
                        #region æŸ¥æ‰¾åº“区一空托盘空货位
                        // EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity < 5 && x.stationCode.Contains("A") && x.location_state != LocationStateEnum.Busy.ToString() && x.enable)
                        //.OrderBy(x => x.column).ThenByDescending(x => x.line).FirstOrDefault();//查找没有任务的空托盘货位
                        // if (EmptyStation != null)
                        // {
                        //     if (stationinfoRepository.Find(x => x.area == EmptyStation.area && x.stationCode.Contains("A") && x.column == EmptyStation.column && x.location_state.Contains("Busy")).Any())
                        //     {
                        //         EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity < 5 && x.stationCode.Contains("A") && x.column != EmptyStation.column && x.location_state != LocationStateEnum.Busy.ToString() && x.enable).OrderBy(x => x.column).ThenByDescending(x => x.line).FirstOrDefault();//排除当列存在任务的货位
                        //     }
                        //     if (EmptyStation != null && EmptyStation.line == 2)//如果任务存在第二行,排查第一行是否有货
                        //     {
                        //         if (stationinfoRepository.Find(x => x.area == EmptyStation.area && x.stationCode.Contains("A") && x.column == EmptyStation.column && x.line == 1 && x.location_state != LocationStateEnum.Empty.ToString()).Any()) EmptyStation = null;
                        //     }
                        // }
                        // if (EmptyStation == null)
                        // {
                        //     EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity < 5 && x.stationCode.Contains(area == "10" ? "D" : "C") && x.location_state == LocationStateEnum.Busy.ToString() && x.enable).OrderByDescending(x => x.column).FirstOrDefault();//最后一个货位有任务则不能生成入库任务
                        //     if (EmptyStation != null) continue;
                        //     EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity < 5 && x.stationCode.Contains(area == "10" ? "D" : "C") && x.location_state == LocationStateEnum.Stroge.ToString() && x.enable).OrderByDescending(x => x.column).FirstOrDefault();//找最外面没堆满5个的货位
                        //     if (EmptyStation == null)
                        //         EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity < 5 && x.stationCode.Contains(area == "10" ? "D" : "C") && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.column).FirstOrDefault();
                        // }
                        #endregion
                        if (EmptyStation != null)
                        {
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/VK4Job.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,79 @@
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Comm.PLCDBItem;
using WIDESEA_Core.Extensions;
using WIDESEA_WCS.Jobs;
using WIDESEA_WCS.WCSClient;
using static Dapper.SqlMapper;
namespace WIDESEA_WCS
{
    [DisallowConcurrentExecution]
    public class VK4Job : JobBase, IJob
    {
        public Task Execute(IJobExecutionContext context)
        {
            try
            {
                ExecuteJob(context, DoAction);
            }
            catch (Exception ex)
            {
            }
            return Task.CompletedTask;
        }
        public static StackerReadDBItem StackerDBItem;
        private void DoAction(IJobExecutionContext context)
        {
            var client = context.JobDetail.JobDataMap.Get("JobParams") as PLCClient;
            //自动重连
            if (!client.IsConnected)
            {
                client.Connect();
                return;
            }
            PropertyInfo[] propertyInfos = typeof(StackerReadDBItem).GetProperties();
            if (StackerDBItem == null)
            {
                StackerDBItem = new();
                //StackerDBItem.OnReadStackerSignal += HandleReadStackerSignal;
            }
            List<StackerReadDBItem> StackerReadDBItems = new List<StackerReadDBItem>();
            var groups = client.itemGroups.OrderBy(x => x.Methods).ThenBy(x=>x.name).GroupBy(x => x.Methods);
            foreach (var key in groups)
            {
                //foreach (var item in key)
                //{
                    for (int i = 0; i < propertyInfos.Length; i++)
                    {
                        if (i == 0)
                        {
                            StackerDBItem.StackerNo = key.First(x=>true).Methods;
                        }
                        else
                        {
                            DBItemGroup group = key.FirstOrDefault(x => x.name == propertyInfos[i].Name);
                            if (group != null)
                            {
                                object readData = DBExtension.Read(group, client);
                                object obj = propertyInfos[i].GetValue(StackerDBItem);
                                if (obj != readData)
                                    propertyInfos[i].SetValue(StackerDBItem, readData);
                            }
                        }
                    }
                    StackerReadDBItems.Add(StackerDBItem);
                //}
            }
        }
    }
}
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/RestockHCJ.cs
@@ -17,6 +17,7 @@
using WIDESEA_WMS.IServices;
using WIDESEA_WMS.Repositories;
using static FreeSql.Internal.GlobalFilter;
using static System.Collections.Specialized.BitVector32;
namespace WIDESEA_WCS.JobsPart.Common
{
@@ -38,7 +39,7 @@
                {
                    if (task.agv_tasktype == "TaskType_EmptyPallet")//空托任务
                    {
                        if (task.agv_fromaddress == "" && DateTime.Now - task.agv_createtime >= TimeSpan.FromMinutes(1))
                        if (task.agv_fromaddress == "" && DateTime.Now - task.agv_createtime >= TimeSpan.FromMinutes(10))
                        {
                            if (task.agv_tasknum.Contains("_"))
                            {
@@ -127,7 +128,7 @@
                    {
                        if (task.agv_toaddress == "")
                        {
                            var EmptyStations = stationinfoRepository.Find(x => x.stationCode.Contains("S01001") && x.location_state == "Empty" && x.enable).ToList();
                            var EmptyStations = stationinfoRepository.Find(x => x.stationCode.Contains("S01001") && x.tray_status == "EmptyTray" /*x.location_state == "Empty"*/ && x.enable).ToList();
                            foreach (var EmptyStation in EmptyStations)
                            {
                                if (agvtaskService.Find(x => x.agv_toaddress == EmptyStation.stationCode).Any()) continue;
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/StationTask.cs
@@ -54,7 +54,7 @@
                    //根据下料口的绑定信息查询对应工单,检测此工单是否已完成  å®Œæˆå³å¯å°†å…¶é€å…¥åº“
                    var work = workinfoRepository.Find(x => x.workOrder == item.Number && x.drawingNo == x.drawingNo && x.heatID == item.heatNumber).FirstOrDefault();
                    var work = workinfoRepository.Find(x => x.workOrder == item.Number && x.drawingNo == x.drawingNo && x.heatID == item.heatNumber && x.processCode == "17").FirstOrDefault();
                    if (work == null)
                    {
                        item.remark = "触发入库任务,但未找到工单信息!";
@@ -63,29 +63,13 @@
                        continue;
                    }
                    //dt_mes_head mesinfo = mes_HeadRepository.Find(x => x.workOrder == item.Number).FirstOrDefault();
                    //if (mesinfo == null)
                    //{
                    //    item.remark = "触发入库任务,但未找到工单头表!";
                    //    item.location_state = LocationStateEnum.Abnormal.ToString();
                    //    stationinfoRepository.Update(item, true);
                    //    continue;
                    //    //throw new Exception("未找到工单头表!工单号:" + item.Number);
                    //}
                    //var dt_Geometry_Data = PipelineJob.QueryMateriel(mesinfo.drawingNo);
                    //var dt_Geometry_Data1 = PipelineJob.QueryMateriel1(mesinfo.drawingNo);
                    //int CompeletedNum = Convert.ToInt32(mesinfo.quantity) - Convert.ToInt32(mesinfo.finishNum);
                    dt_stationinfo TargetLocation = null;
                    string tasktype = "";
                    if (item.quantity == 5 /*|| CompeletedNum == 0*/)  //循环读取车轮数为5或者订单已完成数量的下料口    â†’工单人工关闭的工单
                    if (item.quantity == 5 /*|| CompeletedNum == 0*/)
                    {
                        if (/*(mesinfo.quantity <= 50 &&*/ !string.IsNullOrEmpty(work.area) || item.stationCode.Contains("3"))    //小于50件直接出库
                        if (/*(mesinfo.quantity <= 50 &&*/ !string.IsNullOrEmpty(work.area) || item.stationCode.Contains("3"))
                        {
                            //todo å¯»æ‰¾å¯æ”¾è´§å¤–协放货台
                            tasktype = "TaskType_OutsourceInbound";
@@ -97,7 +81,6 @@
                            //todo:  è°ƒç”¨WMS接口创建任务
                            tasktype = "TaskType_Inbound";
                            TargetLocation = GetLocation.GetEmptyLocation(stationinfoRepository, work, item);
                            //TargetLocation = GetEmptyLocation(stationinfoRepository, mesinfo, item, CompeletedNum, dt_Geometry_Data == null ? dt_Geometry_Data1.e : dt_Geometry_Data.e);
                        }
                        if (TargetLocation != null)
                        {
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/ÐÂÎļþ¼Ð/GetLocation.cs
@@ -31,35 +31,14 @@
                try
                {
                    VOLContext context = new VOLContext();
                    //Idt_mes_detailRepository mes_DetailRepository = new dt_mes_detailRepository(context);
                    Idt_inventoryRepository inventoryRepository = new dt_inventoryRepository(context);
                    //var detail = mes_DetailRepository.Find(x => x.jobID == mesinfo.jobID).FirstOrDefault();
                    //if (detail == null)
                    //{
                    //    stationinfo.remark = "触发入库任务,但未找到工单子表!";
                    //    stationinfo.location_state = LocationStateEnum.Abnormal.ToString();
                    //    stationinfoRepository.Update(stationinfo, true);
                    //    return null;
                    //}
                    string area1 = "";
                    if (stationinfo.tray_type == "LargeTray")
                        area1 = "4";
                    #region æŸ¥æ‰¾åº“å­˜
                    dt_inventory inventory = null;
                    inventory = inventoryRepository.Find(x => x.FigureNumber == mesinfo.drawingNo).OrderByDescending(x => x.OnlineTime).FirstOrDefault();
                    #region æ ¹æ®æ¡ä»¶æŸ¥è¯¢åº“å­˜
                    //if (mesinfo.heatID != null)
                    //{
                    //    inventory = inventoryRepository.Find(x => x.HeatNumber == mesinfo.heatID && x.FigureNumber == mesinfo.drawingNo && x.jobID == mesinfo.workOrder).OrderByDescending(x => x.OnlineTime).FirstOrDefault();
                    //}
                    //else
                    //{
                    //    inventory = inventoryRepository.Find(x => x.FigureNumber == mesinfo.drawingNo && x.jobID == mesinfo.workOrder).OrderByDescending(x => x.OnlineTime).FirstOrDefault();
                    //}
                    #endregion
                    inventory = inventoryRepository.Find(x => x.FigureNumber == stationinfo.stationType).OrderByDescending(x => x.OnlineTime).FirstOrDefault();
                    #endregion
                    dt_stationinfo TargetLocation = null;
@@ -74,27 +53,12 @@
                            TargetLocation = stationinfoRepository.Find(x => x.stationType == stationinfo.stationType && x.location_state == LocationStateEnum.InBusy.ToString() && x.area == area1).FirstOrDefault();
                            if (TargetLocation != null)
                            {
                                //if (TargetLocation.area == "1")
                                //{
                                //    //TargetLocation = stationinfoRepository.Find(x => x.column == TargetLocation.column && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderByDescending(x => x.line).FirstOrDefault();
                                //    TargetLocation = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderBy(x => x.column).FirstOrDefault();//按行存放
                                //    if (TargetLocation != null)
                                //    {
                                //        if (!stationinfoRepository.Find(x => x.column == TargetLocation.column && x.area == TargetLocation.area /*&& x.enable*/ && x.location_state == LocationStateEnum.OutBusy.ToString()).Any())
                                //            return TargetLocation;
                                //    }
                                //}
                                //else
                                //{
                                    TargetLocation = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderBy(x => x.column).FirstOrDefault();
                                    if (TargetLocation != null)
                                    {
                                        if (!stationinfoRepository.Find(x => x.line == TargetLocation.line && x.area == TargetLocation.area && x.location_state == LocationStateEnum.OutBusy.ToString()).Any())
                                            return TargetLocation;
                                    }
                                //}
                            }
                            #endregion
@@ -102,27 +66,14 @@
                            var TargetLocations1 = stationinfoRepository.Find(x => x.location_state == LocationStateEnum.Empty.ToString() && x.enable &&  x.area == area1).OrderBy(x => x.line).ThenBy(x => x.column).ToList();
                            foreach (var Location in TargetLocations1)
                            {
                                //if (Location.area == "1")
                                //{
                                //    if (stationinfoRepository.Find(x => x.column == Location.column && x.area == Location.area && x.stationType == stationinfo.stationType && x.location_state != LocationStateEnum.OutBusy.ToString()).Any()) return Location;
                                //}
                                //else
                                //{
                                    if (stationinfoRepository.Find(x => x.line == Location.line && x.area == Location.area && x.stationType == stationinfo.stationType && x.location_state != LocationStateEnum.OutBusy.ToString()).Any()) return Location;
                                //}
                            }
                            //if (TargetLocation != null)
                            //{
                            //    if (stationinfoRepository.Find(x => x.line == TargetLocation.line && x.column == 1 && x.stationType == stationinfo.stationType).Any()) return TargetLocation;
                            //}
                            #endregion
                        }
                        if (station.area == "1")
                        {
                            //TargetLocation = stationinfoRepository.Find(x => x.column == station.column && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == inventory.area).OrderByDescending(x => x.line).FirstOrDefault();
                            TargetLocation = stationinfoRepository.Find(x => x.line == station.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == station.area).OrderBy(x => x.column).FirstOrDefault();//按行存放
                            if (TargetLocation != null)
@@ -140,7 +91,6 @@
                                    return TargetLocation;
                            }
                        }
                        //if (TargetLocation != null) return TargetLocation;
                    }
                    #endregion
@@ -150,8 +100,6 @@
                    {
                        if (TargetLocation.area == "1")
                        {
                            //TargetLocation = stationinfoRepository.Find(x => x.column == TargetLocation.column && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderByDescending(x => x.line).FirstOrDefault();
                            TargetLocation = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderBy(x => x.column).FirstOrDefault();//按行存放
                            if (TargetLocation != null)
@@ -185,15 +133,9 @@
                            if (stationinfoRepository.Find(x => x.line == Location.line && x.area == Location.area && x.stationType == stationinfo.stationType && x.location_state != LocationStateEnum.OutBusy.ToString()).Any()) return Location;
                        }
                    }
                    //if (TargetLocation != null)
                    //{
                    //    if (stationinfoRepository.Find(x => x.line == TargetLocation.line && x.column == 1 && x.stationType == stationinfo.stationType).Any()) return TargetLocation;
                    //}
                    #endregion
                    #region æœªæ‰¾åˆ°åº“存或当前库存行已满,寻找新的一行
                    //var area1 = string.IsNullOrEmpty(mesinfo.area) ? GetArea(mesinfo.quantity, e) : mesinfo.area;(area == "2" ? 1 : 10)
                    //var area = string.IsNullOrEmpty(mesinfo.area) ? GetArea(mesinfo.quantity, stationinfo.tray_type) : mesinfo.area;
                    var area = GetArea(mesinfo.quantity, stationinfo.tray_type);
                    TargetLocation = stationinfoRepository.Find(x => x.column == 1 && x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault();
                    if (TargetLocation == null && area != "4")
@@ -297,12 +239,10 @@
                                    return TargetLocation;
                            }
                        }
                        //if (TargetLocation != null) return TargetLocation;
                    }
                    #endregion
                    #region æœªæ‰¾åˆ°åº“存或当前库存行已满,寻找新的一行
                    //var area1 = string.IsNullOrEmpty(mesinfo.area) ? GetArea(mesinfo.quantity, e) : mesinfo.area;
                    var area = string.IsNullOrEmpty(mesinfo.area) ? GetArea(mesinfo.quantity, stationinfo.tray_type) : mesinfo.area;
                    TargetLocation = stationinfoRepository.Find(x => x.column == (area == "2" ? 1 : 10) && x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault();
                    if (TargetLocation == null)
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/WCSClient/DBExtension.cs
@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Entity.DomainModels;
@@ -65,15 +66,51 @@
        /// <param name="client"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static object Write(dt_plcinfodetail detail, PLCClient client, object value)
        public static object Read(DBItemGroup itemGroup, PLCClient client)
        {
            try
            //PLCClient client = PLCClient.Clients.Where(x => x.PLCName == itemGroup.name).FirstOrDefault();
            if (client == null)
            {
                return (client.Write(detail.plcdetail_db + "." + detail.plcdetail_value, value));
                throw new Exception($"未找到{itemGroup.name}连接对象");
            }
            catch (Exception ex)
            else
            {
                throw;
                if (itemGroup.dataType == typeof(int).Name.ToLower())//4字节,有符号类型
                {
                    return (client.Read<int>(itemGroup.dbAddress));
                }
                else if (itemGroup.dataType == typeof(uint).Name.ToLower())//4字节,无符号类型
                {
                    return (client.Read<uint>(itemGroup.dbAddress));
                }
                else if (itemGroup.dataType == typeof(short).Name.ToLower())//2字节,有符号类型,最常用
                {
                    return (client.Read<short>(itemGroup.dbAddress));
                }
                else if (itemGroup.dataType == typeof(ushort).Name.ToLower())//2字节,无符号类型
                {
                    return (client.Read<ushort>(itemGroup.dbAddress));
                }
                else if (itemGroup.dataType == typeof(float).Name.ToLower())//浮点型
                {
                    return (client.Read<float>(itemGroup.dbAddress));
                }
                else if (itemGroup.dataType == typeof(bool).Name.ToLower())
                {
                    return (client.Read<bool>(itemGroup.dbAddress));
                }
                else if (itemGroup.dataType == typeof(byte).Name.ToLower())//字节
                {
                    return (client.Read<byte>(itemGroup.dbAddress));
                }
                else if (itemGroup.dataType == typeof(string).Name.ToLower())//字符串
                {
                    return (client.Read<string>(itemGroup.dbAddress, itemGroup.dataLen.GetValueOrDefault()));
                }
                else
                {
                    throw new Exception($"【{itemGroup.name}】,DB地址{itemGroup.dbAddress},未定义数据类型{itemGroup.dataType}");
                }
            }
        }
    }
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WebApi/appsettings.json
@@ -16,7 +16,7 @@
  "Connection": {
    "DBType": "MsSql", //MySql/MsSql/PgSql  //数据库类型,如果使用的是sqlserver此处应设置为MsSql
    //sqlserver连接字符串P@ssw0rd
    "DbConnectionString": "Data Source=192.168.12.101;Initial Catalog=WIDESEA_DB;Persist Security Info=True;User ID=sa;Password=123456;Connect Timeout=500;",
    "DbConnectionString": "Data Source=.;Initial Catalog=WIDESEA_DB;Persist Security Info=True;User ID=sa;Password=P@ssw0rd;Connect Timeout=500;",
    //mysql连接字符串(升级EFCore3.1到时已将mysql连接字符串修改,2019-12-20)
    // "DbConnectionString": " Data Source=127.0.0.1;Database=netcoredev;AllowLoadLocalInfile=true;User ID=root;Password=123456;allowPublicKeyRetrieval=true;pooling=true;CharSet=utf8;port=3306;sslmode=none;",