From c9dd47185d603ccd09dd567f7eb5baeaf03b2746 Mon Sep 17 00:00:00 2001 From: 陈勇 <chenyong@hnkhzn.com> Date: 星期五, 23 二月 2024 11:11:51 +0800 Subject: [PATCH] 上传MES及MES下发工单接口 --- 代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/StationTask.cs | 169 +++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 105 insertions(+), 64 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/StationTask.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/StationTask.cs" index e9ff5f8..04209b7 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/StationTask.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/StationTask.cs" @@ -9,6 +9,7 @@ using WIDESEA_Core.FreeDB; using WIDESEA_Entity.DomainModels; using WIDESEA_Comm; +using static System.Collections.Specialized.BitVector32; namespace WIDESEA_WCS.JobsPart.Common { @@ -27,8 +28,9 @@ foreach (var item in stationinfos) { //鏍规嵁涓嬫枡鍙g殑缁戝畾淇℃伅鏌ヨ瀵瑰簲宸ュ崟锛屾娴嬫宸ュ崟鏄惁宸插畬鎴� 瀹屾垚鍗冲彲灏嗗叾閫佸叆搴� - dt_Workinfo workinfo = workinfoRepository.FindFirst(x => x.WorkNumber == item.Number); - int CompeletedNum = Convert.ToInt32(workinfo.PlannedQuantity) - Convert.ToInt32(workinfo.QuantityCompletion); + + dt_mes_head mesinfo = freeDB.Select<dt_mes_head>().Where(x => x.jobID == item.Number).First(); + int CompeletedNum = Convert.ToInt32(mesinfo.quantity) - Convert.ToInt32(mesinfo.finishNum); //鍒ゅ畾浠诲姟鏄惁宸插垱寤�//濡傚凡瀛樺湪 if (freeDB.Select<dt_agvtask>().Where(x => x.agv_fromaddress == item.stationCode).Count() > 0) @@ -36,11 +38,9 @@ if (item.quantity == 5 || CompeletedNum == 0) //寰幆璇诲彇杞﹁疆鏁颁负5鎴栬�呰鍗曞凡瀹屾垚鏁伴噺鐨勪笅鏂欏彛 鈫掑伐鍗曚汉宸ュ叧闂殑宸ュ崟 { - dt_stationinfo TargetLocation = GetEmptyLocation(stationinfoRepository, workinfo, item); - - if (TargetLocation != null) + if (mesinfo.quantity <= 50) //灏忎簬50浠剁洿鎺ュ嚭搴� { - //todo: 璋冪敤WMS鎺ュ彛鍒涘缓浠诲姟 + //todo 瀵绘壘鍙斁璐у鍗忔斁璐у彴 dt_agvtask agvtask = new dt_agvtask() { agv_fromaddress = item.stationCode, @@ -49,16 +49,35 @@ agv_barcode = "", agv_createtime = DateTime.Now, agv_taskstate = TaskStatus.Created.ToString(), - agv_toaddress = TargetLocation.stationCode, + //agv_toaddress = , }; - freeDB.Add(agvtask); - TargetLocation.location_state = LocationStateEnum.Busy.ToString(); - freeDB.Update(TargetLocation); + } + else + { + dt_stationinfo TargetLocation = GetEmptyLocation(stationinfoRepository, mesinfo, item); + + if (TargetLocation != null) + { + //todo: 璋冪敤WMS鎺ュ彛鍒涘缓浠诲姟 + dt_agvtask agvtask = new dt_agvtask() + { + agv_fromaddress = item.stationCode, + agv_id = Guid.NewGuid(), + agv_grade = 0, + agv_barcode = "", + agv_createtime = DateTime.Now, + agv_taskstate = TaskStatus.Created.ToString(), + agv_toaddress = TargetLocation.stationCode, + }; + + freeDB.Add(agvtask); + TargetLocation.location_state = LocationStateEnum.Busy.ToString(); + freeDB.Update(TargetLocation); + } } } - } } @@ -69,68 +88,67 @@ /// <param name="workinfo">璁㈠崟</param> /// <param name="stationinfo">涓嬫枡鍙d俊鎭�</param> /// <returns></returns> - private dt_stationinfo GetEmptyLocation(Idt_stationinfoRepository stationinfoRepository, dt_Workinfo workinfo, dt_stationinfo stationinfo) + private dt_stationinfo GetEmptyLocation(Idt_stationinfoRepository stationinfoRepository, dt_mes_head mesinfo, dt_stationinfo stationinfo) { //鏀捐揣浣� dt_stationinfo TargetLocation = null; - //鏍规嵁璁㈠崟鏁伴噺鏉ュ鎵惧搴斿簱鍖轰笖鍚岀墿鏂欑被鍨嬪簱浣� - if (workinfo.PlannedQuantity < 50) //搴撳尯1 鐗╂枡绫诲瀷澶� - { - dt_stationinfo station = stationinfoRepository.Find(x => x.stationType == stationinfo.stationType && x.area == "1").OrderByDescending(x => x.lastUpdateTime).FirstOrDefault(); - if (station != null) - { - //濡傚瓨鍦ㄥ悓鐗╂枡绫诲瀷涓斿湪1琛岀殑搴撳瓨鍒欐柊鍏ュ簱鐨勭墿鏂欐斁鑷冲悓鍒� 涓嶅瓨鍦ㄥ垯瀵绘壘鏂拌搴撲綅 - if (station.line == 1) - { - TargetLocation = stationinfoRepository.Find(x => x.area == station.area && x.location_state == LocationStateEnum.Empty.ToString() && x.column == station.column && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault(); - } - TargetLocation = stationinfoRepository.Find(x => x.area == station.area && x.location_state == LocationStateEnum.Empty.ToString() && x.line == 1 && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault(); - } - else - { - TargetLocation = stationinfoRepository.Find(x => x.area == "1" && x.location_state == LocationStateEnum.Empty.ToString() && x.line == 1 && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault(); - } - } - else - { - //int quantity = Convert.ToInt32(workinfo.PlannedQuantity); - //string area = GetArea(quantity); + #region 鏍规嵁璁㈠崟鏁伴噺鏉ュ鎵惧搴斿簱鍖轰笖鍚岀墿鏂欑被鍨嬪簱浣� + //if (workinfo.PlannedQuantity < 50) //搴撳尯1 鐗╂枡绫诲瀷澶� + //{ + // dt_stationinfo station = stationinfoRepository.Find(x => x.stationType == stationinfo.stationType && x.area == "1").OrderByDescending(x => x.lastUpdateTime).FirstOrDefault(); + // if (station != null) + // { + // //濡傚瓨鍦ㄥ悓鐗╂枡绫诲瀷涓斿湪1琛岀殑搴撳瓨鍒欐柊鍏ュ簱鐨勭墿鏂欐斁鑷冲悓鍒� 涓嶅瓨鍦ㄥ垯瀵绘壘鏂拌搴撲綅 + // if (station.line == 1) + // { + // TargetLocation = stationinfoRepository.Find(x => x.area == station.area && x.location_state == LocationStateEnum.Empty.ToString() && x.column == station.column && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault(); + // } + // TargetLocation = stationinfoRepository.Find(x => x.area == station.area && x.location_state == LocationStateEnum.Empty.ToString() && x.line == 1 && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault(); + // } + // else + // { + // TargetLocation = stationinfoRepository.Find(x => x.area == "1" && x.location_state == LocationStateEnum.Empty.ToString() && x.line == 1 && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault(); + // } + //} + //else + //{ + //int quantity = Convert.ToInt32(workinfo.PlannedQuantity); + //string area = GetArea(quantity); - dt_materielinfo materielinfo = freeDB.Select<dt_materielinfo>().Where(x => x.materiel_id == stationinfo.stationType).First(); + //dt_materielinfo materielinfo = freeDB.Select<dt_materielinfo>().Where(x => x.materiel_id == stationinfo.stationType).First(); - if (materielinfo == null) - throw new Exception($"鏃犳鐗╂枡绫诲瀷{stationinfo.stationType}搴撳尯"); + //if (materielinfo == null) + // throw new Exception($"鏃犳鐗╂枡绫诲瀷{stationinfo.stationType}搴撳尯"); - string area = materielinfo.materiel_areaid.ToString(); + //string area = materielinfo.materiel_areaid.ToString(); - //濡傚瓨鍦ㄥ悓绫诲瀷鐗╂枡鍒欐斁缃悓琛屽簱浣� 涓嶅瓨鍦ㄥ垯鏀剧疆鏂拌鐨勭涓�鍒椾腑 - dt_stationinfo station = stationinfoRepository.Find(x => x.stationType == stationinfo.stationType && x.area == area).OrderBy(x => x.lastUpdateTime).FirstOrDefault(); - if (station != null) - { - TargetLocation = stationinfoRepository.Find(x => x.area == station.area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.line == station.line).OrderBy(x => x.column).FirstOrDefault(); - if (TargetLocation == null) - { - TargetLocation = stationinfoRepository.Find(x => x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.column == '1').OrderBy(x => x.line).FirstOrDefault(); - } - } - else - { - TargetLocation = stationinfoRepository.Find(x => x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.column == '1').OrderBy(x => x.line).FirstOrDefault(); - } + //濡傚瓨鍦ㄥ悓绫诲瀷鐗╂枡鍒欐斁缃悓琛屽簱浣� 涓嶅瓨鍦ㄥ垯鏀剧疆鏂拌鐨勭涓�鍒椾腑 + //dt_stationinfo station = stationinfoRepository.Find(x => x.stationType == stationinfo.stationType && x.area == area).OrderBy(x => x.lastUpdateTime).FirstOrDefault(); + //if (station != null) + //{ + // TargetLocation = stationinfoRepository.Find(x => x.area == station.area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.line == station.line).OrderBy(x => x.column).FirstOrDefault(); + // if (TargetLocation == null) + // { + // TargetLocation = stationinfoRepository.Find(x => x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.column == '1').OrderBy(x => x.line).FirstOrDefault(); + // } + //} + //else + //{ + // TargetLocation = stationinfoRepository.Find(x => x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.column == '1').OrderBy(x => x.line).FirstOrDefault(); + //} - //todo 濡傜墿鏂欏凡婊″垯鏀剧疆鍏朵粬搴撳尯 - //if (TargetLocation == null) - //{ - // stationinfoRepository.Find(x => x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.column == '1').OrderBy(x => x.line).FirstOrDefault(); - //} - } - - if (TargetLocation == null) - { - throw new Exception("搴撲綅宸叉弧"); - } + //todo 濡傜墿鏂欏凡婊″垯鏀剧疆鍏朵粬搴撳尯 + //if (TargetLocation == null) + //{ + // stationinfoRepository.Find(x => x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.column == '1').OrderBy(x => x.line).FirstOrDefault(); + //} + //} + //if (TargetLocation == null) + //{ + // throw new Exception("搴撲綅宸叉弧"); + //} //else if (workinfo.PlannedQuantity >= 50 && workinfo.PlannedQuantity < 110) //搴撳尯2 //{ @@ -148,7 +166,30 @@ //else if(workinfo.PlannedQuantity >= 110 && workinfo.PlannedQuantity < 180) //{ - //} + //} + #endregion + + //鏍规嵁璁㈠崟鐐夊彿/宸ュ崟鍙�/绫诲瀷 + if (mesinfo.quantity >= 180) + { + //鏌ヨ搴撳瓨璁板綍涓槸鍚﹀瓨鍦ㄥ悓绫诲瀷/宸ュ崟/鐐夊彿鐨勮褰� 濡傛湁鍒欐斁缃悓涓�琛岋紝鏃犲垯瀵绘壘鏂板簱浣� + var detail = freeDB.Select<dt_mes_detail>().Where(x => x.jobID == mesinfo.jobID).First(); + var inventory = freeDB.Select<dt_inventory>().Where(x => x.HeatNumber == detail.heatID /*&& x.*/).First(); + if (inventory != null) + { + int line = Convert.ToInt16(inventory.stationCode.Split("-")[0]); + TargetLocation = stationinfoRepository.Find(x => x.line == line && x.location_state == LocationStateEnum.Empty.ToString() && x.area == inventory.area).FirstOrDefault(); + } + else + { + TargetLocation = stationinfoRepository.Find(x => x.area == "2" && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault(); + } + } + + if (TargetLocation == null) + { + throw new Exception("搴撲綅宸叉弧"); + } return TargetLocation; } -- Gitblit v1.9.3